From f6175ead09198bda3c3ebb3a782bfbc15473d368 Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Mon, 29 Jan 2024 19:10:12 -0500 Subject: [PATCH] worked on the PreAnalysis and Analyzer --- Analyzer.C | 184 ++++++++++++++++++++++++++++++++++++++++---------- ClassDet.h | 2 + PreAnalysis.C | 78 +++++++++++++++------ 3 files changed, 208 insertions(+), 56 deletions(-) diff --git a/Analyzer.C b/Analyzer.C index 37718f1..3b47c05 100644 --- a/Analyzer.C +++ b/Analyzer.C @@ -3,65 +3,175 @@ #include "Analyzer.h" #include #include +#include +#include -TH2F * hsx3IDVch; -// TH2F * hqqqIDVch; -// TH2F * hpcIDVch; +TH2F * hsx3IndexVE; +TH2F * hqqqIndexVE; +TH2F * hpcIndexVE; +TH2F * hsx3Coin; +TH2F * hqqqCoin; +TH2F * hpcCoin; + +TH2F * hqqqPolar; TH2F * hsx3VpcIndex; -// TH2F * hsx3EVIndex; +int padID = 0; + void Analyzer::Begin(TTree * /*tree*/){ - TString option = GetOption(); + TString option = GetOption(); - hsx3IDVch = new TH2F("hsx3IDVch", "sx3 ID vs ch; ch ; ID", 24, 0, 24, 12, 0, 12); - // hqqqIDVch = new TH2F("hqqqIDVch", "qqq ID vs ch; ch ; ID", 4, 0, 4, 32, 0, 32); - // hpcIDVch = new TH2F("hpcIDVch", "pc ID vs ch; ch ; ID", 2, 0, 2, 24, 0, 24); + hsx3IndexVE = new TH2F("hsx3IndexVE", "SX3 index vs Energy; sx3 index ; Energy", 24*12, 0, 24*12, 400, 0, 500); hsx3IndexVE->SetNdivisions( -612, "x"); + hqqqIndexVE = new TH2F("hqqqIndexVE", "QQQ index vs Energy; QQQ index ; Energy", 4*2*16, 0, 4*2*16, 400, 0, 500); hqqqIndexVE->SetNdivisions( -1204, "x"); + hpcIndexVE = new TH2F("hpcIndexVE", "PC index vs Energy; PC index ; Energy", 2*24, 0, 2*24, 400, 0, 4000); hpcIndexVE->SetNdivisions( -1204, "x"); - hsx3VpcIndex = new TH2F("hsx3Vpcindex", "sx3 vs pc", 24*12, 0, 24*12, 48, 0, 48); + + hsx3Coin = new TH2F("hsx3Coin", "SX3 Coincident", 24*12, 0, 24*12, 24*12, 0, 24*12); + hqqqCoin = new TH2F("hqqqCoin", "QQQ Coincident", 4*2*16, 0, 4*2*16, 4*2*16, 0, 4*2*16); + hpcCoin = new TH2F("hpcCoin", "PC Coincident", 2*24, 0, 2*24, 2*24, 0, 2*24); + + hqqqPolar = new TH2F("hqqqPolar", "QQQ Polar ID", 16*4, -TMath::Pi(), TMath::Pi(),16, 10, 50); + + hsx3VpcIndex = new TH2F("hsx3Vpcindex", "sx3 vs pc; sx3 index; pc index", 24*12, 0, 24*12, 48, 0, 48); + hsx3VpcIndex->SetNdivisions( -612, "x"); + hsx3VpcIndex->SetNdivisions( -12, "y"); } Bool_t Analyzer::Process(Long64_t entry){ - if( entry > 1) return kTRUE; - printf("################### ev : %llu \n", entry); + // if( entry > 1) return kTRUE; + // printf("################### ev : %llu \n", entry); - b_sx3Multi->GetEntry(entry); - b_sx3ID->GetEntry(entry); - b_sx3Ch->GetEntry(entry); - b_sx3E->GetEntry(entry); - b_sx3T->GetEntry(entry); - b_qqqMulti->GetEntry(entry); - b_qqqID->GetEntry(entry); - b_qqqCh->GetEntry(entry); - b_qqqE->GetEntry(entry); - b_qqqT->GetEntry(entry); - b_pcMulti->GetEntry(entry); - b_pcID->GetEntry(entry); - b_pcCh->GetEntry(entry); - b_pcE->GetEntry(entry); - b_pcT->GetEntry(entry); + b_sx3Multi->GetEntry(entry); + b_sx3ID->GetEntry(entry); + b_sx3Ch->GetEntry(entry); + b_sx3E->GetEntry(entry); + b_sx3T->GetEntry(entry); + b_qqqMulti->GetEntry(entry); + b_qqqID->GetEntry(entry); + b_qqqCh->GetEntry(entry); + b_qqqE->GetEntry(entry); + b_qqqT->GetEntry(entry); + b_pcMulti->GetEntry(entry); + b_pcID->GetEntry(entry); + b_pcCh->GetEntry(entry); + b_pcE->GetEntry(entry); + b_pcT->GetEntry(entry); - sx3.CalIndex(); - qqq.CalIndex(); - pc.CalIndex(); + sx3.CalIndex(); + qqq.CalIndex(); + pc.CalIndex(); - sx3.Print(); + // sx3.Print(); - // //======================= SX3 - // for( int i = 0; i < sx3.multi; i ++){ - // for( int j = 0; j < pc.multi; j++){ - // hsx3VpcIndex->Fill( sx3.index[i], pc.index[j] ); - // } - // } + //########################################################### Raw data + // //======================= SX3 + for( int i = 0; i < sx3.multi; i ++){ + + hsx3IndexVE->Fill( sx3.index[i], sx3.e[i] ); + + for( int j = i+1; j < sx3.multi; j++){ + hsx3Coin->Fill( sx3.index[i], sx3.index[j]); + } + + for( int j = 0; j < pc.multi; j++){ + hsx3VpcIndex->Fill( sx3.index[i], pc.index[j] ); + } + } + + // //======================= QQQ + for( int i = 0; i < qqq.multi; i ++){ + hqqqIndexVE->Fill( qqq.index[i], qqq.e[i] ); + + for( int j = i + 1; j < qqq.multi; j++){ + hqqqCoin->Fill( qqq.index[i], qqq.index[j]); + + if( qqq.used[i] == true ) continue; + + if( qqq.id[i] == qqq.id[j] && (16 - qqq.ch[i]) * (16 - qqq.ch[j]) < 0 ){ // must be same detector and wedge and ring + + int chWedge = qqq.ch[i]; + int chRing = qqq.ch[j] - 16; + if( qqq.ch[i] >= 16 ) { + chWedge = qqq.ch[j]; + chRing = qqq.ch[i] - 16; + } + + //printf(" ID : %d , chWedge : %d, chRing : %d \n", qqq.id[i], chWedge, chRing); + + double theta = -TMath::Pi() + 2*TMath::Pi()/16/4.*(qqq.id[i]*16 + chWedge +0.5); + double rho = 10.+40./16.*(chRing+0.5); + + hqqqPolar->Fill( theta, rho); + + qqq.used[i] = true; + qqq.used[j] = true; + + } + } + } + + // //======================= PC + for( int i = 0; i < pc.multi; i ++){ + hpcIndexVE->Fill( pc.index[i], pc.e[i] ); + + for( int j = i+1; j < pc.multi; j++){ + hpcCoin->Fill( pc.index[i], pc.index[j]); + } + } + + //########################################################### Track constrcution - return kTRUE; + + return kTRUE; } void Analyzer::Terminate(){ + gStyle->SetOptStat("neiou"); + TCanvas * canvas = new TCanvas("cANASEN", "ANASEN", 1000, 1000); + canvas->Divide(3,3); + + //hsx3VpcIndex->Draw("colz"); + + //=============================================== pad-1 + padID ++; canvas->cd(padID); canvas->cd(padID)->SetGrid(1); + + hsx3IndexVE->Draw("colz"); + + //=============================================== pad-2 + padID ++; canvas->cd(padID); canvas->cd(padID)->SetGrid(1); + + hqqqIndexVE->Draw("colz"); + + //=============================================== pad-3 + padID ++; canvas->cd(padID); canvas->cd(padID)->SetGrid(1); + + hpcIndexVE->Draw("colz"); + + //=============================================== pad-4 + padID ++; canvas->cd(padID); canvas->cd(padID)->SetGrid(1); + + hsx3Coin->Draw("colz"); + + //=============================================== pad-5 + padID ++; canvas->cd(padID); canvas->cd(padID)->SetGrid(1); + + hqqqCoin->Draw("colz"); + + //=============================================== pad-6 + padID ++; canvas->cd(padID); canvas->cd(padID)->SetGrid(1); + + hpcCoin->Draw("colz"); + + //=============================================== pad-7 + padID ++; canvas->cd(padID); canvas->cd(padID)->SetGrid(1); + + canvas->cd(padID)->DrawFrame(-50, -50, 50, 50); + hqqqPolar->Draw("same colz pol"); } diff --git a/ClassDet.h b/ClassDet.h index 9ae9e6b..4b57ed3 100644 --- a/ClassDet.h +++ b/ClassDet.h @@ -16,6 +16,7 @@ public: unsigned long long t[MAXMULTI]; unsigned short index[MAXMULTI]; // id * 12 + ch; + bool used[MAXMULTI]; void Clear(){ multi = 0; @@ -25,6 +26,7 @@ public: e[i] = 0; t[i] = 0; index[i] = 0; + used[i] = false; } } diff --git a/PreAnalysis.C b/PreAnalysis.C index cfd6757..996337e 100644 --- a/PreAnalysis.C +++ b/PreAnalysis.C @@ -4,39 +4,79 @@ #include #include #include +#include #include "mapping.h" -TH1F *** rate; +TH2F ** hRate; +TH2F ** hEnergy; + + +int padID = 0; void PreAnalysis::Begin(TTree * /*tree*/){ - TString option = GetOption(); + TString option = GetOption(); - //Find the first and last timestamp, to get the run duration + //Find the first and last timestamp, to get the run duration + + hRate = new TH2F * [nBd]; + hEnergy = new TH2F * [nBd]; + for( int i = 0; i < nBd; i++){ + if( board.at(i) > 1000) { + hRate[i] = new TH2F(Form("hRate%d", board.at(i)), Form("Digi-%d; ch; sec", board.at(i)), 64, 0, 64, 100, 0, 100); + hEnergy[i] = new TH2F(Form("hEnergy%d", board.at(i)), Form("Digi-%d; ch; raw E", board.at(i)), 64, 0, 64, 400, 0, 500); + }else{ + hRate[i] = new TH2F(Form("hRate%d", board.at(i)), Form("Digi-%d; ch; sec", board.at(i)), 16, 0, 16, 100, 0, 100); + hEnergy[i] = new TH2F(Form("hEnergy%d", board.at(i)), Form("Digi-%d; ch; raw E", board.at(i)), 16, 0, 16, 400, 0, 5000); + } + } + + printf("================================ done creating histograms.\n"); - rate = new TH1F ** [nBd]; - for( int i = 0; i < nBd; i++){ - if( board.at(i) > 1000) { - rate[i] = new TH1F * [64]; - for(int j = 0; j < 64; j ++){ - rate[i][j] = new TH1F(Form("h%d_%d", board.at(i), j), Form("Digi-%d, ch-%d", board.at(i), j), 100, 0, 100); - } - }else{ - rate[i] = new TH1F * [16]; - for(int j = 0; j < 16; j ++){ - rate[i][j] = new TH1F(Form("h%d_%d", board.at(i), j), Form("Digi-%d, ch-%d", board.at(i), j), 100, 0, 100); - } - } - } - } Bool_t PreAnalysis::Process(Long64_t entry){ + b_multi->GetEntry(entry); + b_sn->GetEntry(entry); + b_ch->GetEntry(entry); + b_e->GetEntry(entry); + b_e_t->GetEntry(entry); - return kTRUE; + // printf("------------- multi: %lu\n", multi); + + for( unsigned int i = 0; i < multi; i++){ + + for( int j = 0; j < nBd; j++ ){ + + if( sn[i] == board.at(j) ) { + hRate[j]->Fill(ch[i], e_t[i]/1e9); + + hEnergy[j]->Fill(ch[i], e[i]); + break; + } + } + } + + return kTRUE; } void PreAnalysis::Terminate(){ + printf("================================ %s\n", __func__); + + gStyle->SetOptStat("neiou"); + TCanvas * canvas = new TCanvas("cANASEN", "Pre-Analysis, ANASEN", 4000, 800); + canvas->Divide(10,2); + + for( int i = 0; i < nBd; i++){ + padID++; canvas->cd(padID); + hRate[i]->Draw("colz"); + } + + for( int i = 0; i < nBd; i++){ + padID++; canvas->cd(padID); + hEnergy[i]->Draw("colz"); + } + }