test
CMS 3D CMS Logo

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