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, TString outFileName, unsigned int layers, |
13 |
pam-fi |
1.2 |
TString mode, bool standAlone, float minDedx, float maxDedx, unsigned int nBinsDedx, float minBeta, float maxBeta, |
14 |
pam-fi |
1.1 |
unsigned int nBinsBeta) : |
15 |
pam-fi |
1.2 |
CollectionAction(actionName), _outFileName(outFileName), _layers(layers), _nLayers(0), _badEvents(0), _histo(), |
16 |
|
|
_mode(mode), _standAlone(standAlone) { |
17 |
pam-fi |
1.1 |
|
18 |
|
|
_histo.SetName(GetName()); |
19 |
|
|
TString title = "TOF dE/dx ("; |
20 |
|
|
if ((_layers & S11) == S11) { |
21 |
|
|
title += "S11"; |
22 |
|
|
_nLayers++; |
23 |
|
|
} |
24 |
|
|
if ((_layers & S12) == S12) { |
25 |
|
|
if (_nLayers > 0) |
26 |
|
|
title += ","; |
27 |
|
|
title += "S12"; |
28 |
|
|
_nLayers++; |
29 |
|
|
} |
30 |
|
|
if ((_layers & S21) == S21) { |
31 |
|
|
if (_nLayers > 0) |
32 |
|
|
title += ","; |
33 |
|
|
title += "S21"; |
34 |
|
|
_nLayers++; |
35 |
|
|
} |
36 |
|
|
if ((_layers & S22) == S22) { |
37 |
|
|
if (_nLayers > 0) |
38 |
|
|
title += ","; |
39 |
|
|
title += "S22"; |
40 |
|
|
_nLayers++; |
41 |
|
|
} |
42 |
|
|
if ((_layers & S31) == S31) { |
43 |
|
|
if (_nLayers > 0) |
44 |
|
|
title += ","; |
45 |
|
|
title += "S31"; |
46 |
|
|
_nLayers++; |
47 |
|
|
} |
48 |
|
|
if ((_layers & S32) == S32) { |
49 |
|
|
if (_nLayers > 0) |
50 |
|
|
title += ","; |
51 |
|
|
title += "S32"; |
52 |
|
|
_nLayers++; |
53 |
|
|
} |
54 |
|
|
title += ") Vs Beta"; |
55 |
|
|
_histo.SetTitle(title); |
56 |
|
|
_histo.GetXaxis()->SetTitle("Beta"); |
57 |
|
|
_histo.GetYaxis()->SetTitle("dE/dx (MIP)"); |
58 |
|
|
|
59 |
|
|
_histo.SetBins(nBinsBeta, minBeta, maxBeta, nBinsDedx, minDedx, maxDedx); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
void TofDedxVsBetaHistoAction::OnGood(PamLevel2 *event) { |
63 |
|
|
|
64 |
|
|
float dEdx = 0.; |
65 |
|
|
float dEdxLayer = 0.; |
66 |
|
|
unsigned int badLayers = 0; |
67 |
pam-fi |
1.2 |
|
68 |
|
|
int trkSeqNo; |
69 |
|
|
if (_standAlone) |
70 |
|
|
trkSeqNo = 0; |
71 |
|
|
else |
72 |
|
|
trkSeqNo = event->GetTrack(0)->GetToFTrack()->trkseqno; |
73 |
pam-fi |
1.1 |
|
74 |
|
|
if ((_layers & S11) == S11) { |
75 |
|
|
dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 0, 100); |
76 |
|
|
if (dEdxLayer > 0. && dEdxLayer < 4090) |
77 |
|
|
dEdx += dEdxLayer; |
78 |
|
|
else |
79 |
|
|
badLayers++; |
80 |
|
|
} |
81 |
|
|
if ((_layers & S12) == S12) { |
82 |
|
|
dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 1, 100); |
83 |
|
|
if (dEdxLayer > 0. && dEdxLayer < 4090) |
84 |
|
|
dEdx += dEdxLayer; |
85 |
|
|
else |
86 |
|
|
badLayers++; |
87 |
|
|
} |
88 |
|
|
if ((_layers & S21) == S21) { |
89 |
|
|
dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 2, 100); |
90 |
|
|
if (dEdxLayer > 0. && dEdxLayer < 4090) |
91 |
|
|
dEdx += dEdxLayer; |
92 |
|
|
else |
93 |
|
|
badLayers++; |
94 |
|
|
} |
95 |
|
|
if ((_layers & S22) == S22) { |
96 |
|
|
dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 3, 100); |
97 |
|
|
if (dEdxLayer > 0. && dEdxLayer < 4090) |
98 |
|
|
dEdx += dEdxLayer; |
99 |
|
|
else |
100 |
|
|
badLayers++; |
101 |
|
|
} |
102 |
|
|
if ((_layers & S31) == S31) { |
103 |
|
|
dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 4, 100); |
104 |
|
|
if (dEdxLayer > 0. && dEdxLayer < 4090) |
105 |
|
|
dEdx += dEdxLayer; |
106 |
|
|
else |
107 |
|
|
badLayers++; |
108 |
|
|
} |
109 |
|
|
if ((_layers & S32) == S32) { |
110 |
|
|
dEdxLayer = event->GetToFLevel2()->GetdEdx(trkSeqNo, 5, 100); |
111 |
|
|
if (dEdxLayer > 0. && dEdxLayer < 4090) |
112 |
|
|
dEdx += dEdxLayer; |
113 |
|
|
else |
114 |
|
|
badLayers++; |
115 |
|
|
} |
116 |
|
|
if (badLayers == 0) { |
117 |
pam-fi |
1.2 |
dEdx /= _nLayers - badLayers; |
118 |
pam-fi |
1.1 |
_histo.Fill(event->GetTrack(0)->GetToFTrack()->beta[12], dEdx); |
119 |
|
|
} |
120 |
|
|
else |
121 |
|
|
_badEvents++; |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
void TofDedxVsBetaHistoAction::Finalize() { |
125 |
|
|
|
126 |
|
|
TFile outFile(_outFileName, _mode); |
127 |
|
|
outFile.cd(); |
128 |
|
|
_histo.Write(); |
129 |
|
|
outFile.Close(); |
130 |
|
|
} |