68 (1,std::pair<int,float>(0,0.));
144 if( fastCalo.
exists(
"ECALResponseScaling") ) {
190 std::cout <<
" The preshower simulation has been turned on; but no preshower geometry is available " << std::endl;
191 std::cout <<
" Disabling the preshower simulation " << std::endl;
207 LogInfo(
"FastCalorimetry") <<
" ===> pid = " << pid << std::endl;
214 if ( pid == 11 || pid == 22 ) {
218 else if ( myTrack.
onVFcal() ) {
234 else if ( pid < 1000000 ) {
251 std::vector<const RawParticle*> thePart;
255 LogInfo(
"FastCalorimetry") <<
" EMShowerSimulation " <<myTrack << std::endl;
265 if ( myTrack.
type() == 22 &&
myPart.e()<0.055)
return;
269 int onEcal = myTrack.
onEcal();
270 int onHcal = myTrack.
onHcal();
283 XYZPoint layer1entrance,layer2entrance;
319 if ( myTrack.
type() == 22 ) {
325 double eMass = 0.000510998902;
327 double xm=eMass/
myPart.e();
332 xe = random->
flatShoot()*(1.-2.*xm) + xm;
333 weight = 1. - 4./3.*xe*(1.-xe);
334 }
while ( weight < random->flatShoot() );
337 if (
myPart.e()*xe < 0.055 ||
myPart.e()*(1.-xe) < 0.055 ) {
347 thePart.push_back(&
myElec);
348 thePart.push_back(&
myPosi);
359 if(thePart.size()==0)
361 if(myPreshower==
NULL)
return;
368 for(
unsigned ip=0;ip < thePart.size();++ip)
369 if(thePart[ip]->
e() >
maxEnergy) maxEnergy = thePart[ip]->
e();
373 if(maxEnergy>100) size=11;
382 if (maxShower > 20.) maxShower = 2.;
384 double depth((X0depth + maxShower) *
393 if(pivot.subdetId() == 0) {
394 edm::LogWarning(
"CalorimetryManager") <<
"Pivot for egamma e = " << myTrack.
hcalEntrance().e() <<
" is not found at depth " <<
depth <<
" and meanShower coordinates = " << meanShower << std::endl;
395 if(myPreshower)
delete myPreshower;
428 if( (onLayer1 || onLayer2) &&
myPart.e()<=250.)
462 theShower.
setHcal(&myHcalHitMaker);
468 for(
const auto& mapIterator : myGrid.
getHits() ) {
469 simE += mapIterator.second;
496 LogInfo(
"FastCalorimetry") <<
" reconstructHCAL " << myTrack << std::endl;
513 double pathEta = trackPosition.eta();
514 double pathPhi = trackPosition.phi();
525 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - MUON !!!" << std::endl;
527 else if( pid == 22 || pid == 11) {
531 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - e/gamma !!!" << std::endl;
538 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::reconstructHCAL - on-calo " 539 <<
" eta = " << pathEta
540 <<
" phi = " << pathPhi
541 <<
" Egen = " << EGen
542 <<
" Emeas = " << emeas << std::endl;
548 std::map<CaloHitID,float> hitMap;
549 hitMap[current_id] = emeas;
562 <<
"CalorimetryManager::HDShowerSimulation - track param." 564 <<
" eta = " << moment.eta() << std::endl
565 <<
" phi = " << moment.phi() << std::endl
566 <<
" et = " << moment.Et() << std::endl
570 LogInfo(
"FastCalorimetry") <<
" HDShowerSimulation " << myTrack << std::endl;
582 }
else if ( myTrack.
onVFcal()) {
589 LogInfo(
"FastCalorimetry") <<
" The particle is not in the acceptance " << std::endl;
595 int onHCAL = hit + 1;
596 int onECAL = myTrack.
onEcal();
598 double pathEta = trackPosition.eta();
599 double pathPhi = trackPosition.phi();
602 double eint = moment.e();
642 <<
"CalorimetryManager::HDShowerSimulation - on-calo 1 " 644 <<
" onEcal = " << myTrack.
onEcal() << std::endl
645 <<
" onHcal = " << myTrack.
onHcal() << std::endl
646 <<
" onVFcal = " << myTrack.
onVFcal() << std::endl
647 <<
" position = " << caloentrance << std::endl;
654 true, myTrack.
onEcal()==1);
734 int showerType = 99 + myTrack.
onEcal();
735 double globalTime = 150.0;
737 Gflash3Vector gfpos(trackPosition.X(),trackPosition.Y(),trackPosition.Z());
746 std::vector<GflashHit>::const_iterator spotIter = gflashHitList.begin();
747 std::vector<GflashHit>::const_iterator spotIterEnd = gflashHitList.end();
751 for( ; spotIter != spotIterEnd; spotIter++){
754 + (30*100/eGen)*(spotIter->getTime() - globalTime);
761 Gflash3Vector positionAtCurrentDepth = trajectoryPoint.getPosition();
763 Gflash3Vector lateralDisplacement = positionAtCurrentDepth - spotIter->getPosition()/CLHEP::cm;
764 double rShower = lateralDisplacement.r();
765 double azimuthalAngle = lateralDisplacement.phi();
770 bool statusPad = myGrid.getPads(currentDepth,
true);
771 if(!statusPad)
continue;
772 myGrid.setSpotEnergy(1.2*spotIter->getEnergy()/
CLHEP::GeV);
776 bool setHDdepth = myHcalHitMaker.
setDepth(currentDepth,
true);
777 if(!setHDdepth)
continue;
800 double correction = emeas / eGen;
807 <<
"CalorimetryManager::HDShowerSimulation - on-calo 2" << std::endl
808 <<
" eta = " << pathEta << std::endl
809 <<
" phi = " << pathPhi << std::endl
810 <<
" Egen = " << eGen << std::endl
811 <<
" Emeas = " << emeas << std::endl
812 <<
" corr = " << correction << std::endl
813 <<
" mip = " << mip << std::endl;
815 if(myTrack.
onEcal() > 0) {
839 std::map<CaloHitID,float> hitMap;
840 hitMap[current_id] = emeas;
843 LogInfo(
"FastCalorimetry") <<
" HCAL simple cell " 844 << cell.
rawId() <<
" added E = " 845 << emeas << std::endl;
852 LogInfo(
"FastCalorimetry") << std::endl <<
" FASTEnergyReconstructor::HDShowerSimulation finished " 872 LogInfo(
"FastCalorimetry") <<
"CalorimetryManager::MuonMipSimulation - track param." 874 <<
" eta = " << moment.eta() << std::endl
875 <<
" phi = " << moment.phi() << std::endl
876 <<
" et = " << moment.Et() << std::endl;
886 }
else if ( myTrack.
onVFcal()) {
893 LogInfo(
"FastCalorimetry") <<
" The particle is not in the acceptance " << std::endl;
901 int onECAL = myTrack.
onEcal();
934 true, myTrack.
onEcal()==1);
953 const std::vector<CaloSegment>& segments=myGrid.getSegments();
954 unsigned nsegments=segments.size();
965 for(
unsigned iseg=0;iseg<nsegments&&ifirstHcal<0;++iseg)
969 float segmentSizeinX0=segments[iseg].X0length();
977 theMuon.
setID(-(
int)charge*13);
978 if ( energyLossECAL ) {
979 energyLossECAL->
updateState(theMuon, segmentSizeinX0, random);
980 energy = energyLossECAL->
deltaMom().E();
981 moment -= energyLossECAL->
deltaMom();
988 myGrid.getPads(segments[iseg].sX0Entrance()+segmentSizeinX0*0.5);
989 myGrid.setSpotEnergy(energy);
990 myGrid.addHit(0.,0.);
1014 float mipenergy=0.0;
1022 if(ifirstHcal>0 && energyLossHCAL){
1023 for(
unsigned iseg=ifirstHcal;iseg<nsegments;++iseg)
1025 float segmentSizeinX0=segments[iseg].X0length();
1028 if (segmentSizeinX0>0.001) {
1032 theMuon.
setID(-(
int)charge*13);
1033 energyLossHCAL->
updateState(theMuon, segmentSizeinX0, random);
1034 mipenergy = energyLossHCAL->
deltaMom().E();
1035 moment -= energyLossHCAL->
deltaMom();
1037 myHcalHitMaker.
addHit(segments[iseg].entrance());
1053 if(energyLossHCAL && ilastHcal>=0) {
1057 }
else if(energyLossECAL && ilastEcal>=0) {
1067 std::map<CaloHitID,float>::const_iterator mapitr;
1068 std::map<CaloHitID,float>::const_iterator endmapitr;
1069 if(myTrack.
onEcal() > 0) {
1078 LogInfo(
"FastCalorimetry") << std::endl <<
" FASTEnergyReconstructor::MipShowerSimulation finished " 1108 aTerm = 1.+radiusPreshowerCorrections_[1]*radiusPreshowerCorrections_[0];
1109 bTerm = radiusPreshowerCorrections_[0];
1113 if(gridSize_ <1) gridSize_= 7;
1114 if(pulledPadSurvivalProbability_ <0. || pulledPadSurvivalProbability_>1 ) pulledPadSurvivalProbability_= 1.;
1115 if(crackPadSurvivalProbability_ <0. || crackPadSurvivalProbability_>1 ) crackPadSurvivalProbability_= 0.9;
1117 LogInfo(
"FastCalorimetry") <<
" Fast ECAL simulation parameters " << std::endl;
1118 LogInfo(
"FastCalorimetry") <<
" =============================== " << std::endl;
1119 if(simulatePreshower_)
1120 LogInfo(
"FastCalorimetry") <<
" The preshower is present " << std::endl;
1122 LogInfo(
"FastCalorimetry") <<
" The preshower is NOT present " << std::endl;
1123 LogInfo(
"FastCalorimetry") <<
" Grid Size : " << gridSize_ << std::endl;
1124 if(spotFraction_>0.)
1125 LogInfo(
"FastCalorimetry") <<
" Spot Fraction : " << spotFraction_ << std::endl;
1128 LogInfo(
"FastCalorimetry") <<
" Core of the shower " << std::endl;
1129 for(
unsigned ir=0; ir < theCoreIntervals_.size()/2;++ir)
1131 LogInfo(
"FastCalorimetry") <<
" r < " << theCoreIntervals_[ir*2] <<
" R_M : " << theCoreIntervals_[ir*2+1] <<
" ";
1133 LogInfo(
"FastCalorimetry") << std::endl;
1135 LogInfo(
"FastCalorimetry") <<
" Tail of the shower " << std::endl;
1136 for(
unsigned ir=0; ir < theTailIntervals_.size()/2;++ir)
1138 LogInfo(
"FastCalorimetry") <<
" r < " << theTailIntervals_[ir*2] <<
" R_M : " << theTailIntervals_[ir*2+1] <<
" ";
1142 LogInfo(
"FastCalorimetry") <<
"Radius correction factors: EB & EE " << radiusFactorEB_ <<
" : "<< radiusFactorEE_ << std::endl;
1144 LogInfo(
"FastCalorimetry") << std::endl;
1146 LogInfo(
"FastCalorimetry") <<
"Improper number of parameters for the preshower ; using 95keV" << std::endl;
1152 LogInfo(
"FastCalorimetry") <<
" FrontLeakageProbability : " << pulledPadSurvivalProbability_ << std::endl;
1153 LogInfo(
"FastCalorimetry") <<
" GapLossProbability : " << crackPadSurvivalProbability_ << std::endl;
1159 rsp = CalorimeterParam.
getParameter<std::vector<double> >(
"RespCorrP");
1160 LogInfo(
"FastCalorimetry") <<
" RespCorrP (rsp) size " << rsp.size() << std::endl;
1162 if( rsp.size()%3 !=0 ) {
1164 <<
" RespCorrP size is wrong -> no corrections applied !!!" 1172 for(
unsigned i = 0;
i < rsp.size();
i += 3) {
1173 LogInfo(
"FastCalorimetry") <<
"i = " <<
i/3 <<
" p = " << rsp [
i]
1174 <<
" k_e(p) = " << rsp[
i+1]
1175 <<
" k_e(p) = " << rsp[
i+2] << std::endl;
1178 k_e.push_back (rsp[i+1]);
1179 k_h.push_back (rsp[i+2]);
1207 useShowerLibrary = m_HS.getUntrackedParameter<
bool>(
"useShowerLibrary",
false);
1208 useCorrectionSL = m_HS.getUntrackedParameter<
bool>(
"useCorrectionSL",
false);
1221 for (
int i = 0;
i < sizeP;
i++) {
1236 double y1 =
k_e[ip-1];
1237 double y2 =
k_e[ip];
1243 ecorr = (y1 + (y2 - y1) * (p - x1)/(x2 - x1));
1247 hcorr = (y1 + (y2 - y1) * (p - x1)/(x2 - x1));
1254 LogInfo(
"FastCalorimetry") <<
" p, ecorr, hcorr = " << p <<
" " 1261 std::map<CaloHitID,float>::const_iterator mapitr;
1262 std::map<CaloHitID,float>::const_iterator endmapitr=hitMap.end();
1265 endmapitr=hitMap.end();
1266 for(mapitr=hitMap.begin();mapitr!=endmapitr;++mapitr) {
1268 float energy = mapitr->second;
1272 CaloHitID current_id(mapitr->first.unitID(),mapitr->first.timeSlice(),trackID);
1274 EBMapping_.push_back(std::pair<CaloHitID,float>(current_id,energy));
1277 else if(onEcal==2) {
1279 endmapitr=hitMap.end();
1280 for(mapitr=hitMap.begin();mapitr!=endmapitr;++mapitr) {
1282 float energy = mapitr->second;
1286 CaloHitID current_id(mapitr->first.unitID(),mapitr->first.timeSlice(),trackID);
1288 EEMapping_.push_back(std::pair<CaloHitID,float>(current_id,energy));
1298 std::map<CaloHitID,float>::const_iterator mapitr;
1299 std::map<CaloHitID,float>::const_iterator endmapitr=hitMap.end();
1301 for(mapitr=hitMap.begin(); mapitr!=endmapitr; ++mapitr) {
1303 float energy = mapitr->second;
1306 float time = mapitr->first.timeSlice();
1338 HMapping_.push_back(std::pair<CaloHitID,float>(current_id,energy));
1344 std::map<CaloHitID,float>::const_iterator mapitr;
1345 std::map<CaloHitID,float>::const_iterator endmapitr=hitMap.end();
1347 for(mapitr=hitMap.begin();mapitr!=endmapitr;++mapitr) {
1349 float energy = mapitr->second;
1353 CaloHitID current_id(mapitr->first.unitID(),mapitr->first.timeSlice(),trackID);
1355 ESMapping_.push_back(std::pair<CaloHitID,float>(current_id,energy));
1396 unsigned size=muons.size();
1399 int id=muons[
i].trackId();
1400 if(
abs(muons[
i].
type())!=13)
continue;
1406 muons[
i].setTkPosition(itcheck->trackerSurfacePosition());
1407 muons[
i].setTkMomentum(itcheck->trackerSurfaceMomentum());
void setSpotEnergy(double e)
Set the spot energy.
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)
double radLenIncm() const
Radiation length in cm.
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 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 CaloSubdetectorGeometry * getHcalGeometry() const
void MuonMipSimulation(const FSimTrack &myTrack, RandomEngineAndDistribution const *)
void readParameters(const edm::ParameterSet &fastCalo)
const std::map< CaloHitID, float > & getHits()
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)
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_
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< FSimTrack > muonSimTracks
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_
const std::map< CaloHitID, float > & getHits()
bool compute()
Compute the shower longitudinal and lateral development.
void setRadiusFactor(double r)
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()
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.
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
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_
bool null() const
is this a null id ?
const std::map< CaloHitID, float > & getHits()
not been done.
std::vector< std::pair< CaloHitID, float > > EEMapping_
void setTkPosition(const math::XYZVectorD &pos)
double getPathLengthOnEcal()
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
int type() const
particle type (HEP PDT convension)
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()
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
bool addHit(double r, double phi, unsigned layer=0)
add the hit in the HCAL in local coordinates
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
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