AlgStripSRList Class Reference

#include <AlgStripSRList.h>

Inheritance diagram for AlgStripSRList:
AlgBase

List of all members.

Public Member Functions

 AlgStripSRList ()
virtual ~AlgStripSRList ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void RunAlgNear (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void RunAlgFar (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void RunAlgMixed (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const
std::map< CandDigitHandle
*, float > 
MakeXtalkMap (const CandDigitListHandle *cdlh, Double_t timewindow)

Private Member Functions

Bool_t PassNearNoise (TObjArray *, Float_t, StripStat *)
Bool_t PassPECut (TObjArray *)
StripStatFindWhiteBoardStats (Double_t)

Private Attributes

Bool_t fNoiseStatsSet

Detailed Description

Definition at line 21 of file AlgStripSRList.h.


Constructor & Destructor Documentation

AlgStripSRList::AlgStripSRList (  ) 

Definition at line 65 of file AlgStripSRList.cxx.

00065                               : fNoiseStatsSet(false)
00066 {
00067 }

AlgStripSRList::~AlgStripSRList (  )  [virtual]

Definition at line 69 of file AlgStripSRList.cxx.

00070 {
00071 }


Member Function Documentation

StripStat * AlgStripSRList::FindWhiteBoardStats ( Double_t  adcMin  )  [private]

Definition at line 651 of file AlgStripSRList.cxx.

References StripStat::fDoNoiseNear, StripStat::fDoNoiseStats, StripStat::fNearNoiseADC, fNoiseStatsSet, Msg::kWarning, and MSG.

Referenced by RunAlgNear().

00652 {
00653 
00654 // from George Irwin/Brian Rebel:
00655 // Find the StripStat object or create one for needed scratch space
00656         StripStat *stats = dynamic_cast<StripStat*>(gROOT->GetRootFolder()->
00657         FindObject("Loon/CandStripSR/StripStat"));
00658         if (stats == 0) {
00659                 MSG("AlgStripSRList", Msg::kWarning)
00660                 << "//root/Loon/CandStripSR/StripStat not found,"
00661                 << " although DoNoiseStats=true"
00662                 << endl;
00663         } else if (!fNoiseStatsSet) {
00664                         // the stats copies of these parameters are for
00665                         // printing only, and don't affect the Alg
00666                 stats->fDoNoiseNear=true;
00667                 stats->fDoNoiseStats=true;
00668                 stats->fNearNoiseADC=adcMin;
00669                 fNoiseStatsSet=true;
00670         }
00671 
00672         return stats;
00673 
00674 }

map< CandDigitHandle *, float > AlgStripSRList::MakeXtalkMap ( const CandDigitListHandle cdlh,
Double_t  timewindow 
)

generate map containing ratio of digitization charge to this charge + charge seen in adjacent pixels. Values near zero indicate xtalk. Diagonal pixels are not included. Charge in adjacent pixels is required to be within timewindow to be included in sum.

Definition at line 481 of file AlgStripSRList.cxx.

References NavKey::CompareValue(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), CandHandle::GetVldContext(), Detector::kNear, and StripSRKeyFromTube().

Referenced by RunAlgFar().

00481                                                                                                              {
00482 
00483   Int_t pmtcolumnsize=4;
00484   if(cdlh->GetVldContext()->GetDetector()==Detector::kNear)pmtcolumnsize=8;
00485        
00486   map<CandDigitHandle*,float> xtalkmap;
00487 
00488   // For inner loop, select digitizations on same PMT
00489  
00490   CandDigitHandleItr digitItr2(cdlh->GetDaughterIterator());
00491   CandDigitHandleKeyFunc *cdhKf = digitItr2.CreateKeyFunc();
00492   cdhKf->SetFun(StripSRKeyFromTube);
00493   digitItr2.GetSet()->AdoptSortKeyFunc(cdhKf);
00494   cdhKf = 0;
00495 
00496   CandDigitHandleItr digitItr1(cdlh->GetDaughterIterator());
00497   while (CandDigitHandle *digit1 = dynamic_cast<CandDigitHandle*>(digitItr1())) {
00498     Int_t pixel1=digit1->GetPlexSEIdAltL().GetBestItem().GetPixelSpotId().GetPixel();
00499     Int_t tube1=digit1->GetPlexSEIdAltL().GetBestItem().GetPixelSpotId().GetUniquePmtEncodedValue();
00500     Int_t ix1 = (pixel1)%pmtcolumnsize;
00501     Int_t iy1 = (Int_t)((pixel1)/pmtcolumnsize+.5);
00502     float pixelcharge = digit1->GetCharge();
00503     float xcharge = 0;
00504 
00505     // set digitIt2 to iterate over digitizations on same tube as digitItr1
00506     // Note:  This technique turned out to be a net time sink
00507     //    digitItr2.GetSet()->ClearSlice();
00508     //  digitItr2.GetSet()->Slice(tube1);
00509     
00510     digitItr2.Reset();
00511     while (CandDigitHandle *digit2 = dynamic_cast<CandDigitHandle*>(digitItr2())) {
00512       if (digit1!=digit2) {
00513         Int_t pixel2=digit2->GetPlexSEIdAltL().GetBestItem().GetPixelSpotId().GetPixel();
00514         Int_t tube2=digit1->GetPlexSEIdAltL().GetBestItem().GetPixelSpotId().GetUniquePmtEncodedValue();
00515         // break out of loop when we have passed the tube match
00516         Int_t comptube = StripSRKeyFromTube(digit2).CompareValue(tube1);
00517         if(comptube<0) break;
00518         if(tube1==tube2){
00519           if (pixel1!=pixel2) {
00520             Int_t ix2 = (pixel2)%pmtcolumnsize;
00521             Int_t iy2 = (Int_t)((pixel2)/pmtcolumnsize+.5);
00522             if(abs(ix1-ix2)+abs(iy1-iy2)==1 && 
00523                fabs(digit1->GetTime()-digit2->GetTime())<timewindow){
00524               xcharge += digit2->GetCharge();
00525             }
00526           }
00527           else if((pixel1==pixel2) &&
00528                   fabs(digit1->GetTime()-digit2->GetTime())<timewindow ){
00529             pixelcharge +=digit2->GetCharge();
00530           }
00531         }
00532       }
00533     }//end inner loop over digits to find xtalk
00534     if(xcharge+pixelcharge != 0.) xtalkmap[digit1] = pixelcharge/(xcharge+pixelcharge);
00535     else xtalkmap[digit1] = 0.;
00536   }//end loop over digit
00537   return xtalkmap;
00538 }

Bool_t AlgStripSRList::PassNearNoise ( TObjArray *  cdhAr,
Float_t  adcMin,
StripStat stats 
) [private]

Definition at line 618 of file AlgStripSRList.cxx.

References StripStat::Add(), RawChannelId::ClearModeBits(), CandDigitHandle::GetChannelId(), CandDigitHandle::GetCharge(), Msg::kDebug, CalDigitType::kNone, and MSG.

Referenced by RunAlgNear().

00620 {
00621 
00622 
00623         Int_t ndig=cdhAr->GetEntriesFast();
00624         
00625         
00626         
00627         CandDigitHandle *cdh=(CandDigitHandle*)cdhAr->First();
00628 
00629         Float_t q=cdh->GetCharge(CalDigitType::kNone);
00630 
00631         //cout << " I am getting the entries in pass near noise " << ndig << " charge  " << q  << endl;
00632 
00633         RawChannelId rcid=cdh->GetChannelId();
00634         rcid.ClearModeBits();
00635 
00636         Bool_t isnoise=( 1 == ndig  && q < adcMin) ;
00637 
00638         MSG("AlgStripSRList", Msg::kDebug) <<
00639         " encoutered RawChannelId:"<<rcid<<
00640         " ndig="<<ndig << 
00641         " ADC="<<q << 
00642         " Noise=="<<isnoise << endl;
00643 
00644         if ( stats ) stats->Add(rcid,isnoise);
00645 
00646         return !isnoise;
00647 
00648 
00649 
00650 }

Bool_t AlgStripSRList::PassPECut ( TObjArray *  cdhAr  )  [private]

Definition at line 605 of file AlgStripSRList.cxx.

References CandDigitHandle::GetCharge(), and CalDigitType::kPE.

00605                                                 {
00606   // Get the total charge
00607   Float_t totalCharge = 0.0;
00608   for(int i = 0; i < cdhAr->GetEntries(); ++i){
00609     CandDigitHandle *dig = (CandDigitHandle*)cdhAr->At(i);
00610     totalCharge += dig->GetCharge(CalDigitType::kPE);
00611   }
00612 
00613   if(totalCharge > 2.0) return true;
00614   else return false;
00615 }

void AlgStripSRList::RunAlg ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

driver routine - calls algorithm method for near, far, or mixed detectors based on validity context.

Implements AlgBase.

Definition at line 77 of file AlgStripSRList.cxx.

References RawDigitDataBlock::At(), digit(), RawDigit::GetChannel(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), RawChannelId::GetElecType(), CandContext::GetMom(), CandDigitHandle::GetRawDigitIndex(), CandHandle::GetVldContext(), Detector::kCalib, Detector::kFar, Detector::kNear, ElecType::kQIE, Msg::kWarning, MSG, RunAlgFar(), RunAlgMixed(), and RunAlgNear().

00078 {
00079    assert(cx.GetDataIn());
00080 // Check for CandDigitListHandle input
00081    if (cx.GetDataIn()->InheritsFrom("CandDigitListHandle")) {
00082       const CandDigitListHandle *cdlh =
00083             dynamic_cast<const CandDigitListHandle*>(cx.GetDataIn());
00084       const MomNavigator *mom = cx.GetMom();
00085 
00086       const RawDigitDataBlock *rddb = 
00087                 DataUtil::GetRawBlock<RawDigitDataBlock>(mom);
00088       if (!rddb) {
00089         MSG("AlgStripSRList", Msg::kWarning) << "No RawDigitDataBlock in RawRecord." << endl;
00090         return;
00091       }
00092       TIter digitItr(cdlh->GetDaughterIterator());
00093       Bool_t found(0);
00094       CandDigitHandle *digit = dynamic_cast<CandDigitHandle*>(digitItr());
00095       switch (cdlh->GetVldContext()->GetDetector()) {
00096       case Detector::kNear:
00097         RunAlgNear(ac,ch,cx);
00098         break;
00099       case Detector::kFar:
00100         RunAlgFar(ac,ch,cx);
00101         break;
00102       case Detector::kCalib:
00103          // need to check if far or near electronics
00104         while (digit && !found) {
00105           const RawDigit *rd = rddb->At(digit->GetRawDigitIndex());
00106           assert(rd);
00107           RawChannelId rawid = rd->GetChannel();
00108           if (rawid.GetElecType()==ElecType::kQIE) found=1;
00109           digit = dynamic_cast<CandDigitHandle*>(digitItr());
00110         }
00111         if (found) {
00112           RunAlgMixed(ac,ch,cx);
00113         } else {
00114           RunAlgFar(ac,ch,cx);
00115         }
00116         break;
00117       default:
00118         break;
00119       }
00120    }
00121 }

void AlgStripSRList::RunAlgFar ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

To be included in a CandStrip, the charge in a given digitization must be larger than a fixed fraction of the total charge in the 4 pixels directly adjacent to the pixel associated with this digitization. This ensures that cross talk hits are not included in CandStrips. Veto shield digitizations are rejected, as are digitizations which have a bad demux flag set. CandDigits are sorted by plane and strip, which ensures that CandDigits which will be associated into CandStrips occupy adjacent entries in this sorted list. One pass is made through the sorted list, checking for identical strip/plane values in adjacent entries. If this occurs, and the CandDigit satisfies the requirements above, the CandDigits are added to the CandStrip.

Definition at line 392 of file AlgStripSRList.cxx.

References CandHandle::AddDaughterLink(), AlgFactory::GetAlgHandle(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), PlexStripEndId::IsSameStrip(), Msg::kDebug, Msg::kWarning, CandStrip::MakeCandidate(), MakeXtalkMap(), MSG, and StripSRKeyFromPSEId().

Referenced by RunAlg().

00393 {
00394   MSG("Alg", Msg::kDebug)
00395                           << "Starting AlgStripSRList::RunAlgFar()" << endl;
00396 
00397   const CandDigitListHandle *cdlh =
00398         dynamic_cast<const CandDigitListHandle*>(cx.GetDataIn());
00399   const MomNavigator *mom = cx.GetMom();
00400 
00401   const RawDigitDataBlock *rddb = 
00402     DataUtil::GetRawBlock<RawDigitDataBlock>(mom);
00403   if (!rddb) {                                         
00404     MSG("StripSR", Msg::kWarning) << "No RawDigitDataBlock in RawRecord." << endl;
00405     return;
00406   }
00407  
00408   Int_t begplane = ac.GetInt("BegPlane");
00409   Int_t endplane = ac.GetInt("EndPlane");
00410   Double_t maxAdjPixelChargeFraction = ac.GetDouble("AdjPixelChargeFraction");
00411   Double_t timewindow=ac.GetDouble("MaxXtalkTimeWindow");
00412 
00413   // generate map containing ratio of digitization charge to 
00414   // xtalk charge associated with each digitization.
00415   // xtalk is defined to be the charge seen in adjacent pixels.  Diagonal
00416   // pixels are not included. 
00417 
00418   map<CandDigitHandle*,float> xtalkmap = MakeXtalkMap(cdlh, timewindow);
00419 
00420   /*  CandDigits are sorted by plane and strip, which ensures that CandDigits which will be  associated into CandStrips occupy adjacent entries in this sorted list. */
00421    CandDigitHandleItr cdhItr(cdlh->GetDaughterIterator());
00422    CandDigitHandleKeyFunc *cdhKf = cdhItr.CreateKeyFunc();
00423    cdhKf->SetFun(StripSRKeyFromPSEId);
00424    cdhItr.GetSet()->AdoptSortKeyFunc(cdhKf);
00425    cdhKf = 0;
00426 
00427    AlgFactory &af = AlgFactory::GetInstance();
00428    AlgHandle ah = af.GetAlgHandle("AlgStripSR","default");
00429    CandContext cxx(this,cx.GetMom());
00430 
00431    /*
00432  One pass is made through the sorted list, checking for identical strip/plane values in adjacent entries.  If this occurs, and the CandDigit satisfies the requirements above, the CandDigits are added to the CandStrip.
00433    */
00434 
00435    CandDigitHandle *prev = 0;
00436    TObjArray cdhAr;
00437    cdhAr.Clear();
00438    while (CandDigitHandle *curr = cdhItr()) {
00439      if (curr->GetPlexSEIdAltL().GetPlane()>=begplane &&
00440          curr->GetPlexSEIdAltL().GetPlane()<=endplane &&
00441          xtalkmap[curr]>=maxAdjPixelChargeFraction &&
00442          !curr->GetPlexSEIdAltL().IsVetoShield() &&
00443          !curr->GetPlexSEIdAltL().GetDemuxVetoFlag() &&
00444          curr->GetPlexSEIdAltL().GetSize()>0) {
00445        if (prev) {
00446          PlexStripEndId pSEId = prev->GetPlexSEIdAltL().GetBestSEId();
00447          PlexStripEndId cSEId = curr->GetPlexSEIdAltL().GetBestSEId();
00448          if (pSEId.IsSameStrip(cSEId)) {
00449             cdhAr.Add(curr);
00450          } else {
00451             cxx.SetDataIn(&cdhAr);
00452             CandStripHandle csh = CandStrip::MakeCandidate(ah,cxx);
00453             ch.AddDaughterLink(csh);
00454             cdhAr.Clear();
00455             cdhAr.Add(curr);
00456          }
00457       } else {
00458          cdhAr.Add(curr);
00459       }
00460       prev = curr;
00461      }
00462    }
00463    if (prev) {
00464       cxx.SetDataIn(&cdhAr);
00465       CandStripHandle csh = CandStrip::MakeCandidate(ah,cxx);
00466       ch.AddDaughterLink(csh);
00467    }
00468 
00469 
00470 
00471 }

void AlgStripSRList::RunAlgMixed ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

CandDigits are sorted by plane, strip. Nested passes are made through the sorted list. The outer loop constructs an array of candigits until a new strip id is seen. The inner loop is then made over this list of digits, which is sorted by time. Then, as in the near detector algorithm, we check that adjacent entries are within the tolerances set by the variables MaxLocTimeSep and MaxGloTimeSep. The first variable is used to check that no large time gaps occur within a CandStrip, and the second is used to ensure that the total duration of a CandStrip is sensible. If this occurs, and the CandDigit satisfies the requirements above, the CandDigits are added to the CandStrip. When one of the time sep requirements is violated, a cand strip is constructed withthe previous digits. This continues until the the digit list has been completely examined.The outer loop then proceeds to make a digitlist for the next seid, continuing until thefull CandDigitList has been examined IMPORTANT NOTE: In mixed analysis, the xtalk removal is not currently done.

Definition at line 128 of file AlgStripSRList.cxx.

References CandHandle::AddDaughterLink(), digit(), AlgFactory::GetAlgHandle(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), PlexSEIdAltL::GetPlane(), PlexSEIdAltL::GetSize(), CandDigitHandle::GetTime(), PlexStripEndId::IsSameStrip(), CandStrip::MakeCandidate(), StripSRKeyFromPSEId(), and StripSRKeyFromTime().

Referenced by RunAlg().

00129 {
00130 
00131    const CandDigitListHandle *cdlh =
00132          dynamic_cast<const CandDigitListHandle*>(cx.GetDataIn());
00133 
00134    // load parameters
00135    Double_t ldtime = ac.GetDouble("MaxLocTimeSep");
00136    Double_t gdtime = ac.GetDouble("MaxGloTimeSep");
00137    Int_t begplane = ac.GetInt("BegPlane");
00138    Int_t endplane = ac.GetInt("EndPlane");
00139    CalTimeType::CalTimeType_t caltimetype = (CalTimeType::CalTimeType_t)(ac.GetInt("CalTimeType"));
00140    
00141    /*CandDigits are sorted by plane, strip. */
00142 
00143    CandDigitHandleItr cdhItr(cdlh->GetDaughterIterator());
00144    CandDigitHandleKeyFunc *cdhKf = cdhItr.CreateKeyFunc();
00145    cdhKf->SetFun(StripSRKeyFromPSEId);
00146    cdhItr.GetSet()->AdoptSortKeyFunc(cdhKf);
00147    cdhKf = 0;
00148 
00149    AlgFactory &af = AlgFactory::GetInstance();
00150    AlgHandle ah = af.GetAlgHandle("AlgStripSR","default");
00151    CandContext cxx(this,cx.GetMom());
00152 
00153    /* Nested passes are made through the sorted list. The outer loop constructs an array of candigits  until a new strip id is seen. The inner loop is then made over this list of digits, which is sorted by time.  */
00154    CandDigitHandle *prev = 0;
00155    CandDigitHandle *first = 0;
00156    TObjArray cdhAr;
00157    cdhAr.Clear();
00158    TObjArray digitlist;
00159    digitlist.Clear();
00160    while (CandDigitHandle *curr = cdhItr()) {
00161      PlexSEIdAltL pseid = curr->GetPlexSEIdAltL();
00162      if (pseid.GetPlane()>=begplane && 
00163          pseid.GetPlane()<=endplane &&
00164          pseid.GetSize()>0) {
00165        if (prev) {
00166          PlexStripEndId pSEId = prev->GetPlexSEIdAltL().GetBestSEId();
00167          PlexStripEndId cSEId = curr->GetPlexSEIdAltL().GetBestSEId();
00168          if (pSEId.IsSameStrip(cSEId)) {
00169            digitlist.Add(curr);
00170          } else {
00171            TIter digitItr(&digitlist);
00172            CandDigitHandleItr timeItr(digitItr);
00173            CandDigitHandleKeyFunc *timeItrKf = timeItr.CreateKeyFunc();
00174            timeItrKf->SetFun(StripSRKeyFromTime);
00175            timeItr.GetSet()->AdoptSortKeyFunc(timeItrKf);
00176            timeItrKf = 0;
00177            first = 0;
00178            cdhAr.Clear();
00179            CandDigitHandle *prevdigit = 0;
00180            /* we check that adjacent entries are within the tolerances set by the variables MaxLocTimeSep and MaxGloTimeSep.  The first variable is used to check that no large time gaps occur within a CandStrip, and the second is used to ensure that the total duration of a CandStrip is sensible.*/
00181            while (CandDigitHandle *digit = timeItr()) {
00182              if (!first) {
00183                first = digit;
00184                cdhAr.Add(digit);
00185              } else if (digit->GetTime(caltimetype)-prevdigit->GetTime(caltimetype)<ldtime && 
00186                         digit->GetTime(caltimetype)-first->GetTime(caltimetype)<gdtime) {
00187                // CandDigit satisfies the requirements above, so add to the CandStrip. 
00188                cdhAr.Add(digit);
00189              } else {
00190                // else done, build this CandStrip
00191                cxx.SetDataIn(&cdhAr);
00192                CandStripHandle csh = CandStrip::MakeCandidate(ah,cxx);
00193                ch.AddDaughterLink(csh);
00194                cdhAr.Clear();
00195                cdhAr.Add(digit);
00196                first = digit;
00197              }
00198              prevdigit = digit;
00199            }
00200            if (cdhAr.GetSize()>=0) {
00201              cxx.SetDataIn(&cdhAr);
00202              CandStripHandle csh = CandStrip::MakeCandidate(ah,cxx);
00203              ch.AddDaughterLink(csh);
00204              cdhAr.Clear();
00205            }
00206            digitlist.Clear();
00207            digitlist.Add(curr);
00208          }
00209        } else {
00210          digitlist.Add(curr);
00211        }
00212        prev = curr;
00213      }
00214    }
00215  
00216    // final cleanup of digitlist to find remaining CandStrips
00217   if (digitlist.GetSize()>=0) {
00218      TIter digitItr(&digitlist);
00219      CandDigitHandleItr timeItr(digitItr);
00220      CandDigitHandleKeyFunc *timeItrKf = timeItr.CreateKeyFunc();
00221      timeItrKf->SetFun(StripSRKeyFromTime);
00222      timeItr.GetSet()->AdoptSortKeyFunc(timeItrKf);
00223      timeItrKf = 0;
00224      first = 0;
00225      cdhAr.Clear();
00226      CandDigitHandle *prevdigit = 0;
00227      while (CandDigitHandle *digit = timeItr()) {
00228        if (!first) {
00229          first = digit;
00230          cdhAr.Add(digit);
00231        } else if (digit->GetTime(caltimetype)-prevdigit->GetTime(caltimetype)<ldtime && 
00232                   digit->GetTime(caltimetype)-first->GetTime(caltimetype)<gdtime) {
00233          cdhAr.Add(digit);
00234        } else {
00235          cxx.SetDataIn(&cdhAr);
00236          CandStripHandle csh = CandStrip::MakeCandidate(ah,cxx);
00237          ch.AddDaughterLink(csh);
00238          cdhAr.Clear();
00239          cdhAr.Add(digit);
00240          first = digit;
00241        }
00242        prevdigit = digit;
00243      }
00244      if (cdhAr.GetSize()>=0) {
00245        cxx.SetDataIn(&cdhAr);
00246        CandStripHandle csh = CandStrip::MakeCandidate(ah,cxx);
00247        ch.AddDaughterLink(csh);
00248        cdhAr.Clear();
00249      }
00250      digitlist.Clear();
00251    }
00252 
00253 }

void AlgStripSRList::RunAlgNear ( AlgConfig ac,
CandHandle ch,
CandContext cx 
) [virtual]

CandDigits are sorted by plane, strip, and time, which ensures that CandDigits wwhich will be associated into CandStrips occupy adjacent entries in this sorted list, and that the CandDigit with the earliest time in a given strip and plane will appear first. One pass is made through the sorted list, checking for identical strip/plane values in adjacent entries, and checking that the time is within the tolerances set by the variables MaxLocTimeSep and MaxGloTimeSep. The first variable is used to check that no large time gaps occur within a CandStrip, and the second is used to ensure that the total duration of a CandStrip is sensible. If this occurs, and the CandDigit satisfies the requirements above, the CandDigits are added to the CandStrip.

Definition at line 260 of file AlgStripSRList.cxx.

References CandHandle::AddDaughterLink(), MuELoss::e, FindWhiteBoardStats(), fNoiseStatsSet, AlgFactory::GetAlgHandle(), PlexSEIdAltL::GetBestSEId(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), Registry::GetDouble(), AlgFactory::GetInstance(), Registry::GetInt(), CandContext::GetMom(), PlexSEIdAltL::GetPlane(), CandDigitHandle::GetPlexSEIdAltL(), PlexSEIdAltL::GetSize(), CandDigitHandle::GetTime(), PlexStripEndId::IsSameStrip(), Msg::kWarning, CandStrip::MakeCandidate(), MSG, PassNearNoise(), StripSRKeyFromPSEId(), and StripSRKeyFromTime().

Referenced by RunAlg().

00261 {
00262 
00263   // Load parameters
00264   Int_t    begplane = ac.GetInt("BegPlane");
00265   Int_t    endplane = ac.GetInt("EndPlane");
00266   Bool_t doNoiseNear=ac.GetInt("DoNoiseNear");
00267   Bool_t doNoiseStats=ac.GetInt("DoNoiseStats");
00268   Double_t nearNoiseAdc=ac.GetDouble("NearNoiseAdc");
00269 
00270   StripStat *NoiseStats=0;
00271   if (doNoiseNear&&doNoiseStats|| !fNoiseStatsSet)
00272   {
00273     NoiseStats=FindWhiteBoardStats(nearNoiseAdc);
00274   }
00275 
00276   const CandDigitListHandle *cdlh = dynamic_cast<const CandDigitListHandle*>(cx.GetDataIn());
00277 
00278   // CandDigits are sorted by plane, strip, and time. This enables us to make some
00279   // assumptions later on to really speed things up.
00280 
00281   CandDigitHandleItr cdhItr(cdlh->GetDaughterIterator());
00282   CandDigitHandleKeyFunc *cdhKf = cdhItr.CreateKeyFunc();
00283 
00284   //Rustem Ospanov: fixing NavKey bug 2005.01.20
00285   //Create NavKey for sorting by encoded PlexStripEndId
00286   //Do not sort until time NavKey is adopted
00287   cdhKf->SetFun(StripSRKeyFromPSEId);
00288   cdhItr.GetSet()->AdoptSortKeyFunc(cdhKf, kTRUE, kFALSE);
00289 
00290   //Created NavKey for sorting by time
00291   cdhKf = cdhItr.CreateKeyFunc();
00292   cdhKf -> SetFun(StripSRKeyFromTime);
00293 
00294   //Sort CandDigits first by encoded PlexStripEndId and then by time
00295   cdhItr.GetSet()->AdoptSortKeyFunc(cdhKf, kFALSE);
00296   cdhKf = 0;
00297 
00298 
00299   // Get singleton instance of AlgFactory
00300   AlgFactory &af = AlgFactory::GetInstance();
00301 
00302   // Get an AlgHandle to AlgStripSR with default AlgConfig
00303  AlgHandle ah = af.GetAlgHandle("AlgStripSR","default");
00304 
00305   // Create Candcontext
00306   CandContext cxx(this,cx.GetMom());
00307 
00308   // TObjArray to store the digits to make the strip
00309   TObjArray digitsForStrip;
00310   digitsForStrip.Clear();
00311 
00312   CalTimeType::CalTimeType_t caltimetype = (CalTimeType::CalTimeType_t)(ac.GetInt("CalTimeType"));
00313 
00314   // This digit is always set to be the previous digit in the list.
00315   CandDigitHandle *prevDigit = 0;
00316   // First hit of the current set of digits
00317   CandDigitHandle *firstOfCurrDigits = 0;
00318 
00319   // Iterate over the digit list.
00320   while (CandDigitHandle *currDigit = cdhItr()) {
00321 
00322     PlexSEIdAltL currPlexId = currDigit->GetPlexSEIdAltL();
00323 
00324     // Are we in the range of planes we want to consider?
00325     if(currPlexId.GetPlane() < begplane || currPlexId.GetPlane() > endplane || currPlexId.GetSize() < 1) continue;
00326 
00327     PlexStripEndId currStripEndId = currPlexId.GetBestSEId();
00328 
00329     // Time since the first hit in the current strip
00330     // Each bucket is approximately 19ns long
00331     const double bucketTime = 19e-9;
00332 
00333     // Is this the same strip as the last digit?
00334     bool sameStrip = false;
00335     if(prevDigit){
00336       if(currStripEndId.IsSameStrip(prevDigit->GetPlexSEIdAltL().GetBestSEId())){
00337         // Check if it occured within 3 buckets of the previous digit
00338         double timeDiff = currDigit->GetTime(caltimetype)-prevDigit->GetTime(caltimetype);
00339         if(timeDiff < 3 * bucketTime){
00340           sameStrip = true;
00341         }
00342       }
00343     }
00344     else{
00345       // If there is no previous digit, this is the first digit.
00346       digitsForStrip.Add(currDigit);
00347       firstOfCurrDigits = currDigit;
00348       prevDigit = currDigit;
00349       continue;
00350     }
00351 
00352     // Are the digits from the same strip?
00353     if(sameStrip){
00354       digitsForStrip.Add(currDigit);
00355       prevDigit = currDigit;
00356     }
00357     else{
00358       // Otherwise make the strip from the current digits in the TObjArray
00359 //      if(!doNoiseNear || (PassPECut(&digitsForStrip) && PassNearNoise(&digitsForStrip,nearNoiseAdc,NoiseStats))){
00360       if(!doNoiseNear || PassNearNoise(&digitsForStrip,nearNoiseAdc,NoiseStats)){
00361         cxx.SetDataIn(&digitsForStrip);
00362         CandStripHandle csh = CandStrip::MakeCandidate(ah,cxx);
00363         ch.AddDaughterLink(csh);
00364         if(prevDigit->GetTime(caltimetype) - firstOfCurrDigits->GetTime(caltimetype) > 1e-6){
00365                                         MSG("CandStripSR", Msg::kWarning)       << "Strip lasting at least 1us made." << std::endl;
00366                                 }
00367       }
00368       // Set up for next iteration.
00369       digitsForStrip.Clear();
00370       digitsForStrip.Add(currDigit);
00371       firstOfCurrDigits = currDigit;
00372       prevDigit = currDigit;
00373     }
00374   } // End loop over the sorted digit list.
00375 
00376   // If the loop ran then we need to deal with whatever is left at the end.
00377   if (prevDigit){
00378 //    if (!doNoiseNear || (PassPECut(&digitsForStrip) && PassNearNoise(&digitsForStrip,nearNoiseAdc,NoiseStats)))
00379     if (!doNoiseNear || PassNearNoise(&digitsForStrip,nearNoiseAdc,NoiseStats))
00380     {
00381       cxx.SetDataIn(&digitsForStrip);
00382       CandStripHandle csh = CandStrip::MakeCandidate(ah,cxx);
00383       ch.AddDaughterLink(csh);
00384     }
00385   }
00386 }

void AlgStripSRList::Trace ( const char *  c  )  const [virtual]

Reimplemented from AlgBase.

Definition at line 541 of file AlgStripSRList.cxx.

00542 {
00543 }


Member Data Documentation

Definition at line 39 of file AlgStripSRList.h.

Referenced by FindWhiteBoardStats(), and RunAlgNear().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1