CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions
HIPTwoBodyDecayAnalyzer Class Reference
Inheritance diagram for HIPTwoBodyDecayAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 HIPTwoBodyDecayAnalyzer (const edm::ParameterSet &)
 
 ~HIPTwoBodyDecayAnalyzer () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- 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 ()
 

Public Attributes

edm::EDGetTokenT< reco::TrackCollectionalcareco_trackCollToken_
 
edm::EDGetTokenT< reco::TrackCollectionctf_trackCollToken_
 
edm::EDGetTokenT< reco::TrackCollectionfinal_trackCollToken_
 
std::vector< std::pair< std::string, float * > > floatBranches
 
std::vector< std::pair< std::string, int * > > intBranches
 
edm::EDGetTokenT< reco::TrackCollectionrefit1_trackCollToken_
 
std::vector< std::pair< std::string, short * > > shortBranches
 
TTree * tree
 

Private Types

enum  BranchType { BranchType_short_t, BranchType_int_t, BranchType_float_t, BranchType_unknown_t }
 

Private Member Functions

bool actuateBranches ()
 
void analyze (const edm::Event &, const edm::EventSetup &) override
 
void analyzeTrackCollection (std::string strTrackType, edm::ESHandle< TransientTrackBuilder > &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool verbose=false)
 
void beginJob () override
 
void bookAllBranches ()
 
bool bookBranch (std::string bname, BranchType btype)
 
void cleanBranches ()
 
void endJob () override
 
reco::Vertex fitDimuonVertex (edm::ESHandle< TransientTrackBuilder > &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool &fitOk)
 
void initializeBranches ()
 
BranchType searchArray (std::string branchname, int &position)
 
template<typename varType >
void setVal (std::string bname, varType value)
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 32 of file HIPTwoBodyDecayAnalyzer.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 88 of file HIPTwoBodyDecayAnalyzer.cc.

References alcareco_trackCollToken_, bookAllBranches(), ctf_trackCollToken_, final_trackCollToken_, edm::ParameterSet::getParameter(), TFileService::make(), and refit1_trackCollToken_.

88  {
89  alcareco_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("alcarecotracks"));
90  refit1_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("refit1tracks"));
91  ctf_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("refit2tracks"));
92  final_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("finaltracks"));
93 
95 
96  tree = fs->make<TTree>("TestTree", "");
98 }
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::TrackCollection > refit1_trackCollToken_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::EDGetTokenT< reco::TrackCollection > alcareco_trackCollToken_
Definition: tree.py:1
edm::EDGetTokenT< reco::TrackCollection > ctf_trackCollToken_
edm::EDGetTokenT< reco::TrackCollection > final_trackCollToken_
HIPTwoBodyDecayAnalyzer::~HIPTwoBodyDecayAnalyzer ( )
override

Definition at line 252 of file HIPTwoBodyDecayAnalyzer.cc.

References cleanBranches().

Member Function Documentation

bool HIPTwoBodyDecayAnalyzer::actuateBranches ( )
private

Definition at line 215 of file HIPTwoBodyDecayAnalyzer.cc.

References beam_dqm_sourceclient-live_cfg::cerr, gather_cfg::cout, floatBranches, intBranches, shortBranches, and summarizeEdmComparisonLogfiles::success.

Referenced by bookAllBranches(), and setVal().

215  {
216  bool success = true;
217  std::cout << "Begin HIPTwoBodyDecayAnalyzer::actuateBranches" << std::endl;
218  std::cout << "Number of short branches: " << shortBranches.size() << std::endl;
219  std::cout << "Number of int branches: " << intBranches.size() << std::endl;
220  std::cout << "Number of float branches: " << floatBranches.size() << std::endl;
221  if (tree != nullptr) {
222  for (unsigned short el = 0; el < shortBranches.size(); el++) {
223  std::cout << "Actuating branch " << shortBranches.at(el).first << " at address " << shortBranches.at(el).second
224  << std::endl;
225  if (!tree->GetBranchStatus(shortBranches.at(el).first.c_str()))
226  tree->Branch(shortBranches.at(el).first.c_str(), shortBranches.at(el).second);
227  else
228  std::cout << "Failed!" << std::endl;
229  }
230  for (unsigned int el = 0; el < intBranches.size(); el++) {
231  std::cout << "Actuating branch " << intBranches.at(el).first.c_str() << " at address "
232  << intBranches.at(el).second << std::endl;
233  if (!tree->GetBranchStatus(intBranches.at(el).first.c_str()))
234  tree->Branch(intBranches.at(el).first.c_str(), intBranches.at(el).second);
235  else
236  std::cout << "Failed!" << std::endl;
237  }
238  for (unsigned int el = 0; el < floatBranches.size(); el++) {
239  std::cout << "Actuating branch " << floatBranches.at(el).first.c_str() << " at address "
240  << floatBranches.at(el).second << std::endl;
241  if (!tree->GetBranchStatus(floatBranches.at(el).first.c_str()))
242  tree->Branch(floatBranches.at(el).first.c_str(), floatBranches.at(el).second);
243  else
244  std::cout << "Failed!" << std::endl;
245  }
246  } else
247  success = false;
248  if (!success)
249  std::cerr << "HIPTwoBodyDecayAnalyzer::actuateBranch: Failed to actuate the branches!" << std::endl;
250  return success;
251 }
std::vector< std::pair< std::string, short * > > shortBranches
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches
Definition: tree.py:1
void HIPTwoBodyDecayAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 254 of file HIPTwoBodyDecayAnalyzer.cc.

References alcareco_trackCollToken_, analyzeTrackCollection(), ctf_trackCollToken_, final_trackCollToken_, edm::EventSetup::get(), edm::Event::getByToken(), initializeBranches(), and refit1_trackCollToken_.

254  {
255  using namespace edm;
256  using namespace reco;
257  using reco::TrackCollection;
258 
259  edm::Handle<reco::TrackCollection> alcarecotracks;
260  iEvent.getByToken(alcareco_trackCollToken_, alcarecotracks);
262  iEvent.getByToken(refit1_trackCollToken_, refit1tracks);
264  iEvent.getByToken(ctf_trackCollToken_, ctftracks);
266  iEvent.getByToken(final_trackCollToken_, finaltracks);
267 
269  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", theTTBuilder);
270 
272 
273  analyzeTrackCollection("alcareco", theTTBuilder, alcarecotracks);
274  analyzeTrackCollection("refit1", theTTBuilder, refit1tracks);
275  analyzeTrackCollection("refit2", theTTBuilder, ctftracks);
276  analyzeTrackCollection("final", theTTBuilder, finaltracks);
277 
278  tree->Fill();
279 }
edm::EDGetTokenT< reco::TrackCollection > refit1_trackCollToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void analyzeTrackCollection(std::string strTrackType, edm::ESHandle< TransientTrackBuilder > &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool verbose=false)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::EDGetTokenT< reco::TrackCollection > alcareco_trackCollToken_
fixed size matrix
HLT enums.
T get() const
Definition: EventSetup.h:73
Definition: tree.py:1
edm::EDGetTokenT< reco::TrackCollection > ctf_trackCollToken_
edm::EDGetTokenT< reco::TrackCollection > final_trackCollToken_
void HIPTwoBodyDecayAnalyzer::analyzeTrackCollection ( std::string  strTrackType,
edm::ESHandle< TransientTrackBuilder > &  theTTBuilder,
edm::Handle< reco::TrackCollection > &  hTrackColl,
bool  verbose = false 
)
private

Definition at line 290 of file HIPTwoBodyDecayAnalyzer.cc.

References TransientTrackBuilder::build(), beam_dqm_sourceclient-live_cfg::cerr, ALCARECOTkAlJpsiMuMu_cff::charge, RecoVertex::convertPos(), gather_cfg::cout, reco::TransientTrack::field(), fitDimuonVertex(), reco::TransientTrack::impactPointState(), edm::HandleBase::isValid(), dqmiolumiharvest::j, PV3DBase< T, PVType, FrameType >::mag(), VtxSmearedParameters_cfi::Phi, funct::pow(), setVal(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, HLT_2018_cff::track, X, PV3DBase< T, PVType, FrameType >::x(), DOFs::Y, PV3DBase< T, PVType, FrameType >::y(), DOFs::Z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by analyze(), and setVal().

293  {
294  if (verbose)
295  std::cout << "Starting to process the track collection for " << strTrackType << std::endl;
296 
297  using namespace edm;
298  using namespace reco;
299  using reco::TrackCollection;
300 
301  if (!hTrackColl.isValid()) {
302  if (verbose)
303  std::cout << "Track collection is invalid." << std::endl;
304  return;
305  }
306  if (hTrackColl->size() < 2) {
307  if (verbose)
308  std::cout << "Track collection size<2." << std::endl;
309  return;
310  }
311 
312  unsigned int itrk = 0;
313  unsigned int j = 0;
314  int totalcharge = 0;
315  bool isValidPair = true;
316  bool ZVtxOk = false;
317  TLorentzVector trackMom[2];
318  TLorentzVector trackMomAfterZVtxFit[2];
319  TVector3 trackVtx[2];
320 
321  for (unsigned int jtrk = 0; jtrk < 2; jtrk++) {
322  trackMom[jtrk].SetXYZT(0, 0, 0, 0);
323  trackVtx[jtrk].SetXYZ(0, 0, 0);
324  }
325  for (reco::TrackCollection::const_iterator track = hTrackColl->begin(); track != hTrackColl->end(); ++track) {
326  int charge = track->charge();
327  totalcharge += charge;
328  if (j == 0) {
329  itrk = (charge > 0 ? 1 : 0);
330  } else
331  itrk = 1 - itrk;
332  trackMom[itrk].SetPtEtaPhiM(track->pt(), track->eta(), track->phi(), 0.105);
333  trackVtx[itrk].SetXYZ(track->vx(), track->vy(), track->vz());
334  j++;
335  if (j == 2)
336  break;
337  }
338 
339  isValidPair = (totalcharge == 0 && trackMom[0].P() != 0. && trackMom[1].P() != 0.);
340  if (verbose && !isValidPair)
341  std::cout << "Track collection does not contain a valid std::pair." << std::endl;
342  setVal(strTrackType + "_present", (isValidPair ? (short)1 : (short)0));
343  if (isValidPair) {
344  TLorentzVector ZMom = trackMom[0] + trackMom[1];
345  setVal(strTrackType + "_ZPt", (float)ZMom.Pt());
346  setVal(strTrackType + "_ZPz", (float)ZMom.Pz());
347  setVal(strTrackType + "_ZPhi", (float)ZMom.Phi());
348  setVal(strTrackType + "_ZMass", (float)ZMom.M());
349 
350  reco::Vertex ZVtx = fitDimuonVertex(theTTBuilder, hTrackColl, ZVtxOk);
351  if (ZVtxOk) {
352  setVal(strTrackType + "_ZVertex_x", (float)ZVtx.x());
353  setVal(strTrackType + "_ZVertex_y", (float)ZVtx.y());
354  setVal(strTrackType + "_ZVertex_z", (float)ZVtx.z());
355  setVal(strTrackType + "_ZVertex_NormChi2", (float)ZVtx.normalizedChi2());
356 
357  // Recalculate track momenta with this vertex as reference
358  j = 0;
359  for (reco::TrackCollection::const_iterator track = hTrackColl->begin(); track != hTrackColl->end(); ++track) {
360  TransientTrack t_track = theTTBuilder->build(&(*track));
361  AnalyticalImpactPointExtrapolator extrapolator(t_track.field());
362  TrajectoryStateOnSurface closestIn3DSpaceState =
363  extrapolator.extrapolate(t_track.impactPointState(), RecoVertex::convertPos(ZVtx.position()));
364  GlobalVector mom = closestIn3DSpaceState.globalMomentum();
365  int charge = track->charge();
366  totalcharge += charge;
367  if (j == 0) {
368  itrk = (charge > 0 ? 1 : 0);
369  } else
370  itrk = 1 - itrk;
371  trackMomAfterZVtxFit[itrk].SetXYZT(mom.x(), mom.y(), mom.z(), sqrt(pow(0.105, 2) + pow(mom.mag(), 2)));
372  j++;
373  if (j == 2)
374  break;
375  }
376  if (totalcharge != 0)
377  std::cerr
378  << "HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Something went wrong! The total charge is no longer 0!"
379  << std::endl;
380  for (unsigned int jtrk = 0; jtrk < 2; jtrk++) {
381  std::string strMuCore = (jtrk == 0 ? "MuMinus" : "MuPlus");
382  setVal(strTrackType + "_" + strMuCore + "Pt_AfterZVtxFit", (float)trackMomAfterZVtxFit[jtrk].Pt());
383  setVal(strTrackType + "_" + strMuCore + "Pz_AfterZVtxFit", (float)trackMomAfterZVtxFit[jtrk].Pz());
384  setVal(strTrackType + "_" + strMuCore + "Phi_AfterZVtxFit", (float)trackMomAfterZVtxFit[jtrk].Phi());
385  }
386  TLorentzVector ZMom_AfterZVtxFit = trackMomAfterZVtxFit[0] + trackMomAfterZVtxFit[1];
387  setVal(strTrackType + "_ZPt_AfterZVtxFit", (float)ZMom_AfterZVtxFit.Pt());
388  setVal(strTrackType + "_ZPz_AfterZVtxFit", (float)ZMom_AfterZVtxFit.Pz());
389  setVal(strTrackType + "_ZPhi_AfterZVtxFit", (float)ZMom_AfterZVtxFit.Phi());
390  setVal(strTrackType + "_ZMass_AfterZVtxFit", (float)ZMom_AfterZVtxFit.M());
391  } else
392  std::cerr << "HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Z vertex fit failed for track collection "
393  << strTrackType << std::endl;
394  }
395  setVal(strTrackType + "_ZVtxFitOk", (ZVtxOk ? (short)1 : (short)0));
396  for (unsigned int jtrk = 0; jtrk < 2; jtrk++) {
397  std::string strMuCore = (jtrk == 0 ? "MuMinus" : "MuPlus");
398  setVal(strTrackType + "_" + strMuCore + "Pt", (float)trackMom[jtrk].Pt());
399  setVal(strTrackType + "_" + strMuCore + "Pz", (float)trackMom[jtrk].Pz());
400  setVal(strTrackType + "_" + strMuCore + "Phi", (float)trackMom[jtrk].Phi());
401  setVal(strTrackType + "_" + strMuCore + "Vertex_x", (float)trackVtx[jtrk].X());
402  setVal(strTrackType + "_" + strMuCore + "Vertex_y", (float)trackVtx[jtrk].Y());
403  setVal(strTrackType + "_" + strMuCore + "Vertex_z", (float)trackVtx[jtrk].Z());
404  }
405 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
reco::Vertex fitDimuonVertex(edm::ESHandle< TransientTrackBuilder > &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool &fitOk)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
reco::TransientTrack build(const reco::Track *p) const
T y() const
Definition: PV3DBase.h:60
#define X(str)
Definition: MuonsGrabber.cc:38
const MagneticField * field() const
void setVal(std::string bname, varType value)
T mag() const
Definition: PV3DBase.h:64
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
bool isValid() const
Definition: HandleBase.h:70
fixed size matrix
HLT enums.
TrajectoryStateOnSurface impactPointState() const
T x() const
Definition: PV3DBase.h:59
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
void HIPTwoBodyDecayAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 281 of file HIPTwoBodyDecayAnalyzer.cc.

281 {}
void HIPTwoBodyDecayAnalyzer::bookAllBranches ( )
private

Definition at line 156 of file HIPTwoBodyDecayAnalyzer.cc.

References actuateBranches(), bookBranch(), BranchType_float_t, BranchType_short_t, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by HIPTwoBodyDecayAnalyzer().

156  {
157  const int nTrackTypes = 4;
158  std::vector<std::string> strTrackTypes;
159  strTrackTypes.reserve(nTrackTypes);
160  strTrackTypes.push_back("alcareco");
161  strTrackTypes.push_back("refit1");
162  strTrackTypes.push_back("refit2");
163  strTrackTypes.push_back("final");
164  for (unsigned int it = 0; it < nTrackTypes; it++) {
165  std::string& strTrackType = strTrackTypes[it];
166  bookBranch(strTrackType + "_present", BranchType_short_t);
167  bookBranch(strTrackType + "_ZVtxFitOk", BranchType_short_t);
168  bookBranch(strTrackType + "_ZMass", BranchType_float_t);
169  bookBranch(strTrackType + "_ZPt", BranchType_float_t);
170  bookBranch(strTrackType + "_ZPz", BranchType_float_t);
171  bookBranch(strTrackType + "_ZPhi", BranchType_float_t);
172  bookBranch(strTrackType + "_ZVertex_x", BranchType_float_t);
173  bookBranch(strTrackType + "_ZVertex_y", BranchType_float_t);
174  bookBranch(strTrackType + "_ZVertex_z", BranchType_float_t);
175  bookBranch(strTrackType + "_ZVertex_NormChi2", BranchType_float_t);
176  bookBranch(strTrackType + "_MuPlusVertex_x", BranchType_float_t);
177  bookBranch(strTrackType + "_MuPlusVertex_y", BranchType_float_t);
178  bookBranch(strTrackType + "_MuPlusVertex_z", BranchType_float_t);
179  bookBranch(strTrackType + "_MuMinusPt_AfterZVtxFit", BranchType_float_t);
180  bookBranch(strTrackType + "_MuMinusPz_AfterZVtxFit", BranchType_float_t);
181  bookBranch(strTrackType + "_MuMinusPhi_AfterZVtxFit", BranchType_float_t);
182  bookBranch(strTrackType + "_MuPlusPt_AfterZVtxFit", BranchType_float_t);
183  bookBranch(strTrackType + "_MuPlusPz_AfterZVtxFit", BranchType_float_t);
184  bookBranch(strTrackType + "_MuPlusPhi_AfterZVtxFit", BranchType_float_t);
185  bookBranch(strTrackType + "_ZMass_AfterZVtxFit", BranchType_float_t);
186  bookBranch(strTrackType + "_ZPt_AfterZVtxFit", BranchType_float_t);
187  bookBranch(strTrackType + "_ZPz_AfterZVtxFit", BranchType_float_t);
188  bookBranch(strTrackType + "_ZPhi_AfterZVtxFit", BranchType_float_t);
189  bookBranch(strTrackType + "_MuMinusPt", BranchType_float_t);
190  bookBranch(strTrackType + "_MuMinusPz", BranchType_float_t);
191  bookBranch(strTrackType + "_MuMinusPhi", BranchType_float_t);
192  bookBranch(strTrackType + "_MuMinusVertex_x", BranchType_float_t);
193  bookBranch(strTrackType + "_MuMinusVertex_y", BranchType_float_t);
194  bookBranch(strTrackType + "_MuMinusVertex_z", BranchType_float_t);
195  bookBranch(strTrackType + "_MuPlusPt", BranchType_float_t);
196  bookBranch(strTrackType + "_MuPlusPz", BranchType_float_t);
197  bookBranch(strTrackType + "_MuPlusPhi", BranchType_float_t);
198  }
199  actuateBranches();
200 }
bool bookBranch(std::string bname, BranchType btype)
bool HIPTwoBodyDecayAnalyzer::bookBranch ( std::string  bname,
BranchType  btype 
)
private

Definition at line 201 of file HIPTwoBodyDecayAnalyzer.cc.

References BranchType_float_t, BranchType_int_t, BranchType_short_t, beam_dqm_sourceclient-live_cfg::cerr, floatBranches, intBranches, and shortBranches.

Referenced by bookAllBranches().

201  {
202  if (btype == BranchType_float_t)
203  floatBranches.emplace_back(bname, new float);
204  else if (btype == BranchType_int_t)
205  intBranches.emplace_back(bname, new int);
206  else if (btype == BranchType_short_t)
207  shortBranches.emplace_back(bname, new short);
208  else {
209  std::cerr << "HIPTwoBodyDecayAnalyzer::bookBranch: No support for type " << btype << " for the branch " << bname
210  << " is available." << std::endl;
211  return false;
212  }
213  return true;
214 }
std::vector< std::pair< std::string, short * > > shortBranches
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches
void HIPTwoBodyDecayAnalyzer::cleanBranches ( )
private

Definition at line 121 of file HIPTwoBodyDecayAnalyzer.cc.

References floatBranches, intBranches, and shortBranches.

Referenced by setVal(), and ~HIPTwoBodyDecayAnalyzer().

121  {
122  for (unsigned short el = 0; el < shortBranches.size(); el++) {
123  if (shortBranches.at(el).second != nullptr)
124  delete shortBranches.at(el).second;
125  shortBranches.at(el).second = nullptr;
126  }
127  shortBranches.clear();
128  for (unsigned int el = 0; el < intBranches.size(); el++) {
129  if (intBranches.at(el).second != nullptr)
130  delete intBranches.at(el).second;
131  intBranches.at(el).second = nullptr;
132  }
133  intBranches.clear();
134  for (unsigned int el = 0; el < floatBranches.size(); el++) {
135  if (floatBranches.at(el).second != nullptr)
136  delete floatBranches.at(el).second;
137  floatBranches.at(el).second = nullptr;
138  }
139  floatBranches.clear();
140 }
std::vector< std::pair< std::string, short * > > shortBranches
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches
void HIPTwoBodyDecayAnalyzer::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 282 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

282 {}
void HIPTwoBodyDecayAnalyzer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static
reco::Vertex HIPTwoBodyDecayAnalyzer::fitDimuonVertex ( edm::ESHandle< TransientTrackBuilder > &  theTTBuilder,
edm::Handle< reco::TrackCollection > &  hTrackColl,
bool &  fitOk 
)
private

Definition at line 407 of file HIPTwoBodyDecayAnalyzer.cc.

References TransientTrackBuilder::build(), DEFINE_FWK_MODULE, TransientVertex::degreesOfFreedom(), TransientVertex::isValid(), GlobalErrorBase< T, ErrorWeightType >::matrix(), TransientVertex::position(), TransientVertex::positionError(), TransientVertex::totalChiSquared(), HLT_2018_cff::track, groupFilesInBlocks::tt, and KalmanVertexFitter::vertex().

Referenced by analyzeTrackCollection(), and setVal().

409  {
410  using namespace edm;
411  using namespace reco;
412 
413  std::vector<TransientTrack> t_tks;
414  for (TrackCollection::const_iterator track = hTrackColl->begin(); track != hTrackColl->end(); ++track) {
415  TransientTrack tt = theTTBuilder->build(&(*track));
416  t_tks.push_back(tt);
417  }
418 
419  // Kalman vertex fit without constraint
420  KalmanVertexFitter vtxFitter;
421  TransientVertex stdVertex = vtxFitter.vertex(t_tks);
422  fitOk = stdVertex.isValid();
423  if (fitOk) {
424  reco::Vertex stdRecoVertex(Vertex::Point(stdVertex.position()),
425  stdVertex.positionError().matrix(),
426  stdVertex.totalChiSquared(),
427  stdVertex.degreesOfFreedom(),
428  0);
429  return stdRecoVertex;
430  } else {
431  reco::Vertex stdRecoVertex;
432  return stdRecoVertex;
433  }
434 }
GlobalError positionError() const
const AlgebraicSymMatrix33 matrix() const
float totalChiSquared() const
reco::TransientTrack build(const reco::Track *p) const
float degreesOfFreedom() const
GlobalPoint position() const
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
fixed size matrix
HLT enums.
bool isValid() const
void HIPTwoBodyDecayAnalyzer::initializeBranches ( )
private

Definition at line 141 of file HIPTwoBodyDecayAnalyzer.cc.

References floatBranches, intBranches, and shortBranches.

Referenced by analyze(), and setVal().

141  {
142  for (unsigned short el = 0; el < shortBranches.size(); el++) {
143  if (shortBranches.at(el).second != nullptr)
144  *(shortBranches.at(el).second) = 0;
145  }
146  for (unsigned int el = 0; el < intBranches.size(); el++) {
147  if (intBranches.at(el).second != nullptr)
148  *(intBranches.at(el).second) = 0;
149  }
150  for (unsigned int el = 0; el < floatBranches.size(); el++) {
151  if (floatBranches.at(el).second != nullptr)
152  *(floatBranches.at(el).second) = 0;
153  }
154 }
std::vector< std::pair< std::string, short * > > shortBranches
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches
HIPTwoBodyDecayAnalyzer::BranchType HIPTwoBodyDecayAnalyzer::searchArray ( std::string  branchname,
int &  position 
)
private

Definition at line 100 of file HIPTwoBodyDecayAnalyzer.cc.

References BranchType_float_t, BranchType_int_t, BranchType_short_t, BranchType_unknown_t, floatBranches, intBranches, and shortBranches.

Referenced by setVal().

100  {
101  for (unsigned short el = 0; el < shortBranches.size(); el++) {
102  if (branchname == shortBranches.at(el).first) {
103  position = el;
104  return BranchType_short_t;
105  }
106  }
107  for (unsigned int el = 0; el < intBranches.size(); el++) {
108  if (branchname == intBranches.at(el).first) {
109  position = el;
110  return BranchType_int_t;
111  }
112  }
113  for (unsigned int el = 0; el < floatBranches.size(); el++) {
114  if (branchname == floatBranches.at(el).first) {
115  position = el;
116  return BranchType_float_t;
117  }
118  }
119  return BranchType_unknown_t;
120 }
std::vector< std::pair< std::string, short * > > shortBranches
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches
static int position[264][3]
Definition: ReadPGInfo.cc:289
template<typename varType >
void HIPTwoBodyDecayAnalyzer::setVal ( std::string  bname,
varType  value 
)
inlineprivate

Definition at line 60 of file HIPTwoBodyDecayAnalyzer.cc.

References actuateBranches(), analyzeTrackCollection(), BranchType_float_t, BranchType_int_t, BranchType_short_t, beam_dqm_sourceclient-live_cfg::cerr, cleanBranches(), fitDimuonVertex(), initializeBranches(), searchArray(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyzeTrackCollection().

60  {
61  int varposition = -1;
62  BranchType varbranchtype = searchArray(bname, varposition);
63  if (varposition == -1)
64  std::cerr << "HIPTwoBodyDecayAnalyzer::setVal -> Could not find the branch called " << bname << "!" << std::endl;
65  else if (varbranchtype == BranchType_short_t)
66  *(shortBranches.at(varposition).second) = value;
67  else if (varbranchtype == BranchType_int_t)
68  *(intBranches.at(varposition).second) = value;
69  else if (varbranchtype == BranchType_float_t)
70  *(floatBranches.at(varposition).second) = value;
71  else
72  std::cerr << "HIPTwoBodyDecayAnalyzer::setVal -> Could not find the type " << varbranchtype
73  << " for branch called " << bname << "!" << std::endl;
74  }
std::vector< std::pair< std::string, short * > > shortBranches
BranchType
Definition: BranchType.h:11
std::vector< std::pair< std::string, float * > > floatBranches
Definition: value.py:1
std::vector< std::pair< std::string, int * > > intBranches
BranchType searchArray(std::string branchname, int &position)

Member Data Documentation

edm::EDGetTokenT<reco::TrackCollection> HIPTwoBodyDecayAnalyzer::alcareco_trackCollToken_

Definition at line 37 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

edm::EDGetTokenT<reco::TrackCollection> HIPTwoBodyDecayAnalyzer::ctf_trackCollToken_

Definition at line 39 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

edm::EDGetTokenT<reco::TrackCollection> HIPTwoBodyDecayAnalyzer::final_trackCollToken_

Definition at line 40 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

std::vector<std::pair<std::string, float*> > HIPTwoBodyDecayAnalyzer::floatBranches
std::vector<std::pair<std::string, int*> > HIPTwoBodyDecayAnalyzer::intBranches
edm::EDGetTokenT<reco::TrackCollection> HIPTwoBodyDecayAnalyzer::refit1_trackCollToken_

Definition at line 38 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

std::vector<std::pair<std::string, short*> > HIPTwoBodyDecayAnalyzer::shortBranches
TTree* HIPTwoBodyDecayAnalyzer::tree