23 #include "art_root_io/TFileService.h" 37 #include "systematicstools/interface/ISystProviderTool.hh" 38 #include "systematicstools/utility/ParameterAndProviderConfigurationUtility.hh" 39 #include "systematicstools/utility/exceptions.hh" 104 double fEv,
fQ2,
fW,
fX,
fY,
fNuMomX,
fNuMomY,
fNuMomZ,
fLepMomX,
fLepMomY,
fLepMomZ,
fLepE,
fLepNuAngle;
106 int nP,
nN,
nPip,
nPim,
nPi0,
nKp,
nKm,
nK0,
nEM,
nOtherHad,
nNucleus,
nUNKNOWN;
177 fSystProviders = systtools::ConfigureISystProvidersFromParameterHeaders(syst_provider_config);
186 fTree = tfs->make<TTree>(
"caf",
"caf");
187 fMetaTree = tfs->make<TTree>(
"meta",
"meta");
212 fTree->Branch(
"W", &
fW,
"W/D");
213 fTree->Branch(
"X", &
fX,
"X/D");
214 fTree->Branch(
"Y", &
fY,
"Y/D");
217 fTree->Branch(
"nP", &
nP,
"nP/I");
218 fTree->Branch(
"nN", &
nN,
"nN/I");
219 fTree->Branch(
"nipip", &
nPip,
"nipip/I");
220 fTree->Branch(
"nipim", &
nPim,
"nipim/I");
221 fTree->Branch(
"nipi0", &
nPi0,
"nipi0/I");
222 fTree->Branch(
"nikp", &
nKp,
"nikp/I");
223 fTree->Branch(
"nikm", &
nKm,
"nikm/I");
224 fTree->Branch(
"nik0", &
nK0,
"nik0/I");
225 fTree->Branch(
"niem", &
nEM,
"niem/I");
229 fTree->Branch(
"eP", &
eP,
"eP/D");
230 fTree->Branch(
"eN", &
eN,
"eN/D");
283 fMetaTree->Branch(
"pot", &
meta_pot,
"pot/D");
284 fMetaTree->Branch(
"run", &
meta_run,
"run/I");
285 fMetaTree->Branch(
"subrun", &
meta_subrun,
"subrun/I");
286 fMetaTree->Branch(
"version", &
meta_version,
"version/I");
290 systtools::SystMetaData metaData = sp->GetSystMetaData();
292 systtools::SystParamHeader head = *itMeta;
294 unsigned int parId = head.systParamId;
295 std::cout <<
"Adding reweight branch " << parId <<
" for " << name <<
" with " << head.paramVariations.
size() <<
" shifts" <<
std::endl;
296 fTree->Branch( Form(
"%s_nshifts", name.c_str()), &
fNwgt[parId], Form(
"%s_nshifts/I", name.c_str()) );
297 fTree->Branch( Form(
"%s_cvwgt", name.c_str()), &
fCvWgts[parId], Form(
"%s_cvwgt/D", name.c_str()) );
298 fTree->Branch( Form(
"wgt_%s", name.c_str()),
fWgts[parId], Form(
"wgt_%s[%s_nshifts]/D", name.c_str(), name.c_str()) );
303 for(
int i = 0; i <
knShifts; ++i ) {
319 if( pots )
meta_pot += pots->totpot;
329 auto cvnin = evt.
getHandle<std::vector<cvn::Result>>(itag1);
331 auto regcnnin = evt.
getHandle<std::vector<cnn::RegCNNResult>>(itag2);
341 if( !pidin.failedToGet() ) {
345 fErecoNue = ereconuein->fNuLorentzVector.E();
357 if( !pidinnue.failedToGet() ) {
361 if( !pidinnumu.failedToGet() ) {
365 if( !cvnin.failedToGet() ) {
411 if(!regcnnin.failedToGet()){
412 if (!regcnnin->empty()){
413 const std::vector<float>& v = (*regcnnin)[0].fOutput;
418 std::vector< art::Ptr<simb::MCTruth> > truth;
419 auto mct = evt.
getHandle< std::vector<simb::MCTruth> >(
"generator");
425 std::vector< art::Ptr<simb::MCFlux> > flux;
426 auto mcf = evt.
getHandle< std::vector<simb::MCFlux> >(
"generator");
440 for(
size_t i=0; i<truth.size(); i++){
449 fIsCC = !(truth[i]->GetNeutrino().CCNC());
450 fNuPDG = truth[i]->GetNeutrino().Nu().PdgCode();
452 fMode = truth[i]->GetNeutrino().Mode();
453 fEv = truth[i]->GetNeutrino().Nu().E();
454 fQ2 = truth[i]->GetNeutrino().QSqr();
455 fW = truth[i]->GetNeutrino().W();
456 fX = truth[i]->GetNeutrino().X();
457 fY = truth[i]->GetNeutrino().Y();
458 fNuMomX = truth[i]->GetNeutrino().Nu().Momentum().X();
459 fNuMomY = truth[i]->GetNeutrino().Nu().Momentum().Y();
460 fNuMomZ = truth[i]->GetNeutrino().Nu().Momentum().Z();
462 vtx_x = truth[i]->GetNeutrino().Lepton().Vx();
463 vtx_y = truth[i]->GetNeutrino().Lepton().Vy();
464 vtx_z = truth[i]->GetNeutrino().Lepton().Vz();
467 fLepPDG = truth[i]->GetNeutrino().Lepton().PdgCode();
468 fLepMomX = truth[i]->GetNeutrino().Lepton().Momentum().X();
469 fLepMomY = truth[i]->GetNeutrino().Lepton().Momentum().Y();
470 fLepMomZ = truth[i]->GetNeutrino().Lepton().Momentum().Z();
471 fLepE = truth[i]->GetNeutrino().Lepton().Momentum().T();
472 fLepNuAngle = truth[i]->GetNeutrino().Nu().Momentum().Vect().Angle(truth[i]->GetNeutrino().Lepton().
Momentum().Vect());
499 for(
int p = 0;
p < truth[i]->NParticles();
p++ ) {
502 int pdg = truth[i]->GetParticle(
p).PdgCode();
503 double ke = truth[i]->GetParticle(
p).E() - truth[i]->GetParticle(
p).Mass();
554 std::unique_ptr<systtools::EventResponse> syst_resp = sp->GetEventResponse(evt);
556 std::cout <<
"[ERROR]: Got nullptr systtools::EventResponse from provider " 557 << sp->GetFullyQualifiedName();
562 systtools::event_unit_response_t resp = *itResp;
564 fNwgt[(*it).pid] = (*it).responses.size();
566 for(
unsigned int i = 0; i < (*it).responses.size(); ++i ) {
567 fWgts[(*it).pid][i] = (*it).responses[i];
double fCVNResult2Pizeros
systtools::provider_list_t fSystProviders
double fCVNResult1Protons
void analyze(art::Event const &evt) override
Handle< PROD > getHandle(SelectorBase const &) const
void beginSubRun(const art::SubRun &sr) override
double fCVNResult0Neutrons
double fCVNResult0Protons
double fCVNResultNPizeros
double fCVNResult2Protons
EDAnalyzer(fhicl::ParameterSet const &pset)
std::string fMVASelectNueLabel
object containing MC flux information
std::string fEnergyRecoNueLabel
#define DEFINE_ART_MODULE(klass)
double fCVNResultNProtons
int fLongestTrackContNumu
T get(std::string const &key) const
double fCVNResult0Pizeros
double fCVNResult2Neutrons
double fCVNResult1Pizeros
double fCVNResultIsAntineutrino
double fCVNResultNNeutrons
RegCNNResult for RegCNN modified from Result.h.
std::string fEnergyRecoNumuLabel
std::string fMVASelectNumuLabel
std::string fMVASelectLabel
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Position4_t fNuLorentzVector
EventNumber_t event() const
Position4_t fHadLorentzVector
double pid
How confident are we?
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
int longestTrackContained
static constexpr double sr
void reconfigure(fhicl::ParameterSet const &pset)
double fWgts[knShifts][kmaxRwgts]
Most commonly used PDG codes. A set of utility functions to handle PDG codes is provided in PDGUtils...
SubRunNumber_t subRun() const
double fCVNResult1Neutrons
QTextStream & endl(QTextStream &s)
Position4_t fLepLorentzVector
CAFMaker(fhicl::ParameterSet const &pset)
void endSubRun(const art::SubRun &sr) override