PIDEval Class Reference

#include <PIDEval.h>

Inheritance diagram for PIDEval:
JobCModule

List of all members.

Public Member Functions

 PIDEval ()
 ~PIDEval ()
void ana (Particles *p, Event *e, NueRecord *nr)
void BeginJob ()
void EndJob ()
JobCResult Reco (MomNavigator *mom)
const RegistryDefaultConfig () const
void Config (const Registry &r)
void Reset ()

Static Public Member Functions

static void LoadMLP ()

Private Attributes

string infile
string outfile
int cnt
int total
string kPOTTreeName
string kPOTTreeNameIn

Static Private Attributes

static int first = 1
static TMultiLayerPerceptron * mlp1 = 0
static TMultiLayerPerceptron * mlp2 = 0
static TMultiLayerPerceptron * mlp3 = 0
static TMultiLayerPerceptron * mlp4 = 0
static TMultiLayerPerceptron * mlp5 = 0
static TMultiLayerPerceptron * mlp6 = 0

Detailed Description

Definition at line 17 of file PIDEval.h.


Constructor & Destructor Documentation

PIDEval::PIDEval (  ) 

Definition at line 31 of file PIDEval.cxx.

References cnt, first, infile, LoadMLP(), mlp1, outfile, and total.

00032 {
00033         if(mlp1==0 && first) //only try once...
00034     {
00035                 LoadMLP();
00036                 first=0;
00037     }
00038     
00039         infile="";
00040         outfile="";
00041         cnt=0;
00042         total=1;
00043         
00044         
00045         //osc
00046 
00047 /*      fBaseLine = 735;
00048         fDeltaMS12= 8.0;
00049         fTh12= 0.816;
00050         fTh23=3.141592/4.0;
00051         fDensity=2.75;
00052         SetOscParamBase(0.00243, TMath::ASin(TMath::Sqrt(0.15))/2.0, 0, 1);     
00053   */               
00054   
00055 }

PIDEval::~PIDEval (  ) 

Definition at line 57 of file PIDEval.cxx.

00058 {}


Member Function Documentation

void PIDEval::ana ( Particles p,
Event e,
NueRecord nr 
)

Definition at line 181 of file PIDEval.cxx.

References cnt, Particles::emfrac, Particles::largest_particle_cmp_chisq, Particles::largest_particle_cmp_ndf, Particles::largest_particle_e, Particles::largest_particle_peakdiff, Particles::longest_s_particle_s, mlp1, mlp2, mlp3, mlp4, mlp5, mlp6, Particles::mol_rad_r, Particles::ntot, Particles::prim_par_a, Particles::prim_par_b, Particles::prim_par_chisq, Particles::prim_par_e0, Particles::totvise, and Particles::weighted_phi.

Referenced by Reco().

00182 {
00183 
00184         if(cnt%10000==0)printf("%d ... \n",cnt);//%2.2f%%\n",cnt,100.*((double)cnt)/((double)total));
00185         cnt++;
00186 
00187 
00188 
00189         event->pidA=-1;
00190         event->pidB=-1;
00191         event->pidC=-1;
00192         event->pidD=-1;
00193         event->pidE=-1; 
00194         event->pidF=-1;
00195 
00196 
00197 
00198         //double reco_frac=particles->prim_vise/event->visenergy;
00199         //double length_z = event->max_z - event->min_z;        
00200     
00201     double largest_frac=particles->totvise ? 
00202         particles->largest_particle_e/particles->totvise : 1;
00203     double prim_ae0=particles->prim_par_e0 ? 
00204         particles->prim_par_a/particles->prim_par_e0 : 0;
00205         double largest_cmp_chisqndf = particles->largest_particle_cmp_ndf ?
00206                 particles->largest_particle_cmp_chisq / 
00207                         particles->largest_particle_cmp_ndf : 0;
00208         
00209         
00210 
00211         //check ranges
00212         if(particles->longest_s_particle_s<0 || 
00213                 particles->longest_s_particle_s>6)return;
00214         //removing restriction on longest_z since it is not in the nn
00215         //if(particles->longest_z<0 || 
00216         //      particles->longest_z>6)return;
00217         if(particles->ntot<0 || 
00218                 particles->ntot>50)return;
00219         //removing restriction on rms_r since it is not in the nn
00220         //if(particles->rms_r<0 || 
00221         //      particles->rms_r>100)return;
00222         if(particles->prim_par_e0<0 || 
00223                 particles->prim_par_e0>40e3)return;
00224         //changing max on prim_par_chisq from 1000 to 10000 for flexibility
00225         if(particles->prim_par_chisq<0 || 
00226                 particles->prim_par_chisq>10000)return;
00227         if(particles->largest_particle_peakdiff<-200 || 
00228                 particles->largest_particle_peakdiff>200)return;                
00230 
00231     
00232     
00233 
00234         double pars[30];//30? Pick numer based on appropriate neural network.
00235         
00236         int z=0;
00237         
00238     if(mlp1 || mlp2)
00239     {
00240 
00241                 z=0;
00242                 
00243 
00244                 pars[z++]=particles->longest_s_particle_s;
00245                 pars[z++]=particles->mol_rad_r;
00246                 pars[z++]=particles->emfrac;
00247                 pars[z++]=particles->ntot;
00248                 pars[z++]=particles->weighted_phi;
00249                 pars[z++]=largest_frac;
00250                 pars[z++]=particles->prim_par_b;
00251                 pars[z++]=particles->prim_par_e0;
00252                 pars[z++]=particles->prim_par_chisq;
00253                 pars[z++]=largest_cmp_chisqndf;
00254                 pars[z++]=particles->prim_par_a;
00255                 pars[z++]=event->nclusters;
00256                 pars[z++]=prim_ae0;
00257 
00258                 for(int i=z;i<30;i++)pars[i]=0;
00259         
00260  
00261                 event->pidA = mlp1 ? mlp1->Evaluate(0, pars) : -1;
00262 
00263                 event->pidB = mlp2 ? mlp2->Evaluate(0, pars) : -1;
00264  
00265         }
00266         
00267         
00268 
00269 
00270         
00271     if(mlp3 || mlp4 || mlp5 || mlp6)
00272     {
00273 
00274                 z=0;
00275                 
00276 
00277                 pars[z++]=particles->longest_s_particle_s;
00278                 pars[z++]=particles->mol_rad_r;
00279                 pars[z++]=particles->emfrac;
00280                 pars[z++]=particles->ntot;
00281                 pars[z++]=particles->weighted_phi;
00282                 pars[z++]=largest_frac;
00283                 pars[z++]=particles->prim_par_b;
00284                 pars[z++]=particles->prim_par_e0;
00285                 pars[z++]=particles->prim_par_chisq;
00286                 pars[z++]=particles->largest_particle_peakdiff;
00287                 pars[z++]=largest_cmp_chisqndf;
00288                 pars[z++]=particles->prim_par_a;
00289                 pars[z++]=event->nclusters;
00290                 pars[z++]=prim_ae0;
00291 
00292                 for(int i=z;i<30;i++)pars[i]=0;
00293         
00294  
00295                 event->pidC = mlp3 ? mlp3->Evaluate(0, pars) : -1;
00296 
00297                 event->pidD = mlp4 ? mlp4->Evaluate(0, pars) : -1;
00298 
00299                 event->pidE = mlp5 ? mlp5->Evaluate(0, pars) : -1;
00300 
00301                 event->pidF = mlp6 ? mlp6->Evaluate(0, pars) : -1;
00302                  
00303         }
00304         
00305          
00306     
00307     
00308 
00309 }

void PIDEval::BeginJob ( void   )  [virtual]

Implement for notification of begin of job

(Document me!)

Reimplemented from JobCModule.

Definition at line 316 of file PIDEval.cxx.

00317 {
00321 
00322 /*      TFile *f = TFile::Open(infile.c_str());
00323         if(!f)return;
00324         TTree * pt = (TTree*)f->Get("PA");
00325         if(pt)
00326         {
00327                 total=pt->GetEntries();
00328                 printf("%d total PRecords\n",total);
00329         }
00330         f->Close();
00331 */
00332 
00333 }

void PIDEval::Config ( const Registry r  )  [virtual]

Return the actual configuration. If your module directly pulls its configuration from the fConfig Registry, you don't need to override this. Override if you have local config variables.

Configure the module given the Registry r

Reimplemented from JobCModule.

Definition at line 470 of file PIDEval.cxx.

References Registry::Get(), infile, kPOTTreeName, kPOTTreeNameIn, and outfile.

00471 {
00475   
00476  
00477     const char* tmps;
00478     if(r.Get("InFileName",tmps)){infile=tmps;}
00479     if(r.Get("OutFileName",tmps)){outfile=tmps;}  
00480 
00481 
00482     if(r.Get("POTTreeName",tmps))kPOTTreeName=tmps;
00483     if(r.Get("POTTreeNameIn",tmps))kPOTTreeNameIn=tmps;
00484 
00485 }

const Registry & PIDEval::DefaultConfig ( void   )  const [virtual]

Get the default configuration registry. This should normally be overridden. One useful idiom is to implement it like:

const Registry& MyModule::DefaultConfig() const { static Registry cfg; // never is destroyed if (cfg.Size()) return cfg; // already filled it // set defaults: cfg.Set("TheAnswer",42); cfg.Set("Units","unknown"); return cfg; }

Supply the default configuration for the module

Reimplemented from JobCModule.

Definition at line 437 of file PIDEval.cxx.

References JobCModule::GetName(), Registry::LockValues(), Registry::Set(), and Registry::UnLockValues().

00438 {
00442 
00443   static Registry r; // Default configuration for module
00444 
00445   // Set name of config
00446   std::string name = this->GetName();
00447   name += ".config.default";
00448   r.SetName(name.c_str());
00449   r.Set("InFileName",""); //don't set when used with a real reco chain
00450   r.Set("OutFileName","");
00451   // Set values in configuration
00452 
00453   r.Set("POTTreeName","");
00454   r.Set("POTTreeNameIn","");
00455 
00456 
00457 
00458 
00459 
00460 
00461   r.UnLockValues();
00462   r.LockValues();
00463 
00464 
00465   return r;
00466 }

void PIDEval::EndJob (  )  [virtual]

Implement for notification of end of job

(Document me!)

Reimplemented from JobCModule.

Definition at line 337 of file PIDEval.cxx.

References kPOTTreeName, and kPOTTreeNameIn.

00338 {
00342 
00343 
00344         //copy pot tree?
00345 /*      if(infile!="" && outfile!="")
00346         {
00347                 //copy the pot tree
00348 
00349                 TDirectory *savedir = gDirectory;
00350         
00351                 TFile *fpf = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject(outfile.c_str()));
00352                 if(fpf){
00353 
00354                         TFile *f = TFile::Open(infile.c_str());
00355                         TTree * pt = (TTree*)f->Get("pottree");
00356                         fpf->cd();
00357                         if(pt)
00358                                 pt->CloneTree()->Write("pottree");
00359                         else
00360                                 printf("NO POTTREE FOUND...!\n");
00361                         savedir->cd();
00362                 }
00363         
00364         }
00365 */
00366 
00367 
00368   if(kPOTTreeName=="")return; //don't want to copy pottree...
00369   
00370 
00371    printf("PIDEval copying POTtree from input file\n");  
00372    TFile *fpf = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject(kPOTTreeName.c_str()));
00373    if(fpf){
00374         printf("got outfile\n");
00375    }
00376 
00377 
00378    TFile *fpi = dynamic_cast<TFile *>(gROOT->GetListOfFiles()->FindObject(kPOTTreeNameIn.c_str()));
00379    if(fpi){
00380         printf("got infile\n");
00381         TTree *pt = (TTree*)fpi->Get("pottree");
00382         if(pt)
00383         {
00384                 printf("got pottree\n");
00385                 fpf->cd();
00386                 pt->CloneTree()->Write();
00387         }
00388    }
00389 
00390 
00391 
00392 
00393 }

void PIDEval::LoadMLP (  )  [static]

Definition at line 60 of file PIDEval.cxx.

References exit(), mlp1, mlp2, mlp3, mlp4, mlp5, and mlp6.

Referenced by PIDEval().

00061 {
00062   TFile *mlpfile0 = TFile::Open("/minos/app/nue/Releases/Griffin/Data/ParticlePID/finalMLPs/MLP_13inp_20:9.root");
00063   if (mlpfile0==0)
00064     {
00065       printf("Error in PIDEval::LoadMLP() 1-- Bad file name\n");
00066     }
00067   if(mlpfile0)mlp1 = (TMultiLayerPerceptron*) mlpfile0->Get("MLP");
00068   if (mlp1==0)
00069     {
00070       printf("Error in PIDEval::LoadMLP() 1-- File does not contain mlp\n");
00071     }else{
00072                 printf("loaded ParticlePID from %s\n",mlpfile0->GetName());
00073                 mlp1=(TMultiLayerPerceptron*)mlp1->Clone();
00074                 mlpfile0->Close();
00075         }
00076 
00077         TFile *mlpfile1 = TFile::Open("/minos/app/nue/Releases/Griffin/Data/ParticlePID/finalMLPs/MLP_13inp_25:10.root");
00078   if (mlpfile1==0)
00079     {
00080       printf("Error in PIDEval::LoadMLP() 2-- Bad file name\n");
00081       
00082     }
00083   if(mlpfile1)mlp2 = (TMultiLayerPerceptron*) mlpfile1->Get("MLP");
00084   if (mlp2==0)
00085     {
00086       printf("Error in PIDEval::LoadMLP() 2-- File does not contain mlp\n");
00087     }else{
00088                 printf("loaded ParticlePID from %s\n",mlpfile1->GetName());
00089                 mlp2=(TMultiLayerPerceptron*)mlp2->Clone();
00090                 mlpfile1->Close();
00091         }
00092   
00093   
00094         TFile *mlpfile2 = TFile::Open("/minos/app/nue/Releases/Griffin/Data/ParticlePID/finalMLPs/MLP_14inp_16:9.root");
00095   if (mlpfile2==0)
00096     {
00097       printf("Error in PIDEval::LoadMLP() 3-- Bad file name\n");
00098       
00099     }
00100   if(mlpfile2)mlp3 = (TMultiLayerPerceptron*) mlpfile2->Get("MLP");
00101   if (mlp3==0)
00102     {
00103       printf("Error in PIDEval::LoadMLP() 3-- File does not contain mlp\n");
00104     }else{
00105                 printf("loaded ParticlePID from %s\n",mlpfile2->GetName());
00106                 mlp3=(TMultiLayerPerceptron*)mlp3->Clone();
00107                 mlpfile2->Close();
00108         }  
00109   
00110   
00111   
00112   
00113         TFile *mlpfile3 = TFile::Open("/minos/app/nue/Releases/Griffin/Data/ParticlePID/finalMLPs/MLP_14inp_18:11.root");
00114 
00115   if (mlpfile3==0)
00116     {
00117       printf("Error in PIDEval::LoadMLP() 4-- Bad file name\n");
00118       
00119     }
00120   if(mlpfile3)mlp4 = (TMultiLayerPerceptron*) mlpfile3->Get("MLP");
00121   if (mlp4==0)
00122     {
00123       printf("Error in PIDEval::LoadMLP() 4-- File does not contain mlp\n");
00124     }else{
00125                 printf("loaded ParticlePID from %s\n",mlpfile3->GetName());
00126                 mlp4=(TMultiLayerPerceptron*)mlp4->Clone();
00127                 mlpfile3->Close();
00128         }    
00129   
00130  
00131   
00132         TFile *mlpfile4 = TFile::Open("/minos/app/nue/Releases/Griffin/Data/ParticlePID/finalMLPs/MLP_14inp_18:6.root");
00133 
00134   if (mlpfile4==0)
00135     {
00136       printf("Error in PIDEval::LoadMLP() 5-- Bad file name\n");
00137       
00138     }
00139   if(mlpfile4)mlp5 = (TMultiLayerPerceptron*) mlpfile4->Get("MLP");
00140   if (mlp5==0)
00141     {
00142       printf("Error in PIDEval::LoadMLP() 5-- File does not contain mlp\n");
00143     }else{
00144                 printf("loaded ParticlePID from %s\n",mlpfile4->GetName());
00145                 mlp5=(TMultiLayerPerceptron*)mlp5->Clone();
00146                 mlpfile4->Close();
00147         }  
00148         
00149         
00150  
00151   
00152         TFile *mlpfile5 = TFile::Open("/minos/app/nue/Releases/Griffin/Data/ParticlePID/finalMLPs/MLP_14inp_23:6.root");
00153 
00154   if (mlpfile5==0)
00155     {
00156       printf("Error in PIDEval::LoadMLP() 6-- Bad file name\n");
00157       
00158     }
00159   if(mlpfile5)mlp6 = (TMultiLayerPerceptron*) mlpfile5->Get("MLP");
00160   if (mlp6==0)
00161     {
00162       printf("Error in PIDEval::LoadMLP() 6-- File does not contain mlp\n");
00163     }else{
00164                 printf("loaded ParticlePID from %s\n",mlpfile5->GetName());
00165                 mlp6=(TMultiLayerPerceptron*)mlp6->Clone();
00166                 mlpfile5->Close();
00167         }         
00168 
00169 
00170     if(! (mlp1 || mlp2 || mlp3 || mlp4 || mlp5 || mlp6) )
00171     {           
00172         printf("ParticlePID files are missing! directory must have moved\nexiting...\n");
00173         exit(1);
00174     }
00175 
00176 
00177   
00178   
00179 }

JobCResult PIDEval::Reco ( MomNavigator mom  )  [virtual]

Implement this for read-write access to the MomNavigator

(Document me!)

Reimplemented from JobCModule.

Definition at line 397 of file PIDEval.cxx.

References ana(), PRecord::event, MomNavigator::GetFragmentList(), JobCResult::kPassed, n, PRecord::particles, NueRecord::precord, and NueRecord::precordMRCC.

00398 {
00402 
00403 
00404         std::vector<TObject* > hft =( mom->GetFragmentList("PRecord"));
00405 
00406         for(unsigned int s =0;s<hft.size();s++)
00407         {
00408                 PRecord *n=0;
00409                 n=dynamic_cast<PRecord *>(hft[s]);
00410                 ana(&(n->particles),&(n->event),0);
00411                 
00412                 //recalc_oscprob(n);
00413                 //adjRecoE(n);
00414         }
00415 
00416         if(hft.size()<1) //no PRecords.. so look for nuerecords...
00417         {
00418                 std::vector<TObject* > nrv =( mom->GetFragmentList("NueRecord"));
00419                 NueRecord * nr =0;
00420                 for(unsigned int s=0;s<nrv.size();s++)
00421                 {
00422                         nr = dynamic_cast<NueRecord *>(nrv[s]);         
00423                         PRecord *n=&nr->precord;
00424                         if(n)ana(&(n->particles),&(n->event),nr);
00425                         n=&nr->precordMRCC;
00426                         if(n)ana(&(n->particles),&(n->event),nr);
00427                         
00428         //              recalc_oscprob(nr);
00429                 }
00430         }
00431 
00432         return JobCResult::kPassed; // kNoDecision, kFailed, etc.
00433 }

void PIDEval::Reset (  )  [virtual]

Implement to reset oneself

(Document me!)

Reimplemented from JobCModule.

Definition at line 489 of file PIDEval.cxx.

00490 {
00494 }


Member Data Documentation

int PIDEval::cnt [private]

Definition at line 55 of file PIDEval.h.

Referenced by ana(), and PIDEval().

int PIDEval::first = 1 [static, private]

Definition at line 46 of file PIDEval.h.

Referenced by PIDEval().

string PIDEval::infile [private]

Definition at line 53 of file PIDEval.h.

Referenced by Config(), and PIDEval().

string PIDEval::kPOTTreeName [private]

Definition at line 71 of file PIDEval.h.

Referenced by Config(), and EndJob().

string PIDEval::kPOTTreeNameIn [private]

Definition at line 72 of file PIDEval.h.

Referenced by Config(), and EndJob().

TMultiLayerPerceptron * PIDEval::mlp1 = 0 [static, private]

Definition at line 47 of file PIDEval.h.

Referenced by ana(), LoadMLP(), and PIDEval().

TMultiLayerPerceptron * PIDEval::mlp2 = 0 [static, private]

Definition at line 48 of file PIDEval.h.

Referenced by ana(), and LoadMLP().

TMultiLayerPerceptron * PIDEval::mlp3 = 0 [static, private]

Definition at line 49 of file PIDEval.h.

Referenced by ana(), and LoadMLP().

TMultiLayerPerceptron * PIDEval::mlp4 = 0 [static, private]

Definition at line 50 of file PIDEval.h.

Referenced by ana(), and LoadMLP().

TMultiLayerPerceptron * PIDEval::mlp5 = 0 [static, private]

Definition at line 51 of file PIDEval.h.

Referenced by ana(), and LoadMLP().

TMultiLayerPerceptron * PIDEval::mlp6 = 0 [static, private]

Definition at line 52 of file PIDEval.h.

Referenced by ana(), and LoadMLP().

string PIDEval::outfile [private]

Definition at line 54 of file PIDEval.h.

Referenced by Config(), and PIDEval().

int PIDEval::total [private]

Definition at line 56 of file PIDEval.h.

Referenced by PIDEval().


The documentation for this class was generated from the following files:

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1