192 int nProfileBins = (
m_binnage[binnumber] ).size() - 1;
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;
210 TProfile *theMeanProfile =
new TProfile( name.c_str(), title.c_str(),
211 nProfileBins, xbins);
212 TProfile *theRMSProfile =
new TProfile( RMSname.c_str(), RMStitle.c_str(),
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();
229 int nbins =
swap->GetNbinsX();
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";
289 std::string legend = name;
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();
309 swap->SetMarkerStyle(marker);
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());
326 if(legend ==
"") legend =
swap->GetTitle();
332 (*canvasvector)[i2]->cd();
334 swap->UseCurrentStyle();
337 swap->SetMarkerStyle(marker);
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());
351 if(legend ==
"") legend =
swap->GetTitle();
void swap(DataVector< T > &a, DataVector< T > &b)
See DataVector<T, BASE>::swap().
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")