1 |
pam-fi |
1.1 |
/* |
2 |
|
|
* TofDedxVsBetaHistoAction.cpp |
3 |
|
|
* |
4 |
|
|
* Created on: 25-giu-2009 |
5 |
|
|
* Author: Nicola Mori |
6 |
|
|
*/ |
7 |
|
|
|
8 |
|
|
/*! @file TofDedxVsBetaHistoAction.cpp The TofDedxVsBetaHistoAction class implementation file. */ |
9 |
|
|
|
10 |
|
|
#include "TofDedxVsBetaHistoAction.h" |
11 |
|
|
|
12 |
|
|
TofDedxVsBetaHistoAction::TofDedxVsBetaHistoAction(const char *actionName, unsigned int layers, bool standAlone, |
13 |
|
|
TString outFileBase, TString mode, bool outRoot, bool outText, TString title) : |
14 |
pam-fi |
1.4 |
Histo2DAction<Int_t>(actionName, title, outFileBase, mode, outRoot, outText), _layers(layers), _nLayers(0), _badEvents( |
15 |
|
|
0), _standAlone(standAlone) { |
16 |
pam-fi |
1.1 |
|
17 |
pam-fi |
1.3 |
bool buildTitle = false; |
18 |
pam-fi |
1.1 |
if (title == "") { |
19 |
pam-fi |
1.3 |
buildTitle = true; |
20 |
pam-fi |
1.1 |
title = "TOF dE/dx ("; |
21 |
pam-fi |
1.2 |
} |
22 |
|
|
if ((_layers & S11) == S11) { |
23 |
pam-fi |
1.3 |
if (buildTitle) |
24 |
|
|
title += "S11"; |
25 |
pam-fi |
1.2 |
_nLayers++; |
26 |
|
|
} |
27 |
|
|
if ((_layers & S12) == S12) { |
28 |
pam-fi |
1.3 |
if (buildTitle) { |
29 |
|
|
if (_nLayers > 0) |
30 |
|
|
title += ","; |
31 |
|
|
title += "S12"; |
32 |
|
|
} |
33 |
pam-fi |
1.2 |
_nLayers++; |
34 |
|
|
} |
35 |
|
|
if ((_layers & S21) == S21) { |
36 |
pam-fi |
1.3 |
if (buildTitle) { |
37 |
|
|
if (_nLayers > 0) |
38 |
|
|
title += ","; |
39 |
|
|
title += "S21"; |
40 |
|
|
} |
41 |
pam-fi |
1.2 |
_nLayers++; |
42 |
|
|
} |
43 |
|
|
if ((_layers & S22) == S22) { |
44 |
pam-fi |
1.3 |
if (buildTitle) { |
45 |
|
|
if (_nLayers > 0) |
46 |
|
|
title += ","; |
47 |
|
|
title += "S22"; |
48 |
|
|
} |
49 |
pam-fi |
1.2 |
_nLayers++; |
50 |
|
|
} |
51 |
|
|
if ((_layers & S31) == S31) { |
52 |
pam-fi |
1.3 |
if (buildTitle) { |
53 |
|
|
if (_nLayers > 0) |
54 |
|
|
title += ","; |
55 |
|
|
title += "S31"; |
56 |
|
|
} |
57 |
pam-fi |
1.2 |
_nLayers++; |
58 |
|
|
} |
59 |
|
|
if ((_layers & S32) == S32) { |
60 |
pam-fi |
1.3 |
if (buildTitle) { |
61 |
|
|
if (_nLayers > 0) |
62 |
|
|
title += ","; |
63 |
|
|
title += "S32"; |
64 |
|
|
} |
65 |
pam-fi |
1.2 |
_nLayers++; |
66 |
|
|
} |
67 |
pam-fi |
1.3 |
if (buildTitle) |
68 |
|
|
title += ") Vs Beta"; |
69 |
pam-fi |
1.1 |
|
70 |
pam-fi |
1.2 |
SetTitle(title); |
71 |
pam-fi |
1.1 |
|
72 |
|
|
} |
73 |
|
|
|
74 |
|
|
void TofDedxVsBetaHistoAction::OnGood(PamLevel2 *event) { |
75 |
|
|
|
76 |
|
|
static float dEdx; |
77 |
|
|
static float dEdxLayer; |
78 |
|
|
static unsigned int badLayers; |
79 |
|
|
|
80 |
|
|
static int trkSeqNo; |
81 |
pam-fi |
1.5 |
static int idx; |
82 |
pam-fi |
1.1 |
if (_standAlone) |
83 |
pam-fi |
1.5 |
trkSeqNo = -1; |
84 |
pam-fi |
1.1 |
else |
85 |
pam-fi |
1.5 |
trkSeqNo = event->GetTrack(0)->GetTrkTrack()->GetSeqNo(); |
86 |
|
|
|
87 |
|
|
for (int i = 0; i < event->GetToFLevel2()->ntrk(); i++) { |
88 |
|
|
if (event->GetToFLevel2()->GetToFTrkVar(i)->trkseqno == trkSeqNo) |
89 |
|
|
idx = i; |
90 |
|
|
} |
91 |
pam-fi |
1.1 |
|
92 |
|
|
dEdx = 0.; |
93 |
|
|
badLayers = 0; |
94 |
|
|
if ((_layers & S11) == S11) { |
95 |
pam-fi |
1.5 |
dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 0, 100); |
96 |
pam-fi |
1.4 |
// Patch to exclude S115b |
97 |
pam-fi |
1.5 |
ToFTrkVar *tofTrk = event->GetToFLevel2()->GetToFTrkVar(idx); |
98 |
pam-fi |
1.4 |
bool has8 = false, has9 = false; |
99 |
|
|
float dedx9 = 0.; |
100 |
|
|
for (Int_t ib = 0; ib < tofTrk->npmtadc; ib++) { |
101 |
|
|
if (tofTrk->pmtadc[ib] == 8) { |
102 |
|
|
has8 = true; |
103 |
|
|
} |
104 |
|
|
if (tofTrk->pmtadc[ib] == 9) { |
105 |
|
|
has9 = true; |
106 |
|
|
dedx9 = tofTrk->dedx[ib]; |
107 |
|
|
} |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
if (has9) { |
111 |
|
|
dEdxLayer -= (dedx9 / ((int) has8 + 1)); |
112 |
|
|
dEdxLayer *= 2.; |
113 |
|
|
} |
114 |
|
|
//End of patch |
115 |
pam-fi |
1.1 |
if (dEdxLayer > 0. && dEdxLayer < 4090) |
116 |
|
|
dEdx += dEdxLayer; |
117 |
|
|
else |
118 |
|
|
badLayers++; |
119 |
|
|
} |
120 |
|
|
if ((_layers & S12) == S12) { |
121 |
pam-fi |
1.5 |
dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 1, 100); |
122 |
pam-fi |
1.1 |
if (dEdxLayer > 0. && dEdxLayer < 4090) |
123 |
|
|
dEdx += dEdxLayer; |
124 |
|
|
else |
125 |
|
|
badLayers++; |
126 |
|
|
} |
127 |
|
|
if ((_layers & S21) == S21) { |
128 |
pam-fi |
1.5 |
dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 2, 100); |
129 |
pam-fi |
1.1 |
if (dEdxLayer > 0. && dEdxLayer < 4090) |
130 |
|
|
dEdx += dEdxLayer; |
131 |
|
|
else |
132 |
|
|
badLayers++; |
133 |
|
|
} |
134 |
|
|
if ((_layers & S22) == S22) { |
135 |
pam-fi |
1.5 |
dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 3, 100); |
136 |
pam-fi |
1.1 |
if (dEdxLayer > 0. && dEdxLayer < 4090) |
137 |
|
|
dEdx += dEdxLayer; |
138 |
|
|
else |
139 |
|
|
badLayers++; |
140 |
|
|
} |
141 |
|
|
if ((_layers & S31) == S31) { |
142 |
pam-fi |
1.5 |
dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 4, 100); |
143 |
pam-fi |
1.1 |
if (dEdxLayer > 0. && dEdxLayer < 4090) |
144 |
|
|
dEdx += dEdxLayer; |
145 |
|
|
else |
146 |
|
|
badLayers++; |
147 |
|
|
} |
148 |
|
|
if ((_layers & S32) == S32) { |
149 |
pam-fi |
1.5 |
dEdxLayer = event->GetToFLevel2()->GetdEdx(idx, 5, 100); |
150 |
pam-fi |
1.1 |
if (dEdxLayer > 0. && dEdxLayer < 4090) |
151 |
|
|
dEdx += dEdxLayer; |
152 |
|
|
else |
153 |
|
|
badLayers++; |
154 |
|
|
} |
155 |
|
|
if (badLayers == 0) { |
156 |
pam-fi |
1.2 |
dEdx /= _nLayers; |
157 |
pam-fi |
1.5 |
Fill(event->GetToFLevel2()->GetToFTrkVar(idx)->beta[12], dEdx); |
158 |
pam-fi |
1.1 |
} |
159 |
|
|
else |
160 |
|
|
_badEvents++; |
161 |
|
|
} |
162 |
|
|
|