diff --git a/cppFMWPC/JEventProcessor_cppFMWPC.cc b/cppFMWPC/JEventProcessor_cppFMWPC.cc new file mode 100644 index 0000000..32c532f --- /dev/null +++ b/cppFMWPC/JEventProcessor_cppFMWPC.cc @@ -0,0 +1,153 @@ +// $Id$ +// +// File: JEventProcessor_cppFMWPC.cc +// Created: Sat Mar 13 08:01:05 EST 2021 +// Creator: zihlmann (on Linux ifarm1901.jlab.org 3.10.0-1062.4.1.el7.x86_64 x86_64) +// + +#include "JEventProcessor_cppFMWPC.h" +using namespace jana; + + +// Routine used to create our JEventProcessor +#include +#include +extern "C"{ + void InitPlugin(JApplication *app){ + InitJANAPlugin(app); + app->AddProcessor(new JEventProcessor_cppFMWPC()); + } +} // "C" + + +//------------------ +// JEventProcessor_cppFMWPC (Constructor) +//------------------ +JEventProcessor_cppFMWPC::JEventProcessor_cppFMWPC() +{ + +} + +//------------------ +// ~JEventProcessor_cppFMWPC (Destructor) +//------------------ +JEventProcessor_cppFMWPC::~JEventProcessor_cppFMWPC() +{ + +} + +//------------------ +// init +//------------------ +jerror_t JEventProcessor_cppFMWPC::init(void) +{ + // This is called once at program startup. + + TDirectory *top = gDirectory; + top->cd(); + + gDirectory->mkdir("FMWPC")->cd(); + + nFMWPCchambers = 6; + char hnam[128], htit[128]; + for ( int k=0; kcd(); + + + return NOERROR; +} + +//------------------ +// brun +//------------------ +jerror_t JEventProcessor_cppFMWPC::brun(JEventLoop *eventLoop, int32_t runnumber) +{ + // This is called whenever the run number changes + return NOERROR; +} + +//------------------ +// evnt +//------------------ +jerror_t JEventProcessor_cppFMWPC::evnt(JEventLoop *loop, uint64_t eventnumber) +{ + // 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->RootFillLock(this); + // ... fill historgrams or trees ... + // japp->RootFillUnLock(this); + + + vector < const DFMWPCHit*> fmwpcHits; + loop->Get(fmwpcHits); + + for (int k=0; k<(int)fmwpcHits.size(); k++) { + + const DFMWPCHit *hit = fmwpcHits[k]; + //std::cout<layer<<" / "<wire<<" / "<t<layer-1]->Fill((double)hit->wire, (double)hit->t); + FMWPCwiresE[hit->layer-1]->Fill((double)hit->wire, (double)hit->dE); + } + + vector fdcHits; + loop->Get(fdcHits); + + for (int k=0; k<(int)fdcHits.size(); k++){ + const DFDCHit *h = fdcHits[k]; + if (h->plane != 2){ + // this is not a wire + continue; + } + int l = h->gLayer - 1 ; + int w = h->element; + FDCwiresT[l]->Fill((double)w, h->t); + } + + return NOERROR; +} + +//------------------ +// erun +//------------------ +jerror_t JEventProcessor_cppFMWPC::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 JEventProcessor_cppFMWPC::fini(void) +{ + // Called before program exit after event processing is finished. + + return NOERROR; +} + diff --git a/cppFMWPC/JEventProcessor_cppFMWPC.h b/cppFMWPC/JEventProcessor_cppFMWPC.h new file mode 100644 index 0000000..6f176f1 --- /dev/null +++ b/cppFMWPC/JEventProcessor_cppFMWPC.h @@ -0,0 +1,40 @@ +// $Id$ +// +// File: JEventProcessor_cppFMWPC.h +// Created: Sat Mar 13 08:01:05 EST 2021 +// Creator: zihlmann (on Linux ifarm1901.jlab.org 3.10.0-1062.4.1.el7.x86_64 x86_64) +// + +#ifndef _JEventProcessor_cppFMWPC_ +#define _JEventProcessor_cppFMWPC_ + +#include + +#include +#include +#include +#include +#include + +class JEventProcessor_cppFMWPC:public jana::JEventProcessor{ + public: + JEventProcessor_cppFMWPC(); + ~JEventProcessor_cppFMWPC(); + const char* className(void){return "JEventProcessor_cppFMWPC";} + + int nFMWPCchambers; + TH2D *FMWPCwiresT[8]; + TH2D *FMWPCwiresE[8]; + + TH2D *FDCwiresT[24]; + + private: + jerror_t init(void); ///< Called once at program start. + jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber); ///< Called everytime a new run number is detected. + jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t 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. +}; + +#endif // _JEventProcessor_cppFMWPC_ + diff --git a/cppFMWPC/SConstruct b/cppFMWPC/SConstruct new file mode 100644 index 0000000..ee01bfa --- /dev/null +++ b/cppFMWPC/SConstruct @@ -0,0 +1,129 @@ + +# +# Jan. 31, 2014 David Lawrence +# +# This SConstruct file can be copied into a directory containing +# the source for a plugin and used to compile it. It will use and +# install into the directory specified by the HALLD_MY environment +# variable if defined. Otherwise, it will install in the HALLD_RECON_HOME +# directory. +# +# This file should not need modification. It will be copied in by +# the mkplugin or mkfactory_plugin scripts or you can just copy it +# by hand. +# +# To use this, just type "scons install" to build and install. +# Just type "scons" if you want to build, but not install it. +# +# > scons install +# +# Note that unlike the rest of the SBMS system, this does not +# use a separate build directory and builds everything in the +# source directory. This is due to technical details and will hopefully +# be fixed in the future. For now it means, that you must be +# diligent of building for multiple platforms using the same source. +# + +import os +import sys +import subprocess +import glob + +# Get HALLD_RECON_HOME environment variable, verifying it is set +halld_home = os.getenv('HALLD_RECON_HOME') +if(halld_home == None): + print 'HALLD_RECON_HOME environment variable not set!' + exit(-1) + +# Get HALLD_MY if it exists. Otherwise use HALLD_RECON_HOME +halld_my = os.getenv('HALLD_MY', halld_home) + +# Add SBMS directory to PYTHONPATH +sbmsdir = "%s/src/SBMS" % halld_home +sys.path.append(sbmsdir) + +import sbms + +# Get command-line options +SHOWBUILD = ARGUMENTS.get('SHOWBUILD', 0) + +# Get platform-specific name +osname = os.getenv('BMS_OSNAME', 'build') + +# Get architecture name +arch = subprocess.Popen(["uname"], stdout=subprocess.PIPE).communicate()[0].strip() + +# Setup initial environment +installdir = "%s/%s" %(halld_my, osname) +include = "%s/include" % (installdir) +bin = "%s/bin" % (installdir) +lib = "%s/lib" % (installdir) +plugins = "%s/plugins" % (installdir) +env = Environment( ENV = os.environ, # Bring in full environment, including PATH + CPPPATH = [include], + LIBPATH = ["%s/%s/lib" %(halld_home, osname)], # n.b. add HALLD_RECON_HOME here and prepend HALLD_MY below + variant_dir = ".%s" % (osname)) + +# Only add HALLD_MY library search path if it already exists +# since we'll get a warning otherwise +if (os.path.exists(lib)): env.PrependUnique(lib) + +# These are SBMS-specific variables (i.e. not default scons ones) +env.Replace(INSTALLDIR = installdir, + OSNAME = osname, + INCDIR = include, + BINDIR = bin, + LIBDIR = lib, + PLUGINSDIR = plugins, + ALL_SOURCES = [], # used so we can add generated sources + SHOWBUILD = SHOWBUILD, + COMMAND_LINE_TARGETS = COMMAND_LINE_TARGETS) + +# Use terse output unless otherwise specified +if SHOWBUILD==0: + env.Replace( CCCOMSTR = "Compiling [$SOURCE]", + CXXCOMSTR = "Compiling [$SOURCE]", + FORTRANPPCOMSTR = "Compiling [$SOURCE]", + FORTRANCOMSTR = "Compiling [$SOURCE]", + SHCCCOMSTR = "Compiling [$SOURCE]", + SHCXXCOMSTR = "Compiling [$SOURCE]", + LINKCOMSTR = "Linking [$TARGET]", + SHLINKCOMSTR = "Linking [$TARGET]", + INSTALLSTR = "Installing [$TARGET]", + ARCOMSTR = "Archiving [$TARGET]", + RANLIBCOMSTR = "Ranlib [$TARGET]") + + +# Get compiler from environment variables (if set) +env.Replace( CXX = os.getenv('CXX', 'g++'), + CC = os.getenv('CC' , 'gcc'), + FC = os.getenv('FC' , 'gfortran') ) + +# Add local directory, directories from HALLD_MY and HALLD_RECON_HOME to include search path +#env.PrependUnique(CPPPATH = ['#']) +env.PrependUnique(CPPPATH = ['%s/src' % halld_my, '%s/src/libraries' % halld_my, '%s/src/libraries/include' % halld_my]) +env.PrependUnique(CPPPATH = ['%s/src' % halld_home, '%s/src/libraries' % halld_home, '%s/src/libraries/include' % halld_home]) + +env.PrependUnique(CPPPATH = ['%s/%s/include' % (halld_my,osname)]) +env.PrependUnique(CPPPATH = ['%s/%s/include' % (halld_home,osname)]) + +# Turn on debug symbols and warnings +env.PrependUnique( CFLAGS = ['-g', '-fPIC', '-Wall']) +env.PrependUnique( CXXFLAGS = ['-g', '-fPIC', '-Wall']) +env.PrependUnique(FORTRANFLAGS = ['-g', '-fPIC', '-Wall']) + +env.PrependUnique( CXXFLAGS = ['-std=c++11']) + +# Apply any platform/architecture specific settings +sbms.ApplyPlatformSpecificSettings(env, arch) +sbms.ApplyPlatformSpecificSettings(env, osname) + +# Make plugin from source in this directory +sbms.AddDANA(env) +sbms.AddROOT(env) +sbms.plugin(env) + +# Make install target +env.Alias('install', installdir) + +