StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcEEmcTreeMaker.h
1 /*
2  * Created by S. Gliske, May 2012
3  *
4  * Description: General utility class for reading and writing
5  * McEEmcTrees. The tree contains the following branches:
6  *
7  * - TClonesArray of EEmcEnergy_t holding deposition of energy for each particle hitting the EEMC
8  * - TClonesArray of McParticle_t for each particle hitting the EEMC
9  * - TClonesArray of McParticle_t for each parent and ancestor of the particles hitting the EEMC
10  * - TClonesArray of TVector3 being the stat and stop vertices for all the above particles
11  *
12  */
13 
14 #ifndef StMcEEmcTreeMaker_H_
15 #define StMcEEmcTreeMaker_H_
16 
17 #include <set>
18 #include <map>
19 
20 #include <Rtypes.h>
21 #include <TVector3.h>
22 
23 #include "StMaker.h"
24 
25 class McParticle_t;
26 class StMcTrack;
27 class StMcVertex;
28 
29 class StMcEEmcTreeMaker_t : public StMaker {
30  public:
32  StMcEEmcTreeMaker_t( const Char_t *myName );
33 
35  virtual ~StMcEEmcTreeMaker_t();
36 
38  Int_t Init();
39 
41  Int_t Make();
42 
44  void Clear(Option_t *opts="");
45 
47  Int_t Finish();
48 
49  // to keep track of trees being read in or written out
50  enum iostatus_t { READ, WRITE, UNSET };
51 
53  void setTreeStatus( iostatus_t iostatus, const Char_t* fileName );
54  void setMaxNumEvents( Int_t maxNum );
55  void setEnergyThreshold( Float_t val ); // particles leaving less energy than this value in the ETOW are ignored.
56 
57  void addTrigger( Int_t trig );
58  void removeTrigger( Int_t trig );
59 
61  Int_t getNumIncidentParticles() const;
62  Int_t getNumAncestorParticles() const;
63  Int_t getNumVertices() const;
64 
65  TIter getIncidentParticleIter();
66  TIter getAncestorParticleIter();
67  McParticle_t* getAncestor( Int_t idx );
68  TVector3* getVertex( Int_t idx);
69 
73 
74  protected:
76  iostatus_t mIOStat;
77  std::string mFilename;
78 
80  TFile *mFile;
81  TTree *mTree;
82 
84  TChain *mChain;
85 
87  Int_t mNumEvents;
88 
91 
92  // Amount of energy in tower required in order to not ignore the
93  // particle having hit
94  Float_t mTowEnergyThres;
95 
96  // list of valid triggers (used when writing)
97  std::set< Int_t > mTriggerSet;
98 
100 
101  TClonesArray *mEEmcEnergyArr;
102  TClonesArray *mAncestorParticleArr;
103  TClonesArray *mIncidentParticleArr;
104  TClonesArray *mVertexArr;
105  Double_t mBjX1, mBjX2;
106 
107  // maps for indexing
108  std::map< const StMcTrack*, Int_t > mAncestorMap;
109  std::map< const StMcVertex*, Int_t > mVertexMap;
110  std::map< const StMcTrack*, Int_t >::iterator mAncestorMapIter;
111  std::map< const StMcVertex*, Int_t >::iterator mVertexMapIter;
112 
113  // extra functions
114  Int_t fill();
115  Int_t getAncestorIdx( const StMcTrack* );
116  Int_t getVertexIdx( const StMcVertex* );
117 
118  private:
119  // for ROOT
120  ClassDef( StMcEEmcTreeMaker_t, 1 );
121 
122 };
123 
124 // inline functions
125 
126 inline Int_t StMcEEmcTreeMaker_t::getNumIncidentParticles() const { return mIncidentParticleArr->GetEntriesFast(); };
127 inline Int_t StMcEEmcTreeMaker_t::getNumAncestorParticles() const { return mAncestorParticleArr->GetEntriesFast(); };
128 inline Int_t StMcEEmcTreeMaker_t::getNumVertices() const { return mVertexArr ->GetEntriesFast(); };
129 
130 inline TIter StMcEEmcTreeMaker_t::getIncidentParticleIter(){ return TIter( mIncidentParticleArr ); };
131 inline TIter StMcEEmcTreeMaker_t::getAncestorParticleIter(){ return TIter( mAncestorParticleArr ); };
132 
133 inline McParticle_t* StMcEEmcTreeMaker_t::getAncestor( Int_t idx ) {
134  return (McParticle_t*)( idx < mAncestorParticleArr->GetEntriesFast() ? (*mAncestorParticleArr)[idx] : 0 );
135 };
136 
137 inline TVector3* StMcEEmcTreeMaker_t::getVertex( Int_t idx ) {
138  return (TVector3*)( idx < mVertexArr->GetEntriesFast() ? (*mVertexArr)[idx] : 0 );
139 };
140 
141 inline void StMcEEmcTreeMaker_t::addTrigger( Int_t trig ){ mTriggerSet.insert( trig ); };
142 inline void StMcEEmcTreeMaker_t::removeTrigger( Int_t trig ){ mTriggerSet.erase( trig ); };
143 
144 #endif
145 
146 /*
147  * $Id: StMcEEmcTreeMaker.h,v 1.2 2013/03/19 18:49:08 sgliske Exp $
148  * $Log: StMcEEmcTreeMaker.h,v $
149  * Revision 1.2 2013/03/19 18:49:08 sgliske
150  * added Bjorken x1 and x2
151  *
152  * Revision 1.1 2012/11/26 19:06:11 sgliske
153  * moved from offline/users/sgliske/StRoot/StEEmcPool/StEEmcTreeMaker to StRoot/StEEmcPool/StEEmcTreeMaker
154  *
155  *
156  */
Int_t getNumIncidentParticles() const
accessors
virtual ~StMcEEmcTreeMaker_t()
deconstructor
Int_t Init()
Initialize.
iostatus_t mIOStat
filenames
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Definition: StMcTrack.hh:144
void setTreeStatus(iostatus_t iostatus, const Char_t *fileName)
modifiers
StMcEEmcTreeMaker_t(const Char_t *myName)
constructor
Int_t Make()
Build an event.
TChain * mChain
TChains for reading.
Int_t Finish()
Write everything to file.
void Clear(Option_t *opts="")
Clear for next event.
Int_t mMaxNumEvents
max number of events
TClonesArray * mEEmcEnergyArr
The data.
Int_t mNumEvents
number of events processed / written outt
TFile * mFile
TFiles/TTrees for writing.