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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by pam-fi, Thu Oct 12 15:41:03 2006 UTC revision 1.10 by pam-fi, Sat Dec 2 10:42:53 2006 UTC
# Line 40  TrkCluster::TrkCluster(){ Line 40  TrkCluster::TrkCluster(){
40  //  //
41  //--------------------------------------  //--------------------------------------
42  TrkCluster::~TrkCluster(){  TrkCluster::~TrkCluster(){
43            
44        if(CLlength){
45          delete [] clsignal;          delete [] clsignal;
46          delete [] clsigma;          delete [] clsigma;
47          delete [] cladc;          delete [] cladc;
48          delete [] clbad;          delete [] clbad;
49        }
50  };  };
51  //--------------------------------------  //--------------------------------------
52  //  //
# Line 57  TrkCluster::TrkCluster(const TrkCluster& Line 59  TrkCluster::TrkCluster(const TrkCluster&
59          indmax   = t.indmax;          indmax   = t.indmax;
60                    
61          CLlength = t.CLlength;            CLlength = t.CLlength;  
62          clsignal = new Float_t[CLlength];          if(CLlength){
63          clsigma  = new Float_t[CLlength];              clsignal = new Float_t[CLlength];
64          cladc    = new Int_t[CLlength];              clsigma  = new Float_t[CLlength];
65          clbad    = new Bool_t[CLlength];              cladc    = new Int_t[CLlength];
66          for(Int_t i=0; i<CLlength;i++){              clbad    = new Bool_t[CLlength];
67                for(Int_t i=0; i<CLlength;i++){
68                  clsignal[i] = t.clsignal[i];                  clsignal[i] = t.clsignal[i];
69                  clsigma[i]  = t.clsigma[i];                  clsigma[i]  = t.clsigma[i];
70                  cladc[i]    = t.cladc[i];                  cladc[i]    = t.cladc[i];
71                  clbad[i]    = t.clbad[i];                  clbad[i]    = t.clbad[i];
72                };
73          };          };
74    };
75    //--------------------------------------
76    //
77    //
78    //--------------------------------------
79    void TrkCluster::Clear(){
80            
81            view     = 0;
82            maxs     = 0;
83            indmax   = 0;
84            
85            CLlength = 0;
86            clsignal = 0;
87            clsigma  = 0;
88            cladc    = 0;
89            clbad    = 0;
90    
91  };  };
92  //--------------------------------------  //--------------------------------------
# Line 270  void TrkCluster::Dump(){ Line 290  void TrkCluster::Dump(){
290   */   */
291  cTrkLevel1* TrkCluster::GetLevel1Struct(){  cTrkLevel1* TrkCluster::GetLevel1Struct(){
292                                    
293          cTrkLevel1* l1 = new cTrkLevel1;  //    cTrkLevel1* l1 = new cTrkLevel1;
294            
295          l1->nclstr1 = 1;      cTrkLevel1* l1 = &level1event_ ;
         l1->view[0] = view;  
         l1->ladder[0] = GetLadder();  
         l1->maxs[0] = maxs;  
         l1->mult[0] = GetMultiplicity();  
         l1->dedx[0] = GetSignal();  
         l1->indstart[0] = 1;  
         l1->indmax[0]   = indmax+1;  
         l1->totCLlength = CLlength;  
         for(Int_t i=0; i<CLlength; i++){  
                 l1->clsignal[i] = clsignal[i];  
                 l1->clsigma[i] = clsigma[i];  
                 l1->cladc[i] = cladc[i];  
                 l1->clbad[i] = clbad[i];  
         };  
296                    
297          return l1;      l1->nclstr1 = 1;
298        l1->view[0] = view;
299        l1->ladder[0] = GetLadder();
300        l1->maxs[0] = maxs;
301        l1->mult[0] = GetMultiplicity();
302        l1->dedx[0] = GetSignal();
303        l1->indstart[0] = 1;
304        l1->indmax[0]   = indmax+1;
305        l1->totCLlength = CLlength;
306        for(Int_t i=0; i<CLlength; i++){
307            l1->clsignal[i] = clsignal[i];
308            l1->clsigma[i] = clsigma[i];
309            l1->cladc[i] = cladc[i];
310            l1->clbad[i] = clbad[i];
311        };
312        
313        return l1;
314  };  };
315  //--------------------------------------  //--------------------------------------
316  //  //
# Line 302  cTrkLevel1* TrkCluster::GetLevel1Struct( Line 324  cTrkLevel1* TrkCluster::GetLevel1Struct(
324   */   */
325  Float_t TrkCluster::GetCOG(Int_t ncog){  Float_t TrkCluster::GetCOG(Int_t ncog){
326                    
327          int ic = 1;      int ic = 1;
328          level1event_ = *GetLevel1Struct();      GetLevel1Struct();
329          return cog_(&ncog,&ic);      return cog_(&ncog,&ic);
330            
331    };
332    /**
333     * Evaluates the Center-Of-Gravity (COG) of the cluster, in strips, relative to the strip with the maximum signal (TrkCluster::maxs),
334     * choosing the number of strips according to the angle, as implemented for the eta-algorythm .
335     *      @param angle Projected angle in degree.        
336     */
337    Float_t TrkCluster::GetCOG(Float_t angle){
338                
339        Int_t neta  = 0;
340    
341    //     Float_t eta = GetETA(0,angle);
342    //     for(neta=2; neta<10; neta++) if( eta == GetETA(neta,angle) ) break;
343    //    if(eta != GetETA(neta,angle) )cout << "Attenzione!! pasticcio "<<endl;
344    
345        if( view%2 ){   //Y
346            neta=2;
347        }else{          //X
348            if( fabs(angle) <= 10. ){
349                neta = 2;
350            }else if( fabs(angle) > 10. && fabs(angle) <= 15. ){
351                neta = 3;
352            }else{
353                neta = 4;
354            };
355        };
356    
357        return GetCOG(neta);
358                    
359  };  };
360  //--------------------------------------  //--------------------------------------
# Line 319  Float_t TrkCluster::GetCOG(Int_t ncog){ Line 369  Float_t TrkCluster::GetCOG(Int_t ncog){
369   */   */
370  Float_t TrkCluster::GetETA(Int_t neta, float angle){  Float_t TrkCluster::GetETA(Int_t neta, float angle){
371                    
372    //    cout << "GetETA(neta,angle) "<< neta << " "<< angle;
373  //      LoadPfaParam();  //      LoadPfaParam();
374          int ic = 1;  
375          level1event_ = *GetLevel1Struct();      float ax = angle;
376          if(neta == 0)      return pfaeta_(&ic,&angle);      int ic = 1;
377          else if(neta == 2) return pfaeta2_(&ic,&angle);      GetLevel1Struct();
378          else if(neta == 3) return pfaeta3_(&ic,&angle);      if(neta == 0)      return pfaeta_(&ic,&ax);
379          else if(neta == 4) return pfaeta4_(&ic,&angle);      else if(neta == 2) return pfaeta2_(&ic,&ax);
380          else cout << "ETA"<<neta<<" not implemented\n";      else if(neta == 3) return pfaeta3_(&ic,&ax);
381          return 0;      else if(neta == 4) return pfaeta4_(&ic,&ax);
382                else cout << "ETA"<<neta<<" not implemented\n";
383        return 0;
384        
385  };  };
386    
387  //--------------------------------------  //--------------------------------------
# Line 336  Float_t TrkCluster::GetETA(Int_t neta, f Line 389  Float_t TrkCluster::GetETA(Int_t neta, f
389  //  //
390  //--------------------------------------  //--------------------------------------
391  TrkLevel1::TrkLevel1(){  TrkLevel1::TrkLevel1(){
392            
393        Cluster = new TClonesArray("TrkCluster");
394            
395  //      good1 = -1;      for(Int_t i=0; i<12 ; i++){
396                    good[i] = -1;
397          Cluster = new TClonesArray("TrkCluster");          for(Int_t j=0; j<24 ; j++){
398                        cn[j][i]=0;
399          for(Int_t i=0; i<12 ; i++){  //          cnrms[j][i]=0;
400  //              crc[i] = -1;              cnn[j][i]=0;
                 good[i] = -1;  
                 for(Int_t j=0; j<24 ; j++){  
                         cnev[j][i]=0;  
                         cnnev[j][i]=0;  
                 };  
 //              fshower[i]=0;  
401          };          };
402        };
403  }  }
404  //--------------------------------------  //--------------------------------------
405  //  //
# Line 357  TrkLevel1::TrkLevel1(){ Line 407  TrkLevel1::TrkLevel1(){
407  //--------------------------------------  //--------------------------------------
408  void TrkLevel1::Dump(){  void TrkLevel1::Dump(){
409            
410          cout<<"DSP status: ";      cout<<"DSP status: ";
411          for(Int_t i=0; i<12 ; i++)cout<<good[i]<<" ";      for(Int_t i=0; i<12 ; i++)cout<<good[i]<<" ";
412          cout<<endl;      cout<<endl;
413                cout<<"VA1 mask : "<<endl;
414          TClonesArray &t  = *Cluster;      for(Int_t i=0; i<12 ; i++){
415          for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();          for(Int_t ii=0; ii<24 ; ii++){
416                Int_t mask = cnn[ii][i];
417                if(mask>0)mask=1;
418                cout<<mask<<" ";
419            }
420            cout <<endl;
421        }
422        
423        TClonesArray &t  = *Cluster;
424        for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();
425        
426  }  }
427  //--------------------------------------  //--------------------------------------
428  //  //
# Line 372  void TrkLevel1::Dump(){ Line 431  void TrkLevel1::Dump(){
431  /**  /**
432   * Fills a TrkLevel1 object with values from a struct cTrkLevel1 (to get data from F77 common).   * Fills a TrkLevel1 object with values from a struct cTrkLevel1 (to get data from F77 common).
433   */   */
434  void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1){  void TrkLevel1::SetFromLevel1Struct(cTrkLevel1 *l1, Bool_t full){
435    
436          //  *** CLUSTER ***      //  ---------------
437          TrkCluster* t_cl = new TrkCluster();      //  *** CLUSTER ***
438          TClonesArray &t = *Cluster;      //  ---------------
439          for(int i=0; i<l1->nclstr1; i++){      TrkCluster* t_cl = new TrkCluster();
440                        TClonesArray &t = *Cluster;
441                  t_cl->view     = l1->view[i];      for(int i=0; i<l1->nclstr1; i++){
442                  t_cl->maxs     = l1->maxs[i];  
443                  t_cl->indmax   = l1->indmax[i] - l1->indstart[i];          t_cl->Clear();
444                            if( full || (!full && l1->whichtrack[i]) ){
445                  Int_t from = l1->indstart[i] -1;          
446                  Int_t to   = l1->totCLlength ;              t_cl->view     = l1->view[i];
447                  if(i != l1->nclstr1-1)to   = l1->indstart[i+1] -1 ;              t_cl->maxs     = l1->maxs[i];
448                  t_cl->CLlength = to - from ;              t_cl->indmax   = l1->indmax[i] - l1->indstart[i];
449                                
450                  t_cl->clsignal = new Float_t[t_cl->CLlength];              Int_t from = l1->indstart[i] -1;
451                  t_cl->clsigma  = new Float_t[t_cl->CLlength];              Int_t to   = l1->totCLlength ;
452                  t_cl->cladc    = new Int_t[t_cl->CLlength];              if(i != l1->nclstr1-1)to   = l1->indstart[i+1] -1 ;
453                  t_cl->clbad    = new Bool_t[t_cl->CLlength];              t_cl->CLlength = to - from ;
454                  Int_t index = 0;              
455                  for(Int_t is = from; is < to; is++ ){              t_cl->clsignal = new Float_t[t_cl->CLlength];
456                          t_cl->clsignal[index] = (Float_t) l1->clsignal[is];              t_cl->clsigma  = new Float_t[t_cl->CLlength];
457                          t_cl->clsigma[index]  = (Float_t) l1->clsigma[is];              t_cl->cladc    = new Int_t[t_cl->CLlength];
458                          t_cl->cladc[index]    = (Int_t)   l1->cladc[is];              t_cl->clbad    = new Bool_t[t_cl->CLlength];
459                          t_cl->clbad[index]    = (Bool_t)  l1->clbad[is];              Int_t index = 0;
460                          index++;              for(Int_t is = from; is < to; is++ ){
461                  };                  t_cl->clsignal[index] = (Float_t) l1->clsignal[is];
462                                                    t_cl->clsigma[index]  = (Float_t) l1->clsigma[is];
463                  new(t[i]) TrkCluster(*t_cl);                  t_cl->cladc[index]    = (Int_t)   l1->cladc[is];
464          };                  t_cl->clbad[index]    = (Bool_t)  l1->clbad[is];
465                            index++;
466          delete t_cl;              };
467            }
468          //  ****general variables****          new(t[i]) TrkCluster(*t_cl); // <<< store cluster
469        };
470          for(Int_t i=0; i<12 ; i++){      
471                  good[i] = -1;      delete t_cl;
472                  for(Int_t j=0; j<24 ; j++){      
473                          cnev[j][i]     = l1->cnev[j][i];      //  -------------------------
474                          cnnev[j][i] = l1->cnnev[j][i];      //  ****general variables****
475                  };      //  -------------------------    
476        for(Int_t i=0; i<12 ; i++){
477            good[i] = l1->good[i];
478            for(Int_t j=0; j<24 ; j++){
479                cn[j][i]     = l1->cnev[j][i];
480    //          cnrms[j][i]  = l1->cnrmsev[j][i];
481                cnn[j][i]    = l1->cnnev[j][i];
482          };          };
483                };
484        
485  }  }
486  /**  /**
487   * Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common).   * Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common).
# Line 423  void TrkLevel1::SetFromLevel1Struct(cTrk Line 489  void TrkLevel1::SetFromLevel1Struct(cTrk
489    
490  cTrkLevel1* TrkLevel1::GetLevel1Struct() {  cTrkLevel1* TrkLevel1::GetLevel1Struct() {
491                    
492          cTrkLevel1 *l1=0;      cTrkLevel1 *l1=0;
493          //          //
494          for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
495                  l1->good[i] = good[i];          l1->good[i] = good[i];
496                  for(Int_t j=0; j<24 ; j++){          for(Int_t j=0; j<24 ; j++){
497                          l1->cnev[j][i]  = cnev[j][i];              l1->cnev[j][i]    = cn[j][i];
498                          l1->cnnev[j][i] = cnnev[j][i];  //          l1->cnrmsev[j][i] = cnrms[j][i];
499                  };              l1->cnnev[j][i]   = cnn[j][i];
500          };          };
501                };
502        
503  //  *** CLUSTERS ***  //  *** CLUSTERS ***
504      l1->nclstr1 =  Cluster->GetEntries();      l1->nclstr1 =  Cluster->GetEntries();
505          for(Int_t i=0;i<l1->nclstr1;i++){      for(Int_t i=0;i<l1->nclstr1;i++){
506            
507                  l1->view[i]     = ((TrkCluster *)Cluster->At(i))->view;          l1->view[i]     = ((TrkCluster *)Cluster->At(i))->view;
508                  l1->maxs[i]     = ((TrkCluster *)Cluster->At(i))->maxs;          l1->maxs[i]     = ((TrkCluster *)Cluster->At(i))->maxs;
                 // COMPLETARE //  
                 // COMPLETARE //  
                 // COMPLETARE //  
                 // COMPLETARE //  
                 // COMPLETARE //  
                 // COMPLETARE //  
                   
         }  
509          // COMPLETARE //          // COMPLETARE //
510          // COMPLETARE //          // COMPLETARE //
511          // COMPLETARE //          // COMPLETARE //
512          // COMPLETARE //          // COMPLETARE //
513          // COMPLETARE //          // COMPLETARE //
514          // COMPLETARE //          // COMPLETARE //
515          return l1;          
516        }
517        // COMPLETARE //
518        // COMPLETARE //
519        // COMPLETARE //
520        // COMPLETARE //
521        // COMPLETARE //
522        // COMPLETARE //
523        return l1;
524  }  }
525  //--------------------------------------  //--------------------------------------
526  //  //
527  //  //
528  //--------------------------------------  //--------------------------------------
529  void TrkLevel1::Clear(){  void TrkLevel1::Clear(){
530                
531          for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
532                  good[i] = -1;          good[i] = -1;
533                  for(Int_t j=0; j<24 ; j++){          for(Int_t j=0; j<24 ; j++){
534                          cnev[j][i]     = 0;              cn[j][i]    = 0;
535                          cnnev[j][i] = 0;  //          cnrms[j][i] = 0;
536                  };              cnn[j][i]   = 0;
537          };          };
538          //      };
539          Cluster->Clear();      //
540        Cluster->Clear();
541        
542  }  }
543  //--------------------------------------  //--------------------------------------
544  //  //
# Line 478  void TrkLevel1::Clear(){ Line 546  void TrkLevel1::Clear(){
546  //--------------------------------------  //--------------------------------------
547  void TrkLevel1::Delete(){  void TrkLevel1::Delete(){
548                    
549          for(Int_t i=0; i<12 ; i++){      for(Int_t i=0; i<12 ; i++){
550                  good[i] = -1;          good[i] = -1;
551                  for(Int_t j=0; j<24 ; j++){          for(Int_t j=0; j<24 ; j++){
552                          cnev[j][i]     = 0;              cn[j][i]    = 0;
553                          cnnev[j][i] = 0;  //          cnrms[j][i] = 0;
554                  };              cnn[j][i]   = 0;
555          };          };
556          //      };
557          Cluster->Delete();      //
558        Cluster->Delete();
559        
560  }  }
561    
562  //--------------------------------------  //--------------------------------------
# Line 496  void TrkLevel1::Delete(){ Line 565  void TrkLevel1::Delete(){
565  //--------------------------------------  //--------------------------------------
566  TrkCluster *TrkLevel1::GetCluster(int is){  TrkCluster *TrkLevel1::GetCluster(int is){
567    
568          if(is >= this->nclstr()){  //      if(is >= this->nclstr()){
569                  cout << "** TrkLevel1::GetCluster(int) ** Cluster "<< is << " does not exits! " << endl;  //              cout << "** TrkLevel1::GetCluster(int) ** Cluster "<< is << " does not exits! " << endl;
570                  cout << "( Stored clusters nclstr() = "<< this->nclstr()<<" )" << endl;  //              cout << "( Stored clusters nclstr() = "<< this->nclstr()<<" )" << endl;
571                  return 0;  //              return 0;
572          }  //      }
573          TClonesArray &t = *(Cluster);          TClonesArray &t = *(Cluster);
574          TrkCluster *cluster = (TrkCluster*)t[is];          TrkCluster *cluster = (TrkCluster*)t[is];
575          return cluster;          return cluster;
# Line 516  TrkCluster *TrkLevel1::GetCluster(int is Line 585  TrkCluster *TrkLevel1::GetCluster(int is
585  int TrkLevel1::LoadPfaParam(TString path){  int TrkLevel1::LoadPfaParam(TString path){
586                    
587          if( strcmp(path_.path,path.Data()) ){          if( strcmp(path_.path,path.Data()) ){
588                  cout <<"Loading p.f.a. parameters\n";              cout <<"Loading p.f.a. parameters\n";
589                  strcpy(path_.path,path.Data());              strcpy(path_.path,path.Data());
590                  path_.pathlen = path.Length();              path_.pathlen = path.Length();
591                  path_.error   = 0;              path_.error   = 0;
592                  return readetaparam_();              return readetaparam_();
593          }                }      
594          return 0;          return 0;
595  }  }

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.23