DmxHypothesis Class Reference

#include <DmxHypothesis.h>

List of all members.

Public Member Functions

 DmxHypothesis ()
 DmxHypothesis (AlgConfig &acd, CandDeMuxDigitHandleItr &cdhitr, Int_t lowerStrip, Int_t upperStrip)
virtual ~DmxHypothesis ()
Float_t GetCoG () const
Int_t GetCompareFlag () const
Int_t GetLowerBound () const
Float_t GetMatedSignalRatio () const
Int_t GetNumberOfStripsUsed () const
Float_t GetStat () const
DmxStatisticGetStatObject () const
Float_t GetTieBreakerStat () const
Float_t GetTimingOffset (UgliGeomHandle *ugh)
Int_t GetUpperBound () const
Bool_t IsValid () const
void PrintRecon ()
void SetStrips ()

Private Attributes

bool fAllUsed
CandDeMuxDigitHandleItr fCdhit
Int_t fCompare
Float_t fCoG
Int_t fLowerBound
Int_t fMaxSeparation
Float_t fMatedSignalRatio
Float_t fRequiredMatedSignalRatio
DmxStatisticfStat
Int_t fStripsUsed
Int_t fUpperBound

Detailed Description

Definition at line 26 of file DmxHypothesis.h.


Constructor & Destructor Documentation

DmxHypothesis::DmxHypothesis (  ) 

Definition at line 37 of file DmxHypothesis.cxx.

00037                              :
00038   fStat(0)
00039 {
00040 }

DmxHypothesis::DmxHypothesis ( AlgConfig acd,
CandDeMuxDigitHandleItr &  cdhitr,
Int_t  lowerStrip,
Int_t  upperStrip 
)

Definition at line 43 of file DmxHypothesis.cxx.

References fAllUsed, fCdhit, fCoG, fLowerBound, fMatedSignalRatio, fStat, fStripsUsed, fUpperBound, CandDigitHandle::GetCharge(), PlexSEIdAltL::GetCurrentSEId(), CandDeMuxDigitHandle::GetDeMuxDigitFlagWord(), PlexSEIdAltL::GetEnd(), CandDigitHandle::GetPlexSEIdAltL(), PlexStripEndId::GetStrip(), PlexSEIdAltL::IsValid(), StripEnd::kEast, StripEnd::kWest, PlexSEIdAltL::Next(), and PlexSEIdAltL::SetFirst().

00044                                                                  :
00045   fAllUsed(true),
00046   fCdhit(cdhitr),
00047   fCompare(0),
00048   fCoG(0.),
00049   fLowerBound(lowerStrip),
00050   fMaxSeparation(23),
00051   fMatedSignalRatio(0.0),
00052   fRequiredMatedSignalRatio(acd.GetDouble("RatioMatedSignalForValid")),
00053   fStat(0),
00054   fStripsUsed(0),
00055   //fTimeOffset(-10.),
00056   fUpperBound(upperStrip)
00057 {
00058   
00059   fCdhit.Reset();
00060 
00061   //loop over the digits to set the values
00062 
00063   //variables to calculate the center of gravity for the hypothesis
00064   Float_t numerator = 0.;       
00065   Float_t denominator = 0.;
00066 
00067   //initialize the signal and strip arrays
00068   Float_t signalE[192];
00069   Float_t signalW[192];
00070 
00071   //make arrays to hold the clear fiber + wls pigtail lengths for each digit
00072   //Float_t westFiber[192];
00073   //Float_t eastFiber[192];
00074   //Float_t eastTime[192];
00075   //Float_t westTime[192];
00076 
00077   //reset the arrays
00078   for(Int_t i = 0; i<192; i++){
00079    }
00080 
00081   for(Int_t vv = 0; vv < 192; vv++){
00082     signalE[vv] = 0.;
00083     signalW[vv] = 0.;
00084     //westFiber[vv] = -1.;
00085     //eastFiber[vv] = -1.;
00086     //eastTime[vv] = -1.;
00087     //westTime[vv] = -1.;
00088  }
00089 
00090   while( fCdhit.IsValid() ){
00091     
00092     //get the next CandDeMuxDigitHanlde object
00093     CandDeMuxDigitHandle *currentDigit = fCdhit.Ptr();
00094     
00095     //set the alternatives list to the first one
00096     currentDigit->GetPlexSEIdAltL().SetFirst();
00097       
00098     //loop through the Strip End Alternative list and see which one is
00099     //in the current hypothesis
00100     
00101     bool digitUsed = false;
00102 
00103     while( currentDigit->GetPlexSEIdAltL().IsValid() ){
00104       Int_t strip = currentDigit->GetPlexSEIdAltL().GetCurrentSEId().GetStrip();
00105       if(strip >= fLowerBound && strip <= fUpperBound){
00106 
00107         //if the flag isnt set, then use the digit - flags are set only if
00108         //the signal fraction is below the limit or the signal is too low
00109         if(currentDigit->GetDeMuxDigitFlagWord() == 0){
00110           
00111           digitUsed = true;
00112           
00113           if( currentDigit->GetPlexSEIdAltL().GetEnd() == StripEnd::kEast ){
00114             signalE[strip] = currentDigit->GetCharge();
00115             //MSG("DmxHyp", Msg::kDebug)<<"\teast strip " << strip << " charge " << signalE[strip] << endl;
00116           }
00117           else if( currentDigit->GetPlexSEIdAltL().GetEnd() == StripEnd::kWest ){
00118             signalW[strip] = currentDigit->GetCharge();
00119             //MSG("DmxHyp", Msg::kDebug)<<"\twest strip " << strip << " charge " << signalW[strip] << endl;
00120           }
00121           
00122           numerator += currentDigit->GetCharge() * strip;
00123           denominator += currentDigit->GetCharge();
00124                 
00125         }//end if this is a good digit to use
00126 
00127         //you found the strip for this digit, so break the loop
00128         break;
00129       }//end if stripend is in hypothesis limit
00130 
00131       //if that Strip End Id wasnt in the hypothesis go to the next one
00132       currentDigit->GetPlexSEIdAltL().Next();
00133 
00134     }//end loop over strip ends
00135     
00136     if( !digitUsed && currentDigit->GetDeMuxDigitFlagWord() == 0){ fAllUsed = false; }
00137     //advance to the next digit
00138     fCdhit.Next(); 
00139   }//end loop over digits
00140 
00141   fCdhit.ResetFirst();
00142 
00143   //find the mated signal and get the timing offset for this hypothesis
00144   //also see how many strips are used in this hypothesis
00145   Float_t matches = 0.0;
00146 
00147   for(Int_t j = 0; j < 192; j++){
00148           if( signalW[j] > 0. && signalE[j] > 0.)
00149                   matches += signalW[j] + signalE[j]; 
00150           if(signalW[j]>0. || signalE[j]>0.) ++fStripsUsed;
00151   }
00152   
00153   if(denominator > 0.){
00154     fCoG = numerator / denominator;
00155     fMatedSignalRatio = matches / denominator;
00156   }
00157 
00158   //get the correct DmxStatistic object from the AlgDeMuxConfig object
00159       
00160   //if(acd.GetStatParameter() == DmxStatTypes::kChi2){ 
00161     fStat = new DmxChiSqrStat(signalW, signalE, fCoG); 
00162     //}
00163     //else if(acd.GetStatParameter() == DmxStatTypes::kRms){ 
00164     //fStat = new DmxRMSStat(signalW, signalE, fCoG); 
00165     //}
00166   
00167   return;
00168 }

DmxHypothesis::~DmxHypothesis (  )  [virtual]

Definition at line 171 of file DmxHypothesis.cxx.

References fStat.

00172 {
00173   //MSG("Dmx", Msg::kVerbose) << "deleting DmxHypothesis with lowerbound = " 
00174   //              << fLowerBound << endl;
00175   delete fStat;
00176 }


Member Function Documentation

Float_t DmxHypothesis::GetCoG (  )  const
Int_t DmxHypothesis::GetCompareFlag (  )  const

Definition at line 191 of file DmxHypothesis.cxx.

References fCompare.

00192 {
00193   return fCompare;
00194 }

Int_t DmxHypothesis::GetLowerBound (  )  const

Definition at line 197 of file DmxHypothesis.cxx.

References fLowerBound.

00198 {
00199   return fLowerBound;
00200 }

Float_t DmxHypothesis::GetMatedSignalRatio (  )  const

Definition at line 203 of file DmxHypothesis.cxx.

References fMatedSignalRatio.

Referenced by AlgDeMuxBeam::DeMuxFirstNPlanesTest(), and DmxShowerPlane::DmxShowerPlane().

00204 {
00205   return fMatedSignalRatio;
00206 }

Int_t DmxHypothesis::GetNumberOfStripsUsed (  )  const

Definition at line 179 of file DmxHypothesis.cxx.

References fStripsUsed.

Referenced by DmxShowerPlane::DmxShowerPlane().

00180 {
00181         return fStripsUsed;
00182 }

Float_t DmxHypothesis::GetStat (  )  const

Definition at line 209 of file DmxHypothesis.cxx.

References fStat, and DmxStatistic::GetGoodness().

Referenced by DmxShowerPlane::CompareHypotheses(), and KeyStat().

00210 {
00211   return fStat->GetGoodness();
00212 }

DmxStatistic * DmxHypothesis::GetStatObject (  )  const

Definition at line 215 of file DmxHypothesis.cxx.

References fStat.

00216 {
00217   return fStat;
00218 }

Float_t DmxHypothesis::GetTieBreakerStat (  )  const

Definition at line 221 of file DmxHypothesis.cxx.

References fStat, and DmxStatistic::GetTieBreaker().

Referenced by DmxShowerPlane::CompareHypotheses().

00222 {
00223   return fStat->GetTieBreaker();
00224 }

Float_t DmxHypothesis::GetTimingOffset ( UgliGeomHandle ugh  ) 

Definition at line 329 of file DmxHypothesis.cxx.

References UgliStripHandle::ClearFiber(), digit(), fCdhit, PlexSEIdAltL::GetBestSEId(), CandDigitHandle::GetCharge(), CandDeMuxDigitHandle::GetDeMuxDigitFlagWord(), PlexSEIdAltL::GetDemuxVetoFlag(), PlexSEIdAltL::GetEnd(), CandDigitHandle::GetPlexSEIdAltL(), PlexStripEndId::GetStrip(), UgliGeomHandle::GetStripHandle(), CandDigitHandle::GetTime(), StripEnd::kEast, CalTimeType::kT0, StripEnd::kWest, and UgliStripHandle::WlsPigtail().

Referenced by DmxShowerPlane::GetTimingOffset().

00330 {
00331   
00332   //make arrays to hold the clear fiber + wls pigtail lengths for each digit
00333   Float_t westFiber[192];
00334   Float_t eastFiber[192];
00335   Float_t eastTime[192];
00336   Float_t westTime[192];
00337 
00338   //reset the arrays
00339   for(Int_t i = 0; i<192; i++){
00340     westFiber[i] = -1.;
00341     eastFiber[i] = -1.;
00342     eastTime[i] = -1.;
00343     westTime[i] = -1.;
00344   }
00345 
00346   //MSG("DmxHyp", Msg::kDebug) << "starting the timing offset in hypothesis" << endl;
00347     
00348   fCdhit.ResetFirst();
00349   //MSG("DmxHyp", Msg::kDebug) << "reset digit iterator in hypothesis" << endl;
00350 
00351   while(fCdhit.IsValid()){
00352     
00353     CandDeMuxDigitHandle *digit = fCdhit.Ptr();
00354     
00355     if(digit->GetPlexSEIdAltL().GetDemuxVetoFlag() == 0 && digit->GetDeMuxDigitFlagWord() == 0){
00356       
00357       Int_t strip = digit->GetPlexSEIdAltL().GetBestSEId().GetStrip();
00358       
00359       //get the side for this digit and fill the array
00360       UgliStripHandle ush = ugh->GetStripHandle(digit->GetPlexSEIdAltL().GetBestSEId());
00361         
00362       if( digit->GetPlexSEIdAltL().GetEnd() == StripEnd::kEast ){
00363         eastFiber[strip] = ush.ClearFiber(StripEnd::kEast) + ush.WlsPigtail(StripEnd::kEast);
00364         eastTime[strip] = 1e9*digit->GetTime(CalTimeType::kT0) - 2093./(102.+TMath::Power(1.*digit->GetCharge(),1.2));
00365       }
00366       else if( digit->GetPlexSEIdAltL().GetEnd() == StripEnd::kWest ){
00367         westFiber[strip] = ush.ClearFiber(StripEnd::kWest) + ush.WlsPigtail(StripEnd::kWest);
00368         westTime[strip] = 1e9*digit->GetTime(CalTimeType::kT0) - 2093./(102.+TMath::Power(1.*digit->GetCharge(),1.2));
00369       }
00370       
00371     }
00372     fCdhit.Next();
00373   }
00374   
00375   //find the average offset from center for this plane based on timing and fill the array
00376   Float_t avTimeNum = 0.;
00377   Float_t avTimeDenom = 0.;
00378   Float_t offset = -10.;
00379   for(Int_t k=0; k<192; k++){
00380     
00381     //if the strip has doubled sided readout, then use it
00382     if(westTime[k] != -1.&& eastTime[k] != -1.){
00383       offset = (0.0825*(eastTime[k] - westTime[k]) + (westFiber[k]-eastFiber[k])/2.);
00384       //MSG("DmxTim", Msg::kDebug) << "shower plane offset = " << offset << endl;
00385       avTimeNum += offset;
00386       avTimeDenom += 1.;
00387     }
00388   }
00389         
00390   if(avTimeDenom>0) offset = avTimeNum/avTimeDenom;
00391   //MSG("DmxTim", Msg::kDebug) << "shower plane offset = " << offset << endl;
00392        
00393   //clear the digit slice
00394   fCdhit.Reset();
00395 
00396   return offset;
00397 } 

Int_t DmxHypothesis::GetUpperBound (  )  const

Definition at line 227 of file DmxHypothesis.cxx.

References fUpperBound.

00228 {
00229   return fUpperBound;
00230 }

Bool_t DmxHypothesis::IsValid (  )  const

Definition at line 233 of file DmxHypothesis.cxx.

References fAllUsed, fMatedSignalRatio, and fRequiredMatedSignalRatio.

00234 {
00235   //MSG("Dmx", Msg::kDebug) << "used flag = " << fAllUsed 
00236   //              << " for lowerbound = " << fLowerBound << endl;
00237   //return fMaxSeparation<24 && fMaxSeparation>0 && fAllUsed>0 && fMatedSignalRatio>0.3;
00238   //return fAllUsed>0 && fMatedSignalRatio>fRequiredMatedSignalRatio;
00239   return fMatedSignalRatio>fRequiredMatedSignalRatio && fAllUsed;
00240 }

void DmxHypothesis::PrintRecon (  ) 

Definition at line 243 of file DmxHypothesis.cxx.

References fCdhit, fLowerBound, fStat, fUpperBound, DmxStatistic::GetGoodness(), DmxStatistic::GetTieBreaker(), StripEnd::kEast, Msg::kInfo, StripEnd::kWest, and MSG.

Referenced by DmxShowerPlane::PrintRecon().

00244 {
00245   MSG("DMX", Msg::kInfo) << "\tLower Bound = " << fLowerBound
00246                          << "\tGoodness of Fit = " << fStat->GetGoodness()
00247                          << "\tTieBreaker = " << fStat->GetTieBreaker() << endl;
00248   while( fCdhit.IsValid() ){
00249     while( fCdhit.Ptr()->GetPlexSEIdAltL().IsValid() ){
00250         if( fCdhit.Ptr()->GetPlexSEIdAltL().GetCurrentSEId().GetStrip() >= fLowerBound && 
00251             fCdhit.Ptr()->GetPlexSEIdAltL().GetCurrentSEId().GetStrip() <= fUpperBound){
00252 
00253           if( fCdhit.Ptr()->GetPlexSEIdAltL().GetEnd() == StripEnd::kWest ){
00254             MSG("DMX", Msg::kInfo)<< "\t\tWest\t" 
00255                                   << fCdhit.Ptr()->GetPlexSEIdAltL().GetCurrentSEId().GetStrip() 
00256                                   << "\t" << fCdhit.Ptr()->GetCharge() << endl;
00257           }
00258           if( fCdhit.Ptr()->GetPlexSEIdAltL().GetEnd() == StripEnd::kEast ){
00259             MSG("DMX", Msg::kInfo)<< "\t\tEast\t" 
00260                                   << fCdhit.Ptr()->GetPlexSEIdAltL().GetCurrentSEId().GetStrip() 
00261                                   << "\t" << fCdhit.Ptr()->GetCharge() << endl;
00262           }
00263         }
00264     }
00265     fCdhit.Next();
00266   }
00267 
00268   return;
00269 }

void DmxHypothesis::SetStrips (  ) 

Definition at line 272 of file DmxHypothesis.cxx.

References PlexSEIdAltL::ClearWeights(), fCdhit, fLowerBound, fUpperBound, PlexSEIdAltL::GetCurrentSEId(), CandDigitHandle::GetPlexSEIdAltL(), CandDigitHandle::GetPlexSEIdAltLWritable(), PlexStripEndId::GetStrip(), PlexSEIdAltL::IsValid(), PlexSEIdAltL::Next(), PlexSEIdAltL::SetCurrentWeight(), PlexSEIdAltL::SetDemuxVetoFlag(), and PlexSEIdAltL::SetFirst().

00273 {
00274   fCdhit.Reset();
00275   while( fCdhit.IsValid() ){
00276     
00277     //get the next CandDigitHanlde object
00278     CandDeMuxDigitHandle *currentDigit = fCdhit.Ptr();
00279     
00280     //clear all weights for the digit
00281     currentDigit->GetPlexSEIdAltLWritable().ClearWeights();
00282     
00283     //set the alternatives list to the first one
00284     currentDigit->GetPlexSEIdAltL().SetFirst();
00285       
00286     //set the veto flag to nonzero, if the digit has a SEId in this hypothesis
00287     //set it back to 0
00288     currentDigit->GetPlexSEIdAltLWritable().SetDemuxVetoFlag(1);
00289 
00290     //loop through the Strip End Alternative list and see which one is
00291     //in the current hypothesis
00292       
00293     while( currentDigit->GetPlexSEIdAltL().IsValid() ){
00294         if( currentDigit->GetPlexSEIdAltL().GetCurrentSEId().GetStrip() >= fLowerBound && 
00295             currentDigit->GetPlexSEIdAltL().GetCurrentSEId().GetStrip() <= fUpperBound){
00296 
00297           //set the Strip weight to 1 if it is in the hypothesis and veto flag to 0
00298           currentDigit->GetPlexSEIdAltLWritable().SetCurrentWeight(1.0);
00299           currentDigit->GetPlexSEIdAltLWritable().SetDemuxVetoFlag(0);
00300 
00301           //print the association
00302           //MSG("Dmx", Msg::kDebug) << "strip = " 
00303           //  << currentDigit->GetPlexSEIdAltLWritable().GetCurrentSEId().GetStrip() 
00304           //      << "\tside = " 
00305           //      << (Int_t)currentDigit->GetPlexSEIdAltLWritable().GetCurrentSEId().GetEnd() 
00306           //      << "\tsignal = " << currentDigit->GetCharge() 
00307           //  << endl;
00308 
00309           //you found the Strip End Id in the current hypothesis so quit looking
00310           break;
00311         }
00312         //if that Strip End Id wasnt in the hypothesis go to the next one
00313         currentDigit->GetPlexSEIdAltL().Next();
00314     }
00315     
00316     fCdhit.Next();
00317   }
00318   fCdhit.Reset();
00319 }


Member Data Documentation

bool DmxHypothesis::fAllUsed [private]

Definition at line 54 of file DmxHypothesis.h.

Referenced by DmxHypothesis(), and IsValid().

CandDeMuxDigitHandleItr DmxHypothesis::fCdhit [private]

Definition at line 55 of file DmxHypothesis.h.

Referenced by DmxHypothesis(), GetTimingOffset(), PrintRecon(), and SetStrips().

Float_t DmxHypothesis::fCoG [private]

Definition at line 57 of file DmxHypothesis.h.

Referenced by DmxHypothesis(), and GetCoG().

Int_t DmxHypothesis::fCompare [private]

Definition at line 56 of file DmxHypothesis.h.

Referenced by GetCompareFlag().

Int_t DmxHypothesis::fLowerBound [private]

Definition at line 58 of file DmxHypothesis.h.

Referenced by DmxHypothesis(), GetLowerBound(), PrintRecon(), and SetStrips().

Definition at line 60 of file DmxHypothesis.h.

Referenced by DmxHypothesis(), GetMatedSignalRatio(), and IsValid().

Definition at line 59 of file DmxHypothesis.h.

Definition at line 62 of file DmxHypothesis.h.

Referenced by IsValid().

Int_t DmxHypothesis::fStripsUsed [private]

Definition at line 66 of file DmxHypothesis.h.

Referenced by DmxHypothesis(), and GetNumberOfStripsUsed().

Int_t DmxHypothesis::fUpperBound [private]

Definition at line 68 of file DmxHypothesis.h.

Referenced by DmxHypothesis(), GetUpperBound(), PrintRecon(), and SetStrips().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1