Skip to content

Commit

Permalink
Merge pull request #16 from brownd1978/kkconfig
Browse files Browse the repository at this point in the history
Kkconfig
  • Loading branch information
brownd1978 authored Jan 25, 2022
2 parents 7394f3a + c5f1285 commit 8f8fe4d
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 108 deletions.
7 changes: 0 additions & 7 deletions Data/Schedule.txt

This file was deleted.

8 changes: 8 additions & 0 deletions Data/Schedule_MCAmbig.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Test Configuration file for iteration schedule
# first global parameters: maxniter dewight dchisquared_converge dchisquared_diverge dchisq_paramdiverge tbuff tol minndof bfcor plevel
10 1.0e6 1.0 50.0 1.0e6 0.0 1e-4 5 1 0
# Then, meta-iteration specific parameters: temperature (mindoca maxdoca minprob)
2.0
1.0
0.0
16 changes: 8 additions & 8 deletions Data/Schedule_driftextend.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#
# Test Configuration iteration schedule for a drift extension
# first global parameters: maxniter dewight dchisquared_converge dchisquared_diverge dchisq_paramdiverge tbuff tol minndof bfcor plevel
10 1.0e6 1.0 50.0 1.0e6 0.0 1e-4 5 1 0
# Order:
# temperature dchisquared_converge dchisquared_diverge (mindoca maxdoca minprob)
2.0 1.0 50.0 1.5 5 1e-5
2.0 1.0 50.0 0.5 5 1e-5
1.0 1.0 50.0 0.5 3.5 1e-5
0.5 1.0 20.0 0.5 2.8 1e-5
0.0 0.1 10.0 0.5 2.8 1e-5
0.0 0.1 10.0 0.5 2.8 1e-4

# temperature (mindoca maxdoca minprob)
2.0 1.5 5 1e-8
2.0 1.0 3.5 1e-8
1.0 0.5 3.5 1e-8
0.5 0.5 2.8 1e-8
0.0 0.5 2.8 1e-6
19 changes: 10 additions & 9 deletions Data/Schedule_driftfit.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#
# Test Configuration iteration schedule for a drift fit
# first global parameters: maxniter dewight dchisquared_converge dchisquared_diverge dchisq_paramdiverge tbuff tol minndof bfcor plevel
10 1.0e6 1.0 50.0 1.0e6 0.0 1e-4 5 1 0
# Order:
# temperature dchisquared_converge dchisquared_diverge (mindoca maxdoca minprob)
2.0 10.0 100.0 20 20 1e-6
1.0 1.0 50.0 10 10 1e-6
0.5 1.0 50.0 5 5 1e-5
2.0 1.0 50.0 0.5 5 1e-5
1.0 1.0 50.0 0.5 3.5 1e-5
0.5 1.0 20.0 0.5 2.8 1e-5
0.0 0.1 10.0 0.5 2.8 1e-5
0.0 0.1 10.0 0.5 2.8 1e-4
# temperature dchisquared_converge dchisquared_diverge (mindoca maxdoca)
2.0 20 20 1e-8
1.0 10 10 1e-8
0.5 5 5 1e-8
2.0 1.5 5 1e-8
1.0 1.0 3.5 1e-8
0.5 0.5 2.8 1e-8
0.0 0.5 2.8 1e-6
15 changes: 8 additions & 7 deletions Data/Schedule_seedfit.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#
# Test Configuration iteration schedule for seed fit
# Order:
# temperature dchisquared_converge dchisquared_diverge (mindoca maxdoca minprob)
2.0 10.0 100.0 20 20 1e-6
1.0 1.0 50.0 10 10 1e-6
0.5 1.0 50.0 5 5 1e-5
# Test Configuration iteration schedule for a null (no drift) fit
# first global parameters: maxniter dewight dchisquared_converge dchisquared_diverge dchisq_paramdiverge tbuff tol minndof bfcor plevel
10 1.0e6 1.0 50.0 1.0e6 0.0 1e-4 5 1 0
# Then, meta-iteration specific parameters: temperature (mindoca maxdoca minprob)
2.0 20 20 1.0e-6
1.0 10 10 1.0e-6
0.0 5 5 1.0e-6

126 changes: 58 additions & 68 deletions Mains/Tracks_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,51 @@ void print_usage() {
printf("Usage: CeTrackTest --mustopsfile s --rmue f --bfield s --trkfield i --targetfile s --trackerfile s --ipafile s --fitschedule s--extschedule s --process s --endpoint f --endrange f --lifetime f --tol f --npts i --ntrks i --draw i --ttree i --tfile s --minnhits i --npot i --printdetail i --saveall i --faildetail i\n");
}

int makeConfig(string const& cfile, KinKal::Config& config) {
string fullfile;
if(strncmp(cfile.c_str(),"/",1) == 0) {
fullfile = string(cfile);
} else {
if(const char* source = std::getenv("TRACKTOY_SOURCE_DIR")){
fullfile = string(source) + ("/Data/") + string(cfile);
} else {
cout << "TRACKTOY_SOURCE_DIR not defined" << endl;
return -1;
}
}
std::ifstream ifs (fullfile, std::ifstream::in);
if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ){
std::cerr << "Error opening " << fullfile << std::endl;
return -1;
}
string line;
int plevel(-1);
unsigned nmiter(0);
while (getline(ifs,line)){
if(strncmp(line.c_str(),"#",1)!=0){
istringstream ss(line);
if(plevel < 0) {
ss >> config.maxniter_ >> config.dwt_ >> config.convdchisq_ >> config.divdchisq_ >>
config.pdchi2_ >> config.tbuff_ >> config.tol_ >> config.minndof_ >> config.bfcorr_ >>
plevel;
config.plevel_ = Config::printLevel(plevel);
} else {
double temp, mindoca(-1.0),maxdoca(-1.0), minprob(-1.0);
ss >> temp >> mindoca >> maxdoca >> minprob;
MetaIterConfig mconfig(temp, nmiter++);
if(mindoca >0.0 || maxdoca > 0.0){
// setup and insert the updater
cout << "SimpleWireHitUpdater for iteration " << nmiter << " with mindoca " << mindoca << " maxdoca " << maxdoca << " minprob " << minprob << endl;
SimpleWireHitUpdater updater(mindoca,maxdoca,minprob);
mconfig.updaters_.push_back(std::any(updater));
}
config.schedule_.push_back(mconfig);
}
}
}
return 0;
}

int main(int argc, char **argv) {
using KTRAJ=LoopHelix;
using PKTRAJ = ParticleTrajectory<KTRAJ>;
Expand All @@ -71,7 +116,7 @@ int main(int argc, char **argv) {
string calofile("Data/Mu2eCalo.dat");
string ipafile("Data/Mu2e_IPA.dat");
string efile_my("Data/EStar_Mylar.dat"); // should come from tracker FIXME
string sfile("Data/Schedule.txt"), extfile; // fit schedule
string sfile("Schedule.txt"), extfile; // fit schedule
string process("CeMinus");
string diofile("Data/DIOAl_fine.dat"); // this should be a parameter FIXME
double mustopeff; // mu stops/POT. This comes from running MuBeam, which also produces the Mustops.root file. These MUST be consistent to get physically correct results!!
Expand Down Expand Up @@ -108,8 +153,6 @@ int main(int argc, char **argv) {
// fit parameters
KinKal::DVEC sigmas(0.5, 0.5, 0.5, 0.5, 0.002, 0.5); // expected parameter sigmas for loop helix
double seedsmear(1.0);
double dwt(1.0e6);
unsigned maxniter(10);
Config::printLevel detail(Config::none), faildetail(Config::none);

static struct option long_options[] = {
Expand Down Expand Up @@ -259,72 +302,10 @@ int main(int argc, char **argv) {
// auto trkfield = bfield;
// setup fit configuration
Config config;
config.dwt_ = dwt;
config.maxniter_ = maxniter;
config.bfcorr_ = bfit;
config.tol_ = tol;
config.plevel_ = detail;
config.pdchi2_ = 1e4;
// read the schedule from the file
fullfile = filefinder.fullFile(sfile);
std::ifstream ifs (fullfile, std::ifstream::in);
if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ){
std::cerr << "Error opening " << fullfile << std::endl;
return -1;
}
string line;
unsigned nmiter(0);
double temp, convdchisq, divdchisq;
while (getline(ifs,line)){
if(strncmp(line.c_str(),"#",1)!=0){
istringstream ss(line);
ss >> temp >> convdchisq >> divdchisq;
MetaIterConfig mconfig(temp, convdchisq, divdchisq, nmiter++);
double mindoca(-1.0),maxdoca(-1.0), minprob(-1.0);
ss >> mindoca >> maxdoca >> minprob;
if(mindoca >0.0 || maxdoca > 0.0){
// setup and insert the updater
SimpleWireHitUpdater updater(mindoca,maxdoca,minprob);
mconfig.updaters_.push_back(std::any(updater));
}
config.schedule_.push_back(mconfig);
}
}
cout << config << endl;
// setup extension (if provided). Parameters should be independent of fit config TODO
makeConfig(sfile,config);
// setup extension (if provided).
Config extconfig;
extconfig.dwt_ = dwt;
extconfig.maxniter_ = maxniter;
extconfig.bfcorr_ = bext;
extconfig.tol_ = tol;
extconfig.plevel_ = detail;
extconfig.pdchi2_ = 1e4;
if(extfile.size() > 0){
fullfile = filefinder.fullFile(extfile);
std::ifstream ifs (fullfile, std::ifstream::in);
if ( (ifs.rdstate() & std::ifstream::failbit ) != 0 ){
std::cerr << "Error opening " << fullfile << std::endl;
return -1;
}
string line;
unsigned nmiter(0);
double temp, convdchisq, divdchisq;
while (getline(ifs,line)){
if(strncmp(line.c_str(),"#",1)!=0){
istringstream ss(line);
ss >> temp >> convdchisq >> divdchisq;
MetaIterConfig mconfig(temp, convdchisq, divdchisq, nmiter++);
double mindoca(-1.0),maxdoca(-1.0),minprob(-1.0);
ss >> mindoca >> maxdoca >> minprob;
if(mindoca >0.0 || maxdoca > 0.0){
// setup and insert the updater
SimpleWireHitUpdater updater(mindoca,maxdoca,minprob);
mconfig.updaters_.push_back(std::any(updater));
}
extconfig.schedule_.push_back(mconfig);
}
}
}
if(extfile.size() > 0)makeConfig(extfile,extconfig);
// randoms
TRandom3 tr_; // random number generator
// setup spectrum
Expand Down Expand Up @@ -529,6 +510,15 @@ int main(int argc, char **argv) {
kktrk.extend(extconfig,exthits,extxings);
}
nfit++;
// fill hit counting
for(auto const& hit : hits) {
if(hit->active()){
++tinfo_.kknactive;
auto swh = dynamic_cast<KinKal::SimpleWireHit<KTRAJ>*>(hit.get());
if(swh != 0 && !swh->hitState().useDrift())++tinfo_.kknnull;
}
}

// fill fit information
auto const& fstat = kktrk.fitStatus();
if(fstat.status_ == Status::failed)nfail++;
Expand Down
5 changes: 4 additions & 1 deletion Test/TrkInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ namespace TrackToy {
struct TrkInfo {
unsigned ncells, narcs, ntrkhits, ncalohits; // hit counting
int kkstatus, kkndof, kknbf, kknmat, kknhit, kkniter;
int kknactive, kknnull;
float kkchisq, kkprob;
void reset() {
ncells = narcs = ntrkhits = ncalohits = 0;
kkstatus = kkndof = kknbf = kknmat = kknhit = kkniter = -1;
kkstatus = -1;
kkndof = kknbf = kknmat = kknhit = kkniter = 0;
kknactive = kknnull = 0;
kkchisq = kkprob = -1.0;
}
};
Expand Down
9 changes: 5 additions & 4 deletions Tests/RunMu2e.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#
# Only need to run MuStops once
bin/MuStops --mubeam MDC2020n_10pc --targetfile Data/Mu2eTarget.dat >& MDC2020N_10pc_mustops.log
nohup time bin/Tracks --process CeMinus --rmue 1e-16 --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eMCAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Data/Schedule.txt >& Mu2eMCAmbigCeM.log &
nohup time bin/Tracks --process FlatDIO --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eMCAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Data/Schedule.txt >& Mu2eMCAmbigDIO.log &
nohup time bin/Tracks --process CeMinus --rmue 1e-16 --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eDriftAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Data/Schedule_driftfit.txt >& Mu2eDriftAmbigCeM.log &
nohup time bin/Tracks --process FlatDIO --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eDriftAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Data/Schedule_driftfit.txt >& Mu2eDriftAmbigDIO.log &
nohup time bin/Tracks --process CeMinus --rmue 1e-16 --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eMCAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Schedule_MCAmbig.txt >& Mu2eMCAmbigCeM.log &
nohup time bin/Tracks --process FlatDIO --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eMCAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Schedule_MCAmbig.txt >& Mu2eMCAmbigFlatDIO.log &
nohup time bin/Tracks --process CeMinus --rmue 1e-16 --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eDriftAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Schedule_driftfit.txt >& Mu2eDriftAmbigCeM.log &
nohup time bin/Tracks --process FlatDIO --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eDriftAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Schedule_driftfit.txt >& Mu2eDriftAmbigFlatDIO.log &
nohup time bin/Tracks --process DIO --ntrks 100000 --mustopsfile MDC2020n_10pc --npot 3.6e20 --tfile Mu2eDriftAmbig --trackerfile Data/Mu2eTracker.dat --fitschedule Schedule_driftfit.txt >& Mu2eDriftAmbigDIO.log &

9 changes: 5 additions & 4 deletions Tests/RunMu2e2.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
bin/MuStops --mubeam Mu2eIIa2 --targetfile Data/Mu2e2Target.dat >& Mu2eIIa2_mustops.log
nohup time bin/Tracks --process CeMinus --rmue 1e-17 --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2MCAmbig --trackerfile Data/Mu2e2Tracker.dat >& Mu2e2MCAmbigCeM.log &
nohup time bin/Tracks --process FlatDIO --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2MCAmbig --trackerfile Data/Mu2e2Tracker.dat >& Mu2e2MCAmbigDIO.log &
nohup time bin/Tracks --process CeMinus --rmue 1e-17 --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2DriftAmbig --trackerfile Data/Mu2e2Tracker.dat --fitschedule Data/Schedule_driftfit.txt >& Mu2e2DriftAmbigCeM.log &
nohup time bin/Tracks --process FlatDIO --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2DriftAmbig --trackerfile Data/Mu2e2Tracker.dat --fitschedule Data/Schedule_driftfit.txt >& Mu2e2DriftAmbigDIO.log &
nohup time bin/Tracks --process CeMinus --rmue 3e-17 --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2MCAmbig --trackerfile Data/Mu2e2Tracker.dat --fitschedule Schedule_MCAmbig.txt >& Mu2e2MCAmbigCeM.log &
nohup time bin/Tracks --process FlatDIO --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2MCAmbig --trackerfile Data/Mu2e2Tracker.dat --fitschedule Schedule_MCAmbig.txt >& Mu2e2MCAmbigFlatDIO.log &
nohup time bin/Tracks --process CeMinus --rmue 3e-17 --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2DriftAmbig --trackerfile Data/Mu2e2Tracker.dat --fitschedule Schedule_driftfit.txt >& Mu2e2DriftAmbigCeM.log &
nohup time bin/Tracks --process FlatDIO --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2DriftAmbig --trackerfile Data/Mu2e2Tracker.dat --fitschedule Schedule_driftfit.txt >& Mu2e2DriftAmbigFlatDIO.log &
nohup time bin/Tracks --process DIO --endrange 3.0 --ntrks 100000 --mustopsfile Mu2eIIa2 --npot 1.3e22 --tfile Mu2e2DriftAmbig --trackerfile Data/Mu2e2Tracker.dat --fitschedule Schedule_driftfit.txt >& Mu2e2DriftAmbigDIO.log &

0 comments on commit 8f8fe4d

Please sign in to comment.