#include #include #include #include #include #include #include #include #include using namespace std; //------------------------------------ // Copied from JEventProcessor_bcal_timing.cc typedef struct{ int event; int layer; int sector; int fADC_up; int fADC_dn; float Etot; float geometric_mean; float tup; float tdn; float tup_corrected; float tdn_corrected; }HIT_t; //------------------------------------ //----------------- // tavg_calibrate_tgraph //----------------- void tavg_calibrate_tgraph(void) { TFile *f = new TFile("hd_root.root"); f->cd(); TTree *tree = (TTree*)gROOT->FindObject("tree"); HIT_t hit; HIT_t *hitptr = &hit; TBranch *branch = tree->GetBranch("T"); branch->SetAddress(hitptr); vector tavgs[10+1]; vector geomns[10+1]; int Nentries = branch->GetEntries(); for(int i=1; i<=Nentries; i++){ tree->GetEntry(i); if(hit.layer<1 || hit.layer>10)continue; // bulletproof if(hit.tup_corrected<-100)continue; if(hit.tdn_corrected<-100)continue; float tavg = (hit.tup_corrected + hit.tdn_corrected)/2.0; float geomn = hit.geometric_mean; if(fabs(tavg)>15.0)continue; tavgs[hit.layer].push_back(tavg); geomns[hit.layer].push_back(geomn); } TCanvas *c1 = new TCanvas("c1"); c1->SetTicks(); c1->SetGrid(); TH2D *axes = new TH2D("axes","", 100, 0.0, 1750.0, 100, -15.0, 15.0); axes->SetStats(0); axes->SetXTitle("fADC"); axes->SetYTitle("t (ns)"); TF1 *fun = new TF1("fun", "[0]+log(x)*([1]+log(x)*([2]+log(x)*([3]+log(x)*([4]+log(x)*([5]+log(x)*[6])))))", 0.0, 3500.0); double parms[10+1][7]; // Open PDF file for plots c1->Print("tavg_tgraph.ps["); // Loop over layers int Nlayers=0; for(int ilayer=1; ilayer<=10 ; ilayer++, Nlayers++){ TGraph *g = new TGraph(tavgs[ilayer].size(), &geomns[ilayer][0], &tavgs[ilayer][0]); char title[256]; sprintf(title, "#Deltat for layer %d", ilayer); axes->SetTitle(title); fun->SetLineColor(kRed); fun->SetParameter(0, 0.0); fun->SetParameter(1, 0.0); fun->SetParameter(2, 0.0); fun->SetParameter(3, 0.0); fun->SetParameter(4, 0.0); fun->SetParameter(5, 0.0); fun->SetParameter(6, 0.0); g->Fit("fun","","",30.0, 1750.0); axes->Draw(); g->Draw("Psame"); for(int ipar=0; ipar<=6; ipar++)parms[ilayer][ipar] = fun->GetParameter(ipar); cout<<"Number of points:"<GetN()<Update(); c1->Print("tavg_tgraph.ps"); } // Close PDF file c1->Print("tavg_tgraph.ps]"); // Write parameters out in form of C++ file const char *cppfname = "tavg_tgraph.cc"; ofstream pout(cppfname); pout<"<NLAYERS_BCAL ? NLAYERS_BCAL:layer;"<