StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
hbt.cc
1 #include <iostream>
2 
3 // Hbt stuff
4 #include "StHbtMaker.h"
5 #include "StHbtManager.h"
6 #include "StHbtAnalysis.h"
7 #include "franksTrackCut.h"
8 #include "trackCutMonitor_P_vs_Dedx.h"
9 #include "mikesEventCut.h"
10 #include "mikesPairCut.h"
11 #include "StHbtAsciiReader.h"
12 #include "StHbtBinaryReader.h"
13 #include "MinvCorrFctn.h"
14 
15 void wait(int n=1) {
16  for ( int i=0; i<n*1e6; i++) { /*no-op*/ }
17 }
18 void mess(const char* c="alive") {
19  for ( int i=0; i<10; i++) { cout << c << endl; }
20 }
21 
22 
23 //==========================================================================================
24 #ifdef __ROOT__
25 int hbt(int argc, char* argv[]) {
26 #else
27 int main(int argc, char* argv[]) {
28 #endif
29 
30  int nevents;
31  char* fileType;
32  char* fileName;
33 
34  switch (argc) {
35  case 4:
36  nevents = atoi(argv[1]);
37  fileType=argv[2];
38  fileName=argv[3];
39  break;
40  default:
41  cout << "usage: hbt nevents asc/bin filename" << endl;
42  return -1;
43  }
44  cout << " nevents = " << nevents << endl;
45  cout << " fileType = " << fileType << endl;
46  cout << " fileName = " << fileName << endl;
47 
48  char* fileAppendix = fileName+strlen(fileName) -4 ;
49  cout << " fileAppendix = " << fileAppendix << endl;
50  // *********
51  // Hbt Maker
52  // *********
53  StHbtMaker* hbtMaker = new StHbtMaker("HBT","title");
54  cout << "StHbtMaker instantiated"<<endl;
55  // -------------- set up of hbt stuff ----- //
56  cout << "StHbtMaker::Init - setting up Reader and Analyses..." << endl;
57  StHbtManager* TheManager = hbtMaker->HbtManager();
58 
59  // ***********************
60  // setup HBT event readers
61  // ***********************
62  StHbtAsciiReader* ascReader;
63  StHbtBinaryReader* binReader;
64  if ( !strcmp(fileType,"asc") ) {
65  ascReader = new StHbtAsciiReader;
66  ascReader->SetFileName(fileName);
67  TheManager->SetEventReader(ascReader);
68  }
69  else if ( !strcmp(fileType,"bin") ) {
70  binReader = new StHbtBinaryReader(0,fileName,0);
71  cout << " now parse files " << endl;
72  /*
73  if ( !strcmp(fileAppendix,".lis") ) {
74  binReader->AddFileList(fileName);
75  cout << " file list added " << endl;
76  }
77  else {
78  binReader->SetFileName(fileName);
79  cout << " file name set " << endl;
80  }
81  */
82  TheManager->SetEventReader(binReader);
83  }
84  else {
85  cout << "unknown fileType : " << fileType << endl;
86  return -2;
87  }
88  cout << "READER SET UP.... " << endl;
89 
90  // define example particle cut and cut monitors to use in the analyses
91  // example particle cut
92  franksTrackCut* aParticleCut = new franksTrackCut; // use "frank's" particle cut object
93  aParticleCut->SetNSigmaPion(+3.0,1.e5); // number of Sigma in TPC dEdx away from nominal pion dEdx
94  aParticleCut->SetNSigmaKaon(-2.,2.); // number of Sigma in TPC dEdx away from nominal kaon dEdx
95  aParticleCut->SetNSigmaProton(-1.e5,-1.0); // number of Sigma in TPC dEdx away from nominal proton dEdx
96  aParticleCut->SetNHits(5,50); // range on number of TPC hits on the track
97  aParticleCut->SetP(0.23,1.0); // range in P
98  aParticleCut->SetPt(0.0,2.0); // range in Pt
99  aParticleCut->SetRapidity(-1.5,1.5); // range in rapidity
100  aParticleCut->SetDCA(0,2.); // range in Distance of Closest Approach to primary vertex
101  aParticleCut->SetCharge(+1); // want positive kaons
102  aParticleCut->SetMass(0.494); // kaon mass
103  // example cut monitor
104  trackCutMonitor_P_vs_Dedx* aDedxMoniPos = new trackCutMonitor_P_vs_Dedx(+1,"P_vs_Dedx +","Momentum (GeV/c) vs Energy loss (a.u.)",
105  100,0.,1.2,100,0.,1e-5);
106  trackCutMonitor_P_vs_Dedx* aDedxMoniNeg = new trackCutMonitor_P_vs_Dedx(-1,"P_vs_Dedx -","Momentum (GeV/c) vs Energy loss (a.u.)",
107  100,0.,1.2,100,0.,1e-5);
108  // now, we define another analysis that runs simultaneously with the previous one.
109  // this one looks at K+K- correlations (so NONidentical particles) in invariant mass
110  // ****************************************** //
111  // * franks phi analysis - by Frank Laue, OSU //
112  // ****************************************** //
113  // 0) now define an analysis...
114  StHbtAnalysis* phiAnal = new StHbtAnalysis;
115  phiAnal = new StHbtAnalysis;
116  // 1) set the Event cuts for the analysis
117  mikesEventCut* phiEvcut = new mikesEventCut; // use "mike's" event cut object
118  phiEvcut->SetEventMult(000,100000); // selected multiplicity range
119  phiEvcut->SetVertZPos(-35.0,35.0); // selected range of vertex z-position
120  //eventCutMonitor_Mult* multMoniPass = new eventCutMonitor_Mult();
121  //eventCutMonitor_Mult* multMoniFail = new eventCutMonitor_Mult();
122  //phiEvcut->AddCutMonitor(multMoniPass, multMoniFail);
123  phiAnal->SetEventCut(phiEvcut); // this is the event cut object for this analsys
124  // 2) set the Track (particle) cuts for the analysis
125  franksTrackCut* kaonTrkcut = new franksTrackCut( *aParticleCut ); // copy from example
126  // new particle cut moni
127  trackCutMonitor_P_vs_Dedx* dedxMoniPosPass = new trackCutMonitor_P_vs_Dedx( *aDedxMoniPos);
128  trackCutMonitor_P_vs_Dedx* dedxMoniPosFail = new trackCutMonitor_P_vs_Dedx( *aDedxMoniPos);
129  kaonTrkcut->AddCutMonitor( dedxMoniPosPass, dedxMoniPosFail);
130  phiAnal->SetFirstParticleCut(kaonTrkcut); // this is the track cut for the "first" particle
131  // copy second particle cut from first particle cut
132  franksTrackCut* antikaonTrkcut = new franksTrackCut( *((franksTrackCut*)phiAnal->FirstParticleCut()) );
133  antikaonTrkcut->SetCharge(-1);
134  phiAnal->SetSecondParticleCut(antikaonTrkcut); // this is the track cut for the "first" particle
135  // new particle cut
136  trackCutMonitor_P_vs_Dedx* dedxMoniNegPass = new trackCutMonitor_P_vs_Dedx( *aDedxMoniNeg);
137  trackCutMonitor_P_vs_Dedx* dedxMoniNegFail = new trackCutMonitor_P_vs_Dedx( *aDedxMoniNeg);
138  antikaonTrkcut->AddCutMonitor( dedxMoniNegPass, dedxMoniNegFail);
139  // 3) set the Pair cuts for the analysis
140  mikesPairCut* phiPairCut = new mikesPairCut; // use "frank's" pair cut object
141  // phiPairCut->SetAngle(0.,180.); // opening angle
142  phiAnal->SetPairCut(phiPairCut); // this is the pair cut for this analysis
143  // 4) set the number of events to mix (per event)
144  phiAnal->SetNumEventsToMix(5);
145  // ********************************************************************
146  // 5) now set up the correlation functions that this analysis will make
147  // ********************************************************************
148  // define example Minv correlation function
149  MinvCorrFctn* MinvCF = new MinvCorrFctn("Minv",150,0.95,1.25);
150  phiAnal->AddCorrFctn(MinvCF); // adds the just-defined correlation function to the analysis
151 
152  TheManager->AddAnalysis(phiAnal);
153 
154  // now perform the event loop
155  int iret=0;
156  iret = hbtMaker->Init();
157  for (int iev=0;iev<nevents; iev++) {
158  hbtMaker->Clear();
159  iret = hbtMaker->Make();
160  cout << "StHbtExample -- Working on eventNumber " << iev << endl;
161  } // Event Loop
162  iret = hbtMaker->Finish();
163 
164  ((MinvCorrFctn*)((StHbtAnalysis*)hbtMaker->HbtManager()->Analysis(0))->CorrFctn(0))->Difference()->Draw();
165 
166  return 0;
167 } // main
168 
169