StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
hbtQinv.cc
1 #include <iostream>
2 
3 // Hbt stuff
4 #include "StHbtMaker.h"
5 #include "StHbtManager.h"
6 #include "StHbtVertexAnalysis.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 "QinvCorrFctn.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(-2.0,+2.0); // number of Sigma in TPC dEdx away from nominal pion dEdx
94  aParticleCut->SetNSigmaAntiElectron(-2.0,+2.0); // number of Sigma in TPC dEdx away from nominal pion dEdx
95  aParticleCut->SetNHits(5,50); // range on number of TPC hits on the track
96  aParticleCut->SetP(0.23,1.0); // range in P
97  aParticleCut->SetPt(0.0,2.0); // range in Pt
98  aParticleCut->SetRapidity(-1.5,1.5); // range in rapidity
99  aParticleCut->SetDCA(0,2.); // range in Distance of Closest Approach to primary vertex
100  aParticleCut->SetCharge(+1); // want positive kaons
101  aParticleCut->SetMass(0.494); // kaon mass
102  // example cut monitor
103  trackCutMonitor_P_vs_Dedx* aDedxMoniPos = new trackCutMonitor_P_vs_Dedx(+1,"P_vs_Dedx +","Momentum (GeV/c) vs Energy loss (a.u.)",
104  100,0.,1.2,100,0.,1e-5);
105  trackCutMonitor_P_vs_Dedx* aDedxMoniNeg = new trackCutMonitor_P_vs_Dedx(-1,"P_vs_Dedx -","Momentum (GeV/c) vs Energy loss (a.u.)",
106  100,0.,1.2,100,0.,1e-5);
107  // now, we define another analysis that runs simultaneously with the previous one.
108  // this one looks at K+K- correlations (so NONidentical particles) in invariant mass
109  // ****************************************** //
110  // * franks phi analysis - by Frank Laue, OSU //
111  // ****************************************** //
112  // 0) now define an analysis...
113  StHbtVertexAnalysis* phiAnal = new StHbtVertexAnalysis(80,-40.,40.);
114  phiAnal = new StHbtVertexAnalysis;
115  // 1) set the Event cuts for the analysis
116  mikesEventCut* phiEvcut = new mikesEventCut; // use "mike's" event cut object
117  phiEvcut->SetEventMult(000,100000); // selected multiplicity range
118  phiEvcut->SetVertZPos(-40.0,40.0); // selected range of vertex z-position
119  //phiEvcut->AddCutMonitor(multMoniPass, multMoniFail);
120  phiAnal->SetEventCut(phiEvcut); // this is the event cut object for this analsys
121  // 2) set the Track (particle) cuts for the analysis
122  franksTrackCut* kaonTrkcut = new franksTrackCut( *aParticleCut ); // copy from example
123  // new particle cut moni
124  trackCutMonitor_P_vs_Dedx* dedxMoniPosPass = new trackCutMonitor_P_vs_Dedx( *aDedxMoniPos);
125  trackCutMonitor_P_vs_Dedx* dedxMoniPosFail = new trackCutMonitor_P_vs_Dedx( *aDedxMoniPos);
126  kaonTrkcut->AddCutMonitor( dedxMoniPosPass, dedxMoniPosFail);
127  phiAnal->SetFirstParticleCut(kaonTrkcut); // this is the track cut for the "first" particle
128  phiAnal->SetSecondParticleCut(kaonTrkcut); // this is the track cut for the "first" particle
129  // 3) set the Pair cuts for the analysis
130  mikesPairCut* phiPairCut = new mikesPairCut; // use "frank's" pair cut object
131  // phiPairCut->SetAngle(0.,180.); // opening angle
132  phiAnal->SetPairCut(phiPairCut); // this is the pair cut for this analysis
133  // 4) set the number of events to mix (per event)
134  phiAnal->SetNumEventsToMix(10);
135  // ********************************************************************
136  // 5) now set up the correlation functions that this analysis will make
137  // ********************************************************************
138  // define example Qinv correlation function
139  QinvCorrFctn* QinvCF = new QinvCorrFctn("Qinv",25,0,0.25);
140  phiAnal->AddCorrFctn(QinvCF); // adds the just-defined correlation function to the analysis
141 
142  TheManager->AddAnalysis(phiAnal);
143 
144  // now perform the event loop
145  int iret=0;
146  iret = hbtMaker->Init();
147  for (int iev=0;iev<nevents; iev++) {
148  hbtMaker->Clear();
149  iret = hbtMaker->Make();
150  cout << "StHbtExample -- Working on eventNumber " << iev << endl;
151  } // Event Loop
152  iret = hbtMaker->Finish();
153 
154  ((QinvCorrFctn*)((StHbtVertexAnalysis*)hbtMaker->HbtManager()->Analysis(0))->CorrFctn(0))->Ratio()->Draw();
155 
156  return 0;
157 } // main
158 
159