StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFwdQAMaker.h
1 #ifndef ST_FWD_TREE_MAKER_H
2 #define ST_FWD_TREE_MAKER_H
3 
4 #include "TClonesArray.h"
5 #ifndef __CINT__
6 #include "GenFit/Track.h"
7 #include "StFwdTrackMaker/include/Tracker/FwdHit.h"
8 #include "StMuDSTMaker/COMMON/StMuFwdTrack.h"
9 #endif
10 
11 #include "StChain/StMaker.h"
12 #include "TTree.h"
13 #include "TVector3.h"
14 #include "TLorentzVector.h"
15 #include "StEvent/StEnumerations.h"
16 #include "StThreeVectorD.hh"
17 
18 #include <map>
19 
20 class StMuFwdTrack;
22 class ForwardTracker;
23 class StFwdTrack;
24 class StMuMcTrack;
25 
29 template<class BranchType>
31  public:
33  ~TClonesArrayWriter() {}
34 
35  void createBranch( TTree *tree, const char* name, int buffSize = 256000, int splitLevel = 99){
36  _tca = new TClonesArray( BranchType::Class_Name() );
37  tree->Branch( name, &this->_tca, buffSize, splitLevel );
38  }
39 
40  void add( BranchType &branch ){
41  if ( nullptr == this->_tca ) return;
42  BranchType *new_branch = new ((*this->_tca)[this->_n]) BranchType( );
43  *new_branch = branch;
44  this->_n++;
45  }
46 
47  void add( BranchType *branch ){
48  if ( nullptr == this->_tca || nullptr == branch) return;
49  BranchType *new_branch = new ((*this->_tca)[this->_n]) BranchType( );
50  *new_branch = *branch;
51  this->_n++;
52  }
53 
54  void reset(){
55  this->_n = 0;
56  if( nullptr != this->_tca )
57  this->_tca->Clear();
58  }
59 
60  UInt_t N() const { return _n; }
61  BranchType *at( UInt_t i ){
62  if ( nullptr == _tca )
63  return nullptr;
64  return (BranchType*)_tca->At( i );
65  }
66 
67  protected:
68  TClonesArray * _tca = nullptr;
69  UInt_t _n = 0;
70 };
71 
72 class FwdTreeHeader : public TObject {
73  public:
74  FwdTreeHeader() : TObject() {
75  run = 0;
76  event = 0;
77  tofmult = 0;
78  vpdVz = -999;
79  pv.SetXYZ(0, 0, 0);
80  }
81 
82  void set( int r, int e, int t, TVector3 &p ){
83  run = r;
84  event = e;
85  tofmult = t;
86  pv = p;
87  }
88 
89  void clear() {
90  run = 0;
91  event = 0;
92  tofmult = 0;
93  TVector3 pv(-999, -999, -999);
94  vpdVz = -999;
95  }
96 
97  TVector3 pv;
98  int run, event, tofmult;
99  float vpdVz;
100 
101  ClassDef(FwdTreeHeader, 1)
102 };
103 
104 class StFcsDb;
105 class StFcsCluster;
106 class StFcsHit;
107 class StMuFcsCluster;
108 class StMuFcsHit;
109 class StMuFttCluster;
110 class StMuFttPoint;
111 class StMuFstHit;
113 
114 
119 class FcsClusterWithStarXYZ: public TObject {
120  public:
122  mXYZ.SetXYZ(0, 0, 0);
123  mClu = nullptr;
124  }
126  TVector3 mXYZ;
127  StMuFcsCluster *mClu;
128  ClassDef(FcsClusterWithStarXYZ, 1);
129 };
130 
135 class FcsHitWithStarXYZ: public TObject {
136  public:
138  mXYZ.SetXYZ(0, 0, 0);
139  mHit = nullptr;
140  }
142  TVector3 mXYZ;
143  StMuFcsHit *mHit;
144  ClassDef(FcsHitWithStarXYZ, 1);
145 };
146 
147 
152 
160 
167 
168  int nSeedTracks;
170 
171 
172  void clear();
173 };
174 
175 
176 class StMuDstMaker;
177 class StMuDst;
179 class StMuFcsCollection;
180 class StFwdTrackMaker;
181 class StEvent;
182 
183 class StFwdQAMaker : public StMaker {
184 
185  ClassDef(StFwdQAMaker, 0);
186 
187  public:
188  StFwdQAMaker();
189  ~StFwdQAMaker(){/* nada */};
190 
191  int Init();
192  int Finish();
193  int Make();
194  void Clear(const Option_t *opts = "");
195 
196  void FillFttClusters();
197  void FillFstPoints();
198  void FillFcsStEvent();
199  void FillFcsStMuDst();
200  void FillTracks();
201  void FillMcTracks();
202 
203  void ProcessFwdTracks();
204  void ProcessFwdMuTracks();
205 
206  void setMuDstInput() { mAnalyzeMuDst = true; }
207  void setLocalOutputFile( TString f ) { mLocalOutputFile = f; }
208  void setTreeFilename( TString f ) {mTreeFilename = f;}
209 
210  protected:
211  TFile *mTreeFile = nullptr;
212  TTree *mTree = nullptr;
213  FwdQATreeData mTreeData;
214 
215  StEvent *mStEvent = nullptr;
216  StMuDstMaker *mMuDstMaker = nullptr;
217  StMuDst *mMuDst = nullptr;
218  StMuFwdTrackCollection * mMuForwardTrackCollection = nullptr;
219  StMuFcsCollection *mMuFcsCollection = nullptr;
220  StFwdTrackMaker *mFwdTrackMaker = nullptr;
221  StFcsDb *mFcsDb = nullptr;
222 
223 
224 //========================================================= new stuff
225  std::map<TString, TH1*> mHists;
226 
233  TH1* getHist( TString n ){
234  if (mHists.count(n))
235  return mHists[n];
236  LOG_ERROR << "Attempting to access non-existing histogram" << endm;
237  return new TH1F( "NULL", "NULL", 1, 0, 1 ); // returning nullptr can lead to seg fault, this fails softly
238  }
239 
244  bool mAnalyzeMuDst = false;
245  TString mLocalOutputFile;
246  TString mTreeFilename;
247 //====================================================== end new stuff
248 
249 };
250 
251 
252 #endif
FwdTreeHeader header
Primary event vertex.
Definition: StFwdQAMaker.h:154
TClonesArrayWriter< StMuMcTrack > mcTracks
MC tracks.
Definition: StFwdQAMaker.h:156
bool mAnalyzeMuDst
Control whether the analysis uses StEvent (default) or MuDst as input.
Definition: StFwdQAMaker.h:244
TH1 * getHist(TString n)
Get the Hist object from the map.
Definition: StFwdQAMaker.h:233
Store Cluster with STAR XYZ position.
Definition: StFwdQAMaker.h:119
TClonesArray writer Helper class for writing TClonesArrays to TTree of custom class type...
Definition: StFwdQAMaker.h:30
This class is a container for the data that will be written to the output tree.
Definition: StFwdQAMaker.h:151
Store Hit with STAR XYZ position.
Definition: StFwdQAMaker.h:135