StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TestFilter.C
1 
2 class StMuDstMaker;
3 class HistMaker;
4 
5 StMuDstMaker* maker;
6 HistMaker* myHistMaker;
7 
8 void TestFilter(const char* indir, const char* infile, const char* outfile)
9 {
10  if (gClassTable->GetID("TTable") < 0) gSystem->Load("libTable");
11  gSystem->Load("St_base");
12  gSystem->Load("StChain");
13  gSystem->Load("St_Tables");
14  gSystem->Load("StMagF");
15  gSystem->Load("StUtilities"); // new addition 22jul99
16  gSystem->Load("StTreeMaker");
17  gSystem->Load("StIOMaker");
18  gSystem->Load("StarClassLibrary");
19  gSystem->Load("StTpcDb");
20  gSystem->Load("StDbUtilities");
21  gSystem->Load("StEvent");
22  gSystem->Load("StEventUtilities");
23  gSystem->Load("StMcEvent");
24  gSystem->Load("StMcEventMaker");
25  gSystem->Load("StAssociationMaker");
26  gSystem->Load("StMcAnalysisMaker");
27  gSystem->Load("StStrangeMuDstMaker");
28  gSystem->Load("StMuDSTMaker");
29  gSystem->Load("JetFinder");
30 
31  cout << " loading done " << endl;
32 
33  StMuDebug::setLevel(0); // switch of some debug output
34 
35  int iret=0;
36  cout <<" --- Create StMuDstMaker --- "<<endl;
37  maker = new StMuDstMaker(0,0,indir,"",infile,1); // set up maker in read mode
38 
39  cout <<" --- Set Cuts ---"<<endl;
40  //Setup cuts
41  AnaCuts cuts;
42  cuts.ptCut = 1.0; // momentum (pt) (GeV)
43  cuts.pseudoRapidityCutOff = 1.5;
44  cuts.minNumberOfFitPoints = 22;
45  cuts.minNumberOfPoints = 25;
46  cuts.verbose=true;
47 
48  cout <<" --- Create Filter ---"<<endl;
49  //This must match the enum in StJetFilter.h
50  enum ioType {kWrite=0, kRead=1};
51 
52  myFilter = new StJetFilter(kWrite,outfile);
53  myFilter.setCuts(cuts);
54 
55  cout <<" --- Loop on events ---"<<endl;
56 
57  //TChain* t = maker->tree();
58  //int nEvents = t->GetEntries();
59 
60  int nEvents = 1000;
61  int iret = 0; //iret==4 means kEOF
62 
63  for (int iev=0; iev<nEvents && iret!=4; ++iev) {
64  iret = maker->Make(); // read an event
65  cout <<"iret:\t"<<iret<<endl;
66  if (iret!=4) {
67  myFilter->fill(maker);
68 
69  //Get Tracks
70  TClonesArray* tracks = myFilter->event()->tracks();
71  cout <<"------------ From Macro -------"<<endl;
72  int nTracks = tracks->GetLast()+1; //don't know why, but they don't have a size method
73  for (int i=0; i<nTracks; ++i) {
74  StMuTrack* track = static_cast<StMuTrack*>(tracks->operator[](i));
75  cout <<"momentum:\t"<<track->p()<<endl;
76  }
77  }
78  }
79 
80  //Now get number of entries:
81  int nEntries = myFilter->nEvents();
82  cout <<"\n\n Wrote file:\t"<<outfile<<"\twith number of entries:\t"<<nEntries<<endl;
83 
84  delete maker;
85  maker=0;
86  delete myFilter;
87  myFilter=0;
88 
89  //Now rename the file:
90  cout <<"tack int onto filename"<<endl;
91  char* newfile = new char[1000];
92  sprintf(newfile,"%s_has_%i_events",outfile,nEntries);
93 
94  cout <<"concat the unix command"<<endl;
95  char* command = new char[2000];
96  sprintf(command,"mv %s %s",outfile, newfile);
97 
98  cout <<"Get TUnixSystem"<<endl;
99  TUnixSystem* sys = static_cast<TUnixSystem*>(gSystem);
100 
101  cout <<"copy a file from:\t"<<outfile<<"\t to:\t"<<newfile<<endl;
102  cout <<"command is:\t"<<command<<endl;
103  sys->Exec(command);
104  cout <<"Done"<<endl;
105 }
106 
virtual int Make()
static void setLevel(unsigned int level)
sets the debug level
Definition: StMuDebug.h:74
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
Definition: StMuTrack.h:259