MadUserAnalysis Class Reference

#include <MadUserAnalysis.h>

Inheritance diagram for MadUserAnalysis:
MadAnalysis MadQuantities MadBase

List of all members.

Public Member Functions

 MadUserAnalysis (TChain *chainSR=0, TChain *chainMC=0, TChain *chainTH=0, TChain *chainEM=0)
 MadUserAnalysis (JobC *, string, int)
 ~MadUserAnalysis ()
void MakeMyFile (std::string)

Public Attributes

Double_t user_variable

Protected Member Functions

Bool_t PassTruthSignal (Int_t mcevent=0)
Bool_t PassAnalysisCuts (Int_t event=0)
Bool_t PassBasicCuts (Int_t event=0)
Float_t PID (Int_t event=0, Int_t method=0)
Float_t RecoAnalysisEnergy (Int_t event=0)
Float_t GetWeight (Int_t event=0)
Bool_t AddUserBranches (TTree *)
void CallUserFunctions (Int_t)

Detailed Description

Definition at line 7 of file MadUserAnalysis.h.


Constructor & Destructor Documentation

MadUserAnalysis::MadUserAnalysis ( TChain *  chainSR = 0,
TChain *  chainMC = 0,
TChain *  chainTH = 0,
TChain *  chainEM = 0 
)

Definition at line 9 of file MadUserAnalysis.cxx.

References MadBase::Clear(), MadBase::emrecord, MadBase::InitChain(), MadBase::isEM, MadBase::isMC, MadBase::isTH, MadBase::mcrecord, MadBase::Nentries, MadBase::record, MadBase::strecord, MadBase::threcord, user_variable, and MadBase::whichSource.

00011 {
00012 
00013   if(!chainSR) {
00014     record = 0;
00015     strecord = 0;
00016     emrecord = 0;
00017     mcrecord = 0;
00018     threcord = 0;
00019     Clear();
00020     whichSource = -1;
00021     isMC = true;
00022     isTH = true;
00023     isEM = true;
00024     Nentries = -1;
00025     return;
00026   }
00027   
00028   InitChain(chainSR,chainMC,chainTH,chainEM);
00029   whichSource = 0;
00030 
00031   user_variable = 0;
00032 
00033 }

MadUserAnalysis::MadUserAnalysis ( JobC j,
string  path,
int  entries 
)

Definition at line 36 of file MadUserAnalysis.cxx.

References MadBase::Clear(), MadBase::emrecord, MadBase::fJC, MadBase::isEM, MadBase::isMC, MadBase::isTH, MadBase::jcPath, MadBase::mcrecord, MadBase::Nentries, MadBase::record, MadBase::strecord, MadBase::threcord, user_variable, and MadBase::whichSource.

00037 {
00038   record = 0;
00039   strecord = 0;
00040   emrecord = 0;
00041   mcrecord = 0;
00042   threcord = 0;
00043   Clear();
00044   isMC = true;
00045   isTH = true;
00046   isEM = true;
00047   Nentries = entries;
00048   whichSource = 1;
00049   jcPath = path;
00050   fJC = j;
00051 
00052   user_variable = 0;
00053 
00054 }

MadUserAnalysis::~MadUserAnalysis (  ) 

Definition at line 57 of file MadUserAnalysis.cxx.

00058 {
00059 
00060 }


Member Function Documentation

Bool_t MadUserAnalysis::AddUserBranches ( TTree *  tree  )  [protected, virtual]

Reimplemented from MadAnalysis.

Definition at line 119 of file MadUserAnalysis.cxx.

References user_variable.

00120 {
00121   if(!tree) return false;
00122   tree->Branch("user_variable",&user_variable,"user_variable/D",32000);
00123   return true;
00124 }

void MadUserAnalysis::CallUserFunctions ( Int_t  event  )  [protected, virtual]

Reimplemented from MadAnalysis.

Definition at line 127 of file MadUserAnalysis.cxx.

References MadBase::LoadEvent(), and user_variable.

00128 {
00129   user_variable = 0;
00130 
00131   if(!LoadEvent(event)) return;
00132   user_variable = 0.5;
00133 
00134 }

Float_t MadUserAnalysis::GetWeight ( Int_t  event = 0  )  [protected, virtual]

Reimplemented from MadAnalysis.

Definition at line 112 of file MadUserAnalysis.cxx.

00113 {  
00114   if(event>=0) return 1.0;
00115   return 0;
00116 }

void MadUserAnalysis::MakeMyFile ( std::string  tag  ) 

Definition at line 137 of file MadUserAnalysis.cxx.

References MadBase::eventSummary, MadBase::GetEntry(), MadBase::LoadEvent(), MadBase::LoadTruthForRecoTH(), MadBase::Nentries, NtpSREventSummary::nevent, and PassTruthSignal().

00137                                              {
00138 
00139   std::string savename = "QEHistos_" + tag + ".root";
00140   TFile save(savename.c_str(),"RECREATE"); 
00141   save.cd();
00142   
00143   //#declare lots of histos:
00144   TH1F *NEvent_NC = new TH1F("NEvent_NC",
00145                               "Number of Reco'd Events - NC",
00146                               20,0,20);
00147   NEvent_NC->SetXTitle("Number of Events");
00148   TH1F *NEvent_CC = new TH1F("NEvent_CC",
00149                               "Number of Reco'd Events - CC",
00150                               20,0,20);
00151   NEvent_CC->SetXTitle("Number of Events");
00152 
00153   for(int i=0;i<Nentries;i++){
00154     
00155     if(i%1000==0) std::cout << float(i)*100./float(Nentries) 
00156                             << "% done" << std::endl;
00157 
00158     if(!this->GetEntry(i)) continue;
00159 
00160     //get which detector this snarl is from
00161     //int theDetector = ntpHeader->GetVldContext().GetDetector()-1;
00162 
00163     for(int j=0;j<eventSummary->nevent;j++){
00164       
00165       if(!LoadEvent(j)) continue;  //does event exist
00166 
00167       //if no good truth candidate, we loose event
00168       int mcevent = -1;
00169       if(LoadTruthForRecoTH(j,mcevent)){ 
00170       
00171         if(PassTruthSignal()) {
00172           NEvent_CC->Fill(eventSummary->nevent);
00173         }
00174         else {
00175           NEvent_NC->Fill(eventSummary->nevent);
00176         }
00177       }
00178     }
00179   }
00180   //#close file  
00181   save.Write();
00182   save.Close();
00183 }

Bool_t MadUserAnalysis::PassAnalysisCuts ( Int_t  event = 0  )  [protected, virtual]

Reimplemented from MadAnalysis.

Definition at line 71 of file MadUserAnalysis.cxx.

References MadBase::LoadEvent(), PassBasicCuts(), and PID().

00072 {
00073   if(!LoadEvent(event)) return false;
00074   if(PassBasicCuts(event)) {
00075     if(PID(event,0)>=1.) return true;
00076   }
00077   return false;
00078 }

Bool_t MadUserAnalysis::PassBasicCuts ( Int_t  event = 0  )  [protected, virtual]

Reimplemented from MadAnalysis.

Definition at line 81 of file MadUserAnalysis.cxx.

References MadBase::LoadEvent(), MadBase::LoadLargestTrackFromEvent(), and MadQuantities::RecoMuEnergy().

Referenced by PassAnalysisCuts().

00082 {
00083   //define my own analysis cuts
00084   if(!LoadEvent(event)) return false;
00085   Int_t track = -1;
00086   if(!LoadLargestTrackFromEvent(event,track)) return false;
00087   if(RecoMuEnergy(track)<100.) return true;
00088   return false;
00089 }

Bool_t MadUserAnalysis::PassTruthSignal ( Int_t  mcevent = 0  )  [protected, virtual]

Reimplemented from MadAnalysis.

Definition at line 63 of file MadUserAnalysis.cxx.

References NtpMCTruth::iaction, NtpMCTruth::inu, MadBase::LoadTruth(), and MadBase::ntpTruth.

Referenced by MakeMyFile().

00064 {
00065   if(!LoadTruth(mcevent)) return false;
00066   if(abs(ntpTruth->inu)==14&&ntpTruth->iaction==1) return true;
00067   return false;
00068 }

Float_t MadUserAnalysis::PID ( Int_t  event = 0,
Int_t  method = 0 
) [protected, virtual]

Reimplemented from MadAnalysis.

Definition at line 92 of file MadUserAnalysis.cxx.

References MadBase::LoadEvent().

Referenced by PassAnalysisCuts().

00092                                                     {
00093   if(!LoadEvent(event)) return 0;
00094   if(method==0) return 1.0;
00095   return 0;
00096 }

Float_t MadUserAnalysis::RecoAnalysisEnergy ( Int_t  event = 0  )  [protected, virtual]

Reimplemented from MadAnalysis.

Definition at line 99 of file MadUserAnalysis.cxx.

References MadBase::LoadEvent(), MadBase::LoadLargestTrackFromEvent(), MadQuantities::RecoMuEnergy(), and MadQuantities::RecoShwEnergy().

00099                                                       {
00100 
00101   if(!LoadEvent(event)) return 0;
00102   int largestTrack = -1;
00103   LoadLargestTrackFromEvent(event,largestTrack);
00104   float emu = RecoMuEnergy(0,largestTrack);
00105   float ehad = RecoShwEnergy(event);
00106   float ereco = emu + ehad;  
00107   return ereco;
00108 
00109 }


Member Data Documentation

Definition at line 31 of file MadUserAnalysis.h.

Referenced by AddUserBranches(), CallUserFunctions(), and MadUserAnalysis().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1