CMS 3D CMS Logo

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

Public Member Functions

 HIPTwoBodyDecayAnalyzer (const edm::ParameterSet &)
 
 ~HIPTwoBodyDecayAnalyzer () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

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, const 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 (const 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)
 

Private Attributes

const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecordttkbuilderToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase 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)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (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 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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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

Definition at line 32 of file HIPTwoBodyDecayAnalyzer.cc.

Member Enumeration Documentation

◆ BranchType

Constructor & Destructor Documentation

◆ HIPTwoBodyDecayAnalyzer()

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

Definition at line 91 of file HIPTwoBodyDecayAnalyzer.cc.

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

92  : ttkbuilderToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))) {
93  usesResource(TFileService::kSharedResource);
94 
95  alcareco_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("alcarecotracks"));
96  refit1_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("refit1tracks"));
97  ctf_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("refit2tracks"));
98  final_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("finaltracks"));
99 
101 
102  tree = fs->make<TTree>("TestTree", "");
103  bookAllBranches();
104 }
static const std::string kSharedResource
Definition: TFileService.h:76
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::TrackCollection > refit1_trackCollToken_
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttkbuilderToken_
edm::EDGetTokenT< reco::TrackCollection > alcareco_trackCollToken_
Definition: tree.py:1
edm::EDGetTokenT< reco::TrackCollection > ctf_trackCollToken_
edm::EDGetTokenT< reco::TrackCollection > final_trackCollToken_

◆ ~HIPTwoBodyDecayAnalyzer()

HIPTwoBodyDecayAnalyzer::~HIPTwoBodyDecayAnalyzer ( )
override

Definition at line 258 of file HIPTwoBodyDecayAnalyzer.cc.

References cleanBranches().

Member Function Documentation

◆ actuateBranches()

bool HIPTwoBodyDecayAnalyzer::actuateBranches ( )
private

Definition at line 221 of file HIPTwoBodyDecayAnalyzer.cc.

References DMR_cfg::cerr, gather_cfg::cout, floatBranches, intBranches, shortBranches, and summarizeEdmComparisonLogfiles::success.

Referenced by bookAllBranches().

221  {
222  bool success = true;
223  std::cout << "Begin HIPTwoBodyDecayAnalyzer::actuateBranches" << std::endl;
224  std::cout << "Number of short branches: " << shortBranches.size() << std::endl;
225  std::cout << "Number of int branches: " << intBranches.size() << std::endl;
226  std::cout << "Number of float branches: " << floatBranches.size() << std::endl;
227  if (tree != nullptr) {
228  for (unsigned short el = 0; el < shortBranches.size(); el++) {
229  std::cout << "Actuating branch " << shortBranches.at(el).first << " at address " << shortBranches.at(el).second
230  << std::endl;
231  if (!tree->GetBranchStatus(shortBranches.at(el).first.c_str()))
232  tree->Branch(shortBranches.at(el).first.c_str(), shortBranches.at(el).second);
233  else
234  std::cout << "Failed!" << std::endl;
235  }
236  for (unsigned int el = 0; el < intBranches.size(); el++) {
237  std::cout << "Actuating branch " << intBranches.at(el).first.c_str() << " at address "
238  << intBranches.at(el).second << std::endl;
239  if (!tree->GetBranchStatus(intBranches.at(el).first.c_str()))
240  tree->Branch(intBranches.at(el).first.c_str(), intBranches.at(el).second);
241  else
242  std::cout << "Failed!" << std::endl;
243  }
244  for (unsigned int el = 0; el < floatBranches.size(); el++) {
245  std::cout << "Actuating branch " << floatBranches.at(el).first.c_str() << " at address "
246  << floatBranches.at(el).second << std::endl;
247  if (!tree->GetBranchStatus(floatBranches.at(el).first.c_str()))
248  tree->Branch(floatBranches.at(el).first.c_str(), floatBranches.at(el).second);
249  else
250  std::cout << "Failed!" << std::endl;
251  }
252  } else
253  success = false;
254  if (!success)
255  std::cerr << "HIPTwoBodyDecayAnalyzer::actuateBranch: Failed to actuate the branches!" << std::endl;
256  return success;
257 }
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

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 260 of file HIPTwoBodyDecayAnalyzer.cc.

References alcareco_trackCollToken_, analyzeTrackCollection(), ctf_trackCollToken_, final_trackCollToken_, edm::EventSetup::getData(), iEvent, initializeBranches(), refit1_trackCollToken_, and ttkbuilderToken_.

260  {
261  using namespace edm;
262  using namespace reco;
263  using reco::TrackCollection;
264 
265  edm::Handle<reco::TrackCollection> alcarecotracks;
266  iEvent.getByToken(alcareco_trackCollToken_, alcarecotracks);
268  iEvent.getByToken(refit1_trackCollToken_, refit1tracks);
270  iEvent.getByToken(ctf_trackCollToken_, ctftracks);
272  iEvent.getByToken(final_trackCollToken_, finaltracks);
273 
274  const auto& theTTBuilder = iSetup.getData(ttkbuilderToken_);
276 
277  analyzeTrackCollection("alcareco", theTTBuilder, alcarecotracks);
278  analyzeTrackCollection("refit1", theTTBuilder, refit1tracks);
279  analyzeTrackCollection("refit2", theTTBuilder, ctftracks);
280  analyzeTrackCollection("final", theTTBuilder, finaltracks);
281 
282  tree->Fill();
283 }
edm::EDGetTokenT< reco::TrackCollection > refit1_trackCollToken_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > ttkbuilderToken_
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::TrackCollection > alcareco_trackCollToken_
fixed size matrix
HLT enums.
Definition: tree.py:1
edm::EDGetTokenT< reco::TrackCollection > ctf_trackCollToken_
void analyzeTrackCollection(std::string strTrackType, const TransientTrackBuilder &theTTBuilder, edm::Handle< reco::TrackCollection > &hTrackColl, bool verbose=false)
edm::EDGetTokenT< reco::TrackCollection > final_trackCollToken_

◆ analyzeTrackCollection()

void HIPTwoBodyDecayAnalyzer::analyzeTrackCollection ( std::string  strTrackType,
const TransientTrackBuilder theTTBuilder,
edm::Handle< reco::TrackCollection > &  hTrackColl,
bool  verbose = false 
)
private

Definition at line 294 of file HIPTwoBodyDecayAnalyzer.cc.

References TransientTrackBuilder::build(), DMR_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_2024v13_cff::track, verbose, X, PV3DBase< T, PVType, FrameType >::x(), beamSpotPI::Y, PV3DBase< T, PVType, FrameType >::y(), beamSpotPI::Z, and PV3DBase< T, PVType, FrameType >::z().

Referenced by analyze().

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

◆ beginJob()

void HIPTwoBodyDecayAnalyzer::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 285 of file HIPTwoBodyDecayAnalyzer.cc.

285 {}

◆ bookAllBranches()

void HIPTwoBodyDecayAnalyzer::bookAllBranches ( )
private

Definition at line 162 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by HIPTwoBodyDecayAnalyzer().

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

◆ bookBranch()

bool HIPTwoBodyDecayAnalyzer::bookBranch ( std::string  bname,
BranchType  btype 
)
private

Definition at line 207 of file HIPTwoBodyDecayAnalyzer.cc.

References BranchType_float_t, BranchType_int_t, BranchType_short_t, CalibrationSummaryClient_cfi::btype, DMR_cfg::cerr, floatBranches, intBranches, and shortBranches.

Referenced by bookAllBranches().

207  {
208  if (btype == BranchType_float_t)
209  floatBranches.emplace_back(bname, new float);
210  else if (btype == BranchType_int_t)
211  intBranches.emplace_back(bname, new int);
212  else if (btype == BranchType_short_t)
213  shortBranches.emplace_back(bname, new short);
214  else {
215  std::cerr << "HIPTwoBodyDecayAnalyzer::bookBranch: No support for type " << btype << " for the branch " << bname
216  << " is available." << std::endl;
217  return false;
218  }
219  return true;
220 }
std::vector< std::pair< std::string, short * > > shortBranches
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches

◆ cleanBranches()

void HIPTwoBodyDecayAnalyzer::cleanBranches ( )
private

Definition at line 127 of file HIPTwoBodyDecayAnalyzer.cc.

References floatBranches, intBranches, and shortBranches.

Referenced by ~HIPTwoBodyDecayAnalyzer().

127  {
128  for (unsigned short el = 0; el < shortBranches.size(); el++) {
129  if (shortBranches.at(el).second != nullptr)
130  delete shortBranches.at(el).second;
131  shortBranches.at(el).second = nullptr;
132  }
133  shortBranches.clear();
134  for (unsigned int el = 0; el < intBranches.size(); el++) {
135  if (intBranches.at(el).second != nullptr)
136  delete intBranches.at(el).second;
137  intBranches.at(el).second = nullptr;
138  }
139  intBranches.clear();
140  for (unsigned int el = 0; el < floatBranches.size(); el++) {
141  if (floatBranches.at(el).second != nullptr)
142  delete floatBranches.at(el).second;
143  floatBranches.at(el).second = nullptr;
144  }
145  floatBranches.clear();
146 }
std::vector< std::pair< std::string, short * > > shortBranches
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches

◆ endJob()

void HIPTwoBodyDecayAnalyzer::endJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 286 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

286 {}

◆ fillDescriptions()

void HIPTwoBodyDecayAnalyzer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 288 of file HIPTwoBodyDecayAnalyzer.cc.

References edm::ConfigurationDescriptions::addDefault(), and submitPVResolutionJobs::desc.

288  {
290  desc.setUnknown();
291  descriptions.addDefault(desc);
292 }
void addDefault(ParameterSetDescription const &psetDescription)

◆ fitDimuonVertex()

reco::Vertex HIPTwoBodyDecayAnalyzer::fitDimuonVertex ( const TransientTrackBuilder theTTBuilder,
edm::Handle< reco::TrackCollection > &  hTrackColl,
bool &  fitOk 
)
private

Definition at line 411 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by analyzeTrackCollection().

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

◆ initializeBranches()

void HIPTwoBodyDecayAnalyzer::initializeBranches ( )
private

Definition at line 147 of file HIPTwoBodyDecayAnalyzer.cc.

References floatBranches, intBranches, and shortBranches.

Referenced by analyze().

147  {
148  for (unsigned short el = 0; el < shortBranches.size(); el++) {
149  if (shortBranches.at(el).second != nullptr)
150  *(shortBranches.at(el).second) = 0;
151  }
152  for (unsigned int el = 0; el < intBranches.size(); el++) {
153  if (intBranches.at(el).second != nullptr)
154  *(intBranches.at(el).second) = 0;
155  }
156  for (unsigned int el = 0; el < floatBranches.size(); el++) {
157  if (floatBranches.at(el).second != nullptr)
158  *(floatBranches.at(el).second) = 0;
159  }
160 }
std::vector< std::pair< std::string, short * > > shortBranches
std::vector< std::pair< std::string, float * > > floatBranches
std::vector< std::pair< std::string, int * > > intBranches

◆ searchArray()

HIPTwoBodyDecayAnalyzer::BranchType HIPTwoBodyDecayAnalyzer::searchArray ( std::string  branchname,
int &  position 
)
private

Definition at line 106 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by setVal().

106  {
107  for (unsigned short el = 0; el < shortBranches.size(); el++) {
108  if (branchname == shortBranches.at(el).first) {
109  position = el;
110  return BranchType_short_t;
111  }
112  }
113  for (unsigned int el = 0; el < intBranches.size(); el++) {
114  if (branchname == intBranches.at(el).first) {
115  position = el;
116  return BranchType_int_t;
117  }
118  }
119  for (unsigned int el = 0; el < floatBranches.size(); el++) {
120  if (branchname == floatBranches.at(el).first) {
121  position = el;
122  return BranchType_float_t;
123  }
124  }
125  return BranchType_unknown_t;
126 }
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

◆ setVal()

template<typename varType >
void HIPTwoBodyDecayAnalyzer::setVal ( std::string  bname,
varType  value 
)
inlineprivate

Definition at line 63 of file HIPTwoBodyDecayAnalyzer.cc.

References BranchType_float_t, BranchType_int_t, BranchType_short_t, DMR_cfg::cerr, floatBranches, intBranches, searchArray(), and shortBranches.

Referenced by analyzeTrackCollection().

63  {
64  int varposition = -1;
65  BranchType varbranchtype = searchArray(bname, varposition);
66  if (varposition == -1)
67  std::cerr << "HIPTwoBodyDecayAnalyzer::setVal -> Could not find the branch called " << bname << "!" << std::endl;
68  else if (varbranchtype == BranchType_short_t)
69  *(shortBranches.at(varposition).second) = value;
70  else if (varbranchtype == BranchType_int_t)
71  *(intBranches.at(varposition).second) = value;
72  else if (varbranchtype == BranchType_float_t)
73  *(floatBranches.at(varposition).second) = value;
74  else
75  std::cerr << "HIPTwoBodyDecayAnalyzer::setVal -> Could not find the type " << varbranchtype
76  << " for branch called " << bname << "!" << std::endl;
77  }
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

◆ alcareco_trackCollToken_

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

Definition at line 37 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

◆ ctf_trackCollToken_

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

Definition at line 39 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

◆ final_trackCollToken_

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

Definition at line 40 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

◆ floatBranches

std::vector<std::pair<std::string, float*> > HIPTwoBodyDecayAnalyzer::floatBranches

◆ intBranches

std::vector<std::pair<std::string, int*> > HIPTwoBodyDecayAnalyzer::intBranches

◆ refit1_trackCollToken_

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

Definition at line 38 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

◆ shortBranches

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

◆ tree

TTree* HIPTwoBodyDecayAnalyzer::tree

◆ ttkbuilderToken_

const edm::ESGetToken<TransientTrackBuilder, TransientTrackRecord> HIPTwoBodyDecayAnalyzer::ttkbuilderToken_
private

Definition at line 51 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze().