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 
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 
63 {
64  delete worker_;
65  delete workerRecover_;
66 }
67 
68 void
70 {
71  using namespace edm;
72 
75 
76  const EBUncalibratedRecHitCollection* ebUncalibRecHits = 0;
77  const EEUncalibratedRecHitCollection* eeUncalibRecHits = 0;
78 
79  // get the barrel uncalib rechit collection
81  evt.getByLabel( ebUncalibRecHitCollection_, pEBUncalibRecHits);
82  if ( pEBUncalibRecHits.isValid() ) {
83  ebUncalibRecHits = pEBUncalibRecHits.product();
84  LogDebug("EcalRecHitDebug") << "total # EB uncalibrated rechits: " << ebUncalibRecHits->size();
85  } else {
86  edm::LogError("EcalRecHitError") << "Error! can't get the product " << ebUncalibRecHitCollection_;
87  }
88  }
89 
91  evt.getByLabel( eeUncalibRecHitCollection_, pEEUncalibRecHits);
92  if ( pEEUncalibRecHits.isValid() ) {
93  eeUncalibRecHits = pEEUncalibRecHits.product(); // get a ptr to the product
94  LogDebug("EcalRecHitDebug") << "total # EE uncalibrated rechits: " << eeUncalibRecHits->size();
95  } else {
96  edm::LogError("EcalRecHitError") << "Error! can't get the product " << eeUncalibRecHitCollection_;
97  }
98  }
99 
100  // collection of rechits to put in the event
101  std::auto_ptr< EBRecHitCollection > ebRecHits( new EBRecHitCollection );
102  std::auto_ptr< EERecHitCollection > eeRecHits( new EERecHitCollection );
103 
104  worker_->set(es);
105 
109  || killDeadChannels_ ) {
110  workerRecover_->set(es);
111  }
112 
113  if (ebUncalibRecHits)
114  {
115  // loop over uncalibrated rechits to make calibrated ones
116  for(EBUncalibratedRecHitCollection::const_iterator it = ebUncalibRecHits->begin(); it != ebUncalibRecHits->end(); ++it) {
117  worker_->run(evt, *it, *ebRecHits);
118  }
119  }
120 
121  if (eeUncalibRecHits)
122  {
123  // loop over uncalibrated rechits to make calibrated ones
124  for(EEUncalibratedRecHitCollection::const_iterator it = eeUncalibRecHits->begin(); it != eeUncalibRecHits->end(); ++it) {
125  worker_->run(evt, *it, *eeRecHits);
126  }
127  }
128 
129  // sort collections before attempting recovery, to avoid insertion of double recHits
130  ebRecHits->sort();
131  eeRecHits->sort();
132 
134  {
136  const std::set<EBDetId> * detIds = 0;
137  if ( ebDetIdToBeRecovered_.label() != "" && ebDetIdToBeRecovered_.instance() != "" ) {
138  evt.getByLabel( ebDetIdToBeRecovered_, pEBDetId);
139  if ( pEBDetId.isValid() ) {
140  detIds = pEBDetId.product();
141  } else {
142  edm::LogError("EcalRecHitError") << "Error! can't get the product " << ebDetIdToBeRecovered_;
143  }
144  }
145  if ( detIds ) {
147  es.get<EcalChannelStatusRcd>().get(chStatus);
148  for( std::set<EBDetId>::const_iterator it = detIds->begin(); it != detIds->end(); ++it ) {
149  // get channel status map to treat dead VFE separately
150  EcalChannelStatusMap::const_iterator chit = chStatus->find( *it );
151  EcalChannelStatusCode chStatusCode = 1;
152  if ( chit != chStatus->end() ) {
153  chStatusCode = *chit;
154  } else {
155  edm::LogError("EcalRecHitProducerError") << "No channel status found for xtal "
156  << (*it).rawId()
157  << "! something wrong with EcalChannelStatus in your DB? ";
158  }
160  if ( (chStatusCode.getStatusCode() & 0x001F) == 12 ) { // dead VFE (from DB info)
161  // uses the EcalUncalibratedRecHit to pass the DetId info
163  if ( recoverEBVFE_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
164  } else {
165  // uses the EcalUncalibratedRecHit to pass the DetId info
167  if ( recoverEBIsolatedChannels_ || killDeadChannels_ ) workerRecover_->run( evt, urh, *ebRecHits );
168  }
169 
170  }
171  }
172  }
173 
175  {
177  const std::set<EEDetId> * detIds = 0;
178  if ( eeDetIdToBeRecovered_.label() != "" && eeDetIdToBeRecovered_.instance() != "" ) {
179  evt.getByLabel( eeDetIdToBeRecovered_, pEEDetId);
180  if ( pEEDetId.isValid() ) {
181  detIds = pEEDetId.product();
182  } else {
183  edm::LogError("EcalRecHitError") << "Error! can't get the product " << eeDetIdToBeRecovered_;
184  }
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 = 1;
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() & 0x001F) == 12 ) { // 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  if ( ebFEToBeRecovered_.label() != "" && ebFEToBeRecovered_.instance() != "" ) {
219  evt.getByLabel( ebFEToBeRecovered_, pEBFEId);
220  if ( pEBFEId.isValid() ) {
221  ttIds = pEBFEId.product();
222  } else {
223  edm::LogError("EcalRecHitError") << "Error! can't get the product " << ebFEToBeRecovered_;
224  }
225  }
226  if ( ttIds ) {
227  for( std::set<EcalTrigTowerDetId>::const_iterator it = ttIds->begin(); it != ttIds->end(); ++it ) {
228  // uses the EcalUncalibratedRecHit to pass the DetId info
229  int ieta = (((*it).ietaAbs()-1)*5+1)*(*it).zside(); // from EcalTrigTowerConstituentsMap
230  int iphi = ((*it).iphi()-1)*5+11; // from EcalTrigTowerConstituentsMap
231  if( iphi <= 0 ) iphi += 360; // from EcalTrigTowerConstituentsMap
233  workerRecover_->run( evt, urh, *ebRecHits );
234  }
235  }
236  }
237 
239  {
241  const std::set<EcalScDetId> * scIds = 0;
242  if ( eeFEToBeRecovered_.label() != "" && eeFEToBeRecovered_.instance() != "" ) {
243  evt.getByLabel( eeFEToBeRecovered_, pEEFEId);
244  if ( pEEFEId.isValid() ) {
245  scIds = pEEFEId.product();
246  } else {
247  edm::LogError("EcalRecHitError") << "Error! can't get the product " << eeFEToBeRecovered_;
248  }
249  }
250  if ( scIds ) {
251  for( std::set<EcalScDetId>::const_iterator it = scIds->begin(); it != scIds->end(); ++it ) {
252  // uses the EcalUncalibratedRecHit to pass the DetId info
253  if (EEDetId::validDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() )) {
254  EcalUncalibratedRecHit urh( EEDetId( ((*it).ix()-1)*5+1, ((*it).iy()-1)*5+1, (*it).zside() ), 0, 0, 0, 0, EcalRecHitWorkerBaseClass::EE_FE );
255  workerRecover_->run( evt, urh, *eeRecHits );
256  }
257  }
258  }
259  }
260 
261  // put the collection of recunstructed hits in the event
262  LogInfo("EcalRecHitInfo") << "total # EB calibrated rechits: " << ebRecHits->size();
263  LogInfo("EcalRecHitInfo") << "total # EE calibrated rechits: " << eeRecHits->size();
264 
265  evt.put( ebRecHits, ebRechitCollection_ );
266  evt.put( eeRecHits, eeRechitCollection_ );
267 }
268 
#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_
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.cc:562
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:84
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
static const int ETAPHIMODE
Definition: EBDetId.h:145
EcalRecHitWorkerBaseClass * workerRecover_
virtual bool run(const edm::Event &evt, const EcalUncalibratedRecHit &uncalibRH, EcalRecHitCollection &result)=0
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:25
virtual void set(const edm::EventSetup &es)=0
std::string const & instance() const
Definition: InputTag.h:26
T get(const Candidate &c)
Definition: component.h:56
edm::InputTag eeUncalibRecHitCollection_