-
Notifications
You must be signed in to change notification settings - Fork 0
/
run17pp510.C
212 lines (195 loc) · 7.12 KB
/
run17pp510.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#include <iostream>
#include "TFile.h"
#include "TNtuple.h"
#include "TTree.h"
#include "TH1.h"
#include "TH2.h"
#include "TTree.h"
#include <TSystem>
class StPicoDstMaker;
class StSpinDbMaker;
class StChain;
class StMaker;
class StPicoDstMaker;
class StPicoDst;
class StPicoEvent;
class St_db_Maker;
StPicoDstMaker *maker;
int n = 0;
// void run17pp510(const char* list, const char* oFile, const char* jobid)
void run17pp510(const char *list, const char *oFile) // interactive mode
{
gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
loadSharedLibraries();
gSystem->Load("StPicoEvent");
gSystem->Load("StPicoDstMaker");
gSystem->Load("StSpinDbMaker");
gSystem->Load("StDbBroker");
gSystem->Load("St_db_Maker");
// Float_t->F, Int_t->I,Double_t->D, UShort_t ->s,Short_t ->S
// Define in /StRoot/StMuDSTMaker/COMMON/StMuTrack.h
const int fMaxHit = 3000;
Int_t ffillNum;
Int_t fevtNum;
Int_t frunNum;
Int_t fspinconfig;
// Int_t ftrigger;
vector<int> ftrigger;
Int_t fmaxpar;
Int_t fTrackCounter;
Double_t fVZ;
Double_t fvzVpd;
Double_t fpT[fMaxHit];
Double_t fp[fMaxHit];
Double_t feta[fMaxHit];
Double_t fphi[fMaxHit];
Double_t fnSigmaPion[fMaxHit];
Double_t fnSigmaKaon[fMaxHit];
Double_t fnSigmaProton[fMaxHit];
Double_t fnSigmaElectron[fMaxHit];
Short_t fcharge[fMaxHit];
Double_t fdEdx[fMaxHit];
Double_t fdca[fMaxHit];
UShort_t ffitPts[fMaxHit];
UShort_t ffitPtsPoss[fMaxHit];
UShort_t fhitsdedx[fMaxHit];
Double_t fBetaToF[fMaxHit];
unsigned int fevTime;
unsigned int frunTime;
Int_t triggerIds[34];
Int_t fMaxTrig;
Int_t bunchId;
//======================= Tree Branch Declearation ===========================
TFile *fout = new TFile(oFile, "recreate");
TTree *ftree = new TTree("ftree", "dihadron ");
ftree->Branch("fevtNum", &fevtNum, "fevtNum/I");
ftree->Branch("ffillNum", &ffillNum, "ffillNum/I");
ftree->Branch("frunNum", &frunNum, "frunNum/I");
ftree->Branch("fspinconfig", &fspinconfig, "fspinconfig/I");
// ftree->Branch("ftrigger", &ftrigger, "ftrigger/I");
ftree->Branch("ftrigger", &ftrigger);
ftree->Branch("fmaxpar", &fmaxpar, "fmaxpar/I");
ftree->Branch("fVZ", &fVZ, "fVZ/D");
ftree->Branch("fvzVpd", &fvzVpd, "fvzVpd/D");
ftree->Branch("fpT", fpT, "fpT[fmaxpar]/D");
ftree->Branch("fp", fp, "fp[fmaxpar]/D");
ftree->Branch("feta", feta, "feta[fmaxpar]/D");
ftree->Branch("fphi", fphi, "fphi[fmaxpar]/D");
ftree->Branch("fcharge", fcharge, "fcharge[fmaxpar]/S");
ftree->Branch("fnSigmaPion", fnSigmaPion, "fnSigmaPion[fmaxpar]/D");
ftree->Branch("fnSigmaKaon", fnSigmaKaon, "fnSigmaKaon[fmaxpar]/D");
ftree->Branch("fnSigmaProton", fnSigmaProton, "fnSigmaProton[fmaxpar]/D");
ftree->Branch("fnSigmaElectron", fnSigmaElectron, "fnSigmaElectron[fmaxpar]/D");
ftree->Branch("fdEdx", fdEdx, "fdEdx[fmaxpar]/D");
ftree->Branch("fdca", fdca, "fdca[fmaxpar]/D");
ftree->Branch("ffitPts", ffitPts, "ffitPts[fmaxpar]/s");
ftree->Branch("ffitPtsPoss", ffitPtsPoss, "ffitPtsPoss[fmaxpar]/s");
ftree->Branch("fhitsdedx", fhitsdedx, "fhitsdedx[fmaxpar]/s");
ftree->Branch("fBetaToF", fBetaToF, "fBetaToF[fmaxpar]/D");
ftree->Branch("fevTime", &fevTime, "fevTime/I");
cout << "----------------OUTPUT File name is------------- : " << oFile << endl;
// char file2[512]= "" ; char krappy[216]= "valami";
chain = new StChain("StChain");
chain->SetDebug(0);
StPicoDstMaker *maker = new StPicoDstMaker(2, list, "picoDst");
St_db_Maker *stDb = new St_db_Maker("StarDb", "MySQL:StarDb");
StSpinDbMaker *spindb = new StSpinDbMaker;
//=====================open database connection for spin configuration===================
const char *database = "mysql://db04.star.bnl.gov:3416/RunLog?timeout=60";
const char *user = "nghimire";
const char *pass = "";
TMySQLServer *mysql = TMySQLServer::Connect(database, user, pass);
float dca;
Int_t i = 0;
chain->Init();
Int_t nevents = maker->chain()->GetEntries();
cout << nevents << "-------nevents-----------" << endl;
// while (!maker->Make())
while (!chain->Make())
{
StPicoDst *pico = maker->picoDst();
StPicoEvent *ev = pico->event();
if (!ev)
continue;
// Adding ranking cut=============
Float_t ranking = ev->ranking();
if (ranking < 1e6)
continue;
// Adding ranking cut=============
unsigned int fevTime = ev->time();
if (fabs(ev->primaryVertex().X() > 1. || fabs(ev->primaryVertex().Y() > 1.)))
continue;
Int_t bx48 = ev->bunchId();
fspinconfig = spindb->spin8usingBX48(bx48);
if (fspinconfig != 51 && fspinconfig != 53 && fspinconfig != 83 && fspinconfig != 85)
continue;
Int_t frunId = ev->runId();
Int_t ffillNum = ev->fillId();
int frunNum = ev->runId();
int fevtNum = ev->eventId();
Double_t fVZ = ev->primaryVertex().Z();
Double_t fvzVpd = -999; // This step is crucial, not using this would give largely increased weired distribution around zero.
fvzVpd = ev->vzVpd();
vector<unsigned int> TriggerIds = ev->triggerIds(); // Had trouble when define Vector TriggerIds in the top and try to run the code so I declare it here.
// cout << TriggerIds.size()<< " Size of Trigger id "<< endl;
int fTrigCounter = 0;
ftrigger.clear();
for (int i = 0; i < TriggerIds.size(); i++)
{
triggerIds[fTrigCounter] = TriggerIds.at(i);
ftrigger.push_back(TriggerIds.at(i));
// cout << ftrigger.at(i) << " TriggerId"<< endl;
fTrigCounter++;
}
fMaxTrig = fTrigCounter;
int ntrk = pico->numberOfTracks();
fTrackCounter = 0;
for (int j = 0; j < ntrk; j++)
{
StPicoEvent *ev = maker->picoDst()->event();
StPicoTrack *track = pico->track(j);
if (!track->isPrimary())
continue;
n = n + 1;
float Eta = track->pMom().Eta();
Double_t Vx = ev->primaryVertex().X();
Double_t Vy = ev->primaryVertex().Y();
Double_t Vz = ev->primaryVertex().Z();
float trackDCA = track->gDCA(Vx, Vy, Vz);
if (fabs(Eta) < 1.5 && track->nHitsFit() > 12 && fabs(trackDCA) < 3.)
{
fpT[fTrackCounter] = track->pPt();
fp[fTrackCounter] = track->pMom().Mag();
feta[fTrackCounter] = track->pMom().Eta();
fphi[fTrackCounter] = track->pMom().Phi();
fnSigmaPion[fTrackCounter] = track->nSigmaPion();
fnSigmaKaon[fTrackCounter] = track->nSigmaKaon();
fnSigmaProton[fTrackCounter] = track->nSigmaProton();
fnSigmaElectron[fTrackCounter] = track->nSigmaElectron();
fcharge[fTrackCounter] = track->charge();
fdEdx[fTrackCounter] = track->dEdx();
fdca[fTrackCounter] = trackDCA;
ffitPts[fTrackCounter] = track->nHitsFit();
fhitsdedx[fTrackCounter] = track->nHitsDedx();
ffitPtsPoss[fTrackCounter] = track->nHitsPoss();
float trackBeta = -999.;
int trackTofIndex = track->bTofPidTraitsIndex();
if (trackTofIndex >= 0)
fBetaToF[fTrackCounter] = pico->btofPidTraits(trackTofIndex)->btofBeta();
fTrackCounter++;
} // if statement close
} // for loop close(Track)
fmaxpar = fTrackCounter;
// cout << fmaxpar << "fmaxpar"<< endl;
if (fmaxpar > 1)
ftree->Fill();
} // while loop loop close // event loop
fout->cd();
ftree->Write();
fout->Close();
cout << "done" << endl;
flush(cout);
mysql->Close();
cout << n << "Total track with isPrimary() working" << endl;
cout << "-----------Time to Close the Shop---------------" << endl;
} // run17pp510 function