edited runID in EventBuilder
This commit is contained in:
parent
c72851bd4e
commit
e8d802a268
8
.gitignore
vendored
8
.gitignore
vendored
|
@ -4,8 +4,16 @@
|
|||
*.root
|
||||
*.evt
|
||||
|
||||
root_data
|
||||
EventBuilder
|
||||
legacy_code
|
||||
nscl2pixie
|
||||
nscl2pixie_haha
|
||||
ev22txt
|
||||
EventBuilder_evt
|
||||
evt2hist
|
||||
MergeEVT
|
||||
|
||||
*.csv
|
||||
|
||||
*_C_ACLiC_*
|
||||
|
|
|
@ -116,12 +116,16 @@ int main(int argc, char **argv) {
|
|||
|
||||
int pos = inFileName[i].Last('/');
|
||||
TString temp = inFileName[i];
|
||||
temp.Remove(0, pos+1);
|
||||
pos = temp.Last('-');
|
||||
temp.Remove(0, pos+1);
|
||||
pos = temp.Last('.');
|
||||
temp.Remove(pos);
|
||||
runID = atoi(temp.Data());
|
||||
temp.Remove(0, pos+1); /// run-XXXX-XX.evt
|
||||
TString runNumStr = temp;
|
||||
runNumStr.Remove(8);
|
||||
runNumStr.Remove(0,4);
|
||||
int runNum = atoi(runNumStr);
|
||||
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 tdif = -1;
|
||||
|
|
Binary file not shown.
BIN
armory/MergeEVT
BIN
armory/MergeEVT
Binary file not shown.
BIN
armory/ev22txt
BIN
armory/ev22txt
Binary file not shown.
BIN
armory/evt2hist
BIN
armory/evt2hist
Binary file not shown.
95
convertElog2CSV.py
Normal file
95
convertElog2CSV.py
Normal 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
80
convertRoot.sh
Executable 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
|
|
@ -56,6 +56,7 @@ double TOFCorrection(double energy){
|
|||
|
||||
|
||||
void peachCake::Begin(TTree * /*tree*/){
|
||||
|
||||
TString option = GetOption();
|
||||
|
||||
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;
|
||||
|
||||
//============================= Save Tree
|
||||
saveFile->cd();
|
||||
newTree->Fill();
|
||||
if( saveNewTree ){
|
||||
saveFile->cd();
|
||||
newTree->Fill();
|
||||
}
|
||||
|
||||
return kTRUE;
|
||||
}
|
||||
|
|
100
peachCake.h
100
peachCake.h
|
@ -47,7 +47,9 @@ public :
|
|||
TBranch *b_multiplicity_Beam; //!
|
||||
TBranch *b_runID; //!
|
||||
|
||||
peachCake(TTree * /*tree*/ =0) : fChain(0) { }
|
||||
peachCake(TTree * /*tree*/ =0) : fChain(0) {
|
||||
saveNewTree = false;
|
||||
}
|
||||
virtual ~peachCake() { }
|
||||
virtual Int_t Version() const { return 2; }
|
||||
virtual void Begin(TTree *tree);
|
||||
|
@ -63,9 +65,13 @@ public :
|
|||
virtual void SlaveTerminate();
|
||||
virtual void Terminate();
|
||||
|
||||
void SaveNewTree(bool YesOrNo){ saveNewTree = YesOrNo;}
|
||||
|
||||
ClassDef(peachCake,0);
|
||||
|
||||
//=========== varibales in new tree
|
||||
bool saveNewTree;
|
||||
|
||||
TFile * saveFile;
|
||||
TTree * newTree;
|
||||
TString saveFileName;
|
||||
|
@ -130,51 +136,55 @@ void peachCake::Init(TTree *tree){
|
|||
|
||||
|
||||
//============ new tree
|
||||
saveFileName = "test";
|
||||
int oldSeg = -100;
|
||||
int numFile = fChain->GetListOfFiles()->GetLast()+1;
|
||||
for( int i = 0; i < numFile; i++){
|
||||
TString name = fChain->GetListOfFiles()->At(i)->GetTitle();
|
||||
int pos = name.Last('/');
|
||||
name = name.Remove(0,pos+1); //this should be run-XXXX-XX.root
|
||||
if( i == 0 ) {
|
||||
saveFileName = name;
|
||||
pos = saveFileName.Last('-');
|
||||
saveFileName = saveFileName.Remove(pos); //run-XXXX
|
||||
}
|
||||
pos = name.Last('-');
|
||||
int segNum = atoi(name.Remove(0, pos+1).Remove(2));
|
||||
if( oldSeg == -100 ) oldSeg = segNum;
|
||||
saveFileName = saveFileName + Form("_%02d",segNum);
|
||||
if( segNum == oldSeg + 1 && i != numFile -1 ){
|
||||
int len = saveFileName.Length();
|
||||
saveFileName = saveFileName.Remove(len - 3);
|
||||
oldSeg = segNum;
|
||||
}
|
||||
printf(" is save tree? :%d \n", saveNewTree);
|
||||
|
||||
if( saveNewTree ){
|
||||
saveFileName = "test";
|
||||
int oldSeg = -100;
|
||||
int numFile = fChain->GetListOfFiles()->GetLast()+1;
|
||||
for( int i = 0; i < numFile; i++){
|
||||
TString name = fChain->GetListOfFiles()->At(i)->GetTitle();
|
||||
int pos = name.Last('/');
|
||||
name = name.Remove(0,pos+1); //this should be run-XXXX-XX.root
|
||||
if( i == 0 ) {
|
||||
saveFileName = name;
|
||||
pos = saveFileName.Last('-');
|
||||
saveFileName = saveFileName.Remove(pos); //run-XXXX
|
||||
}
|
||||
pos = name.Last('-');
|
||||
int segNum = atoi(name.Remove(0, pos+1).Remove(2));
|
||||
if( oldSeg == -100 ) oldSeg = segNum;
|
||||
saveFileName = saveFileName + Form("_%02d",segNum);
|
||||
if( segNum == oldSeg + 1 && i != numFile -1 ){
|
||||
int len = saveFileName.Length();
|
||||
saveFileName = saveFileName.Remove(len - 3);
|
||||
oldSeg = segNum;
|
||||
}
|
||||
}
|
||||
saveFileName = saveFileName + ".root";
|
||||
|
||||
printf("=========== saveFile : %s \n", saveFileName.Data());
|
||||
|
||||
saveFile = new TFile(saveFileName, "recreate");
|
||||
newTree = new TTree("tree", "tree");
|
||||
|
||||
newTree->Branch("eventID", &eventID, "eventID/l");
|
||||
//newTree->Branch("runID", &runID, "runID/I");
|
||||
newTree->Branch("TOF", &TOF, "TOF/D");
|
||||
newTree->Branch("energy", &energy, "energy/D");
|
||||
newTree->Branch("crossTime", &crossTime, "crossTime/l");
|
||||
newTree->Branch("crossEnergy", &crossEnergy, "crossEnergy/i");
|
||||
newTree->Branch("flag", &flag, "flag/S");
|
||||
newTree->Branch("vetoFlag", &vetoFlag, "vetoFlag/S");
|
||||
newTree->Branch("xIons", &xIons, "xIons/D");
|
||||
newTree->Branch("yIons", &yIons, "yIons/D");
|
||||
newTree->Branch("xBeta", &xBeta, "xBeta/D");
|
||||
newTree->Branch("yBeta", &yBeta, "yBeta/D");
|
||||
newTree->Branch("dyIonsTime", dyIonsTime, "dyIonsTime[4]/l");
|
||||
newTree->Branch("dyBetaTime", dyBetaTime, "dyBetaTime[4]/l");
|
||||
newTree->Branch("veto_f", &veto_f, "veto_f/D");
|
||||
newTree->Branch("veto_r", &veto_r, "veto_r/D");
|
||||
}
|
||||
saveFileName = saveFileName + ".root";
|
||||
|
||||
printf("=========== saveFile : %s \n", saveFileName.Data());
|
||||
|
||||
saveFile = new TFile(saveFileName, "recreate");
|
||||
newTree = new TTree("tree", "tree");
|
||||
|
||||
newTree->Branch("eventID", &eventID, "eventID/l");
|
||||
//newTree->Branch("runID", &runID, "runID/I");
|
||||
newTree->Branch("TOF", &TOF, "TOF/D");
|
||||
newTree->Branch("energy", &energy, "energy/D");
|
||||
newTree->Branch("crossTime", &crossTime, "crossTime/l");
|
||||
newTree->Branch("crossEnergy", &crossEnergy, "crossEnergy/i");
|
||||
newTree->Branch("flag", &flag, "flag/S");
|
||||
newTree->Branch("vetoFlag", &vetoFlag, "vetoFlag/S");
|
||||
newTree->Branch("xIons", &xIons, "xIons/D");
|
||||
newTree->Branch("yIons", &yIons, "yIons/D");
|
||||
newTree->Branch("xBeta", &xBeta, "xBeta/D");
|
||||
newTree->Branch("yBeta", &yBeta, "yBeta/D");
|
||||
newTree->Branch("dyIonsTime", dyIonsTime, "dyIonsTime[4]/l");
|
||||
newTree->Branch("dyBetaTime", dyBetaTime, "dyBetaTime[4]/l");
|
||||
newTree->Branch("veto_f", &veto_f, "veto_f/D");
|
||||
newTree->Branch("veto_r", &veto_r, "veto_r/D");
|
||||
|
||||
//==== clock
|
||||
clock.Reset();
|
||||
|
|
31
script.C
31
script.C
|
@ -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() {
|
||||
|
||||
/*
|
||||
|
||||
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->Process("peachCake.C+");
|
||||
*/
|
||||
peachCake * selector = new peachCake();
|
||||
selector->SaveNewTree(isSaveNewTree);
|
||||
chain->Process(selector, "");
|
||||
|
||||
|
||||
//gROOT->ProcessLine("armory/nsclEvtReader.h");
|
||||
|
||||
|
||||
evt->ReadBlock(2);
|
||||
///gROOT->ProcessLine("armory/nsclEvtReader.h");
|
||||
///evt->ReadBlock(2);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user