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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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 bookAllBranches ()
 
bool bookBranch (std::string bname, BranchType btype)
 
void cleanBranches ()
 
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 88 of file HIPTwoBodyDecayAnalyzer.cc.

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

89  : ttkbuilderToken_(esConsumes(edm::ESInputTag("", "TransientTrackBuilder"))) {
90  usesResource(TFileService::kSharedResource);
91 
92  alcareco_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("alcarecotracks"));
93  refit1_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("refit1tracks"));
94  ctf_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("refit2tracks"));
95  final_trackCollToken_ = consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("finaltracks"));
96 
98 
99  tree = fs->make<TTree>("TestTree", "");
100  bookAllBranches();
101 }
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 255 of file HIPTwoBodyDecayAnalyzer.cc.

References cleanBranches().

Member Function Documentation

◆ actuateBranches()

bool HIPTwoBodyDecayAnalyzer::actuateBranches ( )
private

Definition at line 218 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by bookAllBranches().

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

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

257  {
258  using namespace edm;
259  using namespace reco;
260  using reco::TrackCollection;
261 
262  edm::Handle<reco::TrackCollection> alcarecotracks;
263  iEvent.getByToken(alcareco_trackCollToken_, alcarecotracks);
265  iEvent.getByToken(refit1_trackCollToken_, refit1tracks);
267  iEvent.getByToken(ctf_trackCollToken_, ctftracks);
269  iEvent.getByToken(final_trackCollToken_, finaltracks);
270 
271  const auto& theTTBuilder = iSetup.getData(ttkbuilderToken_);
273 
274  analyzeTrackCollection("alcareco", theTTBuilder, alcarecotracks);
275  analyzeTrackCollection("refit1", theTTBuilder, refit1tracks);
276  analyzeTrackCollection("refit2", theTTBuilder, ctftracks);
277  analyzeTrackCollection("final", theTTBuilder, finaltracks);
278 
279  tree->Fill();
280 }
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 291 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_2024v14_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().

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

◆ bookAllBranches()

void HIPTwoBodyDecayAnalyzer::bookAllBranches ( )
private

Definition at line 159 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().

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

◆ bookBranch()

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

Definition at line 204 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by bookAllBranches().

204  {
205  if (btype == BranchType_float_t)
206  floatBranches.emplace_back(bname, new float);
207  else if (btype == BranchType_int_t)
208  intBranches.emplace_back(bname, new int);
209  else if (btype == BranchType_short_t)
210  shortBranches.emplace_back(bname, new short);
211  else {
212  std::cerr << "HIPTwoBodyDecayAnalyzer::bookBranch: No support for type " << btype << " for the branch " << bname
213  << " is available." << std::endl;
214  return false;
215  }
216  return true;
217 }
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 124 of file HIPTwoBodyDecayAnalyzer.cc.

References floatBranches, intBranches, and shortBranches.

Referenced by ~HIPTwoBodyDecayAnalyzer().

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

◆ fillDescriptions()

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

Definition at line 282 of file HIPTwoBodyDecayAnalyzer.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, and ProducerED_cfi::InputTag.

282  {
284  desc.add<edm::InputTag>("alcarecotracks", edm::InputTag("ALCARECOTkAlZMuMu"));
285  desc.add<edm::InputTag>("refit1tracks", edm::InputTag("FirstTrackRefitter"));
286  desc.add<edm::InputTag>("refit2tracks", edm::InputTag("HitFilteredTracksTrackFitter"));
287  desc.add<edm::InputTag>("finaltracks", edm::InputTag("FinalTrackRefitter"));
288  descriptions.addWithDefaultLabel(desc);
289 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ fitDimuonVertex()

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

Definition at line 408 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by analyzeTrackCollection().

410  {
411  using namespace edm;
412  using namespace reco;
413 
414  std::vector<TransientTrack> t_tks;
415  for (TrackCollection::const_iterator track = hTrackColl->begin(); track != hTrackColl->end(); ++track) {
416  TransientTrack tt = theTTBuilder.build(&(*track));
417  t_tks.push_back(tt);
418  }
419 
420  // Kalman vertex fit without constraint
421  KalmanVertexFitter vtxFitter;
422  TransientVertex stdVertex = vtxFitter.vertex(t_tks);
423  fitOk = stdVertex.isValid();
424  if (fitOk) {
425  reco::Vertex stdRecoVertex(Vertex::Point(stdVertex.position()),
426  stdVertex.positionError().matrix(),
427  stdVertex.totalChiSquared(),
428  stdVertex.degreesOfFreedom(),
429  0);
430  return stdRecoVertex;
431  } else {
432  reco::Vertex stdRecoVertex;
433  return stdRecoVertex;
434  }
435 }
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 144 of file HIPTwoBodyDecayAnalyzer.cc.

References floatBranches, intBranches, and shortBranches.

Referenced by analyze().

144  {
145  for (unsigned short el = 0; el < shortBranches.size(); el++) {
146  if (shortBranches.at(el).second != nullptr)
147  *(shortBranches.at(el).second) = 0;
148  }
149  for (unsigned int el = 0; el < intBranches.size(); el++) {
150  if (intBranches.at(el).second != nullptr)
151  *(intBranches.at(el).second) = 0;
152  }
153  for (unsigned int el = 0; el < floatBranches.size(); el++) {
154  if (floatBranches.at(el).second != nullptr)
155  *(floatBranches.at(el).second) = 0;
156  }
157 }
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 103 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by setVal().

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

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

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

◆ 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().