#include #include #include #include #include "TTree.h" #include "TFile.h" #include "TRandom.h" #include "TTree.h" #include "TTree.h" #include "TH2.h" #include "TBrowser.h" #include "TROOT.h" #include "TFrame.h" #include "TGaxis.h" #include "TAxis.h" #include "TFile.h" #include "TTree.h" #include "TLegend.h" #include "TCanvas.h" #include #include "TLatex.h" #include #include using namespace std; //variables int MinRING = -2; int MaxRING = +2; unsigned int MinSECTOR=1; unsigned int MaxSECTOR=12; unsigned int link6 = 6; unsigned int link7 = 7; void drawplot() { TCanvas *c1 = new TCanvas("c1", "c1",200, 10, 1000, 1000); c1->SetBorderSize(4); gStyle->SetOptStat(11); c1->SetBottomMargin(0.1); c1->SetRightMargin(0.12); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(1); c1->SetFrameFillStyle(1); c1->SetFrameBorderMode(2); c1->SetGrid(1); // read the Tree generated by tree1w and fill two histograms // note that we use "new" to create the TFile and TTree objects, // to keep them alive after leaving this function. TFile *f = new TFile("test_Run302485_output.root"); TTree *t1 = (TTree*)f->Get("demo/hotp"); //Twin Mux Variables UInt_t tmnBcn; Float_t tmnVal[550] ; UInt_t tmlink[550]; //[count] UInt_t tmIndx[550]; //[count] Int_t tmwh[550]; //[count] UInt_t tmsec[550]; //[count] UInt_t evt; UInt_t tmnTP; TString Link120;// = new TString();; //Twin mux Branches TBranch *b_Evnt; //! TBranch *b_bcn; //! TBranch *b_Valid; //! TBranch *b_Indx; //! TBranch *b_Link; //! TBranch *b_Wheel; //! TBranch *b_Sector; //! TBranch *b_nTP; //! //TBranch *b_Link120 = t1->Branch("link120",&Link120,"Links in 120 Bins"); t1->SetBranchAddress("Evnt",&evt,&b_Evnt); t1->SetBranchAddress("bcn",&tmnBcn,&b_bcn); t1->SetBranchAddress("Valid",&tmnVal,&b_Valid); t1->SetBranchAddress("Indx", tmIndx, &b_Indx); t1->SetBranchAddress("Link", tmlink, &b_Link); t1->SetBranchAddress("Wheel", tmwh, &b_Wheel); t1->SetBranchAddress("Sector", tmsec, &b_Sector); t1->SetBranchAddress("nTP", &tmnTP, &b_nTP); //t1->SetBranchAddress("link120", &Link120, &b_Link120); // create two histograms for invalids TH1F *hval = new TH1F("hval","Valid distribution",100,-3,3); TH2F *hbcn_inv = new TH2F("hbcn_inv","bcn vs INvalid",10,0,120,3500,0,3500); TH2F *hsec_inv = new TH2F("hsec_inv","invalid sector no.",10,0,120,24,0,12); TH2F *hWhe_inv = new TH2F("hWhe_inv","invalid Wheel No.",10,0,120,30,-3,3); TH1F *hLink_inv = new TH1F("hLink_inv","invalid Link No.",30,5,8); TH1F *hLink120_inv = new TH1F("hLink120_inv","invalid Link120 No.",10,0,120); // create two histograms for valids //TH1F *hval = new TH1F("hval","Valid distribution",100,-3,3); TH2F *hbcn = new TH2F("hbcn","bcn vs valid",120,0,120,3500,0,3500); TH2F *hsec = new TH2F("hSsec","valid sector no.",120,0,120,24,0,12); TH2F *hWhe = new TH2F("hsec","valid Wheel No.",120,0,120,30,-3,3); TH1F *hLink = new TH1F("hLink","valid Link No.",30,5,8); TH1F *hLink120 = new TH1F("hLink120","valid Link120 No.",120,0,120); //read all entries and fill the histograms Int_t nentries = (Int_t)t1->GetEntries(); for (Int_t i=0; iGetEntry(i); hval->Fill(*tmnVal); for(unsigned int j =0; j< tmnTP; j++) { // Link120 = "L"+std::to_string(*tmlink)+"_S_"+std::to_string(*tmsec)+"_R_"+std::to_string(*tmwh); // cout << "Link by * " << Link120 << endl; Link120 = "L"+std::to_string(tmlink[j])+"_S_"+std::to_string(tmsec[j])+"_R_"+std::to_string(tmwh[j]); cout << "Link by j " << Link120 << endl; if(tmnTP < 1) continue; if(tmnVal[j] == 0 ){ hbcn_inv->Fill(Link120,tmnBcn,1); hsec_inv->Fill(Link120,tmsec[j],1); hWhe_inv->Fill(Link120,tmwh[j],1); hLink120_inv->Fill(Link120,1); } else { hbcn->Fill(Link120,tmnBcn,1); hsec->Fill(Link120,tmsec[j],1); hWhe->Fill(Link120,tmwh[j],1); hLink120->Fill(Link120,1); } } } //cout << hsec->GetXaxis()->GetNbins() << endl; // We do not close the file. We want to keep the generated // histograms we open a browser and the TreeViewer // if (gROOT->IsBatch()) return; // new TBrowser (); // t1->StartViewer(); c1->cd(); //h24->SetMarkerStyle(1); //h24->SetMarkerColor(kRed); //Fill Valids hbcn->Draw("COLZ"); c1->SaveAs("check_302485/BcnVsvalid_302485.png"); c1->Update(); hsec->Draw("COLZ"); c1->SaveAs("check_302485/Secvalid_302485.png"); c1->Update(); hWhe->Draw("COLZ"); c1->SaveAs("check_302485/Whevalid_302485.png"); c1->Update(); hLink->Draw(); c1->SaveAs("check_302485/linkvalid_302485.png"); c1->Update(); hLink120->Draw(); c1->SaveAs("check_302485/link120valid_302485.png"); //Fill Invalids hbcn_inv->Draw("COLZ"); c1->SaveAs("check_302485/BcnVsinvalid_302485.png"); c1->Update(); hsec_inv->Draw("COLZ"); c1->SaveAs("check_302485/Secinvalid_302485.png"); c1->Update(); hWhe_inv->Draw("COLZ"); c1->SaveAs("check_302485/Wheinvalid_302485.png"); c1->Update(); hLink_inv->Draw(); c1->SaveAs("check_302485/linkinvalid_302485.png"); c1->Update(); hLink120_inv->Draw(); c1->SaveAs("check_302485/link120invalid_302485.png"); //t1->Write(); }