CMS 3D CMS Logo

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