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

ParticleTruthMaker.cxx

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include "NueAna/ParticlePID/ParticleFinder/Truth/ParticleTruthMaker.h"
00009 #include "MessageService/MsgService.h"
00010 #include "MinosObjectMap/MomNavigator.h"
00011 #include "JobControl/JobCModuleRegistry.h" // For JOBMODULE macro
00012 
00013 #include "CandNtupleSR/NtpSREvent.h"
00014 #include "CandNtupleSR/NtpSRStrip.h"
00015 #include "CandNtupleSR/NtpSRPulseHeight.h"
00016 
00017 #include "StandardNtuple/NtpStRecord.h"
00018 
00019 #include "MCNtuple/NtpMCDigiScintHit.h"
00020 #include "MCNtuple/NtpMCStdHep.h"
00021 
00022 #include "NueAna/ParticlePID/ParticleFinder/ParticleObjectHolder.h"
00023 #include "NueAna/ParticlePID/ParticleFinder/ParticleObject.h"
00024 #include "NueAna/ParticlePID/ParticleFinder/Particle.h"
00025 
00026 
00027 
00028 JOBMODULE(ParticleTruthMaker, "ParticleTruthMaker",
00029           "finds particles");
00030 
00031 //......................................................................
00032 
00033 ParticleTruthMaker::ParticleTruthMaker() :helper(0)  
00034 {
00035 
00036 helper = new ParticleTruthHelper();
00037 
00038 
00039 
00043 }
00044 //......................................................................
00045 
00046 ParticleTruthMaker::~ParticleTruthMaker()
00047 {
00051 
00052 if(helper) delete helper;
00053 
00054 }
00055 
00056 //......................................................................
00057 
00058 void ParticleTruthMaker::BeginJob()
00059 {
00063 }
00064 
00065 //......................................................................
00066 
00067 void ParticleTruthMaker::EndJob()
00068 {
00072 }
00073 
00074 //......................................................................
00075 
00076 JobCResult ParticleTruthMaker::Reco(MomNavigator* mom)
00077 {
00081 
00082 //MSG("ParticleTruthMaker",Msg::kDebug) << "reco called\n";
00083 
00084   NtpStRecord *str=dynamic_cast<NtpStRecord *>(mom->GetFragment("NtpStRecord"));
00085 
00086 
00087   //std::vector<ParticleObjectHolder *>* hf;
00088   std:vector<TObject* > hft =( mom->GetFragmentList("ParticleObjectHolder"));
00089 
00090 
00091 
00092   int make_new_holder=1;
00093 
00094 
00095   if(hft.size()>0)
00096   {
00097       make_new_holder=0;
00098   }
00099  
00100 
00101 printf("size of found array %d\n",hft.size()); 
00102 
00103   std::vector<const NtpSREvent* > evts = str->GetEvents();
00104   
00105 
00106   //TClonesArray * digihit = str->digihit;
00107 
00108   printf("Events %d \n",evts.size());
00109   if(evts.size()<1)
00110         {
00111 
00112                 if(make_new_holder)
00113                 {
00114                         ParticleObjectHolder * h = new ParticleObjectHolder(); 
00115                         mom->AdoptFragment(h);
00116                 }
00117 
00118                 return JobCResult::kPassed;  
00119         }
00120 
00121 
00122         printf("!!! %d events, %d  currently there \n", evts.size(), hft.size());
00123 
00124 //for now multiple events are in the same TObjArray...
00125 
00126 int ievt=0;
00127  // for(int ievt=0;ievt<evts.size();ievt++)
00128  // {
00129 
00130    //    std::vector<const NtpSRStrip* > stp = str->GetStrips(ievt);
00131 //      TClonesArray * digihit = &( str->digihit[ievt]); 
00132 
00133         TClonesArray * digihit = str->digihit;
00134 
00135 
00136         TClonesArray * stdhep = str->stdhep;
00137         
00138 //      TClonesArray *digihit = &dh[ievt];
00139 
00140         helper->Reset();
00141 
00142 
00143         ParticleObjectHolder *n=0;
00144 
00145 
00146         if(make_new_holder || hft.size() < ievt+1)
00147         {
00148                 ParticleObjectHolder * h = new ParticleObjectHolder();
00149                 mom->AdoptFragment(h);
00150                 n=h;
00151         }else{
00152                 n=dynamic_cast<ParticleObjectHolder *>(hft[ievt]);
00153         }
00154 
00155 
00156 printf("partices in current evt %d array %d \n", ievt, n->particles->GetEntries());
00157 
00158         if(n->particletruth->GetEntries()>0)return JobCResult::kPassed; 
00159 
00160 
00161 
00162 
00163         printf("-event %d  with %d strips\n",ievt,evts[ievt]->nstrip);
00164 
00165         //Load processor with event strip data
00166         for(int i=0;i<digihit[ievt].GetEntries();i++)
00167         {
00168         //      helper->AddStrip(stp[evts[ievt]->stp[i]]->plane, stp[evts[ievt]->stp[i]]->strip, (stp[evts[ievt]->stp[i]]->ph0.sigcor+stp[evts[ievt]->stp[i]]->ph1.sigcor)/565.0, stp[evts[ievt]->stp[i]]->tpos, stp[evts[ievt]->stp[i]]->z);
00169                 NtpMCDigiScintHit * dh =  ( NtpMCDigiScintHit *)digihit[ievt][i];
00170                 
00171 
00172                 int trkid = dh->trkId;
00173                 trkid=trkid<0?-trkid:trkid; //abs it
00174 
00175                 NtpMCStdHep * sh = (NtpMCStdHep *)stdhep[ievt][trkid];
00176 
00177                 
00178 
00179                 helper->AddStrip(sh->IdHEP, trkid, dh->plane,dh->strip, dh->dE, dh->planeview);
00180 
00181 
00182 //              printf("%d %d %d %f\n", dh->pId, dh->plane,dh->strip, dh->dE);
00183 
00184         }
00185 
00186         helper->Process(*n);
00187         
00188 
00189         //process event, returns particleobject 
00190 
00191 //dont need digihits anymore, so reset them
00192 digihit->Clear();
00193 
00194   //}
00195 
00196 
00197 
00198 
00199 
00200   return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00201 }
00202 
00203 //......................................................................
00204 
00205 const Registry& ParticleTruthMaker::DefaultConfig() const
00206 {
00210   static Registry r; // Default configuration for module
00211 
00212   // Set name of config
00213   std::string name = this->GetName();
00214   name += ".config.default";
00215   r.SetName(name.c_str());
00216 
00217   // Set values in configuration
00218   r.UnLockValues();
00219   r.LockValues();
00220 
00221   return r;
00222 }
00223 
00224 //......................................................................
00225 
00226 void ParticleTruthMaker::Config(const Registry& r)
00227 {
00231 }
00232 
00233 //......................................................................
00234 
00235 void ParticleTruthMaker::Reset()
00236 {
00240 }
00241 

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