72 std::vector<std::pair<int, float> >(1, std::pair<int, float>(0, 0.));
81 : mySimEvent(aSimEvent),
83 theMuonEcalEffects(nullptr),
84 theMuonHcalEffects(nullptr),
85 bFixedLength_(
false) {
116 if (fastCalo.
exists(
"ECALResponseScaling")) {
151 std::vector<unsigned int>::const_iterator itcheck =
177 <<
" WARNING: The preshower simulation has been turned on; but no preshower geometry is available "
179 edm::LogWarning(
"CalorimetryManager") <<
" Disabling the preshower simulation " << std::endl;
192 LogInfo(
"FastCalorimetry") <<
" ===> pid = " << pid << std::endl;
199 if (pid == 11 || pid == 22) {
211 else if (pid == 13 || pid == 1000024 || (pid > 1000100 && pid < 1999999 && fabs(charge_) > 0.001)) {
217 else if (pid < 1000000) {
230 std::vector<const RawParticle*> thePart;
234 LogInfo(
"FastCalorimetry") <<
" EMShowerSimulation " << myTrack << std::endl;
245 int onEcal = myTrack.
onEcal();
246 int onHcal = myTrack.
onHcal();
256 XYZPoint layer1entrance, layer2entrance;
282 if (myTrack.
type() == 22) {
287 double eMass = 0.000510998902;
294 xe = random->
flatShoot() * (1. - 2. * xm) + xm;
295 weight = 1. - 4. / 3. * xe * (1. - xe);
296 }
while (weight < random->flatShoot());
301 thePart.push_back(&
myPart);
308 thePart.push_back(&
myElec);
309 thePart.push_back(&
myPosi);
315 thePart.push_back(&
myPart);
319 if (thePart.empty()) {
320 if (myPreshower ==
nullptr)
328 for (
unsigned ip = 0; ip < thePart.size(); ++ip)
349 if (pivot.subdetId() == 0) {
351 <<
"Pivot for egamma e = " << myTrack.
hcalEntrance().
e() <<
" is not found at depth " <<
depth
352 <<
" and meanShower coordinates = " << meanShower << std::endl;
385 if (myTrack.
onEcal() == 2)
387 if ((onLayer1 || onLayer2) &&
myPart.
e() <= 250.) {
413 theShower.
setHcal(&myHcalHitMaker);
418 for (
const auto& mapIterator : myGrid.
getHits()) {
419 simE += mapIterator.second;
433 if (myPreshower !=
nullptr) {
443 LogInfo(
"FastCalorimetry") <<
" reconstructHCAL " << myTrack << std::endl;
455 double pathEta = trackPosition.eta();
456 double pathPhi = trackPosition.phi();
462 if (pid == 13 || pid == 1000024 || (pid > 1000100 && pid < 1999999 && fabs(charge_) > 0.001)) {
465 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - MUON !!!" << std::endl;
466 }
else if (pid == 22 || pid == 11) {
469 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - e/gamma !!!" << std::endl;
475 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - on-calo "
476 <<
" eta = " << pathEta <<
" phi = " << pathPhi <<
" Egen = " << EGen
477 <<
" Emeas = " << emeas << std::endl;
484 std::map<CaloHitID, float> hitMap;
485 hitMap[current_id] = emeas;
499 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::HDShowerSimulation - track param." << std::endl
500 <<
" eta = " << moment.eta() << std::endl
501 <<
" phi = " << moment.phi() << std::endl
502 <<
" et = " << moment.Et() << std::endl
506 LogInfo(
"FastCalorimetry") <<
" HDShowerSimulation " << myTrack << std::endl;
516 }
else if (myTrack.
onVFcal()) {
521 LogInfo(
"FastCalorimetry") <<
" The particle is not in the acceptance " << std::endl;
527 int onHCAL =
hit + 1;
528 int onECAL = myTrack.
onEcal();
530 double pathEta = trackPosition.eta();
531 double pathPhi = trackPosition.phi();
533 double eint = moment.e();
551 }
else if (myTrack.
onHcal()) {
560 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::HDShowerSimulation - on-calo 1 " << std::endl
561 <<
" onEcal = " << myTrack.
onEcal() << std::endl
562 <<
" onHcal = " << myTrack.
onHcal() << std::endl
563 <<
" onVFcal = " << myTrack.
onVFcal() << std::endl
564 <<
" position = " << caloentrance << std::endl;
569 }
else if (myTrack.
onHcal()) {
594 HFShower theShower(random, &theHDShowerparam, &myGrid, &myHcalHitMaker, onECAL, eGen);
602 HDShower theShower(random, &theHDShowerparam, &myGrid, &myHcalHitMaker, onECAL, eGen, pmip);
606 HDRShower theShower(random, &theHDShowerparam, &myGrid, &myHcalHitMaker, onECAL, eGen);
619 int showerType = 99 + myTrack.
onEcal();
620 double globalTime = 150.0;
622 Gflash3Vector gfpos(trackPosition.X(), trackPosition.Y(), trackPosition.Z());
631 std::vector<GflashHit>::const_iterator spotIter = gflashHitList.begin();
632 std::vector<GflashHit>::const_iterator spotIterEnd = gflashHitList.end();
636 for (; spotIter != spotIterEnd; spotIter++) {
638 (30 * 100 / eGen) * (spotIter->getTime() - globalTime);
645 Gflash3Vector positionAtCurrentDepth = trajectoryPoint.getPosition();
647 Gflash3Vector lateralDisplacement = positionAtCurrentDepth - spotIter->getPosition() / CLHEP::cm;
648 double rShower = lateralDisplacement.r();
649 double azimuthalAngle = lateralDisplacement.phi();
654 bool statusPad = myGrid.getPads(currentDepth,
true);
657 myGrid.setSpotEnergy(1.2 * spotIter->getEnergy() /
CLHEP::GeV);
660 bool setHDdepth = myHcalHitMaker.
setDepth(currentDepth,
true);
687 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::HDShowerSimulation - on-calo 2" << std::endl
688 <<
" eta = " << pathEta << std::endl
689 <<
" phi = " << pathPhi << std::endl
690 <<
" Egen = " << eGen << std::endl
691 <<
" Emeas = " << emeas << std::endl
693 <<
" mip = " << mip << std::endl;
695 if (myTrack.
onEcal() > 0) {
713 std::map<CaloHitID, float> hitMap;
714 hitMap[current_id] = emeas;
717 LogInfo(
"FastCalorimetry") <<
" HCAL simple cell " << cell.
rawId() <<
" added E = " << emeas << std::endl;
724 LogInfo(
"FastCalorimetry") << std::endl <<
" FASTEnergyReconstructor::HDShowerSimulation finished " << std::endl;
742 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::MuonMipSimulation - track param." << std::endl
743 <<
" eta = " << moment.eta() << std::endl
744 <<
" phi = " << moment.phi() << std::endl
745 <<
" et = " << moment.Et() << std::endl;
751 }
else if (myTrack.
onVFcal()) {
755 LogInfo(
"FastCalorimetry") <<
" The particle is not in the acceptance " << std::endl;
763 int onECAL = myTrack.
onEcal();
775 }
else if (myTrack.
onHcal()) {
786 }
else if (myTrack.
onHcal()) {
798 const std::vector<CaloSegment>& segments = myGrid.getSegments();
799 unsigned nsegments = segments.size();
809 for (
unsigned iseg = 0; iseg < nsegments && ifirstHcal < 0; ++iseg) {
811 float segmentSizeinX0 = segments[iseg].X0length();
820 if (energyLossECAL) {
821 energyLossECAL->
updateState(theMuon, segmentSizeinX0, random);
823 moment -= energyLossECAL->
deltaMom();
829 myGrid.getPads(segments[iseg].sX0Entrance() + segmentSizeinX0 * 0.5);
830 myGrid.setSpotEnergy(
energy);
831 myGrid.addHit(0., 0.);
853 float mipenergy = 0.0;
860 if (ifirstHcal > 0 && energyLossHCAL) {
861 for (
unsigned iseg = ifirstHcal; iseg < nsegments; ++iseg) {
862 float segmentSizeinX0 = segments[iseg].X0length();
865 if (segmentSizeinX0 > 0.001) {
870 energyLossHCAL->
updateState(theMuon, segmentSizeinX0, random);
871 mipenergy = energyLossHCAL->
deltaMom().E();
872 moment -= energyLossHCAL->
deltaMom();
874 myHcalHitMaker.
addHit(segments[iseg].entrance());
882 if (energyLossHCAL && ilastHcal >= 0) {
886 }
else if (energyLossECAL && ilastEcal >= 0) {
895 std::map<CaloHitID, float>::const_iterator mapitr;
896 std::map<CaloHitID, float>::const_iterator endmapitr;
897 if (myTrack.
onEcal() > 0) {
906 LogInfo(
"FastCalorimetry") << std::endl <<
" FASTEnergyReconstructor::MipShowerSimulation finished " << std::endl;
939 if (pulledPadSurvivalProbability_ < 0. || pulledPadSurvivalProbability_ > 1)
941 if (crackPadSurvivalProbability_ < 0. || crackPadSurvivalProbability_ > 1)
944 LogInfo(
"FastCalorimetry") <<
" Fast ECAL simulation parameters " << std::endl;
945 LogInfo(
"FastCalorimetry") <<
" =============================== " << std::endl;
947 LogInfo(
"FastCalorimetry") <<
" The preshower is present " << std::endl;
949 LogInfo(
"FastCalorimetry") <<
" The preshower is NOT present " << std::endl;
954 LogInfo(
"FastCalorimetry") <<
" Core of the shower " << std::endl;
959 LogInfo(
"FastCalorimetry") << std::endl;
961 LogInfo(
"FastCalorimetry") <<
" Tail of the shower " << std::endl;
970 LogInfo(
"FastCalorimetry") << std::endl;
972 LogInfo(
"FastCalorimetry") <<
"Improper number of parameters for the preshower ; using 95keV" << std::endl;
984 rsp = CalorimeterParam.
getParameter<std::vector<double> >(
"RespCorrP");
985 LogInfo(
"FastCalorimetry") <<
" RespCorrP (rsp) size " <<
rsp.size() << std::endl;
987 if (
rsp.size() % 3 != 0) {
988 LogInfo(
"FastCalorimetry") <<
" RespCorrP size is wrong -> no corrections applied !!!" << std::endl;
994 for (
unsigned i = 0;
i <
rsp.size();
i += 3) {
995 LogInfo(
"FastCalorimetry") <<
"i = " <<
i / 3 <<
" p = " <<
rsp[
i] <<
" k_e(p) = " <<
rsp[
i + 1]
996 <<
" k_e(p) = " <<
rsp[
i + 2] << std::endl;
1027 useShowerLibrary = m_HS.getUntrackedParameter<
bool>(
"useShowerLibrary",
false);
1028 useCorrectionSL = m_HS.getUntrackedParameter<
bool>(
"useCorrectionSL",
false);
1039 for (
int i = 0;
i < sizeP;
i++) {
1055 double y1 =
k_e[ip - 1];
1056 double y2 =
k_e[ip];
1068 LogInfo(
"FastCalorimetry") <<
" p, ecorr, hcorr = " <<
p <<
" " <<
ecorr <<
" " <<
hcorr << std::endl;
1072 std::map<CaloHitID, float>::const_iterator mapitr;
1073 std::map<CaloHitID, float>::const_iterator endmapitr = hitMap.end();
1076 endmapitr = hitMap.end();
1077 for (mapitr = hitMap.begin(); mapitr != endmapitr; ++mapitr) {
1079 float energy = mapitr->second;
1083 CaloHitID current_id(mapitr->first.unitID(), mapitr->first.timeSlice(), trackID);
1087 }
else if (onEcal == 2) {
1089 endmapitr = hitMap.end();
1090 for (mapitr = hitMap.begin(); mapitr != endmapitr; ++mapitr) {
1092 float energy = mapitr->second;
1096 CaloHitID current_id(mapitr->first.unitID(), mapitr->first.timeSlice(), trackID);
1106 std::map<CaloHitID, float>::const_iterator mapitr;
1107 std::map<CaloHitID, float>::const_iterator endmapitr = hitMap.end();
1109 for (mapitr = hitMap.begin(); mapitr != endmapitr; ++mapitr) {
1111 float energy = mapitr->second;
1114 float time = mapitr->first.timeSlice();
1146 CaloHitID current_id(mapitr->first.unitID(),
time, trackID);
1152 std::map<CaloHitID, float>::const_iterator mapitr;
1153 std::map<CaloHitID, float>::const_iterator endmapitr = hitMap.end();
1155 for (mapitr = hitMap.begin(); mapitr != endmapitr; ++mapitr) {
1157 float energy = mapitr->second;
1161 CaloHitID current_id(mapitr->first.unitID(), mapitr->first.timeSlice(), trackID);
1211 for (
unsigned i = 0;
i <
size; ++
i) {
1212 int id =
muons[
i].trackId();
1218 std::vector<FSimTrack>::const_iterator itcheck =
1221 muons[
i].setTkPosition(itcheck->trackerSurfacePosition());
1222 muons[
i].setTkMomentum(itcheck->trackerSurfaceMomentum());
1230 if (
track.momentum().perp2() > 1.0 && fabs(
track.momentum().eta()) < 3.0 &&
track.isGlobal())
1234 if (
track.momentum().perp2() > 1.0 && fabs(
track.momentum().eta()) < 3.0 &&
track.isGlobal())