File indexing completed on 2024-04-06 12:32:18
0001 #define Density_cxx
0002 #include "Density.h"
0003 #include <TH2.h>
0004 #include <TStyle.h>
0005 #include <TCanvas.h>
0006
0007 #include <cmath>
0008
0009
0010
0011
0012
0013 void Density::Loop()
0014 {
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038 if (fChain == 0) return;
0039
0040 Long64_t nentries = fChain->GetEntriesFast();
0041
0042 cout << " Entries " << nentries << endl;
0043
0044 Long64_t nbytes = 0, nb = 0;
0045 for (Long64_t jentry=0; jentry<nentries; jentry++) {
0046
0047 Long64_t ientry = LoadTree(jentry);
0048 if (ientry < 0) break;
0049 nb = fChain->GetEntry(jentry); nbytes += nb;
0050
0051
0052 double pathSum = 0.0;
0053 double normDensSum = 0.0;
0054
0055
0056
0057 for(Int_t iStep=0; iStep<Nsteps; iStep++) {
0058
0059
0060 double x_i = sqrt(
0061 (FinalX[iStep]-InitialX[iStep]) * (FinalX[iStep]-InitialX[iStep])
0062 +
0063 (FinalY[iStep]-InitialY[iStep]) * (FinalY[iStep]-InitialY[iStep])
0064 +
0065 (FinalZ[iStep]-InitialZ[iStep]) * (FinalZ[iStep]-InitialZ[iStep])
0066 );
0067
0068 double rho_i = MaterialDensity[iStep];
0069
0070
0071
0072
0073
0074
0075 pathSum += x_i;
0076 normDensSum += (rho_i * x_i);
0077
0078 }
0079
0080 if(Nsteps!=0) {
0081
0082 double averageDensity = normDensSum / pathSum;
0083
0084
0085
0086
0087
0088
0089
0090
0091 prof_density_vs_eta->Fill(fabs(ParticleEta),averageDensity);
0092
0093 }
0094
0095 }
0096
0097
0098 MakePlots("Gigi");
0099
0100
0101 }
0102
0103
0104 void Density::MakePlots(TString suffix) {
0105
0106 TGaxis::SetMaxDigits(3);
0107 gStyle->SetOptStat(0);
0108 gStyle->SetOptFit(0);
0109 gStyle->SetOptLogy(0);
0110
0111
0112
0113 TCanvas can_Gigi("can_Gigi","can_Gigi",1300,800);
0114
0115 can_Gigi.SetFillColor(kWhite);
0116
0117
0118
0119 can_Gigi.cd();
0120 prof_density_vs_eta->SetMarkerColor(kBlue);
0121 prof_density_vs_eta->SetMarkerStyle(20);
0122 prof_density_vs_eta->Draw("E1");
0123
0124
0125
0126 can_Gigi.Update();
0127 can_Gigi.SaveAs( Form("%s/AverageDensity_%s.eps", theDirName.Data(), suffix.Data() ) );
0128 can_Gigi.SaveAs( Form("%s/AverageDensity_%s.gif", theDirName.Data(), suffix.Data() ) );
0129
0130 }
0131
0132 void Density::helpfulCommands() {
0133 cout << "########################################" << endl;
0134 cout << "a.Loop()" << endl;
0135 cout << "########################################" << endl;
0136 }