16 xlow = - geom -> DetHalfWidth();
17 xhigh = geom -> DetHalfWidth();
18 ylow = - geom -> DetHalfHeight();
19 yhigh = geom -> DetHalfHeight();
21 zhigh = geom -> DetLength();
23 if (geom -> DetectorName() ==
"uboone_basic"){
28 std::cout <<
"The dimensions of this detector are read to be:\n"
29 <<
" x: " <<
xlow <<
" to " <<
xhigh <<
"\n"
30 <<
" y: " <<
ylow <<
" to " <<
yhigh <<
"\n"
31 <<
" z: " <<
zlow <<
" to " <<
zhigh <<
"\n";
45 const std::vector<std::vector<float>>& reweightingSigmas){
58 for (
auto & ptr :
reweightVector.back()) ptr =
new rwgt::NuReweight;
60 for (
unsigned int i_weight = 0; i_weight < reweightingSigmas.front().size(); ++i_weight)
65 -> ReweightQEMA(reweightingSigmas[
kQEMA][i_weight]);
69 -> ReweightResGanged(reweightingSigmas[
kResGanged][i_weight]);
71 -> ReweightCCRes(reweightingSigmas[
kCCRes][i_weight]);
73 -> ReweightNCRes(reweightingSigmas[
kNCRes][i_weight]);
77 -> ReweightNonResRvp1pi(reweightingSigmas[
kNonResRvp1pi][i_weight]);
81 -> ReweightNonResRvp2pi(reweightingSigmas[
kNonResRvp2pi][i_weight]);
87 -> ReweightNC(reweightingSigmas[
kNC][i_weight]);
91 -> ReweightDISnucl(reweightingSigmas[
kDISnucl][i_weight]);
98 for (
unsigned int i_reweightingKnob = 0;
105 reweightingSigmas[i_reweightingKnob].
size());
107 for (
unsigned int weight_point = 0;
108 weight_point < reweightingSigmas[i_reweightingKnob].size();
117 reweightVector[i_reweightingKnob][weight_point] =
new rwgt::NuReweight;
119 switch (weights[i_reweightingKnob]){
126 -> ReweightQEMA(reweightingSigmas[
kQEMA][weight_point]);
130 -> ReweightQEVec(reweightingSigmas[
kQEVec][weight_point]);
134 -> ReweightResGanged(reweightingSigmas[
kResGanged][weight_point]);
138 -> ReweightCCRes(reweightingSigmas[
kCCRes][weight_point]);
142 -> ReweightNCRes(reweightingSigmas[
kNCRes][weight_point]);
150 -> ReweightNonResRvp1pi(reweightingSigmas[
kNonResRvp1pi][weight_point]);
154 -> ReweightNonResRvbarp1pi(reweightingSigmas[
kNonResRvbarp1pi][weight_point]);
158 -> ReweightNonResRvp2pi(reweightingSigmas[
kNonResRvp2pi][weight_point]);
162 -> ReweightNonResRvbarp2pi(reweightingSigmas[
kNonResRvbarp2pi][weight_point]);
170 -> ReweightNC(reweightingSigmas[
kNC][weight_point]);
178 -> ReweightDISnucl(reweightingSigmas[
kDISnucl][weight_point]);
212 unsigned int RandSeed,
213 std::vector<std::vector<float> > & reweightingSigmas)
217 rand.SetSeed(RandSeed);
220 for (
unsigned int i = 0; i < reweightingSigmas.size(); ++i)
222 reweightingSigmas[i].resize(NWeights);
223 for (
int j = 0; j < NWeights; j ++)
224 reweightingSigmas[i][j] = rand.Gaus(0,1);
226 return rand.GetSeed();
230 std::vector<reweight> & enum_weights){
232 enum_weights.reserve(string_weights.size());
233 for(
auto &
s : string_weights){
234 if (
s ==
"NCEL") enum_weights.push_back(
kNCEL);
235 else if (
s ==
"QEMA") enum_weights.push_back(
kQEMA);
236 else if (
s ==
"QEVec") enum_weights.push_back(
kQEVec);
237 else if (
s ==
"ResGanged") enum_weights.push_back(
kResGanged);
238 else if (
s ==
"CCRes") enum_weights.push_back(
kCCRes);
239 else if (
s ==
"NCRes") enum_weights.push_back(
kNCRes);
240 else if (
s ==
"Coh") enum_weights.push_back(
kCoh);
241 else if (
s ==
"NonResRvp1pi") enum_weights.push_back(
kNonResRvp1pi);
243 else if (
s ==
"NonResRvp2pi") enum_weights.push_back(
kNonResRvp2pi);
245 else if (
s ==
"ResDecay") enum_weights.push_back(
kResDecay);
246 else if (
s ==
"NC") enum_weights.push_back(
kNC);
247 else if (
s ==
"DIS") enum_weights.push_back(
kDIS);
248 else if (
s ==
"DISnucl") enum_weights.push_back(
kDISnucl);
249 else if (
s ==
"AGKY") enum_weights.push_back(
kAGKY);
258 art::Ptr<simb::GTruth > gtruth,
268 for (
unsigned int i_weight = 0; i_weight <
reweightVector.size(); i_weight ++){
272 for (
unsigned int i_reweightingKnob = 0;
274 i_reweightingKnob ++)
276 weights[i_weight][i_reweightingKnob]
278 -> CalcWeight(*mctruth,*gtruth);
296 std::vector<float>& neutMom,
297 std::vector<float>&
vertex){
307 nuchan = (neutrino->InteractionType() - 1000);
308 inno = neutrino->Nu().PdgCode();
309 enugen = neutrino->Nu().E();
311 if (neutrino->CCNC()==
simb::kCC) isCC = 1;
312 else if (neutrino->CCNC()==
simb::kNC) isCC = 0;
313 mode = neutrino->Mode();
315 simb::MCParticle lepton = neutrino->Lepton();
317 double tempNumerator = lepton.Px()*lepton.Px() + lepton.Py()*lepton.Py();
318 thetaLep = atan(sqrt(tempNumerator)/lepton.Pz());
319 phiLep = atan(lepton.Px()/lepton.Py());
322 vertex[0] = neutrino->Nu().Position().X();
323 vertex[1] = neutrino->Nu().Position().Y();
324 vertex[2] = neutrino->Nu().Position().Z();
325 neutMom[0] = neutrino->Nu().Momentum().E();
326 neutMom[1] = neutrino->Nu().Momentum().X();
327 neutMom[2] = neutrino->Nu().Momentum().Y();
328 neutMom[3] = neutrino->Nu().Momentum().Z();
334 int& ptype,
int& tptype,
int& ndecay,
335 std::vector<float>& neutVertexInWindow,
336 std::vector<float>& ParentVertex,
337 std::vector<float>& nuParentMomAtDecay,
338 std::vector<float>& nuParentMomAtProd,
339 std::vector<float>& nuParentMomTargetExit){
341 ptype = flux -> fptype;
342 tptype = flux->ftptype;
343 ndecay = flux->fndecay;
345 neutVertexInWindow.clear();
346 ParentVertex.clear();
347 nuParentMomAtDecay.clear();
348 nuParentMomAtProd.clear();
349 nuParentMomTargetExit.clear();
351 neutVertexInWindow.push_back(flux -> fgenx);
352 neutVertexInWindow.push_back(flux -> fgeny);
353 neutVertexInWindow.push_back(flux -> fgenz);
354 ParentVertex.push_back(flux -> fvx);
355 ParentVertex.push_back(flux -> fvy);
356 ParentVertex.push_back(flux -> fvz);
357 nuParentMomAtDecay.push_back(flux -> fpdpx);
358 nuParentMomAtDecay.push_back(flux -> fpdpy);
359 nuParentMomAtDecay.push_back(flux -> fpdpz);
360 nuParentMomAtProd.push_back(flux -> fppdxdz);
361 nuParentMomAtProd.push_back(flux -> fppdydz);
362 nuParentMomAtProd.push_back(flux -> fpppz);
363 nuParentMomTargetExit.push_back(flux -> ftpx);
364 nuParentMomTargetExit.push_back(flux -> ftpy);
365 nuParentMomTargetExit.push_back(flux -> ftpz);
372 std::vector<int> & GeniePDG,
374 std::vector<std::string>& GenieProc,
379 std::vector<float> tempMomentum;
380 tempMomentum.resize(4);
381 while( i < truth -> NParticles()){
382 auto part = truth -> GetParticle(i);
383 if (part.StatusCode() == 1){
384 GeniePDG.push_back(part.PdgCode());
385 GenieMomentum.push_back(tempMomentum);
387 GenieProc.push_back(part.Process());
388 if (part.PdgCode() == 22) NGamma ++;
389 if (part.PdgCode() == 111) NPi0FinalState ++;
390 if (
abs(part.PdgCode()) == 211) NChargedPions ++;
397 art::Handle< std::vector<simb::MCParticle> > & mclistLARG4,
400 for(
unsigned int i = 0; i < mclistLARG4 ->
size(); i ++){
401 art::Ptr<simb::MCParticle> particle(mclistLARG4,i);
402 if ( particle -> TrackId() == TrackId){
406 art::Ptr<simb::MCParticle> part;
410 art::Handle< std::vector<simb::MCParticle> > & mclistLARG4,
414 for(
unsigned int i = 0; i < mclistLARG4 ->
size(); i ++){
415 art::Ptr<simb::MCParticle> particle(mclistLARG4,i);
416 if ( particle -> PdgCode() == PDG){
420 art::Ptr<simb::MCParticle> part;
424 if (v.X() >
xhigh || v.X() <
xlow)
return false;
425 if (v.Y() >
yhigh || v.Y() <
ylow)
return false;
426 if (v.Z() >
zhigh || v.Z() <
zlow)
return false;
433 TLorentzVector& ConversionPos,
434 TLorentzVector& ConversionMom){
443 double E = photon->E(0);
456 if (photon->NumberTrajectoryPoints() == 0)
return;
457 if (photon->NumberTrajectoryPoints() == 1){
458 ConversionPos = photon->EndPosition();
459 ConversionMom = photon->EndMomentum();
463 for(
unsigned int i = 1; i < photon->NumberTrajectoryPoints(); i ++){
475 if (photon->E(i) !=
E) {
478 ConversionPos = photon->Position(i);
479 ConversionMom = photon->Momentum(i-1);
487 ConversionPos = photon->EndPosition();
488 ConversionMom = photon->EndMomentum();
494 int NPi0FinalState,
int NGamma,
int NChargedPions,
497 std::vector<std::vector<float>> & p1PhotonConversionPos,
498 std::vector<std::vector<float>> & p1PhotonConversionMom,
499 std::vector<std::vector<float>> & p2PhotonConversionPos,
500 std::vector<std::vector<float>> & p2PhotonConversionMom,
501 std::vector<std::vector<float>> & miscPhotonConversionPos,
502 std::vector<std::vector<float>> & miscPhotonConversionMom,
507 std::vector<int> & chargedPionSign)
513 std::vector<float> empty4Vector;
514 empty4Vector.resize(4);
517 p1PhotonConversionPos.reserve(NPi0FinalState);
518 p1PhotonConversionMom.reserve(NPi0FinalState);
519 p2PhotonConversionPos.reserve(NPi0FinalState);
520 p2PhotonConversionMom.reserve(NPi0FinalState);
521 pionPos.reserve(NPi0FinalState);
522 pionMom.reserve(NPi0FinalState);
523 miscPhotonConversionPos.reserve(NGamma);
524 miscPhotonConversionMom.reserve(NGamma);
527 int nPrimaryLepton(0);
528 int nPrimaryGamma(0);
531 chargedPionPos.resize(NChargedPions);
532 chargedPionMom.resize(NChargedPions);
536 for (
unsigned int i = 0; i < mclarg4 ->
size(); i ++){
537 art::Ptr<simb::MCParticle> particle(mclarg4,i);
541 if (particle -> Mother() == 0 ){
546 if (isCC == 0) nPrimaryLepton ++;
548 if (
abs(particle -> PdgCode()) == 11 ||
549 abs(particle -> PdgCode()) == 12 ||
550 abs(particle -> PdgCode()) == 13 ||
551 abs(particle -> PdgCode()) == 14 )
556 int nTrajectoryPoints = particle -> NumberTrajectoryPoints();
557 leptonPos.reserve(nTrajectoryPoints);
558 leptonMom.reserve(nTrajectoryPoints);
559 for (
int traj_point = 0; traj_point < nTrajectoryPoints; ++traj_point){
560 leptonPos.push_back(empty4Vector);
561 pack4Vector(particle -> Position(traj_point),leptonPos.back());
562 leptonMom.push_back(empty4Vector);
563 pack4Vector(particle -> Momentum(traj_point),leptonMom.back());
564 if (!
isInTPC(particle -> Position(traj_point).Vect()))
break;
568 if (particle -> PdgCode() == 22)
571 TLorentzVector conversionPoint, conversionMom;
573 miscPhotonConversionPos.push_back(empty4Vector);
574 miscPhotonConversionMom.push_back(empty4Vector);
575 pack4Vector(conversionPoint,miscPhotonConversionPos.back());
576 pack4Vector(conversionMom, miscPhotonConversionMom.back());
579 if (particle -> PdgCode() == 111)
581 pionPos.push_back(empty4Vector);
582 pionMom.push_back(empty4Vector);
583 pack4Vector(particle->EndPosition(),pionPos.back());
587 if ( particle -> NumberDaughters() == 2){
589 TLorentzVector conversionPoint, conversionMom;
590 art::Ptr<simb::MCParticle> daughter0
594 p1PhotonConversionPos.push_back(empty4Vector);
595 p1PhotonConversionMom.push_back(empty4Vector);
596 pack4Vector(conversionPoint,p1PhotonConversionPos.back());
597 pack4Vector(conversionMom, p1PhotonConversionMom.back());
600 art::Ptr<simb::MCParticle> daughter1
604 p2PhotonConversionPos.push_back(empty4Vector);
605 p2PhotonConversionMom.push_back(empty4Vector);
606 pack4Vector(conversionPoint,p2PhotonConversionPos.back());
607 pack4Vector(conversionMom, p2PhotonConversionMom.back());
611 TLorentzVector conversionPoint, conversionMom;
612 p2PhotonConversionPos.push_back(empty4Vector);
613 p2PhotonConversionMom.push_back(empty4Vector);
614 for (
int daughter = 0; daughter < 3; daughter ++ ){
615 art::Ptr<simb::MCParticle> daughterParticle
617 if (daughterParticle->PdgCode() == 22) {
621 p1PhotonConversionPos.push_back(empty4Vector);
622 p1PhotonConversionMom.push_back(empty4Vector);
623 pack4Vector(conversionPoint,p1PhotonConversionPos.back());
624 pack4Vector(conversionMom, p1PhotonConversionMom.back());
632 if (
abs(particle -> PdgCode()) == 211)
634 chargedPionSign.push_back(particle ->PdgCode() / 211);
635 int nTrajectoryPoints = particle -> NumberTrajectoryPoints();
636 unsigned int index = chargedPionSign.size() - 1;
637 chargedPionPos[index].reserve(nTrajectoryPoints);
638 chargedPionMom[index].reserve(nTrajectoryPoints);
639 for (
int traj_point = 0; traj_point < nTrajectoryPoints; ++ traj_point){
640 chargedPionPos[index].push_back(empty4Vector);
642 chargedPionPos[index].back());
643 chargedPionMom[index].push_back(empty4Vector);
645 chargedPionMom[index].back());
657 if (nPrimaryGamma != NGamma){
658 std::cerr <<
"Major problems here ... nPrimaryGamma\n"
659 <<
" Should be " << NGamma
660 <<
" but is " << nPrimaryGamma <<
"\n";
663 if (nPrimaryPi0 != NPi0FinalState){
664 std::cerr <<
"Major problems here ... nPrimaryPi0\n"
665 <<
" Should be " << NPi0FinalState
666 <<
" but is " << nPrimaryPi0 <<
"\n";
672 std::vector<float>&
output)
const{
673 if (output.size() != 4) output.resize(4);
674 output[0] = input.E();
675 output[1] = input.X();
676 output[2] = input.Y();
677 output[3] = input.Z();
681 std::vector<float>&
output)
const{
682 if (output.size() != 3) output.resize(3);
683 output[0] = input.X();
684 output[1] = input.Y();
685 output[2] = input.Z();
690 #ifdef CUSTOM_NUTOOLS
697 eventReweight.clear();
698 eventReweight.resize(7);
699 for (
int i = 0; i < 7; i ++)
701 eventReweight[i].resize(1000);
702 for (
int j = 0; j < 1000; ++j)
704 eventReweight[i][j]=flux->eventReweight[i*1000+j];
716 std::cerr <<
"You are asking to pack flux weights but the version "
717 <<
"of nutools you use does not appear to support it.\n";
void pack4Vector(const TLorentzVector &input, std::vector< float > &output) const
void GetPhotonConversionInfo(art::Ptr< simb::MCParticle > photon, TLorentzVector &ConversionPos, TLorentzVector &ConversionMom)
process_name stream1 can override from command line with o or output services DetectorPropertiesService services DetectorPropertiesService services DetectorPropertiesService services DetectorPropertiesService physics analyzers pmtresponse NeutronTrackingCut services LArG4Parameters gaussian physics producers generator PDG
process_name can override from command line with o or output photon
bool isInTPC(const TVector3 &) const
BEGIN_PROLOG could also be cerr
art::Ptr< simb::MCParticle > getParticleByPDG(art::Handle< std::vector< simb::MCParticle > > &mclistLARG4, int) const
std::size_t size(FixedBins< T, C > const &) noexcept
void packFluxWeight(art::Ptr< simb::MCFlux > flux, std::vector< std::vector< float >> &)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Charged-current interactions.
void configureReWeight(const std::vector< reweight > &, const std::vector< std::vector< float >> &)
void packGenieInfo(art::Ptr< simb::MCTruth > truth, std::vector< int > &GeniePDG, std::vector< std::vector< float >> &GenieMomentum, std::vector< std::string > &GenieProc, int &NPi0FinalState, int &NGamma, int &NChargedPions)
void packFluxInfo(art::Ptr< simb::MCFlux > flux, int &ptype, int &tptype, int &ndecay, std::vector< float > &neutVertexInWindow, std::vector< float > &ParentVertex, std::vector< float > &nuParentMomAtDecay, std::vector< float > &nuParentMomAtProd, std::vector< float > &nuParentMomTargetExit)
art::Ptr< simb::MCParticle > getParticleByID(art::Handle< std::vector< simb::MCParticle > > &mclistLARG4, int) const
void pack3Vector(const TVector3 &input, std::vector< float > &output) const
void packLarg4Info(art::Handle< std::vector< simb::MCParticle > > mclarg4, int, int, int, int, std::vector< std::vector< float > > &leptonPos, std::vector< std::vector< float > > &leptonMom, std::vector< std::vector< float > > &p1PhotonConversionPos, std::vector< std::vector< float > > &p1PhotonConversionMom, std::vector< std::vector< float > > &p2PhotonConversionPos, std::vector< std::vector< float > > &p2PhotonConversionMom, std::vector< std::vector< float > > &miscPhotonConversionPos, std::vector< std::vector< float > > &miscPhotonConversionMom, std::vector< std::vector< float > > &pionPos, std::vector< std::vector< float > > &pionMom, std::vector< std::vector< std::vector< float > > > &chargedPionPos, std::vector< std::vector< std::vector< float > > > &chargedPionMom, std::vector< int > &chargePionSign)
then echo File list $list not found else cat $list while read file do echo $file sed s
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
Neutral-current interactions.
void configureGeometry(art::ServiceHandle< geo::Geometry >)
void parseWeights(const std::vector< std::string > &, std::vector< reweight > &)
stream1 can override from command line with o or output services user sbnd
unsigned int prepareSigmas(int, unsigned int, std::vector< std::vector< float > > &)
std::vector< std::vector< rwgt::NuReweight * > > reweightVector
void packNeutrinoInfo(simb::MCNeutrino *neutrino, int &nuchan, int &inno, double &enugen, int &isCC, int &mode, double &thetaLep, double &phiLep, double &Elep, std::vector< float > &neutMom, std::vector< float > &vertex)
void calcWeight(art::Ptr< simb::MCTruth >, art::Ptr< simb::GTruth >, std::vector< std::vector< float >> &)
BEGIN_PROLOG could also be cout