Class for shower library shower lib.
More...
#include <FCALDistEnergyShowerLib.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: FCALDistEnergyShowerLib.h 769594 2016-08-23 13:48:34Z ssnyder $
Definition at line 36 of file FCALDistEnergyShowerLib.h.
◆ distbin
◆ library
◆ ~FCALDistEnergyShowerLib()
virtual ShowerLib::FCALDistEnergyShowerLib::~FCALDistEnergyShowerLib |
( |
| ) |
|
|
inlinevirtual |
default destructor
Definition at line 47 of file FCALDistEnergyShowerLib.h.
50 for (
auto& ene : dist.second ) {
51 for (
auto& spot : ene.second ) {
◆ FCALDistEnergyShowerLib()
ShowerLib::FCALDistEnergyShowerLib::FCALDistEnergyShowerLib |
( |
| ) |
|
|
inlineprivate |
◆ addComment()
void ShowerLib::IShowerLib::addComment |
( |
const std::string & |
comment | ) |
|
|
inlinevirtualinherited |
◆ 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::FCALDistEnergyShowerLib::createEmptyLib |
( |
const std::string & |
inputFile | ) |
|
|
static |
factory method. create empty library with the given structure. returns NULL if file is invalid.
Definition at line 79 of file FCALDistEnergyShowerLib.cxx.
96 std::ifstream filestr(
inputFile.c_str(),std::ios::in);
99 if (!filestr.is_open()) {
100 std::cout <<
"FCALDistEnergyShowerLib " <<
inputFile <<
": bad file!" << std::endl;
105 std::getline(filestr,instr);
106 std::stringstream
ss(instr);
122 std::vector<float> etalist;
130 std::cout <<
"file reading failed! (not enough data)" << std::endl;
136 std::cout <<
"no negative dists allowed (" <<
eta <<
")" << std::endl;
139 etalist.push_back(0.);
142 etalist.push_back(eta);
147 if ((
ss.fail()) || (eta <= etaold)) {
148 std::cout <<
"screwed dists! (" <<
eta <<
"<=" << etaold <<
")" << std::endl;
152 etalist.push_back(eta);
153 }
else if (eta > 4.5) {
154 std::cout <<
"dist can't be bigger than 4.5 (" <<
eta <<
"). ignored" << std::endl;
162 if (!newlib->readStructure(etalist)) {
163 std::cout <<
"this structure is not valid" << std::endl;
168 newlib->m_detector =
det;
169 newlib->m_particle =
part;
171 newlib->m_filled =
false;
173 std::getline(filestr,instr);
174 std::stringstream ss1(instr);
176 ss1 >> (newlib->m_xrodcent) >> (newlib->m_yrodcent) >> (newlib->m_step);
178 std::getline(filestr,instr);
179 newlib->m_comment = instr;
◆ createStatistics()
Implements ShowerLib::IShowerLib.
Definition at line 632 of file FCALDistEnergyShowerLib.cxx.
634 std::map<int, std::string>
names;
635 std::map<int, int> sizes;
638 float distlow =
it->first;
640 library::const_iterator it_copy =
it;
645 disthigh = it_copy->first;
647 std::stringstream
ss;
648 ss << std::showpos << std::fixed << std::setprecision(2);
649 ss <<
"DIST: " << distlow <<
" .. " << disthigh;
652 return new ShowerLibStatistics(
names, sizes);
◆ detector()
const std::string ShowerLib::IShowerLib::detector |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ distance()
float ShowerLib::FCALDistEnergyShowerLib::distance |
( |
double |
x, |
|
|
double |
y |
|
) |
| const |
|
private |
◆ 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::FCALDistEnergyShowerLib::getContainmentR |
( |
const G4Track * |
track | ) |
const |
|
virtual |
get average lateral spread of the showers for the given energy
Implements ShowerLib::IShowerLib.
Definition at line 361 of file FCALDistEnergyShowerLib.cxx.
364 std::cout <<
"Library is not created for production use" << std::endl;
370 double x =
track->GetPosition().getX();
371 double y =
track->GetPosition().getY();
375 G4int particleCode =
track->GetDefinition()->GetPDGEncoding();
376 if ( particleCode < 0 ) particleCode = -particleCode;
379 std::cout <<
"wrong particle: " << particleCode <<
"!=" <<
m_particle << std::endl;
383 library::const_iterator libit =
m_libData.upper_bound(dist);
387 std::cout <<
"Something is wrong with dist: x=" <<
x <<
" y=" <<
y <<
" dist=" << dist << std::endl;
394 if ((*libit).second.empty()) {
395 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
398 double trenergy =
track->GetKineticEnergy();
400 distbin::const_iterator distit = (*libit).second.lower_bound(trenergy);
401 if (distit == (*libit).second.end()) --distit;
402 else if (distit != (*libit).second.begin()) {
403 distbin::const_iterator distitch = distit;
405 if (((*distit).first - trenergy) > (trenergy - (*distitch).first)) {
410 double rezR = (*distit).second.getRSize();
411 distbin::const_iterator distiter = distit;
414 double upperEnergy = (*distit).first * 1.01;
415 for (
int i = 0;
i < spread;
i++) {
417 if (distiter == (*libit).second.end()) {
420 if (upperEnergy < (*distiter).first)
break;
422 rezR += (*distiter).second.getRSize();
426 if (distiter != (*libit).second.begin()) {
427 double lowerEnergy = (*distit).first * 0.99;
428 for (
int i = 0;
i < spread;
i++) {
430 if (lowerEnergy > (*distiter).first)
break;
432 rezR += (*distiter).second.getRSize();
434 if (distiter == (*libit).second.begin()) {
439 return rezR/actualNumFS;
◆ getContainmentZ()
double ShowerLib::FCALDistEnergyShowerLib::getContainmentZ |
( |
const G4Track * |
track | ) |
const |
|
virtual |
get average length of showers for the given energy
Implements ShowerLib::IShowerLib.
Definition at line 280 of file FCALDistEnergyShowerLib.cxx.
283 std::cout <<
"Library is not created for production use" << std::endl;
289 double x =
track->GetPosition().getX();
290 double y =
track->GetPosition().getY();
294 G4int particleCode =
track->GetDefinition()->GetPDGEncoding();
295 if ( particleCode < 0 ) particleCode = -particleCode;
298 std::cout <<
"wrong particle: " << particleCode <<
"!=" <<
m_particle << std::endl;
302 library::const_iterator libit =
m_libData.upper_bound(dist);
306 std::cout <<
"Something is wrong with dist: x=" <<
x <<
" y=" <<
y <<
" dist=" << dist << std::endl;
313 if ((*libit).second.empty()) {
314 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
317 double trenergy =
track->GetKineticEnergy();
319 distbin::const_iterator distit = (*libit).second.lower_bound(trenergy);
320 if (distit == (*libit).second.end()) --distit;
321 else if (distit != (*libit).second.begin()) {
322 distbin::const_iterator distitch = distit;
324 if (((*distit).first - trenergy) > (trenergy - (*distitch).first)) {
329 double rezZ = (*distit).second.getZSize();
330 distbin::const_iterator distiter = distit;
333 double upperEnergy = (*distit).first * 1.01;
334 for (
int i = 0;
i < spread;
i++) {
336 if (distiter == (*libit).second.end()) {
339 if (upperEnergy < (*distiter).first)
break;
341 rezZ += (*distiter).second.getZSize();
345 if (distiter != (*libit).second.begin()) {
346 double lowerEnergy = (*distit).first * 0.99;
347 for (
int i = 0;
i < spread;
i++) {
349 if (lowerEnergy > (*distiter).first)
break;
351 rezZ += (*distiter).second.getZSize();
353 if (distiter == (*libit).second.begin()) {
358 return rezZ/actualNumFS;
◆ getName()
virtual const std::string ShowerLib::FCALDistEnergyShowerLib::getName |
( |
| ) |
const |
|
inlinevirtual |
◆ getShower()
get shower for given G4 track
Implements ShowerLib::IShowerLib.
Definition at line 184 of file FCALDistEnergyShowerLib.cxx.
187 std::cout <<
"Library is not created for production use" << std::endl;
193 double x =
track->GetPosition().getX();
194 double y =
track->GetPosition().getY();
198 G4int particleCode =
track->GetDefinition()->GetPDGEncoding();
199 if ( particleCode < 0 ) particleCode = -particleCode;
202 std::cout <<
"wrong particle: " << particleCode <<
"!=" <<
m_particle << std::endl;
208 library::const_iterator libit =
m_libData.upper_bound(dist);
212 std::cout <<
"Something is wrong with dist: x=" <<
x <<
" y=" <<
y <<
" dist=" << dist << std::endl;
219 if ((*libit).second.empty()) {
220 std::cout <<
"The etabin corresponding to the eta is empty" << std::endl;
223 double trenergy =
track->GetKineticEnergy();
225 distbin::const_iterator distit = (*libit).second.lower_bound(trenergy);
226 if (distit == (*libit).second.end()) --distit;
227 else if (distit != (*libit).second.begin()) {
228 distbin::const_iterator distitch = distit;
230 if (((*distit).first - trenergy) > (trenergy - (*distitch).first)) {
235 if (randomShift > 0) {
236 double upperEnergy = (*distit).first * 1.01;
237 for (
int i = 0;
i < randomShift;
i++) {
239 if (distit == (*libit).second.end()) {
243 if ((*distit).first > upperEnergy)
break;
246 if ((randomShift < 0)&&(distit != (*libit).second.begin())) {
247 double lowerEnergy = (*distit).first * 0.99;
248 for (
int i = 0;
i > randomShift;
i--) {
250 if (distit == (*libit).second.begin()) {
254 if (lowerEnergy > (*distit).first)
break;
259 std::vector<EnergySpot>* outshower =
new std::vector<EnergySpot>();
260 Shower::const_iterator iter;
263 float energyScale =
track->GetKineticEnergy() / (*distit).first;
266 for (iter = (*distit).second.begin() ; iter != (*distit).second.end() ; ++iter) {
267 EnergySpot tmp( (*iter)->GetPosition(), (*iter)->GetEnergy(), (*iter)->GetTime() );
268 tmp.SetEnergy(
tmp.GetEnergy() * energyScale);
269 outshower->push_back(
tmp);
273 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()
const std::string ShowerLib::FCALDistEnergyShowerLib::printParameters |
( |
| ) |
const |
|
protectedvirtual |
◆ read()
bool ShowerLib::FCALDistEnergyShowerLib::read |
( |
TTree * |
source | ) |
|
|
private |
read library from given TTree
Definition at line 490 of file FCALDistEnergyShowerLib.cxx.
507 int nentr =
source->GetEntriesFast();
508 if (nentr < 3)
return false;
510 source->SetBranchAddress(
"x",&
x);
511 source->SetBranchAddress(
"y",&
y);
512 source->SetBranchAddress(
"z",&
z);
513 source->SetBranchAddress(
"e",&
e);
514 source->SetBranchAddress(
"time",&time);
525 int nsh = (
int)(
x+0.1);
528 for(
int i = 0;
i < nsh;
i++) {
531 int nhits = (
int)(
x+0.1);
533 Shower * shower = &((*curbin)[curEnergy]);
536 for(
int j = 0; j < nhits; j++) {
538 shower->push_back(
new ShowerEnergySpot(G4ThreeVector(
x,
y,
z),
e,
time));
541 }
while (entr < nentr);
◆ readFromROOTFile()
IShowerLib * ShowerLib::FCALDistEnergyShowerLib::readFromROOTFile |
( |
TFile * |
source | ) |
|
|
static |
factory method. create a library from root file. returns NULL if file is invalid.
Definition at line 53 of file FCALDistEnergyShowerLib.cxx.
56 ver = (TParameter<int>*)
source->Get(
"version");
60 TTree* TTreeMeta = (TTree*)
source->Get(
"meta");
61 TTree* TTreeLib = (TTree*)
source->Get(
"library");
63 if ((TTreeMeta ==
nullptr) || (TTreeLib ==
nullptr))
return nullptr;
65 std::cout <<
"FCALDistEnergyShowerLib header found." << std::endl;
69 if (!(newlib->readMeta(TTreeMeta)) || !(newlib->read(TTreeLib))) {
71 std::cout <<
"FCALDistEnergyShowerLib 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::FCALDistEnergyShowerLib::readStructure |
( |
std::vector< float > & |
structure | ) |
|
|
private |
Definition at line 621 of file FCALDistEnergyShowerLib.cxx.
623 std::vector<float>::const_iterator iter;
625 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 442 of file FCALDistEnergyShowerLib.cxx.
445 std::cout <<
"ERROR: filled" << std::endl;
449 double x = genParticle->production_vertex()->position().x();
450 double y = genParticle->production_vertex()->position().y();
455 std::cout <<
"ERROR: wrong pdgcode: " <<
m_particle <<
" != " << genParticle->pdg_id() << std::endl;
462 std::cout <<
"Something is wrong with dist: x=" <<
x <<
" y=" <<
y <<
" dist=" << dist << std::endl;
466 (*libit).second.insert(distbin::value_type(genParticle->momentum().e(),(*shower)));
◆ write()
bool ShowerLib::FCALDistEnergyShowerLib::write |
( |
TTree * |
dest | ) |
const |
|
private |
write library to given TTree
Definition at line 551 of file FCALDistEnergyShowerLib.cxx.
569 dest->Branch(
"x",&
x);
570 dest->Branch(
"y",&
y);
571 dest->Branch(
"z",&
z);
572 dest->Branch(
"e",&
e);
573 dest->Branch(
"time",&time);
582 library::const_iterator libit;
584 x = (*libit).second.size();
590 distbin::const_iterator distit;
591 for (distit = (*libit).second.begin(); distit != (*libit).second.end(); ++distit) {
592 x = (*distit).second.size();
593 y = (*distit).second.getRSize();
594 z = (*distit).second.getZSize();
598 Shower::const_iterator iter;
599 for (iter = (*distit).second.begin(); iter != (*distit).second.end(); ++iter) {
600 x = (*iter)->GetPosition().x();
601 y = (*iter)->GetPosition().y();
602 z = (*iter)->GetPosition().z();
603 e = (*iter)->GetEnergy();
604 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::FCALDistEnergyShowerLib::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::FCALDistEnergyShowerLib::m_libData |
|
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 |
◆ m_step
double ShowerLib::FCALDistEnergyShowerLib::m_step |
|
private |
◆ m_xrodcent
double ShowerLib::FCALDistEnergyShowerLib::m_xrodcent |
|
private |
◆ m_yrodcent
double ShowerLib::FCALDistEnergyShowerLib::m_yrodcent |
|
private |
The documentation for this class was generated from the following files:
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses