//#define PRESENTATION //#define PULLS23 // only 3 params to show const int NStations = 2; //#define FILE_OUTPUT #include "TStyle.h" #include "TRandom.h" #include "TH1F.h" #include "TCanvas.h" #include #include #include #include "TF1.h" #include "TMath.h" using std::vector; Double_t distrib (Double_t *x, Double_t *par ) { // return exp(-x[0]/par); return 100*TMath::Exp(-x[0]/par[0]); } void SimulateTimeIntervals() { TStyle *plain = new TStyle("Plain","Plain Style(no colors/fill areas)"); //plain->SetCanvasBorderMode(0); //plain->SetPadBorderMode(0); plain->SetPadColor(0); plain->SetCanvasColor(0); plain->SetTitleColor(0); plain->SetStatColor(0); #ifdef PRESENTATION plain->SetOptStat(0); #else plain->SetOptStat(110010); #endif plain->SetOptFit(0011); plain->SetStatW(0.225); plain->SetStatH(0.06); //plain->SetStatX(0.7); plain->SetOptTitle(0); plain->SetFrameBorderMode(0); plain->SetPadLeftMargin(0.15); plain->SetPadRightMargin(0.05); plain->SetPadTopMargin(0.08); plain->SetPadBottomMargin(0.13); plain->cd(); const float InteractionRate[4] = {1.e4f, 1.e5f, 1.e6f, 1.e7f}; const int nEvents = 1.e7; double tau[4], fullDeltaT, percent,deltaT,deltaTF; TCanvas *c1; c1 = new TCanvas("EventTimeIntervals","EventTimeIntervals",0,0,1200,600); c1->Divide(2,2); TCanvas *c2; c2 = new TCanvas("TimeIntervals&PercentOfEvents","TimeIntervals&PercentOfEvents",0,0,1200,600); c2->Divide(2,2); TH1F *h[8]; float size[4]={1000000.f,100000.f,10000.f,1000.f}; for(int i=0; i<4; i++) { h[i]=new TH1F("histo","histo",size[i]/10, 0.f, size[i]); tau[i] = 1.e9f/InteractionRate[i]; for (int iEv = 1; iEv < nEvents; iEv++ ){ deltaT = gRandom->Exp(tau[i]); h[i]->Fill(deltaT); } c1->cd(i+1); h[i]->Draw(); c1->SaveAs("TrackPull.pdf"); } TF1 *f[4]; for(int i=4; i<8; i++) { h[i]=new TH1F("histo","histo",size[i-4]/10, 0.f, size[i-4]); TAxis* xax = h[i]->GetXaxis(); xax->SetTitle("Time interval between events, ns"); xax->SetTitleColor(kBlack); TAxis* yax = h[i]->GetYaxis(); yax->SetTitle("Events with larger time interval, %"); yax->SetTitleColor(kBlack); // h[i]->SetTitle("%d",size[i-4]); h[i]->SetBinContent(0, h[i-4]->GetBinContent(0)); for (int j=1; jSetBinContent(j, h[i]->GetBinContent(j-1) + h[i-4]->GetBinContent(j) ); for (int k=1; kSetBinContent(k, (1-h[i]->GetBinContent(k)/nEvents)*100); c2->cd(i-3); h[i]->SetLineWidth(4); h[i]->Draw(); tau[i-4] = 1.e9f/InteractionRate[i-4]; f[i-4]= new TF1("distrib",distrib,0,size[i-4],1); f[i-4]->SetParameters(&tau[i-4]); f[i-4]->SetLineColor(kRed); f[i-4]->SetLineWidth(2); f[i-4]->Draw("same"); // h[i]->GetXaxis()->SetTitle("XaxisTitle"); // gPad->Update(); c2->SaveAs("TrackPercent.pdf"); } // for(int i=0;i<4;i++) // { // for(int t=0; t