ParticleCheck Class Reference

#include <ParticleCheck.h>

List of all members.

Public Member Functions

 ParticleCheck (const char *fname)
 ~ParticleCheck ()
void Run ()
int PassesPreselec ()
void MakeHistos ()
void SaveHistos ()
void Process (int cut, int type, double weight)

Public Attributes

TChain * input
ParticleObjectHolderpoh
TChain * inputPA
PRecordprec
TH2F * elec_single_match_eres [nCut][nType]
TH2F * elec_single_match_angle [nCut][nType]
TH2F * elec_single_pi0_eres [nCut][nType]
TH2F * elec_single_pi0_angle [nCut][nType]
TH2F * elec_matched_elec_eres [nCut][nType]
TH2F * elec_matched_pi0_eres [nCut][nType]
TH2F * elec_matched_type_vs_recoE [nCut][nType]
TH2F * elec_matched_typefrac_vs_recoE [nCut][nType]

Detailed Description

Definition at line 13 of file ParticleCheck.h.


Constructor & Destructor Documentation

ParticleCheck::ParticleCheck ( const char *  fname  ) 

Definition at line 13 of file ParticleCheck.cxx.

References input, inputPA, poh, and prec.

00014 {
00015         input=new TChain("PO");
00016         inputPA=new TChain("PA");
00017         input->Add(fname);
00018         inputPA->Add(fname);
00019         poh=new ParticleObjectHolder();
00020         prec=new PRecord();
00021         input->SetBranchAddress("ParticleObjectHolder",&poh);
00022         inputPA->SetBranchAddress("PRecord",&prec);
00023 }

ParticleCheck::~ParticleCheck (  ) 

Definition at line 25 of file ParticleCheck.cxx.

00026 {}


Member Function Documentation

void ParticleCheck::MakeHistos (  ) 

Definition at line 133 of file ParticleCheck.cxx.

References elec_matched_elec_eres, elec_matched_pi0_eres, elec_matched_type_vs_recoE, elec_matched_typefrac_vs_recoE, elec_single_match_angle, elec_single_match_eres, elec_single_pi0_angle, elec_single_pi0_eres, nCut, and nType.

Referenced by Run().

00134 {
00135         for(int i=0;i<nCut;i++)
00136         for(int j=0;j<nType;j++)
00137         {
00138                 char tmp[200];
00139                 
00140                 sprintf(tmp,"elec_single_match_eres_%d_%d",i,j);
00141                 elec_single_match_eres[i][j]=new TH2F(tmp,tmp,100,-2,2,100,0,10);
00142                 
00143                 sprintf(tmp,"elec_single_match_angle_%d_%d",i,j);
00144                 elec_single_match_angle[i][j]=new TH2F(tmp,tmp,100,-2,2,100,0,10);
00145 
00146                 sprintf(tmp,"elec_single_pi0_eres_%d_%d",i,j);
00147                 elec_single_pi0_eres[i][j]=new TH2F(tmp,tmp,100,-2,2,100,0,10);
00148                 
00149                 sprintf(tmp,"elec_single_pi0_angle_%d_%d",i,j);
00150                 elec_single_pi0_angle[i][j]=new TH2F(tmp,tmp,100,-2,2,100,0,10);
00151                         
00152                 
00153                 sprintf(tmp,"elec_matched_elec_eres_%d_%d",i,j);
00154                 elec_matched_elec_eres[i][j]=new TH2F(tmp,tmp,100,-2,2,100,0,10);       
00155                 
00156                 sprintf(tmp,"elec_matched_pi0_eres_%d_%d",i,j);
00157                 elec_matched_pi0_eres[i][j]=new TH2F(tmp,tmp,100,-2,2,100,0,10);        
00158 
00159                 sprintf(tmp,"elec_matched_type_vs_recoE_%d_%d",i,j);
00160                 elec_matched_type_vs_recoE[i][j]=new TH2F(tmp,tmp,2300,0,2300,100,0,10);                                                
00161 
00162                 sprintf(tmp,"elec_matched_typefrac_vs_recoE_%d_%d",i,j);
00163                 elec_matched_typefrac_vs_recoE[i][j]=new TH2F(tmp,tmp,2300,0,2300,100,0,10);            
00164                         
00165         }
00166 }

int ParticleCheck::PassesPreselec (  ) 

Definition at line 190 of file ParticleCheck.cxx.

References PRecord::event, Event::inFiducial, Particles::largest_particle_avg_rms, Particles::longest_z, Event::min_z, Particles::mol_rad_r, Event::nstrips, Particles::ntot, PRecord::particles, prec, Particles::prim_par_b, Particles::primary_long_e, Particles::rms_r, Event::visenergy, and Event::vtx_z.

Referenced by Run().

00191 {
00192         int pass=1;
00193         
00194         pass = pass && prec->event.inFiducial==1;
00195         
00196         pass = pass && prec->event.nstrips>10 && prec->event.nstrips<50;
00197         
00198         pass = pass && prec->particles.ntot>0;
00199 
00200 
00201 
00202         pass = pass &&  prec->event.vtx_z-prec->event.min_z<0.35;
00203         pass = pass &&  prec->event.nstrips>15 && prec->event.nstrips<45;
00204         pass = pass &&  prec->particles.rms_r<1.1;
00205         pass = pass &&  prec->particles.prim_par_b>0.1&&prec->particles.prim_par_b<1.2;
00206         pass = pass &&  prec->particles.ntot/prec->event.visenergy<0.14;
00207         pass = pass &&  prec->particles.mol_rad_r<0.0425;
00208         pass = pass &&  prec->particles.largest_particle_avg_rms<0.017;
00209         pass = pass &&  prec->particles.largest_particle_avg_rms>0.005;
00210         pass = pass &&  prec->particles.ntot<8 ;
00211         pass = pass &&  prec->particles.longest_z<0.8;
00212         pass = pass &&  prec->particles.primary_long_e<60;
00213         
00214         
00215 
00216         
00217 /*      
00218         pass = pass && prec->particles.rough_primary_theta_z<0.7;
00219         pass = pass && prec->particles.primary_long_e<15;
00220         
00221         pass = pass && sqrt((prec->event.max_u-prec->event.min_u)*(prec->event.max_u-prec->event.min_u)
00222                         +(prec->event.max_v-prec->event.min_v)*(prec->event.max_v-prec->event.min_v))>0.3;
00223                         
00224         pass = pass && prec->particles.largest_particle_avg_rms>0.0045;
00225         pass = pass && prec->particles.largest_particle_e/prec->event.visenergy>0.85;
00226 
00227         pass = pass && prec->particles.total_long_e<25;
00228         pass = pass && prec->particles.mol_rad_r>0.001;
00229         pass = pass && prec->particles.mol_rad_r<0.035;
00230 
00231         pass = pass && prec->particles.nelec>0;
00232         pass = pass && prec->particles.ntot<4;
00233         pass = pass && prec->particles.prim_par_b>0.1;
00234         pass = pass && prec->particles.prim_par_b<1;
00235 
00236         pass = pass && prec->particles.longest_z<1;
00237         pass = pass && prec->particles.longest_z>0.1;
00238         pass = pass && prec->particles.longest_particle_type<14;
00239 */
00240         return pass;
00241 }

void ParticleCheck::Process ( int  cut,
int  type,
double  weight 
)

Definition at line 29 of file ParticleCheck.cxx.

References elec_matched_elec_eres, elec_matched_pi0_eres, elec_matched_type_vs_recoE, elec_matched_typefrac_vs_recoE, elec_single_match_angle, elec_single_match_eres, elec_single_pi0_angle, elec_single_pi0_eres, Particle3D::electron, NtpMCStdHep::IdHEP, NtpMCStdHep::mass, TruthCompare::matchangle, PRecord::mctrue, NtpMCStdHep::p4, ParticleObjectHolder::particles3d, Particle3D::particletype, poh, prec, TruthCompare::reco_matched, TruthCompare::reco_to_true_match, MCTrue::stdhep, Particle3D::sum_e, and PRecord::truthcompare.

Referenced by Run().

00030 {
00031 
00032         //do we have a single electron match?
00033         
00034         for(int i=0;i<(int)prec->truthcompare.reco_to_true_match.size();i++)
00035         {
00036                 std::vector<int> truematch=prec->truthcompare.reco_to_true_match[i];
00037                 Particle3D * p = &poh->particles3d[prec->truthcompare.reco_matched[i]];
00038 
00039                 if(truematch.size()==1)
00040                 {
00041                         //we have a single match...
00042                         //are both electons?
00043                         if(p->particletype!=Particle3D::electron)continue;
00044                         NtpMCStdHep *mc = &(prec->mctrue.stdhep[truematch[0]]); 
00045                         double trueE=sqrt(mc->p4[3]*mc->p4[3]-mc->mass*mc->mass);       
00046                 
00047                         if(TMath::Abs(mc->IdHEP)==11)
00048                         {
00049                                 elec_single_match_eres[cut][type]->Fill((p->sum_e/25.-trueE)/trueE,trueE,weight);
00050                                 elec_single_match_angle[cut][type]->Fill(prec->truthcompare.matchangle,trueE,weight);
00051                         }
00052 
00053                         if(TMath::Abs(mc->IdHEP)==111)
00054                         {
00055                                 elec_single_pi0_eres[cut][type]->Fill((p->sum_e/25.-trueE)/trueE,trueE,weight);
00056                                 elec_single_pi0_angle[cut][type]->Fill(prec->truthcompare.matchangle,trueE,weight);
00057                         }
00058                 }
00059                         
00060                 //here we can have multiple true matched particles
00061                 if(p->particletype==Particle3D::electron)
00062                 {
00063                         int le=-1;
00064                         double leE=0;
00065                         
00066                         int lp0=-1;
00067                         double lp0E=0;
00068                         
00069                         double trueEtotal=0;
00070                         for(int j=0;j<(int)truematch.size();j++)
00071                         {
00072                                 NtpMCStdHep *mc = &(prec->mctrue.stdhep[truematch[j]]);
00073                                 double trueE=sqrt(mc->p4[3]*mc->p4[3]-mc->mass*mc->mass);
00074                                 trueEtotal+=trueE;
00075                         }
00076                         
00077                         for(int j=0;j<(int)truematch.size();j++)
00078                         {
00079                                 NtpMCStdHep *mc = &(prec->mctrue.stdhep[truematch[j]]);
00080                                 double trueE=sqrt(mc->p4[3]*mc->p4[3]-mc->mass*mc->mass);
00081 
00082                                 elec_matched_type_vs_recoE[cut][type]->Fill(TMath::Abs(mc->IdHEP),p->sum_e/25.,weight);
00083                                 elec_matched_typefrac_vs_recoE[cut][type]->Fill(TMath::Abs(mc->IdHEP),trueE/trueEtotal,weight);
00084                                 
00085                                 if(TMath::Abs(mc->IdHEP)==11)
00086                                 {
00087                                         if(trueE>leE)
00088                                         {
00089                                                 leE=trueE;
00090                                                 le=j;
00091                                         }
00092                                 }
00093 
00094                                 if(TMath::Abs(mc->IdHEP)==111)
00095                                 {
00096                                         if(trueE>lp0E)
00097                                         {
00098                                                 lp0E=trueE;
00099                                                 lp0=j;
00100                                         }
00101                                 }
00102 
00103                         }
00104                         if(le>-1)
00105                         {
00106                                 NtpMCStdHep *mc = &(prec->mctrue.stdhep[truematch[le]]);
00107                                 double trueE=sqrt(mc->p4[3]*mc->p4[3]-mc->mass*mc->mass);
00108                                 elec_matched_elec_eres[cut][type]->Fill((p->sum_e/25.-trueE)/trueE,trueE,weight);
00109                         }else{
00110                                 elec_matched_elec_eres[cut][type]->Fill(0.,0.,weight);
00111                         }
00112                         
00113                         if(lp0>-1)
00114                         {
00115                                 NtpMCStdHep *mc = &(prec->mctrue.stdhep[truematch[lp0]]);
00116                                 double trueE=sqrt(mc->p4[3]*mc->p4[3]-mc->mass*mc->mass);
00117                                 elec_matched_pi0_eres[cut][type]->Fill((p->sum_e/25.-trueE)/trueE,trueE,weight);
00118                         }else{
00119                                 elec_matched_pi0_eres[cut][type]->Fill(0.,0.,weight);
00120                         }
00121                 
00122                 
00123                 
00124                         
00125                 }
00126                 
00127         }
00128 
00129 
00130 
00131 }

void ParticleCheck::Run (  ) 

Definition at line 243 of file ParticleCheck.cxx.

References MuELoss::a, TruthCompareAna::ana(), RecCandHeader::GetEvent(), RecRecordImp< T >::GetHeader(), RecDataHeader::GetRun(), RecPhysicsHeader::GetSnarl(), input, inputPA, MakeHistos(), ParticleObjectHolder::mctrue, PRecord::mctrue, nCut, MCTrue::oscprob, PassesPreselec(), poh, prec, Process(), SaveHistos(), TruthCompare::stage, MCTrue::totbeamweight, PRecord::truthcompare, and MCTrue::type.

00244 {
00245 
00246         MakeHistos();
00247 
00248 
00249 
00250         int ent =input->GetEntries();
00251         int entpa =inputPA->GetEntries();
00252         printf("%d %d total entries\n",ent,entpa);
00253         
00254         
00255         double typecnt[5];
00256         for(int i=0;i<5;i++)typecnt[i]=0;
00257         
00258         
00259         int saved=0;
00260         int ji=0;
00261         input->GetEntry(0);
00262         for(int i=0;i<entpa;i++)
00263         {
00264                 inputPA->GetEntry(i);
00265                 
00266                 while(poh->GetHeader().GetRun() != prec->GetHeader().GetRun() || poh->GetHeader().GetSnarl()!=prec->GetHeader().GetSnarl()  || poh->GetHeader().GetEvent()!=prec->GetHeader().GetEvent())
00267                         input->GetEntry(ji++);
00268                         
00269         //      MsgService * ms = MsgService::Instance();
00270         //      ms->GetStream("TruthCompareAna")->SetLogLevel(Msg::kDebug);
00271                 
00272                 if(prec->truthcompare.stage<2)
00273                 {
00274                         TruthCompareAna a;
00275                         a.ana(poh,&prec->truthcompare);
00276                 }
00277                 
00278                 
00279         
00280         
00281         
00282                 double weight = poh->mctrue.totbeamweight*poh->mctrue.oscprob*3.25/6.5/5;
00283                 double paweight = prec->mctrue.totbeamweight*prec->mctrue.oscprob*3.25/6.5/5;
00284                 
00285                 
00286                 
00287                 if(TMath::Abs(weight-paweight)>0.001)printf("weight mismatch!\n");
00288                 
00289                 int type=poh->mctrue.type;
00290         
00291                 if(type<0 || type>5)continue;
00292         
00293                 if(type==0)weight/=3.;
00294                 if(type==0)paweight/=3.;
00295         
00296 
00297                 for(int nn=0;nn<nCut;nn++)
00298                 {
00299                 
00300                         if(nn==1 && !PassesPreselec())continue;
00301                 
00302                         Process(nn,type,weight);        
00303                 }
00304                 
00305                 typecnt[type]+=weight;
00306 
00307 
00308 
00309                 if(i%10000==0)printf("Entry %d\n",i);
00310         }
00311 
00312         printf("used %d entries\n",saved);
00313 
00314         printf("values\n");
00315         for(int i=0;i<5;i++)
00316                 printf("%d   %2.2f\n",i,typecnt[i]);
00317         
00318         printf("FOM %2.2f\n",typecnt[1]/sqrt(typecnt[0]+typecnt[2]+typecnt[3]+typecnt[4]));
00319         
00320         SaveHistos();
00321 
00322 }

void ParticleCheck::SaveHistos (  ) 

Definition at line 170 of file ParticleCheck.cxx.

References elec_matched_elec_eres, elec_matched_pi0_eres, elec_matched_type_vs_recoE, elec_matched_typefrac_vs_recoE, elec_single_match_angle, elec_single_match_eres, elec_single_pi0_angle, elec_single_pi0_eres, nCut, and nType.

Referenced by Run().

00171 {
00172         TFile *f = TFile::Open("pcheck.root","RECREATE");
00173         f->cd();
00174         for(int i=0;i<nCut;i++)
00175         for(int j=0;j<nType;j++)
00176         {
00177                 elec_single_match_eres[i][j]->Write();
00178                 elec_single_match_angle[i][j]->Write();
00179                 elec_single_pi0_eres[i][j]->Write();
00180                 elec_single_pi0_angle[i][j]->Write();
00181                 elec_matched_elec_eres[i][j]->Write();
00182                 elec_matched_pi0_eres[i][j]->Write();
00183                 elec_matched_type_vs_recoE[i][j]->Write();
00184                 elec_matched_typefrac_vs_recoE[i][j]->Write();
00185         }
00186         f->Close();
00187 }


Member Data Documentation

Definition at line 38 of file ParticleCheck.h.

Referenced by MakeHistos(), Process(), and SaveHistos().

Definition at line 39 of file ParticleCheck.h.

Referenced by MakeHistos(), Process(), and SaveHistos().

Definition at line 41 of file ParticleCheck.h.

Referenced by MakeHistos(), Process(), and SaveHistos().

Definition at line 42 of file ParticleCheck.h.

Referenced by MakeHistos(), Process(), and SaveHistos().

Definition at line 33 of file ParticleCheck.h.

Referenced by MakeHistos(), Process(), and SaveHistos().

Definition at line 32 of file ParticleCheck.h.

Referenced by MakeHistos(), Process(), and SaveHistos().

Definition at line 36 of file ParticleCheck.h.

Referenced by MakeHistos(), Process(), and SaveHistos().

Definition at line 35 of file ParticleCheck.h.

Referenced by MakeHistos(), Process(), and SaveHistos().

Definition at line 22 of file ParticleCheck.h.

Referenced by ParticleCheck(), and Run().

Definition at line 25 of file ParticleCheck.h.

Referenced by ParticleCheck(), and Run().

Definition at line 23 of file ParticleCheck.h.

Referenced by ParticleCheck(), Process(), and Run().

Definition at line 26 of file ParticleCheck.h.

Referenced by ParticleCheck(), PassesPreselec(), Process(), and Run().


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1