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