/[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.15 by pam-fi, Thu Mar 15 12:17:10 2007 UTC revision 1.22 by pam-fi, Mon Aug 27 12:57:15 2007 UTC
# Line 16  extern "C" { Line 16  extern "C" {
16      float pfaeta2_(int*,float*);      float pfaeta2_(int*,float*);
17      float pfaeta3_(int*,float*);      float pfaeta3_(int*,float*);
18      float pfaeta4_(int*,float*);      float pfaeta4_(int*,float*);
19        float pfaetal_(int*,float*);
20        int   npfastrips_(int*,float*);
21                    
22  }  }
23  //--------------------------------------  //--------------------------------------
# Line 94  void TrkCluster::Clear(){ Line 96  void TrkCluster::Clear(){
96   * strips, around maxs, having a significant signal.   * strips, around maxs, having a significant signal.
97   * @param nstrip   Maximum number of strips.   * @param nstrip   Maximum number of strips.
98   * @param cut      Inclusion cut ( s > cut*sigma ).   * @param cut      Inclusion cut ( s > cut*sigma ).
99     * @param force    Falg to force the PFA strip-inclusion pattern (nstrip>0)
100   * If nstrip<=0 only the inclusion cut is used to determine the cluster size.   * If nstrip<=0 only the inclusion cut is used to determine the cluster size.
101   */   */
102  Float_t TrkCluster::GetSignal(Int_t nstrip, Float_t cut){  Float_t TrkCluster::GetSignal(Int_t nstrip, Float_t cut, Bool_t force){
103            
104      if(CLlength<=0)return 0;      if(CLlength<=0)return 0;
105    
106      Float_t s = 0;      Float_t s = 0;
107            
108        //-----------------------------------
109        // inlcude strips with s > cut*sigma
110        //-----------------------------------
111    
112      if( nstrip<=0 ){      if( nstrip<=0 ){
113  //          for(Int_t is = 0; is < CLlength; is++){  //          for(Int_t is = 0; is < CLlength; is++){
114  //              Float_t scut = cut*clsigma[is];  //              Float_t scut = cut*clsigma[is];
# Line 120  Float_t TrkCluster::GetSignal(Int_t nstr Line 127  Float_t TrkCluster::GetSignal(Int_t nstr
127          return s;          return s;
128      };      };
129            
130        //---------------------------------------------------
131        // inlcude strips with s > cut*sigma, up to nstrip.
132        // strips are included in order of decreasing signal
133        //---------------------------------------------------
134        if( !force ){
135    
136            Int_t il = indmax;
137            Int_t ir = indmax;
138            Int_t inc = 0;
139            
140            if( clsignal[indmax] < cut*clsigma[indmax] ) return 0;
141            
142            while ( inc < nstrip ){
143                Float_t sl = -100000;
144                Float_t sr = -100000;
145                if( il >= 0       ) sl = clsignal[il];
146                if( ir < CLlength ) sr = clsignal[ir];
147                if( sl == sr && inc == 0 ){
148                    s += clsignal[il]; //cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;
149                    il--;
150                    ir++;
151                }else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){
152                    s += sl;//cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;
153                    il--;
154                }else if ( sl < sr && sr > cut*clsigma[ir] ){
155                    s += sr;//cout << inc<<" - " << clsignal[ir]<<" "<<s<<endl;
156                    ir++;
157                }else break;
158                
159                inc++;
160            }
161            return s;
162    
163        }else{
164        //---------------------------------------------------
165        // evaluate signal using a fixed number of strips,
166        // following the PFA inclusion patters
167        //---------------------------------------------------
168    //     --> signal of the central strip
169            Float_t sc = clsignal[indmax];
170    //     signal of adjacent strips
171            Float_t sl1 = -9999.;
172            Float_t sl2 = -9999.;
173            Float_t sr1 = -9999.;
174            Float_t sr2 = -9999.;
175            if(indmax-1>=0) sl1 = clsignal[indmax-1];
176            if(indmax-2>=0) sl2 = clsignal[indmax-2];
177            if(indmax+1<CLlength) sr1 = clsignal[indmax+1];
178            if(indmax+2<CLlength) sr2 = clsignal[indmax+2];
179    
180            if(nstrip==1){
181                s = sc;
182            }else if(nstrip==2){
183                if( sl1>sr1 && sl1+sc!=0 )s = (sl1+sc);
184                if( sl1<sr1 && sr1+sc!=0 )s = (sc+sr1);
185                if( sl1==sr1 && sl1 != -9999.){
186                    if( clsigma[indmax-1] < clsigma[indmax+1] &&  sl1+sc!=0 )s = (sl1+sc);
187                    if( clsigma[indmax-1] > clsigma[indmax+1] &&  sc+sr1!=0 )s = (sc+sr1);
188                }
189            }else if(nstrip==3){
190                s = (sl1+sc+sr1);
191            }else if(nstrip==4){
192                if( sl2>sr2 && sl2+sl1+sc+sr1!=0 )s = (sl2+sl1+sc+sr1);
193                if( sl2<sr2 && sl1+sc+sr1+sr2!=0 )s = (sl1+sc+sr1+sr2);
194                if( sl2==sr2 && sl2 != -9999.){
195                    if( clsigma[indmax-2] < clsigma[indmax+2] &&  sl2+sl1+sc+sr1!=0 )s = (sl2+sl1+sc+sr1);
196                    if( clsigma[indmax-2] > clsigma[indmax+2] &&  sl1+sc+sr1+sr2!=0 )s = (sl1+sc+sr1+sr2);
197                }
198            }else if(nstrip==5){
199                s = (sl1+sc+sr1);
200                if(sl2 != -9999.)s += sl2;
201                if(sr2 != -9999.)s += sr2;
202            }else{
203                cout << "Float_t TrkCluster::GetSignal("<<nstrip<<","<<cut<<","<<force<<")- not implemented"<<endl;  
204            }
205            
206      Int_t il = indmax;      }
     Int_t ir = indmax;  
     Int_t inc = 0;  
207    
208      if( clsignal[indmax] < cut*clsigma[indmax] ) return 0;      return 0.;
209    
     while ( inc < nstrip ){  
         Float_t sl = -100000;  
         Float_t sr = -100000;  
         if( il >= 0       ) sl = clsignal[il];  
         if( ir < CLlength ) sr = clsignal[ir];  
         if( sl == sr && inc == 0 ){  
             s += clsignal[il]; //cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;  
             il--;  
             ir++;  
         }else if ( sl >= sr && sl > cut*clsigma[il] && inc !=0 ){  
             s += sl;//cout << inc<<" - "<< clsignal[il]<<" "<<s<<endl;  
             il--;  
         }else if ( sl < sr && sr > cut*clsigma[ir] ){  
             s += sr;//cout << inc<<" - " << clsignal[ir]<<" "<<s<<endl;  
             ir++;  
         }else break;  
           
         inc++;  
     }  
     return s;  
210  };  };
211    
212    
# Line 239  Bool_t TrkCluster::IsBad(Int_t nbad){ Line 299  Bool_t TrkCluster::IsBad(Int_t nbad){
299      il = indmax;      il = indmax;
300      ir = indmax;      ir = indmax;
301      for(Int_t i=1; i<nbad; i++){      for(Int_t i=1; i<nbad; i++){
302          if (ir == CLlength && il == 0)break;          if (ir == CLlength-1 && il == 0)break;
303          else if (ir == CLlength && il != 0)il--;          else if (ir == CLlength-1 && il != 0)il--;
304          else if (ir != CLlength && il == 0)ir++;          else if (ir != CLlength-1 && il == 0)ir++;
305          else{          else{
306              if(clsignal[il-1] > clsignal[ir+1])il--;              if(clsignal[il-1] > clsignal[ir+1])il--;
307              else ir++;              else ir++;
# Line 264  Bool_t TrkCluster::IsSaturated(Int_t nba Line 324  Bool_t TrkCluster::IsSaturated(Int_t nba
324      il = indmax;      il = indmax;
325      ir = indmax;      ir = indmax;
326      for(Int_t i=1; i<nbad; i++){      for(Int_t i=1; i<nbad; i++){
327          if (ir == CLlength && il == 0)break;          if (ir == CLlength-1 && il == 0)break;
328          else if (ir == CLlength && il != 0)il--;          else if (ir == CLlength-1 && il != 0)il--;
329          else if (ir != CLlength && il == 0)ir++;          else if (ir != CLlength-1 && il == 0)ir++;
330          else{          else{
331              if(clsignal[il-1] > clsignal[ir+1])il--;              if(clsignal[il-1] > clsignal[ir+1])il--;
332              else ir++;              else ir++;
# Line 291  void TrkCluster::Dump(){ Line 351  void TrkCluster::Dump(){
351      cout << "Position of maximun "<< maxs <<endl;      cout << "Position of maximun "<< maxs <<endl;
352      cout << "Multiplicity        "<< GetMultiplicity() <<endl;      cout << "Multiplicity        "<< GetMultiplicity() <<endl;
353      cout << "Tot signal          "<< GetSignal() << " (ADC channels)"<<endl ;      cout << "Tot signal          "<< GetSignal() << " (ADC channels)"<<endl ;
354      cout << "Signal/Noise        "<< GetSignalToNoise();      cout << "Signal/Noise        "<< GetSignalToNoise()<<endl;
355      cout <<endl<< "Strip signals       ";      cout << "COG                 "<< GetCOG(0)<<endl;;
356        cout << "Strip signals       ";
357      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsignal[i];
358      cout <<endl<< "Strip sigmas        ";      cout <<endl<< "Strip sigmas        ";
359      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];      for(Int_t i =0; i<CLlength; i++)cout << " " <<clsigma[i];
# Line 387  Float_t TrkCluster::GetCOG(Float_t angle Line 448  Float_t TrkCluster::GetCOG(Float_t angle
448  //  //
449  //--------------------------------------  //--------------------------------------
450  /**  /**
451   * Evaluates the cluster position, in strips, relative to the strip with the maximum signal (TrkCluster::maxs), by applying the non-linear ETA-algorythm.   * Evaluates the cluster position, in pitch units, relative to the strip with the maximum signal (TrkCluster::maxs), by applying the non-linear ETA-algorythm.
452   *  @param neta  Number of strips to evaluate ETA.   *  @param neta  Number of strips to evaluate ETA.
453   *  @param angle Projected angle between particle track and detector plane.   *  @param angle Projected (effective) angle between particle track and detector plane.
454   * Implemented values of neta are 2,3,4. If neta=0, ETA2, ETA3 and ETA4 are applied according to the angle.   * Implemented values of neta are 2,3,4. If neta=0, ETA2, ETA3 and ETA4 are applied according to the angle.
455   */   */
456  Float_t TrkCluster::GetETA(Int_t neta, float angle){  Float_t TrkCluster::GetETA(Int_t neta, float angle, bool landi){
457                    
458  //    cout << "GetETA(neta,angle) "<< neta << " "<< angle;  //    cout << "GetETA(neta,angle) "<< neta << " "<< angle;
459  //      LoadPfaParam();  //      LoadPfaParam();
460    
461      TrkParams::Load(4);      TrkParams::Load(4);
462      if( !TrkParams::IsLoaded(4) ){      if( !TrkParams::IsLoaded(4) ){
463          cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- p.f.a. parameters  not loaded"<<endl;          cout << "Float_t TrkCluster::GetETA(Int_t neta, float angle, bool landi) --- ERROR --- p.f.a. parameters  not loaded"<<endl;
464          return 0;          return 0;
465      }      }
466    
467      float ax = angle;      float ax = angle;
468      int ic = 1;      int ic = 1;
469      GetLevel1Struct();      GetLevel1Struct();
470      if(neta == 0)      return pfaeta_(&ic,&ax);      if(     neta == 0 && !landi) return pfaeta_(&ic,&ax);
471      else if(neta == 2) return pfaeta2_(&ic,&ax);      else if(neta == 0 && landi ) return pfaetal_(&ic,&ax);
472      else if(neta == 3) return pfaeta3_(&ic,&ax);      else if(neta == 2          ) return pfaeta2_(&ic,&ax);
473      else if(neta == 4) return pfaeta4_(&ic,&ax);      else if(neta == 3          ) return pfaeta3_(&ic,&ax);
474      else cout << "ETA"<<neta<<" not implemented\n";      else if(neta == 4          ) return pfaeta4_(&ic,&ax);
475        else cout << "TrkCluster::GetETA("<<neta<<","<<angle<<","<<landi<<") not implemented\n";
476      return 0;      return 0;
477            
478  };  };
479    
480    /**
481     * Evaluates the cluster position, in pitch unit, relative to the strip with
482     * the maximum signal (TrkCluster::maxs), by applying the PFA set as default (see TrkParams).
483     *  @param angle Projected (effective) angle between particle track and detector plane.
484     */
485    Float_t TrkCluster::GetPositionPU(float angle){
486    
487        if     ( TrkParams::GetPFA() == 0  )return GetETA(0,angle,false);
488        else if( TrkParams::GetPFA() == 2  )return GetETA(2,angle,false);
489        else if( TrkParams::GetPFA() == 3  )return GetETA(3,angle,false);
490        else if( TrkParams::GetPFA() == 4  )return GetETA(4,angle,false);
491        else if( TrkParams::GetPFA() == 5  )return GetETA(0,angle,true);
492        else if( TrkParams::GetPFA() == 10 )return GetCOG(0);
493        else if( TrkParams::GetPFA() == 11 )return GetCOG(1);
494        else if( TrkParams::GetPFA() == 12 )return GetCOG(2);
495        else if( TrkParams::GetPFA() == 13 )return GetCOG(3);
496        else if( TrkParams::GetPFA() == 14 )return GetCOG(4);
497        else cout << "  TrkCluster::GetPositionPU(float "<<angle<<") -- WARNING -- PFA="<<TrkParams::GetPFA()<<" not implemented"<<endl;
498        
499        return 0.;
500        
501    }
502    
503    /**
504     * Give the number of strip used to evaluate the cluster coordinate
505     * according to the p.f.a.
506     * It returns 0 when the COG is used (in this case the number of strip used
507     * equals the multiplicity).
508     */
509    Int_t TrkCluster::GetPFAstrips(float angle){
510    
511        float ax = angle;
512        int ic = 1;
513        GetLevel1Struct();
514        return npfastrips_(&ic,&ax);
515    
516    }
517    
518  //--------------------------------------  //--------------------------------------
519  //  //
520  //  //
# Line 431  TrkLevel1::TrkLevel1(){ Line 531  TrkLevel1::TrkLevel1(){
531              cnn[j][i]=0;              cnn[j][i]=0;
532          };          };
533      };      };
534        TrkParams::SetTrackingMode();
535        TrkParams::SetPrecisionFactor();
536        TrkParams::SetStepMin();
537        TrkParams::SetPFA();
538  }  }
539  //--------------------------------------  //--------------------------------------
540  //  //
# Line 463  void TrkLevel1::Dump(){ Line 567  void TrkLevel1::Dump(){
567      for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();      for(int i=0; i<this->nclstr(); i++)     ((TrkCluster *)t[i])->Dump();
568            
569  }  }
570    /**
571     * \brief Dump processing status
572     */
573    void TrkLevel1::StatusDump(int view){
574        cout << "DSP n. "<<view+1<<" (level1-)status: "<<hex<<showbase<<good[view]<<dec<<endl;    
575    };
576    /**
577     * \brief Check event status
578     *
579     * Check the event status, according to a flag-mask given as input.
580     * Return true if the view passes the check.
581     *
582     * @param view View number (0-11)
583     * @param flagmask Mask of flags to check (eg. flagmask=0x111 no missing packet,
584     *  no crc error, no software alarm)
585     *
586     * @see TrkLevel2 class definition to know how the status flag is defined
587     *
588     */
589    Bool_t TrkLevel1::StatusCheck(int view, int flagmask){
590    
591        if( view<0 || view >= 12)return false;
592        return !(good[view]&flagmask);
593    
594    };
595    
596    
597  //--------------------------------------  //--------------------------------------
598  //  //
599  //  //
# Line 500  void TrkLevel1::SetFromLevel1Struct(cTrk Line 631  void TrkLevel1::SetFromLevel1Struct(cTrk
631              t_cl->clsigma  = new Float_t[t_cl->CLlength];              t_cl->clsigma  = new Float_t[t_cl->CLlength];
632              t_cl->cladc    = new Int_t[t_cl->CLlength];              t_cl->cladc    = new Int_t[t_cl->CLlength];
633              t_cl->clbad    = new Bool_t[t_cl->CLlength];              t_cl->clbad    = new Bool_t[t_cl->CLlength];
634    
635              Int_t index = 0;              Int_t index = 0;
636              for(Int_t is = from; is < to; is++ ){              for(Int_t is = from; is < to; is++ ){
637                  t_cl->clsignal[index] = (Float_t) l1->clsignal[is];                  t_cl->clsignal[index] = (Float_t) l1->clsignal[is];
# Line 873  float* TrkLevel1::GetPfaAbs(TString pfa, Line 1005  float* TrkLevel1::GetPfaAbs(TString pfa,
1005   * Method to call the F77 routine that performs level1->level2 processing.   * Method to call the F77 routine that performs level1->level2 processing.
1006   * The level2 output is stored in a common block, which can be retrieved   * The level2 output is stored in a common block, which can be retrieved
1007   * by mean of the method TrkLevel2::SetFromLevel2Struct().   * by mean of the method TrkLevel2::SetFromLevel2Struct().
  * @param pfa Position finding algorythm used to reconstruct the track  
  * Implemented algorythms:  
  * 0  ETA (default)  
  * 1  ---  
  * 2  ETA2  
  * 3  ETA3  
  * 4  ETA4  
  * 10 COG  
  * 11 COG1  
  * 12 COG2  
  * 13 COG3  
  * 14 COG4  
1008   * NB If the TrkLevel1 object is readout from a tree, and the   * NB If the TrkLevel1 object is readout from a tree, and the
1009   * TrkLevel1::ProcessEvent(int pfa) is used to reprocess the event, attention   * TrkLevel1::ProcessEvent(int pfa) is used to reprocess the event, attention
1010   * should be payed to the fact that single clusters (clusters not associated   * should be payed to the fact that single clusters (clusters not associated
1011   * with any track) might not be stored. Full reprocessing should be done from   * with any track) might not be stored. Full reprocessing should be done starting
1012   * level0 data.   * from level0 data.
1013   */   */
1014  int TrkLevel1::ProcessEvent(int pfa){  //int TrkLevel1::ProcessEvent(int pfa){
1015    int TrkLevel1::ProcessEvent(){
1016    
1017  //    cout << "int TrkLevel1::ProcessEvent()" << endl;  //    cout << "int TrkLevel1::ProcessEvent()" << endl;
1018      TrkParams::Load( );      TrkParams::Load( );
# Line 899  int TrkLevel1::ProcessEvent(int pfa){ Line 1020  int TrkLevel1::ProcessEvent(int pfa){
1020    
1021      GetLevel1Struct();      GetLevel1Struct();
1022    
1023      analysisflight_(&pfa);  //    analysisflight_(&pfa);
1024    //    TrkParams::SetPFA(pfa);
1025  //    cout << "...done"<<endl;      analysisflight_();
1026    
1027      return 1;      return 1;
1028    

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.23