Newer
Older
#include "THcShHit.h"
#include "TMath.h"
#include <vector>
#include <iterator>
#include <iostream>
using namespace std;
// Track class for the HMS calorimeter calibration.
// Comprises the spectrometer track parameters and calorimeter hits.
//
// Container (collection) of hits and its iterator.
//
typedef vector<THcShHit*> THcShHitList;
typedef THcShHitList::iterator THcShHitIt;
class THcShTrack {
UInt_t Nhits;
Double_t P; // track momentum
Double_t X; // at the calorimater face
Double_t Xp; // slope
Double_t Y; // at the calorimater face
Double_t Yp; // slope
THcShHitList Hits;
public:
THcShTrack();
THcShTrack(UInt_t nh, Double_t p,
Double_t x, Double_t xp, Double_t y, Double_t yp);
~THcShTrack();
void SetTrack(UInt_t nh, Double_t p,
Double_t x, Double_t xp, Double_t y, Double_t yp);
void AddHit(Double_t adc_pos, Double_t adc_neg,
Double_t e_pos, Double_t e_neg,
UInt_t blk_number);
Float_t Ycor(Double_t); // coord. corection for single PMT module
Float_t Ycor(Double_t, Int_t); // coord. correction for double PMT module
// Coordinate correction constants from hcana.param.
//
static const Double_t fAcor = 200.;
static const Double_t fBcor = 8000.;
static const Double_t fCcor = 64.36;
static const Double_t fDcor = 1.66;
// Calorimeter geometry constants.
//
static const Double_t fZbl = 10; //cm, block transverse size
static const UInt_t fNrows = 13;
static const UInt_t fNcols = 4;
static const UInt_t fNnegs = 26; // number of blocks with neg. side PMTs.
static const UInt_t fNpmts = 78; // total number of PMTs.
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
static const UInt_t fNblks = fNrows*fNcols;
};
THcShTrack::THcShTrack() { };
THcShTrack::THcShTrack(UInt_t nh, Double_t p,
Double_t x, Double_t xp, Double_t y, Double_t yp) {
Nhits = nh;
P = p;
X = x;
Xp = xp;
Y = y;
Yp =yp;
};
void THcShTrack::SetTrack(UInt_t nh, Double_t p,
Double_t x, Double_t xp, Double_t y, Double_t yp) {
Nhits = nh;
P = p;
X = x;
Xp = xp;
Y = y;
Yp =yp;
Hits.clear();
};
void THcShTrack::AddHit(Double_t adc_pos, Double_t adc_neg,
Double_t e_pos, Double_t e_neg,
UInt_t blk_number) {
THcShHit* hit = new THcShHit(adc_pos, adc_neg, blk_number);
hit->SetEpos(e_pos);
hit->SetEneg(e_neg);
Hits.push_back(hit);
};
THcShHit* THcShTrack::GetHit(UInt_t k) {
THcShHitIt it = Hits.begin();
for (UInt_t i=0; i<k; i++) it++;
return *it;
}
void THcShTrack::Print() {
cout << "ShTrack: P=" << P << " X=" << X << " Xp=" << Xp
<< " Y=" << Y << " Yp=" << Yp << " Nhits=" << Nhits << endl;
cout << "Hits size=" << Hits.size() << endl;
for (THcShHitIt iter = Hits.begin(); iter != Hits.end(); iter++) {
(*iter)->Print();
};
};
// Check hit number with the size of hit collection.
//
Bool_t THcShTrack::CheckHitNumber() {
return (Nhits == Hits.size());
};
THcShTrack::~THcShTrack() {
for (THcShHitIt i = Hits.begin(); i != Hits.end(); ++i) {
delete *i;
*i = 0;
}
};
//------------------------------------------------------------------------------
void THcShTrack::SetEs(Double_t* alpha) {
// Set hit energy depositions seen from postive and negative sides,
// by use of calibration (gain) constants alpha.
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
for (THcShHitIt iter = Hits.begin(); iter != Hits.end(); iter++) {
Double_t adc_pos = (*iter)->GetADCpos();
Double_t adc_neg = (*iter)->GetADCneg();
UInt_t nblk = (*iter)->GetBlkNumber();
Int_t ncol=(nblk-1)/fNrows+1;
Double_t xh=X+Xp*(ncol-0.5)*fZbl;
Double_t yh=Y+Yp*(ncol-0.5)*fZbl;
if (nblk <= fNnegs) {
(*iter)->SetEpos(adc_pos*Ycor(yh,0)*alpha[nblk-1]);
(*iter)->SetEneg(adc_neg*Ycor(yh,1)*alpha[fNblks+nblk-1]);
}
else {
(*iter)->SetEpos(adc_pos*Ycor(yh)*alpha[nblk-1]);
(*iter)->SetEneg(0.);
};
};
}
//------------------------------------------------------------------------------
Double_t THcShTrack::Enorm() {
// Normalized to track momentum energy depostion in the calorimeter.
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
Double_t sum = 0;
for (THcShHitIt iter = Hits.begin(); iter != Hits.end(); iter++) {
sum += (*iter)->GetEpos();
sum += (*iter)->GetEneg();
};
return sum/P/1000.;
}
//------------------------------------------------------------------------------
//Coordinate correction for single PMT modules.
//PMT attached at right (positive) side.
Float_t THcShTrack::Ycor(Double_t y) {
return TMath::Exp(y/fAcor)/(1. + y*y/fBcor);
}
//Coordinate correction for double PMT modules.
//
Float_t THcShTrack::Ycor(Double_t y, Int_t side) {
if (side!=0&&side!=1) {
cout << "THcShower::Ycor : wrong side " << side << endl;
return 0.;
}
Int_t sign = 1 - 2*side;
return (fCcor + sign*y)/(fCcor + sign*y/fDcor);
}