CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EopTreeWriter Class Reference

#include <Alignment/OfflineValidation/plugins/EopTreeWriter.cc>

Inheritance diagram for EopTreeWriter:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 EopTreeWriter (const edm::ParameterSet &)
 
 ~EopTreeWriter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
double getDistInCM (double eta1, double phi1, double eta2, double phi2)
 

Private Attributes

edm::Service< TFileServicefs_
 
TrackAssociatorParameters parameters_
 
edm::InputTag src_
 
TrackDetectorAssociator trackAssociator_
 
TTree * tree_
 
EopVariablestreeMemPtr_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 68 of file EopTreeWriter.cc.

Constructor & Destructor Documentation

◆ EopTreeWriter()

EopTreeWriter::EopTreeWriter ( const edm::ParameterSet iConfig)
explicit

Definition at line 101 of file EopTreeWriter.cc.

101  : src_(iConfig.getParameter<edm::InputTag>("src")) {
102  //now do what ever initialization is needed
103 
104  // TrackAssociator parameters
105  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
108 
109  tree_ = fs_->make<TTree>("EopTree", "EopTree");
111  tree_->Branch("EopVariables", &treeMemPtr_); // address of pointer!
112 }

References edm::EDConsumerBase::consumesCollector(), fs_, edm::ParameterSet::getParameter(), TrackAssociatorParameters::loadParameters(), TFileService::make(), parameters_, tree_, and treeMemPtr_.

◆ ~EopTreeWriter()

EopTreeWriter::~EopTreeWriter ( )
override

Definition at line 114 of file EopTreeWriter.cc.

114  {
115  // do anything here that needs to be done at destruction time
116  // (e.g. close files, deallocate resources etc.)
117 }

Member Function Documentation

◆ analyze()

void EopTreeWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 124 of file EopTreeWriter.cc.

124  {
125  using namespace edm;
126 
127  // get geometry
129  iSetup.get<CaloGeometryRecord>().get(geometry);
130  const CaloGeometry* geo = geometry.product();
131  // const CaloSubdetectorGeometry* towerGeometry =
132  // geo->getSubdetectorGeometry(DetId::Calo, CaloTowerDetId::SubdetId);
133 
134  // temporary collection of EB+EE recHits
135  std::unique_ptr<EcalRecHitCollection> tmpEcalRecHitCollection(new EcalRecHitCollection);
136  std::vector<edm::InputTag> ecalLabels_;
137 
139  bool ecalInAlca = iEvent.getByLabel(edm::InputTag("IsoProd", "IsoTrackEcalRecHitCollection"), tmpEc);
140  bool ecalInReco = iEvent.getByLabel(edm::InputTag("ecalRecHit", "EcalRecHitsEB"), tmpEc) &&
141  iEvent.getByLabel(edm::InputTag("ecalRecHit", "EcalRecHitsEE"), tmpEc);
142  if (ecalInAlca)
143  ecalLabels_.push_back(edm::InputTag("IsoProd", "IsoTrackEcalRecHitCollection"));
144  else if (ecalInReco) {
145  ecalLabels_.push_back(edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
146  ecalLabels_.push_back(edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
147  } else
148  throw cms::Exception("MissingProduct", "can not find EcalRecHits");
149 
150  std::vector<edm::InputTag>::const_iterator i;
151  for (i = ecalLabels_.begin(); i != ecalLabels_.end(); i++) {
153  iEvent.getByLabel(*i, ec);
154  for (EcalRecHitCollection::const_iterator recHit = (*ec).begin(); recHit != (*ec).end(); ++recHit) {
155  tmpEcalRecHitCollection->push_back(*recHit);
156  }
157  }
158 
160  iEvent.getByLabel(src_, tracks);
161 
164  bool pixelInAlca = iEvent.getByLabel(edm::InputTag("IsoProd", "HcalIsolatedTrackCollection"), tmpPix);
165  if (pixelInAlca)
166  iEvent.getByLabel(edm::InputTag("IsoProd", "HcalIsolatedTrackCollection"), isoPixelTracks);
167 
168  Double_t trackemc1;
169  Double_t trackemc3;
170  Double_t trackemc5;
171  Double_t trackhac1;
172  Double_t trackhac3;
173  Double_t trackhac5;
174  Double_t maxPNearby;
175  Double_t dist;
176  Double_t EnergyIn;
177  Double_t EnergyOut;
178 
179  parameters_.useMuon = false;
180 
181  if (pixelInAlca)
182  if (isoPixelTracks->empty())
183  return;
184 
185  for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) {
186  bool noChargedTracks = true;
187 
188  if (track->p() < 9.)
189  continue;
190 
194 
195  trackemc1 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 0);
196  trackemc3 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 1);
197  trackemc5 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 2);
198  trackhac1 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 0);
199  trackhac3 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 1);
200  trackhac5 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 2);
201 
202  if (trackhac3 < 5.)
203  continue;
204 
205  double etaecal = info.trkGlobPosAtEcal.eta();
206  double phiecal = info.trkGlobPosAtEcal.phi();
207 
208  maxPNearby = -10;
209  dist = 50;
210  for (reco::TrackCollection::const_iterator track1 = tracks->begin(); track1 != tracks->end(); track1++) {
211  if (track == track1)
212  continue;
214  double etaecal1 = info1.trkGlobPosAtEcal.eta();
215  double phiecal1 = info1.trkGlobPosAtEcal.phi();
216 
217  if (etaecal1 == 0 && phiecal1 == 0)
218  continue;
219 
220  double ecDist = getDistInCM(etaecal, phiecal, etaecal1, phiecal1);
221 
222  if (ecDist < 40.) {
223  //calculate maximum P and sum P near seed track
224  if (track1->p() > maxPNearby) {
225  maxPNearby = track1->p();
226  dist = ecDist;
227  }
228 
229  //apply loose isolation criteria
230  if (track1->p() > 5.) {
231  noChargedTracks = false;
232  break;
233  }
234  }
235  }
236  EnergyIn = 0;
237  EnergyOut = 0;
238  if (noChargedTracks) {
239  for (std::vector<EcalRecHit>::const_iterator ehit = tmpEcalRecHitCollection->begin();
240  ehit != tmpEcalRecHitCollection->end();
241  ehit++) {
243  // R-scheme of ECAL CLUSTERIZATION
244  const GlobalPoint& posH = geo->getPosition((*ehit).detid());
245  double phihit = posH.phi();
246  double etahit = posH.eta();
247 
248  double dHitCM = getDistInCM(etaecal, phiecal, etahit, phihit);
249 
250  if (dHitCM < 9.0) {
251  EnergyIn += ehit->energy();
252  }
253  if (dHitCM > 15.0 && dHitCM < 35.0) {
254  EnergyOut += ehit->energy();
255  }
256  }
257 
258  treeMemPtr_->fillVariables(track->charge(),
259  track->innerOk(),
260  track->outerRadius(),
261  track->numberOfValidHits(),
262  track->numberOfLostHits(),
263  track->chi2(),
264  track->normalizedChi2(),
265  track->p(),
266  track->pt(),
267  track->ptError(),
268  track->theta(),
269  track->eta(),
270  track->phi(),
271  trackemc1,
272  trackemc3,
273  trackemc5,
274  trackhac1,
275  trackhac3,
276  trackhac5,
277  maxPNearby,
278  dist,
279  EnergyIn,
280  EnergyOut);
281 
282  tree_->Fill();
283  }
284  }
285 }

References TrackDetectorAssociator::associate(), TrackDetMatchInfo::EcalRecHits, PV3DBase< T, PVType, FrameType >::eta(), Exception, EopVariables::fillVariables(), geometry, edm::EventSetup::get(), get, getDistInCM(), TrackDetectorAssociator::getFreeTrajectoryState(), CaloGeometry::getPosition(), TrackDetMatchInfo::HcalRecHits, mps_fire::i, iEvent, info(), parameters_, PV3DBase< T, PVType, FrameType >::phi(), rpcPointValidation_cfi::recHit, src_, HLT_2018_cff::track, trackAssociator_, PDWG_EXOHSCP_cff::tracks, tree_, treeMemPtr_, TrackDetMatchInfo::trkGlobPosAtEcal, TrackDetectorAssociator::useDefaultPropagator(), and TrackAssociatorParameters::useMuon.

◆ beginJob()

void EopTreeWriter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 288 of file EopTreeWriter.cc.

288 {}

◆ endJob()

void EopTreeWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 291 of file EopTreeWriter.cc.

291  {
292  delete treeMemPtr_;
293  treeMemPtr_ = nullptr;
294 }

References treeMemPtr_.

Referenced by o2olib.O2ORunMgr::executeJob().

◆ getDistInCM()

double EopTreeWriter::getDistInCM ( double  eta1,
double  phi1,
double  eta2,
double  phi2 
)
private

Definition at line 296 of file EopTreeWriter.cc.

296  {
297  double deltaPhi = phi1 - phi2;
298  while (deltaPhi > TMath::Pi())
299  deltaPhi -= 2 * TMath::Pi();
300  while (deltaPhi <= -TMath::Pi())
301  deltaPhi += 2 * TMath::Pi();
302  double dR;
303  // double Rec;
304  double theta1 = 2 * atan(exp(-eta1));
305  double theta2 = 2 * atan(exp(-eta2));
306  double cotantheta1;
307  if (cos(theta1) == 0)
308  cotantheta1 = 0;
309  else
310  cotantheta1 = 1 / tan(theta1);
311  double cotantheta2;
312  if (cos(theta2) == 0)
313  cotantheta2 = 0;
314  else
315  cotantheta2 = 1 / tan(theta2);
316  // if (fabs(eta1)<1.479) Rec=129; //radius of ECAL barrel
317  // else Rec=317; //distance from IP to ECAL endcap
318  //|vect| times tg of acos(scalar product)
319  // dR=fabs((Rec/sin(theta1))*tan(acos(sin(theta1)*sin(theta2)*(sin(phi1)*sin(phi2)+cos(phi1)*cos(phi2))+cos(theta1)*cos(theta2))));
320  if (fabs(eta1) < 1.479)
321  dR = 129 * sqrt((cotantheta1 - cotantheta2) * (cotantheta1 - cotantheta2) + deltaPhi * deltaPhi);
322  else
323  dR = 317 *
324  sqrt(tan(theta1) * tan(theta1) + tan(theta2) * tan(theta2) - 2 * tan(theta1) * tan(theta2) * cos(deltaPhi));
325  return dR;
326 }

References funct::cos(), SiPixelRawToDigiRegional_cfi::deltaPhi, HGC3DClusterGenMatchSelector_cfi::dR, HLT_2018_cff::eta1, HLT_2018_cff::eta2, JetChargeProducer_cfi::exp, Pi, mathSSE::sqrt(), and funct::tan().

Referenced by analyze().

Member Data Documentation

◆ fs_

edm::Service<TFileService> EopTreeWriter::fs_
private

Definition at line 83 of file EopTreeWriter.cc.

Referenced by EopTreeWriter().

◆ parameters_

TrackAssociatorParameters EopTreeWriter::parameters_
private

◆ src_

edm::InputTag EopTreeWriter::src_
private

Definition at line 81 of file EopTreeWriter.cc.

Referenced by analyze().

◆ trackAssociator_

TrackDetectorAssociator EopTreeWriter::trackAssociator_
private

Definition at line 86 of file EopTreeWriter.cc.

Referenced by analyze().

◆ tree_

TTree* EopTreeWriter::tree_
private

Definition at line 84 of file EopTreeWriter.cc.

Referenced by analyze(), and EopTreeWriter().

◆ treeMemPtr_

EopVariables* EopTreeWriter::treeMemPtr_
private

Definition at line 85 of file EopTreeWriter.cc.

Referenced by analyze(), endJob(), and EopTreeWriter().

EopVariables
container to hold data to be written into TTree
Definition: EopVariables.h:8
geometry
ESHandle< TrackerGeometry > geometry
Definition: TkLasBeamFitter.cc:200
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
EopTreeWriter::getDistInCM
double getDistInCM(double eta1, double phi1, double eta2, double phi2)
Definition: EopTreeWriter.cc:296
EopTreeWriter::trackAssociator_
TrackDetectorAssociator trackAssociator_
Definition: EopTreeWriter.cc:86
CaloGeometry::getPosition
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
TrackDetectorAssociator::useDefaultPropagator
void useDefaultPropagator()
use the default propagator
Definition: TrackDetectorAssociator.cc:120
geometry
Definition: geometry.py:1
HLT_2018_cff.eta1
eta1
Definition: HLT_2018_cff.py:8220
edm::SortedCollection< EcalRecHit >
edm::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
TrackAssociatorParameters::useMuon
bool useMuon
Definition: TrackAssociatorParameters.h:74
EopTreeWriter::treeMemPtr_
EopVariables * treeMemPtr_
Definition: EopTreeWriter.cc:85
edm::Handle
Definition: AssociativeIterator.h:50
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
EopTreeWriter::fs_
edm::Service< TFileService > fs_
Definition: EopTreeWriter.cc:83
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
TrackDetectorAssociator::getFreeTrajectoryState
static FreeTrajectoryState getFreeTrajectoryState(const edm::EventSetup &, const reco::Track &)
get FreeTrajectoryState from different track representations
Definition: TrackDetectorAssociator.cc:600
TrackDetMatchInfo::EcalRecHits
Definition: TrackDetMatchInfo.h:16
CaloGeometry
Definition: CaloGeometry.h:21
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
SiPixelRawToDigiRegional_cfi.deltaPhi
deltaPhi
Definition: SiPixelRawToDigiRegional_cfi.py:9
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
edm::ESHandle< CaloGeometry >
EopTreeWriter::parameters_
TrackAssociatorParameters parameters_
Definition: EopTreeWriter.cc:87
Point3DBase< float, GlobalTag >
TrackAssociatorParameters::loadParameters
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
Definition: TrackAssociatorParameters.cc:18
HLT_2018_cff.eta2
eta2
Definition: HLT_2018_cff.py:8221
EopTreeWriter::src_
edm::InputTag src_
Definition: EopTreeWriter.cc:81
edm::ParameterSet
Definition: ParameterSet.h:36
PV3DBase::eta
T eta() const
Definition: PV3DBase.h:73
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
iEvent
int iEvent
Definition: GenABIO.cc:224
get
#define get
TrackDetMatchInfo::trkGlobPosAtEcal
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
Definition: TrackDetMatchInfo.h:39
EopVariables::fillVariables
void fillVariables(Int_t charge, Int_t innerOk, Double_t outerRadius, Int_t numberOfValidHits, Int_t numberOfLostHits, Double_t chi2, Double_t normalizedChi2, Double_t p, Double_t pt, Double_t ptError, Double_t theta, Double_t eta, Double_t phi, Double_t emc1, Double_t emc3, Double_t emc5, Double_t hac1, Double_t hac3, Double_t hac5, Double_t maxPNearby, Double_t dist, Double_t EnergyIn, Double_t EnergyOut)
fill variables into tree
Definition: EopVariables.h:22
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TrackDetMatchInfo
Definition: TrackDetMatchInfo.h:14
Exception
Definition: hltDiff.cc:246
TrackDetMatchInfo::HcalRecHits
Definition: TrackDetMatchInfo.h:16
Pi
const double Pi
Definition: CosmicMuonParameters.h:18
HLT_2018_cff.track
track
Definition: HLT_2018_cff.py:10352
TrackDetectorAssociator::associate
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
Definition: TrackDetectorAssociator.cc:154
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
EopTreeWriter::tree_
TTree * tree_
Definition: EopTreeWriter.cc:84
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition: TFileService.h:64