CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 EopTreeWriter (const edm::ParameterSet &)
 
 ~EopTreeWriter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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_
 
edm::ESGetToken< CaloGeometry,
CaloGeometryRecord
geometryToken_
 
TrackAssociatorParameters parameters_
 
edm::InputTag src_
 
TrackDetectorAssociator trackAssociator_
 
TTree * tree_
 
EopVariablestreeMemPtr_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, 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)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

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

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

Definition at line 67 of file EopTreeWriter.cc.

Constructor & Destructor Documentation

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

Definition at line 101 of file EopTreeWriter.cc.

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

102  : src_(iConfig.getParameter<edm::InputTag>("src")), geometryToken_(esConsumes()) {
103  usesResource(TFileService::kSharedResource);
104  //now do what ever initialization is needed
105 
106  // TrackAssociator parameters
107  edm::ParameterSet parameters = iConfig.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
109  parameters_.loadParameters(parameters, iC);
110 
111  tree_ = fs_->make<TTree>("EopTree", "EopTree");
113  tree_->Branch("EopVariables", &treeMemPtr_); // address of pointer!
114 }
static const std::string kSharedResource
Definition: TFileService.h:76
container to hold data to be written into TTree
Definition: EopVariables.h:8
void loadParameters(const edm::ParameterSet &, edm::ConsumesCollector &)
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::InputTag src_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
TrackAssociatorParameters parameters_
edm::Service< TFileService > fs_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
EopVariables * treeMemPtr_
EopTreeWriter::~EopTreeWriter ( )
override

Definition at line 116 of file EopTreeWriter.cc.

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

Member Function Documentation

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

Implements edm::one::EDAnalyzerBase.

Definition at line 126 of file EopTreeWriter.cc.

References TrackDetectorAssociator::associate(), TrackAssociatorParameters::bFieldToken, TrackDetMatchInfo::EcalRecHits, PV3DBase< T, PVType, FrameType >::eta(), Exception, EopVariables::fillVariables(), geometryToken_, edm::Event::getByLabel(), edm::EventSetup::getData(), getDistInCM(), TrackDetectorAssociator::getFreeTrajectoryState(), TrackDetMatchInfo::HcalRecHits, mps_fire::i, info(), TrackDetMatchInfo::nXnEnergy(), parameters_, PV3DBase< T, PVType, FrameType >::phi(), src_, HLT_FULL_cff::track, trackAssociator_, tracks, tree_, treeMemPtr_, TrackDetMatchInfo::trkGlobPosAtEcal, TrackDetectorAssociator::useDefaultPropagator(), and TrackAssociatorParameters::useMuon.

126  {
127  using namespace edm;
128 
129  // get geometry
130  const CaloGeometry* geo = &iSetup.getData(geometryToken_);
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 
193  iEvent,
194  iSetup,
196  parameters_);
197 
198  trackemc1 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 0);
199  trackemc3 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 1);
200  trackemc5 = info.nXnEnergy(TrackDetMatchInfo::EcalRecHits, 2);
201  trackhac1 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 0);
202  trackhac3 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 1);
203  trackhac5 = info.nXnEnergy(TrackDetMatchInfo::HcalRecHits, 2);
204 
205  if (trackhac3 < 5.)
206  continue;
207 
208  double etaecal = info.trkGlobPosAtEcal.eta();
209  double phiecal = info.trkGlobPosAtEcal.phi();
210 
211  maxPNearby = -10;
212  dist = 50;
213  for (reco::TrackCollection::const_iterator track1 = tracks->begin(); track1 != tracks->end(); track1++) {
214  if (track == track1)
215  continue;
216  TrackDetMatchInfo info1 = trackAssociator_.associate(iEvent, iSetup, *track1, parameters_);
217  double etaecal1 = info1.trkGlobPosAtEcal.eta();
218  double phiecal1 = info1.trkGlobPosAtEcal.phi();
219 
220  if (etaecal1 == 0 && phiecal1 == 0)
221  continue;
222 
223  double ecDist = getDistInCM(etaecal, phiecal, etaecal1, phiecal1);
224 
225  if (ecDist < 40.) {
226  //calculate maximum P and sum P near seed track
227  if (track1->p() > maxPNearby) {
228  maxPNearby = track1->p();
229  dist = ecDist;
230  }
231 
232  //apply loose isolation criteria
233  if (track1->p() > 5.) {
234  noChargedTracks = false;
235  break;
236  }
237  }
238  }
239  EnergyIn = 0;
240  EnergyOut = 0;
241  if (noChargedTracks) {
242  for (std::vector<EcalRecHit>::const_iterator ehit = tmpEcalRecHitCollection->begin();
243  ehit != tmpEcalRecHitCollection->end();
244  ehit++) {
246  // R-scheme of ECAL CLUSTERIZATION
247  const GlobalPoint& posH = geo->getPosition((*ehit).detid());
248  double phihit = posH.phi();
249  double etahit = posH.eta();
250 
251  double dHitCM = getDistInCM(etaecal, phiecal, etahit, phihit);
252 
253  if (dHitCM < 9.0) {
254  EnergyIn += ehit->energy();
255  }
256  if (dHitCM > 15.0 && dHitCM < 35.0) {
257  EnergyOut += ehit->energy();
258  }
259  }
260 
261  treeMemPtr_->fillVariables(track->charge(),
262  track->innerOk(),
263  track->outerRadius(),
264  track->numberOfValidHits(),
265  track->numberOfLostHits(),
266  track->chi2(),
267  track->normalizedChi2(),
268  track->p(),
269  track->pt(),
270  track->ptError(),
271  track->theta(),
272  track->eta(),
273  track->phi(),
274  trackemc1,
275  trackemc3,
276  trackemc5,
277  trackhac1,
278  trackhac3,
279  trackhac5,
280  maxPNearby,
281  dist,
282  EnergyIn,
283  EnergyOut);
284 
285  tree_->Fill();
286  }
287  }
288 }
static const TGPicture * info(bool iBackgroundIsBlack)
void useDefaultPropagator()
use the default propagator
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
std::vector< EcalRecHit >::const_iterator const_iterator
auto const & tracks
cannot be loose
edm::InputTag src_
double nXnEnergy(const DetId &, EnergyType, int gridSize=1)
get energy of the NxN shape (N = 2*gridSize + 1) around given detector element
bool getData(T &iHolder) const
Definition: EventSetup.h:128
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > bFieldToken
TrackAssociatorParameters parameters_
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
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:500
TrackDetectorAssociator trackAssociator_
static FreeTrajectoryState getFreeTrajectoryState(const MagneticField *, const reco::Track &)
get FreeTrajectoryState from different track representations
T eta() const
Definition: PV3DBase.h:73
double getDistInCM(double eta1, double phi1, double eta2, double phi2)
TrackDetMatchInfo associate(const edm::Event &, const edm::EventSetup &, const FreeTrajectoryState &, const AssociatorParameters &)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometryToken_
math::XYZPoint trkGlobPosAtEcal
Track position at different parts of the calorimeter.
EopVariables * treeMemPtr_
void EopTreeWriter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 291 of file EopTreeWriter.cc.

291 {}
void EopTreeWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 294 of file EopTreeWriter.cc.

References treeMemPtr_.

Referenced by o2olib.O2ORunMgr::executeJob().

294  {
295  delete treeMemPtr_;
296  treeMemPtr_ = nullptr;
297 }
EopVariables * treeMemPtr_
double EopTreeWriter::getDistInCM ( double  eta1,
double  phi1,
double  eta2,
double  phi2 
)
private

Definition at line 299 of file EopTreeWriter.cc.

References funct::cos(), srCondWrite_cfg::deltaPhi, funct::exp(), Pi, mathSSE::sqrt(), and funct::tan().

Referenced by analyze().

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

Member Data Documentation

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

Definition at line 83 of file EopTreeWriter.cc.

Referenced by EopTreeWriter().

edm::ESGetToken<CaloGeometry, CaloGeometryRecord> EopTreeWriter::geometryToken_
private

Definition at line 81 of file EopTreeWriter.cc.

Referenced by analyze().

TrackAssociatorParameters EopTreeWriter::parameters_
private
edm::InputTag EopTreeWriter::src_
private

Definition at line 80 of file EopTreeWriter.cc.

Referenced by analyze().

TrackDetectorAssociator EopTreeWriter::trackAssociator_
private

Definition at line 86 of file EopTreeWriter.cc.

Referenced by analyze().

TTree* EopTreeWriter::tree_
private

Definition at line 84 of file EopTreeWriter.cc.

Referenced by analyze(), and EopTreeWriter().

EopVariables* EopTreeWriter::treeMemPtr_
private

Definition at line 85 of file EopTreeWriter.cc.

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