53 template <
typename TEle,
typename TCand>
62 if (iConfig.
existsAs<std::vector<edm::InputTag>>(
"electronTags")) {
66 <<
"[SelectedElectronFEDListProducer] empty electron collection is given --> at least one \n";
69 <<
"[SelectedElectronFEDListProducer] no electron collection are given --> need at least one \n";
72 LogDebug(
"SelectedElectronFEDListProducer") <<
" Electron Collections" << std::endl;
76 LogDebug(
"SelectedElectronFEDListProducer") <<
" Ele collection: " << *(itEleTag) << std::endl;
80 if (iConfig.
existsAs<std::vector<edm::InputTag>>(
"recoEcalCandidateTags")) {
83 throw cms::Exception(
"Configuration") <<
"[SelectedElectronFEDListProducer] empty ecal candidate collections " 84 "collection is given --> at least one \n";
86 throw cms::Exception(
"Configuration") <<
"[SelectedElectronFEDListProducer] no electron reco ecal candidate " 87 "collection are given --> need at least one \n";
94 LogDebug(
"SelectedElectronFEDListProducer") <<
" Reco ecal candidate collection: " << *(itEcalCandTag) << std::endl;
98 if (iConfig.
existsAs<std::vector<int>>(
"isGsfElectronCollection")) {
102 <<
"[SelectedElectronFEDListProducer] empty electron flag collection --> at least one \n";
105 <<
"[SelectedElectronFEDListProducer] no electron flag are given --> need at least one \n";
109 throw cms::Exception(
"Configuration") <<
"[SelectedElectronFEDListProducer] electron flag , electron collection " 110 "and reco ecal cand collection must have the same size ! \n";
141 LogDebug(
"SelectedElectronFEDListProducer") <<
" RawDataInput " <<
rawDataTag_ << std::endl;
144 if (iConfig.
existsAs<std::vector<int>>(
"addThisSelectedFEDs")) {
153 LogDebug(
"SelectedElectronFEDListProducer") <<
" Additional FED: " << *(AddFed) << std::endl;
170 if (iConfig.
existsAs<
double>(
"dRStripRegion"))
178 if (iConfig.
existsAs<
double>(
"dRHcalRegion"))
184 if (iConfig.
existsAs<
double>(
"dPhiPixelRegion"))
189 if (iConfig.
existsAs<
double>(
"dEtaPixelRegion"))
194 if (iConfig.
existsAs<
double>(
"maxZPixelRegion"))
199 LogDebug(
"SelectedElectronFEDListProducer")
204 if (iConfig.
existsAs<
bool>(
"dumpSelectedEcalFed"))
209 if (iConfig.
existsAs<
bool>(
"dumpSelectedSiStripFed"))
214 if (iConfig.
existsAs<
bool>(
"dumpSelectedSiPixelFed"))
219 if (iConfig.
existsAs<
bool>(
"dumpSelectedHCALFed"))
224 LogDebug(
"SelectedElectronFEDListProducer")
228 if (iConfig.
existsAs<
bool>(
"dumpAllEcalFed"))
233 if (iConfig.
existsAs<
bool>(
"dumpAllTrackerFed"))
238 if (iConfig.
existsAs<
bool>(
"dumpAllHCALFed"))
243 LogDebug(
"SelectedElectronFEDListProducer")
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++)
255 int nLines, iz, ip, ix, iy, fed, kchip, pace, bundle, fiber, optorx;
256 std::ifstream ES_file;
258 LogDebug(
"SelectedElectronFEDListProducer")
260 if (ES_file.is_open()) {
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;
267 LogDebug(
"SelectedElectronFEDListProducer")
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())
287 if (!pixelModuleVector_.empty())
288 pixelModuleVector_.clear();
291 template <
typename TEle,
typename TCand>
293 LogDebug(
"SelectedElectronFEDListProducer") <<
" Begin of the Job " << std::endl;
296 template <
typename TEle,
typename TCand>
299 const auto& pSetup = iSetup.
getData(hcalDbToken_);
300 HcalReadoutMap_ = pSetup.getHcalMapping();
303 EcalMapping_ = &iSetup.
getData(ecalMappingToken_);
306 const auto& caloGeometry = iSetup.
getData(caloGeometryToken_);
307 GeometryCalo_ = &caloGeometry;
314 PixelCabling_.reset();
315 PixelCabling_ = pixelCablingMap->cablingTree();
317 const auto& trackerGeometry = iSetup.
getData(trackerGeometryToken_);
319 if (pixelModuleVector_.empty()) {
321 std::vector<const GeomDet*>::const_iterator itTracker = trackerGeometry.dets().begin();
322 for (; itTracker != trackerGeometry.dets().end(); ++itTracker) {
323 int subdet = (*itTracker)->geographicalId().subdetId();
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;
336 pixelModuleVector_.push_back(
module);
338 std::sort(pixelModuleVector_.begin(), pixelModuleVector_.end());
341 StripRegionCabling_ = &iSetup.
getData(siStripRegionCablingToken_);
344 SiStripCabling = StripRegionCabling_->getRegionCabling();
345 regionDimension_ = StripRegionCabling_->regionDimensions();
351 iEvent.getByToken(rawDataToken_, rawdata);
358 beamSpotPosition_ =
beamSpot->position();
360 beamSpotPosition_.SetXYZ(0, 0, 0);
365 iEvent.getByToken(hbheRecHitToken_, hbheRecHitHandle);
368 hcalRecHitCollection = hbheRecHitHandle.
product();
370 double radTodeg = 180. /
Geom::pi();
372 if (dumpAllEcalFed_) {
374 fedList_.push_back(iEcalFed);
376 fedList_.push_back(iESFed);
379 if (dumpAllTrackerFed_) {
381 fedList_.push_back(iPixelFed);
383 fedList_.push_back(iStripFed);
386 if (dumpAllHCALFed_) {
388 fedList_.push_back(iHcalFed);
396 std::vector<edm::Ref<TCandColl>> recoEcalCandColl;
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();
405 if (!dumpAllTrackerFed_ || !dumpAllEcalFed_) {
407 for (; itRecoEcalCandColl != recoEcalCandidateToken_.end() and itElectronColl != electronToken_.end() and
408 itElectronCollFlag != isGsfElectronCollection_.end();
409 ++itElectronColl, ++itElectronCollFlag, ++itRecoEcalCandColl) {
411 iEvent.getByToken(*itRecoEcalCandColl, triggerRecoEcalCandidateCollection);
412 if (triggerRecoEcalCandidateCollection.
failedToGet())
421 if (recoEcalCandColl.empty())
423 if (recoEcalCandColl.empty())
426 typename std::vector<edm::Ref<TCandColl>>::const_iterator itRecoEcalCand =
427 recoEcalCandColl.begin();
430 for (; itRecoEcalCand != recoEcalCandColl.end(); ++itRecoEcalCand) {
431 recoEcalCand = (*itRecoEcalCand);
433 recoEcalCand->superCluster();
435 typename TEleColl::const_iterator itEle =
electrons->begin();
436 for (; itEle !=
electrons->end(); ++itEle) {
440 if (scRefRecoEcalCand != scRef)
443 const std::vector<std::pair<DetId, float>>&
hits = scRef->hitsAndFractions();
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) {
449 EBDetId idEBRaw((*itSChits).first);
452 EcalMapping_->GetFED(
double(
point.eta()),
double(
point.phi()) * radTodeg);
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;
460 if (dumpSelectedEcalFed_) {
461 if (!fedList_.empty()) {
462 if (
std::find(fedList_.begin(), fedList_.end(), hitFED) == fedList_.end())
463 fedList_.push_back(hitFED);
465 fedList_.push_back(hitFED);
467 }
else if ((*itSChits).first.subdetId() ==
EcalEndcap) {
468 EEDetId idEERaw((*itSChits).first);
471 EcalMapping_->GetFED(
double(
point.eta()),
double(
point.phi()) * radTodeg);
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);
483 fedList_.push_back(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;
498 if (!fedList_.empty()) {
499 if (
std::find(fedList_.begin(), fedList_.end(), hitFED) == fedList_.end())
500 fedList_.push_back(hitFED);
502 fedList_.push_back(hitFED);
508 ES_fedId_[(3 - stripY.
zside()) / 2 - 1][stripY.
plane() - 1][stripY.
six() - 1][stripY.
siy() - 1];
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;
516 if (!fedList_.empty()) {
517 if (
std::find(fedList_.begin(), fedList_.end(), hitFED) == fedList_.end())
518 fedList_.push_back(hitFED);
520 fedList_.push_back(hitFED);
526 if (dumpSelectedHCALFed_) {
528 for (; itHcalRecHit != hcalRecHitCollection->
end(); ++itHcalRecHit) {
531 static_cast<const HcalGeometry*
>(GeometryCalo_->getSubdetectorGeometry(recHitId));
534 cellGeometry->getPosition(recHitId).eta(),
535 cellGeometry->getPosition(recHitId).phi());
536 if (
dR <= dRHcalRegion_) {
539 LogDebug(
"SelectedElectronFEDListProducer")
540 <<
" matched hcal recHit : HcalDetId " << recHitId <<
" HcalElectronicsId " << electronicId
541 <<
" dcc id " << electronicId.
dccid() <<
" spigot " << electronicId.
spigot() <<
" fiber channel " 547 if (!fedList_.empty()) {
548 if (
std::find(fedList_.begin(), fedList_.end(), hitFED) == fedList_.end())
549 fedList_.push_back(hitFED);
551 fedList_.push_back(hitFED);
558 if (!dumpAllTrackerFed_) {
560 if (dumpSelectedSiStripFed_) {
563 if (*itElectronCollFlag) {
570 for (uint32_t iCabling = 0; iCabling < SiStripCabling.size(); iCabling++) {
572 double dphi = fabs(
pos.second -
phi);
574 dphi = 2 * acos(-1) - dphi;
576 if (
R -
sqrt(
pow(regionDimension_.first / 2, 2) +
pow(regionDimension_.second / 2, 2)) > dRStripRegion_)
587 regSubdetLayers[ilayer];
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();
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);
599 fedList_.push_back(hitFED);
606 if (dumpSelectedSiPixelFed_) {
608 if (*itElectronCollFlag)
609 momentum =
electron.gsfTrack()->momentum();
611 momentum =
electron.track()->momentum();
612 PixelRegion region(momentum, dPhiPixelRegion_, dEtaPixelRegion_, maxZPixelRegion_);
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);
622 if (lowerBound.Phi < -
M_PI)
623 lowerBound.Phi = lowerBound.Phi + 2 *
M_PI;
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);
629 if (upperBound.Phi < -
M_PI)
630 upperBound.Phi = upperBound.Phi - 2 *
M_PI;
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);
643 for (
unsigned int iFed = 0; iFed < addThisSelectedFEDs_.size(); iFed++) {
644 if (addThisSelectedFEDs_.at(iFed) == -1)
646 fedList_.push_back(addThisSelectedFEDs_.at(iFed));
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 <<
" ";
656 if (
data.size() > 0) {
657 FEDRawData& fedData = streamFEDRawProduct->FEDData(*itfedList);
665 if (!fedList_.empty())
669 template <
typename TEle,
typename TCand>
671 LogDebug(
"SelectedElectronFEDListProducer") <<
" End of the Job " << std::endl;
674 template <
typename TEle,
typename TCand>
676 std::vector<PixelModule>::const_iterator& itUp,
678 for (; itDn != itUp; ++itDn) {
679 float zmodule = itDn->z - ((itDn->x - beamSpotPosition_.x()) *
region.cosphi +
680 (itDn->y - beamSpotPosition_.y()) *
region.sinphi) *
684 int hitFED = itDn->Fed;
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);
693 fedList_.push_back(hitFED);
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")});
708 desc.add<vector<int>>(
"addThisSelectedFEDs", {812, 813});
709 desc.add<vector<int>>(
"isGsfElectronCollection", {
true});
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);
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
std::vector< edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > > recoEcalCandidateToken_
T getParameter(std::string const &) const
edm::InputTag beamSpotTag_
std::string fullPath() const
SelectedElectronFEDListProducer(const edm::ParameterSet &)
Producer constructor.
std::string outputLabelModule_
T const * product() const
std::vector< T >::const_iterator const_iterator
std::string defaultModuleLabel()
edm::FileInPath ESLookupTable_
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
std::vector< Element > ElementCabling
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
bool dumpSelectedSiStripFed_
edm::EDGetTokenT< HBHERecHitCollection > hbheRecHitToken_
edm::EDGetTokenT< FEDRawDataCollection > rawDataToken_
void resize(size_t newsize)
~SelectedElectronFEDListProducer() override
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...
edm::InputTag HBHERecHitTag_
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Abs< T >::type abs(const T &t)
edm::InputTag rawDataTag_
#define DEFINE_FWK_MODULE(type)
bool getData(T &iHolder) const
const_iterator begin() const
std::vector< RegionCabling > Cabling
std::vector< int > isGsfElectronCollection_
bool dumpSelectedHCALFed_
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const_iterator end() const
std::vector< edm::InputTag > recoEcalCandidateTags_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
constexpr uint32_t rawId() const
get the raw id
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)
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
bool dumpSelectedSiPixelFed_
char data[epos_bytes_allocation]
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
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
int ES_fedId_[2][2][40][40]
std::vector< ElementCabling > WedgeCabling
std::vector< int > addThisSelectedFEDs_
Readout chain identification for Hcal.
void pixelFedDump(std::vector< PixelModule >::const_iterator &itDn, std::vector< PixelModule >::const_iterator &itUp, const PixelRegion ®ion)
std::vector< edm::EDGetTokenT< TEleColl > > electronToken_
bool dumpSelectedEcalFed_
Power< A, B >::type pow(const A &a, const B &b)
*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
std::vector< edm::InputTag > electronTags_