Skip to content

Commit

Permalink
Fixing configuration manager type in some executables. Updating genet…
Browse files Browse the repository at this point in the history
…icOptimizer for QCD events.
  • Loading branch information
jniedzie committed Feb 11, 2019
1 parent c481e70 commit d16176d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
10 changes: 5 additions & 5 deletions algoBenchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
maxLayer=40

# range of ntuples to test (will be appended to the inputPath string below):
minNtuple = 11
maxNtuple = 11
minNtuple = 1
maxNtuple = 1

# base input and output paths:
inputPath = "../data/_SingleGammaPt100Eta1p6_2p8_PhaseIITDRFall17DR-noPUFEVT_93X_upgrade2023_realistic_v2-v1_GEN-SIM-RECO/NTUP/_SingleGammaPt100Eta1p6_2p8_PhaseIITDRFall17DR-noPUFEVT_93X_upgrade2023_realistic_v2-v1_GEN-SIM-RECO_NTUP_"

outDir = "clusteringResults"
outDir = "clusteringResultsPython/"
#----------------------------------------------------------------------------------------


Expand Down Expand Up @@ -107,9 +107,9 @@ def getRecHitsPerHexel(hits, hexels):

# get clustered hexels by re-running the clustering algorithm
def getRecClustersFromImagingAlgo(recHitsRaw):
HGCalAlgo = HGCalImagingAlgo(energyMin, deltac, multiclusterRadii, minClusters, dependSensor, verbosityLevel = 0)
HGCalAlgo = HGCalImagingAlgo(energyMin, deltac, multiclusterRadii, minClusters, dependSensor, verbosityLevel = 2)
clusters2D_rerun = HGCalAlgo.makeClusters(recHitsRaw,energyMin,True) # nested list of "hexels", per layer, per 2D cluster
clusters2DList_rerun = HGCalAlgo.getClusters(clusters2D_rerun, verbosityLevel = 0) # flat list of 2D clusters (as basic clusters)
clusters2DList_rerun = HGCalAlgo.getClusters(clusters2D_rerun, verbosityLevel = 2) # flat list of 2D clusters (as basic clusters)
hexelsClustered_rerun = [iNode for bClust in clusters2DList_rerun for iNode in bClust.thisCluster if not iNode.isHalo] # flat list of clustered "hexeles", without the "halo" hexels


Expand Down
2 changes: 1 addition & 1 deletion cppVersion/plotGenetic.C
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <dirent.h>

string basePath = "geneticResults/twoPions/";
string basePath = "geneticResults/qcd/";

void PlotInCanvas(TCanvas *canvas, TCanvas *canvasWgt, TCanvas *canvas1D, int pad, TFile *file, string name)
{
Expand Down
2 changes: 1 addition & 1 deletion cppVersion/src/algoBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ int main(int argc, char* argv[])
exit(0);
}
string configPath(argv[1]);
ConfigurationManager *config = ConfigurationManager::Instance(configPath);
auto config = ConfigurationManager::Instance(configPath);

gROOT->ProcessLine(".L loader.C+");

Expand Down
2 changes: 1 addition & 1 deletion cppVersion/src/analyzeTestbeam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main(int argc, char* argv[])
cout<<"Usage: analyzeTestbeam path_to_config"<<endl;
exit(0);
}
ConfigurationManager *config = ConfigurationManager::Instance(argv[1]);
auto config = ConfigurationManager::Instance(argv[1]);
cout<<endl;config->Print();

gROOT->ProcessLine(".L loader.C+");
Expand Down
26 changes: 16 additions & 10 deletions cppVersion/src/geneticOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ using namespace std;

string baseResultsPath;

string baseResultsSearchPath = "geneticResults/twoPions/";
string baseResultsSearchPath = "geneticResults/qcd/";
string baseResultsDirName = "results_";

int populationSize = 40; ///< Size of the population, will stay the same for all generations. Make it an even numb er, otherwise there may be some complications.
int populationSize = 5; ///< Size of the population, will stay the same for all generations. Make it an even number, otherwise there may be some complications.
int maxBatchSize = 20; ///< execute this number of jobs simultaneously
int nGenerations = 100; ///< Number of iterations
int nEventsPerTest = 100; ///< On how many events per ntuple each population member will be tested
int nEventsPerTest = 10; ///< On how many events per ntuple each population member will be tested

int processTimeout = 200; ///< this is a timeout for the test of whole population in given generation, give it at least 2-3 seconds per member per event (processTimeout ~ 2*maxBatchSize*nEventsPerTest)

double mutationChance = 0.003;
double severityFactor = 10.0; // larger the value, more easily population members will die (and the more good solutions will be promoted)

bool dependSensor = true;
bool reachedEE = true;
bool reachedEE = false;

Chromosome::ECrossover crossoverStrategy = Chromosome::kFixedSinglePoint;

Expand All @@ -55,14 +55,20 @@ int maxNtuple = 1;
int minLayer = 1;
int maxLayer = 53;

double energyThreshold = 3.0;
int kernelFunction = 0; // 0 - step, 1 - gauss, 2 - exp
double matchingDistance = 10.0;

// two-photons
//string dataPath = "../../data/MultiParticleInConeGunProducer_PDGid22_nPart1_Pt6p57_Eta2p2_InConeDR0p10_PDGid22_predragm_cmssw1020pre1_20180730/NTUP/partGun_PDGid22_x96_Pt6.57To6.57_NTUP_";

// two-pions
string dataPath = "../../data/MultiParticleInConeGunProducer_SinglePion_Pt80_Eta2_InConePion_DeltaR0p1_clange_20171102/NTUP/partGun_PDGid211_x120_Pt80.0To80.0_NTUP_";
//string dataPath = "../../data/MultiParticleInConeGunProducer_SinglePion_Pt80_Eta2_InConePion_DeltaR0p1_clange_20171102/NTUP/partGun_PDGid211_x120_Pt80.0To80.0_NTUP_";

string outputPath = "../clusteringResultsCXX/geneticOptimizer/";
// QCD event
string dataPath = "../../data/eventQCD_wf24031p0_Pt_80_120_14TeV_2023D28_noPU_jniedzie_20190208/NTUP/eventQCD_x1320_1.0To35.0_NTUP_";

string outputPath = "../clusteringResultsCXX/geneticOptimizerQCD/";

mt19937 randGenerator;

Expand All @@ -79,7 +85,7 @@ atomic<bool> allKidsFinished;

int scheduleClustering(Chromosome *chromo)
{
int kernelIndex = round(chromo->GetParam(kKernel));
int kernelIndex = kernelFunction;//round(chromo->GetParam(kKernel));
string kernel;
if(kernelIndex == 0) kernel = "step";
if(kernelIndex == 1) kernel = "gaus";
Expand All @@ -92,7 +98,7 @@ int scheduleClustering(Chromosome *chromo)
+to_string(chromo->GetParam(kDeltacEE))+" "
+to_string(chromo->GetParam(kDeltacFH))+" "
+to_string(chromo->GetParam(kDeltacBH))+" "
+to_string(chromo->GetParam(kEnergyThreshold))+" "
+to_string(energyThreshold /*chromo->GetParam(kEnergyThreshold)*/)+" "
+to_string(chromo->GetParam(kCriticalDistanceEE))+" "
+to_string(chromo->GetParam(kCriticalDistanceFH))+" "
+to_string(chromo->GetParam(kCriticalDistanceBH))+" "
Expand All @@ -105,7 +111,7 @@ int scheduleClustering(Chromosome *chromo)
+to_string(nEventsPerTest)+" "
+kernel+" "
+to_string(reachedEE)+" "
+to_string(chromo->GetParam(kMatchingDistance))+" "
+to_string(matchingDistance /*chromo->GetParam(kMatchingDistance)*/)+" "
+chromo->GetClusteringOutputPath()+" "
+" > /dev/null 2>&1";

Expand Down Expand Up @@ -298,7 +304,7 @@ int main(int argc, char* argv[])
cout<<"Usage:"<<endl;
cout<<"./geneticOptimizer"<<endl;
cout<<"or with custom parameters:"<<endl;
cout<<"./ geneticOptimizer populationSize nGenerations nEventsPerTest processTimeout mutationChance severityFactor dataPath outputPath"<<endl;
cout<<"./geneticOptimizer populationSize nGenerations nEventsPerTest processTimeout mutationChance severityFactor dataPath outputPath"<<endl;
exit(0);
}
if(argc == 9){
Expand Down

0 comments on commit d16176d

Please sign in to comment.