From 16c49c4f12e9f319b2c7d34beab8aef22abae548 Mon Sep 17 00:00:00 2001 From: vsitaraman Date: Mon, 27 Apr 2026 13:52:27 -0400 Subject: [PATCH] modified: Armory/ClassDet.h modified: Armory/Mapper.cpp modified: mapping.h made changes to allow misc det type to be read in modified: ProcessRun.sh added file paths in diferent pcs modified: anasen_fem/garfield_sim.py --- Armory/ClassDet.h | 67 +++++++------- Armory/Mapper.cpp | 176 ++++++++++++++++++++++--------------- ProcessRun.sh | 14 +-- anasen_fem/garfield_sim.py | 2 +- mapping.h | 5 ++ 5 files changed, 156 insertions(+), 108 deletions(-) diff --git a/Armory/ClassDet.h b/Armory/ClassDet.h index 510cbb4..7472b45 100644 --- a/Armory/ClassDet.h +++ b/Armory/ClassDet.h @@ -5,60 +5,67 @@ #define MAXMULTI 1000 -class Det{ +class Det +{ public: - Det(): multi(0) {Clear(); } + 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]; + unsigned short multi; // max 65535 + unsigned short id[MAXMULTI]; + unsigned short ch[MAXMULTI]; + unsigned short e[MAXMULTI]; + unsigned long long t[MAXMULTI]; + unsigned long long tf[MAXMULTI]; - unsigned short sn[MAXMULTI]; - unsigned short digiCh[MAXMULTI]; + unsigned short sn[MAXMULTI]; + unsigned short digiCh[MAXMULTI]; - unsigned short index[MAXMULTI]; // id * nCh + ch; - bool used[MAXMULTI]; + unsigned short index[MAXMULTI]; // id * nCh + ch; + bool used[MAXMULTI]; - void Clear(){ + void Clear() + { multi = 0; - for( int i = 0; i < MAXMULTI; i++){ + for (int i = 0; i < MAXMULTI; i++) + { id[i] = 0; ch[i] = 0; - e[i] = 0; - t[i] = 0; - index[i] = 0; - sn[i] = 0; - digiCh[i] = 0; - used[i] = false; + e[i] = 0; + t[i] = 0; + tf[i] = 0; + index[i] = 0; + sn[i] = 0; + digiCh[i] = 0; + used[i] = false; } } - void Print(){ + void Print() + { printf("=============================== multi : %u\n", multi); - for( int i = 0; i < multi; i++) { - printf(" %3d | %2d-%-2d(%5d) %5u %15llu \n", i, id[i], ch[i], index[i], e[i], t[i]); + for (int i = 0; i < multi; i++) + { + printf(" %3d | %2d-%-2d(%5d) %5u %15llu %15llu \n", i, id[i], ch[i], index[i], e[i], t[i], tf[i]); } } - void SetDetDimension(unsigned short maxID, unsigned maxCh){ + void SetDetDimension(unsigned short maxID, unsigned maxCh) + { nID = maxID; nCh = maxCh; } - void CalIndex(){ - for( int i = 0; i < multi; i++){ - index[i] = id[i] * nCh + ch[i] ; + void CalIndex() + { + for (int i = 0; i < multi; i++) + { + index[i] = id[i] * nCh + ch[i]; } } private: - unsigned short nID; unsigned short nCh; - }; - -#endif +#endif diff --git a/Armory/Mapper.cpp b/Armory/Mapper.cpp index 8030de1..5261d45 100644 --- a/Armory/Mapper.cpp +++ b/Armory/Mapper.cpp @@ -11,12 +11,14 @@ #include "ClassDet.h" //=============================== -int main(int argc, char **argv){ +int main(int argc, char **argv) +{ printf("=========================================\n"); printf("=== Mapper ===\n"); - printf("=========================================\n"); - if (argc != 2) { + printf("=========================================\n"); + if (argc != 2) + { printf("Incorrect number of arguments:\n"); printf("%s [inFile]\n", argv[0]); printf("\n\n"); @@ -28,155 +30,185 @@ int main(int argc, char **argv){ PrintMapping(); - TFile * inFile = new TFile(inFileName.c_str(), "READ"); - TTree * tree = (TTree*) inFile->Get("tree"); + TFile *inFile = new TFile(inFileName.c_str(), "READ"); + TTree *tree = (TTree *)inFile->Get("tree"); unsigned long long totnumEntry = tree->GetEntries(); - ULong64_t evID; - UInt_t multi; - UShort_t sn[MAXMULTI]; - UShort_t ch[MAXMULTI]; - UShort_t e[MAXMULTI]; - UShort_t e2[MAXMULTI]; - ULong64_t e_t[MAXMULTI]; - UShort_t e_f[MAXMULTI]; + ULong64_t evID; + UInt_t multi; + UShort_t sn[MAXMULTI]; + UShort_t ch[MAXMULTI]; + UShort_t e[MAXMULTI]; + UShort_t e2[MAXMULTI]; + ULong64_t e_t[MAXMULTI]; + UShort_t e_f[MAXMULTI]; - tree->SetBranchAddress("evID", &evID); + tree->SetBranchAddress("evID", &evID); tree->SetBranchAddress("multi", &multi); - tree->SetBranchAddress("sn", sn); - tree->SetBranchAddress("ch", ch); - tree->SetBranchAddress("e", e); - tree->SetBranchAddress("e2", e2); - tree->SetBranchAddress("e_t", e_t); - tree->SetBranchAddress("e_f", e_f); + tree->SetBranchAddress("sn", sn); + tree->SetBranchAddress("ch", ch); + tree->SetBranchAddress("e", e); + tree->SetBranchAddress("e2", e2); + tree->SetBranchAddress("e_t", e_t); + tree->SetBranchAddress("e_f", e_f); ///================== new tree TString outFileName = inFileName; - TString runStr = outFileName; + TString runStr = outFileName; int pos = outFileName.Last('/'); - pos = outFileName.Index("_", pos+1); // find next "_" - runStr.Remove(0, pos+1); + pos = outFileName.Index("_", pos + 1); // find next "_" + runStr.Remove(0, pos + 1); runStr.Remove(3); - pos = outFileName.Index("_", pos+1); // find next "_" - outFileName.Remove(pos); // remove the rest + pos = outFileName.Index("_", pos + 1); // find next "_" + outFileName.Remove(pos); // remove the rest outFileName += "_mapped.root"; ULong_t eventID; UInt_t run = runStr.Atoi(); - + Det sx3; Det qqq; - Det pc ; + Det pc; + Det misc; printf(" Raw root file : %s\n", inFileName.c_str()); printf(" Run : %03d\n", run); printf(" total Entry : %lld \n", totnumEntry); printf(" Out file name : %s \n", outFileName.Data()); - TFile * saveFile = new TFile( outFileName,"RECREATE"); - TTree * newTree = new TTree("tree","tree"); - + TFile *saveFile = new TFile(outFileName, "RECREATE"); + TTree *newTree = new TTree("tree", "tree"); - newTree->Branch("evID", &eventID,"eventID/l"); - newTree->Branch("run", &run,"run/i"); + newTree->Branch("evID", &eventID, "eventID/l"); + newTree->Branch("run", &run, "run/i"); newTree->Branch("sx3Multi", &sx3.multi, "sx3Multi/s"); - newTree->Branch("sx3ID", &sx3.id, "sx3ID[sx3Multi]/s"); - newTree->Branch("sx3Ch", &sx3.ch, "sx3Ch[sx3Multi]/s"); - newTree->Branch("sx3E", &sx3.e, "sx3Energy[sx3Multi]/s"); - newTree->Branch("sx3T", &sx3.t, "sx3Time[sx3Multi]/l"); + newTree->Branch("sx3ID", &sx3.id, "sx3ID[sx3Multi]/s"); + newTree->Branch("sx3Ch", &sx3.ch, "sx3Ch[sx3Multi]/s"); + newTree->Branch("sx3E", &sx3.e, "sx3Energy[sx3Multi]/s"); + newTree->Branch("sx3T", &sx3.t, "sx3Time[sx3Multi]/l"); newTree->Branch("qqqMulti", &qqq.multi, "qqqMulti/s"); - newTree->Branch("qqqID", &qqq.id, "qqqID[qqqMulti]/s"); - newTree->Branch("qqqCh", &qqq.ch, "qqqCh[qqqMulti]/s"); - newTree->Branch("qqqE", &qqq.e, "qqqEnergy[qqqMulti]/s"); - newTree->Branch("qqqT", &qqq.t, "qqqTime[qqqMulti]/l"); - newTree->Branch("qqqSN", &qqq.sn, "qqqSN[qqqMulti]/s"); + newTree->Branch("qqqID", &qqq.id, "qqqID[qqqMulti]/s"); + newTree->Branch("qqqCh", &qqq.ch, "qqqCh[qqqMulti]/s"); + newTree->Branch("qqqE", &qqq.e, "qqqEnergy[qqqMulti]/s"); + newTree->Branch("qqqT", &qqq.t, "qqqTime[qqqMulti]/l"); + newTree->Branch("qqqSN", &qqq.sn, "qqqSN[qqqMulti]/s"); newTree->Branch("pcMulti", &pc.multi, "pcMulti/s"); - newTree->Branch("pcID", &pc.id, "pcID[pcMulti]/s"); - newTree->Branch("pcCh", &pc.ch, "pcCh[pcMulti]/s"); - newTree->Branch("pcE", &pc.e, "pcEnergy[pcMulti]/s"); - newTree->Branch("pcT", &pc.t, "pcTime[pcMulti]/l"); + newTree->Branch("pcID", &pc.id, "pcID[pcMulti]/s"); + newTree->Branch("pcCh", &pc.ch, "pcCh[pcMulti]/s"); + newTree->Branch("pcE", &pc.e, "pcEnergy[pcMulti]/s"); + newTree->Branch("pcT", &pc.t, "pcTime[pcMulti]/l"); + + newTree->Branch("miscMulti", &misc.multi, "miscMulti/s"); + newTree->Branch("miscID", &misc.id, "miscID[miscMulti]/s"); + newTree->Branch("miscCh", &misc.ch, "miscCh[miscMulti]/s"); + newTree->Branch("miscE", &misc.e, "miscEnergy[miscMulti]/s"); + newTree->Branch("miscT", &misc.t, "miscTime[miscMulti]/l"); + newTree->Branch("miscF", &misc.tf, "miscFineTime[miscMulti]/l"); ///================== looping old tree and apply mapping - //clock - // TBenchmark clock; - // Bool_t shown; + // clock + // TBenchmark clock; + // Bool_t shown; - for( unsigned long long ev = 0; ev < totnumEntry; ev++){ + for (unsigned long long ev = 0; ev < totnumEntry; ev++) + { tree->GetEntry(ev); eventID = evID; sx3.multi = 0; qqq.multi = 0; pc.multi = 0; + misc.multi = 0; + sx3.Clear(); qqq.Clear(); + pc.Clear(); + misc.Clear(); - for( unsigned int i = 0; i < multi; i++){ + for (unsigned int i = 0; i < multi; i++) + { // printf("%10u/%10u| %5d, %2u, %6u, %14llu\n", i, multi, sn[i], ch[i], e[i], e_t[i] ); - - //globalCh = digi-ID * nCh(digi-iD) + ch + + // globalCh = digi-ID * nCh(digi-iD) + ch int globalCh = -1; - for( int j = 0; j < nBd; j++){ - if( board.at(j) == sn[i]){ - globalCh = (sn[i] > 1000 ? j * 64 : 7*64 + (j-7) * 16) + ch[i]; //& = number V1740 + for (int j = 0; j < nBd; j++) + { + if (board.at(j) == sn[i]) + { + globalCh = (sn[i] > 1000 ? j * 64 : 7 * 64 + (j - 7) * 16) + ch[i]; //& = number V1740 break; } } - - if( globalCh == -1) printf("ev %llu\n", ev); + + if (globalCh == -1) + printf("ev %llu\n", ev); unsigned short ID = mapping[globalCh]; //=================================== sx3 - if( ID < 10000 ) { + if (ID < 10000) + { sx3.id[sx3.multi] = ID / 100; sx3.ch[sx3.multi] = ID % 100; sx3.e[sx3.multi] = e[i]; sx3.t[sx3.multi] = e_t[i]; - sx3.multi ++; + sx3.multi++; } //=================================== qqq - if( 10000 <= ID && ID < 20000 ) { + if (10000 <= ID && ID < 20000) + { qqq.id[qqq.multi] = (ID - 10000) / 100; qqq.ch[qqq.multi] = (ID - 10000) % 100; qqq.e[qqq.multi] = e[i]; qqq.t[qqq.multi] = e_t[i]; qqq.sn[qqq.multi] = sn[i]; - qqq.multi ++; + qqq.multi++; } //=================================== pc - if( 20000 <= ID && ID < 30000 ) { + if (20000 <= ID && ID < 30000) + { pc.id[pc.multi] = (ID - 20000) / 100; pc.ch[pc.multi] = (ID - 20000) % 100; pc.e[pc.multi] = e[i]; pc.t[pc.multi] = e_t[i]; - pc.multi ++; + pc.multi++; + } + + //=================================== misc + if (30000 <= ID && ID < 40000) + { + misc.id[misc.multi] = (ID - 30000) / 100; + misc.ch[misc.multi] = (ID - 30000) % 100; + misc.e[misc.multi] = e[i]; + misc.t[misc.multi] = e_t[i]; + misc.tf[misc.multi] = e_f[i]; + // if( ID == 30002 || ID == 30004 ) printf("sn : %d ch: %2d | gID %3d | ID %6d | e_f : %d\n", sn[i], ch[i], globalCh, ID, e_f[i]); + misc.multi++; } } - - saveFile->cd(); //set focus on this file - newTree->Fill(); - - if( eventID % 100 == 0 ) printf("%6lu/%6llu [%2d%%]\n\033[A\r", eventID, totnumEntry, TMath::Nint((eventID+1)*100./totnumEntry)); + saveFile->cd(); // set focus on this file + newTree->Fill(); + + if (eventID % 100 == 0) + printf("%6lu/%6llu [%2d%%]\n\033[A\r", eventID, totnumEntry, TMath::Nint((eventID + 1) * 100. / totnumEntry)); } inFile->Close(); - saveFile->cd(); //set focus on this file - newTree->Write(); + saveFile->cd(); // set focus on this file + newTree->Write(); UInt_t eventNumber = newTree->GetEntries(); saveFile->Close(); printf("-------------- done, %u\n", eventNumber); - - return 0; + return 0; } \ No newline at end of file diff --git a/ProcessRun.sh b/ProcessRun.sh index 33f9df2..3b20b2b 100755 --- a/ProcessRun.sh +++ b/ProcessRun.sh @@ -13,22 +13,26 @@ timeWindow=$2 option=$3 # rawFolder=/home/tandem/data1/2024_09_17Fap/data -rawFolder=/mnt/d/17F -rootFolder=/mnt/d/Remapped_files/17F_data/root_data +# rawFolder=/mnt/d/17F +# rootFolder=/mnt/d/Remapped_files/17F_data/root_data +# rawFolder=/mnt/data1/vs19g/2024_06_27Al_vs19g/data +# rootFolder=/home/vs19g/Desktop/27Al_Data/root_data +rawFolder=/mnt/data1/vs19g/2024_09_17Fap/data +rootFolder=/home/vs19g/Desktop/17F_Data/root_data if [ $option -eq 0 ]; then # rsync -auh --info=progress2 splitpole@128.186.111.223:/media/nvmeData/2024_09_17Fap/*.fsu /home/tandem/data1/2024_09_17Fap/data - fileList=`\ls -1 ${rawFolder}/*SourceRun_${runID}_*.fsu` + fileList=`\ls -1 ${rawFolder}/*Run*_${runID}_*.fsu` - ./EventBuilder ${timeWindow} 0 0 100000000 ${fileList} + time ./EventBuilder ${timeWindow} 0 0 100000000 ${fileList} outFile=${rawFolder}/*${runID}*${timeWindow}.root mv -vf ${outFile} ${rootFolder}/. - ./Mapper ${rootFolder}/*${runID}*${timeWindow}.root + time ./Mapper ${rootFolder}/*${runID}*${timeWindow}.root fi # root "processRun.C(\"${rootFolder}/Run_${runID}_mapped.root\")" diff --git a/anasen_fem/garfield_sim.py b/anasen_fem/garfield_sim.py index 839f98e..31e5adc 100644 --- a/anasen_fem/garfield_sim.py +++ b/anasen_fem/garfield_sim.py @@ -48,7 +48,7 @@ fm = ROOT.Garfield.ComponentElmer() fm.Initialise("wires2d/mesh.header", "wires2d/mesh.elements", "wires2d/mesh.nodes", - "wires2d/dielectrics.dat", # Dielectrics (leave as empty string) + "wires2d/dielectrics.dat", "wires2d/elstatics.result", "mm") diff --git a/mapping.h b/mapping.h index f5cc3da..9090c03 100644 --- a/mapping.h +++ b/mapping.h @@ -260,6 +260,11 @@ void GenMapping(std::string mapFile) detID += 100 + atoi(words[4].c_str()); } + if(words[2] == "MISC") + { + detID += 30000; + } + if (words[2] == "blank") { detID = -1;