#if 1 #include #include #include #include #include #include #include #include #include #include "RootHeader.h" #include "TTree.h" #include "TProfile.h" #include "TH1F.h" #include "TFile.h" #include "TPolyLine.h" #include "TImage.h" using namespace std; #endif void ps_check() { int c; gStyle->SetOptStat(0); gStyle->SetOptFit(0); TCanvas *cc[19]; Int_t y_pos = 0; for(Int_t can = 1; can < 10; can++){ char title[30]; sprintf(title,"can%d",can); y_pos = 0; Int_t x_pos = ((can - 1)%10)*200; cc[can] = new TCanvas(title,title,x_pos,y_pos,200,200); cc[can]->Divide(4,4); } for(Int_t can = 10; can < 19; can++){ char title[30]; sprintf(title,"can%d",can); y_pos = 250; Int_t x_pos = 1600. - (can - 10)*200; cc[can] = new TCanvas(title,title,x_pos,y_pos,200,200); cc[can]->Divide(4,4); } TCanvas *psc_right = new TCanvas(" PSC Right ", "PSC Right",0, 700, 1600,200); psc_right->Divide(8,1); TCanvas *psc_left = new TCanvas(" PSC Left ", "PSC Left ",0, 480, 1600,200); psc_left->Divide(8,1); TProfile *fadc_raw[12][21][16]; TH1F *hen = new TH1F("en","en",1000,-100,900); // TFile *f1=new TFile ("ps_calib_98.root","R"); // TFile *f1=new TFile ("ps_calib_141.root","R"); // TFile *f1=new TFile ("ps_calib_145.root","R"); // TFile *f1=new TFile ("ps_calib_147.root","R"); // No converter // TFile *f1=new TFile ("ps_calib_147.root","R"); TFile *f1=new TFile ("ps_calib_153.root","R"); // TFile *f1=new TFile ("ps_calib_159.root","R"); TTree *t1= (TTree*)f1->Get("tree1"); TBranch *br_nhit =t1->GetBranch("nhit"); TBranch *br_hcrate =t1->GetBranch("hcrate"); TBranch *br_hslot =t1->GetBranch("hslot"); TBranch *br_hch =t1->GetBranch("hch"); TBranch *br_nsamp =t1->GetBranch("nsamp"); TBranch *br_samp =t1->GetBranch("samp"); cout << "I am here " << endl; Int_t nhit; Int_t hcrate[1600], hslot[1600], hch[1600], nsamp[1600]; Int_t samp[1600][100]; br_nhit->SetAddress(&nhit); br_samp->SetAddress(&samp); br_hcrate->SetAddress(&hcrate); br_hslot->SetAddress(&hslot); br_hch->SetAddress(&hch); br_nsamp->SetAddress(&nsamp); br_samp->SetAddress(&samp); Int_t nevent = t1->GetEntries(); cout << " Number of events = " << nevent << endl; for(Int_t crate = 0; crate < 2; crate++){ for(Int_t slot = 0; slot < 21; slot++){ for(Int_t channel = 0; channel < 16; channel++){ char title[30]; sprintf(title,"raw_cr%d_sl%d_ch%d",crate,slot,channel); fadc_raw[crate][slot][channel] = new TProfile(title,title,100,-0.5,99.5,-10.,4096); fadc_raw[crate][slot][channel]->SetMinimum(50); fadc_raw[crate][slot][channel]->SetMaximum(800); if(crate == 1){ fadc_raw[crate][slot][channel]->SetMinimum(50); fadc_raw[crate][slot][channel]->SetMaximum(1000); } } } } for(Int_t i = 0; i < nevent; i++){ br_nhit->GetEntry(i); br_hcrate->GetEntry(i); br_hslot->GetEntry(i); br_hch->GetEntry(i); br_nsamp->GetEntry(i); br_samp->GetEntry(i); if(nhit == 0){ cout << " No hits found in the event" << endl; continue; } if(nhit > 0){ for(Int_t hit = 0; hit < nhit; hit++){ Int_t crate = -1; Int_t slot = -1; Int_t channel = -1; crate = hcrate[hit]; slot = hslot[hit]; channel = hch[hit]; Int_t sig_int = 0; Int_t base_int = 0; if(nsamp[hit] > 0){ // cout << " CRATE = " << crate << " SLOT = " << slot << " CHANNEL = " << channel << " NSAMP = " // << nsamp[hit] << " hit = " << hit << endl; // cout << " " << samp[hit][0] << " " << samp[hit][1] << " " << samp[hit][2] << " " << samp[hit][3] << endl; base_int = 0; for (Int_t sample = 0; sample < nsamp[hit]; sample++){ fadc_raw[crate][slot][channel]->Fill(float(sample),float(samp[hit][sample])); sig_int += samp[hit][sample]; if(sample > 5 && sample <= 15) base_int += samp[hit][sample]; } hen->Fill(float(sig_int)-200.*40); Float_t en = float(sig_int)-float(base_int)*13; } } } // Canvas 1: PS left cnt 2 - 16 for(Int_t ch = 0; ch < 16; ch++){ cc[1]->cd(ch + 1); fadc_raw[1][3][ch]->Draw(); } // Canvas 2: PS right cnt 2 - 16 for(Int_t ch = 0; ch < 16; ch++){ cc[18]->cd(ch + 1); fadc_raw[1][4][ch]->Draw(); } for(Int_t cr = 0; cr < 1; cr++){ for(Int_t slot = 3; slot < 21; slot++){ for(Int_t ch = 0; ch < 16; ch++){ Int_t can; if(slot < 11) can = slot - 3; else if(slot > 12) can = slot - 5; cc[can + 2]->cd(ch + 1); fadc_raw[cr][slot][ch]->Draw(); } } } for(Int_t ch = 0; ch < 8; ch++){ psc_left->cd(8 - ch); fadc_raw[1][6][ch]->Draw(); } for(Int_t ch = 8; ch < 16; ch++){ psc_right->cd(ch - 8 + 1); fadc_raw[1][6][ch]->Draw(); } for(Int_t can = 1; can < 19; can++){ cc[can]->Update(); } psc_left->Update(); psc_right->Update(); cout << " Read Event " << i + 1 << endl; c = getchar(); if(c == 'E'){ cout << " I am here " << endl; return; } for(Int_t cr = 0; cr < 2; cr++){ for(Int_t bd = 0; bd < 21; bd++){ for(Int_t ch = 0; ch < 16; ch++){ fadc_raw[cr][bd][ch]->Reset(); } } } } return; }