StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ntuple.C
1 // examples :
2 // tracks = ((ntupleTrack*) (((StHbtAnalysis*)((StHbtMaker*) chain->GetMaker("HBT"))->HbtManager()->Analysis(0))->FirstParticleCut()))->GetNtupleTrack()
3 // tracks->Draw("dca")
4 // events = (TTree*) ((ntupleEvent*) ((StHbtAnalysis*)((StHbtMaker*)chain->GetMaker("HBT"))->HbtManager()->Analysis(0))->EventCut())->getNtupleEvent()
5 // events->Draw("numOfTracks")
6 
7 // NOTE - chain needs to be declared global so for StHbtEventReader
8 class StChain;
9 StChain *chain=0;
10 
11 // keep pointers to Analysis global, so you can have access to themm ...
12 class StHbtAnalysis;
13 StHbtAnalysis* anal;
14 
15 // File-scope stuff needed by setFiles, nextFile. Someone ambitious
16 // can clean this up by putting it all into a nice clean class.
17 Int_t usePath = 0;
18 Int_t nFile = 0;
19 TString thePath;
20 TString theFileName;
21 TString originalPath;
22 
23 
24 void StHbtExampledd(const Int_t nevents, const Char_t **fileList, const char*);
25 
26 //==========================================================================================
27 //==========================================================================================
28 void ntuple(const Int_t nevents=9999, const Char_t *path = "-",
29  const Char_t *file = "/star/rcf/pwg/hbt/July2000/HalfFieldData_new2.microDst")
30 {
31  const char *fileListQQ[]={0,0};
32  if (path[0]=='-') {
33  fileListQQ[0]=file;
34  } else {
35  fileListQQ[0] = gSystem->ConcatFileName(path,file);
36  }
37  StHbtExampledd(nevents,fileListQQ);
38 }
39 //==========================================================================================
40 //==========================================================================================
41 void StHbtExampledd(const Int_t nevents, const Char_t **fileList)
42 {
43 
44  // Dynamically link needed shared libs
45  gSystem->Load("St_base");
46  gSystem->Load("StChain");
47  gSystem->Load("St_Tables");
48  gSystem->Load("StMagF");
49  gSystem->Load("StUtilities");
50  gSystem->Load("StTreeMaker");
51  gSystem->Load("StIOMaker");
52  gSystem->Load("StarClassLibrary");
53  gSystem->Load("StEvent");
54  gSystem->Load("StEventMaker");
55  gSystem->Load("StHbtMaker");
56 
57  cout << " loading done " << endl;
58 
59  chain = new StChain("StChain");
60  chain->SetDebug();
61 
62  // file handling
63  StFile *setFiles= new StFile();
64  for (int ifil=0; fileList[ifil]; ifil++)
65  {
66  setFiles->AddFile(fileList[ifil]);
67  }
68 
69  // Hbt Maker
70  StHbtMaker* hbtMaker = new StHbtMaker("HBT","title");
71  cout << "StHbtMaker instantiated."<<endl;
72 
73 
74  // set up of hbt stuff
75  cout << "StHbtMaker::Init - setting up Reader and Analyses..." << endl;
76  StHbtManager* TheManager = hbtMaker->HbtManager();
77 
78  // set up mikro dst Reader
79  StHbtBinaryReader* Reader = new StHbtBinaryReader((const char*)0,*fileList,(const char*)0);
80  TheManager->SetEventReader(Reader);
81  cout << "READER SET UP.... " << endl;
82 
83 
84 
85  // ********************************************* //
86  // * ntuple chain
87  // ********************************************* //
88  // 0) now define an analysis...
89  StHbtAnalysis* ntupleAnal = new StHbtAnalysis;
90  // 1) set the Event cuts for the analysis
91  mikesEventCut* evcut = new mikesEventCut; // use "mike's" event cut object
92  evcut->SetEventMult(00,100000);
93  evcut->SetVertZPos(-50.0,50.0);
94  ntupleEvent* nevent = new ntupleEvent; // OR PRODUCE EVENT NTUPLE !!!
95  ntupleAnal->SetEventCut(nevent);
96  // 2) set the Track cut
97  franksTrackCut* piPlusTrkcut = new franksTrackCut(); // use "frank's" track cut object
98  piPlusTrkcut->SetNSigmaPion(-100.0,100.0);
99  piPlusTrkcut->SetNSigmaKaon(-100.0,100.0);
100  piPlusTrkcut->SetNSigmaProton(-100.0,100.0);
101  piPlusTrkcut->SetNHits(0,0 );
102  piPlusTrkcut->SetP(0.1,3.0);
103  piPlusTrkcut->SetPt(0.0,2.0);
104  piPlusTrkcut->SetRapidity(-1.0,1.0);
105  piPlusTrkcut->SetDCA(-1.0,1.0);
106  piPlusTrkcut->SetCharge(+1);
107  piPlusTrkcut->SetMass(0.139);
108  ntupleTrack* ntrack = new ntupleTrack(); // OR PRODUCE TRACK NTUPLE !!!
109  ntupleAnal->SetFirstParticleCut(ntrack); // this is the track cut for the "first" particle
110  ntupleAnal->SetSecondParticleCut(piPlusTrkcut); // this is the track cut for the "second" particle
111  // 3) set the Pair cuts for the analysis, must be provided !
112  qpc = new qualityPairCut();
113  ntupleAnal->SetPairCut(qpc); // this is the pair cut for this analysis
114  // 4) set the number of events to mix (per event)
115  ntupleAnal->SetNumEventsToMix(1);
116  // 5) now set up the correlation functions that this analysis will make
117  QinvEbyECorrFctn* QinvEbyECF = new QinvEbyECorrFctn("QinvEbyE",20,0.,.2);
118  ntupleAnal->AddCorrFctn(QinvEbyECF);
119  // 6) add the Analysis to the AnalysisCollection
120  TheManager->AddAnalysis(ntupleAnal);
121 
122 
123  // now run the chain
124  chain->Init(); // This should call the Init() method in ALL makers
125  chain->PrintInfo();
126 
127  for (Int_t iev=0;iev<nevents; iev++) {
128  cout << "StHbtExample -- Working on eventNumber " << iev << endl;
129  chain->Clear();
130  int iret = chain->Make(iev); // This should call the Make() method in ALL makers
131  if (iret) {
132  cout << "Bad return code!" << endl;
133  break;
134  }
135  } // Event Loop
136  chain->Finish(); // This should call the Finish() method in ALL makers
137 
138 }
139 
140 
141 
Definition: StTree.h:125
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Int_t Make()
Definition: StChain.cxx:110