GnumiInterface Class Reference

#include <GnumiInterface.h>

List of all members.

Public Member Functions

 GnumiInterface ()
 ~GnumiInterface ()
Bool_t SetFileDir (std::string)
Bool_t Status () const
void GetParent (NtpMCRecord *, int, NuParent &)
void GetParent (NtpStRecord *, int, NuParent &)
void GetParent (Int_t, Int_t, Int_t, Int_t, NuParent &)
void FillANtpTruth (Int_t, Int_t, Int_t, Int_t, ANtpTruthInfoBeam &)
void FillANtpTruth (NtpMCRecord *, int, ANtpTruthInfoBeam &)
void FillANtpTruth (NtpStRecord *, int, ANtpTruthInfoBeam &)

Private Member Functions

Bool_t OpenFiles ()
void SetAddresses ()
void CloseFiles ()

Private Attributes

std::map< int, TFile * > fFile
std::map< int, TTree * > fTree
std::string fdir
Bool_t fok
Int_t fRunNum
Int_t fEvtNum
Float_t fX
Float_t fY
Float_t fZ
Float_t fPX
Float_t fPY
Float_t fPZ
Int_t fPID
Int_t fGen

Detailed Description

Definition at line 13 of file GnumiInterface.h.


Constructor & Destructor Documentation

GnumiInterface::GnumiInterface (  ) 

Definition at line 16 of file GnumiInterface.cxx.

References fdir, fok, OpenFiles(), and SetAddresses().

00017 {
00018   fok = false;
00019   char *dir = getenv("GNUMIAUX");
00020   if(dir!=NULL) fdir = dir;
00021   else fdir = ".";
00022   if(OpenFiles()) SetAddresses();
00023 }

GnumiInterface::~GnumiInterface (  ) 

Definition at line 26 of file GnumiInterface.cxx.

References CloseFiles().

00027 {
00028   CloseFiles();
00029 }


Member Function Documentation

void GnumiInterface::CloseFiles (  )  [private]

Definition at line 95 of file GnumiInterface.cxx.

References fFile, fok, and fTree.

Referenced by ~GnumiInterface().

00096 {
00097   fTree.clear();
00098   map<Int_t,TFile*>::iterator Beg = fFile.begin();
00099   map<Int_t,TFile*>::iterator End = fFile.end();
00100   while(Beg!=End){
00101     TFile *f = Beg->second;
00102     f->Close();
00103     delete f;
00104     fFile.erase(Beg->first);
00105     Beg++;
00106   }
00107   fok = false;
00108 }

void GnumiInterface::FillANtpTruth ( NtpStRecord rec,
int  mcevent,
ANtpTruthInfoBeam ntpBeam 
)

Definition at line 239 of file GnumiInterface.cxx.

References NuParent::GetGen(), GetParent(), NuParent::GetPID(), NuParent::GetPx(), NuParent::GetPy(), NuParent::GetPz(), NuParent::GetX(), NuParent::GetY(), NuParent::GetZ(), ANtpTruthInfoBeam::parentGen, ANtpTruthInfoBeam::parentPID, ANtpTruthInfoBeam::parentPX, ANtpTruthInfoBeam::parentPY, ANtpTruthInfoBeam::parentPZ, ANtpTruthInfoBeam::parentX, ANtpTruthInfoBeam::parentY, and ANtpTruthInfoBeam::parentZ.

00241 {
00242   NuParent parent;
00243   this->GetParent(rec,mcevent,parent);
00244   ntpBeam.parentX   = parent.GetX();
00245   ntpBeam.parentY   = parent.GetY();
00246   ntpBeam.parentZ   = parent.GetZ();
00247   ntpBeam.parentPX  = parent.GetPx();
00248   ntpBeam.parentPY  = parent.GetPy();
00249   ntpBeam.parentPZ  = parent.GetPz();
00250   ntpBeam.parentPID = parent.GetPID();
00251   ntpBeam.parentGen = parent.GetGen();
00252 }

void GnumiInterface::FillANtpTruth ( NtpMCRecord rec,
int  mcevent,
ANtpTruthInfoBeam ntpBeam 
)

Definition at line 223 of file GnumiInterface.cxx.

References NuParent::GetGen(), GetParent(), NuParent::GetPID(), NuParent::GetPx(), NuParent::GetPy(), NuParent::GetPz(), NuParent::GetX(), NuParent::GetY(), NuParent::GetZ(), ANtpTruthInfoBeam::parentGen, ANtpTruthInfoBeam::parentPID, ANtpTruthInfoBeam::parentPX, ANtpTruthInfoBeam::parentPY, ANtpTruthInfoBeam::parentPZ, ANtpTruthInfoBeam::parentX, ANtpTruthInfoBeam::parentY, and ANtpTruthInfoBeam::parentZ.

00225 {
00226   NuParent parent;
00227   this->GetParent(rec,mcevent,parent);
00228   ntpBeam.parentX   = parent.GetX();
00229   ntpBeam.parentY   = parent.GetY();
00230   ntpBeam.parentZ   = parent.GetZ();
00231   ntpBeam.parentPX  = parent.GetPx();
00232   ntpBeam.parentPY  = parent.GetPy();
00233   ntpBeam.parentPZ  = parent.GetPz();
00234   ntpBeam.parentPID = parent.GetPID();
00235   ntpBeam.parentGen = parent.GetGen();
00236 }

void GnumiInterface::FillANtpTruth ( Int_t  fileNum,
Int_t  entryNum,
Int_t  runNum,
Int_t  evtNum,
ANtpTruthInfoBeam ntpBeam 
)

Definition at line 204 of file GnumiInterface.cxx.

References NuParent::GetGen(), GetParent(), NuParent::GetPID(), NuParent::GetPx(), NuParent::GetPy(), NuParent::GetPz(), NuParent::GetX(), NuParent::GetY(), NuParent::GetZ(), ANtpTruthInfoBeam::parentGen, ANtpTruthInfoBeam::parentPID, ANtpTruthInfoBeam::parentPX, ANtpTruthInfoBeam::parentPY, ANtpTruthInfoBeam::parentPZ, ANtpTruthInfoBeam::parentX, ANtpTruthInfoBeam::parentY, and ANtpTruthInfoBeam::parentZ.

Referenced by MadAnalysis::CreateANtpPAN().

00209 {
00210   NuParent parent;
00211   this->GetParent(fileNum,entryNum,runNum,evtNum,parent);
00212   ntpBeam.parentX   = parent.GetX();
00213   ntpBeam.parentY   = parent.GetY();
00214   ntpBeam.parentZ   = parent.GetZ();
00215   ntpBeam.parentPX  = parent.GetPx();
00216   ntpBeam.parentPY  = parent.GetPy();
00217   ntpBeam.parentPZ  = parent.GetPz();
00218   ntpBeam.parentPID = parent.GetPID();
00219   ntpBeam.parentGen = parent.GetGen();
00220 }

void GnumiInterface::GetParent ( Int_t  fileNum,
Int_t  entryNum,
Int_t  runNum,
Int_t  evtNum,
NuParent par 
)

Definition at line 111 of file GnumiInterface.cxx.

References fEvtNum, fGen, fPID, fPX, fPY, fPZ, fRunNum, fTree, fX, fY, fZ, NuParent::SetGen(), NuParent::SetPID(), NuParent::SetPx(), NuParent::SetPy(), NuParent::SetPz(), NuParent::SetX(), NuParent::SetY(), NuParent::SetZ(), and NuParent::Zero().

00114 {
00115   par.Zero();
00116   //NOTES:
00117   //1) fileNum is the order that a shell would list the files:
00118   //i.e. 1,10,11,12,..19,2,20,3,4...
00119   //this code puts the files into a map using the
00120   //filename# (le_#.root) as the key - this is the same as 
00121   //the runNum so set fileNum = runNum to get the appropriate file
00122   fileNum = runNum;
00123 
00124   //2) There are entries in the stdhep array with 
00125   //runNum = 99, corresponding to flux file job9/le_9.root 
00126   //if fileNum is 99, change it to 9 in order to pick up the right file
00127   //(runNum is indeed 99 in le_9.root, so don't change that!) 
00128   if(fileNum==99) fileNum = 9;
00129 
00130   //3) entryNum is in fortran numbering i.e. 1,2,3....
00131   //subtract 1 to get to C numbering:
00132   entryNum -= 1;
00133 
00134   map<Int_t,TTree*>::iterator End = fTree.end();  
00135   map<Int_t,TTree*>::iterator Cur = fTree.find(fileNum);
00136   if(Cur==End) return;
00137   Cur->second->GetEntry(entryNum);
00138   if(fRunNum==runNum && fEvtNum==evtNum) {
00139     par.SetX(fX);
00140     par.SetY(fY);
00141     par.SetZ(fZ);
00142     par.SetPx(fPX);
00143     par.SetPy(fPY);
00144     par.SetPz(fPZ);
00145     par.SetPID(fPID);
00146     par.SetGen(fGen);
00147   }
00148   return;
00149 }

void GnumiInterface::GetParent ( NtpStRecord rec,
int  mcevent,
NuParent par 
)

Definition at line 178 of file GnumiInterface.cxx.

References GetParent(), NtpMCStdHep::IstHEP, NtpMCStdHep::mc, NtpMCStdHep::p4, and NtpStRecord::stdhep.

00180 {
00181 
00182   Int_t filenum = -1;
00183   Int_t entrynum = -1;
00184   Int_t runnum = -1;
00185   Int_t evtnum = -1;
00186 
00187   TClonesArray& heparray = *(rec->stdhep);
00188   Int_t nhep = heparray.GetEntries();  
00189   for(int i=0;i<nhep;i++){
00190     NtpMCStdHep *sh = static_cast<NtpMCStdHep *>(heparray[i]);
00191     if(sh->mc==mcevent){
00192       if(sh->IstHEP==999){ //beam file info
00193         runnum = Int_t(sh->p4[0]);
00194         evtnum = Int_t(sh->p4[1]);
00195         filenum = Int_t(sh->p4[2]);
00196         entrynum = Int_t(sh->p4[3]);
00197       }
00198     }
00199   }
00200   this->GetParent(filenum,entrynum,runnum,evtnum,par);
00201 }

void GnumiInterface::GetParent ( NtpMCRecord rec,
int  mcevent,
NuParent par 
)

Definition at line 152 of file GnumiInterface.cxx.

References NtpMCStdHep::IstHEP, NtpMCStdHep::mc, NtpMCStdHep::p4, and NtpMCRecord::stdhep.

Referenced by MadTestAnalysis::CreatePAN(), MadMKAnalysis::CreatePAN(), MadAnalysis::CreatePAN(), FillANtpTruth(), GetParent(), and MadEdAnalysis::MyCreatePAN().

00154 {
00155 
00156   Int_t filenum = -1;
00157   Int_t entrynum = -1;
00158   Int_t runnum = -1;
00159   Int_t evtnum = -1;
00160 
00161   TClonesArray& heparray = *(rec->stdhep);
00162   Int_t nhep = heparray.GetEntries();  
00163   for(int i=0;i<nhep;i++){
00164     NtpMCStdHep *sh = static_cast<NtpMCStdHep *>(heparray[i]);
00165     if(sh->mc==mcevent){
00166       if(sh->IstHEP==999){ //beam file info
00167         runnum = Int_t(sh->p4[0]);
00168         evtnum = Int_t(sh->p4[1]);
00169         filenum = Int_t(sh->p4[2]);
00170         entrynum = Int_t(sh->p4[3]);
00171       }
00172     }
00173   }
00174   this->GetParent(filenum,entrynum,runnum,evtnum,par);
00175 }

Bool_t GnumiInterface::OpenFiles (  )  [private]

Definition at line 43 of file GnumiInterface.cxx.

References fdir, fFile, fok, and fTree.

Referenced by GnumiInterface(), and SetFileDir().

00044 {
00045   map<Int_t,TFile*>::iterator End = fFile.end();
00046   for(int i=1;i<=20;i++){
00047     map<Int_t,TFile*>::iterator Cur = fFile.find(i);
00048     if(Cur!=End){
00049       TFile *f1 = Cur->second;
00050       f1->Close();     //close file 
00051       delete f1;       //delete TFile
00052       fFile.erase(Cur->first);  //erase file map entry
00053       fTree.erase(Cur->first);  //erase tree map entry
00054     }
00055     char name[256];
00056     sprintf(name,"%s/job%i/le_%i.root",fdir.c_str(),i,i);
00057     cout << name << endl;
00058     TFile *f = new TFile(name,"READ");
00059     if(f->IsOpen() && !f->IsZombie()){
00060       fFile[i] = f;
00061       TTree *tree = (TTree*) f->Get("h10");
00062       fTree[i] = tree;
00063     }
00064     else if(i==1) return false;
00065     else break;
00066   }
00067   fok = true;
00068   return true;
00069 }

void GnumiInterface::SetAddresses (  )  [private]

Definition at line 72 of file GnumiInterface.cxx.

References fEvtNum, fGen, fok, fPID, fPX, fPY, fPZ, fRunNum, fTree, fX, fY, and fZ.

Referenced by GnumiInterface(), and SetFileDir().

00073 {
00074   if(!fok) return;
00075   map<Int_t,TTree*>::iterator Beg = fTree.begin();
00076   map<Int_t,TTree*>::iterator End = fTree.end();
00077   while(Beg!=End){
00078     TTree *tree = Beg->second;
00079     tree->SetBranchAddress("run",&fRunNum);
00080     tree->SetBranchAddress("evtno",&fEvtNum);
00081     tree->SetBranchAddress("tvx",&fX);
00082     tree->SetBranchAddress("tvy",&fY);
00083     tree->SetBranchAddress("tvz",&fZ);
00084     tree->SetBranchAddress("tpx",&fPX);
00085     tree->SetBranchAddress("tpy",&fPY);
00086     tree->SetBranchAddress("tpz",&fPZ);
00087     tree->SetBranchAddress("tptype",&fPID);
00088     tree->SetBranchAddress("tgen",&fGen);
00089     Beg++;
00090   }
00091 
00092 }

Bool_t GnumiInterface::SetFileDir ( std::string  dir  ) 

Definition at line 32 of file GnumiInterface.cxx.

References fdir, OpenFiles(), and SetAddresses().

00033 {
00034   fdir = dir;
00035   if(OpenFiles()) {
00036     SetAddresses();
00037     return true;
00038   }
00039   return false;
00040 } 

Bool_t GnumiInterface::Status (  )  const [inline]

Member Data Documentation

std::string GnumiInterface::fdir [private]

Definition at line 20 of file GnumiInterface.h.

Referenced by GnumiInterface(), OpenFiles(), and SetFileDir().

Int_t GnumiInterface::fEvtNum [private]

Definition at line 28 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

std::map<int,TFile*> GnumiInterface::fFile [private]

Definition at line 18 of file GnumiInterface.h.

Referenced by CloseFiles(), and OpenFiles().

Int_t GnumiInterface::fGen [private]

Definition at line 36 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

Bool_t GnumiInterface::fok [private]

Definition at line 25 of file GnumiInterface.h.

Referenced by CloseFiles(), GnumiInterface(), OpenFiles(), SetAddresses(), and Status().

Int_t GnumiInterface::fPID [private]

Definition at line 35 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

Float_t GnumiInterface::fPX [private]

Definition at line 32 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

Float_t GnumiInterface::fPY [private]

Definition at line 33 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

Float_t GnumiInterface::fPZ [private]

Definition at line 34 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

Int_t GnumiInterface::fRunNum [private]

Definition at line 27 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

std::map<int,TTree*> GnumiInterface::fTree [private]

Definition at line 19 of file GnumiInterface.h.

Referenced by CloseFiles(), GetParent(), OpenFiles(), and SetAddresses().

Float_t GnumiInterface::fX [private]

Definition at line 29 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

Float_t GnumiInterface::fY [private]

Definition at line 30 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().

Float_t GnumiInterface::fZ [private]

Definition at line 31 of file GnumiInterface.h.

Referenced by GetParent(), and SetAddresses().


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

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1