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

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

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

revision 1.42 by pam-fi, Tue Nov 27 15:28:57 2007 UTC revision 1.54 by pam-fi, Wed Mar 11 14:19:10 2009 UTC
# Line 12  using namespace std; Line 12  using namespace std;
12  extern "C" {      extern "C" {    
13      void dotrack_(int*, double*, double*, double*, double*, int*);      void dotrack_(int*, double*, double*, double*, double*, int*);
14      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);
15        void dotrack3_(int*, double*, double*, double*, double*,double*, double*, double*,double*,int*);
16      void mini2_(int*,int*,int*);      void mini2_(int*,int*,int*);
17      void guess_();      void guess_();
18      void gufld_(float*, float*);      void gufld_(float*, float*);
# Line 60  TrkTrack::TrkTrack(){ Line 61  TrkTrack::TrkTrack(){
61          ypu[ip]    = 0;            ypu[ip]    = 0;  
62    
63      };      };
64        
65  //     TrkParams::SetTrackingMode();  //     TrkParams::SetTrackingMode();
66  //     TrkParams::SetPrecisionFactor();  //     TrkParams::SetPrecisionFactor();
67  //     TrkParams::SetStepMin();  //     TrkParams::SetStepMin();
68      TrkParams::SetMiniDefault();      TrkParams::SetMiniDefault();
69      TrkParams::SetPFA();      TrkParams::SetPFA();
70    
71        int ngf = TrkParams::nGF;
72        for(int i=0; i<ngf; i++){
73            xGF[i] = 0.;
74            yGF[i] = 0.;
75        }
76    
77    
78  };  };
79  //--------------------------------------  //--------------------------------------
80  //  //
# Line 112  TrkTrack::TrkTrack(const TrkTrack& t){ Line 120  TrkTrack::TrkTrack(const TrkTrack& t){
120      TrkParams::SetMiniDefault();      TrkParams::SetMiniDefault();
121      TrkParams::SetPFA();      TrkParams::SetPFA();
122    
123        int ngf = TrkParams::nGF;
124        for(int i=0; i<ngf; i++){
125            xGF[i] = t.xGF[i];
126            yGF[i] = t.yGF[i];
127        }
128  };  };
129  //--------------------------------------  //--------------------------------------
130  //  //
# Line 152  void TrkTrack::Copy(TrkTrack& t){ Line 165  void TrkTrack::Copy(TrkTrack& t){
165          t.ypu[ip]      = ypu[ip];            t.ypu[ip]      = ypu[ip];  
166                            
167      };      };
168        int ngf = TrkParams::nGF;
169        for(int i=0; i<ngf; i++){
170            t.xGF[i] = xGF[i];
171            t.yGF[i] = yGF[i];
172        }
173    
174            
175  };  };
# Line 160  void TrkTrack::Copy(TrkTrack& t){ Line 178  void TrkTrack::Copy(TrkTrack& t){
178  //  //
179  //--------------------------------------  //--------------------------------------
180  /**  /**
181   * Evaluates the trajectory in the apparatus associated to the track.   *
182   * It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling  TrkLevel2::LoadField() ), otherwise an error message is returned.     * >>> OBSOLETE !!! use TrkTrack::DoTrack(Trajectory* t) instead
183   * @param t pointer to an object of the class Trajectory,   *
  * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ).  
  * @return error flag.  
184   */   */
185  int TrkTrack::DoTrack(Trajectory* t){  int TrkTrack::DoTrack2(Trajectory* t){
   
     double *dxout = new double[t->npoint];  
     double *dyout = new double[t->npoint];  
     double *dzin = new double[t->npoint];  
     double dal[5];  
   
     int ifail = 0;  
   
     for (int i=0; i<5; i++)         dal[i]  = (double)al[i];  
     for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i];  
186    
187      TrkParams::Load(1);      cout << endl;
188      if( !TrkParams::IsLoaded(1) ){      cout << " int TrkTrack::DoTrack2(Trajectory* t) --->> NB NB !! this method is going to be eliminated !!! "<<endl;
189          cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl;      cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl;
190          return 0;      cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl;
191      }      cout << endl;
     dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail);  
       
     for (int i=0; i<t->npoint; i++){  
         t->x[i] = (float)*dxout++;  
         t->y[i] = (float)*dyout++;  
     }  
192    
193  //    delete [] dxout;      return DoTrack(t);
 //    delete [] dyout;  
 //    delete [] dzin;  
194    
     return ifail;  
195  };  };
196  //--------------------------------------  //--------------------------------------
197  //  //
198  //  //
199  //--------------------------------------  //--------------------------------------
200  /**  /**
201   * Evaluates the trajectory in the apparatus associated to the track.   * Evaluates the trajectory in the apparatus associated to the track state-vector.
202   * It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling  TrkLevel2::LoadField() ), otherwise an error message is returned.     * It integrates the equations of motion in the magnetic field.
203   * @param t pointer to an object of the class Trajectory,   * @param t pointer to an object of the class Trajectory,
204   * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ).   * which z coordinates should be previously assigned.
205   * @return error flag.   * @return error flag.
206   */   */
207  int TrkTrack::DoTrack2(Trajectory* t){  int TrkTrack::DoTrack(Trajectory* t){
208    
209      double *dxout   = new double[t->npoint];      double *dxout   = new double[t->npoint];
210      double *dyout   = new double[t->npoint];      double *dyout   = new double[t->npoint];
# Line 224  int TrkTrack::DoTrack2(Trajectory* t){ Line 221  int TrkTrack::DoTrack2(Trajectory* t){
221    
222      TrkParams::Load(1);      TrkParams::Load(1);
223      if( !TrkParams::IsLoaded(1) ){      if( !TrkParams::IsLoaded(1) ){
224          cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl;          cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl;
225          return 0;          return 0;
226      }      }
227      dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);      dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
228            
229      for (int i=0; i<t->npoint; i++){      for (int i=0; i<t->npoint; i++){
230          t->x[i]   = (float)*dxout++;          t->x[i]   = (float)*(dxout+i);
231          t->y[i]   = (float)*dyout++;          t->y[i]   = (float)*(dyout+i);
232          t->thx[i] = (float)*dthxout++;          t->thx[i] = (float)*(dthxout+i);
233          t->thy[i] = (float)*dthyout++;          t->thy[i] = (float)*(dthyout+i);
234          t->tl[i]  = (float)*dtlout++;          t->tl[i]  = (float)*(dtlout+i);
235      }      }
236    
237  //    delete [] dxout;      delete [] dxout;
238  //    delete [] dyout;      delete [] dyout;
239  //    delete [] dzin;      delete [] dzin;
240        delete [] dthxout;
241        delete [] dthyout;
242        delete [] dtlout;
243    
244      return ifail;      return ifail;
245  };  };
# Line 299  Float_t TrkTrack::GetDEDX(){ Line 299  Float_t TrkTrack::GetDEDX(){
299      return dedx;      return dedx;
300  };  };
301  /**  /**
302   * Returns 1 if the cluster on a tracker view includes bad strips.   * Returns 1 if the cluster on a tracker view includes bad strips
303     * (at least one bad strip among the four strip used by p.f.a.)
304   * @param ip plane (0-5)   * @param ip plane (0-5)
305   * @param iv view (0=x 1=y)   * @param iv view (0=x 1=y)
306   */   */
# Line 373  Int_t TrkTrack::GetLeverArmY(){ Line 374  Int_t TrkTrack::GetLeverArmY(){
374      return (last_plane-first_plane+1);      return (last_plane-first_plane+1);
375  }  }
376  /**  /**
377     * Returns the track "lever-arm" on the x+y view, defined as the distance (in planes) between
378     * the upper and lower x,y (couple) measurements (the maximum value of lever-arm is 6).
379     */
380    Int_t TrkTrack::GetLeverArmXY(){
381        int first_plane = -1;
382        int last_plane  = -1;
383        for(Int_t ip=0; ip<6; ip++){
384            if( XGood(ip)*YGood(ip) && first_plane == -1 )first_plane = ip;
385            if( XGood(ip)*YGood(ip) && first_plane != -1 )last_plane = ip;
386        }
387        if( first_plane == -1 || last_plane == -1){
388            cout<< "Int_t TrkTrack::GetLeverArmXY() -- XGood(ip)*YGood(ip) always false ??? "<<endl;
389            return 0;
390        }
391        return (last_plane-first_plane+1);
392    }
393    /**
394   * Returns the reduced chi-square of track x-projection   * Returns the reduced chi-square of track x-projection
395   */   */
396  Float_t  TrkTrack::GetChi2X(){  Float_t  TrkTrack::GetChi2X(){
# Line 583  void TrkTrack::SetStudentParam(int flag) Line 601  void TrkTrack::SetStudentParam(int flag)
601                     4.52043,                     4.52043,
602                     4.29926};                     4.29926};
603      int index;      int index;
604      float fact;      float fact=0.;
605      for(int i=0; i<6; i++) {      for(int i=0; i<6; i++) {
606          index = int((fabs(axv[i])+1.)/2.);          index = int((fabs(axv[i])+1.)/2.);
607          if(index>10) index=10;          if(index>10) index=10;
# Line 630  void TrkTrack::LoadField(TString path){ Line 648  void TrkTrack::LoadField(TString path){
648    
649      TrkParams::Set(path,1);      TrkParams::Set(path,1);
650      TrkParams::Load(1);      TrkParams::Load(1);
651        if( !TrkParams::IsLoaded(1) ){
652            cout << "void TrkTrack::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl;
653        }
654    
655  };  };
656    
# Line 651  void TrkTrack::FillMiniStruct(cMini2trac Line 672  void TrkTrack::FillMiniStruct(cMini2trac
672          track.zm[i]=zm[i];          track.zm[i]=zm[i];
673                    
674  //      --- temporaneo ----------------------------  //      --- temporaneo ----------------------------
675  //      andrebbe inserita la dimensione del sensore  //      float segment = 100.;
676          float segment = 100.;  //      track.xm_a[i]=xm[i];
677          track.xm_a[i]=xm[i];  //      track.xm_b[i]=xm[i];
678          track.xm_b[i]=xm[i];  //      track.ym_a[i]=ym[i];
679          track.ym_a[i]=ym[i];  //      track.ym_b[i]=ym[i];
680          track.ym_b[i]=ym[i];  //      if(       XGood(i) && !YGood(i) ){
681          if(       XGood(i) && !YGood(i) ){  //          track.ym_a[i] = track.ym_a[i]+segment;
682              track.ym_a[i] = track.ym_a[i]+segment;  //          track.ym_b[i] = track.ym_b[i]-segment;
683              track.ym_b[i] = track.ym_b[i]-segment;  //      }else if( !XGood(i) && YGood(i)){
684          }else if( !XGood(i) && YGood(i)){  //          track.xm_a[i] = track.xm_a[i]+segment;
685              track.xm_a[i] = track.xm_a[i]+segment;  //          track.xm_b[i] = track.xm_b[i]-segment;
686              track.xm_b[i] = track.xm_b[i]-segment;  //      }
         }  
687  //      --- temporaneo ----------------------------  //      --- temporaneo ----------------------------
688    
689            if( XGood(i) || YGood(i) ){
690                double segment = 2.;//cm
691                // NB: i parametri di allineamento hanno una notazione particolare!!!
692                // sensor = 0 (hybrid side), 1
693                // ladder = 0-2 (increasing x)
694                // plane  = 0-5 (from bottom to top!!!)
695                int is = (int)GetSensor(i); if(i==5)is=1-is;
696                int ip = 5-i;
697                int il = (int)GetLadder(i);
698                
699                double omega   = 0.;
700                double beta    = 0.;
701                double gamma   = 0.;
702                if(
703                    (is < 0 || is > 1 || ip < 0 || ip > 5 || il < 0 || il > 2) &&
704                    true){
705                    // se il piano risulta colpito, ladder e sensore devono essere
706                    // assegnati correttamente
707                    cout << " void TrkTrack::FillMiniStruct(cMini2track&) --- WARNING --- sensor not defined, cannot read alignment parameters "<<endl;
708                    cout << " is ip il = "<<is<<" "<<ip<<" "<<il<<endl;
709                }else{
710                    omega   = alignparameters_.omega[is][il][ip];
711                    beta    = alignparameters_.beta[is][il][ip];
712                    gamma   = alignparameters_.gamma[is][il][ip];
713                }
714                
715                if(       XGood(i) && !YGood(i) ){
716                    track.xm_a[i] = xm[i] - omega * segment;
717                    track.ym_a[i] = ym[i] + segment;
718    //          track.zm_a[i] = zm[i] + beta * segment;//not used yet
719                    track.xm_b[i] = xm[i] + omega * segment;
720                    track.ym_b[i] = ym[i] - segment;
721    //          track.zm_b[i] = zm[i] - beta * segment;//not used yet
722                }else if( !XGood(i) && YGood(i) ){
723                    track.xm_a[i] = xm[i] + segment;
724                    track.ym_a[i] = ym[i] + omega * segment;
725    //          track.zm_a[i] = zm[i] - gamma * segment;//not used yet
726                    track.xm_b[i] = xm[i] - segment;
727                    track.ym_b[i] = ym[i] - omega * segment;
728    //          track.zm_b[i] = zm[i] + gamma * segment;//not used yet
729                }
730            }
731                    
732          track.resx[i]=resx[i];          track.resx[i]=resx[i];
733          track.resy[i]=resy[i];          track.resy[i]=resy[i];
734          track.tailx[i]=tailx[i];          track.tailx[i]=tailx[i];
735          track.taily[i]=taily[i];          track.taily[i]=taily[i];
# Line 729  Bool_t TrkTrack::EvaluateClusterPosition Line 792  Bool_t TrkTrack::EvaluateClusterPosition
792            
793  //     cout << "void TrkTrack::GetClusterositions() "<<endl;  //     cout << "void TrkTrack::GetClusterositions() "<<endl;
794    
795      TrkParams::Load( );      TrkParams::Load(1);
796      if( !TrkParams::IsLoaded() )return false;      if( !TrkParams::IsLoaded(1) ){
797                cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl;
798            return false;
799        }    
800        TrkParams::Load(4);
801        if( !TrkParams::IsLoaded(4) ){
802            cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl;
803            return false;
804        }
805        TrkParams::Load(5);
806        if( !TrkParams::IsLoaded(5) ){
807            cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl;
808            return false;
809        }
810    
811      for(int ip=0; ip<6; ip++){      for(int ip=0; ip<6; ip++){
812  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;
813          int icx = GetClusterX_ID(ip)+1;          int icx = GetClusterX_ID(ip)+1;
# Line 783  Bool_t TrkTrack::EvaluateClusterPosition Line 859  Bool_t TrkTrack::EvaluateClusterPosition
859   */   */
860  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){
861    
862      float al_ini[] = {0.,0.,0.,0.,0.};      TrkParams::Load(1);
863        if( !TrkParams::IsLoaded(1) ){
864            cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl;
865            return;
866        }
867        TrkParams::Load(5);
868        if( !TrkParams::IsLoaded(5) ){
869            cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- align.param. not loaded "<<endl;
870            return;
871        }
872    
873      TrkParams::Load( );      float al_ini[] = {0.,0.,0.,0.,0.};
     if( !TrkParams::IsLoaded() )return;  
874    
875      extern cMini2track track_;      extern cMini2track track_;
876      fail = 0;      fail = 0;
# Line 822  void TrkTrack::Fit(double pfixed, int& f Line 906  void TrkTrack::Fit(double pfixed, int& f
906    
907      //  ------------------------------------------      //  ------------------------------------------
908      //  call mini routine      //  call mini routine
909  //     TrkParams::Load(1);      //  ------------------------------------------
 //     if( !TrkParams::IsLoaded(1) ){  
 //      cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl;  
 //      return;  
 //     }  
910      int istep=0;      int istep=0;
911      int ifail=0;      int ifail=0;
912      mini2_(&istep,&ifail, &iprint);      mini2_(&istep,&ifail, &iprint);
# Line 890  void TrkTrack::SetDeltaB(int id, double Line 970  void TrkTrack::SetDeltaB(int id, double
970  }  }
971    
972  /**  /**
973   * Returns 1 if the track is inside the magnet cavity   * Returns true if the track is inside the magnet cavity.
974   * Set the minimum number of steps for tracking precision   * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
975   */   */
976  Bool_t TrkTrack::IsInsideCavity(){  Bool_t TrkTrack::IsInsideCavity(float toll){
977      float xmagntop, ymagntop, xmagnbottom, ymagnbottom;  
978      xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*axv[0]/180.);  //     float xmagntop, ymagntop, xmagnbottom, ymagnbottom;
979      ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(cos(-1.0)*ayv[0]/180.);  //     xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.);
980      xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*axv[5]/180.);  //     ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*ayv[0]/180.);
981      ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(cos(-1.0)*ayv[5]/180.);  //     xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*axv[5]/180.);
982      if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&  //     ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.);
983          ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&  //     if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&
984          xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&  //      ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&
985          ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);  //      xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&
986      else return(false);  //      ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);
987    //     else return(false);
988    
989        int ngf = TrkParams::nGF;
990        for(int i=0; i<ngf; i++){
991            //
992    //      cout << endl << TrkParams::GF_element[i];
993            if(
994                TrkParams::GF_element[i].CompareTo("CUF") &&
995                TrkParams::GF_element[i].CompareTo("T2")  &&
996                TrkParams::GF_element[i].CompareTo("T3")  &&
997                TrkParams::GF_element[i].CompareTo("T4")  &&
998                TrkParams::GF_element[i].CompareTo("T5")  &&
999                TrkParams::GF_element[i].CompareTo("CLF") &&
1000                true)continue;
1001            // apply condition only within the cavity
1002    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1003            if(
1004                xGF[i] <= TrkParams::xGF_min[i] + toll ||
1005                xGF[i] >= TrkParams::xGF_max[i] - toll ||
1006                yGF[i] <= TrkParams::yGF_min[i] + toll ||
1007                yGF[i] >= TrkParams::yGF_max[i] - toll ||
1008                false){
1009                
1010                return false;
1011            }
1012        }
1013        return true;
1014    
1015    
1016  }  }
1017  /**  /**
1018     * Returns true if the track is inside the nominal acceptance, which is defined
1019     * by the intersection among magnet cavity, silicon-plane sensitive area and
1020     * ToF sensitive area (nominal values from the official document used to
1021     * calculate the geometrical factor)
1022     * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
1023     */
1024    // Bool_t TrkTrack::IsInsideAcceptance(){
1025    
1026    //     int ngf = TrkParams::nGF;
1027    //     for(int i=0; i<ngf; i++){
1028    //      if(
1029    //          xGF[i] <= TrkParams::xGF_min[i] ||
1030    //          xGF[i] >= TrkParams::xGF_max[i] ||
1031    //          yGF[i] <= TrkParams::yGF_min[i] ||
1032    //          yGF[i] >= TrkParams::yGF_max[i] ||
1033    //          false)return false;
1034    //     }
1035    //     return true;
1036    
1037    // }
1038    Bool_t TrkTrack::IsInsideAcceptance(float toll){
1039    
1040    
1041        int ngf = TrkParams::nGF;
1042        for(int i=0; i<ngf; i++){
1043            //
1044    //      cout << endl << TrkParams::GF_element[i];
1045            if(
1046                TrkParams::GF_element[i].CompareTo("S11") &&
1047                TrkParams::GF_element[i].CompareTo("S12") &&
1048                TrkParams::GF_element[i].CompareTo("S21") &&
1049                TrkParams::GF_element[i].CompareTo("S22") &&
1050                TrkParams::GF_element[i].CompareTo("T1")  &&
1051                TrkParams::GF_element[i].CompareTo("CUF") &&
1052                TrkParams::GF_element[i].CompareTo("T2")  &&
1053                TrkParams::GF_element[i].CompareTo("T3")  &&
1054                TrkParams::GF_element[i].CompareTo("T4")  &&
1055                TrkParams::GF_element[i].CompareTo("T5")  &&
1056                TrkParams::GF_element[i].CompareTo("CLF") &&
1057                TrkParams::GF_element[i].CompareTo("T6")  &&
1058                TrkParams::GF_element[i].CompareTo("S31") &&
1059                TrkParams::GF_element[i].CompareTo("S32") &&
1060                true)continue;
1061            // apply condition only within the cavity
1062    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1063            if(
1064                xGF[i] <= TrkParams::xGF_min[i] + toll ||
1065                xGF[i] >= TrkParams::xGF_max[i] - toll ||
1066                yGF[i] <= TrkParams::yGF_min[i] + toll ||
1067                yGF[i] >= TrkParams::yGF_max[i] - toll ||
1068                false){
1069                
1070                return false;
1071            }
1072        }
1073        return true;
1074    }
1075    
1076    /**
1077     * Returns true if the track is inside one of the surfaces which define the
1078     * geometrical acceptance.
1079     * @param surf tag of the surface (possible values are: S11 S12 S21 S22 T1
1080     * CUF T2 T3 T4 T5 CLF T6 S31 S32).
1081     * @param toll  Tolerance around the nominal surface (toll>0 define an inner
1082     * fiducial surface)
1083    */
1084    Bool_t TrkTrack::IsInsideGFSurface(const char* surf, float toll){
1085    
1086    
1087        int ngf = TrkParams::nGF;
1088        bool SURFOK = false;
1089        for(int i=0; i<ngf; i++){
1090            if(  !TrkParams::GF_element[i].CompareTo(surf)  ){
1091                SURFOK=true;
1092                if(
1093                    xGF[i] > TrkParams::xGF_min[i] + toll &&
1094                    xGF[i] < TrkParams::xGF_max[i] - toll &&
1095                    yGF[i] > TrkParams::yGF_min[i] + toll &&
1096                    yGF[i] < TrkParams::yGF_max[i] - toll &&
1097                    true)return true;
1098            }
1099        }
1100        if( !SURFOK )cout << " Bool_t TrkTrack::IsInsideGFSurface(char* surf, float toll) --> suface "<<surf<<" not defined "<<endl;
1101        return false;
1102    
1103    }
1104    
1105    /**
1106   * Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track.   * Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track.
1107   * If no cluster is associated, ID=-1.   * If no cluster is associated, ID=-1.
1108   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
# Line 923  Int_t TrkTrack::GetClusterY_ID(int ip){ Line 1120  Int_t TrkTrack::GetClusterY_ID(int ip){
1120  };  };
1121    
1122  /**  /**
1123   * Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane.   * Method to retrieve the ladder (0-2, increasing x) traversed by the track on this plane.
1124   * If no ladder is traversed (dead area) the metod retuns -1.   * If no ladder is traversed (dead area) the metod retuns -1.
1125   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1126   */   */
# Line 946  Int_t TrkTrack::GetSensor(int ip){ Line 1143  Int_t TrkTrack::GetSensor(int ip){
1143  /**  /**
1144   * \brief Method to include a x-cluster to the track.   * \brief Method to include a x-cluster to the track.
1145   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1146   * @param clid Cluster ID (0,1,...)   * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise )
1147   * @param is Sensor (0-1, increasing y)   * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit)
1148     * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit)
1149     * @param bad True if the cluster contains bad strips  
1150   * @see Fit(double pfixed, int& fail, int iprint, int froml1)   * @see Fit(double pfixed, int& fail, int iprint, int froml1)
1151   */   */
1152  void TrkTrack::SetXGood(int ip, int clid, int is){  void TrkTrack::SetXGood(int ip, int clid, int il, int is, bool bad){
1153      int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1154      bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1155      xgood[ip]=il*100000000+is*10000000+clid;      if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1)
1156            cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1157        xgood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1158      if(bad)xgood[ip]=-xgood[ip];      if(bad)xgood[ip]=-xgood[ip];
1159  };  };
1160  /**  /**
1161   * \brief Method to include a y-cluster to the track.   * \brief Method to include a y-cluster to the track.
1162   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1163   * @param clid Cluster ID (0,1,...)   * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise )
1164   * @param is Sensor (0-1)   * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit)
1165     * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit)
1166     * @param bad True if the cluster contains bad strips  
1167   * @see Fit(double pfixed, int& fail, int iprint, int froml1)   * @see Fit(double pfixed, int& fail, int iprint, int froml1)
1168   */   */
1169  void TrkTrack::SetYGood(int ip, int clid, int is){  void TrkTrack::SetYGood(int ip, int clid, int il, int is, bool bad){
1170      int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1171      bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1172      ygood[ip]=il*100000000+is*10000000+clid;      if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1)
1173            cout << " void TrkTrack::SetYGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1174        ygood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1175      if(bad)ygood[ip]=-ygood[ip];      if(bad)ygood[ip]=-ygood[ip];
1176  };  };
1177    
1178    /**
1179     * \brief Average X
1180     * Average value of <xv>, evaluated from the first to the last hit x view.
1181     */
1182    Float_t TrkTrack::GetXav(){
1183    
1184        int first_plane = -1;
1185        int last_plane  = -1;
1186        for(Int_t ip=0; ip<6; ip++){
1187            if( XGood(ip) && first_plane == -1 )first_plane = ip;
1188            if( XGood(ip) && first_plane != -1 )last_plane = ip;
1189        }
1190        if( first_plane == -1 || last_plane == -1){
1191            return -100;
1192        }
1193        if( last_plane-first_plane+1 ==0 )return -100;
1194    
1195        Float_t av = 0;    
1196        for(int ip=first_plane; ip<=last_plane; ip++)av+=xv[ip];
1197        
1198        return (av/(last_plane-first_plane+1));    
1199    }
1200    /**
1201     * \brief Average Y
1202     * Average value of <yv>, evaluated from the first to the last hit x view.
1203     */
1204    Float_t TrkTrack::GetYav(){
1205    
1206        int first_plane = -1;
1207        int last_plane  = -1;
1208        for(Int_t ip=0; ip<6; ip++){
1209            if( XGood(ip) && first_plane == -1 )first_plane = ip;
1210            if( XGood(ip) && first_plane != -1 )last_plane = ip;
1211        }
1212        if( first_plane == -1 || last_plane == -1){
1213            return -100;
1214        }
1215        if( last_plane-first_plane+1 ==0 )return -100;
1216    
1217        Float_t av = 0;    
1218        for(int ip=first_plane; ip<=last_plane; ip++)av+=yv[ip];
1219    
1220        return (av/(last_plane-first_plane+1));    
1221    }
1222    /**
1223     * \brief Average Z
1224     * Average value of <zv>, evaluated from the first to the last hit x view.
1225     */
1226    Float_t TrkTrack::GetZav(){
1227    
1228        int first_plane = -1;
1229        int last_plane  = -1;
1230        for(Int_t ip=0; ip<6; ip++){
1231            if( XGood(ip) && first_plane == -1 )first_plane = ip;
1232            if( XGood(ip) && first_plane != -1 )last_plane = ip;
1233        }
1234        if( first_plane == -1 || last_plane == -1){
1235            return -100;
1236        }
1237        if( last_plane-first_plane+1 ==0 )return -100;
1238    
1239        Float_t av = 0;    
1240        for(int ip=first_plane; ip<=last_plane; ip++)av+=zv[ip];
1241        
1242        return (av/(last_plane-first_plane+1));    
1243    }
1244    
1245    /**
1246     * \brief Number of column traversed
1247     */
1248    Int_t TrkTrack::GetNColumns(){
1249        int sensors[] = {0,0,0,0,0,0};
1250        for(int ip=0; ip<6; ip++){
1251            int sensorid = GetLadder(ip)+3*GetSensor(ip);    
1252            if(XGood(ip)||YGood(ip))
1253                if(sensorid>=0 && sensorid<6)sensors[sensorid]=1;
1254        }
1255        int nsensors=0;
1256        for(int is=0; is<6; is++)nsensors += sensors[is];
1257        return nsensors;
1258    };
1259    /**
1260     * \brief Give the maximum energy release
1261     */
1262    Float_t TrkTrack::GetDEDX_max(int ip, int iv){
1263        Float_t max=0;
1264        int pfrom = 0;
1265        int pto   = 6;
1266        int vfrom = 0;
1267        int vto   = 2;
1268        if(ip>=0&&ip<6){
1269            pfrom = ip;
1270            pto   = ip+1;
1271        }
1272        if(iv>=0&&iv<2){
1273            vfrom = iv;
1274            vto   = iv+1;
1275        }
1276        for(int i=pfrom; i<pto; i++)
1277            for(int j=vfrom; j<vto; j++){
1278                if(j==0 && XGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j);
1279                if(j==1 && YGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j);
1280            }
1281        return max;
1282    
1283    };
1284    
1285    /**
1286     * \brief Give the minimum energy release
1287     */
1288    Float_t TrkTrack::GetDEDX_min(int ip, int iv){
1289        Float_t min=100000000;
1290        int pfrom = 0;
1291        int pto   = 6;
1292        int vfrom = 0;
1293        int vto   = 2;
1294        if(ip>=0&&ip<6){
1295            pfrom = ip;
1296            pto   = ip+1;
1297        }
1298        if(iv>=0&&iv<2){
1299            vfrom = iv;
1300            vto   = iv+1;
1301        }
1302        for(int i=pfrom; i<pto; i++)
1303            for(int j=vfrom; j<vto; j++){
1304                if(j==0 && XGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j);
1305                if(j==1 && YGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j);
1306            }
1307        return min;
1308    
1309    };
1310    
1311    /**
1312     * \brief Give the maximum spatial residual  
1313     */
1314    Float_t TrkTrack::GetResidual_max(int ip, int iv){
1315        Float_t max=0;
1316        int pfrom = 0;
1317        int pto   = 6;
1318        int vfrom = 0;
1319        int vto   = 2;
1320        if(ip>=0&&ip<6){
1321            pfrom = ip;
1322            pto   = ip+1;
1323        }
1324        if(iv>=0&&iv<2){
1325            vfrom = iv;
1326            vto   = iv+1;
1327        }
1328        for(int i=pfrom; i<pto; i++){
1329            for(int j=vfrom; j<vto; j++){
1330                if(j==0 && XGood(i) && fabs(xm[i]-xv[i])>fabs(max))max=xm[i]-xv[i];
1331                if(j==1 && YGood(i) && fabs(ym[i]-yv[i])>fabs(max))max=ym[i]-yv[i];
1332            }
1333        }
1334        return max;
1335    
1336    };
1337    /**
1338     * \brief Give the anerage spatial residual
1339     */
1340    Float_t TrkTrack::GetResidual_av(int ip, int iv){
1341        //
1342    //Sum$((xm>-50)*(xm-xv)/resx)/sqrt(TrkTrack.GetNX()*TrkTrack.GetChi2X())<0.3
1343    
1344        Float_t av  = 0.;
1345        int     nav = 0;
1346        //
1347        int pfrom = 0;
1348        int pto   = 6;
1349        int vfrom = 0;
1350        int vto   = 2;
1351        if(ip>=0&&ip<6){
1352            pfrom = ip;
1353            pto   = ip+1;
1354        }
1355        if(iv>=0&&iv<2){
1356            vfrom = iv;
1357            vto   = iv+1;
1358        }
1359        for(int i=pfrom; i<pto; i++){
1360            for(int j=vfrom; j<vto; j++){
1361                nav++;
1362                if(j==0 && XGood(i)) av += (xm[i]-xv[i])/resx[i];
1363                if(j==1 && YGood(i)) av += (ym[i]-yv[i])/resy[i];
1364            }
1365        }
1366        if(nav==0)return -100.;
1367        return av/nav;
1368    
1369    };
1370    
1371    
1372    /**
1373     * \brief Give the maximum multiplicity on the x view
1374     */
1375    Int_t TrkTrack::GetClusterX_Multiplicity_max(){
1376        int max=0;
1377        for(int ip=0; ip<6; ip++)
1378            if(GetClusterX_Multiplicity(ip)>max)max=GetClusterX_Multiplicity(ip);
1379        return max;
1380    };
1381    /**
1382     * \brief Give the minimum multiplicity on the x view
1383     */
1384    Int_t TrkTrack::GetClusterX_Multiplicity_min(){
1385        int min=50;
1386        for(int ip=0; ip<6; ip++)
1387            if(GetClusterX_Multiplicity(ip)<min)min=GetClusterX_Multiplicity(ip);
1388        return min;
1389    };
1390    /**
1391     * \brief Give the maximum multiplicity on the x view
1392     */
1393    Int_t TrkTrack::GetClusterY_Multiplicity_max(){
1394        int max=0;
1395        for(int ip=0; ip<6; ip++)
1396            if(GetClusterY_Multiplicity(ip)>max)max=GetClusterY_Multiplicity(ip);
1397        return max;
1398    };
1399    /**
1400     * \brief Give the minimum multiplicity on the x view
1401     */
1402    Int_t TrkTrack::GetClusterY_Multiplicity_min(){
1403        int min=50;
1404        for(int ip=0; ip<6; ip++)
1405            if(GetClusterY_Multiplicity(ip)<min)min=GetClusterY_Multiplicity(ip);
1406        return min;
1407    };
1408    
1409    /**
1410     * \brief Give the minimum seed on the x view
1411     */
1412    Float_t TrkTrack::GetClusterX_Seed_min(){
1413        Float_t min=100000;
1414        for(int ip=0; ip<6; ip++)
1415            if(XGood(ip) && GetClusterX_Seed(ip)<min)min=GetClusterX_Seed(ip);
1416        return min;
1417    };
1418    /**
1419     * \brief Give the minimum seed on the x view
1420     */
1421    Float_t TrkTrack::GetClusterY_Seed_min(){
1422        Float_t min=100000;
1423        for(int ip=0; ip<6; ip++)
1424            if(YGood(ip) && GetClusterY_Seed(ip)<min)min=GetClusterY_Seed(ip);
1425        return min;
1426    };
1427    
1428    
1429  //--------------------------------------  //--------------------------------------
1430  //  //
1431  //  //
# Line 1003  void TrkTrack::Clear(){ Line 1459  void TrkTrack::Clear(){
1459          dedx_y[ip] = 0;          dedx_y[ip] = 0;
1460    
1461      };      };
1462        int ngf = TrkParams::nGF;
1463        for(int i=0; i<ngf; i++){
1464            xGF[i] = 0.;
1465            yGF[i] = 0.;
1466        }
1467  //     if(clx)clx->Clear();  //     if(clx)clx->Clear();
1468  //     if(cly)cly->Clear();  //     if(cly)cly->Clear();
1469  //    clx.Clear();  //    clx.Clear();
# Line 1029  void TrkTrack::Delete(){ Line 1490  void TrkTrack::Delete(){
1490  //--------------------------------------  //--------------------------------------
1491  TrkSinglet::TrkSinglet(){  TrkSinglet::TrkSinglet(){
1492  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;
1493      plane    = 0;  //     plane    = 0;
1494      coord[0] = 0;  //     coord[0] = 0;
1495      coord[1] = 0;  //     coord[1] = 0;
1496      sgnl     = 0;  //     sgnl     = 0;
1497    //     multmax  = 0;
1498  //    cls      = 0;  //    cls      = 0;
1499        Clear();
1500  };  };
1501  //--------------------------------------  //--------------------------------------
1502  //  //
# Line 1045  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1508  TrkSinglet::TrkSinglet(const TrkSinglet&
1508      coord[0] = s.coord[0];      coord[0] = s.coord[0];
1509      coord[1] = s.coord[1];      coord[1] = s.coord[1];
1510      sgnl     = s.sgnl;      sgnl     = s.sgnl;
1511        multmax  = s.multmax;
1512  //      cls      = 0;//<<<<pointer  //      cls      = 0;//<<<<pointer
1513  //    cls      = TRef(s.cls);  //    cls      = TRef(s.cls);
1514  };  };
# Line 1055  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1519  TrkSinglet::TrkSinglet(const TrkSinglet&
1519  void TrkSinglet::Dump(){  void TrkSinglet::Dump(){
1520      int i=0;      int i=0;
1521      cout << endl << "========== Singlet " ;      cout << endl << "========== Singlet " ;
1522      cout << endl << "plane    : " << plane;      cout << endl << "plane        : " << plane;
1523      cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++;      cout << endl << "coord[2]     : "; while( i<2 && cout << coord[i] << " ") i++;
1524      cout << endl << "sgnl     : " << sgnl;      cout << endl << "sgnl         : " << sgnl;
1525        cout << endl << "max.strip    : ";
1526        cout << endl << "multiplicity : ";
1527  }  }
1528  //--------------------------------------  //--------------------------------------
1529  //  //
# Line 1070  void TrkSinglet::Clear(){ Line 1536  void TrkSinglet::Clear(){
1536      coord[0]=-999;      coord[0]=-999;
1537      coord[1]=-999;      coord[1]=-999;
1538      sgnl=0;      sgnl=0;
1539        multmax  = 0;
1540            
1541  }  }
1542  //--------------------------------------  //--------------------------------------
# Line 1180  Bool_t TrkLevel2::GetVKFlag(int iv, int Line 1647  Bool_t TrkLevel2::GetVKFlag(int iv, int
1647   * forced (see TrkLevel2::GetVKMask(int,int)) or   * forced (see TrkLevel2::GetVKMask(int,int)) or
1648   * for this event only (TrkLevel2::GetVKFlag(int,int)).   * for this event only (TrkLevel2::GetVKFlag(int,int)).
1649   * @param iv Tracker view (0-11)   * @param iv Tracker view (0-11)
1650   * @param ivk Viking-chip number (0-23)   * @param ivk Viking-chip number (0-23)
1651   */   */
1652  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){
1653      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );
# Line 1276  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1743  void TrkLevel2::SetFromLevel2Struct(cTrk
1743              //-----------------------------------------------------              //-----------------------------------------------------
1744              //-----------------------------------------------------              //-----------------------------------------------------
1745          };          };
1746            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1747            // evaluated coordinates (to define GF)
1748            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1749            int    ngf = TrkParams::nGF;
1750            float *zgf = TrkParams::zGF;
1751            Trajectory tgf = Trajectory(ngf,zgf);
1752            tgf.DoTrack(t_track->al);//<<<< integrate the trajectory
1753            for(int ip=0; ip<ngf; ip++){
1754                t_track->xGF[ip] = tgf.x[ip];
1755                t_track->yGF[ip] = tgf.y[ip];
1756            }
1757            
1758  //      if(t_track->IsSaturated())t_track->Dump();  //      if(t_track->IsSaturated())t_track->Dump();
1759          new(t[i]) TrkTrack(*t_track);          new(t[i]) TrkTrack(*t_track);
1760          t_track->Clear();          t_track->Clear();
1761      };      };//end loop over track
1762    
1763  //  ----------------  //  ----------------
1764  //  *** SINGLETS ***  //  *** SINGLETS ***
# Line 1291  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1770  void TrkLevel2::SetFromLevel2Struct(cTrk
1770          t_singlet->coord[0] = l2->xs[i][0];          t_singlet->coord[0] = l2->xs[i][0];
1771          t_singlet->coord[1] = l2->xs[i][1];          t_singlet->coord[1] = l2->xs[i][1];
1772          t_singlet->sgnl     = l2->signlxs[i];          t_singlet->sgnl     = l2->signlxs[i];
1773            t_singlet->multmax = l2->multmaxsx[i];
1774            if(l2->sxbad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1775          //-----------------------------------------------------          //-----------------------------------------------------
1776  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);
1777          //-----------------------------------------------------          //-----------------------------------------------------
# Line 1304  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1785  void TrkLevel2::SetFromLevel2Struct(cTrk
1785          t_singlet->coord[0] = l2->ys[i][0];          t_singlet->coord[0] = l2->ys[i][0];
1786          t_singlet->coord[1] = l2->ys[i][1];          t_singlet->coord[1] = l2->ys[i][1];
1787          t_singlet->sgnl     = l2->signlys[i];          t_singlet->sgnl     = l2->signlys[i];
1788            t_singlet->multmax  = l2->multmaxsy[i];
1789            if(l2->sybad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1790          //-----------------------------------------------------          //-----------------------------------------------------
1791  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);
1792          //-----------------------------------------------------          //-----------------------------------------------------
1793          new(sy[i]) TrkSinglet(*t_singlet);          new(sy[i]) TrkSinglet(*t_singlet);
1794          t_singlet->Clear();          t_singlet->Clear();
1795      };      };
1796    
1797    
1798                    
1799      delete t_track;      delete t_track;
1800      delete t_singlet;      delete t_singlet;
# Line 1422  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1907  TRefArray *TrkLevel2::GetTracks_NFitSort
1907    
1908      if(!Track)return 0;      if(!Track)return 0;
1909    
1910      TRefArray *sorted = new TRefArray();      //    TRefArray *sorted = new TRefArray();
1911        TRefArray *sorted = NULL;
1912                    
1913      TClonesArray &t  = *Track;      TClonesArray &t  = *Track;
1914  //    TClonesArray &ts = *PhysicalTrack;  //    TClonesArray &ts = *PhysicalTrack;
# Line 1460  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1946  TRefArray *TrkLevel2::GetTracks_NFitSort
1946                    
1947  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;
1948          };          };
1949            if(!sorted)sorted = new TRefArray( TProcessID::GetProcessWithUID(t[indi]));
1950          sorted->Add( (TrkTrack*)t[indi] );                sorted->Add( (TrkTrack*)t[indi] );      
1951                                    
1952          m[indi] = 0;          m[indi] = 0;
# Line 1630  void TrkLevel2::LoadField(TString path){ Line 2117  void TrkLevel2::LoadField(TString path){
2117    
2118      TrkParams::Set(path,1);      TrkParams::Set(path,1);
2119      TrkParams::Load(1);      TrkParams::Load(1);
2120        if( !TrkParams::IsLoaded(1) ){
2121            cout << "void TrkLevel2::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl;
2122        }
2123    
2124  //  //
2125  };  };
# Line 1817  float Trajectory::GetLength(int ifirst, Line 2307  float Trajectory::GetLength(int ifirst,
2307    
2308  /**  /**
2309   * Evaluates the trajectory in the apparatus associated to the track.   * Evaluates the trajectory in the apparatus associated to the track.
2310   * It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling  TrkLevel2::LoadField() ), otherwise an error message is returned.     * It integrates the equations of motion in the magnetic field.
2311   * @param t pointer to an object of the class Trajectory,   * @param al Track state-vector (X0,Y0,sin(theta),phi,deflection).
2312   * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ).   * @param zini z-coordinate of the reference plane (Z0).
2313   * @return error flag.   * @return error flag.
2314   */   *
2315  int Trajectory::DoTrack2(float* al){   * This method is needed when you want to integrate the particle trajectory
2316     * starting from a track state-vector relative to an arbitrary reference plane.
2317      double *dxout   = new double[npoint];   * The default reference plane, used by the tracker routines, is at zini=23.5.
2318      double *dyout   = new double[npoint];   * If you give as input the track state-vector from a TrkTrack object,
2319      double *dthxout = new double[npoint];   * you can use Trajectory::DoTrack(float* al) instead.
2320      double *dthyout = new double[npoint];   */
2321      double *dtlout  = new double[npoint];  int Trajectory::DoTrack(float* al, float zini){
2322      double *dzin    = new double[npoint];  
2323    //      double *dxout   = new double[npoint];
2324    //      double *dyout   = new double[npoint];
2325    //      double *dthxout = new double[npoint];
2326    //      double *dthyout = new double[npoint];
2327    //      double *dtlout  = new double[npoint];
2328    //      double *dzin    = new double[npoint];
2329        
2330        double *dxout;
2331        double *dyout;
2332        double *dthxout;
2333        double *dthyout;
2334        double *dtlout;
2335        double *dzin;
2336        
2337        dxout   = (double*) malloc(npoint*sizeof(double));
2338        dyout   = (double*) malloc(npoint*sizeof(double));
2339        dthxout = (double*) malloc(npoint*sizeof(double));
2340        dthyout = (double*) malloc(npoint*sizeof(double));
2341        dtlout  = (double*) malloc(npoint*sizeof(double));
2342        dzin    = (double*) malloc(npoint*sizeof(double));
2343        
2344      double dal[5];      double dal[5];
2345    
2346      int ifail = 0;      double dzini = (double)zini;
2347    
2348        int ifail = 0;
2349        
2350      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];
2351      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];
2352    
2353      TrkParams::Load(1);      TrkParams::Load(1);
2354      if( !TrkParams::IsLoaded(1) ){      if( !TrkParams::IsLoaded(1) ){
2355          cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl;          cout << "int Trajectory::DoTrack(float* al) --- ERROR --- m.field not loaded"<<endl;
2356          return 0;          return 0;
2357      }      }
2358      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);  //    dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
2359        dotrack3_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&dzini,&ifail);
2360            
2361      for (int i=0; i<npoint; i++){      for (int i=0; i<npoint; i++){
2362          x[i]   = (float)*dxout++;          x[i]   = (float)*(dxout+i);
2363          y[i]   = (float)*dyout++;          y[i]   = (float)*(dyout+i);
2364          thx[i] = (float)*dthxout++;          thx[i] = (float)*(dthxout+i);
2365          thy[i] = (float)*dthyout++;          thy[i] = (float)*(dthyout+i);
2366          tl[i]  = (float)*dtlout++;          tl[i]  = (float)*(dtlout+i);
2367      }      }
2368    
2369        if(dxout)  free( dxout );
2370        if(dyout)  free( dyout );
2371        if(dthxout)free( dthxout );
2372        if(dthyout)free( dthyout );
2373        if(dtlout) free( dtlout );
2374        if(dzin)   free( dzin );
2375    
2376    //      delete [] dxout;
2377    //      delete [] dyout;
2378    //      delete [] dthxout;
2379    //      delete [] dthyout;
2380    //      delete [] dtlout;
2381    //      delete [] dzin;
2382    
2383    
2384      return ifail;      return ifail;
2385  };  };
2386    
2387    /**
2388     *
2389     * >>> OBSOLETE !!! use Trajectory::DoTrack(float* al, float zini) instead
2390     *
2391     */
2392    int Trajectory::DoTrack2(float* al, float zini){
2393    
2394        cout << endl;
2395        cout << " int Trajectory::DoTrack2(float* al, float zini) --->> NB NB !! this method is going to be eliminated !!! "<<endl;
2396        cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl;
2397        cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl;
2398        cout << endl;
2399    
2400        return DoTrack(al,zini);
2401    
2402    };
2403    
2404    
2405    
2406  ClassImp(TrkLevel2);  ClassImp(TrkLevel2);
2407  ClassImp(TrkSinglet);  ClassImp(TrkSinglet);
2408  ClassImp(TrkTrack);  ClassImp(TrkTrack);

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.54

  ViewVC Help
Powered by ViewVC 1.1.23