// $Id$ // // File: DEventProcessor_n3pi_skim.cc // Created: Tue Apr 15 21:00:39 EDT 2014 // Creator: pmatt (on Darwin pmattLaptop 10.8.0 i386) // #include "DEventProcessor_n3pi_skim.h" // Routine used to create our DEventProcessor extern "C" { void InitPlugin(JApplication *locApplication) { InitJANAPlugin(locApplication); locApplication->AddProcessor(new DEventProcessor_n3pi_skim()); //register this plugin locApplication->AddFactoryGenerator(new DFactoryGenerator_n3pi_skim()); //register the factory generator } } // "C" //------------------ // init //------------------ jerror_t DEventProcessor_n3pi_skim::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(); // string locFileName = "eventlist_n3pi_skim.idxa"; dIDXAStream.open(locFileName.c_str()); dIDXAStream << "IDXA" << endl; return NOERROR; } //------------------ // brun //------------------ jerror_t DEventProcessor_n3pi_skim::brun(jana::JEventLoop* locEventLoop, int locRunNumber) { // This is called whenever the run number changes return NOERROR; } //------------------ // evnt //------------------ jerror_t DEventProcessor_n3pi_skim::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 //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); for(size_t loc_i = 0; loc_i < locAnalysisResultsVector.size(); ++loc_i) { const DAnalysisResults* locAnalysisResults = locAnalysisResultsVector[loc_i]; if(locAnalysisResults->Get_Reaction()->Get_ReactionName() != "n3pi_skim") continue; // analysis results were for a different reaction if(locAnalysisResults->Get_NumPassedParticleCombos() == 0) continue; JEvent& locEvent = locEventLoop->GetJEvent(); JEventSource* locEventSource = locEvent.GetJEventSource(); string locSourceName = locEventSource->GetSourceName(); string locFileNumberString = locSourceName.substr(locSourceName.size() - 12, 7); istringstream locIStream(locFileNumberString); unsigned int locFileNumber = 0; locIStream >> locFileNumber; dIDXAStream << locEvent.GetRunNumber() << " " << locEventNumber << " " << locFileNumber << endl; } return NOERROR; } //------------------ // erun //------------------ jerror_t DEventProcessor_n3pi_skim::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_n3pi_skim::fini(void) { // Called before program exit after event processing is finished. dIDXAStream.close(); return NOERROR; }