5 #ifndef PixelResidualHistograms_C
6 #define PixelResidualHistograms_C
17 #include <TDirectory.h>
26 const std::string&
title,
29 const std::vector< std::vector < float > > &binnage,
30 const std::vector< std::string > &binnames):
31 m_HistogramsVector(0),
32 m_MeanProfilesVector(0),
33 m_RMSProfilesVector(0),
39 TH1D *Histomodel =
new TH1D(
name.c_str(),
title.c_str(),
nbins,-limits,limits);
90 int writtenhistos = 0;
97 if(
swap->Write() ) writtenhistos++;
99 if(
swap->Write() ) writtenhistos++;
103 if( swap2->Write() ) writtenhistos++;
108 return writtenhistos;
163 double limits =
swap->GetXaxis()->GetXmax();
169 nbins,-limits,limits);
193 float*
xbins =
new float[nProfileBins+1];
194 std::string Xvar_name =
m_binnames[binnumber];
195 std::string Xvar_name_s = Xvar_name;
196 size_t found0 = Xvar_name_s.find(
'#');
197 if(found0 != std::string::npos) Xvar_name_s.erase(Xvar_name_s.begin(), Xvar_name_s.begin()+found0+1);
198 size_t found1 = Xvar_name_s.find(
'_');
199 if(found1 != std::string::npos) Xvar_name_s.erase(Xvar_name_s.begin()+found1,Xvar_name_s.end());
200 for(
int i = 0 ;
i < nProfileBins+1 ;
i++)
204 std::string RMSname =
name + std::string(
"_RMS_vs_") + Xvar_name_s;
205 std::string RMStitle = std::string(
"Resolution of ") +
206 title + std::string(
" vs ") + Xvar_name;
207 name =
name + std::string(
"_Mean_vs_") + Xvar_name_s;
208 title = std::string(
"Mean of ") +
title + std::string(
" vs ") + Xvar_name;
211 nProfileBins,
xbins);
213 nProfileBins,
xbins);
215 theMeanProfile->GetXaxis()->SetTitle( Xvar_name.c_str() );
216 theRMSProfile->GetXaxis()->SetTitle( Xvar_name.c_str() );
217 theMeanProfile->GetYaxis()->SetTitle( (std::string(
"Mean of ") +
m_axisName).c_str() );
218 theRMSProfile->GetYaxis()->SetTitle( (std::string(
"RMS of ") +
m_axisName).c_str() );
221 std::vector<int> indexes;
222 for(
int ibin = 0; ibin < nProfileBins; ibin++){
225 std::ostringstream binname;
228 double limits =
swap->GetXaxis()->GetXmax();
230 TH1D *
bin =
new TH1D(binname.str().c_str(), bintitle.c_str(),
231 nbins,-limits,limits);
234 if(indexes[binnumber] == ibin){
242 double mean_error = 0.;
244 double rms_error = 0.;
246 if(
bin->GetEntries() > 50){
257 theMeanProfile->SetBinContent(ibin+1,
mean*
entries);
258 theMeanProfile->SetBinError(ibin+1,mean_error);
259 theMeanProfile->SetBinEntries(ibin+1,
entries);
260 theRMSProfile->SetBinContent(ibin+1,
rms*
entries);
261 theRMSProfile->SetBinError(ibin+1,rms_error);
262 theRMSProfile->SetBinEntries(ibin+1,
entries);
275 (*m_MeanProfilesVector)[binnumber] = theMeanProfile;
276 (*m_RMSProfilesVector)[binnumber] = theRMSProfile;
277 if(
RMS)
return theRMSProfile;
278 else return theMeanProfile;
285 std::vector <TCanvas*> *canvasvector,
const std::string&
name ){
288 std::string drawoptions =
"Psame";
290 if(canvasvector == 0){
292 canvasvector =
new std::vector<TCanvas*>();
294 TCanvas *
c1 =
new TCanvas();
295 c1->UseCurrentStyle();
296 canvasvector->push_back(
c1);
304 (*canvasvector)[
i]->cd();
306 swap->UseCurrentStyle();
310 swap->Draw(drawoptions.c_str());
311 swap->GetYaxis()->SetTitleOffset(1.2);
312 double maximum =
swap->GetMaximum();
313 double minimum =
swap->GetMinimum();
314 swap->SetMaximum(maximum + fabs(minimum) + fabs(maximum));
315 swap->SetMinimum(minimum - fabs(maximum) - fabs(minimum));
318 if(drawoptions ==
"P"){
319 size_t found = std::string(
swap->GetTitle()).find(
"p_{T}");
320 if(
found != std::string::npos) (*canvasvector)[
i]->SetLogx();
321 (*canvasvector)[
i]->SetGridy();
323 (*canvasvector)[
i]->SetName(
swap->GetName());
332 (*canvasvector)[i2]->cd();
334 swap->UseCurrentStyle();
338 swap->Draw(drawoptions.c_str());
339 swap->GetYaxis()->SetTitleOffset(1.2);
340 swap->SetMaximum(2*fabs(
swap->GetMaximum()));
343 if(drawoptions ==
"P"){
344 size_t found = std::string(
swap->GetTitle()).find(
"p_{T}");
345 if(
found != std::string::npos) (*canvasvector)[i2]->SetLogx();
346 (*canvasvector)[i2]->SetGridy();
348 (*canvasvector)[i2]->SetName(
swap->GetName());
497 #endif // #ifdef PixelResidualHistograms_C