29#include "HepPDT/ParticleDataTable.hh"
33#include "CLHEP/Random/RandFlat.h"
66 const std::string& name,
67 const IInterface* parent )
68: base_class(
type, name, parent)
85 return StatusCode::FAILURE;
90 if (resolvedFileName.empty()) {
92 return StatusCode::FAILURE;
94 ATH_MSG_INFO(
"[ punchthrough ] Parametrisation file found: " << resolvedFileName );
99 ATH_MSG_WARNING(
"[ punchthrough ] unable to open the lookup-table for the punch-through simulation (file does not exist)");
100 return StatusCode::FAILURE;
104 ATH_MSG_WARNING(
"[ punchthrough ] unable to open the lookup-table for the punch-through simulation (wrong or empty file?)");
105 return StatusCode::FAILURE;
111 ATH_MSG_WARNING(
"[ punchthrough ] unable to open or read the inverse CDF config");
112 return StatusCode::FAILURE;
118 ATH_MSG_WARNING(
"[ punchthrough ] unable to open or read the inverse PCA config");
119 return StatusCode::FAILURE;
125 ATH_MSG_WARNING(
"[ punchthrough ] size of infoMap for PCA and CDF differs! Something is wrong with input xml files.");
126 return StatusCode::FAILURE;
136 ATH_MSG_FATAL(
" [ punchthrough ] Could not get ParticleDataTable! Cannot associate pdg code with charge! Abort. " );
137 return StatusCode::FAILURE;
143 ATH_MSG_FATAL (
"[ punchthrough ] Could not retrieve GeometryIdentifier Service. Abort");
144 return StatusCode::FAILURE;
151 return StatusCode::FAILURE;
175 ATH_MSG_VERBOSE(
"[ punchthrough ] registering punch-through particle type with pdg = " << pdg );
176 if (
registerParticle( pdg, doAnti, minEnergy, maxNum, numFactor, energyFactor, posAngleFactor, momAngleFactor )
177 != StatusCode::SUCCESS)
179 ATH_MSG_ERROR(
"[ punchthrough ] unable to register punch-through particle type with pdg = " << pdg);
190 ATH_MSG_WARNING(
"[ punchthrough ] more punch-through particle correlations are given, than punch-through particle types are registered (skipping the last ones)");
195 for (
unsigned int num = 0; num < numCorrelations; num++ )
203 if ( ! pdg2)
continue;
205 if (
registerCorrelation(pdg1, pdg2, minCorrEnergy, fullCorrEnergy) != StatusCode::SUCCESS )
207 ATH_MSG_ERROR(
"[ punchthrough ] unable to register punch-through particle correlation for pdg1=" << pdg1 <<
" pdg2=" << pdg2 );
217 found1=
false; found2=
false;
219 for (
size_t i=0; i<rzCalo->size();++i)
221 const double r_tempCalo = rzCalo->at(i).first;
222 const double z_tempCalo = rzCalo->at(i).second;
226 for (
size_t j=0; j<rzMS->size();++j)
228 const double r_tempMS =rzMS->at(j).first;
229 const double z_tempMS =rzMS->at(j).second;
231 if (r_tempCalo==r_tempMS && z_tempCalo==z_tempMS && found1==
false )
234 m_z1=std::fabs(z_tempMS);
238 else if (r_tempCalo==r_tempMS && z_tempCalo==z_tempMS && r_tempCalo!=
m_R1 && std::fabs(z_tempCalo)!=
m_z1)
241 m_z2=std::fabs(z_tempMS);
246 if (found1==
true && found2==
true)
break;
251 if (found1 ==
false)
ATH_MSG_ERROR (
"first coordinate of calo-MS border not found");
252 if (found2 ==
false)
ATH_MSG_ERROR (
"second coordinate of calo-MS border not found; first one is: R1 ="<<
m_R1<<
" z1 ="<<
m_z1);
255 double r_temp, z_temp;
265 ATH_MSG_INFO(
"punchthrough initialization is successful" );
266 return StatusCode::SUCCESS;
283 return StatusCode::SUCCESS;
293 ATH_MSG_DEBUG(
"[ punchthrough ] starting punch-through simulation");
296 auto isfpCont = std::make_unique<ISF::ISFParticleVector>();
304 ATH_MSG_VERBOSE (
"[ GeoIDSvc ] input particle doesn't point to calorimeter"<<
"Next GeoID: "<<
m_geoIDSvc->identifyNextGeoID(isfp) );
316 for ( ; pdgIt != pdgItEnd; ++pdgIt, ++minEnergyIt)
318 if (std::abs(isfp.
pdgCode()) == *pdgIt){
319 if(std::sqrt( isfp.
momentum().mag2() + isfp.
mass()*isfp.
mass() ) < *minEnergyIt){
320 ATH_MSG_DEBUG(
"[ punchthrough ] particle does not meet initiator min energy requirement. Dropping it in the calo.");
328 if (pdgIt == pdgItEnd)
330 ATH_MSG_DEBUG(
"[ punchthrough ] particle is not registered as punch-through initiator. Dropping it in the calo.");
336 ATH_MSG_DEBUG(
"[ punchthrough ] particle does not meet initiator eta range requirement. Dropping it in the calo.");
344 double punchThroughClassifierRand = CLHEP::RandFlat::shoot(rndmEngine);
346 ATH_MSG_DEBUG(
"[ punchthrough ] punchThroughProbability output: " << punchThroughProbability <<
" RandFlat: " << punchThroughClassifierRand );
349 if( punchThroughClassifierRand > punchThroughProbability){
350 ATH_MSG_DEBUG(
"[ punchthrough ] particle not classified to create punch through. Dropping it in the calo.");
364 const double initEnergy = std::sqrt( isfp.
momentum().mag2() + isfp.
mass()*isfp.
mass() );
365 const double initEta = isfp.
position().eta();
371 std::map<int, int> corrPdgNumDone;
377 while(isfpCont->empty() && nTries < maxTries) {
382 int doPdg = currentParticle.first;
384 int corrPdg = currentParticle.second->getCorrelatedPdg();
390 std::map<int,int>::iterator pos = corrPdgNumDone.find(doPdg);
393 if ( pos == corrPdgNumDone.end() ) pos = corrPdgNumDone.find(corrPdg);
397 if ( pos == corrPdgNumDone.end() )
400 if ( CLHEP::RandFlat::shoot(rndmEngine) > 0.5 ) doPdg = corrPdg;
403 corrPdgNumDone[doPdg] =
getAllParticles(isfp, *isfpCont, rndmEngine, doPdg, interpEnergy, interpEta);
412 const int donePdg = pos->first;
413 const int doneNumPart = pos->second;
415 if (donePdg == doPdg) doPdg = corrPdg;
427 else getAllParticles(isfp, *isfpCont, rndmEngine, doPdg, interpEnergy, interpEta);
434 if (!isfpCont->empty())
ATH_MSG_DEBUG(
"[ punchthrough ] returning ISFparticle vector , size: "<<isfpCont->size() );
437 ATH_MSG_DEBUG(
"codes of produced punch through particle: pdg = "<< particle->pdgCode());
439 ATH_MSG_DEBUG(
"position of produced punch-through particle: x = "<< position.x() <<
" y = "<< position.y() <<
" z = "<< position.z());
441 ATH_MSG_DEBUG(
"momentum of produced punch-through particle: px = "<< momentum.x() <<
" py = "<< momentum.x() <<
" pz = "<< momentum.x() <<
" e = "<< particle->ekin() <<
" mass = " << particle->mass());
444 return isfpCont.release();
459 if ( numParticles < 0 )
462 std::vector<int> parameters;
463 parameters.push_back( std::round(interpEnergy) );
464 parameters.push_back( std::round(interpEta*100) );
467 int maxParticles = p->getMaxNumParticles();
473 numParticles = int( p->getNumParticlesPDF()->getRand(rndmEngine, parameters) );
476 numParticles = lround( numParticles *= p->getNumParticlesFactor() );
478 while ( (maxParticles >= 0.) && (numParticles > maxParticles) );
481 ATH_MSG_VERBOSE(
"[ punchthrough ] adding " << numParticles <<
" punch-through particles with pdg " << pdg);
484 double energyRest = std::sqrt( isfp.
momentum().mag2() + isfp.
mass()*isfp.
mass() );
485 double minEnergy = p->getMinEnergy();
488 for ( numCreated = 0; (numCreated < numParticles) && (energyRest > minEnergy); numCreated++ )
496 ATH_MSG_ERROR(
"[ punchthrough ] something went wrong while creating punch-through particles");
502 double curEnergy = std::sqrt(par->momentum().mag2() + restMass*restMass);
506 energyRest -= curEnergy;
509 isfpCont.push_back( par );
526 const double initEnergy = std::sqrt( isfp.
momentum().mag2() + isfp.
mass()*isfp.
mass() );
529 double rand = CLHEP::RandFlat::shoot(rndmEngine)
530 *(p->getFullCorrelationEnergy()-p->getMinCorrelationEnergy())
531 + p->getMinCorrelationEnergy();
532 if ( initEnergy < rand )
535 return getAllParticles(isfp, isfpCont, rndmEngine, pdg, interpEnergy, interpEta);
540 double *histDomains = p->getCorrelationHistDomains();
541 TH2F *hist2d =
nullptr;
544 if ( initEnergy < histDomains[1])
548 hist2d = p->getCorrelationLowEHist();
552 double rand = CLHEP::RandFlat::shoot(rndmEngine)*(histDomains[2]-histDomains[1])
554 hist2d = ( initEnergy < rand) ? p->getCorrelationLowEHist()
555 : p->getCorrelationHighEHist();
562 Int_t xbin = hist2d->GetXaxis()->FindFixBin(corrParticles);
563 int numParticles = 0;
564 int maxParticles = p->getMaxNumParticles();
569 double rand = CLHEP::RandFlat::shoot(rndmEngine);
571 for (
int ybin = 1; ybin <= hist2d->GetNbinsY(); ybin++ )
573 sum += hist2d->GetBinContent(xbin, ybin);
577 numParticles = ybin - 1;
582 numParticles = lround( numParticles * p->getNumParticlesFactor() );
584 while ( (maxParticles >= 0.) && (numParticles > maxParticles) );
587 return getAllParticles(isfp, isfpCont, rndmEngine, pdg, interpEnergy, interpEta, numParticles);
603 ATH_MSG_DEBUG(
"[ punchthrough ] passedPCAIterator ==> pcaCdfIterator = "<< pcaCdfIterator <<
" , pdg = "<< pdg <<
" , interpEnergy = "<< interpEnergy <<
" MeV, interpEta(*100) = "<< interpEta*100);
607 if ( p->getdoAnti() )
610 double rand = CLHEP::RandFlat::shoot(rndmEngine);
612 if (rand > 0.5) anti = -1;
617 std::vector<int> parInitEnergyEta;
618 parInitEnergyEta.push_back( std::round(interpEnergy) );
619 parInitEnergyEta.push_back( std::round(interpEta*100) );
623 double deltaTheta = 0.;
625 double momDeltaTheta = 0.;
626 double momDeltaPhi = 0.;
628 double principal_component_0 = 0.;
629 double principal_component_1 = 0.;
630 double principal_component_2 = 0.;
631 double principal_component_3 = 0.;
632 double principal_component_4 = 0.;
633 std::vector<double> transformed_variables;
636 principal_component_0 = p->getPCA0PDF()->getRand(rndmEngine, parInitEnergyEta);
637 principal_component_1 = p->getPCA1PDF()->getRand(rndmEngine, parInitEnergyEta);
638 principal_component_2 = p->getPCA2PDF()->getRand(rndmEngine, parInitEnergyEta);
639 principal_component_3 = p->getPCA3PDF()->getRand(rndmEngine, parInitEnergyEta);
640 principal_component_4 = p->getPCA4PDF()->getRand(rndmEngine, parInitEnergyEta);
642 ATH_MSG_DEBUG(
"Drawn punch through kinematics PCA components: PCA0 = "<< principal_component_0 <<
" PCA1 = "<< principal_component_1 <<
" PCA2 = "<< principal_component_2 <<
" PCA3 = "<< principal_component_3 <<
" PCA4 = "<< principal_component_4 );
644 std::vector<double> principal_components {
645 principal_component_0,
646 principal_component_1,
647 principal_component_2,
648 principal_component_3,
649 principal_component_4
652 transformed_variables =
inversePCA(pcaCdfIterator,principal_components);
660 ATH_MSG_DEBUG(
"Transformed punch through kinematics: energy = "<< energy <<
" MeV deltaTheta = "<< deltaTheta <<
" deltaPhi = "<<
deltaPhi <<
" momDeltaTheta = "<< momDeltaTheta <<
" momDeltaPhi = "<< momDeltaPhi );
662 energy *= p->getEnergyFactor();
663 if (energy < p->getMinEnergy()) {
664 energy = p->getMinEnergy() + 10;
674 deltaTheta *= ( CLHEP::RandFlat::shoot(rndmEngine) > 0.5 ) ? 1. : -1.;
677 theta = isfp.
position().theta() + deltaTheta*p->getPosAngleFactor();
683 deltaPhi *= ( CLHEP::RandFlat::shoot(rndmEngine) > 0.5 ) ? 1. : -1.;
695 double momTheta = 0.;
699 momDeltaTheta *= ( CLHEP::RandFlat::shoot(rndmEngine) > 0.5 ) ? 1. : -1.;
702 momTheta =
theta + momDeltaTheta*p->getMomAngleFactor();
705 while ( (momTheta >
M_PI) || (momTheta < 0.) );
709 momDeltaPhi *= ( CLHEP::RandFlat::shoot(rndmEngine) > 0.5 ) ? 1. : -1.;
711 double momPhi =
phi + momDeltaPhi*p->getMomAngleFactor();
713 while ( std::fabs(momPhi) > 2*
M_PI) momPhi /= 2.;
714 while (momPhi >
M_PI) momPhi -= 2*
M_PI;
715 while (momPhi < -
M_PI) momPhi += 2*
M_PI;
719 ATH_MSG_DEBUG(
"createExitPs input parameters: doAnti? = "<< pdg*anti <<
" energy = "<< energy <<
" theta = "<<
theta <<
" phi = "<<
phi <<
" momTheta = "<< momTheta <<
" momPhi " << momPhi );
729 return 0.5 * TMath::Erfc(-
x * M_SQRT1_2);
734 std::vector<double> result;
735 result.reserve(m.size());
736 for (
const auto&
r : m){
737 result.push_back(std::inner_product(v.begin(), v.end(),
r.begin(), 0.0));
746 constexpr char delimiters =
',';
747 std::vector<T> tokens;
749 std::string_view::size_type lastPos =
str.find_first_not_of(delimiters, 0);
751 std::string_view::size_type pos =
str.find_first_of(delimiters, lastPos);
753 while (std::string_view::npos != pos || std::string_view::npos != lastPos) {
755 std::string_view numbStr =
str.substr(lastPos, pos - lastPos);
757 std::from_chars(numbStr.data(), numbStr.data() + numbStr.size(), num);
758 tokens.push_back(num);
760 lastPos =
str.find_first_not_of(delimiters, pos);
762 pos =
str.find_first_of(delimiters, lastPos);
770 int pidStrSingle = std::abs(pid);
774 for (
int i = 0;
const InfoMap& m : mapvect) {
776 const std::vector<int>& v = m.pidStr;
777 if(std::find(v.begin(), v.end(),pidStrSingle)==v.end())
continue;
778 assert(m.etaMaxs.size() == m.etaMins.size());
779 for (
unsigned int j = 0; j < m.etaMins.size(); j++){
780 double etaMinToCompare = m.etaMins[j];
781 double etaMaxToCompare = m.etaMaxs[j];
782 if((
eta >= etaMinToCompare) && (
eta < etaMaxToCompare)){
802 std::vector<InfoMap> xml_info;
804 for (
const XMLCoreNode*
node : doc.get_children (mainNode +
"/info/item")) {
805 xml_info.emplace_back(*
node);
815 std::transform (transformed_variables.begin(), transformed_variables.end(),
m_PCA_means[pcaCdfIterator].begin(), transformed_variables.begin(), std::plus<double>());
817 return transformed_variables;
823 std::unique_ptr<XMLCoreNode> doc = p.parse (inversePCAConfigFile);
825 ATH_MSG_INFO(
"[ punchthrough ] Loading inversePCA: " << inversePCAConfigFile);
831 const std::string& attrib,
833 -> std::vector<double>
835 std::vector<double> row;
836 for (
int i = 0; i <=
imax; ++i) {
838 std::string propName = attrib + std::to_string(i);
839 row.push_back (
node->get_double_attrib (propName));
845 std::vector<std::vector<double>> PCA_matrix;
849 PCA_matrix.push_back(getRow(matrix,
"comp_", 4));
859 return StatusCode::SUCCESS;
865 std::unique_ptr<XMLCoreNode> doc = p.parse (inverseCdfConfigFile);
867 ATH_MSG_INFO(
"[ punchthrough ] Loading inverse CDF: " << inverseCdfConfigFile);
884 return StatusCode::SUCCESS;
887std::map<double, double>
890 std::map<double, double> mappings;
894 double ref = child->get_double_attrib (
"ref");
895 double quant = child->get_double_attrib (
"quant");
907 auto upper = inverse_cdf_map.upper_bound(norm_cdf);
908 auto lower =
upper--;
910 double m = (
upper->second - lower->second)/(
upper->first - lower->first);
911 double c = lower->second - m * lower->first;
912 double transformed = m * norm_cdf + c;
920 ATH_MSG_DEBUG(
"[ punchthrough ] interpolating incoming energy: " << energy);
922 std::string energyPointsString;
924 energyPointsString += std::to_string(element) +
" ";
927 ATH_MSG_DEBUG(
"[ punchthrough ] available energy points: " << energyPointsString);
932 ATH_MSG_DEBUG(
"[ punchthrough ] incoming energy > largest energy point, returning greatest energy point: " <<
m_energyPoints.back());
936 ATH_MSG_DEBUG(
"[ punchthrough ] incoming energy < smallest energy point, returning smallest energy point: " << *upperEnergy);
940 ATH_MSG_DEBUG(
"[ punchthrough ] energy points upper_bound: "<< *upperEnergy);
942 double randomShoot = CLHEP::RandFlat::shoot(rndmEngine);
944 ATH_MSG_DEBUG(
"[ punchthrough ] Shooting random number: "<< randomShoot);
946 double midPoint = *std::prev(upperEnergy)*M_SQRT2;
948 if(energy < midPoint){
950 double distance = std::abs(energy - *std::prev(upperEnergy))/((midPoint) - *std::prev(upperEnergy));
952 ATH_MSG_DEBUG(
"[ punchthrough ] incoming energy is closest to prev(upper_bound) in log(energy), distance: " << distance );
954 if(randomShoot < distance){
955 ATH_MSG_DEBUG(
"[ punchthrough ] randomShoot < distance, returning upper_bound " << *upperEnergy );
958 ATH_MSG_DEBUG(
"[ punchthrough ] randomShoot > distance, returning prev(upper_bound) " << *std::prev(upperEnergy) );
960 return *std::prev(upperEnergy);
962 else if(energy > midPoint){
964 double distance = std::abs(energy - *upperEnergy)/((*upperEnergy - midPoint));
966 ATH_MSG_DEBUG(
"[ punchthrough ] incoming energy is closest to upper_bound in log(energy), distance: " << distance );
968 if(randomShoot < distance){
969 ATH_MSG_DEBUG(
"[ punchthrough ] randomShoot < distance, returning prev(upper_bound) " << *std::prev(upperEnergy) );
970 return *std::prev(upperEnergy);
972 ATH_MSG_DEBUG(
"[ punchthrough ] randomShoot > distance, returning upper_bound " << *upperEnergy );
981 double absEta = std::abs(
eta);
983 ATH_MSG_DEBUG(
"[ punchthrough ] interpolating incoming abs(eta): " << absEta);
985 std::string etaPointsString;
987 etaPointsString += std::to_string(element) +
" ";
990 ATH_MSG_DEBUG(
"[ punchthrough ] available eta points: " << etaPointsString);
995 ATH_MSG_DEBUG(
"[ punchthrough ] incoming abs(eta) > largest eta point, returning greatest eta point: " <<
m_etaPoints.back());
1000 ATH_MSG_DEBUG(
"[ punchthrough ] eta points upper_bound: "<< *upperEta);
1002 double randomShoot = CLHEP::RandFlat::shoot(rndmEngine);
1004 ATH_MSG_DEBUG(
"[ punchthrough ] Shooting random number: "<< randomShoot);
1006 if(std::abs(absEta - *upperEta) < std::abs(absEta - *std::prev(upperEta))){
1008 double distance = std::abs(absEta - *upperEta)/((*upperEta - *std::prev(upperEta))/2);
1010 ATH_MSG_DEBUG(
"[ punchthrough ] abs(eta) is closer to eta points upper_bound, distance: " << distance );
1012 if(randomShoot > distance){
1013 ATH_MSG_DEBUG(
"[ punchthrough ] randomShoot > distance, returning upper_bound " << *upperEta );
1017 ATH_MSG_DEBUG(
"[ punchthrough ] randomShoot < distance, returning prev(upper_bound) " << *std::prev(upperEta) );
1019 return *std::prev(upperEta);
1021 else if(std::abs(absEta - *std::prev(upperEta)) < std::abs(absEta - *upperEta)){
1024 ATH_MSG_DEBUG(
"[ punchthrough ] prev of upper bound is begin, returning that: " << *std::prev(upperEta) );
1025 return *std::prev(upperEta);
1028 double distance = std::abs(absEta - *std::prev(upperEta))/((*std::prev(upperEta) - *std::prev(std::prev(upperEta)))/2);
1030 ATH_MSG_DEBUG(
"[ punchthrough ] abs(eta) is closer to eta points prev(upper_bound), distance: " << distance );
1032 if(randomShoot > distance){
1033 ATH_MSG_DEBUG(
"[ punchthrough ] randomShoot > distance, returning prev(prev(upper_bound)) " << *std::prev(std::prev(upperEta)) );
1035 return *std::prev(std::prev(upperEta));
1037 ATH_MSG_DEBUG(
"[ punchthrough ] randomShoot < distance, returning prev(upper_bound) " << *std::prev(upperEta) );
1039 return *std::prev(upperEta);
1042 return *std::prev(upperEta);
1052 double minEnergy,
int maxNumParticles,
double numParticlesFactor,
1053 double energyFactor,
double posAngleFactor,
double momAngleFactor)
1059 if (!pdf_num )
return StatusCode::FAILURE;
1065 return StatusCode::FAILURE;
1073 return StatusCode::FAILURE;
1081 return StatusCode::FAILURE;
1088 return StatusCode::FAILURE;
1095 return StatusCode::FAILURE;
1100 particle->setNumParticlesPDF(std::move(pdf_num));
1101 particle->setPCA0PDF(std::move(pdf_pca0));
1102 particle->setPCA1PDF(std::move(pdf_pca1));
1103 particle->setPCA2PDF(std::move(pdf_pca2));
1104 particle->setPCA3PDF(std::move(pdf_pca3));
1105 particle->setPCA4PDF(std::move(pdf_pca4));
1109 minEnergy = ( minEnergy > restMass ) ? minEnergy : restMass;
1110 particle->setMinEnergy(minEnergy);
1111 particle->setMaxNumParticles(maxNumParticles);
1112 particle->setNumParticlesFactor(numParticlesFactor);
1113 particle->setEnergyFactor(energyFactor);
1114 particle->setPosAngleFactor(posAngleFactor);
1115 particle->setMomAngleFactor(momAngleFactor);
1120 return StatusCode::SUCCESS;
1129 double minCorrEnergy,
double fullCorrEnergy)
1132 std::map<int, PunchThroughParticle*>::iterator location1 =
m_particles.find(pdgID1);
1133 std::map<int, PunchThroughParticle*>::iterator location2 =
m_particles.find(pdgID2);
1137 return StatusCode::FAILURE;
1140 std::stringstream name;
1141 name <<
"NumExitCorrelations/x_PDG" << std::abs(pdgID1) <<
"__y_PDG" << std::abs(pdgID2) <<
"__lowE";
1144 name <<
"NumExitCorrelations/x_PDG" << std::abs(pdgID1) <<
"__y_PDG" << std::abs(pdgID2) <<
"__highE";
1147 name <<
"NumExitCorrelations/x_PDG" << std::abs(pdgID2) <<
"__y_PDG" << std::abs(pdgID1) <<
"__lowE";
1150 name <<
"NumExitCorrelations/x_PDG" << std::abs(pdgID2) <<
"__y_PDG" << std::abs(pdgID1) <<
"__highE";
1153 if ( (!hist1_2_lowE) || (!hist2_1_lowE) || (!hist1_2_highE) || (!hist2_1_highE) )
1155 ATH_MSG_ERROR(
"[ punchthrough ] unable to retrieve the correlation data for PDG IDs " << pdgID1 <<
" and " << pdgID2);
1156 return StatusCode::FAILURE;
1168 m_particles[pdgID1]->setCorrelation(pdgID2, hist2_1_lowE, hist2_1_highE,
1169 minCorrEnergy, fullCorrEnergy,
1170 lowE, midE, upperE);
1172 m_particles[pdgID2]->setCorrelation(pdgID1, hist1_2_lowE, hist1_2_highE,
1173 minCorrEnergy, fullCorrEnergy,
1174 lowE, midE, upperE);
1175 return StatusCode::SUCCESS;
1190 std::unique_ptr<ISF::PDFcreator> pdf = std::make_unique<ISF::PDFcreator>();
1193 std::stringstream dirName;
1194 dirName << folderName << pdg;
1195 pdf->setName(dirName.str().c_str());
1200 ATH_MSG_ERROR(
"[ punchthrough ] unable to retrieve directory object ("<< folderName << pdg <<
")" );
1207 TIter keyList(dir->GetListOfKeys());
1210 while ((key = (TKey*)keyList())) {
1213 TH1* hist =
nullptr;
1215 std::string histName;
1216 if(strcmp(key->GetClassName(),
"TH1F") == 0){
1217 hist = (TH1*)key->ReadObj();
1218 histName = hist->GetName();
1222 std::string strEnergy = histName.substr( histName.find_first_of(
'E') + 1, histName.find_first_of(
'_')-histName.find_first_of(
'E') - 1 );
1223 histName.erase(0, histName.find_first_of(
'_') + 1);
1224 std::string strEtaMin = histName.substr( histName.find(
"etaMin") + 6, histName.find_first_of(
'_') - histName.find(
"etaMin") - 6 );
1225 histName.erase(0, histName.find(
'_') + 1);
1226 std::string strEtaMax = histName.substr( histName.find(
"etaMax") + 6, histName.length());
1229 const int energy = std::stoi(strEnergy);
1230 const int etaMin = std::stoi(strEtaMin);
1233 pdf->addToEnergyEtaHist1DMap(energy, etaMin, hist);
1236 const double energyDbl =
static_cast<double>(energy);
1237 const double etaDbl =
static_cast<double>(etaMin)/100.;
1260 double energy,
double theta,
double phi,
double momTheta,
double momPhi)
const
1273 Amg::setRThetaPhi( mom, std::sqrt(energy*energy - mass*mass), momTheta, momPhi);
1274 ATH_MSG_DEBUG(
"setRThetaPhi pre input parameters: energy = "<< energy <<
" mass = "<< mass);
1275 ATH_MSG_DEBUG(
"setRThetaPhi input parameters: std::sqrt(energy*energy - mass*mass) = "<< std::sqrt(energy*energy - mass*mass) <<
" momTheta = "<< momTheta <<
" momPhi = "<< momPhi);
1280 charge *= (pdg > 0.) ? 1. : -1.;
1282 const double pTime = 0;
1303 const std::string_view
str( cstr);
1304 const std::string_view pattern( cpattern);
1305 const size_t pos =
str.find(pattern);
1307 if ( pos == std::string::npos)
1309 ATH_MSG_WARNING(
"[ punchthrough ] unable to retrieve floating point number from string");
1310 return -999999999999.;
1312 const std::string_view substring =
str.substr(pos+pattern.length());
1313 std::from_chars(substring.data(), substring.data() + substring.size(), num);
1326 const double theta1 = atan (
m_R1/
m_z1);
1327 const double theta2 = atan (
m_R1/
m_z2);
1328 const double theta3 = atan (
m_R2/
m_z2);
1346 else if (
theta >= theta3 &&
theta < (TMath::Pi()-theta3) )
1351 else if (
theta >= (TMath::Pi()-theta3) &&
theta < (TMath::Pi()-theta2) )
1356 else if (
theta >= (TMath::Pi()-theta2) &&
theta < (TMath::Pi()-theta1) )
1361 else if (
theta >= (TMath::Pi()-theta1) &&
theta <= TMath::Pi() )
1370 ATH_MSG_WARNING (
"Given theta angle is incorrect, setting particle position to (0, 0, 0)");
1371 x = 0.0;
y = 0.0;
z = 0.0;
r = 0.0;
1378 ATH_MSG_DEBUG(
"position of produced punch-through particle: x = "<<
x <<
" y = "<<
y <<
" z = "<<
z<<
" r = "<< pos.perp() <<
"std::sqrt(x^2+y^2) = "<< std::sqrt(
x*
x+
y*
y) );
const boost::regex ref(r_ef)
Scalar eta() const
pseudorapidity method
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
An STL vector of pointers that by default owns its pointed-to elements.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
std::vector< RZPair > RZPairVector
Simple DOM-like node structure to hold the result of XML parsing.
The generic ISF particle definition,.
const Amg::Vector3D & momentum() const
The current momentum vector of the ISFParticle.
void setNextGeoID(AtlasDetDescr::AtlasRegion geoID)
register the next AtlasDetDescr::AtlasRegion
const Amg::Vector3D & position() const
The current position of the ISFParticle.
int pdgCode() const
PDG value.
double mass() const
mass of the particle
This class holds information for different properties of a punch-through particle (energy,...
Simple DOM-like node structure to hold the result of XML parsing.
void setRThetaPhi(Amg::Vector3D &v, double r, double theta, double phi)
sets radius, the theta and phi angle of a vector.
Eigen::Matrix< double, 3, 1 > Vector3D
constexpr int UNDEFINED_ID
constexpr int SIM_STATUS_THRESHOLD
Constant definiting the status threshold for simulated particles, eg. can be used to separate generat...
std::vector< ISF::ISFParticle * > ISFParticleVector
ISFParticle vector.