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