Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated changes from main #14

Open
wants to merge 54 commits into
base: new_event_builder
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
6fc2e03
Read Simple Reco info to PhaseIITreeMaker and updated Reweight Tool (…
jminock Aug 5, 2024
144875a
PMT timing offsets, new hit timing method, and changes to ClusterFind…
S81D Aug 5, 2024
fa6a435
A minor fix and an addition for the Energy Reconstruction toolchains …
alxkon13 Aug 5, 2024
c7d7225
Improved clarity of the load and save operation of the RingCounting t…
s4294967296 Aug 5, 2024
a2b8ece
Updated to read in new ANNIE flux histograms (#270)
jminock Aug 12, 2024
c12b01e
Added RingCounting Variables to PhaseIITreeMaker (#269)
jminock Aug 12, 2024
5e2beb1
Update Makefile (#271)
marvlad Aug 12, 2024
53828d0
BeamFetcherV2 tool changes (#273)
S81D Aug 16, 2024
597c9e8
Reduce cluster window from 50 to 40ns (#275)
S81D Sep 9, 2024
8559aa0
PMT 416 hit "leakage" (#276)
S81D Sep 9, 2024
2a9d03d
Add MC "pulse" width as a configuration variable (#279)
S81D Sep 23, 2024
ff86893
Beam Database query tool change to save all entries (#274)
S81D Sep 23, 2024
b8673ed
AnnieGeom Distance to Tank: fixed y and z convention (#283)
jminock Oct 7, 2024
791a160
Updated Fiducial Volume from ANNIEGeometry to be usable and use corre…
jminock Oct 7, 2024
56c375a
BackTracker tool for linking reco MC clusters to the MCParticle that …
atcsutton Oct 7, 2024
ca22bc5
deleted second application of GReWeightResonanceDecay calculator (#299)
leehagaman Oct 7, 2024
2049927
Adding torch Python package to container (#300)
jminock Oct 7, 2024
5730477
Added additional GENIE info including FS PDGs and momentum, energy an…
jminock Nov 11, 2024
339ad78
Added additional GENIE info to LoadReweightGenieEvent including FS PD…
jminock Nov 11, 2024
9957100
Added additional GENIE info to PhaseIITreeMaker (#282)
jminock Nov 11, 2024
e29a1be
Update Setup.sh (#313)
S81D Nov 11, 2024
774f3b1
ADC hit time fix (#314)
S81D Nov 11, 2024
c2be2f8
Andrew's new BeamQuality tool (#287)
S81D Nov 11, 2024
2e1e018
EventBuilder toolchain to include Beam information (#303)
S81D Nov 11, 2024
eff6d84
Add check for TriggerWord being set (#311)
rory42edwards Nov 15, 2024
ae71732
RWM + BRF fittting tool (#289)
S81D Nov 15, 2024
d1024ca
TriggerDataDecoder and MRDTracks minor bug fix (#292)
S81D Nov 15, 2024
527ebcb
Added MuonFitter Tool (#293)
jminock Nov 15, 2024
533962a
Create pull_request_template.md
marc1uk Nov 15, 2024
3fc9a21
Update pull_request_template.md
marc1uk Nov 15, 2024
decb4cc
Add BeamFetcherV2 toolchain (#297)
S81D Nov 18, 2024
1188842
Add files via upload (#298)
S81D Nov 18, 2024
5f7634d
Update LoadRawData.cpp (#301)
S81D Nov 18, 2024
3120be3
LoadRawData tool changes to handle LAPPDs (#302)
S81D Nov 18, 2024
5cb8e45
AssignBunchTimingMC tool to add the BNB spill structure to MC cluster…
S81D Nov 18, 2024
62910f6
Add bunchTimes to PhaseIITreeMaker (#305)
S81D Nov 18, 2024
b1d0be9
New PrintDQ tool for DataQuality monitoring of processed beam runs (#…
S81D Nov 18, 2024
88afcec
MuonFitter RNNFit model scripts (#290)
jminock Nov 19, 2024
de2db55
PrintDQ toolchain (#315)
S81D Nov 25, 2024
f1cfada
Minimal Toolchain for MuonFitter (#316)
jminock Nov 25, 2024
13289a7
Updated NeutronMultiplicity Tool according to Julie (#291)
jminock Nov 26, 2024
29969e3
Added config files for MuonFitter to CC_MC_RECO_ntuple Toolchain (#294)
jminock Nov 26, 2024
0b1f89f
Added README's for MuonFitter (#295)
jminock Nov 26, 2024
30a9cb9
Added documentation regarding model generation. Updated paths in Data…
jminock Nov 26, 2024
db4358b
Added MuonFitter updates to PhaseIITreeMaker (#296)
jminock Nov 26, 2024
0d9aca0
Added ensemble support for RingCounting tool. (#278)
s4294967296 Nov 26, 2024
17eeb30
LAPPD_EB tool chain (#310)
fengyvoid Nov 27, 2024
536de96
LAPPDProcessedAna (#309)
fengyvoid Nov 27, 2024
f4a5486
Update ClusterFinderConfig - expand MC pulse width (#322)
S81D Dec 16, 2024
acd73f3
AssignBunchTimingMC tool + config file changes (#323)
S81D Dec 16, 2024
968f02d
Add FitRWMWaveform to Unity + Factory (#326)
S81D Dec 16, 2024
0bc220f
Revert PR #278 "Added ensemble support for RingCounting tool." (#327)
marc1uk Dec 17, 2024
4a88c36
Add csv file output to PrintDQ (#328)
S81D Dec 20, 2024
5b3a549
Do not add event time for unsmeared hits (#331)
S81D Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Describe your changes

## Checklist before submitting your PR
- [ ] This PR implements a single change (one new/modified Tool, or a set of changes to implement one new/modified feature)
- [ ] This PR alters the minimum number of files to affect this change
- [ ] If this PR includes a new Tool, a README and minimal demonstration ToolChain is provided
- [ ] If a new Tool/ToolChain requires model or configuration files, their paths are not hard-coded, and means of generating those files is described in the readme, with examples provided on /pnfs/annie/persistent
- [ ] For every `new` usage, there is a reason the data must be on the heap
- [ ] For every `new` there is a `delete`, unless I explicitly know why (e.g. ROOT or a BoostStore takes ownership)

## Additional Material
Attach any validation or demonstration files here. You may also link to relavant docdb articles.
55 changes: 28 additions & 27 deletions DataModel/ANNIEGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ void ANNIEGeometry::SetGeometry(){
//WCSim
fCylRadius = 152.0; //cm
fCylLength = 396.0; //cm
fCylFiducialRadius = 0.0;
fCylFiducialLength = 0.0;
fCylFiducialRadius = 100.0; //cm
fCylFiducialLength = 200.0; //cm
fXoffset = 0.0;
fYoffset = 0.0;
fZoffset = 0.0;
Expand Down Expand Up @@ -337,11 +337,11 @@ bool ANNIEGeometry::InsideDetector(double x, double y, double z)
bool ANNIEGeometry::InsideFiducialVolume(double x, double y, double z)
{
if( fGeoType==ANNIEGeometry::kCylinder ){
if( z>=-0.5*fCylFiducialLength && z<=+0.5*fCylFiducialLength
&& x*x+y*y<=fCylFiducialRadius*fCylFiducialRadius ){
if( y>=-0.5*fCylFiducialLength && y<=+0.5*fCylFiducialLength
&& x*x+z*z<=fCylFiducialRadius*fCylFiducialRadius ){
return 1;
}
} else std::cout<<"WTF ANNIE Should Be A Cylinder!!!!"<<std::endl;
} else std::cout<<"WTH ANNIE Should Be A Cylinder!!!!"<<std::endl;

return 0;
}
Expand Down Expand Up @@ -377,42 +377,43 @@ double ANNIEGeometry::DistanceToEdge(double x, double y, double z)
double dr = 0.0;
if( fCylRadius>dr ) dr = fCylRadius;
if( 0.5*fCylLength>dr ) dr = 0.5*fCylLength;
if( -sqrt(x*x+y*y)+fCylRadius<dr ) dr = -sqrt(x*x+y*y)+fCylRadius;
if( -z+0.5*fCylLength<dr ) dr = -z+0.5*fCylLength;
if( +z+0.5*fCylLength<dr ) dr = +z+0.5*fCylLength;
if( -sqrt(x*x+z*z)+fCylRadius<dr ) dr = -sqrt(x*x+z*z)+fCylRadius;
if( -y+0.5*fCylLength<dr ) dr = -y+0.5*fCylLength;
if( y+0.5*fCylLength<dr ) dr = y+0.5*fCylLength;
return dr;
}

// outside detector (convention: -ve dr)
else{

// side region
if( z>=-0.5*fCylLength && z<=+0.5*fCylLength ){
return -sqrt(x*x+y*y)+fCylRadius;
if( y>=-0.5*fCylLength && y<=+0.5*fCylLength ){
return -sqrt(x*x+z*z)+fCylRadius;
}

// top region
if( z<=-0.5*fCylLength
&& x*x+y*y<fCylRadius*fCylRadius ){
return +z+0.5*fCylLength;
// below tank
if( y<=-0.5*fCylLength
&& x*x+z*z<fCylRadius*fCylRadius ){
return y+0.5*fCylLength;
}
if( z>=+0.5*fCylLength
&& x*x+y*y<fCylRadius*fCylRadius ){
return -z+0.5*fCylLength;
// above tank
if( y>=+0.5*fCylLength
&& x*x+z*z<fCylRadius*fCylRadius ){
return -y+0.5*fCylLength;
}

// corner regions
if( z>=+0.5*fCylLength
&& x*x+y*y>=fCylRadius ){
double dr = sqrt(x*x+y*y)-fCylRadius;
double dz = -z+0.5*fCylLength;
return -sqrt(dr*dr+dz*dz);
if( y>=+0.5*fCylLength
&& x*x+z*z>=fCylRadius ){
double dr = sqrt(x*x+z*z)-fCylRadius;
double dy = -y+0.5*fCylLength;
return -sqrt(dr*dr+dy*dy);
}
if( z<=-0.5*fCylLength
&& x*x+y*y>=fCylRadius ){
double dr = sqrt(x*x+y*y)-fCylRadius;
double dz = +z+0.5*fCylLength;
return -sqrt(dr*dr+dz*dz);
if( y<=-0.5*fCylLength
&& x*x+z*z>=fCylRadius ){
double dr = sqrt(x*x+z*z)-fCylRadius;
double dy = y+0.5*fCylLength;
return -sqrt(dr*dr+dy*dy);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions GetToolDAQ.sh
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ then
pip3 install uproot==4.3.7
pip3 install xgboost==1.6.2
pip3 install tensorflow==2.10.0
pip3 install torch==1.12.1
pip3 install PyQt5
# set tensorflow verbosity to suppress info messages about not having a GPU or maximal acceleration
# https://stackoverflow.com/questions/35911252/disable-tensorflow-debugging-information/42121886#42121886
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ clean:
rm -f include/*.h
rm -f lib/*.so
rm -f Analyse
rm -f UserTools/*/*.o
find UserTools/* -type f -name '*.o' -follow -writable -delete
rm -f DataModel/*.o
rm -f DataModel/DataModel_Linkdef.hh
rm -f DataModel/DataModel_RootDict*
Expand Down
4 changes: 3 additions & 1 deletion Setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

ToolDAQapp=`pwd`

ulimit -n 4096

export LIBGL_ALWAYS_INDIRECT=1

source ${ToolDAQapp}/ToolDAQ/root-6.24.06/install/bin/thisroot.sh
Expand All @@ -24,7 +26,7 @@ export PATH=${ToolDAQapp}/ToolDAQ/LHAPDF-6.3.0/install/bin:$GENIE/bin:$GENIE_REW
export PATH=/ToolAnalysis/ToolDAQ/fsplit:$PATH
export TF_CPP_MIN_LOG_LEVEL=2

export FW_SEARCH_PATH=${ToolDAQapp}/UserTools/ReweightEventsGenie
export FW_SEARCH_PATH=${ToolDAQapp}/UserTools/ReweightFlux

for folder in `ls -d ${PWD}/UserTools/*/ `
do
Expand Down
245 changes: 245 additions & 0 deletions UserTools/AssignBunchTimingMC/AssignBunchTimingMC.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
#include "AssignBunchTimingMC.h"

AssignBunchTimingMC::AssignBunchTimingMC():Tool(){}

//------------------------------------------------------------------------------

bool AssignBunchTimingMC::Initialise(std::string configfile, DataModel &data){

// Get configuration variables and set default values if necessary

if ( !configfile.empty() ) m_variables.Initialise(configfile);
m_data = &data;

bool got_verbosity = m_variables.Get("verbosity", verbosity);
bool got_width = m_variables.Get("bunchwidth", fbunchwidth);
bool got_interval = m_variables.Get("bunchinterval", fbunchinterval);
bool got_count = m_variables.Get("bunchcount", fbunchcount);
bool got_sample = m_variables.Get("sampletype", fsample);
bool got_trigger = m_variables.Get("prompttriggertime", ftriggertime);

if (!got_verbosity) {
verbosity = 0;
logmessage = "Warning (AssignBunchTimingMC): \"verbosity\" not set in the config, defaulting to 0";
Log(logmessage, v_warning, verbosity);
}


// default bunch parameters from MicroBooNE paper: https://doi.org/10.1103/PhysRevD.108.052010

if (!got_width) {
fbunchwidth = 1.308; // ns
logmessage = ("Warning (AssignBunchTimingMC): \"bunchwidth\" not "
"set in the config file. Using default: 1.308ns");
Log(logmessage, v_warning, verbosity);
}

if (!got_interval) {
fbunchinterval = 18.936; // ns
logmessage = ("Warning (AssignBunchTimingMC): \"bunchinterval\" not "
"set in the config file. Using default: 18.936ns");
Log(logmessage, v_warning, verbosity);
}

if (!got_count) {
fbunchwidth = 81;
logmessage = ("Warning (AssignBunchTimingMC): \"bunchcount\" not "
"set in the config file. Using default: 81");
Log(logmessage, v_warning, verbosity);
}

if (!got_sample) {
fsample = 0; // assume they are using the Tank samples
logmessage = ("Warning (AssignBunchTimingMC): \"sampletype\" not "
"set in the config file. Using default: 0 (GENIE tank samples)");
Log(logmessage, v_warning, verbosity);
}

if (!got_trigger) {
ftriggertime = 0; // assume they are using the old WCSim prompt trigger time (t = 0, first particle arrival)
logmessage = ("Warning (AssignBunchTimingMC): \"prompttriggertime\" not "
"set in the config file. Using default: 0 (WCSim prompt trigger time = 0)");
Log(logmessage, v_warning, verbosity);
}


if (verbosity >= v_message) {
std::cout<<"------------------------------------"<<"\n";
std::cout<<"AssignBunchTimingMC: Config settings"<<"\n";
std::cout<<"------------------------------------"<<"\n";
std::cout<<"bunch width = "<<fbunchwidth<<" ns"<<"\n";
std::cout<<"bunch interval = "<<fbunchinterval<<" ns"<<"\n";
std::cout<<"number of bunches = "<<fbunchcount<<"\n";
std::cout<<"sample type = "<<(fsample == 0 ? "(0) Tank" : "(1) World")<<"\n";
std::cout<<"trigger time = "<<(ftriggertime == 0 ? "(0) prompt trigger starts when first particle arrives (default WCSim)"
: "(1) prompt trigger starts at beam dump (modified WCSim)")<<"\n";
}

fbunchTimes = new std::map<double, double>; // set up pointer; Store will handle deletion in Finalize

return true;
}

//------------------------------------------------------------------------------


bool AssignBunchTimingMC::Execute()
{

if (verbosity >= v_debug) {
std::cout << "AssignBunchTimingMC: Executing tool..." << std::endl;
}

if (!LoadStores()) // Load info from store
return false;
if (verbosity >= v_debug) {
std::cout << "AssignBunchTimingMC: Store info loading successful" << std::endl;
}

fbunchTimes->clear(); // clear map

BNBtiming(); // grab BNB structure
if (verbosity >= v_debug) {
std::cout << "AssignBunchTimingMC: BNB timing successful" << std::endl;
}

for (std::pair<double, std::vector<MCHit>>&& apair : *fClusterMapMC) {
double totalHitTime = 0;
int hitCount = 0;
int totalHits = apair.second.size();

CalculateClusterAndBunchTimes(apair.second, totalHitTime, hitCount, totalHits);

// store the cluster time in a map (e.g., keyed by cluster identifier)
fbunchTimes->emplace(apair.first, bunchTime);
}

if (verbosity >= v_debug) {
std::cout << "AssignBunchTimingMC: Assigned bunch time successfully. Writing to Store..." << std::endl;
}

// send to store
m_data->Stores.at("ANNIEEvent")->Set("bunchTimes", fbunchTimes);

return true;

}


//------------------------------------------------------------------------------

bool AssignBunchTimingMC::Finalise()
{
return true;
}

//------------------------------------------------------------------------------




bool AssignBunchTimingMC::LoadStores()
{
// grab necessary information from Stores

bool get_MCClusters = m_data->CStore.Get("ClusterMapMC", fClusterMapMC);
if (!get_MCClusters) {
Log("AssignBunchTimingMC: no ClusterMapMC in the CStore! Are you sure you ran the ClusterFinder tool?", v_error, verbosity);
return false;
}

bool get_AnnieEvent = m_data->Stores.count("ANNIEEvent");
if (!get_AnnieEvent) {
Log("AssignBunchTimingMC: no ANNIEEvent store!", v_error, verbosity);
return false;
}

bool get_MCHits = m_data->Stores.at("ANNIEEvent")->Get("MCHits", fMCHitsMap);
if (!get_MCHits) {
Log("AssignBunchTimingMC: no MCHits in the ANNIEEvent!", v_error, verbosity);
return false;
}

bool get_neutrino_vtxt = m_data->Stores["GenieInfo"]->Get("NuIntxVtx_T",TrueNuIntxVtx_T); // grab neutrino interaction time
if (!get_neutrino_vtxt) {
Log("AssignBunchTimingMC: no GENIE neutrino interaction time info in the ANNIEEvent! Are you sure you ran the LoadGENIEEvent tool?", v_error, verbosity);
return false;
}

return true;
}


//------------------------------------------------------------------------------


void AssignBunchTimingMC::BNBtiming()
{
// Determined from GENIE samples (as of Dec 2024)
const double tank_time = 33.0; // Tank neutrino arrival time: 33ns
const double world_time = 33.0; // WORLD neutrino arrival time: 33ns (As of Dec 2024, World samples have not yet been re-produced fully)

if (ftriggertime == 0) {
new_nu_time = (fsample == 0) ? (TrueNuIntxVtx_T - tank_time) : (TrueNuIntxVtx_T - world_time);
} else if (ftriggertime == 1) {
new_nu_time = (fsample == 0) ? -tank_time : -world_time;
}

// seed random number generator with the current time
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
generator.seed(seed);
if (verbosity >= v_debug) {
std::cout << "AssignBunchTimingMC: Random seed selected: " << seed << std::endl;
}


// per event, assign BNB structure (random bunch number + jitter based on intrinsic bunch width + new_nu_time)
bunchNumber = rand() % fbunchcount;
std::normal_distribution<double> distribution(0, fbunchwidth);
jitter = distribution(generator);

if (verbosity >= v_message) {
std::string logmessage = "AssignBunchTimingMC: bunchNumber = " + std::to_string(bunchNumber) + " | t0 = " + std::to_string(new_nu_time);
Log(logmessage, v_debug, verbosity);
}

}


//------------------------------------------------------------------------------


void AssignBunchTimingMC::CalculateClusterAndBunchTimes(std::vector<MCHit> const &mchits, double &totalHitTime, int &hitCount, int &totalHits)
{

// loop over the hits to get their times
for (auto mchit : mchits) {
double hitTime = mchit.GetTime();
totalHitTime += hitTime;
hitCount++;
if (verbosity >= v_debug) {
std::string logmessage = "AssignBunchTimingMC: (" + std::to_string(hitCount) + "/" + std::to_string(totalHits) + ") MCHit time = " + std::to_string(hitTime);
Log(logmessage, v_debug, verbosity);
}
}

// find nominal cluster time (average hit time)
double clusterTime = (hitCount > 0) ? totalHitTime / hitCount : -9999;
if (verbosity >= v_debug) {
std::string logmessage = "AssignBunchTimingMC: ClusterTime = " + std::to_string(clusterTime);
Log(logmessage, v_debug, verbosity);
}

// calculate BunchTime
bunchTime = fbunchinterval * bunchNumber + clusterTime + jitter + new_nu_time ;
if (verbosity >= v_debug) {
std::string logmessage = "AssignBunchTimingMC: bunchTime = " + std::to_string(bunchTime);
Log(logmessage, v_debug, verbosity);
}

}


//------------------------------------------------------------------------------

// done
Loading