StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StPeCLumiMaker.cxx
1 // $Id: StPeCLumiMaker.cxx,v 1.7 2007/04/28 17:56:33 perev Exp $
2 // $Log: StPeCLumiMaker.cxx,v $
3 // Revision 1.7 2007/04/28 17:56:33 perev
4 // Redundant StChain.h removed
5 //
6 // Revision 1.6 2003/02/01 18:50:18 yepes
7 // New Lumi version for MuDst
8 //
9 // Revision 1.5 2002/06/04 17:55:01 meissner
10 // filtering: filter all UPC triggerwords
11 //
12 // Revision 1.3 2002/04/18 19:02:09 meissner
13 // Change Init to InitRun
14 //
15 // Revision 1.2 2002/03/20 17:42:14 meissner
16 // buu fix //uDst->SetFormat
17 //
18 // Revision 1.1 2002/03/19 22:23:39 meissner
19 // New variables: zdc unatt., Trigger word, MC tree if Geant Branch, DCA for primary pairs, all tracks for secondary pairs (Test)
20 //
21 //
22 // Revision 1.0 2001 Meissner
23 // initial version based on StPeCMaker
24 //
25 //
27 //
28 // StPeCLumiMaker
29 //
30 // Description:
31 // Small maker for Luminosity determination
32 // For each event some variables are written out (multiplicities, ZDC'x etc)
33 // Environment:
34 // Software developed for the STAR Detector at Brookhaven National Laboratory
35 //
36 // Author List:
37 // Falk Meissner, LBNL, based on STPeCMaker
38 //
39 // History:
40 //
42 #include "StPeCLumiMaker.h"
43 #include "StEventTypes.h"
44 #include "Stypes.h"
45 #include "StMessMgr.h"
46 #include "TH1.h"
47 #include <vector>
48 #ifndef ST_NO_NAMESPACES
49 using std::vector;
50 #endif
51 
52 #include "StTriggerDetectorCollection.h"
53 #include "StCtbTriggerDetector.h"
54 #include "StMwcTriggerDetector.h"
55 #include "StVpdTriggerDetector.h"
56 #include "StZdcTriggerDetector.h"
57 #include "StFtpcHitCollection.h"
58 #include "StFtpcPlaneHitCollection.h"
59 #include "StFtpcSectorHitCollection.h"
60 
61 #include "StMcEventTypes.hh"
62 #include "StMcEventMaker/StMcEventMaker.h"
63 #include "StIOMaker/StIOMaker.h"
64 
65 
66 
67 static const char rcsid[] = "$Id: StPeCLumiMaker.cxx,v 1.7 2007/04/28 17:56:33 perev Exp $";
68 
69 ClassImp(StPeCLumiMaker)
70 
71 StPeCLumiMaker::StPeCLumiMaker(const Char_t *name) : StMaker(name) {
72  // infoLevel = 0 ;
73  //filter = 0 ;
74 }
75 
76 StPeCLumiMaker::~StPeCLumiMaker() {}
77 
78 Int_t StPeCLumiMaker::Init() {
79  cout << "StPeCLumiMaker::Init, Do nothing!";
80  return StMaker::Init();
81 }
82 
83 Int_t StPeCLumiMaker::InitRun(Int_t runnr) {
84 
85  // if ( infoLevel > 0 )
86  cout<<"StPeCLumiMaker: Initializing..run " << runnr <<endl;
87 //
88 // Set uDst output file
89 //
90  TString uDstFileName("StPeCMaker.tree.root");
91  StIOMaker* pIOMaker = (StIOMaker*)GetMaker("IO");
92  if ( pIOMaker) {
93  uDstFileName = pIOMaker->GetFile() ;
94  const char* ccc = "/" ;
95  Ssiz_t slashPosition = uDstFileName.Last(*ccc) ;
96  if ( slashPosition != -1 &&
97  slashPosition < uDstFileName.Length() )
98  uDstFileName.Remove(0,slashPosition+1);
99  }
100 
101  cout << uDstFileName << endl;
102  TString tDst("dst");
103  TString tEvt("event");
104  TString tEvtSel("evtsel");
105  TString tuDst("lumiDst");
106  TString tuDstSel("lumiDstSel");
107  uDstFileName.ReplaceAll(tDst,tuDst);
108  uDstFileName.ReplaceAll(tEvt,tuDst);
109  uDstFileName.ReplaceAll(tEvtSel,tuDstSel);
110  cout << "StPeCLumiMaker: uDst output file: " << uDstFileName << endl;
111  // Get runnumber from filename somewhow
112  // filenumber=
113 
114  m_outfile = new TFile( uDstFileName,"recreate");
115  // OLD not needed anymore
116  // Get the standard root format to be independent of Star IO
117  // m_outfile->SetFormat(1);
118  // m_outfile->SetCompressionLevel(1);
119 
120 
121  uDstTree = new TTree("uDst","Pcol uDst",99);
122 
123  // Instantiate StPeCLumiEntry
124  LumiEntry = new StPeCLumiEntry() ;
125  uDstTree->Branch ("LumiEntry","StPeCLumiEntry",&LumiEntry,64000,1);
126 
127  //if ( infoLevel > 0 )
128  cout<<"StPeCLumiMaker: Initialization done!"<<endl;
129 
130  return StMaker::InitRun(runnr);
131 }
132 
133 
135 
136  // Count all the events
137  //if ( infoLevel > 0 ) printf ( "StPeCLumiMaker::Make: Start \n" ) ;
138 
139  //Vladimir - first check if muDst is available, if not, see if StEvent is
140 
141  if (muDst) {
142  cout<<"StPeCLumiMaker: Reading muDst"<<endl;
143  Int_t NTracks = muDst->globalTracks()->GetEntries();
144  cout<<"StPeCLumiMaker: Number of tracks "<<NTracks<<endl;
145 
146  Int_t flag = kStOk ;
147 
148  if( NTracks > StPeCnMaxTracks ){
149  cout<<"StPeCLumiMaker: Number of tracks: "<<NTracks<<endl;
150  cout<<"Not a peripheral event (NTracks>15)"<<endl;
151  flag = kStErr;
152  }
153  if( NTracks <= 1 ){
154  cout<<"StPeCLumiMaker: Event has no tracks!"<<endl;
155  flag = kStErr;
156  }
157 
158 
159  StL0Trigger &trig = muDst->event()->l0Trigger();
160  int tw = trig.triggerWord();
161  cout << "Trigger word " << tw << endl;
162  if (tw == 0x3001 || tw==0x3002 || tw == 0x3011 || tw == 0x1001 ) {
163  cout << "UPC trigger filter event" << endl;
164  flag= kStOk;
165  }
166 
167  //fill LumiEntry
168  LumiEntry->fill(muDst );
169  // fill the tree
170  uDstTree->Fill();
171  //return kStOk ;
172  return flag ;
173 
174  }
175 
176 
177  else {
178  // look for StEvent
179  StEvent* event = 0 ;
180  event = (StEvent *) GetInputDS("StEvent");
181 
182  if (event){
183 
184  // Do this way since call to event->summary->numberOfTracks() crashes
185  StSPtrVecTrackNode& tempn = event->trackNodes();
186  Int_t NTracks=tempn.size();
187  cout<<"StPeCLumiMaker: Number of tracks: "<<NTracks<<endl;
188 
189  Int_t flag = kStOk ;
190 
191  if( NTracks > StPeCnMaxTracks ){
192  cout<<"StPeCLumiMaker: Number of tracks: "<<NTracks<<endl;
193  cout<<"Not a peripheral event (NTracks>15)"<<endl;
194  flag = kStErr;
195  }
196  if( NTracks <= 1 ){
197  cout<<"StPeCLumiMaker: Event has no tracks!"<<endl;
198  flag = kStErr;
199  }
200 
201  int tw = event->l0Trigger()->triggerWord();
202  cout << "Trigger word " << tw << endl;
203  if (tw == 0x3001 || tw==0x3002 || tw == 0x3011 || tw == 0x1001 ) {
204  cout << "UPC trigger filter event" << endl;
205  flag= kStOk;
206  }
207 
208  // put runnumber to fill function
209  // LumiEntry->fill( event , filenumber);
210  LumiEntry->fill( event );
211  // fill the tree
212  uDstTree->Fill();
213  //return kStOk ;
214  return flag ;
215  }
216  else {
217  cout<<"StPeCLumiMaker: There was no StEvent! Return."<<endl;
218  return kStOK;
219  }
220  }
221 }
222 
224  cout << "StPeCLumiMaker: Finish" << endl;
225  m_outfile->Write();
226  m_outfile->Close();
227  StMaker::Finish();
228  return kStOK;
229 }
230 
231 
static TObjArray * globalTracks()
returns pointer to the global tracks list
Definition: StMuDst.h:303
virtual Int_t Finish()
virtual Int_t Make()
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Definition: Stypes.h:40
virtual Int_t Finish()
Definition: StMaker.cxx:776
Definition: Stypes.h:44
Definition: Stypes.h:41