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

ParticlePIDSaver.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #include "TTree.h"
00010 #include "TFile.h"
00011 #include "TDirectory.h"
00012 #include "TROOT.h"
00013 
00014 #include "NueAna/ParticlePID/ParticlePIDSaver.h"
00015 #include "MessageService/MsgService.h"
00016 #include "MinosObjectMap/MomNavigator.h"
00017 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00018 
00019 
00020 JOBMODULE(ParticlePIDSaver, "ParticlePIDSaver",
00021           "copies PRecords from MOM into NueRecord");
00022 CVSID("$Id: ParticlePIDSaver.cxx,v 1.6 2009/08/13 11:29:10 scavan Exp $");
00023 
00024 
00025 
00026 
00027 //......................................................................
00028 
00029 ParticlePIDSaver::ParticlePIDSaver() 
00030 {
00031 
00035 }
00036 //......................................................................
00037 
00038 ParticlePIDSaver::~ParticlePIDSaver()
00039 {
00043 
00044 }
00045 
00046 //......................................................................
00047 
00048 void ParticlePIDSaver::BeginJob()
00049 {
00053 }
00054 
00055 //......................................................................
00056 
00057 void ParticlePIDSaver::EndJob()
00058 {
00062 
00063   if(kPOTTreeName=="")return; //don't want to copy pottree...
00064 
00065 
00066    TFile *fpf = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject(kPOTTreeName.c_str()));
00067    if(fpf){
00068         printf("got outfile\n");
00069    }
00070 
00071 
00072    TFile *fpi = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject(kPOTTreeNameIn.c_str()));
00073    if(fpi){
00074         printf("got infile\n");
00075         TTree *pt = (TTree*)fpi->Get("pottree");           
00076         if(pt)
00077         {
00078                 printf("got pottree\n");
00079                 fpf->cd();
00080                 pt->Write();
00081         }
00082    }
00083 
00084 
00085 
00086 
00087 }
00088 
00089 //......................................................................
00090 
00091 JobCResult ParticlePIDSaver::Reco(MomNavigator* mom)
00092 {
00096 
00097 
00098   std::vector<TObject* > nrv = ( mom->GetFragmentList("NueRecord"));
00099   std::vector<TObject* > hft =( mom->GetFragmentList("PRecord","Normal"));
00100   std::vector<TObject* > hftm =( mom->GetFragmentList("PRecord","MRCC"));
00101 
00102 
00103 for(unsigned int s =0;s<hft.size();s++)
00104 {
00105 
00106         PRecord *pr=0;
00107         pr=dynamic_cast<PRecord *>(hft[s]);
00108 
00109         if(!pr)continue;
00110         
00111         NueRecord *nr=0;
00112         if(s<nrv.size())
00113                 nr=dynamic_cast<NueRecord *>(nrv[s]);
00114 
00115 
00116         //make sure we are synced...
00117         int match=0;
00118         if(nr)match=isMatched(nr,pr);
00119         
00120         if(!match)
00121         {
00122                 for(int m=0;m<(int)nrv.size();m++)
00123                 {
00124                         nr=dynamic_cast<NueRecord *>(nrv[m]);
00125                         int mm = isMatched(nr,pr);
00126                         if(mm){
00127                                 match=1;
00128                                 break;
00129                         }
00130                 }
00131         }
00132   
00133         if(!match)continue;//unable to finding matching nue record... probably not passing nue quality cuts
00134 
00135 
00136 /*
00137         if(!match)
00138         {
00139                 printf("unable to match in ParticlePIDSaver!\n");
00140                 exit(1);
00141         }
00142 */      
00143         
00144         (nr->precord) = *pr;
00145 
00146         //is there an mrcc record?
00147         for(unsigned int j=0;j<hftm.size();j++)
00148         {
00149                 PRecord *pr=0;
00150                 pr=dynamic_cast<PRecord *>(hftm[j]);
00151                 if(!pr)continue;
00152 
00153                 //make sure we are synced...
00154                 int match=1;
00155                 match = match && (nr->GetHeader().GetRun() == pr->GetHeader().GetRun());
00156                 match = match && (nr->GetHeader().GetSnarl() == pr->GetHeader().GetSnarl());
00157                 match = match && (nr->GetHeader().GetEventNo() == pr->GetHeader().GetEvent());
00158 
00159                 if(match)
00160                 {
00161 
00162                         (nr->precordMRCC) = *pr;
00163 
00164                 }
00165 
00166         }
00167 
00168 }
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00177 }
00178 
00179 //......................................................................
00180 
00181 const Registry& ParticlePIDSaver::DefaultConfig() const
00182 {
00186   static Registry r; // Default configuration for module
00187 
00188 
00189   std::string name = this->GetName();
00190   name += ".config.default";
00191   r.SetName(name.c_str());
00192 
00193 
00194 
00195 
00196   // Set values in configuration
00197   r.UnLockValues();
00198   r.Set("POTTreeName","");
00199   r.Set("POTTreeNameIn","");
00200 
00201   r.LockValues();
00202 
00203 
00204   return r;
00205 }
00206 
00207 //......................................................................
00208 
00209 void ParticlePIDSaver::Config(const Registry& r)
00210 {
00214   
00215     const char* tmps;
00216     if(r.Get("POTTreeName",tmps))kPOTTreeName=tmps;
00217     if(r.Get("POTTreeNameIn",tmps))kPOTTreeNameIn=tmps;
00218 
00219 
00220   
00221 }
00222 
00223 //......................................................................
00224 
00225 void ParticlePIDSaver::Reset()
00226 {
00230 }
00231 
00233 
00234                 
00235 
00236 
00237 int ParticlePIDSaver::isMatched(NueRecord *nr, PRecord *pr)
00238 {
00239         int match = 1;
00240         match = match && (nr->GetHeader().GetRun() == pr->GetHeader().GetRun());
00241         match = match && (nr->GetHeader().GetSnarl() == pr->GetHeader().GetSnarl());
00242         match = match && (nr->GetHeader().GetEventNo() == pr->GetHeader().GetEvent());
00243 
00244         return match;
00245 }
00246 
00247 

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