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