/[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.43 by pam-fi, Tue Jan 22 08:55:07 2008 UTC revision 1.56 by pam-fi, Thu Feb 27 11:24:43 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 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                //NB!! the length of the sensor is not exactely taken into account    
691                double segment = 7.;// 2.;//cm //Elena 10th
692                // NB: i parametri di allineamento hanno una notazione particolare!!!
693                // sensor = 0 (hybrid side), 1
694                // ladder = 0-2 (increasing x)
695                // plane  = 0-5 (from bottom to top!!!)
696                int is = (int)GetSensor(i); if(i==5)is=1-is;
697                int ip = 5-i;
698                int il = (int)GetLadder(i);
699                
700                double omega   = 0.;
701                //      double beta    = 0.;// EM GCC 4.7
702                //      double gamma   = 0.;
703                if(
704                    (is < 0 || is > 1 || ip < 0 || ip > 5 || il < 0 || il > 2) &&
705                    true){
706                    // se il piano risulta colpito, ladder e sensore devono essere
707                    // assegnati correttamente
708                    cout << " void TrkTrack::FillMiniStruct(cMini2track&) --- WARNING --- sensor not defined, cannot read alignment parameters "<<endl;
709                    cout << " is ip il = "<<is<<" "<<ip<<" "<<il<<endl;
710                }else{
711                    omega   = alignparameters_.omega[is][il][ip];
712                    //              beta    = alignparameters_.beta[is][il][ip];// EM GCC 4.7 unused
713                    //              gamma   = alignparameters_.gamma[is][il][ip];// EM GCC 4.7 unused
714                }
715                
716                if(       XGood(i) && !YGood(i) ){
717                    track.xm_a[i] = xm[i] - omega * segment;
718                    track.ym_a[i] = ym[i] + segment;
719    //          track.zm_a[i] = zm[i] + beta * segment;//not used yet
720                    track.xm_b[i] = xm[i] + omega * segment;
721                    track.ym_b[i] = ym[i] - segment;
722    //          track.zm_b[i] = zm[i] - beta * segment;//not used yet
723                }else if( !XGood(i) && YGood(i) ){
724                    track.xm_a[i] = xm[i] + segment;
725                    track.ym_a[i] = ym[i] + omega * segment;
726    //          track.zm_a[i] = zm[i] - gamma * segment;//not used yet
727                    track.xm_b[i] = xm[i] - segment;
728                    track.ym_b[i] = ym[i] - omega * segment;
729    //          track.zm_b[i] = zm[i] + gamma * segment;//not used yet
730                }
731            }
732                    
733          track.resx[i]=resx[i];          track.resx[i]=resx[i];
734          track.resy[i]=resy[i];          track.resy[i]=resy[i];
735          track.tailx[i]=tailx[i];          track.tailx[i]=tailx[i];
736          track.taily[i]=taily[i];          track.taily[i]=taily[i];
# Line 697  void TrkTrack::SetFromMiniStruct(cMini2t Line 761  void TrkTrack::SetFromMiniStruct(cMini2t
761          zm[i]  = track->zm[i];          zm[i]  = track->zm[i];
762          axv[i] = track->axv[i];          axv[i] = track->axv[i];
763          ayv[i] = track->ayv[i];          ayv[i] = track->ayv[i];
764            resx[i] = track->resx[i]; //Elena 10th
765            resy[i] = track->resy[i];
766      }      }
767            
768  }  }
# Line 729  Bool_t TrkTrack::EvaluateClusterPosition Line 795  Bool_t TrkTrack::EvaluateClusterPosition
795            
796  //     cout << "void TrkTrack::GetClusterositions() "<<endl;  //     cout << "void TrkTrack::GetClusterositions() "<<endl;
797    
798      TrkParams::Load( );      TrkParams::Load(1);
799      if( !TrkParams::IsLoaded() )return false;      if( !TrkParams::IsLoaded(1) ){
800                cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl;
801            return false;
802        }    
803        TrkParams::Load(4);
804        if( !TrkParams::IsLoaded(4) ){
805            cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl;
806            return false;
807        }
808        TrkParams::Load(5);
809        if( !TrkParams::IsLoaded(5) ){
810            cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl;
811            return false;
812        }
813    
814      for(int ip=0; ip<6; ip++){      for(int ip=0; ip<6; ip++){
815  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;
816          int icx = GetClusterX_ID(ip)+1;          int icx = GetClusterX_ID(ip)+1;//0=no-cluster,1-N
817          int icy = GetClusterY_ID(ip)+1;          int icy = GetClusterY_ID(ip)+1;//0=no-cluster,1-N
818          int sensor = GetSensor(ip)+1;//<< convenzione "Paolo"          int sensor = GetSensor(ip)+1;//<< convenzione "Paolo"
819          if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena"          if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena"
820          int ladder = GetLadder(ip)+1;          int ladder = GetLadder(ip)+1;
# Line 749  Bool_t TrkTrack::EvaluateClusterPosition Line 828  Bool_t TrkTrack::EvaluateClusterPosition
828          float bfy = 10*TrkParams::GetBY(v);//Tesla          float bfy = 10*TrkParams::GetBY(v);//Tesla
829          int ipp=ip+1;          int ipp=ip+1;
830          xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy);          xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy);
831          if(icx<0 || icy<0)return false;          //      if(icx<0 || icy<0)return false;
832      }      }
833      return true;      return true;
834  }  }
# Line 783  Bool_t TrkTrack::EvaluateClusterPosition Line 862  Bool_t TrkTrack::EvaluateClusterPosition
862   */   */
863  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){
864    
865      float al_ini[] = {0.,0.,0.,0.,0.};      TrkParams::Load(1);
866        if( !TrkParams::IsLoaded(1) ){
867            cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl;
868            return;
869        }
870        TrkParams::Load(5);
871        if( !TrkParams::IsLoaded(5) ){
872            cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- align.param. not loaded "<<endl;
873            return;
874        }
875    
876      TrkParams::Load( );      float al_ini[] = {0.,0.,0.,0.,0.};
     if( !TrkParams::IsLoaded() )return;  
877    
878      extern cMini2track track_;      extern cMini2track track_;
879      fail = 0;      fail = 0;
880    
881      FillMiniStruct(track_);      //    FillMiniStruct(track_);
882                    
883      if(froml1!=0){      if(froml1!=0){
884          if( !EvaluateClusterPositions() ){          if( !EvaluateClusterPositions() ){
# Line 822  void TrkTrack::Fit(double pfixed, int& f Line 909  void TrkTrack::Fit(double pfixed, int& f
909    
910      //  ------------------------------------------      //  ------------------------------------------
911      //  call mini routine      //  call mini routine
912  //     TrkParams::Load(1);      //  ------------------------------------------
 //     if( !TrkParams::IsLoaded(1) ){  
 //      cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl;  
 //      return;  
 //     }  
913      int istep=0;      int istep=0;
914      int ifail=0;      int ifail=0;
915      mini2_(&istep,&ifail, &iprint);      mini2_(&istep,&ifail, &iprint);
# Line 834  void TrkTrack::Fit(double pfixed, int& f Line 917  void TrkTrack::Fit(double pfixed, int& f
917          if(iprint)cout << "ERROR: ifail= " << ifail << endl;          if(iprint)cout << "ERROR: ifail= " << ifail << endl;
918          fail = 1;          fail = 1;
919      }      }
920        if(chi2!=chi2){
921            if(iprint)cout << "ERROR: chi2= " << chi2 << endl;      
922            FitReset();
923            fail = 1;      
924        }
925      //  ------------------------------------------      //  ------------------------------------------
926            
927      SetFromMiniStruct(&track_);      SetFromMiniStruct(&track_);
# Line 890  void TrkTrack::SetDeltaB(int id, double Line 978  void TrkTrack::SetDeltaB(int id, double
978  }  }
979    
980  /**  /**
981   * Returns 1 if the track is inside the magnet cavity   * Returns true if the track is inside the magnet cavity.
982   * Set the minimum number of steps for tracking precision   * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
983   */   */
984  Bool_t TrkTrack::IsInsideCavity(){  Bool_t TrkTrack::IsInsideCavity(float toll){
985      float xmagntop, ymagntop, xmagnbottom, ymagnbottom;  
986      xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.);  //     float xmagntop, ymagntop, xmagnbottom, ymagnbottom;
987      ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*ayv[0]/180.);  //     xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.);
988      xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*axv[5]/180.);  //     ymagntop = yv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*ayv[0]/180.);
989      ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.);  //     xmagnbottom = xv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*axv[5]/180.);
990      if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&  //     ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.);
991          ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&  //     if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&
992          xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&  //      ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&
993          ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);  //      xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&
994      else return(false);  //      ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);
995    //     else return(false);
996    
997        int ngf = TrkParams::nGF;
998        for(int i=0; i<ngf; i++){
999            //
1000    //      cout << endl << TrkParams::GF_element[i];
1001            if(
1002                TrkParams::GF_element[i].CompareTo("CUF") &&
1003                TrkParams::GF_element[i].CompareTo("T2")  &&
1004                TrkParams::GF_element[i].CompareTo("T3")  &&
1005                TrkParams::GF_element[i].CompareTo("T4")  &&
1006                TrkParams::GF_element[i].CompareTo("T5")  &&
1007                TrkParams::GF_element[i].CompareTo("CLF") &&
1008                true)continue;
1009            // apply condition only within the cavity
1010    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1011            if(
1012                xGF[i] <= TrkParams::xGF_min[i] + toll ||
1013                xGF[i] >= TrkParams::xGF_max[i] - toll ||
1014                yGF[i] <= TrkParams::yGF_min[i] + toll ||
1015                yGF[i] >= TrkParams::yGF_max[i] - toll ||
1016                false){
1017                
1018                return false;
1019            }
1020        }
1021        return true;
1022    
1023    
1024    }
1025    /**
1026     * Returns true if the track is inside the nominal acceptance, which is defined
1027     * by the intersection among magnet cavity, silicon-plane sensitive area and
1028     * ToF sensitive area (nominal values from the official document used to
1029     * calculate the geometrical factor)
1030     * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
1031     */
1032    // Bool_t TrkTrack::IsInsideAcceptance(){
1033    
1034    //     int ngf = TrkParams::nGF;
1035    //     for(int i=0; i<ngf; i++){
1036    //      if(
1037    //          xGF[i] <= TrkParams::xGF_min[i] ||
1038    //          xGF[i] >= TrkParams::xGF_max[i] ||
1039    //          yGF[i] <= TrkParams::yGF_min[i] ||
1040    //          yGF[i] >= TrkParams::yGF_max[i] ||
1041    //          false)return false;
1042    //     }
1043    //     return true;
1044    
1045    // }
1046    Bool_t TrkTrack::IsInsideAcceptance(float toll){
1047    
1048    
1049        int ngf = TrkParams::nGF;
1050        for(int i=0; i<ngf; i++){
1051            //
1052    //      cout << endl << TrkParams::GF_element[i];
1053            if(
1054                TrkParams::GF_element[i].CompareTo("S11") &&
1055                TrkParams::GF_element[i].CompareTo("S12") &&
1056                TrkParams::GF_element[i].CompareTo("S21") &&
1057                TrkParams::GF_element[i].CompareTo("S22") &&
1058                TrkParams::GF_element[i].CompareTo("T1")  &&
1059                TrkParams::GF_element[i].CompareTo("CUF") &&
1060                TrkParams::GF_element[i].CompareTo("T2")  &&
1061                TrkParams::GF_element[i].CompareTo("T3")  &&
1062                TrkParams::GF_element[i].CompareTo("T4")  &&
1063                TrkParams::GF_element[i].CompareTo("T5")  &&
1064                TrkParams::GF_element[i].CompareTo("CLF") &&
1065                TrkParams::GF_element[i].CompareTo("T6")  &&
1066                TrkParams::GF_element[i].CompareTo("S31") &&
1067                TrkParams::GF_element[i].CompareTo("S32") &&
1068                true)continue;
1069            // apply condition only within the cavity
1070    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1071            if(
1072                xGF[i] <= TrkParams::xGF_min[i] + toll ||
1073                xGF[i] >= TrkParams::xGF_max[i] - toll ||
1074                yGF[i] <= TrkParams::yGF_min[i] + toll ||
1075                yGF[i] >= TrkParams::yGF_max[i] - toll ||
1076                false){
1077                
1078                return false;
1079            }
1080        }
1081        return true;
1082    }
1083    
1084    /**
1085     * Returns true if the track is inside one of the surfaces which define the
1086     * geometrical acceptance.
1087     * @param surf tag of the surface (possible values are: S11 S12 S21 S22 T1
1088     * CUF T2 T3 T4 T5 CLF T6 S31 S32).
1089     * @param toll  Tolerance around the nominal surface (toll>0 define an inner
1090     * fiducial surface)
1091    */
1092    Bool_t TrkTrack::IsInsideGFSurface(const char* surf, float toll){
1093    
1094    
1095        int ngf = TrkParams::nGF;
1096        bool SURFOK = false;
1097        for(int i=0; i<ngf; i++){
1098            if(  !TrkParams::GF_element[i].CompareTo(surf)  ){
1099                SURFOK=true;
1100                if(
1101                    xGF[i] > TrkParams::xGF_min[i] + toll &&
1102                    xGF[i] < TrkParams::xGF_max[i] - toll &&
1103                    yGF[i] > TrkParams::yGF_min[i] + toll &&
1104                    yGF[i] < TrkParams::yGF_max[i] - toll &&
1105                    true)return true;
1106            }
1107        }
1108        if( !SURFOK )cout << " Bool_t TrkTrack::IsInsideGFSurface(char* surf, float toll) --> suface "<<surf<<" not defined "<<endl;
1109        return false;
1110    
1111  }  }
1112    
1113  /**  /**
1114   * 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.
1115   * If no cluster is associated, ID=-1.   * If no cluster is associated, ID=-1.
# Line 923  Int_t TrkTrack::GetClusterY_ID(int ip){ Line 1128  Int_t TrkTrack::GetClusterY_ID(int ip){
1128  };  };
1129    
1130  /**  /**
1131   * 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.
1132   * If no ladder is traversed (dead area) the metod retuns -1.   * If no ladder is traversed (dead area) the metod retuns -1.
1133   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1134   */   */
# Line 946  Int_t TrkTrack::GetSensor(int ip){ Line 1151  Int_t TrkTrack::GetSensor(int ip){
1151  /**  /**
1152   * \brief Method to include a x-cluster to the track.   * \brief Method to include a x-cluster to the track.
1153   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1154   * @param clid Cluster ID (0,1,...)   * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise )
1155   * @param is Sensor (0-1, increasing y)   * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit)
1156     * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit)
1157     * @param bad True if the cluster contains bad strips  
1158   * @see Fit(double pfixed, int& fail, int iprint, int froml1)   * @see Fit(double pfixed, int& fail, int iprint, int froml1)
1159   */   */
1160  void TrkTrack::SetXGood(int ip, int clid, int is){  void TrkTrack::SetXGood(int ip, int clid, int il, int is, bool bad){
1161      int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1162      bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1163      xgood[ip]=il*100000000+is*10000000+clid;      if(ip<0||ip>5||clid<1||il<-1||il>2||is<-1||is>1)
1164            cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1165        xgood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1166      if(bad)xgood[ip]=-xgood[ip];      if(bad)xgood[ip]=-xgood[ip];
1167  };  };
1168  /**  /**
1169   * \brief Method to include a y-cluster to the track.   * \brief Method to include a y-cluster to the track.
1170   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1171   * @param clid Cluster ID (0,1,...)   * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise )
1172   * @param is Sensor (0-1)   * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit)
1173     * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit)
1174     * @param bad True if the cluster contains bad strips  
1175   * @see Fit(double pfixed, int& fail, int iprint, int froml1)   * @see Fit(double pfixed, int& fail, int iprint, int froml1)
1176   */   */
1177  void TrkTrack::SetYGood(int ip, int clid, int is){  void TrkTrack::SetYGood(int ip, int clid, int il, int is, bool bad){
1178      int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1179      bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1180      ygood[ip]=il*100000000+is*10000000+clid;      if(ip<0||ip>5||clid<1||il<-1||il>2||is<-1||is>1)
1181            cout << " void TrkTrack::SetYGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1182        ygood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1183      if(bad)ygood[ip]=-ygood[ip];      if(bad)ygood[ip]=-ygood[ip];
1184  };  };
1185    
# Line 1069  Float_t TrkTrack::GetDEDX_max(int ip, in Line 1282  Float_t TrkTrack::GetDEDX_max(int ip, in
1282          vto   = iv+1;          vto   = iv+1;
1283      }      }
1284      for(int i=pfrom; i<pto; i++)      for(int i=pfrom; i<pto; i++)
1285          for(int j=0; j<vto; j++)          for(int j=vfrom; j<vto; j++){
1286              if(GetDEDX(i,j)>max)max=GetDEDX(i,j);              if(j==0 && XGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j);
1287                if(j==1 && YGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j);
1288            }
1289      return max;      return max;
1290    
1291  };  };
# Line 1094  Float_t TrkTrack::GetDEDX_min(int ip, in Line 1308  Float_t TrkTrack::GetDEDX_min(int ip, in
1308          vto   = iv+1;          vto   = iv+1;
1309      }      }
1310      for(int i=pfrom; i<pto; i++)      for(int i=pfrom; i<pto; i++)
1311          for(int j=0; j<vto; j++)          for(int j=vfrom; j<vto; j++){
1312              if(GetDEDX(i,j)<min)min=GetDEDX(i,j);              if(j==0 && XGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j);
1313                if(j==1 && YGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j);
1314            }
1315      return min;      return min;
1316    
1317  };  };
1318    
1319  /**  /**
1320   * \brief Give the maximum spatial residual release   * \brief Give the maximum spatial residual  
1321   */   */
1322  Float_t TrkTrack::GetResidual_max(int ip, int iv){  Float_t TrkTrack::GetResidual_max(int ip, int iv){
1323      Float_t max=0;      Float_t max=0;
# Line 1119  Float_t TrkTrack::GetResidual_max(int ip Line 1334  Float_t TrkTrack::GetResidual_max(int ip
1334          vto   = iv+1;          vto   = iv+1;
1335      }      }
1336      for(int i=pfrom; i<pto; i++){      for(int i=pfrom; i<pto; i++){
1337          for(int j=0; j<vto; j++){          for(int j=vfrom; j<vto; j++){
1338              if(j==0 && XGood(i) && fabs(xm[i]-xv[i])>fabs(max))max=xv[i]-xm[i];              if(j==0 && XGood(i) && fabs(xm[i]-xv[i])>fabs(max))max=xm[i]-xv[i];
1339              if(j==1 && YGood(i) && fabs(ym[i]-yv[i])>fabs(max))max=yv[i]-ym[i];              if(j==1 && YGood(i) && fabs(ym[i]-yv[i])>fabs(max))max=ym[i]-yv[i];
1340          }          }
1341      }      }
1342      return max;      return max;
1343    
1344  };  };
1345    /**
1346     * \brief Give the anerage spatial residual
1347     */
1348    Float_t TrkTrack::GetResidual_av(int ip, int iv){
1349        //
1350    //Sum$((xm>-50)*(xm-xv)/resx)/sqrt(TrkTrack.GetNX()*TrkTrack.GetChi2X())<0.3
1351    
1352        Float_t av  = 0.;
1353        int     nav = 0;
1354        //
1355        int pfrom = 0;
1356        int pto   = 6;
1357        int vfrom = 0;
1358        int vto   = 2;
1359        if(ip>=0&&ip<6){
1360            pfrom = ip;
1361            pto   = ip+1;
1362        }
1363        if(iv>=0&&iv<2){
1364            vfrom = iv;
1365            vto   = iv+1;
1366        }
1367        for(int i=pfrom; i<pto; i++){
1368            for(int j=vfrom; j<vto; j++){
1369                nav++;
1370                if(j==0 && XGood(i)) av += (xm[i]-xv[i])/resx[i];
1371                if(j==1 && YGood(i)) av += (ym[i]-yv[i])/resy[i];
1372            }
1373        }
1374        if(nav==0)return -100.;
1375        return av/nav;
1376    
1377    };
1378    
1379    
1380  /**  /**
# Line 1219  void TrkTrack::Clear(){ Line 1467  void TrkTrack::Clear(){
1467          dedx_y[ip] = 0;          dedx_y[ip] = 0;
1468    
1469      };      };
1470        int ngf = TrkParams::nGF;
1471        for(int i=0; i<ngf; i++){
1472            xGF[i] = 0.;
1473            yGF[i] = 0.;
1474        }
1475  //     if(clx)clx->Clear();  //     if(clx)clx->Clear();
1476  //     if(cly)cly->Clear();  //     if(cly)cly->Clear();
1477  //    clx.Clear();  //    clx.Clear();
# Line 1245  void TrkTrack::Delete(){ Line 1498  void TrkTrack::Delete(){
1498  //--------------------------------------  //--------------------------------------
1499  TrkSinglet::TrkSinglet(){  TrkSinglet::TrkSinglet(){
1500  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;
1501      plane    = 0;  //     plane    = 0;
1502      coord[0] = 0;  //     coord[0] = 0;
1503      coord[1] = 0;  //     coord[1] = 0;
1504      sgnl     = 0;  //     sgnl     = 0;
1505    //     multmax  = 0;
1506  //    cls      = 0;  //    cls      = 0;
1507        Clear();
1508  };  };
1509  //--------------------------------------  //--------------------------------------
1510  //  //
# Line 1261  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1516  TrkSinglet::TrkSinglet(const TrkSinglet&
1516      coord[0] = s.coord[0];      coord[0] = s.coord[0];
1517      coord[1] = s.coord[1];      coord[1] = s.coord[1];
1518      sgnl     = s.sgnl;      sgnl     = s.sgnl;
1519        multmax  = s.multmax;
1520  //      cls      = 0;//<<<<pointer  //      cls      = 0;//<<<<pointer
1521  //    cls      = TRef(s.cls);  //    cls      = TRef(s.cls);
1522  };  };
# Line 1271  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1527  TrkSinglet::TrkSinglet(const TrkSinglet&
1527  void TrkSinglet::Dump(){  void TrkSinglet::Dump(){
1528      int i=0;      int i=0;
1529      cout << endl << "========== Singlet " ;      cout << endl << "========== Singlet " ;
1530      cout << endl << "plane    : " << plane;      cout << endl << "plane        : " << plane;
1531      cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++;      cout << endl << "coord[2]     : "; while( i<2 && cout << coord[i] << " ") i++;
1532      cout << endl << "sgnl     : " << sgnl;      cout << endl << "sgnl         : " << sgnl;
1533        cout << endl << "max.strip    : ";
1534        cout << endl << "multiplicity : ";
1535  }  }
1536  //--------------------------------------  //--------------------------------------
1537  //  //
# Line 1286  void TrkSinglet::Clear(){ Line 1544  void TrkSinglet::Clear(){
1544      coord[0]=-999;      coord[0]=-999;
1545      coord[1]=-999;      coord[1]=-999;
1546      sgnl=0;      sgnl=0;
1547        multmax  = 0;
1548            
1549  }  }
1550  //--------------------------------------  //--------------------------------------
# Line 1396  Bool_t TrkLevel2::GetVKFlag(int iv, int Line 1655  Bool_t TrkLevel2::GetVKFlag(int iv, int
1655   * forced (see TrkLevel2::GetVKMask(int,int)) or   * forced (see TrkLevel2::GetVKMask(int,int)) or
1656   * for this event only (TrkLevel2::GetVKFlag(int,int)).   * for this event only (TrkLevel2::GetVKFlag(int,int)).
1657   * @param iv Tracker view (0-11)   * @param iv Tracker view (0-11)
1658   * @param ivk Viking-chip number (0-23)   * @param ivk Viking-chip number (0-23)
1659   */   */
1660  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){
1661      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );
# Line 1492  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1751  void TrkLevel2::SetFromLevel2Struct(cTrk
1751              //-----------------------------------------------------              //-----------------------------------------------------
1752              //-----------------------------------------------------              //-----------------------------------------------------
1753          };          };
1754            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1755            // evaluated coordinates (to define GF)
1756            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1757            int    ngf = TrkParams::nGF;
1758            float *zgf = TrkParams::zGF;
1759            Trajectory tgf = Trajectory(ngf,zgf);
1760            tgf.DoTrack(t_track->al);//<<<< integrate the trajectory
1761            for(int ip=0; ip<ngf; ip++){
1762                t_track->xGF[ip] = tgf.x[ip];
1763                t_track->yGF[ip] = tgf.y[ip];
1764            }
1765            
1766  //      if(t_track->IsSaturated())t_track->Dump();  //      if(t_track->IsSaturated())t_track->Dump();
1767          new(t[i]) TrkTrack(*t_track);          new(t[i]) TrkTrack(*t_track);
1768          t_track->Clear();          t_track->Clear();
1769      };      };//end loop over track
1770    
1771  //  ----------------  //  ----------------
1772  //  *** SINGLETS ***  //  *** SINGLETS ***
# Line 1507  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1778  void TrkLevel2::SetFromLevel2Struct(cTrk
1778          t_singlet->coord[0] = l2->xs[i][0];          t_singlet->coord[0] = l2->xs[i][0];
1779          t_singlet->coord[1] = l2->xs[i][1];          t_singlet->coord[1] = l2->xs[i][1];
1780          t_singlet->sgnl     = l2->signlxs[i];          t_singlet->sgnl     = l2->signlxs[i];
1781            t_singlet->multmax = l2->multmaxsx[i];
1782            if(l2->sxbad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1783          //-----------------------------------------------------          //-----------------------------------------------------
1784  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);
1785          //-----------------------------------------------------          //-----------------------------------------------------
# Line 1520  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1793  void TrkLevel2::SetFromLevel2Struct(cTrk
1793          t_singlet->coord[0] = l2->ys[i][0];          t_singlet->coord[0] = l2->ys[i][0];
1794          t_singlet->coord[1] = l2->ys[i][1];          t_singlet->coord[1] = l2->ys[i][1];
1795          t_singlet->sgnl     = l2->signlys[i];          t_singlet->sgnl     = l2->signlys[i];
1796            t_singlet->multmax  = l2->multmaxsy[i];
1797            if(l2->sybad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1798          //-----------------------------------------------------          //-----------------------------------------------------
1799  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);
1800          //-----------------------------------------------------          //-----------------------------------------------------
1801          new(sy[i]) TrkSinglet(*t_singlet);          new(sy[i]) TrkSinglet(*t_singlet);
1802          t_singlet->Clear();          t_singlet->Clear();
1803      };      };
1804    
1805    
1806                    
1807      delete t_track;      delete t_track;
1808      delete t_singlet;      delete t_singlet;
# Line 1638  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1915  TRefArray *TrkLevel2::GetTracks_NFitSort
1915    
1916      if(!Track)return 0;      if(!Track)return 0;
1917    
1918      TRefArray *sorted = new TRefArray();      //    TRefArray *sorted = new TRefArray();
1919        TRefArray *sorted = NULL;
1920                    
1921      TClonesArray &t  = *Track;      TClonesArray &t  = *Track;
1922  //    TClonesArray &ts = *PhysicalTrack;  //    TClonesArray &ts = *PhysicalTrack;
# Line 1676  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1954  TRefArray *TrkLevel2::GetTracks_NFitSort
1954                    
1955  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;
1956          };          };
1957            if(!sorted)sorted = new TRefArray( TProcessID::GetProcessWithUID(t[indi]));
1958          sorted->Add( (TrkTrack*)t[indi] );                sorted->Add( (TrkTrack*)t[indi] );      
1959                                    
1960          m[indi] = 0;          m[indi] = 0;
# Line 1846  void TrkLevel2::LoadField(TString path){ Line 2125  void TrkLevel2::LoadField(TString path){
2125    
2126      TrkParams::Set(path,1);      TrkParams::Set(path,1);
2127      TrkParams::Load(1);      TrkParams::Load(1);
2128        if( !TrkParams::IsLoaded(1) ){
2129            cout << "void TrkLevel2::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl;
2130        }
2131    
2132  //  //
2133  };  };
# Line 2033  float Trajectory::GetLength(int ifirst, Line 2315  float Trajectory::GetLength(int ifirst,
2315    
2316  /**  /**
2317   * Evaluates the trajectory in the apparatus associated to the track.   * Evaluates the trajectory in the apparatus associated to the track.
2318   * 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.
2319   * @param t pointer to an object of the class Trajectory,   * @param al Track state-vector (X0,Y0,sin(theta),phi,deflection).
2320   * 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).
2321   * @return error flag.   * @return error flag.
2322   */   *
2323  int Trajectory::DoTrack2(float* al){   * This method is needed when you want to integrate the particle trajectory
2324     * starting from a track state-vector relative to an arbitrary reference plane.
2325      double *dxout   = new double[npoint];   * The default reference plane, used by the tracker routines, is at zini=23.5.
2326      double *dyout   = new double[npoint];   * If you give as input the track state-vector from a TrkTrack object,
2327      double *dthxout = new double[npoint];   * you can use Trajectory::DoTrack(float* al) instead.
2328      double *dthyout = new double[npoint];   */
2329      double *dtlout  = new double[npoint];  int Trajectory::DoTrack(float* al, float zini){
2330      double *dzin    = new double[npoint];  
2331    //      double *dxout   = new double[npoint];
2332    //      double *dyout   = new double[npoint];
2333    //      double *dthxout = new double[npoint];
2334    //      double *dthyout = new double[npoint];
2335    //      double *dtlout  = new double[npoint];
2336    //      double *dzin    = new double[npoint];
2337        
2338        double *dxout;
2339        double *dyout;
2340        double *dthxout;
2341        double *dthyout;
2342        double *dtlout;
2343        double *dzin;
2344        
2345        dxout   = (double*) malloc(npoint*sizeof(double));
2346        dyout   = (double*) malloc(npoint*sizeof(double));
2347        dthxout = (double*) malloc(npoint*sizeof(double));
2348        dthyout = (double*) malloc(npoint*sizeof(double));
2349        dtlout  = (double*) malloc(npoint*sizeof(double));
2350        dzin    = (double*) malloc(npoint*sizeof(double));
2351        
2352      double dal[5];      double dal[5];
2353    
2354      int ifail = 0;      double dzini = (double)zini;
2355    
2356        int ifail = 0;
2357        
2358      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];
2359      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];
2360    
2361      TrkParams::Load(1);      TrkParams::Load(1);
2362      if( !TrkParams::IsLoaded(1) ){      if( !TrkParams::IsLoaded(1) ){
2363          cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl;          cout << "int Trajectory::DoTrack(float* al) --- ERROR --- m.field not loaded"<<endl;
2364          return 0;          return 0;
2365      }      }
2366      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);  //    dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
2367        dotrack3_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&dzini,&ifail);
2368            
2369      for (int i=0; i<npoint; i++){      for (int i=0; i<npoint; i++){
2370          x[i]   = (float)*dxout++;          x[i]   = (float)*(dxout+i);
2371          y[i]   = (float)*dyout++;          y[i]   = (float)*(dyout+i);
2372          thx[i] = (float)*dthxout++;          thx[i] = (float)*(dthxout+i);
2373          thy[i] = (float)*dthyout++;          thy[i] = (float)*(dthyout+i);
2374          tl[i]  = (float)*dtlout++;          tl[i]  = (float)*(dtlout+i);
2375      }      }
2376    
2377        if(dxout)  free( dxout );
2378        if(dyout)  free( dyout );
2379        if(dthxout)free( dthxout );
2380        if(dthyout)free( dthyout );
2381        if(dtlout) free( dtlout );
2382        if(dzin)   free( dzin );
2383    
2384    //      delete [] dxout;
2385    //      delete [] dyout;
2386    //      delete [] dthxout;
2387    //      delete [] dthyout;
2388    //      delete [] dtlout;
2389    //      delete [] dzin;
2390    
2391    
2392      return ifail;      return ifail;
2393  };  };
2394    
2395    /**
2396     *
2397     * >>> OBSOLETE !!! use Trajectory::DoTrack(float* al, float zini) instead
2398     *
2399     */
2400    int Trajectory::DoTrack2(float* al, float zini){
2401    
2402        cout << endl;
2403        cout << " int Trajectory::DoTrack2(float* al, float zini) --->> NB NB !! this method is going to be eliminated !!! "<<endl;
2404        cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl;
2405        cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl;
2406        cout << endl;
2407    
2408        return DoTrack(al,zini);
2409    
2410    };
2411    
2412    
2413    
2414  ClassImp(TrkLevel2);  ClassImp(TrkLevel2);
2415  ClassImp(TrkSinglet);  ClassImp(TrkSinglet);
2416  ClassImp(TrkTrack);  ClassImp(TrkTrack);

Legend:
Removed from v.1.43  
changed lines
  Added in v.1.56

  ViewVC Help
Powered by ViewVC 1.1.23