Changeset 867 for trunk/MagicSoft/Mars/mhist
- Timestamp:
- 07/13/01 18:13:06 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mhist
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.cc
r859 r867 26 26 #include "MHMcCollectionArea.h" 27 27 28 #include < MLog.h>29 #include <T H2.h>28 #include <TH2.h> 29 #include <TCanvas.h> 30 30 31 31 ClassImp(MHMcCollectionArea); … … 49 49 50 50 51 fHistAll = new TH2D(" collAreaAll", "all showers - Radius vs log(E) distribution",51 fHistAll = new TH2D("All Events", "All showers - Radius vs log(E) distribution", 52 52 50, 0., 5., 53 53 50, 0., 500.); 54 54 55 fHistSel = new TH2D("collAreaSel", "selected showers - Radius vs log(E) distribution", 55 fHistAll->SetXTitle("log(E/GeV)"); 56 fHistAll->SetYTitle("r/m"); 57 fHistAll->SetZTitle("N"); 58 59 fHistSel = new TH2D("Selected Events", "Selected showers - Radius vs log(E) distribution", 56 60 50, 0., 5., 57 61 50, 0., 500.); 58 62 59 fHistCol = new TH1D("collArea", "Collection Area", 63 fHistSel->SetXTitle("log(E/GeV)"); 64 fHistSel->SetYTitle("r/m"); 65 fHistSel->SetYTitle("N"); 66 67 fHistCol = new TH1D("Area", "Collection Area vs. log(E)", 60 68 50, 0., 5.); 69 70 fHistCol->SetXTitle("log(E/GeV)"); 71 fHistCol->SetYTitle("A/m^2"); 61 72 } 62 73 … … 78 89 } 79 90 80 void MHMcCollectionArea::DrawAll( )91 void MHMcCollectionArea::DrawAll(Option_t* option) 81 92 { 82 fHistAll->Draw(); 93 TCanvas *c=new TCanvas(fHistAll->GetName(), fHistAll->GetTitle()); 94 95 fHistSel->Draw(option); 96 97 c->Modified(); 98 c->Update(); 83 99 } 84 100 85 void MHMcCollectionArea::DrawSel( )101 void MHMcCollectionArea::DrawSel(Option_t* option) 86 102 { 87 fHistSel->Draw(); 103 TCanvas *c=new TCanvas(fHistSel->GetName(), fHistSel->GetTitle()); 104 105 fHistSel->Draw(option); 106 107 c->Modified(); 108 c->Update(); 88 109 } 89 110 90 111 void MHMcCollectionArea::Draw(Option_t* option) 91 112 { 113 TCanvas *c=new TCanvas(fHistCol->GetName(), fHistCol->GetTitle()); 114 92 115 fHistCol->Draw(option); 116 117 c->Modified(); 118 c->Update(); 93 119 } 94 120 -
trunk/MagicSoft/Mars/mhist/MHMcCollectionArea.h
r853 r867 21 21 { 22 22 private: 23 TH2D *fHistAll ; //! all simulated showers 24 TH2D *fHistSel ; //! the selected showers 25 TH1D *fHistCol ; // the collection area 23 TH2D *fHistAll; //! all simulated showers 24 TH2D *fHistSel; //! the selected showers 25 26 TH1D *fHistCol; // the collection area 26 27 27 28 public: 28 29 29 MHMcCollectionArea(const char *name=NULL, const char *title=NULL) 30 ~MHMcCollectionArea() 30 MHMcCollectionArea(const char *name=NULL, const char *title=NULL); 31 ~MHMcCollectionArea(); 31 32 32 void FillAll(Float_t log10E, Float_t radius) ; 33 void FillSel(Float_t log10E, Float_t radius) ; 34 void DrawAll() ; 35 void DrawSel() ; 36 void Draw(Option_t* option = "") ; 37 void CalcEfficiency() ; 33 void FillAll(Float_t log10E, Float_t radius); 34 void FillSel(Float_t log10E, Float_t radius); 35 36 void DrawAll(Option_t *option = ""); 37 void DrawSel(Option_t *option = ""); 38 void Draw (Option_t *option = ""); 39 40 void CalcEfficiency(); 38 41 39 42 ClassDef(MHMcCollectionArea, 1) // Data Container to calculate Collection Area -
trunk/MagicSoft/Mars/mhist/MHMcEnergies.cc
r861 r867 66 66 delete fHists; 67 67 } 68 68 69 // -------------------------------------------------------------------------- 69 70 // -
trunk/MagicSoft/Mars/mhist/MHMcEnergy.cc
r863 r867 51 51 52 52 if (idx>0) 53 sprintf(aux+10, ";%i", idx); 53 sprintf(aux+strlen(aux), ";%i", idx); 54 54 55 *fName = name ? name : aux; 55 *fTitle = title ? title : "Container for a MC energyhistogram" ;56 *fTitle = title ? title : "Container for an energy distribution histogram" ; 56 57 57 // - we initialize the histogram and the gaus function58 // - we initialize the histogram 58 59 // - we have to give diferent names for the diferent histograms because 59 60 // root don't allow us to have diferent histograms with the same name 60 61 61 strcpy(aux, "fLogEnergy"); 62 char text[256]; 63 sprintf(text, "Energy Distribution for trigger condition #%i", idx); 64 65 strcpy(aux, "log(E)"); 62 66 if (idx>0) 63 sprintf(aux+10, ";%i", idx); 64 fLogEner = new TF1(aux, "gaus", 1., 3.); 65 66 strcpy(aux, "hLogEnergy"); 67 if (idx>0) 68 sprintf(aux+10, ";%i", idx); 69 hLogEner = new TH1F(aux, "", 40, 0.5, 4.5); 70 hLogEner->SetXTitle("log(E) [GeV]"); 71 hLogEner->SetYTitle("dN/dE"); 67 sprintf(aux+strlen(aux), " #%i", idx); 68 fHist = new TH1F(aux, text, 40, 0.5, 4.5); 69 fHist->SetXTitle("log(E/GeV)"); 70 fHist->SetYTitle("dN/dE"); 72 71 } 73 72 … … 78 77 MHMcEnergy::~MHMcEnergy() 79 78 { 80 delete hLogEner; 81 delete fLogEner; 79 delete fHist; 82 80 } 83 81 … … 88 86 void MHMcEnergy::Fill(Float_t log10E, Float_t w) 89 87 { 90 hLogEner->Fill(log10E, w);88 fHist->Fill(log10E, w); 91 89 } 92 90 … … 101 99 // Q: quiet mode 102 100 // 103 hLogEner->Fit(fLogEner->GetName(), "Q0", "", xxmin, xxmax); 101 fHist->Fit("gaus", "Q0", "", xxmin, xxmax); 102 103 TF1 *result = fHist->GetFunction("gaus"); 104 105 fThreshold = CalcThreshold(result); 106 fThresholdErr = CalcThresholdErr(result); 107 fGaussPeak = CalcGaussPeak(result); 108 fGaussSigma = CalcGaussSigma(result); 104 109 } 105 110 … … 110 115 void MHMcEnergy::Draw(Option_t *option) 111 116 { 112 char text[50]; 113 sprintf(text, "Energy Threshold = %4.1f +- %4.1f GeV", 114 GetThreshold(), GetThresholdErr()); 117 char text[256]; 115 118 116 const Float_t min = hLogEner->GetMinimum();117 const Float_t max = hLogEner->GetMaximum();119 const Float_t min = fHist->GetMinimum(); 120 const Float_t max = fHist->GetMaximum(); 118 121 const Float_t sum = min+max; 119 122 120 TCanvas *c=new TCanvas( "Energy Distribution","Energy distribution for triggered events");123 TCanvas *c=new TCanvas(fHist->GetName(), fHist->GetTitle()); 121 124 122 hLogEner->Draw(option); 125 fHist->Draw(option); 126 127 sprintf(text, "Energy Threshold = %4.1f +- %4.1f GeV", 128 fThreshold, fThresholdErr); 123 129 124 130 TPaveLabel* label = new TPaveLabel(2.2, 0.75*sum, 4.4, 0.90*sum, text); 125 131 label->SetFillColor(10); 126 132 label->SetTextSize(0.3); 133 label->SetBit(kCanDelete); 127 134 label->Draw(); 128 135 … … 137 144 void MHMcEnergy::SetNumBins(Int_t nbins) 138 145 { 139 hLogEner->SetBins(nbins, 0.5, 4.5);146 fHist->SetBins(nbins, 0.5, 4.5); 140 147 } 141 148 // -------------------------------------------------------------------------- … … 145 152 void MHMcEnergy::Print(Option_t*) 146 153 { 147 cout << "Threshold: " << GetThreshold() << " +- " << GetThresholdErr()<< endl;154 cout << "Threshold: " << fThreshold << " +- " << fThresholdErr << endl; 148 155 } 149 156 … … 152 159 // Return the threshold 153 160 // 154 Float_t MHMcEnergy:: GetThreshold() const161 Float_t MHMcEnergy::CalcThreshold(TF1 *gauss) 155 162 { 156 const Float_t p1 = fLogEner->GetParameter(1);163 const Float_t p1 = gauss->GetParameter(1); 157 164 158 165 return pow(10, p1); … … 163 170 // Return the error of the threshold. 164 171 // 165 Float_t MHMcEnergy:: GetThresholdErr() const172 Float_t MHMcEnergy::CalcThresholdErr(TF1 *gauss) 166 173 { 167 174 const Float_t lg10 = log(10); 168 const Float_t p1 = fLogEner->GetParameter(1);169 const Float_t p1err = fLogEner->GetParError(1);175 const Float_t p1 = gauss->GetParameter(1); 176 const Float_t p1err = gauss->GetParError(1); 170 177 171 178 // The error has into accuont the error in the fit … … 177 184 // Return the peak of the fitted gaussan function. 178 185 // 179 Float_t MHMcEnergy:: GetGaussPeak() const186 Float_t MHMcEnergy::CalcGaussPeak(TF1 *gauss) 180 187 { 181 return fLogEner->GetParameter(1);188 return gauss->GetParameter(1); 182 189 } 183 190 … … 186 193 // Return the sigma of the fitted gaussan function. 187 194 // 188 Float_t MHMcEnergy:: GetGaussSigma() const195 Float_t MHMcEnergy::CalcGaussSigma(TF1 *gauss) 189 196 { 190 return fLogEner->GetParameter(2);197 return gauss->GetParameter(2); 191 198 } 192 199 -
trunk/MagicSoft/Mars/mhist/MHMcEnergy.h
r863 r867 16 16 private: 17 17 18 TH1F *hLogEner; // histogram with the logarith of the energy 19 TF1 *fLogEner; // gausian function to fit the histogram 18 TH1F *fHist; // histogram with the logarith of the energy 19 20 Float_t fThreshold; 21 Float_t fThresholdErr; 22 Float_t fGaussPeak; 23 Float_t fGaussSigma; 24 25 Float_t CalcThreshold(TF1 *gauss); 26 Float_t CalcThresholdErr(TF1 *gauss); 27 28 Float_t CalcGaussPeak(TF1 *gauss); 29 Float_t CalcGaussSigma(TF1 *gauss); 20 30 21 31 public: … … 24 34 ~MHMcEnergy(); 25 35 26 Float_t GetThreshold() const ;27 Float_t GetThresholdErr() const ;36 Float_t GetThreshold() const { return fThreshold; } 37 Float_t GetThresholdErr() const { return fThresholdErr; } 28 38 29 Float_t GetGaussPeak() const ;30 Float_t GetGaussSigma() const ;39 Float_t GetGaussPeak() const { return fGaussPeak; } 40 Float_t GetGaussSigma() const { return fGaussSigma; }; 31 41 32 42 void Fill(Float_t log10E, Float_t w);
Note:
See TracChangeset
for help on using the changeset viewer.