CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.cc

Go to the documentation of this file.
00001 #include "RecoLocalCalo/CaloTowersCreator/src/CaloTowersCreator.h"
00002 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
00003 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "RecoLocalCalo/CaloTowersCreator/interface/EScales.h"
00006 
00007 // severity level for ECAL
00008 //#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
00009 
00010 const std::vector<double>& 
00011 CaloTowersCreator::getGridValues()
00012 {
00013   static std::vector<double> retval;
00014   
00015   if (retval.size() == 0)
00016     {
00017       retval.push_back(0.);
00018       retval.push_back(10.);
00019       retval.push_back(20.);
00020       retval.push_back(30.);
00021       retval.push_back(40.);
00022       retval.push_back(50.);
00023       retval.push_back(100.);
00024       retval.push_back(1000.); 
00025     }
00026 
00027   return retval;
00028 }
00029 
00030 
00031 CaloTowersCreator::CaloTowersCreator(const edm::ParameterSet& conf) : 
00032   algo_(conf.getParameter<double>("EBThreshold"),
00033               conf.getParameter<double>("EEThreshold"),
00034 
00035         conf.getParameter<bool>("UseEtEBTreshold"),
00036         conf.getParameter<bool>("UseEtEETreshold"),
00037         conf.getParameter<bool>("UseSymEBTreshold"),
00038         conf.getParameter<bool>("UseSymEETreshold"),
00039 
00040 
00041               conf.getParameter<double>("HcalThreshold"),
00042               conf.getParameter<double>("HBThreshold"),
00043               conf.getParameter<double>("HESThreshold"),
00044               conf.getParameter<double>("HEDThreshold"),
00045         conf.getParameter<double>("HOThreshold0"),
00046         conf.getParameter<double>("HOThresholdPlus1"),
00047         conf.getParameter<double>("HOThresholdMinus1"),
00048         conf.getParameter<double>("HOThresholdPlus2"),
00049         conf.getParameter<double>("HOThresholdMinus2"),
00050               conf.getParameter<double>("HF1Threshold"),
00051               conf.getParameter<double>("HF2Threshold"),
00052         conf.getParameter<std::vector<double> >("EBGrid"),
00053         conf.getParameter<std::vector<double> >("EBWeights"),
00054         conf.getParameter<std::vector<double> >("EEGrid"),
00055         conf.getParameter<std::vector<double> >("EEWeights"),
00056         conf.getParameter<std::vector<double> >("HBGrid"),
00057         conf.getParameter<std::vector<double> >("HBWeights"),
00058         conf.getParameter<std::vector<double> >("HESGrid"),
00059         conf.getParameter<std::vector<double> >("HESWeights"),
00060         conf.getParameter<std::vector<double> >("HEDGrid"),
00061         conf.getParameter<std::vector<double> >("HEDWeights"),
00062         conf.getParameter<std::vector<double> >("HOGrid"),
00063         conf.getParameter<std::vector<double> >("HOWeights"),
00064         conf.getParameter<std::vector<double> >("HF1Grid"),
00065         conf.getParameter<std::vector<double> >("HF1Weights"),
00066         conf.getParameter<std::vector<double> >("HF2Grid"),
00067         conf.getParameter<std::vector<double> >("HF2Weights"),
00068               conf.getParameter<double>("EBWeight"),
00069               conf.getParameter<double>("EEWeight"),
00070               conf.getParameter<double>("HBWeight"),
00071               conf.getParameter<double>("HESWeight"),
00072               conf.getParameter<double>("HEDWeight"),
00073               conf.getParameter<double>("HOWeight"),
00074               conf.getParameter<double>("HF1Weight"),
00075               conf.getParameter<double>("HF2Weight"),
00076               conf.getParameter<double>("EcutTower"),
00077               conf.getParameter<double>("EBSumThreshold"),
00078               conf.getParameter<double>("EESumThreshold"),
00079               conf.getParameter<bool>("UseHO"),
00080          // (for momentum reconstruction algorithm)
00081         conf.getParameter<int>("MomConstrMethod"),
00082         conf.getParameter<double>("MomHBDepth"),
00083         conf.getParameter<double>("MomHEDepth"),
00084         conf.getParameter<double>("MomEBDepth"),
00085         conf.getParameter<double>("MomEEDepth")
00086         ),
00087 
00088   hbheLabel_(conf.getParameter<edm::InputTag>("hbheInput")),
00089   hoLabel_(conf.getParameter<edm::InputTag>("hoInput")),
00090   hfLabel_(conf.getParameter<edm::InputTag>("hfInput")),
00091   ecalLabels_(conf.getParameter<std::vector<edm::InputTag> >("ecalInputs")),
00092   allowMissingInputs_(conf.getParameter<bool>("AllowMissingInputs")),
00093 
00094   theHcalAcceptSeverityLevel_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevel")),
00095   theEcalAcceptSeverityLevel_(conf.getParameter<unsigned int>("EcalAcceptSeverityLevel")),
00096 
00097   theRecoveredHcalHitsAreUsed_(conf.getParameter<bool>("UseHcalRecoveredHits")),
00098   theRecoveredEcalHitsAreUsed_(conf.getParameter<bool>("UseEcalRecoveredHits")),
00099 
00100   // paramaters controlling the use of rejected hits
00101 
00102   useRejectedHitsOnly_(conf.getParameter<bool>("UseRejectedHitsOnly")),
00103 
00104   theHcalAcceptSeverityLevelForRejectedHit_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevelForRejectedHit")),
00105   theEcalAcceptSeverityLevelForRejectedHit_(conf.getParameter<unsigned int>("EcalAcceptSeverityLevelForRejectedHit")),
00106   useRejectedRecoveredHcalHits_(conf.getParameter<bool>("UseRejectedRecoveredHcalHits")),
00107   useRejectedRecoveredEcalHits_(conf.getParameter<bool>("UseRejectedRecoveredEcalHits"))
00108 
00109 
00110 
00111 {
00112   EBEScale=EScales.EBScale; 
00113   EEEScale=EScales.EEScale; 
00114   HBEScale=EScales.HBScale; 
00115   HESEScale=EScales.HESScale; 
00116   HEDEScale=EScales.HEDScale; 
00117   HOEScale=EScales.HOScale; 
00118   HF1EScale=EScales.HF1Scale; 
00119   HF2EScale=EScales.HF2Scale; 
00120   if (EScales.instanceLabel=="") produces<CaloTowerCollection>();
00121   else produces<CaloTowerCollection>(EScales.instanceLabel);
00122 }
00123 
00124 void CaloTowersCreator::produce(edm::Event& e, const edm::EventSetup& c) {
00125   // get the necessary event setup objects...
00126   edm::ESHandle<CaloGeometry> pG;
00127   edm::ESHandle<HcalTopology> htopo;
00128   edm::ESHandle<CaloTowerConstituentsMap> cttopo;
00129   c.get<CaloGeometryRecord>().get(pG);
00130   c.get<IdealGeometryRecord>().get(htopo);
00131   c.get<IdealGeometryRecord>().get(cttopo);
00132  
00133   // ECAL channel status map ****************************************
00134   edm::ESHandle<EcalChannelStatus> ecalChStatus;
00135   c.get<EcalChannelStatusRcd>().get( ecalChStatus );
00136   const EcalChannelStatus* dbEcalChStatus = ecalChStatus.product();
00137  
00138   // HCAL channel status map ****************************************
00139   edm::ESHandle<HcalChannelQuality> hcalChStatus;    
00140   c.get<HcalChannelQualityRcd>().get( hcalChStatus );
00141   const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();
00142  
00143   // Assignment of severity levels **********************************
00144   edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
00145   c.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
00146   const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();
00147  
00148   const EcalSeverityLevelAlgo* ecalSevLvlAlgo = new EcalSeverityLevelAlgo();
00149 
00150   
00151   algo_.setEBEScale(EBEScale);
00152   algo_.setEEEScale(EEEScale);
00153   algo_.setHBEScale(HBEScale);
00154   algo_.setHESEScale(HESEScale);
00155   algo_.setHEDEScale(HEDEScale);
00156   algo_.setHOEScale(HOEScale);
00157   algo_.setHF1EScale(HF1EScale);
00158   algo_.setHF2EScale(HF2EScale);
00159   algo_.setGeometry(cttopo.product(),htopo.product(),pG.product());
00160 
00161   // for treatment of problematic and anomalous cells
00162 
00163   algo_.setHcalChStatusFromDB(dbHcalChStatus);
00164   algo_.setEcalChStatusFromDB(dbEcalChStatus);
00165    
00166   algo_.setHcalAcceptSeverityLevel(theHcalAcceptSeverityLevel_);
00167   algo_.setEcalAcceptSeverityLevel(theEcalAcceptSeverityLevel_);
00168 
00169   algo_.setRecoveredHcalHitsAreUsed(theRecoveredHcalHitsAreUsed_);
00170   algo_.setRecoveredEcalHitsAreUsed(theRecoveredEcalHitsAreUsed_);
00171 
00172   algo_.setHcalSevLvlComputer(hcalSevLvlComputer);
00173   algo_.setEcalSevLvlAlgo(ecalSevLvlAlgo);
00174 
00175 
00176   algo_.setUseRejectedHitsOnly(useRejectedHitsOnly_);
00177 
00178   algo_.setHcalAcceptSeverityLevelForRejectedHit(theHcalAcceptSeverityLevelForRejectedHit_);
00179   algo_.setEcalAcceptSeverityLevelForRejectedHit(theEcalAcceptSeverityLevelForRejectedHit_);
00180 
00181   algo_.setUseRejectedRecoveredHcalHits(useRejectedRecoveredHcalHits_);
00182   algo_.setUseRejectedRecoveredEcalHits(useRejectedRecoveredEcalHits_);
00183 
00184 
00185 
00186 
00187 
00188   algo_.begin(); // clear the internal buffer
00189 
00190   algo_.makeHcalDropChMap();
00191 
00192 
00193   // ----------------------------------------------------------
00194   // For ecal error handling need to 
00195   // have access to the EB and EE collections at the end of 
00196   // tower reconstruction.
00197 
00198   edm::Handle<EcalRecHitCollection> ebHandle;
00199   edm::Handle<EcalRecHitCollection> eeHandle;
00200 
00201   for (std::vector<edm::InputTag>::const_iterator i=ecalLabels_.begin(); 
00202        i!=ecalLabels_.end(); i++) {
00203     
00204     edm::Handle<EcalRecHitCollection> ec_tmp;
00205     
00206     if (! e.getByLabel(*i,ec_tmp) ) continue;
00207     if (ec_tmp->size()==0) continue;
00208 
00209     // check if this is EB or EE
00210     if ( (ec_tmp->begin()->detid()).subdetId() == EcalBarrel ) {
00211       ebHandle = ec_tmp;
00212     }
00213     else if ((ec_tmp->begin()->detid()).subdetId() == EcalEndcap ) {
00214       eeHandle = ec_tmp;
00215     }
00216 
00217   }
00218 
00219   algo_.setEbHandle(ebHandle);
00220   algo_.setEeHandle(eeHandle);
00221 
00222   //-----------------------------------------------------------
00223 
00224 
00225 
00226   bool present;
00227 
00228   // Step A/C: Get Inputs and process (repeatedly)
00229   edm::Handle<HBHERecHitCollection> hbhe;
00230   present=e.getByLabel(hbheLabel_,hbhe);
00231   if (present || !allowMissingInputs_)  algo_.process(*hbhe);
00232 
00233   edm::Handle<HORecHitCollection> ho;
00234   present=e.getByLabel(hoLabel_,ho);
00235   if (present || !allowMissingInputs_) algo_.process(*ho);
00236 
00237   edm::Handle<HFRecHitCollection> hf;
00238   present=e.getByLabel(hfLabel_,hf);
00239   if (present || !allowMissingInputs_) algo_.process(*hf);
00240 
00241   std::vector<edm::InputTag>::const_iterator i;
00242   for (i=ecalLabels_.begin(); i!=ecalLabels_.end(); i++) {
00243     edm::Handle<EcalRecHitCollection> ec;
00244     present=e.getByLabel(*i,ec);
00245     if (present || !allowMissingInputs_) algo_.process(*ec);
00246   }
00247 
00248   // Step B: Create empty output
00249   std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
00250 
00251   // Step C: Process
00252   algo_.finish(*prod);
00253 
00254   // Step D: Put into the event
00255   if (EScales.instanceLabel=="") e.put(prod);
00256   else e.put(prod,EScales.instanceLabel);
00257 
00258 
00259   if (ecalSevLvlAlgo) delete ecalSevLvlAlgo;
00260 
00261 
00262 }
00263