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
 
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)
 
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 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 33 of file HIPTwoBodyDecayAnalyzer.cc.

Member Enumeration Documentation

Constructor & Destructor Documentation

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

Definition at line 94 of file HIPTwoBodyDecayAnalyzer.cc.

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

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 }
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 220 of file HIPTwoBodyDecayAnalyzer.cc.

References cleanBranches().

220  {
221  cleanBranches();
222 }

Member Function Documentation

bool HIPTwoBodyDecayAnalyzer::actuateBranches ( )
private

Definition at line 190 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by bookAllBranches(), and setVal().

190  {
191  bool success=true;
192  std::cout << "Begin HIPTwoBodyDecayAnalyzer::actuateBranches" << std::endl;
193  std::cout << "Number of short branches: " << shortBranches.size() << std::endl;
194  std::cout << "Number of int branches: " << intBranches.size() << std::endl;
195  std::cout << "Number of float branches: " << floatBranches.size() << std::endl;
196  if (tree!=nullptr){
197  for (unsigned short el=0; el<shortBranches.size(); el++){
198  std::cout << "Actuating branch " << shortBranches.at(el).first << " at address " << shortBranches.at(el).second << std::endl;
199  if (!tree->GetBranchStatus(shortBranches.at(el).first.c_str()))
200  tree->Branch(shortBranches.at(el).first.c_str(), shortBranches.at(el).second);
201  else std::cout << "Failed!" << std::endl;
202  }
203  for (unsigned int el=0; el<intBranches.size(); el++){
204  std::cout << "Actuating branch " << intBranches.at(el).first.c_str() << " at address " << intBranches.at(el).second << std::endl;
205  if (!tree->GetBranchStatus(intBranches.at(el).first.c_str()))
206  tree->Branch(intBranches.at(el).first.c_str(), intBranches.at(el).second);
207  else std::cout << "Failed!" << std::endl;
208  }
209  for (unsigned int el=0; el<floatBranches.size(); el++){
210  std::cout << "Actuating branch " << floatBranches.at(el).first.c_str() << " at address " << floatBranches.at(el).second << std::endl;
211  if (!tree->GetBranchStatus(floatBranches.at(el).first.c_str()))
212  tree->Branch(floatBranches.at(el).first.c_str(), floatBranches.at(el).second);
213  else std::cout << "Failed!" << std::endl;
214  }
215  }
216  else success=false;
217  if (!success) std::cerr << "HIPTwoBodyDecayAnalyzer::actuateBranch: Failed to actuate the branches!" << std::endl;
218  return success;
219 }
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 224 of file HIPTwoBodyDecayAnalyzer.cc.

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

224  {
225  using namespace edm;
226  using namespace reco;
227  using reco::TrackCollection;
228 
229  edm::Handle<reco::TrackCollection> alcarecotracks;
230  iEvent.getByToken(alcareco_trackCollToken_, alcarecotracks);
232  iEvent.getByToken(refit1_trackCollToken_, refit1tracks);
234  iEvent.getByToken(ctf_trackCollToken_, ctftracks);
236  iEvent.getByToken(final_trackCollToken_, finaltracks);
237 
239  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", theTTBuilder);
240 
242 
243  analyzeTrackCollection("alcareco", theTTBuilder, alcarecotracks);
244  analyzeTrackCollection("refit1", theTTBuilder, refit1tracks);
245  analyzeTrackCollection("refit2", theTTBuilder, ctftracks);
246  analyzeTrackCollection("final", theTTBuilder, finaltracks);
247 
248  tree->Fill();
249 }
edm::EDGetTokenT< reco::TrackCollection > refit1_trackCollToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
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_
const T & get() const
Definition: EventSetup.h:59
fixed size matrix
HLT enums.
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 260 of file HIPTwoBodyDecayAnalyzer.cc.

References TransientTrackBuilder::build(), MessageLogger_cfi::cerr, ALCARECOTkAlJpsiMuMu_cff::charge, RecoVertex::convertPos(), gather_cfg::cout, reco::TransientTrack::field(), fitDimuonVertex(), reco::TransientTrack::impactPointState(), edm::HandleBase::isValid(), PV3DBase< T, PVType, FrameType >::mag(), colinearityKinematic::Phi, funct::pow(), reco::tau::disc::Pt(), setVal(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, HiIsolationCommonParameters_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().

260  {
261  if (verbose) std::cout << "Starting to process the track collection for " << strTrackType << std::endl;
262 
263  using namespace edm;
264  using namespace reco;
265  using reco::TrackCollection;
266 
267  if (!hTrackColl.isValid()){
268  if (verbose) std::cout << "Track collection is invalid." << std::endl;
269  return;
270  }
271  if (hTrackColl->size()<2){
272  if (verbose) std::cout << "Track collection size<2." << std::endl;
273  return;
274  }
275 
276  unsigned int itrk=0;
277  unsigned int j=0;
278  int totalcharge=0;
279  bool isValidPair=true;
280  bool ZVtxOk=false;
281  TLorentzVector trackMom[2];
282  TLorentzVector trackMomAfterZVtxFit[2];
283  TVector3 trackVtx[2];
284 
285  for (unsigned int jtrk=0; jtrk<2; jtrk++){
286  trackMom[jtrk].SetXYZT(0, 0, 0, 0);
287  trackVtx[jtrk].SetXYZ(0, 0, 0);
288  }
289  for (reco::TrackCollection::const_iterator track = hTrackColl->begin(); track != hTrackColl->end(); ++track){
290  int charge = track->charge();
291  totalcharge += charge;
292  if (j==0){
293  itrk = (charge>0 ? 1 : 0);
294  }
295  else itrk = 1-itrk;
296  trackMom[itrk].SetPtEtaPhiM(track->pt(), track->eta(), track->phi(), 0.105);
297  trackVtx[itrk].SetXYZ(track->vx(), track->vy(), track->vz());
298  j++;
299  if (j==2) break;
300  }
301 
302  isValidPair = (totalcharge==0 && trackMom[0].P()!=0. && trackMom[1].P()!=0.);
303  if (verbose && !isValidPair) std::cout << "Track collection does not contain a valid std::pair." << std::endl;
304  setVal(strTrackType + "_present", (isValidPair ? (short)1 : (short)0));
305  if (isValidPair){
306  TLorentzVector ZMom = trackMom[0] + trackMom[1];
307  setVal(strTrackType + "_ZPt", (float)ZMom.Pt());
308  setVal(strTrackType + "_ZPz", (float)ZMom.Pz());
309  setVal(strTrackType + "_ZPhi", (float)ZMom.Phi());
310  setVal(strTrackType + "_ZMass", (float)ZMom.M());
311 
312  reco::Vertex ZVtx = fitDimuonVertex(theTTBuilder, hTrackColl, ZVtxOk);
313  if (ZVtxOk){
314  setVal(strTrackType + "_ZVertex_x", (float)ZVtx.x());
315  setVal(strTrackType + "_ZVertex_y", (float)ZVtx.y());
316  setVal(strTrackType + "_ZVertex_z", (float)ZVtx.z());
317  setVal(strTrackType + "_ZVertex_NormChi2", (float)ZVtx.normalizedChi2());
318 
319  // Recalculate track momenta with this vertex as reference
320  j=0;
321  for (reco::TrackCollection::const_iterator track = hTrackColl->begin(); track != hTrackColl->end(); ++track){
322  TransientTrack t_track = theTTBuilder->build(&(*track));
323  AnalyticalImpactPointExtrapolator extrapolator(t_track.field());
324  TrajectoryStateOnSurface closestIn3DSpaceState = extrapolator.extrapolate(t_track.impactPointState(), RecoVertex::convertPos(ZVtx.position()));
325  GlobalVector mom = closestIn3DSpaceState.globalMomentum();
326  int charge = track->charge();
327  totalcharge += charge;
328  if (j==0){
329  itrk = (charge>0 ? 1 : 0);
330  }
331  else itrk = 1-itrk;
332  trackMomAfterZVtxFit[itrk].SetXYZT(mom.x(), mom.y(), mom.z(), sqrt(pow(0.105, 2) + pow(mom.mag(), 2)));
333  j++;
334  if (j==2) break;
335  }
336  if (totalcharge!=0) std::cerr << "HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Something went wrong! The total charge is no longer 0!" << std::endl;
337  for (unsigned int jtrk=0; jtrk<2; jtrk++){
338  std::string strMuCore = (jtrk==0 ? "MuMinus" : "MuPlus");
339  setVal(strTrackType + "_" + strMuCore + "Pt_AfterZVtxFit", (float)trackMomAfterZVtxFit[jtrk].Pt());
340  setVal(strTrackType + "_" + strMuCore + "Pz_AfterZVtxFit", (float)trackMomAfterZVtxFit[jtrk].Pz());
341  setVal(strTrackType + "_" + strMuCore + "Phi_AfterZVtxFit", (float)trackMomAfterZVtxFit[jtrk].Phi());
342  }
343  TLorentzVector ZMom_AfterZVtxFit = trackMomAfterZVtxFit[0] + trackMomAfterZVtxFit[1];
344  setVal(strTrackType + "_ZPt_AfterZVtxFit", (float)ZMom_AfterZVtxFit.Pt());
345  setVal(strTrackType + "_ZPz_AfterZVtxFit", (float)ZMom_AfterZVtxFit.Pz());
346  setVal(strTrackType + "_ZPhi_AfterZVtxFit", (float)ZMom_AfterZVtxFit.Phi());
347  setVal(strTrackType + "_ZMass_AfterZVtxFit", (float)ZMom_AfterZVtxFit.M());
348  }
349  else std::cerr << "HIPTwoBodyDecayAnalyzer::analyzeTrackCollection: Z vertex fit failed for track collection " << strTrackType << std::endl;
350  }
351  setVal(strTrackType + "_ZVtxFitOk", (ZVtxOk ? (short)1 : (short)0));
352  for (unsigned int jtrk=0; jtrk<2; jtrk++){
353  std::string strMuCore = (jtrk==0 ? "MuMinus" : "MuPlus");
354  setVal(strTrackType + "_" + strMuCore + "Pt", (float)trackMom[jtrk].Pt());
355  setVal(strTrackType + "_" + strMuCore + "Pz", (float)trackMom[jtrk].Pz());
356  setVal(strTrackType + "_" + strMuCore + "Phi", (float)trackMom[jtrk].Phi());
357  setVal(strTrackType + "_" + strMuCore + "Vertex_x", (float)trackVtx[jtrk].X());
358  setVal(strTrackType + "_" + strMuCore + "Vertex_y", (float)trackVtx[jtrk].Y());
359  setVal(strTrackType + "_" + strMuCore + "Vertex_z", (float)trackVtx[jtrk].Z());
360  }
361 }
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:63
#define X(str)
Definition: MuonsGrabber.cc:48
const MagneticField * field() const
void setVal(std::string bname, varType value)
T mag() const
Definition: PV3DBase.h:67
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
bool isValid() const
Definition: HandleBase.h:74
fixed size matrix
HLT enums.
TrajectoryStateOnSurface impactPointState() const
T x() const
Definition: PV3DBase.h:62
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void HIPTwoBodyDecayAnalyzer::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 251 of file HIPTwoBodyDecayAnalyzer.cc.

251 {}
void HIPTwoBodyDecayAnalyzer::bookAllBranches ( )
private

Definition at line 157 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by HIPTwoBodyDecayAnalyzer().

157  {
158  const int nTrackTypes = 4;
159  std::vector<std::string> strTrackTypes; 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); bookBranch(strTrackType + "_ZPt", BranchType_float_t); bookBranch(strTrackType + "_ZPz", BranchType_float_t); bookBranch(strTrackType + "_ZPhi", BranchType_float_t);
169  bookBranch(strTrackType + "_ZVertex_x", BranchType_float_t); bookBranch(strTrackType + "_ZVertex_y", BranchType_float_t); bookBranch(strTrackType + "_ZVertex_z", BranchType_float_t); bookBranch(strTrackType + "_ZVertex_NormChi2", BranchType_float_t);
170  bookBranch(strTrackType + "_MuPlusVertex_x", BranchType_float_t); bookBranch(strTrackType + "_MuPlusVertex_y", BranchType_float_t); bookBranch(strTrackType + "_MuPlusVertex_z", BranchType_float_t);
171  bookBranch(strTrackType + "_MuMinusPt_AfterZVtxFit", BranchType_float_t); bookBranch(strTrackType + "_MuMinusPz_AfterZVtxFit", BranchType_float_t); bookBranch(strTrackType + "_MuMinusPhi_AfterZVtxFit", BranchType_float_t);
172  bookBranch(strTrackType + "_MuPlusPt_AfterZVtxFit", BranchType_float_t); bookBranch(strTrackType + "_MuPlusPz_AfterZVtxFit", BranchType_float_t); bookBranch(strTrackType + "_MuPlusPhi_AfterZVtxFit", BranchType_float_t);
173  bookBranch(strTrackType + "_ZMass_AfterZVtxFit", BranchType_float_t); bookBranch(strTrackType + "_ZPt_AfterZVtxFit", BranchType_float_t); bookBranch(strTrackType + "_ZPz_AfterZVtxFit", BranchType_float_t); bookBranch(strTrackType + "_ZPhi_AfterZVtxFit", BranchType_float_t);
174  bookBranch(strTrackType + "_MuMinusPt", BranchType_float_t); bookBranch(strTrackType + "_MuMinusPz", BranchType_float_t); bookBranch(strTrackType + "_MuMinusPhi", BranchType_float_t);
175  bookBranch(strTrackType + "_MuMinusVertex_x", BranchType_float_t); bookBranch(strTrackType + "_MuMinusVertex_y", BranchType_float_t); bookBranch(strTrackType + "_MuMinusVertex_z", BranchType_float_t);
176  bookBranch(strTrackType + "_MuPlusPt", BranchType_float_t); bookBranch(strTrackType + "_MuPlusPz", BranchType_float_t); bookBranch(strTrackType + "_MuPlusPhi", BranchType_float_t);
177  }
178  actuateBranches();
179 }
bool bookBranch(std::string bname, BranchType btype)
bool HIPTwoBodyDecayAnalyzer::bookBranch ( std::string  bname,
BranchType  btype 
)
private

Definition at line 180 of file HIPTwoBodyDecayAnalyzer.cc.

References BranchType_float_t, BranchType_int_t, BranchType_short_t, MessageLogger_cfi::cerr, floatBranches, intBranches, and shortBranches.

Referenced by bookAllBranches().

180  {
181  if (btype==BranchType_float_t) floatBranches.emplace_back(bname, new float);
182  else if (btype==BranchType_int_t) intBranches.emplace_back(bname, new int);
183  else if (btype==BranchType_short_t) shortBranches.emplace_back(bname, new short);
184  else{
185  std::cerr << "HIPTwoBodyDecayAnalyzer::bookBranch: No support for type " << btype << " for the branch " << bname << " is available." << std::endl;
186  return false;
187  }
188  return true;
189 }
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 128 of file HIPTwoBodyDecayAnalyzer.cc.

References floatBranches, intBranches, and shortBranches.

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

128  {
129  for (unsigned short el=0; el<shortBranches.size(); el++){
130  if (shortBranches.at(el).second!=nullptr) 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) delete intBranches.at(el).second;
136  intBranches.at(el).second=nullptr;
137  }
138  intBranches.clear();
139  for (unsigned int el=0; el<floatBranches.size(); el++){
140  if (floatBranches.at(el).second!=nullptr) delete floatBranches.at(el).second;
141  floatBranches.at(el).second=nullptr;
142  }
143  floatBranches.clear();
144 }
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 252 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

252 {}
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 363 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by analyzeTrackCollection(), and setVal().

363  {
364  using namespace edm;
365  using namespace reco;
366 
367  std::vector<TransientTrack> t_tks;
368  for (TrackCollection::const_iterator track = hTrackColl->begin(); track != hTrackColl->end(); ++track){
369  TransientTrack tt = theTTBuilder->build(&(*track));
370  t_tks.push_back(tt);
371  }
372 
373  // Kalman vertex fit without constraint
374  KalmanVertexFitter vtxFitter;
375  TransientVertex stdVertex = vtxFitter.vertex(t_tks);
376  fitOk = stdVertex.isValid();
377  if (fitOk){
378  reco::Vertex stdRecoVertex(
379  Vertex::Point(stdVertex.position()), stdVertex.positionError().matrix(),
380  stdVertex.totalChiSquared(), stdVertex.degreesOfFreedom(), 0
381  );
382  return stdRecoVertex;
383  }
384  else{
385  reco::Vertex stdRecoVertex;
386  return stdRecoVertex;
387  }
388 }
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 145 of file HIPTwoBodyDecayAnalyzer.cc.

References floatBranches, intBranches, and shortBranches.

Referenced by analyze(), and setVal().

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

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

Referenced by setVal().

107  {
108  for (unsigned short el=0; el<shortBranches.size(); el++){
109  if (branchname==shortBranches.at(el).first){
110  position = el;
111  return BranchType_short_t;
112  }
113  }
114  for (unsigned int el=0; el<intBranches.size(); el++){
115  if (branchname==intBranches.at(el).first){
116  position = el;
117  return BranchType_int_t;
118  }
119  }
120  for (unsigned int el=0; el<floatBranches.size(); el++){
121  if (branchname==floatBranches.at(el).first){
122  position = el;
123  return BranchType_float_t;
124  }
125  }
126  return BranchType_unknown_t;
127 }
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:509
template<typename varType >
void HIPTwoBodyDecayAnalyzer::setVal ( std::string  bname,
varType  value 
)
inlineprivate

Definition at line 67 of file HIPTwoBodyDecayAnalyzer.cc.

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

Referenced by analyzeTrackCollection().

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

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

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

Definition at line 41 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

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

Definition at line 42 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 40 of file HIPTwoBodyDecayAnalyzer.cc.

Referenced by analyze(), and HIPTwoBodyDecayAnalyzer().

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