#include <GENIEHelper.h>
Inheritance diagram for evgen::GENIEHelper:
Public Member Functions | |
GENIEHelper () | |
GENIEHelper (std::string config, std::string version) | |
~GENIEHelper () | |
void | Update (const cfg::Config &c) |
void | Initialize () |
bool | Sample (sim::MCTruth &truth) |
Private Member Functions | |
void | InitializeGeometry () |
void | InitializeFluxDriver () |
void | PackNuMIFlux (sim::MCTruth &truth) |
void | PackMCTruth (genie::EventRecord *record, sim::MCTruth &truth) |
Private Attributes | |
genie::GeomAnalyzerI * | fGeomD |
genie::GFluxI * | fFluxD |
genie::GMCJDriver * | fDriver |
rawdata::det_id_ | fDetector |
std::string | fFluxType |
ipnd, nd, fd | |
std::string | fFluxFile |
histogram or ntuple | |
std::string | fBeamName |
name of file containing histograms or ntuples, or txt | |
std::vector< TH1D * > | fFluxHistograms |
name of the beam we are simulating | |
int | fEvents |
histograms for each nu species | |
double | fTotalGen |
number of events to generate | |
double | fTotalRequested |
total number of events/pot generated to this point | |
double | fPOT |
total number of events/pot requested to be generated | |
double | fFluxNormalization |
total POT to generate | |
double | fMonoEnergy |
POT per file. | |
std::vector< int > | fGenFlavors |
energy of monoenergetic neutrinos | |
std::vector< string > | fEnvironment |
pdg codes for flavors to generate | |
std::map< int, int > | fFlavorMap |
environmental variables and settings used by genie |
|
Definition at line 54 of file GENIEHelper.cxx. References fFlavorMap, and cfg::Observer::SetWatch(). 00054 : 00055 fTotalGen(0.) 00056 { 00057 00058 fFlavorMap[12] = kNue; 00059 fFlavorMap[-12] = kNueBar; 00060 fFlavorMap[14] = kNuMu; 00061 fFlavorMap[-14] = kNuMuBar; 00062 fFlavorMap[16] = kNuTau; 00063 fFlavorMap[-16] = kNuTauBar; 00064 00065 this->SetWatch("GENIE","default"); 00066 }
|
|
Definition at line 69 of file GENIEHelper.cxx. References fFlavorMap, and cfg::Observer::SetWatch(). 00070 { 00071 fFlavorMap[12] = kNue; 00072 fFlavorMap[-12] = kNueBar; 00073 fFlavorMap[14] = kNuMu; 00074 fFlavorMap[-14] = kNuMuBar; 00075 fFlavorMap[16] = kNuTau; 00076 fFlavorMap[-16] = kNuTauBar; 00077 00078 this->SetWatch(config.c_str(), version.c_str()); 00079 }
|
|
Definition at line 82 of file GENIEHelper.cxx. 00083 { 00084 }
|
|
initialize the Geometry and Flux drivers turn on following line to speed up driver initialization Definition at line 193 of file GENIEHelper.cxx. References fDriver, fFluxD, fGeomD, InitializeFluxDriver(), and InitializeGeometry(). Referenced by main(). 00194 { 00195 00197 InitializeGeometry(); 00198 InitializeFluxDriver(); 00199 fDriver = new genie::GMCJDriver(); 00200 fDriver->UseFluxDriver(fFluxD); 00201 fDriver->UseGeomAnalyzer(fGeomD); 00202 00204 //driver->UseMaxPathLengths(***supply some xml file name***); 00205 00206 fDriver->Configure(); 00207 fDriver->UseSplines(); 00208 fDriver->ForceSingleProbScale(); 00209 00210 return; 00211 }
|
|
z=0 is the front face of the tpc set the number of cycles to run +++++++++this is stupid - to really set it i have to get a value from the MCJDriver and i am not even sure what i have below is approximately correct. end if using ntuple flux files get the geometry of the detector set the beam direction and spot based on the detector beamR, bspot need to be fixed up for FD and ND, the 0.05 angle is an estimate multiply by 1e-2 to put the values in meters, the default for genie making sure we are in genie units now add the different fluxes end loop to add flux histograms to driver weight each species equally in the generation Definition at line 231 of file GENIEHelper.cxx. References geo::Geometry::DetHalfHeight(), geo::Geometry::DetLength(), fDetector, fFlavorMap, fFluxD, fFluxFile, fFluxHistograms, fFluxNormalization, fFluxType, fGenFlavors, fMonoEnergy, fPOT, and geo::Geometry::Instance(). Referenced by Initialize(). 00232 { 00233 00234 if(fFluxType.compare("ntuple") == 0){ 00235 genie::flux::GNuMIFlux* numiFlux = new genie::flux::GNuMIFlux(); 00236 numiFlux->LoadBeamSimData(fFluxFile); 00237 numiFlux->SetFilePOT(fFluxNormalization); 00238 numiFlux->SetUpstreamZ(-1000.); 00239 00244 numiFlux->SetNumOfCycles(int(fPOT/fFluxNormalization)); 00245 00246 fFluxD = dynamic_cast<genie::GFluxI *>(numiFlux); 00247 } 00248 else if(fFluxType.compare("histogram") == 0){ 00249 00251 geo::Geometry& geo = geo::Geometry::Instance(0, fDetector); 00252 00253 TVector3 bdir(0.015,0.104,sqrt(1. - 0.104*0.104 - 0.015*0.015)); 00254 double beamR = 0.5*(2.*geo.DetHalfHeight()*cos(0.11) + geo.DetLength()*sin(0.11)); 00255 double epsilon = beamR - geo.DetLength()*sin(0.11); 00256 double cx = 0.; 00257 double cy = epsilon*cos(0.11)-geo.DetHalfHeight(); 00258 double cz = -epsilon*sin(0.11); 00259 00262 if(fDetector == rawdata::kNear){ 00263 bdir.SetXYZ(0.014, -2.7*3.1415/180., sqrt(1. - 0.014*0.014 - 2.7*2.7*3.1415*3.1415/(180.*180.))); 00264 beamR = 0.5*(2.*geo.DetHalfHeight()*cos(0.05) + geo.DetLength()*sin(0.05)); 00265 epsilon = beamR - geo.DetLength()*sin(0.05); 00266 cx = 0.; 00267 cy = geo.DetHalfHeight()-epsilon*cos(0.05); 00268 cz = -epsilon*sin(0.05); 00269 } 00270 else if(fDetector == rawdata::kFar){ 00271 bdir.SetXYZ(0.014, 2.7*3.1415/180., sqrt(1. - 0.014*0.014 - 2.7*2.7*3.1415*3.1415/(180.*180.))); 00272 beamR = 0.5*(2.*geo.DetHalfHeight()*cos(0.05) + geo.DetLength()*sin(0.05)); 00273 epsilon = beamR - geo.DetLength()*sin(0.05); 00274 cx = 0.; 00275 cy = epsilon*cos(0.05)-geo.DetHalfHeight(); 00276 cz = -epsilon*sin(0.05); 00277 } 00279 TVector3 bspot(cx*1.e-2, cy*1.e-2, cz*1.e-2); 00280 00281 genie::flux::GCylindTH1Flux* histFlux = new genie::flux::GCylindTH1Flux(); 00282 00283 histFlux->SetNuDirection(bdir); 00284 histFlux->SetBeamSpot(bspot); 00285 histFlux->SetTransverseRadius(beamR*1.e-2); 00286 00287 std::cout << "beam r = " << beamR << " centered at (" 00288 << cx << "," << cy << "," << cz << ")" << std::endl; 00289 00291 for(unsigned int i = 0; i < fGenFlavors.size(); ++i){ 00292 if(fFluxHistograms[fFlavorMap[fGenFlavors[i]]]) 00293 histFlux->AddEnergySpectrum(fGenFlavors[i], fFluxHistograms[fFlavorMap[fGenFlavors[i]]]); 00294 } 00295 00296 fFluxD = dynamic_cast<genie::GFluxI *>(histFlux); 00297 }//end if using a histogram 00298 else if(fFluxType.compare("mono") == 0){ 00299 00301 double weight = 1./(1.*fGenFlavors.size()); 00302 //make a map of pdg to weight codes 00303 std::map<int, double> pdgwmap; 00304 for(unsigned int i = 0; i < fGenFlavors.size(); ++i) 00305 pdgwmap[fGenFlavors[i]] = weight; 00306 00307 genie::flux::GMonoEnergeticFlux *monoflux = new genie::flux::GMonoEnergeticFlux(fMonoEnergy, pdgwmap); 00308 fFluxD = dynamic_cast<genie::GFluxI *>(monoflux); 00309 }//end if using monoenergetic beam 00310 00311 return; 00312 }
|
|
get the geometry of the detector the detector geometry uses cgs units. casting to the GENIE geometry driver interface Definition at line 214 of file GENIEHelper.cxx. References fDetector, fGeomD, geo::Geometry::Instance(), and geo::Geometry::ROOTGeoManager(). Referenced by Initialize(). 00215 { 00217 geo::Geometry& geo = geo::Geometry::Instance(0, fDetector); 00218 00219 genie::geometry::ROOTGeomAnalyzer *rgeom = new genie::geometry::ROOTGeomAnalyzer(geo.ROOTGeoManager()); 00220 00222 rgeom->SetLengthUnits(genie::units::centimeter); 00223 rgeom->SetDensityUnits(genie::units::gram_centimeter3); 00224 00226 fGeomD = dynamic_cast<genie::GeomAnalyzerI *>(rgeom); 00227 return; 00228 }
|
|
check the vertex z position against the length of the detector if the neutrino interacts beyond the end of the detector, we dont need to save it in the file get the Interaction object from the record - this is the object that talks to the event information objects and is in m get the different components making up the interaction set whether it is NC or CC set the interaction type add the particles from the interaction GHepParticles return units of GeV/c for p. the V_i are all in fermis and are relative to the center of the struck nucleus. add the vertex X/Y/Z to the V_i for status codes 0 and 1 set the vertex location for the neutrino, nucleus and everything that is to be tracked. vertex returns values in meters. end loop to convert GHepParticles to TParticles Definition at line 364 of file GENIEHelper.cxx. References sim::MCTruth::Add(), geo::Geometry::DetLength(), fDetector, geo::Geometry::Instance(), sim::MCTruth::SetCCNC(), sim::MCTruth::SetMode(), and sim::MCTruth::SetNeutrino(). Referenced by Sample(). 00366 { 00367 00368 TLorentzVector *vertex = record->Vertex(); 00369 00370 //std::cout << "vertex loc " << vertex->X() << "," << vertex->Y() << "," << vertex->Z() << std::endl; 00371 00375 geo::Geometry& geo = geo::Geometry::Instance(0, fDetector); 00376 if(vertex->Z() > geo.DetLength()) return; 00377 00380 genie::Interaction *inter = record->Summary(); 00381 00383 const genie::InitialState &initState = inter->InitState(); 00384 const genie::ProcessInfo &procInfo = inter->ProcInfo(); 00385 const genie::Kinematics &kine = inter->Kine(); 00386 const genie::XclsTag &exclTag = inter->ExclTag(); 00387 const genie::KPhaseSpace &phaseSpace = inter->PhaseSpace(); 00388 00389 truth.SetNeutrino(initState.ProbePdg(), initState.GetProbeP4()->Energy()); 00390 00392 if(procInfo.IsWeakCC()) truth.SetCCNC(sim::kCC); 00393 else if(procInfo.IsWeakNC()) truth.SetCCNC(sim::kNC); 00394 00396 if(procInfo.IsQuasiElastic()) truth.SetMode(sim::kQE); 00397 else if(procInfo.IsDeepInelastic()) truth.SetMode(sim::kDIS); 00398 else if(procInfo.IsResonant()) truth.SetMode(sim::kRes); 00399 else if(procInfo.IsCoherent()) truth.SetMode(sim::kCoh); 00400 00402 TIter partitr(record); 00403 genie::GHepParticle *part = 0; 00407 while( (part = dynamic_cast<genie::GHepParticle *>(partitr.Next())) ){ 00408 TParticle tpart(part->Pdg(), part->Status(), 00409 part->FirstMother(), part->LastMother(), 00410 part->FirstDaughter(), part->LastDaughter(), 00411 part->Px(), part->Py(), part->Pz(), part->E(), 00412 part->Vx(), part->Vy(), part->Vz(), part->Vt()); 00413 00416 if(part->Status() == 0 || part->Status() == 1) 00417 tpart.SetProductionVertex(100.*(part->Vx()*1.e-15 + vertex->X()), 00418 100.*(part->Vy()*1.e-15 + vertex->Y()), 00419 100.*(part->Vz()*1.e-15 + vertex->Z()), 00420 part->Vt()); 00421 00422 truth.Add(tpart); 00423 00424 } 00425 00426 00427 00428 return; 00429 }
|
|
cast the fFluxD pointer to be of the right type Definition at line 353 of file GENIEHelper.cxx. Referenced by Sample(). 00354 { 00355 00357 genie::flux::GNuMIFlux *gnf = dynamic_cast<genie::flux::GNuMIFlux *>(fFluxD); 00358 const genie::flux::GNuMIFluxPassThroughInfo& nflux = gnf->PassThroughInfo(); 00359 00360 return; 00361 }
|
|
pack the flux information make sure you havent gone over the limit set the flag in the parent object that says the fluxes came from histograms and fill related values get the flux for each neutrino flavor of this energy make sure you havent gone over the limit Definition at line 315 of file GENIEHelper.cxx. References sim::MCTruth::Enu(), fDriver, fFluxHistograms, fFluxType, fTotalGen, kNue, kNueBar, kNuMu, kNuMuBar, kNuTau, kNuTauBar, PackMCTruth(), PackNuMIFlux(), and sim::MCTruth::SetFluxGen(). Referenced by main(). 00316 { 00317 genie::EventRecord* record = fDriver->GenerateEvent(); 00318 00319 if(!record) return false; 00320 00321 PackMCTruth(record, truth); 00322 00324 if(fFluxType.compare("ntuple") == 0) PackNuMIFlux(truth); 00325 else if(fFluxType.compare("histogram") == 0){ 00327 if(fTotalGen > fTotalRequested) return false; 00328 fTotalGen += 1.; 00329 00332 00333 int bin = fFluxHistograms[kNue]->FindBin(truth.Enu()); 00335 truth.SetFluxGen(fFluxHistograms[kNue]->GetBinContent(bin), 00336 fFluxHistograms[kNueBar]->GetBinContent(bin), 00337 fFluxHistograms[kNuMu]->GetBinContent(bin), 00338 fFluxHistograms[kNuMuBar]->GetBinContent(bin), 00339 fFluxHistograms[kNuTau]->GetBinContent(bin), 00340 fFluxHistograms[kNuTauBar]->GetBinContent(bin)); 00341 00342 } 00343 else if(fFluxType.compare("mono") == 0){ 00345 if(fTotalGen > fTotalRequested) return false; 00346 fTotalGen += 1.; 00347 } 00348 00349 return true; 00350 }
|
|
get a random number generator set the environment, the vector should come in pairs of variable name, then value figure out which detector you are using make the histograms get the detector mass and figure out how many events correspond to the requested POT if it is non-zero events = flux * pot * 10^-38 cm^2 (xsec) * mass detector (in kg) / carbon mass (in kg) integrate the flux from all species you are using end loop to add flux histograms to driver pick the number of events to generate out of a poisson distribution if doing the ipnd, account for the rock under the detector volume is now in cm^2, density of rock is 2.7 g/cm^3, convert to kg end if figuring out how many events given POT corresponds to Implements cfg::Observer. Definition at line 87 of file GENIEHelper.cxx. References geo::Geometry::DetLength(), fBeamName, fDetector, fEnvironment, fEvents, fFlavorMap, fFluxFile, fFluxHistograms, fFluxNormalization, fFluxType, fGenFlavors, fMonoEnergy, fPOT, fTotalRequested, util::RandomHandler::GetGenerator(), geo::Geometry::Instance(), and geo::Geometry::TotalMass(). 00088 { 00089 std::string geom; 00090 00091 c("FluxNormalization").Get(fFluxNormalization); 00092 c("Detector").Get(geom); 00093 c("FluxType").Get(fFluxType); 00094 c("FluxFile").Get(fFluxFile); 00095 c("BeamName").Get(fBeamName); 00096 c("Events").Get(fEvents); 00097 c("POT").Get(fPOT); 00098 c("MonoEnergy").Get(fMonoEnergy); 00099 c("GenFlavors").Get(fGenFlavors); 00100 c("Environment").Get(fEnvironment); 00101 00103 util::TRandomNOVA *rand = util::RandomHandler::GetGenerator(); 00104 TString junk = ""; 00105 junk += rand->Integer(100000000); 00106 std::string seed(junk); 00107 fEnvironment.push_back("GSEED"); 00108 fEnvironment.push_back(seed); 00110 for(unsigned int i = 0; i < fEnvironment.size(); i += 2){ 00111 gSystem->Setenv(fEnvironment[i].c_str(), fEnvironment[i+1].c_str()); 00112 std::cout << "setting GENIE environment " << fEnvironment[i] 00113 << " to " << fEnvironment[i+1] << std::endl; 00114 } 00115 00117 fDetector = rawdata::kIPND; 00118 if(geom.compare("near") == 0) fDetector = rawdata::kNear; 00119 else if(geom.compare("far") == 0) fDetector = rawdata::kFar; 00120 00121 if(fEvents > 0 && fPOT > 0.){ 00122 std::cerr << "cant specify both # of POT and # of events - using pot" << std::endl; 00123 } 00124 00125 fTotalRequested = 1.*fEvents; 00126 00128 if(fFluxType.compare("histogram") == 0){ 00129 TDirectory *savedir = gDirectory; 00130 00131 fFluxHistograms.resize(6); 00132 TFile tf(fFluxFile.c_str()); 00133 tf.ls(); 00134 00135 fFluxHistograms[kNue] = dynamic_cast<TH1D *>(tf.Get("nue")); 00136 fFluxHistograms[kNueBar] = dynamic_cast<TH1D *>(tf.Get("nuebar")); 00137 fFluxHistograms[kNuMu] = dynamic_cast<TH1D *>(tf.Get("numu")); 00138 fFluxHistograms[kNuMuBar] = dynamic_cast<TH1D *>(tf.Get("numubar")); 00139 fFluxHistograms[kNuTau] = dynamic_cast<TH1D *>(tf.Get("nutau")); 00140 fFluxHistograms[kNuTauBar] = dynamic_cast<TH1D *>(tf.Get("nutaubar")); 00141 00142 for(unsigned int i = 0; i < fFluxHistograms.size(); ++i) 00143 if(fFluxHistograms[i]) fFluxHistograms[i]->SetDirectory(savedir); 00144 00145 if(fPOT > 0.){ 00149 geo::Geometry& geo = geo::Geometry::Instance(0, fDetector); 00150 00151 double mass = geo.TotalMass(); 00152 double flux = 0.; 00153 00155 for(unsigned int i = 0; i < fGenFlavors.size(); ++i){ 00156 if(!fFluxHistograms[fFlavorMap[fGenFlavors[i]]]) continue; 00157 else flux += fFluxHistograms[fFlavorMap[fGenFlavors[i]]]->Integral(); 00158 } 00159 00162 fTotalRequested = rand->Poisson(flux*fPOT*mass*5.02e-13*1.e-20); 00163 00164 if(fDetector == rawdata::kIPND){ 00165 double length = geo.DetLength(); 00166 double vol = 3.141592654*(0.33*pow(length, 3.)*pow(sin(0.11)*cos(0.11), 2.) 00167 + pow(length, 3.)*pow(sin(0.11), 2.)*(pow(cos(0.11), 2.) - 1.)); 00169 double massrock = 2.7*vol*1.e-3; 00170 fTotalRequested = rand->Poisson(flux*fPOT*(mass+massrock)*5.02e-13*1.e-20); 00171 }//end if IPND 00172 00173 } 00174 00175 }//end if getting fluxes from histograms 00176 00177 std::cout << "Generating events for " << fFluxType.c_str() << " from " 00178 << fFluxFile.c_str() << " with an exposure of " 00179 << fTotalRequested << "(events)/" << fPOT 00180 << "(POT) in detector " << geom.c_str() << std::endl; 00181 00182 std::cout << "Generating the following flavors " << std::endl; 00183 for(unsigned int i = 0; i < fGenFlavors.size(); ++i) 00184 std::cout << " " << fGenFlavors[i] << std::endl; 00185 00186 if(fFluxType.compare("mono")==0) 00187 std::cout << "Generating monoenergetic (" << fMonoEnergy << " GeV) neutrinos" << std::endl; 00188 00189 return; 00190 }
|
|
name of file containing histograms or ntuples, or txt
Definition at line 57 of file GENIEHelper.h. Referenced by Update(). |
|
Definition at line 54 of file GENIEHelper.h. Referenced by InitializeFluxDriver(), InitializeGeometry(), PackMCTruth(), and Update(). |
|
Definition at line 52 of file GENIEHelper.h. Referenced by Initialize(), and Sample(). |
|
pdg codes for flavors to generate
Definition at line 67 of file GENIEHelper.h. Referenced by Update(). |
|
histograms for each nu species
Definition at line 60 of file GENIEHelper.h. Referenced by Update(). |
|
environmental variables and settings used by genie
Definition at line 68 of file GENIEHelper.h. Referenced by GENIEHelper(), InitializeFluxDriver(), and Update(). |
|
Definition at line 51 of file GENIEHelper.h. Referenced by Initialize(), and InitializeFluxDriver(). |
|
histogram or ntuple
Definition at line 56 of file GENIEHelper.h. Referenced by InitializeFluxDriver(), and Update(). |
|
name of the beam we are simulating
Definition at line 58 of file GENIEHelper.h. Referenced by InitializeFluxDriver(), Sample(), and Update(). |
|
total POT to generate
Definition at line 64 of file GENIEHelper.h. Referenced by InitializeFluxDriver(), and Update(). |
|
ipnd, nd, fd
Definition at line 55 of file GENIEHelper.h. Referenced by InitializeFluxDriver(), Sample(), and Update(). |
|
energy of monoenergetic neutrinos
Definition at line 66 of file GENIEHelper.h. Referenced by InitializeFluxDriver(), and Update(). |
|
Definition at line 50 of file GENIEHelper.h. Referenced by Initialize(), and InitializeGeometry(). |
|
POT per file.
Definition at line 65 of file GENIEHelper.h. Referenced by InitializeFluxDriver(), and Update(). |
|
total number of events/pot requested to be generated
Definition at line 63 of file GENIEHelper.h. Referenced by InitializeFluxDriver(), and Update(). |
|
number of events to generate
Definition at line 61 of file GENIEHelper.h. Referenced by Sample(). |
|
total number of events/pot generated to this point
Definition at line 62 of file GENIEHelper.h. Referenced by Update(). |