69 (1,std::pair<int,float>(0,0.));
124 if( fastCalo.
exists(
"ECALResponseScaling") ) {
185 edm::LogWarning(
"CalorimetryManager") <<
" WARNING: The preshower simulation has been turned on; but no preshower geometry is available " << std::endl;
186 edm::LogWarning(
"CalorimetryManager") <<
" Disabling the preshower simulation " << std::endl;
199 LogInfo(
"FastCalorimetry") <<
" ===> pid = " << pid << std::endl;
206 if ( pid == 11 || pid == 22 ) {
210 else if ( myTrack.
onVFcal() ) {
219 else if (pid == 13 || pid == 1000024 || (pid > 1000100 && pid < 1999999 && fabs(charge_) > 0.001))
226 else if ( pid < 1000000 ) {
238 std::vector<const RawParticle*> thePart;
242 LogInfo(
"FastCalorimetry") <<
" EMShowerSimulation " <<myTrack << std::endl;
249 if ( myTrack.
type() == 22 &&
myPart.e()<0.055)
return;
253 int onEcal = myTrack.
onEcal();
254 int onHcal = myTrack.
onHcal();
265 XYZPoint layer1entrance,layer2entrance;
299 if ( myTrack.
type() == 22 ) {
305 double eMass = 0.000510998902;
307 double xm=eMass/
myPart.e();
312 xe = random->
flatShoot()*(1.-2.*xm) + xm;
313 weight = 1. - 4./3.*xe*(1.-xe);
314 }
while ( weight < random->flatShoot() );
317 if (
myPart.e()*xe < 0.055 ||
myPart.e()*(1.-xe) < 0.055 ) {
327 thePart.push_back(&
myElec);
328 thePart.push_back(&
myPosi);
341 if(myPreshower==
nullptr)
return;
348 for(
unsigned ip=0;ip < thePart.size();++ip)
349 if(thePart[ip]->
e() >
maxEnergy) maxEnergy = thePart[ip]->
e();
353 if(maxEnergy>100) size=11;
358 if (maxShower > 20.) maxShower = 2.;
360 double depth((X0depth + maxShower) *
368 if(pivot.subdetId() == 0) {
369 edm::LogWarning(
"CalorimetryManager") <<
"Pivot for egamma e = " << myTrack.
hcalEntrance().e() <<
" is not found at depth " <<
depth <<
" and meanShower coordinates = " << meanShower << std::endl;
370 if(myPreshower)
delete myPreshower;
403 if( (onLayer1 || onLayer2) &&
myPart.e()<=250.)
430 theShower.
setHcal(&myHcalHitMaker);
435 for(
const auto& mapIterator : myGrid.
getHits() ) {
436 simE += mapIterator.second;
449 if(myPreshower!=
nullptr) {
462 LogInfo(
"FastCalorimetry") <<
" reconstructHCAL " << myTrack << std::endl;
474 double pathEta = trackPosition.eta();
475 double pathPhi = trackPosition.phi();
481 if (pid == 13 || pid == 1000024 || (pid > 1000100 && pid < 1999999 && fabs(charge_) > 0.001)) {
484 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - MUON !!!" << std::endl;
486 else if( pid == 22 || pid == 11) {
489 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - e/gamma !!!" << std::endl;
496 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - on-calo " 497 <<
" eta = " << pathEta
498 <<
" phi = " << pathPhi
499 <<
" Egen = " << EGen
500 <<
" Emeas = " << emeas << std::endl;
506 std::map<CaloHitID,float> hitMap;
507 hitMap[current_id] = emeas;
522 <<
"CalorimetryManager::HDShowerSimulation - track param." 524 <<
" eta = " << moment.eta() << std::endl
525 <<
" phi = " << moment.phi() << std::endl
526 <<
" et = " << moment.Et() << std::endl
530 LogInfo(
"FastCalorimetry") <<
" HDShowerSimulation " << myTrack << std::endl;
541 }
else if ( myTrack.
onVFcal()) {
548 LogInfo(
"FastCalorimetry") <<
" The particle is not in the acceptance " << std::endl;
554 int onHCAL = hit + 1;
555 int onECAL = myTrack.
onEcal();
557 double pathEta = trackPosition.eta();
558 double pathPhi = trackPosition.phi();
560 double eint = moment.e();
597 <<
"CalorimetryManager::HDShowerSimulation - on-calo 1 " 599 <<
" onEcal = " << myTrack.
onEcal() << std::endl
600 <<
" onHcal = " << myTrack.
onHcal() << std::endl
601 <<
" onVFcal = " << myTrack.
onVFcal() << std::endl
602 <<
" position = " << caloentrance << std::endl;
609 true, myTrack.
onEcal()==1);
680 int showerType = 99 + myTrack.
onEcal();
681 double globalTime = 150.0;
683 Gflash3Vector gfpos(trackPosition.X(),trackPosition.Y(),trackPosition.Z());
692 std::vector<GflashHit>::const_iterator spotIter = gflashHitList.begin();
693 std::vector<GflashHit>::const_iterator spotIterEnd = gflashHitList.end();
697 for( ; spotIter != spotIterEnd; spotIter++){
700 + (30*100/eGen)*(spotIter->getTime() - globalTime);
707 Gflash3Vector positionAtCurrentDepth = trajectoryPoint.getPosition();
709 Gflash3Vector lateralDisplacement = positionAtCurrentDepth - spotIter->getPosition()/CLHEP::cm;
710 double rShower = lateralDisplacement.r();
711 double azimuthalAngle = lateralDisplacement.phi();
716 bool statusPad = myGrid.getPads(currentDepth,
true);
717 if(!statusPad)
continue;
718 myGrid.setSpotEnergy(1.2*spotIter->getEnergy()/
CLHEP::GeV);
722 bool setHDdepth = myHcalHitMaker.
setDepth(currentDepth,
true);
723 if(!setHDdepth)
continue;
746 double correction = emeas / eGen;
753 <<
"CalorimetryManager::HDShowerSimulation - on-calo 2" << std::endl
754 <<
" eta = " << pathEta << std::endl
755 <<
" phi = " << pathPhi << std::endl
756 <<
" Egen = " << eGen << std::endl
757 <<
" Emeas = " << emeas << std::endl
758 <<
" corr = " << correction << std::endl
759 <<
" mip = " << mip << std::endl;
761 if(myTrack.
onEcal() > 0) {
781 std::map<CaloHitID,float> hitMap;
782 hitMap[current_id] = emeas;
785 LogInfo(
"FastCalorimetry") <<
" HCAL simple cell " 786 << cell.
rawId() <<
" added E = " 787 << emeas << std::endl;
794 LogInfo(
"FastCalorimetry") << std::endl <<
" FASTEnergyReconstructor::HDShowerSimulation finished " 817 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::MuonMipSimulation - track param." 819 <<
" eta = " << moment.eta() << std::endl
820 <<
" phi = " << moment.phi() << std::endl
821 <<
" et = " << moment.Et() << std::endl;
827 }
else if ( myTrack.
onVFcal()) {
833 LogInfo(
"FastCalorimetry") <<
" The particle is not in the acceptance " << std::endl;
841 int onECAL = myTrack.
onEcal();
870 true, myTrack.
onEcal()==1);
888 const std::vector<CaloSegment>& segments=myGrid.getSegments();
889 unsigned nsegments=segments.size();
900 for(
unsigned iseg=0;iseg<nsegments&&ifirstHcal<0;++iseg)
904 float segmentSizeinX0=segments[iseg].X0length();
912 theMuon.
setID(-(
int)charge*13);
913 if ( energyLossECAL ) {
914 energyLossECAL->
updateState(theMuon, segmentSizeinX0, random);
915 energy = energyLossECAL->
deltaMom().E();
916 moment -= energyLossECAL->
deltaMom();
923 myGrid.getPads(segments[iseg].sX0Entrance()+segmentSizeinX0*0.5);
924 myGrid.setSpotEnergy(energy);
925 myGrid.addHit(0.,0.);
957 if(ifirstHcal>0 && energyLossHCAL){
958 for(
unsigned iseg=ifirstHcal;iseg<nsegments;++iseg)
960 float segmentSizeinX0=segments[iseg].X0length();
963 if (segmentSizeinX0>0.001) {
967 theMuon.
setID(-(
int)charge*13);
968 energyLossHCAL->
updateState(theMuon, segmentSizeinX0, random);
969 mipenergy = energyLossHCAL->
deltaMom().E();
970 moment -= energyLossHCAL->
deltaMom();
972 myHcalHitMaker.
addHit(segments[iseg].entrance());
980 if(energyLossHCAL && ilastHcal>=0) {
984 }
else if(energyLossECAL && ilastEcal>=0) {
993 std::map<CaloHitID,float>::const_iterator mapitr;
994 std::map<CaloHitID,float>::const_iterator endmapitr;
995 if(myTrack.
onEcal() > 0) {
1004 LogInfo(
"FastCalorimetry") << std::endl <<
" FASTEnergyReconstructor::MipShowerSimulation finished " 1033 aTerm = 1.+radiusPreshowerCorrections_[1]*radiusPreshowerCorrections_[0];
1034 bTerm = radiusPreshowerCorrections_[0];
1038 if(gridSize_ <1) gridSize_= 7;
1039 if(pulledPadSurvivalProbability_ <0. || pulledPadSurvivalProbability_>1 ) pulledPadSurvivalProbability_= 1.;
1040 if(crackPadSurvivalProbability_ <0. || crackPadSurvivalProbability_>1 ) crackPadSurvivalProbability_= 0.9;
1042 LogInfo(
"FastCalorimetry") <<
" Fast ECAL simulation parameters " << std::endl;
1043 LogInfo(
"FastCalorimetry") <<
" =============================== " << std::endl;
1044 if(simulatePreshower_)
1045 LogInfo(
"FastCalorimetry") <<
" The preshower is present " << std::endl;
1047 LogInfo(
"FastCalorimetry") <<
" The preshower is NOT present " << std::endl;
1048 LogInfo(
"FastCalorimetry") <<
" Grid Size : " << gridSize_ << std::endl;
1049 if(spotFraction_>0.)
1050 LogInfo(
"FastCalorimetry") <<
" Spot Fraction : " << spotFraction_ << std::endl;
1053 LogInfo(
"FastCalorimetry") <<
" Core of the shower " << std::endl;
1054 for(
unsigned ir=0; ir < theCoreIntervals_.size()/2;++ir)
1056 LogInfo(
"FastCalorimetry") <<
" r < " << theCoreIntervals_[ir*2] <<
" R_M : " << theCoreIntervals_[ir*2+1] <<
" ";
1058 LogInfo(
"FastCalorimetry") << std::endl;
1060 LogInfo(
"FastCalorimetry") <<
" Tail of the shower " << std::endl;
1061 for(
unsigned ir=0; ir < theTailIntervals_.size()/2;++ir)
1063 LogInfo(
"FastCalorimetry") <<
" r < " << theTailIntervals_[ir*2] <<
" R_M : " << theTailIntervals_[ir*2+1] <<
" ";
1066 LogInfo(
"FastCalorimetry") <<
"Radius correction factors: EB & EE " << radiusFactorEB_ <<
" : "<< radiusFactorEE_ << std::endl;
1068 LogInfo(
"FastCalorimetry") << std::endl;
1070 LogInfo(
"FastCalorimetry") <<
"Improper number of parameters for the preshower ; using 95keV" << std::endl;
1076 LogInfo(
"FastCalorimetry") <<
" FrontLeakageProbability : " << pulledPadSurvivalProbability_ << std::endl;
1077 LogInfo(
"FastCalorimetry") <<
" GapLossProbability : " << crackPadSurvivalProbability_ << std::endl;
1083 rsp = CalorimeterParam.
getParameter<std::vector<double> >(
"RespCorrP");
1084 LogInfo(
"FastCalorimetry") <<
" RespCorrP (rsp) size " << rsp.size() << std::endl;
1086 if( rsp.size()%3 !=0 ) {
1088 <<
" RespCorrP size is wrong -> no corrections applied !!!" 1096 for(
unsigned i = 0;
i < rsp.size();
i += 3) {
1097 LogInfo(
"FastCalorimetry") <<
"i = " <<
i/3 <<
" p = " << rsp [
i]
1098 <<
" k_e(p) = " << rsp[
i+1]
1099 <<
" k_e(p) = " << rsp[
i+2] << std::endl;
1102 k_e.push_back (rsp[i+1]);
1103 k_h.push_back (rsp[i+2]);
1131 useShowerLibrary = m_HS.getUntrackedParameter<
bool>(
"useShowerLibrary",
false);
1132 useCorrectionSL = m_HS.getUntrackedParameter<
bool>(
"useCorrectionSL",
false);
1145 for (
int i = 0;
i < sizeP;
i++) {
1160 double y1 =
k_e[ip-1];
1161 double y2 =
k_e[ip];
1163 ecorr = (y1 + (y2 - y1) * (p - x1)/(x2 -
x1));
1167 hcorr = (y1 + (y2 - y1) * (p - x1)/(x2 -
x1));
1174 LogInfo(
"FastCalorimetry") <<
" p, ecorr, hcorr = " << p <<
" " 1181 std::map<CaloHitID,float>::const_iterator mapitr;
1182 std::map<CaloHitID,float>::const_iterator endmapitr=hitMap.end();
1185 endmapitr=hitMap.end();
1186 for(mapitr=hitMap.begin();mapitr!=endmapitr;++mapitr) {
1188 float energy = mapitr->second;
1192 CaloHitID current_id(mapitr->first.unitID(),mapitr->first.timeSlice(),trackID);
1194 EBMapping_.push_back(std::pair<CaloHitID,float>(current_id,energy));
1197 else if(onEcal==2) {
1199 endmapitr=hitMap.end();
1200 for(mapitr=hitMap.begin();mapitr!=endmapitr;++mapitr) {
1202 float energy = mapitr->second;
1206 CaloHitID current_id(mapitr->first.unitID(),mapitr->first.timeSlice(),trackID);
1208 EEMapping_.push_back(std::pair<CaloHitID,float>(current_id,energy));
1218 std::map<CaloHitID,float>::const_iterator mapitr;
1219 std::map<CaloHitID,float>::const_iterator endmapitr=hitMap.end();
1221 for(mapitr=hitMap.begin(); mapitr!=endmapitr; ++mapitr) {
1223 float energy = mapitr->second;
1226 float time = mapitr->first.timeSlice();
1258 HMapping_.push_back(std::pair<CaloHitID,float>(current_id,energy));
1264 std::map<CaloHitID,float>::const_iterator mapitr;
1265 std::map<CaloHitID,float>::const_iterator endmapitr=hitMap.end();
1267 for(mapitr=hitMap.begin();mapitr!=endmapitr;++mapitr) {
1269 float energy = mapitr->second;
1273 CaloHitID current_id(mapitr->first.unitID(),mapitr->first.timeSlice(),trackID);
1275 ESMapping_.push_back(std::pair<CaloHitID,float>(current_id,energy));
1316 unsigned size=muons.size();
1319 int id = muons[
i].trackId();
1328 muons[
i].setTkPosition(itcheck->trackerSurfacePosition());
1329 muons[
i].setTkMomentum(itcheck->trackerSurfaceMomentum());
1340 if(
track.momentum().perp2() > 1.0 && fabs(
track.momentum().eta()) < 3.0 &&
track.isGlobal()) c.push_back(
track);
1343 if(
track.momentum().perp2() > 1.0 && fabs(
track.momentum().eta()) < 3.0 &&
track.isGlobal()) c.push_back(
track);
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< double > rsp
std::vector< double > k_h
bool noEndVertex() const
no end vertex
RawParticle myElec
A few pointers to save time.
std::vector< std::pair< CaloHitID, float > > ESMapping_
float charge() const
charge
void reconstructHCAL(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
std::vector< PCaloHit > PCaloHitContainer
const ECALProperties * ecalProperties(int onEcal) const
ECAL properties.
double responseHCAL(int _mip, double energy, double eta, int partype, RandomEngineAndDistribution const *)
const RawParticle & vfcalEntrance() const
The particle at VFCAL entrance.
void updateHCAL(const std::map< CaloHitID, float > &hitMap, int trackID=0, float corr=1.0)
GflashPiKShowerProfile * thePiKProfile
double flatShoot(double xmin=0.0, double xmax=1.0) const
double pulledPadSurvivalProbability_
std::vector< double > timeShiftHO_
void updatePreshower(const std::map< CaloHitID, float > &hitMap, int trackID=0, float corr=1.0)
GflashTrajectory * getHelix()
MaterialEffects * theMuonEcalEffects
double crackPadSurvivalProbability_
MaterialEffects * theMuonHcalEffects
void recoHFShowerLibrary(const FSimTrack &myTrack)
const XYZTLorentzVector & momentum() const
Temporary (until move of SimTrack to Mathcore) - No! Actually very useful.
void setCrackPadSurvivalProbability(double val)
double getHCALEnergyResponse(double e, int hit, RandomEngineAndDistribution const *)
GflashHadronShowerProfile * theProfile
const RawParticle & layer1Entrance() const
The particle at Preshower Layer 1.
bool compute()
Compute the shower longitudinal and lateral development.
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void correctHF(double e, int type)
void reconstructTrack(FSimTrack &myTrack, RandomEngineAndDistribution const *)
void setPreshower(PreshowerHitMaker *const myPresh)
set the preshower address
void loadFromPreshower(edm::PCaloHitContainer &c) const
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 std::map< CaloHitID, float > & getHits() override
const CaloSubdetectorGeometry * getHcalGeometry() const
void MuonMipSimulation(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
void readParameters(const edm::ParameterSet &fastCalo)
const PreshowerLayer1Properties * layer1Properties(int onLayer1) const
Preshower Layer1 properties.
static EEDetId unhashIndex(int hi)
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.
std::vector< std::pair< CaloHitID, float > > EBMapping_
std::vector< FSimTrack > muonSimTracks
double radLenIncm() const override
Radiation length in cm.
uint32_t rawId() const
get the raw id
U second(std::pair< T, U > const &p)
void HDShowerSimulation(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
Hadronic Shower Simulation.
const LandauFluctuationGenerator * aLandauGenerator
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
int depth() const
get the tower depth
void reconstruct(RandomEngineAndDistribution const *)
CalorimeterNumber getCalorimeterNumber(const Gflash3Vector &position)
GflashAntiProtonShowerProfile * theAntiProtonProfile
math::XYZVector XYZVector
GflashShowino * getGflashShowino()
GflashProtonShowerProfile * theProtonProfile
const PreshowerLayer2Properties * layer2Properties(int onLayer2) const
Preshower Layer2 properties.
double getPathLengthAtShower()
virtual void loadParameters()
const std::map< CaloHitID, float > & getHits() override
not been done.
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
void setTrackParameters(const XYZNormal &normal, double X0depthoffset, const FSimTrack &theTrack)
void loadFromEcalEndcap(edm::PCaloHitContainer &c) const
const XYZTLorentzVector & deltaMom() const
Returns the actual energy lost.
std::vector< double > radiusPreshowerCorrections_
const HCALProperties * hcalProperties(int onHcal) const
HCAL properties.
Abs< T >::type abs(const T &t)
double getMIPfraction(double energy, double eta)
const RawParticle & ecalEntrance() const
The particle at ECAL entrance.
void setSpotEnergy(double e) override
Set the spot energy.
std::vector< double > theTailIntervals_
std::vector< double > samplingHBHE_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
void loadMuonSimTracks(edm::SimTrackContainer &m) const
unsigned int nTracks() const
Number of tracks.
HCALResponse * myHDResponse_
CaloGeometryHelper * myCalorimeter_
std::vector< double > timeShiftHB_
int ietaAbs() const
get the absolute value of the cell ieta
void initialize(RandomEngineAndDistribution const *random)
const double intLength[kNumberCalorimeter]
std::vector< double > theCoreIntervals_
void getGflashTrajectoryPoint(GflashTrajectoryPoint &point, double s) const
edm::EventID id() const
Method to return the EventId.
const XYZTLorentzVector & vertex() const
the vertex fourvector
void hadronicParameterization()
void loadFromHcal(edm::PCaloHitContainer &c) const
GammaFunctionGenerator * aGammaGenerator
XYZVectorD XYZVector
spatial vector with cartesian internal representation
CLHEP::Hep3Vector Gflash3Vector
std::vector< double > mipValues_
static std::vector< std::pair< int, float > > myZero_
std::vector< FSimTrack > savedMuonSimTracks
bool null() const
is this a null id ?
std::vector< std::pair< CaloHitID, float > > EEMapping_
void setTkPosition(const math::XYZVectorD &pos)
double getPathLengthOnEcal()
void SetRandom(const RandomEngineAndDistribution *)
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
int type() const
particle type (HEP PDT convension)
void harvestMuonSimTracks(edm::SimTrackContainer &m) const
std::vector< unsigned int > evtsToDebug_
int id() const
the index in FBaseSimEvent and other vectors
bool preshowerPresent() const
const std::map< CaloHitID, float > & getHitsMap()
void setPulledPadSurvivalProbability(double val)
const RawParticle & layer2Entrance() const
The particle at Preshower Layer 2.
std::vector< double > k_e
std::vector< GflashHit > & getGflashHitList()
const std::map< CaloHitID, float > & getHits() override
void setTkMomentum(const math::XYZTLorentzVectorD &mom)
const RawParticle & hcalEntrance() const
The particle at HCAL entrance.
std::vector< std::pair< CaloHitID, float > > HMapping_
std::vector< double > samplingHO_
void setPreshowerPresent(bool ps)
FastHFShowerLibrary * theHFShowerLibrary
DetId getClosestCell(const XYZPoint &point, bool ecal, bool central) const
EnergyLossSimulator * energyLossSimulator() const
Return the Energy Loss engine.
std::unique_ptr< KKCorrectionFactors > ecalCorrection
HSParameters * myHSParameters_
std::vector< SimTrack > SimTrackContainer
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
void initialize(int showerType, double energy, double globalTime, double charge, Gflash3Vector &position, Gflash3Vector &momentum)
math::XYZTLorentzVector XYZTLorentzVector
void print() const
print the FBaseSimEvent in an intelligible way
void setHcal(HcalHitMaker *const myHcal)
set the HCAL address
void setGrid(EcalHitMaker *const myGrid)
set the grid address
void EMShowerSimulation(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
std::vector< double > timeShiftHE_
FSimTrack & track(int id) const
Return track with given Id.
double getMaximumOfShower() const
get the depth of the centre of gravity of the shower(s)
void loadFromEcalBarrel(edm::PCaloHitContainer &c) const