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

Public Member Functions | |
| AlgFilterDigitList () | |
| virtual | ~AlgFilterDigitList () |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
| virtual void | Trace (const char *c) const |
Private Member Functions | |
| void | MakeBadChannelMap (Detector::Detector_t det) |
| FilterBadChannelMap * | MakeBadChannelMapDB (const VldContext &vc) |
Private Attributes | |
| std::string | fBadChannelFile |
| TFolder * | fTFolder |
| path and file holding bad channel info | |
|
|
Definition at line 58 of file AlgFilterDigitList.cxx. 00058 : 00059 fTFolder(0) 00060 { 00061 }
|
|
|
Definition at line 64 of file AlgFilterDigitList.cxx. References fTFolder. 00065 {
00066 FilterBadChannelMap *badChannelMap;
00067 if (fTFolder && (badChannelMap = dynamic_cast<FilterBadChannelMap*>
00068 (fTFolder->FindObject("FilterBadChannelMap")))) {
00069 fTFolder->Remove(badChannelMap);
00070 delete badChannelMap;
00071 }
00072 }
|
|
|
Definition at line 272 of file AlgFilterDigitList.cxx. References RawChannelId::AsString(), RawChannelId::ClearModeBits(), fBadChannelFile, FilterBadChannelMap::fBadChannelMap, fTFolder, RawChannelId::GetEncoded(), and MSG. Referenced by RunAlg(). 00273 {
00274 UInt_t prevEncoded = 0;
00275
00276 // make the bad channel map object
00277 FilterBadChannelMap *badChMap = new FilterBadChannelMap();
00278
00279 // open the bad channel file
00280 ifstream badChannels(fBadChannelFile.c_str());
00281
00282 if (!badChannels.is_open()) {
00283 MSG("AlgFilterDigitList", Msg::kError)
00284 << "cannot open list of bad channels,"
00285 << fBadChannelFile
00286 << " assume there are none" << endl;
00287
00288 // Add the map to the white board. AlgFilterDigitList retains ownership!
00289 fTFolder->Add(badChMap);
00290 return;
00291 }
00292
00293 // fill the map
00294 if (det==Detector::kNear) {
00295 UInt_t crate = 0;
00296 UInt_t geo = 0;
00297 UInt_t masterChannel = 0;
00298 UInt_t minderChannel = 0;
00299
00300 // read in the list of bad channels
00301 while (!badChannels.eof()) {
00302 badChannels >> crate >> geo >> masterChannel >> minderChannel;
00303
00304 // make a RawChannelId to get the encoded value
00305 #ifdef RAWCHANNELID_NEW_CTOR
00306 RawChannelId rawId(det,ElecType::kQIE, crate, geo,
00307 masterChannel, minderChannel);
00308 #else
00309 RawChannelId rawId(det,ElecType::kQIE, crate, geo,
00310 masterChannel, minderChannel, false, false);
00311 #endif
00312 rawId.ClearModeBits();
00313 MSG("AlgFilterDigitList", Msg::kDebug)
00314 << "*******filter channel********"
00315 << crate << " " << geo << " " << masterChannel << " "
00316 << minderChannel << " "
00317 << rawId.AsString("ec") << endl;
00318
00319 // if the channel is in the list it is a bad channel so the flag is true
00320 if (rawId.GetEncoded() != prevEncoded)
00321 badChMap->fBadChannelMap[rawId] = true;
00322
00323 } // end loop over input file
00324 } // end if near detector
00325
00326 // Add the map to the white board. AlgFilterDigitList retains ownership!
00327 fTFolder->Add(badChMap);
00328 return;
00329 }
|
|
|
Definition at line 333 of file AlgFilterDigitList.cxx. References FilterBadChannelMap::fBadChannelMap, CandDigitBadChannels::GetChAdd(), CandDigitBadChannels::GetCrate(), VldContext::GetDetector(), DbiResultPtr< T >::GetNumRows(), DbiResultPtr< T >::GetRow(), MAXMSG, and MSG. Referenced by RunAlg(). 00334 {
00335 //make the bad channel map object once
00336 static FilterBadChannelMap* badChMap=new FilterBadChannelMap();
00337
00338 //clear out any channels that are already in the map
00339 badChMap->fBadChannelMap.clear();
00340
00341 static Bool_t firstTime=true;
00342 if (firstTime) {
00343 firstTime=false;
00344 MAXMSG("AlgFilterDigitList",Msg::kDebug,200)
00345 <<"Running AlgFilterDigitList::MakeBadChannelMapDB for first time"
00346 <<endl;
00347 //vc.Print();
00348 }
00349
00350 //now fill the map from the database
00351 //read in the list of bad channels
00352 Int_t task=0;
00353 DbiResultPtr<CandDigitBadChannels> badChannelsPtr(vc,task);
00354
00355 MAXMSG("AlgFilterDigitList",Msg::kDebug,100)
00356 <<"Num of CandDigitBadChannels rows="
00357 <<badChannelsPtr.GetNumRows()<<endl;
00358
00359 //loop over all the bad channels and add to map
00360 for (UInt_t irow=0;irow<badChannelsPtr.GetNumRows();++irow) {
00361
00362 //get bad channel
00363 const CandDigitBadChannels& badChannel=*(badChannelsPtr.GetRow(irow));
00364
00365 MSG("AlgFilterDigitList",Msg::kDebug)
00366 <<"Crate="<<badChannel.GetCrate()
00367 <<", ChAdd="<<badChannel.GetChAdd()
00368 //<<", badnessReason="<<badChannel.GetBadness()
00369 //<<", parA="<<badChannel.GetParA()<<", parB="<<badChannel.GetParB()
00370 //<<", parC="<<badChannel.GetParC()
00371 <<endl;
00372
00373 Int_t crate=badChannel.GetCrate();
00374 Int_t chadd=badChannel.GetChAdd();
00375
00376 //deal with electronics type
00377 ElecType::Elec_t et=ElecType::kVA;
00378 if (vc.GetDetector()==Detector::kNear) et=ElecType::kQIE;
00379
00380 //make a RawChannelId to get the encoded value
00381 RawChannelId rawId(vc.GetDetector(),et,crate,chadd);
00382 rawId.ClearModeBits();
00383
00384 MAXMSG("AlgFilterDigitList",Msg::kDebug,200)
00385 << "*******filter channel********"
00386 <<rawId.AsString("ec")<<endl;
00387
00388 //add channel to map
00389 //if channel is in the list it is a bad channel so set to true
00390 badChMap->fBadChannelMap[rawId]=true;
00391 }
00392
00393 return badChMap;
00394 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 75 of file AlgFilterDigitList.cxx. References CandHandle::AddDaughterLink(), RawChannelId::AsString(), RawChannelId::ClearModeBits(), fBadChannelFile, FilterBadChannelMap::fBadChannelMap, fTFolder, Registry::Get(), CandDigitListHandle::GetAbsTime(), CandHandle::GetCandRecord(), CandDigitHandle::GetChannelId(), CandDigitHandle::GetCharge(), RawChannelId::GetCrate(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), RawChannelId::GetGeographicAddress(), CandDigitListHandle::GetIsSparse(), RawChannelId::GetMasterChannel(), RawChannelId::GetMinderChannel(), CandDigitHandle::GetQieErrorBits(), CandDigitHandle::GetSubtractedTime(), CandDigitHandle::GetVaErrorBits(), CandHandle::GetVldContext(), MakeBadChannelMap(), MakeBadChannelMapDB(), MAXMSG, MSG, CandDigitListHandle::SetAbsTime(), CandHandle::SetCandRecord(), and CandDigitListHandle::SetIsSparse(). 00077 {
00078 MSG("AlgFilterDigitList", Msg::kDebug)
00079 << "Starting AlgFilterDigitList::RunAlg()" << endl;
00080
00081 // Check for input CandDigitListHandle in CandContext
00082 assert(cx.GetDataIn());
00083
00084 // Obtain CandContext's CandDigitList as input
00085 const CandDigitListHandle *cdlh =
00086 dynamic_cast<const CandDigitListHandle *> (cx.GetDataIn());
00087 assert(cdlh); // Check for input CandDigitListHandle in CandContext
00088
00089 // Obtain filtering parameters from AlgConfig
00090 Int_t filterstrategy = 0;
00091 Float_t chargeMin = -FLT_MAX;
00092 Double_t timeMin = -FLT_MAX;
00093 Int_t errorBitsMaskVA = 0;
00094 Int_t errorBitsMaskQIE = 0;
00095
00096 Int_t tmpi = 0;
00097 Double_t tmpd = 0;
00098 const char* tmps;
00099 if (ac.Get("FilterStrategy", tmpi)) filterstrategy = tmpi;
00100 if (ac.Get("ChargeMin",tmpd)) chargeMin = tmpd;
00101 if (ac.Get("SubtractedTimeMin",tmpd)) timeMin = tmpd;
00102 if (ac.Get("ErrorBitsMaskVA",tmpi)) errorBitsMaskVA = tmpi;
00103 if (ac.Get("ErrorBitsMaskQIE",tmpi)) errorBitsMaskQIE = tmpi;
00104 if (ac.Get("BadChannelFile", tmps)) fBadChannelFile = tmps;
00105
00106 MSG("AlgFilterDigitList", Msg::kDebug) << "file = "
00107 << fBadChannelFile << " strategy = "
00108 << filterstrategy << endl;
00109
00110 // Set CandRecord pointer in new CandDigitList to that of CandDigitList
00111 ch.SetCandRecord((cdlh->GetCandRecord())); //Sub-algorithms need this
00112
00113 // Copy member variables from orig CandDigitList to new CandDigitList
00114 CandDigitListHandle &cddlh = dynamic_cast<CandDigitListHandle &>(ch);
00115 cddlh.SetAbsTime(cdlh->GetAbsTime());
00116 cddlh.SetIsSparse(cdlh->GetIsSparse());
00117
00118 // Iterate over CandContext's CandDigitList to find CandDigitHandles.
00119 TIter cdhiter = cdlh->GetDaughterIterator();
00120 TObject *tob;
00121 while ((tob = cdhiter())) {
00122 CandDigitHandle *cdh = dynamic_cast<CandDigitHandle *>(tob);
00123 if (cdh == 0) continue; // Skip daughter if not a CandDigitHandle
00124
00125 // Filter unwanted digits here
00126 // if (DontWantThisDigit(filterstrategy)) continue;
00127
00128 // Strategy 1: filter away digits that have error codes
00129 // or are below the sparsification threshold
00130 if (1==filterstrategy) {
00131 if ( cdh->GetCharge() < chargeMin ) continue;
00132 if ( cdh->GetSubtractedTime() < timeMin ) continue;
00133 if ( cdh->GetVaErrorBits() & errorBitsMaskVA ) continue;
00134 if ( cdh->GetQieErrorBits() & errorBitsMaskQIE ) continue;
00135 } // End Filter Strategy 1
00136
00137 // Strategy 2: Strategy 1 + filter away digits from known bad channels
00138 if(filterstrategy==2){
00139 MSG("AlgFilterDigitList", Msg::kDebug)
00140 << "using strategy 2" << endl;
00141
00142 // Look for the FilterBadChannelMap object on the TFolder white board.
00143 if (fTFolder==0) {
00144 TFolder *lf = dynamic_cast<TFolder*>
00145 (gROOT->GetRootFolder()->FindObject("Loon"));
00146 if (lf==0) {
00147 MSG("AlgFilterDigitList", Msg::kDebug)
00148 << "Creating Loon TFolder" << endl;
00149 lf = gROOT->GetRootFolder()->AddFolder("Loon",
00150 "Loon analysis");
00151 gROOT->GetListOfBrowsables()->Add(lf, "Loon");
00152 }
00153 fTFolder = dynamic_cast<TFolder*>(lf->FindObject("CandDigit"));
00154 if (fTFolder==0) {
00155 MSG("AlgFilterDigitList", Msg::kDebug)
00156 << "Creating Loon/CandDigit TFolder" << endl;
00157 fTFolder =
00158 lf->AddFolder("CandDigit", "CandDigit diagnostics");
00159 }
00160 }
00161
00162 FilterBadChannelMap *badChannelMap =
00163 dynamic_cast<FilterBadChannelMap*>
00164 (fTFolder->FindObject("FilterBadChannelMap"));
00165 if (badChannelMap==0) {
00166 MSG("AlgFilterDigitList", Msg::kDebug)
00167 << "Creating Loon/CandDigit/FilterBadChannelMap" << endl;
00168 MakeBadChannelMap(cdh->GetVldContext()->GetDetector());
00169 badChannelMap = dynamic_cast<FilterBadChannelMap*>
00170 (fTFolder->FindObject("FilterBadChannelMap"));
00171
00172 if ( !badChannelMap ) MSG("AlgFilterDigitList", Msg::kFatal)
00173 << "still no Loon/CandDigit/FilterBadChannelMap" << endl;
00174 }
00175
00176 // grab the RawChannelId and copy it to a local thing
00177 RawChannelId theChannel = cdh->GetChannelId();
00178 theChannel.ClearModeBits();
00179
00180 MSG("AlgFilterDigitList", Msg::kDebug) << "encoded value = "
00181 << theChannel.AsString("ec") << endl;
00182
00183 // check to see if the channel for this digit is in the bad channel map
00184 map<RawChannelId, bool>& theMap = badChannelMap->fBadChannelMap;
00185 if (theMap.find(theChannel) != theMap.end()) {
00186 MSG("AlgFilterDigitList", Msg::kDebug)
00187 << "filtering " << cdh->GetChannelId().GetCrate() << "-"
00188 << cdh->GetChannelId().GetGeographicAddress() << "-"
00189 << cdh->GetChannelId().GetMasterChannel() << "-"
00190 << cdh->GetChannelId().GetMinderChannel() << endl;
00191 continue;
00192 }
00193
00194 if ( cdh->GetCharge() < chargeMin ) continue;
00195 if ( cdh->GetSubtractedTime() < timeMin ) continue;
00196 if ( cdh->GetVaErrorBits() & errorBitsMaskVA ) continue;
00197 if ( cdh->GetQieErrorBits() & errorBitsMaskQIE ) continue;
00198
00199 } // end strategy 2
00200
00202 //Strategy 3: Strategy 1 + filter away digits from BADCHANNELS db
00203 //This uses the database so is more flexible
00205 else if(filterstrategy==3){
00206 MSG("AlgFilterDigitList",Msg::kVerbose)
00207 <<"Using filterstrategy 3"<<endl;
00208
00209 //do filter strategy 1 first
00210 if ( cdh->GetCharge() < chargeMin ) continue;
00211 if ( cdh->GetSubtractedTime() < timeMin ) continue;
00212 if ( cdh->GetVaErrorBits() & errorBitsMaskVA ) continue;
00213 if ( cdh->GetQieErrorBits() & errorBitsMaskQIE ) continue;
00214
00216 //now do the additional filter strategy
00218
00219 //create the bad channel map pointer
00220 static FilterBadChannelMap* badChannelMap=0;
00221
00222 //only create a bad channel map once per validity context
00223 static VldContext lastvc;
00224 if (*cdh->GetVldContext()!=lastvc) {
00225 MAXMSG("AlgFilterDigitList",Msg::kDebug,3)
00226 <<"AlgFilterDigitList: found new VldContext..."<<endl;
00227 //get the map of bad channels
00228 badChannelMap=this->MakeBadChannelMapDB(*cdh->GetVldContext());
00229 }
00230 assert(badChannelMap);
00231 //store the vc for next iteration of loop
00232 lastvc=*cdh->GetVldContext();
00233
00234 //check that there is actually something in the map
00235 if (badChannelMap->fBadChannelMap.size()>0) {
00236 //cache the RawChannelId
00237 RawChannelId theChannel=cdh->GetChannelId();
00238 theChannel.ClearModeBits();
00239
00240 MSG("AlgFilterDigitList",Msg::kDebug)
00241 <<"Encoded value = "<<theChannel.AsString("ec")<<endl;
00242
00243 //check to see if channel for this digit is in bad channel map
00244 map<RawChannelId, bool>& theMap = badChannelMap->fBadChannelMap;
00245 if (theMap.find(theChannel)!=theMap.end()) {
00246 MAXMSG("AlgFilterDigitList",Msg::kInfo,3)
00247 <<"AlgFilterDigitList::Filtering bad channel: "<<theChannel.AsString("ec")
00248 <<endl;
00249 continue;
00250 }
00251 }
00252 else {
00253 MAXMSG("AlgFilterDigitList",Msg::kInfo,1)
00254 <<"AlgFilterDigitList: No CandDigitBadChannels found in map"
00255 <<", skipping this filter step"<<endl;
00256 }
00257 }
00258
00259 //Effect copy of wanted digits from orig CandDigitList to daughter list
00260 CandDigitHandle cddh(*cdh);
00261 ch.AddDaughterLink(cddh, kFALSE); // Don't check for dups
00262 }
00263 }
|
|
|
Reimplemented from AlgBase. Definition at line 266 of file AlgFilterDigitList.cxx. 00267 {
00268 }
|
|
|
Definition at line 36 of file AlgFilterDigitList.h. Referenced by MakeBadChannelMap(), and RunAlg(). |
|
|
path and file holding bad channel info
Definition at line 37 of file AlgFilterDigitList.h. Referenced by MakeBadChannelMap(), RunAlg(), and ~AlgFilterDigitList(). |
1.3.9.1