17 #include "Randomize.hh"
25 enum DETECTOR {
EMB=100000,
EMEC=200000,
FCAL1=300000,
FCAL2=400000,FCAL3=500000,HECLOC=600000,
HEC=700000};
40 std::vector<std::string> ignoredLibraryFiles{};
44 if (resolvedFilename.empty()) {
46 ignoredLibraryFiles.push_back(
fileName);
49 ATH_MSG_INFO(
"Resolving input filename to " << resolvedFilename);
52 TFile
rootfile(resolvedFilename.c_str(),
"READ");
55 ATH_MSG_WARNING(
"File " << resolvedFilename <<
" is not a valid ROOT file");
56 ignoredLibraryFiles.push_back(
fileName);
66 if (library ==
nullptr) {
67 ATH_MSG_WARNING(
"File " << resolvedFilename <<
" is not a valid library file");
68 ignoredLibraryFiles.push_back(
fileName);
73 ATH_MSG_WARNING(
"Library " << resolvedFilename <<
" is produced for unknown detector: " << library->
detector());
74 ignoredLibraryFiles.push_back(
fileName);
79 std::stringstream location;
96 ATH_MSG_ERROR(
"No library files found. Please check the configuration of this job.");
97 return StatusCode::FAILURE;
100 if (!ignoredLibraryFiles.empty() ) {
101 for (
const std::string&
fileName : ignoredLibraryFiles) {
104 ATH_MSG_ERROR(
"Some library filenames were invalid. Please check the configuration of this job.");
105 return StatusCode::FAILURE;
110 #ifdef DEBUG_FrozenShowers
114 ATH_MSG_INFO(
"Shower library successfully initialized.");
116 return StatusCode::SUCCESS;
124 libmap::const_iterator
iter;
128 ATH_MSG_INFO(std::endl << (*iter).second->statistics());
132 ATH_MSG_INFO(
"No statistics available for this kind of library");
134 delete (*iter).second ;
137 return StatusCode::SUCCESS;
148 location = detectorTag + particleCode;
152 return (*iter).second;
162 if (library !=
nullptr)
return true;
172 #ifdef DEBUG_FrozenShowers
173 std::vector<EnergySpot>
176 std::vector<EnergySpot>
183 if (library ==
nullptr) {
185 ATH_MSG_ERROR(
"No library for location: " << detectorTag <<
"/" <<
track.GetPrimaryTrack()->GetDefinition()->GetPDGEncoding());
186 return std::vector<EnergySpot>();
190 G4ThreeVector PositionShower =
track.GetPrimaryTrack()->GetPosition();
194 randomShift = (
int)(CLHEP::RandGaussZiggurat::shoot(G4Random::getTheEngine(), 0., 2.5)+0.5);
196 #ifdef DEBUG_FrozenShowers
197 std::vector<EnergySpot>* shower = library->
getShower(
track.GetPrimaryTrack(), m_statisticsMap[library], randomShift);
199 std::vector<EnergySpot>* shower = library->
getShower(
track.GetPrimaryTrack(),
nullptr, randomShift);
203 if (shower ==
nullptr) {
204 return std::vector<EnergySpot>();
208 G4ThreeVector DirectionShower =
track.GetPrimaryTrack()->GetMomentumDirection();
211 G4double tof =
track.GetPrimaryTrack()->GetGlobalTime() /
Units::ns;
217 for (hit = shower->begin(); hit != shower->end(); ++hit) {
218 G4ThreeVector hitpos = (*hit).GetPosition();
219 hitpos.rotateUz(DirectionShower);
220 (*hit).SetPosition(hitpos+PositionShower);
221 (*hit).SetTime((*hit).GetTime() +
time);
226 for (std::vector<EnergySpot>::const_iterator
iter = shower->begin();
iter != shower->end(); ++
iter) {
228 <<
" " <<
iter->GetEnergy() <<
" " <<
iter->GetTime());
232 return *std::unique_ptr< std::vector<EnergySpot> >(shower);
241 if (library ==
nullptr) {
254 if (library ==
nullptr) {