00001
00017 #include <cassert>
00018
00019 #include "Algorithm/AlgFactory.h"
00020 #include "Algorithm/AlgHandle.h"
00021 #include "CandData/CandHeader.h"
00022 #include "CandData/CandRecord.h"
00023 #include "CandDigit/CandDigitHandle.h"
00024 #include "CandDigit/CandDigitList.h"
00025 #include "CandDigit/CandDigitListHandle.h"
00026 #include "Candidate/CandContext.h"
00027 #include "JobControl/JobCModuleRegistry.h"
00028 #include "JobControl/JobCommand.h"
00029 #include "MessageService/MsgService.h"
00030 #include "MinosObjectMap/MomNavigator.h"
00031 #include "RawData/RawRecord.h"
00032 #include "RawData/RawDaqSnarlHeader.h"
00033
00034 #include "FilterLIModule.h"
00035 #include "LIPatternFinder.h"
00036 #include "LIFinderFactory.h"
00037
00038 ClassImp(FilterLIModule)
00039
00040
00041 CVSID("$Id: FilterLIModule.cxx,v 1.6 2004/07/09 16:08:20 costas Exp $");
00042
00043 JOBMODULE(FilterLIModule, "FilterLIModule",
00044 "Filters LI-like snarls from physics reconstruction jobs");
00045
00046 FilterLIModule::FilterLIModule()
00047 {
00048 MSG("LIFilter", Msg::kVerbose) << "FilterLIModule::Constructor\n";
00049 }
00050
00051 FilterLIModule::~FilterLIModule()
00052 {
00053 MSG("LIFilter", Msg::kVerbose) << "FilterLIModule::Destructor\n";
00054 }
00055
00056 void FilterLIModule::BeginJob()
00057 {
00058 MSG("LIFilter", Msg::kVerbose) << "FilterLIModule::BeginJob\n";
00059 }
00060
00061 void FilterLIModule::Config(const Registry& )
00062 {
00063 MSG("LIFilter", Msg::kDebug) << "FilterLIModule::Config" << endl;
00064 }
00065
00066 const Registry& FilterLIModule::DefaultConfig() const
00067 {
00068 MSG("LIFilter", Msg::kDebug)
00069 << "FilterLIModule::DefaultConfig" << endl;
00070 static Registry r;
00071
00072 std::string name = this->JobCModule::GetName();
00073 name += ".config.default";
00074 r.SetName(name.c_str());
00075
00076 r.UnLockValues();
00077
00078 r.Set("NameListIn", "canddigitlist");
00079 r.Set("NameListOut", "canddigitlist");
00080 r.Set("LIFinderName", "SimpleLIPatternFinder");
00081
00082
00083 r.Set("MaxEWAsymmetry", 4.e+5);
00084 r.Set("MaxNDigits", 1400);
00085 r.Set("MaxCharge", 5.e+5);
00086 r.Set("PulseHeightThreshold", 200);
00087 r.Set("HighActivityThreshold", 0.94);
00088 r.Set("LowActivityThreshold", 0.07);
00089
00090
00091 r.Set("FractionalChargeThreshold", 0.8);
00092
00093 r.LockValues();
00094
00095 return r;
00096 }
00097
00098 JobCResult FilterLIModule::Ana(const MomNavigator * mom)
00099 {
00100 JobCResult result(JobCResult::kPassed);
00101
00102 MSG("LIFilter", Msg::kVerbose) << "FilterLIModule::Reco" << endl;
00103
00104
00105 const char * tmps = 0;
00106
00107 const char * namelistin = 0;
00108 const char * namelistout = 0;
00109 const char * algname = 0;
00110
00111 Registry &r = GetConfig();
00112 if (r.Get("NameListIn", tmps)) namelistin = tmps;
00113 if (r.Get("NameListOut", tmps)) namelistout = tmps;
00114 if (r.Get("LIFinderName", tmps)) algname = tmps;
00115
00116
00117 CandRecord *candrec = dynamic_cast<CandRecord *>
00118 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00119 if (candrec == 0) {
00120 MSG("LIFilter", Msg::kWarning)
00121 << "No PrimaryCandidateRecord in MOM" << endl;
00122 result.SetWarning().SetFailed();
00123 return result;
00124 }
00125
00126 CandDigitListHandle *cdlh = dynamic_cast<CandDigitListHandle *>
00127 (candrec->FindCandHandle("CandDigitListHandle",namelistin));
00128
00129 if (cdlh == 0) {
00130 MSG("LIFilter", Msg::kWarning)
00131 << "No CandDigitListHandle named " << namelistin
00132 << " in CandRecord." << endl;
00133 result.SetWarning().SetFailed();
00134 return result;
00135 }
00136
00137
00138
00139 MSG("LIFilter", Msg::kDebug)
00140 << "Getting a LIFinderFactory instance" << endl;
00141
00142 LIFinderFactory * factory = LIFinderFactory::GetInstance();
00143
00144
00145
00146 MSG("LIFilter", Msg::kDebug)
00147 << "Asking LIFinderFactory for ["
00148 << algname << "] algorithm " << endl;
00149
00150 LIPatternFinder * li_finder = factory->LIFinder(algname);
00151
00152
00153
00154 if(!li_finder) {
00155
00156 MSG("LIFilter", Msg::kWarning)
00157 << " ** Unspecified LIPatternFinder ** "
00158 << " Skipping Pattern Finding & passing event to next module"
00159 << endl;
00160
00161 return JobCResult::kPassed;
00162
00163 } else {
00164
00165 li_finder->Configure(r);
00166
00167 if ( li_finder->IsLightInjectionTrash(cdlh) ) {
00168
00169
00170
00171 RawRecord * rawrec = dynamic_cast<RawRecord *>
00172 (mom->GetFragment("RawRecord"));
00173 if (rawrec != 0) {
00174
00175 const RawDaqSnarlHeader * snrlHdr =
00176 dynamic_cast<const RawDaqSnarlHeader *>
00177 (rawrec->GetRawHeader());
00178 if(snrlHdr != 0) {
00179 MAXMSG("LIFilter",Msg::kInfo, 200)
00180 << "REJECTING SNARL = " << snrlHdr->GetSnarl() << endl;
00181 }
00182 }
00183
00184 return JobCResult::kFailed;
00185 }
00186 }
00187
00188 return JobCResult::kPassed;
00189 }
00190
00191
00192