/[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.51 by pam-fi, Fri Dec 5 08:30:27 2008 UTC revision 1.53 by pam-fi, Tue Feb 3 13:57:15 2009 UTC
# Line 12  using namespace std; Line 12  using namespace std;
12  extern "C" {      extern "C" {    
13      void dotrack_(int*, double*, double*, double*, double*, int*);      void dotrack_(int*, double*, double*, double*, double*, int*);
14      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);      void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);
15        void dotrack3_(int*, double*, double*, double*, double*,double*, double*, double*,double*,int*);
16      void mini2_(int*,int*,int*);      void mini2_(int*,int*,int*);
17      void guess_();      void guess_();
18      void gufld_(float*, float*);      void gufld_(float*, float*);
# Line 177  void TrkTrack::Copy(TrkTrack& t){ Line 178  void TrkTrack::Copy(TrkTrack& t){
178  //  //
179  //--------------------------------------  //--------------------------------------
180  /**  /**
  * Evaluates the trajectory in the apparatus associated to the track.  
  * It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling  TrkLevel2::LoadField() ), otherwise an error message is returned.    
  * @param t pointer to an object of the class Trajectory,  
  * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ).  
  * @return error flag.  
181   *   *
182   * >>> OBSOLETE !!! use TrkTrack::DoTrack2(Trajectory* t) instead   * >>> OBSOLETE !!! use TrkTrack::DoTrack(Trajectory* t) instead
183   *   *
184   */   */
185  int TrkTrack::DoTrack(Trajectory* t){  int TrkTrack::DoTrack2(Trajectory* t){
   
     cout << " int TrkTrack::DoTrack(Trajectory* t) --->> OBSOLETE !!! "<<endl;  
     cout << " use int TrkTrack::DoTrack2(Trajectory* t)"<<endl;  
   
     double *dxout = new double[t->npoint];  
     double *dyout = new double[t->npoint];  
     double *dzin = new double[t->npoint];  
     double dal[5];  
   
     int ifail = 0;  
   
     for (int i=0; i<5; i++)         dal[i]  = (double)al[i];  
     for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i];  
186    
187      TrkParams::Load(1);      cout << endl;
188      if( !TrkParams::IsLoaded(1) ){      cout << " int TrkTrack::DoTrack2(Trajectory* t) --->> NB NB !! this method is going to be eliminated !!! "<<endl;
189          cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl;      cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl;
190          return 0;      cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl;
191      }      cout << endl;
     dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail);  
       
     for (int i=0; i<t->npoint; i++){  
         t->x[i] = (float)*(dxout+i);  
         t->y[i] = (float)*(dyout+i);  
     }  
192    
193      delete [] dxout;      return DoTrack(t);
     delete [] dyout;  
     delete [] dzin;  
194    
     return ifail;  
195  };  };
196  //--------------------------------------  //--------------------------------------
197  //  //
198  //  //
199  //--------------------------------------  //--------------------------------------
200  /**  /**
201   * Evaluates the trajectory in the apparatus associated to the track.   * Evaluates the trajectory in the apparatus associated to the track state-vector.
202   * It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling  TrkLevel2::LoadField() ), otherwise an error message is returned.     * It integrates the equations of motion in the magnetic field.
203   * @param t pointer to an object of the class Trajectory,   * @param t pointer to an object of the class Trajectory,
204   * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ).   * which z coordinates should be previously assigned.
205   * @return error flag.   * @return error flag.
206   */   */
207  int TrkTrack::DoTrack2(Trajectory* t){  int TrkTrack::DoTrack(Trajectory* t){
208    
209      double *dxout   = new double[t->npoint];      double *dxout   = new double[t->npoint];
210      double *dyout   = new double[t->npoint];      double *dyout   = new double[t->npoint];
# Line 247  int TrkTrack::DoTrack2(Trajectory* t){ Line 221  int TrkTrack::DoTrack2(Trajectory* t){
221    
222      TrkParams::Load(1);      TrkParams::Load(1);
223      if( !TrkParams::IsLoaded(1) ){      if( !TrkParams::IsLoaded(1) ){
224          cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl;          cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl;
225          return 0;          return 0;
226      }      }
227      dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);      dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
# Line 818  Bool_t TrkTrack::EvaluateClusterPosition Line 792  Bool_t TrkTrack::EvaluateClusterPosition
792            
793  //     cout << "void TrkTrack::GetClusterositions() "<<endl;  //     cout << "void TrkTrack::GetClusterositions() "<<endl;
794    
795      bool OK=true;      TrkParams::Load(1);
796      TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl;      if( !TrkParams::IsLoaded(1) ){
797      TrkParams::Load(4); if( !TrkParams::IsLoaded(4) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl;          cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl;
798      TrkParams::Load(5); if( !TrkParams::IsLoaded(5) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl;          return false;
799      if(!OK)return false;      }    
800        TrkParams::Load(4);
801        if( !TrkParams::IsLoaded(4) ){
802            cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl;
803            return false;
804        }
805        TrkParams::Load(5);
806        if( !TrkParams::IsLoaded(5) ){
807            cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl;
808            return false;
809        }
810    
811      for(int ip=0; ip<6; ip++){      for(int ip=0; ip<6; ip++){
812  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;
# Line 875  Bool_t TrkTrack::EvaluateClusterPosition Line 859  Bool_t TrkTrack::EvaluateClusterPosition
859   */   */
860  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){
861    
862      bool OK=true;      TrkParams::Load(1);
863      TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl;      if( !TrkParams::IsLoaded(1) ){
864      if(!OK)return;          cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl;
865            return;
866        }
867        TrkParams::Load(5);
868        if( !TrkParams::IsLoaded(5) ){
869            cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- align.param. not loaded "<<endl;
870            return;
871        }
872    
873      float al_ini[] = {0.,0.,0.,0.,0.};      float al_ini[] = {0.,0.,0.,0.,0.};
874    
# Line 1690  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1681  void TrkLevel2::SetFromLevel2Struct(cTrk
1681          int    ngf = TrkParams::nGF;          int    ngf = TrkParams::nGF;
1682          float *zgf = TrkParams::zGF;          float *zgf = TrkParams::zGF;
1683          Trajectory tgf = Trajectory(ngf,zgf);          Trajectory tgf = Trajectory(ngf,zgf);
1684          tgf.DoTrack2(t_track->al);//<<<< integrate the trajectory          tgf.DoTrack(t_track->al);//<<<< integrate the trajectory
1685          for(int ip=0; ip<ngf; ip++){          for(int ip=0; ip<ngf; ip++){
1686              t_track->xGF[ip] = tgf.x[ip];              t_track->xGF[ip] = tgf.x[ip];
1687              t_track->yGF[ip] = tgf.y[ip];              t_track->yGF[ip] = tgf.y[ip];
# Line 1848  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1839  TRefArray *TrkLevel2::GetTracks_NFitSort
1839    
1840      if(!Track)return 0;      if(!Track)return 0;
1841    
1842      TRefArray *sorted = new TRefArray();      //    TRefArray *sorted = new TRefArray();
1843        TRefArray *sorted = NULL;
1844                    
1845      TClonesArray &t  = *Track;      TClonesArray &t  = *Track;
1846  //    TClonesArray &ts = *PhysicalTrack;  //    TClonesArray &ts = *PhysicalTrack;
# Line 1886  TRefArray *TrkLevel2::GetTracks_NFitSort Line 1878  TRefArray *TrkLevel2::GetTracks_NFitSort
1878                    
1879  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;  //          cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl;
1880          };          };
1881            if(!sorted)sorted = new TRefArray( TProcessID::GetProcessWithUID(t[indi]));
1882          sorted->Add( (TrkTrack*)t[indi] );                sorted->Add( (TrkTrack*)t[indi] );      
1883                                    
1884          m[indi] = 0;          m[indi] = 0;
# Line 2246  float Trajectory::GetLength(int ifirst, Line 2239  float Trajectory::GetLength(int ifirst,
2239    
2240  /**  /**
2241   * Evaluates the trajectory in the apparatus associated to the track.   * Evaluates the trajectory in the apparatus associated to the track.
2242   * 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.
2243   * @param t pointer to an object of the class Trajectory,   * @param al Track state-vector (X0,Y0,sin(theta),phi,deflection).
2244   * 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).
2245   * @return error flag.   * @return error flag.
2246     *
2247     * This method is needed when you want to integrate the particle trajectory
2248     * starting from a track state-vector relative to an arbitrary reference plane.
2249     * The default reference plane, used by the tracker routines, is at zini=23.5.
2250     * If you give as input the track state-vector from a TrkTrack object,
2251     * you can use Trajectory::DoTrack(float* al) instead.
2252   */   */
2253  int Trajectory::DoTrack2(float* al){  int Trajectory::DoTrack(float* al, float zini){
2254    
2255  //      double *dxout   = new double[npoint];  //      double *dxout   = new double[npoint];
2256  //      double *dyout   = new double[npoint];  //      double *dyout   = new double[npoint];
# Line 2260  int Trajectory::DoTrack2(float* al){ Line 2259  int Trajectory::DoTrack2(float* al){
2259  //      double *dtlout  = new double[npoint];  //      double *dtlout  = new double[npoint];
2260  //      double *dzin    = new double[npoint];  //      double *dzin    = new double[npoint];
2261            
2262       double *dxout;      double *dxout;
2263       double *dyout;      double *dyout;
2264       double *dthxout;      double *dthxout;
2265       double *dthyout;      double *dthyout;
2266       double *dtlout;      double *dtlout;
2267       double *dzin;      double *dzin;
2268        
2269       dxout   = (double*) malloc(npoint*sizeof(double));      dxout   = (double*) malloc(npoint*sizeof(double));
2270       dyout   = (double*) malloc(npoint*sizeof(double));      dyout   = (double*) malloc(npoint*sizeof(double));
2271       dthxout = (double*) malloc(npoint*sizeof(double));      dthxout = (double*) malloc(npoint*sizeof(double));
2272       dthyout = (double*) malloc(npoint*sizeof(double));      dthyout = (double*) malloc(npoint*sizeof(double));
2273       dtlout  = (double*) malloc(npoint*sizeof(double));      dtlout  = (double*) malloc(npoint*sizeof(double));
2274       dzin    = (double*) malloc(npoint*sizeof(double));      dzin    = (double*) malloc(npoint*sizeof(double));
2275        
2276        double dal[5];
2277    
2278       double dal[5];      double dzini = (double)zini;
2279    
2280      int ifail = 0;      int ifail = 0;
2281        
2282      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];      for (int i=0; i<5; i++)      dal[i]  = (double)al[i];
2283      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];      for (int i=0; i<npoint; i++) dzin[i] = (double)z[i];
2284    
2285      TrkParams::Load(1);      TrkParams::Load(1);
2286      if( !TrkParams::IsLoaded(1) ){      if( !TrkParams::IsLoaded(1) ){
2287          cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl;          cout << "int Trajectory::DoTrack(float* al) --- ERROR --- m.field not loaded"<<endl;
2288          return 0;          return 0;
2289      }      }
2290      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);  //    dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
2291        dotrack3_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&dzini,&ifail);
2292            
2293      for (int i=0; i<npoint; i++){      for (int i=0; i<npoint; i++){
2294          x[i]   = (float)*(dxout+i);          x[i]   = (float)*(dxout+i);
# Line 2314  int Trajectory::DoTrack2(float* al){ Line 2316  int Trajectory::DoTrack2(float* al){
2316      return ifail;      return ifail;
2317  };  };
2318    
2319    /**
2320     *
2321     * >>> OBSOLETE !!! use Trajectory::DoTrack(float* al, float zini) instead
2322     *
2323     */
2324    int Trajectory::DoTrack2(float* al, float zini){
2325    
2326        cout << endl;
2327        cout << " int Trajectory::DoTrack2(float* al, float zini) --->> NB NB !! this method is going to be eliminated !!! "<<endl;
2328        cout << " >>>> replace it with TrkTrack::DoTrack(Trajectory* t) <<<<"<<endl;
2329        cout << " (Sorry Wolfgang!! Don't be totally confused!! By Elena)"<<endl;
2330        cout << endl;
2331    
2332        return DoTrack(al,zini);
2333    
2334    };
2335    
2336    
2337    
2338  ClassImp(TrkLevel2);  ClassImp(TrkLevel2);
2339  ClassImp(TrkSinglet);  ClassImp(TrkSinglet);
2340  ClassImp(TrkTrack);  ClassImp(TrkTrack);

Legend:
Removed from v.1.51  
changed lines
  Added in v.1.53

  ViewVC Help
Powered by ViewVC 1.1.23