{ Int_t runno=299; Int_t maxevents=100; char string[256]; // sprintf(string,"%s%d%s","fcal_",runno,".root"); sprintf(string,"%s%d%s","simple_",runno,".root"); printf ("Filename = %s\n",string); // TFile f1("fcal_395.root"); TFile *f1 = new TFile(string); TTree *t1= (TTree*)f1->Get("tree1"); Int_t nevent = t1->GetEntries(); cout << "Events on file=" << nevent << endl; if (maxevents > nevent) maxevents = nevent; cout << "Events to process=" << maxevents << endl; const int window_size = 100; Float_t x_min = 0.5; Float_t x_max = window_size + 0.5; TBranch *br_fadc_raw=t1->GetBranch("fadc_raw"); Int_t fadc_raw[2][16][window_size]; br_fadc_raw->SetAddress(&fadc_raw); #if 1 Int_t trig_ch = 3; Float_t tdc_res = 0.58; Int_t trig_time; TBranch *br_nhit_tdc = t1->GetBranch("nhit_tdc"); TBranch *br_tdc_ch = t1->GetBranch("tdc_ch"); TBranch *br_tdc_time = t1->GetBranch("tdc_time"); Int_t nhit_tdc; Int_t tdc_ch[64]; Int_t tdc_time[64]; br_nhit_tdc->SetAddress(&nhit_tdc); br_tdc_ch->SetAddress(&tdc_ch); br_tdc_time->SetAddress(&tdc_time); TH1F *htdc_mult = new TH1F("TDC mult","TDC mult",32,-0.5,31.5); TH1F *htdc_dt[32]; for(Int_t ch = 0; ch < 32; ch++){ char title[50]; // sprintf(title,"Ttrig - Tsig ch%d",ch); // htdc_dt[ch] = new TH1F(title,title,2000,-100.,100.); sprintf(title," ch%d",ch); htdc_dt[ch] = new TH1F(title,title,2000,0.,4000.); } #endif gStyle->SetOptStat(0); gStyle->SetTitleFontSize(0.08); TProfile *hfadc_raw[2][16]; for(Int_t bd = 0; bd < 2; bd++){ for(Int_t ch = 0; ch < 16; ch++){ char title[30]; sprintf(title,"fadc_raw%d_ch%d",bd,ch); hfadc_raw[bd][ch] = new TProfile(title,title,window_size,x_min,x_max,-10.,9000.); } } TCanvas *c1 = new TCanvas("FADC SLOT 14","FADC SLOT 14",820.,820.); c1->Divide(4,4); TCanvas *c2 = new TCanvas("FADC SLOT 15","FADC SLOT 15",820.,820.); c2->Divide(4,4); TCanvas *c3 = new TCanvas("TDC hit multiplicity","TDC hit multiplicity",300.,300.); // TCanvas *c4 = new TCanvas("TDC T_trig - T_hit (ch 0-15) ","TDC T_trig - T_hit (ch 0-15)",500.,500.); TCanvas *c4 = new TCanvas("TDC T_hit (ch 0-11) ","TDC T_hit (ch 0-11)",650.,650.); c4->Divide(4,3); // TCanvas *c5 = new TCanvas("TDC T_trig - T_hit (ch 16-31) ","TDC T_trig - T_hit (ch 16-31)",500.,500.); TCanvas *c5 = new TCanvas("TDC T_hit (ch 16-27) ","TDC T_hit (ch 16-27)",650.,650.); c5->Divide(4,3); for(Int_t i = 0; i < maxevents; i++){ trig_time = 0.; br_fadc_raw->GetEntry(i); br_nhit_tdc->GetEntry(i); br_tdc_ch->GetEntry(i); br_tdc_time->GetEntry(i); for(Int_t bd = 0; bd < 2; bd++){ // cout << " Bd = " << bd << endl; for(Int_t ch = 0; ch < 16; ch++){ for(Int_t samp = 1; samp < window_size; samp++){ hfadc_raw[bd][ch]->Fill(float(samp),float(fadc_raw[bd][ch][samp]),1.); // cout << fadc_raw[0][0][samp] << " " << samp << endl; } } } if(nhit_tdc > 0){ for(Int_t n = 0; n < nhit_tdc; n++){ cout << tdc_time[n] << " " << tdc_ch[n] << endl; if(tdc_time[n] > 0){ htdc_mult->Fill(Float_t(tdc_ch[n])); htdc_dt[tdc_ch[n]]->Fill(Float_t(tdc_time[n])*0.058); if(tdc_ch[n] == trig_ch) trig_time = tdc_time[n]; } } } #if 0 if(trig_time > 0){ for(Int_t n = 0; n < nhit_tdc; n++){ Float_t dt = Float_t(trig_time- tdc_time[n])*tdc_res; cout << dt << " " << tdc_ch[n] << endl; htdc_dt[tdc_ch[n]]->Fill(dt); } } #endif // TDC cout << " F1TDC nhits = " << nhit_tdc << endl; c1->cd(1); hfadc_raw[0][0]->Draw("histo"); c1->cd(2); hfadc_raw[0][1]->Draw("histo"); c1->cd(3); hfadc_raw[0][2]->Draw("histo"); c1->cd(4); hfadc_raw[0][3]->Draw("histo"); c1->cd(5); hfadc_raw[0][4]->Draw("histo"); c1->cd(6); hfadc_raw[0][5]->Draw("histo"); c1->cd(7); hfadc_raw[0][6]->Draw("histo"); c1->cd(8); hfadc_raw[0][7]->Draw("histo"); c1->cd(9); hfadc_raw[0][8]->Draw("histo"); c1->cd(10); hfadc_raw[0][9]->Draw("histo"); c1->cd(11); hfadc_raw[0][10]->Draw("histo"); c1->cd(12); hfadc_raw[0][11]->Draw("histo"); c1->cd(13); hfadc_raw[0][12]->Draw("histo"); c1->cd(14); hfadc_raw[0][13]->Draw("histo"); c1->cd(15); hfadc_raw[0][14]->Draw("histo"); c1->cd(16); hfadc_raw[0][15]->Draw("histo"); c1->Update(); #if 1 c2->cd(1); hfadc_raw[1][0]->Draw("histo"); c2->cd(2); hfadc_raw[1][1]->Draw("histo"); c2->cd(3); hfadc_raw[1][2]->Draw("histo"); c2->cd(4); hfadc_raw[1][3]->Draw("histo"); c2->cd(5); hfadc_raw[1][4]->Draw("histo"); c2->cd(6); hfadc_raw[1][5]->Draw("histo"); c2->cd(7); hfadc_raw[1][6]->Draw("histo"); c2->cd(8); hfadc_raw[1][7]->Draw("histo"); c2->cd(9); hfadc_raw[1][8]->Draw("histo"); c2->cd(10); hfadc_raw[1][9]->Draw("histo"); c2->cd(11); hfadc_raw[1][10]->Draw("histo"); c2->cd(12); hfadc_raw[1][11]->Draw("histo"); c2->cd(13); hfadc_raw[1][12]->Draw("histo"); c2->cd(14); hfadc_raw[1][13]->Draw("histo"); c2->cd(15); hfadc_raw[1][14]->Draw("histo"); c2->cd(16); hfadc_raw[1][15]->Draw("histo"); c2->Update(); #endif c3->cd(); htdc_mult->Draw(); c3->Update(); for(Int_t ch = 0; ch < 12; ch++){ c4->cd(ch+1); htdc_dt[ch]->Draw("histo"); htdc_dt[ch]->GetXaxis()->SetTitleSize(0.06); htdc_dt[ch]->GetXaxis()->SetTitle("Time (ns)"); } c4->Update(); #if 1 for(Int_t ch = 16; ch < 28; ch++){ c5->cd(ch-15); htdc_dt[ch]->Draw("histo"); htdc_dt[ch]->GetXaxis()->SetTitleSize(0.06); htdc_dt[ch]->GetXaxis()->SetTitle("Time (ns)"); } c5->Update(); if(i== 2 | i==20 | i==45){ sprintf(string,"%s%d%s%d%s","Run",runno,"_event",i,"_fadc_c1.png"); printf ("Print %s\n",string); c1->SaveAs(string); sprintf(string,"%s%d%s%d%s","Run",runno,"_event",i,"_fadc_c2.png"); printf ("Print %s\n",string); c2->SaveAs(string); // c1->SaveAs("bcal_cos_fadc1.png"); // c2->SaveAs("bcal_cos_fadc2.png"); // c4->SaveAs("bcal_cos_tdc1.png"); // c5->SaveAs("bcal_cos_tdc2.png"); } #endif cout << " Event number = " << i << endl; getchar(); for(Int_t bd = 0; bd < 2; bd++){ for(Int_t ch = 0; ch < 16; ch++){ hfadc_raw[bd][ch]->Reset(); } } for(Int_t ch = 0; ch < 32; ch++){ htdc_dt[ch]->Reset(); } htdc_mult->Reset(); } }