MCMonitorBeamHistograms Class Reference

#include <MCMonitorBeamHistograms.h>

List of all members.

Public Types

enum  EShieldFlag { kAll, kNoShield, kShieldOnly }

Public Member Functions

 MCMonitorBeamHistograms (std::string name)
 ~MCMonitorBeamHistograms ()
int NumHistograms (const TFolder *folder=0) const
string GetName () const
void FillHistograms (const NtpStRecord *strec, const NtpMCRecord *mcrec)
void AllSumw2 (const TFolder *folder=0)
void SetCanRebin (const TFolder *folder=0)

Private Member Functions

void FillHistsTrue (std::string basepath, const NtpStRecord *strec, const NtpMCRecord *mcrec)
void FillTrueNumEvt (std::string truepath, int nmc)
void FillTrueNumStdHep (std::string truepath, int nstdhep, std::string clause="")
void FillHistsTrueStdHep (std::string stdheppath, const TClonesArray *stdheparray, std::string clause="", bool primaryonly=false, bool musthavehit=false)

Private Attributes

std::string fName
Detector::Detector_t fDetector
EShieldFlag fShieldFlag
Int_t fParticleId

Detailed Description

Definition at line 31 of file MCMonitorBeamHistograms.h.


Member Enumeration Documentation

Enumerator:
kAll 
kNoShield 
kShieldOnly 

Definition at line 36 of file MCMonitorBeamHistograms.h.

00036                    {
00037     // Used to determine if shield is included or not in plot quantities
00038     kAll,
00039     kNoShield,
00040     kShieldOnly
00041   };


Constructor & Destructor Documentation

MCMonitorBeamHistograms::MCMonitorBeamHistograms ( std::string  name  ) 

Definition at line 26 of file MCMonitorBeamHistograms.cxx.

00027 : fName(name),fDetector(Detector::kUnknown),fShieldFlag(kAll),fParticleId(0) {
00028   // Default constructor
00029 
00030 }

MCMonitorBeamHistograms::~MCMonitorBeamHistograms (  ) 

Definition at line 33 of file MCMonitorBeamHistograms.cxx.

00033                                                   {
00034   // Destructor
00035 
00036 }


Member Function Documentation

void MCMonitorBeamHistograms::AllSumw2 ( const TFolder *  folder = 0  ) 

Definition at line 247 of file MCMonitorBeamHistograms.cxx.

References fName, GetName(), and Lit::Print().

Referenced by MCMonitorBeam::EndJob().

00247                                                                 {
00248   // Default argument null => start at base folder
00249   // sets default Poisson errors on all histograms
00250   
00251   if ( !baseFolder ) {
00252     HistMan hm(fName.c_str());
00253     const TFolder* folder = dynamic_cast<TFolder*>
00254                             (hm.BaseFolder().FindObject(fName.c_str()));
00255     if ( folder ) return AllSumw2(folder);
00256   }
00257   else {
00258     cout << "In AllSumw2 for folder " << baseFolder -> GetName() << endl;
00259 
00260     TCollection* objlist = baseFolder -> GetListOfFolders();
00261     TIter nextobj(objlist);
00262     TObject* obj = 0;
00263     while ( ( obj = (TObject*)nextobj() ) ) {
00264       cout << "Printing object" << endl;
00265       obj -> Print();
00266       TFolder* folder = dynamic_cast<TFolder*>(obj);
00267       if ( folder ) this -> AllSumw2(folder);
00268       else {
00269         TH1* hist = dynamic_cast<TH1*>(obj);
00270         if ( hist ) {
00271           TProfile* prof = dynamic_cast<TProfile*>(obj);
00272           if (!prof) hist -> Sumw2();
00273         }
00274       }
00275     }
00276   }
00277   
00278   return;
00279    
00280 }

void MCMonitorBeamHistograms::FillHistograms ( const NtpStRecord strec,
const NtpMCRecord mcrec 
)

Definition at line 39 of file MCMonitorBeamHistograms.cxx.

References fDetector, FillHistsTrue(), fName, VldContext::GetDetector(), and RecRecordImp< T >::GetVldContext().

00040                                                                          {
00041   // Public method to fill all histograms. Histograms created on first call.
00042 
00043   if (!strec && !mcrec) return;
00044   
00045   // Set detector type
00046   const VldContext* vldc 
00047            = (strec)? strec->GetVldContext() : mcrec->GetVldContext();
00048   fDetector = vldc->GetDetector();
00049   
00050   std::string basepath = fName;
00051   FillHistsTrue(basepath,strec,mcrec);
00052 
00053 }

void MCMonitorBeamHistograms::FillHistsTrue ( std::string  basepath,
const NtpStRecord strec,
const NtpMCRecord mcrec 
) [private]

Definition at line 56 of file MCMonitorBeamHistograms.cxx.

References FillHistsTrueStdHep(), FillTrueNumEvt(), FillTrueNumStdHep(), fParticleId, NtpMCRecord::mchdr, NtpStRecord::mchdr, NtpMCSummary::nmc, NtpMCSummary::nstdhep, NtpStRecord::stdhep, and NtpMCRecord::stdhep.

Referenced by FillHistograms().

00058                                                                       {
00059   // Private method to fill all ../True/.. histograms
00060 
00061   if (!strec && !mcrec) return;
00062   
00063   std::string truepath = basepath + "/True";
00064   
00065   const NtpMCSummary& mchdr = (strec)? strec->mchdr : mcrec->mchdr;
00066   
00067   // mchdr
00068   FillTrueNumEvt(truepath,mchdr.nmc);
00069   FillTrueNumStdHep(truepath,mchdr.nstdhep);
00070 
00071   const TDatabasePDG& dbpdg = *(TDatabasePDG::Instance());
00072   const int npid = 12;
00073   // mu-,mu+,e-,e+,pi-,pi+,K-,K+,p,n,pi0,gamma
00074   int pidarray[npid] = {13,-13,11,-11,211,-211,321,-321,2212,2112,111,22}; 
00075   
00076   // stdhep
00077   const TClonesArray* stdheparray 
00078                        = (strec) ? strec->stdhep : mcrec->stdhep;
00079   if ( stdheparray ) {
00080     // Fill for each particle type of interest
00081     for ( int ipid = 0; ipid < npid; ipid++ ) {
00082       fParticleId = pidarray[ipid]; // particle type
00083       std::string partname = "???";
00084       if ( dbpdg.GetParticle(fParticleId) ) partname
00085                               = dbpdg.GetParticle(fParticleId)->GetName();
00086       std::string partpath = truepath + "/" + partname;
00087       std::string clause = " (" + partname + ")";
00088       FillHistsTrueStdHep(partpath,stdheparray,clause,false,false);
00089       std::string noprim_clause = clause + " (Primaries only) ";
00090       std::string noprim_partpath = truepath + "/Primaries/" + partname;
00091       FillHistsTrueStdHep(noprim_partpath,stdheparray,noprim_clause,
00092                           true,false);
00093       /*
00094       std::string onehit_clause = clause + " (At least one hit) ";
00095       std::string onehit_partpath = truepath + "/AtLeastOneHit/" + partname;
00096       FillHistsTrueStdHep(onehit_partpath,stdheparray,onehit_clause,false,
00097                           true);
00098       */
00099     }
00100         
00101   }
00102   
00103 }

void MCMonitorBeamHistograms::FillHistsTrueStdHep ( std::string  stdheppath,
const TClonesArray *  stdheparray,
std::string  clause = "",
bool  primaryonly = false,
bool  musthavehit = false 
) [private]

Definition at line 150 of file MCMonitorBeamHistograms.cxx.

References FillTrueNumStdHep(), fParticleId, NtpMCStdHep::IdHEP, and NtpMCStdHep::IstHEP.

Referenced by FillHistsTrue().

00153                                                                           {
00154   // Private method to fill all ../True/StdHep/.. histograms
00155   
00156   if ( !stdheparray ) return;
00157   std::string stdheppath = truepath + "/StdHep";
00158 
00159   HistMan hm(stdheppath.c_str());
00160   
00161   int nstdhep = 0;
00162   for ( int istd = 0; istd < stdheparray->GetEntriesFast(); istd++ ) {
00163     const NtpMCStdHep& stdhep 
00164              = *(dynamic_cast<NtpMCStdHep*>(stdheparray->At(istd)));
00165 
00166     // cout << stdhep.IdHEP << "/" << stdhep.ParticleName() << endl;
00167     if ( stdhep.IdHEP != fParticleId ) continue;
00168     if ( primaryonly && (stdhep.IstHEP >= 200) ) continue;
00169     // if ( musthavehit && (stdhep.ndethit <= 0 ) ) continue;
00170     
00171     nstdhep++;
00172 
00173   }
00174 
00175   FillTrueNumStdHep(stdheppath,nstdhep,clause);
00176   
00177   return;
00178   
00179 }

void MCMonitorBeamHistograms::FillTrueNumEvt ( std::string  truepath,
int  nmc 
) [private]

Definition at line 107 of file MCMonitorBeamHistograms.cxx.

Referenced by FillHistsTrue().

00108                                                         {
00109   // Private method to fill ../True/NumEvtPerSnarl 
00110   
00111   HistMan hm(truepath.c_str());
00112 
00113   TH1F* hist1 = hm.Get<TH1F>("NumEvtPerSnarl");
00114   if ( !hist1 ) {
00115     hist1 = new TH1F("NumEvtPerSnarl","True Num Evt/Snarl",60,0.,60.);
00116     hist1->SetXTitle("True Num Evt/Snarl");
00117     hist1->SetYTitle("Entries/1");
00118     hm.Adopt("",hist1);
00119   }
00120   
00121   hist1 -> Fill(nmc);
00122   
00123 }

void MCMonitorBeamHistograms::FillTrueNumStdHep ( std::string  truepath,
int  nstdhep,
std::string  clause = "" 
) [private]

Definition at line 126 of file MCMonitorBeamHistograms.cxx.

Referenced by FillHistsTrue(), and FillHistsTrueStdHep().

00127                                                                     {
00128   // Private method to fill ../True/NumStdHepPerSnarl 
00129   
00130   HistMan hm(truepath.c_str());
00131 
00132   TH1F* hist1 = hm.Get<TH1F>("NumStdHepPerSnarl");
00133   if ( !hist1 ) {
00134     if ( clause.empty() ) 
00135       hist1 = new TH1F("NumStdHepPerSnarl","Num StdHep/Snarl",50,0.,100.);
00136     else
00137       hist1 = new TH1F("NumStdHepPerSnarl","Num StdHep/Snarl",50,0.,50.);
00138     
00139     std::string xtitle = std::string("Num StdHep/Snarl") + clause;
00140     hist1->SetXTitle(xtitle.c_str());
00141     hist1->SetYTitle("Entries/2");
00142     hm.Adopt("",hist1);
00143   }
00144   
00145   hist1 -> Fill(nstdhep);
00146   
00147 }

string MCMonitorBeamHistograms::GetName ( void   )  const [inline]

Definition at line 48 of file MCMonitorBeamHistograms.h.

References fName.

Referenced by AllSumw2(), MCMonitorBeam::EndJob(), NumHistograms(), and SetCanRebin().

00048 { return fName; } // name for this collection

int MCMonitorBeamHistograms::NumHistograms ( const TFolder *  folder = 0  )  const

Definition at line 182 of file MCMonitorBeamHistograms.cxx.

References fName, GetName(), and Lit::Print().

Referenced by MCMonitorBeam::EndJob().

00182                                                                           {
00183   // Default argument null => start at base folder
00184   // number of histograms in the class
00185   
00186   int numHist = 0;
00187   
00188   if ( !baseFolder ) {
00189     HistMan hm(fName.c_str());
00190     const TFolder* folder = dynamic_cast<TFolder*>
00191                             (hm.BaseFolder().FindObject(fName.c_str()));
00192     if ( folder ) return NumHistograms(folder);
00193   }
00194   else {
00195     cout << "In NumHistograms for folder " << baseFolder -> GetName() << endl;
00196 
00197     TCollection* objlist = baseFolder -> GetListOfFolders();
00198     TIter nextobj(objlist);
00199     TObject* obj = 0;
00200     while ( ( obj = (TObject*)nextobj() ) ) {
00201       cout << "Printing object" << endl;
00202       obj -> Print();
00203       TFolder* folder = dynamic_cast<TFolder*>(obj);
00204       if ( folder ) numHist += this -> NumHistograms(folder);
00205       else numHist++;
00206     }
00207   }
00208   
00209   return numHist;
00210    
00211 }

void MCMonitorBeamHistograms::SetCanRebin ( const TFolder *  folder = 0  ) 

Definition at line 214 of file MCMonitorBeamHistograms.cxx.

References fName, GetName(), and Lit::Print().

Referenced by MCMonitorBeam::EndJob().

00214                                                                    {
00215   // Default argument null => start at base folder
00216   // Set all the histograms so they can be rebinned by the user by default
00217 
00218   if ( !baseFolder ) {
00219     HistMan hm(fName.c_str());
00220     const TFolder* folder = dynamic_cast<TFolder*>
00221                             (hm.BaseFolder().FindObject(fName.c_str()));
00222     if ( folder ) return SetCanRebin(folder);
00223   }
00224   else {
00225     cout << "In SetCanRebin for folder " << baseFolder -> GetName() << endl;
00226 
00227     TCollection* objlist = baseFolder -> GetListOfFolders();
00228     TIter nextobj(objlist);
00229     TObject* obj = 0;
00230     while ( ( obj = (TObject*)nextobj() ) ) {
00231       cout << "Printing object" << endl;
00232       obj -> Print();
00233       TFolder* folder = dynamic_cast<TFolder*>(obj);
00234       if ( folder ) this -> SetCanRebin(folder);
00235       else {
00236         TH1* hist = dynamic_cast<TH1*>(obj);
00237         hist -> SetBit(TH1::kCanRebin);
00238       }
00239     }
00240   }
00241   
00242   return;
00243    
00244 }


Member Data Documentation

Definition at line 74 of file MCMonitorBeamHistograms.h.

Referenced by FillHistograms().

std::string MCMonitorBeamHistograms::fName [private]

Definition at line 76 of file MCMonitorBeamHistograms.h.

Referenced by FillHistsTrue(), and FillHistsTrueStdHep().

Definition at line 75 of file MCMonitorBeamHistograms.h.


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

Generated on 22 Nov 2017 for loon by  doxygen 1.6.1