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 
27 
29 {
30 
31  ebRechitCollection_ = ps.getParameter<std::string>("EBrechitCollection");
32  eeRechitCollection_ = ps.getParameter<std::string>("EErechitCollection");
33 
34  recoverEBIsolatedChannels_ = ps.getParameter<bool>("recoverEBIsolatedChannels");
35  recoverEEIsolatedChannels_ = ps.getParameter<bool>("recoverEEIsolatedChannels");
36  recoverEBVFE_ = ps.getParameter<bool>("recoverEBVFE");
37  recoverEEVFE_ = ps.getParameter<bool>("recoverEEVFE");
38  recoverEBFE_ = ps.getParameter<bool>("recoverEBFE");
39  recoverEEFE_ = ps.getParameter<bool>("recoverEEFE");
40  killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
41 
42 
43  produces< EBRecHitCollection >(ebRechitCollection_);
44  produces< EERecHitCollection >(eeRechitCollection_);
45 
46 
48  consumes<EBUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection"));
49 
51  consumes<EEUncalibratedRecHitCollection>( ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection"));
52 
54  consumes<std::set<EBDetId>>(ps.getParameter<edm::InputTag>("ebDetIdToBeRecovered"));
55 
57  consumes<std::set<EEDetId>>(ps.getParameter<edm::InputTag>("eeDetIdToBeRecovered"));
58 
59  ebFEToBeRecoveredToken_ = consumes<std::set<EcalTrigTowerDetId>>(ps.getParameter<edm::InputTag>("ebFEToBeRecovered"));
60 
61  eeFEToBeRecoveredToken_= consumes<std::set<EcalScDetId>>( ps.getParameter<edm::InputTag>("eeFEToBeRecovered")) ;
62 
63  std::string componentType = ps.getParameter<std::string>("algo");
65  worker_ = EcalRecHitWorkerFactory::get()->create(componentType, ps, c);
66 
67  // to recover problematic channels
68  componentType = ps.getParameter<std::string>("algoRecover");
69  workerRecover_ = EcalRecHitWorkerFactory::get()->create(componentType, ps, c);
70 
71  edm::ParameterSet cleaningPs =
72  ps.getParameter<edm::ParameterSet>("cleaningConfig");
73  cleaningAlgo_ = new EcalCleaningAlgo(cleaningPs);
74 }
75 
77 {
78  delete worker_;
79  delete workerRecover_;
80  delete cleaningAlgo_;
81 }
82 
83 void
85 {
86  using namespace edm;
87 
90 
91  const EBUncalibratedRecHitCollection* ebUncalibRecHits = 0;
92  const EEUncalibratedRecHitCollection* eeUncalibRecHits = 0;
93 
94  // get the barrel uncalib rechit collection
95 
96  evt.getByToken( ebUncalibRecHitToken_, pEBUncalibRecHits);
97  ebUncalibRecHits = pEBUncalibRecHits.product();
98  LogDebug("EcalRecHitDebug") << "total # EB uncalibrated rechits: " << ebUncalibRecHits->size();
99 
100 
101 
102  evt.getByToken( eeUncalibRecHitToken_, pEEUncalibRecHits);
103  eeUncalibRecHits = pEEUncalibRecHits.product(); // get a ptr to the product
104  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits: " << eeUncalibRecHits->size();
105 
106  // collection of rechits to put in the event
107  std::auto_ptr< EBRecHitCollection > ebRecHits( new EBRecHitCollection );
108  std::auto_ptr< EERecHitCollection > eeRecHits( new EERecHitCollection );
109 
110  worker_->set(es);
111 
115  || killDeadChannels_ ) {
116  workerRecover_->set(es);
117  }
118 
119  if (ebUncalibRecHits)
120  {
121  // loop over uncalibrated rechits to make calibrated ones
122  for(EBUncalibratedRecHitCollection::const_iterator it = ebUncalibRecHits->begin(); it != ebUncalibRecHits->end(); ++it) {
123  worker_->run(evt, *it, *ebRecHits);
124  }
125  }
126 
127  if (eeUncalibRecHits)
128  {
129  // loop over uncalibrated rechits to make calibrated ones
130  for(EEUncalibratedRecHitCollection::const_iterator it = eeUncalibRecHits->begin(); it != eeUncalibRecHits->end(); ++it) {
131  worker_->run(evt, *it, *eeRecHits);
132  }
133  }
134 
135  // sort collections before attempting recovery, to avoid insertion of double recHits
136  ebRecHits->sort();
137  eeRecHits->sort();
138 
140  {
142  const std::set<EBDetId> * detIds = 0;
143  evt.getByToken( ebDetIdToBeRecoveredToken_, pEBDetId);
144  detIds = pEBDetId.product();
145 
146 
147  if ( detIds ) {
149  es.get<EcalChannelStatusRcd>().get(chStatus);
150  for( std::set<EBDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
151  // get channel status map to treat dead VFE separately
152  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
153  EcalChannelStatusCode chStatusCode;
154  if ( chit != chStatus->end() ) {
155  chStatusCode = *chit;
156  } else {
157  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
158  << (*it).rawId()
159  << "! something wrong with EcalChannelStatus in your DB? ";
160  }
162  if ( chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE ) { // dead VFE (from DB info)
163  // uses the EcalUncalibratedRecHit to pass the DetId info
165  if ( recoverEBVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
166  } else {
167  // uses the EcalUncalibratedRecHit to pass the DetId info
169  if ( recoverEBIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
170  }
171 
172  }
173  }
174  }
175 
177  {
179  const std::set<EEDetId> * detIds = 0;
180 
181  evt.getByToken( eeDetIdToBeRecoveredToken_, pEEDetId);
182  detIds = pEEDetId.product();
183 
184  if ( detIds ) {
186  es.get<EcalChannelStatusRcd>().get(chStatus);
187  for( std::set<EEDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
188  // get channel status map to treat dead VFE separately
189  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
190  EcalChannelStatusCode chStatusCode;
191  if ( chit != chStatus->end() ) {
192  chStatusCode = *chit;
193  } else {
194  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
195  << (*it).rawId()
196  << "! something wrong with EcalChannelStatus in your DB? ";
197  }
199  if ( chStatusCode.getStatusCode() == EcalChannelStatusCode::kDeadVFE) { // dead VFE (from DB info)
200  // uses the EcalUncalibratedRecHit to pass the DetId info
202  if ( recoverEEVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *eeRecHits );
203  } else {
204  // uses the EcalUncalibratedRecHit to pass the DetId info
206  if ( recoverEEIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *eeRecHits );
207  }
208  }
209  }
210  }
211 
213  {
215  const std::set<EcalTrigTowerDetId> * ttIds = 0;
216 
217  evt.getByToken( ebFEToBeRecoveredToken_, pEBFEId);
218  ttIds = pEBFEId.product();
219 
220  if ( ttIds ) {
221  for( std::set<EcalTrigTowerDetId>::const_iterator it = ttIds->begin(); it != ttIds->end(); ++it ) {
222  // uses the EcalUncalibratedRecHit to pass the DetId info
223  int ieta = (((*it).ietaAbs()-1)*5+1)*(*it).zside(); // from EcalTrigTowerConstituentsMap
224  int iphi = ((*it).iphi()-1)*5+11; // from EcalTrigTowerConstituentsMap
225  if( iphi <= 0 ) iphi += 360; // from EcalTrigTowerConstituentsMap
227  workerRecover_->run( evt, urh, *ebRecHits );
228  }
229  }
230  }
231 
233  {
235  const std::set<EcalScDetId> * scIds = 0;
236 
237  evt.getByToken( eeFEToBeRecoveredToken_, pEEFEId);
238  scIds = pEEFEId.product();
239 
240 
241  if ( scIds ) {
242  for( std::set<EcalScDetId>::const_iterator it = scIds->begin(); it != scIds->end(); ++it ) {
243  // uses the EcalUncalibratedRecHit to pass the DetId info
244  if (EEDetId::validDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() )) {
245  EcalUncalibratedRecHit urh( EEDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() ), 0, 0, 0, 0, EcalRecHitWorkerBaseClass::EE_FE );
246  workerRecover_->run( evt, urh, *eeRecHits );
247  }
248  }
249  }
250  }
251 
252  // without re-sorting, find (used below in cleaning) will lead
253  // to undefined results
254  ebRecHits->sort();
255  eeRecHits->sort();
256 
257  // apply spike cleaning
258  if (cleaningAlgo_){
259  cleaningAlgo_->setFlags(*ebRecHits);
260  cleaningAlgo_->setFlags(*eeRecHits);
261  }
262 
263 
264  // put the collection of recunstructed hits in the event
265  LogInfo("EcalRecHitInfo") << "total # EB calibrated rechits: " << ebRecHits->size();
266  LogInfo("EcalRecHitInfo") << "total # EE calibrated rechits: " << eeRecHits->size();
267 
268  evt.put( ebRecHits, ebRechitCollection_ );
269  evt.put( eeRecHits, eeRechitCollection_ );
270 }
271 
#define LogDebug(id)
std::string eeRechitCollection_
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#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)
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
EcalCleaningAlgo * cleaningAlgo_
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_
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:55
std::vector< Item >::const_iterator const_iterator
T const * product() const
Definition: Handle.h:81
virtual void set(const edm::EventSetup &es)=0
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_