-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTrackUtilities.C
executable file
·159 lines (132 loc) · 4.83 KB
/
TrackUtilities.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
#ifndef TrackUtilities_C
#define TrackUtilities_C
#include <TMath.h>
// Calo Matching -----------------------------------------
void HiForest::matchTrackCalo(bool allEvents){
if(allEvents || currentEvent == 0){
towerEt = new Float_t[maxEntry];
towerdR = new Float_t[maxEntry];
hbheEt = new Float_t[maxEntry];
hbhedR = new Float_t[maxEntry];
trackTree->Branch("towerEt",towerEt,"towerEt[nTrk]/F");
trackTree->Branch("towerdR",towerdR,"towerdR[nTrk]/F");
trackTree->Branch("hbhedR",hbheEt,"hbhedR[nTrk]/F");
trackTree->Branch("hbheEt",hbheEt,"hbheEt[nTrk]/F");
}
for (int i=0; allEvents ? i<GetEntries() : 1;i++){
if(allEvents) GetEntry(i);
for (int j=0;j<track.nTrk;j++) {
int matchedTower = getMatchedCaloTowerAllowReuse(j);
int matchedHBHE = getMatchedHBHEAllowReuse(j);
float matchedTowerdR = deltaR(track.trkEta[j],track.trkPhi[j],tower.eta[matchedTower],tower.phi[matchedTower]);
float matchedHbhedR = deltaR(track.trkEta[j],track.trkPhi[j],hbhe.eta[matchedHBHE],hbhe.phi[matchedHBHE]);
towerEt[j]=tower.et[matchedTower];
towerdR[j]=matchedTowerdR;
hbheEt[j]=hbhe.et[matchedHBHE];
hbhedR[j]=matchedHbhedR;
}
trackTree->Fill();
}
}
int HiForest::getMatchedCaloTowerAllowReuse(int j)
{
int best=-1;
float bestDR2 = 1e10;
float eta = track.trkEta[j];
float phi = track.trkPhi[j];
for (int i=0; i<tower.n; i++)
{
float dR2 = deltaR2(eta,phi,tower.eta[i],tower.phi[i]);
if (dR2<bestDR2) {
bestDR2 = dR2;
best = i;
}
}
return best;
}
int HiForest::getMatchedHBHEAllowReuse(int j)
{
int best=-1;
float bestDR2 = 1e10;
float eta = track.trkEta[j];
float phi = track.trkPhi[j];
for (int i=0; i<hbhe.n; i++)
{
float dR2 = deltaR2(eta,phi,hbhe.eta[i],hbhe.phi[i]);
if (dR2<bestDR2) {
bestDR2 = dR2;
best = i;
}
}
return best;
}
double HiForest::getTrackCorrectionPara(int j)
{
float trackWt_fromParam=0;
if (track.trkAlgo[j]>=4&&!(track.highPurity[j])) return 0;
if (initialized) {
trackWt_fromParam = trackCorrFromParam->GetCorr(track.trkEta[j],track.trkPt[j],track.trkPhi[j],evt.hiBin);
} else {
cout <<"FATAL: Tracking correction is not initialized. Return 0, Please do HiForest->InitTree()."<<endl;
}
return trackWt_fromParam;
}
double HiForest::getTrackCorrection(int j)
{
double trkWt = 0;
if (track.trkAlgo[j]>=4&&!(track.highPurity[j])) return 0;
if (initialized) {
// check if the leading and subleading jet is found
if (leadingJetPtForTrkCor<-1) {
// Select leading and subleading jet
for (int k=0; k<akPu3PF.nref; k++) {
if (TMath::Abs(akPu3PF.jteta[k])>2) continue;
if (akPu3PF.jtpt[k]>leadingJetPtForTrkCor) {
leadingJetPtForTrkCor = akPu3PF.jtpt[k];
leadingJetEtaForTrkCor = akPu3PF.jteta[k];
leadingJetPhiForTrkCor = akPu3PF.jtphi[k];
}
if (akPu3PF.jtpt[k]>subleadingJetPtForTrkCor && akPu3PF.jtpt[k] < leadingJetPtForTrkCor) {
subleadingJetPtForTrkCor = akPu3PF.jtpt[k];
subleadingJetEtaForTrkCor = akPu3PF.jteta[k];
subleadingJetPhiForTrkCor = akPu3PF.jtphi[k];
}
if (akPu3PF.jtpt[k]<subleadingJetPtForTrkCor) break;
}
}
} else {
cout <<"FATAL: Tracking correction is not initialized. Return 0, Please do HiForest->InitTree()."<<endl;
return 0;
}
double dr1 = deltaR(track.trkEta[j], track.trkPhi[j],leadingJetEtaForTrkCor, leadingJetPhiForTrkCor);
double dr2 = deltaR(track.trkEta[j], track.trkPhi[j],subleadingJetEtaForTrkCor, subleadingJetPhiForTrkCor);
int leadingSet=0, subleadingSet=0;
if (doTrackingSeparateLeadingSubleading) {
leadingSet=1;
subleadingSet=2;
}
if (leadingJetPtForTrkCor>=minJetPtForTrkCor&&dr1<0.5) {
trkWt = trackCorrections[leadingSet]->GetCorr(track.trkPt[j],track.trkEta[j],leadingJetPtForTrkCor,evt.hiBin);
} else if (subleadingJetPtForTrkCor>=minJetPtForTrkCor&&dr2<0.5) {
trkWt = trackCorrections[subleadingSet]->GetCorr(track.trkPt[j],track.trkEta[j],subleadingJetPtForTrkCor,evt.hiBin);
} else {
trkWt = trackCorrections[0]->GetCorr(track.trkPt[j],track.trkEta[j],0,evt.hiBin);
}
return trkWt;
}
bool HiForest::selectTrack(int j){
if(j >= track.nTrk) return 0;
if(1 || collisionMode==cPPb){
if(!(track.highPurity[j])) return 0 ;
if(TMath::Abs(track.trkDz1[j]/track.trkDzError1[j]) > 3) return 0 ;
if(TMath::Abs(track.trkDxy1[j]/track.trkDxyError1[j]) > 3) return 0 ;
if(track.trkPtError[j]/track.trkPt[j]>0.1) return 0 ;
if(TMath::Abs(track.trkEta[j]) > 2.4) return 0;
if(track.trkPt[j] < 0.4) return 0;
}else{
cout<<"Track selection not implemented for this type of collision!"<<endl;
return 0;
}
return 1;
}
#endif