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
This commit is contained in:
Vignesh Sitaraman 2026-04-27 13:52:27 -04:00
parent 1a01f332e6
commit 16c49c4f12
5 changed files with 156 additions and 108 deletions

View File

@ -5,15 +5,17 @@
#define MAXMULTI 1000 #define MAXMULTI 1000
class Det{ class Det
{
public: public:
Det(): multi(0) {Clear(); } Det() : multi(0) { Clear(); }
unsigned short multi; // max 65535 unsigned short multi; // max 65535
unsigned short id[MAXMULTI]; unsigned short id[MAXMULTI];
unsigned short ch[MAXMULTI]; unsigned short ch[MAXMULTI];
unsigned short e[MAXMULTI]; unsigned short e[MAXMULTI];
unsigned long long t[MAXMULTI]; unsigned long long t[MAXMULTI];
unsigned long long tf[MAXMULTI];
unsigned short sn[MAXMULTI]; unsigned short sn[MAXMULTI];
unsigned short digiCh[MAXMULTI]; unsigned short digiCh[MAXMULTI];
@ -21,13 +23,16 @@ public:
unsigned short index[MAXMULTI]; // id * nCh + ch; unsigned short index[MAXMULTI]; // id * nCh + ch;
bool used[MAXMULTI]; bool used[MAXMULTI];
void Clear(){ void Clear()
{
multi = 0; multi = 0;
for( int i = 0; i < MAXMULTI; i++){ for (int i = 0; i < MAXMULTI; i++)
{
id[i] = 0; id[i] = 0;
ch[i] = 0; ch[i] = 0;
e[i] = 0; e[i] = 0;
t[i] = 0; t[i] = 0;
tf[i] = 0;
index[i] = 0; index[i] = 0;
sn[i] = 0; sn[i] = 0;
digiCh[i] = 0; digiCh[i] = 0;
@ -35,30 +40,32 @@ public:
} }
} }
void Print(){ void Print()
{
printf("=============================== multi : %u\n", multi); printf("=============================== multi : %u\n", multi);
for( int i = 0; i < multi; i++) { 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]); {
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; nID = maxID;
nCh = maxCh; nCh = maxCh;
} }
void CalIndex(){ void CalIndex()
for( int i = 0; i < multi; i++){ {
index[i] = id[i] * nCh + ch[i] ; for (int i = 0; i < multi; i++)
{
index[i] = id[i] * nCh + ch[i];
} }
} }
private: private:
unsigned short nID; unsigned short nID;
unsigned short nCh; unsigned short nCh;
}; };
#endif #endif

View File

@ -11,12 +11,14 @@
#include "ClassDet.h" #include "ClassDet.h"
//=============================== //===============================
int main(int argc, char **argv){ int main(int argc, char **argv)
{
printf("=========================================\n"); printf("=========================================\n");
printf("=== Mapper ===\n"); printf("=== Mapper ===\n");
printf("=========================================\n"); printf("=========================================\n");
if (argc != 2) { if (argc != 2)
{
printf("Incorrect number of arguments:\n"); printf("Incorrect number of arguments:\n");
printf("%s [inFile]\n", argv[0]); printf("%s [inFile]\n", argv[0]);
printf("\n\n"); printf("\n\n");
@ -28,8 +30,8 @@ int main(int argc, char **argv){
PrintMapping(); PrintMapping();
TFile * inFile = new TFile(inFileName.c_str(), "READ"); TFile *inFile = new TFile(inFileName.c_str(), "READ");
TTree * tree = (TTree*) inFile->Get("tree"); TTree *tree = (TTree *)inFile->Get("tree");
unsigned long long totnumEntry = tree->GetEntries(); unsigned long long totnumEntry = tree->GetEntries();
ULong64_t evID; ULong64_t evID;
@ -54,10 +56,10 @@ int main(int argc, char **argv){
TString outFileName = inFileName; TString outFileName = inFileName;
TString runStr = outFileName; TString runStr = outFileName;
int pos = outFileName.Last('/'); int pos = outFileName.Last('/');
pos = outFileName.Index("_", pos+1); // find next "_" pos = outFileName.Index("_", pos + 1); // find next "_"
runStr.Remove(0, pos+1); runStr.Remove(0, pos + 1);
runStr.Remove(3); runStr.Remove(3);
pos = outFileName.Index("_", pos+1); // find next "_" pos = outFileName.Index("_", pos + 1); // find next "_"
outFileName.Remove(pos); // remove the rest outFileName.Remove(pos); // remove the rest
outFileName += "_mapped.root"; outFileName += "_mapped.root";
@ -66,19 +68,19 @@ int main(int argc, char **argv){
Det sx3; Det sx3;
Det qqq; Det qqq;
Det pc ; Det pc;
Det misc;
printf(" Raw root file : %s\n", inFileName.c_str()); printf(" Raw root file : %s\n", inFileName.c_str());
printf(" Run : %03d\n", run); 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()); printf(" Out file name : %s \n", outFileName.Data());
TFile * saveFile = new TFile( outFileName,"RECREATE"); TFile *saveFile = new TFile(outFileName, "RECREATE");
TTree * newTree = new TTree("tree","tree"); TTree *newTree = new TTree("tree", "tree");
newTree->Branch("evID", &eventID, "eventID/l");
newTree->Branch("evID", &eventID,"eventID/l"); newTree->Branch("run", &run, "run/i");
newTree->Branch("run", &run,"run/i");
newTree->Branch("sx3Multi", &sx3.multi, "sx3Multi/s"); newTree->Branch("sx3Multi", &sx3.multi, "sx3Multi/s");
newTree->Branch("sx3ID", &sx3.id, "sx3ID[sx3Multi]/s"); newTree->Branch("sx3ID", &sx3.id, "sx3ID[sx3Multi]/s");
@ -99,84 +101,114 @@ int main(int argc, char **argv){
newTree->Branch("pcE", &pc.e, "pcEnergy[pcMulti]/s"); newTree->Branch("pcE", &pc.e, "pcEnergy[pcMulti]/s");
newTree->Branch("pcT", &pc.t, "pcTime[pcMulti]/l"); 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 ///================== looping old tree and apply mapping
//clock // clock
// TBenchmark clock; // TBenchmark clock;
// Bool_t shown; // Bool_t shown;
for( unsigned long long ev = 0; ev < totnumEntry; ev++){ for (unsigned long long ev = 0; ev < totnumEntry; ev++)
{
tree->GetEntry(ev); tree->GetEntry(ev);
eventID = evID; eventID = evID;
sx3.multi = 0; sx3.multi = 0;
qqq.multi = 0; qqq.multi = 0;
pc.multi = 0; pc.multi = 0;
misc.multi = 0;
sx3.Clear();
qqq.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] ); // 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; int globalCh = -1;
for( int j = 0; j < nBd; j++){ 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 if (board.at(j) == sn[i])
{
globalCh = (sn[i] > 1000 ? j * 64 : 7 * 64 + (j - 7) * 16) + ch[i]; //& = number V1740
break; break;
} }
} }
if( globalCh == -1) printf("ev %llu\n", ev); if (globalCh == -1)
printf("ev %llu\n", ev);
unsigned short ID = mapping[globalCh]; unsigned short ID = mapping[globalCh];
//=================================== sx3 //=================================== sx3
if( ID < 10000 ) { if (ID < 10000)
{
sx3.id[sx3.multi] = ID / 100; sx3.id[sx3.multi] = ID / 100;
sx3.ch[sx3.multi] = ID % 100; sx3.ch[sx3.multi] = ID % 100;
sx3.e[sx3.multi] = e[i]; sx3.e[sx3.multi] = e[i];
sx3.t[sx3.multi] = e_t[i]; sx3.t[sx3.multi] = e_t[i];
sx3.multi ++; sx3.multi++;
} }
//=================================== qqq //=================================== qqq
if( 10000 <= ID && ID < 20000 ) { if (10000 <= ID && ID < 20000)
{
qqq.id[qqq.multi] = (ID - 10000) / 100; qqq.id[qqq.multi] = (ID - 10000) / 100;
qqq.ch[qqq.multi] = (ID - 10000) % 100; qqq.ch[qqq.multi] = (ID - 10000) % 100;
qqq.e[qqq.multi] = e[i]; qqq.e[qqq.multi] = e[i];
qqq.t[qqq.multi] = e_t[i]; qqq.t[qqq.multi] = e_t[i];
qqq.sn[qqq.multi] = sn[i]; qqq.sn[qqq.multi] = sn[i];
qqq.multi ++; qqq.multi++;
} }
//=================================== pc //=================================== pc
if( 20000 <= ID && ID < 30000 ) { if (20000 <= ID && ID < 30000)
{
pc.id[pc.multi] = (ID - 20000) / 100; pc.id[pc.multi] = (ID - 20000) / 100;
pc.ch[pc.multi] = (ID - 20000) % 100; pc.ch[pc.multi] = (ID - 20000) % 100;
pc.e[pc.multi] = e[i]; pc.e[pc.multi] = e[i];
pc.t[pc.multi] = e_t[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 saveFile->cd(); // set focus on this file
newTree->Fill(); newTree->Fill();
if( eventID % 100 == 0 ) printf("%6lu/%6llu [%2d%%]\n\033[A\r", eventID, totnumEntry, TMath::Nint((eventID+1)*100./totnumEntry)); if (eventID % 100 == 0)
printf("%6lu/%6llu [%2d%%]\n\033[A\r", eventID, totnumEntry, TMath::Nint((eventID + 1) * 100. / totnumEntry));
} }
inFile->Close(); inFile->Close();
saveFile->cd(); //set focus on this file saveFile->cd(); // set focus on this file
newTree->Write(); newTree->Write();
UInt_t eventNumber = newTree->GetEntries(); UInt_t eventNumber = newTree->GetEntries();
saveFile->Close(); saveFile->Close();
printf("-------------- done, %u\n", eventNumber); printf("-------------- done, %u\n", eventNumber);
return 0; return 0;
} }

View File

@ -13,22 +13,26 @@ timeWindow=$2
option=$3 option=$3
# rawFolder=/home/tandem/data1/2024_09_17Fap/data # rawFolder=/home/tandem/data1/2024_09_17Fap/data
rawFolder=/mnt/d/17F # rawFolder=/mnt/d/17F
rootFolder=/mnt/d/Remapped_files/17F_data/root_data # 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 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 # 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 outFile=${rawFolder}/*${runID}*${timeWindow}.root
mv -vf ${outFile} ${rootFolder}/. mv -vf ${outFile} ${rootFolder}/.
./Mapper ${rootFolder}/*${runID}*${timeWindow}.root time ./Mapper ${rootFolder}/*${runID}*${timeWindow}.root
fi fi
# root "processRun.C(\"${rootFolder}/Run_${runID}_mapped.root\")" # root "processRun.C(\"${rootFolder}/Run_${runID}_mapped.root\")"

View File

@ -48,7 +48,7 @@ fm = ROOT.Garfield.ComponentElmer()
fm.Initialise("wires2d/mesh.header", fm.Initialise("wires2d/mesh.header",
"wires2d/mesh.elements", "wires2d/mesh.elements",
"wires2d/mesh.nodes", "wires2d/mesh.nodes",
"wires2d/dielectrics.dat", # Dielectrics (leave as empty string) "wires2d/dielectrics.dat",
"wires2d/elstatics.result", "wires2d/elstatics.result",
"mm") "mm")

View File

@ -260,6 +260,11 @@ void GenMapping(std::string mapFile)
detID += 100 + atoi(words[4].c_str()); detID += 100 + atoi(words[4].c_str());
} }
if(words[2] == "MISC")
{
detID += 30000;
}
if (words[2] == "blank") if (words[2] == "blank")
{ {
detID = -1; detID = -1;