00001
00002
00003
00004
00005
00006
00007
00009 #include "CalDetPID/RealCalDetPIDModule.h"
00010 #include "CalDetPID/CandCalDetPIDHandle.h"
00011 #include "CalDetSI/CandCalDetSIHandle.h"
00012 #include "MessageService/MsgService.h"
00013 #include "MinosObjectMap/MomNavigator.h"
00014 #include "JobControl/JobCModuleRegistry.h"
00015 #include "DataUtil/GetCandHeader.h"
00016 #include "DataUtil/GetCandidate.h"
00017 #include "Algorithm/AlgFactory.h"
00018 #include "Algorithm/AlgHandle.h"
00019 #include "Algorithm/AlgConfig.h"
00020 #include "Candidate/CandContext.h"
00021
00022
00023 JOBMODULE(RealCalDetPIDModule, "RealCalDetPIDModule",
00024 "Constructs CandCalDetPID objects");
00025 CVSID("$Id: RealCalDetPIDModule.cxx,v 1.2 2003/11/18 22:20:47 vahle Exp $");
00026
00027
00028
00029 ClassImp(RealCalDetPIDModule)
00030
00031 RealCalDetPIDModule::RealCalDetPIDModule()
00032 :
00033 fNAllowedBefore(1), fNAllowedAfter(1), fNAllowedOut(2),fNRequiredIn(1),
00034 fTimeFileNum(0)
00035 {
00036
00037
00038
00039 }
00040
00041
00042
00043 RealCalDetPIDModule::~RealCalDetPIDModule()
00044 {
00045
00046
00047
00048 }
00049
00050 void RealCalDetPIDModule::BeginJob()
00051 {
00052
00053 AlgFactory& af = AlgFactory::GetInstance();
00054 af.Register("AlgCalDetPID", "default", "libCalDetPID.so", "AlgConfig");
00055
00056 }
00057
00058
00059
00060 JobCResult RealCalDetPIDModule::Reco(MomNavigator* mom)
00061 {
00062
00063
00064
00065
00066
00067
00068
00069 JobCResult result=JobCResult::kPassed;
00070
00071 AlgHandle ah =
00072 AlgFactory::GetInstance().GetAlgHandle("AlgCalDetPID","default");
00073
00074 AlgConfig& ac = ah.GetAlgConfig();
00075
00076 ac.UnLockValues();
00077 ac.Set("NAllowedBefore",fNAllowedBefore);
00078 ac.Set("NAllowedAfter", fNAllowedAfter);
00079 ac.Set("NAllowedOut", fNAllowedOut);
00080 ac.Set("NRequiredIn", fNRequiredIn);
00081 ac.Set("TimeFileNum", fTimeFileNum);
00082 ac.LockValues();
00083
00084 CandCalDetSIHandle* csih_ptr
00085 = DataUtil::GetCandidate<CandCalDetSIHandle>
00086 (mom,"CandCalDetSIHandle");
00087 if(csih_ptr){
00088 CandContext cc(this, mom);
00089 cc.SetDataIn(csih_ptr);
00090
00091 CandRecord* cr = dynamic_cast<CandRecord*>
00092 (mom->GetFragment("CandRecord","PrimaryCandidateRecord"));
00093 if(cr==0){
00094 MSG("CalDetPID", Msg::kError)
00095 <<"Could not find a CandRecord?!?! Failing event!"<<endl;
00096 result=JobCResult::kFailed;
00097 }
00098 else{
00099 cc.SetCandRecord(cr);
00100 CandCalDetPIDHandle cpidh =
00101 CandCalDetPID::MakeCandidate(ah, cc);
00102 cr->SecureCandHandle(cpidh);
00103 }
00104 }
00105 else {
00106 MSG("CalDetPID", Msg::kWarning)
00107 <<"Could not find a CandCalDetSIHandle. Failing event!"<<endl;
00108 result = JobCResult::kFailed;
00109 }
00110 return result;
00111 }
00112
00113
00114
00115
00116 void RealCalDetPIDModule::Help()
00117 {
00118
00119
00120
00121
00122 MSG("CalDetPID", Msg::kInfo)
00123 <<"RealCalDetPIDModule::Reco():\n"
00124 <<"=======================================================\n"
00125 <<"Construct a CandCalDetPID object and stick it in Mom.\n"
00126 <<"This will return JobCResult::kFailed in case of error.\n"
00127 <<"The constructed CandCaldetPID object"
00128 <<" may correspond to a single\n"
00129 <<"particle (see CalDetParticleType.h) or some"
00130 <<" combination if the PID\n"
00131 <<"is (sufficiently) ambiguous.\n"
00132 <<"========================================================\n"
00133 <<endl;
00134
00135 }
00136
00138
00139
00140 const Registry& RealCalDetPIDModule::DefaultConfig() const
00141 {
00142
00143
00144
00145 static Registry r;
00146
00147
00148 std::string name = this->JobCModule::GetName();
00149 name += ".config.default";
00150 r.SetName(name.c_str());
00151
00152
00153 r.UnLockValues();
00154
00155
00156 r.Set("NAllowedBefore", 1);
00157 r.Set("NAllowedAfter", 1);
00158 r.Set("NAllowedOut", 2);
00159 r.Set("NRequiredIn", 1);
00160
00161 r.LockValues();
00162
00163 return r;
00164 }
00165
00166
00167
00168 void RealCalDetPIDModule::Config(const Registry& r)
00169 {
00170
00171
00172
00173 int tmpi;
00174
00175 if (r.Get("NAllowedBefore",tmpi)) { fNAllowedBefore = tmpi; }
00176 if (r.Get("NAllowedAfter",tmpi)) { fNAllowedAfter = tmpi; }
00177 if (r.Get("NAllowedOut",tmpi)) { fNAllowedOut = tmpi; }
00178 if (r.Get("NRequiredIn",tmpi)) { fNRequiredIn = tmpi; }
00179 if (r.Get("TimeFileNum",tmpi)) { fTimeFileNum = tmpi;}
00180 }
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190