AlgFilterDigitListSR Class Reference

#include <AlgFilterDigitListSR.h>

Inheritance diagram for AlgFilterDigitListSR:
AlgBase

List of all members.

Public Member Functions

 AlgFilterDigitListSR ()
virtual ~AlgFilterDigitListSR ()
virtual void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
virtual void Trace (const char *c) const

Detailed Description

Definition at line 16 of file AlgFilterDigitListSR.h.


Constructor & Destructor Documentation

AlgFilterDigitListSR::AlgFilterDigitListSR (  ) 

Definition at line 43 of file AlgFilterDigitListSR.cxx.

00044 {
00045 }

AlgFilterDigitListSR::~AlgFilterDigitListSR (  )  [virtual]

Definition at line 48 of file AlgFilterDigitListSR.cxx.

00049 {
00050 }


Member Function Documentation

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

Implements AlgBase.

Definition at line 59 of file AlgFilterDigitListSR.cxx.

References CandHandle::AddDaughterLink(), Registry::Get(), CandDigitHandle::GetChannelId(), CandDigitHandle::GetCharge(), CandContext::GetDataIn(), PlexSEIdAltL::GetPlane(), CandDigitHandle::GetPlexSEIdAltL(), PlexHandle::GetReadoutType(), CandHeader::GetRun(), CandHeader::GetSnarl(), CandDigitHandle::GetSubtractedTime(), CandDigitHandle::GetTime(), PlexSEIdAltL::IsVetoShield(), Msg::kDebug, KeyFromDigitTime(), ReadoutType::kScintStrip, Msg::kVerbose, MSG, CandDigitListHandle::SetAbsTime(), CandHandle::SetCandRecord(), and CandDigitListHandle::SetIsSparse().

00061 {
00062 
00063 
00064    MSG("FilterDigitSR", Msg::kDebug)
00065                      << "Starting AlgFilterDigitListSR::RunAlg()" << endl;
00066 
00067 // Check for input CandDigitListHandle in CandContext
00068    assert(cx.GetDataIn());
00069 
00070 // Obtain CandContext's CandDigitList as input
00071    const CandDigitListHandle *cdlh =
00072              dynamic_cast<const CandDigitListHandle *> (cx.GetDataIn());
00073    assert(cdlh);   // Check for input CandDigitListHandle in CandContext
00074 
00075 // Obtain filtering parameters from AlgConfig
00076    Int_t tmpi = 0;
00077    Double_t tmpd = 0.;
00078    Int_t filterstrategy = 0;
00079    Double_t dt_trig = 100.e-9;
00080    Double_t dt_readout = 150.e-9;
00081    Double_t dt_prereadout = 50.e-9;
00082    Int_t shieldmode = 0;
00083    if (ac.Get("FilterStrategy", tmpi)) filterstrategy = tmpi;
00084    if (ac.Get("TriggerWindow",tmpd)) dt_trig = (tmpd)*1.e-9;
00085    if (ac.Get("PostReadoutWindow",tmpd)) dt_readout = (tmpd)*1.e-9;
00086    if (ac.Get("PreReadoutWindow",tmpd)) dt_prereadout = (tmpd)*1.e-9;
00087    if (ac.Get("ShieldMode",tmpi)) shieldmode = tmpi;
00088    dt_trig = fabs(dt_trig);
00089    dt_readout = fabs(dt_readout);
00090    dt_prereadout = fabs(dt_prereadout);
00091    if (shieldmode<0 || shieldmode>2) shieldmode=0;
00092 
00093 // Set CandRecord pointer in new CandDigitList to that of CandDigitList
00094    ch.SetCandRecord((cdlh->GetCandRecord())); //Sub-algorithms need this
00095 
00096 // Copy member variables from orig CandDigitList to new CandDigitList
00097    CandDigitListHandle &cddlh = dynamic_cast<CandDigitListHandle &>(ch);
00098    cddlh.SetIsSparse(cdlh->GetIsSparse());
00099    cddlh.SetAbsTime(cdlh->GetAbsTime());
00100 
00101 // Get VldContext
00102    const VldContext &vldc = *(cdlh->GetCandRecord()->GetVldContext());
00103 
00104    PlexHandle ph(vldc);
00105 
00106 // Iterate over CandContext's CandDigitList to find CandDigitHandles.
00107    CandDigitHandleItr cdhiter(cdlh->GetDaughterIterator());
00108    CandDigitHandleKeyFunc *cdhKf = cdhiter.CreateKeyFunc();
00109    cdhKf->SetFun(KeyFromDigitTime);
00110    cdhiter.GetSet()->AdoptSortKeyFunc(cdhKf);
00111    cdhKf = 0;
00112 
00113    Float_t totadc = 0.;
00114    Float_t totadcfilter = 0.;
00115 
00116    Double_t endtime = 0.;
00117    TObject *tob;
00118    TObjArray digitlist;
00119    map<CandDigitHandle*,Bool_t> shielddigitmap;
00120    map<CandDigitHandle*,Bool_t>::iterator shielddigitmapiter;
00121    while ((tob = cdhiter())) {
00122      CandDigitHandle *cdh = dynamic_cast<CandDigitHandle *>(tob);
00123      if (cdh == 0) continue;   // Skip daughter if not a CandDigitHandle
00124      Bool_t isshielddigit = 0;
00125      if (cdh->GetPlexSEIdAltL().IsVetoShield()) isshielddigit=1;
00126      if (shieldmode==2 && isshielddigit) continue;
00127      if (isshielddigit) shielddigitmap[cdh] = 1;
00128      if (ph.GetReadoutType(cdh->GetChannelId()) != ReadoutType::kScintStrip) continue;
00129      if (!isshielddigit && cdh->GetSubtractedTime()<0.) continue; // pre digits not counted -- the 4/5 trigger calculation in the DAQ was done with digits GetSubtractedTime()>=0
00130      if (cdh->GetSubtractedTime()>endtime) endtime = cdh->GetSubtractedTime();
00131      totadc += cdh->GetCharge();
00132      digitlist.Add(cdh);
00133    }
00134 
00135 
00136    CandDigitHandle *gooddgt = 0;
00137    Float_t goodadc = 0.;
00138    Int_t timeplane[500]; // used to eliminate redundant calculations
00139    for (int i=0; i<500; i++) {
00140      timeplane[i] = -999999999;
00141    }
00142    for (int i=0; i<=digitlist.GetLast(); i++) {
00143      CandDigitHandle *dgt0 = dynamic_cast<CandDigitHandle*>(digitlist.At(i));
00144      shielddigitmapiter = shielddigitmap.find(dgt0);
00145      if (shielddigitmapiter!=shielddigitmap.end()) continue; // don't use shield digits for 4/5 calculation
00146      Float_t trigplane[500];
00147      for (int j=0; j<500; j++) trigplane[j] = 0.;
00148      Int_t iplane0 = dgt0->GetPlexSEIdAltL().GetPlane();
00149      if (iplane0<=0 ||iplane0>=500) continue;
00150      if (dgt0->GetSubtractedTime()<=timeplane[iplane0]) continue;
00151      timeplane[iplane0] = (Int_t)(dgt0->GetSubtractedTime()*1.e9);
00152      trigplane[iplane0] = dgt0->GetCharge();
00153      CandDigitHandle *dgt1 = 0;
00154      Int_t ipln0=iplane0;
00155      Int_t ipln1=iplane0;
00156      for (int j=i+1; j<=digitlist.GetLast() && (!dgt1 || dgt1->GetSubtractedTime()-dgt0->GetSubtractedTime()<=dt_trig); j++) {
00157        dgt1 = dynamic_cast<CandDigitHandle*>(digitlist.At(j));
00158        Int_t iplane1 = dgt1->GetPlexSEIdAltL().GetPlane();
00159        if (iplane1<=0 ||iplane1>=500) continue;
00160        trigplane[iplane1] += dgt1->GetCharge();
00161        if (iplane1<ipln0) ipln0 = iplane1;
00162        if (iplane1>ipln1) ipln1 = iplane1;
00163      }
00164      for (int iplane = ipln0; iplane<=ipln1-3; iplane++) {
00165        Int_t nhitplane = 0;
00166        Int_t mintrigplane = 9999;
00167        Int_t maxtrigplane = -1;
00168        Float_t thisadc = 0.;
00169        for (int dplane=0; dplane<5 && iplane+dplane<=ipln1; dplane++) {
00170          if (trigplane[iplane+dplane]>0.) {
00171            nhitplane++;
00172            thisadc += trigplane[iplane+dplane];
00173            if (iplane+dplane<mintrigplane) mintrigplane = iplane+dplane;
00174            if (iplane+dplane>maxtrigplane) maxtrigplane = iplane+dplane;
00175          }
00176        }
00177        if (nhitplane>=4 && iplane0>=mintrigplane && iplane0<=maxtrigplane && thisadc>goodadc) {
00178          gooddgt = dgt0;
00179          goodadc = thisadc;
00180        }
00181      }
00182    }
00183 
00184    if (gooddgt) {
00185      cddlh.SetAbsTime(gooddgt->GetTime());
00186      for (int i=0; i<=digitlist.GetLast(); i++) {
00187        CandDigitHandle *dgt = dynamic_cast<CandDigitHandle*>(digitlist.At(i));
00188        Bool_t isshielddigit = 0;
00189        shielddigitmapiter = shielddigitmap.find(dgt);
00190        if (shielddigitmapiter!=shielddigitmap.end()) isshielddigit = 1;
00191        if ((isshielddigit && shieldmode==0) || (gooddgt->GetSubtractedTime()-dgt->GetSubtractedTime()<=dt_prereadout && gooddgt->GetSubtractedTime()-dgt->GetSubtractedTime()>=0.) || (dgt->GetSubtractedTime()-gooddgt->GetSubtractedTime()<=dt_readout && dgt->GetSubtractedTime()-gooddgt->GetSubtractedTime()>=0.)) {
00192          CandDigitHandle cddh(*dgt);
00193          ch.AddDaughterLink(cddh, kFALSE);           // Don't check for dups
00194          totadcfilter += cddh.GetCharge();
00195          MSG("FilterDigitSR",Msg::kVerbose) << "adding digit, plane " << dgt->GetPlexSEIdAltL().GetPlane() << " relative time " << (dgt->GetSubtractedTime()-gooddgt->GetSubtractedTime())*1.e9 << " isshield " << isshielddigit << endl;
00196        }
00197      }
00198    }
00199 
00200    const CandHeader *candheader = cdlh->GetCandRecord()->GetCandHeader();
00201    assert(candheader);
00202    double fraction = 0;
00203    if (totadc != 0) fraction = totadcfilter/totadc;
00204 
00205    MSG("FilterDigitSR",Msg::kDebug) << "Run " << candheader->GetRun() << " Snarl " << candheader->GetSnarl() << " trigger = " << (gooddgt ? 1 : 0) << " adc = " << totadc << " fraction = " << fraction << " timelength = " << endtime*1.e9 << endl;
00206 
00207 
00208 }

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

Reimplemented from AlgBase.

Definition at line 211 of file AlgFilterDigitListSR.cxx.

00212 {
00213 }


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1