diff --git a/.vscode/settings.json b/.vscode/settings.json index ec94e33..e1fb437 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,6 +13,8 @@ "initializer_list": "cpp", "span": "cpp", "ApplyMapping.C": "cpp", - "script.C": "cpp" + "script.C": "cpp", + "Analyzer.C": "cpp", + "PreAnalysis.C": "cpp" } } \ No newline at end of file diff --git a/Analyzer.C b/Analyzer.C new file mode 100644 index 0000000..0c19d30 --- /dev/null +++ b/Analyzer.C @@ -0,0 +1,56 @@ +#define Analyzer_cxx + +#include "Analyzer.h" +#include +#include + +// TH2F * hsx3IDVch; +// // TH2F * hqqqIDVch; +// // TH2F * hpcIDVch; + +// TH2F * hsx3VpcIndex; + +// TH2F * hsx3EVIndex; + +void Analyzer::Begin(TTree * /*tree*/){ + 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); + + // hsx3VpcIndex = new TH2F("hsx3Vpcindex", "sx3 vs pc", 24*12, 0, 24*12, 48, 0, 48); + +} + +Bool_t Analyzer::Process(Long64_t 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 + for( int i = 0; i < sx3.multi; i ++){ + sx3.Print(); + } + + return kTRUE; +} + +void Analyzer::Terminate(){ + + +} diff --git a/Analyzer.h b/Analyzer.h new file mode 100644 index 0000000..4a550db --- /dev/null +++ b/Analyzer.h @@ -0,0 +1,111 @@ +#ifndef Analyzer_h +#define Analyzer_h + +#include +#include +#include +#include + +#include "ClassDet.h" + +class Analyzer : public TSelector { +public : + TTree *fChain; //!pointer to the analyzed TTree or TChain + +// Fixed size dimensions of array or collections stored in the TTree if any. + + // Declaration of leaf types + Det sx3; + Det qqq; + Det pc ; + + ULong64_t evID; + UInt_t run; + + // List of branches + TBranch *b_eventID; //! + TBranch *b_run; //! + TBranch *b_sx3Multi; //! + TBranch *b_sx3ID; //! + TBranch *b_sx3Ch; //! + TBranch *b_sx3E; //! + TBranch *b_sx3T; //! + TBranch *b_qqqMulti; //! + TBranch *b_qqqID; //! + TBranch *b_qqqCh; //! + TBranch *b_qqqE; //! + TBranch *b_qqqT; //! + TBranch *b_pcMulti; //! + TBranch *b_pcID; //! + TBranch *b_pcCh; //! + TBranch *b_pcE; //! + TBranch *b_pcT; //! + + Analyzer(TTree * /*tree*/ =0) : fChain(0) { } + virtual ~Analyzer() { } + virtual Int_t Version() const { return 2; } + virtual void Begin(TTree *tree); + virtual void SlaveBegin(TTree *tree); + virtual void Init(TTree *tree); + virtual Bool_t Notify(); + virtual Bool_t Process(Long64_t entry); + virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; } + virtual void SetOption(const char *option) { fOption = option; } + virtual void SetObject(TObject *obj) { fObject = obj; } + virtual void SetInputList(TList *input) { fInput = input; } + virtual TList *GetOutputList() const { return fOutput; } + virtual void SlaveTerminate(); + virtual void Terminate(); + + ClassDef(Analyzer,0); +}; + +#endif + +#ifdef Analyzer_cxx +void Analyzer::Init(TTree *tree){ + + // Set branch addresses and branch pointers + if (!tree) return; + fChain = tree; + fChain->SetMakeClass(1); + + fChain->SetBranchAddress("evID", &evID, &b_eventID); + fChain->SetBranchAddress("run", &run, &b_run); + + + fChain->SetBranchAddress("sx3Multi", &sx3.multi, &b_sx3Multi); + fChain->SetBranchAddress("sx3ID", &sx3.id, &b_sx3ID); + fChain->SetBranchAddress("sx3Ch", &sx3.ch, &b_sx3Ch); + fChain->SetBranchAddress("sx3E", &sx3.e, &b_sx3E); + fChain->SetBranchAddress("sx3T", &sx3.t, &b_sx3T); + fChain->SetBranchAddress("qqqMulti", &qqq.multi, &b_qqqMulti); + fChain->SetBranchAddress("qqqID", &qqq.id, &b_qqqID); + fChain->SetBranchAddress("qqqCh", &qqq.ch, &b_qqqCh); + fChain->SetBranchAddress("qqqE", &qqq.e, &b_qqqE); + fChain->SetBranchAddress("qqqT", &qqq.t, &b_qqqT); + fChain->SetBranchAddress("pcMulti", &pc.multi, &b_pcMulti); + fChain->SetBranchAddress("pcID", &pc.id, &b_pcID); + fChain->SetBranchAddress("pcCh", &pc.ch, &b_pcCh); + fChain->SetBranchAddress("pcE", &pc.e, &b_pcE); + fChain->SetBranchAddress("pcT", &pc.t, &b_pcT); + +} + +Bool_t Analyzer::Notify(){ + + return kTRUE; +} + +void Analyzer::SlaveBegin(TTree * /*tree*/){ + + TString option = GetOption(); + +} + +void Analyzer::SlaveTerminate(){ + +} + + +#endif // #ifdef Analyzer_cxx diff --git a/ClassDet.h b/ClassDet.h new file mode 100644 index 0000000..4466e6f --- /dev/null +++ b/ClassDet.h @@ -0,0 +1,37 @@ +#ifndef ClassDet_h +#define ClassDet_h + +#include + +#define MAXMULTI 1000 + +class Det{ +public: + Det(): multi(0) {Clear(); } + + unsigned short multi; // max 65535 + unsigned short id[MAXMULTI]; + unsigned short ch[MAXMULTI]; + unsigned short e[MAXMULTI]; + unsigned long long t[MAXMULTI]; + + void Clear(){ + multi = 0; + for( int i = 0; i < MAXMULTI; i++){ + id[i] = 0; + ch[i] = 0; + e[i] = 0; + t[i] = 0; + } + } + + void Print(){ + printf("=============================== multi : %u\n", multi); + for( int i = 0; i < multi; i++) { + printf(" %3d | %2d-%2d %5u %llu \n", i, id[i], ch[i], e[i], t[i]); + } + } +}; + + +#endif \ No newline at end of file diff --git a/Makefile b/Makefile index 3427d34..21030f1 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,6 @@ all : $(ALL) clean : /bin/rm -f $(OBJS) $(ALL) -Mapper : Mapper.cpp mapping.h +Mapper : Mapper.cpp mapping.h ClassDet.h @echo "--------- making Mapper" $(CC) $(COPTS) -o Mapper Mapper.cpp $(ROOTLIBS) diff --git a/Mapper.cpp b/Mapper.cpp index 012a5ef..9128d3e 100644 --- a/Mapper.cpp +++ b/Mapper.cpp @@ -1,4 +1,3 @@ - #include #include @@ -9,36 +8,7 @@ #include #include "mapping.h" - -#define MAXMULTI 1000 - -class Det{ -public: - Det(): multi(0) {Clear(); } - - UShort_t multi; - UShort_t id[MAXMULTI]; - UShort_t ch[MAXMULTI]; - UShort_t e[MAXMULTI]; - ULong64_t t[MAXMULTI]; - - void Clear(){ - multi = 0; - for( int i = 0; i < MAXMULTI; i++){ - id[i] = 0; - ch[i] = 0; - e[i] = 0; - t[i] = 0; - } - } - - void Print(){ - printf("=============================== multi : %u\n", multi); - for( int i = 0; i < multi; i++) { - printf(" %3d | %2d-%2d %5u %llu \n", i, id[i], ch[i], e[i], t[i]); - } - } -}; +#include "ClassDet.h" //=============================== int main(int argc, char **argv){ @@ -58,7 +28,6 @@ int main(int argc, char **argv){ PrintMapping(); - TFile * inFile = new TFile(inFileName.c_str(), "READ"); TTree * tree = (TTree*) inFile->Get("tree"); unsigned long long totnumEntry = tree->GetEntries(); @@ -101,7 +70,7 @@ int main(int argc, char **argv){ printf(" Raw root file : %s\n", inFileName.c_str()); printf(" Run : %03d\n", run); - printf( " total Entry : %lld \n", totnumEntry); + printf(" total Entry : %lld \n", totnumEntry); printf(" Out file name : %s \n", outFileName.Data()); TFile * saveFile = new TFile( outFileName,"RECREATE"); diff --git a/PreAnalysis.C b/PreAnalysis.C new file mode 100644 index 0000000..cfd6757 --- /dev/null +++ b/PreAnalysis.C @@ -0,0 +1,42 @@ +#define PreAnalysis_cxx + +#include "PreAnalysis.h" +#include +#include +#include + +#include "mapping.h" + +TH1F *** rate; + +void PreAnalysis::Begin(TTree * /*tree*/){ + TString option = GetOption(); + + //Find the first and last timestamp, to get the run duration + + 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){ + + + return kTRUE; +} + +void PreAnalysis::Terminate(){ + +} diff --git a/PreAnalysis.h b/PreAnalysis.h new file mode 100644 index 0000000..373f21b --- /dev/null +++ b/PreAnalysis.h @@ -0,0 +1,92 @@ +#ifndef PreAnalysis_h +#define PreAnalysis_h + +#include +#include +#include +#include + +#define MAXMULTI 1000 + +class PreAnalysis : public TSelector { +public : + TTree *fChain; //!pointer to the analyzed TTree or TChain + + // Declaration of leaf types + ULong64_t evID; + UInt_t multi; + UShort_t sn[MAXMULTI]; //[multi] + UShort_t ch[MAXMULTI]; //[multi] + UShort_t e[MAXMULTI]; //[multi] + UShort_t e2[MAXMULTI]; //[multi] + ULong64_t e_t[MAXMULTI]; //[multi] + UShort_t e_f[MAXMULTI]; //[multi] + Bool_t pileUp[MAXMULTI]; //[multi] + + // List of branches + TBranch *b_event_ID; //! + TBranch *b_multi; //! + TBranch *b_sn; //! + TBranch *b_ch; //! + TBranch *b_e; //! + TBranch *b_e2; //! + TBranch *b_e_t; //! + TBranch *b_e_f; //! + TBranch *b_pileUp; //! + + PreAnalysis(TTree * /*tree*/ =0) : fChain(0) { } + virtual ~PreAnalysis() { } + virtual Int_t Version() const { return 2; } + virtual void Begin(TTree *tree); + virtual void SlaveBegin(TTree *tree); + virtual void Init(TTree *tree); + virtual Bool_t Notify(); + virtual Bool_t Process(Long64_t entry); + virtual Int_t GetEntry(Long64_t entry, Int_t getall = 0) { return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0; } + virtual void SetOption(const char *option) { fOption = option; } + virtual void SetObject(TObject *obj) { fObject = obj; } + virtual void SetInputList(TList *input) { fInput = input; } + virtual TList *GetOutputList() const { return fOutput; } + virtual void SlaveTerminate(); + virtual void Terminate(); + + ClassDef(PreAnalysis,0); +}; + +#endif + +#ifdef PreAnalysis_cxx +void PreAnalysis::Init(TTree *tree){ + + // Set branch addresses and branch pointers + if (!tree) return; + fChain = tree; + fChain->SetMakeClass(1); + + fChain->SetBranchAddress("evID", &evID, &b_event_ID); + fChain->SetBranchAddress("multi", &multi, &b_multi); + fChain->SetBranchAddress("sn", sn, &b_sn); + fChain->SetBranchAddress("ch", ch, &b_ch); + fChain->SetBranchAddress("e", e, &b_e); + fChain->SetBranchAddress("e2", e2, &b_e2); + fChain->SetBranchAddress("e_t", e_t, &b_e_t); + fChain->SetBranchAddress("e_f", e_f, &b_e_f); + fChain->SetBranchAddress("pileUp", pileUp, &b_pileUp); +} + +Bool_t PreAnalysis::Notify(){ + + return kTRUE; +} + +void PreAnalysis::SlaveBegin(TTree * /*tree*/){ + + TString option = GetOption(); + +} + +void PreAnalysis::SlaveTerminate(){ + +} + +#endif // #ifdef PreAnalysis_cxx diff --git a/ProceeRun.sh b/ProceeRun.sh new file mode 100755 index 0000000..7fb9cf9 --- /dev/null +++ b/ProceeRun.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ "$#" -ne 2 ]; then + echo "Usage: $0 runID timeWindow_ns" + echo "Exiting..." + exit 1 +fi + +runID=$1 +timeWindow=$2 + +rawFolder=/media/nvmeData/ANASEN_test +rootFolder=/media/nvmeData/ANASEN_test/root_data + +fileList=`\ls -1 ${rawFolder}/*${runID}*.fsu` + +./EventBuilderNoTrace ${timeWindow} 0 ${fileList} + +outFile=${rawFolder}/*${runID}*${timeWindow}_noTrace.root + +mv -vf ${outFile} ${rootFolder}/. + +./Mapper ${rootFolder}/*${runID}*${timeWindow}_noTrace.root \ No newline at end of file diff --git a/mapping.h b/mapping.h index 8c307bd..bd1ac61 100644 --- a/mapping.h +++ b/mapping.h @@ -11,24 +11,6 @@ #include -// class Hit{ - -// public: -// std::string label; -// unsigned short ch; -// double energy; -// unsigned long long timestamp; -// Hit() : label(""), ch(-1), energy(TMath::QuietNaN()), timestamp(0) {} - -// Hit(std::string label, unsigned short ch, double energy, unsigned long long timestamp){ -// this->label = label; -// this->ch = ch; -// this->energy = energy; -// this->timestamp = timestamp; -// } - -// }; - const std::map board = { {0, 17122}, // id, sn {1, 17123}, @@ -43,6 +25,9 @@ const std::map board = { }; const int nBd = board.size(); +const int nV1740 = 7; +const int nV1725 = 3; + //+++++++++++++++++++ detID; // The detectors are seperated into 2 type: SuperX3, QQQ, and PC // the SuperX3 has 24 detectors for each kind, wach detector has 12 channels