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

StripCands.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include <cassert>
00009 
00010 #include "MuonRemoval/StripCands.h"
00011 #include "MessageService/MsgService.h"
00012 #include "MinosObjectMap/MomNavigator.h"
00013 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00014 
00015 #include <CandData/CandRecord.h>
00016 #include <CandData/CandHeader.h>
00017 #include <CandDigit/CandDigitListHandle.h>
00018 #include <RecoBase/CandTrackListHandle.h>
00019 #include <RecoBase/CandFitTrackHandle.h>
00020 #include <RecoBase/CandTrackHandle.h>
00021 #include <RecoBase/CandShowerHandle.h>
00022 #include <RecoBase/CandShowerListHandle.h>
00023 #include <RecoBase/CandStripHandle.h>
00024 #include <RecoBase/CandStripListHandle.h>
00025 #include <RecoBase/CandEventListHandle.h>
00026 #include <RecoBase/CandEventHandle.h>
00027 #include "StandardNtuple/NtpStRecord.h"
00028 
00029 #include "RawData/RawRecord.h"
00030 #include "RawData/RawDigit.h"
00031 #include "RawData/RawDigitDataBlock.h"
00032 
00033 JOBMODULE(StripCands, "StripCands",
00034           "strips cands");
00035 CVSID("$Id: StripCands.cxx,v 1.5 2007/02/13 01:11:18 cbs Exp $");
00036 //......................................................................
00037 
00038 StripCands::StripCands() : 
00039   fKeepDigitList("")
00040 {
00044 }
00045 //......................................................................
00046 
00047 StripCands::~StripCands()
00048 {
00052 }
00053 
00054 //......................................................................
00055 
00056 void StripCands::BeginJob()
00057 {
00061 }
00062 
00063 //......................................................................
00064 
00065 void StripCands::EndJob()
00066 {
00070 }
00071 
00072 //......................................................................
00073 
00074 JobCResult StripCands::Ana(const MomNavigator* mom)
00075 {
00079  CandRecord* candrec = dynamic_cast<CandRecord*>(mom->GetFragment("CandRecord"));
00080   if(!candrec){
00081     MSG("StripCands",Msg::kDebug) << " Unable to find CandRecord in mom " << endl;
00082     return JobCResult::kFailed;
00083   }
00084 
00085   const CandHeader* header  = dynamic_cast<const CandHeader*>(candrec->GetHeader());
00086 
00087   TIter iter(candrec->GetCandHandleIter());
00088   TObject* tobj = NULL;
00089   MSG("StripCands",Msg::kInfo)  << "************* New Mom **************" <<endl;
00090   if(header){
00091     MSG("StripCands",Msg::kInfo)  << "  Run:  " << header->GetRun()
00092                                <<  "    " << header->GetSnarl()<<endl;
00093   }
00094 
00095   RawRecord *rr = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord"));
00096   if (rr == 0) {
00097     MSG("StripCands", Msg::kWarning) << "No RawRecord in MOM." << endl;
00098     return JobCResult::kFailed;
00099   }
00100   const RawDigitDataBlock *rddb=dynamic_cast<const RawDigitDataBlock *>
00101     (rr->FindRawBlock("RawDigitDataBlock"));
00102 
00103   while((tobj = iter()) ){
00104     const CandHandle* cand = dynamic_cast<const CandHandle*>(tobj);
00105     assert(cand);
00106     MSG("StripCands",Msg::kInfo)  << cand->ClassName()<<":"
00107                                <<((cand->GetName())?cand->GetName():" ? ")
00108                                << "  N "  << cand->GetNDaughters() << endl;
00109     if(strcmp("CandDeMuxDigitListHandle", tobj->ClassName()) !=0 &&
00110        strcmp("CandDigitListHandle", tobj->ClassName()) !=0 &&
00111        strcmp("CandStripListHandle", tobj->ClassName()) !=0){
00112       TIter iter2(cand->GetDaughterIterator());
00113       TObject* tobj2 = 0;
00114       while((tobj2 = iter2())){
00115         const CandHandle* cand2= dynamic_cast<const CandHandle*>(tobj2);
00116         assert(cand2);
00117         MSG("StripCands",Msg::kInfo)  << "  " << cand2->ClassName()<<":"
00118                                    <<((cand2->GetName()!=NULL)?cand2->GetName():" ")<<endl;
00119       }
00120     }
00121     else if(MsgService::Instance()->IsActive("StripCands",Msg::kVerbose) && 
00122             strcmp("CandDigitListHandle", tobj->ClassName())==0){      
00123       TIter iter2(cand->GetDaughterIterator());
00124       TObject* tobj2 = 0;
00125       while((tobj2 = iter2())){
00126         const CandDigitHandle* cand2 = dynamic_cast<const CandDigitHandle*>(tobj2);
00127         const RawDigit* raw_digit = rddb->At(cand2->GetRawDigitIndex());
00128         MSG("StripCands",Msg::kVerbose) << cand2->GetRawDigitIndex() << " " 
00129                                         << raw_digit->GetADC() << " " 
00130                                         << raw_digit->GetTDC() << endl;
00131       }
00132     }
00133   }
00134   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00135 }
00136 
00137 //......................................................................
00138 
00139 JobCResult StripCands::Reco(MomNavigator* mom)
00140 {
00144   
00145  CandRecord* candrec = dynamic_cast<CandRecord*>(mom->GetFragment("CandRecord"));
00146   if(!candrec){
00147     MSG("StripCands",Msg::kDebug)  << " Unable to find CandRecord in mom " << endl;
00148     return JobCResult::kFailed;
00149   }
00150 
00151   const CandHeader* header  = dynamic_cast<const CandHeader*>(candrec->GetHeader());
00152   if(header){
00153     MSG("StripCands",Msg::kDebug)  << "Run:  " << header->GetRun()<<endl;
00154   }
00155 
00156   TIter iter(candrec->GetCandHandleIter());
00157   TObject* tobj = NULL;
00158   MSG("StripCands",Msg::kDebug)  << " New Mom : " <<endl;
00159   while( (tobj = iter()) ){
00160     CandHandle* cand = dynamic_cast<CandHandle*>(tobj);
00161     if( strcmp("candrmmulist", tobj->GetName()) ==0 ) { 
00162       MSG("StripCands",Msg::kDebug) << " Found and keeping: " 
00163                                  << tobj->ClassName() 
00164                                  <<":"<<tobj->GetName()<<endl;
00165       continue;
00166     }
00167     else if( strcmp(fKeepDigitList.c_str(), tobj->GetName()) !=0 ) {
00168       MSG("StripCands",Msg::kDebug) << " REMOVING: " <<  tobj->ClassName() 
00169                                  <<":"<<tobj->GetName()<<endl;
00170       candrec->RemoveCandHandle(cand);
00171     }
00172     else{
00173       MSG("StripCands",Msg::kDebug) <<" KEEPING: " <<  tobj->ClassName()
00174                                  <<":"<<tobj->GetName()<<endl;
00175       cand->SetName("canddigitlist");
00176       MSG("StripCands",Msg::kDebug) << "   Changed name " 
00177                                  << cand->GetName() <<endl; 
00178     }
00179   }
00180 
00181   /* NOT DOING THIS ANYMORE - CAN ALL BE CONFIGURED VIA MACRO
00182   //rename any Ntp objects:
00183   NtpStRecord *ntpst = dynamic_cast<NtpStRecord*> (mom->GetFragment("NtpStRecord"));
00184   if(ntpst) {
00185     MSG("StripCands",Msg::kDebug) << " RENAMING: " <<  ntpst->ClassName() 
00186                                   << ":" << ntpst->GetName() << endl;
00187     ntpst->SetName("NtpStRecordOld");
00188   }
00189   */
00190   
00191   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00192 }
00193 
00194 //......................................................................
00195 
00196 const Registry& StripCands::DefaultConfig() const
00197 {
00201   static Registry r; // Default configuration for module
00202 
00203   // Set name of config
00204   std::string name = this->GetName();
00205   name += ".config.default";
00206   r.SetName(name.c_str());
00207 
00208   // Set values in configuration
00209   r.UnLockValues();
00210   r.Set("keepdigitlist","mergedigitlist");
00211   r.LockValues();
00212 
00213   return r;
00214 }
00215 
00216 //......................................................................
00217 
00218 void StripCands::Config(const Registry& r)
00219 {
00223   fKeepDigitList = r.GetCharString("keepdigitlist");
00224 }
00225 

Generated on Mon Jun 16 14:58:42 2008 for loon by  doxygen 1.3.9.1