#include <AlgFilterDigitListSR.h>
Inheritance diagram for AlgFilterDigitListSR:

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