/[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.52 by pam-fi, Tue Feb 3 10:14:27 2009 UTC revision 1.58 by mocchiut, Wed Aug 27 14:44:37 2014 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 177  void TrkTrack::Copy(TrkTrack& t){ Line 178  void TrkTrack::Copy(TrkTrack& t){
178  //  //
179  //--------------------------------------  //--------------------------------------
180  /**  /**
  * Evaluates the trajectory in the apparatus associated to the track.  
  * 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.    
  * @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.  
181   *   *
182   * >>> OBSOLETE !!! use TrkTrack::DoTrack2(Trajectory* t) instead   * >>> OBSOLETE !!! use TrkTrack::DoTrack(Trajectory* t) instead
183   *   *
184   */   */
185  int TrkTrack::DoTrack(Trajectory* t){  int TrkTrack::DoTrack2(Trajectory* t){
   
     cout << " int TrkTrack::DoTrack(Trajectory* t) --->> OBSOLETE !!! "<<endl;  
     cout << " use int TrkTrack::DoTrack2(Trajectory* t)"<<endl;  
   
     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+i);  
         t->y[i] = (float)*(dyout+i);  
     }  
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 247  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);
# Line 417  Int_t TrkTrack::GetLeverArmXY(){ Line 391  Int_t TrkTrack::GetLeverArmXY(){
391      return (last_plane-first_plane+1);      return (last_plane-first_plane+1);
392  }  }
393  /**  /**
394     * Returns the number of hit planes
395     */
396    Int_t TrkTrack::GetNhit()  {
397      int np=0;
398      for(Int_t ip=0; ip<6; ip++) np += (XGood(ip)||YGood(ip)) ;
399      return np;
400    };
401    /**
402   * Returns the reduced chi-square of track x-projection   * Returns the reduced chi-square of track x-projection
403   */   */
404  Float_t  TrkTrack::GetChi2X(){  Float_t  TrkTrack::GetChi2X(){
# Line 424  Float_t  TrkTrack::GetChi2X(){ Line 406  Float_t  TrkTrack::GetChi2X(){
406      for(int ip=0; ip<6; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.);      for(int ip=0; ip<6; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.);
407      if(GetNX()>3)chiq=chiq/(GetNX()-3);      if(GetNX()>3)chiq=chiq/(GetNX()-3);
408      else chiq=0;      else chiq=0;
409      if(chiq==0)cout << " Float_t  TrkTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl;      //    if(chiq==0)cout << " Float_t  TrkTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl;
410      return chiq;      return chiq;
411  }  }
412  /**  /**
# Line 435  Float_t  TrkTrack::GetChi2Y(){ Line 417  Float_t  TrkTrack::GetChi2Y(){
417      for(int ip=0; ip<6; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.);      for(int ip=0; ip<6; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.);
418      if(GetNY()>2)chiq=chiq/(GetNY()-2);      if(GetNY()>2)chiq=chiq/(GetNY()-2);
419      else chiq=0;      else chiq=0;
420      if(chiq==0)cout << " Float_t  TrkTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl;      //    if(chiq==0)cout << " Float_t  TrkTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl;
421      return chiq;      return chiq;
422  }  }
423  /**  /**
# Line 690  void TrkTrack::FillMiniStruct(cMini2trac Line 672  void TrkTrack::FillMiniStruct(cMini2trac
672    
673  //      cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl;  //      cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl;
674  //      cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl;  //      cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl;
675          track.xgood[i]=XGood(i);        track.xgood[i] = (double) XGood(i);
676          track.ygood[i]=YGood(i);          track.ygood[i] = (double) YGood(i);
677                    
678          track.xm[i]=xm[i];          track.xm[i]= (double) xm[i];
679          track.ym[i]=ym[i];          track.ym[i]= (double) ym[i];
680          track.zm[i]=zm[i];          track.zm[i]= (double) zm[i];
681                    
682  //      --- temporaneo ----------------------------  //      --- temporaneo ----------------------------
683  //      float segment = 100.;  //      float segment = 100.;
# Line 713  void TrkTrack::FillMiniStruct(cMini2trac Line 695  void TrkTrack::FillMiniStruct(cMini2trac
695  //      --- temporaneo ----------------------------  //      --- temporaneo ----------------------------
696    
697          if( XGood(i) || YGood(i) ){          if( XGood(i) || YGood(i) ){
698              double segment = 2.;//cm              //NB!! the length of the sensor is not exactely taken into account    
699                double segment = 7.;// 2.;//cm //Elena 10th
700              // NB: i parametri di allineamento hanno una notazione particolare!!!              // NB: i parametri di allineamento hanno una notazione particolare!!!
701              // sensor = 0 (hybrid side), 1              // sensor = 0 (hybrid side), 1
702              // ladder = 0-2 (increasing x)              // ladder = 0-2 (increasing x)
# Line 723  void TrkTrack::FillMiniStruct(cMini2trac Line 706  void TrkTrack::FillMiniStruct(cMini2trac
706              int il = (int)GetLadder(i);              int il = (int)GetLadder(i);
707                            
708              double omega   = 0.;              double omega   = 0.;
709              double beta    = 0.;              //      double beta    = 0.;// EM GCC 4.7
710              double gamma   = 0.;              //      double gamma   = 0.;
711              if(              if(
712                  (is < 0 || is > 1 || ip < 0 || ip > 5 || il < 0 || il > 2) &&                  (is < 0 || is > 1 || ip < 0 || ip > 5 || il < 0 || il > 2) &&
713                  true){                  true){
# Line 734  void TrkTrack::FillMiniStruct(cMini2trac Line 717  void TrkTrack::FillMiniStruct(cMini2trac
717                  cout << " is ip il = "<<is<<" "<<ip<<" "<<il<<endl;                  cout << " is ip il = "<<is<<" "<<ip<<" "<<il<<endl;
718              }else{              }else{
719                  omega   = alignparameters_.omega[is][il][ip];                  omega   = alignparameters_.omega[is][il][ip];
720                  beta    = alignparameters_.beta[is][il][ip];                  //              beta    = alignparameters_.beta[is][il][ip];// EM GCC 4.7 unused
721                  gamma   = alignparameters_.gamma[is][il][ip];                  //              gamma   = alignparameters_.gamma[is][il][ip];// EM GCC 4.7 unused
722              }              }
723                            
724              if(       XGood(i) && !YGood(i) ){              if(       XGood(i) && !YGood(i) ){
725                  track.xm_a[i] = xm[i] - omega * segment;                  track.xm_a[i] =  (double) xm[i] - omega * segment;
726                  track.ym_a[i] = ym[i] + segment;                  track.ym_a[i] =  (double) ym[i] + segment;
727  //          track.zm_a[i] = zm[i] + beta * segment;//not used yet  //          track.zm_a[i] = zm[i] + beta * segment;//not used yet
728                  track.xm_b[i] = xm[i] + omega * segment;                  track.xm_b[i] =  (double) xm[i] + omega * segment;
729                  track.ym_b[i] = ym[i] - segment;                  track.ym_b[i] =  (double) ym[i] - segment;
730  //          track.zm_b[i] = zm[i] - beta * segment;//not used yet  //          track.zm_b[i] = zm[i] - beta * segment;//not used yet
731              }else if( !XGood(i) && YGood(i) ){              }else if( !XGood(i) && YGood(i) ){
732                  track.xm_a[i] = xm[i] + segment;                  track.xm_a[i] =  (double) xm[i] + segment;
733                  track.ym_a[i] = ym[i] + omega * segment;                  track.ym_a[i] =  (double) ym[i] + omega * segment;
734  //          track.zm_a[i] = zm[i] - gamma * segment;//not used yet  //          track.zm_a[i] = zm[i] - gamma * segment;//not used yet
735                  track.xm_b[i] = xm[i] - segment;                  track.xm_b[i] =  (double) xm[i] - segment;
736                  track.ym_b[i] = ym[i] - omega * segment;                  track.ym_b[i] =  (double) ym[i] - omega * segment;
737  //          track.zm_b[i] = zm[i] + gamma * segment;//not used yet  //          track.zm_b[i] = zm[i] + gamma * segment;//not used yet
738              }              }
739          }          }
740                    
741          track.resx[i]=resx[i];          track.resx[i]= (double) resx[i];
742          track.resy[i]=resy[i];          track.resy[i]= (double) resy[i];
743          track.tailx[i]=tailx[i];          track.tailx[i]= (double) tailx[i];
744          track.taily[i]=taily[i];          track.taily[i]= (double) taily[i];
745      }      }
746    
747      for(int i=0; i<5; i++) track.al[i]=al[i];      for(int i=0; i<5; i++) track.al[i]= (double) al[i];
748      track.zini = 23.5;      track.zini = 23.5;
749  // ZINI = 23.5 !!! it should be the same parameter in all codes  // ZINI = 23.5 !!! it should be the same parameter in all codes
750            
# Line 772  void TrkTrack::FillMiniStruct(cMini2trac Line 755  void TrkTrack::FillMiniStruct(cMini2trac
755  void TrkTrack::SetFromMiniStruct(cMini2track *track){  void TrkTrack::SetFromMiniStruct(cMini2track *track){
756    
757      for(int i=0; i<5; i++) {      for(int i=0; i<5; i++) {
758          al[i]=track->al[i];        al[i]= (float) (track->al[i]);
759          for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j];          for(int j=0; j<5; j++) coval[i][j]= (float) (track->cov[i][j]);
760      }      }
761      chi2  = track->chi2;      chi2  =  (float) (track->chi2);
762      nstep = track->nstep;      nstep =  (float) (track->nstep);
763      for(int i=0; i<6; i++){      for(int i=0; i<6; i++){
764          xv[i]  = track->xv[i];          xv[i]  =  (float) (track->xv[i]);
765          yv[i]  = track->yv[i];          yv[i]  =  (float) (track->yv[i]);
766          zv[i]  = track->zv[i];          zv[i]  =  (float) (track->zv[i]);
767          xm[i]  = track->xm[i];          xm[i]  = (float)  (track->xm[i]);
768          ym[i]  = track->ym[i];          ym[i]  =  (float) (track->ym[i]);
769          zm[i]  = track->zm[i];          zm[i]  =  (float) (track->zm[i]);
770          axv[i] = track->axv[i];          axv[i] =  (float) (track->axv[i]);
771          ayv[i] = track->ayv[i];          ayv[i] =  (float) (track->ayv[i]);      
772            resx[i] = (float)  (track->resx[i]); //Elena 10th
773            resy[i] =  (float) (track->resy[i]);
774      }      }
775            
776  }  }
# Line 818  Bool_t TrkTrack::EvaluateClusterPosition Line 803  Bool_t TrkTrack::EvaluateClusterPosition
803            
804  //     cout << "void TrkTrack::GetClusterositions() "<<endl;  //     cout << "void TrkTrack::GetClusterositions() "<<endl;
805    
806      bool OK=true;      TrkParams::Load(1);
807      TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl;      if( !TrkParams::IsLoaded(1) ){
808      TrkParams::Load(4); if( !TrkParams::IsLoaded(4) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl;          cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl;
809      TrkParams::Load(5); if( !TrkParams::IsLoaded(5) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl;          return false;
810      if(!OK)return false;      }    
811        TrkParams::Load(4);
812        if( !TrkParams::IsLoaded(4) ){
813            cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl;
814            return false;
815        }
816        TrkParams::Load(5);
817        if( !TrkParams::IsLoaded(5) ){
818            cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl;
819            return false;
820        }
821    
822      for(int ip=0; ip<6; ip++){      for(int ip=0; ip<6; ip++){
823  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;
824          int icx = GetClusterX_ID(ip)+1;          int icx = GetClusterX_ID(ip)+1;//0=no-cluster,1-N
825          int icy = GetClusterY_ID(ip)+1;          int icy = GetClusterY_ID(ip)+1;//0=no-cluster,1-N
826          int sensor = GetSensor(ip)+1;//<< convenzione "Paolo"          int sensor = GetSensor(ip)+1;//<< convenzione "Paolo"
827          if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena"          if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena"
828          int ladder = GetLadder(ip)+1;          int ladder = GetLadder(ip)+1;
# Line 841  Bool_t TrkTrack::EvaluateClusterPosition Line 836  Bool_t TrkTrack::EvaluateClusterPosition
836          float bfy = 10*TrkParams::GetBY(v);//Tesla          float bfy = 10*TrkParams::GetBY(v);//Tesla
837          int ipp=ip+1;          int ipp=ip+1;
838          xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy);          xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy);
839          if(icx<0 || icy<0)return false;          //      if(icx<0 || icy<0)return false;
840      }      }
841      return true;      return true;
842  }  }
# Line 875  Bool_t TrkTrack::EvaluateClusterPosition Line 870  Bool_t TrkTrack::EvaluateClusterPosition
870   */   */
871  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){
872    
873      bool OK=true;      TrkParams::Load(1);
874      TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl;      if( !TrkParams::IsLoaded(1) ){
875      if(!OK)return;          cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl;
876            return;
877        }
878        TrkParams::Load(5);
879        if( !TrkParams::IsLoaded(5) ){
880            cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- align.param. not loaded "<<endl;
881            return;
882        }
883    
884      float al_ini[] = {0.,0.,0.,0.,0.};      float al_ini[] = {0.,0.,0.,0.,0.};
885    
886      extern cMini2track track_;      extern cMini2track track_;
887      fail = 0;      fail = 0;
888    
889      FillMiniStruct(track_);      //    FillMiniStruct(track_);
890                    
891      if(froml1!=0){      if(froml1!=0){
892          if( !EvaluateClusterPositions() ){          if( !EvaluateClusterPositions() ){
# Line 923  void TrkTrack::Fit(double pfixed, int& f Line 925  void TrkTrack::Fit(double pfixed, int& f
925          if(iprint)cout << "ERROR: ifail= " << ifail << endl;          if(iprint)cout << "ERROR: ifail= " << ifail << endl;
926          fail = 1;          fail = 1;
927      }      }
928        if(chi2!=chi2){
929            if(iprint)cout << "ERROR: chi2= " << chi2 << endl;      
930            FitReset();
931            fail = 1;      
932        }
933      //  ------------------------------------------      //  ------------------------------------------
934            
935      SetFromMiniStruct(&track_);      SetFromMiniStruct(&track_);
# Line 1028  Bool_t TrkTrack::IsInsideCavity(float to Line 1035  Bool_t TrkTrack::IsInsideCavity(float to
1035   * by the intersection among magnet cavity, silicon-plane sensitive area and   * by the intersection among magnet cavity, silicon-plane sensitive area and
1036   * ToF sensitive area (nominal values from the official document used to   * ToF sensitive area (nominal values from the official document used to
1037   * calculate the geometrical factor)   * calculate the geometrical factor)
1038     * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
1039   */   */
1040  Bool_t TrkTrack::IsInsideAcceptance(){  // Bool_t TrkTrack::IsInsideAcceptance(){
1041    
1042    //     int ngf = TrkParams::nGF;
1043    //     for(int i=0; i<ngf; i++){
1044    //      if(
1045    //          xGF[i] <= TrkParams::xGF_min[i] ||
1046    //          xGF[i] >= TrkParams::xGF_max[i] ||
1047    //          yGF[i] <= TrkParams::yGF_min[i] ||
1048    //          yGF[i] >= TrkParams::yGF_max[i] ||
1049    //          false)return false;
1050    //     }
1051    //     return true;
1052    
1053    // }
1054    Bool_t TrkTrack::IsInsideAcceptance(float toll){
1055    
1056    
1057      int ngf = TrkParams::nGF;      int ngf = TrkParams::nGF;
1058      for(int i=0; i<ngf; i++){      for(int i=0; i<ngf; i++){
1059            //
1060    //      cout << endl << TrkParams::GF_element[i];
1061          if(          if(
1062              xGF[i] <= TrkParams::xGF_min[i] ||              TrkParams::GF_element[i].CompareTo("S11") &&
1063              xGF[i] >= TrkParams::xGF_max[i] ||              TrkParams::GF_element[i].CompareTo("S12") &&
1064              yGF[i] <= TrkParams::yGF_min[i] ||              TrkParams::GF_element[i].CompareTo("S21") &&
1065              yGF[i] >= TrkParams::yGF_max[i] ||              TrkParams::GF_element[i].CompareTo("S22") &&
1066              false)return false;              TrkParams::GF_element[i].CompareTo("T1")  &&
1067                TrkParams::GF_element[i].CompareTo("CUF") &&
1068                TrkParams::GF_element[i].CompareTo("T2")  &&
1069                TrkParams::GF_element[i].CompareTo("T3")  &&
1070                TrkParams::GF_element[i].CompareTo("T4")  &&
1071                TrkParams::GF_element[i].CompareTo("T5")  &&
1072                TrkParams::GF_element[i].CompareTo("CLF") &&
1073                TrkParams::GF_element[i].CompareTo("T6")  &&
1074                TrkParams::GF_element[i].CompareTo("S31") &&
1075                TrkParams::GF_element[i].CompareTo("S32") &&
1076                true)continue;
1077            // apply condition only within the cavity
1078    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1079            if(
1080                xGF[i] <= TrkParams::xGF_min[i] + toll ||
1081                xGF[i] >= TrkParams::xGF_max[i] - toll ||
1082                yGF[i] <= TrkParams::yGF_min[i] + toll ||
1083                yGF[i] >= TrkParams::yGF_max[i] - toll ||
1084                false){
1085                
1086                return false;
1087            }
1088      }      }
1089      return true;      return true;
1090    }
1091    
1092    /**
1093     * Returns true if the track is inside one of the surfaces which define the
1094     * geometrical acceptance.
1095     * @param surf tag of the surface (possible values are: S11 S12 S21 S22 T1
1096     * CUF T2 T3 T4 T5 CLF T6 S31 S32).
1097     * @param toll  Tolerance around the nominal surface (toll>0 define an inner
1098     * fiducial surface)
1099    */
1100    Bool_t TrkTrack::IsInsideGFSurface(const char* surf, float toll){
1101    
1102    
1103        int ngf = TrkParams::nGF;
1104        bool SURFOK = false;
1105        for(int i=0; i<ngf; i++){
1106            if(  !TrkParams::GF_element[i].CompareTo(surf)  ){
1107                SURFOK=true;
1108                if(
1109                    xGF[i] > TrkParams::xGF_min[i] + toll &&
1110                    xGF[i] < TrkParams::xGF_max[i] - toll &&
1111                    yGF[i] > TrkParams::yGF_min[i] + toll &&
1112                    yGF[i] < TrkParams::yGF_max[i] - toll &&
1113                    true)return true;
1114            }
1115        }
1116        if( !SURFOK )cout << " Bool_t TrkTrack::IsInsideGFSurface(char* surf, float toll) --> suface "<<surf<<" not defined "<<endl;
1117        return false;
1118    
1119  }  }
1120    
1121  /**  /**
1122   * 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.
1123   * If no cluster is associated, ID=-1.   * If no cluster is associated, ID=-1.
# Line 1093  Int_t TrkTrack::GetSensor(int ip){ Line 1168  Int_t TrkTrack::GetSensor(int ip){
1168  void TrkTrack::SetXGood(int ip, int clid, int il, int is, bool bad){  void TrkTrack::SetXGood(int ip, int clid, int il, int is, bool bad){
1169  //    int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1170  //    bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1171      if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1)      if(ip<0||ip>5||clid<1||il<-1||il>2||is<-1||is>1)
1172          cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;          cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1173      xgood[ip]=(il+1)*100000000+(is+1)*10000000+clid;      xgood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1174      if(bad)xgood[ip]=-xgood[ip];      if(bad)xgood[ip]=-xgood[ip];
# Line 1110  void TrkTrack::SetXGood(int ip, int clid Line 1185  void TrkTrack::SetXGood(int ip, int clid
1185  void TrkTrack::SetYGood(int ip, int clid, int il, int is, bool bad){  void TrkTrack::SetYGood(int ip, int clid, int il, int is, bool bad){
1186  //    int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1187  //    bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1188      if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1)      if(ip<0||ip>5||clid<1||il<-1||il>2||is<-1||is>1)
1189          cout << " void TrkTrack::SetYGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;          cout << " void TrkTrack::SetYGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1190      ygood[ip]=(il+1)*100000000+(is+1)*10000000+clid;      ygood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1191      if(bad)ygood[ip]=-ygood[ip];      if(bad)ygood[ip]=-ygood[ip];
# Line 1690  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1765  void TrkLevel2::SetFromLevel2Struct(cTrk
1765          int    ngf = TrkParams::nGF;          int    ngf = TrkParams::nGF;
1766          float *zgf = TrkParams::zGF;          float *zgf = TrkParams::zGF;
1767          Trajectory tgf = Trajectory(ngf,zgf);          Trajectory tgf = Trajectory(ngf,zgf);
1768          tgf.DoTrack2(t_track->al);//<<<< integrate the trajectory          tgf.DoTrack(t_track->al);//<<<< integrate the trajectory
1769          for(int ip=0; ip<ngf; ip++){          for(int ip=0; ip<ngf; ip++){
1770              t_track->xGF[ip] = tgf.x[ip];              t_track->xGF[ip] = tgf.x[ip];
1771              t_track->yGF[ip] = tgf.y[ip];              t_track->yGF[ip] = tgf.y[ip];
# Line 2119  Float_t TrkLevel2::GetZTrk(Int_t plane_i Line 2194  Float_t TrkLevel2::GetZTrk(Int_t plane_i
2194   * (By default is created with z-coordinates inside the tracking volume)   * (By default is created with z-coordinates inside the tracking volume)
2195    */    */
2196  Trajectory::Trajectory(){  Trajectory::Trajectory(){
2197      npoint = 10;      npoint = 6;
2198      x = new float[npoint];      x = new float[npoint];
2199      y = new float[npoint];      y = new float[npoint];
2200      z = new float[npoint];      z = new float[npoint];
# Line 2186  Trajectory::Trajectory(int n, float* zin Line 2261  Trajectory::Trajectory(int n, float* zin
2261      thy = new float[npoint];      thy = new float[npoint];
2262      tl = new float[npoint];      tl = new float[npoint];
2263      int i=0;      int i=0;
2264      do{      do{      
2265          x[i] = 0;          x[i] = 0.;
2266          y[i] = 0;          y[i] = 0.;
2267          z[i] = zin[i];          z[i] = zin[i];
2268          thx[i] = 0;          thx[i] = 0.;
2269          thy[i] = 0;          thy[i] = 0.;
2270          tl[i] = 0;          tl[i] = 0.;
2271          i++;                      i++;            
2272      }while(zin[i-1] > zin[i] && i < npoint);      }while(zin[i-1] > zin[i] && i < npoint);
2273      npoint=i;      npoint=i;
2274      if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl;      if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points instean of "<<n<<endl;
2275        //    Dump();
2276  }  }
2277  void Trajectory::Delete(){  void Trajectory::Delete(){
2278            
# Line 2248  float Trajectory::GetLength(int ifirst, Line 2324  float Trajectory::GetLength(int ifirst,
2324    
2325  /**  /**
2326   * Evaluates the trajectory in the apparatus associated to the track.   * Evaluates the trajectory in the apparatus associated to the track.
2327   * 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.
2328   * @param t pointer to an object of the class Trajectory,   * @param al Track state-vector (X0,Y0,sin(theta),phi,deflection).
2329   * 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).
2330   * @return error flag.   * @return error flag.
2331     *
2332     * This method is needed when you want to integrate the particle trajectory
2333     * starting from a track state-vector relative to an arbitrary reference plane.
2334     * The default reference plane, used by the tracker routines, is at zini=23.5.
2335     * If you give as input the track state-vector from a TrkTrack object,
2336     * you can use Trajectory::DoTrack(float* al) instead.
2337   */   */
2338  int Trajectory::DoTrack2(float* al){  int Trajectory::DoTrack(float* al, float zini){
2339    
2340  //      double *dxout   = new double[npoint];  //      double *dxout   = new double[npoint];
2341  //      double *dyout   = new double[npoint];  //      double *dyout   = new double[npoint];
# Line 2262  int Trajectory::DoTrack2(float* al){ Line 2344  int Trajectory::DoTrack2(float* al){
2344  //      double *dtlout  = new double[npoint];  //      double *dtlout  = new double[npoint];
2345  //      double *dzin    = new double[npoint];  //      double *dzin    = new double[npoint];
2346            
2347       double *dxout;      double *dxout;
2348       double *dyout;      double *dyout;
2349       double *dthxout;      double *dthxout;
2350       double *dthyout;      double *dthyout;
2351       double *dtlout;      double *dtlout;
2352       double *dzin;      double *dzin;
2353        
2354       dxout   = (double*) malloc(npoint*sizeof(double));      dxout   = (double*) malloc(npoint*sizeof(double));
2355       dyout   = (double*) malloc(npoint*sizeof(double));      dyout   = (double*) malloc(npoint*sizeof(double));
2356       dthxout = (double*) malloc(npoint*sizeof(double));      dthxout = (double*) malloc(npoint*sizeof(double));
2357       dthyout = (double*) malloc(npoint*sizeof(double));      dthyout = (double*) malloc(npoint*sizeof(double));
2358       dtlout  = (double*) malloc(npoint*sizeof(double));      dtlout  = (double*) malloc(npoint*sizeof(double));
2359       dzin    = (double*) malloc(npoint*sizeof(double));      dzin    = (double*) malloc(npoint*sizeof(double));
2360        
2361        double dal[5];
2362    
2363       double dal[5];      double dzini = (double)zini;
2364    
2365      int ifail = 0;      int ifail = 0;
2366        
2367      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];
2368      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];
2369    
2370      TrkParams::Load(1);      TrkParams::Load(1);
2371      if( !TrkParams::IsLoaded(1) ){      if( !TrkParams::IsLoaded(1) ){
2372          cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl;          cout << "int Trajectory::DoTrack(float* al) --- ERROR --- m.field not loaded"<<endl;
2373          return 0;          return 0;
2374      }      }
2375      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);  //    dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
2376        dotrack3_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&dzini,&ifail);
2377            
2378      for (int i=0; i<npoint; i++){      for (int i=0; i<npoint; i++){
2379          x[i]   = (float)*(dxout+i);          x[i]   = (float)*(dxout+i);
# Line 2316  int Trajectory::DoTrack2(float* al){ Line 2401  int Trajectory::DoTrack2(float* al){
2401      return ifail;      return ifail;
2402  };  };
2403    
2404    /**
2405     *
2406     * >>> OBSOLETE !!! use Trajectory::DoTrack(float* al, float zini) instead
2407     *
2408     */
2409    int Trajectory::DoTrack2(float* al, float zini){
2410    
2411        cout << endl;
2412        cout << " int Trajectory::DoTrack2(float* al, float zini) --->> NB NB !! this method is going to be eliminated !!! "<<endl;
2413        cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl;
2414        cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl;
2415        cout << endl;
2416    
2417        return DoTrack(al,zini);
2418    
2419    };
2420    
2421    
2422    
2423  ClassImp(TrkLevel2);  ClassImp(TrkLevel2);
2424  ClassImp(TrkSinglet);  ClassImp(TrkSinglet);
2425  ClassImp(TrkTrack);  ClassImp(TrkTrack);

Legend:
Removed from v.1.52  
changed lines
  Added in v.1.58

  ViewVC Help
Powered by ViewVC 1.1.23