ScintCalTrack Class Reference

#include <ScintCalTrack.h>

List of all members.

Public Member Functions

 ScintCalTrack ()
 ScintCalTrack (const NtpSRTrack *track, const MomNavigator *mom)
virtual ~ScintCalTrack ()
virtual Float_t BiggestPCorHit () const
virtual Float_t CorrectedPH (const UInt_t planeNum) const
virtual void DoPathLengthCor ()
virtual UInt_t First () const
virtual UInt_t Last () const
virtual Float_t MeanPHX (const UInt_t planeNum) const
virtual Float_t MeanPHY (const UInt_t planeNum) const
Float_t MeanPHU (const UInt_t planeNum) const
Float_t MeanPHV (const UInt_t planeNum) const
virtual Float_t MeanPHRSq (const UInt_t planeNum) const
virtual UInt_t NumPlanesCrossed () const
virtual Float_t PathLengthCor () const
virtual const ScintCalPlanePlane (const UInt_t planenum) const
virtual void RemoveFirstAndLastPlanes ()

Private Attributes

std::map< UInt_t, ScintCalPlanefmPlanes
Bool_t fpathlengthcorrected
Float_t fpathratio
const NtpSRTrackfSRtrack

Detailed Description

Definition at line 11 of file ScintCalTrack.h.


Constructor & Destructor Documentation

ScintCalTrack::ScintCalTrack (  ) 

Definition at line 19 of file ScintCalTrack.cxx.

00020 {
00021   fmPlanes.clear();
00022   fpathlengthcorrected = false;
00023   fpathratio = 1.0;
00024   fSRtrack = 0;
00025 }

ScintCalTrack::ScintCalTrack ( const NtpSRTrack track,
const MomNavigator mom 
)

Definition at line 28 of file ScintCalTrack.cxx.

References NtpSRTrack::end, fmPlanes, fpathlengthcorrected, fpathratio, fSRtrack, MomNavigator::GetFragment(), Msg::kDebug, Msg::kWarning, MSG, NtpSRTrack::nstrip, NtpSRStrip::ph0, NtpSRStrip::ph1, NtpSRStrip::plane, NtpSRVertex::plane, NtpSRPulseHeight::raw, ScintCalPlane::SingleHitUpdate(), NtpStRecord::stp, NtpSRTrack::stp, NtpSRTrack::stpx, NtpSRTrack::stpy, and NtpSRTrack::vtx.

00030 {
00031   fpathlengthcorrected = false;
00032   fpathratio = 1.0;
00033   fSRtrack = track;
00034 
00035   UInt_t pvtx = (UInt_t) fSRtrack->vtx.plane;
00036   UInt_t pend = (UInt_t) fSRtrack->end.plane;
00037   UInt_t startplane = pend;
00038   UInt_t endplane = pvtx;
00039   //Swap start and end planes if the track's going backwards.
00040   if (pend > pvtx){
00041     startplane = pvtx;
00042     endplane = pend;
00043   }
00044   
00045   //Make a map of empty planes for every plane between start and end of
00046   //track.
00047   fmPlanes.clear();
00048   for (UInt_t planenum = startplane;
00049        planenum < (endplane+1);
00050        ++planenum){
00051     fmPlanes[planenum] = ScintCalPlane(planenum);
00052   }
00053   
00054   //Get the TClonesArray of strips from Mom via the NtpStRecord.
00055   NtpStRecord* stRecord = dynamic_cast<NtpStRecord*>
00056     (mom->GetFragment("NtpStRecord"));
00057   if (!stRecord){
00058     MSG("ScintCalEvent",Msg::kWarning) 
00059       << "No NtpStRecord in Mom" << endl;
00060     return;
00061   }
00062   TClonesArray& stripArray = *(stRecord->stp);
00063   Int_t numTrkStrips = fSRtrack->nstrip;
00064   
00065   //Loop through the hits and fill the planes.
00066   for (Int_t presentStrip = 0; presentStrip < numTrkStrips; ++presentStrip){
00067     //Find the plane number of the strip.
00068     const NtpSRStrip* pstp =
00069       dynamic_cast<NtpSRStrip*>(stripArray[fSRtrack->stp[presentStrip]]);
00070     const NtpSRStrip& stp = (*pstp);
00071     UShort_t planeNo = stp.plane;
00072     //Get some useful information.
00073     Float_t hitph = stp.ph0.raw + stp.ph1.raw;
00074     Float_t hitx = track->stpx[presentStrip];
00075     Float_t hity = track->stpy[presentStrip];
00076     
00077     //Is the strip inside the track's plane range?
00078     if (startplane <= planeNo && endplane >= planeNo){
00079       //cache the scp for this plane.
00080       //(Jeff's tip: I can then use it again without doing another
00081       //binary search of the map.)
00082       ScintCalPlane& scp = fmPlanes[planeNo];
00083       //Fill the plane.
00084       scp.SingleHitUpdate(hitph, hitx, hity);
00085     }
00086     else{
00087       MSG("ScintCalEvent",Msg::kDebug) 
00088         << "Strip outside plane range! Something bad has happenned!" 
00089         << endl;
00090     }
00091   }
00092 }

ScintCalTrack::~ScintCalTrack (  )  [virtual]

Definition at line 95 of file ScintCalTrack.cxx.

References fmPlanes.

00096 {
00097   fmPlanes.clear();
00098 }


Member Function Documentation

Float_t ScintCalTrack::BiggestPCorHit (  )  const [virtual]

Definition at line 101 of file ScintCalTrack.cxx.

References fmPlanes, and it.

00102 {
00103   Float_t biggesthit = 0.0;
00104   for (map<UInt_t, ScintCalPlane>::const_iterator it = fmPlanes.begin();
00105        it != fmPlanes.end();
00106        it++){
00107     if (it->second.CorrectedPH() > biggesthit){
00108       biggesthit = it->second.CorrectedPH();
00109     }
00110   }
00111   return biggesthit;
00112 }

Float_t ScintCalTrack::CorrectedPH ( const UInt_t  planeNum  )  const [virtual]

Definition at line 115 of file ScintCalTrack.cxx.

References ScintCalPlane::CorrectedPH(), Msg::kWarning, MSG, and Plane().

Referenced by ScintCalModule::Ana().

00116 {
00117   const ScintCalPlane* requestPlane = this->Plane(planeNum);
00118   if (!requestPlane){
00119     MSG("ScintCalEvent",Msg::kWarning) 
00120       << "Asking for a non-existent plane!" 
00121       << endl;
00122     return -9999.9;
00123   }
00124   return requestPlane->CorrectedPH();
00125 }

void ScintCalTrack::DoPathLengthCor (  )  [virtual]

Definition at line 128 of file ScintCalTrack.cxx.

References NtpSRTrack::ds, NtpSRTrack::end, fmPlanes, fpathlengthcorrected, fpathratio, fSRtrack, it, NtpSRTrack::vtx, and NtpSRVertex::z.

Referenced by ScintCalModule::Ana().

00129 {
00130   if (fpathlengthcorrected){return;}
00131 
00132   Float_t pathlength = fSRtrack->ds;
00133   Float_t zlength = (fSRtrack->vtx.z) - (fSRtrack->end.z);
00134   fpathratio = fabs(pathlength/zlength);
00135 
00136   for (map<UInt_t, ScintCalPlane>::iterator it  = fmPlanes.begin();
00137        it != fmPlanes.end();
00138        it++){
00139     it->second.SetCorrectedPH( (it->second.PH())/fpathratio );
00140   }
00141   fpathlengthcorrected = true;
00142   return;
00143 }

UInt_t ScintCalTrack::First ( void   )  const [virtual]

Definition at line 146 of file ScintCalTrack.cxx.

References fmPlanes, it, Msg::kWarning, and MSG.

Referenced by ScintCalModule::Ana(), MeanPHX(), and MeanPHY().

00147 {
00148   map<UInt_t, ScintCalPlane>::const_iterator it = fmPlanes.begin();
00149   if (fmPlanes.end() == it){
00150       MSG("ScintCalEvent",Msg::kWarning) 
00151         << "This track is empty..." 
00152         << endl;
00153       return 0;
00154   }
00155   else {return it->first;}
00156 }

UInt_t ScintCalTrack::Last ( void   )  const [virtual]

Definition at line 159 of file ScintCalTrack.cxx.

References fmPlanes, it, Msg::kWarning, and MSG.

Referenced by ScintCalModule::Ana(), MeanPHX(), and MeanPHY().

00160 {
00161   map<UInt_t, ScintCalPlane>::const_iterator it = fmPlanes.end();
00162   if (fmPlanes.begin() == it){
00163       MSG("ScintCalEvent",Msg::kWarning) 
00164         << "This track is empty..." 
00165         << endl;
00166       return 0;
00167   }
00168   else{
00169     it--;
00170     return it->first;
00171   }
00172 }

Float_t ScintCalTrack::MeanPHRSq ( const UInt_t  planeNum  )  const [virtual]

Definition at line 183 of file ScintCalTrack.cxx.

References MeanPHX(), and MeanPHY().

Referenced by ScintCalModule::Ana().

00184 {
00185   Float_t x = this->MeanPHX(planeNum);
00186   if (-9999.9 == x) {return -9999.9;}
00187   Float_t y = this->MeanPHY(planeNum);
00188   if (-9999.9 == y) {return -9999.9;}
00189   Float_t rsq = x*x + y*y;
00190   return rsq;
00191 }

Float_t ScintCalTrack::MeanPHU ( const UInt_t  planeNum  )  const

Definition at line 303 of file ScintCalTrack.cxx.

References Msg::kWarning, MeanPHX(), MeanPHY(), MSG, and Plane().

Referenced by ScintCalModule::Ana().

00304 {
00305   const ScintCalPlane* requestPlane = this->Plane(planeNum);
00306   if (!requestPlane){
00307     MSG("ScintCalEvent",Msg::kWarning) 
00308       << "This track is empty..." 
00309       << endl;
00310     return -9999.9;
00311   }
00312   
00313   return (this->MeanPHX(planeNum)+this->MeanPHY(planeNum))/sqrt(2.);
00314   
00315 }

Float_t ScintCalTrack::MeanPHV ( const UInt_t  planeNum  )  const

Definition at line 318 of file ScintCalTrack.cxx.

References Msg::kWarning, MeanPHX(), MeanPHY(), MSG, and Plane().

Referenced by ScintCalModule::Ana().

00319 {
00320   const ScintCalPlane* requestPlane = this->Plane(planeNum);
00321   if (!requestPlane){
00322     MSG("ScintCalEvent",Msg::kWarning) 
00323       << "This track is empty..." 
00324       << endl;
00325     return -9999.9;
00326   }
00327   
00328   return (-this->MeanPHX(planeNum)+this->MeanPHY(planeNum))/sqrt(2.);
00329   
00330 }

Float_t ScintCalTrack::MeanPHX ( const UInt_t  planeNum  )  const [virtual]

Definition at line 194 of file ScintCalTrack.cxx.

References ScintCalPlane::CorrectedPH(), First(), Msg::kInfo, Msg::kWarning, Last(), ScintCalPlane::MeanPHX(), MSG, and Plane().

Referenced by ScintCalModule::Ana(), MeanPHRSq(), MeanPHU(), and MeanPHV().

00195 {
00196   const ScintCalPlane* requestPlane = this->Plane(planeNum);
00197   if (!requestPlane){
00198     MSG("ScintCalEvent",Msg::kWarning) 
00199       << "This track is empty..." 
00200       << endl;
00201     return -9999.9;
00202   }
00203   if (requestPlane->CorrectedPH()){
00204     return requestPlane->MeanPHX();
00205   }
00206   else{
00207     //CorrectedPH() e zero!
00208     //Get previous filled plane
00209     Int_t bDist = 0;
00210     Int_t fDist = 0;
00211     Float_t bPHX = 0.0;
00212     Float_t fPHX = 0.0;
00213     for (UInt_t b = planeNum-1; b>=this->First(); --b){
00214       bPHX = this->Plane(b)->MeanPHX();
00215       ++bDist;
00216       if (-9999.9 != bPHX){
00217         break;
00218       }//if
00219     }//for
00220     //Get next filled plane
00221     for (UInt_t f = planeNum+1; f<=this->Last(); ++f){
00222       fPHX = this->Plane(f)->MeanPHX();
00223       ++fDist;
00224       if (-9999.9 != fPHX){
00225         break;
00226       }//if
00227     }//for
00228     //zero hit correction is here!
00229     if (-9999.9 != bPHX){
00230       if(-9999.9 != fPHX){
00231         return (bPHX*fDist + fPHX*bDist)/(fDist+bDist);
00232       }//if(fPHX)
00233       else {
00234         MSG("ScintCalEvent",Msg::kInfo) 
00235           << "Zero X plane at start of track!" 
00236           << endl;
00237         return -9999.9;
00238       }//else(fPHX)
00239     }
00240     else {
00241       MSG("ScintCalEvent",Msg::kInfo) 
00242         << "Zero X plane at end of track!" 
00243         << endl;
00244       return -9999.9;
00245     }//else(bPHX)
00246   }
00247 }

Float_t ScintCalTrack::MeanPHY ( const UInt_t  planeNum  )  const [virtual]

Definition at line 250 of file ScintCalTrack.cxx.

References ScintCalPlane::CorrectedPH(), First(), Msg::kInfo, Msg::kWarning, Last(), ScintCalPlane::MeanPHY(), MSG, and Plane().

Referenced by ScintCalModule::Ana(), MeanPHRSq(), MeanPHU(), and MeanPHV().

00251 {
00252   const ScintCalPlane* requestPlane = this->Plane(planeNum);
00253   if (!requestPlane){
00254     MSG("ScintCalEvent",Msg::kWarning) 
00255       << "This track is empty..." 
00256       << endl;
00257     return -9999.9;
00258   }
00259   if (requestPlane->CorrectedPH()){
00260     return requestPlane->MeanPHY();
00261   }
00262   else{
00263     //Get previous filled plane
00264     Int_t bDist = 0;
00265     Int_t fDist = 0;
00266     Float_t bPHY = 0.0;
00267     Float_t fPHY = 0.0;
00268     for (UInt_t b = planeNum-1; b>=this->First(); --b){
00269       bPHY = this->Plane(b)->MeanPHY();
00270       ++bDist;
00271       if (-9999.9 != bPHY){
00272         break;
00273       }//if
00274     }//for
00275     for (UInt_t f = planeNum+1; f<=this->Last(); ++f){
00276       fPHY = this->Plane(f)->MeanPHY();
00277       ++fDist;
00278       if (-9999.9 != fPHY){
00279         break;
00280       }//if
00281     }//for
00282     if (-9999.9 != bPHY){
00283       if(-9999.9 != fPHY){
00284         return (bPHY*fDist + fPHY*bDist)/(fDist+bDist);
00285       }//if(fPHY)
00286       else {
00287         MSG("ScintCalEvent",Msg::kInfo) 
00288           << "Zero Y plane at start of track!" 
00289           << endl;
00290         return -9999.9;
00291       }//else(fPHY)
00292     }
00293     else {
00294       MSG("ScintCalEvent",Msg::kInfo) 
00295         << "Zero Y plane at end of track!" 
00296         << endl;
00297       return -9999.9;
00298     }//else(bPHY)
00299   }
00300 }

UInt_t ScintCalTrack::NumPlanesCrossed (  )  const [virtual]

Definition at line 175 of file ScintCalTrack.cxx.

References fmPlanes.

Referenced by ScintCalModule::Ana().

00176 {
00177   //Returns the sixe of the current ScintCalTrack,
00178   //after any plane removal that might have taken place.
00179   return (UInt_t) fmPlanes.size();
00180 }

Float_t ScintCalTrack::PathLengthCor (  )  const [virtual]

Definition at line 332 of file ScintCalTrack.cxx.

References fpathratio.

Referenced by ScintCalModule::Ana().

00333 {
00334   return fpathratio;
00335 }

const ScintCalPlane * ScintCalTrack::Plane ( const UInt_t  planenum  )  const [virtual]

Definition at line 338 of file ScintCalTrack.cxx.

References fmPlanes, and it.

Referenced by CorrectedPH(), MeanPHU(), MeanPHV(), MeanPHX(), and MeanPHY().

00339 {
00340   map<UInt_t, ScintCalPlane>::const_iterator 
00341     it = fmPlanes.find(planenum);
00342   if (fmPlanes.end() == it){return 0;}
00343   else {return &(it->second);}
00344 }

void ScintCalTrack::RemoveFirstAndLastPlanes (  )  [virtual]

Definition at line 347 of file ScintCalTrack.cxx.

References NtpSRTrack::end, fmPlanes, fSRtrack, NtpSRVertex::plane, and NtpSRTrack::vtx.

Referenced by ScintCalModule::Ana().

00348 {
00349   fmPlanes.erase(fSRtrack->vtx.plane);
00350   if (fSRtrack->vtx.plane == fSRtrack->end.plane){return;}
00351   fmPlanes.erase(fSRtrack->end.plane);
00352   return;
00353 }


Member Data Documentation

std::map<UInt_t, ScintCalPlane> ScintCalTrack::fmPlanes [private]

Definition at line 35 of file ScintCalTrack.h.

Referenced by DoPathLengthCor(), and ScintCalTrack().

Float_t ScintCalTrack::fpathratio [private]

Definition at line 36 of file ScintCalTrack.h.

Referenced by DoPathLengthCor(), PathLengthCor(), and ScintCalTrack().

Definition at line 37 of file ScintCalTrack.h.

Referenced by DoPathLengthCor(), RemoveFirstAndLastPlanes(), and ScintCalTrack().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1