|
ATLAS Offline Software
|
Go to the documentation of this file.
31 #include "TParameter.h"
33 #define LIB_VERSION 10
44 ver = (TParameter<int>*)
source->Get(
"version");
48 TTree* TTreeMeta = (TTree*)
source->Get(
"meta");
49 TTree* TTreeLib = (TTree*)
source->Get(
"library");
51 if ((TTreeMeta ==
nullptr) || (TTreeLib ==
nullptr))
return nullptr;
53 std::cout <<
"TestShowerLib header found." << std::endl;
57 if (!(newlib->
readMeta(TTreeMeta)) || !(newlib->
read(TTreeLib))) {
59 std::cout <<
"TestShowerLib read unsuccessful." << std::endl;
79 std::ifstream filestr(
inputFile.c_str(),std::ios::in);
81 if (!filestr.is_open()) {
82 std::cout <<
"TestShowerLib " <<
inputFile <<
": bad file!" << std::endl;
87 std::getline(filestr,instr);
88 std::stringstream
ss(instr);
111 std::getline(filestr,instr);
121 std::cout <<
"Library is not created for production use" << std::endl;
125 std::cout <<
"Library is only for testing, not for production use" << std::endl;
132 std::cout <<
"Library is not created for production use" << std::endl;
136 std::cout <<
"Library is only for testing, not for production use" << std::endl;
143 std::cout <<
"Library is not created for production use" << std::endl;
147 std::cout <<
"Library is only for testing, not for production use" << std::endl;
154 std::cout <<
"ERROR: filled" << std::endl;
159 theinfo.
vertex = std::make_unique<HepMC::FourVector>(genParticle->production_vertex()->position());
160 theinfo.momentum = std::make_unique<HepMC::FourVector>(genParticle->momentum());
162 m_libData.emplace_back(std::move(theinfo), *shower);
172 dest->WriteObject(&
ver,
"version");
180 dest->WriteObject(&TTreeLib,
"library");
181 dest->WriteObject(&TTreeMeta,
"meta");
201 int nentr =
source->GetEntriesFast();
202 if (nentr < 3)
return false;
203 Float_t
x,
y,
z,
e,time;
204 source->SetBranchAddress(
"x",&
x);
205 source->SetBranchAddress(
"y",&
y);
206 source->SetBranchAddress(
"z",&
z);
207 source->SetBranchAddress(
"e",&
e);
208 source->SetBranchAddress(
"time",&time);
214 int nhits = (
int)(
e+0.1);
218 theinfo.
vertex = std::make_unique<HepMC::FourVector>(
x,
y,
z,0);
221 theinfo.momentum = std::make_unique<HepMC::FourVector>(
x,
y,
z,
e);
222 for(
int i = 0;
i < nhits;
i++) {
226 m_libData.emplace_back(std::move(theinfo),shower);
227 }
while (entr < nentr);
247 Float_t
x,
y,
z,
e,time;
248 dest->Branch(
"x",&
x);
249 dest->Branch(
"y",&
y);
250 dest->Branch(
"z",&
z);
251 dest->Branch(
"e",&
e);
252 dest->Branch(
"time",&time);
254 HepMC::FourVector
vertex = *lib.first.vertex;
255 HepMC::FourVector
momentum = *lib.first.momentum;
259 e = lib.second.size();
260 time = lib.second.getZSize();
266 time = lib.second.getRSize();
void setZSize(const float zsize)
std::string m_detector
name of the detector
Class for shower library shower.
static IShowerLib * readFromROOTFile(TFile *source)
factory method. create a library from root file. returns NULL if file is invalid.
virtual ~TestShowerLib()
default destructor
bool read(TTree *source)
read library from given TTree
virtual std::vector< EnergySpot > * getShower(const G4Track *track, ShowerLibStatistics *stats, int randomShift) const
get shower for given G4 track
std::string m_comment
comment
G4ThreeVector GetPosition() const
static IShowerLib * createEmptyLib(const std::string &inputFile)
factory method. create empty library with the given structure. returns NULL if file is invalid.
bool m_filled
is the library read from ROOT or from structure file
bool write(TTree *dest) const
write library to given TTree
virtual double getContainmentR(const G4Track *track) const
get average lateral spread of the showers for the given energy
bool writeMeta(TTree *dest) const
write metadata to the given TTree
virtual double getContainmentZ(const G4Track *track) const
get average length of showers for the given energy
int m_particle
ID of the generated particles.
Class for shower library shower lib interface.
bool readMeta(TTree *source)
read metadata from the given TTree
virtual ShowerLibStatistics * createStatistics() const
const GenParticle * ConstGenParticlePtr
std::unique_ptr< HepMC::FourVector > vertex
virtual bool writeToROOT(TFile *dest)
write library to ROOT file
virtual bool storeShower(HepMC::ConstGenParticlePtr genParticle, const Shower *shower)
store shower in the library
void setRSize(const float rsize)
G4double GetEnergy() const
Namespace for the ShowerLib related classes.
std::pair< genInfo, Shower > storedShower
Class for shower library shower lib.