File indexing completed on 2023-03-17 11:27:28
0001
0002
0003
0004
0005
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
0022
0023 TProfile* prof_density_vs_eta;
0024
0025
0026
0027 std::ofstream theLogFile;
0028
0029
0030
0031 double etaMin;
0032 double etaMax;
0033
0034
0035 class Density {
0036 public :
0037 TTree *fChain;
0038 Int_t fCurrent;
0039
0040
0041 Float_t ParticleEta;
0042 Int_t Nsteps;
0043 Double_t InitialX[8000];
0044 Double_t InitialY[8000];
0045 Double_t InitialZ[8000];
0046 Double_t FinalX[8000];
0047 Double_t FinalY[8000];
0048 Double_t FinalZ[8000];
0049 Float_t MaterialDensity[8000];
0050
0051
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
0078 TString theDirName;
0079 };
0080
0081 #endif
0082
0083 #ifdef Density_cxx
0084 Density::Density(TString fileName)
0085 {
0086
0087 theDirName = "Images";
0088
0089
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
0099 TFile* theDetectorFile = new TFile(fileName);
0100
0101
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
0120 if (!fChain) return 0;
0121 return fChain->GetEntry(entry);
0122 }
0123 Long64_t Density::LoadTree(Long64_t entry)
0124 {
0125
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
0141
0142
0143
0144
0145
0146
0147
0148
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
0169
0170
0171
0172
0173
0174 return kTRUE;
0175 }
0176
0177 void Density::Show(Long64_t entry)
0178 {
0179
0180
0181 if (!fChain) return;
0182 fChain->Show(entry);
0183 }
0184 Int_t Density::Cut(Long64_t entry)
0185 {
0186
0187
0188
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