/[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.5 by mocchiut, Thu Aug 7 16:04:14 2014 UTC revision 1.8 by pam-fi, Thu Jan 28 14:38:24 2016 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{  //   }else{
# Line 230  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 496  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 specified, deallocates the hit vectors.
501     */
502  void ExtTrack::Clear(Option_t* option){  void ExtTrack::Clear(Option_t* option){
503        
504    //    cout << " ExtTrack::Clear( "<<option<<" )"<<this<<endl;
505            
506        Reset();
507    
508       if (option && option[0] == 'C') {
509    
510    //       cout << " uccidi!! "<<endl;
511    
512           if(xgood) delete []      xgood;
513           if(ygood) delete []      ygood;
514           if(multmaxx) delete [] multmaxx;
515           if(multmaxy) delete [] multmaxy;
516           if(xm)    delete []      xm;
517           if(ym)    delete []      ym;
518           if(zm)    delete []      zm;
519           if(xma)   delete []      xma;
520           if(yma)   delete []      yma;
521           if(zma)   delete []      zma;
522           if(xmb)   delete []      xmb;
523           if(ymb)   delete []      ymb;
524           if(zmb)   delete []      zmb;
525           if(resx)  delete []      resx;
526           if(resy)  delete []      resy;
527           if(xv)    delete []      xv;
528           if(yv)    delete []      yv;
529           if(zv)    delete []      zv;
530           if(axv)   delete []      axv;
531           if(ayv)   delete []      ayv;
532           if(dedx_x)delete []      dedx_x;
533           if(dedx_y)delete []      dedx_y;
534           //}
535    //        delete []     xgood;
536    //        delete []     ygood;
537    //        delete [] multmaxx;
538    //        delete [] multmaxy;
539    //        delete []     xm;
540    //        delete []     ym;
541    //        delete []     zm;
542    //        delete []     xma;
543    //        delete []     yma;
544    //        delete []     zma;
545    //        delete []     xmb;
546    //        delete []     ymb;
547    //        delete []     zmb;
548    //        delete []     resx;
549    //        delete []     resy;
550    //        delete []     xv;
551    //        delete []     yv;
552    //        delete []     zv;
553    //        delete []     axv;
554    //        delete []     ayv;
555    //        delete []     dedx_x;
556    //        delete []     dedx_y;
557    
558           xgood   = NULL;
559           ygood   = NULL;
560           multmaxx   = NULL;
561           multmaxy   = NULL;
562           xm      = NULL;
563           ym      = NULL;
564           zm      = NULL;
565           xma     = NULL;
566           yma     = NULL;
567           zma     = NULL;
568           xmb     = NULL;
569           ymb     = NULL;
570           zmb     = NULL;
571           resx    = NULL;
572           resy    = NULL;
573           xv      = NULL;
574           yv      = NULL;
575           zv      = NULL;
576           axv     = NULL;
577           ayv     = NULL;
578           dedx_x  = NULL;
579           dedx_y  = NULL;
580    
581    //  cout << " ExtTrack::Clear("<<option<<")  "<<this<<endl;         nplanes = 0;
   
   
   //  cout << " xgood "<<xgood<<endl;  
     
   //  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;  
   
   nplanes = 0;  
582    
583    //  Reset();     }
584    
585  };  };
586    
587  void ExtTrack::Delete(){  void ExtTrack::Delete(){
588    Clear();    Clear("C");
589    // delete [] xGF;    // delete [] xGF;
590    // delete [] yGF;    // delete [] yGF;
591  }          }        
# Line 736  void ExtTrack::Fit(double pfixed, int& f Line 763  void ExtTrack::Fit(double pfixed, int& f
763      if(iprint)cout << " >>>> fit failed "<<endl;      if(iprint)cout << " >>>> fit failed "<<endl;
764      for(int i=0; i<5; i++) al[i]=al_ini[i];      for(int i=0; i<5; i++) al[i]=al_ini[i];
765    }    }
766    
767      int ngf = TrkParams::nGF;
768      float* zgf =  TrkParams::zGF;    
769      Trajectory tj = Trajectory(ngf,zgf);
770      tj.DoTrack(al,zini);
771      for(int i=0; i<14; i++){
772          xGF[i] = tj.x[i];
773          yGF[i] = tj.y[i];
774      }
775    
776    
777  };  };
778    
779  /**  /**
# Line 807  void ExtTrack::SetFromMiniStruct(cMiniEx Line 845  void ExtTrack::SetFromMiniStruct(cMiniEx
845   *   *
846   */   */
847  int ExtTrack::GetClusterX_ID(int ip){  int ExtTrack::GetClusterX_ID(int ip){
848        if(ip<0 || ip>=nplanes)return -1;
849      return ((int)fabs(xgood[ip]))%10000000-1;      return ((int)fabs(xgood[ip]))%10000000-1;
850  };  };
851  /**  /**
# Line 814  int ExtTrack::GetClusterX_ID(int ip){ Line 853  int ExtTrack::GetClusterX_ID(int ip){
853   *   *
854   */   */
855  int ExtTrack::GetClusterY_ID(int ip){  int ExtTrack::GetClusterY_ID(int ip){
856        if(ip<0 || ip>=nplanes)return -1;
857      return ((int)fabs(ygood[ip]))%10000000-1;      return ((int)fabs(ygood[ip]))%10000000-1;
858  };  };
859    
# Line 823  int ExtTrack::GetClusterY_ID(int ip){ Line 863  int ExtTrack::GetClusterY_ID(int ip){
863   * @param iv view (0=x 1=y)   * @param iv view (0=x 1=y)
864   */   */
865  Float_t ExtTrack::GetDEDX(int ip, int iv){  Float_t ExtTrack::GetDEDX(int ip, int iv){
866      if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]);      if(iv==0 && ip>=0 && ip<nplanes)return fabs(dedx_x[ip]);
867      else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]);      else if(iv==1 && ip>=0 && ip<nplanes)return fabs(dedx_y[ip]);
868      else {      else {
869          cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;          cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
870          return 0.;          return 0.;
# Line 845  Float_t ExtTrack::GetDEDX(int ip){ Line 885  Float_t ExtTrack::GetDEDX(int ip){
885   */   */
886  Float_t ExtTrack::GetDEDX(){  Float_t ExtTrack::GetDEDX(){
887      Float_t dedx=0;      Float_t dedx=0;
888      for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip);      for(Int_t ip=0; ip<nplanes; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip);
889      dedx = dedx/(GetNX()+GetNY());      dedx = dedx/(GetNX()+GetNY());
890      return dedx;      return dedx;
891  };  };
892    
893    
894    /**
895     * Method to evaluate the dE/dx averaged over all X views.
896     */
897    Float_t ExtTrack::GetDEDXX(bool cutSat){
898        Float_t dedx=0;
899        Int_t   np=0;
900        for(Int_t ip=0; ip<nplanes; ip++){
901            dedx += GetDEDX(ip,0)*XGood(ip)*(cutSat ? !IsSaturated(ip,0) : 1);
902            np   +=               XGood(ip)*(cutSat ? !IsSaturated(ip,0) : 1);
903        }
904        if(np>0)return dedx/np;
905        return -1;
906    };
907    /**
908     * Method to evaluate the dE/dx averaged over all Y views.
909     */
910    Float_t ExtTrack::GetDEDXY(bool cutSat){
911        Float_t dedx=0;
912        Int_t   np=0;
913        for(Int_t ip=0; ip<nplanes; ip++){
914            dedx += GetDEDX(ip,1)*YGood(ip)*(cutSat ? !IsSaturated(ip,1) : 1);
915            np   +=               YGood(ip)*(cutSat ? !IsSaturated(ip,1) : 1);
916        }
917        if(np>0)return dedx/np;
918        return -1;
919    };
920    
921    /**
922     * Returns 1 if the cluster on a tracker view includes bad strips
923     * (at least one bad strip among the four strip used by p.f.a.)
924     * @param ip plane (0-5)
925     * @param iv view (0=x 1=y)
926     */
927    Bool_t ExtTrack::IsBad(int ip,int iv){
928        if(ip>=6&&ip<8)return false;
929        if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ;
930        else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ;
931        else {
932            cout << "ExtTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
933            return 0.;
934        }
935    };
936    
937  /**  /**
938   * Method to retrieve the ladder, if assigned   * Method to retrieve the ladder, if assigned
939   */   */
# Line 928  Float_t ExtTrack::GetDeflection(){ Line 1012  Float_t ExtTrack::GetDeflection(){
1012  //  //
1013  Bool_t ExtTrack::IsInsideAcceptance(float toll){  Bool_t ExtTrack::IsInsideAcceptance(float toll){
1014      int ngf = TrkParams::nGF;      int ngf = TrkParams::nGF;
1015        float* zgf =  TrkParams::zGF;
1016        
1017        Trajectory tj = Trajectory(ngf,zgf);
1018        tj.DoTrack(al,zini);
1019    
1020      for(int i=0; i<ngf; i++){      for(int i=0; i<ngf; i++){
1021          //          //
1022  //      cout << endl << TrkParams::GF_element[i];  //      cout << endl << TrkParams::GF_element[i];
1023          if(  //      if(
1024              TrkParams::GF_element[i].CompareTo("S11") &&  //          TrkParams::GF_element[i].CompareTo("S11") &&
1025              TrkParams::GF_element[i].CompareTo("S12") &&  //          TrkParams::GF_element[i].CompareTo("S12") &&
1026              TrkParams::GF_element[i].CompareTo("S21") &&  //          TrkParams::GF_element[i].CompareTo("S21") &&
1027              TrkParams::GF_element[i].CompareTo("S22") &&  //          TrkParams::GF_element[i].CompareTo("S22") &&
1028              TrkParams::GF_element[i].CompareTo("T1")  &&  //          TrkParams::GF_element[i].CompareTo("T1")  &&
1029              TrkParams::GF_element[i].CompareTo("CUF") &&  //          TrkParams::GF_element[i].CompareTo("CUF") &&
1030              TrkParams::GF_element[i].CompareTo("T2")  &&  //          TrkParams::GF_element[i].CompareTo("T2")  &&
1031              TrkParams::GF_element[i].CompareTo("T3")  &&  //          TrkParams::GF_element[i].CompareTo("T3")  &&
1032              TrkParams::GF_element[i].CompareTo("T4")  &&  //          TrkParams::GF_element[i].CompareTo("T4")  &&
1033              TrkParams::GF_element[i].CompareTo("T5")  &&  //          TrkParams::GF_element[i].CompareTo("T5")  &&
1034              TrkParams::GF_element[i].CompareTo("CLF") &&  //          TrkParams::GF_element[i].CompareTo("CLF") &&
1035              TrkParams::GF_element[i].CompareTo("T6")  &&  //          TrkParams::GF_element[i].CompareTo("T6")  &&
1036              TrkParams::GF_element[i].CompareTo("S31") &&  //          TrkParams::GF_element[i].CompareTo("S31") &&
1037              TrkParams::GF_element[i].CompareTo("S32") &&  //          TrkParams::GF_element[i].CompareTo("S32") &&
1038              true)continue;  //          true)continue;
1039          // apply condition only within the cavity          // apply condition only within the cavity
1040  //      cout << " -- "<<xGF[i]<<" "<<yGF[i];  //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1041          if(          if(
1042              xGF[i] <= TrkParams::xGF_min[i] + toll ||  //          xGF[i] <= TrkParams::xGF_min[i] + toll ||
1043              xGF[i] >= TrkParams::xGF_max[i] - toll ||  //          xGF[i] >= TrkParams::xGF_max[i] - toll ||
1044              yGF[i] <= TrkParams::yGF_min[i] + toll ||  //          yGF[i] <= TrkParams::yGF_min[i] + toll ||
1045              yGF[i] >= TrkParams::yGF_max[i] - toll ||  //          yGF[i] >= TrkParams::yGF_max[i] - toll ||
1046                tj.x[i] <= TrkParams::xGF_min[i] + toll ||
1047                tj.x[i] >= TrkParams::xGF_max[i] - toll ||
1048                tj.y[i] <= TrkParams::yGF_min[i] + toll ||
1049                tj.y[i] >= TrkParams::yGF_max[i] - toll ||
1050              false){              false){
1051                            
1052              return false;              return false;
# Line 970  Float_t  ExtTrack::GetChi2X(){ Line 1063  Float_t  ExtTrack::GetChi2X(){
1063      for(int ip=0; ip<nplanes; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.);      for(int ip=0; ip<nplanes; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.);
1064      if(GetNX()>3)chiq=chiq/(GetNX()-3);      if(GetNX()>3)chiq=chiq/(GetNX()-3);
1065      else chiq=0;      else chiq=0;
1066      if(chiq==0)cout << " Float_t  ExtTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl;      //    if(chiq==0)cout << " Float_t  ExtTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl;
1067      return chiq;      return chiq;
1068  }  }
1069  /**  /**
# Line 981  Float_t  ExtTrack::GetChi2Y(){ Line 1074  Float_t  ExtTrack::GetChi2Y(){
1074      for(int ip=0; ip<nplanes; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.);      for(int ip=0; ip<nplanes; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.);
1075      if(GetNY()>2)chiq=chiq/(GetNY()-2);      if(GetNY()>2)chiq=chiq/(GetNY()-2);
1076      else chiq=0;      else chiq=0;
1077      if(chiq==0)cout << " Float_t  ExtTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl;      //    if(chiq==0)cout << " Float_t  ExtTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl;
1078      return chiq;      return chiq;
1079  }  }
1080    
1081    /**
1082     * Returns the track "lever-arm" on the x view, defined as the distance (in planes) between
1083     * the upper and lower x measurements (the maximum value of lever-arm is 6).
1084     */
1085    Int_t ExtTrack::GetLeverArmX(){
1086        int first_plane = -1;
1087        int last_plane  = -1;
1088        for(Int_t ip=0; ip<nplanes; ip++){
1089            if( XGood(ip) && first_plane == -1 )first_plane = ip;
1090            if( XGood(ip) && first_plane != -1 )last_plane = ip;
1091        }
1092        if( first_plane == -1 || last_plane == -1){
1093            cout<< "Int_t ExtTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl;
1094            return 0;
1095        }
1096        return (last_plane-first_plane+1);
1097    }
1098    /**
1099     * Returns the track "lever-arm" on the y view, defined as the distance (in planes) between
1100     * the upper and lower y measurements (the maximum value of lever-arm is 6).
1101     */
1102    Int_t ExtTrack::GetLeverArmY(){
1103        int first_plane = -1;
1104        int last_plane  = -1;
1105        for(Int_t ip=0; ip<nplanes; ip++){
1106            if( YGood(ip) && first_plane == -1 )first_plane = ip;
1107            if( YGood(ip) && first_plane != -1 )last_plane = ip;
1108        }
1109        if( first_plane == -1 || last_plane == -1){
1110            cout<< "Int_t ExtTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl;
1111            return 0;
1112        }
1113        return (last_plane-first_plane+1);
1114    }
1115    /**
1116     * Returns the track "lever-arm" on the x+y view, defined as the distance (in planes) between
1117     * the upper and lower x,y (couple) measurements (the maximum value of lever-arm is 6).
1118     */
1119    Int_t ExtTrack::GetLeverArmXY(){
1120        int first_plane = -1;
1121        int last_plane  = -1;
1122        for(Int_t ip=0; ip<nplanes; ip++){
1123            if( XGood(ip) && YGood(ip) && first_plane == -1 )first_plane = ip;
1124            if( XGood(ip) && YGood(ip) && first_plane != -1 )last_plane = ip;
1125        }
1126        if( first_plane == -1 || last_plane == -1){
1127    //      cout<< "Int_t ExtTrack::GetLeverArmXY() -- XGood(ip)*YGood(ip) always false ??? "<<endl;
1128            return 0;
1129        }
1130        return (last_plane-first_plane+1);
1131    }
1132    
1133    
1134    /**
1135     * Returns 1 if the signal on a tracker view is saturated.
1136     * @param ip plane (0-5)
1137     * @param iv view (0=x 1=y)
1138     */
1139    Bool_t ExtTrack::IsSaturated(int ip,int iv){
1140        if(ip>=6 && ip<8)return false;
1141        if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ;
1142        else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ;
1143        else {
1144            cout << "ExtTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
1145            return 0.;
1146        }
1147    };
1148    /**
1149     * Returns 1 if either the x or the y signal on a tracker plane is saturated.
1150     * @param ip plane (0-5)
1151     */
1152    Bool_t ExtTrack::IsSaturated(int ip){
1153        return (IsSaturated(ip,0)||IsSaturated(ip,1));
1154    };
1155    /**
1156     * Returns 1 if there is at least a saturated signal along the track.
1157     */
1158    Bool_t ExtTrack::IsSaturated(){
1159        for(int ip=0; ip<nplanes; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true;
1160        return false;
1161    }
1162    
1163    
1164    
1165    
1166    
1167  ClassImp(ExtTrack);  ClassImp(ExtTrack);

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.23