// $Id$ // // File: DEventProcessor_ksz_k0.cc // Created: Mon Jul 8 14:22:11 EDT 2013 // Creator: pmatt (on Darwin pmattLaptop 10.8.0 i386) // #include "DEventProcessor_ksz_k0.h" // Routine used to create our DEventProcessor extern "C" { void InitPlugin(JApplication *locApplication) { InitJANAPlugin(locApplication); locApplication->AddProcessor(new DEventProcessor_ksz_k0()); //register this plugin locApplication->AddFactoryGenerator(new DFactoryGenerator_ksz_k0()); //register the factory generator } } // "C" //------------------ // init //------------------ jerror_t DEventProcessor_ksz_k0::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_ksz_k0::brun(jana::JEventLoop* locEventLoop, int locRunNumber) { // This is called whenever the run number changes //Recommeded: Initialize reaction-independent analysis actions (nothing should be done if already initialized) dHistogramAction_TrackMultiplicity.Initialize(locEventLoop); dHistogramAction_ThrownParticleKinematics.Initialize(locEventLoop); dHistogramAction_DetectedParticleKinematics.Initialize(locEventLoop); dHistogramAction_GenReconTrackComparison.Initialize(locEventLoop); //Recommeded: 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_ksz_k0::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 // loop->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; // loop->Get(mydataclasses); // // japp->RootWriteLock(); // ... fill historgrams or trees ... // japp->RootUnLock(); // DOCUMENTATION: // ANALYSIS library: https://halldweb1.jlab.org/wiki/index.php/GlueX_Analysis_Software //Recommended: Execute reaction-independent actions (fill histograms) dHistogramAction_TrackMultiplicity(locEventLoop); dHistogramAction_ThrownParticleKinematics(locEventLoop); dHistogramAction_DetectedParticleKinematics(locEventLoop); dHistogramAction_GenReconTrackComparison(locEventLoop); //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. const DEventWriterROOT* locEventWriterROOT = NULL; locEventLoop->GetSingle(locEventWriterROOT); // string is DReaction factory tag: will fill trees for all DReactions that are defined in the specified factory locEventWriterROOT->Fill_DataTrees(locEventLoop, "ksz_k0"); return NOERROR; } //------------------ // erun //------------------ jerror_t DEventProcessor_ksz_k0::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_ksz_k0::fini(void) { // Called before program exit after event processing is finished. return NOERROR; }