From b92673ee7a006e6811d5b68e1c0edf33ba039a45 Mon Sep 17 00:00:00 2001 From: "Ryan@Debain10" Date: Fri, 4 Mar 2022 16:13:40 -0500 Subject: [PATCH] remove mapping in evtReader and DataBlock --- armory/DataBlock.h | 6 +----- armory/MergeEVT.cpp | 13 +++++++++---- armory/evt2hist.cpp | 23 ++++++++++++++--------- armory/evtReader.h | 10 ++++------ armory/to2root.cpp | 14 ++++++++------ 5 files changed, 36 insertions(+), 30 deletions(-) diff --git a/armory/DataBlock.h b/armory/DataBlock.h index 5ce4773..5c240f9 100644 --- a/armory/DataBlock.h +++ b/armory/DataBlock.h @@ -35,8 +35,6 @@ public: Int_t baseline; Int_t QDCsum[8]; - UShort_t id; - Int_t detID; ULong64_t eventID; UShort_t trace[1024]; @@ -59,8 +57,6 @@ public: energy = 0; trace_length = 0; trace_out_of_range = 0; - id = 0; - detID = -1; eventID = 0; ClearQDC(); ClearTrace(); @@ -81,7 +77,7 @@ public: void Print(){ printf("============== eventID : %llu\n", eventID); - printf("Crate: %d, Slot: %d, Ch: %d | id: %d = detID : %d \n", crate, slot, ch, id, detID); + printf("Crate: %d, Slot: %d, Ch: %d \n", crate, slot, ch); printf("HeaderLength: %d, Event Length: %d, energy: %d, timeStamp: %llu\n", headerLength, eventLength, energy, time); printf("trace_length: %d, pile-up:%d\n", trace_length, pileup); if( headerLength > 4 ){ diff --git a/armory/MergeEVT.cpp b/armory/MergeEVT.cpp index 4e0c90d..47f2592 100644 --- a/armory/MergeEVT.cpp +++ b/armory/MergeEVT.cpp @@ -50,7 +50,7 @@ int main(int argn, char **argv) { evtReader * evt = new evtReader(); DataBlock * data = evt->data; - + short detID; printf("====================================\n"); //====== ROOT file @@ -58,7 +58,7 @@ int main(int argn, char **argv) { TTree * tree = new TTree("tree", "tree"); tree->Branch("evID", &data->eventID, "data_ID/L"); - tree->Branch("id", &data->detID, "ID/s"); + tree->Branch("detID", &detID, "detID/s"); tree->Branch("e", &data->energy, "crystal_energy/s"); tree->Branch("e_t", &data->time, "crystal_timestamp/l"); @@ -67,7 +67,6 @@ int main(int argn, char **argv) { gClock.Reset(); gClock.Start("timer"); - //========================================= //========================================= //========================================= @@ -89,10 +88,16 @@ int main(int argn, char **argv) { evt->ReadBlock(); evt->PrintStatus(10000); + + int id = data->crate*MAX_BOARDS_PER_CRATE*MAX_CHANNELS_PER_BOARD + (data->slot-BOARD_START)*MAX_CHANNELS_PER_BOARD + data->ch; + detID = mapping[id]; + + printf("--------- a\n"); + outFile-> + //cern fill tree outFile->cd(); tree->Fill(); - } clock2.Stop("timer"); diff --git a/armory/evt2hist.cpp b/armory/evt2hist.cpp index dd40ad5..1932522 100644 --- a/armory/evt2hist.cpp +++ b/armory/evt2hist.cpp @@ -109,14 +109,15 @@ int main(int argn, char **argv) { //================ ROOT tree TFile * fFile = NULL; TTree * tree = NULL; + + short detID; + if( rootFileName != "" ){ fFile = new TFile(rootFileName, "RECREATE"); tree = new TTree("tree", "tree"); - tree->Branch("headerLenght", &data->headerLength, "HeaderLength/s"); - tree->Branch("detID", &data->detID, "detID/s"); - tree->Branch("id", &data->id, "id/s"); + tree->Branch("detID", &detID, "detID/s"); tree->Branch("e", &data->energy, "energy/s"); tree->Branch("e_t", &data->time, "timestamp/l"); tree->Branch("p", &data->pileup, "pileup/O"); @@ -191,22 +192,26 @@ int main(int argn, char **argv) { } //==== Fill Histogram - if( 0 <= data->detID && data->detID < 100 && data->energy > rawEnergyThreshold ){ + + int haha = data->crate*MAX_BOARDS_PER_CRATE*MAX_CHANNELS_PER_BOARD + (data->slot-BOARD_START)*MAX_CHANNELS_PER_BOARD + data->ch; + detID = mapping[haha]; + + if( 0 <= detID && detID < 100 && data->energy > rawEnergyThreshold ){ if( corrFile != ""){ ///========= apply correction - int order = (int) eCorr[data->detID].size(); + int order = (int) eCorr[detID].size(); double eCal = 0; for( int k = 0; k < order ; k++){ - eCal += eCorr[data->detID][k] * TMath::Power(data->energy, k); + eCal += eCorr[detID][k] * TMath::Power(data->energy, k); } - he[data->detID]->Fill(eCal); + he[detID]->Fill(eCal); }else{ - he[data->detID]->Fill(data->energy); + he[detID]->Fill(data->energy); } } ///============ QDC - if( data->detID == GAGGID && (data->headerLength < data->eventLength) ){ + if( detID == GAGGID && (data->headerLength < data->eventLength) ){ double bg = (data->QDCsum[0] + data->QDCsum[1])/60.; double peak = data->QDCsum[3]/20. - bg; double tail = data->QDCsum[5]/55. - bg; diff --git a/armory/evtReader.h b/armory/evtReader.h index ee859db..f507df4 100644 --- a/armory/evtReader.h +++ b/armory/evtReader.h @@ -14,7 +14,6 @@ #include "TString.h" #include "TBenchmark.h" -#include "../mapping.h" #include "../armory/DataBlock.h" #define MAX_CRATES 2 @@ -120,6 +119,8 @@ void evtReader::OpenFile(TString inFileName){ gClock.Reset(); gClock.Start("timer"); + + isOpened = true; } }; @@ -136,7 +137,7 @@ bool evtReader::IsEndOfFile() { } -int evtReader::ReadBlock(int opt = 0){ +int evtReader::ReadBlock(int opt){ if( feof(inFile) ) return -1; if( endOfFile ) return -1; @@ -165,9 +166,6 @@ int evtReader::ReadBlock(int opt = 0){ data->trace_length = (header[3] >> 16) & 0x7FFF; data->trace_out_of_range = header[3] >> 31; - data->id = data->crate*MAX_BOARDS_PER_CRATE*MAX_CHANNELS_PER_BOARD + (data->slot-BOARD_START)*MAX_CHANNELS_PER_BOARD + data->ch; - data->detID = mapping[data->id]; - data->ClearQDC(); ///======== read QDCsum @@ -198,7 +196,7 @@ int evtReader::ReadBlock(int opt = 0){ fread(traceBlock, sizeof(unsigned int) * ( data->trace_length / 2 ), 1, inFile); for( int i = 0; i < data->trace_length/2 ; i++){ - data->trace[2*i+0] = traceBlock[i] & 0xFFFF ; + data->trace[2*i+0] = traceBlock[i] & 0xFFFF ; data->trace[2*i+1] = (traceBlock[i] >> 16 ) & 0xFFFF ; } diff --git a/armory/to2root.cpp b/armory/to2root.cpp index 5d67a7e..a54c9db 100644 --- a/armory/to2root.cpp +++ b/armory/to2root.cpp @@ -158,23 +158,25 @@ int main(int argc, char **argv) { multiCry = 0; multiGagg = 0; - id[multi] = data->detID; + int haha = data->crate*MAX_BOARDS_PER_CRATE*MAX_CHANNELS_PER_BOARD + (data->slot-BOARD_START)*MAX_CHANNELS_PER_BOARD + data->ch; + id[multi] = mapping[haha]; e[multi] = data->energy; e_t[multi] = data->time; for( int i = 0; i < 8; i++) qdc[multi][i] = data->QDCsum[i]; multi++ ; - if( data->detID < 100 ) multiCry ++; - if( data->detID >= 200 ) multiGagg ++; + if( id[multi] < 100 ) multiCry ++; + if( id[multi] >= 200 ) multiGagg ++; }else{ //if within time window, fill array; - id[multi] = data->detID; + int haha = data->crate*MAX_BOARDS_PER_CRATE*MAX_CHANNELS_PER_BOARD + (data->slot-BOARD_START)*MAX_CHANNELS_PER_BOARD + data->ch; + id[multi] = mapping[haha]; e[multi] = data->energy; e_t[multi] = data->time; for( int i = 0; i < 8; i++) qdc[multi-1][i] = data->QDCsum[i]; multi++ ; - if( data->detID < 100 ) multiCry ++; - if( data->detID >= 200 ) multiGagg ++; + if( id[multi] < 100 ) multiCry ++; + if( id[multi] >= 200 ) multiGagg ++; }