StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StV0TofCorrection.h
Go to the documentation of this file.
1 // $Id: StV0TofCorrection.h,v 1.2 2014/01/20 16:55:50 geurts Exp $
8 // ---
9 // $Log: StV0TofCorrection.h,v $
10 // Revision 1.2 2014/01/20 16:55:50 geurts
11 // Major update by Patrick Huck:
12 // - fixed memory leaks, clean-up
13 // - switch from a custom closest-points-of-approach-finder to the StHelix::pathLengths()
14 // - added a public helper function calcM2() to calculate mass^2 after TOF correction
15 //
16 // Revision 1.1 2011/01/24 21:01:49 geurts
17 // *** empty log message ***
18 //
19 // ---
20 #ifndef STV0TOFCORRECTION_H
21 #define STV0TOFCORRECTION_H
22 
23 #include <stdio.h>
24 #include <stdarg.h>
25 
26 #include <TROOT.h>
27 #include "TMath.h"
28 #include "StPhysicalHelixD.hh"
29 #include "StarClassLibrary/StLorentzVectorD.hh"
30 #include "StarClassLibrary/StThreeVectorD.hh"
31 #include <iostream>
32 #include "TVirtualStreamerInfo.h"
33 
34 #include <vector>
35 #include <map>
36 
38 
39 template < class T, class container = std::vector<T> >
40 class StInlineContainer : public container {
41  private:
42  Int_t NrArgs;
43  StInlineContainer<T>* pContainer;
44 
45  public:
46  StInlineContainer() { NrArgs = 0; pContainer = NULL; }
47  virtual ~StInlineContainer() {}
49  explicit StInlineContainer(const T vec) : container(1,vec) { }
50  StInlineContainer<T> operator()(const T vec) {
52  NrArgs++;
53  pContainer->setNrArgs(NrArgs);
54  pContainer->push_back(vec);
55  return *pContainer;
56  }
58  void setNrArgs(const Int_t& c) { NrArgs = c; }
60  Int_t getNrArgs() { return NrArgs; }
62  void setPointer2Container(StInlineContainer<T>* p) { pContainer = p; }
63 };
64 
65 typedef std::map< std::string, std::pair<float, float> > M2CutType;
66 
68 
71  private:
73  inline Float_t calcTof(const StLorentzVectorD&, const Float_t&);
75  inline Bool_t inputOk();
77  inline Bool_t cutOnMass2(const Float_t&, const std::string&);
78 
79  Float_t clight;
80  Bool_t cleared, cleared2;
81  Int_t NrDecays;
84 
86  static M2CutType createM2CutMap() {
87  M2CutType m;
88  m["pi"] = std::make_pair(0.015, 0.025);
89  m["K"] = std::make_pair(0.2, 0.3);
90  m["p"] = std::make_pair(0.8085, 1.15);
91  return m;
92  }
93 
94  public:
96  virtual ~StV0TofCorrection() ;
97 
100  if ( cleared ) {
101  Vectors3D = new StInlineContainer<StThreeVectorD>;
102  }
103  else {
104  const char* err_msg =
105  "Make sure to call clearContainers() function"
106  "every time a correction of a particle is done!"
107  "Otherwise you're using the same container over and over again!";
108  Error("StV0TofCorrection::setVectors3D", err_msg);
109  }
110  Vectors3D->setNrArgs(0);
111  Vectors3D->setPointer2Container(Vectors3D);
112  cleared = kFALSE;
113  return (*Vectors3D)(vec);
114  }
115 
118  if ( cleared2 ) {
120  tracks->setNrArgs(0);
121  tracks->setPointer2Container(tracks);
122  cleared2 = kFALSE;
123  return (*tracks)(tr);
124  }
125  else {
126  Error(
127  "StV0TofCorrection::setMotherTracks",
128  "Again: Don't forget clearContainers()!"
129  );
130  return (*tracks);
131  }
132  }
133 
135  Bool_t correctBeta(
136  const StPhysicalHelixD&, const Float_t&, Float_t&,
137  const Float_t& MomentumA = -999.,
138  const std::string& particle = ""
139  );
140 
142  // (free allocated memory and set pointers to NULL)
144  delete Vectors3D; delete tracks;
145  Vectors3D = NULL; tracks = NULL;
146  cleared = kTRUE; cleared2 = kTRUE;
147  }
148 
150  inline Float_t calcM2(const Float_t& mom, const Float_t& beta) {
151  Float_t f2 = 1./(beta*beta) - 1.;
152  return mom*mom * f2;
153  }
154 
156  static M2CutType mM2CutMap;
157 
158  ClassDef(StV0TofCorrection,1)
159 };
160 #endif
Definition: FJcore.h:367
void setNrArgs(const Int_t &c)
setter for number of arguments
Float_t calcM2(const Float_t &mom, const Float_t &beta)
helper function to calculate m2 from momentum &amp; beta
StInlineContainer< T > operator()(const T vec)
operater () overloaded for filling container
Int_t getNrArgs()
getter for number of arguments
StInlineContainer< StLorentzVectorD > setMotherTracks(const StLorentzVectorD tr)
function for initialization of mother tracks container
void clearContainers()
function for finalization by destroying containers
StInlineContainer(const T vec)
explicit constructor
virtual ~StV0TofCorrection()
destructor
void setPointer2Container(StInlineContainer< T > *p)
set pointer to container
template class defining an inline container
StInlineContainer< StThreeVectorD > setVectors3D(const StThreeVectorD vec)
function for initialization of 3d-vectors container
static M2CutType mM2CutMap
default m2 cuts
StV0TofCorrection()
constructor
Bool_t correctBeta(const StPhysicalHelixD &, const Float_t &, Float_t &, const Float_t &MomentumA=-999., const std::string &particle="")
main function for beta correction
A class providing tools to correct the time of flight of V0 particles.