CMS 3D CMS Logo

CaloTowersCreator.cc
Go to the documentation of this file.
7 // severity level for ECAL
10 
11 //#define EDM_ML_DEBUG
12 
14  algo_(conf.getParameter<double>("EBThreshold"),
15  conf.getParameter<double>("EEThreshold"),
16 
17  conf.getParameter<bool>("UseEtEBTreshold"),
18  conf.getParameter<bool>("UseEtEETreshold"),
19  conf.getParameter<bool>("UseSymEBTreshold"),
20  conf.getParameter<bool>("UseSymEETreshold"),
21 
22 
23  conf.getParameter<double>("HcalThreshold"),
24  conf.getParameter<double>("HBThreshold"),
25  conf.getParameter<double>("HBThreshold1"),
26  conf.getParameter<double>("HBThreshold2"),
27  conf.getParameter<double>("HESThreshold"),
28  conf.getParameter<double>("HESThreshold1"),
29  conf.getParameter<double>("HEDThreshold"),
30  conf.getParameter<double>("HEDThreshold1"),
31  conf.getParameter<double>("HOThreshold0"),
32  conf.getParameter<double>("HOThresholdPlus1"),
33  conf.getParameter<double>("HOThresholdMinus1"),
34  conf.getParameter<double>("HOThresholdPlus2"),
35  conf.getParameter<double>("HOThresholdMinus2"),
36  conf.getParameter<double>("HF1Threshold"),
37  conf.getParameter<double>("HF2Threshold"),
38  conf.getParameter<std::vector<double> >("EBGrid"),
39  conf.getParameter<std::vector<double> >("EBWeights"),
40  conf.getParameter<std::vector<double> >("EEGrid"),
41  conf.getParameter<std::vector<double> >("EEWeights"),
42  conf.getParameter<std::vector<double> >("HBGrid"),
43  conf.getParameter<std::vector<double> >("HBWeights"),
44  conf.getParameter<std::vector<double> >("HESGrid"),
45  conf.getParameter<std::vector<double> >("HESWeights"),
46  conf.getParameter<std::vector<double> >("HEDGrid"),
47  conf.getParameter<std::vector<double> >("HEDWeights"),
48  conf.getParameter<std::vector<double> >("HOGrid"),
49  conf.getParameter<std::vector<double> >("HOWeights"),
50  conf.getParameter<std::vector<double> >("HF1Grid"),
51  conf.getParameter<std::vector<double> >("HF1Weights"),
52  conf.getParameter<std::vector<double> >("HF2Grid"),
53  conf.getParameter<std::vector<double> >("HF2Weights"),
54  conf.getParameter<double>("EBWeight"),
55  conf.getParameter<double>("EEWeight"),
56  conf.getParameter<double>("HBWeight"),
57  conf.getParameter<double>("HESWeight"),
58  conf.getParameter<double>("HEDWeight"),
59  conf.getParameter<double>("HOWeight"),
60  conf.getParameter<double>("HF1Weight"),
61  conf.getParameter<double>("HF2Weight"),
62  conf.getParameter<double>("EcutTower"),
63  conf.getParameter<double>("EBSumThreshold"),
64  conf.getParameter<double>("EESumThreshold"),
65  conf.getParameter<bool>("UseHO"),
66  // (for momentum reconstruction algorithm)
67  conf.getParameter<int>("MomConstrMethod"),
68  conf.getParameter<double>("MomHBDepth"),
69  conf.getParameter<double>("MomHEDepth"),
70  conf.getParameter<double>("MomEBDepth"),
71  conf.getParameter<double>("MomEEDepth"),
72  conf.getParameter<int>("HcalPhase")
73  ),
74 
75  ecalLabels_(conf.getParameter<std::vector<edm::InputTag> >("ecalInputs")),
76  allowMissingInputs_(conf.getParameter<bool>("AllowMissingInputs")),
77 
78  theHcalAcceptSeverityLevel_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevel")),
79 
80  theRecoveredHcalHitsAreUsed_(conf.getParameter<bool>("UseHcalRecoveredHits")),
81  theRecoveredEcalHitsAreUsed_(conf.getParameter<bool>("UseEcalRecoveredHits")),
82 
83  // paramaters controlling the use of rejected hits
84 
85  useRejectedHitsOnly_(conf.getParameter<bool>("UseRejectedHitsOnly")),
86 
87  theHcalAcceptSeverityLevelForRejectedHit_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevelForRejectedHit")),
88 
89 
90  useRejectedRecoveredHcalHits_(conf.getParameter<bool>("UseRejectedRecoveredHcalHits")),
91  useRejectedRecoveredEcalHits_(conf.getParameter<bool>("UseRejectedRecoveredEcalHits"))
92 
93 
94 
95 {
96  algo_.setMissingHcalRescaleFactorForEcal(conf.getParameter<double>("missingHcalRescaleFactorForEcal"));
97 
98  // register for data access
99  tok_hbhe_ = consumes<HBHERecHitCollection>(conf.getParameter<edm::InputTag>("hbheInput"));
100  tok_ho_ = consumes<HORecHitCollection>(conf.getParameter<edm::InputTag>("hoInput"));
101  tok_hf_ = consumes<HFRecHitCollection>(conf.getParameter<edm::InputTag>("hfInput"));
102 
103  const unsigned nLabels = ecalLabels_.size();
104  for ( unsigned i=0; i != nLabels; i++ )
105  toks_ecal_.push_back(consumes<EcalRecHitCollection>(ecalLabels_[i]));
106 
107 
116 
117  // get the Ecal severities to be excluded
118  const std::vector<std::string> severitynames =
119  conf.getParameter<std::vector<std::string> >("EcalRecHitSeveritiesToBeExcluded");
120 
121  theEcalSeveritiesToBeExcluded_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
122 
123  // get the Ecal severities to be used for bad towers
125  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(conf.getParameter<std::vector<std::string> >("EcalSeveritiesToBeUsedInBadTowers") );
126 
127  if (eScales_.instanceLabel.empty()) produces<CaloTowerCollection>();
128  else produces<CaloTowerCollection>(eScales_.instanceLabel);
129 
130 #ifdef EDM_ML_DEBUG
131  std::cout << "VI Producer "
132  << (useRejectedHitsOnly_ ? "use rejectOnly " : " ")
133  << (allowMissingInputs_ ? "allowMissing " : " " )
134  << nLabels << ' ' << severitynames.size()
135  << std::endl;
136 #endif
137 }
138 
140  // get the necessary event setup objects...
145  c.get<CaloGeometryRecord>().get(pG);
146  c.get<HcalRecNumberingRecord>().get(htopo);
147  c.get<HcalRecNumberingRecord>().get(cttopo);
148  c.get<CaloGeometryRecord>().get(ctmap);
149 
150  // ECAL channel status map ****************************************
152  c.get<EcalChannelStatusRcd>().get( ecalChStatus );
153  const EcalChannelStatus* dbEcalChStatus = ecalChStatus.product();
154 
155  // HCAL channel status map ****************************************
156  edm::ESHandle<HcalChannelQuality> hcalChStatus;
157  c.get<HcalChannelQualityRcd>().get( "withTopo", hcalChStatus );
158 
159  const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();
160 
161  // Assignment of severity levels **********************************
162  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
163  c.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
164  const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();
165 
166  edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
167  c.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
168  const EcalSeverityLevelAlgo* ecalSevLvlAlgo = ecalSevLvlAlgoHndl.product();
169 
170 
179  algo_.setGeometry(cttopo.product(),ctmap.product(),htopo.product(),pG.product());
180 
181  // for treatment of problematic and anomalous cells
182 
183  algo_.setHcalChStatusFromDB(dbHcalChStatus);
184  algo_.setEcalChStatusFromDB(dbEcalChStatus);
185 
188 
191 
192  algo_.setHcalSevLvlComputer(hcalSevLvlComputer);
193  algo_.setEcalSevLvlAlgo(ecalSevLvlAlgo);
194 
195 
197 
200 
203 
204 #ifdef EDM_ML_DEBUG
205  std::cout << "VI Produce: "
206  << (useRejectedHitsOnly_ ? "use rejectOnly " : " ")
207  << (allowMissingInputs_ ? "allowMissing " : " " )
208  << (theRecoveredEcalHitsAreUsed_ ? "use RecoveredEcal ": " " )
209  << toks_ecal_.size()
210  << ' ' << theEcalSeveritiesToBeExcluded_.size()
211  << ' ' << theEcalSeveritiesToBeUsedInBadTowers_.size()
212  << std::endl;
213 #endif
214 
215  algo_.begin(); // clear the internal buffer
216 
217  // can't chain these in a big OR statement, or else it'll
218  // get triggered for each of the first three events
219  bool check1 = hcalSevLevelWatcher_.check(c);
220  bool check2 = hcalChStatusWatcher_.check(c);
221  bool check3 = caloTowerConstituentsWatcher_.check(c);
222  if(check1 || check2 || check3)
223  {
225  }
226 
227  // check ecal SevLev
229 
230  // ----------------------------------------------------------
231  // For ecal error handling need to
232  // have access to the EB and EE collections at the end of
233  // tower reconstruction.
234 
237 
238  for (std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i=toks_ecal_.begin();
239  i!=toks_ecal_.end(); i++) {
240 
242 
243  if (! e.getByToken(*i,ec_tmp) ) continue;
244  if (ec_tmp->empty()) continue;
245 
246  // check if this is EB or EE
247  if ( (ec_tmp->begin()->detid()).subdetId() == EcalBarrel ) {
248  ebHandle = ec_tmp;
249  }
250  else if ((ec_tmp->begin()->detid()).subdetId() == EcalEndcap) {
251  eeHandle = ec_tmp;
252  }
253  }
254 
255  algo_.setEbHandle(ebHandle);
256  algo_.setEeHandle(eeHandle);
257 
258  //-----------------------------------------------------------
259 
260  bool present;
261 
262  // Step A/C: Get Inputs and process (repeatedly)
264  present=e.getByToken(tok_hbhe_,hbhe);
265  if (present || !allowMissingInputs_) algo_.process(*hbhe);
266 
268  present=e.getByToken(tok_ho_,ho);
269  if (present || !allowMissingInputs_) algo_.process(*ho);
270 
272  present=e.getByToken(tok_hf_,hf);
273  if (present || !allowMissingInputs_) algo_.process(*hf);
274 
275  std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i;
276  for (i=toks_ecal_.begin(); i!=toks_ecal_.end(); i++) {
278  present=e.getByToken(*i,ec);
279  if (present || !allowMissingInputs_) algo_.process(*ec);
280  }
281 
282  // Step B: Create empty output
283  auto prod = std::make_unique<CaloTowerCollection>();
284 
285  // Step C: Process
286  algo_.finish(*prod);
287 
288 #ifdef EDM_ML_DEBUG
289  int totc=0; float totE=0;
291  for (auto const & tw : (*prod) ) {
292  totc += tw.constituents().size();
293  totE+=tw.energy();
294  totP4+=tw.p4();
295  std::cout << "CaloTowerCreator: " << tw.id() << " with E " << tw.energy()
296  << " and " << tw.constituents().size() << " constituents\n";
297  }
298  std::cout << "VI " << (*prod).size() << " " << totc << " " << totE << " " << totP4 << std::endl;
299 #endif
300 
301  // Step D: Put into the event
302  if (eScales_.instanceLabel.empty()) e.put(std::move(prod));
304 
305 
306 }
307 
310  desc.add<double>("EBSumThreshold", 0.2);
311  desc.add<double>("HF2Weight", 1.0);
312  desc.add<double>("EBWeight", 1.0);
313  desc.add<double>("EESumThreshold", 0.45);
314  desc.add<double>("HOThreshold0", 1.1);
315  desc.add<double>("HOThresholdPlus1", 3.5);
316  desc.add<double>("HOThresholdMinus1", 3.5);
317  desc.add<double>("HOThresholdPlus2", 3.5);
318  desc.add<double>("HOThresholdMinus2", 3.5);
319  desc.add<double>("HBThreshold", 0.7);
320  desc.add<double>("HBThreshold1", 0.7);
321  desc.add<double>("HBThreshold2", 0.7);
322  desc.add<double>("HF1Threshold", 0.5);
323  desc.add<double>("HEDWeight", 1.0);
324  desc.add<double>("EEWeight", 1.0);
325  desc.add<double>("HESWeight", 1.0);
326  desc.add<double>("HF1Weight", 1.0);
327  desc.add<double>("HOWeight", 1.0);
328  desc.add<double>("EBThreshold", 0.07);
329  desc.add<double>("EEThreshold", 0.3);
330  desc.add<double>("HcalThreshold", -1000.0);
331  desc.add<double>("HF2Threshold", 0.85);
332  desc.add<double>("HESThreshold", 0.8);
333  desc.add<double>("HESThreshold1", 0.8);
334  desc.add<double>("HEDThreshold", 0.8);
335  desc.add<double>("HEDThreshold1", 0.8);
336  desc.add<double>("EcutTower", -1000.0);
337  desc.add<double>("HBWeight", 1.0);
338  desc.add<double>("MomHBDepth", 0.2);
339  desc.add<double>("MomHEDepth", 0.4);
340  desc.add<double>("MomEBDepth", 0.3);
341  desc.add<double>("MomEEDepth", 0.0);
342  desc.add<bool>("UseHO", true);
343  desc.add<bool>("UseEtEBTreshold", false);
344  desc.add<bool>("UseSymEBTreshold", true);
345  desc.add<bool>("UseEtEETreshold", false);
346  desc.add<bool>("UseSymEETreshold", true);
347  desc.add<bool>("UseHcalRecoveredHits", true);
348  desc.add<bool>("UseEcalRecoveredHits", false);
349  desc.add<bool>("UseRejectedHitsOnly", false);
350  desc.add<bool>("UseRejectedRecoveredHcalHits", true);
351  desc.add<bool>("UseRejectedRecoveredEcalHits", false);
352  desc.add<double>("missingHcalRescaleFactorForEcal", 0.0);
353  desc.add<bool>("AllowMissingInputs", false);
354  desc.add<std::vector<double> >("HBGrid", {-1.0, 1.0, 10.0, 100.0, 1000.0});
355  desc.add<std::vector<double> >("EEWeights", {1.0, 1.0, 1.0, 1.0, 1.0});
356  desc.add<std::vector<double> >("HF2Weights", {1.0, 1.0, 1.0, 1.0, 1.0});
357  desc.add<std::vector<double> >("HOWeights", {1.0, 1.0, 1.0, 1.0, 1.0});
358  desc.add<std::vector<double> >("EEGrid", {-1.0, 1.0, 10.0, 100.0, 1000.0});
359  desc.add<std::vector<double> >("HBWeights", {1.0, 1.0, 1.0, 1.0, 1.0});
360  desc.add<std::vector<double> >("HF2Grid", {-1.0, 1.0, 10.0, 100.0, 1000.0});
361  desc.add<std::vector<double> >("HEDWeights", {1.0, 1.0, 1.0, 1.0, 1.0});
362  desc.add<std::vector<double> >("HF1Grid", {-1.0, 1.0, 10.0, 100.0, 1000.0});
363  desc.add<std::vector<double> >("EBWeights", {1.0, 1.0, 1.0, 1.0, 1.0});
364  desc.add<std::vector<double> >("HF1Weights", {1.0, 1.0, 1.0, 1.0, 1.0});
365  desc.add<std::vector<double> >("HESGrid", {-1.0, 1.0, 10.0, 100.0, 1000.0});
366  desc.add<std::vector<double> >("HESWeights", {1.0, 1.0, 1.0, 1.0, 1.0});
367  desc.add<std::vector<double> >("HEDGrid", {-1.0, 1.0, 10.0, 100.0, 1000.0});
368  desc.add<std::vector<double> >("HOGrid", {-1.0, 1.0, 10.0, 100.0, 1000.0});
369  desc.add<std::vector<double> >("EBGrid", {-1.0, 1.0, 10.0, 100.0, 1000.0});
370  desc.add<edm::InputTag>("hfInput", edm::InputTag("hfreco"));
371  desc.add<edm::InputTag>("hbheInput", edm::InputTag("hbhereco"));
372  desc.add<edm::InputTag>("hoInput", edm::InputTag("horeco"));
373  desc.add<std::vector<edm::InputTag> >("ecalInputs", {edm::InputTag("ecalRecHit","EcalRecHitsEB"), edm::InputTag("ecalRecHit","EcalRecHitsEE")});
374  desc.add<int>("MomConstrMethod", 1);
375  desc.add<unsigned int>("HcalAcceptSeverityLevel", 9);
376  desc.add<std::vector<std::string> >("EcalRecHitSeveritiesToBeExcluded", {"kTime","kWeird","kBad"});
377  desc.add<unsigned int>("HcalAcceptSeverityLevelForRejectedHit", 9999);
378  desc.add<std::vector<std::string> >("EcalSeveritiesToBeUsedInBadTowers", {});
379  desc.add<int>("HcalPhase", 0);
380 
381  descriptions.addDefault(desc);
382 }
CaloTowersCreator(const edm::ParameterSet &ps)
double HF2Scale
Definition: EScales.h:20
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
void setEcalChStatusFromDB(const EcalChannelStatus *s)
CaloTowersCreationAlgo algo_
double EEScale
Definition: EScales.h:14
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
void produce(edm::Event &e, const edm::EventSetup &c) override
void setHcalChStatusFromDB(const HcalChannelQuality *s)
void finish(CaloTowerCollection &destCollection)
void setEeHandle(const edm::Handle< EcalRecHitCollection > ee)
double HOScale
Definition: EScales.h:18
std::vector< int > theEcalSeveritiesToBeExcluded_
double HF1Scale
Definition: EScales.h:19
edm::EDGetTokenT< HORecHitCollection > tok_ho_
void setGeometry(const CaloTowerTopology *cttopo, const CaloTowerConstituentsMap *ctmap, const HcalTopology *htopo, const CaloGeometry *geo)
double HEDScale
Definition: EScales.h:17
void setEbHandle(const edm::Handle< EcalRecHitCollection > eb)
void setUseRejectedRecoveredEcalHits(bool flag)
void addDefault(ParameterSetDescription const &psetDescription)
void setEcalSeveritiesToBeExcluded(const std::vector< int > &ecalSev)
void setHcalAcceptSeverityLevelForRejectedHit(unsigned int level)
void setHcalSevLvlComputer(const HcalSeverityLevelComputer *c)
std::vector< edm::EDGetTokenT< EcalRecHitCollection > > toks_ecal_
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
void SetEcalSeveritiesToBeUsedInBadTowers(const std::vector< int > &ecalSev)
void setRecoveredEcalHitsAreUsed(bool flag)
double EBScale
Definition: EScales.h:13
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
double HBScale
Definition: EScales.h:15
edm::ESWatcher< HcalChannelQualityRcd > hcalChStatusWatcher_
void process(const HBHERecHitCollection &hbhe)
std::string instanceLabel
Definition: EScales.h:21
unsigned int theHcalAcceptSeverityLevelForRejectedHit_
void setRecoveredHcalHitsAreUsed(bool flag)
void setUseRejectedHitsOnly(bool flag)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
void setMissingHcalRescaleFactorForEcal(float factor)
unsigned int theHcalAcceptSeverityLevel_
HLT enums.
T get() const
Definition: EventSetup.h:68
void setHcalAcceptSeverityLevel(unsigned int level)
std::vector< edm::InputTag > ecalLabels_
double HESScale
Definition: EScales.h:16
edm::ESWatcher< HcalSeverityLevelComputerRcd > hcalSevLevelWatcher_
void setEcalSevLvlAlgo(const EcalSeverityLevelAlgo *a)
void setUseRejectedRecoveredHcalHits(bool flag)
edm::ESWatcher< IdealGeometryRecord > caloTowerConstituentsWatcher_
T const * product() const
Definition: ESHandle.h:84
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: LeafCandidate.h:23
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const_iterator begin() const
edm::ESWatcher< EcalSeverityLevelAlgoRcd > ecalSevLevelWatcher_