Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

RealCalDetPIDModule.cxx

Go to the documentation of this file.
00001 
00002 // $Id: RealCalDetPIDModule.cxx,v 1.2 2003/11/18 22:20:47 vahle Exp $
00003 //
00004 // Constructs CandCalDetPID objects.
00005 // Requires CandCalDetSI objects to be already constructed.
00006 //
00007 // kordosky@hep.utexas.edu
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" // For JOBMODULE macro
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 // Default constructor
00038 //======================================================================
00039 }
00040 
00041 //......................................................................
00042 
00043 RealCalDetPIDModule::~RealCalDetPIDModule()
00044 {
00045 //======================================================================
00046 // Destructor
00047 //======================================================================
00048 }
00049 
00050 void RealCalDetPIDModule::BeginJob()
00051 {
00052      // register my algorithm
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 // Construct a CandCalDetPID object and stick it in Mom.
00064 // This will return JobCResult::kFailed in case of error.
00065 // The constructed CandCaldetPID object may correspond to a single
00066 // particle (see CalDetParticleType.h" or some combination if the PID
00067 // is (sufficiently) ambiguous.
00068 //======================================================================
00069      JobCResult result=JobCResult::kPassed;
00070      
00071      AlgHandle ah = 
00072           AlgFactory::GetInstance().GetAlgHandle("AlgCalDetPID","default");
00073      
00074      AlgConfig& ac = ah.GetAlgConfig();
00075      // set up algorithm configuration
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; // kNoDecision, kFailed, etc.
00111 }
00112 
00113 
00114 //......................................................................
00115 
00116 void RealCalDetPIDModule::Help()
00117 {
00118 //======================================================================
00119 // Prints a helpful message
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 // Supply the default configuration for the module
00144 //======================================================================
00145   static Registry r; // Default configuration for module
00146 
00147   // Set name of config
00148   std::string name = this->JobCModule::GetName();
00149   name += ".config.default";
00150   r.SetName(name.c_str());
00151 
00152   // Set values in configuration
00153   r.UnLockValues();
00154 
00155   // for AlgCalDetPID
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 // Configure the module given the Registry r
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 

Generated on Mon Feb 15 11:07:29 2010 for loon by  doxygen 1.3.9.1