mirror of
https://github.com/OpenCMT/uLib.git
synced 2025-12-06 07:21:31 +01:00
Compare commits
6 Commits
beam_trace
...
v0.5.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7c775ee35 | ||
|
|
7bc4932d09 | ||
|
|
8832f47e75 | ||
|
|
043a44150c | ||
|
|
fce2a39393 | ||
|
|
d223a3a308 |
@@ -11,7 +11,7 @@ project(uLib)
|
|||||||
|
|
||||||
# The version number.
|
# The version number.
|
||||||
set(PROJECT_VERSION_MAJOR 0)
|
set(PROJECT_VERSION_MAJOR 0)
|
||||||
set(PROJECT_VERSION_MINOR 4)
|
set(PROJECT_VERSION_MINOR 5)
|
||||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
set(PROJECT_SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
|
|
||||||
@@ -79,8 +79,25 @@ include(${EIGEN3_USE_FILE})
|
|||||||
find_package(ROOT CONFIG REQUIRED)
|
find_package(ROOT CONFIG REQUIRED)
|
||||||
include(${ROOT_USE_FILE})
|
include(${ROOT_USE_FILE})
|
||||||
|
|
||||||
find_package(VTK CONFIG REQUIRED)
|
find_package(VTK REQUIRED
|
||||||
include(${VTK_USE_FILE})
|
COMPONENTS CommonColor
|
||||||
|
CommonCore
|
||||||
|
FiltersCore
|
||||||
|
FiltersModeling
|
||||||
|
FiltersSources
|
||||||
|
IOLegacy
|
||||||
|
IOXML
|
||||||
|
IOXMLParser
|
||||||
|
ImagingCore
|
||||||
|
InteractionStyle
|
||||||
|
InteractionWidgets
|
||||||
|
RenderingAnnotation
|
||||||
|
RenderingContextOpenGL2
|
||||||
|
RenderingCore
|
||||||
|
RenderingFreeType
|
||||||
|
RenderingGL2PSOpenGL2
|
||||||
|
RenderingOpenGL2
|
||||||
|
RenderingVolumeOpenGL2)
|
||||||
|
|
||||||
set(CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_INCLUDES math.h)
|
set(CMAKE_REQUIRED_INCLUDES CMAKE_REQUIRED_INCLUDES math.h)
|
||||||
set(CMAKE_REQUIRED_LIBRARIES CMAKE_REQUIRED_LIBRARIES m)
|
set(CMAKE_REQUIRED_LIBRARIES CMAKE_REQUIRED_LIBRARIES m)
|
||||||
|
|||||||
@@ -1,12 +1,43 @@
|
|||||||
set(HEADERS RootMathDense.h
|
set(HEADERS RootMathDense.h
|
||||||
RootMuonScatter.h
|
RootMuonScatter.h
|
||||||
RootHitRaw.h)
|
RootHitRaw.h
|
||||||
|
muCastorMCTrack.h
|
||||||
|
muCastorHit.h
|
||||||
|
muCastorInfo.h
|
||||||
|
muCastorSkinHit.h
|
||||||
|
SkinDetectorWriter.h)
|
||||||
|
|
||||||
set(SOURCES ${HEADERS} RootMuonScatter.cpp)
|
set(SOURCES ${HEADERS} RootMuonScatter.cpp
|
||||||
|
muCastorMCTrack.cpp
|
||||||
|
muCastorHit.cpp
|
||||||
|
muCastorInfo.cpp
|
||||||
|
muCastorSkinHit.cpp
|
||||||
|
SkinDetectorWriter.cpp)
|
||||||
|
|
||||||
|
set(DICTIONARY_HEADERS muCastorMCTrack.h
|
||||||
|
muCastorHit.h
|
||||||
|
muCastorInfo.h
|
||||||
|
muCastorSkinHit.h
|
||||||
|
SkinDetectorWriter.h)
|
||||||
|
|
||||||
set(LIBRARIES ${ROOT_LIBRARIES}
|
set(LIBRARIES ${ROOT_LIBRARIES}
|
||||||
${PACKAGE_LIBPREFIX}Math)
|
${PACKAGE_LIBPREFIX}Math)
|
||||||
|
|
||||||
|
set(rDictName ${PACKAGE_LIBPREFIX}RootDict)
|
||||||
|
root_generate_dictionary(${rDictName} ${DICTIONARY_HEADERS}
|
||||||
|
LINKDEF Linkdef.h)
|
||||||
|
set_source_files_properties(${rDictName}.cxx
|
||||||
|
PROPERTIES GENERATED TRUE)
|
||||||
|
set_source_files_properties(${rDictName}.h
|
||||||
|
PROPERTIES GENERATED TRUE)
|
||||||
|
list(APPEND SOURCES ${rDictName}.cxx)
|
||||||
|
|
||||||
|
# TODO use a custom target linked to root_generate_dictionary
|
||||||
|
set(R_ARTIFACTS ${CMAKE_CURRENT_BINARY_DIR}/lib${rDictName}_rdict.pcm
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/lib${rDictName}.rootmap)
|
||||||
|
install(FILES ${R_ARTIFACTS}
|
||||||
|
DESTINATION ${PACKAGE_INSTALL_LIB_DIR})
|
||||||
|
|
||||||
set(libname ${PACKAGE_LIBPREFIX}Root)
|
set(libname ${PACKAGE_LIBPREFIX}Root)
|
||||||
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
set(ULIB_SHARED_LIBRARIES ${ULIB_SHARED_LIBRARIES} ${libname} PARENT_SCOPE)
|
||||||
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Root PARENT_SCOPE)
|
set(ULIB_SELECTED_MODULES ${ULIB_SELECTED_MODULES} Root PARENT_SCOPE)
|
||||||
|
|||||||
@@ -79,6 +79,9 @@ using namespace ROOT::Mutom;
|
|||||||
#pragma link C++ class muCastorMCTrack+;
|
#pragma link C++ class muCastorMCTrack+;
|
||||||
#pragma link C++ class muCastorHit+;
|
#pragma link C++ class muCastorHit+;
|
||||||
#pragma link C++ class muCastorInfo+;
|
#pragma link C++ class muCastorInfo+;
|
||||||
|
#pragma link C++ class muCastorSkinHit+;
|
||||||
|
|
||||||
|
#pragma link C++ class SkinDetectorWriter+;
|
||||||
|
|
||||||
#endif // __CINT__
|
#endif // __CINT__
|
||||||
|
|
||||||
|
|||||||
47
src/Root/SkinDetectorWriter.cpp
Normal file
47
src/Root/SkinDetectorWriter.cpp
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#include "SkinDetectorWriter.h"
|
||||||
|
#include "muCastorSkinHit.h"
|
||||||
|
#include "TVector3.h"
|
||||||
|
|
||||||
|
SkinDetectorWriter::SkinDetectorWriter(string filename) :
|
||||||
|
t_file(nullptr),
|
||||||
|
t_tree(nullptr),
|
||||||
|
t_buffer(nullptr),
|
||||||
|
i_status(0)
|
||||||
|
{
|
||||||
|
t_file = new TFile(filename.c_str(), "RECREATE");
|
||||||
|
t_tree = new TTree("muCastorMC", "muCastorMC");
|
||||||
|
t_buffer = new TClonesArray("muCastorSkinHit");
|
||||||
|
|
||||||
|
t_tree->Branch("CastorSkinHits", "TClonesArray", t_buffer, 32000, 99);
|
||||||
|
|
||||||
|
if (t_file->IsZombie()) i_status = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
SkinDetectorWriter::~SkinDetectorWriter()
|
||||||
|
{}
|
||||||
|
|
||||||
|
void SkinDetectorWriter::add(int detID, float p_x, float p_y, float p_z,
|
||||||
|
float m_x, float m_y, float m_z)
|
||||||
|
{
|
||||||
|
TClonesArray& ref = *t_buffer;
|
||||||
|
int size = ref.GetEntriesFast();
|
||||||
|
|
||||||
|
muCastorSkinHit* new_hit = new(ref[size]) muCastorSkinHit();
|
||||||
|
new_hit->SetDetID(detID);
|
||||||
|
new_hit->SetPdgCode(13);
|
||||||
|
new_hit->SetMotherID(-1);
|
||||||
|
new_hit->SetPos (TVector3(p_x, p_y, p_z));
|
||||||
|
new_hit->SetMom (TVector3(m_x, m_y, m_z));
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkinDetectorWriter::write()
|
||||||
|
{
|
||||||
|
if (t_tree->Fill() < 0) i_status = 2;
|
||||||
|
t_buffer->Delete(); // or t_buffer->Clear() ??
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkinDetectorWriter::close()
|
||||||
|
{
|
||||||
|
if (t_tree->Write() == 0) i_status = 3;
|
||||||
|
t_file->Close();
|
||||||
|
}
|
||||||
32
src/Root/SkinDetectorWriter.h
Normal file
32
src/Root/SkinDetectorWriter.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef SkinDetectorWriter_h
|
||||||
|
#define SkinDetectorWriter_h
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "TFile.h"
|
||||||
|
#include "TTree.h"
|
||||||
|
#include "TClonesArray.h"
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
|
||||||
|
class SkinDetectorWriter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SkinDetectorWriter(string filename);
|
||||||
|
virtual ~SkinDetectorWriter();
|
||||||
|
|
||||||
|
void add(int detID, float p_x, float p_y, float p_z, float m_x, float m_y, float m_z);
|
||||||
|
int status() { return i_status; }
|
||||||
|
void write();
|
||||||
|
void close();
|
||||||
|
|
||||||
|
private:
|
||||||
|
TFile* t_file;
|
||||||
|
TTree* t_tree;
|
||||||
|
TClonesArray* t_buffer;
|
||||||
|
int i_status;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif //SkinDetectorWriter_h
|
||||||
43
src/Root/muCastorSkinHit.cpp
Normal file
43
src/Root/muCastorSkinHit.cpp
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
//----------------------------------------------------------
|
||||||
|
// Class : CastorSkinHit
|
||||||
|
// Date: October 2020
|
||||||
|
// Author: Germano Bonomi germano.bonomi@unibs.it
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "muCastorSkinHit.h"
|
||||||
|
|
||||||
|
/// \cond CLASSIMP
|
||||||
|
ClassImp(muCastorSkinHit)
|
||||||
|
/// \endcond
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorSkinHit::muCastorSkinHit() :
|
||||||
|
fDetID(-1),
|
||||||
|
fPdgCode(-1),
|
||||||
|
fMotherID(-1),
|
||||||
|
fMomX(0.),
|
||||||
|
fMomY(0.),
|
||||||
|
fMomZ(0.),
|
||||||
|
fPosX(0.),
|
||||||
|
fPosY(0.),
|
||||||
|
fPosZ(0.)
|
||||||
|
{}
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
muCastorSkinHit::~muCastorSkinHit()
|
||||||
|
{}
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
void muCastorSkinHit::Print(const Option_t* /*opt*/) const
|
||||||
|
{
|
||||||
|
cout << " detID: " << fDetID
|
||||||
|
<< " position (cm): ("
|
||||||
|
<< fPosX << ", " << fPosY << ", " << fPosZ << ")"
|
||||||
|
<< " momentum (MeV/c): ("
|
||||||
|
<< fMomX << ", " << fMomY << ", " << fMomZ << ")"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
52
src/Root/muCastorSkinHit.h
Normal file
52
src/Root/muCastorSkinHit.h
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
//----------------------------------------------------------
|
||||||
|
// Class : CastorSkinHit
|
||||||
|
// Date: October 2020
|
||||||
|
// Author: Germano Bonomi germano.bonomi@unibs.it
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
|
#ifndef muCastor_SKINHIT_H
|
||||||
|
#define muCastor_SKINHIT_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <TObject.h>
|
||||||
|
#include <TVector3.h>
|
||||||
|
|
||||||
|
class muCastorSkinHit : public TObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
muCastorSkinHit();
|
||||||
|
virtual ~muCastorSkinHit();
|
||||||
|
|
||||||
|
// methods
|
||||||
|
virtual void Print(const Option_t* option = "") const;
|
||||||
|
|
||||||
|
// set methods
|
||||||
|
void SetDetID(Int_t id) { fDetID = id; };
|
||||||
|
void SetPdgCode(Int_t pdg) { fPdgCode = pdg; };
|
||||||
|
void SetMotherID(Int_t mid) { fMotherID = mid; };
|
||||||
|
void SetMom(TVector3 xyz) { fMomX = xyz.X(); fMomY = xyz.Y(); fMomZ = xyz.Z(); };
|
||||||
|
void SetPos(TVector3 xyz) { fPosX = xyz.X(); fPosY = xyz.Y(); fPosZ = xyz.Z(); };
|
||||||
|
|
||||||
|
Int_t GetDetID() { return fDetID; }
|
||||||
|
Int_t GetPdgCode() { return fPdgCode; }
|
||||||
|
Int_t GetMotherID() { return fMotherID; }
|
||||||
|
TVector3 GetMom() { return TVector3(fMomX, fMomY, fMomZ); }
|
||||||
|
TVector3 GetPos() { return TVector3(fPosX, fPosY, fPosZ); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
Int_t fDetID; // Detector module ID
|
||||||
|
Int_t fPdgCode; // Particle PDG Code
|
||||||
|
Int_t fMotherID; // Particle mother ID (-1 = primary, 0 = secondary, etc..)
|
||||||
|
Double_t fMomX; // Track momentum when releasing the hit (X)
|
||||||
|
Double_t fMomY; // Track momentum when releasing the hit (Y)
|
||||||
|
Double_t fMomZ; // Track momentum when releasing the hit (Z)
|
||||||
|
Double_t fPosX; // Hit coordinates (at the entrance of the detector) (X)
|
||||||
|
Double_t fPosY; // Hit coordinates (at the entrance of the detector) (Y)
|
||||||
|
Double_t fPosZ; // Hit coordinates (at the entrance of the detector) (Z)
|
||||||
|
|
||||||
|
ClassDef(muCastorSkinHit,1) //muCastorSkinHit
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif //muCastort_SKINHIT_H
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user