Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:18

0001 //////////////////////////////////////////////////////////
0002 // This class has been automatically generated on
0003 // Mon Aug  7 10:01:22 2006 by ROOT version 5.12/00
0004 // from TTree T1/GeometryTest Tree
0005 // found on file: matbdg_tree_TOB.root
0006 //////////////////////////////////////////////////////////
0007 
0008 #ifndef Density_h
0009 #define Density_h
0010 
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014 #include <TString.h>
0015 #include <TGaxis.h>
0016 
0017 #include <TTree.h>
0018 #include <iostream>
0019 #include <fstream>
0020 
0021 // histograms
0022 // Target
0023 TProfile* prof_density_vs_eta;
0024 //
0025 
0026 // logfile
0027 std::ofstream theLogFile;
0028 //
0029 
0030 // plot range
0031 double etaMin;
0032 double etaMax;
0033 //
0034 
0035 class Density {
0036 public :
0037   TTree          *fChain;   //!pointer to the analyzed TTree or TChain
0038   Int_t           fCurrent; //!current Tree number in a TChain
0039   
0040   // Declaration of leave types
0041   Float_t         ParticleEta;
0042   Int_t           Nsteps;
0043   Double_t        InitialX[8000];   //[Nsteps]
0044   Double_t        InitialY[8000];   //[Nsteps]
0045   Double_t        InitialZ[8000];   //[Nsteps]
0046   Double_t        FinalX[8000];   //[Nsteps]
0047   Double_t        FinalY[8000];   //[Nsteps]
0048   Double_t        FinalZ[8000];   //[Nsteps]
0049   Float_t         MaterialDensity[8000];   //[Nsteps]
0050   
0051   // List of branches
0052   TBranch        *b_ParticleEta;   //!
0053   TBranch        *b_Nsteps;   //!
0054   TBranch        *b_InitialX;   //!
0055   TBranch        *b_InitialY;   //!
0056   TBranch        *b_InitialZ;   //!
0057   TBranch        *b_FinalX;   //!
0058   TBranch        *b_FinalY;   //!
0059   TBranch        *b_FinalZ;   //!
0060   TBranch        *b_MaterialDensity;   //!
0061   
0062   Density(TString fileName);
0063   virtual ~Density();
0064   virtual Int_t    Cut(Long64_t entry);
0065   virtual Int_t    GetEntry(Long64_t entry);
0066   virtual Long64_t LoadTree(Long64_t entry);
0067   virtual void     Init(TTree *tree);
0068   virtual void     Loop();
0069   virtual Bool_t   Notify();
0070   virtual void     Show(Long64_t entry = -1);
0071 
0072   
0073 private:
0074   //
0075   virtual void helpfulCommands();
0076   //
0077   // directory to store images
0078   TString theDirName;
0079 };
0080 
0081 #endif
0082 
0083 #ifdef Density_cxx
0084 Density::Density(TString fileName)
0085 {
0086   // images directory
0087   theDirName = "Images";
0088   
0089   // files
0090   cout << "*** Open file... " << endl;
0091   cout << fileName << endl;
0092   cout << "***" << endl;
0093   cout << " Output Directory... " << endl;
0094   cout << theDirName << endl;
0095   cout << "***" << endl;
0096   //
0097   
0098   // open root files
0099   TFile* theDetectorFile = new TFile(fileName);
0100   //
0101   // get tree
0102   TTree* theTree = (TTree*)theDetectorFile->Get("T1");
0103   //
0104   Init(theTree);
0105   Book();
0106   //
0107   helpfulCommands();
0108   //
0109 }
0110 
0111 Density::~Density()
0112 {
0113   if (!fChain) return;
0114   delete fChain->GetCurrentFile();
0115 }
0116 
0117 Int_t Density::GetEntry(Long64_t entry)
0118 {
0119   // Read contents of entry.
0120   if (!fChain) return 0;
0121   return fChain->GetEntry(entry);
0122 }
0123 Long64_t Density::LoadTree(Long64_t entry)
0124 {
0125   // Set the environment to read one entry
0126   if (!fChain) return -5;
0127   Long64_t centry = fChain->LoadTree(entry);
0128   if (centry < 0) return centry;
0129   if (fChain->IsA() != TChain::Class()) return centry;
0130   TChain *chain = (TChain*)fChain;
0131   if (chain->GetTreeNumber() != fCurrent) {
0132     fCurrent = chain->GetTreeNumber();
0133     Notify();
0134   }
0135   return centry;
0136 }
0137 
0138 void Density::Init(TTree *tree)
0139 {
0140   // The Init() function is called when the selector needs to initialize
0141   // a new tree or chain. Typically here the branch addresses and branch
0142   // pointers of the tree will be set.
0143   // It is normaly not necessary to make changes to the generated
0144   // code, but the routine can be extended by the user if needed.
0145   // Init() will be called many times when running on PROOF
0146   // (once per file to be processed).
0147   
0148   // Set branch addresses and branch pointers
0149   if (!tree) return;
0150   fChain = tree;
0151   fCurrent = -1;
0152   fChain->SetMakeClass(1);
0153   
0154   fChain->SetBranchAddress("Particle Eta",    &ParticleEta, &b_ParticleEta);
0155   fChain->SetBranchAddress("Nsteps", &Nsteps, &b_Nsteps);
0156   fChain->SetBranchAddress("Initial X", InitialX, &b_InitialX);
0157   fChain->SetBranchAddress("Initial Y", InitialY, &b_InitialY);
0158   fChain->SetBranchAddress("Initial Z", InitialZ, &b_InitialZ);
0159   fChain->SetBranchAddress("Final X",   FinalX,   &b_FinalX);
0160   fChain->SetBranchAddress("Final Y",   FinalY,   &b_FinalY);
0161   fChain->SetBranchAddress("Final Z",   FinalZ,   &b_FinalZ);
0162   fChain->SetBranchAddress("Material Density",   MaterialDensity,   &b_MaterialDensity);
0163   Notify();
0164 }
0165 
0166 Bool_t Density::Notify()
0167 {
0168   // The Notify() function is called when a new file is opened. This
0169   // can be either for a new TTree in a TChain or when when a new TTree
0170   // is started when using PROOF. It is normaly not necessary to make changes
0171   // to the generated code, but the routine can be extended by the
0172   // user if needed. The return value is currently not used.
0173   
0174   return kTRUE;
0175 }
0176 
0177 void Density::Show(Long64_t entry)
0178 {
0179   // Print contents of entry.
0180   // If entry is not specified, print current entry
0181   if (!fChain) return;
0182   fChain->Show(entry);
0183 }
0184 Int_t Density::Cut(Long64_t entry)
0185 {
0186   // This function may be called from Loop.
0187   // returns  1 if entry is accepted.
0188   // returns -1 otherwise.
0189   return 1;
0190 }
0191 
0192 void Density::Book(){
0193   etaBin = 15;
0194   etaMin = 0.0;
0195   etaMax = 3.0;
0196   //
0197   prof_density_vs_eta = new TProfile("prof_density_vs_eta",
0198                      "Average Density vs Pseudorapidity;|#eta|;#bar{#rho} [g/cm^{3}]",
0199                      etaBin,etaMin,etaMax);
0200 }
0201 
0202 void Density::MakePlots(TString suffix);
0203 
0204 #endif // #ifdef Density_cxx