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 #include "Geometry/CaloTopology/interface/HcalTopology.h"
00007
00008 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgoRcd.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
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
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
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
00134 edm::ESHandle<EcalChannelStatus> ecalChStatus;
00135 c.get<EcalChannelStatusRcd>().get( ecalChStatus );
00136 const EcalChannelStatus* dbEcalChStatus = ecalChStatus.product();
00137
00138
00139 edm::ESHandle<HcalChannelQuality> hcalChStatus;
00140 c.get<HcalChannelQualityRcd>().get( hcalChStatus );
00141 const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();
00142
00143
00144 edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
00145 c.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
00146 const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();
00147
00148 edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
00149 c.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
00150 const EcalSeverityLevelAlgo* ecalSevLvlAlgo = ecalSevLvlAlgoHndl.product();
00151
00152
00153 algo_.setEBEScale(EBEScale);
00154 algo_.setEEEScale(EEEScale);
00155 algo_.setHBEScale(HBEScale);
00156 algo_.setHESEScale(HESEScale);
00157 algo_.setHEDEScale(HEDEScale);
00158 algo_.setHOEScale(HOEScale);
00159 algo_.setHF1EScale(HF1EScale);
00160 algo_.setHF2EScale(HF2EScale);
00161 algo_.setGeometry(cttopo.product(),htopo.product(),pG.product());
00162
00163
00164
00165 algo_.setHcalChStatusFromDB(dbHcalChStatus);
00166 algo_.setEcalChStatusFromDB(dbEcalChStatus);
00167
00168 algo_.setHcalAcceptSeverityLevel(theHcalAcceptSeverityLevel_);
00169 algo_.setEcalAcceptSeverityLevel(theEcalAcceptSeverityLevel_);
00170
00171 algo_.setRecoveredHcalHitsAreUsed(theRecoveredHcalHitsAreUsed_);
00172 algo_.setRecoveredEcalHitsAreUsed(theRecoveredEcalHitsAreUsed_);
00173
00174 algo_.setHcalSevLvlComputer(hcalSevLvlComputer);
00175 algo_.setEcalSevLvlAlgo(ecalSevLvlAlgo);
00176
00177
00178 algo_.setUseRejectedHitsOnly(useRejectedHitsOnly_);
00179
00180 algo_.setHcalAcceptSeverityLevelForRejectedHit(theHcalAcceptSeverityLevelForRejectedHit_);
00181 algo_.setEcalAcceptSeverityLevelForRejectedHit(theEcalAcceptSeverityLevelForRejectedHit_);
00182
00183 algo_.setUseRejectedRecoveredHcalHits(useRejectedRecoveredHcalHits_);
00184 algo_.setUseRejectedRecoveredEcalHits(useRejectedRecoveredEcalHits_);
00185
00186
00187
00188
00189
00190 algo_.begin();
00191
00192
00193
00194 bool check1 = hcalSevLevelWatcher_.check(c);
00195 bool check2 = hcalChStatusWatcher_.check(c);
00196 bool check3 = caloTowerConstituentsWatcher_.check(c);
00197 if(check1 || check2 || check3)
00198 {
00199 algo_.makeHcalDropChMap();
00200 }
00201
00202
00203
00204
00205
00206
00207 edm::Handle<EcalRecHitCollection> ebHandle;
00208 edm::Handle<EcalRecHitCollection> eeHandle;
00209
00210 for (std::vector<edm::InputTag>::const_iterator i=ecalLabels_.begin();
00211 i!=ecalLabels_.end(); i++) {
00212
00213 edm::Handle<EcalRecHitCollection> ec_tmp;
00214
00215 if (! e.getByLabel(*i,ec_tmp) ) continue;
00216 if (ec_tmp->size()==0) continue;
00217
00218
00219 if ( (ec_tmp->begin()->detid()).subdetId() == EcalBarrel ) {
00220 ebHandle = ec_tmp;
00221 }
00222 else if ((ec_tmp->begin()->detid()).subdetId() == EcalEndcap ) {
00223 eeHandle = ec_tmp;
00224 }
00225
00226 }
00227
00228 algo_.setEbHandle(ebHandle);
00229 algo_.setEeHandle(eeHandle);
00230
00231
00232
00233
00234
00235 bool present;
00236
00237
00238 edm::Handle<HBHERecHitCollection> hbhe;
00239 present=e.getByLabel(hbheLabel_,hbhe);
00240 if (present || !allowMissingInputs_) algo_.process(*hbhe);
00241
00242 edm::Handle<HORecHitCollection> ho;
00243 present=e.getByLabel(hoLabel_,ho);
00244 if (present || !allowMissingInputs_) algo_.process(*ho);
00245
00246 edm::Handle<HFRecHitCollection> hf;
00247 present=e.getByLabel(hfLabel_,hf);
00248 if (present || !allowMissingInputs_) algo_.process(*hf);
00249
00250 std::vector<edm::InputTag>::const_iterator i;
00251 for (i=ecalLabels_.begin(); i!=ecalLabels_.end(); i++) {
00252 edm::Handle<EcalRecHitCollection> ec;
00253 present=e.getByLabel(*i,ec);
00254 if (present || !allowMissingInputs_) algo_.process(*ec);
00255 }
00256
00257
00258 std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
00259
00260
00261 algo_.finish(*prod);
00262
00263
00264 if (EScales.instanceLabel=="") e.put(prod);
00265 else e.put(prod,EScales.instanceLabel);
00266
00267
00268 }
00269