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

Public Types | |
| enum | EListTypes { kDataList = BIT(0), kMCList = BIT(1), kDataAndMC = (kDataList | kMCList) } |
Public Member Functions | |
| DigitListModule () | |
| ~DigitListModule () | |
| void | BeginJob () |
| void | Config (const Registry &r) |
| const Registry & | DefaultConfig () const |
| JobCResult | Get (MomNavigator *mom) |
| JobCResult | Reco (MomNavigator *mom) |
|
|
Definition at line 24 of file DigitListModule.h. 00024 {
00025 kDataList = BIT(0),
00026 kMCList = BIT(1),
00027 kDataAndMC = (kDataList | kMCList)
00028 };
|
|
|
Definition at line 51 of file DigitListModule.cxx. References MSG. 00052 {
00053 MSG("Digit", Msg::kVerbose) << "DigitListModule::Constructor\n";
00054 }
|
|
|
Definition at line 57 of file DigitListModule.cxx. References MSG. 00058 {
00059 MSG("Digit", Msg::kVerbose) << "DigitListModule::Destructor\n";
00060 }
|
|
|
Implement for notification of begin of job Reimplemented from JobCModule. Definition at line 63 of file DigitListModule.cxx. References Registry::Get(), AlgHandle::GetAlgConfig(), AlgFactory::GetAlgHandle(), JobCModule::GetConfig(), AlgFactory::GetInstance(), and MSG. 00064 {
00065 MSG("Digit", Msg::kVerbose) << "DigitListModule::BeginJob\n";
00066
00067 // Get CandDigitList Algorithm:AlgConfig names from JobModule Registry
00068 const char *tmps = 0;
00069
00070 const char *digitlistalgorithm = 0;
00071 const char *digitlistalgconfig = 0;
00072
00073 Registry &r = GetConfig(); // Get this JobModule's Registry object
00074 if (r.Get("DigitListAlgorithm", tmps)) digitlistalgorithm = tmps;
00075 if (r.Get("DigitListAlgConfig", tmps)) digitlistalgconfig = tmps;
00076
00077 // Get Singleton instance of AlgFactory.
00078 AlgFactory &af = AlgFactory::GetInstance();
00079
00080 // Get CandDigit Algorithm:AlgConfig names from CandDigitList AlgConfig
00081 AlgHandle ahdl = af.GetAlgHandle(digitlistalgorithm,
00082 digitlistalgconfig);
00083 AlgConfig &acdl = ahdl.GetAlgConfig();
00084
00085 const char *digitalgorithm = 0;
00086 const char *digitalgconfig = 0;
00087
00088 if (acdl.Get("DigitAlgorithm", tmps)) digitalgorithm = tmps;
00089 if (acdl.Get("DigitAlgConfig", tmps)) digitalgconfig = tmps;
00090
00091 // Get DigitCalibrator parameters from AlgConfig for AlgDigit
00092 AlgHandle ahd = af.GetAlgHandle(digitalgorithm, digitalgconfig);
00093 //AlgConfig &acd = ahd.GetAlgConfig();
00094 }
|
|
|
Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables. Reimplemented from JobCModule. Definition at line 97 of file DigitListModule.cxx. References MSG. 00098 {
00099 MSG("Digit", Msg::kDebug) << "DigitListModule::Config" << endl;
00100 }
|
|
|
Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like: const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; } Reimplemented from JobCModule. Definition at line 103 of file DigitListModule.cxx. References JobCModule::GetName(), kDataList, Registry::LockValues(), MSG, Registry::Set(), and Registry::UnLockValues(). 00104 {
00105 MSG("Digit", Msg::kDebug)
00106 << "DigitListModule::DefaultConfig" << endl;
00107
00108 static Registry r;
00109
00110 std::string name = this->JobCModule::GetName();
00111 name += ".config.default";
00112 r.SetName(name.c_str());
00113
00114 r.UnLockValues();
00115 r.Set("ListsToMake", DigitListModule::kDataList);
00116 r.Set("NameDataList", "canddigitlist");
00117 r.Set("NameMCList", "candmcdigitlist");
00118 r.Set("TitleDataList", "Created by DigitListModule from raw data");
00119 r.Set("TitleMCList", "Created by DigitListModule from MCTruth data");
00120 r.Set("DigitListAlgorithm", "AlgDigitList");
00121 r.Set("DigitListAlgConfig", "default");
00122 r.Set("MCDigitListAlgorithm", "AlgMCDigitList");
00123 r.Set("MCDigitListAlgConfig", "default");
00124 r.LockValues();
00125
00126 return r;
00127 }
|
|
|
Implement if your module needs to read data from some external source and fill mom Reimplemented from JobCModule. Definition at line 130 of file DigitListModule.cxx. References MomNavigator::AdoptFragment(), RawDataBlock::GetBlockId(), RawBlockId::GetEncoded(), MomNavigator::GetFragment(), RawRecord::GetRawBlockIter(), RawRecord::GetRawHeader(), RawDaqHeader::GetRun(), RawDaqSnarlHeader::GetSnarl(), RecMinosHdr::GetVldContext(), Calibrator::Instance(), MAXMSG, MSG, CalScheme::Reset(), run(), JobCResult::SetFailed(), and JobCResult::SetWarning(). 00131 {
00132 JobCResult result(JobCResult::kPassed);
00133
00134 MSG("Digit", Msg::kVerbose) << "DigitListModule::Get\n";
00135
00136 // Create a VldContext
00137 // Preferentially take record from DaqSnarl stream as those have
00138 // RawDaqSnarlHeaders which contain run & snarl #'s.
00139 RawRecord *rawrec =
00140 dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord",0,"DaqSnarl"));
00141
00142 if (!rawrec) {
00143 MAXMSG("Digit", Msg::kWarning,100)
00144 << "No RawRecord in DaqSnarl stream in MOM." << endl;
00145 // No DaqSnarl record, try to find any appropriate raw record
00146 rawrec = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord",0,
00147 "LightInjection"));
00148 if (!rawrec)
00149 rawrec = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord",0,
00150 "DaqMonitor"));
00151 if (!rawrec)
00152 rawrec = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord"));
00153 }
00154
00155 if (!rawrec) {
00156 MAXMSG("Digit", Msg::kWarning,100)
00157 << "No RawRecord in MOM." << endl;
00158 result.SetWarning().SetFailed();
00159 return result;
00160 }
00161
00162 VldContext vldc = rawrec->GetRawHeader()->GetVldContext();
00163 Int_t run = -1;
00164 Int_t snarl = -1;
00165
00166 // (Re)Initialize VldContext in DigitCalibrator - put here for now.
00167
00168 Calibrator::Instance().Reset(vldc);
00169
00170 const RawDaqSnarlHeader* snarlHdr =
00171 dynamic_cast<const RawDaqSnarlHeader*>(rawrec->GetRawHeader());
00172 if (snarlHdr) {
00173 run = snarlHdr->GetRun();
00174 snarl = snarlHdr->GetSnarl();
00175 } else {
00176 const RawDaqHeader* daqHdr =
00177 dynamic_cast<const RawDaqHeader*>(rawrec->GetRawHeader());
00178 if (daqHdr) {
00179 MSG("Digit", Msg::kWarning)
00180 << "RawRecord only had a RawDaqHeader"
00181 << " - CandHeader will have bogus Snarl #'s"
00182 << endl;
00183 run = daqHdr->GetRun();
00184 } else {
00185 MSG("Digit", Msg::kWarning)
00186 << "RawRecord didn't have RawDaq[Snarl]Header"
00187 << " - CandHeader will have bogus Run/Snarl #'s"
00188 << endl;
00189 cout << " List of RawDataBlocks in RawRecord:" << endl;
00190 TIter rbi = rawrec->GetRawBlockIter();
00191 TObject *tobj;
00192 RawDataBlock *rb;
00193 while ( (tobj = rbi()) ) {
00194 rb = dynamic_cast<RawDataBlock *>(tobj);
00195 if (!rb) continue;
00196 cout << " " << rb->ClassName() << " : "
00197 << rb->GetName()
00198 << " 0x" << hex << rb->GetBlockId().GetEncoded() << dec
00199 << endl;
00200 }
00201 }
00202 }
00203
00204 // Check if there's a PrimaryCandidateRecord fragment in MOM.
00205 CandRecord *candrec = dynamic_cast<CandRecord *>
00206 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00207 if (candrec == 0) {
00208 MSG("Digit", Msg::kDebug)
00209 << "No PrimaryCandidateRecord in MOM. Create a new one."
00210 << endl;
00211 // Create a CandHeader
00212 // no event splitting so don't supply a "event" number
00213 CandHeader *head = new CandHeader(vldc,run,snarl);
00214
00215 // Produce a CandRecord, have it adopt the header
00216 candrec = new CandRecord(head);
00217
00218 // Give the CandRecord to MOM to hold as a "fragment"
00219 candrec->SetName("PrimaryCandidateRecord");
00220 candrec->SetTitle("Created by DigitListModule from RawRecord.");
00221 mom->AdoptFragment(candrec);
00222 }
00223
00224 return result;
00225 }
|
|
|
Implement this for read-write access to the MomNavigator Reimplemented from JobCModule. Definition at line 228 of file DigitListModule.cxx. References RawRecord::FindRawBlock(), Registry::Get(), AlgFactory::GetAlgHandle(), JobCModule::GetConfig(), MomNavigator::GetFragment(), AlgFactory::GetInstance(), VldContext::GetSimFlag(), RecMinos::GetVldContext(), kMCList, CandDigitList::MakeCandidate(), MSG, CandRecord::SecureCandHandle(), CandContext::SetCandRecord(), CandContext::SetDataIn(), JobCResult::SetFailed(), CandHandle::SetName(), CandHandle::SetTitle(), and JobCResult::SetWarning(). 00229 {
00230 JobCResult result(JobCResult::kPassed);
00231
00232 MSG("Digit", Msg::kVerbose) << "DigitListModule::Reco\n";
00233
00234 // Cache JobModule Registry values for Reco method
00235 const char *tmps = 0;
00236 Int_t tmpi = 0;
00237
00238 UInt_t liststomake = 0;
00239 const char *namedatalist = 0;
00240 const char *namemclist = 0;
00241 const char *titledatalist = 0;
00242 const char *titlemclist = 0;
00243 const char *digitlistalgorithm = 0;
00244 const char *digitlistalgconfig = 0;
00245 const char *mcdigitlistalgorithm = 0;
00246 const char *mcdigitlistalgconfig = 0;
00247
00248 Registry &r = GetConfig(); // Get this JobModule's Registry object
00249 if (r.Get("ListsToMake", tmpi)) liststomake = tmpi;
00250 if (r.Get("NameDataList", tmps)) namedatalist = tmps;
00251 if (r.Get("NameMCList", tmps)) namemclist = tmps;
00252 if (r.Get("TitleDataList", tmps)) titledatalist = tmps;
00253 if (r.Get("TitleMCList", tmps)) titlemclist = tmps;
00254 if (r.Get("DigitListAlgorithm", tmps)) digitlistalgorithm = tmps;
00255 if (r.Get("DigitListAlgConfig", tmps)) digitlistalgconfig = tmps;
00256 if (r.Get("MCDigitListAlgorithm", tmps)) mcdigitlistalgorithm = tmps;
00257 if (r.Get("MCDigitListAlgConfig", tmps)) mcdigitlistalgconfig = tmps;
00258
00259 // Find RawRecord fragment in MOM.
00260 // First try DaqSnarl stream, if that fails then try LightInjection
00261 // Otherwise it's hopeless ... (unless DAQ DCP code is really messed up)
00262 // Previously we relied on the implicit order in MOM, but that is dangerous
00263 // and doesn't work in certain circumstances.
00264 MSG("Digit", Msg::kDebug)
00265 << "RawRecord *rr = "
00266 << "(RawRecord *) mom->GetFragment(\"RawRecord\",0,\"DaqSnarl\");"
00267 << endl;
00268 RawRecord *rr =
00269 dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord",0,"DaqSnarl"));
00270
00271 if (rr == 0) {
00272 MSG("Digit", Msg::kDebug)
00273 << "No RawRecord in DaqSnarl stream in MOM."
00274 << endl;
00275
00276 MSG("Digit", Msg::kDebug)
00277 << "rr = "
00278 << "(RawRecord *) mom->GetFragment(\"RawRecord\",0,\"LightInjection\");"
00279 << endl;
00280 rr = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord",0,"LightInjection"));
00281
00282 if (rr == 0) {
00283 MSG("Digit", Msg::kDebug)
00284 << "No RawRecord in DaqSnarl or LightInjection streams in MOM."
00285 << endl;
00286 result.SetWarning().SetFailed();
00287 return result;
00288 }
00289 }
00290
00291 // require at least one RawDigitDataBlock in the RawRecord
00292 if ( ! rr->FindRawBlock("RawDigitDataBlock") ) {
00293 MSG("Digit", Msg::kDebug)
00294 << "No RawDigitDataBlock in RawRecord."
00295 << endl;
00296 result.SetWarning().SetFailed();
00297 return result;
00298 }
00299
00300 MSG("Digit", Msg::kDebug) << "CandContext cx(this);" << endl;
00301 CandContext cx(this, mom);
00302
00303 MSG("Digit", Msg::kDebug) << "cx.SetDataIn(rr);" << endl;
00304 cx.SetDataIn(rr);
00305
00306 // Find PrimaryCandidateRecord fragment in MOM.
00307 CandRecord *candrec = dynamic_cast<CandRecord *>
00308 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00309 if (candrec == 0) {
00310 MSG("Digit", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00311 << endl;
00312 result.SetWarning().SetFailed();
00313 return result;
00314 }
00315 else {
00316 MSG("Digit", Msg::kDebug)
00317 << "Set CandRecord pointer in CandContext." << endl;
00318 cx.SetCandRecord(candrec);
00319 }
00320
00321 // Get Singleton instance of AlgFactory.
00322 MSG("Digit", Msg::kDebug)
00323 << "Get Singleton instance of AlgFactory." << endl
00324 << "AlgFactory &af = AlgFactory::GetInstance();" << endl;
00325 AlgFactory &af = AlgFactory::GetInstance();
00326
00327 if (liststomake & DigitListModule::kDataList) {
00328
00329 // Build a CandDigitList containing all CandDigits in Frame.
00330 MSG("Digit", Msg::kDebug)
00331 << "Ask AlgFactory for Singleton AlgDigitList instance." << endl
00332 << "AlgHandle adlh = af.GetAlgHandle("
00333 << digitlistalgorithm << ", "
00334 << digitlistalgconfig << ");" << endl;
00335 AlgHandle adlh = af.GetAlgHandle(digitlistalgorithm,
00336 digitlistalgconfig);
00337
00338 MSG("Digit", Msg::kDebug)
00339 << "cdlh = CandDigitList::MakeCandidate(adlh, cx);" << endl;
00340 CandDigitListHandle cdlh = CandDigitList::MakeCandidate(adlh, cx);
00341 cdlh.SetName(namedatalist);
00342 cdlh.SetTitle(titledatalist);
00343
00344 // Give the CandHandle to the CandRecord
00345 MSG("Digit", Msg::kDebug) << "candrec->SecureCandHandle(cdlh);"
00346 << endl;
00347 candrec->SecureCandHandle(cdlh);
00348 }
00349
00350 SimFlag::SimFlag_t simflag = rr->GetVldContext()->GetSimFlag();
00351 bool isMC = (simflag == SimFlag::kReroot ||
00352 simflag == SimFlag::kMC );
00353
00354 static bool dowarn = true;
00355 if ((liststomake & DigitListModule::kMCList) && !isMC && dowarn) {
00356 MSG("Digit",Msg::kInfo)
00357 << "DigitListModule::Reco MCList making enabled for non-MC data: "
00358 << endl
00359 << " " << *(rr->GetVldContext())
00360 << " -- no MC list will be made" << endl;
00361 dowarn = false;
00362 }
00363
00364 if (liststomake & DigitListModule::kMCList && isMC ) {
00365
00366 // Build an MC CandDigitList corresponding to all CandDigits in Frame.
00367 MSG("Digit", Msg::kDebug)
00368 << "Ask AlgFactory for Singleton AlgDigitMCList instance." << endl
00369 << "AlgHandle amcdlh = af.GetAlgHandle("
00370 << mcdigitlistalgorithm << ", "
00371 << mcdigitlistalgconfig << ");" << endl;
00372 AlgHandle amcdlh = af.GetAlgHandle(mcdigitlistalgorithm,
00373 mcdigitlistalgconfig);
00374
00375 MSG("Digit", Msg::kDebug)
00376 << "cmcdlh = CandDigitList::MakeCandidate(amcdlh, cx);" << endl;
00377 CandDigitListHandle cmcdlh =
00378 CandDigitList::MakeCandidate(amcdlh,cx);
00379 cmcdlh.SetName(namemclist);
00380 cmcdlh.SetTitle(titlemclist);
00381
00382 // Give the CandHandle to the CandRecord
00383 MSG("Digit", Msg::kDebug) << "candrec->SecureCandHandle(cmcdlh);"
00384 << endl;
00385 candrec->SecureCandHandle(cmcdlh);
00386 }
00387
00388 return result;
00389 }
|
1.3.9.1