edited runID in EventBuilder

This commit is contained in:
Ryan Tang 2022-06-08 14:43:03 -04:00
parent c72851bd4e
commit e8d802a268
11 changed files with 274 additions and 63 deletions

8
.gitignore vendored
View File

@ -4,8 +4,16 @@
*.root *.root
*.evt *.evt
root_data
EventBuilder EventBuilder
legacy_code legacy_code
nscl2pixie nscl2pixie
nscl2pixie_haha nscl2pixie_haha
ev22txt
EventBuilder_evt
evt2hist
MergeEVT
*.csv
*_C_ACLiC_* *_C_ACLiC_*

View File

@ -116,12 +116,16 @@ int main(int argc, char **argv) {
int pos = inFileName[i].Last('/'); int pos = inFileName[i].Last('/');
TString temp = inFileName[i]; TString temp = inFileName[i];
temp.Remove(0, pos+1); temp.Remove(0, pos+1); /// run-XXXX-XX.evt
pos = temp.Last('-'); TString runNumStr = temp;
temp.Remove(0, pos+1); runNumStr.Remove(8);
pos = temp.Last('.'); runNumStr.Remove(0,4);
temp.Remove(pos); int runNum = atoi(runNumStr);
runID = atoi(temp.Data()); TString segNumStr = temp;
segNumStr.Remove(11);
segNumStr.Remove(0,9);
int segNum = atoi(segNumStr);
runID = runNum * 100 + segNum;
long long int etime = -1; long long int etime = -1;
long long int tdif = -1; long long int tdif = -1;

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

95
convertElog2CSV.py Normal file
View File

@ -0,0 +1,95 @@
import csv
import os
import re
fcsv = open("test.csv", 'w')
writer = csv.writer(fcsv)
runNumStart = -4
runNumStop = -1
skipID = [11, 12, 29, 36, 208, 296, 297, 298, 299, 300, 301]
for elogID in range(2, 583) :
continueFlag = False
for y in skipID:
if( elogID == y ):
continueFlag = True
break
if( continueFlag ):
continue
runNumber = -4
runStartFlag=False;
runStopFlag=False;
print("===================================== %d" % elogID)
cmd = "elog -h elog.physics.fsu.edu -l elog/2022_05_e21062_FRIB -u GeneralFox fsuphysics888 -w %d > haha.txt" % elogID
#print(cmd)
os.system(cmd)
felog = open("haha.txt", "r")
for x in felog :
#print(x)
posStart = x.find('Type: Run Start')
posStop = x.find('Type: Run End')
posRunNum = x.find('RunNumber:')
if( posStart >= 0 ) :
runStartFlag = True
if( posStop >= 0 ):
runStopFlag = True
if( posRunNum >= 0 and (runStartFlag or runStopFlag) ):
pos = re.search(r"\d", x)
if( pos ):
runNumber = int(x[pos.start():-1])
#print("-- Run Number : |%d|" % runNumber)
print("RunNumber : %d, start : %d, stop : %d " % (runNumber, runStartFlag, runStopFlag))
if( runNumber == -4 ) :
continue
if( posStart == False and posStop == False ) :
continue
msg = x
if( runStartFlag ):
runNumStart = runNumber
dateStart=msg[0:30]
#print("|%s|" % dateStart)
pos=msg.find('Title:')
title=msg[pos+7:-1]
#print("|%s|" % title)
runStartFlag = False
if( runStopFlag ):
runNumStop = runNumber
dateStop=msg[0:30]
#print("|%s|" % dateStop)
runStopFlag = False
felog.close()
if( runNumStart == runNumStop):
print([runNumStart, dateStart,dateStop,title])
writer.writerow([runNumStart, dateStart,dateStop,title])
runNumStart = -4
runNumStop = -1
fcsv.close()

80
convertRoot.sh Executable file
View File

@ -0,0 +1,80 @@
nCore=10;
if [ $# -eq 0 ]; then
echo "Usage: "
echo " ./convertRoot.sh [Start_RunNum] [Stop_RunNum]"
exit;
fi
runNum1=$1
runNum2=$2
for (( runNum=${runNum1}; runNum <=${runNum2}; runNum++)); do
nFile=$(ls -1 rawdata/run${runNum}/run*evt | wc -l)
files=$(ls -1 rawdata/run${runNum}/run*evt)
nLoop=$((${nFile}/nCore+1))
echo "===== number of files in run-${runNum} = ${nFile}"
echo " number of loops = ${nLoop}"
echo "================================================="
i=0
while [[ $i -lt ${nLoop} ]]; do
j=0
while [[ $j -lt ${nCore} ]]; do
SegNum=$((${nCore}*i+j))
if [[ ${SegNum} -ge ${nFile} ]]; then break; fi
#patching the prefix ZERO
if [ $runNum -lt 10 ]; then
runPrefix="000"
elif [ $runNum -lt 100 ]; then
runPrefix="00"
elif [ $runNum -lt 1000 ]; then
runPrefix="0"
fi
#patching the prefix ZERO for segment
if [ $SegNum -lt 10 ]; then
segPrefix="0"
else
segPrefix=""
fi
fileName=rawdata/run${runNum}/run-${runPrefix}${runNum}-${segPrefix}${SegNum}.evt
outFileName=root_data/run-${runPrefix}${runNum}-${segPrefix}${SegNum}.root
if [[ -f ${outFileName} ]]; then
echo "${outFileName} exist. Skip."
else
echo ${fileName}
armory/EventBuilder ${outFileName} 1 250 ${fileName} > /dev/null &
fi
((j += 1))
done
sleep 2
SegNum0=$((${nCore}*i))
SegNum1=$((${nCore}*i + j ))
while true; do
nthings=`ps aux | grep "[E]ventBuilder"| wc -l`
echo $(date)" || "$nthings" EventBuilder are running. $runNum, ${SegNum0}-${SegNum1}"
if [[ $nthings > 0 ]]; then
sleep 10;
else
break
fi
done
((i += 1))
done
done

View File

@ -56,6 +56,7 @@ double TOFCorrection(double energy){
void peachCake::Begin(TTree * /*tree*/){ void peachCake::Begin(TTree * /*tree*/){
TString option = GetOption(); TString option = GetOption();
hCloverID = new TH2F("hCloverID", "Clover; ID; energy [keV]", 52, 0, 52, 400, 0, 2000); hCloverID = new TH2F("hCloverID", "Clover; ID; energy [keV]", 52, 0, 52, 400, 0, 2000);
@ -378,8 +379,10 @@ Bool_t peachCake::Process(Long64_t entry){
if ( flag == 0 ) return kTRUE; if ( flag == 0 ) return kTRUE;
//============================= Save Tree //============================= Save Tree
if( saveNewTree ){
saveFile->cd(); saveFile->cd();
newTree->Fill(); newTree->Fill();
}
return kTRUE; return kTRUE;
} }

View File

@ -47,7 +47,9 @@ public :
TBranch *b_multiplicity_Beam; //! TBranch *b_multiplicity_Beam; //!
TBranch *b_runID; //! TBranch *b_runID; //!
peachCake(TTree * /*tree*/ =0) : fChain(0) { } peachCake(TTree * /*tree*/ =0) : fChain(0) {
saveNewTree = false;
}
virtual ~peachCake() { } virtual ~peachCake() { }
virtual Int_t Version() const { return 2; } virtual Int_t Version() const { return 2; }
virtual void Begin(TTree *tree); virtual void Begin(TTree *tree);
@ -63,9 +65,13 @@ public :
virtual void SlaveTerminate(); virtual void SlaveTerminate();
virtual void Terminate(); virtual void Terminate();
void SaveNewTree(bool YesOrNo){ saveNewTree = YesOrNo;}
ClassDef(peachCake,0); ClassDef(peachCake,0);
//=========== varibales in new tree //=========== varibales in new tree
bool saveNewTree;
TFile * saveFile; TFile * saveFile;
TTree * newTree; TTree * newTree;
TString saveFileName; TString saveFileName;
@ -130,6 +136,9 @@ void peachCake::Init(TTree *tree){
//============ new tree //============ new tree
printf(" is save tree? :%d \n", saveNewTree);
if( saveNewTree ){
saveFileName = "test"; saveFileName = "test";
int oldSeg = -100; int oldSeg = -100;
int numFile = fChain->GetListOfFiles()->GetLast()+1; int numFile = fChain->GetListOfFiles()->GetLast()+1;
@ -175,6 +184,7 @@ void peachCake::Init(TTree *tree){
newTree->Branch("dyBetaTime", dyBetaTime, "dyBetaTime[4]/l"); newTree->Branch("dyBetaTime", dyBetaTime, "dyBetaTime[4]/l");
newTree->Branch("veto_f", &veto_f, "veto_f/D"); newTree->Branch("veto_f", &veto_f, "veto_f/D");
newTree->Branch("veto_r", &veto_r, "veto_r/D"); newTree->Branch("veto_r", &veto_r, "veto_r/D");
}
//==== clock //==== clock
clock.Reset(); clock.Reset();

View File

@ -1,23 +1,34 @@
#include "armory/evtReader.h" ///#include "armory/evtReader.h"
evtReader * evt = new evtReader("run-0238-00.evt", true); ///evtReader * evt = new evtReader("run-0238-00.evt", true);
#include "peachCake.C+"
void script() { void script() {
/*
TChain * chain = new TChain("tree"); TChain * chain = new TChain("tree");
chain->Add("root_data/run-0238-[0-4][0-9].root"); //chain->Add("root_data/run-0237-*.root");
//chain->Add("root_data/run-0238-*.root");
//chain->Add("root_data/run-0241-*.root");
//chain->Add("root_data/run-0244-*.root");
//chain->Add("root_data/run-0246-*.root");
chain->Add("root_data/run-02[3-4][0-9]-00.root");
bool isSaveNewTree = false;
chain->GetListOfFiles()->Print(); chain->GetListOfFiles()->Print();
peachCake * selector = new peachCake();
chain->Process("peachCake.C+"); selector->SaveNewTree(isSaveNewTree);
*/ chain->Process(selector, "");
//gROOT->ProcessLine("armory/nsclEvtReader.h");
///gROOT->ProcessLine("armory/nsclEvtReader.h");
evt->ReadBlock(2); ///evt->ReadBlock(2);
} }