CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SelectedElectronFEDListProducer.cc
Go to the documentation of this file.
5 
7 template< typename TEle, typename TCand>
9 
10  // input electron collection Tag
11  if(iConfig.existsAs<std::vector<edm::InputTag> >("electronTags")){
12  electronTags_ = iConfig.getParameter<std::vector<edm::InputTag>>("electronTags");
13  if(electronTags_.empty())
14  throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty electron collection is given --> at least one \n";
15  }
16  else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron collection are given --> need at least one \n";
17 
18  // Consumes for the electron collection
19  LogDebug("SelectedElectronFEDListProducer")<<" Electron Collections"<<std::endl;
20  for( std::vector<edm::InputTag>::const_iterator itEleTag = electronTags_.begin(); itEleTag != electronTags_.end(); ++itEleTag){
21  electronToken_.push_back(consumes<TEleColl>(*itEleTag));
22  LogDebug("SelectedElectronFEDListProducer")<<" Ele collection: "<<*(itEleTag)<<std::endl;
23  }
24 
25  // input RecoEcalCandidate collection Tag
26  if(iConfig.existsAs<std::vector<edm::InputTag> >("recoEcalCandidateTags")){
27  recoEcalCandidateTags_ = iConfig.getParameter<std::vector<edm::InputTag>>("recoEcalCandidateTags");
28  if(recoEcalCandidateTags_.empty())
29  throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty ecal candidate collections collection is given --> at least one \n";
30  }
31  else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron reco ecal candidate collection are given --> need at least one \n";
32 
33  // Consumes for the recoEcal candidate collection
34  for( std::vector<edm::InputTag>::const_iterator itEcalCandTag = recoEcalCandidateTags_.begin(); itEcalCandTag != recoEcalCandidateTags_.end(); ++itEcalCandTag){
35  recoEcalCandidateToken_.push_back(consumes<trigger::TriggerFilterObjectWithRefs>(*itEcalCandTag));
36  LogDebug("SelectedElectronFEDListProducer")<<" Reco ecal candidate collection: "<<*(itEcalCandTag)<<std::endl;
37  }
38 
39  // list of gsf collections
40  if(iConfig.existsAs<std::vector<int>>("isGsfElectronCollection")){
41  isGsfElectronCollection_ = iConfig.getParameter<std::vector<int>>("isGsfElectronCollection");
42  if(isGsfElectronCollection_.empty())
43  throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] empty electron flag collection --> at least one \n";
44  }
45  else throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] no electron flag are given --> need at least one \n";
46 
47  if(isGsfElectronCollection_.size() < electronTags_.size())
48  throw cms::Exception("Configuration")<<"[SelectedElectronFEDListProducer] electron flag < electron collection --> need at equal number to understand which are Gsf and which not \n";
49 
50  // take the beam spot Tag
51  if(iConfig.existsAs<edm::InputTag>("beamSpot"))
52  beamSpotTag_ = iConfig.getParameter<edm::InputTag>("beamSpot");
53  else beamSpotTag_ = edm::InputTag("hltOnlineBeamSpot");
54 
55  if(!(beamSpotTag_ == edm::InputTag(""))) beamSpotToken_ = consumes<reco::BeamSpot>(beamSpotTag_);
56 
57  LogDebug("SelectedElectronFEDListProducer")<<" Beam Spot Tag "<<beamSpotTag_<<std::endl;
58 
59  // take the HBHE recHit Tag
60  if(iConfig.existsAs<edm::InputTag>("HBHERecHitTag"))
61  HBHERecHitTag_ = iConfig.getParameter<edm::InputTag>("HBHERecHitTag");
62  else HBHERecHitTag_ = edm::InputTag("hltHbhereco");
63 
64  if(!(HBHERecHitTag_ == edm::InputTag(""))) hbheRecHitToken_ = consumes<HBHERecHitCollection>(HBHERecHitTag_);
65 
66  // raw data collector label
67  if(iConfig.existsAs<edm::InputTag>("rawDataTag"))
68  rawDataTag_ = iConfig.getParameter<edm::InputTag>("rawDataTag");
69  else rawDataTag_ = edm::InputTag("rawDataCollector") ;
70 
71  if(!(rawDataTag_ == edm::InputTag(""))) rawDataToken_ = consumes<FEDRawDataCollection>(rawDataTag_);
72 
73  LogDebug("SelectedElectronFEDListProducer")<<" RawDataInput "<<rawDataTag_<<std::endl;
74 
75 
76  // add a set of selected feds
77  if(iConfig.existsAs<std::vector<int>>("addThisSelectedFEDs")){
78  addThisSelectedFEDs_ = iConfig.getParameter<std::vector<int>>("addThisSelectedFEDs");
79  if(addThisSelectedFEDs_.empty())
80  addThisSelectedFEDs_.push_back(-1);
81  }
82  else addThisSelectedFEDs_.push_back(-1);
83 
84  std::vector<int>::const_iterator AddFed = addThisSelectedFEDs_.begin();
85  for( ; AddFed !=addThisSelectedFEDs_.end() ; ++AddFed)
86  LogDebug("SelectedElectronFEDListProducer")<<" Additional FED: "<<*(AddFed)<<std::endl;
87 
88 
89  // ES look up table path
90  if(iConfig.existsAs<std::string>("ESLookupTable"))
91  ESLookupTable_ = iConfig.getParameter<edm::FileInPath>("ESLookupTable");
92  else ESLookupTable_ = edm::FileInPath("EventFilter/ESDigiToRaw/data/ES_lookup_table.dat");
93 
94  // output model label
95  if(iConfig.existsAs<std::string>("outputLabelModule"))
96  outputLabelModule_ = iConfig.getParameter<std::string>("outputLabelModule");
97  else outputLabelModule_ = "streamElectronRawData" ;
98 
99  LogDebug("SelectedElectronFEDListProducer")<<" Output Label "<<outputLabelModule_<<std::endl;
100 
101  // dR for the strip region
102  if(iConfig.existsAs<double>("dRStripRegion"))
103  dRStripRegion_ = iConfig.getParameter<double>("dRStripRegion");
104  else dRStripRegion_ = 0.5 ;
105 
106  LogDebug("SelectedElectronFEDListProducer")<<" dRStripRegion "<<dRStripRegion_<<std::endl;
107 
108  // dR for the hcal region
109  if(iConfig.existsAs<double>("dRHcalRegion"))
110  dRHcalRegion_ = iConfig.getParameter<double>("dRHcalRegion");
111  else dRHcalRegion_ = 0.5 ;
112 
113  // dPhi, dEta and maxZ for pixel dump
114  if(iConfig.existsAs<double>("dPhiPixelRegion"))
115  dPhiPixelRegion_ = iConfig.getParameter<double>("dPhiPixelRegion");
116  else dPhiPixelRegion_ = 0.5 ;
117 
118  if(iConfig.existsAs<double>("dEtaPixelRegion"))
119  dEtaPixelRegion_ = iConfig.getParameter<double>("dEtaPixelRegion");
120  else dEtaPixelRegion_ = 0.5 ;
121 
122  if(iConfig.existsAs<double>("maxZPixelRegion"))
123  maxZPixelRegion_ = iConfig.getParameter<double>("maxZPixelRegion");
124  else maxZPixelRegion_ = 24. ;
125 
126  LogDebug("SelectedElectronFEDListProducer")<<" dPhiPixelRegion "<<dPhiPixelRegion_<<" dEtaPixelRegion "<<dEtaPixelRegion_<<" MaxZPixelRegion "<<maxZPixelRegion_<<std::endl;
127 
128  // bool
129  if( iConfig.existsAs<bool>("dumpSelectedEcalFed"))
130  dumpSelectedEcalFed_ = iConfig.getParameter< bool >("dumpSelectedEcalFed");
131  else dumpSelectedEcalFed_ = true ;
132 
133  if(iConfig.existsAs<bool>("dumpSelectedSiStripFed"))
134  dumpSelectedSiStripFed_ = iConfig.getParameter<bool>("dumpSelectedSiStripFed");
135  else dumpSelectedSiStripFed_ = true ;
136 
137  if(iConfig.existsAs<bool>("dumpSelectedSiPixelFed"))
138  dumpSelectedSiPixelFed_ = iConfig.getParameter<bool>("dumpSelectedSiPixelFed");
139  else dumpSelectedSiPixelFed_ = true ;
140 
141  if(iConfig.existsAs<bool>("dumpSelectedHCALFed"))
142  dumpSelectedHCALFed_ = iConfig.getParameter<bool>("dumpSelectedHCALFed");
143  else dumpSelectedHCALFed_ = true ;
144 
145  LogDebug("SelectedElectronFEDListProducer")<<" DumpEcalFedList set to "<<dumpSelectedEcalFed_<<" DumpSelectedSiStripFed "<<dumpSelectedSiStripFed_<<" DumpSelectedSiPixelFed "<<dumpSelectedSiPixelFed_<<std::endl;
146 
147  if(iConfig.existsAs<bool>("dumpAllEcalFed"))
148  dumpAllEcalFed_ = iConfig.getParameter<bool>("dumpAllEcalFed");
149  else dumpAllEcalFed_ = false ;
150 
151  if(iConfig.existsAs<bool>("dumpAllTrackerFed"))
152  dumpAllTrackerFed_ = iConfig.getParameter<bool>("dumpAllTrackerFed");
153  else dumpAllTrackerFed_ = false ;
154 
155  if(iConfig.existsAs<bool>("dumpAllHCALFed"))
156  dumpAllHCALFed_ = iConfig.getParameter<bool>("dumpAllHCALFed");
157  else dumpAllHCALFed_ = false ;
158 
159  LogDebug("SelectedElectronFEDListProducer")<<" DumpAllEcalFed "<<dumpAllEcalFed_<<" DumpAllTrackerFed "<<dumpAllTrackerFed_<<" Dump all HCAL fed "<<dumpAllHCALFed_<<std::endl;
160 
161 
162  // initialize pre-shower fed id --> look up table
163  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;
164 
165  // read in look-up table
166  int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
167  std::ifstream ES_file;
168  ES_file.open(ESLookupTable_.fullPath().c_str());
169  LogDebug("SelectedElectronFEDListProducer")<<" Look Up table for ES "<<ESLookupTable_.fullPath().c_str()<<std::endl;
170  if( ES_file.is_open() ) {
171  ES_file >> nLines;
172  for (int i=0; i<nLines; ++i) {
173  ES_file >> iz >> ip >> ix >> iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx ;
174  ES_fedId_[(3-iz)/2-1][ip-1][ix-1][iy-1] = fed;
175  }
176  }
177  else LogDebug("SelectedElectronFEDListProducer")<<" Look up table file can not be found in "<<ESLookupTable_.fullPath().c_str() <<std::endl;
178  ES_file.close();
179 
180  // produce the final collection
181  produces<FEDRawDataCollection>(outputLabelModule_); // produce exit collection
182 
183 }
184 
185 template< typename TEle, typename TCand>
187 
188  if(!electronTags_.empty()) electronTags_.clear() ;
189  if(!recoEcalCandidateTags_.empty()) recoEcalCandidateTags_.clear() ;
190  if(!recoEcalCandidateToken_.empty()) recoEcalCandidateToken_.clear();
191  if(!electronToken_.empty()) electronToken_.clear();
192  if(!fedList_.empty()) fedList_.clear() ;
193  if(!RawDataCollection_) delete RawDataCollection_ ;
194 }
195 
196 template< typename TEle, typename TCand>
198  eventCounter_ = 0 ;
199  LogDebug("SelectedElectronFEDListProducer")<<" Begin of the Job : event counter set to"<<eventCounter_<<std::endl;
200 }
201 
202 template< typename TEle, typename TCand>
204 
205  if(!fedList_.empty()) fedList_.clear();
206  if(!RawDataCollection_) delete RawDataCollection_ ;
207 
208  // Build FED strip map --> just one time
209  // Retrieve FED ids from cabling map and iterate through
210 
211  if(eventCounter_ ==0 ){
212 
213  // get the hcal electronics map
215  iSetup.get<HcalDbRecord>().get(pSetup);
216  hcalReadoutMap_ = pSetup->getHcalMapping();
217 
218 
219  // get the ecal electronics map
221  iSetup.get<EcalMappingRcd >().get(ecalmapping);
222  TheMapping_ = ecalmapping.product();
223 
224  // get the calo geometry
225  edm::ESHandle<CaloGeometry> caloGeometry;
226  iSetup.get<CaloGeometryRecord>().get(caloGeometry);
227  geometry_ = caloGeometry.product();
228 
229  //ES geometry
230  geometryES_ = caloGeometry->getSubdetectorGeometry(DetId::Ecal,EcalPreshower);
231 
232  // pixel tracker cabling map
234  iSetup.get<SiPixelFedCablingMapRcd>().get(pixelCablingMap);
235 
236  PixelCabling_.reset();
237  PixelCabling_ = pixelCablingMap->cablingTree();
238 
239  edm::ESHandle<TrackerGeometry> trackerGeometry;
240  iSetup.get<TrackerDigiGeometryRecord>().get( trackerGeometry );
241 
242  if(!pixelModuleVector_.empty()) pixelModuleVector_.clear();
243 
244  // build the tracker pixel module map
245  std::vector<const GeomDet*>::const_iterator itTracker = trackerGeometry->dets().begin();
246  for( ; itTracker !=trackerGeometry->dets().end() ; ++itTracker){
247  int subdet = (*itTracker)->geographicalId().subdetId();
248  if(! (subdet == PixelSubdetector::PixelBarrel || subdet == PixelSubdetector::PixelEndcap) ) continue;
250  module.x = (*itTracker)->position().x();
251  module.y = (*itTracker)->position().y();
252  module.z = (*itTracker)->position().z();
253  module.Phi = normalizedPhi((*itTracker)->position().phi()) ;
254  module.Eta = (*itTracker)->position().eta() ;
255  module.DetId = (*itTracker)->geographicalId().rawId();
256  const std::vector<sipixelobjects::CablingPathToDetUnit> path2det = PixelCabling_->pathToDetUnit(module.DetId);
257  module.Fed = path2det[0].fed;
258  assert(module.Fed<40);
259  pixelModuleVector_.push_back(module);
260  }
261  std::sort(pixelModuleVector_.begin(),pixelModuleVector_.end());
262 
263  edm::ESHandle<SiStripRegionCabling> SiStripCabling ;
264  iSetup.get<SiStripRegionCablingRcd>().get(SiStripCabling);
265  StripRegionCabling_ = SiStripCabling.product();
266 
267  cabling_ = StripRegionCabling_->getRegionCabling();
268  regionDimension_ = StripRegionCabling_->regionDimensions();
269  }
270 
271  // event by event analysis
272 
273  // Get event raw data
275  if(!(rawDataTag_ == edm::InputTag(""))) iEvent.getByToken(rawDataToken_,rawdata);
276 
277  // take the beam spot position
279  if(!(beamSpotTag_ == edm::InputTag(""))) iEvent.getByToken(beamSpotToken_, beamSpot);
280  if(!beamSpot.failedToGet()) beamSpotPosition_ = beamSpot->position();
281  else beamSpotPosition_.SetXYZ(0,0,0);
282 
283  // take the calo tower collection
284  edm::Handle<HBHERecHitCollection> hbheRecHitHandle;
285  if(!(HBHERecHitTag_ == edm::InputTag(""))) iEvent.getByToken(hbheRecHitToken_,hbheRecHitHandle);
286  const HBHERecHitCollection* hcalRecHitCollection = NULL;
287  if(!hbheRecHitHandle.failedToGet()) hcalRecHitCollection = hbheRecHitHandle.product();
288 
289  double radTodeg = 180. / Geom::pi();
290 
291  if(dumpAllEcalFed_){
292  for(uint32_t iEcalFed = FEDNumbering::MINECALFEDID ; iEcalFed <= FEDNumbering::MAXECALFEDID ; iEcalFed++)
293  fedList_.push_back(iEcalFed);
294  for(uint32_t iESFed = FEDNumbering::MINPreShowerFEDID ; iESFed <= FEDNumbering::MAXPreShowerFEDID ; iESFed++)
295  fedList_.push_back(iESFed);
296  }
297 
298  if(dumpAllTrackerFed_){
299  for(uint32_t iPixelFed = FEDNumbering::MINSiPixelFEDID; iPixelFed <= FEDNumbering::MAXSiPixelFEDID ; iPixelFed++)
300  fedList_.push_back(iPixelFed);
301  for(uint32_t iStripFed = FEDNumbering::MINSiStripFEDID; iStripFed <= FEDNumbering::MAXSiStripFEDID ; iStripFed++)
302  fedList_.push_back(iStripFed);
303  }
304 
305  if(dumpAllHCALFed_){
306  for(uint32_t iHcalFed = FEDNumbering::MINHCALFEDID ; iHcalFed <= FEDNumbering::MAXHCALFEDID; iHcalFed++)
307  fedList_.push_back(iHcalFed);
308  }
309 
310 
311  // loop on the input electron collection vector
312  TEle electron ;
313  edm::Ref<TCandColl> recoEcalCand ;
315  edm::Handle<trigger::TriggerFilterObjectWithRefs> triggerRecoEcalCandidateCollection;
316  std::vector<edm::Ref<TCandColl>> recoEcalCandColl;
317 
318  // iterator to electron and ecal candidate collections
319  typename std::vector<edm::EDGetTokenT<TEleColl> >::const_iterator itElectronColl = electronToken_.begin();
320  std::vector<int>::const_iterator itElectronCollFlag = isGsfElectronCollection_.begin();
321  std::vector<edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> >::const_iterator itRecoEcalCandColl = recoEcalCandidateToken_.begin();
322 
323  // if you want to dump just FED related to the triggering electron/s
324  if( !dumpAllTrackerFed_ || !dumpAllEcalFed_ ){
325  for( ; itRecoEcalCandColl != recoEcalCandidateToken_.end(); ++itRecoEcalCandColl){
326 
327  try { iEvent.getByToken(*itRecoEcalCandColl,triggerRecoEcalCandidateCollection);
328  if(triggerRecoEcalCandidateCollection.failedToGet()) continue ;
329  }
330  catch (cms::Exception &exception){ continue; }
331 
332  triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerCluster, recoEcalCandColl);
333  if(recoEcalCandColl.empty()) triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerPhoton, recoEcalCandColl);
334  if(recoEcalCandColl.empty()) triggerRecoEcalCandidateCollection->getObjects(trigger::TriggerElectron, recoEcalCandColl);
335 
336  typename std::vector<edm::Ref<TCandColl>>::const_iterator itRecoEcalCand = recoEcalCandColl.begin(); // loop on recoEcalCandidate objects
337 
338  for( ; itRecoEcalCand != recoEcalCandColl.end() ; ++itRecoEcalCand){
339  recoEcalCand = (*itRecoEcalCand);
340  reco::SuperClusterRef scRefRecoEcalCand = recoEcalCand->superCluster(); // take the supercluster in order to match with electron objects
341 
342  for( ; itElectronColl != electronToken_.end() && itElectronCollFlag != isGsfElectronCollection_.end(); ++itElectronColl , ++itElectronCollFlag){ // loop on electron collections
343  try { iEvent.getByToken(*itElectronColl,electrons);
344  if(electrons.failedToGet()) continue ;
345  }
346  catch (cms::Exception &exception){ continue; }
347 
348  typename TEleColl::const_iterator itEle = electrons->begin();
349  for( ; itEle!=electrons->end() ; ++itEle){ // loop on all the electrons inside a collection
350  // get electron supercluster and the associated hit -> detID
351  electron = (*itEle);
352  reco::SuperClusterRef scRef = electron.superCluster();
353  if ( scRefRecoEcalCand != scRef ) continue ; // mathching
354 
355  const std::vector<std::pair<DetId,float> >& hits = scRef->hitsAndFractions();
356  // start in dump the ecal FED associated to the electron
357  std::vector<std::pair<DetId,float> >::const_iterator itSChits = hits.begin();
358  if(!dumpAllEcalFed_){
359  for( ; itSChits!=hits.end() ; ++itSChits){
360  if((*itSChits).first.subdetId()== EcalBarrel){ // barrel part
361  EBDetId idEBRaw ((*itSChits).first);
362  GlobalPoint point = geometry_->getPosition(idEBRaw);
363  int hitFED = FEDNumbering::MINECALFEDID + TheMapping_->GetFED(double(point.eta()),double(point.phi())*radTodeg);
364  if( hitFED < FEDNumbering::MINECALFEDID || hitFED > FEDNumbering::MAXECALFEDID ) continue;
365 
366  LogDebug("SelectedElectronFEDListProducer")<<" electron hit detID Barrel "<<(*itSChits).first.rawId()<<" eta "<<double(point.eta())<<" phi "<< double(point.phi())*radTodeg <<" FED "<<hitFED<<std::endl;
367 
368  if(dumpSelectedEcalFed_){
369  if(!fedList_.empty()){
370  if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED); // in order not to duplicate info
371  }
372  else fedList_.push_back(hitFED);
373  }
374  }
375  else if((*itSChits).first.subdetId()== EcalEndcap){ // endcap one
376  EEDetId idEERaw ((*itSChits).first);
377  GlobalPoint point = geometry_->getPosition(idEERaw);
378  int hitFED = FEDNumbering::MINECALFEDID + TheMapping_->GetFED(double(point.eta()),double(point.phi())*radTodeg);
379  if( hitFED < FEDNumbering::MINECALFEDID || hitFED > FEDNumbering::MAXECALFEDID ) continue;
380 
381  LogDebug("SelectedElectronFEDListProducer")<<" electron hit detID Endcap "<<(*itSChits).first.rawId()<<" eta "<<double(point.eta())<<" phi "<<double(point.phi())*radTodeg <<" FED "<<hitFED<<std::endl;
382  if(dumpSelectedEcalFed_){
383  if(!fedList_.empty()){
384  if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED);
385  }
386  else fedList_.push_back(hitFED);
387 
388  // preshower hit for each ecal endcap hit
389  DetId tmpX = (dynamic_cast<const EcalPreshowerGeometry*>(geometryES_))->getClosestCellInPlane(point,1);
390  ESDetId stripX = (tmpX == DetId(0)) ? ESDetId(0) : ESDetId(tmpX);
391  int hitFED = ES_fedId_[(3-stripX.zside())/2-1][stripX.plane()-1][stripX.six()-1][stripX.siy()-1];
392  LogDebug("SelectedElectronFEDListProducer")<<" ES hit plane X (deiID) "<<stripX.rawId()<<" six "<<stripX.six()<<" siy "<<stripX.siy()<<" plane "<<stripX.plane()<<" FED ID "<<hitFED<<std::endl;
393  if(hitFED < FEDNumbering::MINPreShowerFEDID || hitFED > FEDNumbering::MAXPreShowerFEDID) continue;
394  if(hitFED < 0) continue;
395  if(!fedList_.empty()){
396  if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED);
397  }
398  else fedList_.push_back(hitFED);
399 
400  DetId tmpY = (dynamic_cast<const EcalPreshowerGeometry*>(geometryES_))->getClosestCellInPlane(point,2);
401  ESDetId stripY = (tmpY == DetId(0)) ? ESDetId(0) : ESDetId(tmpY);
402  hitFED = ES_fedId_[(3-stripY.zside())/2-1][stripY.plane()-1][stripY.six()-1][stripY.siy()-1];
403  if(hitFED < FEDNumbering::MINPreShowerFEDID || hitFED > FEDNumbering::MAXPreShowerFEDID) continue;
404  LogDebug("SelectedElectronFEDListProducer")<<" ES hit plane Y (deiID) "<<stripY.rawId()<<" six "<<stripY.six()<<" siy "<<stripY.siy()<<" plane "<<stripY.plane()<<" FED ID "<<hitFED<<std::endl;
405  if(hitFED < 0) continue;
406  if(!fedList_.empty()){
407  if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED);
408  }
409  else fedList_.push_back(hitFED);
410  }
411  } // end endcap
412  } // end loop on SC hit
413 
414  // check HCAL behind each hit
415  if(dumpSelectedHCALFed_) {
416  HBHERecHitCollection::const_iterator itHcalRecHit = hcalRecHitCollection->begin();
417  for( ; itHcalRecHit != hcalRecHitCollection->end() ; ++itHcalRecHit) {
418  HcalDetId recHitId(itHcalRecHit->id());
419  const CaloCellGeometry* cellGeometry = geometry_->getSubdetectorGeometry(recHitId)->getGeometry(recHitId);
420  float dR = reco::deltaR(scRef->eta(),scRef->phi(),cellGeometry->getPosition().eta(),cellGeometry->getPosition().phi());
421  if(dR <= dRHcalRegion_) {
422  const HcalElectronicsId electronicId = hcalReadoutMap_->lookup(recHitId);
423  int hitFED = electronicId.dccid() + FEDNumbering::MINHCALFEDID;
424  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;
425  if(hitFED < FEDNumbering::MINHCALFEDID || hitFED > FEDNumbering::MAXHCALFEDID)
426  continue; //first eighteen feds are for HBHE
427  if(hitFED < 0)
428  continue;
429  if(!fedList_.empty()) {
430  if(std::find(fedList_.begin(), fedList_.end(), hitFED) == fedList_.end())
431  fedList_.push_back(hitFED);
432  }
433  else
434  fedList_.push_back(hitFED);
435  }
436  }
437  } // End Hcal
438  }// End Ecal
439 
440  // get the electron track
441  if( !dumpAllTrackerFed_ ){
442  //loop on the region
443  if(dumpSelectedSiStripFed_){
444  double eta ;
445  double phi ;
446  if(*itElectronCollFlag){
447  eta = electron.gsfTrack()->eta();
448  phi = electron.gsfTrack()->phi();
449  }
450  else{
451  eta = electron.track()->eta();
452  phi = electron.track()->phi();
453  }
454  for(uint32_t iCabling = 0; iCabling < cabling_.size(); iCabling++){
455  SiStripRegionCabling::Position pos = StripRegionCabling_->position(iCabling);
456  double dphi=fabs(pos.second-phi);
457  if (dphi>acos(-1)) dphi=2*acos(-1)-dphi;
458  double R = sqrt(pow(pos.first-eta,2)+dphi*dphi);
459  if (R-sqrt(pow(regionDimension_.first/2,2)+pow(regionDimension_.second/2,2))>dRStripRegion_) continue;
460  //get vector of subdets within region
461  const SiStripRegionCabling::RegionCabling regSubdets = cabling_[iCabling];
462  //cycle on subdets
463  for (uint32_t idet=0; idet<SiStripRegionCabling::ALLSUBDETS; idet++){ //cicle between 1 and 4
464  //get vector of layers whin subdet of region
465  const SiStripRegionCabling::WedgeCabling regSubdetLayers = regSubdets[idet]; // at most 10 layers
466  for (uint32_t ilayer=0; ilayer<SiStripRegionCabling::ALLLAYERS; ilayer++){
467  //get map of vectors of feds withing the layer of subdet of region
468  const SiStripRegionCabling::ElementCabling fedVectorMap = regSubdetLayers[ilayer]; // vector of the fed
469  SiStripRegionCabling::ElementCabling::const_iterator itFedMap = fedVectorMap.begin();
470  for( ; itFedMap!=fedVectorMap.end(); itFedMap++){
471  for (uint32_t op=0; op<(itFedMap->second).size(); op++){
472  int hitFED = (itFedMap->second)[op].fedId();
473  if(hitFED < FEDNumbering::MINSiStripFEDID || hitFED > FEDNumbering::MAXSiStripFEDID) continue;
474  LogDebug("SelectedElectronFEDListProducer")<<" SiStrip (FedID) "<<hitFED<<std::endl;
475  if(!fedList_.empty()){
476  if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED);
477  }
478  else fedList_.push_back(hitFED);
479  }
480  }
481  }
482  }
483  }
484  } // end si strip
485 
486  if(dumpSelectedSiPixelFed_){
487  math::XYZVector momentum;
488  if(*itElectronCollFlag) momentum = electron.gsfTrack()->momentum();
489  else momentum = electron.track()->momentum();
490  PixelRegion region (momentum,dPhiPixelRegion_,dEtaPixelRegion_,maxZPixelRegion_);
491 
492  PixelModule lowerBound (normalizedPhi(region.vector.phi())-region.dPhi, region.vector.eta()-region.dEta);
493  PixelModule upperBound (normalizedPhi(region.vector.phi())+region.dPhi, region.vector.eta()+region.dEta);
494 
495  std::vector<PixelModule>::const_iterator itUp, itDn ;
496  if(lowerBound.Phi >= -M_PI && upperBound.Phi <= M_PI ){
497  itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),lowerBound);
498  itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),upperBound);
499  pixelFedDump(itDn,itUp,region);
500  }
501  else{
502  if(lowerBound.Phi < -M_PI) lowerBound.Phi = lowerBound.Phi+2*M_PI;
503  PixelModule phi_p(M_PI,region.vector.eta()-region.dEta);
504  itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),lowerBound);
505  itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),phi_p);
506  pixelFedDump(itDn,itUp,region);
507 
508  if(upperBound.Phi < -M_PI) upperBound.Phi = upperBound.Phi-2*M_PI;
509  PixelModule phi_m(-M_PI,region.vector.eta()-region.dEta);
510  itDn = std::lower_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),phi_m);
511  itUp = std::upper_bound(pixelModuleVector_.begin(),pixelModuleVector_.end(),upperBound);
512  pixelFedDump(itDn,itUp,region);
513  }
514  }
515  }// end tracker analysis
516  }// end loop on the electron candidate
517  } // end loop on the electron collection collection
518  } // end loop on the recoEcal candidate
519  } // end loop on the recoEcal candidate collection
520  }
521  // add a set of chosen FED
522  for( unsigned int iFed = 0 ; iFed < addThisSelectedFEDs_.size() ; iFed++){
523  if(addThisSelectedFEDs_.at(iFed) == -1 ) continue ;
524  fedList_.push_back(addThisSelectedFEDs_.at(iFed));
525  }
526 
527  // make the final raw data collection
528  RawDataCollection_ = new FEDRawDataCollection();
529  std::sort(fedList_.begin(),fedList_.end());
530  std::vector<uint32_t>::const_iterator itfedList = fedList_.begin();
531  for( ; itfedList!=fedList_.end() ; ++itfedList){
532  LogDebug("SelectedElectronFEDListProducer")<<" fed point "<<*itfedList<<" ";
533  const FEDRawData& data = rawdata->FEDData(*itfedList);
534  if(data.size()>0){
535  FEDRawData& fedData = RawDataCollection_->FEDData(*itfedList);
536  fedData.resize(data.size());
537  memcpy(fedData.data(),data.data(),data.size());
538  }
539  }
540 
541  std::auto_ptr<FEDRawDataCollection> streamFEDRawProduct(RawDataCollection_);
542  iEvent.put(streamFEDRawProduct,outputLabelModule_);
543  eventCounter_ ++ ;
544 }
545 
546 
547 template< typename TEle, typename TCand>
549  LogDebug("SelectedElectronFEDListProducer")<<" End of the Job : Counted Events "<<eventCounter_<<std::endl;
550 }
551 
552 template< typename TEle, typename TCand>
553 void SelectedElectronFEDListProducer<TEle,TCand>::pixelFedDump( std::vector<PixelModule>::const_iterator & itDn,
554  std::vector<PixelModule>::const_iterator & itUp,
555  const PixelRegion & region){
556 
557  for( ; itDn != itUp ; ++itDn){
558  float zmodule = itDn->z-((itDn->x-beamSpotPosition_.x())*region.cosphi+(itDn->y-beamSpotPosition_.y())*region.sinphi)*region.atantheta;
559  if ( std::abs(zmodule) > region.maxZ ) continue;
560  int hitFED = itDn->Fed;
561  if(hitFED < FEDNumbering::MINSiPixelFEDID || hitFED > FEDNumbering::MAXSiPixelFEDID) continue;
562  LogDebug("SelectedElectronFEDListProducer")<<" electron pixel hit "<<itDn->DetId<<" hitFED "<<hitFED<<std::endl;
563  if(!fedList_.empty()){
564  if(std::find(fedList_.begin(),fedList_.end(),hitFED)==fedList_.end()) fedList_.push_back(hitFED);
565  }
566  else fedList_.push_back(hitFED);
567  }
568 
569  return ;
570 }
571 
572 template< typename TEle, typename TCand>
575  desc.add<vector<edm::InputTag>>("electronTags",{edm::InputTag("hltEgammaGsfElectrons")});
576  desc.add<vector<edm::InputTag>>("recoEcalCandidateTags",{edm::InputTag("hltL1EG25Ele27WP85GsfTrackIsoFilter")});
577  desc.add<edm::FileInPath>("ESLookupTable",edm::FileInPath("EventFilter/ESDigiToRaw/data/ES_lookup_table.dat"));
578  desc.add<edm::InputTag>("HBHERecHitTag",edm::InputTag("hltHbhereco"));
579  desc.add<edm::InputTag>("beamSpotTag",edm::InputTag("hltOnlineBeamSpot"));
580  desc.add<edm::InputTag>("rawDataTag",edm::InputTag("rawDataCollector"));
581  desc.add<vector<int>>("addThisSelectedFEDs",{812,813});
582  desc.add<vector<int>>("isGsfElectronCollection",{true});
583  desc.add<std::string>("outputLabelModule","StreamElectronRawFed");
584  desc.add<bool>("dumpSelectedSiPixelFed",true);
585  desc.add<bool>("dumpSelectedSiStripFed",true);
586  desc.add<bool>("dumpSelectedEcalFed",true);
587  desc.add<bool>("dumpSelectedHCALFed",true);
588  desc.add<double>("dPhiPixelRegion",0.3);
589  desc.add<double>("dEtaPixelRegion",0.3);
590  desc.add<double>("dRStripRegion",0.3);
591  desc.add<double>("dRHcalRegion",0.3);
592  desc.add<double>("maxZPixelRegion",24);
593  desc.add<bool>("dumpAllTrackerFed",false);
594  desc.add<bool>("dumpAllEcalFed",false);
595  desc.add<bool>("dumpAllHcalFed",false);
596 
598 }
599 
600 
605 
#define LogDebug(id)
T getParameter(std::string const &) const
std::string defaultModuleLabel()
int i
Definition: DBlmapReader.cc:9
int fiberIndex() const
get the fiber index. For VME 1-8 (which of eight fibers carried by a spigot), for uTCA fibers are zer...
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:185
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
SelectedElectronFEDListProducer(const edm::ParameterSet &)
Producer constructor.
assert(m_qm.get())
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:48
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
T eta() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
return((rh^lh)&mask)
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:50
void resize(size_t newsize)
Definition: FEDRawData.cc:32
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
std::vector< ElementCabling > WedgeCabling
T sqrt(T t)
Definition: SSEVec.h:48
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
int j
Definition: DBlmapReader.cc:9
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:44
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define M_PI
int spigot() const
get the spigot (input number on DCC, AMC card number for uTCA)
const_iterator end() const
bool failedToGet() const
Definition: HandleBase.h:79
Definition: DetId.h:18
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
T const * product() const
Definition: ESHandle.h:86
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T eta() const
Definition: PV3DBase.h:76
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
double pi()
Definition: Pi.h:31
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:46
dictionary rawdata
Definition: lumiPlot.py:393
volatile std::atomic< bool > shutdown_flag false
double normalizedPhi(double phi)
Definition: normalizedPhi.cc:5
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)
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
*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
Definition: DDAxes.h:10