/[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.9 by pam-fi, Fri Feb 26 12:03:36 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{
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 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 734  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 805  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 812  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    
860  /**  /**
861     * Method to retrieve the dE/dx measured on a tracker view.
862     * @param ip plane (0-5)
863     * @param iv view (0=x 1=y)
864     */
865    Float_t ExtTrack::GetDEDX(int ip, int iv){
866        if(iv==0 && ip>=0 && ip<nplanes)return fabs(dedx_x[ip]);
867        else if(iv==1 && ip>=0 && ip<nplanes)return fabs(dedx_y[ip]);
868        else {
869            cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
870            return 0.;
871        }
872    }
873    /**
874     * Method to evaluate the dE/dx measured on a tracker plane.
875     * The two measurements on x- and y-view are averaged.
876     * @param ip plane (0-5)
877     */
878    Float_t ExtTrack::GetDEDX(int ip){
879        if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0;
880        return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip));
881    };
882    
883    /**
884     * Method to evaluate the dE/dx averaged over all planes.
885     */
886    Float_t ExtTrack::GetDEDX(){
887        Float_t dedx=0;
888        for(Int_t ip=0; ip<nplanes; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip);
889        dedx = dedx/(GetNX()+GetNY());
890        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   */   */
940  int ExtTrack::GetLadder(int ip){  int ExtTrack::GetLadder(int ip){
# Line 880  Float_t ExtTrack::GetRigidity(){ Line 999  Float_t ExtTrack::GetRigidity(){
999          if(rig<0) rig=-rig;          if(rig<0) rig=-rig;
1000          return rig;          return rig;
1001  };  };
1002    //
1003    Float_t ExtTrack::GetDeflection(){
1004            Float_t def=0;
1005            if(chi2>0)def=al[4];
1006            return def;
1007    };
1008    
1009    
1010    //
1011    // all that follows: EM porting from TrkLevel2
1012    //
1013    Bool_t ExtTrack::IsInsideAcceptance(float toll){
1014        int ngf = TrkParams::nGF;
1015        float* zgf =  TrkParams::zGF;
1016        
1017        //this is a patch, to assign correctly xGF and yGF cordinates.
1018    
1019        Trajectory tj = Trajectory(ngf,zgf);
1020        tj.DoTrack(al,zini);
1021    
1022        //NB the folowing assignment is NOT permanent!!!
1023        for(int i=0; i<14; i++){
1024            xGF[i] = tj.x[i];
1025            yGF[i] = tj.y[i];
1026        }
1027    
1028        for(int i=0; i<ngf; i++){
1029            //
1030    //      cout << endl << TrkParams::GF_element[i];
1031    //      if(
1032    //          TrkParams::GF_element[i].CompareTo("S11") &&
1033    //          TrkParams::GF_element[i].CompareTo("S12") &&
1034    //          TrkParams::GF_element[i].CompareTo("S21") &&
1035    //          TrkParams::GF_element[i].CompareTo("S22") &&
1036    //          TrkParams::GF_element[i].CompareTo("T1")  &&
1037    //          TrkParams::GF_element[i].CompareTo("CUF") &&
1038    //          TrkParams::GF_element[i].CompareTo("T2")  &&
1039    //          TrkParams::GF_element[i].CompareTo("T3")  &&
1040    //          TrkParams::GF_element[i].CompareTo("T4")  &&
1041    //          TrkParams::GF_element[i].CompareTo("T5")  &&
1042    //          TrkParams::GF_element[i].CompareTo("CLF") &&
1043    //          TrkParams::GF_element[i].CompareTo("T6")  &&
1044    //          TrkParams::GF_element[i].CompareTo("S31") &&
1045    //          TrkParams::GF_element[i].CompareTo("S32") &&
1046    //          true)continue;
1047            // apply condition only within the cavity
1048    //      cout << " -- "<<xGF[i]<<" "<<yGF[i];
1049            if(
1050    //          xGF[i] <= TrkParams::xGF_min[i] + toll ||
1051    //          xGF[i] >= TrkParams::xGF_max[i] - toll ||
1052    //          yGF[i] <= TrkParams::yGF_min[i] + toll ||
1053    //          yGF[i] >= TrkParams::yGF_max[i] - toll ||
1054                tj.x[i] <= TrkParams::xGF_min[i] + toll ||
1055                tj.x[i] >= TrkParams::xGF_max[i] - toll ||
1056                tj.y[i] <= TrkParams::yGF_min[i] + toll ||
1057                tj.y[i] >= TrkParams::yGF_max[i] - toll ||
1058                false){
1059                
1060                return false;
1061            }
1062        }
1063        return true;
1064    }
1065    
1066    /**
1067     * Returns the reduced chi-square of track x-projection
1068     */
1069    Float_t  ExtTrack::GetChi2X(){
1070        float chiq=0;
1071        for(int ip=0; ip<nplanes; ip++)if(XGood(ip))chiq+= pow((xv[ip]-xm[ip])/resx[ip],2.);
1072        if(GetNX()>3)chiq=chiq/(GetNX()-3);
1073        else chiq=0;
1074        //    if(chiq==0)cout << " Float_t  ExtTrack::GetChi2X() -- WARNING -- value not defined "<<chiq<<endl;
1075        return chiq;
1076    }
1077    /**
1078     * Returns the reduced chi-square of track y-projection
1079     */
1080    Float_t  ExtTrack::GetChi2Y(){
1081        float chiq=0;
1082        for(int ip=0; ip<nplanes; ip++)if(YGood(ip))chiq+= pow((yv[ip]-ym[ip])/resy[ip],2.);
1083        if(GetNY()>2)chiq=chiq/(GetNY()-2);
1084        else chiq=0;
1085        //    if(chiq==0)cout << " Float_t  ExtTrack::GetChi2Y() -- WARNING -- value not defined "<<chiq<<endl;
1086        return chiq;
1087    }
1088    
1089    /**
1090     * Returns the track "lever-arm" on the x view, defined as the distance (in planes) between
1091     * the upper and lower x measurements (the maximum value of lever-arm is 6).
1092     */
1093    Int_t ExtTrack::GetLeverArmX(){
1094        int first_plane = -1;
1095        int last_plane  = -1;
1096        for(Int_t ip=0; ip<nplanes; ip++){
1097            if( XGood(ip) && first_plane == -1 )first_plane = ip;
1098            if( XGood(ip) && first_plane != -1 )last_plane = ip;
1099        }
1100        if( first_plane == -1 || last_plane == -1){
1101            cout<< "Int_t ExtTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl;
1102            return 0;
1103        }
1104        return (last_plane-first_plane+1);
1105    }
1106    /**
1107     * Returns the track "lever-arm" on the y view, defined as the distance (in planes) between
1108     * the upper and lower y measurements (the maximum value of lever-arm is 6).
1109     */
1110    Int_t ExtTrack::GetLeverArmY(){
1111        int first_plane = -1;
1112        int last_plane  = -1;
1113        for(Int_t ip=0; ip<nplanes; ip++){
1114            if( YGood(ip) && first_plane == -1 )first_plane = ip;
1115            if( YGood(ip) && first_plane != -1 )last_plane = ip;
1116        }
1117        if( first_plane == -1 || last_plane == -1){
1118            cout<< "Int_t ExtTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl;
1119            return 0;
1120        }
1121        return (last_plane-first_plane+1);
1122    }
1123    /**
1124     * Returns the track "lever-arm" on the x+y view, defined as the distance (in planes) between
1125     * the upper and lower x,y (couple) measurements (the maximum value of lever-arm is 6).
1126     */
1127    Int_t ExtTrack::GetLeverArmXY(){
1128        int first_plane = -1;
1129        int last_plane  = -1;
1130        for(Int_t ip=0; ip<nplanes; ip++){
1131            if( XGood(ip) && YGood(ip) && first_plane == -1 )first_plane = ip;
1132            if( XGood(ip) && YGood(ip) && first_plane != -1 )last_plane = ip;
1133        }
1134        if( first_plane == -1 || last_plane == -1){
1135    //      cout<< "Int_t ExtTrack::GetLeverArmXY() -- XGood(ip)*YGood(ip) always false ??? "<<endl;
1136            return 0;
1137        }
1138        return (last_plane-first_plane+1);
1139    }
1140    
1141    
1142    /**
1143     * Returns 1 if the signal on a tracker view is saturated.
1144     * @param ip plane (0-5)
1145     * @param iv view (0=x 1=y)
1146     */
1147    Bool_t ExtTrack::IsSaturated(int ip,int iv){
1148        if(ip>=6 && ip<8)return false;
1149        if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ;
1150        else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ;
1151        else {
1152            cout << "ExtTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl;
1153            return 0.;
1154        }
1155    };
1156    /**
1157     * Returns 1 if either the x or the y signal on a tracker plane is saturated.
1158     * @param ip plane (0-5)
1159     */
1160    Bool_t ExtTrack::IsSaturated(int ip){
1161        return (IsSaturated(ip,0)||IsSaturated(ip,1));
1162    };
1163    /**
1164     * Returns 1 if there is at least a saturated signal along the track.
1165     */
1166    Bool_t ExtTrack::IsSaturated(){
1167        for(int ip=0; ip<nplanes; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true;
1168        return false;
1169    }
1170    
1171    
1172    
1173    
1174    
1175  ClassImp(ExtTrack);  ClassImp(ExtTrack);

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

  ViewVC Help
Powered by ViewVC 1.1.23