Class for shower library shower lib.
More...
#include <EtaEnergyShowerLib.h>
Class for shower library shower lib.
Store complete shower library (collection of energy bins)
- Author
- Wolfgang Ehrenfeld, University of Hamburg, Germany
-
Sasha Glazov, DESY Hamburg, Germany
- Version
- $Id: EtaEnergyShowerLib.h 769594 2016-08-23 13:48:34Z ssnyder $
Definition at line 35 of file EtaEnergyShowerLib.h.
◆ etabin
◆ library
◆ ~EtaEnergyShowerLib()
virtual ShowerLib::EtaEnergyShowerLib::~EtaEnergyShowerLib |
( |
| ) |
|
|
inlinevirtual |
default destructor
Definition at line 46 of file EtaEnergyShowerLib.h.
49 for (
auto& ene :
eta.second ) {
50 for (
auto& spot : ene.second ) {
◆ EtaEnergyShowerLib()
ShowerLib::EtaEnergyShowerLib::EtaEnergyShowerLib |
( |
| ) |
|
|
inlineprivate |
◆ addComment()
void ShowerLib::IShowerLib::addComment |
( |
const std::string & |
comment | ) |
|
|
inlinevirtualinherited |
◆ checkEtaAndStuff()
bool ShowerLib::EtaEnergyShowerLib::checkEtaAndStuff |
( |
const G4Track * |
track | ) |
const |
|
private |
Definition at line 550 of file EtaEnergyShowerLib.cxx.
553 std::cout <<
"Library is not created for production use" << std::endl;
557 double eta =
track->GetPosition().eta();
562 std::cout <<
"eta is outside library eta range: mineta=" <<
m_mineta <<
" maxeta: " <<
m_maxeta <<
" eta=" <<
eta << std::endl;
566 G4int particleCode =
track->GetDefinition()->GetPDGEncoding();
567 if ( particleCode < 0 ) particleCode = -particleCode;
570 std::cout <<
"wrong particle: " << particleCode <<
"!=" <<
m_particle << std::endl;
◆ comment() [1/2]
const std::string ShowerLib::IShowerLib::comment |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ comment() [2/2]
void ShowerLib::IShowerLib::comment |
( |
const std::string & |
comment | ) |
|
|
inlinevirtualinherited |
◆ createEmptyLib()
IShowerLib * ShowerLib::EtaEnergyShowerLib::createEmptyLib |
( |
const std::string & |
inputFile | ) |
|
|
static |
factory method. create empty library with the given structure. returns NULL if file is invalid.
Definition at line 62 of file EtaEnergyShowerLib.cxx.
77 std::ifstream filestr(
inputFile.c_str(),std::ios::in);
80 if (!filestr.is_open()) {
81 std::cout <<
"EtaEnergyShowerLib " <<
inputFile <<
": bad file!" << std::endl;
86 std::getline(filestr,instr);
87 std::stringstream
ss(instr);
103 std::vector<float> etalist;
106 float etaold = -9999999.9;
111 std::cout <<
"file reading failed! (not enough data)" << std::endl;
119 if ((
ss.fail()) || (eta <= etaold)) {
120 std::cout <<
"screwed etas! (" <<
eta <<
"<=" << etaold <<
")" << std::endl;
123 etalist.push_back(eta);
130 if (!newlib->readStructure(etalist)) {
131 std::cout <<
"this structure is not valid" << std::endl;
136 newlib->m_detector =
det;
137 newlib->m_particle =
part;
138 newlib->m_mineta = mineta;
139 newlib->m_maxeta = maxeta;
141 newlib->m_filled =
false;
142 if (mineta < 0) newlib->m_onlyPositive =
false;
143 else newlib->m_onlyPositive =
true;
145 std::getline(filestr,instr);
146 newlib->m_comment = instr;
◆ createStatistics()
Implements ShowerLib::IShowerLib.
Definition at line 527 of file EtaEnergyShowerLib.cxx.
529 std::map<int, std::string>
names;
530 std::map<int, int> sizes;
533 float etalow =
it->first;
535 library::const_iterator it_copy =
it;
540 etahigh = it_copy->first;
542 std::stringstream
ss;
543 ss << std::showpos << std::fixed << std::setprecision(2);
544 ss <<
"ETA: " << etalow <<
" .. " << etahigh;
547 return new ShowerLibStatistics(
names, sizes);
◆ detector()
const std::string ShowerLib::IShowerLib::detector |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ geantVersion() [1/2]
const std::string ShowerLib::IShowerLib::geantVersion |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ geantVersion() [2/2]
void ShowerLib::IShowerLib::geantVersion |
( |
const std::string & |
version | ) |
|
|
inlinevirtualinherited |
◆ geometry() [1/2]
const std::string ShowerLib::IShowerLib::geometry |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ geometry() [2/2]
void ShowerLib::IShowerLib::geometry |
( |
const std::string & |
geometry | ) |
|
|
inlinevirtualinherited |
◆ getContainmentR()
double ShowerLib::EtaEnergyShowerLib::getContainmentR |
( |
const G4Track * |
track | ) |
const |
|
virtual |
get average lateral spread of the showers for the given energy
Implements ShowerLib::IShowerLib.
Definition at line 295 of file EtaEnergyShowerLib.cxx.
299 double eta =
track->GetPosition().eta();
303 library::const_iterator libit =
m_libData.upper_bound(eta);
307 std::cout <<
"Something is wrong with eta: mineta=" <<
m_mineta <<
" eta=" <<
eta << std::endl;
312 if ((*libit).second.empty()) {
313 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
316 double trenergy =
track->GetKineticEnergy();
317 etabin::const_iterator etait = (*libit).second.lower_bound(trenergy);
318 if (etait == (*libit).second.end()) --etait;
319 else if (etait != (*libit).second.begin()) {
320 etabin::const_iterator etaitch = etait;
322 if (((*etait).first - trenergy) > (trenergy - (*etaitch).first)) {
327 double rezR = (*etait).second.getRSize();
328 etabin::const_iterator etaiter = etait;
331 double upperEnergy = (*etait).first * 1.01;
332 for (
int i = 0;
i < spread;
i++) {
334 if (etaiter == (*libit).second.end()) {
337 if (upperEnergy < (*etaiter).first)
break;
339 rezR += (*etaiter).second.getRSize();
343 if (etaiter != (*libit).second.begin()) {
344 double lowerEnergy = (*etait).first * 0.99;
345 for (
int i = 0;
i < spread;
i++) {
347 if (lowerEnergy > (*etaiter).first)
break;
349 rezR += (*etaiter).second.getRSize();
351 if (etaiter == (*libit).second.begin()) {
356 return rezR/actualNumFS;
◆ getContainmentZ()
double ShowerLib::EtaEnergyShowerLib::getContainmentZ |
( |
const G4Track * |
track | ) |
const |
|
virtual |
get average length of showers for the given energy
Implements ShowerLib::IShowerLib.
Definition at line 231 of file EtaEnergyShowerLib.cxx.
235 double eta =
track->GetPosition().eta();
239 library::const_iterator libit =
m_libData.upper_bound(eta);
243 std::cout <<
"Something is wrong with eta: mineta=" <<
m_mineta <<
" eta=" <<
eta << std::endl;
248 if ((*libit).second.empty()) {
249 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
252 double trenergy =
track->GetKineticEnergy();
253 etabin::const_iterator etait = (*libit).second.lower_bound(trenergy);
254 if (etait == (*libit).second.end()) --etait;
255 else if (etait != (*libit).second.begin()) {
256 etabin::const_iterator etaitch = etait;
258 if (((*etait).first - trenergy) > (trenergy - (*etaitch).first)) {
263 double rezZ = (*etait).second.getZSize();
264 etabin::const_iterator etaiter = etait;
267 double upperEnergy = (*etait).first * 1.01;
268 for (
int i = 0;
i < spread;
i++) {
270 if (etaiter == (*libit).second.end()) {
273 if (upperEnergy < (*etaiter).first)
break;
275 rezZ += (*etaiter).second.getZSize();
279 if (etaiter != (*libit).second.begin()) {
280 double lowerEnergy = (*etait).first * 0.99;
281 for (
int i = 0;
i < spread;
i++) {
283 if (lowerEnergy > (*etaiter).first)
break;
285 rezZ += (*etaiter).second.getZSize();
287 if (etaiter == (*libit).second.begin()) {
292 return rezZ/actualNumFS;
◆ getName()
virtual const std::string ShowerLib::EtaEnergyShowerLib::getName |
( |
| ) |
const |
|
inlinevirtual |
◆ getShower()
get shower for given G4 track
Implements ShowerLib::IShowerLib.
Definition at line 151 of file EtaEnergyShowerLib.cxx.
155 double eta =
track->GetPosition().eta();
159 library::const_iterator libit =
m_libData.upper_bound(eta);
163 std::cout <<
"Something is wrong with eta: mineta=" <<
m_mineta <<
" eta=" <<
eta << std::endl;
170 if ((*libit).second.empty()) {
171 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
174 double trenergy =
track->GetKineticEnergy();
176 etabin::const_iterator etait = (*libit).second.lower_bound(trenergy);
177 if (etait == (*libit).second.end()) --etait;
178 else if (etait != (*libit).second.begin()) {
179 etabin::const_iterator etaitch = etait;
181 if (((*etait).first - trenergy) > (trenergy - (*etaitch).first)) {
186 if (randomShift > 0) {
187 double upperEnergy = (*etait).first * 1.01;
188 for (
int i = 0;
i < randomShift;
i++) {
190 if (etait == (*libit).second.end()) {
194 if ((*etait).first > upperEnergy)
break;
197 if ((randomShift < 0)&&(etait != (*libit).second.begin())) {
198 double lowerEnergy = (*etait).first * 0.99;
199 for (
int i = 0;
i > randomShift;
i--) {
201 if (etait == (*libit).second.begin()) {
205 if (lowerEnergy > (*etait).first)
break;
210 std::vector<EnergySpot>* outshower =
new std::vector<EnergySpot>();
211 Shower::const_iterator iter;
214 float energyScale =
track->GetKineticEnergy() / (*etait).first;
217 for (iter = (*etait).second.begin() ; iter != (*etait).second.end() ; ++iter) {
218 EnergySpot tmp( (*iter)->GetPosition(), (*iter)->GetEnergy(), (*iter)->GetTime() );
219 tmp.SetEnergy(
tmp.GetEnergy() * energyScale);
220 outshower->push_back(
tmp);
224 if (
stats !=
nullptr) {
◆ particle_id()
int ShowerLib::IShowerLib::particle_id |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ physicsList() [1/2]
const std::string ShowerLib::IShowerLib::physicsList |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ physicsList() [2/2]
void ShowerLib::IShowerLib::physicsList |
( |
const std::string & |
list | ) |
|
|
inlinevirtualinherited |
◆ printParameters()
virtual const std::string ShowerLib::EtaEnergyShowerLib::printParameters |
( |
| ) |
const |
|
inlineprotectedvirtual |
◆ read()
bool ShowerLib::EtaEnergyShowerLib::read |
( |
TTree * |
source | ) |
|
|
private |
read library from given TTree
Definition at line 410 of file EtaEnergyShowerLib.cxx.
424 int nentr =
source->GetEntriesFast();
425 if (nentr < 3)
return false;
427 source->SetBranchAddress(
"x",&
x);
428 source->SetBranchAddress(
"y",&
y);
429 source->SetBranchAddress(
"z",&
z);
430 source->SetBranchAddress(
"e",&
e);
431 source->SetBranchAddress(
"time",&time);
437 int nsh = (
int)(
x+0.1);
442 for(
int i = 0;
i < nsh;
i++) {
445 int nhits = (
int)(
x+0.1);
447 Shower * shower = &((*curbin)[curEnergy]);
450 for(
int j = 0; j < nhits; j++) {
452 shower->push_back(
new ShowerEnergySpot(G4ThreeVector(
x,
y,
z),
e,
time));
455 }
while (entr < nentr);
◆ readFromROOTFile()
IShowerLib * ShowerLib::EtaEnergyShowerLib::readFromROOTFile |
( |
TFile * |
source | ) |
|
|
static |
factory method. create a library from root file. returns NULL if file is invalid.
Definition at line 36 of file EtaEnergyShowerLib.cxx.
39 ver = (TParameter<int>*)
source->Get(
"version");
43 TTree* TTreeMeta = (TTree*)
source->Get(
"meta");
44 TTree* TTreeLib = (TTree*)
source->Get(
"library");
46 if ((TTreeMeta ==
nullptr) || (TTreeLib ==
nullptr))
return nullptr;
48 std::cout <<
"EtaEnergyShowerLib header found." << std::endl;
52 if (!(newlib->readMeta(TTreeMeta)) || !(newlib->read(TTreeLib))) {
54 std::cout <<
"EtaEnergyShowerLib read unsuccessful." << std::endl;
◆ readMeta()
bool ShowerLib::IShowerLib::readMeta |
( |
TTree * |
source | ) |
|
|
protectedinherited |
read metadata from the given TTree
Definition at line 16 of file IShowerLib.cxx.
27 source->SetBranchAddress(
"geantVersion",&geant);
28 source->SetBranchAddress(
"physicsList",&physics);
◆ readStructure()
bool ShowerLib::EtaEnergyShowerLib::readStructure |
( |
std::vector< float > & |
structure | ) |
|
|
private |
Definition at line 516 of file EtaEnergyShowerLib.cxx.
518 std::vector<float>::const_iterator iter;
520 for (iter = structure.begin(); iter != structure.end(); ++iter) {
◆ release() [1/2]
const std::string ShowerLib::IShowerLib::release |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ release() [2/2]
void ShowerLib::IShowerLib::release |
( |
const std::string & |
release | ) |
|
|
inlinevirtualinherited |
◆ statistics()
const std::string ShowerLib::IShowerLib::statistics |
( |
| ) |
const |
|
inherited |
print library statistics
Definition at line 71 of file IShowerLib.cxx.
74 std::stringstream
out;
76 out <<
"======================================================" << std::endl;
77 out <<
" Statistics of the shower library " << std::endl;
78 out <<
"======================================================" << std::endl;
86 std::stringstream
out;
◆ storeShower()
store shower in the library
Implements ShowerLib::IShowerLib.
Definition at line 359 of file EtaEnergyShowerLib.cxx.
362 std::cout <<
"ERROR: filled" << std::endl;
366 double eta = genParticle->production_vertex()->position().eta();
371 std::cout <<
"ERROR: eta is outside: " <<
m_mineta <<
" << " <<
m_maxeta <<
" : " <<
eta << std::endl;
375 std::cout <<
"ERROR: wrong pdgcode: " <<
m_particle <<
" != " << genParticle->pdg_id() << std::endl;
382 std::cout <<
"Something is wrong with eta: mineta=" <<
m_mineta <<
" eta=" <<
eta << std::endl;
386 (*libit).second.insert(etabin::value_type(genParticle->momentum().e(),(*shower)));
◆ write()
bool ShowerLib::EtaEnergyShowerLib::write |
( |
TTree * |
dest | ) |
const |
|
private |
write library to given TTree
Definition at line 467 of file EtaEnergyShowerLib.cxx.
482 dest->Branch(
"x",&
x);
483 dest->Branch(
"y",&
y);
484 dest->Branch(
"z",&
z);
485 dest->Branch(
"e",&
e);
486 dest->Branch(
"time",&time);
487 library::const_iterator libit;
489 x = (*libit).second.size();
494 etabin::const_iterator etait;
495 for (etait = (*libit).second.begin(); etait != (*libit).second.end(); ++etait) {
496 x = (*etait).second.size();
497 y = (*etait).second.getRSize();
498 z = (*etait).second.getZSize();
501 Shower::const_iterator iter;
502 for (iter = (*etait).second.begin(); iter != (*etait).second.end(); ++iter) {
503 x = (*iter)->GetPosition().x();
504 y = (*iter)->GetPosition().y();
505 z = (*iter)->GetPosition().z();
506 e = (*iter)->GetEnergy();
507 time = (*iter)->GetTime();
◆ writeMeta()
bool ShowerLib::IShowerLib::writeMeta |
( |
TTree * |
dest | ) |
const |
|
protectedinherited |
write metadata to the given TTree
Definition at line 40 of file IShowerLib.cxx.
64 source->Branch(
"geantVersion",&geant,
"geantVersion/C");
65 source->Branch(
"physicsList",&physics,
"physicsList/C");
◆ writeToROOT()
bool ShowerLib::EtaEnergyShowerLib::writeToROOT |
( |
TFile * |
dest | ) |
|
|
virtual |
◆ m_comment
std::string ShowerLib::IShowerLib::m_comment |
|
protectedinherited |
◆ m_detector
std::string ShowerLib::IShowerLib::m_detector |
|
protectedinherited |
◆ m_filled
bool ShowerLib::IShowerLib::m_filled |
|
protectedinherited |
is the library read from ROOT or from structure file
Definition at line 114 of file IShowerLib.h.
◆ m_geantVersion
std::string ShowerLib::IShowerLib::m_geantVersion |
|
protectedinherited |
◆ m_geometry
std::string ShowerLib::IShowerLib::m_geometry |
|
protectedinherited |
◆ m_libData
library ShowerLib::EtaEnergyShowerLib::m_libData |
|
private |
◆ m_maxeta
float ShowerLib::EtaEnergyShowerLib::m_maxeta |
|
private |
◆ m_mineta
float ShowerLib::EtaEnergyShowerLib::m_mineta |
|
private |
◆ m_onlyPositive
bool ShowerLib::EtaEnergyShowerLib::m_onlyPositive |
|
private |
◆ m_particle
int ShowerLib::IShowerLib::m_particle |
|
protectedinherited |
ID of the generated particles.
Definition at line 107 of file IShowerLib.h.
◆ m_physicsList
std::string ShowerLib::IShowerLib::m_physicsList |
|
protectedinherited |
◆ m_release
std::string ShowerLib::IShowerLib::m_release |
|
protectedinherited |
The documentation for this class was generated from the following files:
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses