/[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.14 - (show annotations) (download)
Fri Feb 16 14:56:01 2007 UTC (17 years, 9 months ago) by pam-fi
Branch: MAIN
Changes since 1.13: +271 -46 lines
Magnetic field, improoved de/dx, reprocessing tools

1 /**
2 * \file TrkLevel1.cpp
3 * \author Elena Vannuccini
4 */
5 #include <TrkLevel1.h>
6 #include <iostream>
7 using namespace std;
8 //......................................
9 // F77 routines
10 //......................................
11 extern "C" {
12
13 // int readetaparam_();
14 float cog_(int*,int*);
15 float pfaeta_(int*,float*);
16 float pfaeta2_(int*,float*);
17 float pfaeta3_(int*,float*);
18 float pfaeta4_(int*,float*);
19
20 }
21 //--------------------------------------
22 //
23 //
24 //--------------------------------------
25 TrkCluster::TrkCluster(){
26
27 // cout << "TrkCluster::TrkCluster()"<<endl;
28 view = -1;
29 maxs = -1;
30 indmax = -1;
31
32 CLlength = 0;
33 clsignal = 0;
34 clsigma = 0;
35 cladc = 0;
36 clbad = 0;
37
38 };
39 //--------------------------------------
40 //
41 //
42 //--------------------------------------
43 TrkCluster::TrkCluster(const TrkCluster& t){
44
45 view = t.view;
46 maxs = t.maxs;
47 indmax = t.indmax;
48
49 CLlength = t.CLlength;
50 if(CLlength){
51 clsignal = new Float_t[CLlength];
52 clsigma = new Float_t[CLlength];
53 cladc = new Int_t[CLlength];
54 clbad = new Bool_t[CLlength];
55 for(Int_t i=0; i<CLlength;i++){
56 clsignal[i] = t.clsignal[i];
57 clsigma[i] = t.clsigma[i];
58 cladc[i] = t.cladc[i];
59 clbad[i] = t.clbad[i];
60 };
61 };
62 };
63 //--------------------------------------
64 //
65 //
66 //--------------------------------------
67 void TrkCluster::Clear(){
68
69 // cout << "void TrkCluster::Clear()"<<endl;
70 if(CLlength){
71 delete [] clsignal;
72 delete [] clsigma;
73 delete [] cladc;
74 delete [] clbad;
75 }
76
77 view = 0;
78 maxs = 0;
79 indmax = 0;
80
81 CLlength = 0;
82 clsignal = 0;
83 clsigma = 0;
84 cladc = 0;
85 clbad = 0;
86
87 };
88 //--------------------------------------
89 //
90 //
91 //--------------------------------------
92 /**
93 * Evaluate the cluster signal including a maximum number of adjacent
94 * strips, around maxs, having a significant signal.
95 * @param nstrip Maximum number of strips.
96 * @param cut Inclusion cut ( s > cut*sigma ).
97 * If nstrip<=0 only the inclusion cut is used to determine the cluster size.
98 */
99 Float_t TrkCluster::GetSignal(Int_t nstrip, Float_t cut){
100
101 if(CLlength<=0)return 0;
102
103 Float_t s = 0;
104
105 if( nstrip<=0 ){
106 // for(Int_t is = 0; is < CLlength; is++){
107 // Float_t scut = cut*clsigma[is];
108 // if(clsignal[is] > scut) s += clsignal[is];
109 // };
110 for(Int_t is = indmax+1; is < CLlength; is++){
111 Float_t scut = cut*clsigma[is];
112 if(clsignal[is] > scut) s += clsignal[is];
113 else break;
114 };
115 for(Int_t is = indmax; is >=0; is--){
116 Float_t scut = cut*clsigma[is];
117 if(clsignal[is] > scut) s += clsignal[is];
118 else break;
119 };
120 return s;
121 };
122
123
124 Int_t il = indmax;
125 Int_t ir = indmax;
126 Int_t inc = 0;
127
128 if( clsignal[indmax] < cut*clsigma[indmax] ) return 0;
129
130 while ( inc < nstrip ){
131 Float_t sl = -100000;
132 Float_t sr = -100000;
133 if( il >= 0 ) sl = clsignal[il];
134 if( ir < CLlength ) sr = clsignal[ir];
135 if( sl == sr && inc == 0 ){
136 s += clsignal[il]; //cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;
137 il--;
138 ir++;
139 }else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){
140 s += sl;//cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;
141 il--;
142 }else if ( sl < sr && sr > cut*clsigma[ir] ){
143 s += sr;//cout << inc<<" - " << clsignal[ir]<<" "<<s<<endl;
144 ir++;
145 }else break;
146
147 inc++;
148 }
149 return s;
150 };
151
152
153 /**
154 * Evaluate the cluster signal-to-noise, as defined by Turchetta, including a
155 * maximum number of adjacent strips, around maxs, having a significant signal.
156 * @param nstrip Maximum number of strips.
157 * @param cut Inclusion cut ( s > cut*sigma ).
158 * If nstrip<=0 only the inclusion cut is used to determine the cluster size.
159 */
160 Float_t TrkCluster::GetSignalToNoise(Int_t nstrip, Float_t cut){
161
162 if(CLlength<=0)return 0;
163
164 Float_t sn = 0;
165
166 if( nstrip<=0 ){
167 for(Int_t is = indmax+1; is < CLlength; is++){
168 Float_t scut = cut*clsigma[is];
169 if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is];
170 else break;
171 };
172 for(Int_t is = indmax; is >=0; is--){
173 Float_t scut = cut*clsigma[is];
174 if(clsignal[is] > scut) sn += clsignal[is]/clsigma[is];
175 else break;
176 };
177 return sn;
178 };
179
180
181 Int_t il = indmax;
182 Int_t ir = indmax;
183 Int_t inc = 0;
184
185 if( clsignal[indmax] < cut*clsigma[indmax] ) return 0;
186
187 while ( inc < nstrip ){
188 Float_t sl = -100000;
189 Float_t sr = -100000;
190 if( il >= 0 ) sl = clsignal[il];
191 if( ir < CLlength ) sr = clsignal[ir];
192 if( sl == sr && inc == 0 ){
193 sn += clsignal[il]/clsigma[il];
194 il--;
195 ir++;
196 }else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){
197 sn += sl/clsigma[il];
198 il--;
199 }else if ( sl < sr && sr > cut*clsigma[ir] ){
200 sn += sr/clsigma[ir];
201 ir++;
202 }else break;
203
204 inc++;
205 }
206 return sn;
207 };
208 /**
209 * Evaluate the cluster multiplicity.
210 * @param cut Inclusion cut.
211 */
212 Int_t TrkCluster::GetMultiplicity(Float_t cut){
213
214 if(CLlength<=0)return 0;
215
216 Int_t m = 0;
217
218 for(Int_t is = indmax+1; is < CLlength; is++){
219 Float_t scut = cut*clsigma[is];
220 if(clsignal[is] > scut) m++;
221 else break;
222 };
223 for(Int_t is = indmax; is >=0; is--){
224 Float_t scut = cut*clsigma[is];
225 if(clsignal[is] > scut) m++;
226 else break;
227 };
228 return m;
229 };
230 /**
231 * True if the cluster contains bad strips.
232 * @param nbad Number of strips around the maximum.
233 */
234 Bool_t TrkCluster::IsBad(Int_t nbad){
235
236 if(CLlength<=0)return 0;
237
238 Int_t il,ir;
239 il = indmax;
240 ir = indmax;
241 for(Int_t i=1; i<nbad; i++){
242 if (ir == CLlength && il == 0)break;
243 else if (ir == CLlength && il != 0)il--;
244 else if (ir != CLlength && il == 0)ir++;
245 else{
246 if(clsignal[il-1] > clsignal[ir+1])il--;
247 else ir++;
248 }
249 }
250 Int_t isbad = 0;
251 for(Int_t i=il; i<=ir; i++)isbad += clbad[i];
252
253 return ( isbad != nbad );
254 };
255 /**
256 * True if the cluster contains saturated strips.
257 * @param nbad Number of strips around the maximum.
258 */
259 Bool_t TrkCluster::IsSaturated(Int_t nbad){
260
261 if(CLlength<=0)return 0;
262
263 Int_t il,ir;
264 il = indmax;
265 ir = indmax;
266 for(Int_t i=1; i<nbad; i++){
267 if (ir == CLlength && il == 0)break;
268 else if (ir == CLlength && il != 0)il--;
269 else if (ir != CLlength && il == 0)ir++;
270 else{
271 if(clsignal[il-1] > clsignal[ir+1])il--;
272 else ir++;
273 }
274 }
275 Int_t isbad = 0;
276 for(Int_t i=il; i<=ir; i++){
277 if( IsX() && cladc[i] > 2980 )isbad++;
278 if( IsY() && cladc[i] < 80 )isbad++;
279 }
280 return ( isbad != 0 );
281
282 }
283 //--------------------------------------
284 //
285 //
286 //--------------------------------------
287 void TrkCluster::Dump(){
288
289 cout << "----- Cluster" << endl;
290 cout << "View "<<view << " - Ladder "<<GetLadder()<<endl;
291 cout << "Position of maximun "<< maxs <<endl;
292 cout << "Multiplicity "<< GetMultiplicity() <<endl;
293 cout << "Tot signal "<< GetSignal() << " (ADC channels)"<<endl ;
294 cout << "Signal/Noise "<< GetSignalToNoise();
295 cout <<endl<< "Strip signals ";
296 for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];
297 cout <<endl<< "Strip sigmas ";
298 for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];
299 cout <<endl<< "Strip ADC ";
300 for(Int_t i =0; i<CLlength; i++)cout << " " <<cladc[i];
301 cout <<endl<< "Strip BAD ";
302 for(Int_t i =0; i<CLlength; i++){
303 if(i==indmax)cout << " *" <<clbad[i]<<"*";
304 else cout << " " <<clbad[i];
305 }
306 cout << endl;
307
308 }
309 //--------------------------------------
310 //
311 //
312 //--------------------------------------
313 /**
314 * Method to fill a level1 struct with only one cluster (done to use F77 p.f.a. routines on a cluster basis).
315 */
316 void TrkCluster::GetLevel1Struct(cTrkLevel1* l1){
317
318 // cTrkLevel1* l1 = new cTrkLevel1;
319
320 // cTrkLevel1* l1 = &level1event_ ;
321
322 l1->nclstr1 = 1;
323 l1->view[0] = view;
324 l1->ladder[0] = GetLadder();
325 l1->maxs[0] = maxs;
326 l1->mult[0] = GetMultiplicity();
327 l1->dedx[0] = GetSignal();
328 l1->indstart[0] = 1;
329 l1->indmax[0] = indmax+1;
330 l1->totCLlength = CLlength;
331 for(Int_t i=0; i<CLlength; i++){
332 l1->clsignal[i] = clsignal[i];
333 l1->clsigma[i] = clsigma[i];
334 l1->cladc[i] = cladc[i];
335 l1->clbad[i] = clbad[i];
336 };
337
338 // return l1;
339 };
340 //--------------------------------------
341 //
342 //
343 //--------------------------------------
344 /**
345 * Evaluates the Center-Of-Gravity (COG) of the cluster, in strips, relative to the strip with the maximum signal (TrkCluster::maxs).
346 * @param ncog Number of strips to evaluate COG.
347 * If ncog=0, the COG of the cluster is evaluated according to the cluster multiplicity (defined by the inclusion cut).
348 * If ncog>0, the COG is evaluated using ncog strips, even if they have a negative signal (according to G.Landi)
349 */
350 Float_t TrkCluster::GetCOG(Int_t ncog){
351
352 int ic = 1;
353 GetLevel1Struct();
354 return cog_(&ncog,&ic);
355
356 };
357 /**
358 * Evaluates the Center-Of-Gravity (COG) of the cluster, in strips, relative to the strip with the maximum signal (TrkCluster::maxs),
359 * choosing the number of strips according to the angle, as implemented for the eta-algorythm .
360 * @param angle Projected angle in degree.
361 */
362 Float_t TrkCluster::GetCOG(Float_t angle){
363
364 Int_t neta = 0;
365
366 // Float_t eta = GetETA(0,angle);
367 // for(neta=2; neta<10; neta++) if( eta == GetETA(neta,angle) ) break;
368 // if(eta != GetETA(neta,angle) )cout << "Attenzione!! pasticcio "<<endl;
369
370 if( view%2 ){ //Y
371 neta=2;
372 }else{ //X
373 if( fabs(angle) <= 10. ){
374 neta = 2;
375 }else if( fabs(angle) > 10. && fabs(angle) <= 15. ){
376 neta = 3;
377 }else{
378 neta = 4;
379 };
380 };
381
382 return GetCOG(neta);
383
384 };
385 //--------------------------------------
386 //
387 //
388 //--------------------------------------
389 /**
390 * Evaluates the cluster position, in strips, relative to the strip with the maximum signal (TrkCluster::maxs), by applying the non-linear ETA-algorythm.
391 * @param neta Number of strips to evaluate ETA.
392 * @param angle Projected angle between particle track and detector plane.
393 * Implemented values of neta are 2,3,4. If neta=0, ETA2, ETA3 and ETA4 are applied according to the angle.
394 */
395 Float_t TrkCluster::GetETA(Int_t neta, float angle){
396
397 // cout << "GetETA(neta,angle) "<< neta << " "<< angle;
398 // LoadPfaParam();
399
400 TrkParams::Load(4);
401 if( !TrkParams::IsLoaded(4) ){
402 cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- p.f.a. parameters not loaded"<<endl;
403 return 0;
404 }
405
406 float ax = angle;
407 int ic = 1;
408 GetLevel1Struct();
409 if(neta == 0) return pfaeta_(&ic,&ax);
410 else if(neta == 2) return pfaeta2_(&ic,&ax);
411 else if(neta == 3) return pfaeta3_(&ic,&ax);
412 else if(neta == 4) return pfaeta4_(&ic,&ax);
413 else cout << "ETA"<<neta<<" not implemented\n";
414 return 0;
415
416 };
417
418 //--------------------------------------
419 //
420 //
421 //--------------------------------------
422 TrkLevel1::TrkLevel1(){
423
424 // cout << "TrkLevel1::TrkLevel1()"<<endl;
425 // Cluster = new TClonesArray("TrkCluster");
426 Cluster = 0;
427 for(Int_t i=0; i<12 ; i++){
428 good[i] = -1;
429 for(Int_t j=0; j<24 ; j++){
430 cn[j][i]=0;
431 cnn[j][i]=0;
432 };
433 };
434 }
435 //--------------------------------------
436 //
437 //
438 //--------------------------------------
439 void TrkLevel1::Set(){
440 if(!Cluster)Cluster = new TClonesArray("TrkCluster");
441 }
442 //--------------------------------------
443 //
444 //
445 //--------------------------------------
446 void TrkLevel1::Dump(){
447
448 cout<<"DSP status: ";
449 for(Int_t i=0; i<12 ; i++)cout<<good[i]<<" ";
450 cout<<endl;
451 cout<<"VA1 mask : "<<endl;
452 for(Int_t i=0; i<12 ; i++){
453 for(Int_t ii=0; ii<24 ; ii++){
454 Int_t mask = cnn[ii][i];
455 if(mask>0)mask=1;
456 cout<<mask<<" ";
457 }
458 cout <<endl;
459 }
460
461 if(!Cluster)return;
462 TClonesArray &t = *Cluster;
463 for(int i=0; i<this->nclstr(); i++) ((TrkCluster *)t[i])->Dump();
464
465 }
466 //--------------------------------------
467 //
468 //
469 //--------------------------------------
470 /**
471 * Fills a TrkLevel1 object with values from a struct cTrkLevel1 (to get data from F77 common).
472 */
473 void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full){
474
475 // ---------------
476 // *** CLUSTER ***
477 // ---------------
478 TrkCluster* t_cl = new TrkCluster();
479 if(!Cluster)Cluster = new TClonesArray("TrkCluster");
480 TClonesArray &t = *Cluster;
481 for(int i=0; i<l1->nclstr1; i++){
482
483 t_cl->Clear();
484 // if( full || (!full && l1->whichtrack[i]) ){
485
486 t_cl->view = l1->view[i];
487 t_cl->maxs = l1->maxs[i];
488
489 if( full || (!full && l1->whichtrack[i]) ){
490 t_cl->indmax = l1->indmax[i] - l1->indstart[i];
491 Int_t from = l1->indstart[i] -1;
492 Int_t to = l1->totCLlength ;
493 if(i != l1->nclstr1-1)to = l1->indstart[i+1] -1 ;
494 t_cl->CLlength = to - from ;
495
496 t_cl->clsignal = new Float_t[t_cl->CLlength];
497 t_cl->clsigma = new Float_t[t_cl->CLlength];
498 t_cl->cladc = new Int_t[t_cl->CLlength];
499 t_cl->clbad = new Bool_t[t_cl->CLlength];
500 Int_t index = 0;
501 for(Int_t is = from; is < to; is++ ){
502 t_cl->clsignal[index] = (Float_t) l1->clsignal[is];
503 t_cl->clsigma[index] = (Float_t) l1->clsigma[is];
504 t_cl->cladc[index] = (Int_t) l1->cladc[is];
505 t_cl->clbad[index] = (Bool_t) l1->clbad[is];
506 index++;
507 };
508 }
509 new(t[i]) TrkCluster(*t_cl); // <<< store cluster
510 };
511
512 delete t_cl;
513
514 // -------------------------
515 // ****general variables****
516 // -------------------------
517 for(Int_t i=0; i<12 ; i++){
518 good[i] = l1->good[i];
519 for(Int_t j=0; j<24 ; j++){
520 cn[j][i] = l1->cnev[j][i];
521 // cnrms[j][i] = l1->cnrmsev[j][i];
522 cnn[j][i] = l1->cnnev[j][i];
523 };
524 };
525
526 }
527 /**
528 * Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common).
529 */
530
531 void TrkLevel1::GetLevel1Struct(cTrkLevel1* l1) {
532
533 // cTrkLevel1* l1 = &level1event_ ;
534
535 for(Int_t i=0; i<12 ; i++){
536 l1->good[i] = good[i];
537 for(Int_t j=0; j<24 ; j++){
538 l1->cnev[j][i] = cn[j][i] ;
539 l1->cnnev[j][i] = cnn[j][i] ;
540 l1->cnrmsev[j][i] = 0. ;
541 };
542 l1->fshower[i] = 0;
543 };
544
545 l1->nclstr1=0;
546 l1->totCLlength=0;
547 Int_t index=0;
548 if(Cluster){
549 Int_t i=0;
550 for(Int_t ii=0;ii<Cluster->GetEntries();ii++){
551 TrkCluster *clu = GetCluster(ii);
552 // ----------------------------------------
553 // attenzione!!
554 // se il cluster non e` salvato (view = 0)
555 // DEVE essere escluso dal common F77
556 // ----------------------------------------
557 if(clu->view != 0 ){
558 l1->view[i] = clu->view;
559 l1->ladder[i] = clu->GetLadder();
560 l1->maxs[i] = clu->maxs;
561 l1->mult[i] = clu->GetMultiplicity();
562 l1->dedx[i] = clu->GetSignal();
563 l1->indstart[i] = index+1;
564 l1->indmax[i] = l1->indstart[i] + clu->indmax;
565 l1->totCLlength += clu->CLlength;
566 for(Int_t iw=0; iw < clu->CLlength; iw++){
567 l1->clsignal[index] = clu->clsignal[iw];
568 l1->clsigma[index] = clu->clsigma[iw];
569 l1->cladc[index] = clu->cladc[iw];
570 l1->clbad[index] = clu->clbad[iw];
571 index++;
572 }
573 i++;
574 }
575 }
576 l1->nclstr1 = i;
577 }
578
579 // return l1;
580 }
581 //--------------------------------------
582 //
583 //
584 //--------------------------------------
585 void TrkLevel1::Clear(){
586
587 for(Int_t i=0; i<12 ; i++){
588 good[i] = -1;
589 for(Int_t j=0; j<24 ; j++){
590 cn[j][i] = 0;
591 cnn[j][i] = 0;
592 };
593 };
594 // if(Cluster)Cluster->Clear("C");
595 if(Cluster)Cluster->Delete();
596
597 }
598 //--------------------------------------
599 //
600 //
601 //--------------------------------------
602 void TrkLevel1::Delete(){
603
604 // Clear();
605 if(Cluster)Cluster->Delete();
606 if(Cluster)delete Cluster;
607
608 }
609 //--------------------------------------
610 //
611 //
612 //--------------------------------------
613 TrkCluster *TrkLevel1::GetCluster(int is){
614
615 if(!Cluster)return 0;
616 if(is >= nclstr()){
617 cout << "** TrkLevel1::GetCluster(int) ** Cluster "<< is << " does not exits! " << endl;
618 cout << "( Stored clusters nclstr() = "<< this->nclstr()<<" )" << endl;
619 return 0;
620 }
621
622 TClonesArray &t = *(Cluster);
623 TrkCluster *cluster = (TrkCluster*)t[is];
624 return cluster;
625 }
626 //--------------------------------------
627 //
628 //
629 //--------------------------------------
630 // /**
631 // * Load Position-Finding-Algorythm parameters (call the F77 routine).
632 // *
633 // */
634 // int TrkLevel1::LoadPfaParam(TString path){
635
636 // if( path.IsNull() ){
637 // path = gSystem->Getenv("PAM_CALIB");
638 // if(path.IsNull()){
639 // cout << " TrkLevel1::LoadPfaParam() ==> No PAMELA environment variables defined "<<endl;
640 // return 0;
641 // }
642 // path.Append("/trk-param/eta_param-0/");
643 // }
644
645 // strcpy(path_.path,path.Data());
646 // path_.pathlen = path.Length();
647 // path_.error = 0;
648 // cout <<"Loading p.f.a. parameters: "<<path<<endl;
649 // return readetaparam_();
650 // }
651
652 // /**
653 // * Load magnetic field parameters (call the F77 routine).
654 // *
655 // */
656 // int TrkLevel1::LoadFieldParam(TString path){
657
658 // // if( strcmp(path_.path,path.Data()) ){
659 // if( path.IsNull() ){
660 // path = gSystem->Getenv("PAM_CALIB");
661 // if(path.IsNull()){
662 // cout << " TrkLevel1::LoadFieldParam() ==> No PAMELA environment variables defined "<<endl;
663 // return 0;
664 // }
665 // path.Append("/trk-param/field_param-0/");
666 // }
667 // cout <<"Loading magnetic field "<<path<<endl;
668 // strcpy(path_.path,path.Data());
669 // path_.pathlen = path.Length();
670 // path_.error = 0;
671 // return readb_();
672 // // }
673 // // return 0;
674 // }
675 // /**
676 // * Load magnetic field parameters (call the F77 routine).
677 // *
678 // */
679 // int TrkLevel1::LoadChargeParam(TString path){
680
681 // // if( strcmp(path_.path,path.Data()) ){
682 // if( path.IsNull() ){
683 // path = gSystem->Getenv("PAM_CALIB");
684 // if(path.IsNull()){
685 // cout << " TrkLevel1::LoadChargeParam() ==> No PAMELA environment variables defined "<<endl;
686 // return 0;
687 // }
688 // path.Append("/trk-param/charge_param-1/");
689 // }
690 // cout <<"Loading charge-correlation parameters: "<<path<<endl;
691 // strcpy(path_.path,path.Data());
692 // path_.pathlen = path.Length();
693 // path_.error = 0;
694 // return readchargeparam_();
695 // // }
696 // // return 0;
697 // }
698 // /**
699 // * Load magnetic field parameters (call the F77 routine).
700 // *
701 // */
702 // int TrkLevel1::LoadAlignmentParam(TString path){
703
704 // // if( strcmp(path_.path,path.Data()) ){
705 // if( path.IsNull() ){
706 // path = gSystem->Getenv("PAM_CALIB");
707 // if(path.IsNull()){
708 // cout << " TrkLevel1::LoadAlignmentParam() ==> No PAMELA environment variables defined "<<endl;
709 // return 0;
710 // }
711 // path.Append("/trk-param/align_param-0/");
712 // }
713 // cout <<"Loading alignment parameters: "<<path<<endl;
714 // strcpy(path_.path,path.Data());
715 // path_.pathlen = path.Length();
716 // path_.error = 0;
717 // return readalignparam_();
718 // // }
719 // // return 0;
720 // }
721 // /**
722 // * Load magnetic field parameters (call the F77 routine).
723 // *
724 // */
725 // int TrkLevel1::LoadMipParam(TString path){
726
727 // // if( strcmp(path_.path,path.Data()) ){
728 // if( path.IsNull() ){
729 // path = gSystem->Getenv("PAM_CALIB");
730 // if(path.IsNull()){
731 // cout << " TrkLevel1::LoadMipParam() ==> No PAMELA environment variables defined "<<endl;
732 // return 0;
733 // }
734 // path.Append("/trk-param/mip_param-0/");
735 // }
736 // cout <<"Loading ADC-to-MIP conversion parameters: "<<path<<endl;
737 // strcpy(path_.path,path.Data());
738 // path_.pathlen = path.Length();
739 // path_.error = 0;
740 // return readmipparam_();
741 // // }
742 // // return 0;
743 // }
744 // /**
745 // * Load magnetic field parameters (call the F77 routine).
746 // *
747 // */
748 // int TrkLevel1::LoadVKMaskParam(TString path){
749
750 // // if( strcmp(path_.path,path.Data()) ){
751 // if( path.IsNull() ){
752 // path = gSystem->Getenv("PAM_CALIB");
753 // if(path.IsNull()){
754 // cout << " TrkLevel1::LoadVKMaskParam() ==> No PAMELA environment variables defined "<<endl;
755 // return 0;
756 // }
757 // path.Append("/trk-param/mask_param-1/");
758 // }
759 // cout <<"Loading VK-mask parameters: "<<path<<endl;
760 // strcpy(path_.path,path.Data());
761 // path_.pathlen = path.Length();
762 // path_.error = 0;
763 // return readvkmask_();
764 // // }
765 // // return 0;
766 // }
767
768 // /**
769 // * Load all (default) parameters. Environment variable must be defined.
770 // *
771 // */
772 // int TrkLevel1::LoadParams(){
773
774 // int result=0;
775
776 // result = result * LoadFieldParam();
777 // result = result * LoadPfaParam();
778 // result = result * LoadChargeParam();
779 // result = result * LoadAlignmentParam();
780 // result = result * LoadMipParam();
781 // result = result * LoadVKMaskParam();
782
783 // return result;
784 // }
785
786
787
788 int TrkLevel1::GetPfaNbinsAngle(){
789 TrkParams::Load(4);
790 if( !TrkParams::IsLoaded(4) ){
791 cout << "int TrkLevel1::GetPfaNbinsAngle() --- ERROR --- p.f.a. parameters not loaded"<<endl;
792 return 0;
793 }
794 return pfa_.nangbin;
795 };
796
797 int TrkLevel1::GetPfaNbinsETA(){
798 TrkParams::Load(4);
799 if( !TrkParams::IsLoaded(4) ){
800 cout << "int TrkLevel1::GetPfaNbinsETA() --- ERROR --- p.f.a. parameters not loaded"<<endl;
801 return 0;
802 }
803 return pfa_.netaval;
804 };
805
806 /**
807 *
808 *
809 */
810 float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang){
811
812 TrkParams::Load(4);
813 if( !TrkParams::IsLoaded(4) ){
814 cout << "float* TrkLevel1::GetPfaCoord(TString pfa, int nview, int nladder, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl;
815 return 0;
816 }
817
818 int nbins = GetPfaNbinsETA();
819 if(!nbins)return 0;
820
821 float *fcorr = new float [nbins];
822
823 if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
824 for(int ib=0; ib<nbins; ib++){
825 fcorr[ib] = pfa_.feta2[nang][nladder][nview][ib];
826 cout << pfa_.eta2[nang][ib] << " - " << pfa_.feta2[nang][nladder][nview][ib]<<endl;;
827 }
828 }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
829 for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta3[nang][nladder][nview][ib];
830 }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
831 for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.feta4[nang][nladder][nview][ib];
832 }else{
833 cout << pfa<<" pfa parameters not implemented "<<endl;
834 return 0;
835 }
836
837 return fcorr;
838
839 };
840
841 float* TrkLevel1::GetPfaAbs(TString pfa, int nang){
842
843 TrkParams::Load(4);
844 if( !TrkParams::IsLoaded(4) ){
845 cout << "float* TrkLevel1::GetPfaAbs(TString pfa, int nang) --- ERROR --- p.f.a. parameters not loaded"<<endl;
846 return 0;
847 }
848
849 int nbins = GetPfaNbinsETA();
850 if(!nbins)return 0;
851
852 float *fcorr = new float [nbins];
853
854 if(!pfa.CompareTo("ETA2",TString::kIgnoreCase)){
855 for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta2[nang][ib];
856 }else if (!pfa.CompareTo("ETA3",TString::kIgnoreCase)){
857 for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta3[nang][ib];
858 }else if (!pfa.CompareTo("ETA4",TString::kIgnoreCase)){
859 for(int ib=0; ib<nbins; ib++)fcorr[ib] = pfa_.eta4[nang][ib];
860 }else{
861 cout << pfa<<" pfa parameters not implemented "<<endl;
862 return 0;
863 }
864
865 return fcorr;
866
867 };
868
869 /**
870 * Method to call the F77 routine that performs level1->level2 processing.
871 * The level2 output is stored in a common block, which can be retrieved
872 * by mean of the method TrkLevel2::SetFromLevel2Struct().
873 * @param pfa Position finding algorythm used to reconstruct the track
874 * Implemented algorythms:
875 * 0 ETA (default)
876 * 1 ---
877 * 2 ETA2
878 * 3 ETA3
879 * 4 ETA4
880 * 10 COG
881 * 11 COG1
882 * 12 COG2
883 * 13 COG3
884 * 14 COG4
885 * NB If the TrkLevel1 object is readout from a tree, and the
886 * TrkLevel1::ProcessEvent(int pfa) is used to reprocess the event, attention
887 * should be payed to the fact that single clusters (clusters not associated
888 * with any track) might not be stored. Full reprocessing should be done from
889 * level0 data.
890 */
891 int TrkLevel1::ProcessEvent(int pfa){
892
893 // cout << "int TrkLevel1::ProcessEvent()" << endl;
894 TrkParams::Load( );
895 if( !TrkParams::IsLoaded() )return 0;
896
897 GetLevel1Struct();
898
899 analysisflight_(&pfa);
900
901 return 1;
902
903 }
904
905
906 ClassImp(TrkLevel1);
907 ClassImp(TrkCluster);

  ViewVC Help
Powered by ViewVC 1.1.23