Created
May 29, 2018 04:23
-
-
Save jdbrice/9c9d9ca5392ab4acba0ec03498fd3b07 to your computer and use it in GitHub Desktop.
Run13 TOF reso export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void print_tray( int tray ){ | |
cout << endl << tray << " 0" << endl; | |
} | |
void export_params(){ | |
TFile *f = new TFile( "hRes.root" ); | |
TH1 * h1 = (TH1*)f->Get( "hRes_1" ); | |
TH1 * h2 = (TH1*)f->Get( "hRes_2" ); | |
TH1F * hm = new TH1F( "hm", "", 1000, -1, 1 ); | |
vector<float> means; | |
for ( int i = 0; i < h1->GetXaxis()->GetNbins(); i++ ){ | |
float v = h1->GetBinContent( i+1 ); | |
if ( 0 == v ) | |
continue; | |
hm->Fill( v ); | |
} | |
hm->Draw(); | |
stdev = hm->GetStdDev()/2.0; | |
int iTray = 0; | |
string delim = ""; | |
for ( int i = 0; i < h2->GetXaxis()->GetNbins(); i++ ){ | |
if ( 0 == i % 192 ){ | |
if ( iTray >= 120 ) | |
break; | |
print_tray( iTray ); | |
iTray++; | |
delim = ""; | |
} | |
double v = h2->GetBinContent(i+1) - 0.004 + stdev; | |
if ( v < 0.01 || v > 0.15 ) | |
v = h2->GetBinContent((i%120)+1) - 0.004 + stdev; | |
cout << delim << (int)(v*1000); // subtract avg start side | |
delim = " "; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void make_res(){ | |
TChain *c = new TChain( "tof" ); | |
c->Add("4E5CCBAF2CE7730AD34F794AD547FBD1_*.ntuple.root"); | |
TFile * f = new TFile( "hRes.root", "RECREATE" ); | |
TH2 *hRes = new TH2F( "hRes", ";cell;delta tof (ns)", 24000, 0, 24000, 100, -0.5, 0.5 ); | |
c->Draw("tofCorr - TMath::Sqrt( length*length / (898.755) * ( 1 + 0.135*0.135 / pow(pt * TMath::CosH(eta), 2) ) ) : ((tray-1) * 192) + (module-1) * 6 + (cell-1) >>hRes", "", "colz"); | |
// hRes = (TH2*)gDirectory->Get( "hRes" ); | |
hRes->Draw("colz"); | |
TF1 * fg = new TF1( "fg", "gaus" ); | |
fg->SetRange( -0.2, 0.2 ); | |
hRes->FitSlicesY( fg ); | |
f->Write(); | |
f->Close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment