StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuDst2StEventMaker.cxx
1 /***************************************************************************
2  *
3  * $Id: StMuDst2StEventMaker.cxx,v 1.13 2007/05/16 18:50:49 mvl Exp $
4  * Author: Frank Laue, BNL, laue@bnl.gov
5  ***************************************************************************/
6 #include "StMuDst2StEventMaker.h"
7 
8 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
9 #include "StMuDSTMaker/COMMON/StMuDst.h"
10 #include "StMuDSTMaker/COMMON/StMuDebug.h"
11 #include "StEvent/StEventTypes.h"
12 #include "StEvent/StTriggerIdCollection.h"
13 #include "StEvent/StTriggerId.h"
14 #include "StEvent/StTpcDedxPidAlgorithm.h"
15 
16 
18  mStEvent =0;
19  //cout << "StMuDst2StEventMaker::StMuDst2StEventMaker : constructor with args called" << endl;
20  //cout << " muDstMakerName " << muDstMakerName << endl;
21  //cout << " self " << self << endl;
22  //cout << " GetMaker(muDstMakerName) " << (int) mMuDstMaker << endl;
23 }
24 
25 StMuDst2StEventMaker::~StMuDst2StEventMaker() {
26  /* no=op */
27 }
28 
29 
30 void StMuDst2StEventMaker::Clear(const char*) {
31  if ( mStEvent ) delete mStEvent;
32  mStEvent =0;
33 }
34 
36  mStEvent = 0; // I do not delete the StEvent, the chain is responsible for deletion.
37  // I just set the pointer to zero, so that you never pick up the old StEvent
38 
39  StMuDst *muDst=0;
40  muDst=(StMuDst*)GetInputDS("MuDst");
41  if (muDst) {
42  mStEvent=muDst->createStEvent();
43  if(mStEvent) {
44  // set chain date to be the same of event date
45  StEvtHddr *hd = GetEvtHddr();
46  hd->SetGMTime(mStEvent->time());
47  if(mStEvent->runInfo()) hd->SetRunNumber(mStEvent->runInfo()->runId());
48  AddData(mStEvent); // add StEvent to the .data tree
49  }
50 
51  // print all the trigger ids
52  // so now you have a StEvent and you can loop
53  // uncomment the following if to have to print out and tests
54  //if (mStEvent) {
55  // printTriggerIds(mStEvent);
56  // loopOverTracks(mStEvent);
57  //}
58 
59  } else {
60  LOG_WARN << "StMuDst2StEventMaker::Make() : WARNING Did not get pointer to MuDst. " << endm;
61  LOG_WARN << " StEvent will NOT be filled (nothing we can do)" << endm;
62  }
63  return 0;
64 }
65 
66 
67 
68 void StMuDst2StEventMaker::printTriggerIds(StEvent* ev) {
69  if ( ev->triggerIdCollection() ) {
70  if ( ev->triggerIdCollection()->l1() ) {
71  if ( StMuDebug::level()>0 ) {
72  cout << "l1 triggers: ";
73  vector<unsigned int> v = ev->triggerIdCollection()->l1()->triggerIds();
74  for ( unsigned int i=0; i<v.size(); i++) cout << v[i] << " ";
75  cout << endl;
76  }
77  }
78  if ( ev->triggerIdCollection()->l2() ) {
79  if ( StMuDebug::level()>0 ) {
80  cout << "l2 triggers: ";
81  vector<unsigned int> v = ev->triggerIdCollection()->l2()->triggerIds();
82  for ( unsigned int i=0; i<v.size(); i++) cout << v[i] << " ";
83  cout << endl;
84  }
85  }
86  if ( ev->triggerIdCollection()->l3() ) {
87  if ( StMuDebug::level()>0 ) {
88  cout << "l3 triggers: ";
89  vector<unsigned int> v = ev->triggerIdCollection()->l3()->triggerIds();
90  for ( unsigned int i=0; i<v.size(); i++) cout << v[i] << " ";
91  cout << endl;
92  }
93  }
94  if ( ev->triggerIdCollection()->nominal() ) {
95  if ( StMuDebug::level()>0 ) {
96  cout << "nominal triggers: ";
97  vector<unsigned int> v = ev->triggerIdCollection()->nominal()->triggerIds();
98  for ( unsigned int i=0; i<v.size(); i++) cout << v[i] << " ";
99  cout << endl;
100  }
101  }
102  }
103 }
104 
105 void StMuDst2StEventMaker::loopOverTracks(StEvent* ev) {
106  LOG_DEBUG << "StMuDst2StEventMaker::loopOverTracks(...)" << endm;
107  StDedxPidTraits dEdxPidTraits;
108  StTpcDedxPidAlgorithm pidAlgorithm;
109  // get the track nodes vector and loop over nodes
110  // const StSPtrVecTrackNode nodes = ev->trackNodes();
111  int numberOfNodes = ev->trackNodes().size();
112  for ( int i=0; i< numberOfNodes; i++) {
113  StTrackNode* node = ev->trackNodes()[i];
114  // print some primary track values
115  StTrack* t = node->track(primary);
116  if (t) {
117  // fill pid traits and print some values
118  const StParticleDefinition* pid = t->pidTraits(pidAlgorithm);if(pid){/*nothing*/}
119  // if we have pid traits
120  if ( pidAlgorithm.traits() ) {
121  // cout << "dE/dx = " << pidAlgorithm.traits()->mean() << " ";
122  // cout << "number of hits used in dE/dx = " << pidAlgorithm.traits()->numberOfPoints() << endl;
123  }
124  }
125  }
126 }
127 
128 
129 
130 ClassImp(StMuDst2StEventMaker)
131 
132 /***************************************************************************
133  *
134  * $Log: StMuDst2StEventMaker.cxx,v $
135  * Revision 1.13 2007/05/16 18:50:49 mvl
136  * Cleanup of output. Replaced cout with LOG_INFO etc.
137  *
138  * Revision 1.12 2004/10/21 02:59:01 mvl
139  * Now get MuDst from GetInputDS, instead of StMuDSTMaker
140  *
141  * Revision 1.11 2004/04/15 00:24:07 perev
142  * GetEvtHddr() used now
143  *
144  * Revision 1.10 2003/10/14 14:35:53 laue
145  * Alex Suaide EMC updates
146  *
147  * Revision 1.9 2003/09/17 02:54:37 jeromel
148  * Name clash. Added warning in case this happens in future
149  *
150  * Revision 1.8 2003/09/12 21:32:40 jeromel
151  * Bug fix : zeroing missing
152  *
153  * Revision 1.7 2003/09/07 03:49:03 perev
154  * gcc 3.2 + WarnOff
155  *
156  * Revision 1.6 2003/08/29 14:54:00 laue
157  * Commented out printing of the trigger ids and the (test)-loop over the tracks.
158  *
159  * Revision 1.5 2003/08/28 13:01:45 laue
160  * now passing proper maker name to the call of the StMaker(name) constructor
161  *
162  * Revision 1.4 2003/08/04 14:38:10 laue
163  * Alex Suaide's updated for the EMC. Now EEMC is included.
164  *
165  * Revision 1.3 2003/04/15 18:48:35 laue
166  * Minor changes to be able to filter MuDst.root files and an example
167  * how to do this. The StMuDstFilterMaker is just an example, it has to be
168  * customized (spoilers, chrome weels, etc.) by the user.
169  *
170  * Revision 1.2 2003/03/19 18:58:04 laue
171  * StMuChainMaker: updates for moved file catalog
172  * StTriggerIdCollection added to the createStEvent function in StMuDst.cxx
173  *
174  * Revision 1.1 2003/01/09 18:59:45 laue
175  * initial check in of new EMC classes and the changes required
176  *
177  * Revision 1.15 2002/11/08 14:18:59 laue
178  *
179  **************************************************************************/
StMuDst * muDst()
Definition: StMuDstMaker.h:425
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
static int level()
returns debug level
Definition: StMuDebug.h:78
int Make()
create a StEvent from the muDst and put it into the .data tree structure. Also time stamp gets writte...
StMuDst2StEventMaker(const char *self="muDst2StEventMaker")
Default constructor; get pointer to StMuDstMaker.
StEvent * createStEvent()
creates a StEvent from the StMuDst (this) and returns a pointer to it. (This function is not yet fini...
Definition: StMuDst.cxx:702