70 std::vector<std::pair<int, float> >(1, std::pair<int, float>(0, 0.));
80 : mySimEvent(aSimEvent),
82 theMuonEcalEffects(nullptr),
83 theMuonHcalEffects(nullptr),
84 bFixedLength_(
false) {
115 if (fastCalo.
exists(
"ECALResponseScaling")) {
150 std::vector<unsigned int>::const_iterator itcheck =
176 <<
" WARNING: The preshower simulation has been turned on; but no preshower geometry is available " 178 edm::LogWarning(
"CalorimetryManager") <<
" Disabling the preshower simulation " << std::endl;
191 LogInfo(
"FastCalorimetry") <<
" ===> pid = " << pid << std::endl;
198 if (pid == 11 || pid == 22) {
210 else if (pid == 13 || pid == 1000024 || (pid > 1000100 && pid < 1999999 && fabs(charge_) > 0.001)) {
216 else if (pid < 1000000) {
229 std::vector<const RawParticle*> thePart;
233 LogInfo(
"FastCalorimetry") <<
" EMShowerSimulation " << myTrack << std::endl;
244 int onEcal = myTrack.
onEcal();
245 int onHcal = myTrack.
onHcal();
255 XYZPoint layer1entrance, layer2entrance;
281 if (myTrack.
type() == 22) {
286 double eMass = 0.000510998902;
293 xe = random->
flatShoot() * (1. - 2. * xm) + xm;
294 weight = 1. - 4. / 3. * xe * (1. - xe);
295 }
while (weight < random->flatShoot());
300 thePart.push_back(&
myPart);
307 thePart.push_back(&
myElec);
308 thePart.push_back(&
myPosi);
314 thePart.push_back(&
myPart);
318 if (thePart.empty()) {
319 if (myPreshower ==
nullptr)
327 for (
unsigned ip = 0; ip < thePart.size(); ++ip)
348 if (pivot.subdetId() == 0) {
350 <<
"Pivot for egamma e = " << myTrack.
hcalEntrance().
e() <<
" is not found at depth " <<
depth 351 <<
" and meanShower coordinates = " << meanShower << std::endl;
384 if (myTrack.
onEcal() == 2)
386 if ((onLayer1 || onLayer2) &&
myPart.
e() <= 250.) {
412 theShower.
setHcal(&myHcalHitMaker);
417 for (
const auto& mapIterator : myGrid.
getHits()) {
418 simE += mapIterator.second;
432 if (myPreshower !=
nullptr) {
442 LogInfo(
"FastCalorimetry") <<
" reconstructHCAL " << myTrack << std::endl;
454 double pathEta = trackPosition.eta();
455 double pathPhi = trackPosition.phi();
461 if (pid == 13 || pid == 1000024 || (pid > 1000100 && pid < 1999999 && fabs(charge_) > 0.001)) {
464 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - MUON !!!" << std::endl;
465 }
else if (pid == 22 || pid == 11) {
468 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - e/gamma !!!" << std::endl;
474 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - on-calo " 475 <<
" eta = " << pathEta <<
" phi = " << pathPhi <<
" Egen = " << EGen
476 <<
" Emeas = " << emeas << std::endl;
483 std::map<CaloHitID, float> hitMap;
484 hitMap[current_id] = emeas;
498 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::HDShowerSimulation - track param." << std::endl
499 <<
" eta = " << moment.eta() << std::endl
500 <<
" phi = " << moment.phi() << std::endl
501 <<
" et = " << moment.Et() << std::endl
505 LogInfo(
"FastCalorimetry") <<
" HDShowerSimulation " << myTrack << std::endl;
515 }
else if (myTrack.
onVFcal()) {
520 LogInfo(
"FastCalorimetry") <<
" The particle is not in the acceptance " << std::endl;
526 int onHCAL =
hit + 1;
527 int onECAL = myTrack.
onEcal();
529 double pathEta = trackPosition.eta();
530 double pathPhi = trackPosition.phi();
532 double eint = moment.e();
550 }
else if (myTrack.
onHcal()) {
559 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::HDShowerSimulation - on-calo 1 " << std::endl
560 <<
" onEcal = " << myTrack.
onEcal() << std::endl
561 <<
" onHcal = " << myTrack.
onHcal() << std::endl
562 <<
" onVFcal = " << myTrack.
onVFcal() << std::endl
563 <<
" position = " << caloentrance << std::endl;
568 }
else if (myTrack.
onHcal()) {
593 HFShower theShower(random, &theHDShowerparam, &myGrid, &myHcalHitMaker, onECAL, eGen);
601 HDShower theShower(random, &theHDShowerparam, &myGrid, &myHcalHitMaker, onECAL, eGen, pmip);
605 HDRShower theShower(random, &theHDShowerparam, &myGrid, &myHcalHitMaker, onECAL, eGen);
618 int showerType = 99 + myTrack.
onEcal();
619 double globalTime = 150.0;
621 Gflash3Vector gfpos(trackPosition.X(), trackPosition.Y(), trackPosition.Z());
630 std::vector<GflashHit>::const_iterator spotIter = gflashHitList.begin();
631 std::vector<GflashHit>::const_iterator spotIterEnd = gflashHitList.end();
635 for (; spotIter != spotIterEnd; spotIter++) {
637 (30 * 100 / eGen) * (spotIter->getTime() - globalTime);
644 Gflash3Vector positionAtCurrentDepth = trajectoryPoint.getPosition();
646 Gflash3Vector lateralDisplacement = positionAtCurrentDepth - spotIter->getPosition() / CLHEP::cm;
647 double rShower = lateralDisplacement.r();
648 double azimuthalAngle = lateralDisplacement.phi();
653 bool statusPad = myGrid.getPads(currentDepth,
true);
656 myGrid.setSpotEnergy(1.2 * spotIter->getEnergy() / CLHEP::GeV);
659 bool setHDdepth = myHcalHitMaker.
setDepth(currentDepth,
true);
662 myHcalHitMaker.
setSpotEnergy(1.4 * spotIter->getEnergy() / CLHEP::GeV);
686 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::HDShowerSimulation - on-calo 2" << std::endl
687 <<
" eta = " << pathEta << std::endl
688 <<
" phi = " << pathPhi << std::endl
689 <<
" Egen = " << eGen << std::endl
690 <<
" Emeas = " << emeas << std::endl
692 <<
" mip = " << mip << std::endl;
694 if (myTrack.
onEcal() > 0) {
712 std::map<CaloHitID, float> hitMap;
713 hitMap[current_id] = emeas;
716 LogInfo(
"FastCalorimetry") <<
" HCAL simple cell " << cell.
rawId() <<
" added E = " << emeas << std::endl;
723 LogInfo(
"FastCalorimetry") << std::endl <<
" FASTEnergyReconstructor::HDShowerSimulation finished " << std::endl;
741 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::MuonMipSimulation - track param." << std::endl
742 <<
" eta = " << moment.eta() << std::endl
743 <<
" phi = " << moment.phi() << std::endl
744 <<
" et = " << moment.Et() << std::endl;
750 }
else if (myTrack.
onVFcal()) {
754 LogInfo(
"FastCalorimetry") <<
" The particle is not in the acceptance " << std::endl;
762 int onECAL = myTrack.
onEcal();
774 }
else if (myTrack.
onHcal()) {
785 }
else if (myTrack.
onHcal()) {
797 const std::vector<CaloSegment>& segments = myGrid.getSegments();
798 unsigned nsegments = segments.size();
808 for (
unsigned iseg = 0; iseg < nsegments && ifirstHcal < 0; ++iseg) {
810 float segmentSizeinX0 = segments[iseg].X0length();
819 if (energyLossECAL) {
820 energyLossECAL->
updateState(theMuon, segmentSizeinX0, random);
822 moment -= energyLossECAL->
deltaMom();
828 myGrid.getPads(segments[iseg].sX0Entrance() + segmentSizeinX0 * 0.5);
829 myGrid.setSpotEnergy(
energy);
830 myGrid.addHit(0., 0.);
852 float mipenergy = 0.0;
859 if (ifirstHcal > 0 && energyLossHCAL) {
860 for (
unsigned iseg = ifirstHcal; iseg < nsegments; ++iseg) {
861 float segmentSizeinX0 = segments[iseg].X0length();
864 if (segmentSizeinX0 > 0.001) {
869 energyLossHCAL->
updateState(theMuon, segmentSizeinX0, random);
870 mipenergy = energyLossHCAL->
deltaMom().E();
871 moment -= energyLossHCAL->
deltaMom();
873 myHcalHitMaker.
addHit(segments[iseg].entrance());
881 if (energyLossHCAL && ilastHcal >= 0) {
885 }
else if (energyLossECAL && ilastEcal >= 0) {
894 std::map<CaloHitID, float>::const_iterator mapitr;
895 std::map<CaloHitID, float>::const_iterator endmapitr;
896 if (myTrack.
onEcal() > 0) {
905 LogInfo(
"FastCalorimetry") << std::endl <<
" FASTEnergyReconstructor::MipShowerSimulation finished " << std::endl;
938 if (pulledPadSurvivalProbability_ < 0. || pulledPadSurvivalProbability_ > 1)
940 if (crackPadSurvivalProbability_ < 0. || crackPadSurvivalProbability_ > 1)
943 LogInfo(
"FastCalorimetry") <<
" Fast ECAL simulation parameters " << std::endl;
944 LogInfo(
"FastCalorimetry") <<
" =============================== " << std::endl;
946 LogInfo(
"FastCalorimetry") <<
" The preshower is present " << std::endl;
948 LogInfo(
"FastCalorimetry") <<
" The preshower is NOT present " << std::endl;
953 LogInfo(
"FastCalorimetry") <<
" Core of the shower " << std::endl;
958 LogInfo(
"FastCalorimetry") << std::endl;
960 LogInfo(
"FastCalorimetry") <<
" Tail of the shower " << std::endl;
969 LogInfo(
"FastCalorimetry") << std::endl;
971 LogInfo(
"FastCalorimetry") <<
"Improper number of parameters for the preshower ; using 95keV" << std::endl;
983 rsp = CalorimeterParam.
getParameter<std::vector<double> >(
"RespCorrP");
984 LogInfo(
"FastCalorimetry") <<
" RespCorrP (rsp) size " <<
rsp.size() << std::endl;
986 if (
rsp.size() % 3 != 0) {
987 LogInfo(
"FastCalorimetry") <<
" RespCorrP size is wrong -> no corrections applied !!!" << std::endl;
993 for (
unsigned i = 0;
i <
rsp.size();
i += 3) {
994 LogInfo(
"FastCalorimetry") <<
"i = " <<
i / 3 <<
" p = " <<
rsp[
i] <<
" k_e(p) = " <<
rsp[
i + 1]
995 <<
" k_e(p) = " <<
rsp[
i + 2] << std::endl;
1026 useShowerLibrary = m_HS.getUntrackedParameter<
bool>(
"useShowerLibrary",
false);
1027 useCorrectionSL = m_HS.getUntrackedParameter<
bool>(
"useCorrectionSL",
false);
1038 for (
int i = 0;
i < sizeP;
i++) {
1054 double y1 =
k_e[ip - 1];
1055 double y2 =
k_e[ip];
1067 LogInfo(
"FastCalorimetry") <<
" p, ecorr, hcorr = " <<
p <<
" " <<
ecorr <<
" " <<
hcorr << std::endl;
1071 std::map<CaloHitID, float>::const_iterator mapitr;
1072 std::map<CaloHitID, float>::const_iterator endmapitr = hitMap.end();
1075 endmapitr = hitMap.end();
1076 for (mapitr = hitMap.begin(); mapitr != endmapitr; ++mapitr) {
1078 float energy = mapitr->second;
1082 CaloHitID current_id(mapitr->first.unitID(), mapitr->first.timeSlice(), trackID);
1086 }
else if (onEcal == 2) {
1088 endmapitr = hitMap.end();
1089 for (mapitr = hitMap.begin(); mapitr != endmapitr; ++mapitr) {
1091 float energy = mapitr->second;
1095 CaloHitID current_id(mapitr->first.unitID(), mapitr->first.timeSlice(), trackID);
1105 std::map<CaloHitID, float>::const_iterator mapitr;
1106 std::map<CaloHitID, float>::const_iterator endmapitr = hitMap.end();
1108 for (mapitr = hitMap.begin(); mapitr != endmapitr; ++mapitr) {
1110 float energy = mapitr->second;
1113 float time = mapitr->first.timeSlice();
1145 CaloHitID current_id(mapitr->first.unitID(),
time, trackID);
1151 std::map<CaloHitID, float>::const_iterator mapitr;
1152 std::map<CaloHitID, float>::const_iterator endmapitr = hitMap.end();
1154 for (mapitr = hitMap.begin(); mapitr != endmapitr; ++mapitr) {
1156 float energy = mapitr->second;
1160 CaloHitID current_id(mapitr->first.unitID(), mapitr->first.timeSlice(), trackID);
1210 for (
unsigned i = 0;
i <
size; ++
i) {
1211 int id =
muons[
i].trackId();
1217 std::vector<FSimTrack>::const_iterator itcheck =
1220 muons[
i].setTkPosition(itcheck->trackerSurfacePosition());
1221 muons[
i].setTkMomentum(itcheck->trackerSurfaceMomentum());
1229 if (
track.momentum().perp2() > 1.0 && fabs(
track.momentum().eta()) < 3.0 &&
track.isGlobal())
1233 if (
track.momentum().perp2() > 1.0 && fabs(
track.momentum().eta()) < 3.0 &&
track.isGlobal())
bool preshowerPresent() const
std::vector< double > rsp
std::vector< double > k_h
RawParticle myElec
A few pointers to save time.
FSimTrack & track(int id) const
Return track with given Id.
double radLenIncm() const override
Radiation length in cm.
T getParameter(std::string const &) const
void reconstructHCAL(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
std::vector< PCaloHit > PCaloHitContainer
const RawParticle & vfcalEntrance() const
The particle at VFCAL entrance.
void loadFromPreshower(edm::PCaloHitContainer &c) const
double responseHCAL(int _mip, double energy, double eta, int partype, RandomEngineAndDistribution const *)
DetId getClosestCell(const XYZPoint &point, bool ecal, bool central) const
void updateHCAL(const std::map< CaloHitID, float > &hitMap, int trackID=0, float corr=1.0)
const RawParticle & hcalEntrance() const
The particle at HCAL entrance.
const PreshowerLayer1Properties * layer1Properties(int onLayer1) const
Preshower Layer1 properties.
GflashPiKShowerProfile * thePiKProfile
const XYZTLorentzVector & deltaMom() const
Returns the actual energy lost.
const RawParticle & layer2Entrance() const
The particle at Preshower Layer 2.
double pulledPadSurvivalProbability_
std::vector< double > timeShiftHO_
void updatePreshower(const std::map< CaloHitID, float > &hitMap, int trackID=0, float corr=1.0)
GflashTrajectory * getHelix()
const RawParticle & ecalEntrance() const
The particle at ECAL entrance.
MaterialEffects * theMuonEcalEffects
constexpr int ietaAbs() const
get the absolute value of the cell ieta
const ECALProperties * ecalProperties(int onEcal) const
ECAL properties.
double crackPadSurvivalProbability_
MaterialEffects * theMuonHcalEffects
void harvestMuonSimTracks(edm::SimTrackContainer &m) const
void recoHFShowerLibrary(const FSimTrack &myTrack)
void setCrackPadSurvivalProbability(double val)
double getHCALEnergyResponse(double e, int hit, RandomEngineAndDistribution const *)
const PreshowerLayer2Properties * layer2Properties(int onLayer2) const
Preshower Layer2 properties.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
GflashHadronShowerProfile * theProfile
const std::map< CaloHitID, float > & getHits() override
void loadFromEcalEndcap(edm::PCaloHitContainer &c) const
bool compute()
Compute the shower longitudinal and lateral development.
void correctHF(double e, int type)
void reconstructTrack(FSimTrack &myTrack, RandomEngineAndDistribution const *)
void setPreshower(PreshowerHitMaker *const myPresh)
set the preshower address
void updateState(ParticlePropagator &myTrack, double radlen, RandomEngineAndDistribution const *)
Compute the material effect (calls the sub class)
void updateECAL(const std::map< CaloHitID, float > &hitMap, int onEcal, int trackID=0, float corr=1.0)
const XYZTLorentzVector & momentum() const
the momentum fourvector
void MuonMipSimulation(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
void readParameters(const edm::ParameterSet &fastCalo)
RawParticle makeMuon(bool isParticle, const math::XYZTLorentzVector &p, const math::XYZTLorentzVector &xStart)
unsigned int nTracks() const
Number of tracks.
static EEDetId unhashIndex(int hi)
bool noEndVertex() const
no end vertex
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
static double constexpr eMass
Electron mass[GeV].
std::vector< double > timeShiftHF_
std::vector< double > p_knots
void compute()
Compute the shower longitudinal and lateral development.
const HepPDT::ParticleDataTable * theTable() const
Get the pointer to the particle data table.
std::vector< FSimTrack > muonSimTracks
T getUntrackedParameter(std::string const &, T const &) const
U second(std::pair< T, U > const &p)
int type() const
particle type (HEP PDT convension)
void HDShowerSimulation(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
Hadronic Shower Simulation.
const LandauFluctuationGenerator * aLandauGenerator
constexpr bool null() const
is this a null id ?
std::vector< double > samplingHF_
bool compute()
Compute the shower longitudinal and lateral development.
void setRadiusFactor(double r)
bool addHit(double r, double phi, unsigned layer=0) override
add the hit in the HCAL in local coordinates
const CaloSubdetectorGeometry * getHcalGeometry() const
void print() const
print the FBaseSimEvent in an intelligible way
void reconstruct(RandomEngineAndDistribution const *)
CalorimeterNumber getCalorimeterNumber(const Gflash3Vector &position)
const XYZTLorentzVector & momentum() const
Temporary (until move of SimTrack to Mathcore) - No! Actually very useful.
GflashAntiProtonShowerProfile * theAntiProtonProfile
math::XYZVector XYZVector
GflashShowino * getGflashShowino()
GflashProtonShowerProfile * theProtonProfile
double getPathLengthAtShower()
virtual void loadParameters()
const std::map< CaloHitID, float > & getHits() override
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
float charge() const
charge
void setTrackParameters(const XYZNormal &normal, double X0depthoffset, const FSimTrack &theTrack)
std::vector< std::pair< CaloHitID, float > > ESMapping_
std::vector< double > radiusPreshowerCorrections_
Abs< T >::type abs(const T &t)
double getMIPfraction(double energy, double eta)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void setSpotEnergy(double e) override
Set the spot energy.
const std::map< CaloHitID, float > & getHitsMap()
std::vector< double > theTailIntervals_
void loadFromEcalBarrel(edm::PCaloHitContainer &c) const
std::vector< double > samplingHBHE_
HCALResponse * myHDResponse_
CaloGeometryHelper * myCalorimeter_
std::vector< double > timeShiftHB_
std::vector< std::pair< CaloHitID, float > > HMapping_
void initialize(RandomEngineAndDistribution const *random)
const double intLength[kNumberCalorimeter]
void getGflashTrajectoryPoint(GflashTrajectoryPoint &point, double s) const
std::vector< double > theCoreIntervals_
Log< level::Info, false > LogInfo
XYZVector Vect() const
the momentum threevector
void hadronicParameterization()
GammaFunctionGenerator * aGammaGenerator
edm::EventID id() const
Method to return the EventId.
XYZVectorD XYZVector
spatial vector with cartesian internal representation
constexpr uint32_t rawId() const
get the raw id
CLHEP::Hep3Vector Gflash3Vector
std::vector< double > mipValues_
static std::vector< std::pair< int, float > > myZero_
std::vector< FSimTrack > savedMuonSimTracks
void setTkPosition(const math::XYZVectorD &pos)
std::vector< std::pair< CaloHitID, float > > EEMapping_
double getPathLengthOnEcal()
void SetRandom(const RandomEngineAndDistribution *)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
std::vector< unsigned int > evtsToDebug_
void setPulledPadSurvivalProbability(double val)
std::vector< double > k_e
std::vector< GflashHit > & getGflashHitList()
double getMaximumOfShower() const
get the depth of the centre of gravity of the shower(s)
void setTkMomentum(const math::XYZTLorentzVectorD &mom)
std::vector< std::pair< CaloHitID, float > > EBMapping_
void setMipEnergy(double e1, double e2)
void loadMuonSimTracks(edm::SimTrackContainer &m) const
std::vector< double > samplingHO_
void setPreshowerPresent(bool ps)
FastHFShowerLibrary * theHFShowerLibrary
double flatShoot(double xmin=0.0, double xmax=1.0) const
Log< level::Warning, false > LogWarning
math::XYZVector XYZVector
const RawParticle & layer1Entrance() const
The particle at Preshower Layer 1.
std::unique_ptr< KKCorrectionFactors > ecalCorrection
const HCALProperties * hcalProperties(int onHcal) const
HCAL properties.
HSParameters * myHSParameters_
double e() const
energy of the momentum
std::vector< SimTrack > SimTrackContainer
EnergyLossSimulator * energyLossSimulator() const
Return the Energy Loss engine.
void setVertex(const XYZTLorentzVector &vtx)
set the vertex
bool setDepth(double, bool inCm=false)
set the depth in X0 or Lambda0 units depending on showerType
EventNumber_t event() const
int id() const
the index in FBaseSimEvent and other vectors
void initialize(int showerType, double energy, double globalTime, double charge, Gflash3Vector &position, Gflash3Vector &momentum)
math::XYZTLorentzVector XYZTLorentzVector
const XYZTLorentzVector & vertex() const
the vertex fourvector
void setHcal(HcalHitMaker *const myHcal)
set the HCAL address
void loadFromHcal(edm::PCaloHitContainer &c) const
void setGrid(EcalHitMaker *const myGrid)
set the grid address
void EMShowerSimulation(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
const std::map< CaloHitID, float > & getHits() override
std::vector< double > timeShiftHE_
constexpr int depth() const
get the tower depth