Difference between revisions of "Analysis JEventProcessor"
From GlueXWiki
(Created page with "== DEventProcessor_b1pi_hists.h == <syntaxhighlight> #ifndef _DEventProcessor_b1pi_hists_ #define _DEventProcessor_b1pi_hists_ #include "TFile.h" #include "TROOT.h" #include "J...") |
|||
Line 38: | Line 38: | ||
#endif // _DEventProcessor_b1pi_hists_ | #endif // _DEventProcessor_b1pi_hists_ | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | == DEventProcessor_b1pi_hists.cc == | ||
+ | <syntaxhighlight> | ||
+ | #include "DEventProcessor_b1pi_hists.h" | ||
+ | |||
+ | // Routine used to create our DEventProcessor | ||
+ | extern "C" | ||
+ | { | ||
+ | void InitPlugin(JApplication *app) | ||
+ | { | ||
+ | InitJANAPlugin(app); | ||
+ | app->AddProcessor(new DEventProcessor_b1pi_hists()); | ||
+ | app->AddFactoryGenerator(new DFactoryGenerator_DReaction()); | ||
+ | } | ||
+ | } // "C" | ||
+ | |||
+ | //------------------ | ||
+ | // init | ||
+ | //------------------ | ||
+ | jerror_t DEventProcessor_b1pi_hists::init(void) | ||
+ | { | ||
+ | return NOERROR; | ||
+ | } | ||
+ | |||
+ | //------------------ | ||
+ | // brun | ||
+ | //------------------ | ||
+ | jerror_t DEventProcessor_b1pi_hists::brun(JEventLoop *locEventLoop, int runnumber) | ||
+ | { | ||
+ | return NOERROR; | ||
+ | } | ||
+ | |||
+ | //------------------ | ||
+ | // evnt | ||
+ | //------------------ | ||
+ | jerror_t DEventProcessor_b1pi_hists::evnt(JEventLoop *locEventLoop, int eventnumber) | ||
+ | { | ||
+ | //Fill reaction-independent histograms. | ||
+ | dHistogramAction_TrackMultiplicity(locEventLoop); | ||
+ | dHistogramAction_ThrownParticleKinematics(locEventLoop); | ||
+ | dHistogramAction_DetectedParticleKinematics(locEventLoop); | ||
+ | dHistogramAction_GenReconTrackComparison(locEventLoop); | ||
+ | |||
+ | vector<const DAnalysisResults*> locAnalysisResultsVector; | ||
+ | locEventLoop->Get(locAnalysisResultsVector); | ||
+ | |||
+ | bool locSaveEventFlag = false; | ||
+ | for(size_t loc_i = 0; loc_i < locAnalysisResultsVector.size(); ++loc_i) | ||
+ | { | ||
+ | const DAnalysisResults* locAnalysisResults = locAnalysisResultsVector[loc_i]; | ||
+ | if(locAnalysisResults->Get_Reaction()->Get_ReactionName() != "b1pi") | ||
+ | continue; | ||
+ | if(locAnalysisResults->Get_NumPassedParticleCombos() == 0) | ||
+ | continue; | ||
+ | locSaveEventFlag = true; | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | if(locSaveEventFlag) | ||
+ | { | ||
+ | vector<const DEventWriterREST*> locEventWriterRESTVector; | ||
+ | locEventLoop->Get(locEventWriterRESTVector); | ||
+ | locEventWriterRESTVector[0]->Write_RESTEvent(locEventLoop, "b1pi"); | ||
+ | } | ||
+ | |||
+ | return NOERROR; | ||
+ | } | ||
+ | |||
+ | //------------------ | ||
+ | // erun | ||
+ | //------------------ | ||
+ | jerror_t DEventProcessor_b1pi_hists::erun(void) | ||
+ | { | ||
+ | // Any final calculations on histograms (like dividing them) | ||
+ | // should be done here. This may get called more than once. | ||
+ | return NOERROR; | ||
+ | } | ||
+ | |||
+ | //------------------ | ||
+ | // fini | ||
+ | //------------------ | ||
+ | jerror_t DEventProcessor_b1pi_hists::fini(void) | ||
+ | { | ||
+ | return NOERROR; | ||
+ | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 23:01, 17 February 2013
DEventProcessor_b1pi_hists.h
#ifndef _DEventProcessor_b1pi_hists_ #define _DEventProcessor_b1pi_hists_ #include "TFile.h" #include "TROOT.h" #include "JANA/JEventProcessor.h" #include "DANA/DApplication.h" #include "ANALYSIS/DAnalysisResults.h" #include "HDDM/DEventWriterREST.h" #include "DFactoryGenerator_DReaction.h" using namespace jana; class DEventProcessor_b1pi_hists : public JEventProcessor { public: DEventProcessor_b1pi_hists(){}; ~DEventProcessor_b1pi_hists(){}; const char* className(void){return "DEventProcessor_b1pi_hists";} private: jerror_t init(void); ///< Called once at program start. jerror_t brun(JEventLoop *eventLoop, int runnumber); ///< Called everytime a new run number is detected. jerror_t evnt(JEventLoop *eventLoop, int eventnumber); ///< Called every event. jerror_t erun(void); ///< Called everytime run number changes, provided brun has been called. jerror_t fini(void); ///< Called after last event of last event source has been processed. DHistogramAction_TrackMultiplicity dHistogramAction_TrackMultiplicity; DHistogramAction_ThrownParticleKinematics dHistogramAction_ThrownParticleKinematics; DHistogramAction_DetectedParticleKinematics dHistogramAction_DetectedParticleKinematics; DHistogramAction_GenReconTrackComparison dHistogramAction_GenReconTrackComparison; }; #endif // _DEventProcessor_b1pi_hists_
DEventProcessor_b1pi_hists.cc
#include "DEventProcessor_b1pi_hists.h" // Routine used to create our DEventProcessor extern "C" { void InitPlugin(JApplication *app) { InitJANAPlugin(app); app->AddProcessor(new DEventProcessor_b1pi_hists()); app->AddFactoryGenerator(new DFactoryGenerator_DReaction()); } } // "C" //------------------ // init //------------------ jerror_t DEventProcessor_b1pi_hists::init(void) { return NOERROR; } //------------------ // brun //------------------ jerror_t DEventProcessor_b1pi_hists::brun(JEventLoop *locEventLoop, int runnumber) { return NOERROR; } //------------------ // evnt //------------------ jerror_t DEventProcessor_b1pi_hists::evnt(JEventLoop *locEventLoop, int eventnumber) { //Fill reaction-independent histograms. dHistogramAction_TrackMultiplicity(locEventLoop); dHistogramAction_ThrownParticleKinematics(locEventLoop); dHistogramAction_DetectedParticleKinematics(locEventLoop); dHistogramAction_GenReconTrackComparison(locEventLoop); vector<const DAnalysisResults*> locAnalysisResultsVector; locEventLoop->Get(locAnalysisResultsVector); bool locSaveEventFlag = false; for(size_t loc_i = 0; loc_i < locAnalysisResultsVector.size(); ++loc_i) { const DAnalysisResults* locAnalysisResults = locAnalysisResultsVector[loc_i]; if(locAnalysisResults->Get_Reaction()->Get_ReactionName() != "b1pi") continue; if(locAnalysisResults->Get_NumPassedParticleCombos() == 0) continue; locSaveEventFlag = true; break; } if(locSaveEventFlag) { vector<const DEventWriterREST*> locEventWriterRESTVector; locEventLoop->Get(locEventWriterRESTVector); locEventWriterRESTVector[0]->Write_RESTEvent(locEventLoop, "b1pi"); } return NOERROR; } //------------------ // erun //------------------ jerror_t DEventProcessor_b1pi_hists::erun(void) { // Any final calculations on histograms (like dividing them) // should be done here. This may get called more than once. return NOERROR; } //------------------ // fini //------------------ jerror_t DEventProcessor_b1pi_hists::fini(void) { return NOERROR; }