00001
00002
00003
00004
00005
00006
00007
00008
00010
00011 #include "DeMux/DmxDeMuxFilterModule.h"
00012 #include "DeMux/DmxChiSqrStat.h"
00013 #include "JobControl/JobCModuleRegistry.h"
00014 #include "JobControl/JobCommand.h"
00015 #include "MessageService/MsgService.h"
00016 #include "MinosObjectMap/MomNavigator.h"
00017 #include "Algorithm/AlgConfig.h"
00018 #include "CandDigit/CandDigitListHandle.h"
00019 #include "CandDigit/CandDigitHandle.h"
00020 #include "Algorithm/AlgFactory.h"
00021 #include "Algorithm/AlgHandle.h"
00022 #include "CandData/CandRecord.h"
00023 #include "CandData/CandHeader.h"
00024 #include "Candidate/CandContext.h"
00025 #include "Navigation/NavKey.h"
00026 #include "Navigation/NavSet.h"
00027 #include "Conventions/PlaneView.h"
00028 #include "Navigation/XxxItr.h"
00029 #include "DeMux/DmxShowerPlane.h"
00030 #include "DeMux/DmxMuonPlane.h"
00031 #include "DeMux/DmxPlane.h"
00032 #include "DeMux/DmxHypothesis.h"
00033 #include "TFile.h"
00034 #include "TH1.h"
00035 #include "TH2.h"
00036 #include "TClonesArray.h"
00037 #include "Validity/VldContext.h"
00038 #include "UgliGeometry/UgliGeomHandle.h"
00039
00040 #include <cassert>
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 ClassImp(DmxDeMuxFilterModule)
00053
00054 CVSID("$Id: DmxDeMuxFilterModule.cxx,v 1.12 2003/05/21 16:24:35 bv Exp $");
00055
00056
00057
00058
00059
00060 JOBMODULE(DmxDeMuxFilterModule,
00061 "DeMuxFilterModule",
00062 "A module used for demultiplexing cosmics in the far detector");
00063
00064
00065 DmxDeMuxFilterModule::DmxDeMuxFilterModule() :
00066 fDontUseCandDigitMasks(false),
00067 fSignalFractionLimit(0.1)
00068 {
00069
00070 MSG("JobC", Msg::kDebug) << "DmxDeMuxFilterModule::Constructor" << endl;
00071
00072
00073 }
00074
00075
00076 DmxDeMuxFilterModule::~DmxDeMuxFilterModule()
00077 {
00078 MSG("JobC", Msg::kDebug) << "DmxDeMuxFilterModule::Destructor" << endl;
00079 }
00080
00081
00082
00083 void DmxDeMuxFilterModule::BeginJob()
00084 {
00085 AlgFactory &af = AlgFactory::GetInstance();
00086 af.Register("AlgDeMuxCosmics", "default", "libDeMux.so", "AlgConfigDeMux");
00087 AlgHandle ah = af.GetAlgHandle("AlgDeMuxCosmics", "default");
00088
00089
00090
00091 AlgConfig &acd = ah.GetAlgConfig();
00092 acd.UnLockValues();
00093 acd.Set("HoughInterceptLimit",1.5);
00094 acd.Set("HoughPeakLimit",0.66);
00095 acd.Set("HoughSlopeLimit",1.);
00096 acd.Set("HypothesisSize",24);
00097 acd.Set("MuonTrackSlopeLimit",0.09);
00098 acd.Set("NumberOfHypotheses",169);
00099 acd.Set("NumberOfStrips", 192);
00100 acd.Set("PlanesInSet",6);
00101 acd.Set("RatioMatedSignalForValid",0.3);
00102 acd.Set("UseCandDigitMask", 1);
00103 acd.Set("XTalkFractionLimit", 0.1);
00104 acd.Set("IgnoreFractionLimit", 0.05);
00105 acd.Set("AveragePEGainConversion", 55.);
00106 acd.Set("StrayDeltaStripLimit",6);
00107 acd.Set("StrayPlanesLimit",10);
00108 acd.Set("UseStrayPlaneCheck", 0);
00109
00110 acd.LockValues();
00111 acd.LockKeys();
00112
00113
00114
00115 fStatus = DmxStatus();
00116
00117 return;
00118 }
00119
00120
00121
00122 JobCResult DmxDeMuxFilterModule::Reco(MomNavigator *mom)
00123 {
00124 JobCResult result(JobCResult::kPassed);
00125
00126 MSG("JobC", Msg::kDebug) << "DeMuxFilterModule::Reco\n";
00127
00128 fStatus.ClearPlaneArray();
00129
00130
00131 assert(mom);
00132
00133
00134 CandRecord *candrec = dynamic_cast<CandRecord *>
00135 (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00136 if (candrec == 0) {
00137 result.SetError().SetFailed();
00138 return result;
00139 }
00140
00141
00142 CandDigitListHandle *crdlh = dynamic_cast<CandDigitListHandle *>
00143 (candrec->FindCandHandle("CandDigitListHandle", "canddigitlist"));
00144 if (crdlh == 0) {
00145 result.SetError().SetFailed();
00146 return result;
00147 }
00148
00149 Int_t event = fStatus.GetEventNumber();
00150 const CandHeader* chead = candrec->GetCandHeader();
00151 if (!chead) {
00152 MSG("JobC",Msg::kWarning) << "No CandHeader, but continuing" << endl;
00153 }
00154 ++event;
00155
00156
00157 AlgFactory &af = AlgFactory::GetInstance();
00158 AlgHandle ah = af.GetAlgHandle("AlgDeMuxCosmics", "default");
00159
00160
00161
00162
00163 fStatus.SetEventDeMuxed(true);
00164 fStatus.SetMultipleMuon(false);
00165
00166 CandContext cx(this, mom);
00167 cx.SetDataIn(&fStatus);
00168
00169 ah.RunAlg(*crdlh, cx);
00170
00171 if( !fStatus.GetEventDeMuxed() ){
00172 result.SetError().SetFailed();
00173 return result;
00174 }
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213 return result;
00214 }
00215
00216
00217
00218 void DmxDeMuxFilterModule::HandleCommand(JobCommand *command)
00219 {
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239 MSG("JobC", Msg::kDebug) << "DeMuxFilterModule::HandleCommand" << endl;
00240
00241 TString cmd = command->PopCmd();
00242 if(cmd == "Set"){
00243 TString opt = command->PopOpt();
00244 if(opt == "DontUseCandDigitMasks"){ fDontUseCandDigitMasks = true;}
00245 else if(opt = "SignalFractionLimit"){ fSignalFractionLimit = command->PopFloatOpt();}
00246 else {
00247 MSG("JobC", Msg::kWarning)<< "DeMuxFilterModule: Unrecognized option " << opt << endl;
00248 }
00249 }
00250 else {
00251 MSG("JobC", Msg::kWarning)<< "DeMuxFilterModule: Unrecognized command " << cmd << endl;
00252 }
00253 return;
00254 }
00255
00256
00257 void DmxDeMuxFilterModule::ClearStatusObject()
00258 {
00259 fStatus.ClearPlaneArray();
00260 return;
00261 }
00262
00263 void DmxDeMuxFilterModule::Help()
00264 {
00265 MSG("JobC", Msg::kInfo)
00266 << "DeMuxFilterModule::Help\n"
00267 <<"DmxDeMuxFilterModule is a module which demultiplexes events "
00268 <<"in the far detector." << endl
00269 << "see http://beaker.astro.indiana.edu/brebel/demux_notes/how_to_demux.html for details"
00270 << endl;
00271 }
00272
00273
00274
00275