{ gROOT->Reset(); #include // MACRO to Calibrate TOT distribution using muons // Author; E.C.S // Date: Oct 28, 2002 TFile *n1 = new TFile("C:/GLAST/DATA/oneTower/muon_0.3_3.5_0_100_50_900_5000_ra.root"); TTree *t1 = (TTree*) n1->Get("Output"); Float_t xmaxe= 12.0; Float_t xmine= 0.0; Int_t xbine= 50; TH1F *h[12]; h[0] = new TH1F("0", "2X" ,xbine,xmine,xmaxe); h[1] = new TH1F("1", "2Y" ,xbine,xmine,xmaxe); h[2] = new TH1F("2", "1Y" ,xbine,xmine,xmaxe); h[3] = new TH1F("3", "1X" ,xbine,xmine,xmaxe); h[4] = new TH1F("4", "0X" ,xbine,xmine,xmaxe); h[5] = new TH1F("5", "0Y" ,xbine,xmine,xmaxe); h[6] = new TH1F("6", "2X" ,xbine,xmine,xmaxe); h[7] = new TH1F("7", "2Y" ,xbine,xmine,xmaxe); h[8] = new TH1F("8", "1Y" ,xbine,xmine,xmaxe); h[9] = new TH1F("9", "1X" ,xbine,xmine,xmaxe); h[10] = new TH1F("10", "0X" ,xbine,xmine,xmaxe); h[11] = new TH1F("11", "0Y" ,xbine,xmine,xmaxe); // Cuts // Select on axis (< 5 deg) one-track events TCut x2 = "totX1[2]>0&&totX1[2]<9000&&nTkrTracks==1&&(180./3.1415*acos((zDir*startDirZ+yDir*startDirY+xDir*startDirX)))<6"; TCut y2 = "totY1[2]>0&&totY1[2]<9000&&nTkrTracks==1&&(180./3.1415*acos((zDir*startDirZ+yDir*startDirY+xDir*startDirX)))<6"; TCut y1 = "totY1[1]>0&&totY1[1]<9000&&nTkrTracks==1&&(180./3.1415*acos((zDir*startDirZ+yDir*startDirY+xDir*startDirX)))<6"; TCut x1 = "totX1[1]>0&&totX1[1]<9000&&nTkrTracks==1&&(180./3.1415*acos((zDir*startDirZ+yDir*startDirY+xDir*startDirX)))<6"; TCut x0 = "totX1[0]>0&&totX1[0]<9000&&nTkrTracks==1&&(180./3.1415*acos((zDir*startDirZ+yDir*startDirY+xDir*startDirX)))<6"; TCut y0 = "totY1[0]>0&&totY1[0]<9000&&nTkrTracks==1&&(180./3.1415*acos((zDir*startDirZ+yDir*startDirY+xDir*startDirX)))<6"; // convert from counts to microseconds // 1 count = 1 ns // Note: the value above does not correspond the actual value and is to be used just as an illustration // 1000 ns = 1 us t1->Draw("(totX1[2]-totX0[2])/1000>>0",x2); t1->Draw("(totY1[2]-totY0[2])/1000>>1",y2); t1->Draw("(totY1[1]-totY0[1])/1000>>2",y1); t1->Draw("(totX1[1]-totX0[1])/1000>>3",x1); t1->Draw("(totX1[0]-totX0[0])/1000>>4",x0); t1->Draw("(totY1[0]-totY0[0])/1000>>5",y0); TCanvas *c1 = new TCanvas("c1","",0,10,1200,800); c1->SetFillColor(10); int i; /*set the number of pads*/ int nb_x = 3; int nb_y = 2; int index; index = nb_x * nb_y; //TCanvas * c1 = new TCanvas("c1","canvas"); c1->Divide(nb_x,nb_y); gStyle->SetOptFit(00100); gStyle->SetStatW(0.28); gStyle->SetStatH(0.10); gStyle->SetTitleH(0.20); // Fraction of title box hight gStyle->SetTitleW(0.28); // Fraction of title box width gStyle->SetTitleX(0.1); // X position of the title box from left gStyle->SetTitleY(1.0); // Y position of the title box from bottom /*draw stuff in different pads*/ for (i=1;i<=index;i++) { c1->cd(i); //AFTER cd, gPad points to the current pad h[i-1]->Draw(); gPad->SetLogx(0); gPad->GetFrame()->SetFillColor(10); gPad->SetLogy(0); // linear scale gPad->SetFillColor(10); gPad->Draw(); h[i-1]->SetFillColor(4); h[i-1]->SetLabelSize(0.05,"X"); h[i-1]->SetLabelSize(0.05,"Y"); h[i-1]->SetXTitle("TOT (us)"); h[i-1]->SetYTitle("Nevents"); h[i-1]->SetTitleSize(0.05,"X"); h[i-1]->SetTitleSize(0.05,"Y"); h[i-1]->SetTitleOffset(1.0,"X"); h[i-1]->SetTitleOffset(1.0,"Y"); h[i-1]->Draw(); h[i-1]->Fit("landau"); } ofstream out("c13em.txt"); out << "Layer " << "View " << "MPV " << "Sigma " << endl; TF1 *fun = h[0]->GetFunction("landau"); out << "2 " << "0 " << fun->GetParameter(1) << " " << fun->GetParameter(2) << endl; fun = h[1]->GetFunction("landau"); out << "2 " << "1 " << fun->GetParameter(1) << " " << fun->GetParameter(2) << endl; fun = h[2]->GetFunction("landau"); out << "1 " << "1 " << fun->GetParameter(1) << " " << fun->GetParameter(2) << endl; fun = h[1]->GetFunction("landau"); out << "1 " << "0 " << fun->GetParameter(1) << " " << fun->GetParameter(2) << endl; fun = h[1]->GetFunction("landau"); out << "0 " << "0 " << fun->GetParameter(1) << " " << fun->GetParameter(2) << endl; fun = h[1]->GetFunction("landau"); out << "0 " << "1 " << fun->GetParameter(1) << " " << fun->GetParameter(2) << endl; }