// $Id$ // // File: DEventProcessor_p3pi.cc // Created: Wed Jan 21 16:43:31 EST 2015 // Creator: jrsteven (on Linux ifarm1401 2.6.32-431.el6.x86_64 x86_64) // #include "DEventProcessor_p3pi.h" // Routine used to create our DEventProcessor extern "C" { void InitPlugin(JApplication *locApplication) { InitJANAPlugin(locApplication); locApplication->AddProcessor(new DEventProcessor_p3pi()); //register this plugin locApplication->AddFactoryGenerator(new DFactoryGenerator_p3pi()); //register the factory generator } } // "C" //------------------ // init //------------------ jerror_t DEventProcessor_p3pi::init(void) { // This is called once at program startup. If you are creating // and filling historgrams in this plugin, you should lock the // ROOT mutex like this: // // japp->RootWriteLock(); // ... create historgrams or trees ... // japp->RootUnLock(); // return NOERROR; } //------------------ // brun //------------------ jerror_t DEventProcessor_p3pi::brun(jana::JEventLoop* locEventLoop, int locRunNumber) { // This is called whenever the run number changes //Recommended: Create output ROOT TTrees (nothing is done if already created) const DEventWriterROOT* locEventWriterROOT = NULL; locEventLoop->GetSingle(locEventWriterROOT); locEventWriterROOT->Create_DataTrees(locEventLoop); return NOERROR; } //------------------ // evnt //------------------ jerror_t DEventProcessor_p3pi::evnt(jana::JEventLoop* locEventLoop, int locEventNumber) { // This is called for every event. Use of common resources like writing // to a file or filling a histogram should be mutex protected. Using // locEventLoop->Get(...) to get reconstructed objects (and thereby activating the // reconstruction algorithm) should be done outside of any mutex lock // since multiple threads may call this method at the same time. // // Here's an example: // // vector mydataclasses; // locEventLoop->Get(mydataclasses); // // japp->RootWriteLock(); // ... fill historgrams or trees ... // japp->RootUnLock(); // DOCUMENTATION: // ANALYSIS library: https://halldweb1.jlab.org/wiki/index.php/GlueX_Analysis_Software /*********************************************************** REQUIRED ***********************************************************/ //REQUIRED: To run an analysis, You MUST call one at least of the below code fragments. //JANA is on-demand, so if you don't call one of these, then your analysis won't run. //Recommended: Write surviving particle combinations (if any) to output ROOT TTree //If no cuts are performed by the analysis actions added to a DReaction, then this saves all of its particle combinations. //The event writer gets the DAnalysisResults objects from JANA, performing the analysis. // string is DReaction factory tag: will fill trees for all DReactions that are defined in the specified factory const DEventWriterROOT* locEventWriterROOT = NULL; locEventLoop->GetSingle(locEventWriterROOT); locEventWriterROOT->Fill_DataTrees(locEventLoop, "p3pi"); /* //Optional: Get the analysis results for all DReactions. //Getting these objects triggers the analysis, if it wasn't performed already. //These objects contain the DParticleCombo objects that survived the DAnalysisAction cuts that were added to the DReactions vector locAnalysisResultsVector; locEventLoop->Get(locAnalysisResultsVector); */ /*********************************************************** OPTIONAL ***********************************************************/ /* //Optional: Get all particle combinations for all DReactions. //If kinematic fits were requested, these contain both the measured and kinematic-fit track parameters //No cuts from DAnalysisActions are placed on these combos vector locParticleCombos; locEventLoop->Get(locParticleCombos); for(size_t loc_i = 0; loc_i < locParticleCombos.size(); ++loc_i) { const DParticleCombo* locParticleCombo = locParticleCombos[loc_i]; if(locParticleCombo->Get_Reaction()->Get_ReactionName() != "p3pi") continue; // particle combination was for a different reaction //perform further analysis steps here... } */ /* //Optional: Perform further cuts on the particle combos in the analysis results. for(size_t loc_i = 0; loc_i < locAnalysisResultsVector.size(); ++loc_i) { const DAnalysisResults* locAnalysisResults = locAnalysisResultsVector[loc_i]; if(locAnalysisResults->Get_Reaction()->Get_ReactionName() != "p3pi") continue; // analysis results were for a different reaction //get the DParticleCombo objects for this DReaction that survived all of the DAnalysisAction cuts deque locPassedParticleCombos; locAnalysisResults->Get_PassedParticleCombos(locPassedParticleCombos); for(size_t loc_j = 0; loc_j < locPassedParticleCombos.size(); ++loc_j) { const DParticleCombo* locPassedParticleCombo = locPassedParticleCombos[loc_j]; //perform further analysis steps here... } } */ /* //Optional: Save event to output REST file. Use this to create skims. const DEventWriterREST* locEventWriterREST = NULL; locEventLoop->GetSingle(locEventWriterREST); locEventLoop->Write_RESTEvent(locEventLoop, "p3pi"); //string is part of output file name */ return NOERROR; } //------------------ // erun //------------------ jerror_t DEventProcessor_p3pi::erun(void) { // This is called whenever the run number changes, before it is // changed to give you a chance to clean up before processing // events from the next run number. return NOERROR; } //------------------ // fini //------------------ jerror_t DEventProcessor_p3pi::fini(void) { // Called before program exit after event processing is finished. return NOERROR; }