80 #include "TLorentzVector.h" 113 void endJob()
override;
189 float ecalEta(
float EtaParticle,
float Zvertex,
float RhoVertex) {
190 if (EtaParticle != 0.) {
192 float ZEcal = (
R_ECAL - RhoVertex) * sinh(EtaParticle) + Zvertex;
195 Theta = atan(
R_ECAL / ZEcal);
197 Theta = Theta +
M_PI;
203 if (EtaParticle < 0.0)
205 float Zlen = Zend - Zvertex;
206 float RR = Zlen / sinh(EtaParticle);
207 Theta = atan((RR + RhoVertex) / Zend);
209 Theta = Theta +
M_PI;
214 edm::LogWarning(
"") <<
"[EcalPositionFromTrack::etaTransformation] Warning: Eta equals to zero, not correcting";
229 theBarrelSupClusCollectionToken_(
232 edm::
InputTag(
"multi5x5SuperClusters",
"multi5x5EndcapSuperClusters"))),
236 theGsfElectronCoreCollectionToken_(
238 theTrigger_(iConfig.getParameter<
std::
string>(
"triggerPath")),
239 theFilter_(iConfig.getParameter<
std::
string>(
"hltFilter")),
240 debugTriggerSelection_(iConfig.getParameter<
bool>(
"debugTriggerSelection")) {
257 HcalVSEcal =
fs_->
make<TH2D>(
"HcalVSEcal",
"HcalVSEcal", 100, 0, 160, 100, 0, 10);
282 h_distToClosestSC->SetXTitle(
"distance from track to closest SuperCluster in eta-phi plan (weighted matching)");
285 h_distToClosestSCgsf->SetXTitle(
"distance from track to closest SuperCluster in eta-phi plan (gsfElectronCore)");
291 HcalEnergy->SetXTitle(
"Hcal energy deposit (GeV)");
294 h_Momentum->SetXTitle(
"Momentum magnitude (GeV)");
315 Double_t EnergyHcalIn01;
316 Double_t EnergyHcalIn02;
317 Double_t EnergyHcalIn03;
318 Double_t EnergyHcalIn04;
319 Double_t EnergyHcalIn05;
333 Bool_t NoTrackIn0015;
336 Bool_t NoTrackIn0020;
339 Bool_t NoTrackIn0025;
342 Bool_t NoTrackIn0030;
345 Bool_t NoTrackIn0035;
346 Bool_t NoTrackIn0040;
348 Double_t dRSC_second;
354 Bool_t isTrackerDriven;
371 edm::LogError(
"EopElecTreeWriter") <<
"Error: no primary vertex found!";
380 if (subGeo ==
nullptr)
381 edm::LogError(
"EopElecTreeWriter") <<
"ERROR: unable to find SubDetector geometry!!!";
389 edm::LogError(
"EopElecTreeWriter") <<
"ERROR: unable to find the EcalRecHit collection !!!";
406 std::map<std::string, EopTriggerType> HLTpaths;
413 for (
unsigned int ps = 0; ps < prescaleSize; ps++) {
415 if (prescaleValue != 1) {
421 if (myTrigger.
index == -1)
430 for (
const auto&
it : HLTpaths) {
431 if (
it.second.fired) {
433 firstFiredPath =
it.first;
447 for (
unsigned int i = 0;
i <
filters.size();
i++) {
462 std::vector<const trigger::TriggerObject*> HLTelectrons;
463 for (
unsigned int i = 0;
i != KEYS_el.size(); ++
i) {
465 HLTelectrons.push_back(triggerObject_el);
470 if (HLTelectrons.empty())
475 unsigned int HighPtIndex = 0;
476 double maxPtHLT = -5.;
477 for (
unsigned int j = 0;
j < HLTelectrons.size();
j++) {
478 if (HLTelectrons[
j]->
pt() > maxPtHLT) {
479 maxPtHLT = HLTelectrons[
j]->pt();
492 std::vector<const reco::GsfTrack*> filterTracks;
496 reco::deltaR(
track.eta(),
track.phi(), HLTelectrons[HighPtIndex]->eta(), HLTelectrons[HighPtIndex]->phi());
506 filterTracks.push_back(&
track);
517 if (filterTracks.empty())
526 if ((elec.gsfTrack())->
pt() < 10.)
530 DELTAR =
reco::deltaR((elec.superCluster())->
eta(), (elec.superCluster())->
phi(), etaGSF, (elec.gsfTrack())->
phi());
539 for (
const auto&
track : filterTracks) {
542 isTrackerDriven =
false;
565 if (
track->pt() < 10.)
583 etaOut = outMom.
eta();
584 phiOut = outMom.
phi();
585 fbrem = (pin - pout) / pin;
597 for (
const auto&
hcal : *HcalHits) {
599 double phihit = posH.
phi();
600 double etahit = posH.
eta();
605 EnergyHcalIn01 +=
hcal.energy();
607 EnergyHcalIn02 +=
hcal.energy();
609 EnergyHcalIn03 +=
hcal.energy();
611 EnergyHcalIn04 +=
hcal.energy();
613 EnergyHcalIn05 +=
hcal.energy();
621 NoTrackIn0015 =
true;
624 NoTrackIn0020 =
true;
627 NoTrackIn0025 =
true;
630 NoTrackIn0030 =
true;
633 NoTrackIn0035 =
true;
634 NoTrackIn0040 =
true;
636 for (
const auto& track1 : filterTracks) {
647 etaIn1 = inMom1.
eta();
648 phiIn1 = inMom1.
phi();
651 if (etaIn1 == 0 && phiIn1 == 0)
658 NoTrackIn0015 =
false;
660 NoTrackIn0020 =
false;
662 NoTrackIn0025 =
false;
664 NoTrackIn0030 =
false;
666 NoTrackIn0035 =
false;
668 NoTrackIn0040 =
false;
672 SumPtIn01 += track1->pt();
673 if (track1->pt() > MaxPtIn01) {
674 MaxPtIn01 = track1->pt();
679 SumPtIn02 += track1->pt();
680 if (track1->pt() > MaxPtIn02) {
681 MaxPtIn02 = track1->pt();
685 SumPtIn03 += track1->pt();
686 if (track1->pt() > MaxPtIn03) {
687 MaxPtIn03 = track1->pt();
691 SumPtIn04 += track1->pt();
692 if (track1->pt() > MaxPtIn04) {
693 MaxPtIn04 = track1->pt();
697 SumPtIn05 += track1->pt();
698 if (track1->pt() > MaxPtIn05) {
699 MaxPtIn05 = track1->pt();
707 double etaAtEcal = 0;
712 for (
const auto& SC : *BarrelSupClusCollection) {
713 dRSC =
reco::deltaR(SC.eta(), SC.phi(), etaAtEcal, phiIn);
715 if (dRSC < dRSC_first) {
718 else if (dRSC < dRSC_second) {
731 algo_ID = SC.algoID();
732 EnergyEcal = SC.energy();
733 nBasicClus = SC.clustersSize();
742 for (
const auto& SC : *EndcapSupClusCollection) {
743 dRSC =
reco::deltaR(SC.eta(), SC.phi(), etaAtEcal, phiIn);
745 if (dRSC < dRSC_first) {
748 else if (dRSC < dRSC_second) {
761 algo_ID = SC.algoID();
762 EnergyEcal = SC.energy();
763 nBasicClus = SC.clustersSize();
770 if (dRSC_first < 0.1)
777 if (nbSC > 1 || nbSC == 0)
782 edm::LogError(
"EopElecTreeWriter") <<
"Error: Super Cluster double matching!";
790 if (
track->charge() < 0)
792 if (
track->charge() > 0)
798 edm::LogError(
"GsfElectronCore") <<
"The GsfTrack has no seed ?!";
802 edm::LogError(
"GsfElectronCore") <<
"The GsfTrack seed is not an ElectronSeed ?!";
805 isTrackerDriven = elseed->isTrackerDriven();
896 edm::LogInfo(
"EopElecTreeWriter") <<
"HLTpath: " << (
i++) <<
" = " <<
it;
906 desc.setComment(
"Generate tree for Tracker Alignment E/p validation");
909 desc.add<
std::string>(
"hltFilter",
"hltDiEle27L1DoubleEGWPTightHcalIsoFilter");
910 desc.add<
bool>(
"debugTriggerSelection",
false);
static const std::string kSharedResource
bool accept() const
Has at least one path accepted the event?
const edm::EDGetTokenT< reco::SuperClusterCollection > theEndCapSupClusCollectionToken_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
TH1D * h_Eop_InnerNegative
void Calculate_Covariances(const reco::SuperCluster &passedCluster)
TH1D * h_nTrkRejectedPerEvt
TH1D * h_nEventsTriggered
unsigned int prescaleSize() const
static void fillDescriptions(edm::ConfigurationDescriptions &)
bool error() const
Has any path encountered an error (exception)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
The single EDProduct to be saved for each event (AOD case)
double z() const
z coordinate
Double_t px_rejected_track
const edm::EDGetTokenT< HBHERecHitCollection > theHBHERecHitCollectionToken_
TH1D * h_nEventsHLTelectron
std::vector< std::string > triggerNames_
const Point & position() const
position
TH1D * h_nEventsWithVertex
void beginRun(const edm::Run &, const edm::EventSetup &) override
Geom::Phi< T > phi() const
std::vector< Vertex > VertexCollection
collection of Vertex objects
float ecalEta(float EtaParticle, float Zvertex, float RhoVertex)
TH1D * h_nEventsHLTFilter
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeomToken_
Log< level::Error, false > LogError
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeomToken_
EopElecVariables * treeMemPtr_
static constexpr float R_ECAL
std::vector< Vertex > VertexCollection
std::vector< TPRegexp > filters
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
bool wasrun() const
Was at least one path run?
T prescaleValue(unsigned int set, const std::string &trigger) const
HLT prescale value in specific prescale set for a specific trigger path.
const edm::EDGetTokenT< EcalRecHitCollection > theEcalRecHitCollectionToken_
const edm::EDGetTokenT< reco::SuperClusterCollection > theBarrelSupClusCollectionToken_
Single trigger physics object (e.g., an isolated muon)
edm::Service< TFileService > fs_
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
const edm::EDGetTokenT< reco::GsfElectronCoreCollection > theGsfElectronCoreCollectionToken_
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
static constexpr float k_etaBarrel
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
std::vector< GsfElectronCore > GsfElectronCoreCollection
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
const edm::EDGetTokenT< reco::VertexCollection > theVertexCollectionToken_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
const edm::EDGetTokenT< edm::TriggerResults > theTriggerResultsToken_
#define DEFINE_FWK_MODULE(type)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
static constexpr float etaBarrelEndcap
HLTConfigProvider hltConfig_
Double_t p_rejected_track
bool isNull() const
Checks for null.
bool isEndcap(GeomDetEnumerators::SubDetector m)
TH1D * h_distToClosestSCgsf
void analyze(const edm::Event &, const edm::EventSetup &) override
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Log< level::Info, false > LogInfo
TH1D * h_Eop_InnerPositive
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
TH1D * h_nTrkSelectedPerEvt
const edm::EDGetTokenT< trigger::TriggerEvent > theTriggerEventToken_
bool debugTriggerSelection_
std::vector< size_type > Keys
Double_t pz_rejected_track
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
~EopElecTreeWriter() override
const std::vector< std::string > & triggerNames() const
names of trigger paths
bool momentumFromModePPhiEta(TrajectoryStateOnSurface const &tsos, GlobalVector &momentum)
EopElecTreeWriter(const edm::ParameterSet &)
void endRun(const edm::Run &, const edm::EventSetup &) override
static constexpr float k_etaEndcap
T * make(const Args &...args) const
make new ROOT object
Log< level::Warning, false > LogWarning
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
const edm::EDGetTokenT< reco::GsfTrackCollection > theGsfTrackCollectionToken_
Double_t py_rejected_track
TH1D * h_nEventsHLTrejected
static constexpr float Z_Endcap
MultiTrajectoryStateTransform * mtsTransform_