StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StRareMaker.cxx
1 // $Id: StRareMaker.cxx,v 1.8 2002/01/18 19:14:10 struck Exp $
2 // $Log: StRareMaker.cxx,v $
3 // Revision 1.8 2002/01/18 19:14:10 struck
4 // compress track classes, filter only hadronic unbiased/Z=-2 events
5 //
6 // Revision 1.7 2001/12/04 18:26:10 struck
7 // update for gcc2.95-3
8 //
9 // Revision 1.6 2001/11/02 00:05:41 struck
10 // major update: bug fixes in StRareMaker to get dca for l3 tracks and correct wrong l3 field setting in run 291023
11 //
12 // Revision 1.5 2001/10/16 01:26:14 struck
13 // added filename parameter for tree file to constructors
14 //
15 // Revision 1.4 2001/10/15 20:20:27 struck
16 // first version with L3 included
17 //
18 // Revision 1.3 2001/09/06 20:51:23 hardtke
19 // Update
20 //
21 //
22 //
24 //
25 // StRareMaker
26 //
27 // Description:
28 // Make uDST for Rare Particle Search
29 //
30 // Environment:
31 // Software developed for the STAR Detector at Brookhaven National Laboratory
32 //
33 // Author List:
34 // David Hardtke, LBNL
35 //
36 // History:
37 //
39 #include "StRareMaker.h"
40 #include "StRareEvent.h"
41 #include "StRareEventCut.h"
42 #include "StRareTrackCut.h"
43 #include "StL3RareTrackCut.h"
44 #include "StAcceptAllEvents.h"
45 #include "StAcceptAllTracks.h"
46 #include "StAcceptAllL3Tracks.h"
47 #include "StChain.h"
48 #include "StEventTypes.h"
49 #include "StMessMgr.h"
50 #include "StarClassLibrary/StThreeVector.hh"
51 
52 ClassImp(StRareEventCut)
53 ClassImp(StRareTrackCut)
54 ClassImp(StL3RareTrackCut)
55 
56 static const char rcsid[] = "$Id: StRareMaker.cxx,v 1.8 2002/01/18 19:14:10 struck Exp $";
57 
58 double dEdx_formula(double momentum, double mass);
59 
60 ClassImp(StRareMaker)
61 
62 StRareMaker::StRareMaker(const Char_t *name, const Char_t* fileName) : StMaker(name) {
63  mRareEvent = new StRareEvent();
64  out = new TFile(fileName, "RECREATE");
65  out->SetCompressionLevel(2);
66  m_Tree = new TTree("RareTree", "RareTree");
67  // m_Tree->SetBranchStyle(0);
68  m_Tree->AutoSave();
69  m_Tree->SetAutoSave(10000000);
70  m_Tree->Branch("StRareEvent", "StRareEvent", &mRareEvent, 64000, 1);
71  mEventCut = new StAcceptAllEvents();
72  mTrackCut = new StAcceptAllTracks();
73  mL3TrackCut = new StAcceptAllL3Tracks();
74 }
75 
76 StRareMaker::StRareMaker(const Char_t *name, const Char_t* fileName,
77  StRareEventCut* cut, StRareTrackCut* track) : StMaker(name) {
78  out = new TFile(fileName, "RECREATE");
79  out->SetCompressionLevel(2);
80  m_Tree = new TTree("RareTree", "RareTree", 1000000);
81  m_Tree->AutoSave();
82  m_Tree->SetAutoSave(10000000);
83  mRareEvent = new StRareEvent();
84  m_Tree->Branch("StRareEvent", "StRareEvent", &mRareEvent, 64000, 1);
85  mEventCut = cut;
86  mTrackCut = track;
87  mL3TrackCut = 0;
88 }
89 
90 StRareMaker::StRareMaker(const Char_t *name, const Char_t* fileName,
91  StRareEventCut* cut,
92  StRareTrackCut* trackCut,
93  StL3RareTrackCut* l3trackCut) : StMaker(name) {
94  //out = new TFile("/direct/star+data01/pwg/spectra/struck/2001/RareEvent.root","RECREATE");
95  out = new TFile(fileName, "RECREATE");
96  out->SetCompressionLevel(2);
97  m_Tree = new TTree("RareTree", "RareTree", 1000000);
98  m_Tree->AutoSave();
99  m_Tree->SetAutoSave(10000000);
100  mRareEvent = new StRareEvent();
101  m_Tree->Branch("StRareEvent", "StRareEvent", &mRareEvent, 64000, 1);
102  mEventCut = cut;
103  mTrackCut = trackCut;
104  mL3TrackCut = l3trackCut;
105 }
106 
108  //
109  // This method is called every event. That's the
110  // right place to plug in your analysis to be
111  // done every event.
112  //
113  StEvent* mEvent;
114  mEvent = (StEvent *) GetInputDS("StEvent");
115  if (!mEvent) return kStOK; // If no event, we're done
116 
117  // test
118  // get event number and run number
119  cout << " event ID = " << mEvent->id() << endl;
120  int runNumber = mEvent->runId();
121 
122  mRareEvent->clear();
123 
124  // take only hadronic events
125  StL0Trigger* l0Trigger = mEvent->l0Trigger();
126  if (!l0Trigger) {
127  cout << "No l0 trigger found.\n";
128  cout << "Skip this event!\n";
129  return 0;
130  }
131  else if (l0Trigger->triggerWord()<0x1000 ||
132  l0Trigger->triggerWord()>0x1fff) {
133  return 0;
134  }
135 
136  // take only unbiased events and events triggered by Z=-2 trigger
137  StL3Trigger* l3Event;
138  l3Event = (StL3Trigger*) mEvent->l3Trigger();
139  if (l3Event) {
140  const StL3EventSummary* l3EventSummary = l3Event->l3EventSummary();
141  if (!l3EventSummary) {
142  cout << "No l3 event summary found." << endl;
143  return 0;
144  }
145  bool take = l3EventSummary->unbiasedTrigger();
146 
147  const StPtrVecL3AlgorithmInfo& algInfo = l3EventSummary->algorithmsAcceptingEvent();
148  for (unsigned int i=0; i<algInfo.size(); i++) {
149  if (algInfo[i]->id() == 6) take = kTRUE;
150  }
151  if (!take) return 0;
152  }
153 
154  if (mEventCut->Accept(mEvent)) {
155  mRareEvent->fillRareEvent(mEvent);
156  StPrimaryTrackIterator itr;
157  StPrimaryTrack *trk;
158  if (mEvent->primaryVertex()) {
159  StSPtrVecPrimaryTrack& tracks = mEvent->primaryVertex()->daughters();
160  for (itr=tracks.begin(); itr != tracks.end(); itr++){
161  trk = *itr;
162  if (mTrackCut->Accept(trk)) mRareEvent->addTrack(trk);
163  }
164  }
165 
166  // now look for L3
167  float l3zVertex = -999;
168  if (mL3TrackCut && l3Event) {
169  mRareEvent->fillL3Info(l3Event);
170  if (l3Event->primaryVertex())
171  l3zVertex = l3Event->primaryVertex()->position().z();
172  // Loop over tracks
173  StGlobalTrack *l3trk;
174  StSPtrVecTrackNode& mtracknodes = (StSPtrVecTrackNode&) l3Event->trackNodes();
175  for (unsigned int i=0; i<mtracknodes.size(); i++) {
176  l3trk = (StGlobalTrack* )mtracknodes[i]->track(0);
177  // correct my bug in StEvent filling
178  //StGlobalTrack* newL3Track = new StGlobalTrack(*l3trk);
179  StHelixModel* oldHelix = (StHelixModel*) l3trk->geometry();
180  int charge = oldHelix->charge();
181  short int h = oldHelix->helicity();
182  // correct wrong field polarity in run 2291023
183  if (runNumber==2291023) {
184  charge *= -1;
185  h *= -1;
186  float kapa = /*0.001 * */oldHelix->curvature();
187  float lambda = /*atan(*/oldHelix->dipAngle();
188  StHelixModel* newHelix = new StHelixModel(charge, (float) oldHelix->psi(),
189  kapa, lambda, oldHelix->origin(),
190  oldHelix->momentum(), h);
191  l3trk->setGeometry(newHelix);
192  }
193  //float kapa = 0.001 * oldHelix->curvature();
194  //float lambda = atan(oldHelix->dipAngle());
195  //StHelixModel* newHelix = new StHelixModel(charge, (float) oldHelix->psi(),
196  // kapa, lambda, oldHelix->origin(),
197  // oldHelix->momentum(), h);
198  //newL3Track->setGeometry(newHelix);
199  // get dca2d to l3zVertex
200  if (l3zVertex!=-999) {
201  StThreeVectorD vertex(0, 0, l3zVertex);
202  float dca2d = oldHelix->helix().distance(vertex);
203  //cout << l3zVertex << " ==> dca = " << dca2d << endl;
204  //newL3Track->setImpactParameter(dca2d);
205  l3trk->setImpactParameter(dca2d);
206  }
207 
208  if (mL3TrackCut->Accept(l3trk)) mRareEvent->addL3Track(l3trk);
209 
210  // clean up this mess
211  //delete newL3Track;
212  }
213  }
214 
215  m_Tree->Fill();
216  //m_Tree->Print();
217  mRareEvent->Clear();
218  }
219  return kStOK;
220 }
221 
222 Int_t StRareMaker::Init() {
223  number_of_events_processed = 0;
224  Report();
225  return StMaker::Init();
226 }
227 
228 void StRareMaker::Report(){
229  mEventCut->Report();
230  mTrackCut->Report();
231 }
232 
233 
234 void StRareMaker::PrintInfo() {
235  printf("**************************************************************\n");
236  printf("* $Id: StRareMaker.cxx,v 1.8 2002/01/18 19:14:10 struck Exp $\n");
237  printf("**************************************************************\n");
238 }
239 
240 void StRareMaker::Clear(Option_t *opt) {
241 }
242 
243 
245  out->Write();
246  out->Close();
247  return kStOK;
248 }
249 
250 
251 
252 
253 
254 
255 
256 
257 
258 
virtual void Clear(Option_t *option="")
User defined functions.
double distance(const StThreeVector< double > &p, bool scanPeriods=true) const
minimal distance between point and helix
Definition: StHelix.cc:240
virtual Int_t Finish()
Definition: Stypes.h:40
virtual Int_t Make()