/[PAMELA software]/DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp
ViewVC logotype

Contents of /DarthVader/CalorimeterLevel2/src/CaloLevel2.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Thu Nov 9 17:05:44 2006 UTC (18 years ago) by mocchiut
Branch: MAIN
Changes since 1.6: +10 -23 lines
Added unpackError in all classes, ToF .rz bug fixed, install_GL_PARAM time screw bug fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23