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

CalDetSIModule.cxx

Go to the documentation of this file.
00001 /**************************************************************************/
00002 /*   A Module to make CandCalDetSI objects                                */
00003 /*   PATRICIA VAHLE & Mike Kordosky                                       */
00004 /*   January 8, 2002                                                      */
00005 /**************************************************************************/
00006 
00007 
00008 #include "CalDetSI/CalDetSIModule.h"
00009 #include "CalDetSI/AlgCalDetSI.h"
00010 #include "CalDetSI/CandCalDetSI.h"
00011 #include "CalDetSI/CandCalDetSIHandle.h"
00012 #include "JobControl/JobCResult.h"
00013 #include "JobControl/JobCModuleRegistry.h" // JOBMODULE registration macro
00014 #include "JobControl/JobCommand.h"
00015 #include "MinosObjectMap/MomNavigator.h"
00016 #include "MessageService/MsgService.h"
00017 #include "Algorithm/AlgConfig.h"
00018 #include "Algorithm/AlgFactory.h"
00019 #include "Algorithm/AlgHandle.h"
00020 #include "Candidate/CandContext.h"
00021 #include "RawData/RawRecord.h"
00022 
00023 //some scripts that must be here
00024 ClassImp(CalDetSIModule)
00025 CVSID("$Id: CalDetSIModule.cxx,v 1.2 2003/10/17 08:36:08 vahle Exp $");
00026 JOBMODULE(CalDetSIModule,"CalDetSIModule","Incorporates PID and special CalDet info into candidates\n");
00027 
00028 //___________________________________________________________________________
00029 
00030 CalDetSIModule::CalDetSIModule() :
00031   fIsMC(kFALSE)
00032 
00033 {
00034 
00035   MSG("CalDetSI", Msg::kDebug)<<"CalDetSIModule::Construct"<<endl;
00036 
00037 } //constructor
00038 
00039 //___________________________________________________________________________
00040 
00041 CalDetSIModule::~CalDetSIModule() {} //destructor
00042 
00043 //__________________________________________________________________________
00044 
00045 void CalDetSIModule::BeginJob()
00046 {
00047 MSG("CalDetSI", Msg::kVerbose) << "CalDetSIModule::BeginJob\n";
00048 
00049 // Get Singleton instance of AlgFactory.
00050   AlgFactory &af = AlgFactory::GetInstance();
00051 
00052 
00053 // Register (Algorithm, configset) by names ("AlgCalDetSI", "default")
00054     af.Register("AlgCalDetSI", "default", "libCandCalDetSI.so", "AlgConfig");
00055 
00056 // Register (Algorithm, configset) by names ("AlgCalDetSI", "default")
00057     //    af.Register("AlgCalDetSI", "default", "libCandCalDetSI.so",
00058     //   "AlgConfig");
00059   /*
00060 
00061     //MonteCarlo Stuff
00062   if (fListsToMake & kMCList) {
00063 
00064 // Register (Algorithm, configset) by names ("AlgMCDigit", "default")
00065     af.Register("AlgMCDigit", "default", "libCandDigit.so",
00066                                                            "AlgConfig");
00067 
00068 // Register an alternative configset for ("AlgMCDigitList", "default")
00069     af.Register("AlgMCDigitList", "default", "libCandDigit.so",
00070                                                            "AlgConfig");
00071   }
00072 
00073   */
00074 }//end BeginJob
00075 
00076 //__________________________________________________________________________
00077 
00078 JobCResult CalDetSIModule::Reco(MomNavigator *mom)
00079 {
00080 
00081   MSG("CalDetSIModule",Msg::kDebug)<<"Beginning Reco"<<endl;
00082   //get a data fragment
00083   RawRecord *rr = dynamic_cast<RawRecord *> (mom->GetFragment("RawRecord"));
00084 
00085   AlgFactory &af = AlgFactory::GetInstance();
00086   AlgHandle ah = af.GetAlgHandle("AlgCalDetSI", "default");
00087 
00088   //create a CandContext
00089   CandContext cx(this, mom);
00090   cx.SetDataIn(rr);
00091 
00092   //make the candcaldetsi
00093   MSG("CalDetSIModule",Msg::kDebug)<<"About to make candidate"<<endl;
00094   CandCalDetSIHandle csih = CandCalDetSI::MakeCandidate(ah, cx); 
00095   if(!csih.GetIsSnarlRecord()&&!fIsMC){
00096     MSG("CalDetSIModule",Msg::kDebug)<<"csih is not a snarl record or MC"<<endl;
00097     return JobCResult(JobCResult::kFailed);
00098   }
00099 
00100   //give the CandCalDetSIHandle to the candrecord
00101   if(!fIsMC){
00102     CandRecord *candrec = dynamic_cast<CandRecord *>
00103       (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00104     if (candrec == 0) {
00105       MSG("CalDetSIModule", Msg::kInfo) 
00106         << "No PrimaryCandidateRecord in MOM."<< endl;
00107       return JobCResult(JobCResult::kFailed);
00108     }
00109 
00110     candrec->SecureCandHandle(csih);
00111   }
00112 
00113   //older version, gave candcaldetsihandle to mom, also works with MC files
00114   else{
00115     CandCalDetSIHandle *onheap = new CandCalDetSIHandle(csih); //copy handle
00116     mom->AdoptFragment(onheap);  //give new candidate caldetsi to mom
00117   }
00118   
00119   return JobCResult(JobCResult::kPassed);  
00120 
00121 }//end Reco
00122 
00123 //__________________________________________________________________________
00124 
00125 void CalDetSIModule::HandleCommand(JobCommand *cmd)
00126 {
00127   const char *c = cmd->PopCmd();
00128   if(c){
00129     string sc(c);
00130     
00131     if(sc=="MonteCarlo"){
00132       fIsMC = kTRUE;
00133     }
00134 
00135     MSG("CalDetSIModule", Msg::kInfo)<<"Prepared for a MonteCarlo File"<<endl;
00136   
00137   }
00138 
00139 }//end HandleCommand
00140 
00141 //__________________________________________________________________________
00142 
00143 
00144 
00145 
00146 
00147 
00148 
00149 
00150 
00151 
00152 
00153 
00154 
00155 
00156 
00157 

Generated on Fri Mar 28 15:28:57 2008 for loon by  doxygen 1.3.9.1