/[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.45 by pam-fi, Sat Mar 22 08:32:50 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 890  void TrkTrack::SetDeltaB(int id, double Line 917  void TrkTrack::SetDeltaB(int id, double
917  }  }
918    
919  /**  /**
920   * Returns 1 if the track is inside the magnet cavity   * Returns true if the track is inside the magnet cavity.
921   * Set the minimum number of steps for tracking precision   * @param toll Tolerance around the nominal volume (toll>0 define an inner fiducial volume)
922   */   */
923  Bool_t TrkTrack::IsInsideCavity(){  Bool_t TrkTrack::IsInsideCavity(float toll){
924      float xmagntop, ymagntop, xmagnbottom, ymagnbottom;  
925      xmagntop = xv[0] + (ZMAGNHIGH-zv[0])*tan(acos(-1.0)*axv[0]/180.);  //     float xmagntop, ymagntop, xmagnbottom, ymagnbottom;
926      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.);
927      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.);
928      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.);
929      if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&  //     ymagnbottom = yv[5] + (ZMAGNLOW-zv[5])*tan(acos(-1.0)*ayv[5]/180.);
930          ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&  //     if( xmagntop>XMAGNLOW && xmagntop<XMAGNHIGH &&
931          xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&  //      ymagntop>YMAGNLOW && ymagntop<YMAGNHIGH &&
932          ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);  //      xmagnbottom>XMAGNLOW && xmagnbottom<XMAGNHIGH &&
933      else return(false);  //      ymagnbottom>YMAGNLOW && ymagnbottom<YMAGNHIGH ) return(true);
934    //     else return(false);
935    
936        int ngf = TrkParams::nGF;
937        for(int i=0; i<ngf; i++){
938            //
939    //      cout << endl << TrkParams::GF_element[i];
940            if(
941                TrkParams::GF_element[i].CompareTo("CUF") &&
942                TrkParams::GF_element[i].CompareTo("T2")  &&
943                TrkParams::GF_element[i].CompareTo("T3")  &&
944                TrkParams::GF_element[i].CompareTo("T4")  &&
945                TrkParams::GF_element[i].CompareTo("T5")  &&
946                TrkParams::GF_element[i].CompareTo("CLF") &&
947                true)continue;
948            // apply condition only within the cavity
949    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
950            if(
951                xGF[i] <= TrkParams::xGF_min[i] + toll ||
952                xGF[i] >= TrkParams::xGF_max[i] - toll ||
953                yGF[i] <= TrkParams::yGF_min[i] + toll ||
954                yGF[i] >= TrkParams::yGF_max[i] - toll ||
955                false){
956                
957                return false;
958            }
959        }
960        return true;
961    
962    
963    }
964    /**
965     * Returns true if the track is inside the nominal acceptance, which is defined
966     * by the intersection among magnet cavity, silicon-plane sensitive area and
967     * ToF sensitive area (nominal values from the official document used to
968     * calculate the geometrical factor)
969     */
970    Bool_t TrkTrack::IsInsideAcceptance(){
971    
972        int ngf = TrkParams::nGF;
973        for(int i=0; i<ngf; i++){
974            if(
975                xGF[i] <= TrkParams::xGF_min[i] ||
976                xGF[i] >= TrkParams::xGF_max[i] ||
977                yGF[i] <= TrkParams::yGF_min[i] ||
978                yGF[i] >= TrkParams::yGF_max[i] ||
979                false)return false;
980        }
981        return true;
982    
983  }  }
984  /**  /**
985   * 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 1219  void TrkTrack::Clear(){ Line 1295  void TrkTrack::Clear(){
1295          dedx_y[ip] = 0;          dedx_y[ip] = 0;
1296    
1297      };      };
1298        int ngf = TrkParams::nGF;
1299        for(int i=0; i<ngf; i++){
1300            xGF[i] = 0.;
1301            yGF[i] = 0.;
1302        }
1303  //     if(clx)clx->Clear();  //     if(clx)clx->Clear();
1304  //     if(cly)cly->Clear();  //     if(cly)cly->Clear();
1305  //    clx.Clear();  //    clx.Clear();
# Line 1245  void TrkTrack::Delete(){ Line 1326  void TrkTrack::Delete(){
1326  //--------------------------------------  //--------------------------------------
1327  TrkSinglet::TrkSinglet(){  TrkSinglet::TrkSinglet(){
1328  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;  //    cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl;
1329      plane    = 0;  //     plane    = 0;
1330      coord[0] = 0;  //     coord[0] = 0;
1331      coord[1] = 0;  //     coord[1] = 0;
1332      sgnl     = 0;  //     sgnl     = 0;
1333    //     multmax  = 0;
1334  //    cls      = 0;  //    cls      = 0;
1335        Clear();
1336  };  };
1337  //--------------------------------------  //--------------------------------------
1338  //  //
# Line 1261  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1344  TrkSinglet::TrkSinglet(const TrkSinglet&
1344      coord[0] = s.coord[0];      coord[0] = s.coord[0];
1345      coord[1] = s.coord[1];      coord[1] = s.coord[1];
1346      sgnl     = s.sgnl;      sgnl     = s.sgnl;
1347        multmax  = s.multmax;
1348  //      cls      = 0;//<<<<pointer  //      cls      = 0;//<<<<pointer
1349  //    cls      = TRef(s.cls);  //    cls      = TRef(s.cls);
1350  };  };
# Line 1271  TrkSinglet::TrkSinglet(const TrkSinglet& Line 1355  TrkSinglet::TrkSinglet(const TrkSinglet&
1355  void TrkSinglet::Dump(){  void TrkSinglet::Dump(){
1356      int i=0;      int i=0;
1357      cout << endl << "========== Singlet " ;      cout << endl << "========== Singlet " ;
1358      cout << endl << "plane    : " << plane;      cout << endl << "plane        : " << plane;
1359      cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++;      cout << endl << "coord[2]     : "; while( i<2 && cout << coord[i] << " ") i++;
1360      cout << endl << "sgnl     : " << sgnl;      cout << endl << "sgnl         : " << sgnl;
1361        cout << endl << "max.strip    : ";
1362        cout << endl << "multiplicity : ";
1363  }  }
1364  //--------------------------------------  //--------------------------------------
1365  //  //
# Line 1286  void TrkSinglet::Clear(){ Line 1372  void TrkSinglet::Clear(){
1372      coord[0]=-999;      coord[0]=-999;
1373      coord[1]=-999;      coord[1]=-999;
1374      sgnl=0;      sgnl=0;
1375        multmax  = 0;
1376            
1377  }  }
1378  //--------------------------------------  //--------------------------------------
# Line 1396  Bool_t TrkLevel2::GetVKFlag(int iv, int Line 1483  Bool_t TrkLevel2::GetVKFlag(int iv, int
1483   * forced (see TrkLevel2::GetVKMask(int,int)) or   * forced (see TrkLevel2::GetVKMask(int,int)) or
1484   * for this event only (TrkLevel2::GetVKFlag(int,int)).   * for this event only (TrkLevel2::GetVKFlag(int,int)).
1485   * @param iv Tracker view (0-11)   * @param iv Tracker view (0-11)
1486   * @param ivk Viking-chip number (0-23)   * @param ivk Viking-chip number (0-23)
1487   */   */
1488  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){  Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){
1489      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );      return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) );
# Line 1492  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1579  void TrkLevel2::SetFromLevel2Struct(cTrk
1579              //-----------------------------------------------------              //-----------------------------------------------------
1580              //-----------------------------------------------------              //-----------------------------------------------------
1581          };          };
1582            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1583            // evaluated coordinates (to define GF)
1584            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1585            int    ngf = TrkParams::nGF;
1586            float *zgf = TrkParams::zGF;
1587            Trajectory tgf = Trajectory(ngf,zgf);
1588            tgf.DoTrack2(t_track->al);//<<<< integrate the trajectory
1589            for(int ip=0; ip<ngf; ip++){
1590                t_track->xGF[ip] = tgf.x[ip];
1591                t_track->yGF[ip] = tgf.y[ip];
1592            }
1593            
1594  //      if(t_track->IsSaturated())t_track->Dump();  //      if(t_track->IsSaturated())t_track->Dump();
1595          new(t[i]) TrkTrack(*t_track);          new(t[i]) TrkTrack(*t_track);
1596          t_track->Clear();          t_track->Clear();
1597      };      };//end loop over track
1598    
1599  //  ----------------  //  ----------------
1600  //  *** SINGLETS ***  //  *** SINGLETS ***
# Line 1507  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1606  void TrkLevel2::SetFromLevel2Struct(cTrk
1606          t_singlet->coord[0] = l2->xs[i][0];          t_singlet->coord[0] = l2->xs[i][0];
1607          t_singlet->coord[1] = l2->xs[i][1];          t_singlet->coord[1] = l2->xs[i][1];
1608          t_singlet->sgnl     = l2->signlxs[i];          t_singlet->sgnl     = l2->signlxs[i];
1609            t_singlet->multmax = l2->multmaxsx[i];
1610            if(l2->sxbad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1611          //-----------------------------------------------------          //-----------------------------------------------------
1612  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsx[i]-1);
1613          //-----------------------------------------------------          //-----------------------------------------------------
# Line 1520  void TrkLevel2::SetFromLevel2Struct(cTrk Line 1621  void TrkLevel2::SetFromLevel2Struct(cTrk
1621          t_singlet->coord[0] = l2->ys[i][0];          t_singlet->coord[0] = l2->ys[i][0];
1622          t_singlet->coord[1] = l2->ys[i][1];          t_singlet->coord[1] = l2->ys[i][1];
1623          t_singlet->sgnl     = l2->signlys[i];          t_singlet->sgnl     = l2->signlys[i];
1624            t_singlet->multmax  = l2->multmaxsy[i];
1625            if(l2->sybad[i]>0) t_singlet->multmax = -1*t_singlet->multmax;
1626          //-----------------------------------------------------          //-----------------------------------------------------
1627  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);  //      if(l1) t_singlet->cls      = l1->GetCluster(l2->clsy[i]-1);
1628          //-----------------------------------------------------          //-----------------------------------------------------
1629          new(sy[i]) TrkSinglet(*t_singlet);          new(sy[i]) TrkSinglet(*t_singlet);
1630          t_singlet->Clear();          t_singlet->Clear();
1631      };      };
1632    
1633    
1634                    
1635      delete t_track;      delete t_track;
1636      delete t_singlet;      delete t_singlet;
# Line 2040  float Trajectory::GetLength(int ifirst, Line 2145  float Trajectory::GetLength(int ifirst,
2145   */   */
2146  int Trajectory::DoTrack2(float* al){  int Trajectory::DoTrack2(float* al){
2147    
2148      double *dxout   = new double[npoint];  //      double *dxout   = new double[npoint];
2149      double *dyout   = new double[npoint];  //      double *dyout   = new double[npoint];
2150      double *dthxout = new double[npoint];  //      double *dthxout = new double[npoint];
2151      double *dthyout = new double[npoint];  //      double *dthyout = new double[npoint];
2152      double *dtlout  = new double[npoint];  //      double *dtlout  = new double[npoint];
2153      double *dzin    = new double[npoint];  //      double *dzin    = new double[npoint];
2154      double dal[5];      
2155         double *dxout;
2156         double *dyout;
2157         double *dthxout;
2158         double *dthyout;
2159         double *dtlout;
2160         double *dzin;
2161    
2162         dxout   = (double*) malloc(npoint*sizeof(double));
2163         dyout   = (double*) malloc(npoint*sizeof(double));
2164         dthxout = (double*) malloc(npoint*sizeof(double));
2165         dthyout = (double*) malloc(npoint*sizeof(double));
2166         dtlout  = (double*) malloc(npoint*sizeof(double));
2167         dzin    = (double*) malloc(npoint*sizeof(double));
2168    
2169         double dal[5];
2170    
2171      int ifail = 0;      int ifail = 0;
2172    
# Line 2061  int Trajectory::DoTrack2(float* al){ Line 2181  int Trajectory::DoTrack2(float* al){
2181      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);      dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail);
2182            
2183      for (int i=0; i<npoint; i++){      for (int i=0; i<npoint; i++){
2184          x[i]   = (float)*dxout++;          x[i]   = (float)*(dxout+i);
2185          y[i]   = (float)*dyout++;          y[i]   = (float)*(dyout+i);
2186          thx[i] = (float)*dthxout++;          thx[i] = (float)*(dthxout+i);
2187          thy[i] = (float)*dthyout++;          thy[i] = (float)*(dthyout+i);
2188          tl[i]  = (float)*dtlout++;          tl[i]  = (float)*(dtlout+i);
2189      }      }
2190    
2191        if(dxout)  free( dxout );
2192        if(dyout)  free( dyout );
2193        if(dthxout)free( dthxout );
2194        if(dthyout)free( dthyout );
2195        if(dtlout) free( dtlout );
2196        if(dzin)   free( dzin );
2197    
2198    //      delete [] dxout;
2199    //      delete [] dyout;
2200    //      delete [] dthxout;
2201    //      delete [] dthyout;
2202    //      delete [] dtlout;
2203    //      delete [] dzin;
2204    
2205    
2206      return ifail;      return ifail;
2207  };  };

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

  ViewVC Help
Powered by ViewVC 1.1.23