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

PurgeCandidateModule.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "PurgeCandidateModule.h"
00009 #include "MessageService/MsgService.h"
00010 #include "MinosObjectMap/MomNavigator.h"
00011 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00012 #include "CandData/CandRecord.h"
00013 #include "DataUtil/GetCandidate.h"
00014 #include "Candidate/CandHandle.h"
00015 
00016 JOBMODULE(PurgeCandidateModule, "PurgeCandidateModule",
00017           "Removes candidates from Mom");
00018 CVSID("$Id: PurgeCandidateModule.cxx,v 1.1 2005/06/30 10:22:42 tagg Exp $");
00019 //......................................................................
00020 
00021 PurgeCandidateModule::PurgeCandidateModule() : 
00022   fCandidates("")
00023 {
00027 }
00028 //......................................................................
00029 
00030 PurgeCandidateModule::~PurgeCandidateModule()
00031 {
00035 }
00036 
00037 //......................................................................
00038 
00039 JobCResult PurgeCandidateModule::Reco(MomNavigator* mom)
00040 {
00045   vector<string> list;
00046   UInt_t n = fCandidates.length();
00047   UInt_t start = 0;
00048   UInt_t end = n;
00049   while(start<n) {
00050     UInt_t pos = fCandidates.find_first_of(',',start);
00051     if(pos==string::npos) end = n;
00052     else                  end=pos;
00053     if(start>=end) break;
00054     list.push_back(fCandidates.substr(start,end-start));
00055     start = end+1;
00056     end = n;
00057   }
00058   
00059   // Find PrimaryCandidateRecord fragment in MOM.
00060   CandRecord *candrec = dynamic_cast<CandRecord *>
00061     (mom->GetFragment("CandRecord", "PrimaryCandidateRecord"));
00062   if (candrec == 0) {
00063     MSG("DataUtil", Msg::kWarning) << "No PrimaryCandidateRecord in MOM."
00064                                    << endl;
00065     return JobCResult::kFailed;
00066   }
00067   
00068   for(UInt_t i=0;i<list.size(); i++) {
00069     CandHandle* ch;
00070     while( (ch = candrec->FindCandHandle(list[i].c_str())) ) {
00071       if(candrec->RemoveCandHandle(ch))
00072         MSG("DataUtil",Msg::kDebug)   << "Purged " << list[i] << endl;
00073       else 
00074         MSG("DataUtil",Msg::kWarning) << "Cand find " << list[i] << " to purge" << endl;    
00075     }
00076   }
00077 
00078   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00079 }
00080 
00081 //......................................................................
00082 
00083 const Registry& PurgeCandidateModule::DefaultConfig() const
00084 {
00088   static Registry r; // Default configuration for module
00089 
00090   // Set name of config
00091   std::string name = this->GetName();
00092   name += ".config.default";
00093   r.SetName(name.c_str());
00094 
00095   // Set values in configuration
00096   r.UnLockValues();
00097   r.Set("Candidates","CandStripListHandle,CandSliceListHandle,CandClusterListHandle,CandShowerListHandle,CandEventListHandle");
00098   r.LockValues();
00099 
00100   return r;
00101 }
00102 
00103 //......................................................................
00104 
00105 void PurgeCandidateModule::Config(const Registry& r)
00106 {
00110   fCandidates = r.GetCharString("Candidates");
00111 }
00112 

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