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 
14 
16 
24 
27 
29 
30 
32 {
33  ebUncalibRecHitCollection_ = ps.getParameter<edm::InputTag>("EBuncalibRecHitCollection");
34  eeUncalibRecHitCollection_ = ps.getParameter<edm::InputTag>("EEuncalibRecHitCollection");
35  ebRechitCollection_ = ps.getParameter<std::string>("EBrechitCollection");
36  eeRechitCollection_ = ps.getParameter<std::string>("EErechitCollection");
37 
38  recoverEBIsolatedChannels_ = ps.getParameter<bool>("recoverEBIsolatedChannels");
39  recoverEEIsolatedChannels_ = ps.getParameter<bool>("recoverEEIsolatedChannels");
40  recoverEBVFE_ = ps.getParameter<bool>("recoverEBVFE");
41  recoverEEVFE_ = ps.getParameter<bool>("recoverEEVFE");
42  recoverEBFE_ = ps.getParameter<bool>("recoverEBFE");
43  recoverEEFE_ = ps.getParameter<bool>("recoverEEFE");
44  killDeadChannels_ = ps.getParameter<bool>("killDeadChannels");
45 
46  ebDetIdToBeRecovered_ = ps.getParameter<edm::InputTag>("ebDetIdToBeRecovered");
47  eeDetIdToBeRecovered_ = ps.getParameter<edm::InputTag>("eeDetIdToBeRecovered");
48  ebFEToBeRecovered_ = ps.getParameter<edm::InputTag>("ebFEToBeRecovered");
49  eeFEToBeRecovered_ = ps.getParameter<edm::InputTag>("eeFEToBeRecovered");
50 
51  produces< EBRecHitCollection >(ebRechitCollection_);
52  produces< EERecHitCollection >(eeRechitCollection_);
53 
54  std::string componentType = ps.getParameter<std::string>("algo");
55  worker_ = EcalRecHitWorkerFactory::get()->create(componentType, ps);
56 
57  // to recover problematic channels
58  componentType = ps.getParameter<std::string>("algoRecover");
59  workerRecover_ = EcalRecHitWorkerFactory::get()->create(componentType, ps);
60 
61  edm::ParameterSet cleaningPs =
62  ps.getParameter<edm::ParameterSet>("cleaningConfig");
63  cleaningAlgo_ = new EcalCleaningAlgo(cleaningPs);
64 }
65 
67 {
68  delete worker_;
69  delete workerRecover_;
70  delete cleaningAlgo_;
71 }
72 
73 void
75 {
76  using namespace edm;
77 
80 
81  const EBUncalibratedRecHitCollection* ebUncalibRecHits = 0;
82  const EEUncalibratedRecHitCollection* eeUncalibRecHits = 0;
83 
84  // get the barrel uncalib rechit collection
86  evt.getByLabel( ebUncalibRecHitCollection_, pEBUncalibRecHits);
87  if ( pEBUncalibRecHits.isValid() ) {
88  ebUncalibRecHits = pEBUncalibRecHits.product();
89  LogDebug("EcalRecHitDebug") << "total # EB uncalibrated rechits: " << ebUncalibRecHits->size();
90  } else {
91  edm::LogError("EcalRecHitError") << "Error! can't get the product " << ebUncalibRecHitCollection_;
92  }
93  }
94 
96  evt.getByLabel( eeUncalibRecHitCollection_, pEEUncalibRecHits);
97  if ( pEEUncalibRecHits.isValid() ) {
98  eeUncalibRecHits = pEEUncalibRecHits.product(); // get a ptr to the product
99  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits: " << eeUncalibRecHits->size();
100  } else {
101  edm::LogError("EcalRecHitError") << "Error! can't get the product " << eeUncalibRecHitCollection_;
102  }
103  }
104 
105  // collection of rechits to put in the event
106  std::auto_ptr< EBRecHitCollection > ebRecHits( new EBRecHitCollection );
107  std::auto_ptr< EERecHitCollection > eeRecHits( new EERecHitCollection );
108 
109  worker_->set(es);
110 
114  || killDeadChannels_ ) {
115  workerRecover_->set(es);
116  }
117 
118  if (ebUncalibRecHits)
119  {
120  // loop over uncalibrated rechits to make calibrated ones
121  for(EBUncalibratedRecHitCollection::const_iterator it = ebUncalibRecHits->begin(); it != ebUncalibRecHits->end(); ++it) {
122  worker_->run(evt, *it, *ebRecHits);
123  }
124  }
125 
126  if (eeUncalibRecHits)
127  {
128  // loop over uncalibrated rechits to make calibrated ones
129  for(EEUncalibratedRecHitCollection::const_iterator it = eeUncalibRecHits->begin(); it != eeUncalibRecHits->end(); ++it) {
130  worker_->run(evt, *it, *eeRecHits);
131  }
132  }
133 
134  // sort collections before attempting recovery, to avoid insertion of double recHits
135  ebRecHits->sort();
136  eeRecHits->sort();
137 
139  {
141  const std::set<EBDetId> * detIds = 0;
142  if ( ebDetIdToBeRecovered_.label() != "" && ebDetIdToBeRecovered_.instance() != "" ) {
143  evt.getByLabel( ebDetIdToBeRecovered_, pEBDetId);
144  if ( pEBDetId.isValid() ) {
145  detIds = pEBDetId.product();
146  } else {
147  edm::LogError("EcalRecHitError") << "Error! can't get the product " << ebDetIdToBeRecovered_;
148  }
149  }
150  if ( detIds ) {
152  es.get<EcalChannelStatusRcd>().get(chStatus);
153  for( std::set<EBDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
154  // get channel status map to treat dead VFE separately
155  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
156  EcalChannelStatusCode chStatusCode = 1;
157  if ( chit != chStatus->end() ) {
158  chStatusCode = *chit;
159  } else {
160  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
161  << (*it).rawId()
162  << "! something wrong with EcalChannelStatus in your DB? ";
163  }
165  if ( (chStatusCode.getStatusCode() & 0x001F) == 12 ) { // dead VFE (from DB info)
166  // uses the EcalUncalibratedRecHit to pass the DetId info
168  if ( recoverEBVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
169  } else {
170  // uses the EcalUncalibratedRecHit to pass the DetId info
172  if ( recoverEBIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
173  }
174 
175  }
176  }
177  }
178 
180  {
182  const std::set<EEDetId> * detIds = 0;
183  if ( eeDetIdToBeRecovered_.label() != "" && eeDetIdToBeRecovered_.instance() != "" ) {
184  evt.getByLabel( eeDetIdToBeRecovered_, pEEDetId);
185  if ( pEEDetId.isValid() ) {
186  detIds = pEEDetId.product();
187  } else {
188  edm::LogError("EcalRecHitError") << "Error! can't get the product " << eeDetIdToBeRecovered_;
189  }
190  }
191  if ( detIds ) {
193  es.get<EcalChannelStatusRcd>().get(chStatus);
194  for( std::set<EEDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
195  // get channel status map to treat dead VFE separately
196  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
197  EcalChannelStatusCode chStatusCode = 1;
198  if ( chit != chStatus->end() ) {
199  chStatusCode = *chit;
200  } else {
201  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
202  << (*it).rawId()
203  << "! something wrong with EcalChannelStatus in your DB? ";
204  }
206  if ( (chStatusCode.getStatusCode() & 0x001F) == 12 ) { // dead VFE (from DB info)
207  // uses the EcalUncalibratedRecHit to pass the DetId info
209  if ( recoverEEVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *eeRecHits );
210  } else {
211  // uses the EcalUncalibratedRecHit to pass the DetId info
213  if ( recoverEEIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *eeRecHits );
214  }
215  }
216  }
217  }
218 
220  {
222  const std::set<EcalTrigTowerDetId> * ttIds = 0;
223  if ( ebFEToBeRecovered_.label() != "" && ebFEToBeRecovered_.instance() != "" ) {
224  evt.getByLabel( ebFEToBeRecovered_, pEBFEId);
225  if ( pEBFEId.isValid() ) {
226  ttIds = pEBFEId.product();
227  } else {
228  edm::LogError("EcalRecHitError") << "Error! can't get the product " << ebFEToBeRecovered_;
229  }
230  }
231  if ( ttIds ) {
232  for( std::set<EcalTrigTowerDetId>::const_iterator it = ttIds->begin(); it != ttIds->end(); ++it ) {
233  // uses the EcalUncalibratedRecHit to pass the DetId info
234  int ieta = (((*it).ietaAbs()-1)*5+1)*(*it).zside(); // from EcalTrigTowerConstituentsMap
235  int iphi = ((*it).iphi()-1)*5+11; // from EcalTrigTowerConstituentsMap
236  if( iphi <= 0 ) iphi += 360; // from EcalTrigTowerConstituentsMap
238  workerRecover_->run( evt, urh, *ebRecHits );
239  }
240  }
241  }
242 
244  {
246  const std::set<EcalScDetId> * scIds = 0;
247  if ( eeFEToBeRecovered_.label() != "" && eeFEToBeRecovered_.instance() != "" ) {
248  evt.getByLabel( eeFEToBeRecovered_, pEEFEId);
249  if ( pEEFEId.isValid() ) {
250  scIds = pEEFEId.product();
251  } else {
252  edm::LogError("EcalRecHitError") << "Error! can't get the product " << eeFEToBeRecovered_;
253  }
254  }
255  if ( scIds ) {
256  for( std::set<EcalScDetId>::const_iterator it = scIds->begin(); it != scIds->end(); ++it ) {
257  // uses the EcalUncalibratedRecHit to pass the DetId info
258  if (EEDetId::validDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() )) {
259  EcalUncalibratedRecHit urh( EEDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() ), 0, 0, 0, 0, EcalRecHitWorkerBaseClass::EE_FE );
260  workerRecover_->run( evt, urh, *eeRecHits );
261  }
262  }
263  }
264  }
265 
266  // without re-sorting, find (used below in cleaning) will lead
267  // to undefined results
268  ebRecHits->sort();
269  eeRecHits->sort();
270 
271  // apply spike cleaning
272  if (cleaningAlgo_){
273  cleaningAlgo_->setFlags(*ebRecHits);
274  cleaningAlgo_->setFlags(*eeRecHits);
275  }
276 
277 
278  // put the collection of recunstructed hits in the event
279  LogInfo("EcalRecHitInfo") << "total # EB calibrated rechits: " << ebRecHits->size();
280  LogInfo("EcalRecHitInfo") << "total # EE calibrated rechits: " << eeRecHits->size();
281 
282  evt.put( ebRecHits, ebRechitCollection_ );
283  evt.put( eeRecHits, eeRechitCollection_ );
284 }
285 
#define LogDebug(id)
std::string eeRechitCollection_
T getParameter(std::string const &) const
edm::InputTag ebFEToBeRecovered_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< T >::const_iterator const_iterator
edm::InputTag ebDetIdToBeRecovered_
edm::InputTag eeFEToBeRecovered_
EcalRecHitWorkerBaseClass * worker_
EcalRecHitProducer(const edm::ParameterSet &ps)
virtual void produce(edm::Event &evt, const edm::EventSetup &es)
uint16_t getStatusCode() const
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
EcalCleaningAlgo * cleaningAlgo_
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
static const int ETAPHIMODE
Definition: EBDetId.h:167
EcalRecHitWorkerBaseClass * workerRecover_
virtual bool run(const edm::Event &evt, const EcalUncalibratedRecHit &uncalibRH, EcalRecHitCollection &result)=0
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:249
edm::InputTag eeDetIdToBeRecovered_
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:74
edm::InputTag ebUncalibRecHitCollection_
std::string const & label() const
Definition: InputTag.h:42
virtual void set(const edm::EventSetup &es)=0
void setFlags(EcalRecHitCollection &rhs)
std::string const & instance() const
Definition: InputTag.h:43
T get(const Candidate &c)
Definition: component.h:56
edm::InputTag eeUncalibRecHitCollection_