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.
6 // severity level for ECAL
9 
10 
12  algo_(conf.getParameter<double>("EBThreshold"),
13  conf.getParameter<double>("EEThreshold"),
14 
15  conf.getParameter<bool>("UseEtEBTreshold"),
16  conf.getParameter<bool>("UseEtEETreshold"),
17  conf.getParameter<bool>("UseSymEBTreshold"),
18  conf.getParameter<bool>("UseSymEETreshold"),
19 
20 
21  conf.getParameter<double>("HcalThreshold"),
22  conf.getParameter<double>("HBThreshold"),
23  conf.getParameter<double>("HESThreshold"),
24  conf.getParameter<double>("HEDThreshold"),
25  conf.getParameter<double>("HOThreshold0"),
26  conf.getParameter<double>("HOThresholdPlus1"),
27  conf.getParameter<double>("HOThresholdMinus1"),
28  conf.getParameter<double>("HOThresholdPlus2"),
29  conf.getParameter<double>("HOThresholdMinus2"),
30  conf.getParameter<double>("HF1Threshold"),
31  conf.getParameter<double>("HF2Threshold"),
32  conf.getParameter<std::vector<double> >("EBGrid"),
33  conf.getParameter<std::vector<double> >("EBWeights"),
34  conf.getParameter<std::vector<double> >("EEGrid"),
35  conf.getParameter<std::vector<double> >("EEWeights"),
36  conf.getParameter<std::vector<double> >("HBGrid"),
37  conf.getParameter<std::vector<double> >("HBWeights"),
38  conf.getParameter<std::vector<double> >("HESGrid"),
39  conf.getParameter<std::vector<double> >("HESWeights"),
40  conf.getParameter<std::vector<double> >("HEDGrid"),
41  conf.getParameter<std::vector<double> >("HEDWeights"),
42  conf.getParameter<std::vector<double> >("HOGrid"),
43  conf.getParameter<std::vector<double> >("HOWeights"),
44  conf.getParameter<std::vector<double> >("HF1Grid"),
45  conf.getParameter<std::vector<double> >("HF1Weights"),
46  conf.getParameter<std::vector<double> >("HF2Grid"),
47  conf.getParameter<std::vector<double> >("HF2Weights"),
48  conf.getParameter<double>("EBWeight"),
49  conf.getParameter<double>("EEWeight"),
50  conf.getParameter<double>("HBWeight"),
51  conf.getParameter<double>("HESWeight"),
52  conf.getParameter<double>("HEDWeight"),
53  conf.getParameter<double>("HOWeight"),
54  conf.getParameter<double>("HF1Weight"),
55  conf.getParameter<double>("HF2Weight"),
56  conf.getParameter<double>("EcutTower"),
57  conf.getParameter<double>("EBSumThreshold"),
58  conf.getParameter<double>("EESumThreshold"),
59  conf.getParameter<bool>("UseHO"),
60  // (for momentum reconstruction algorithm)
61  conf.getParameter<int>("MomConstrMethod"),
62  conf.getParameter<double>("MomHBDepth"),
63  conf.getParameter<double>("MomHEDepth"),
64  conf.getParameter<double>("MomEBDepth"),
65  conf.getParameter<double>("MomEEDepth")
66  ),
67 
68  ecalLabels_(conf.getParameter<std::vector<edm::InputTag> >("ecalInputs")),
69  allowMissingInputs_(conf.getParameter<bool>("AllowMissingInputs")),
70 
71  theHcalAcceptSeverityLevel_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevel")),
72 
73  theRecoveredHcalHitsAreUsed_(conf.getParameter<bool>("UseHcalRecoveredHits")),
74  theRecoveredEcalHitsAreUsed_(conf.getParameter<bool>("UseEcalRecoveredHits")),
75 
76  // paramaters controlling the use of rejected hits
77 
78  useRejectedHitsOnly_(conf.getParameter<bool>("UseRejectedHitsOnly")),
79 
80  theHcalAcceptSeverityLevelForRejectedHit_(conf.getParameter<unsigned int>("HcalAcceptSeverityLevelForRejectedHit")),
81 
82 
83  useRejectedRecoveredHcalHits_(conf.getParameter<bool>("UseRejectedRecoveredHcalHits")),
84  useRejectedRecoveredEcalHits_(conf.getParameter<bool>("UseRejectedRecoveredEcalHits"))
85 
86 
87 
88 {
89 
90  // register for data access
91  tok_hbhe_ = consumes<HBHERecHitCollection>(conf.getParameter<edm::InputTag>("hbheInput"));
92  tok_ho_ = consumes<HORecHitCollection>(conf.getParameter<edm::InputTag>("hoInput"));
93  tok_hf_ = consumes<HFRecHitCollection>(conf.getParameter<edm::InputTag>("hfInput"));
94 
95  const unsigned nLabels = ecalLabels_.size();
96  for ( unsigned i=0; i != nLabels; i++ )
97  toks_ecal_.push_back(consumes<EcalRecHitCollection>(ecalLabels_[i]));
98 
99 
108 
109  // get the Ecal severities to be excluded
110  const std::vector<std::string> severitynames =
111  conf.getParameter<std::vector<std::string> >("EcalRecHitSeveritiesToBeExcluded");
112 
113  theEcalSeveritiesToBeExcluded_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynames);
114 
115  // get the Ecal severities to be used for bad towers
117  StringToEnumValue<EcalSeverityLevel::SeverityLevel>(conf.getParameter<std::vector<std::string> >("EcalSeveritiesToBeUsedInBadTowers") );
118 
119  if (eScales_.instanceLabel=="") produces<CaloTowerCollection>();
120  else produces<CaloTowerCollection>(eScales_.instanceLabel);
121 
122  /*
123  std::cout << "VI Producer "
124  << (useRejectedHitsOnly_ ? "use rejectOnly " : " ")
125  << (allowMissingInputs_ ? "allowMissing " : " " )
126  << nLabels << ' ' << severitynames.size()
127  << std::endl;
128  */
129 }
130 
132  // get the necessary event setup objects...
136  c.get<CaloGeometryRecord>().get(pG);
137  c.get<IdealGeometryRecord>().get(htopo);
138  c.get<IdealGeometryRecord>().get(cttopo);
139 
140  // ECAL channel status map ****************************************
142  c.get<EcalChannelStatusRcd>().get( ecalChStatus );
143  const EcalChannelStatus* dbEcalChStatus = ecalChStatus.product();
144 
145  // HCAL channel status map ****************************************
146  edm::ESHandle<HcalChannelQuality> hcalChStatus;
147  c.get<HcalChannelQualityRcd>().get( hcalChStatus );
148  const HcalChannelQuality* dbHcalChStatus = hcalChStatus.product();
149 
150  if (!dbHcalChStatus->topo()) dbHcalChStatus->setTopo(htopo.product());
151 
152  // Assignment of severity levels **********************************
153  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
154  c.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
155  const HcalSeverityLevelComputer* hcalSevLvlComputer = hcalSevLvlComputerHndl.product();
156 
157  edm::ESHandle<EcalSeverityLevelAlgo> ecalSevLvlAlgoHndl;
158  c.get<EcalSeverityLevelAlgoRcd>().get(ecalSevLvlAlgoHndl);
159  const EcalSeverityLevelAlgo* ecalSevLvlAlgo = ecalSevLvlAlgoHndl.product();
160 
161 
170  algo_.setGeometry(cttopo.product(),htopo.product(),pG.product());
171 
172  // for treatment of problematic and anomalous cells
173 
174  algo_.setHcalChStatusFromDB(dbHcalChStatus);
175  algo_.setEcalChStatusFromDB(dbEcalChStatus);
176 
179 
182 
183  algo_.setHcalSevLvlComputer(hcalSevLvlComputer);
184  algo_.setEcalSevLvlAlgo(ecalSevLvlAlgo);
185 
186 
188 
191 
194 
195  /*
196  std::cout << "VI Produce: "
197  << (useRejectedHitsOnly_ ? "use rejectOnly " : " ")
198  << (allowMissingInputs_ ? "allowMissing " : " " )
199  << (theRecoveredEcalHitsAreUsed_ ? "use RecoveredEcal ": " " )
200  << toks_ecal_.size()
201  << ' ' << theEcalSeveritiesToBeExcluded_.size()
202  << ' ' << theEcalSeveritiesToBeUsedInBadTowers_.size()
203  << std::endl;
204  */
205 
206  algo_.begin(); // clear the internal buffer
207 
208  // can't chain these in a big OR statement, or else it'll
209  // get triggered for each of the first three events
210  bool check1 = hcalSevLevelWatcher_.check(c);
211  bool check2 = hcalChStatusWatcher_.check(c);
212  bool check3 = caloTowerConstituentsWatcher_.check(c);
213  if(check1 || check2 || check3)
214  {
216  }
217 
218  // check ecal SevLev
220 
221  // ----------------------------------------------------------
222  // For ecal error handling need to
223  // have access to the EB and EE collections at the end of
224  // tower reconstruction.
225 
228 
229  for (std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i=toks_ecal_.begin();
230  i!=toks_ecal_.end(); i++) {
231 
233 
234  if (! e.getByToken(*i,ec_tmp) ) continue;
235  if (ec_tmp->size()==0) continue;
236 
237  // check if this is EB or EE
238  if ( (ec_tmp->begin()->detid()).subdetId() == EcalBarrel ) {
239  ebHandle = ec_tmp;
240  }
241  else if ((ec_tmp->begin()->detid()).subdetId() == EcalEndcap ) {
242  eeHandle = ec_tmp;
243  }
244  }
245 
246  algo_.setEbHandle(ebHandle);
247  algo_.setEeHandle(eeHandle);
248 
249  //-----------------------------------------------------------
250 
251  bool present;
252 
253  // Step A/C: Get Inputs and process (repeatedly)
255  present=e.getByToken(tok_hbhe_,hbhe);
256  if (present || !allowMissingInputs_) algo_.process(*hbhe);
257 
259  present=e.getByToken(tok_ho_,ho);
260  if (present || !allowMissingInputs_) algo_.process(*ho);
261 
263  present=e.getByToken(tok_hf_,hf);
264  if (present || !allowMissingInputs_) algo_.process(*hf);
265 
266  std::vector<edm::EDGetTokenT<EcalRecHitCollection> >::const_iterator i;
267  for (i=toks_ecal_.begin(); i!=toks_ecal_.end(); i++) {
269  present=e.getByToken(*i,ec);
270  if (present || !allowMissingInputs_) algo_.process(*ec);
271  }
272 
273  // Step B: Create empty output
274  std::auto_ptr<CaloTowerCollection> prod(new CaloTowerCollection());
275 
276  // Step C: Process
277  algo_.finish(*prod);
278 
279  /*
280  int totc=0; float totE=0;
281  reco::LeafCandidate::LorentzVector totP4;
282  for (auto const & tw : (*prod) ) { totc += tw.constituents().size(); totE+=tw.energy(); totP4+=tw.p4();}
283  std::cout << "VI " << (*prod).size() << " " << totc << " " << totE << " " << totP4 << std::endl;
284  */
285 
286  // Step D: Put into the event
287  if (eScales_.instanceLabel=="") e.put(prod);
288  else e.put(prod,eScales_.instanceLabel);
289 
290 
291 }
292 
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:434
void setHcalChStatusFromDB(const HcalChannelQuality *s)
void setTopo(const HcalTopology *topo) const
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_
double HEDScale
Definition: EScales.h:15
void setEbHandle(const edm::Handle< EcalRecHitCollection > eb)
void setUseRejectedRecoveredEcalHits(bool flag)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
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
double HBScale
Definition: EScales.h:13
edm::ESWatcher< HcalChannelQualityRcd > hcalChStatusWatcher_
tuple conf
Definition: dbtoconf.py:185
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:55
T const * product() const
Definition: ESHandle.h:62
void setUseRejectedHitsOnly(bool flag)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:58
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_
void setGeometry(const CaloTowerConstituentsMap *cttopo, const HcalTopology *htopo, const CaloGeometry *geo)
std::vector< int > theEcalSeveritiesToBeUsedInBadTowers_
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
const HcalTopology * topo() const
edm::ESWatcher< EcalSeverityLevelAlgoRcd > ecalSevLevelWatcher_