1 |
/** |
2 |
* \file src/CaloLevel2.cpp |
3 |
* \author Emiliano Mocchiutti |
4 |
* |
5 |
**/ |
6 |
#include <TObject.h> |
7 |
#include <CaloLevel2.h> |
8 |
|
9 |
// |
10 |
ClassImp(CaloTrkVar); |
11 |
ClassImp(CaloLevel2); |
12 |
|
13 |
/** |
14 |
* CaloTrkVar constructor |
15 |
**/ |
16 |
CaloTrkVar::CaloTrkVar() { |
17 |
this->Clear(); |
18 |
}; |
19 |
|
20 |
/** |
21 |
* Clear variables |
22 |
**/ |
23 |
void CaloTrkVar::Clear() { |
24 |
trkseqno = 0; |
25 |
noint = 0; |
26 |
ncore = 0; |
27 |
qcore = 0.; |
28 |
ncyl = 0; |
29 |
qcyl = 0.; |
30 |
qtrack = 0.; |
31 |
qtrackx = 0.; |
32 |
qtracky = 0.; |
33 |
dxtrack = 0.; |
34 |
dytrack = 0.; |
35 |
qlast = 0.; |
36 |
nlast = 0; |
37 |
qpre = 0.; |
38 |
npre = 0; |
39 |
qpresh = 0.; |
40 |
npresh = 0; |
41 |
qtr = 0.; |
42 |
ntr = 0; |
43 |
planetot = 0; |
44 |
qmean = 0.; |
45 |
qlow = 0.; |
46 |
nlow = 0; |
47 |
dX0l = 0.; |
48 |
memset(tbar, 0, 2*22*sizeof(Float_t)); |
49 |
memset(tibar, 0, 2*22*sizeof(Int_t)); |
50 |
} |
51 |
|
52 |
/** |
53 |
* Copies from t to this |
54 |
**/ |
55 |
CaloTrkVar::CaloTrkVar(const CaloTrkVar &t){ |
56 |
trkseqno = t.trkseqno; |
57 |
noint = t.noint; |
58 |
ncore = t.ncore; |
59 |
qcore = t.qcore; |
60 |
ncyl = t.ncyl; |
61 |
qcyl = t.qcyl; |
62 |
qtrack = t.qtrack; |
63 |
qtrackx = t.qtrackx; |
64 |
qtracky = t.qtracky; |
65 |
dxtrack = t.dxtrack; |
66 |
dytrack = t.dytrack; |
67 |
qlast = t.qlast; |
68 |
nlast = t.nlast; |
69 |
qpre = t.qpre; |
70 |
npre = t.npre; |
71 |
qpresh = t.qpresh; |
72 |
npresh = t.npresh; |
73 |
qtr = t.qtr; |
74 |
ntr = t.ntr; |
75 |
planetot = t.planetot; |
76 |
qmean = t.qmean; |
77 |
dX0l = t.dX0l; |
78 |
qlow = t.qlow; |
79 |
nlow = t.nlow; |
80 |
memcpy(tibar,t.tibar,sizeof(tibar)); |
81 |
memcpy(tbar,t.tbar,sizeof(tbar)); |
82 |
} |
83 |
|
84 |
/** |
85 |
* CaloLevel2 constructor |
86 |
**/ |
87 |
CaloLevel2::CaloLevel2() { |
88 |
// |
89 |
// CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
90 |
CaloTrk = 0; //ELENA |
91 |
// |
92 |
this->Clear(); |
93 |
// |
94 |
}; |
95 |
/** |
96 |
* Create the TClonesArray |
97 |
**/ |
98 |
void CaloLevel2::Set(){//ELENA |
99 |
if(!CaloTrk)CaloTrk = new TClonesArray("CaloTrkVar",1); //ELENA |
100 |
}//ELENA |
101 |
|
102 |
/** |
103 |
* Clear the CaloLevel2 object |
104 |
**/ |
105 |
void CaloLevel2::Clear() { |
106 |
// |
107 |
// CaloTrk->Clear(); //ELENA |
108 |
if(CaloTrk)CaloTrk->Delete(); //ELENA |
109 |
// |
110 |
nstrip = 0; |
111 |
qtot = 0.; |
112 |
impx = 0.; |
113 |
impy = 0.; |
114 |
tanx = 0.; |
115 |
tany = 0.; |
116 |
qmax = 0.; |
117 |
nx22 = 0; |
118 |
qx22 = 0.; |
119 |
elen = 0.; |
120 |
selen = 0.; |
121 |
memset(perr, 0, 4*sizeof(Int_t)); |
122 |
memset(swerr, 0, 4*sizeof(Int_t)); |
123 |
memset(crc, 0, 4*sizeof(Int_t)); |
124 |
memset(qq, 0, 4*sizeof(Int_t)); |
125 |
memset(varcfit, 0, 2*sizeof(Float_t)); |
126 |
memset(npcfit, 0, 2*sizeof(Int_t)); |
127 |
memset(planemax, 0, 2*sizeof(Int_t)); |
128 |
memset(cibar, 0, 2*22*sizeof(Int_t)); |
129 |
memset(cbar, 0, 2*22*sizeof(Float_t)); |
130 |
good = 0; |
131 |
selftrigger = 0; |
132 |
// |
133 |
}; |
134 |
|
135 |
/** |
136 |
* Delete the CaloLevel2 object |
137 |
**/ |
138 |
void CaloLevel2::Delete() { //ELENA |
139 |
if(CaloTrk){ //ELENA |
140 |
CaloTrk->Delete(); //ELENA |
141 |
delete CaloTrk; //ELENA |
142 |
} //ELENA |
143 |
} //ELENA |
144 |
|
145 |
/** |
146 |
* Fills a struct cCaloLevel2 with values from a CaloLevel2 object (to put data into a F77 common). |
147 |
*/ |
148 |
void CaloLevel2::GetLevel2Struct(cCaloLevel2 *l2) const { |
149 |
|
150 |
l2->good = good; |
151 |
l2->selftrigger = selftrigger; |
152 |
l2->nstrip = nstrip; |
153 |
l2->nx22 = nx22; |
154 |
l2->qtot = qtot; |
155 |
l2->qx22 = qx22; |
156 |
l2->qmax = qmax; |
157 |
l2->impx = impx; |
158 |
l2->impy = impy; |
159 |
l2->tanx = tanx; |
160 |
l2->tany = tany; |
161 |
l2->elen = elen; |
162 |
l2->selen = selen; |
163 |
|
164 |
for(Int_t i=0;i<2;i++){ |
165 |
l2->planemax[i] = planemax[i]; |
166 |
l2->varcfit[i] = varcfit[i]; |
167 |
l2->npcfit[i] = npcfit[i]; |
168 |
} |
169 |
for(Int_t i=0;i<4;i++){ |
170 |
l2->perr[i] = perr[i]; |
171 |
l2->swerr[i] = swerr[i]; |
172 |
l2->calcrc[i] = crc[i]; |
173 |
l2->qq[i] = qq[i]; |
174 |
} |
175 |
|
176 |
if(CaloTrk){ //ELENA |
177 |
l2->calntrk = CaloTrk->GetEntries(); |
178 |
for(Int_t i=0;i<l2->calntrk;i++){ |
179 |
l2->caltrkseqno[i] = ((CaloTrkVar *)CaloTrk->At(i))->trkseqno; |
180 |
l2->ncore[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncore; |
181 |
l2->noint[i] = ((CaloTrkVar *)CaloTrk->At(i))->noint; |
182 |
l2->ncyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->ncyl; |
183 |
l2->nlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlast; |
184 |
l2->npre[i] = ((CaloTrkVar *)CaloTrk->At(i))->npre; |
185 |
l2->npresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->npresh; |
186 |
l2->ntr[i] = ((CaloTrkVar *)CaloTrk->At(i))->ntr; |
187 |
l2->planetot[i] = ((CaloTrkVar *)CaloTrk->At(i))->planetot; |
188 |
l2->nlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->nlow; |
189 |
l2->qcore[i] =((CaloTrkVar *)CaloTrk->At(i))->qcore ; |
190 |
l2->qcyl[i] = ((CaloTrkVar *)CaloTrk->At(i))->qcyl; |
191 |
l2->qlast[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlast; |
192 |
l2->qpre[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpre; |
193 |
l2->qpresh[i] = ((CaloTrkVar *)CaloTrk->At(i))->qpresh; |
194 |
l2->qtr[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtr; |
195 |
l2->qtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrack; |
196 |
l2->qtrackx[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtrackx; |
197 |
l2->qtracky[i] = ((CaloTrkVar *)CaloTrk->At(i))->qtracky; |
198 |
l2->dxtrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dxtrack; |
199 |
l2->dytrack[i] = ((CaloTrkVar *)CaloTrk->At(i))->dytrack; |
200 |
l2->qmean[i] = ((CaloTrkVar *)CaloTrk->At(i))->qmean; |
201 |
l2->qlow[i] = ((CaloTrkVar *)CaloTrk->At(i))->qlow; |
202 |
l2->dX0l[i] = ((CaloTrkVar *)CaloTrk->At(i))->dX0l; |
203 |
for (Int_t j=0; j<2; j++){ |
204 |
for (Int_t k=0; k<22; k++){ |
205 |
l2->tbar[i][k][j] = ((CaloTrkVar *)CaloTrk->At(i))->tbar[k][j]; |
206 |
}; |
207 |
}; |
208 |
} |
209 |
} //ELENA |
210 |
} |
211 |
|
212 |
/** |
213 |
* Should return the energy in GeV if the particle would be an electron |
214 |
* using a parametrization taken from Monte Carlo simulation |
215 |
**/ |
216 |
void CaloLevel2::GetElectronEnergy(Float_t &energy, Float_t &sigma){ |
217 |
if ( nstrip == 0 ) return; |
218 |
energy = qtot * 40.82 * 0.000106; |
219 |
sigma = 0.; |
220 |
if ( energy > 0. ) sigma = energy * (0.01183 + 0.121/sqrt(energy)); |
221 |
return; |
222 |
}; |
223 |
|
224 |
/** |
225 |
* Returns pointer to the set of track-related variables "itrk" |
226 |
**/ |
227 |
CaloTrkVar *CaloLevel2::GetCaloTrkVar(Int_t itrk){ |
228 |
// |
229 |
if(itrk >= ntrk()){ |
230 |
printf(" CaloLevel2 ERROR: track related variables set %i does not exists! \n",itrk); |
231 |
printf(" stored track related variables = %i \n",ntrk()); |
232 |
return(NULL); |
233 |
} |
234 |
if(!CaloTrk)return 0; //ELENA |
235 |
TClonesArray &t = *(CaloTrk); |
236 |
CaloTrkVar *calotrack = (CaloTrkVar*)t[itrk]; |
237 |
return calotrack; |
238 |
} |