CMS 3D CMS Logo

SelectedElectronFEDListProducer.cc
Go to the documentation of this file.
2 
3 #include <fstream>
5 
7 
8 //#include "DataFormats/Common/interface/Handle.h"
9 
12 // raw data
14 //#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
15 
16 // Geometry
19 // strip geometry
22 
23 // egamma objects
30 
31 // Hcal objects
33 
34 // Strip and pixel
37 
38 // detector id
41 // Hcal rec hit
44 // Geometry
51 // strip geometry
54 // Message logger
56 // Strip and pixel
60 
61 // Hcal objects
64 
65 
66 using namespace std;
67 
69 template< typename TEle, typename TCand>
71 
72  // input electron collection Tag
73  if(iConfig.existsAs<std::vector<edm::InputTag> >("electronTags")){
74  electronTags_ = iConfig.getParameter<std::vector<edm::InputTag>>("electronTags");
75  if(electronTags_.empty())
76  throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty electron collection is given --> at least one \n";
77  }
78  else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron collection are given --> need at least one \n";
79 
80  // Consumes for the electron collection
81  LogDebug("SelectedElectronFEDListProducer")<<" Electron Collections"<<std::endl;
82  for( std::vector<edm::InputTag>::const_iterator itEleTag = electronTags_.begin(); itEleTag != electronTags_.end(); ++itEleTag){
83  electronToken_.push_back(consumes<TEleColl>(*itEleTag));
84  LogDebug("SelectedElectronFEDListProducer")<<" Ele collection: "<<*(itEleTag)<<std::endl;
85  }
86 
87  // input RecoEcalCandidate collection Tag
88  if(iConfig.existsAs<std::vector<edm::InputTag> >("recoEcalCandidateTags")){
89  recoEcalCandidateTags_ = iConfig.getParameter<std::vector<edm::InputTag>>("recoEcalCandidateTags");
90  if(recoEcalCandidateTags_.empty())
91  throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty ecal candidate collections collection is given --> at least one \n";
92  }
93  else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron reco ecal candidate collection are given --> need at least one \n";
94 
95  // Consumes for the recoEcal candidate collection
96  for( std::vector<edm::InputTag>::const_iterator itEcalCandTag = recoEcalCandidateTags_.begin(); itEcalCandTag != recoEcalCandidateTags_.end(); ++itEcalCandTag){
97  recoEcalCandidateToken_.push_back(consumes<trigger::TriggerFilterObjectWithRefs>(*itEcalCandTag));
98  LogDebug("SelectedElectronFEDListProducer")<<" Reco ecal candidate collection: "<<*(itEcalCandTag)<<std::endl;
99  }
100 
101  // list of gsf collections
102  if(iConfig.existsAs<std::vector<int>>("isGsfElectronCollection")){
103  isGsfElectronCollection_ = iConfig.getParameter<std::vector<int>>("isGsfElectronCollection");
104  if(isGsfElectronCollection_.empty())
105  throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty electron flag collection --> at least one \n";
106  }
107  else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron flag are given --> need at least one \n";
108 
109  if(isGsfElectronCollection_.size() != electronTags_.size() or isGsfElectronCollection_.size() != recoEcalCandidateTags_.size())
110  throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] electron flag , electron collection and reco ecal cand collection must have the same size ! \n";
111 
112  // take the beam spot Tag
113  if(iConfig.existsAs<edm::InputTag>("beamSpot"))
114  beamSpotTag_ = iConfig.getParameter<edm::InputTag>("beamSpot");
115  else beamSpotTag_ = edm::InputTag("hltOnlineBeamSpot");
116 
117  if(!(beamSpotTag_ == edm::InputTag(""))) beamSpotToken_ = consumes<reco::BeamSpot>(beamSpotTag_);
118 
119  LogDebug("SelectedElectronFEDListProducer")<<" Beam Spot Tag "<<beamSpotTag_<<std::endl;
120 
121  // take the HBHE recHit Tag
122  if(iConfig.existsAs<edm::InputTag>("HBHERecHitTag"))
123  HBHERecHitTag_ = iConfig.getParameter<edm::InputTag>("HBHERecHitTag");
124  else HBHERecHitTag_ = edm::InputTag("hltHbhereco");
125 
126  if(!(HBHERecHitTag_ == edm::InputTag(""))) hbheRecHitToken_ = consumes<HBHERecHitCollection>(HBHERecHitTag_);
127 
128  // raw data collector label
129  if(iConfig.existsAs<edm::InputTag>("rawDataTag"))
130  rawDataTag_ = iConfig.getParameter<edm::InputTag>("rawDataTag");
131  else rawDataTag_ = edm::InputTag("rawDataCollector") ;
132 
133  if(!(rawDataTag_ == edm::InputTag(""))) rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_);
134 
135  LogDebug("SelectedElectronFEDListProducer")<<" RawDataInput "<<rawDataTag_<<std::endl;
136 
137 
138  // add a set of selected feds
139  if(iConfig.existsAs<std::vector<int>>("addThisSelectedFEDs")){
140  addThisSelectedFEDs_ = iConfig.getParameter<std::vector<int>>("addThisSelectedFEDs");
141  if(addThisSelectedFEDs_.empty())
142  addThisSelectedFEDs_.push_back(-1);
143  }
144  else addThisSelectedFEDs_.push_back(-1);
145 
146  std::vector<int>::const_iterator AddFed = addThisSelectedFEDs_.begin();
147  for( ; AddFed !=addThisSelectedFEDs_.end() ; ++AddFed)
148  LogDebug("SelectedElectronFEDListProducer")<<" Additional FED: "<<*(AddFed)<<std::endl;
149 
150 
151  // ES look up table path
152  if(iConfig.existsAs<std::string>("ESLookupTable"))
153  ESLookupTable_ = iConfig.getParameter<edm::FileInPath>("ESLookupTable");
154  else ESLookupTable_ = edm::FileInPath("EventFilter/ESDigiToRaw/data/ES_lookup_table.dat");
155 
156  // output model label
157  if(iConfig.existsAs<std::string>("outputLabelModule"))
158  outputLabelModule_ = iConfig.getParameter<std::string>("outputLabelModule");
159  else outputLabelModule_ = "streamElectronRawData" ;
160 
161  LogDebug("SelectedElectronFEDListProducer")<<" Output Label "<<outputLabelModule_<<std::endl;
162 
163  // dR for the strip region
164  if(iConfig.existsAs<double>("dRStripRegion"))
165  dRStripRegion_ = iConfig.getParameter<double>("dRStripRegion");
166  else dRStripRegion_ = 0.5 ;
167 
168  LogDebug("SelectedElectronFEDListProducer")<<" dRStripRegion "<<dRStripRegion_<<std::endl;
169 
170  // dR for the hcal region
171  if(iConfig.existsAs<double>("dRHcalRegion"))
172  dRHcalRegion_ = iConfig.getParameter<double>("dRHcalRegion");
173  else dRHcalRegion_ = 0.5 ;
174 
175  // dPhi, dEta and maxZ for pixel dump
176  if(iConfig.existsAs<double>("dPhiPixelRegion"))
177  dPhiPixelRegion_ = iConfig.getParameter<double>("dPhiPixelRegion");
178  else dPhiPixelRegion_ = 0.5 ;
179 
180  if(iConfig.existsAs<double>("dEtaPixelRegion"))
181  dEtaPixelRegion_ = iConfig.getParameter<double>("dEtaPixelRegion");
182  else dEtaPixelRegion_ = 0.5 ;
183 
184  if(iConfig.existsAs<double>("maxZPixelRegion"))
185  maxZPixelRegion_ = iConfig.getParameter<double>("maxZPixelRegion");
186  else maxZPixelRegion_ = 24. ;
187 
188  LogDebug("SelectedElectronFEDListProducer")<<" dPhiPixelRegion "<<dPhiPixelRegion_<<" dEtaPixelRegion "<<dEtaPixelRegion_<<" MaxZPixelRegion "<<maxZPixelRegion_<<std::endl;
189 
190  // bool
191  if( iConfig.existsAs<bool>("dumpSelectedEcalFed"))
192  dumpSelectedEcalFed_ = iConfig.getParameter< bool >("dumpSelectedEcalFed");
193  else dumpSelectedEcalFed_ = true ;
194 
195  if(iConfig.existsAs<bool>("dumpSelectedSiStripFed"))
196  dumpSelectedSiStripFed_ = iConfig.getParameter<bool>("dumpSelectedSiStripFed");
197  else dumpSelectedSiStripFed_ = true ;
198 
199  if(iConfig.existsAs<bool>("dumpSelectedSiPixelFed"))
200  dumpSelectedSiPixelFed_ = iConfig.getParameter<bool>("dumpSelectedSiPixelFed");
201  else dumpSelectedSiPixelFed_ = true ;
202 
203  if(iConfig.existsAs<bool>("dumpSelectedHCALFed"))
204  dumpSelectedHCALFed_ = iConfig.getParameter<bool>("dumpSelectedHCALFed");
205  else dumpSelectedHCALFed_ = true ;
206 
207  LogDebug("SelectedElectronFEDListProducer")<<" DumpEcalFedList set to "<<dumpSelectedEcalFed_<<" DumpSelectedSiStripFed "<<dumpSelectedSiStripFed_<<" DumpSelectedSiPixelFed "<<dumpSelectedSiPixelFed_<<std::endl;
208 
209  if(iConfig.existsAs<bool>("dumpAllEcalFed"))
210  dumpAllEcalFed_ = iConfig.getParameter<bool>("dumpAllEcalFed");
211  else dumpAllEcalFed_ = false ;
212 
213  if(iConfig.existsAs<bool>("dumpAllTrackerFed"))
214  dumpAllTrackerFed_ = iConfig.getParameter<bool>("dumpAllTrackerFed");
215  else dumpAllTrackerFed_ = false ;
216 
217  if(iConfig.existsAs<bool>("dumpAllHCALFed"))
218  dumpAllHCALFed_ = iConfig.getParameter<bool>("dumpAllHCALFed");
219  else dumpAllHCALFed_ = false ;
220 
221  LogDebug("SelectedElectronFEDListProducer")<<" DumpAllEcalFed "<<dumpAllEcalFed_<<" DumpAllTrackerFed "<<dumpAllTrackerFed_<<" Dump all HCAL fed "<<dumpAllHCALFed_<<std::endl;
222 
223  // initialize pre-shower fed id --> look up table
224  for (int i=0; i<2; ++i) for (int j=0; j<2; ++j) for (int k=0 ;k<40; ++k) for (int m=0; m<40; m++) ES_fedId_[i][j][k][m] = -1;
225 
226  // read in look-up table
227  int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
228  std::ifstream ES_file;
229  ES_file.open(ESLookupTable_.fullPath().c_str());
230  LogDebug("SelectedElectronFEDListProducer")<<" Look Up table for ES "<<ESLookupTable_.fullPath().c_str()<<std::endl;
231  if( ES_file.is_open() ) {
232  ES_file >> nLines;
233  for (int i=0; i<nLines; ++i) {
234  ES_file >> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx ;
235  ES_fedId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fed;
236  }
237  }
238  else LogDebug("SelectedElectronFEDListProducer")<<" Look up table file can not be found in "<<ESLookupTable_.fullPath().c_str() <<std::endl;
239  ES_file.close();
240 
241  // produce the final collection
242  produces<FEDRawDataCollection>(outputLabelModule_); // produce exit collection
243 
244 }
245 
246 template< typename TEle, typename TCand>
248 
249  if(!electronTags_.empty()) electronTags_.clear() ;
250  if(!recoEcalCandidateTags_.empty()) recoEcalCandidateTags_.clear() ;
251  if(!recoEcalCandidateToken_.empty()) recoEcalCandidateToken_.clear();
252  if(!electronToken_.empty()) electronToken_.clear();
253  if(!fedList_.empty()) fedList_.clear() ;
254  if(!pixelModuleVector_.empty()) pixelModuleVector_.clear();
255 }
256 
257 template< typename TEle, typename TCand>
259  LogDebug("SelectedElectronFEDListProducer")<<" Begin of the Job "<<std::endl;
260 
261 }
262 
263 template< typename TEle, typename TCand>
265 
266  // get the hcal electronics map
268  iSetup.get<HcalDbRecord>().get(pSetup);
269  HcalReadoutMap_ = pSetup->getHcalMapping();
270 
271  // get the ecal electronics map
273  iSetup.get<EcalMappingRcd >().get(ecalmapping);
274  EcalMapping_ = ecalmapping.product();
275 
276  // get the calo geometry
277  edm::ESHandle<CaloGeometry> caloGeometry;
278  iSetup.get<CaloGeometryRecord>().get(caloGeometry);
279  GeometryCalo_ = caloGeometry.product();
280 
281  //ES geometry
282  GeometryES_ = caloGeometry->getSubdetectorGeometry(DetId::Ecal,EcalPreshower);
283 
284  // pixel tracker cabling map
286  iSetup.get<SiPixelFedCablingMapRcd>().get(pixelCablingMap);
287  PixelCabling_.reset();
288  PixelCabling_ = pixelCablingMap->cablingTree();
289 
290  edm::ESHandle<TrackerGeometry> trackerGeometry;
291  iSetup.get<TrackerDigiGeometryRecord>().get( trackerGeometry );
292 
293  if(pixelModuleVector_.empty()){
294 
295  // build the tracker pixel module map
296  std::vector<const GeomDet*>::const_iterator itTracker = trackerGeometry->dets().begin();
297  for( ; itTracker !=trackerGeometry->dets().end() ; ++itTracker){
298  int subdet = (*itTracker)->geographicalId().subdetId();
299  if(! (subdet == PixelSubdetector::PixelBarrel || subdet == PixelSubdetector::PixelEndcap) ) continue;
301  module.x = (*itTracker)->position().x();
302  module.y = (*itTracker)->position().y();
303  module.z = (*itTracker)->position().z();
304  module.Phi = (*itTracker)->position().phi();
305  module.Eta = (*itTracker)->position().eta();
306  module.DetId = (*itTracker)->geographicalId().rawId();
307  const std::vector<sipixelobjects::CablingPathToDetUnit> path2det = PixelCabling_->pathToDetUnit(module.DetId);
308  module.Fed = path2det[0].fed;
309 
310  pixelModuleVector_.push_back(module);
311  }
312  std::sort(pixelModuleVector_.begin(),pixelModuleVector_.end());
313  }
314 
315  edm::ESHandle<SiStripRegionCabling> SiStripCablingHandle ;
316  iSetup.get<SiStripRegionCablingRcd>().get(SiStripCablingHandle);
317  StripRegionCabling_ = SiStripCablingHandle.product();
318 
319  SiStripRegionCabling::Cabling SiStripCabling;
320  SiStripCabling = StripRegionCabling_->getRegionCabling();
321  regionDimension_ = StripRegionCabling_->regionDimensions();
322 
323  // event by event analysis
324  // Get event raw data
326  if(!(rawDataTag_ == edm::InputTag(""))) iEvent.getByToken(rawDataToken_,rawdata);
327 
328  // take the beam spot position
330  if(!(beamSpotTag_ == edm::InputTag(""))) iEvent.getByToken(beamSpotToken_, beamSpot);
331  if(!beamSpot.failedToGet()) beamSpotPosition_ = beamSpot->position();
332  else beamSpotPosition_.SetXYZ(0,0,0);
333 
334  // take the calo tower collection
335  edm::Handle<HBHERecHitCollection> hbheRecHitHandle;
336  if(!(HBHERecHitTag_ == edm::InputTag(""))) iEvent.getByToken(hbheRecHitToken_,hbheRecHitHandle);
337  const HBHERecHitCollection* hcalRecHitCollection = NULL;
338  if(!hbheRecHitHandle.failedToGet()) hcalRecHitCollection = hbheRecHitHandle.product();
339 
340  double radTodeg = 180. / Geom::pi();
341 
342  if(dumpAllEcalFed_){
343  for(uint32_t iEcalFed = FEDNumbering::MINECALFEDID ; iEcalFed <= FEDNumbering::MAXECALFEDID ; iEcalFed++)
344  fedList_.push_back(iEcalFed);
345  for(uint32_t iESFed = FEDNumbering::MINPreShowerFEDID ; iESFed <= FEDNumbering::MAXPreShowerFEDID ; iESFed++)
346  fedList_.push_back(iESFed);
347  }
348 
349  if(dumpAllTrackerFed_){
350  for(uint32_t iPixelFed = FEDNumbering::MINSiPixelFEDID; iPixelFed <= FEDNumbering::MAXSiPixelFEDID ; iPixelFed++)
351  fedList_.push_back(iPixelFed);
352  for(uint32_t iStripFed = FEDNumbering::MINSiStripFEDID; iStripFed <= FEDNumbering::MAXSiStripFEDID ; iStripFed++)
353  fedList_.push_back(iStripFed);
354  }
355 
356  if(dumpAllHCALFed_){
357  for(uint32_t iHcalFed = FEDNumbering::MINHCALFEDID ; iHcalFed <= FEDNumbering::MAXHCALFEDID; iHcalFed++)
358  fedList_.push_back(iHcalFed);
359  }
360 
361  // loop on the input electron collection vector
362  TEle electron ;
363  edm::Ref<TCandColl> recoEcalCand ;
365  edm::Handle<trigger::TriggerFilterObjectWithRefs> triggerRecoEcalCandidateCollection;
366  std::vector<edm::Ref<TCandColl>> recoEcalCandColl;
367 
368  // iterator to electron and ecal candidate collections
369  typename std::vector<edm::EDGetTokenT<TEleColl> >::const_iterator itElectronColl = electronToken_.begin();
370  std::vector<int>::const_iterator itElectronCollFlag = isGsfElectronCollection_.begin();
371  std::vector<edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> >::const_iterator itRecoEcalCandColl = recoEcalCandidateToken_.begin();
372 
373  // if you want to dump just FED related to the triggering electron/s
374  if( !dumpAllTrackerFed_ || !dumpAllEcalFed_ ){
375 
376  // loop on the same time on ecal candidate and elctron collection and boolean for Gsf ones
377  for( ; itRecoEcalCandColl != recoEcalCandidateToken_.end() and itElectronColl != electronToken_.end() and itElectronCollFlag != isGsfElectronCollection_.end();
378  ++itElectronColl , ++itElectronCollFlag, ++itRecoEcalCandColl){
379 
380  // get ecal candidate collection
381  iEvent.getByToken(*itRecoEcalCandColl,triggerRecoEcalCandidateCollection);
382  if(triggerRecoEcalCandidateCollection.failedToGet()) continue ;
383 
384  // get gsf electron collection
385  iEvent.getByToken(*itElectronColl,electrons);
386  if(electrons.failedToGet()) continue ;
387 
388  triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerCluster, recoEcalCandColl);
389  if(recoEcalCandColl.empty()) triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerPhoton, recoEcalCandColl);
390  if(recoEcalCandColl.empty()) triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerElectron, recoEcalCandColl);
391 
392  typename std::vector<edm::Ref<TCandColl>>::const_iterator itRecoEcalCand = recoEcalCandColl.begin(); // loop on recoEcalCandidate objects
393 
394  // loop on the recoEcalCandidates
395  for( ; itRecoEcalCand != recoEcalCandColl.end() ; ++itRecoEcalCand){
396  recoEcalCand = (*itRecoEcalCand);
397  reco::SuperClusterRef scRefRecoEcalCand = recoEcalCand->superCluster(); // take the supercluster in order to match with electron objects
398 
399  typename TEleColl::const_iterator itEle = electrons->begin();
400  for( ; itEle!=electrons->end() ; ++itEle){ // loop on all the electrons inside a collection
401  // get electron supercluster and the associated hit -> detID
402  electron = (*itEle);
403  reco::SuperClusterRef scRef = electron.superCluster();
404  if ( scRefRecoEcalCand != scRef ) continue ; // mathching
405 
406  const std::vector<std::pair<DetId,float> >& hits = scRef->hitsAndFractions();
407  // start in dump the ecal FED associated to the electron
408  std::vector<std::pair<DetId,float> >::const_iterator itSChits = hits.begin();
409  if(!dumpAllEcalFed_){
410  for( ; itSChits!=hits.end() ; ++itSChits){
411  if((*itSChits).first.subdetId()== EcalBarrel){ // barrel part
412  EBDetId idEBRaw ((*itSChits).first);
413  GlobalPoint point = GeometryCalo_->getPosition(idEBRaw);
414  int hitFED = FEDNumbering::MINECALFEDID + EcalMapping_->GetFED(double(point.eta()),double(point.phi())*radTodeg);
415  if( hitFED < FEDNumbering::MINECALFEDID || hitFED > FEDNumbering::MAXECALFEDID ) continue;
416 
417  LogDebug("SelectedElectronFEDListProducer")<<" electron hit detID Barrel "<<(*itSChits).first.rawId()<<" eta "<<double(point.eta())<<" phi "<< double(point.phi())*radTodeg <<" FED "<<hitFED<<std::endl;
418 
419  if(dumpSelectedEcalFed_){
420  if(!fedList_.empty()){
421  if(std::find(fedList_.begin(),fedList_.end(),hitFED) == fedList_.end())
422  fedList_.push_back(hitFED); // in order not to duplicate info
423  }
424  else fedList_.push_back(hitFED);
425  }
426  }
427  else if((*itSChits).first.subdetId()== EcalEndcap){ // endcap one
428  EEDetId idEERaw ((*itSChits).first);
429  GlobalPoint point = GeometryCalo_->getPosition(idEERaw);
430  int hitFED = FEDNumbering::MINECALFEDID + EcalMapping_->GetFED(double(point.eta()),double(point.phi())*radTodeg);
431  if( hitFED < FEDNumbering::MINECALFEDID || hitFED > FEDNumbering::MAXECALFEDID ) continue;
432 
433  LogDebug("SelectedElectronFEDListProducer")<<" electron hit detID Endcap "<<(*itSChits).first.rawId()<<" eta "<<double(point.eta())<<" phi "<<double(point.phi())*radTodeg <<" FED "<<hitFED<<std::endl;
434  if(dumpSelectedEcalFed_){
435  if(!fedList_.empty()){
436  if(std::find(fedList_.begin(),fedList_.end(),hitFED) == fedList_.end())
437  fedList_.push_back(hitFED);
438  }
439  else fedList_.push_back(hitFED);
440 
441  // preshower hit for each ecal endcap hit
442  DetId tmpX = (dynamic_cast<const EcalPreshowerGeometry*>(GeometryES_))->getClosestCellInPlane(point,1);
443  ESDetId stripX = (tmpX == DetId(0)) ? ESDetId(0) : ESDetId(tmpX);
444  int hitFED = ES_fedId_[(3-stripX.zside())/2-1][stripX.plane()-1][stripX.six()-1][stripX.siy()-1];
445  LogDebug("SelectedElectronFEDListProducer")<<" ES hit plane X (deiID) "<<stripX.rawId()<<" six "<<stripX.six()<<" siy "<<stripX.siy()<<" plane "<<stripX.plane()<<" FED ID "<<hitFED<<std::endl;
446  if(hitFED < FEDNumbering::MINPreShowerFEDID || hitFED > FEDNumbering::MAXPreShowerFEDID) continue;
447  if(hitFED < 0) continue;
448  if(!fedList_.empty()){
449  if(std::find(fedList_.begin(),fedList_.end(),hitFED) == fedList_.end())
450  fedList_.push_back(hitFED);
451  }
452  else fedList_.push_back(hitFED);
453 
454  DetId tmpY = (dynamic_cast<const EcalPreshowerGeometry*>(GeometryES_))->getClosestCellInPlane(point,2);
455  ESDetId stripY = (tmpY == DetId(0)) ? ESDetId(0) : ESDetId(tmpY);
456  hitFED = ES_fedId_[(3-stripY.zside())/2-1][stripY.plane()-1][stripY.six()-1][stripY.siy()-1];
457  if(hitFED < FEDNumbering::MINPreShowerFEDID || hitFED > FEDNumbering::MAXPreShowerFEDID) continue;
458  LogDebug("SelectedElectronFEDListProducer")<<" ES hit plane Y (deiID) "<<stripY.rawId()<<" six "<<stripY.six()<<" siy "<<stripY.siy()<<" plane "<<stripY.plane()<<" FED ID "<<hitFED<<std::endl;
459  if(hitFED < 0) continue;
460  if(!fedList_.empty()){
461  if(std::find(fedList_.begin(),fedList_.end(),hitFED) == fedList_.end())
462  fedList_.push_back(hitFED);
463  }
464  else fedList_.push_back(hitFED);
465  }
466  } // end endcap
467  } // end loop on SC hit
468 
469  // check HCAL behind each hit
470  if(dumpSelectedHCALFed_) {
471  HBHERecHitCollection::const_iterator itHcalRecHit = hcalRecHitCollection->begin();
472  for( ; itHcalRecHit != hcalRecHitCollection->end() ; ++itHcalRecHit) {
473  HcalDetId recHitId(itHcalRecHit->id());
474  const CaloCellGeometry* cellGeometry = GeometryCalo_->getSubdetectorGeometry(recHitId)->getGeometry(recHitId);
475  float dR = reco::deltaR(scRef->eta(),scRef->phi(),cellGeometry->getPosition().eta(),cellGeometry->getPosition().phi());
476  if(dR <= dRHcalRegion_) {
477  const HcalElectronicsId electronicId = HcalReadoutMap_->lookup(recHitId);
478  int hitFED = electronicId.dccid() + FEDNumbering::MINHCALFEDID;
479  LogDebug("SelectedElectronFEDListProducer")<< " matched hcal recHit : HcalDetId "<<recHitId<<" HcalElectronicsId "<<electronicId<<" dcc id "<<electronicId.dccid()<<" spigot "<<electronicId.spigot()<<" fiber channel "<<electronicId.fiberChanId()<<" fiber index "<<electronicId.fiberIndex()<<std::endl;
480  if(hitFED < FEDNumbering::MINHCALFEDID || hitFED > FEDNumbering::MAXHCALFEDID)
481  continue; //first eighteen feds are for HBHE
482  if(hitFED < 0)
483  continue;
484  if(!fedList_.empty()) {
485  if(std::find(fedList_.begin(), fedList_.end(), hitFED) == fedList_.end())
486  fedList_.push_back(hitFED);
487  }
488  else
489  fedList_.push_back(hitFED);
490  }
491  }
492  } // End Hcal
493  }// End Ecal
494 
495  // get the electron track
496  if( !dumpAllTrackerFed_ ){
497  //loop on the region
498  if(dumpSelectedSiStripFed_){
499  double eta ;
500  double phi ;
501  if(*itElectronCollFlag){
502  eta = electron.gsfTrack()->eta();
503  phi = electron.gsfTrack()->phi();
504  }
505  else{
506  eta = electron.track()->eta();
507  phi = electron.track()->phi();
508  }
509  for(uint32_t iCabling = 0; iCabling < SiStripCabling.size(); iCabling++){
510  SiStripRegionCabling::Position pos = StripRegionCabling_->position(iCabling);
511  double dphi=fabs(pos.second-phi);
512  if (dphi>acos(-1)) dphi=2*acos(-1)-dphi;
513  double R = sqrt(pow(pos.first-eta,2)+dphi*dphi);
514  if (R-sqrt(pow(regionDimension_.first/2,2)+pow(regionDimension_.second/2,2))>dRStripRegion_) continue;
515  //get vector of subdets within region
516  const SiStripRegionCabling::RegionCabling regSubdets = SiStripCabling[iCabling];
517  //cycle on subdets
518  for (uint32_t idet=0; idet<SiStripRegionCabling::ALLSUBDETS; idet++){ //cicle between 1 and 4
519  //get vector of layers whin subdet of region
520  const SiStripRegionCabling::WedgeCabling regSubdetLayers = regSubdets[idet]; // at most 10 layers
521  for (uint32_t ilayer=0; ilayer<SiStripRegionCabling::ALLLAYERS; ilayer++){
522  //get map of vectors of feds withing the layer of subdet of region
523  const SiStripRegionCabling::ElementCabling fedVectorMap = regSubdetLayers[ilayer]; // vector of the fed
524  SiStripRegionCabling::ElementCabling::const_iterator itFedMap = fedVectorMap.begin();
525  for( ; itFedMap!=fedVectorMap.end(); itFedMap++){
526  for (uint32_t op=0; op<(itFedMap->second).size(); op++){
527  int hitFED = (itFedMap->second)[op].fedId();
528  if(hitFED < FEDNumbering::MINSiStripFEDID || hitFED > FEDNumbering::MAXSiStripFEDID) continue;
529  LogDebug("SelectedElectronFEDListProducer")<<" SiStrip (FedID) "<<hitFED<<std::endl;
530  if(!fedList_.empty()){
531  if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED);
532  }
533  else fedList_.push_back(hitFED);
534  }
535  }
536  }
537  }
538  }
539  } // end si strip
540  if(dumpSelectedSiPixelFed_){
541  math::XYZVector momentum;
542  if(*itElectronCollFlag) momentum = electron.gsfTrack()->momentum();
543  else momentum = electron.track()->momentum();
544  PixelRegion region (momentum,dPhiPixelRegion_,dEtaPixelRegion_,maxZPixelRegion_);
545  PixelModule lowerBound (region.vector.phi()-region.dPhi, region.vector.eta()-region.dEta);
546  PixelModule upperBound (region.vector.phi()+region.dPhi, region.vector.eta()+region.dEta);
547 
548  std::vector<PixelModule>::const_iterator itUp, itDn ;
549  if(lowerBound.Phi >= -M_PI && upperBound.Phi <= M_PI ){
550  itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),lowerBound);
551  itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),upperBound);
552  pixelFedDump(itDn,itUp,region);
553  }
554  else{
555  if(lowerBound.Phi < -M_PI) lowerBound.Phi = lowerBound.Phi+2*M_PI;
556  PixelModule phi_p(M_PI,region.vector.eta()-region.dEta);
557  itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),lowerBound);
558  itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),phi_p);
559  pixelFedDump(itDn,itUp,region);
560 
561  if(upperBound.Phi < -M_PI) upperBound.Phi = upperBound.Phi-2*M_PI;
562  PixelModule phi_m(-M_PI,region.vector.eta()-region.dEta);
563  itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),phi_m);
564  itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),upperBound);
565  pixelFedDump(itDn,itUp,region);
566  }
567  }
568  }// end tracker analysis
569  }// end loop on the electron candidate
570  } // end loop on the electron collection collection
571  } // end loop on the recoEcal candidate
572  } // end loop on the recoEcal candidate collection
573  // add a set of chosen FED
574  for( unsigned int iFed = 0 ; iFed < addThisSelectedFEDs_.size() ; iFed++){
575  if(addThisSelectedFEDs_.at(iFed) == -1 ) continue ;
576  fedList_.push_back(addThisSelectedFEDs_.at(iFed));
577  }
578 
579  // make the final raw data collection
580  auto streamFEDRawProduct = std::make_unique<FEDRawDataCollection>();
581  std::sort(fedList_.begin(),fedList_.end());
582  std::vector<uint32_t>::const_iterator itfedList = fedList_.begin();
583  for( ; itfedList!=fedList_.end() ; ++itfedList){
584  LogDebug("SelectedElectronFEDListProducer")<<" fed point "<<*itfedList<<" ";
585  const FEDRawData& data = rawdata->FEDData(*itfedList);
586  if(data.size()>0){
587  FEDRawData& fedData = streamFEDRawProduct->FEDData(*itfedList);
588  fedData.resize(data.size());
589  memcpy(fedData.data(),data.data(),data.size());
590  }
591  }
592 
593  iEvent.put(std::move(streamFEDRawProduct),outputLabelModule_);
594 
595  if(!fedList_.empty()) fedList_.clear();
596 
597 }
598 
599 
600 template< typename TEle, typename TCand>
602  LogDebug("SelectedElectronFEDListProducer")<<" End of the Job "<<std::endl;
603 }
604 
605 template< typename TEle, typename TCand>
606 void SelectedElectronFEDListProducer<TEle,TCand>::pixelFedDump( std::vector<PixelModule>::const_iterator & itDn,
607  std::vector<PixelModule>::const_iterator & itUp,
608  const PixelRegion & region){
609 
610  for( ; itDn != itUp ; ++itDn){
611  float zmodule = itDn->z-((itDn->x-beamSpotPosition_.x())*region.cosphi+(itDn->y-beamSpotPosition_.y())*region.sinphi)*region.atantheta;
612  if ( std::abs(zmodule) > region.maxZ ) continue;
613  int hitFED = itDn->Fed;
614  if(hitFED < FEDNumbering::MINSiPixelFEDID || hitFED > FEDNumbering::MAXSiPixelFEDID) continue;
615  LogDebug("SelectedElectronFEDListProducer")<<" electron pixel hit "<<itDn->DetId<<" hitFED "<<hitFED<<std::endl;
616  if(!fedList_.empty()){
617  if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED);
618  }
619  else fedList_.push_back(hitFED);
620  }
621 
622  return ;
623 }
624 
625 template< typename TEle, typename TCand>
628  desc.add<vector<edm::InputTag>>("electronTags",{edm::InputTag("hltEgammaGsfElectrons")});
629  desc.add<vector<edm::InputTag>>("recoEcalCandidateTags",{edm::InputTag("hltL1EG25Ele27WP85GsfTrackIsoFilter")});
630  desc.add<edm::FileInPath>("ESLookupTable",edm::FileInPath("EventFilter/ESDigiToRaw/data/ES_lookup_table.dat"));
631  desc.add<edm::InputTag>("HBHERecHitTag",edm::InputTag("hltHbhereco"));
632  desc.add<edm::InputTag>("beamSpotTag",edm::InputTag("hltOnlineBeamSpot"));
633  desc.add<edm::InputTag>("rawDataTag",edm::InputTag("rawDataCollector"));
634  desc.add<vector<int>>("addThisSelectedFEDs",{812,813});
635  desc.add<vector<int>>("isGsfElectronCollection",{true});
636  desc.add<std::string>("outputLabelModule","StreamElectronRawFed");
637  desc.add<bool>("dumpSelectedSiPixelFed",true);
638  desc.add<bool>("dumpSelectedSiStripFed",true);
639  desc.add<bool>("dumpSelectedEcalFed",true);
640  desc.add<bool>("dumpSelectedHCALFed",true);
641  desc.add<double>("dPhiPixelRegion",0.3);
642  desc.add<double>("dEtaPixelRegion",0.3);
643  desc.add<double>("dRStripRegion",0.3);
644  desc.add<double>("dRHcalRegion",0.3);
645  desc.add<double>("maxZPixelRegion",24);
646  desc.add<bool>("dumpAllTrackerFed",false);
647  desc.add<bool>("dumpAllEcalFed",false);
648  desc.add<bool>("dumpAllHcalFed",false);
649 
651 }
652 
653 
658 
#define LogDebug(id)
size
Write out results.
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:45
std::string defaultModuleLabel()
int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
const DetContainer & dets() const
Returm a vector of all GeomDet (including all GeomDetUnits)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
SelectedElectronFEDListProducer(const edm::ParameterSet &)
Producer constructor.
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< HBHERecHit >::const_iterator const_iterator
#define NULL
Definition: scimark2.h:8
std::vector< Element > ElementCabling
int six() const
Definition: ESDetId.h:49
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
virtual void produce(edm::Event &, const edm::EventSetup &)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int iEvent
Definition: GenABIO.cc:230
int siy() const
Definition: ESDetId.h:51
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void resize(size_t newsize)
Definition: FEDRawData.cc:32
std::vector< ElementCabling > WedgeCabling
T sqrt(T t)
Definition: SSEVec.h:18
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int dccid() const
get the (Hcal local) DCC id for VME, crate number for uTCA
std::pair< double, double > Position
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
SelectedElectronFEDListProducer< reco::Electron, reco::RecoEcalCandidate > SelectedElectronFEDListProducerGsf
int fiberChanId() const
get the fiber channel id (which of channels on a fiber)
int zside() const
Definition: ESDetId.h:45
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
#define M_PI
int k[5][pyjets_maxn]
const_iterator end() const
bool failedToGet() const
Definition: HandleBase.h:78
Definition: DetId.h:18
std::unique_ptr< SiPixelFedCablingTree > cablingTree() const
T const * product() const
Definition: Handle.h:81
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
const T & get() const
Definition: EventSetup.h:56
void add(std::string const &label, ParameterSetDescription const &psetDescription)
return(e1-e2)*(e1-e2)+dp *dp
T eta() const
Definition: PV3DBase.h:76
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
int plane() const
Definition: ESDetId.h:47
const HcalElectronicsMap * getHcalMapping() const
const Point & position() const
position
Definition: BeamSpot.h:62
constexpr double pi()
Definition: Pi.h:31
T const * product() const
Definition: ESHandle.h:86
std::vector< WedgeCabling > RegionCabling
Readout chain identification for Hcal.
void pixelFedDump(std::vector< PixelModule >::const_iterator &itDn, std::vector< PixelModule >::const_iterator &itUp, const PixelRegion &region)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
def move(src, dest)
Definition: eostools.py:510
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
const_iterator begin() const
std::vector< RegionCabling > Cabling