/[PAMELA software]/DarthVader/TrackerLevel2/src/TrkLevel1.cpp
ViewVC logotype

Contents of /DarthVader/TrackerLevel2/src/TrkLevel1.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Thu Sep 28 14:04:39 2006 UTC (18 years, 2 months ago) by pam-fi
Branch: MAIN
Changes since 1.1: +105 -116 lines
some bugs fixed, some changings in the classes:

1 /**
2 * \file TrkLevel1.cpp
3 * \author Elena Vannuccini
4 */
5 #include <TrkLevel1.h>
6 #include <iostream>
7 using namespace std;
8 //--------------------------------------
9 //
10 //
11 //--------------------------------------
12 TrkCluster::TrkCluster(){
13
14 view = 0;
15 maxs = 0;
16 indmax = 0;
17
18 CLlength = 0;
19 clsignal = 0;
20 clsigma = 0;
21 cladc = 0;
22 clbad = 0;
23
24 };
25 //--------------------------------------
26 //
27 //
28 //--------------------------------------
29 TrkCluster::~TrkCluster(){
30
31 delete [] clsignal;
32 delete [] clsigma;
33 delete [] cladc;
34 delete [] clbad;
35 };
36 //--------------------------------------
37 //
38 //
39 //--------------------------------------
40 TrkCluster::TrkCluster(const TrkCluster& t){
41
42 view = t.view;
43 maxs = t.maxs;
44 indmax = t.indmax;
45
46 CLlength = t.CLlength;
47 clsignal = new Float_t[CLlength];
48 clsigma = new Float_t[CLlength];
49 cladc = new Int_t[CLlength];
50 clbad = new Bool_t[CLlength];
51 for(Int_t i=0; i<CLlength;i++){
52 clsignal[i] = t.clsignal[i];
53 clsigma[i] = t.clsigma[i];
54 cladc[i] = t.cladc[i];
55 clbad[i] = t.clbad[i];
56 };
57
58 };
59 //--------------------------------------
60 //
61 //
62 //--------------------------------------
63 /**
64 * Evaluate the cluster signal.
65 * @param cut Inclusion cut.
66 */
67 Float_t TrkCluster::GetSignal(Float_t cut){
68 Float_t s = 0;
69 for(Int_t is = 0; is < CLlength; is++){
70 Float_t scut = cut*clsigma[is];
71 if(clsignal[is] > scut) s += clsignal[is];
72 };
73 return s;
74 };
75 /**
76 * Evaluate the cluster signal-to-noise, as defined by Turchetta.
77 * @param cut Inclusion cut.
78 */
79 Float_t TrkCluster::GetSignalToNoise(Float_t cut){
80 Float_t sn = 0;
81 for(Int_t is = 0; is < CLlength; is++){
82 Float_t scut = cut*clsigma[is];
83 if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is];
84 };
85 return sn;
86 };
87 /**
88 * Evaluate the cluster multiplicity.
89 * @param cut Inclusion cut.
90 */
91 Int_t TrkCluster::GetMultiplicity(Float_t cut){
92 Int_t m = 0;
93 for(Int_t is = 0; is < CLlength; is++){
94 Float_t scut = cut*clsigma[is];
95 if(clsignal[is] > scut) m++;
96 };
97 return m;
98 };
99 /**
100 * True if the cluster contains bad strips.
101 * @param nbad Number of strips around the maximum.
102 */
103 Bool_t TrkCluster::IsBad(Int_t nbad){
104
105 /* Float_t max = 0;
106 Int_t imax = 0;
107 for(Int_t is = 0; is < CLlength; is++){
108 if(clsignal[is] > max){
109 max = clsignal[is];
110 imax = is;
111 };
112 };
113
114 Int_t il,ir;
115 il = imax;
116 ir = imax;*/
117
118 Int_t il,ir;
119 il = indmax;
120 ir = indmax;
121 for(Int_t i=1; i<nbad; i++){
122 if (ir == CLlength && il == 0)break;
123 else if (ir == CLlength && il != 0)il--;
124 else if (ir != CLlength && il == 0)ir++;
125 else{
126 if(clsignal[il-1] > clsignal[ir+1])il--;
127 else ir++;
128 }
129 }
130 Int_t isbad = 0;
131 for(Int_t i=il; i<=ir; i++)isbad += clbad[i];
132
133 return ( isbad != nbad );
134 };
135 //--------------------------------------
136 //
137 //
138 //--------------------------------------
139 void TrkCluster::Dump(){
140
141 cout << "----- Cluster" << endl;
142 cout << "View "<<view << " - Ladder "<<GetLadder()<<endl;
143 cout << "Position of maximun "<< maxs <<endl;
144 cout << "Multiplicity "<< GetMultiplicity() <<endl;
145 cout << "Tot signal "<< GetSignal() << " (ADC channels)"<<endl ;
146 cout << "Signal/Noise "<< GetSignalToNoise();
147 cout <<endl<< "Strip signals ";
148 for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];
149 cout <<endl<< "Strip sigmas ";
150 for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];
151 cout <<endl<< "Strip ADC ";
152 for(Int_t i =0; i<CLlength; i++)cout << " " <<cladc[i];
153 cout <<endl<< "Strip BAD ";
154 for(Int_t i =0; i<CLlength; i++){
155 if(i==indmax)cout << " *" <<clbad[i]<<"*";
156 else cout << " " <<clbad[i];
157 }
158 cout << endl;
159
160 }
161 //--------------------------------------
162 //
163 //
164 //--------------------------------------
165 TrkLevel1::TrkLevel1(){
166
167 // good1 = -1;
168
169 Cluster = new TClonesArray("TrkCluster");
170
171 for(Int_t i=0; i<12 ; i++){
172 // crc[i] = -1;
173 good[i] = -1;
174 for(Int_t j=0; j<24 ; j++){
175 cnev[j][i]=0;
176 cnnev[j][i]=0;
177 };
178 // fshower[i]=0;
179 };
180 }
181 //--------------------------------------
182 //
183 //
184 //--------------------------------------
185 void TrkLevel1::Dump(){
186
187 cout<<"DSP status: ";
188 for(Int_t i=0; i<12 ; i++)cout<<good[i]<<" ";
189 cout<<endl;
190
191 TClonesArray &t = *Cluster;
192 for(int i=0; i<this->nclstr(); i++) ((TrkCluster *)t[i])->Dump();
193
194 }
195 //--------------------------------------
196 //
197 //
198 //--------------------------------------
199 /**
200 * Fills a TrkLevel1 object with values from a struct cTrkLevel1 (to get data from F77 common).
201 */
202 void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1){
203
204 // *** CLUSTER ***
205 TrkCluster* t_cl = new TrkCluster();
206 TClonesArray &t = *Cluster;
207 for(int i=0; i<l1->nclstr1; i++){
208
209 t_cl->view = l1->view[i];
210 t_cl->maxs = l1->maxs[i];
211 t_cl->indmax = l1->indmax[i] - l1->indstart[i];
212
213 Int_t from = l1->indstart[i] -1;
214 Int_t to = l1->totCLlength ;
215 if(i != l1->nclstr1-1)to = l1->indstart[i+1] -1 ;
216 t_cl->CLlength = to - from ;
217
218 t_cl->clsignal = new Float_t[t_cl->CLlength];
219 t_cl->clsigma = new Float_t[t_cl->CLlength];
220 t_cl->cladc = new Int_t[t_cl->CLlength];
221 t_cl->clbad = new Bool_t[t_cl->CLlength];
222 Int_t index = 0;
223 for(Int_t is = from; is < to; is++ ){
224 t_cl->clsignal[index] = (Float_t) l1->clsignal[is];
225 t_cl->clsigma[index] = (Float_t) l1->clsigma[is];
226 t_cl->cladc[index] = (Int_t) l1->cladc[is];
227 t_cl->clbad[index] = (Bool_t) l1->clbad[is];
228 index++;
229 };
230
231 new(t[i]) TrkCluster(*t_cl);
232 };
233
234 delete t_cl;
235
236 // ****general variables****
237
238 for(Int_t i=0; i<12 ; i++){
239 good[i] = -1;
240 for(Int_t j=0; j<24 ; j++){
241 cnev[j][i] = l1->cnev[j][i];
242 cnnev[j][i] = l1->cnnev[j][i];
243 };
244 };
245
246 }
247 /**
248 * Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common).
249 */
250
251 void TrkLevel1::GetLevel1Struct(cTrkLevel1 *l1) const {
252
253 // ********* completare ********* //
254 // ********* completare ********* //
255 // ********* completare ********* //
256 // ********* completare ********* //
257 // ********* completare ********* //
258 // ********* completare ********* //
259 // general variables
260 // l1->good1 = good1;
261 for(Int_t i=0; i<12 ; i++){
262 // l1->crc[i] = crc[i];
263 for(Int_t j=0; j<24 ; j++){
264 l1->cnev[j][i] = cnev[j][i];
265 l1->cnnev[j][i] = cnnev[j][i];
266 };
267 // l1->fshower[i] = fshower[i];
268 };
269
270 // *** CLUSTERS ***
271 l1->nclstr1 = Cluster->GetEntries();
272 for(Int_t i=0;i<l1->nclstr1;i++){
273
274 l1->view[i] = ((TrkCluster *)Cluster->At(i))->view;
275 // l1->ladder[i] = ((TrkCluster *)Cluster->At(i))->ladder;
276 l1->maxs[i] = ((TrkCluster *)Cluster->At(i))->maxs;
277 // l1->mult[i] = ((TrkCluster *)Cluster->At(i))->mult;
278 // l1->dedx[i] = ((TrkCluster *)Cluster->At(i))->sgnl;
279
280 }
281
282 // ********* completare ********* //
283
284 }
285 //--------------------------------------
286 //
287 //
288 //--------------------------------------
289 void TrkLevel1::Clear(){
290
291 for(Int_t i=0; i<12 ; i++){
292 good[i] = -1;
293 for(Int_t j=0; j<24 ; j++){
294 cnev[j][i] = 0;
295 cnnev[j][i] = 0;
296 };
297 };
298 //
299 Cluster->Clear();
300
301 }
302 //--------------------------------------
303 //
304 //
305 //--------------------------------------
306 TrkCluster *TrkLevel1::GetCluster(int is){
307
308 if(is >= this->nclstr()){
309 cout << "** TrkLevel1::GetCluster(int) ** Cluster "<< is << " does not exits! " << endl;
310 cout << "( Stored clusters nclstr() = "<< this->nclstr()<<" )" << endl;
311 return 0;
312 }
313 TClonesArray &t = *(Cluster);
314 TrkCluster *cluster = (TrkCluster*)t[is];
315 return cluster;
316 }
317
318
319 ClassImp(TrkLevel1);
320 ClassImp(TrkCluster);

  ViewVC Help
Powered by ViewVC 1.1.23