CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalRecHitProducer.cc
Go to the documentation of this file.
1 
11 
13 
21 
24 
26 
29 
31 {
32 
33  ebRechitCollection_ = ps.getParameter<std::string>("EBrechitCollection");
34  eeRechitCollection_ = ps.getParameter<std::string>("EErechitCollection");
35 
36  recoverEBIsolatedChannels_ = ps.getParameter<bool>("recoverEBIsolatedChannels");
37  recoverEEIsolatedChannels_ = ps.getParameter<bool>("recoverEEIsolatedChannels");
38  recoverEBVFE_ = ps.getParameter<bool>("recoverEBVFE");
39  recoverEEVFE_ = ps.getParameter<bool>("recoverEEVFE");
40  recoverEBFE_ = ps.getParameter<bool>("recoverEBFE");
41  recoverEEFE_ = ps.getParameter<bool>("recoverEEFE");
42  killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
43 
44 
45  produces< EBRecHitCollection >(ebRechitCollection_);
46  produces< EERecHitCollection >(eeRechitCollection_);
47 
48 
50  consumes<EBUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection"));
51 
53  consumes<EEUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection"));
54 
56  consumes<std::set<EBDetId>>(ps.getParameter<edm::InputTag>("ebDetIdToBeRecovered"));
57 
59  consumes<std::set<EEDetId>>(ps.getParameter<edm::InputTag>("eeDetIdToBeRecovered"));
60 
61  ebFEToBeRecoveredToken_ = consumes<std::set<EcalTrigTowerDetId>>(ps.getParameter<edm::InputTag>("ebFEToBeRecovered"));
62 
63  eeFEToBeRecoveredToken_= consumes<std::set<EcalScDetId>>( ps.getParameter<edm::InputTag>("eeFEToBeRecovered")) ;
64 
65  std::string componentType = ps.getParameter<std::string>("algo");
67  worker_ = EcalRecHitWorkerFactory::get()->create(componentType, ps, c);
68 
69  // to recover problematic channels
70  componentType = ps.getParameter<std::string>("algoRecover");
71  workerRecover_ = EcalRecHitWorkerFactory::get()->create(componentType, ps, c);
72 
73  edm::ParameterSet cleaningPs =
74  ps.getParameter<edm::ParameterSet>("cleaningConfig");
75  cleaningAlgo_ = new EcalCleaningAlgo(cleaningPs);
76 }
77 
79 {
80  delete worker_;
81  delete workerRecover_;
82  delete cleaningAlgo_;
83 }
84 
85 void
87 {
88  using namespace edm;
89 
92 
93  const EBUncalibratedRecHitCollection* ebUncalibRecHits = 0;
94  const EEUncalibratedRecHitCollection* eeUncalibRecHits = 0;
95 
96  // get the barrel uncalib rechit collection
97 
98  evt.getByToken( ebUncalibRecHitToken_, pEBUncalibRecHits);
99  ebUncalibRecHits = pEBUncalibRecHits.product();
100  LogDebug("EcalRecHitDebug") << "total # EB uncalibrated rechits: " << ebUncalibRecHits->size();
101 
102 
103 
104  evt.getByToken( eeUncalibRecHitToken_, pEEUncalibRecHits);
105  eeUncalibRecHits = pEEUncalibRecHits.product(); // get a ptr to the product
106  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits: " << eeUncalibRecHits->size();
107 
108  // collection of rechits to put in the event
109  std::auto_ptr< EBRecHitCollection > ebRecHits( new EBRecHitCollection );
110  std::auto_ptr< EERecHitCollection > eeRecHits( new EERecHitCollection );
111 
112  worker_->set(es);
113 
117  || killDeadChannels_ ) {
118  workerRecover_->set(es);
119  }
120 
121  if (ebUncalibRecHits)
122  {
123  // loop over uncalibrated rechits to make calibrated ones
124  for(EBUncalibratedRecHitCollection::const_iterator it = ebUncalibRecHits->begin(); it != ebUncalibRecHits->end(); ++it) {
125  worker_->run(evt, *it, *ebRecHits);
126  }
127  }
128 
129  if (eeUncalibRecHits)
130  {
131  // loop over uncalibrated rechits to make calibrated ones
132  for(EEUncalibratedRecHitCollection::const_iterator it = eeUncalibRecHits->begin(); it != eeUncalibRecHits->end(); ++it) {
133  worker_->run(evt, *it, *eeRecHits);
134  }
135  }
136 
137  // sort collections before attempting recovery, to avoid insertion of double recHits
138  ebRecHits->sort();
139  eeRecHits->sort();
140 
142  {
144  const std::set<EBDetId> * detIds = 0;
145  evt.getByToken( ebDetIdToBeRecoveredToken_, pEBDetId);
146  detIds = pEBDetId.product();
147 
148 
149  if ( detIds ) {
151  es.get<EcalChannelStatusRcd>().get(chStatus);
152  for( std::set<EBDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
153  // get channel status map to treat dead VFE separately
154  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
155  EcalChannelStatusCode chStatusCode;
156  if ( chit != chStatus->end() ) {
157  chStatusCode = *chit;
158  } else {
159  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
160  << (*it).rawId()
161  << "! something wrong with EcalChannelStatus in your DB? ";
162  }
164  if ( chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE ) { // dead VFE (from DB info)
165  // uses the EcalUncalibratedRecHit to pass the DetId info
167  if ( recoverEBVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
168  } else {
169  // uses the EcalUncalibratedRecHit to pass the DetId info
171  if ( recoverEBIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
172  }
173 
174  }
175  }
176  }
177 
179  {
181  const std::set<EEDetId> * detIds = 0;
182 
183  evt.getByToken( eeDetIdToBeRecoveredToken_, pEEDetId);
184  detIds = pEEDetId.product();
185 
186  if ( detIds ) {
188  es.get<EcalChannelStatusRcd>().get(chStatus);
189  for( std::set<EEDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
190  // get channel status map to treat dead VFE separately
191  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
192  EcalChannelStatusCode chStatusCode;
193  if ( chit != chStatus->end() ) {
194  chStatusCode = *chit;
195  } else {
196  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
197  << (*it).rawId()
198  << "! something wrong with EcalChannelStatus in your DB? ";
199  }
201  if ( chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE) { // dead VFE (from DB info)
202  // uses the EcalUncalibratedRecHit to pass the DetId info
204  if ( recoverEEVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *eeRecHits );
205  } else {
206  // uses the EcalUncalibratedRecHit to pass the DetId info
208  if ( recoverEEIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *eeRecHits );
209  }
210  }
211  }
212  }
213 
215  {
217  const std::set<EcalTrigTowerDetId> * ttIds = 0;
218 
219  evt.getByToken( ebFEToBeRecoveredToken_, pEBFEId);
220  ttIds = pEBFEId.product();
221 
222  if ( ttIds ) {
223  for( std::set<EcalTrigTowerDetId>::const_iterator it = ttIds->begin(); it != ttIds->end(); ++it ) {
224  // uses the EcalUncalibratedRecHit to pass the DetId info
225  int ieta = (((*it).ietaAbs()-1)*5+1)*(*it).zside(); // from EcalTrigTowerConstituentsMap
226  int iphi = (((*it).iphi()-1)*5+11)%360; // from EcalTrigTowerConstituentsMap
227  if( iphi <= 0 ) iphi += 360; // from EcalTrigTowerConstituentsMap
229  workerRecover_->run( evt, urh, *ebRecHits );
230  }
231  }
232  }
233 
235  {
237  const std::set<EcalScDetId> * scIds = 0;
238 
239  evt.getByToken( eeFEToBeRecoveredToken_, pEEFEId);
240  scIds = pEEFEId.product();
241 
242 
243  if ( scIds ) {
244  for( std::set<EcalScDetId>::const_iterator it = scIds->begin(); it != scIds->end(); ++it ) {
245  // uses the EcalUncalibratedRecHit to pass the DetId info
246  if (EEDetId::validDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() )) {
247  EcalUncalibratedRecHit urh( EEDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() ), 0, 0, 0, 0, EcalRecHitWorkerBaseClass::EE_FE );
248  workerRecover_->run( evt, urh, *eeRecHits );
249  }
250  }
251  }
252  }
253 
254  // without re-sorting, find (used below in cleaning) will lead
255  // to undefined results
256  ebRecHits->sort();
257  eeRecHits->sort();
258 
259  // apply spike cleaning
260  if (cleaningAlgo_){
261  cleaningAlgo_->setFlags(*ebRecHits);
262  cleaningAlgo_->setFlags(*eeRecHits);
263  }
264 
265 
266  // put the collection of recunstructed hits in the event
267  LogInfo("EcalRecHitInfo") << "total # EB calibrated rechits: " << ebRecHits->size();
268  LogInfo("EcalRecHitInfo") << "total # EE calibrated rechits: " << eeRecHits->size();
269 
270  evt.put( ebRecHits, ebRechitCollection_ );
271  evt.put( eeRecHits, eeRechitCollection_ );
272 }
273 
276  desc.add<bool>("recoverEEVFE",false);
277  desc.add<std::string>("EErechitCollection","EcalRecHitsEE");
278  desc.add<bool>("recoverEBIsolatedChannels",false);
279  desc.add<bool>("recoverEBVFE",false);
280  desc.add<bool>("laserCorrection",true);
281  desc.add<double>("EBLaserMIN",0.5);
282  desc.add<bool>("killDeadChannels",true);
283  {
284  std::vector<int> temp1;
285  temp1.reserve(3);
286  temp1.push_back(14);
287  temp1.push_back(78);
288  temp1.push_back(142);
289  desc.add<std::vector<int> >("dbStatusToBeExcludedEB",temp1);
290  }
291  desc.add<edm::InputTag>("EEuncalibRecHitCollection",edm::InputTag("ecalMultiFitUncalibRecHit","EcalUncalibRecHitsEE"));
292  {
293  std::vector<int> temp1;
294  temp1.reserve(3);
295  temp1.push_back(14);
296  temp1.push_back(78);
297  temp1.push_back(142);
298  desc.add<std::vector<int> >("dbStatusToBeExcludedEE",temp1);
299  }
300  desc.add<double>("EELaserMIN",0.5);
301  desc.add<edm::InputTag>("ebFEToBeRecovered",edm::InputTag("ecalDetIdToBeRecovered","ebFE"));
302  {
304  psd0.add<double>("e6e2thresh",0.04);
305  psd0.add<double>("tightenCrack_e6e2_double",3);
306  psd0.add<double>("e4e1Threshold_endcap",0.3);
307  psd0.add<double>("tightenCrack_e4e1_single",3);
308  psd0.add<double>("tightenCrack_e1_double",2);
309  psd0.add<double>("cThreshold_barrel",4);
310  psd0.add<double>("e4e1Threshold_barrel",0.08);
311  psd0.add<double>("tightenCrack_e1_single",2);
312  psd0.add<double>("e4e1_b_barrel",-0.024);
313  psd0.add<double>("e4e1_a_barrel",0.04);
314  psd0.add<double>("ignoreOutOfTimeThresh",1000000000.0);
315  psd0.add<double>("cThreshold_endcap",15);
316  psd0.add<double>("e4e1_b_endcap",-0.0125);
317  psd0.add<double>("e4e1_a_endcap",0.02);
318  psd0.add<double>("cThreshold_double",10);
319  desc.add<edm::ParameterSetDescription>("cleaningConfig",psd0);
320  }
321  desc.add<double>("logWarningEtThreshold_EE_FE",50);
322  desc.add<edm::InputTag>("eeDetIdToBeRecovered",edm::InputTag("ecalDetIdToBeRecovered","eeDetId"));
323  desc.add<bool>("recoverEBFE",true);
324  desc.add<edm::InputTag>("eeFEToBeRecovered",edm::InputTag("ecalDetIdToBeRecovered","eeFE"));
325  desc.add<edm::InputTag>("ebDetIdToBeRecovered",edm::InputTag("ecalDetIdToBeRecovered","ebDetId"));
326  desc.add<double>("singleChannelRecoveryThreshold",8);
327  {
328  std::vector<std::string> temp1;
329  temp1.reserve(9);
330  temp1.push_back("kNoisy");
331  temp1.push_back("kNNoisy");
332  temp1.push_back("kFixedG6");
333  temp1.push_back("kFixedG1");
334  temp1.push_back("kFixedG0");
335  temp1.push_back("kNonRespondingIsolated");
336  temp1.push_back("kDeadVFE");
337  temp1.push_back("kDeadFE");
338  temp1.push_back("kNoDataNoTP");
339  desc.add<std::vector<std::string> >("ChannelStatusToBeExcluded",temp1);
340  }
341  desc.add<std::string>("EBrechitCollection","EcalRecHitsEB");
342  desc.add<edm::InputTag>("triggerPrimitiveDigiCollection",edm::InputTag("ecalDigis","EcalTriggerPrimitives"));
343  desc.add<bool>("recoverEEFE",true);
344  desc.add<std::string>("singleChannelRecoveryMethod","NeuralNetworks");
345  desc.add<double>("EBLaserMAX",3.0);
346  {
348  {
349  std::vector<std::string> temp2;
350  temp2.reserve(4);
351  temp2.push_back("kOk");
352  temp2.push_back("kDAC");
353  temp2.push_back("kNoLaser");
354  temp2.push_back("kNoisy");
355  psd0.add<std::vector<std::string> >("kGood",temp2);
356  }
357  {
358  std::vector<std::string> temp2;
359  temp2.reserve(3);
360  temp2.push_back("kFixedG0");
361  temp2.push_back("kNonRespondingIsolated");
362  temp2.push_back("kDeadVFE");
363  psd0.add<std::vector<std::string> >("kNeighboursRecovered",temp2);
364  }
365  {
366  std::vector<std::string> temp2;
367  temp2.reserve(1);
368  temp2.push_back("kNoDataNoTP");
369  psd0.add<std::vector<std::string> >("kDead",temp2);
370  }
371  {
372  std::vector<std::string> temp2;
373  temp2.reserve(3);
374  temp2.push_back("kNNoisy");
375  temp2.push_back("kFixedG6");
376  temp2.push_back("kFixedG1");
377  psd0.add<std::vector<std::string> >("kNoisy",temp2);
378  }
379  {
380  std::vector<std::string> temp2;
381  temp2.reserve(1);
382  temp2.push_back("kDeadFE");
383  psd0.add<std::vector<std::string> >("kTowerRecovered",temp2);
384  }
385  desc.add<edm::ParameterSetDescription>("flagsMapDBReco",psd0);
386  }
387  desc.add<edm::InputTag>("EBuncalibRecHitCollection",edm::InputTag("ecalMultiFitUncalibRecHit","EcalUncalibRecHitsEB"));
388  desc.add<std::string>("algoRecover","EcalRecHitWorkerRecover");
389  desc.add<std::string>("algo","EcalRecHitWorkerSimple");
390  desc.add<double>("EELaserMAX",8.0);
391  desc.add<double>("logWarningEtThreshold_EB_FE",50);
392  desc.add<bool>("recoverEEIsolatedChannels",false);
393  descriptions.add("ecalRecHit",desc);
394 }
395 
#define LogDebug(id)
std::string eeRechitCollection_
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void reserve(SetDescriptionEntries::size_type n)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Code getStatusCode() const
return decoded status
std::vector< EcalUncalibratedRecHit >::const_iterator const_iterator
EcalRecHitWorkerBaseClass * worker_
EcalRecHitProducer(const edm::ParameterSet &ps)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
EcalCleaningAlgo * cleaningAlgo_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< EEUncalibratedRecHitCollection > eeUncalibRecHitToken_
edm::EDGetTokenT< std::set< EcalScDetId > > eeFEToBeRecoveredToken_
static const int ETAPHIMODE
Definition: EBDetId.h:166
edm::EDGetTokenT< EBUncalibratedRecHitCollection > ebUncalibRecHitToken_
EcalRecHitWorkerBaseClass * workerRecover_
virtual bool run(const edm::Event &evt, const EcalUncalibratedRecHit &uncalibRH, EcalRecHitCollection &result)=0
edm::EDGetTokenT< std::set< EBDetId > > ebDetIdToBeRecoveredToken_
T const * product() const
Definition: Handle.h:81
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
std::string ebRechitCollection_
const T & get() const
Definition: EventSetup.h:56
std::vector< Item >::const_iterator const_iterator
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void set(const edm::EventSetup &es)=0
virtual void produce(edm::Event &evt, const edm::EventSetup &es) override
void setFlags(EcalRecHitCollection &rhs)
edm::EDGetTokenT< std::set< EEDetId > > eeDetIdToBeRecoveredToken_
T get(const Candidate &c)
Definition: component.h:55
edm::EDGetTokenT< std::set< EcalTrigTowerDetId > > ebFEToBeRecoveredToken_