[uLib Geometry]

non working version!

+ adds ProgrammableAccessor
+ renaming of some Image structures ...
This commit is contained in:
Andrea Rigoni
2014-11-03 10:27:52 +00:00
commit 99e771a223
403 changed files with 61684 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
# HEADERS
set(HEADERS
DetectorChamber.h
ExperimentFitEvent.h
GeantEvent.h
HitMC.h
MuonScatter.h
MuonEvent.h
MuonError.h
ChamberHitEvent.h
Hit.h
LinearFit.h
Solid.h
Matter.h
Scene.h
)
# SOURCES
set(SOURCES
Solid.cpp
Scene.cpp
)
set(LIBRARIES
${Boost_SERIALIZATION_LIBRARY}
${Boost_SIGNALS_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Eigen_LIBRARY}
${Geant4_LIBRARIES}
${ROOT_LIBRARIES}
${PACKAGE_LIBPREFIX}Core
${PACKAGE_LIBPREFIX}Math
${PACKAGE_LIBPREFIX}Detectors
)
uLib_add_shared_library(${uLib-module})
add_subdirectory(testing)

View File

@@ -0,0 +1,56 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_CHAMBERHITEVENT_H
#define U_CHAMBERHITEVENT_H
#include "Core/Vector.h"
#include "Hit.h"
#include "ChamberDetector.h"
namespace uLib {
class ChamberHitEventData
{
public:
uLibConstRefMacro (Hits, Vector<HitData> )
uLibGetMacro (Idv, ChamberDetector::ID)
private:
friend class ChamberHitEvent;
Vector<HitData> m_Hits;
DetectorChamber::ID m_Idv; // -> chamber/view
};
class ChamberHitEvent : public ChamberHitEventData {
public:
uLibRefMacro (Hits, Vector<HitData> )
uLibSetMacro (Idv, ChamberDetector::ID)
};
}
#endif // CHAMBERHITEVENT_H

View File

@@ -0,0 +1,48 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_CHAMBERDETECTOR_H
#define U_CHAMBERDETECTOR_H
#include "Core/Types.h"
#include "Math/ContainerBox.h"
namespace uLib {
class DetectorChamber : public ContainerBox {
public:
private:
};
}
#endif // CHAMBERDETECTOR_H

View File

@@ -0,0 +1,48 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_EXPERIMENTFITEVENT_H
#define U_EXPERIMENTFITEVENT_H
namespace uLib {
class ExperimentFitEventData {
public:
private:
};
}
#endif // EXPERIMENTFITEVENT_H

View File

@@ -0,0 +1,69 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_GEANTEVENT_H
#define U_GEANTEVENT_H
#include "Core/Types.h"
#include "Core/Vector.h"
#include "Math/Dense.h"
#include "ChamberHitEvent.h"
namespace uLib {
class GeantEventData {
public:
uLibGetMacro (EventID, Id_t )
uLibGetMacro (Momentum,Scalarf )
uLibConstRefMacro (GenPos, Vector3f)
uLibConstRefMacro (GenDir, Vector3f)
uLibConstRefMacro (ChEvents,Vector<ChamberHitEventData>)
private:
friend class GeantEvent;
Id_t m_EventID;
Scalarf m_Momentum;
Vector3f m_GenPos;
Vector3f m_GenDir;
Vector<ChamberHitEventData> m_ChEvents;
};
class GeantEvent {
public:
uLibSetMacro (EventID, Id_t )
uLibSetMacro (Momentum,Scalarf )
uLibRefMacro (GenPos, Vector3f)
uLibRefMacro (GenDir, Vector3f)
uLibRefMacro (ChEvents,Vector<ChamberHitEventData>)
};
}
#endif // GEANTEVENT_H

View File

@@ -0,0 +1,41 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_DETECTORS_HIERARCHICALENCODING_H
#define U_DETECTORS_HIERARCHICALENCODING_H
#include <Core/BitCoding.h>
namespace uLib {
} // uLib
#endif // HIERARCHICALENCODING_H

70
src/Detectors/Hit.h Normal file
View File

@@ -0,0 +1,70 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 HIT_H
#define HIT_H
#include "Math/BitCode.h"
namespace uLib {
class HitRawCode_CMSDrift :
public BitCode4<unsigned short,6,3,2,5>
{
typedef unsigned short T;
public:
HitRawCode_CMSDrift() : BitCode4(0) {}
HitRawCode_CMSDrift(const Vector4i &v) : BitCode4(v) {}
HitRawCode_CMSDrift(T Chamber, T ROB, T TDC, T Channel ) {
(*this) << Chamber, ROB, TDC, Channel;
}
inline T Chamber() const { return m_data.bitf.field1; }
inline void SetChamber(const T data) { m_data.bitf.field1 = data; }
inline T ROB() const { return m_data.bitf.field2; }
inline void SetROB(const T data) { m_data.bitf.field2 = data; }
inline T TDC() const { return m_data.bitf.field3; }
inline void SetTDC(const T data) { m_data.bitf.field3 = data; }
inline T Channel() const { return m_data.bitf.field4; }
inline void SetChannel(const T data) { m_data.bitf.field4 = data; }
};
}
#endif // HIT_H

67
src/Detectors/HitMC.h Normal file
View File

@@ -0,0 +1,67 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_HITMC_H
#define U_HITMC_H
#include "Core/Macros.h"
#include "Math/Dense.h"
#include "Hit.h"
namespace uLib {
class HitMCData : public HitData{
public:
enum Type {
PrimaryMu,
SecondaryMu,
DeltaRay
};
uLibConstRefMacro(Position,HPoint3f)
uLibGetMacro(Type, enum Type)
private:
HPoint3f m_Position;
enum Type m_Type;
};
class HitMC : public HitMCData {
public:
uLibRefMacro(Position,HPoint3f)
uLibSetMacro(Type, enum Type)
};
}
#endif // HITMC_H

73
src/Detectors/LinearFit.h Normal file
View File

@@ -0,0 +1,73 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_LINEARFIT_H
#define U_LINEARFIT_H
#include "Core/Macros.h"
#include "Math/Dense.h"
#include "ChamberDetector.h"
namespace uLib {
class LinearFitData {
public:
uLibConstRefMacro(Position,Vector2f)
uLibConstRefMacro(Slope,Vector2f)
uLibConstRefMacro(PositionError,Vector2f)
uLibConstRefMacro(SlopeError,Vector2f)
uLibGetMacro(HitsNumber,int)
uLibGetMacro(Idv,ChamberDetector::ID)
private:
friend class LinearFit;
Vector2f m_Position;
Vector2f m_Slope;
Vector2f m_PositionError;
Vector2f m_SlopeError;
int m_HitsNumber;
DetectorChamber::ID m_Idv;
};
class LinearFit : public LinearFitData {
public:
uLibRefMacro(Position,Vector2f)
uLibRefMacro(Slope,Vector2f)
uLibRefMacro(PositionError,Vector2f)
uLibRefMacro(SlopeError,Vector2f)
uLibSetMacro(HitsNumber,int)
uLibSetMacro(Idv,ChamberDetector::ID)
};
}
#endif // LINEARFIT_H

25
src/Detectors/Makefile.am Normal file
View File

@@ -0,0 +1,25 @@
include $(top_srcdir)/Common.am
library_includedir = $(includedir)/libmutom-${PACKAGE_VERSION}/Detectors
library_include_HEADERS = DetectorChamber.h \
ExperimentFitEvent.h \
GeantEvent.h \
HitMC.h \
MuonScatter.h \
MuonEvent.h \
MuonError.h \
ChamberHitEvent.h \
Hit.h \
LinearFit.h \
Solid.h \
Matter.h \
Scene.h
_DETECTORS_SOURCES = \
Solid.cpp \
Scene.cpp
noinst_LTLIBRARIES = libmutomdetectors.la
libmutomdetectors_la_SOURCES = ${_DETECTORS_SOURCES}

71
src/Detectors/Matter.h Normal file
View 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 MATTER_H
#define MATTER_H
#include "Core/Object.h"
class G4Element;
class G4Material;
namespace uLib {
////////////////////////////////////////////////////////////////////////////////
//// ELEMENT ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
class Element {
public:
uLibRefMacro(G4Data,G4Element *)
private:
G4Element *m_G4Data;
};
////////////////////////////////////////////////////////////////////////////////
//// MATERIAL //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
class Material : public Object {
public:
uLibRefMacro(G4Data,G4Material *)
private:
G4Material *m_G4Data;
};
}
#endif // MATTER_H

58
src/Detectors/MuonError.h Normal file
View File

@@ -0,0 +1,58 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_MUONERROR_H
#define U_MUONERROR_H
#include "Core/Macros.h"
#include "Math/Dense.h"
namespace uLib {
class MuonErrorData {
friend class MuonError;
public:
uLibConstRefMacro(Theta,Scalarf)
uLibConstRefMacro(Phi,Scalarf)
private:
Scalarf m_Theta;
Scalarf m_Phi;
};
class MuonError : public MuonErrorData {
public:
uLibRefMacro(Theta,Scalarf)
uLibRefMacro(Phi,Scalarf)
};
} // end ulib space
#endif // U_MUONERROR_H

75
src/Detectors/MuonEvent.h Normal file
View 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.
//////////////////////////////////////////////////////////////////////////////*/
#ifndef U_MUONEVENT_H
#define U_MUONEVENT_H
#include "Core/Macros.h"
#include "Math/Dense.h"
namespace uLib {
class MuonEventData {
friend class MuonEvent;
public:
uLibConstRefMacro(LineIn,HLine3f)
uLibConstRefMacro(LineOut,HLine3f)
uLibGetMacro(Momentum,Scalarf)
private:
HLine3f m_LineIn;
HLine3f m_LineOut;
Scalarf m_Momentum;
};
class MuonEvent : public MuonEventData {
public:
uLibRefMacro(LineIn,HLine3f)
uLibRefMacro(LineOut,HLine3f)
uLibRefMacro(Momentum,Scalarf)
};
inline std::ostream&
operator<< (std::ostream& stream, const MuonEventData &mu) {
stream << " MuonEventData: --------------- \n"
<< " P: " << mu.GetMomentum() << "\n"
<< " IN: " << mu.LineIn() << "\n"
<< " OUT: " << mu.LineOut() << "\n"
<< " ------------------------------ \n";
return stream;
}
} // end ulib space
#endif // U_MUONEVENT_H

View File

@@ -0,0 +1,81 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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_MUONSCATTER_H
#define U_MUONSCATTER_H
#include "Core/Macros.h"
#include "Math/Dense.h"
#include "Math/Line.h"
namespace uLib {
class MuonScatter {
public:
uLibConstRefMacro(LineIn,Line4f)
uLibConstRefMacro(ErrorIn,Line4f)
uLibConstRefMacro(LineOut,Line4f)
uLibConstRefMacro(ErrorOut,Line4f)
uLibRefMacro(LineIn,Line4f)
uLibRefMacro(ErrorIn,Line4f)
uLibRefMacro(LineOut,Line4f)
uLibRefMacro(ErrorOut,Line4f)
uLibSetMacro(Momentum,Scalarf)
uLibSetMacro(MomentumPrime,Scalarf)
uLibGetMacro(Momentum,Scalarf)
uLibGetMacro(MomentumPrime,Scalarf)
protected:
Line4f m_LineIn;
Line4f m_LineOut;
Line4f m_ErrorIn;
Line4f m_ErrorOut;
Scalarf m_Momentum;
Scalarf m_MomentumPrime;
};
typedef MuonScatter MuonScatterData;
inline std::ostream&
operator<< (std::ostream& stream, const MuonScatterData &mu) {
stream << " MuonScatterData: ------------- \n"
// << " P: " << mu.GetMomentum() << " Pprim: " << mu.GetMomentumPrime() << "\n"
// << " IN: " << mu.LineIn() << "\n"
// << " " << mu.ErrorIn() << "\n"
// << " OUT: " << mu.LineOut() << "\n"
// << " " << mu.ErrorOut() <<"\n"
<< " ------------------------------ \n";
return stream;
}
}
#endif // U_MUONSCATTER_H

75
src/Detectors/Scene.cpp Normal file
View 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 <Geant4/G4Material.hh>
#include <Geant4/G4NistManager.hh>
#include <Geant4/G4LogicalVolume.hh>
#include <Geant4/G4GDMLParser.hh>
#include "Core/Vector.h"
#include "Matter.h"
#include "Solid.h"
#include "Scene.h"
namespace uLib {
class DetectorsScenePimpl {
public:
// members //
//Vector<Solid> m_Solids;
};
DetectorsScene::DetectorsScene() :
d(new DetectorsScenePimpl())
{}
DetectorsScene::~DetectorsScene()
{
delete d;
}
void DetectorsScene::AddSolid(const Solid &solid)
{
// d->m_Solids.push_back(solid);
}
}

52
src/Detectors/Scene.h Normal file
View File

@@ -0,0 +1,52 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 SCENE_H
#define SCENE_H
#include "Core/Object.h"
#include "Core/Vector.h"
#include "Solid.h"
namespace uLib {
class DetectorsScene : public Object {
public:
DetectorsScene();
~DetectorsScene();
void AddSolid(const Solid &solid);
private:
class DetectorsScenePimpl *d;
};
}
#endif // SCENE_H

114
src/Detectors/Solid.cpp Normal file
View File

@@ -0,0 +1,114 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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.
//////////////////////////////////////////////////////////////////////////////*/
// G4 Solid //
#include <Geant4/G4Material.hh>
#include <Geant4/G4NistManager.hh>
#include <Geant4/G4LogicalVolume.hh>
// Tessellated solid //
#include <Geant4/G4TessellatedSolid.hh>
#include <Geant4/G4TriangularFacet.hh>
#include <Geant4/G4ThreeVector.hh>
#include "Math/Dense.h"
#include "Solid.h"
namespace uLib {
class DetectorsSolidPimpl {
public:
static G4ThreeVector getG4Vector3f(const Vector3f &vector) {
return G4ThreeVector( vector(0), vector(1), vector(2) );
}
};
Solid::Solid() :
m_Logical (new G4LogicalVolume(NULL,NULL,"unnamed_solid")),
m_Material(NULL)
{}
Solid::Solid(const char *name) :
m_Logical(new G4LogicalVolume(NULL,NULL,name)),
m_Material(NULL)
{}
void Solid::SetNistMaterial(const char *name)
{
G4NistManager *nist = G4NistManager::Instance();
if (m_Material) delete m_Material;
m_Material = nist->FindOrBuildMaterial(name);
m_Logical->SetMaterial(m_Material);
}
void Solid::SetMaterial(G4Material *material)
{
if(material)
{
m_Material = material;
m_Logical->SetMaterial(material);
}
}
TessellatedSolid::TessellatedSolid(const char *name) :
BaseClass(name),
m_Solid(new G4TessellatedSolid(name))
{}
void TessellatedSolid::SetMesh(TriangleMesh &mesh)
{
G4TessellatedSolid *ts = this->m_Solid;
for (int i=0; i<mesh.Triangles().size(); ++i) {
const Vector3i &trg = mesh.Triangles().at(i);
G4TriangularFacet *facet = new G4TriangularFacet(
DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(0))),
DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(1))),
DetectorsSolidPimpl::getG4Vector3f(mesh.Points().at(trg(2))),
ABSOLUTE);
ts->AddFacet((G4VFacet *)facet);
}
this->m_Logical->SetSolid(ts);
}
}

86
src/Detectors/Solid.h Normal file
View File

@@ -0,0 +1,86 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 SOLID_H
#define SOLID_H
#include "Core/Object.h"
#include "Math/Dense.h"
#include "Math/TriangleMesh.h"
#include "Detectors/Matter.h"
class G4Material;
class G4LogicalVolume;
class G4TessellatedSolid;
namespace uLib {
class Solid : public Object {
public:
Solid();
Solid(const char *name);
void SetNistMaterial(const char *name);
void SetMaterial(G4Material *material);
uLibGetMacro(Material,G4Material *)
uLibGetMacro(Logical,G4LogicalVolume *)
protected:
G4Material *m_Material;
G4LogicalVolume *m_Logical;
};
class TessellatedSolid : public Solid {
typedef Solid BaseClass;
public:
TessellatedSolid(const char *name);
void SetMesh(TriangleMesh &mesh);
uLibGetMacro(Solid,G4TessellatedSolid *)
private:
G4TessellatedSolid *m_Solid;
};
}
#endif // SOLID_H

View File

@@ -0,0 +1,18 @@
# TESTS
set( TESTS
GDMLSolidTest
HierarchicalEncodingTest
)
#set(LIBRARIES
# ${PACKAGE_LIBPREFIX}Core
# ${PACKAGE_LIBPREFIX}Math
# ${PACKAGE_LIBPREFIX}Detectors
# ${Boost_SERIALIZATION_LIBRARY}
# ${Boost_SIGNALS_LIBRARY}
# ${Boost_PROGRAM_OPTIONS_LIBRARY}
# ${Eigen_LIBRARY}
# ${Geant4_LIBRARIES}
# ${ROOT_LIBRARIES}
#)
uLib_add_tests(${uLib-module})

View File

@@ -0,0 +1,72 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 <Geant4/G4RunManager.hh>
#include <Geant4/G4Material.hh>
#include <Geant4/G4NistManager.hh>
#include <Geant4/G4Box.hh>
#include <Geant4/G4TessellatedSolid.hh>
#include <Geant4/G4LogicalVolume.hh>
#include <Geant4/G4PVPlacement.hh>
#include <Geant4/G4GDMLParser.hh>
//#include <Geant4/G4GDMLRead.hh>
//#include <Geant4/G4GDMLReadSolids.hh>
#include "Detectors/Solid.h"
#include "testing-prototype.h"
int main()
{
// G4RunManager* runManager = new G4RunManager;
G4NistManager *nist = G4NistManager::Instance();
G4Material *air = nist->FindOrBuildMaterial("G4_AIR");
G4Box *box = new G4Box("box",5,5,5);
G4LogicalVolume box_lv(NULL,NULL,"box test");
box_lv.SetSolid(box);
box_lv.SetMaterial(air);
G4PVPlacement box_pl(0,G4ThreeVector(),&box_lv,"box test",0,0,0);
G4GDMLParser parser;
parser.Write("test_out.gdml",&box_lv);
}

View 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.
//////////////////////////////////////////////////////////////////////////////*/
#include <iostream>
#include <Detectors/Hit.h>
#include "testing-prototype.h"
using namespace uLib;
int main() {
BEGIN_TESTING(Hierarchical Encoding);
HitRawCode_CMSDrift code;
code = Vector4i(5,6,2,8);
Vector4i v = code;
std::cout << code << "\n";
std::cout << v << "\n";
END_TESTING;
}

View File

@@ -0,0 +1,16 @@
include $(top_srcdir)/Common.am
#AM_DEFAULT_SOURCE_EXT = .cpp
# if HAVE_CHECK
TESTS = GDMLSolidTest
# else
# TEST =
# endif
LDADD = $(top_srcdir)/libmutom-${PACKAGE_VERSION}.la
check_PROGRAMS = $(TESTS)

View File

@@ -0,0 +1,37 @@
/*//////////////////////////////////////////////////////////////////////////////
// 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 <stdio.h>
#define BEGIN_TESTING(name) \
static int _fail = 0; \
printf("..:: Testing " #name " ::..\n");
#define TEST1(val) _fail += (val)==0
#define TEST0(val) _fail += (val)!=0
#define END_TESTING return _fail;