// $Id$ // // File: DCustomAction_CALCut.cc // Created: Tue Jul 26 12:29:29 EDT 2016 // Creator: nsparks (on Linux cua2.jlab.org 3.10.0-327.22.2.el7.x86_64 x86_64) // #include "DCustomAction_CALCut.h" void DCustomAction_CALCut::Initialize(JEventLoop* locEventLoop) { /* //Optional: Create histograms and/or modify member variables. //Create any histograms/trees/etc. within a ROOT lock. //This is so that when running multithreaded, only one thread is writing to the ROOT file at a time. //NEVER: Get anything from the JEventLoop while in a lock: May deadlock //CREATE THE HISTOGRAMS //Since we are creating histograms, the contents of gDirectory will be modified: must use JANA-wide ROOT lock japp->RootWriteLock(); //ACQUIRE ROOT LOCK!! { //Required: Create a folder in the ROOT output file that will contain all of the output ROOT objects (if any) for this action. //If another thread has already created the folder, it just changes to it. CreateAndChangeTo_ActionDirectory(); // Optional: Create a ROOT subfolder. //If another thread has already created the folder, it just changes to it. // CreateAndChangeTo_Directory("MyDirName", "MyDirTitle"); //make sub-directory content here // gDirectory->cd(".."); //return to the action directory // (Optional) Example: Create a histogram. // This function will return the histogram if already created by another thread. If not pre-existing, it will create and return it. // Function arguments are identical to those used for the histogram constructors // dMyHist = GetOrCreate_Histogram("MyHistName", "MyHistTitle", 100, 0.0, 1.0); } japp->RootUnLock(); //RELEASE ROOT LOCK!! */ } bool DCustomAction_CALCut::Perform_Action(JEventLoop* locEventLoop, const DParticleCombo* locParticleCombo) { //Write custom code to perform an action on the INPUT DParticleCombo (DParticleCombo) //NEVER: Grab DParticleCombo or DAnalysisResults objects (of any tag!) from the JEventLoop within this function //NEVER: Grab objects that are created post-kinfit (e.g. DKinFitResults, etc.) from the JEventLoop if Get_UseKinFitResultsFlag() == false: CAN CAUSE INFINITE DEPENDENCY LOOP //NEVER: Get anything from the JEventLoop while in a lock: May deadlock deque locParticles; locParticleCombo->Get_DetectedFinalNeutralParticles_Measured(locParticles); for(size_t loc_i = 0; loc_i < locParticles.size(); ++loc_i) { if(locParticles[loc_i]->energy() < dMinimumEnergy) return false; } return true; //return false if you want to use this action to apply a cut (and it fails the cut!) }