Skip to content

Commit 6051a11

Browse files
committed
cleaning up code
1 parent 83479a0 commit 6051a11

1 file changed

Lines changed: 3 additions & 69 deletions

File tree

sbncode/SBNEventWeight/Calculators/Geant4/Geant4WeightCalc.cxx

Lines changed: 3 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,9 @@ class Geant4WeightCalc : public WeightCalc {
6060
std::string fMCTruthProducer; //!< Label for the MCTruth producer
6161
CLHEP::RandGaussQ* fGaussRandom; //!< Random number generator
6262
fhicl::ParameterSet fMaterial; //!< Detector material, i.e. LAr
63-
// std::map<int, ParticleDef> fParticles; //!< Particles to reweight
6463
unsigned fNsims; //!< Number of universes (multisim mode)
6564
unsigned fNsigmas; //!< Number of sigmas (multisigma mode)
6665
int fPdg; //!< PDG value for particles that a given weight calculator should apply to. Note that for now this module can only handle weights for one particle species at a time.
67-
// float fXSUncertainty; //!< Flat cross section uncertainty
6866
G4ReweighterFactory fRWFactory; //!< Base class to handle all Geant4Reweighters
6967
G4Reweighter *fReweighter; //!< Geant4Reweighter -- this is what provides the weights
7068
G4ReweightParameterMaker *fParMaker;
@@ -90,10 +88,7 @@ class Geant4WeightCalc : public WeightCalc {
9088
int p_nElasticScatters; //!< Variables for by-particle output tree
9189
std::vector<double> p_weight; //!< Variables for by-particle output tree
9290

93-
9491
// **IF** I understand correctly, then after commit 11077f2 (el_weight*inel_weight) is returned by GetWeight()
95-
//std::vector<double> p_inel_weight; //!< Variables for by-particle output tree
96-
//std::vector<double> p_elastic_weight; //!< Variables for by-particle output
9792

9893
bool fDebug; //!< print debug statements
9994

@@ -108,7 +103,6 @@ void Geant4WeightCalc::Configure(fhicl::ParameterSet const& p,
108103

109104
// Get configuration for this function
110105
fhicl::ParameterSet const& pset = p.get<fhicl::ParameterSet>(GetName());
111-
// std::cout << pset.GetName() << std::endl;
112106
fMCParticleProducer = pset.get<std::string>("MCParticleProducer", "largeant");
113107
fMCTruthProducer = pset.get<std::string>("MCTruthProducer", "generator");
114108
fMakeOutputTrees = pset.get< bool >( "makeoutputtree", false );
@@ -144,8 +138,6 @@ void Geant4WeightCalc::Configure(fhicl::ParameterSet const& p,
144138
fOutTree_Particle->Branch("pdg_to_reweight",&fPdg);
145139

146140
fOutTree_Particle->Branch("weight",&p_weight);
147-
//fOutTree_Particle->Branch("inelastic_weight",&p_inel_weight);
148-
//fOutTree_Particle->Branch("elastic_weight",&p_elastic_weight);
149141
fOutTree_Particle->Branch("track_length",&p_track_length);
150142
fOutTree_Particle->Branch("PDG",&p_PDG);
151143
fOutTree_Particle->Branch("final_proc",&p_final_proc);
@@ -165,7 +157,6 @@ void Geant4WeightCalc::Configure(fhicl::ParameterSet const& p,
165157
fOutTree_MCTruth->Branch("pdg_to_reweight",&fPdg);
166158
}
167159

168-
169160
// Read input parameter sets and set up universes
170161
size_t n_parsets = FitParSets.size();
171162
std::vector<std::string> FitParNames;
@@ -193,29 +184,7 @@ void Geant4WeightCalc::Configure(fhicl::ParameterSet const& p,
193184
fParameterSet.AddParameter(theName, theSigma);
194185
}
195186

196-
//DEPRECATED
197-
if (mode=="pm1sigma"){
198-
// pm1sigma mode: 0 = +1sigma, 1 = -1sigma of a single parameter. All other parameters at nominal
199-
for (size_t i_parset=0; i_parset<n_parsets; ++i_parset){
200-
// For each parameter, first create a nominal parameter set (one for +1sigma and one for -1sigma)
201-
std::map<std::string, double> tmp_vals_p1sigma(theNominals);
202-
std::map<std::string, double> tmp_vals_m1sigma(theNominals);
203-
// Now reset the +1sigma and -1sigma values for this parameter set only
204-
tmp_vals_p1sigma[FitParNames.at(i_parset)] = FitParNominals.at(i_parset)+FitParSigmas.at(i_parset);
205-
tmp_vals_m1sigma[FitParNames.at(i_parset)] = FitParNominals.at(i_parset)-FitParSigmas.at(i_parset);
206-
207-
if (fDebug){
208-
std::cout << "Universe " << i_parset*2 << ": " << FitParNames.at(i_parset) << " = " << FitParNominals.at(i_parset)+FitParSigmas.at(i_parset) << std::endl;
209-
std::cout << "Universe " << i_parset*2+1 << ": " << FitParNames.at(i_parset) << " = " << FitParNominals.at(i_parset)-FitParSigmas.at(i_parset) << std::endl;
210-
}
211-
212-
// Finally, add these universes into the vector
213-
UniverseVals.push_back(tmp_vals_p1sigma);
214-
UniverseVals.push_back(tmp_vals_m1sigma);
215-
} // end loop over parsets (i)
216-
} // pm1sigma
217-
218-
else if (mode=="multisim"){
187+
if (mode=="multisim"){
219188
// multisim mode: parameter values sample within the given uncertainty for all parameters simultaneously
220189
// Loop over universes j
221190
for (unsigned j=0; j<fNsims; j++){
@@ -230,7 +199,7 @@ void Geant4WeightCalc::Configure(fhicl::ParameterSet const& p,
230199
} // loop over Nsims (j)
231200
} // multisim
232201

233-
if (mode=="multisigma"){
202+
else if (mode=="multisigma"){
234203
// pm1sigma mode: 0 = +1sigma, 1 = -1sigma of a single parameter. All other parameters at nominal
235204
for (size_t i_parset=0; i_parset<n_parsets; ++i_parset){
236205
for ( int i_sigma = -1*fNsigmas; i_sigma < int(fNsigmas+1); i_sigma++ ) {
@@ -279,10 +248,6 @@ std::vector<float> Geant4WeightCalc::GetWeight(art::Event& e, size_t itruth ) {
279248
// Reset things to be saved in the output tree for fast validation
280249
p_weight.clear();
281250
p_weight.resize(fNsims,1.0);
282-
//p_inel_weight.clear();
283-
//p_inel_weight.resize(fNsims,1.0);
284-
//p_elastic_weight.clear();
285-
//p_elastic_weight.resize(fNsims,1.0);
286251
p_track_length=-9999;
287252
p_PDG=-9999;
288253
p_final_proc="dummy";
@@ -384,17 +349,13 @@ std::vector<float> Geant4WeightCalc::GetWeight(art::Event& e, size_t itruth ) {
384349
p_nElasticScatters = elastic_indices.size();
385350
for( size_t istep = 1; istep < nSteps; ++istep ){
386351

387-
// if( istep == trajpoint_PX.size() - 1 && std::find( elastic_indices.begin(), elastic_indices.end(), j ) != elastic_indices.end() )
388-
// std::cout << "Warning: last step an elastic process" << std::endl;
389-
390352
std::string proc = "default";
391353
if( istep == trajpoint_PX.size() - 1 )
392354
proc = EndProcess;
393355
else if( std::find( elastic_indices.begin(), elastic_indices.end(), istep ) != elastic_indices.end() ){
394356
proc = "hadElastic";
395357
}
396358

397-
398359
double deltaX = ( trajpoint_X.at(istep) - trajpoint_X.at(istep-1) );
399360
double deltaY = ( trajpoint_Y.at(istep) - trajpoint_Y.at(istep-1) );
400361
double deltaZ = ( trajpoint_Z.at(istep) - trajpoint_Z.at(istep-1) );
@@ -460,7 +421,7 @@ std::vector<float> Geant4WeightCalc::GetWeight(art::Event& e, size_t itruth ) {
460421

461422
// Loop through universes (j)
462423
for (size_t j=0; j<weight.size(); j++) {
463-
float w/*, el_w*/;
424+
float w;
464425

465426
// I think this is the only bit that needs to change for different universes -- all the above is jut about the track, which doesn't change based on universe
466427
fParMaker->SetNewVals(UniverseVals.at(j));
@@ -474,37 +435,10 @@ std::vector<float> Geant4WeightCalc::GetWeight(art::Event& e, size_t itruth ) {
474435
// just for the output tree
475436
p_weight[j] = w;
476437

477-
/*
478-
// Do the same for elastic weight (should be 1 unless set to non-nominal )
479-
el_w = fReweighter->GetElasticWeight( &theTraj );
480-
weight[j] *= std::max((float)0.0,el_w);
481-
482-
// just for the output tree
483-
p_inel_weight[j] = w;
484-
p_elastic_weight[j] = el_w;
485-
486-
if (fDebug){
487-
std::cout << " Universe " << j << ": ";
488-
// std::cout << UniverseVals.at(j) << std::endl;
489-
std::cout << " w = " << w << ", el_w = " << el_w << std::endl;
490-
}
491-
*/
492-
493438
} // loop through universes (j)
494439

495440
if (fDebug){
496441
std::cout << "PDG = " << p_PDG << std::endl;
497-
/*
498-
std::cout << "inel weights by particle: ";
499-
for (unsigned int j=0; j<weight.size(); j++){
500-
std::cout << p_inel_weight[j] << ", ";
501-
}
502-
std::cout << std::endl;
503-
std::cout << "elastic weights by particle: ";
504-
for (unsigned int j=0; j<weight.size(); j++){
505-
std::cout << p_elastic_weight[j] << ", ";
506-
}
507-
*/
508442
std::cout << "weights by particle: ";
509443
for (unsigned int j=0; j<weight.size(); j++){
510444
std::cout << p_weight[j] << ", ";

0 commit comments

Comments
 (0)