Skip to content

Commit 78a6ec5

Browse files
authored
Merge pull request #7 from hyperk/update_to_WCSim_v1.12.16
Update to compile with WCSim v1.12.16 and new WCTE PMT response
2 parents ecae9f1 + 5e70dcc commit 78a6ec5

12 files changed

Lines changed: 249 additions & 55 deletions

File tree

README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,7 @@ The library provides C++ classes that manage three tasks:
1818
Simple runtime procedures. First set up your ROOT and WCSIM:
1919
```
2020
source your_thisroot.sh
21-
export WCSIMDIR=your_WCSIM_installation
22-
```
23-
If `libWCSimRoot.so` is not directly under `WCSIMDIR`, export to `WCSIMROOTDIR`.
24-
```
25-
export WCSIMROOTDIR=your_libWCSimRoot.so_installation
21+
source your_this_wcsim.sh # or just export WCSIM_BUILD_DIR
2622
```
2723
Then set up the MDT environment.
2824
```
@@ -32,7 +28,7 @@ cd $MDTROOT/app/utilities/WCRootData; make clean; make all
3228
cd $MDTROOT/app/application; make clean; make all
3329
cd $MDTROOT
3430
# edit variables properly in run_test_mdt4wcte.sh
35-
bash run_test_mdt4iwcd.sh
31+
bash run_test_mdt4wcte.sh
3632
```
3733

3834
## IWCD usage

app/application/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ CXX=g++
22
LD=g++
33

44
CXXFLAGS += -Wall -std=c++11 -g $(shell root-config --cflags)\
5-
-I$(WCSIMDIR)/include\
5+
-I$(WCSIM_BUILD_DIR)/include/WCSim\
66
-I${MDTROOT}/cpp/include\
77
-I${WCRDROOT}/include
88

99
LDFLAGS += $(shell root-config --ldflags) $(shell root-config --libs) -lTreePlayer\
10-
-L$(WCSIMROOTDIR) -lWCSimRoot\
10+
-L$(WCSIM_BUILD_DIR)/lib -lWCSimRoot\
1111
-L${MDTROOT}/cpp -lMDT\
1212
-L${WCRDROOT} -lWCRData
1313

app/application/appWCTESingleEvent.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ int main(int argc, char **argv)
4242
// WCTE will use single PMT type, so define the corresponding type of 3-inch PMT
4343
const int NPMTType = 1;
4444
string fPMTType[NPMTType];
45-
fPMTType[0] = "PMT3inchR12199_02";
45+
fPMTType[0] = "PMT3inchR14374_WCTE";
4646

4747
MDTManager *MDT = new MDTManager(fSeed);
48-
MDT->RegisterPMTType(fPMTType[0], new PMTResponse3inchR12199_02());
48+
MDT->RegisterPMTType(fPMTType[0], new Response3inchR14374_WCTE());
4949

5050
const vector<string> listWCRootEvt{"wcsimrootevent"};
5151

app/utilities/WCRootData/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
CXX=g++
22
LD=g++
33

4-
CXXFLAGS += -Wall -O2 -std=c++11 -g -fPIC -I./include $(shell root-config --cflags) -I$(WCSIMDIR)/include -I${MDTROOT}/cpp/include
4+
CXXFLAGS += -Wall -O2 -std=c++11 -g -fPIC -I./include $(shell root-config --cflags) -I$(WCSIM_BUILD_DIR)/include/WCSim -I${MDTROOT}/cpp/include
55
#LDFLAGS += -shared $(shell root-config --ldflags) $(shell root-config --libs) -lTreePlayer -lMinuit2 -L$(WCSIMDIR) -lWCSimRoot -L${MDTROOT}/cpp -lMDT
6-
LDFLAGS += -shared $(shell root-config --ldflags) $(shell root-config --libs) -L$(WCSIMROOTDIR) -lWCSimRoot -L${MDTROOT}/cpp -lMDT
6+
LDFLAGS += -shared $(shell root-config --ldflags) $(shell root-config --libs) -L$(WCSIM_BUILD_DIR)/lib -lWCSimRoot -L${MDTROOT}/cpp -lMDT
77

88
TARGET=libWCRData.so
99

app/utilities/WCRootData/src/WCRootData.cc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ void WCRootData::AddTrueHitsToMDT(HitTubeCollection *hc, PMTResponse *pr, float
9191

9292
th->SetStartTime(aHitTime->GetPhotonStartTime()+intTime);
9393
for(int k=0; k<3; k++){ th->SetStartPosition(k, aHitTime->GetPhotonStartPos(k)); }
94+
th->SetCreatorProcess((int)(aHitTime->GetPhotonCreatorProcess()));
9495
if( !pr->ApplyDE(th) ){ continue; }
9596

9697
(&(*hc)[tubeID])->AddRawPE(th);
@@ -207,6 +208,7 @@ void WCRootData::AddDigiHits(HitTubeCollection *hc, TriggerInfo *ti, int eventID
207208
std::vector<TVector3> photonEndPos;
208209
std::vector<TVector3> photonStartDir;
209210
std::vector<TVector3> photonEndDir;
211+
std::vector<ProcessType_t> photonCreatorProcess;
210212
for(hc->Begin(); !hc->IsEnd(); hc->Next())
211213
{
212214
// Get tube ID
@@ -227,6 +229,7 @@ void WCRootData::AddDigiHits(HitTubeCollection *hc, TriggerInfo *ti, int eventID
227229
photonEndPos.push_back(TVector3(PEs[iPE]->GetPosition(0),PEs[iPE]->GetPosition(1),PEs[iPE]->GetPosition(2)));
228230
photonStartDir.push_back(TVector3(PEs[iPE]->GetStartDirection(0),PEs[iPE]->GetStartDirection(1),PEs[iPE]->GetStartDirection(2)));
229231
photonEndDir.push_back(TVector3(PEs[iPE]->GetDirection(0),PEs[iPE]->GetDirection(1),PEs[iPE]->GetDirection(2)));
232+
photonCreatorProcess.push_back((ProcessType_t)(PEs[iPE]->GetCreatorProcess()));
230233
}
231234

232235
anEvent->AddCherenkovHit(tubeID,
@@ -238,7 +241,8 @@ void WCRootData::AddDigiHits(HitTubeCollection *hc, TriggerInfo *ti, int eventID
238241
photonStartPos,
239242
photonEndPos,
240243
photonStartDir,
241-
photonEndDir);
244+
photonEndDir,
245+
photonCreatorProcess);
242246

243247
truetime.clear();
244248
primaryParentID.clear();
@@ -247,6 +251,7 @@ void WCRootData::AddDigiHits(HitTubeCollection *hc, TriggerInfo *ti, int eventID
247251
photonEndPos.clear();
248252
photonStartDir.clear();
249253
photonEndDir.clear();
254+
photonCreatorProcess.clear();
250255
}
251256
const int nTriggers = ti->GetNumOfTrigger();
252257
for(int iTrig=0; iTrig<nTriggers; iTrig++)
@@ -358,7 +363,7 @@ void WCRootData::AddTracks(const WCSimRootTrigger *aEvtIn, float offset_time, in
358363
Int_t parenttype = aTrack->GetParenttype();
359364
Int_t id = aTrack->GetId();
360365
Int_t idPrnt = aTrack->GetParentId();
361-
366+
ProcessType_t creatorProcess = aTrack->GetCreatorProcess();
362367

363368
Double_t dir[3];
364369
Double_t pdir[3];
@@ -393,6 +398,7 @@ void WCRootData::AddTracks(const WCSimRootTrigger *aEvtIn, float offset_time, in
393398
stop,
394399
start,
395400
parenttype,
401+
creatorProcess,
396402
time,
397403
id,
398404
idPrnt,

cpp/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CXX=g++
22
LD=g++
33

4-
CXXFLAGS += -Wall -O2 -std=c++11 -g -fPIC -I./include
5-
LDFLAGS += -shared
4+
CXXFLAGS += -Wall -O2 -std=c++11 -g -fPIC -I./include $(shell root-config --cflags)
5+
LDFLAGS += -shared $(shell root-config --ldflags) $(shell root-config --libs)
66

77
TARGET=libMDT.so
88
SRCDIR = ./src

cpp/include/PMTResponse.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

33
#include <string>
4+
#include <TGraph.h>
45
#include "MTRandom.h"
56
#include "HitTube.h"
67

@@ -78,3 +79,16 @@ class Response3inchR14374 : public GenericPMTResponse
7879
private:
7980
double fTimeResAt1PE;
8081
};
82+
83+
class Response3inchR14374_WCTE : public GenericPMTResponse
84+
{
85+
public:
86+
Response3inchR14374_WCTE(int, const string &s="");
87+
Response3inchR14374_WCTE();
88+
virtual ~Response3inchR14374_WCTE();
89+
float HitTimeSmearing(float);
90+
void Initialize(int, const string &s="");
91+
92+
private:
93+
TGraph *gTResol = nullptr; // timing resolution
94+
};

cpp/include/TrueHit.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ class TrueHit
1515
float GetStartPosition(int i) const { return fStartPosition[i]; }
1616
float GetStartDirection(int i) const { return fStartDirection[i]; }
1717
int GetPosBin(int i) const { return fBin[i]; }
18+
int GetCreatorProcess() const { return fCreatorProcess; }
1819

1920
void SetPosition(int i, float f) { fPosition[i] = f; }
2021
void SetDirection(int i, float f) { fDirection[i] = f; }
2122
void SetStartTime(float f) { fStartTime = f; }
2223
void SetStartPosition(int i, float f) { fStartPosition[i] = f; }
2324
void SetStartDirection(int i, float f) { fStartDirection[i] = f; }
2425
void SetPosBin(int i, int b){ fBin[i] = b; }
26+
void SetCreatorProcess(int i){ fCreatorProcess = i; }
2527

2628
private:
2729
double fTime;
@@ -32,4 +34,5 @@ class TrueHit
3234
float fStartDirection[3]; // Photon track initial direction
3335
int fParentId;
3436
int fBin[3];
37+
int fCreatorProcess;
3538
};

cpp/src/PMTResponse.cc

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,3 +229,78 @@ float Response3inchR14374::HitTimeSmearing(float Q)
229229
float timingResolution = 0.6*fSclFacTTS;
230230
return fRand->Gaus(0., timingResolution);
231231
}
232+
233+
///////////////////////////////////////////////////////////////////
234+
///////////////////////////////////////////////////////////////////
235+
Response3inchR14374_WCTE::Response3inchR14374_WCTE(int seed, const string &pmtname)
236+
{
237+
double charge[14] =
238+
{
239+
0.2, 0.4, 0.6, 0.8, 1.0,
240+
1.2, 1.4, 1.6, 1.8, 2.0,
241+
2.5, 3.0, 3.5, 4.0
242+
};
243+
double resol[14] =
244+
{
245+
1.1654, 0.61088, 0.4186, 0.32532, 0.26484,
246+
0.23084, 0.20969, 0.19297, 0.17716, 0.17046,
247+
0.15455, 0.1427, 0.13699, 0.13229
248+
};
249+
gTResol = new TGraph(14,charge,resol);
250+
251+
this->Initialize(seed, pmtname);
252+
}
253+
254+
Response3inchR14374_WCTE::Response3inchR14374_WCTE()
255+
{
256+
double charge[14] =
257+
{
258+
0.2, 0.4, 0.6, 0.8, 1.0,
259+
1.2, 1.4, 1.6, 1.8, 2.0,
260+
2.5, 3.0, 3.5, 4.0
261+
};
262+
double resol[14] =
263+
{
264+
1.1654, 0.61088, 0.4186, 0.32532, 0.26484,
265+
0.23084, 0.20969, 0.19297, 0.17716, 0.17046,
266+
0.15455, 0.1427, 0.13699, 0.13229
267+
};
268+
gTResol = new TGraph(14,charge,resol);
269+
}
270+
271+
Response3inchR14374_WCTE::~Response3inchR14374_WCTE()
272+
{
273+
delete gTResol;
274+
}
275+
276+
void Response3inchR14374_WCTE::Initialize(int seed, const string &pmtname)
277+
{
278+
fPMTType = pmtname;
279+
fRand = new MTRandom(seed);
280+
281+
map<string, string> s;
282+
s["ScalFactorTTS"] = "ScalFactorTTS";
283+
s["SPECDFFile"] = "SPECDFFile";
284+
if( fPMTType!="" )
285+
{
286+
map<string, string>::iterator i;
287+
for(i=s.begin(); i!=s.end(); i++)
288+
{
289+
i->second += "_" + fPMTType;
290+
}
291+
}
292+
Configuration *Conf = Configuration::GetInstance();
293+
Conf->GetValue<float>(s["ScalFactorTTS"], fSclFacTTS);
294+
Conf->GetValue<string>(s["SPECDFFile"], fTxtFileSPECDF);
295+
this->LoadCDFOfSPE(fTxtFileSPECDF);
296+
}
297+
298+
float Response3inchR14374_WCTE::HitTimeSmearing(float Q)
299+
{
300+
float pmt_tts = 1.5;
301+
if (Q>4.0) Q = 4.0; // limit Q to valid range
302+
float val = gTResol->Eval(Q,0,"S");
303+
float timingResolution = sqrt(pmt_tts*pmt_tts+val*val)/2.355; // conversion from FWHM to sigma
304+
timingResolution *= fSclFacTTS;
305+
return fRand->Gaus(0.0,timingResolution);
306+
}

envMDT.sh

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if [ -n "${MDTROOT}" ] ; then
2727
drop_from_path "$LD_LIBRARY_PATH" "${old_mdtroot}/cpp"
2828
LD_LIBRARY_PATH=$newpath
2929

30-
drop_from_path "$LD_LIBRARY_PATH" "${WCSIMROOTDIR}"
30+
drop_from_path "$LD_LIBRARY_PATH" "${WCSIM_BUILD_DIR}/lib"
3131
LD_LIBRARY_PATH=$newpath
3232

3333
drop_from_path "$LD_LIBRARY_PATH" "${WCRDROOT}"
@@ -59,18 +59,15 @@ else
5959
fi
6060

6161
#--- WCSim
62-
if [[ -z "${WCSIMDIR}" ]]; then
63-
echo "WCSIMDIR not set. Exit!"
62+
if [[ -z "${WCSIM_BUILD_DIR}" ]]; then
63+
echo "WCSIM_BUILD_DIR not set. Exit!"
6464
return
6565
else
66-
echo "Using WCSIM installed in $WCSIMDIR"
66+
echo "Using WCSIM installed in $WCSIM_BUILD_DIR"
6767
#export LD_LIBRARY_PATH=${WCSIMDIR}:$LD_LIBRARY_PATH
6868

69-
if [[ -z "${WCSIMROOTDIR}" ]]; then
70-
WCSIMROOTDIR=$WCSIMDIR
71-
fi
72-
echo "Using libWCSimRoot.so installed in $WCSIMROOTDIR"
73-
export LD_LIBRARY_PATH=${WCSIMROOTDIR}:$LD_LIBRARY_PATH
69+
echo "Using libWCSimRoot.so installed in $WCSIM_BUILD_DIR/lib"
70+
export LD_LIBRARY_PATH=${WCSIM_BUILD_DIR}/lib:$LD_LIBRARY_PATH
7471
fi
7572

7673
#--- MDT's utility

0 commit comments

Comments
 (0)