/[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.48 by bongi, Thu Nov 20 15:06:26 2008 UTC
# Line 60  TrkTrack::TrkTrack(){ Line 60  TrkTrack::TrkTrack(){
60          ypu[ip]    = 0;            ypu[ip]    = 0;  
61    
62      };      };
63        
64  //     TrkParams::SetTrackingMode();  //     TrkParams::SetTrackingMode();
65  //     TrkParams::SetPrecisionFactor();  //     TrkParams::SetPrecisionFactor();
66  //     TrkParams::SetStepMin();  //     TrkParams::SetStepMin();
67      TrkParams::SetMiniDefault();      TrkParams::SetMiniDefault();
68      TrkParams::SetPFA();      TrkParams::SetPFA();
69    
70        int ngf = TrkParams::nGF;
71        for(int i=0; i<ngf; i++){
72            xGF[i] = 0.;
73            yGF[i] = 0.;
74        }
75    
76    
77  };  };
78  //--------------------------------------  //--------------------------------------
79  //  //
# Line 112  TrkTrack::TrkTrack(const TrkTrack& t){ Line 119  TrkTrack::TrkTrack(const TrkTrack& t){
119      TrkParams::SetMiniDefault();      TrkParams::SetMiniDefault();
120      TrkParams::SetPFA();      TrkParams::SetPFA();
121    
122        int ngf = TrkParams::nGF;
123        for(int i=0; i<ngf; i++){
124            xGF[i] = t.xGF[i];
125            yGF[i] = t.yGF[i];
126        }
127  };  };
128  //--------------------------------------  //--------------------------------------
129  //  //
# Line 152  void TrkTrack::Copy(TrkTrack& t){ Line 164  void TrkTrack::Copy(TrkTrack& t){
164          t.ypu[ip]      = ypu[ip];            t.ypu[ip]      = ypu[ip];  
165                            
166      };      };
167        int ngf = TrkParams::nGF;
168        for(int i=0; i<ngf; i++){
169            t.xGF[i] = xGF[i];
170            t.yGF[i] = yGF[i];
171        }
172    
173            
174  };  };
# Line 165  void TrkTrack::Copy(TrkTrack& t){ Line 182  void TrkTrack::Copy(TrkTrack& t){
182   * @param t pointer to an object of the class Trajectory,   * @param t pointer to an object of the class Trajectory,
183   * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ).   * which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ).
184   * @return error flag.   * @return error flag.
185     *
186     * >>> OBSOLETE !!! use TrkTrack::DoTrack2(Trajectory* t) instead
187     *
188   */   */
189  int TrkTrack::DoTrack(Trajectory* t){  int TrkTrack::DoTrack(Trajectory* t){
190    
191        cout << " int TrkTrack::DoTrack(Trajectory* t) --->> OBSOLETE !!! "<<endl;
192        cout << " use int TrkTrack::DoTrack2(Trajectory* t)"<<endl;
193    
194      double *dxout = new double[t->npoint];      double *dxout = new double[t->npoint];
195      double *dyout = new double[t->npoint];      double *dyout = new double[t->npoint];
196      double *dzin = new double[t->npoint];      double *dzin = new double[t->npoint];
# Line 186  int TrkTrack::DoTrack(Trajectory* t){ Line 209  int TrkTrack::DoTrack(Trajectory* t){
209      dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail);      dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail);
210            
211      for (int i=0; i<t->npoint; i++){      for (int i=0; i<t->npoint; i++){
212          t->x[i] = (float)*dxout++;          t->x[i] = (float)*(dxout+i);
213          t->y[i] = (float)*dyout++;          t->y[i] = (float)*(dyout+i);
214      }      }
215    
216  //    delete [] dxout;      delete [] dxout;
217  //    delete [] dyout;      delete [] dyout;
218  //    delete [] dzin;      delete [] dzin;
219    
220      return ifail;      return ifail;
221  };  };
# Line 230  int TrkTrack::DoTrack2(Trajectory* t){ Line 253  int TrkTrack::DoTrack2(Trajectory* t){
253      dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);      dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
254            
255      for (int i=0; i<t->npoint; i++){      for (int i=0; i<t->npoint; i++){
256          t->x[i]   = (float)*dxout++;          t->x[i]   = (float)*(dxout+i);
257          t->y[i]   = (float)*dyout++;          t->y[i]   = (float)*(dyout+i);
258          t->thx[i] = (float)*dthxout++;          t->thx[i] = (float)*(dthxout+i);
259          t->thy[i] = (float)*dthyout++;          t->thy[i] = (float)*(dthyout+i);
260          t->tl[i]  = (float)*dtlout++;          t->tl[i]  = (float)*(dtlout+i);
261      }      }
262    
263  //    delete [] dxout;      delete [] dxout;
264  //    delete [] dyout;      delete [] dyout;
265  //    delete [] dzin;      delete [] dzin;
266        delete [] dthxout;
267        delete [] dthyout;
268        delete [] dtlout;
269    
270      return ifail;      return ifail;
271  };  };
# Line 299  Float_t TrkTrack::GetDEDX(){ Line 325  Float_t TrkTrack::GetDEDX(){
325      return dedx;      return dedx;
326  };  };
327  /**  /**
328   * Returns 1 if the cluster on a tracker view includes bad strips.   * Returns 1 if the cluster on a tracker view includes bad strips
329     * (at least one bad strip among the four strip used by p.f.a.)
330   * @param ip plane (0-5)   * @param ip plane (0-5)
331   * @param iv view (0=x 1=y)   * @param iv view (0=x 1=y)
332   */   */
# Line 630  void TrkTrack::LoadField(TString path){ Line 657  void TrkTrack::LoadField(TString path){
657    
658      TrkParams::Set(path,1);      TrkParams::Set(path,1);
659      TrkParams::Load(1);      TrkParams::Load(1);
660        if( !TrkParams::IsLoaded(1) ){
661            cout << "void TrkTrack::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl;
662        }
663    
664  };  };
665    
# Line 651  void TrkTrack::FillMiniStruct(cMini2trac Line 681  void TrkTrack::FillMiniStruct(cMini2trac
681          track.zm[i]=zm[i];          track.zm[i]=zm[i];
682                    
683  //      --- temporaneo ----------------------------  //      --- temporaneo ----------------------------
684  //      andrebbe inserita la dimensione del sensore  //      float segment = 100.;
685          float segment = 100.;  //      track.xm_a[i]=xm[i];
686          track.xm_a[i]=xm[i];  //      track.xm_b[i]=xm[i];
687          track.xm_b[i]=xm[i];  //      track.ym_a[i]=ym[i];
688          track.ym_a[i]=ym[i];  //      track.ym_b[i]=ym[i];
689          track.ym_b[i]=ym[i];  //      if(       XGood(i) && !YGood(i) ){
690          if(       XGood(i) && !YGood(i) ){  //          track.ym_a[i] = track.ym_a[i]+segment;
691              track.ym_a[i] = track.ym_a[i]+segment;  //          track.ym_b[i] = track.ym_b[i]-segment;
692              track.ym_b[i] = track.ym_b[i]-segment;  //      }else if( !XGood(i) && YGood(i)){
693          }else if( !XGood(i) && YGood(i)){  //          track.xm_a[i] = track.xm_a[i]+segment;
694              track.xm_a[i] = track.xm_a[i]+segment;  //          track.xm_b[i] = track.xm_b[i]-segment;
695              track.xm_b[i] = track.xm_b[i]-segment;  //      }
         }  
696  //      --- temporaneo ----------------------------  //      --- temporaneo ----------------------------
697    
698            if( XGood(i) || YGood(i) ){
699                double segment = 2.;//cm
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.;
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];
721                    gamma   = alignparameters_.gamma[is][il][ip];
722                }
723                
724                if(       XGood(i) && !YGood(i) ){
725                    track.xm_a[i] = xm[i] - omega * segment;
726                    track.ym_a[i] = ym[i] + segment;
727                    track.zm_a[i] = zm[i] + beta * segment;
728                    track.xm_b[i] = xm[i] + omega * segment;
729                    track.ym_b[i] = ym[i] - segment;
730                    track.zm_b[i] = zm[i] - beta * segment;
731                }else if( !XGood(i) && YGood(i) ){
732                    track.xm_a[i] = xm[i] + segment;
733                    track.ym_a[i] = ym[i] + omega * segment;
734                    track.zm_a[i] = zm[i] - gamma * segment;
735                    track.xm_b[i] = xm[i] - segment;
736                    track.ym_b[i] = ym[i] - omega * segment;
737                    track.zm_b[i] = zm[i] + gamma * segment;
738                }
739            }
740                    
741          track.resx[i]=resx[i];          track.resx[i]=resx[i];
742          track.resy[i]=resy[i];          track.resy[i]=resy[i];
743          track.tailx[i]=tailx[i];          track.tailx[i]=tailx[i];
744          track.taily[i]=taily[i];          track.taily[i]=taily[i];
# Line 729  Bool_t TrkTrack::EvaluateClusterPosition Line 801  Bool_t TrkTrack::EvaluateClusterPosition
801            
802  //     cout << "void TrkTrack::GetClusterositions() "<<endl;  //     cout << "void TrkTrack::GetClusterositions() "<<endl;
803    
804      TrkParams::Load( );      bool OK=true;
805      if( !TrkParams::IsLoaded() )return false;      TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- m.field not loaded "<<endl;
806            TrkParams::Load(4); if( !TrkParams::IsLoaded(4) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- p.f.a. par. not loaded "<<endl;
807        TrkParams::Load(5); if( !TrkParams::IsLoaded(5) )cout << "Bool_t TrkTrack::EvaluateClusterPositions() ---ERROR--- alignment par. not loaded "<<endl;
808        if(!OK)return false;
809    
810      for(int ip=0; ip<6; ip++){      for(int ip=0; ip<6; ip++){
811  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;  //      cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;;
812          int icx = GetClusterX_ID(ip)+1;          int icx = GetClusterX_ID(ip)+1;
# Line 783  Bool_t TrkTrack::EvaluateClusterPosition Line 858  Bool_t TrkTrack::EvaluateClusterPosition
858   */   */
859  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){  void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){
860    
861      float al_ini[] = {0.,0.,0.,0.,0.};      bool OK=true;
862        TrkParams::Load(1); if( !TrkParams::IsLoaded(1) )cout << "void TrkTrack::Fit(double,int&,int,int) ---ERROR--- m.field not loaded "<<endl;
863        if(!OK)return;
864    
865      TrkParams::Load( );      float al_ini[] = {0.,0.,0.,0.,0.};
     if( !TrkParams::IsLoaded() )return;  
866    
867      extern cMini2track track_;      extern cMini2track track_;
868      fail = 0;      fail = 0;
# Line 822  void TrkTrack::Fit(double pfixed, int& f Line 898  void TrkTrack::Fit(double pfixed, int& f
898    
899      //  ------------------------------------------      //  ------------------------------------------
900      //  call mini routine      //  call mini routine
901  //     TrkParams::Load(1);      //  ------------------------------------------
 //     if( !TrkParams::IsLoaded(1) ){  
 //      cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl;  
 //      return;  
 //     }  
902      int istep=0;      int istep=0;
903      int ifail=0;      int ifail=0;
904      mini2_(&istep,&ifail, &iprint);      mini2_(&istep,&ifail, &iprint);
# Line 890  void TrkTrack::SetDeltaB(int id, double Line 962  void TrkTrack::SetDeltaB(int id, double
962  }  }
963    
964  /**  /**
965   * Returns 1 if the track is inside the magnet cavity   * Returns true if the track is inside the magnet cavity.
966   * Set the minimum number of steps for tracking precision   * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
967   */   */
968  Bool_t TrkTrack::IsInsideCavity(){  Bool_t TrkTrack::IsInsideCavity(float toll){
969      float xmagntop, ymagntop, xmagnbottom, ymagnbottom;  
970      xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.);  //     float xmagntop, ymagntop, xmagnbottom, ymagnbottom;
971      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.);
972      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.);
973      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.);
974      if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&  //     ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.);
975          ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&  //     if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&
976          xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&  //      ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&
977          ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);  //      xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&
978      else return(false);  //      ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);
979    //     else return(false);
980    
981        int ngf = TrkParams::nGF;
982        for(int i=0; i<ngf; i++){
983            //
984    //      cout << endl << TrkParams::GF_element[i];
985            if(
986                TrkParams::GF_element[i].CompareTo("CUF") &&
987                TrkParams::GF_element[i].CompareTo("T2")  &&
988                TrkParams::GF_element[i].CompareTo("T3")  &&
989                TrkParams::GF_element[i].CompareTo("T4")  &&
990                TrkParams::GF_element[i].CompareTo("T5")  &&
991                TrkParams::GF_element[i].CompareTo("CLF") &&
992                true)continue;
993            // apply condition only within the cavity
994    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
995            if(
996                xGF[i] <= TrkParams::xGF_min[i] + toll ||
997                xGF[i] >= TrkParams::xGF_max[i] - toll ||
998                yGF[i] <= TrkParams::yGF_min[i] + toll ||
999                yGF[i] >= TrkParams::yGF_max[i] - toll ||
1000                false){
1001                
1002                return false;
1003            }
1004        }
1005        return true;
1006    
1007    
1008    }
1009    /**
1010     * Returns true if the track is inside the nominal acceptance, which is defined
1011     * by the intersection among magnet cavity, silicon-plane sensitive area and
1012     * ToF sensitive area (nominal values from the official document used to
1013     * calculate the geometrical factor)
1014     */
1015    Bool_t TrkTrack::IsInsideAcceptance(){
1016    
1017        int ngf = TrkParams::nGF;
1018        for(int i=0; i<ngf; i++){
1019            if(
1020                xGF[i] <= TrkParams::xGF_min[i] ||
1021                xGF[i] >= TrkParams::xGF_max[i] ||
1022                yGF[i] <= TrkParams::yGF_min[i] ||
1023                yGF[i] >= TrkParams::yGF_max[i] ||
1024                false)return false;
1025        }
1026        return true;
1027    
1028  }  }
1029  /**  /**
1030   * 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.
# Line 923  Int_t TrkTrack::GetClusterY_ID(int ip){ Line 1044  Int_t TrkTrack::GetClusterY_ID(int ip){
1044  };  };
1045    
1046  /**  /**
1047   * 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.
1048   * If no ladder is traversed (dead area) the metod retuns -1.   * If no ladder is traversed (dead area) the metod retuns -1.
1049   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1050   */   */
# Line 946  Int_t TrkTrack::GetSensor(int ip){ Line 1067  Int_t TrkTrack::GetSensor(int ip){
1067  /**  /**
1068   * \brief Method to include a x-cluster to the track.   * \brief Method to include a x-cluster to the track.
1069   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1070   * @param clid Cluster ID (0,1,...)   * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise )
1071   * @param is Sensor (0-1, increasing y)   * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit)
1072     * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit)
1073     * @param bad True if the cluster contains bad strips  
1074   * @see Fit(double pfixed, int& fail, int iprint, int froml1)   * @see Fit(double pfixed, int& fail, int iprint, int froml1)
1075   */   */
1076  void TrkTrack::SetXGood(int ip, int clid, int is){  void TrkTrack::SetXGood(int ip, int clid, int il, int is, bool bad){
1077      int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1078      bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1079      xgood[ip]=il*100000000+is*10000000+clid;      if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1)
1080            cout << " void TrkTrack::SetXGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1081        xgood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1082      if(bad)xgood[ip]=-xgood[ip];      if(bad)xgood[ip]=-xgood[ip];
1083  };  };
1084  /**  /**
1085   * \brief Method to include a y-cluster to the track.   * \brief Method to include a y-cluster to the track.
1086   * @param ip Tracker plane (0-5)   * @param ip Tracker plane (0-5)
1087   * @param clid Cluster ID (0,1,...)   * @param clid Cluster ID (0 = no-cluster, 1,2,... otherwise )
1088   * @param is Sensor (0-1)   * @param il Ladder (0-2, increasing x, -1 if no sensitive area is hit)
1089     * @param is Sensor (0-1, increasing y, -1 if no sensitive area is hit)
1090     * @param bad True if the cluster contains bad strips  
1091   * @see Fit(double pfixed, int& fail, int iprint, int froml1)   * @see Fit(double pfixed, int& fail, int iprint, int froml1)
1092   */   */
1093  void TrkTrack::SetYGood(int ip, int clid, int is){  void TrkTrack::SetYGood(int ip, int clid, int il, int is, bool bad){
1094      int il=0;       //ladder (temporary)  //    int il=0;       //ladder (temporary)
1095      bool bad=false; //ladder (temporary)  //    bool bad=false; //ladder (temporary)
1096      ygood[ip]=il*100000000+is*10000000+clid;      if(ip<0||ip>5||clid<0||il<-1||il>2||is<-1||is>1)
1097            cout << " void TrkTrack::SetYGood(int,int,int,int,bool) --> MA SEI DI COCCIO?!?!"<<endl;
1098        ygood[ip]=(il+1)*100000000+(is+1)*10000000+clid;
1099      if(bad)ygood[ip]=-ygood[ip];      if(bad)ygood[ip]=-ygood[ip];
1100  };  };
1101    
# Line 1069  Float_t TrkTrack::GetDEDX_max(int ip, in Line 1198  Float_t TrkTrack::GetDEDX_max(int ip, in
1198          vto   = iv+1;          vto   = iv+1;
1199      }      }
1200      for(int i=pfrom; i<pto; i++)      for(int i=pfrom; i<pto; i++)
1201          for(int j=0; j<vto; j++)          for(int j=vfrom; j<vto; j++){
1202              if(GetDEDX(i,j)>max)max=GetDEDX(i,j);              if(j==0 && XGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j);
1203                if(j==1 && YGood(i) && GetDEDX(i,j)>max)max=GetDEDX(i,j);
1204            }
1205      return max;      return max;
1206    
1207  };  };
# Line 1094  Float_t TrkTrack::GetDEDX_min(int ip, in Line 1224  Float_t TrkTrack::GetDEDX_min(int ip, in
1224          vto   = iv+1;          vto   = iv+1;
1225      }      }
1226      for(int i=pfrom; i<pto; i++)      for(int i=pfrom; i<pto; i++)
1227          for(int j=0; j<vto; j++)          for(int j=vfrom; j<vto; j++){
1228              if(GetDEDX(i,j)<min)min=GetDEDX(i,j);              if(j==0 && XGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j);
1229                if(j==1 && YGood(i) && GetDEDX(i,j)<min)min=GetDEDX(i,j);
1230            }
1231      return min;      return min;
1232    
1233  };  };
1234    
1235  /**  /**
1236   * \brief Give the maximum spatial residual release   * \brief Give the maximum spatial residual  
1237   */   */
1238  Float_t TrkTrack::GetResidual_max(int ip, int iv){  Float_t TrkTrack::GetResidual_max(int ip, int iv){
1239      Float_t max=0;      Float_t max=0;
# Line 1119  Float_t TrkTrack::GetResidual_max(int ip Line 1250  Float_t TrkTrack::GetResidual_max(int ip
1250          vto   = iv+1;          vto   = iv+1;
1251      }      }
1252      for(int i=pfrom; i<pto; i++){      for(int i=pfrom; i<pto; i++){
1253          for(int j=0; j<vto; j++){          for(int j=vfrom; j<vto; j++){
1254              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];
1255              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];
1256          }          }
1257      }      }
1258      return max;      return max;
1259    
1260  };  };
1261    /**
1262     * \brief Give the average spatial residual
1263     */
1264    Float_t TrkTrack::GetResidual_av(int ip, int iv){
1265        //
1266    //Sum$((xm>-50)*(xm-xv)/resx)/sqrt(TrkTrack.GetNX()*TrkTrack.GetChi2X())<0.3
1267    
1268        Float_t av  = 0.;
1269        int     nav = 0;
1270        //
1271        int pfrom = 0;
1272        int pto   = 6;
1273        int vfrom = 0;
1274        int vto   = 2;
1275        if(ip>=0&&ip<6){
1276            pfrom = ip;
1277            pto   = ip+1;
1278        }
1279        if(iv>=0&&iv<2){
1280            vfrom = iv;
1281            vto   = iv+1;
1282        }
1283        for(int i=pfrom; i<pto; i++){
1284            for(int j=vfrom; j<vto; j++){
1285                nav++;
1286                if(j==0 && XGood(i)) av += (xm[i]-xv[i])/resx[i];
1287                if(j==1 && YGood(i)) av += (ym[i]-yv[i])/resy[i];
1288            }
1289        }
1290        if(nav==0)return -100.;
1291        return av/nav;
1292    
1293    };
1294    
1295    
1296  /**  /**
# Line 1219  void TrkTrack::Clear(){ Line 1383  void TrkTrack::Clear(){
1383          dedx_y[ip] = 0;          dedx_y[ip] = 0;
1384    
1385      };      };
1386        int ngf = TrkParams::nGF;
1387        for(int i=0; i<ngf; i++){
1388            xGF[i] = 0.;
1389            yGF[i] = 0.;
1390        }
1391  //     if(clx)clx->Clear();  //     if(clx)clx->Clear();
1392  //     if(cly)cly->Clear();  //     if(cly)cly->Clear();
1393  //    clx.Clear();  //    clx.Clear();
# Line 1245  void TrkTrack::Delete(){ Line 1414  void TrkTrack::Delete(){
1414  //--------------------------------------  //--------------------------------------
1415  TrkSinglet::TrkSinglet(){  TrkSinglet::TrkSinglet(){
1416  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;
1417      plane    = 0;  //     plane    = 0;
1418      coord[0] = 0;  //     coord[0] = 0;
1419      coord[1] = 0;  //     coord[1] = 0;
1420      sgnl     = 0;  //     sgnl     = 0;
1421    //     multmax  = 0;
1422  //    cls      = 0;  //    cls      = 0;
1423        Clear();
1424  };  };
1425  //--------------------------------------  //--------------------------------------
1426  //  //
# Line 1261  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1432  TrkSinglet::TrkSinglet(const TrkSinglet&
1432      coord[0] = s.coord[0];      coord[0] = s.coord[0];
1433      coord[1] = s.coord[1];      coord[1] = s.coord[1];
1434      sgnl     = s.sgnl;      sgnl     = s.sgnl;
1435        multmax  = s.multmax;
1436  //      cls      = 0;//<<<<pointer  //      cls      = 0;//<<<<pointer
1437  //    cls      = TRef(s.cls);  //    cls      = TRef(s.cls);
1438  };  };
# Line 1271  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1443  TrkSinglet::TrkSinglet(const TrkSinglet&
1443  void TrkSinglet::Dump(){  void TrkSinglet::Dump(){
1444      int i=0;      int i=0;
1445      cout << endl << "========== Singlet " ;      cout << endl << "========== Singlet " ;
1446      cout << endl << "plane    : " << plane;      cout << endl << "plane        : " << plane;
1447      cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++;      cout << endl << "coord[2]     : "; while( i<2 && cout << coord[i] << " ") i++;
1448      cout << endl << "sgnl     : " << sgnl;      cout << endl << "sgnl         : " << sgnl;
1449        cout << endl << "max.strip    : ";
1450        cout << endl << "multiplicity : ";
1451  }  }
1452  //--------------------------------------  //--------------------------------------
1453  //  //
# Line 1286  void TrkSinglet::Clear(){ Line 1460  void TrkSinglet::Clear(){
1460      coord[0]=-999;      coord[0]=-999;
1461      coord[1]=-999;      coord[1]=-999;
1462      sgnl=0;      sgnl=0;
1463        multmax  = 0;
1464            
1465  }  }
1466  //--------------------------------------  //--------------------------------------
# Line 1396  Bool_t TrkLevel2::GetVKFlag(int iv, int Line 1571  Bool_t TrkLevel2::GetVKFlag(int iv, int
1571   * forced (see TrkLevel2::GetVKMask(int,int)) or   * forced (see TrkLevel2::GetVKMask(int,int)) or
1572   * for this event only (TrkLevel2::GetVKFlag(int,int)).   * for this event only (TrkLevel2::GetVKFlag(int,int)).
1573   * @param iv Tracker view (0-11)   * @param iv Tracker view (0-11)
1574   * @param ivk Viking-chip number (0-23)   * @param ivk Viking-chip number (0-23)
1575   */   */
1576  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){
1577      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );
# Line 1492  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1667  void TrkLevel2::SetFromLevel2Struct(cTrk
1667              //-----------------------------------------------------              //-----------------------------------------------------
1668              //-----------------------------------------------------              //-----------------------------------------------------
1669          };          };
1670            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1671            // evaluated coordinates (to define GF)
1672            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1673            int    ngf = TrkParams::nGF;
1674            float *zgf = TrkParams::zGF;
1675            Trajectory tgf = Trajectory(ngf,zgf);
1676            tgf.DoTrack2(t_track->al);//<<<< integrate the trajectory
1677            for(int ip=0; ip<ngf; ip++){
1678                t_track->xGF[ip] = tgf.x[ip];
1679                t_track->yGF[ip] = tgf.y[ip];
1680            }
1681            
1682  //      if(t_track->IsSaturated())t_track->Dump();  //      if(t_track->IsSaturated())t_track->Dump();
1683          new(t[i]) TrkTrack(*t_track);          new(t[i]) TrkTrack(*t_track);
1684          t_track->Clear();          t_track->Clear();
1685      };      };//end loop over track
1686    
1687  //  ----------------  //  ----------------
1688  //  *** SINGLETS ***  //  *** SINGLETS ***
# Line 1507  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1694  void TrkLevel2::SetFromLevel2Struct(cTrk
1694          t_singlet->coord[0] = l2->xs[i][0];          t_singlet->coord[0] = l2->xs[i][0];
1695          t_singlet->coord[1] = l2->xs[i][1];          t_singlet->coord[1] = l2->xs[i][1];
1696          t_singlet->sgnl     = l2->signlxs[i];          t_singlet->sgnl     = l2->signlxs[i];
1697            t_singlet->multmax = l2->multmaxsx[i];
1698            if(l2->sxbad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1699          //-----------------------------------------------------          //-----------------------------------------------------
1700  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);
1701          //-----------------------------------------------------          //-----------------------------------------------------
# Line 1520  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1709  void TrkLevel2::SetFromLevel2Struct(cTrk
1709          t_singlet->coord[0] = l2->ys[i][0];          t_singlet->coord[0] = l2->ys[i][0];
1710          t_singlet->coord[1] = l2->ys[i][1];          t_singlet->coord[1] = l2->ys[i][1];
1711          t_singlet->sgnl     = l2->signlys[i];          t_singlet->sgnl     = l2->signlys[i];
1712            t_singlet->multmax  = l2->multmaxsy[i];
1713            if(l2->sybad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1714          //-----------------------------------------------------          //-----------------------------------------------------
1715  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);
1716          //-----------------------------------------------------          //-----------------------------------------------------
1717          new(sy[i]) TrkSinglet(*t_singlet);          new(sy[i]) TrkSinglet(*t_singlet);
1718          t_singlet->Clear();          t_singlet->Clear();
1719      };      };
1720    
1721    
1722                    
1723      delete t_track;      delete t_track;
1724      delete t_singlet;      delete t_singlet;
# Line 1846  void TrkLevel2::LoadField(TString path){ Line 2039  void TrkLevel2::LoadField(TString path){
2039    
2040      TrkParams::Set(path,1);      TrkParams::Set(path,1);
2041      TrkParams::Load(1);      TrkParams::Load(1);
2042        if( !TrkParams::IsLoaded(1) ){
2043            cout << "void TrkLevel2::LoadField(TString path) --- ERROR --- m.field not loaded"<<endl;
2044        }
2045    
2046  //  //
2047  };  };
# Line 2040  float Trajectory::GetLength(int ifirst, Line 2236  float Trajectory::GetLength(int ifirst,
2236   */   */
2237  int Trajectory::DoTrack2(float* al){  int Trajectory::DoTrack2(float* al){
2238    
2239      double *dxout   = new double[npoint];  //      double *dxout   = new double[npoint];
2240      double *dyout   = new double[npoint];  //      double *dyout   = new double[npoint];
2241      double *dthxout = new double[npoint];  //      double *dthxout = new double[npoint];
2242      double *dthyout = new double[npoint];  //      double *dthyout = new double[npoint];
2243      double *dtlout  = new double[npoint];  //      double *dtlout  = new double[npoint];
2244      double *dzin    = new double[npoint];  //      double *dzin    = new double[npoint];
2245      double dal[5];      
2246         double *dxout;
2247         double *dyout;
2248         double *dthxout;
2249         double *dthyout;
2250         double *dtlout;
2251         double *dzin;
2252    
2253         dxout   = (double*) malloc(npoint*sizeof(double));
2254         dyout   = (double*) malloc(npoint*sizeof(double));
2255         dthxout = (double*) malloc(npoint*sizeof(double));
2256         dthyout = (double*) malloc(npoint*sizeof(double));
2257         dtlout  = (double*) malloc(npoint*sizeof(double));
2258         dzin    = (double*) malloc(npoint*sizeof(double));
2259    
2260         double dal[5];
2261    
2262      int ifail = 0;      int ifail = 0;
2263    
# Line 2061  int Trajectory::DoTrack2(float* al){ Line 2272  int Trajectory::DoTrack2(float* al){
2272      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
2273            
2274      for (int i=0; i<npoint; i++){      for (int i=0; i<npoint; i++){
2275          x[i]   = (float)*dxout++;          x[i]   = (float)*(dxout+i);
2276          y[i]   = (float)*dyout++;          y[i]   = (float)*(dyout+i);
2277          thx[i] = (float)*dthxout++;          thx[i] = (float)*(dthxout+i);
2278          thy[i] = (float)*dthyout++;          thy[i] = (float)*(dthyout+i);
2279          tl[i]  = (float)*dtlout++;          tl[i]  = (float)*(dtlout+i);
2280      }      }
2281    
2282        if(dxout)  free( dxout );
2283        if(dyout)  free( dyout );
2284        if(dthxout)free( dthxout );
2285        if(dthyout)free( dthyout );
2286        if(dtlout) free( dtlout );
2287        if(dzin)   free( dzin );
2288    
2289    //      delete [] dxout;
2290    //      delete [] dyout;
2291    //      delete [] dthxout;
2292    //      delete [] dthyout;
2293    //      delete [] dtlout;
2294    //      delete [] dzin;
2295    
2296    
2297      return ifail;      return ifail;
2298  };  };

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

  ViewVC Help
Powered by ViewVC 1.1.23