/[PAMELA software]/DarthVader/TrackerLevel2/src/ExtTrack.cpp
ViewVC logotype

Diff of /DarthVader/TrackerLevel2/src/ExtTrack.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by pam-ts, Wed Jun 4 07:57:03 2014 UTC revision 1.7 by pam-ts, Wed Oct 15 08:45:51 2014 UTC
# Line 135  void ExtTrack::Copy( ExtTrack& t ){ Line 135  void ExtTrack::Copy( ExtTrack& t ){
135    //  cout << " ExtTrack::Copy( ExtTrack& t ) "<<endl;    //  cout << " ExtTrack::Copy( ExtTrack& t ) "<<endl;
136    
137    t.Reset();//reset variables    t.Reset();//reset variables
138    t.Clear();//deallocate vectors    t.Clear("C");//deallocate vectors
139    t.SetDimension(nplanes);//allocate vectors    t.SetDimension(nplanes);//allocate vectors
140    
141    t.zini  = zini;    t.zini  = zini;
# Line 145  void ExtTrack::Copy( ExtTrack& t ){ Line 145  void ExtTrack::Copy( ExtTrack& t ){
145      t.al[it1] = al[it1];      t.al[it1] = al[it1];
146      for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2];      for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2];
147    };        };    
148    //    cout << "ExtTrack::Copy()........nplanes "<<nplanes<<endl;  //  cout << "ExtTrack::Copy()........nplanes "<<nplanes<<endl;
149    for(int ip=0;ip<nplanes;ip++){    for(int ip=0;ip<nplanes;ip++){
150      t.xgood[ip]  = xgood[ip];      t.xgood[ip]  = xgood[ip];
151      t.ygood[ip]  = ygood[ip];      t.ygood[ip]  = ygood[ip];
# Line 185  void ExtTrack::Set( TrkTrack& t , int in Line 185  void ExtTrack::Set( TrkTrack& t , int in
185    
186    //  cout << "Set("<< &t <<", "<<index<<")"<<endl;    //  cout << "Set("<< &t <<", "<<index<<")"<<endl;
187    if(index < 0 ){ //NON FUNZIONA    if(index < 0 ){ //NON FUNZIONA
188      cout << "Clear() "<<endl;      cout << "Clear(\"C\") "<<endl;
189      Reset();//reset variables      Reset();//reset variables
190      Clear();//deallocate vectors      Clear("C");//deallocate vectors
191      cout << "SetDimension("<<t.GetNhit()<<")"<<endl;      cout << "SetDimension("<<t.GetNhit()<<")"<<endl;
192      SetDimension(t.GetNhit()); //allocate vectors      SetDimension(t.GetNhit()); //allocate vectors
193    //   }else{
194    //       SetDimension(6+index);
195    }    }
196    // default fit settings (the same as TrkTrack)    // default fit settings (the same as TrkTrack)
197    SetMiniDefault();    SetMiniDefault();
# Line 228  void ExtTrack::Set( TrkTrack& t , int in Line 230  void ExtTrack::Set( TrkTrack& t , int in
230        ymb[ipp]     = dummy;        ymb[ipp]     = dummy;
231        zmb[ipp]     = zm[ipp];        zmb[ipp]     = zm[ipp];
232    
233        if( t.XGood(ip)*t.YGood(ip) ){ //double hit        if( t.XGood(ip) && t.YGood(ip) ){ //double hit
234          xma[ipp]     = t.xm[ip];          xma[ipp]     = t.xm[ip];
235          yma[ipp]     = t.ym[ip];          yma[ipp]     = t.ym[ip];
236          zma[ipp]     = t.zm[ip];          zma[ipp]     = t.zm[ip];
# Line 494  bool ExtTrack::SetYGood(int ip,int icl_p Line 496  bool ExtTrack::SetYGood(int ip,int icl_p
496  //  //
497  //  //
498  //--------------------------------------  //--------------------------------------
499    /**
500     * Clear the track. If option C is specied, deallocate the hit vectors.
501     */
502  void ExtTrack::Clear(Option_t* option){  void ExtTrack::Clear(Option_t* option){
503    
504       Reset();
505    
506    
507    //  cout << " ExtTrack::Clear("<<option<<")  "<<this<<endl;    //  cout << " ExtTrack::Clear("<<option<<")  "<<this<<endl;
508    
509    
510    //  cout << " xgood "<<xgood<<endl;    //  cout << " xgood "<<xgood<<endl;
511        
512    //  if(nplanes>0){    //  if(nplanes>0){
   if(xgood) delete []   xgood;  
   if(ygood) delete []   ygood;  
   if(multmaxx) delete [] multmaxx;  
   if(multmaxy) delete [] multmaxy;  
   if(xm)    delete []   xm;  
   if(ym)    delete []   ym;  
   if(zm)    delete []   zm;  
   if(xma)   delete []   xma;  
   if(yma)   delete []   yma;  
   if(zma)   delete []   zma;  
   if(xmb)   delete []   xmb;  
   if(ymb)   delete []   ymb;  
   if(zmb)   delete []   zmb;  
   if(resx)  delete []   resx;  
   if(resy)  delete []   resy;  
   if(xv)    delete []   xv;  
   if(yv)    delete []   yv;  
   if(zv)    delete []   zv;  
   if(axv)   delete []   axv;  
   if(ayv)   delete []   ayv;  
   if(dedx_x)delete []   dedx_x;  
   if(dedx_y)delete []   dedx_y;  
   //}  
   
   xgood   = NULL;  
   ygood   = NULL;  
   multmaxx   = NULL;  
   multmaxy   = NULL;  
   xm      = NULL;  
   ym      = NULL;  
   zm      = NULL;  
   xma     = NULL;  
   yma     = NULL;  
   zma     = NULL;  
   xmb     = NULL;  
   ymb     = NULL;  
   zmb     = NULL;  
   resx    = NULL;  
   resy    = NULL;  
   xv      = NULL;  
   yv      = NULL;  
   zv      = NULL;  
   axv     = NULL;  
   ayv     = NULL;  
   dedx_x  = NULL;  
   dedx_y  = NULL;  
513    
514    nplanes = 0;     if (option && option[0] == 'C') {
515    
516    //  Reset();  
517           if(xgood) delete []      xgood;
518           if(ygood) delete []      ygood;
519           if(multmaxx) delete [] multmaxx;
520           if(multmaxy) delete [] multmaxy;
521           if(xm)    delete []      xm;
522           if(ym)    delete []      ym;
523           if(zm)    delete []      zm;
524           if(xma)   delete []      xma;
525           if(yma)   delete []      yma;
526           if(zma)   delete []      zma;
527           if(xmb)   delete []      xmb;
528           if(ymb)   delete []      ymb;
529           if(zmb)   delete []      zmb;
530           if(resx)  delete []      resx;
531           if(resy)  delete []      resy;
532           if(xv)    delete []      xv;
533           if(yv)    delete []      yv;
534           if(zv)    delete []      zv;
535           if(axv)   delete []      axv;
536           if(ayv)   delete []      ayv;
537           if(dedx_x)delete []      dedx_x;
538           if(dedx_y)delete []      dedx_y;
539           //}
540    
541           xgood   = NULL;
542           ygood   = NULL;
543           multmaxx   = NULL;
544           multmaxy   = NULL;
545           xm      = NULL;
546           ym      = NULL;
547           zm      = NULL;
548           xma     = NULL;
549           yma     = NULL;
550           zma     = NULL;
551           xmb     = NULL;
552           ymb     = NULL;
553           zmb     = NULL;
554           resx    = NULL;
555           resy    = NULL;
556           xv      = NULL;
557           yv      = NULL;
558           zv      = NULL;
559           axv     = NULL;
560           ayv     = NULL;
561           dedx_x  = NULL;
562           dedx_y  = NULL;
563    
564           nplanes = 0;
565    
566       }
567    
568  };  };
569    
570  void ExtTrack::Delete(){  void ExtTrack::Delete(){
571    Clear();    Clear("C");
572    // delete [] xGF;    // delete [] xGF;
573    // delete [] yGF;    // delete [] yGF;
574  }          }        
# Line 805  void ExtTrack::SetFromMiniStruct(cMiniEx Line 817  void ExtTrack::SetFromMiniStruct(cMiniEx
817   *   *
818   */   */
819  int ExtTrack::GetClusterX_ID(int ip){  int ExtTrack::GetClusterX_ID(int ip){
820        if(ip<0 || ip>=nplanes)return -1;
821      return ((int)fabs(xgood[ip]))%10000000-1;      return ((int)fabs(xgood[ip]))%10000000-1;
822  };  };
823  /**  /**
# Line 812  int ExtTrack::GetClusterX_ID(int ip){ Line 825  int ExtTrack::GetClusterX_ID(int ip){
825   *   *
826   */   */
827  int ExtTrack::GetClusterY_ID(int ip){  int ExtTrack::GetClusterY_ID(int ip){
828        if(ip<0 || ip>=nplanes)return -1;
829      return ((int)fabs(ygood[ip]))%10000000-1;      return ((int)fabs(ygood[ip]))%10000000-1;
830  };  };
831    
832  /**  /**
833     * Method to retrieve the dE/dx measured on a tracker view.
834     * @param ip plane (0-5)
835     * @param iv view (0=x 1=y)
836     */
837    Float_t ExtTrack::GetDEDX(int ip, int iv){
838        if(iv==0 && ip>=0 && ip<nplanes)return fabs(dedx_x[ip]);
839        else if(iv==1 && ip>=0 && ip<nplanes)return fabs(dedx_y[ip]);
840        else {
841            cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
842            return 0.;
843        }
844    }
845    /**
846     * Method to evaluate the dE/dx measured on a tracker plane.
847     * The two measurements on x- and y-view are averaged.
848     * @param ip plane (0-5)
849     */
850    Float_t ExtTrack::GetDEDX(int ip){
851        if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0;
852        return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip));
853    };
854    
855    /**
856     * Method to evaluate the dE/dx averaged over all planes.
857     */
858    Float_t ExtTrack::GetDEDX(){
859        Float_t dedx=0;
860        for(Int_t ip=0; ip<nplanes; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip);
861        dedx = dedx/(GetNX()+GetNY());
862        return dedx;
863    };
864    
865    /**
866   * Method to retrieve the ladder, if assigned   * Method to retrieve the ladder, if assigned
867   */   */
868  int ExtTrack::GetLadder(int ip){  int ExtTrack::GetLadder(int ip){
# Line 880  Float_t ExtTrack::GetRigidity(){ Line 927  Float_t ExtTrack::GetRigidity(){
927          if(rig<0) rig=-rig;          if(rig<0) rig=-rig;
928          return rig;          return rig;
929  };  };
930    //
931    Float_t ExtTrack::GetDeflection(){
932            Float_t def=0;
933            if(chi2>0)def=al[4];
934            return def;
935    };
936    
937    
938    //
939    // all that follows: EM porting from TrkLevel2
940    //
941    Bool_t ExtTrack::IsInsideAcceptance(float toll){
942        int ngf = TrkParams::nGF;
943        for(int i=0; i<ngf; i++){
944            //
945    //      cout << endl << TrkParams::GF_element[i];
946            if(
947                TrkParams::GF_element[i].CompareTo("S11") &&
948                TrkParams::GF_element[i].CompareTo("S12") &&
949                TrkParams::GF_element[i].CompareTo("S21") &&
950                TrkParams::GF_element[i].CompareTo("S22") &&
951                TrkParams::GF_element[i].CompareTo("T1")  &&
952                TrkParams::GF_element[i].CompareTo("CUF") &&
953                TrkParams::GF_element[i].CompareTo("T2")  &&
954                TrkParams::GF_element[i].CompareTo("T3")  &&
955                TrkParams::GF_element[i].CompareTo("T4")  &&
956                TrkParams::GF_element[i].CompareTo("T5")  &&
957                TrkParams::GF_element[i].CompareTo("CLF") &&
958                TrkParams::GF_element[i].CompareTo("T6")  &&
959                TrkParams::GF_element[i].CompareTo("S31") &&
960                TrkParams::GF_element[i].CompareTo("S32") &&
961                true)continue;
962            // apply condition only within the cavity
963    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
964            if(
965                xGF[i] <= TrkParams::xGF_min[i] + toll ||
966                xGF[i] >= TrkParams::xGF_max[i] - toll ||
967                yGF[i] <= TrkParams::yGF_min[i] + toll ||
968                yGF[i] >= TrkParams::yGF_max[i] - toll ||
969                false){
970                
971                return false;
972            }
973        }
974        return true;
975    }
976    
977    /**
978     * Returns the reduced chi-square of track x-projection
979     */
980    Float_t  ExtTrack::GetChi2X(){
981        float chiq=0;
982        for(int ip=0; ip<nplanes; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.);
983        if(GetNX()>3)chiq=chiq/(GetNX()-3);
984        else chiq=0;
985        //    if(chiq==0)cout << " Float_t  ExtTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl;
986        return chiq;
987    }
988    /**
989     * Returns the reduced chi-square of track y-projection
990     */
991    Float_t  ExtTrack::GetChi2Y(){
992        float chiq=0;
993        for(int ip=0; ip<nplanes; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.);
994        if(GetNY()>2)chiq=chiq/(GetNY()-2);
995        else chiq=0;
996        //    if(chiq==0)cout << " Float_t  ExtTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl;
997        return chiq;
998    }
999    
1000    /**
1001     * Returns the track "lever-arm" on the x view, defined as the distance (in planes) between
1002     * the upper and lower x measurements (the maximum value of lever-arm is 6).
1003     */
1004    Int_t ExtTrack::GetLeverArmX(){
1005        int first_plane = -1;
1006        int last_plane  = -1;
1007        for(Int_t ip=0; ip<nplanes; ip++){
1008            if( XGood(ip) && first_plane == -1 )first_plane = ip;
1009            if( XGood(ip) && first_plane != -1 )last_plane = ip;
1010        }
1011        if( first_plane == -1 || last_plane == -1){
1012            cout<< "Int_t ExtTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl;
1013            return 0;
1014        }
1015        return (last_plane-first_plane+1);
1016    }
1017    /**
1018     * Returns the track "lever-arm" on the y view, defined as the distance (in planes) between
1019     * the upper and lower y measurements (the maximum value of lever-arm is 6).
1020     */
1021    Int_t ExtTrack::GetLeverArmY(){
1022        int first_plane = -1;
1023        int last_plane  = -1;
1024        for(Int_t ip=0; ip<nplanes; ip++){
1025            if( YGood(ip) && first_plane == -1 )first_plane = ip;
1026            if( YGood(ip) && first_plane != -1 )last_plane = ip;
1027        }
1028        if( first_plane == -1 || last_plane == -1){
1029            cout<< "Int_t ExtTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl;
1030            return 0;
1031        }
1032        return (last_plane-first_plane+1);
1033    }
1034    /**
1035     * Returns the track "lever-arm" on the x+y view, defined as the distance (in planes) between
1036     * the upper and lower x,y (couple) measurements (the maximum value of lever-arm is 6).
1037     */
1038    Int_t ExtTrack::GetLeverArmXY(){
1039        int first_plane = -1;
1040        int last_plane  = -1;
1041        for(Int_t ip=0; ip<nplanes; ip++){
1042            if( XGood(ip) && YGood(ip) && first_plane == -1 )first_plane = ip;
1043            if( XGood(ip) && YGood(ip) && first_plane != -1 )last_plane = ip;
1044        }
1045        if( first_plane == -1 || last_plane == -1){
1046    //      cout<< "Int_t ExtTrack::GetLeverArmXY() -- XGood(ip)*YGood(ip) always false ??? "<<endl;
1047            return 0;
1048        }
1049        return (last_plane-first_plane+1);
1050    }
1051    
1052    
1053    
1054  ClassImp(ExtTrack);  ClassImp(ExtTrack);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.23