CMS 3D CMS Logo

CalorimetryManager Class Reference

#include <FastSimulation/Calorimetry/interface/CalorimetryManager.h>

List of all members.

Public Member Functions

 CalorimetryManager (FSimEvent *aSimEvent, const edm::ParameterSet &fastCalo, const RandomEngine *engine)
 CalorimetryManager ()
CaloGeometryHelpergetCalorimeter () const
void loadFromEcalBarrel (edm::PCaloHitContainer &c) const
void loadFromEcalEndcap (edm::PCaloHitContainer &c) const
void loadFromHcal (edm::PCaloHitContainer &c) const
void loadFromPreshower (edm::PCaloHitContainer &c) const
void reconstruct ()
 ~CalorimetryManager ()

Private Member Functions

void clean ()
void EMShowerSimulation (const FSimTrack &myTrack)
void HDShowerSimulation (const FSimTrack &myTrack)
 Hadronic Shower Simulation.
void readParameters (const edm::ParameterSet &fastCalo)
void reconstructECAL (const FSimTrack &track)
void reconstructHCAL (const FSimTrack &myTrack)
void updateMap (int hi, float energy, int id, std::vector< std::vector< std::pair< int, float > > > &mymap, std::vector< int > &firedCells)
void updateMap (uint32_t cellid, float energy, int id, std::map< uint32_t, std::vector< std::pair< int, float > > > &mymap)

Private Attributes

GammaFunctionGeneratoraGammaGenerator
const LandauFluctuationGeneratoraLandauGenerator
double crackPadSurvivalProbability_
bool debug_
std::vector< std::vector
< std::pair< int, float > > > 
EBMapping_
std::vector< std::vector
< std::pair< int, float > > > 
EEMapping_
std::map< uint32_t,
std::vector< std::pair< int,
float > > > 
ESMapping_
std::vector< intfiredCellsEB_
std::vector< intfiredCellsEE_
std::vector< intfiredCellsHCAL_
int gridSize_
int hdGridSize_
int hdSimMethod_
std::vector< std::vector
< std::pair< int, float > > > 
HMapping_
bool initialized_
CaloGeometryHelpermyCalorimeter_
RawParticle myElec
 A few pointers to save time.
HCALResponsemyHDResponse_
HistosmyHistos
HSParametersmyHSParameters_
RawParticle myPart
RawParticle myPosi
FSimEventmySimEvent
int optionHDSim_
double pulledPadSurvivalProbability_
double radiusFactor_
const RandomEnginerandom
double RCFactor_
double RTFactor_
bool simulatePreshower_
double spotFraction_
std::vector< double > theCoreIntervals_
std::vector< DetIdtheDetIds_
std::vector< double > theTailIntervals_
bool unfoldedMode_

Static Private Attributes

static std::vector< std::pair
< int, float > > 
myZero_


Detailed Description

Definition at line 30 of file CalorimetryManager.h.


Constructor & Destructor Documentation

CalorimetryManager::CalorimetryManager (  ) 

Definition at line 48 of file CalorimetryManager.cc.

00048                                        : 
00049   myCalorimeter_(0),
00050   myHistos(0),
00051   random(0),initialized_(false)
00052 {;}

CalorimetryManager::CalorimetryManager ( FSimEvent aSimEvent,
const edm::ParameterSet fastCalo,
const RandomEngine engine 
)

Definition at line 54 of file CalorimetryManager.cc.

References aGammaGenerator, aLandauGenerator, Histos::book(), Histos::bookByNumber(), EBMapping_, EEMapping_, edm::ParameterSet::getParameter(), HMapping_, Histos::instance(), myCalorimeter_, myHDResponse_, myHistos, myHSParameters_, random, readParameters(), s, theDetIds_, and unfoldedMode_.

00057   : 
00058   mySimEvent(aSimEvent), 
00059   random(engine),initialized_(false)
00060 
00061 {
00062 
00063   aLandauGenerator = new LandauFluctuationGenerator(random);
00064   aGammaGenerator = new GammaFunctionGenerator(random);
00065 
00066   readParameters(fastCalo);
00067 
00068 //  EBMapping_.resize(62000,myZero_);
00069 //  EEMapping_.resize(20000,myZero_);
00070 //  HMapping_.resize(10000,myZero_);
00071   EBMapping_.resize(62000);
00072   EEMapping_.resize(20000);
00073   HMapping_.resize(10000);
00074   theDetIds_.resize(10000);
00075 
00076   unsigned s=(unfoldedMode_)?5:1;
00077   for(unsigned ic=0;ic<62000;++ic)
00078     {
00079       EBMapping_[ic].reserve(s);
00080       if(ic<20000)
00081         EEMapping_[ic].reserve(s);
00082       if(ic<10000)
00083         HMapping_[ic].reserve(s);
00084     }
00085   
00086 
00087 
00088   myHistos = 0; 
00089 #ifdef FAMOSDEBUG
00090   myHistos = Histos::instance();
00091   myHistos->book("h10",140,-3.5,3.5,100,-0.5,99.5);
00092   myHistos->book("h20",150,0,150.,100,-0.5,99.5);
00093   myHistos->book("h100",140,-3.5,3.5,100,0,0.1);
00094   myHistos->book("h110",140,-3.5,3.5,100,0,10.);
00095   myHistos->book("h120",200,-5.,5.,100,0,0.5);
00096 
00097   myHistos->book("h200",300,0,3.,100,0.,35.);
00098   myHistos->book("h210",720,-M_PI,M_PI,100,0,35.);
00099   myHistos->book("h212",720,-M_PI,M_PI,100,0,35.);
00100 
00101   myHistos->bookByNumber("h30",0,7,300,-3.,3.,100,0.,35.);
00102   myHistos->book("h310",75,-3.,3.,"");
00103   myHistos->book("h400",100,-10.,10.,100,0.,35.);
00104   myHistos->book("h410",720,-M_PI,M_PI);
00105 #endif
00106   myCalorimeter_ = 
00107     new CaloGeometryHelper(fastCalo);
00108   myHDResponse_ = 
00109     new HCALResponse(fastCalo.getParameter<edm::ParameterSet>("HCALResponse"),
00110                      random);
00111   myHSParameters_ = 
00112     new HSParameters(fastCalo.getParameter<edm::ParameterSet>("HSParameters"));
00113 
00114 
00115 }

CalorimetryManager::~CalorimetryManager (  ) 

Definition at line 144 of file CalorimetryManager.cc.

References myCalorimeter_, myHDResponse_, myHistos, and Histos::put().

00145 {
00146 #ifdef FAMOSDEBUG
00147   myHistos->put("Famos.root");
00148 #endif
00149   if(myCalorimeter_) delete myCalorimeter_;
00150   if(myHDResponse_) delete myHDResponse_;
00151 }


Member Function Documentation

void CalorimetryManager::clean (  )  [private]

Definition at line 117 of file CalorimetryManager.cc.

References EBMapping_, EEMapping_, ESMapping_, firedCellsEB_, firedCellsEE_, firedCellsHCAL_, HMapping_, and size.

Referenced by reconstruct().

00118 {
00119   unsigned size=firedCellsEB_.size();
00120   for(unsigned ic=0;ic<size;++ic)
00121     {
00122       EBMapping_[firedCellsEB_[ic]].clear();
00123     }
00124   firedCellsEB_.clear();
00125 
00126   size=firedCellsEE_.size();
00127   for(unsigned ic=0;ic<size;++ic)
00128     {
00129       EEMapping_[firedCellsEE_[ic]].clear();
00130     }
00131   firedCellsEE_.clear();
00132   
00133   size=firedCellsHCAL_.size();
00134   for(unsigned ic=0;ic<size;++ic)
00135     {
00136       HMapping_[firedCellsHCAL_[ic]].clear();
00137     }
00138   firedCellsHCAL_.clear();
00139 
00140   ESMapping_.clear();
00141 
00142 }

void CalorimetryManager::EMShowerSimulation ( const FSimTrack myTrack  )  [private]

Definition at line 225 of file CalorimetryManager.cc.

References aGammaGenerator, aLandauGenerator, EMShower::compute(), crackPadSurvivalProbability_, e, EBMapping_, FSimTrack::ecalEntrance(), Calorimeter::ecalProperties(), EEMapping_, ESMapping_, firedCellsEB_, firedCellsEE_, firedCellsHCAL_, RandomEngine::flatShoot(), CaloGeometryHelper::getClosestCell(), PreshowerHitMaker::getHits(), HcalHitMaker::getHits(), EMShower::getMaximumOfShower(), gridSize_, Calorimeter::hcalProperties(), HMapping_, FSimTrack::id(), FSimTrack::layer1Entrance(), Calorimeter::layer1Properties(), FSimTrack::layer2Entrance(), Calorimeter::layer2Properties(), funct::log(), myCalorimeter_, myElec, myPart, myPosi, NULL, FSimTrack::onEcal(), FSimTrack::onHcal(), FSimTrack::onLayer1(), FSimTrack::onLayer2(), pulledPadSurvivalProbability_, radiusFactor_, ECALProperties::radLenIncm(), random, RCFactor_, RTFactor_, EMShower::setGrid(), EMShower::setHcal(), EMShower::setPreshower(), RawParticle::setVertex(), simulatePreshower_, size, theCoreIntervals_, theTailIntervals_, CoreSimTrack::type(), updateMap(), RawParticle::vertex(), and weight.

Referenced by reconstruct().

00225                                                                     {
00226   std::vector<const RawParticle*> thePart;
00227   double X0depth;
00228   
00229   //  std::cout << " Simulating " << myTrack << std::endl;
00230 
00231   // The Particle at ECAL entrance
00232   //  std::cout << " Before ecalEntrance " << std::endl;
00233   myPart = myTrack.ecalEntrance(); 
00234 
00235   // protection against infinite loop.  
00236   if ( myTrack.type() == 22 && myPart.e()<0.055) return; 
00237 
00238 
00239   // Barrel or Endcap ?
00240   int onEcal = myTrack.onEcal();
00241   int onHcal = myTrack.onHcal();
00242   int onLayer1 = myTrack.onLayer1();
00243   int onLayer2 = myTrack.onLayer2();
00244 
00245   // The entrance in ECAL
00246   XYZPoint ecalentrance = myPart.vertex().Vect();
00247   
00248   //  std::cout << " Ecal entrance " << ecalentrance << std::endl;
00249   
00250   // The preshower
00251   PreshowerHitMaker * myPreshower = NULL ;
00252   if(simulatePreshower_ && (onLayer1 || onLayer2))
00253     {
00254       XYZPoint layer1entrance,layer2entrance;
00255       XYZVector dir1,dir2;
00256       if(onLayer1) 
00257         {
00258           layer1entrance = XYZPoint(myTrack.layer1Entrance().vertex().Vect());
00259           dir1 = XYZVector(myTrack.layer1Entrance().Vect().Unit());
00260         }
00261       if(onLayer2) 
00262         {
00263           layer2entrance = XYZPoint(myTrack.layer2Entrance().vertex().Vect());
00264           dir2 = XYZVector(myTrack.layer2Entrance().Vect().Unit());
00265         }
00266       //      std::cout << " Layer1entrance " << layer1entrance << std::endl;
00267       //      std::cout << " Layer2entrance " << layer2entrance << std::endl;
00268       myPreshower = new PreshowerHitMaker(myCalorimeter_,
00269                                           layer1entrance,
00270                                           dir1,
00271                                           layer2entrance,
00272                                           dir2,
00273                                           aLandauGenerator);
00274     }
00275 
00276   // The ECAL Properties
00277   EMECALShowerParametrization 
00278     showerparam(myCalorimeter_->ecalProperties(onEcal), 
00279                 myCalorimeter_->hcalProperties(onHcal), 
00280                 myCalorimeter_->layer1Properties(onLayer1), 
00281                 myCalorimeter_->layer2Properties(onLayer2),
00282                 theCoreIntervals_,
00283                 theTailIntervals_,
00284                 RCFactor_,
00285                 RTFactor_);
00286 
00287   // Photons : create an e+e- pair
00288   if ( myTrack.type() == 22 ) {
00289     
00290     // Depth for the first e+e- pair creation (in X0)
00291     X0depth = -log(random->flatShoot()) * (9./7.);
00292     
00293     // Initialization
00294     double eMass = 0.000510998902; 
00295     double xe=0;
00296     double xm=eMass/myPart.e();
00297     double weight = 0.;
00298     
00299     // Generate electron energy between emass and eGamma-emass
00300     do {
00301       xe = random->flatShoot()*(1.-2.*xm) + xm;
00302       weight = 1. - 4./3.*xe*(1.-xe);
00303     } while ( weight < random->flatShoot() );
00304     
00305     // Protection agains infinite loop in Famos Shower
00306     if ( myPart.e()*xe < 0.055 || myPart.e()*(1.-xe) < 0.055 ) {
00307       
00308       if ( myPart.e() > 0.055 ) thePart.push_back(&myPart);
00309       
00310     } else {      
00311       
00312       myElec = (myPart) * xe;
00313       myPosi = (myPart) * (1.-xe);
00314       myElec.setVertex(myPart.vertex());
00315       myPosi.setVertex(myPart.vertex());
00316       thePart.push_back(&myElec);
00317       thePart.push_back(&myPosi);
00318     }
00319   // Electrons
00320   } else {  
00321     
00322     X0depth = 0.;
00323     if ( myPart.e() > 0.055 ) thePart.push_back(&myPart);
00324     
00325   } 
00326   
00327   // After the different protections, this shouldn't happen. 
00328   if(thePart.size()==0) 
00329     { 
00330       if(myPreshower==NULL) return; 
00331       delete myPreshower; 
00332       return; 
00333     } 
00334 
00335   // find the most energetic particle
00336   double maxEnergy=-1.;
00337   for(unsigned ip=0;ip < thePart.size();++ip)
00338     if(thePart[ip]->e() > maxEnergy) maxEnergy = thePart[ip]->e();
00339   
00340   // Initialize the Grid in ECAL
00341   int size = gridSize_;
00342   if(maxEnergy>100) size=11;
00343 //  if ( maxEnergy < threshold5x5 ) size = 5;
00344 //  if ( maxEnergy < threshold3x3 ) size = 3;
00345 
00346 
00347   EMShower theShower(random,aGammaGenerator,&showerparam,&thePart);
00348 
00349 
00350   double depth((X0depth+theShower.getMaximumOfShower())*myCalorimeter_->ecalProperties(onEcal)->radLenIncm());
00351   XYZPoint meanShower=ecalentrance+myPart.Vect().Unit()*depth;
00352   
00353   //  if(onEcal!=1) return ; 
00354 
00355   // The closest crystal
00356   DetId pivot(myCalorimeter_->getClosestCell(meanShower, true, onEcal==1));
00357 
00358   //  std::cout << " After getClosestCell " << std::endl;
00359   
00360   EcalHitMaker myGrid(myCalorimeter_,ecalentrance,pivot,onEcal,size,0,random);
00361   //                                             ^^^^
00362   //                                         for EM showers
00363   myGrid.setPulledPadSurvivalProbability(pulledPadSurvivalProbability_);
00364   myGrid.setCrackPadSurvivalProbability(crackPadSurvivalProbability_);
00365   myGrid.setRadiusFactor(radiusFactor_);
00366   myGrid.setPreshowerPresent(simulatePreshower_);
00367   
00368   // The shower simulation
00369   myGrid.setTrackParameters(myPart.Vect().Unit(),X0depth,myTrack);
00370 
00371 //  std::cout << " PS ECAL GAP HCAL X0 " << myGrid.ps1TotalX0()+myGrid.ps2TotalX0() << " " << myGrid.ecalTotalX0();
00372 //  std::cout << " " << myGrid.ecalHcalGapTotalX0() << " " << myGrid.hcalTotalX0() << std::endl;
00373 //  std::cout << " PS ECAL GAP HCAL L0 " << myGrid.ps1TotalL0()+myGrid.ps2TotalL0() << " " << myGrid.ecalTotalL0();
00374 //   std::cout << " " << myGrid.ecalHcalGapTotalL0() << " " << myGrid.hcalTotalL0() << std::endl;
00375 //   std::cout << "ECAL-HCAL " << myTrack.momentum().eta() << " " <<  myGrid.ecalHcalGapTotalL0() << std::endl;
00376 //
00377 //  std::cout << " Grid created " << std::endl;
00378   if(myPreshower) theShower.setPreshower(myPreshower);
00379   
00380   HcalHitMaker myHcalHitMaker(myGrid,(unsigned)0); 
00381 
00382   theShower.setGrid(&myGrid);
00383   theShower.setHcal(&myHcalHitMaker);
00384   //  std:: cout << " About to compute " << std::endl;
00385   theShower.compute();
00386   //  std::cout << " Coming back from compute" << std::endl;
00387   //myHistos->fill("h502", myPart->eta(),myGrid.totalX0());
00388   
00389   // Save the hits !
00390   std::map<uint32_t,float>::const_iterator mapitr;
00391   std::map<uint32_t,float>::const_iterator endmapitr=myGrid.getHits().end();
00392   for(mapitr=myGrid.getHits().begin();mapitr!=endmapitr;++mapitr)
00393     {
00394       if(onEcal==1)
00395         {
00396           updateMap(EBDetId(mapitr->first).hashedIndex(), mapitr->second,myTrack.id(),EBMapping_,firedCellsEB_);
00397         }
00398             
00399       else if(onEcal==2)
00400         updateMap(EEDetId(mapitr->first).hashedIndex(), mapitr->second,myTrack.id(),EEMapping_,firedCellsEE_);
00401       //      std::cout << " Adding " <<mapitr->first << " " << mapitr->second <<std::endl; 
00402     }
00403 
00404   // Now fill the HCAL hits
00405   endmapitr=myHcalHitMaker.getHits().end();
00406   for(mapitr=myHcalHitMaker.getHits().begin();mapitr!=endmapitr;++mapitr)
00407     {
00408       updateMap(HcalDetId(mapitr->first).hashed_index(),mapitr->second,myTrack.id(),HMapping_,firedCellsHCAL_);
00409       //      std::cout << " Adding " <<mapitr->first << " " << mapitr->second <<std::endl; 
00410     }
00411 
00412   // delete the preshower
00413   if(myPreshower!=0)
00414     {
00415       endmapitr=myPreshower->getHits().end();
00416       for(mapitr=myPreshower->getHits().begin();mapitr!=endmapitr;++mapitr)
00417         {
00418           updateMap(mapitr->first,mapitr->second,myTrack.id(),ESMapping_);
00419           //      std::cout << " Adding " <<mapitr->first << " " << mapitr->second <<std::endl; 
00420         }
00421       delete myPreshower;
00422     }
00423   //  std::cout << " Deleting myPreshower " << std::endl;
00424   
00425 }

CaloGeometryHelper* CalorimetryManager::getCalorimeter (  )  const [inline]

Definition at line 43 of file CalorimetryManager.h.

References myCalorimeter_.

Referenced by FamosManager::setupGeometryAndField().

00043 {return myCalorimeter_;}

void CalorimetryManager::HDShowerSimulation ( const FSimTrack myTrack  )  [private]

Hadronic Shower Simulation.

Definition at line 587 of file CalorimetryManager.cc.

References HFShower::compute(), HDShower::compute(), HDRShower::computeShower(), debug_, direction, e, EBMapping_, FSimTrack::ecalEntrance(), Calorimeter::ecalProperties(), EEMapping_, lat::endl(), relval_parameters_module::energy, firedCellsEB_, firedCellsEE_, firedCellsHCAL_, RandomEngine::gaussShoot(), CaloGeometryHelper::getClosestCell(), HCALResponse::getHCALEnergyResolution(), HCALResponse::getHCALEnergyResponse(), HcalHitMaker::getHits(), HDShower::getmip(), FSimTrack::hcalEntrance(), Calorimeter::hcalProperties(), hdGridSize_, hdSimMethod_, HMapping_, FSimTrack::id(), LogDebug, FSimTrack::momentum(), myCalorimeter_, myHDResponse_, myHSParameters_, myPart, DetId::null(), FSimTrack::onEcal(), FSimTrack::onHcal(), FSimTrack::onVFcal(), optionHDSim_, random, DetId::rawId(), HCALResponse::responseHCAL(), StDecayID::status, updateMap(), RawParticle::vertex(), and FSimTrack::vfcalEntrance().

Referenced by reconstruct().

00588 {
00589   //  TimeMe t(" FASTEnergyReconstructor::HDShower");
00590   XYZTLorentzVector moment = myTrack.momentum();
00591 
00592   if(debug_)
00593     LogDebug("FastCalorimetry") << "CalorimetryManager::HDShowerSimulation - track param."
00594          << std::endl
00595          << "  eta = " << moment.eta() << std::endl
00596          << "  phi = " << moment.phi() << std::endl
00597          << "   et = " << moment.Et()  << std::endl;
00598 
00599   int hit;
00600   //  int pid = abs(myTrack.type());
00601 
00602   XYZTLorentzVector trackPosition;
00603   if ( myTrack.onEcal() ) {
00604     trackPosition=myTrack.ecalEntrance().vertex();
00605     hit = myTrack.onEcal()-1;                               //
00606     myPart = myTrack.ecalEntrance();
00607   } else if ( myTrack.onVFcal()) {
00608     trackPosition=myTrack.vfcalEntrance().vertex();
00609     hit = 2;
00610     myPart = myTrack.vfcalEntrance();
00611   }
00612   else
00613     {
00614       LogDebug("FastCalorimetry") << " The particle is not in the acceptance " << std::endl;
00615       return;
00616     }
00617 
00618   // int onHCAL = hit + 1; - specially for myCalorimeter->hcalProperties(onHCAL)
00619   // (below) to get VFcal properties ...
00620   int onHCAL = hit + 1;
00621   int onECAL = myTrack.onEcal();
00622   
00623   double pathEta   = trackPosition.eta();
00624   double pathPhi   = trackPosition.phi();       
00625   //  double pathTheta = trackPosition.theta();
00626 
00627   double eGen  = myTrack.hcalEntrance().e();
00628   double e     = 0.;
00629   double sigma = 0.;
00630 
00631   double emeas = 0.;  
00632   
00633   //===========================================================================
00634   if(eGen > 0.) {  
00635 
00636     // ECAL and HCAL properties to get
00637     HDShowerParametrization 
00638       theHDShowerparam(myCalorimeter_->ecalProperties(onECAL),
00639                        myCalorimeter_->hcalProperties(onHCAL),
00640                        myHSParameters_);
00641     
00642     //Making ECAL Grid (and segments calculation)
00643     XYZPoint caloentrance;
00644     XYZVector direction;
00645     if(myTrack.onEcal()) 
00646       { 
00647         caloentrance = myTrack.ecalEntrance().vertex().Vect();
00648         direction = myTrack.ecalEntrance().Vect().Unit();
00649       }
00650     else if(myTrack.onHcal())
00651       {
00652         caloentrance = myTrack.hcalEntrance().vertex().Vect();
00653         direction = myTrack.hcalEntrance().Vect().Unit();
00654       }
00655     else
00656       {
00657         caloentrance = myTrack.vfcalEntrance().vertex().Vect();
00658         direction = myTrack.vfcalEntrance().Vect().Unit();
00659       }
00660 
00661     DetId pivot;
00662     if(myTrack.onEcal())
00663       {
00664         pivot=myCalorimeter_->getClosestCell(caloentrance,
00665                                              true, myTrack.onEcal()==1);
00666       }
00667     else if(myTrack.onHcal())
00668       {
00669         //      std::cout << " CalorimetryManager onHcal " <<  myTrack.onHcal() << " caloentrance" << caloentrance  << std::endl;
00670         pivot=myCalorimeter_->getClosestCell(caloentrance,                                           
00671                                             false, false);
00672       }
00673 
00674     EcalHitMaker myGrid(myCalorimeter_,caloentrance,pivot,
00675                         pivot.null()? 0 : myTrack.onEcal(),hdGridSize_,1,
00676                         random);
00677     // 1=HAD shower
00678 
00679     myGrid.setTrackParameters(direction,0,myTrack);
00680     // Build the FAMOS HCAL 
00681     HcalHitMaker myHcalHitMaker(myGrid,(unsigned)1); 
00682     
00683     // Shower simulation
00684     bool status;
00685     int  mip = 2;
00686     // Use HFShower for HF
00687     if ( !myTrack.onEcal() && !myTrack.onHcal() ) {
00688       //      std::cout << "CalorimetryManager::HDShowerSimulation(): track entrance = "
00689       //                << myTrack.vfcalEntrance().vertex().X() << " "
00690       //                << myTrack.vfcalEntrance().vertex().Y() << " "
00691       //                << myTrack.vfcalEntrance().vertex().Z() << " "
00692       //                << " , Energy (Gen/Scale) = " << eGen << " " << e << std::endl;
00693 
00694       // Warning : We give here the particle energy with the response
00695       //           but without the resolution/gaussian smearing
00696       //           For HF, the resolution is due to the PE statistic
00697 
00698       HFShower theShower(random,
00699                          &theHDShowerparam,
00700                          &myGrid,
00701                          &myHcalHitMaker,
00702                          onECAL,
00703                          eGen);
00704                          //                      eGen);
00705                          //                      e); // PV Warning : temporarly set the energy to the generated E
00706 
00707       status = theShower.compute();
00708     } else { 
00709       if(hdSimMethod_ == 0) {
00710         HDShower theShower(random,
00711                            &theHDShowerparam,
00712                            &myGrid,
00713                            &myHcalHitMaker,
00714                            onECAL,
00715                            eGen);
00716         status = theShower.compute();
00717         mip    = theShower.getmip();
00718       }
00719       else {
00720         HDRShower theShower(random,
00721                             &theHDShowerparam,
00722                             &myGrid,
00723                             &myHcalHitMaker,
00724                             onECAL,
00725                             eGen);
00726         status = theShower.computeShower();
00727         mip = 2;
00728       }
00729     }
00730     
00731     if(status) {
00732 
00733       // Here to switch between simple formulae and parameterized response
00734       if(optionHDSim_ == 1) {
00735         e     = myHDResponse_->getHCALEnergyResponse  (eGen, hit);
00736         sigma = myHDResponse_->getHCALEnergyResolution(eGen, hit);
00737       }
00738       else { // optionHDsim == 2
00739         std::pair<double,double> response =
00740           myHDResponse_->responseHCAL(mip, eGen, pathEta, 1); // 1=hadron
00741         e     = response.first;
00742         sigma = response.second;
00743       }
00744       
00745       emeas = random->gaussShoot(e,sigma);      
00746       double correction = emeas / eGen;
00747 
00748       if(debug_)
00749         LogDebug("FastCalorimetry") 
00750           << "CalorimetryManager::HDShowerSimulation - on-calo " << std::endl
00751           << "   eta  = " << pathEta << std::endl
00752           << "   phi  = " << pathPhi << std::endl
00753           << "  Egen  = " << eGen << std::endl
00754           << "  Eres  = " << e << std::endl
00755           << " sigma  = " << sigma << std::endl
00756           << "  Emeas = " << emeas << std::endl;
00757       
00758       
00759       // was map<unsigned,double> but CaloHitMaker uses float
00760       std::map<unsigned,float>::const_iterator mapitr;
00761       std::map<unsigned,float>::const_iterator endmapitr;
00762       if(myTrack.onEcal() > 0) {
00763         // Save ECAL hits 
00764         endmapitr=myGrid.getHits().end();
00765         for(mapitr=myGrid.getHits().begin(); mapitr!=endmapitr; ++mapitr) {
00766           double energy = mapitr->second;
00767           energy *= correction;              // RESCALING 
00768           if(energy > 0.000001) { 
00769             if(onECAL==1)
00770                 updateMap(EBDetId(mapitr->first).hashedIndex(),energy,myTrack.id(),EBMapping_,firedCellsEB_);
00771 
00772             else if(onECAL==2)
00773               updateMap(EEDetId(mapitr->first).hashedIndex(),energy,myTrack.id(),EEMapping_,firedCellsEE_);
00774 
00775             if(debug_)
00776               LogDebug("FastCalorimetry") << " ECAL cell " << mapitr->first << " added,  E = " 
00777                    << energy << std::endl;  
00778           }
00779         }
00780       }
00781       
00782       // Save HCAL hits
00783       endmapitr=myHcalHitMaker.getHits().end();
00784       for(mapitr=myHcalHitMaker.getHits().begin(); mapitr!=endmapitr; ++mapitr) {
00785         double energy = mapitr->second;
00786         energy *= correction;              // RESCALING 
00787 
00788         updateMap(HcalDetId(mapitr->first).hashed_index(),energy,myTrack.id(),HMapping_,firedCellsHCAL_);
00789         if(debug_)
00790           LogDebug("FastCalorimetry") << " HCAL cell "  
00791                << mapitr->first << " added    E = " 
00792                << mapitr->second << std::endl;  
00793       }
00794     }      
00795     else {  // shower simulation failed  
00796 //      std::cout << " Shower simulation failed " << trackPosition.Vect() << std::endl;
00797 //      std::cout << " The FSimTrack " << myTrack << std::endl;
00798 //      std::cout << " HF entrance on VFcal" << myTrack.onVFcal() << std::endl;
00799 //      std::cout << " trackPosition.eta() " << trackPosition.eta() << std::endl;
00800       if(myTrack.onHcal() || myTrack.onVFcal())
00801         {
00802           DetId cell = myCalorimeter_->getClosestCell(trackPosition.Vect(),false,false);
00803           updateMap(HcalDetId(cell).hashed_index(),emeas,myTrack.id(),HMapping_,firedCellsHCAL_);
00804           if(debug_)
00805             LogDebug("FastCalorimetry") << " HCAL simple cell "   
00806                                         << cell.rawId() << " added    E = " 
00807                                         << emeas << std::endl;  
00808         }
00809     }
00810 
00811   } // e > 0. ...
00812 
00813   if(debug_)
00814     LogDebug("FastCalorimetry") << std::endl << " FASTEnergyReconstructor::HDShowerSimulation  finished "
00815          << std::endl;
00816 }

void CalorimetryManager::loadFromEcalBarrel ( edm::PCaloHitContainer c  )  const

Definition at line 934 of file CalorimetryManager.cc.

References EBMapping_, firedCellsEB_, first, npart, edm::second(), size, unfoldedMode_, and EBDetId::unhashIndex().

Referenced by FamosProducer::produce().

00935 { 
00936   unsigned size=firedCellsEB_.size();
00937   //  float sum=0.;
00938   for(unsigned ic=0;ic<size;++ic)
00939     {
00940       int hi=firedCellsEB_[ic];
00941       if(!unfoldedMode_)
00942         {
00943           c.push_back(PCaloHit(EBDetId::unhashIndex(hi),EBMapping_[hi][0].second,0.,0));
00944           //      std::cout << "Adding " << hi << " " << EBDetId::unhashIndex(hi) << " " ;
00945           //      std::cout << EBMapping_[hi][0].second << " " << EBMapping_[hi][0].first << std::endl;
00946         }
00947       else
00948         {
00949           unsigned npart=EBMapping_[hi].size();
00950           for(unsigned ip=0;ip<npart;++ip)
00951             {
00952               c.push_back(PCaloHit(EBDetId::unhashIndex(hi),EBMapping_[hi][ip].second,0.,
00953                                    EBMapping_[hi][ip].first));
00954 
00955             }
00956         }
00957         
00958       //      sum+=cellit->second;
00959     }
00960   
00961 //  for(unsigned ic=0;ic<61200;++ic) 
00962 //    { 
00963 //      EBDetId myCell(EBDetId::unhashIndex(ic)); 
00964 //      if(!myCell.null()) 
00965 //        { 
00966 //        float total=0.;
00967 //        for(unsigned id=0;id<EBMapping_[ic].size();++id)
00968 //          total+=EBMapping_[ic][id].second;
00969 //        if(EBMapping_[ic].size()>0)
00970 //          std::cout << "Adding " << ic << " " << myCell << " " << std::setprecision(8) <<total << std::endl; 
00971 //        } 
00972 //    } 
00973 
00974 
00975   //  std::cout << " SUM : " << sum << std::endl;
00976   //  std::cout << " Added " <<c.size() << " hits " <<std::endl;
00977 }

void CalorimetryManager::loadFromEcalEndcap ( edm::PCaloHitContainer c  )  const

Definition at line 980 of file CalorimetryManager.cc.

References EEMapping_, firedCellsEE_, first, npart, edm::second(), size, unfoldedMode_, and EEDetId::unhashIndex().

Referenced by FamosProducer::produce().

00981 {
00982   unsigned size=firedCellsEE_.size();
00983   //  float sum=0.;
00984   for(unsigned ic=0;ic<size;++ic)
00985     {
00986       int hi=firedCellsEE_[ic];
00987       if(!unfoldedMode_)
00988         c.push_back(PCaloHit(EEDetId::unhashIndex(hi),EEMapping_[hi][0].second,0.,0));
00989       else
00990         {
00991           unsigned npart=EEMapping_[hi].size();
00992           for(unsigned ip=0;ip<npart;++ip)
00993             c.push_back(PCaloHit(EEDetId::unhashIndex(hi),EEMapping_[hi][ip].second,0.,
00994                                  EEMapping_[hi][ip].first));
00995         }
00996         
00997       //      sum+=cellit->second;
00998     }
00999   //  std::cout << " SUM : " << sum << std::endl;
01000   //  std::cout << " Added " <<c.size() << " hits " <<std::endl;
01001 }

void CalorimetryManager::loadFromHcal ( edm::PCaloHitContainer c  )  const

Definition at line 1003 of file CalorimetryManager.cc.

References firedCellsHCAL_, first, HMapping_, npart, edm::second(), size, theDetIds_, and unfoldedMode_.

Referenced by FamosProducer::produce().

01004 {
01005   unsigned size=firedCellsHCAL_.size();
01006   //  float sum=0.;
01007   for(unsigned ic=0;ic<size;++ic)
01008     {
01009       int hi=firedCellsHCAL_[ic];
01010       if(!unfoldedMode_)
01011         c.push_back(PCaloHit(theDetIds_[hi],HMapping_[hi][0].second,0.,0));
01012       else
01013         {
01014           unsigned npart=HMapping_[hi].size();
01015           for(unsigned ip=0;ip<npart;++ip)
01016             c.push_back(PCaloHit(theDetIds_[hi],HMapping_[hi][ip].second,0.,
01017                                  HMapping_[hi][ip].first));
01018         }
01019         
01020       //      sum+=cellit->second;
01021     }
01022   //  std::cout << " SUM : " << sum << std::endl;
01023   //  std::cout << " Added " <<c.size() << " hits " <<std::endl;
01024 }

void CalorimetryManager::loadFromPreshower ( edm::PCaloHitContainer c  )  const

Definition at line 1026 of file CalorimetryManager.cc.

References ESMapping_, npart, and unfoldedMode_.

Referenced by FamosProducer::produce().

01027 {
01028   std::map<uint32_t,std::vector<std::pair< int,float> > >::const_iterator cellit;
01029   std::map<uint32_t,std::vector<std::pair <int,float> > >::const_iterator preshEnd=ESMapping_.end();
01030   
01031   for(cellit=ESMapping_.begin();cellit!=preshEnd;++cellit)
01032     {
01033       if(!unfoldedMode_)        
01034         c.push_back(PCaloHit(cellit->first,cellit->second[0].second,0.,0));
01035       else
01036         {
01037           unsigned npart=cellit->second.size();
01038           for(unsigned ip=0;ip<npart;++ip)
01039             {
01040               c.push_back(PCaloHit(cellit->first,cellit->second[ip].second,0.,cellit->second[ip].first));
01041             }
01042         }
01043     }
01044 }

void CalorimetryManager::readParameters ( const edm::ParameterSet fastCalo  )  [private]

Definition at line 820 of file CalorimetryManager.cc.

References crackPadSurvivalProbability_, debug_, lat::endl(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), gridSize_, hdGridSize_, hdSimMethod_, optionHDSim_, pulledPadSurvivalProbability_, radiusFactor_, RCFactor_, RTFactor_, simulatePreshower_, spotFraction_, theCoreIntervals_, theTailIntervals_, and unfoldedMode_.

Referenced by CalorimetryManager().

00820                                                                        {
00821   edm::ParameterSet ECALparameters = fastCalo.getParameter<edm::ParameterSet>("ECAL");
00822   gridSize_ = ECALparameters.getParameter<int>("GridSize");
00823   spotFraction_ = ECALparameters.getParameter<double>("SpotFraction");
00824   pulledPadSurvivalProbability_ = ECALparameters.getParameter<double>("FrontLeakageProbability");
00825   crackPadSurvivalProbability_ = ECALparameters.getParameter<double>("GapLossProbability");
00826   debug_ = ECALparameters.getUntrackedParameter<bool>("Debug");
00827   
00828   theCoreIntervals_ = ECALparameters.getParameter<std::vector<double> >("CoreIntervals");
00829   theTailIntervals_ = ECALparameters.getParameter<std::vector<double> >("TailIntervals");
00830   
00831   RCFactor_ = ECALparameters.getParameter<double>("RCFactor");
00832   RTFactor_ = ECALparameters.getParameter<double>("RTFactor");
00833   radiusFactor_ = ECALparameters.getParameter<double>("RadiusFactor");
00834   simulatePreshower_ = ECALparameters.getParameter<bool>("SimulatePreshower");
00835 
00836   if(gridSize_ <1) gridSize_= 7;
00837   if(pulledPadSurvivalProbability_ <0. || pulledPadSurvivalProbability_>1 ) pulledPadSurvivalProbability_= 1.;
00838   if(crackPadSurvivalProbability_ <0. || crackPadSurvivalProbability_>1 ) crackPadSurvivalProbability_= 0.9;
00839   
00840   LogInfo("FastCalorimetry") << " Fast ECAL simulation parameters " << std::endl;
00841   LogInfo("FastCalorimetry") << " =============================== " << std::endl;
00842   if(simulatePreshower_)
00843     LogInfo("FastCalorimetry") << " The preshower is present " << std::endl;
00844   else
00845     LogInfo("FastCalorimetry") << " The preshower is NOT present " << std::endl;
00846   LogInfo("FastCalorimetry") << " Grid Size : " << gridSize_  << std::endl; 
00847   if(spotFraction_>0.) 
00848     LogInfo("FastCalorimetry") << " Spot Fraction : " << spotFraction_ << std::endl;
00849   else
00850     {
00851       LogInfo("FastCalorimetry") << " Core of the shower " << std::endl;
00852       for(unsigned ir=0; ir < theCoreIntervals_.size()/2;++ir)
00853         {
00854           LogInfo("FastCalorimetry") << " r < " << theCoreIntervals_[ir*2] << " R_M : " << theCoreIntervals_[ir*2+1] << "        ";
00855         }
00856       LogInfo("FastCalorimetry") << std::endl;
00857         
00858       LogInfo("FastCalorimetry") << " Tail of the shower " << std::endl;
00859       for(unsigned ir=0; ir < theTailIntervals_.size()/2;++ir)
00860         {
00861           LogInfo("FastCalorimetry") << " r < " << theTailIntervals_[ir*2] << " R_M : " << theTailIntervals_[ir*2+1] << "        ";
00862         }
00863       LogInfo("FastCalotimetry") << "Radius correction factor " << radiusFactor_ << std::endl;
00864       LogInfo("FastCalorimetry") << std::endl;
00865     }
00866 
00867   LogInfo("FastCalorimetry") << " FrontLeakageProbability : " << pulledPadSurvivalProbability_ << std::endl;
00868   LogInfo("FastCalorimetry") << " GapLossProbability : " << crackPadSurvivalProbability_ << std::endl;
00869 
00870   //FR
00871   edm::ParameterSet HCALparameters = fastCalo.getParameter<edm::ParameterSet>("HCAL");
00872   optionHDSim_ = HCALparameters.getParameter<int>("SimOption");
00873   hdGridSize_ = HCALparameters.getParameter<int>("GridSize");
00874   hdSimMethod_ = HCALparameters.getParameter<int>("SimMethod");
00875   //RF
00876 
00877   unfoldedMode_ = fastCalo.getUntrackedParameter<bool>("UnfoldedMode",false);
00878 }

void CalorimetryManager::reconstruct (  ) 

Definition at line 153 of file CalorimetryManager.cc.

References funct::abs(), clean(), GenMuonPlsPt100GeV_cfg::cout, debug_, EMShowerSimulation(), lat::endl(), Calorimeter::getHcalGeometry(), CaloSubdetectorGeometry::getValidDetIds(), HcalDetId::hashed_index(), DetId::Hcal, HDShowerSimulation(), i, initialized_, int, LogDebug, myCalorimeter_, mySimEvent, FSimTrack::noEndVertex(), FSimEvent::nTracks(), FSimTrack::onEcal(), FSimTrack::onHcal(), FSimTrack::onVFcal(), optionHDSim_, CaloGeometryHelper::preshowerPresent(), reconstructHCAL(), simulatePreshower_, theDetIds_, FBaseSimEvent::track(), and CoreSimTrack::type().

Referenced by FamosManager::reconstruct().

00154 {
00155   // Clear the content of the calorimeters 
00156   if(!initialized_)
00157     {
00158       const CaloSubdetectorGeometry* geom=myCalorimeter_->getHcalGeometry();
00159       for(int subdetn=1;subdetn<=4;++subdetn)
00160         {
00161           const std::vector<DetId>& ids(geom->getValidDetIds(DetId::Hcal,subdetn));  
00162           for (std::vector<DetId>::const_iterator i=ids.begin(); i!=ids.end(); i++) 
00163             {
00164               HcalDetId myDetId(*i);
00165               unsigned hi=myDetId.hashed_index();
00166               theDetIds_[hi]=myDetId;
00167             }
00168         }
00169       
00170       // Check if the preshower is really available
00171       if(simulatePreshower_ && !myCalorimeter_->preshowerPresent())
00172         {
00173           std::cout << " WARNING " << std::endl;
00174           std::cout << " The preshower simulation has been turned on; but no preshower geometry is available " << std::endl;
00175           std::cout << " Disabling the preshower simulation " << std::endl;
00176           simulatePreshower_ = false;
00177         }
00178 
00179       initialized_=true;
00180     }
00181   clean();
00182 
00183   LogInfo("FastCalorimetry") << "Reconstructing " << (int) mySimEvent->nTracks() << " tracks." << std::endl;
00184   for( int fsimi=0; fsimi < (int) mySimEvent->nTracks() ; ++fsimi) {
00185 
00186     FSimTrack& myTrack = mySimEvent->track(fsimi);
00187 
00188     int pid = abs(myTrack.type());
00189 
00190     if (debug_) {
00191       LogDebug("FastCalorimetry") << " ===> pid = "  << pid << std::endl;      
00192     }
00193     
00194     
00195     // Check that the particle hasn't decayed
00196     if(myTrack.noEndVertex()) {
00197       // Simulate energy smearing for photon and electrons
00198       if ( pid == 11 || pid == 22 ) {
00199           
00200           
00201            if ( myTrack.onEcal() ) 
00202             EMShowerSimulation(myTrack);
00203           else if ( myTrack.onVFcal() )
00204             reconstructHCAL(myTrack);
00205            
00206       } // electron or photon
00207       // Simulate energy smearing for hadrons (i.e., everything 
00208       // but muons... and SUSY particles that deserve a special 
00209       // treatment.
00210       else if ( pid < 1000000 ) {
00211         if ( myTrack.onHcal() || myTrack.onVFcal() )      
00212           if(optionHDSim_ == 0 || pid == 13)  reconstructHCAL(myTrack);
00213           else HDShowerSimulation(myTrack);
00214             
00215       } // pid < 1000000 
00216     } // myTrack.noEndVertex()
00217   } // particle loop
00218   //  LogInfo("FastCalorimetry") << " Number of  hits (barrel)" << EBMapping_.size() << std::endl;
00219   //  LogInfo("FastCalorimetry") << " Number of  hits (Hcal)" << HMapping_.size() << std::endl;
00220   //  std::cout << " Nombre de hit (endcap)" << EEMapping_.size() << std::endl;
00221 
00222 } // reconstruct

void CalorimetryManager::reconstructECAL ( const FSimTrack track  )  [private]

Definition at line 430 of file CalorimetryManager.cc.

References GenMuonPlsPt100GeV_cfg::cout, debug_, e, FSimTrack::ecalEntrance(), lat::endl(), firedCellsHCAL_, RandomEngine::gaussShoot(), CaloGeometryHelper::getClosestCell(), HcalDetId::hashed_index(), HcalForward, HMapping_, FSimTrack::id(), FSimTrack::momentum(), myCalorimeter_, myHDResponse_, DetId::null(), FSimTrack::onEcal(), optionHDSim_, random, DetId::rawId(), HCALResponse::responseHCAL(), DetId::subdetId(), updateMap(), RawParticle::vertex(), and FSimTrack::vfcalEntrance().

00430                                                                {
00431   if(debug_) {
00432     XYZTLorentzVector moment = track.momentum();
00433     std::cout << "FASTEnergyReconstructor::reconstructECAL - " << std::endl
00434          << "  eta " << moment.eta() << std::endl
00435          << "  phi " << moment.phi() << std::endl
00436          << "   et " << moment.Et()  << std::endl;
00437   }
00438   
00439   int hit; 
00440   
00441   bool central=track.onEcal()==1;
00442   
00443   //Reconstruct only electrons and photons. 
00444 
00445   //deal with different conventions
00446   // ParticlePropagator 1 <-> Barrel
00447   //                    2 <-> EC
00448   // whereas for Artur(this code):
00449   //                    0 <-> Barrel
00450   //                    1 <-> EC
00451   //                    2 <-> VF
00452   XYZTLorentzVector trackPosition;
00453   if( track.onEcal() ) {
00454     hit=track.onEcal()-1;
00455     trackPosition=track.ecalEntrance().vertex();
00456   } else {
00457     hit=2;
00458     trackPosition=track.vfcalEntrance().vertex();
00459   }
00460   
00461   double pathEta   = trackPosition.eta();
00462   double pathPhi   = trackPosition.phi();       
00463   double EGen      = track.ecalEntrance().e();
00464   
00465 
00466   double e=0.;
00467   double sigma=0.;
00468   // if full simulation and in HF, but without showering anyway...
00469   if(hit == 2 && optionHDSim_ == 2 ) { 
00470     std::pair<double,double> response =
00471       myHDResponse_->responseHCAL(0, EGen, pathEta, 0); // last par.= 0 = e/gamma 
00472     e     = response.first;
00473     sigma = response.second;
00474   }
00475 
00476   double emeas = 0.;
00477   
00478   if(sigma>0.)
00479     emeas = random->gaussShoot(e,sigma);
00480   
00481 
00482   if(debug_)
00483     std::cout << "FASTEnergyReconstructor::reconstructECAL : " 
00484          << "  on-calo  eta, phi  = " << pathEta << " " << pathPhi << std::endl 
00485          << "  Egen  = " << EGen << std::endl 
00486          << "  Eres  = " << e << std::endl 
00487          << " sigma  = " << sigma << std::endl 
00488          << "  Emeas = " << emeas << std::endl; 
00489 
00490 
00491   if(debug_)
00492     std::cout << "FASTEnergyReconstructor::reconstructECAL : " 
00493          << " Track position - " << trackPosition.Vect() 
00494          << "   bool central - " << central
00495          << "   hit - " << hit   << std::endl;  
00496 
00497   DetId detid;  
00498   if( hit==2 ) 
00499       detid = myCalorimeter_->getClosestCell(trackPosition.Vect(),false,central);
00500   // Check that the detid is HCAL forward
00501   HcalDetId hdetid(detid);
00502   if(!hdetid.subdetId()!=HcalForward) return;
00503 
00504   if(debug_)
00505     std::cout << "FASTEnergyReconstructor::reconstructECAL : " 
00506               << " CellID - " <<  detid.rawId() << std::endl;
00507 
00508   if( hit != 2  || emeas > 0.) 
00509     if(!detid.null()) 
00510       {
00511         updateMap(hdetid.hashed_index(),emeas,track.id(),HMapping_,firedCellsHCAL_);
00512       }
00513 
00514 }

void CalorimetryManager::reconstructHCAL ( const FSimTrack myTrack  )  [private]

Definition at line 517 of file CalorimetryManager.cc.

References funct::abs(), debug_, e, lat::endl(), firedCellsHCAL_, RandomEngine::gaussShoot(), CaloGeometryHelper::getClosestCell(), HCALResponse::getHCALEnergyResolution(), HCALResponse::getHCALEnergyResponse(), FSimTrack::hcalEntrance(), HMapping_, FSimTrack::id(), LogDebug, myCalorimeter_, myHDResponse_, FSimTrack::onHcal(), random, HCALResponse::responseHCAL(), CoreSimTrack::type(), updateMap(), RawParticle::vertex(), and FSimTrack::vfcalEntrance().

Referenced by reconstruct().

00518 {
00519   int hit;
00520   int pid = abs(myTrack.type());
00521   //  FSimTrack myTrack = mySimEvent.track(fsimi);
00522 
00523   //  int pid=abs(myTrack.type());
00524   //  std::cout << "reconstructHCAL " << std::endl;
00525   
00526   XYZTLorentzVector trackPosition;
00527   if (myTrack.onHcal()) {
00528     trackPosition=myTrack.hcalEntrance().vertex();
00529     hit = myTrack.onHcal()-1;
00530   } else {
00531     trackPosition=myTrack.vfcalEntrance().vertex();
00532     hit = 2;
00533   }
00534 
00535   double pathEta   = trackPosition.eta();
00536   double pathPhi   = trackPosition.phi();       
00537   //  double pathTheta = trackPosition.theta();
00538 
00539   double EGen  = myTrack.hcalEntrance().e();
00540   double e     = 0.;
00541   double sigma = 0.;
00542   double emeas = 0.;
00543 
00544   if(pid == 13) { 
00545     std::pair<double,double> response =
00546       myHDResponse_->responseHCAL(0, EGen, pathEta, 2); // 2=muon 
00547     emeas  = response.first;
00548     if(debug_)
00549       LogDebug("FastCalorimetry") << "CalorimetryManager::reconstructHCAL - MUON !!!" << std::endl;
00550   }
00551   else if( pid == 22 || pid == 11)
00552     {
00553       
00554       std::pair<double,double> response =
00555         myHDResponse_->responseHCAL(0, EGen, pathEta, 0); // last par. = 0 = e/gamma
00556       e     = response.first;              //
00557       sigma = response.second;             //
00558       emeas = random->gaussShoot(e,sigma); //
00559 
00560       //  cout <<  "CalorimetryManager::reconstructHCAL - e/gamma !!!" << std::endl;
00561       if(debug_)
00562         LogDebug("FastCalorimetry") << "CalorimetryManager::reconstructHCAL - e/gamma !!!" << std::endl;
00563     }
00564     else {
00565       e     = myHDResponse_->getHCALEnergyResponse(EGen,hit);
00566       sigma = myHDResponse_->getHCALEnergyResolution(EGen, hit);
00567       
00568       emeas = random->gaussShoot(e,sigma);  
00569     }
00570     
00571 
00572   if(debug_)
00573     LogDebug("FastCalorimetry") << "CalorimetryManager::reconstructHCAL - on-calo "   
00574                                 << "  eta = " << pathEta 
00575                                 << "  phi = " << pathPhi 
00576                                 << "  Egen = " << EGen 
00577                                 << "  Eres = " << e 
00578                                 << "  sigma = " << sigma 
00579                                 << "  Emeas = " << emeas << std::endl;
00580 
00581   if(emeas > 0.) {  
00582     DetId cell = myCalorimeter_->getClosestCell(trackPosition.Vect(),false,false);
00583     updateMap(HcalDetId(cell).hashed_index(), emeas, myTrack.id(),HMapping_,firedCellsHCAL_);
00584   }
00585 }

void CalorimetryManager::updateMap ( int  hi,
float  energy,
int  id,
std::vector< std::vector< std::pair< int, float > > > &  mymap,
std::vector< int > &  firedCells 
) [private]

Definition at line 904 of file CalorimetryManager.cc.

References mymap, size, and unfoldedMode_.

00905 {
00906   // Standard case first : one entry per cell 
00907   if(!unfoldedMode_)
00908     {
00909       // if new entry, update the list 
00910       if(mymap[hi].size()==0)
00911         {
00912           firedCells.push_back(hi);
00913           mymap[hi].push_back(std::pair<int,float>(0,energy));
00914         }
00915       else
00916         mymap[hi][0].second+=energy;
00917     }
00918   else
00919     {
00920       //      std::cout << "update map " << mymap[hi].size() << " " << hi << std::setw(8) << std::setprecision(6) <<  energy ;
00921       //      std::cout << " " << mymap[hi][0].second << std::endl;
00922       // the minimal size is always 1 ; in this case, no push_back 
00923       if(mymap[hi].size()==0)
00924         {
00925           //      if(tid==0) std::cout << " Shit ! " << std::endl;
00926           firedCells.push_back(hi);
00927         }
00928 
00929       mymap[hi].push_back(std::pair<int,float>(tid,energy));
00930     }
00931   
00932 }

void CalorimetryManager::updateMap ( uint32_t  cellid,
float  energy,
int  id,
std::map< uint32_t, std::vector< std::pair< int, float > > > &  mymap 
) [private]

Definition at line 881 of file CalorimetryManager.cc.

References mymap, and unfoldedMode_.

Referenced by EMShowerSimulation(), HDShowerSimulation(), reconstructECAL(), and reconstructHCAL().

00882 {
00883   //  std::cout << " updateMap " << std::endl;
00884   std::map<unsigned,std::vector<std::pair<int,float> > >::iterator cellitr;
00885   cellitr = mymap.find(cellid);
00886   if(!unfoldedMode_) id=0;
00887   if( cellitr==mymap.end())
00888     {      
00889       std::vector<std::pair<int,float> > myElement;
00890       myElement.push_back(std::pair<int,float> (id,energy));
00891       mymap[cellid]=myElement;
00892     }
00893   else
00894     {
00895       if(!unfoldedMode_)
00896         {
00897           cellitr->second[0].second+=energy;
00898         }
00899       else
00900         cellitr->second.push_back(std::pair<int,float>(id,energy));
00901     }
00902 }


Member Data Documentation

GammaFunctionGenerator* CalorimetryManager::aGammaGenerator [private]

Definition at line 123 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), and EMShowerSimulation().

const LandauFluctuationGenerator* CalorimetryManager::aLandauGenerator [private]

Definition at line 122 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), and EMShowerSimulation().

double CalorimetryManager::crackPadSurvivalProbability_ [private]

Definition at line 109 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and readParameters().

bool CalorimetryManager::debug_ [private]

Definition at line 98 of file CalorimetryManager.h.

Referenced by HDShowerSimulation(), readParameters(), reconstruct(), reconstructECAL(), and reconstructHCAL().

std::vector<std::vector<std::pair<int,float> > > CalorimetryManager::EBMapping_ [private]

Definition at line 86 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), clean(), EMShowerSimulation(), HDShowerSimulation(), and loadFromEcalBarrel().

std::vector<std::vector<std::pair<int,float> > > CalorimetryManager::EEMapping_ [private]

Definition at line 87 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), clean(), EMShowerSimulation(), HDShowerSimulation(), and loadFromEcalEndcap().

std::map<uint32_t,std::vector<std::pair<int,float> > > CalorimetryManager::ESMapping_ [private]

Definition at line 89 of file CalorimetryManager.h.

Referenced by clean(), EMShowerSimulation(), and loadFromPreshower().

std::vector<int> CalorimetryManager::firedCellsEB_ [private]

Definition at line 91 of file CalorimetryManager.h.

Referenced by clean(), EMShowerSimulation(), HDShowerSimulation(), and loadFromEcalBarrel().

std::vector<int> CalorimetryManager::firedCellsEE_ [private]

Definition at line 92 of file CalorimetryManager.h.

Referenced by clean(), EMShowerSimulation(), HDShowerSimulation(), and loadFromEcalEndcap().

std::vector<int> CalorimetryManager::firedCellsHCAL_ [private]

Definition at line 93 of file CalorimetryManager.h.

Referenced by clean(), EMShowerSimulation(), HDShowerSimulation(), loadFromHcal(), reconstructECAL(), and reconstructHCAL().

int CalorimetryManager::gridSize_ [private]

Definition at line 112 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and readParameters().

int CalorimetryManager::hdGridSize_ [private]

Definition at line 116 of file CalorimetryManager.h.

Referenced by HDShowerSimulation(), and readParameters().

int CalorimetryManager::hdSimMethod_ [private]

Definition at line 116 of file CalorimetryManager.h.

Referenced by HDShowerSimulation(), and readParameters().

std::vector<std::vector<std::pair<int,float> > > CalorimetryManager::HMapping_ [private]

Definition at line 88 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), clean(), EMShowerSimulation(), HDShowerSimulation(), loadFromHcal(), reconstructECAL(), and reconstructHCAL().

bool CalorimetryManager::initialized_ [private]

Definition at line 126 of file CalorimetryManager.h.

Referenced by reconstruct().

CaloGeometryHelper* CalorimetryManager::myCalorimeter_ [private]

Definition at line 77 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), EMShowerSimulation(), getCalorimeter(), HDShowerSimulation(), reconstruct(), reconstructECAL(), reconstructHCAL(), and ~CalorimetryManager().

RawParticle CalorimetryManager::myElec [private]

A few pointers to save time.

Definition at line 103 of file CalorimetryManager.h.

Referenced by EMShowerSimulation().

HCALResponse* CalorimetryManager::myHDResponse_ [private]

Definition at line 81 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), HDShowerSimulation(), reconstructECAL(), reconstructHCAL(), and ~CalorimetryManager().

Histos* CalorimetryManager::myHistos [private]

Definition at line 79 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), and ~CalorimetryManager().

HSParameters* CalorimetryManager::myHSParameters_ [private]

Definition at line 82 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), and HDShowerSimulation().

RawParticle CalorimetryManager::myPart [private]

Definition at line 105 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and HDShowerSimulation().

RawParticle CalorimetryManager::myPosi [private]

Definition at line 104 of file CalorimetryManager.h.

Referenced by EMShowerSimulation().

FSimEvent* CalorimetryManager::mySimEvent [private]

Definition at line 76 of file CalorimetryManager.h.

Referenced by reconstruct().

std::vector< std::pair< int, float > > CalorimetryManager::myZero_ [static, private]

Initial value:

 std::vector<std::pair<int,float> >
(1,std::pair<int,float>(0,0.))

Definition at line 125 of file CalorimetryManager.h.

int CalorimetryManager::optionHDSim_ [private]

Definition at line 116 of file CalorimetryManager.h.

Referenced by HDShowerSimulation(), readParameters(), reconstruct(), and reconstructECAL().

double CalorimetryManager::pulledPadSurvivalProbability_ [private]

Definition at line 108 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and readParameters().

double CalorimetryManager::radiusFactor_ [private]

Definition at line 111 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and readParameters().

const RandomEngine* CalorimetryManager::random [private]

Definition at line 121 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), EMShowerSimulation(), HDShowerSimulation(), reconstructECAL(), and reconstructHCAL().

double CalorimetryManager::RCFactor_ [private]

Definition at line 114 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and readParameters().

double CalorimetryManager::RTFactor_ [private]

Definition at line 114 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and readParameters().

bool CalorimetryManager::simulatePreshower_ [private]

Definition at line 117 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), readParameters(), and reconstruct().

double CalorimetryManager::spotFraction_ [private]

Definition at line 110 of file CalorimetryManager.h.

Referenced by readParameters().

std::vector<double> CalorimetryManager::theCoreIntervals_ [private]

Definition at line 113 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and readParameters().

std::vector<DetId> CalorimetryManager::theDetIds_ [private]

Definition at line 97 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), loadFromHcal(), and reconstruct().

std::vector<double> CalorimetryManager::theTailIntervals_ [private]

Definition at line 113 of file CalorimetryManager.h.

Referenced by EMShowerSimulation(), and readParameters().

bool CalorimetryManager::unfoldedMode_ [private]

Definition at line 100 of file CalorimetryManager.h.

Referenced by CalorimetryManager(), loadFromEcalBarrel(), loadFromEcalEndcap(), loadFromHcal(), loadFromPreshower(), readParameters(), and updateMap().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:15:54 2009 for CMSSW by  doxygen 1.5.4