/[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.60 by pam-fi, Thu Jan 28 14:38:24 2016 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 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 380  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 391  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 583  void TrkTrack::SetStudentParam(int flag) Line 609  void TrkTrack::SetStudentParam(int flag)
609                     4.52043,                     4.52043,
610                     4.29926};                     4.29926};
611      int index;      int index;
612      float fact;      float fact=0.;
613      for(int i=0; i<6; i++) {      for(int i=0; i<6; i++) {
614          index = int((fabs(axv[i])+1.)/2.);          index = int((fabs(axv[i])+1.)/2.);
615          if(index>10) index=10;          if(index>10) index=10;
# Line 630  void TrkTrack::LoadField(TString path){ Line 656  void TrkTrack::LoadField(TString path){
656    
657      TrkParams::Set(path,1);      TrkParams::Set(path,1);
658      TrkParams::Load(1);      TrkParams::Load(1);
659        if( !TrkParams::IsLoaded(1) ){
660            cout << "void TrkTrack::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl;
661        }
662    
663  };  };
664    
# Line 643  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  //      andrebbe inserita la dimensione del sensore  //      float segment = 100.;
684          float segment = 100.;  //      track.xm_a[i]=xm[i];
685          track.xm_a[i]=xm[i];  //      track.xm_b[i]=xm[i];
686          track.xm_b[i]=xm[i];  //      track.ym_a[i]=ym[i];
687          track.ym_a[i]=ym[i];  //      track.ym_b[i]=ym[i];
688          track.ym_b[i]=ym[i];  //      if(       XGood(i) && !YGood(i) ){
689          if(       XGood(i) && !YGood(i) ){  //          track.ym_a[i] = track.ym_a[i]+segment;
690              track.ym_a[i] = track.ym_a[i]+segment;  //          track.ym_b[i] = track.ym_b[i]-segment;
691              track.ym_b[i] = track.ym_b[i]-segment;  //      }else if( !XGood(i) && YGood(i)){
692          }else if( !XGood(i) && YGood(i)){  //          track.xm_a[i] = track.xm_a[i]+segment;
693              track.xm_a[i] = track.xm_a[i]+segment;  //          track.xm_b[i] = track.xm_b[i]-segment;
694              track.xm_b[i] = track.xm_b[i]-segment;  //      }
         }  
695  //      --- temporaneo ----------------------------  //      --- temporaneo ----------------------------
696    
697            if( XGood(i) || YGood(i) ){
698                //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!!!
701                // sensor = 0 (hybrid side), 1
702                // ladder = 0-2 (increasing x)
703                // plane  = 0-5 (from bottom to top!!!)
704                int is = (int)GetSensor(i); if(i==5)is=1-is;
705                int ip = 5-i;
706                int il = (int)GetLadder(i);
707                
708                double omega   = 0.;
709                //      double beta    = 0.;// EM GCC 4.7
710                //      double gamma   = 0.;
711                if(
712                    (is < 0 || is > 1 || ip < 0 || ip > 5 || il < 0 || il > 2) &&
713                    true){
714                    // se il piano risulta colpito, ladder e sensore devono essere
715                    // assegnati correttamente
716                    cout << " void TrkTrack::FillMiniStruct(cMini2track&) --- WARNING --- sensor not defined, cannot read alignment parameters "<<endl;
717                    cout << " is ip il = "<<is<<" "<<ip<<" "<<il<<endl;
718                }else{
719                    omega   = alignparameters_.omega[is][il][ip];
720                    //              beta    = alignparameters_.beta[is][il][ip];// EM GCC 4.7 unused
721                    //              gamma   = alignparameters_.gamma[is][il][ip];// EM GCC 4.7 unused
722                }
723                
724                if(       XGood(i) && !YGood(i) ){
725                    track.xm_a[i] =  (double) xm[i] - omega * segment;
726                    track.ym_a[i] =  (double) ym[i] + segment;
727    //          track.zm_a[i] = zm[i] + beta * segment;//not used yet
728                    track.xm_b[i] =  (double) xm[i] + omega * segment;
729                    track.ym_b[i] =  (double) ym[i] - segment;
730    //          track.zm_b[i] = zm[i] - beta * segment;//not used yet
731                }else if( !XGood(i) && YGood(i) ){
732                    track.xm_a[i] =  (double) xm[i] + segment;
733                    track.ym_a[i] =  (double) ym[i] + omega * segment;
734    //          track.zm_a[i] = zm[i] - gamma * segment;//not used yet
735                    track.xm_b[i] =  (double) xm[i] - segment;
736                    track.ym_b[i] =  (double) ym[i] - omega * segment;
737    //          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 683  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 729  Bool_t TrkTrack::EvaluateClusterPosition Line 803  Bool_t TrkTrack::EvaluateClusterPosition
803            
804  //     cout << "void TrkTrack::GetClusterositions() "<<endl;  //     cout << "void TrkTrack::GetClusterositions() "<<endl;
805    
806      TrkParams::Load( );      TrkParams::Load(1);
807      if( !TrkParams::IsLoaded() )return false;      if( !TrkParams::IsLoaded(1) ){
808                cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl;
809            return false;
810        }    
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 749  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 783  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      float al_ini[] = {0.,0.,0.,0.,0.};      TrkParams::Load(1);
874        if( !TrkParams::IsLoaded(1) ){
875            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      TrkParams::Load( );      float al_ini[] = {0.,0.,0.,0.,0.};
     if( !TrkParams::IsLoaded() )return;  
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 822  void TrkTrack::Fit(double pfixed, int& f Line 917  void TrkTrack::Fit(double pfixed, int& f
917    
918      //  ------------------------------------------      //  ------------------------------------------
919      //  call mini routine      //  call mini routine
920  //     TrkParams::Load(1);      //  ------------------------------------------
 //     if( !TrkParams::IsLoaded(1) ){  
 //      cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl;  
 //      return;  
 //     }  
921      int istep=0;      int istep=0;
922      int ifail=0;      int ifail=0;
923      mini2_(&istep,&ifail, &iprint);      mini2_(&istep,&ifail, &iprint);
# Line 834  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 843  void TrkTrack::Fit(double pfixed, int& f Line 939  void TrkTrack::Fit(double pfixed, int& f
939          for(int i=0; i<5; i++) al[i]=al_ini[i];          for(int i=0; i<5; i++) al[i]=al_ini[i];
940      }      }
941    
942    
943        //ELENA 2015
944        int ngf = TrkParams::nGF;
945        float* zgf =  TrkParams::zGF;    
946        Trajectory tj = Trajectory(ngf,zgf);
947        tj.DoTrack(al,ZINI);
948        for(int i=0; i<14; i++){
949            xGF[i] = tj.x[i];
950            yGF[i] = tj.y[i];
951        }
952        if(ngf!=14){
953            cout << "TrkTrack::Fit("<<pfixed<<","<<fail<<","<<iprint<<","<<froml1<<"<<) "<<endl;;
954            cout << "TrkParams::nGF = "<<TrkParams::nGF<<" != 14 "<<endl;
955            cout << "back-incompatibility !?!?! acceptance check not reliable"<<endl;
956        }
957        
958        
959    
960  };  };
961  /**  /**
962   * Reset the fit parameters   * Reset the fit parameters
# Line 890  void TrkTrack::SetDeltaB(int id, double Line 1004  void TrkTrack::SetDeltaB(int id, double
1004  }  }
1005    
1006  /**  /**
1007   * Returns 1 if the track is inside the magnet cavity   * Returns true if the track is inside the magnet cavity.
1008   * Set the minimum number of steps for tracking precision   * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
1009   */   */
1010  Bool_t TrkTrack::IsInsideCavity(){  Bool_t TrkTrack::IsInsideCavity(float toll){
1011      float xmagntop, ymagntop, xmagnbottom, ymagnbottom;  
1012      xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.);  //     float xmagntop, ymagntop, xmagnbottom, ymagnbottom;
1013      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.);
1014      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.);
1015      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.);
1016      if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&  //     ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.);
1017          ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&  //     if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&
1018          xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&  //      ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&
1019          ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);  //      xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&
1020      else return(false);  //      ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);
1021    //     else return(false);
1022    
1023        int ngf = TrkParams::nGF;
1024        for(int i=0; i<ngf; i++){
1025            //
1026    //      cout << endl << TrkParams::GF_element[i];
1027            if(
1028                TrkParams::GF_element[i].CompareTo("CUF") &&
1029                TrkParams::GF_element[i].CompareTo("T2")  &&
1030                TrkParams::GF_element[i].CompareTo("T3")  &&
1031                TrkParams::GF_element[i].CompareTo("T4")  &&
1032                TrkParams::GF_element[i].CompareTo("T5")  &&
1033                TrkParams::GF_element[i].CompareTo("CLF") &&
1034                true)continue;
1035            // apply condition only within the cavity
1036    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1037            if(
1038                xGF[i] <= TrkParams::xGF_min[i] + toll ||
1039                xGF[i] >= TrkParams::xGF_max[i] - toll ||
1040                yGF[i] <= TrkParams::yGF_min[i] + toll ||
1041                yGF[i] >= TrkParams::yGF_max[i] - toll ||
1042                false){
1043                
1044                return false;
1045            }
1046        }
1047        return true;
1048    
1049    
1050  }  }
1051  /**  /**
1052     * Returns true if the track is inside the nominal acceptance, which is defined
1053     * by the intersection among magnet cavity, silicon-plane sensitive area and
1054     * ToF sensitive area (nominal values from the official document used to
1055     * calculate the geometrical factor)
1056     * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
1057     */
1058    // Bool_t TrkTrack::IsInsideAcceptance(){
1059    
1060    //     int ngf = TrkParams::nGF;
1061    //     for(int i=0; i<ngf; i++){
1062    //      if(
1063    //          xGF[i] <= TrkParams::xGF_min[i] ||
1064    //          xGF[i] >= TrkParams::xGF_max[i] ||
1065    //          yGF[i] <= TrkParams::yGF_min[i] ||
1066    //          yGF[i] >= TrkParams::yGF_max[i] ||
1067    //          false)return false;
1068    //     }
1069    //     return true;
1070    
1071    // }
1072    Bool_t TrkTrack::IsInsideAcceptance(float toll){
1073    
1074    
1075        int ngf = TrkParams::nGF;
1076        for(int i=0; i<ngf; i++){
1077            //
1078    //      cout << endl << TrkParams::GF_element[i];
1079            if(
1080                TrkParams::GF_element[i].CompareTo("S11") &&
1081                TrkParams::GF_element[i].CompareTo("S12") &&
1082                TrkParams::GF_element[i].CompareTo("S21") &&
1083                TrkParams::GF_element[i].CompareTo("S22") &&
1084                TrkParams::GF_element[i].CompareTo("T1")  &&
1085                TrkParams::GF_element[i].CompareTo("CUF") &&
1086                TrkParams::GF_element[i].CompareTo("T2")  &&
1087                TrkParams::GF_element[i].CompareTo("T3")  &&
1088                TrkParams::GF_element[i].CompareTo("T4")  &&
1089                TrkParams::GF_element[i].CompareTo("T5")  &&
1090                TrkParams::GF_element[i].CompareTo("CLF") &&
1091                TrkParams::GF_element[i].CompareTo("T6")  &&
1092                TrkParams::GF_element[i].CompareTo("S31") &&
1093                TrkParams::GF_element[i].CompareTo("S32") &&
1094                true)continue;
1095            // apply condition only within the cavity
1096    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1097            if(
1098                xGF[i] <= TrkParams::xGF_min[i] + toll ||
1099                xGF[i] >= TrkParams::xGF_max[i] - toll ||
1100                yGF[i] <= TrkParams::yGF_min[i] + toll ||
1101                yGF[i] >= TrkParams::yGF_max[i] - toll ||
1102                false){
1103                
1104                return false;
1105            }
1106        }
1107        return true;
1108    }
1109    
1110    /**
1111     * Returns true if the track is inside one of the surfaces which define the
1112     * geometrical acceptance.
1113     * @param surf tag of the surface (possible values are: S11 S12 S21 S22 T1
1114     * CUF T2 T3 T4 T5 CLF T6 S31 S32).
1115     * @param toll  Tolerance around the nominal surface (toll>0 define an inner
1116     * fiducial surface)
1117    */
1118    Bool_t TrkTrack::IsInsideGFSurface(const char* surf, float toll){
1119    
1120    
1121        int ngf = TrkParams::nGF;
1122        bool SURFOK = false;
1123        for(int i=0; i<ngf; i++){
1124            if(  !TrkParams::GF_element[i].CompareTo(surf)  ){
1125                SURFOK=true;
1126                if(
1127                    xGF[i] > TrkParams::xGF_min[i] + toll &&
1128                    xGF[i] < TrkParams::xGF_max[i] - toll &&
1129                    yGF[i] > TrkParams::yGF_min[i] + toll &&
1130                    yGF[i] < TrkParams::yGF_max[i] - toll &&
1131                    true)return true;
1132            }
1133        }
1134        if( !SURFOK )cout << " Bool_t TrkTrack::IsInsideGFSurface(char* surf, float toll) --> suface "<<surf<<" not defined "<<endl;
1135        return false;
1136    
1137    }
1138    
1139    /**
1140   * 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.
1141   * If no cluster is associated, ID=-1.   * If no cluster is associated, ID=-1.
1142   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
# Line 923  Int_t TrkTrack::GetClusterY_ID(int ip){ Line 1154  Int_t TrkTrack::GetClusterY_ID(int ip){
1154  };  };
1155    
1156  /**  /**
1157   * 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.
1158   * If no ladder is traversed (dead area) the metod retuns -1.   * If no ladder is traversed (dead area) the metod retuns -1.
1159   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1160   */   */
# Line 946  Int_t TrkTrack::GetSensor(int ip){ Line 1177  Int_t TrkTrack::GetSensor(int ip){
1177  /**  /**
1178   * \brief Method to include a x-cluster to the track.   * \brief Method to include a x-cluster to the track.
1179   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1180   * @param clid Cluster ID (0,1,...)   * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise )
1181   * @param is Sensor (0-1, increasing y)   * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit)
1182     * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit)
1183     * @param bad True if the cluster contains bad strips  
1184   * @see Fit(double pfixed, int& fail, int iprint, int froml1)   * @see Fit(double pfixed, int& fail, int iprint, int froml1)
1185   */   */
1186  void TrkTrack::SetXGood(int ip, int clid, int is){  void TrkTrack::SetXGood(int ip, int clid, int il, int is, bool bad){
1187      int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1188      bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1189      xgood[ip]=il*100000000+is*10000000+clid;      if(ip<0||ip>5||clid<1||il<-1||il>2||is<-1||is>1)
1190            cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1191        xgood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1192      if(bad)xgood[ip]=-xgood[ip];      if(bad)xgood[ip]=-xgood[ip];
1193  };  };
1194  /**  /**
1195   * \brief Method to include a y-cluster to the track.   * \brief Method to include a y-cluster to the track.
1196   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1197   * @param clid Cluster ID (0,1,...)   * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise )
1198   * @param is Sensor (0-1)   * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit)
1199     * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit)
1200     * @param bad True if the cluster contains bad strips  
1201   * @see Fit(double pfixed, int& fail, int iprint, int froml1)   * @see Fit(double pfixed, int& fail, int iprint, int froml1)
1202   */   */
1203  void TrkTrack::SetYGood(int ip, int clid, int is){  void TrkTrack::SetYGood(int ip, int clid, int il, int is, bool bad){
1204      int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1205      bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1206      ygood[ip]=il*100000000+is*10000000+clid;      if(ip<0||ip>5||clid<1||il<-1||il>2||is<-1||is>1)
1207            cout << " void TrkTrack::SetYGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1208        ygood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1209      if(bad)ygood[ip]=-ygood[ip];      if(bad)ygood[ip]=-ygood[ip];
1210  };  };
1211    
# Line 1069  Float_t TrkTrack::GetDEDX_max(int ip, in Line 1308  Float_t TrkTrack::GetDEDX_max(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)>max)max=GetDEDX(i,j);              if(j==0 && XGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j);
1313                if(j==1 && YGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j);
1314            }
1315      return max;      return max;
1316    
1317  };  };
# Line 1094  Float_t TrkTrack::GetDEDX_min(int ip, in Line 1334  Float_t TrkTrack::GetDEDX_min(int ip, in
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(GetDEDX(i,j)<min)min=GetDEDX(i,j);              if(j==0 && XGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j);
1339                if(j==1 && YGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j);
1340            }
1341      return min;      return min;
1342    
1343  };  };
1344    
1345  /**  /**
1346   * \brief Give the maximum spatial residual release   * \brief Give the maximum spatial residual  
1347   */   */
1348  Float_t TrkTrack::GetResidual_max(int ip, int iv){  Float_t TrkTrack::GetResidual_max(int ip, int iv){
1349      Float_t max=0;      Float_t max=0;
# Line 1119  Float_t TrkTrack::GetResidual_max(int ip Line 1360  Float_t TrkTrack::GetResidual_max(int ip
1360          vto   = iv+1;          vto   = iv+1;
1361      }      }
1362      for(int i=pfrom; i<pto; i++){      for(int i=pfrom; i<pto; i++){
1363          for(int j=0; j<vto; j++){          for(int j=vfrom; j<vto; j++){
1364              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];
1365              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];
1366          }          }
1367      }      }
1368      return max;      return max;
1369    
1370  };  };
1371    /**
1372     * \brief Give the anerage spatial residual
1373     */
1374    Float_t TrkTrack::GetResidual_av(int ip, int iv){
1375        //
1376    //Sum$((xm>-50)*(xm-xv)/resx)/sqrt(TrkTrack.GetNX()*TrkTrack.GetChi2X())<0.3
1377    
1378        Float_t av  = 0.;
1379        int     nav = 0;
1380        //
1381        int pfrom = 0;
1382        int pto   = 6;
1383        int vfrom = 0;
1384        int vto   = 2;
1385        if(ip>=0&&ip<6){
1386            pfrom = ip;
1387            pto   = ip+1;
1388        }
1389        if(iv>=0&&iv<2){
1390            vfrom = iv;
1391            vto   = iv+1;
1392        }
1393        for(int i=pfrom; i<pto; i++){
1394            for(int j=vfrom; j<vto; j++){
1395                nav++;
1396                if(j==0 && XGood(i)) av += (xm[i]-xv[i])/resx[i];
1397                if(j==1 && YGood(i)) av += (ym[i]-yv[i])/resy[i];
1398            }
1399        }
1400        if(nav==0)return -100.;
1401        return av/nav;
1402    
1403    };
1404    
1405    
1406  /**  /**
# Line 1219  void TrkTrack::Clear(){ Line 1493  void TrkTrack::Clear(){
1493          dedx_y[ip] = 0;          dedx_y[ip] = 0;
1494    
1495      };      };
1496        int ngf = TrkParams::nGF;
1497        for(int i=0; i<ngf; i++){
1498            xGF[i] = 0.;
1499            yGF[i] = 0.;
1500        }
1501  //     if(clx)clx->Clear();  //     if(clx)clx->Clear();
1502  //     if(cly)cly->Clear();  //     if(cly)cly->Clear();
1503  //    clx.Clear();  //    clx.Clear();
# Line 1245  void TrkTrack::Delete(){ Line 1524  void TrkTrack::Delete(){
1524  //--------------------------------------  //--------------------------------------
1525  TrkSinglet::TrkSinglet(){  TrkSinglet::TrkSinglet(){
1526  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;
1527      plane    = 0;  //     plane    = 0;
1528      coord[0] = 0;  //     coord[0] = 0;
1529      coord[1] = 0;  //     coord[1] = 0;
1530      sgnl     = 0;  //     sgnl     = 0;
1531    //     multmax  = 0;
1532  //    cls      = 0;  //    cls      = 0;
1533        Clear();
1534  };  };
1535  //--------------------------------------  //--------------------------------------
1536  //  //
# Line 1261  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1542  TrkSinglet::TrkSinglet(const TrkSinglet&
1542      coord[0] = s.coord[0];      coord[0] = s.coord[0];
1543      coord[1] = s.coord[1];      coord[1] = s.coord[1];
1544      sgnl     = s.sgnl;      sgnl     = s.sgnl;
1545        multmax  = s.multmax;
1546  //      cls      = 0;//<<<<pointer  //      cls      = 0;//<<<<pointer
1547  //    cls      = TRef(s.cls);  //    cls      = TRef(s.cls);
1548  };  };
# Line 1271  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1553  TrkSinglet::TrkSinglet(const TrkSinglet&
1553  void TrkSinglet::Dump(){  void TrkSinglet::Dump(){
1554      int i=0;      int i=0;
1555      cout << endl << "========== Singlet " ;      cout << endl << "========== Singlet " ;
1556      cout << endl << "plane    : " << plane;      cout << endl << "plane        : " << plane;
1557      cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++;      cout << endl << "coord[2]     : "; while( i<2 && cout << coord[i] << " ") i++;
1558      cout << endl << "sgnl     : " << sgnl;      cout << endl << "sgnl         : " << sgnl;
1559        cout << endl << "max.strip    : ";
1560        cout << endl << "multiplicity : ";
1561  }  }
1562  //--------------------------------------  //--------------------------------------
1563  //  //
# Line 1286  void TrkSinglet::Clear(){ Line 1570  void TrkSinglet::Clear(){
1570      coord[0]=-999;      coord[0]=-999;
1571      coord[1]=-999;      coord[1]=-999;
1572      sgnl=0;      sgnl=0;
1573        multmax  = 0;
1574            
1575  }  }
1576  //--------------------------------------  //--------------------------------------
# Line 1317  void TrkLevel2::Set(){ Line 1602  void TrkLevel2::Set(){
1602  //  //
1603  //  //
1604  //--------------------------------------  //--------------------------------------
1605    void TrkLevel2::SetTrackArray(TClonesArray *track){
1606        if(track && strcmp(track->GetClass()->GetName(),"TrkTrack")==0){
1607            if(Track)Track->Clear("C");    
1608            Track = track;
1609        }
1610    }
1611    //--------------------------------------
1612    //
1613    //
1614    //--------------------------------------
1615  void TrkLevel2::Dump(){  void TrkLevel2::Dump(){
1616                    
1617          //          //
# Line 1396  Bool_t TrkLevel2::GetVKFlag(int iv, int Line 1691  Bool_t TrkLevel2::GetVKFlag(int iv, int
1691   * forced (see TrkLevel2::GetVKMask(int,int)) or   * forced (see TrkLevel2::GetVKMask(int,int)) or
1692   * for this event only (TrkLevel2::GetVKFlag(int,int)).   * for this event only (TrkLevel2::GetVKFlag(int,int)).
1693   * @param iv Tracker view (0-11)   * @param iv Tracker view (0-11)
1694   * @param ivk Viking-chip number (0-23)   * @param ivk Viking-chip number (0-23)
1695   */   */
1696  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){
1697      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );
# Line 1492  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1787  void TrkLevel2::SetFromLevel2Struct(cTrk
1787              //-----------------------------------------------------              //-----------------------------------------------------
1788              //-----------------------------------------------------              //-----------------------------------------------------
1789          };          };
1790            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1791            // evaluated coordinates (to define GF)
1792            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1793            int    ngf = TrkParams::nGF;
1794            float *zgf = TrkParams::zGF;
1795            Trajectory tgf = Trajectory(ngf,zgf);
1796            tgf.DoTrack(t_track->al);//<<<< integrate the trajectory
1797            for(int ip=0; ip<ngf; ip++){
1798                t_track->xGF[ip] = tgf.x[ip];
1799                t_track->yGF[ip] = tgf.y[ip];
1800            }
1801            
1802  //      if(t_track->IsSaturated())t_track->Dump();  //      if(t_track->IsSaturated())t_track->Dump();
1803          new(t[i]) TrkTrack(*t_track);          new(t[i]) TrkTrack(*t_track);
1804          t_track->Clear();          t_track->Clear();
1805      };      };//end loop over track
1806    
1807  //  ----------------  //  ----------------
1808  //  *** SINGLETS ***  //  *** SINGLETS ***
# Line 1507  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1814  void TrkLevel2::SetFromLevel2Struct(cTrk
1814          t_singlet->coord[0] = l2->xs[i][0];          t_singlet->coord[0] = l2->xs[i][0];
1815          t_singlet->coord[1] = l2->xs[i][1];          t_singlet->coord[1] = l2->xs[i][1];
1816          t_singlet->sgnl     = l2->signlxs[i];          t_singlet->sgnl     = l2->signlxs[i];
1817            t_singlet->multmax = l2->multmaxsx[i];
1818            if(l2->sxbad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1819          //-----------------------------------------------------          //-----------------------------------------------------
1820  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);
1821          //-----------------------------------------------------          //-----------------------------------------------------
# Line 1520  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1829  void TrkLevel2::SetFromLevel2Struct(cTrk
1829          t_singlet->coord[0] = l2->ys[i][0];          t_singlet->coord[0] = l2->ys[i][0];
1830          t_singlet->coord[1] = l2->ys[i][1];          t_singlet->coord[1] = l2->ys[i][1];
1831          t_singlet->sgnl     = l2->signlys[i];          t_singlet->sgnl     = l2->signlys[i];
1832            t_singlet->multmax  = l2->multmaxsy[i];
1833            if(l2->sybad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1834          //-----------------------------------------------------          //-----------------------------------------------------
1835  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);
1836          //-----------------------------------------------------          //-----------------------------------------------------
1837          new(sy[i]) TrkSinglet(*t_singlet);          new(sy[i]) TrkSinglet(*t_singlet);
1838          t_singlet->Clear();          t_singlet->Clear();
1839      };      };
1840    
1841    
1842                    
1843      delete t_track;      delete t_track;
1844      delete t_singlet;      delete t_singlet;
# Line 1638  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1951  TRefArray *TrkLevel2::GetTracks_NFitSort
1951    
1952      if(!Track)return 0;      if(!Track)return 0;
1953    
1954      TRefArray *sorted = new TRefArray();      //    TRefArray *sorted = new TRefArray();
1955        TRefArray *sorted = NULL;
1956                    
1957      TClonesArray &t  = *Track;      TClonesArray &t  = *Track;
1958  //    TClonesArray &ts = *PhysicalTrack;  //    TClonesArray &ts = *PhysicalTrack;
# Line 1676  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1990  TRefArray *TrkLevel2::GetTracks_NFitSort
1990                    
1991  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;
1992          };          };
1993            if(!sorted)sorted = new TRefArray( TProcessID::GetProcessWithUID(t[indi]));
1994          sorted->Add( (TrkTrack*)t[indi] );                sorted->Add( (TrkTrack*)t[indi] );      
1995                                    
1996          m[indi] = 0;          m[indi] = 0;
# Line 1846  void TrkLevel2::LoadField(TString path){ Line 2161  void TrkLevel2::LoadField(TString path){
2161    
2162      TrkParams::Set(path,1);      TrkParams::Set(path,1);
2163      TrkParams::Load(1);      TrkParams::Load(1);
2164        if( !TrkParams::IsLoaded(1) ){
2165            cout << "void TrkLevel2::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl;
2166        }
2167    
2168  //  //
2169  };  };
# Line 1904  Float_t TrkLevel2::GetZTrk(Int_t plane_i Line 2222  Float_t TrkLevel2::GetZTrk(Int_t plane_i
2222   * (By default is created with z-coordinates inside the tracking volume)   * (By default is created with z-coordinates inside the tracking volume)
2223    */    */
2224  Trajectory::Trajectory(){  Trajectory::Trajectory(){
2225      npoint = 10;      npoint = 6;
2226      x = new float[npoint];      x = new float[npoint];
2227      y = new float[npoint];      y = new float[npoint];
2228      z = new float[npoint];      z = new float[npoint];
# Line 1971  Trajectory::Trajectory(int n, float* zin Line 2289  Trajectory::Trajectory(int n, float* zin
2289      thy = new float[npoint];      thy = new float[npoint];
2290      tl = new float[npoint];      tl = new float[npoint];
2291      int i=0;      int i=0;
2292      do{      do{      
2293          x[i] = 0;          x[i] = 0.;
2294          y[i] = 0;          y[i] = 0.;
2295          z[i] = zin[i];          z[i] = zin[i];
2296          thx[i] = 0;          thx[i] = 0.;
2297          thy[i] = 0;          thy[i] = 0.;
2298          tl[i] = 0;          tl[i] = 0.;
2299          i++;                      i++;            
2300      }while(zin[i-1] > zin[i] && i < npoint);      }while(zin[i-1] > zin[i] && i < npoint);
2301      npoint=i;      npoint=i;
2302      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;
2303        //    Dump();
2304  }  }
2305  void Trajectory::Delete(){  void Trajectory::Delete(){
2306            
# Line 2033  float Trajectory::GetLength(int ifirst, Line 2352  float Trajectory::GetLength(int ifirst,
2352    
2353  /**  /**
2354   * Evaluates the trajectory in the apparatus associated to the track.   * Evaluates the trajectory in the apparatus associated to the track.
2355   * 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.
2356   * @param t pointer to an object of the class Trajectory,   * @param al Track state-vector (X0,Y0,sin(theta),phi,deflection).
2357   * 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).
2358   * @return error flag.   * @return error flag.
2359   */   *
2360  int Trajectory::DoTrack2(float* al){   * This method is needed when you want to integrate the particle trajectory
2361     * starting from a track state-vector relative to an arbitrary reference plane.
2362      double *dxout   = new double[npoint];   * The default reference plane, used by the tracker routines, is at zini=23.5.
2363      double *dyout   = new double[npoint];   * If you give as input the track state-vector from a TrkTrack object,
2364      double *dthxout = new double[npoint];   * you can use Trajectory::DoTrack(float* al) instead.
2365      double *dthyout = new double[npoint];   */
2366      double *dtlout  = new double[npoint];  int Trajectory::DoTrack(float* al, float zini){
2367      double *dzin    = new double[npoint];  
2368    //      double *dxout   = new double[npoint];
2369    //      double *dyout   = new double[npoint];
2370    //      double *dthxout = new double[npoint];
2371    //      double *dthyout = new double[npoint];
2372    //      double *dtlout  = new double[npoint];
2373    //      double *dzin    = new double[npoint];
2374        
2375        double *dxout;
2376        double *dyout;
2377        double *dthxout;
2378        double *dthyout;
2379        double *dtlout;
2380        double *dzin;
2381        
2382        dxout   = (double*) malloc(npoint*sizeof(double));
2383        dyout   = (double*) malloc(npoint*sizeof(double));
2384        dthxout = (double*) malloc(npoint*sizeof(double));
2385        dthyout = (double*) malloc(npoint*sizeof(double));
2386        dtlout  = (double*) malloc(npoint*sizeof(double));
2387        dzin    = (double*) malloc(npoint*sizeof(double));
2388        
2389      double dal[5];      double dal[5];
2390    
2391      int ifail = 0;      double dzini = (double)zini;
2392    
2393        int ifail = 0;
2394        
2395      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];
2396      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];
2397    
2398      TrkParams::Load(1);      TrkParams::Load(1);
2399      if( !TrkParams::IsLoaded(1) ){      if( !TrkParams::IsLoaded(1) ){
2400          cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl;          cout << "int Trajectory::DoTrack(float* al) --- ERROR --- m.field not loaded"<<endl;
2401          return 0;          return 0;
2402      }      }
2403      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);  //    dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
2404        dotrack3_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&dzini,&ifail);
2405            
2406      for (int i=0; i<npoint; i++){      for (int i=0; i<npoint; i++){
2407          x[i]   = (float)*dxout++;          x[i]   = (float)*(dxout+i);
2408          y[i]   = (float)*dyout++;          y[i]   = (float)*(dyout+i);
2409          thx[i] = (float)*dthxout++;          thx[i] = (float)*(dthxout+i);
2410          thy[i] = (float)*dthyout++;          thy[i] = (float)*(dthyout+i);
2411          tl[i]  = (float)*dtlout++;          tl[i]  = (float)*(dtlout+i);
2412      }      }
2413    
2414        if(dxout)  free( dxout );
2415        if(dyout)  free( dyout );
2416        if(dthxout)free( dthxout );
2417        if(dthyout)free( dthyout );
2418        if(dtlout) free( dtlout );
2419        if(dzin)   free( dzin );
2420    
2421    //      delete [] dxout;
2422    //      delete [] dyout;
2423    //      delete [] dthxout;
2424    //      delete [] dthyout;
2425    //      delete [] dtlout;
2426    //      delete [] dzin;
2427    
2428    
2429      return ifail;      return ifail;
2430  };  };
2431    
2432    /**
2433     *
2434     * >>> OBSOLETE !!! use Trajectory::DoTrack(float* al, float zini) instead
2435     *
2436     */
2437    int Trajectory::DoTrack2(float* al, float zini){
2438    
2439        cout << endl;
2440        cout << " int Trajectory::DoTrack2(float* al, float zini) --->> NB NB !! this method is going to be eliminated !!! "<<endl;
2441        cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl;
2442        cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl;
2443        cout << endl;
2444    
2445        return DoTrack(al,zini);
2446    
2447    };
2448    
2449    
2450    
2451  ClassImp(TrkLevel2);  ClassImp(TrkLevel2);
2452  ClassImp(TrkSinglet);  ClassImp(TrkSinglet);
2453  ClassImp(TrkTrack);  ClassImp(TrkTrack);

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

  ViewVC Help
Powered by ViewVC 1.1.23