#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" void tpol(){ c1 = new TCanvas("c1","c1",100,100,800,800); c1->Divide(4,4); TProfile *fadc_raw[16]; for(Int_t channel = 0; channel < 16; channel++){ char title[30]; sprintf(title,"ch%d",channel); fadc_raw[channel] = new TProfile(title,title,100,-0.5,99.5,-10.,4096); fadc_raw[channel]->SetMinimum(50); fadc_raw[channel]->SetMaximum(4095); } TFile *f1 = new TFile ("calib_3452.root"); 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 i = 0; i < nevent; i++){ cout << "------------- NEW EVENT ------------- " << endl; 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){ 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]; if(slot != 14) continue; for (Int_t sample = 0; sample < nsamp[hit]; sample++){ if(channel == 14) cout << crate << " Slot = " << slot << " Channel " << channel << " Sample = " << sample << " " << samp[hit][sample] << endl; fadc_raw[channel]->Fill(float(sample),float(samp[hit][sample])); } } } for(Int_t ch = 0; ch < 16; ch++){ c1->cd(ch + 1); fadc_raw[ch]->Draw(); } c1->Update(); gPad->Modified(); getchar(); for(Int_t ch = 0; ch < 16; ch++){ fadc_raw[ch]->Reset(); } c1->Update(); } }