mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
[uLib Geometry]
non working version! + adds ProgrammableAccessor + renaming of some Image structures ...
This commit is contained in:
39
src/Root/CMakeLists.txt
Normal file
39
src/Root/CMakeLists.txt
Normal file
@@ -0,0 +1,39 @@
|
||||
set(HEADERS
|
||||
TestTObject.h
|
||||
RootMathDense.h
|
||||
RootMuonScatter.h
|
||||
RootHitRaw.h
|
||||
)
|
||||
|
||||
set(DICTIONARY_HEADERS
|
||||
TestTObject.h
|
||||
RootMathDense.h
|
||||
RootMuonScatter.h
|
||||
RootHitRaw.h
|
||||
)
|
||||
|
||||
SET(SOURCES
|
||||
TestTObject.cpp
|
||||
RootMuonScatter.cpp
|
||||
)
|
||||
|
||||
|
||||
|
||||
set(LIBRARIES
|
||||
# ${Boost_SERIALIZATION_LIBRARY}
|
||||
# ${Boost_SIGNALS_LIBRARY}
|
||||
# ${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
${ROOT_LIBRARIES}
|
||||
${PACKAGE_LIBPREFIX}Core
|
||||
${PACKAGE_LIBPREFIX}Math
|
||||
)
|
||||
|
||||
include(FindROOTv6)
|
||||
root_generate_dictionary(uLibRootDict ${DICTIONARY_HEADERS} LINKDEF Linkdef.h)
|
||||
set_source_files_properties(uLibRootDict.cxx PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(uLibRootDict.h PROPERTIES GENERATED TRUE)
|
||||
list(APPEND SOURCES uLibRootDict.cxx)
|
||||
|
||||
|
||||
uLib_add_shared_library(${uLib-module})
|
||||
add_subdirectory(testing)
|
||||
79
src/Root/Linkdef.h
Normal file
79
src/Root/Linkdef.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#ifndef U_ROOT_LINKDEF_H
|
||||
#define U_ROOT_LINKDEF_H
|
||||
|
||||
#ifdef __CINT__
|
||||
|
||||
#pragma link off all globals;
|
||||
#pragma link off all classes;
|
||||
#pragma link off all functions;
|
||||
#pragma link C++ nestedclasses;
|
||||
|
||||
#pragma link C++ class TestTObject+;
|
||||
|
||||
using namespace ROOT::Mutom;
|
||||
|
||||
#pragma link C++ class ROOT::Math::Cartesian2D<int>+;
|
||||
#pragma link C++ class ROOT::Math::Cartesian2D<float>+;
|
||||
#pragma link C++ class ROOT::Math::Cartesian2D<double>+;
|
||||
|
||||
#pragma link C++ class ROOT::Math::Cartesian3D<int>+;
|
||||
#pragma link C++ class ROOT::Math::Cartesian3D<float>+;
|
||||
#pragma link C++ class ROOT::Math::Cartesian3D<double>+;
|
||||
|
||||
#pragma link C++ class Vector2i+;
|
||||
#pragma link C++ class Vector2f+;
|
||||
#pragma link C++ class Vector2d+;
|
||||
|
||||
#pragma link C++ class Vector3i+;
|
||||
#pragma link C++ class Vector3f+;
|
||||
#pragma link C++ class Vector3d+;
|
||||
|
||||
#pragma link C++ typedef Matrix3i;
|
||||
#pragma link C++ typedef Matrix3f;
|
||||
#pragma link C++ typedef Matrix3d;
|
||||
|
||||
#pragma link C++ class Line3f+;
|
||||
#pragma link C++ class Line3d+;
|
||||
|
||||
#pragma link C++ class MuonScatter+;
|
||||
#pragma link C++ function MuonScatter::p_mean() const;
|
||||
|
||||
// #pragma link C++ class DetectorChamber+;
|
||||
|
||||
#pragma link C++ class HitRaw+;
|
||||
#pragma link C++ function HitRaw::Chm() const;
|
||||
#pragma link C++ function HitRaw::Rob() const;
|
||||
#pragma link C++ function HitRaw::Tdc() const;
|
||||
#pragma link C++ function HitRaw::Ch() const;
|
||||
|
||||
|
||||
#endif // __CINT__
|
||||
|
||||
#endif // LINKDEF_H
|
||||
20
src/Root/Makefile.am
Normal file
20
src/Root/Makefile.am
Normal file
@@ -0,0 +1,20 @@
|
||||
SUBDIRS = .
|
||||
|
||||
ROOTCINT = `which rootcint`
|
||||
|
||||
include $(top_srcdir)/Common.am
|
||||
|
||||
library_includedir = $(includedir)/libmutom-${PACKAGE_VERSION}/Root
|
||||
|
||||
library_include_HEADERS = TestTObject.h
|
||||
|
||||
|
||||
_CORE_SOURCES = TestTObject.cpp
|
||||
|
||||
|
||||
MutomDict.cxx: $(library_include_HEADERS) Linkdef.h
|
||||
$(ROOTCINT) -f $@ -c $(AM_CXXFLAGS) -p $^
|
||||
|
||||
|
||||
noinst_LTLIBRARIES = libmutomroot.la
|
||||
libmutomroot_la_SOURCES = MutomDict.cxx ${_CORE_SOURCES}
|
||||
50
src/Root/RootHitMC.h
Normal file
50
src/Root/RootHitMC.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
#ifndef ROOTHITMC_H
|
||||
#define ROOTHITMC_H
|
||||
|
||||
#include <TMCParticleType.h>
|
||||
#include <Root/RootMathDense.h>
|
||||
|
||||
namespace ROOT {
|
||||
namespace Mutom {
|
||||
|
||||
class HitMC {
|
||||
public:
|
||||
int chm; // chamber id
|
||||
Vector3f pos; // hit position in local coords
|
||||
float_t drift; // drift time
|
||||
enum TMCParticleType ptype;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // Mutom
|
||||
} // ROOT
|
||||
|
||||
|
||||
#endif // ROOTHITMC_H
|
||||
71
src/Root/RootHitRaw.h
Normal file
71
src/Root/RootHitRaw.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
#ifndef ROOTHITRAW_H
|
||||
#define ROOTHITRAW_H
|
||||
|
||||
#include <Rtypes.h>
|
||||
|
||||
namespace ROOT {
|
||||
namespace Mutom {
|
||||
|
||||
|
||||
|
||||
class Hit32 {
|
||||
public:
|
||||
Int_t code;
|
||||
Float_t drift;
|
||||
};
|
||||
|
||||
class Hit64 {
|
||||
public:
|
||||
Long_t code;
|
||||
Double_t drift;
|
||||
};
|
||||
|
||||
|
||||
|
||||
class HitRaw
|
||||
{
|
||||
public:
|
||||
virtual Int_t Flags() {}
|
||||
virtual Int_t Chm() const {}
|
||||
virtual Int_t Rob() const {}
|
||||
virtual Int_t Tdc() const {}
|
||||
virtual Int_t Ch() const {}
|
||||
virtual void SetFlags (Int_t flags) = 0;
|
||||
virtual void SetChamber(Int_t cmb) = 0;
|
||||
virtual void SetChannel(Int_t Rob, Int_t Tdc, Int_t Ch) = 0;
|
||||
virtual float operator() ( ) {}
|
||||
protected:
|
||||
virtual ~HitRaw() {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // Mutom
|
||||
} // ROOT
|
||||
|
||||
#endif // ROOTHITRAW_H
|
||||
68
src/Root/RootMathDense.h
Normal file
68
src/Root/RootMathDense.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#ifndef ROOTMATHDENSE_H
|
||||
#define ROOTMATHDENSE_H
|
||||
|
||||
|
||||
#include <Math/Vector3D.h>
|
||||
#include <Math/Vector2D.h>
|
||||
|
||||
#include <Math/MatrixRepresentationsStatic.h>
|
||||
|
||||
namespace ROOT {
|
||||
namespace Mutom {
|
||||
|
||||
typedef ROOT::Math::Cartesian2D<int> Vector2i;
|
||||
typedef ROOT::Math::Cartesian2D<float> Vector2f;
|
||||
typedef ROOT::Math::Cartesian2D<double> Vector2d;
|
||||
|
||||
typedef ROOT::Math::Cartesian3D<int> Vector3i;
|
||||
typedef ROOT::Math::Cartesian3D<float> Vector3f;
|
||||
typedef ROOT::Math::Cartesian3D<double> Vector3d;
|
||||
|
||||
typedef ROOT::Math::MatRepStd<int ,3> Matrix3i;
|
||||
typedef ROOT::Math::MatRepStd<float ,3> Matrix3f;
|
||||
typedef ROOT::Math::MatRepStd<double,3> Matrix3d;
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct Line3D
|
||||
{
|
||||
ROOT::Math::Cartesian3D<T> origin,direction;
|
||||
};
|
||||
|
||||
|
||||
typedef Line3D<float> Line3f;
|
||||
typedef Line3D<double> Line3d;
|
||||
|
||||
|
||||
|
||||
} // Mutom
|
||||
} // ROOT
|
||||
|
||||
#endif // ROOTMATHDENSE_H
|
||||
75
src/Root/RootMuonScatter.cpp
Normal file
75
src/Root/RootMuonScatter.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#include "RootMuonScatter.h"
|
||||
#include "Detectors/MuonScatter.h"
|
||||
|
||||
|
||||
namespace ROOT {
|
||||
namespace Mutom {
|
||||
|
||||
MuonScatter &operator <<(MuonScatter &rmu, const uLib::MuonScatter &mu)
|
||||
{
|
||||
|
||||
rmu.in.origin.SetX(mu.LineIn().origin()(0));
|
||||
rmu.in.origin.SetY(mu.LineIn().origin()(1));
|
||||
rmu.in.origin.SetZ(mu.LineIn().origin()(2));
|
||||
rmu.in.direction.SetX(mu.LineIn().direction()(0));
|
||||
rmu.in.direction.SetY(mu.LineIn().direction()(1));
|
||||
rmu.in.direction.SetZ(mu.LineIn().direction()(2));
|
||||
|
||||
rmu.out.origin.SetX(mu.LineOut().origin()(0));
|
||||
rmu.out.origin.SetY(mu.LineOut().origin()(1));
|
||||
rmu.out.origin.SetZ(mu.LineOut().origin()(2));
|
||||
rmu.out.direction.SetX(mu.LineOut().direction()(0));
|
||||
rmu.out.direction.SetY(mu.LineOut().direction()(1));
|
||||
rmu.out.direction.SetZ(mu.LineOut().direction()(2));
|
||||
|
||||
rmu.in.p = mu.GetMomentum();
|
||||
rmu.out.p = mu.GetMomentumPrime();
|
||||
|
||||
return rmu;
|
||||
}
|
||||
|
||||
uLib::MuonScatter &operator >>(const MuonScatter &rmu, uLib::MuonScatter &mu) {
|
||||
|
||||
mu.LineIn().origin() << rmu.in.origin.x(), rmu.in.origin.z(), rmu.in.origin.z();
|
||||
mu.LineIn().direction() << rmu.in.direction.x(), rmu.in.direction.z(), rmu.in.direction.z();
|
||||
mu.LineOut().origin() << rmu.out.origin.x(), rmu.out.origin.z(), rmu.out.origin.z();
|
||||
mu.LineOut().direction() << rmu.out.direction.x(), rmu.out.direction.z(), rmu.out.direction.z();
|
||||
|
||||
mu.SetMomentum(rmu.in.p);
|
||||
mu.SetMomentumPrime(rmu.out.p);
|
||||
|
||||
return mu;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
66
src/Root/RootMuonScatter.h
Normal file
66
src/Root/RootMuonScatter.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#ifndef ROOTMUONSCATTER_H
|
||||
#define ROOTMUONSCATTER_H
|
||||
|
||||
#include <Root/RootMathDense.h>
|
||||
|
||||
namespace uLib {
|
||||
class MuonScatter;
|
||||
}
|
||||
|
||||
|
||||
namespace ROOT {
|
||||
namespace Mutom {
|
||||
|
||||
struct MuonTrack {
|
||||
Vector3f origin;
|
||||
Vector3f direction;
|
||||
float p;
|
||||
};
|
||||
|
||||
struct MuonScatter {
|
||||
public:
|
||||
MuonTrack in,out;
|
||||
MuonTrack in_err, out_err;
|
||||
inline Vector2f p_mean() const;
|
||||
};
|
||||
|
||||
// this is only for testing function link in dictionary ... //
|
||||
Vector2f MuonScatter::p_mean() const {
|
||||
return Vector2f( (in.p + out.p)/2, (in_err.p + out_err.p)/2 );
|
||||
}
|
||||
|
||||
MuonScatter &operator <<(MuonScatter &rmu, const uLib::MuonScatter &mu);
|
||||
uLib::MuonScatter &operator >>(const MuonScatter &rmu, uLib::MuonScatter &mu);
|
||||
|
||||
|
||||
} // Mutom
|
||||
} // ROOT
|
||||
|
||||
#endif // ROOTMUONSCATTER_H
|
||||
31
src/Root/TestTObject.cpp
Normal file
31
src/Root/TestTObject.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#include "TestTObject.h"
|
||||
|
||||
|
||||
ClassImp(TestTObject)
|
||||
47
src/Root/TestTObject.h
Normal file
47
src/Root/TestTObject.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
#ifndef U_ROOT_TESTTOBJECT_H
|
||||
#define U_ROOT_TESTTOBJECT_H
|
||||
|
||||
#include <math.h>
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TFolder.h>
|
||||
|
||||
class TestTObject : public TObject {
|
||||
public:
|
||||
int a,b,c;
|
||||
TestTObject() : a(1),b(2),c(3) {}
|
||||
virtual ~TestTObject() {}
|
||||
ClassDef(TestTObject,1)
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // TESTTOBJECT_H
|
||||
15
src/Root/testing/CMakeLists.txt
Normal file
15
src/Root/testing/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
# TESTS
|
||||
set( TESTS
|
||||
RootDebugTest
|
||||
)
|
||||
|
||||
set(LIBRARIES
|
||||
${PACKAGE_LIBPREFIX}Core
|
||||
${PACKAGE_LIBPREFIX}Math
|
||||
${PACKAGE_LIBPREFIX}Root
|
||||
${Boost_SERIALIZATION_LIBRARY}
|
||||
${Boost_SIGNALS_LIBRARY}
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
${ROOT_LIBRARIES}
|
||||
)
|
||||
uLib_add_tests(${uLib-module})
|
||||
20
src/Root/testing/Makefile.am
Normal file
20
src/Root/testing/Makefile.am
Normal file
@@ -0,0 +1,20 @@
|
||||
include $(top_srcdir)/Common.am
|
||||
|
||||
#AM_DEFAULT_SOURCE_EXT = .cpp
|
||||
|
||||
# if HAVE_CHECK
|
||||
TESTS = RootDebugTest
|
||||
|
||||
# UuidTest
|
||||
|
||||
# else
|
||||
# TEST =
|
||||
# endif
|
||||
|
||||
LDADD = $(top_srcdir)/libmutom-${PACKAGE_VERSION}.la $(AM_LIBS_BOOST) $(AM_LIBS_ROOT)
|
||||
|
||||
check_PROGRAMS = $(TESTS)
|
||||
|
||||
|
||||
all: $(TESTS)
|
||||
|
||||
122
src/Root/testing/RootDebugTest.cpp
Normal file
122
src/Root/testing/RootDebugTest.cpp
Normal file
@@ -0,0 +1,122 @@
|
||||
/*//////////////////////////////////////////////////////////////////////////////
|
||||
// CMT Cosmic Muon Tomography project //////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Copyright (c) 2014, Universita' degli Studi di Padova, INFN sez. di Padova
|
||||
All rights reserved
|
||||
|
||||
Authors: Andrea Rigoni Garola < andrea.rigoni@pd.infn.it >
|
||||
|
||||
------------------------------------------------------------------
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3.0 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library.
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include <TApplication.h>
|
||||
#include <TTree.h>
|
||||
#include <TFile.h>
|
||||
#include <TBrowser.h>
|
||||
#include <TString.h>
|
||||
#include <TText.h>
|
||||
#include <TPave.h>
|
||||
|
||||
#include "Root/TestTObject.h"
|
||||
#include "Root/RootMuonScatter.h"
|
||||
|
||||
#include "Detectors/MuonScatter.h"
|
||||
|
||||
TTree * getTree(TFile *m_File, const char *path, const char *name) {
|
||||
std::string p = std::string("/") + std::string(path);
|
||||
TDirectory *dir = m_File->GetDirectory(p.c_str());
|
||||
if(!dir) {
|
||||
m_File->mkdir(path);
|
||||
}
|
||||
m_File->cd(path);
|
||||
std::string n = p + std::string("/") + std::string(name);
|
||||
TObject *obj = m_File->Get(n.c_str());
|
||||
if(!obj) {
|
||||
TTree *tree = new TTree();
|
||||
tree->SetName(name);
|
||||
return tree;
|
||||
}
|
||||
else {
|
||||
return (TTree *)obj;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int main(int argc,char **argv) {
|
||||
|
||||
uLib::MuonScatter u_mu;
|
||||
ROOT::Mutom::MuonScatter mu;
|
||||
ROOT::Mutom::Vector3f v3f(0,1,0);
|
||||
|
||||
TFile *file = new TFile("test_file.root","RECREATE");
|
||||
TTree *tree = getTree(file,"testing/dump","testing_tree");
|
||||
TTree *tree2 = getTree(file,"new_dump","testing_tree");
|
||||
|
||||
tree->Branch("mu",&mu);
|
||||
tree->AddFriend(tree2);
|
||||
|
||||
|
||||
mu.in.origin = ROOT::Mutom::Vector3f(1,2,3);
|
||||
mu.in.direction = ROOT::Mutom::Vector3f(4,5,6);
|
||||
mu.p_in = 555;
|
||||
mu.p_out = 2368;
|
||||
|
||||
tree->Fill();
|
||||
|
||||
u_mu.LineIn().origin << 3,3,3;
|
||||
u_mu.LineIn().direction << 5,5,5;
|
||||
u_mu.LineOut().origin << 1,2,3;
|
||||
u_mu.LineOut().direction << 4,5,6;
|
||||
u_mu.SetMomentum(555);
|
||||
u_mu.SetMomentumPrime(2368);
|
||||
|
||||
mu << u_mu;
|
||||
|
||||
tree->Fill();
|
||||
|
||||
tree2->Branch("vec",&v3f);
|
||||
tree2->Branch("p_in",&mu.p_in);
|
||||
tree2->Branch("p_out",&mu.p_out);
|
||||
mu.p_in = 1;
|
||||
mu.p_out = 2;
|
||||
tree2->Fill();
|
||||
|
||||
file->cd("/testing/dump");
|
||||
tree->Write();
|
||||
file->cd("/new_dump");
|
||||
tree2->Write();
|
||||
|
||||
TText text(0,0,"this file contain a muon scatter event");
|
||||
file->cd("/");
|
||||
text.Write("content");
|
||||
|
||||
|
||||
|
||||
gApplication = new TApplication("Application", &argc, argv);
|
||||
TBrowser *tbr = new TBrowser("test");
|
||||
tbr->Show();
|
||||
|
||||
|
||||
gApplication->Run();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user