//-------------------------------------------------------------------------- // File and Version Information: // NTrkExample.cc March 16 1999 // // Description: // Class NTrkExample // // This is an analysis module class used as the // first example in the offline workbook. // The workbook can be found on the web at the // following URL: // BFROOT/www/doc/workbook/workbook.html // // The NTrkExample class only plots a histogram of // the number of tracks per event. // // // Environment: // Software developed for the BaBar Detector at the SLAC B-Factory. // // Author List: // Charlie Young Original Author // Tracey Marsh minimize module // // Copyright Information: // Copyright (C) 1997 // //------------------------------------------------------------------------ #include "BaBar/BaBar.hh" //----------------------- // This Class's Header -- //----------------------- //#include "BetaUser/NTrkExample.hh" //------------- // C Headers -- //------------- #include //--------------- // C++ Headers -- //--------------- #include #include //------------------------------- // Collaborating Class Headers -- //------------------------------- #include "CLHEP/Alist/ConstAList.h" #include "AbsEvent/AbsEvent.hh" #include "AbsEvent/getTmpAList.hh" #include "AbsEnv/AbsEnv.hh" #include "GenEnv/GenEnv.hh" #include "ProxyDict/IfdHepAList.hh" #include "ProxyDict/IfdStrKey.hh" #include "ProxyDict/IfdKey.hh" #include "Beta/BtaCandidate.hh" #include "HepTuple/TupleManager.h" #include "HepTuple/Histogram.h" //----------------------------------------------------------------------- // Local Macros, Typedefs, Structures, Unions and Forward Declarations -- //----------------------------------------------------------------------- #include "PAFAdapters/PAFBbrAnalysis.hh" #include "PAFUser/NTrkExample.hh" ClassImp(NTrkExample) static const char rcsid[] = "$Id: NTrkExample2.cc,v 1.2 2000/08/18 14:15:19 marcel Exp $"; //---------------- // Constructors -- //---------------- // in general, a module constructor should not do much. The begin(job) or // begin(run) members are better places to put initialization NTrkExample::NTrkExample( const char* const theName, const char* const theDescription ) : AppModule( theName, theDescription ) , _btaChargedList("trackCandidates", this, "ChargedTracks") { } //-------------- // Destructor -- //-------------- // The destructor should be limited to undoing the work of the constructor NTrkExample::~NTrkExample( ) { } //-------------- // Operations -- //-------------- // The begin(AppJob*) member function is run before any events are // processed. In this example code, it opens the output histogram file // and then books a histogram. APPMODULERETURNTYPE2 NTrkExample::beginJob( AbsEvent* anEvent ) { cout<< name() << ": Begin job" << endl; HepTupleManager* manager = TPico::Instance()->GetPersistenceManager(); assert(manager != 0); // book the momentum distribution histogram _numTrkHisto = manager->histogram("Tracks per Event", 20, 0., 20. ); return APPMODULERETURNVAL2; } // end(AppJob*) function is called after all events have been processed. APPMODULERETURNTYPE2 NTrkExample::endJob( AbsEvent* anEvent ) { cout << name() << ": End job" << endl; return APPMODULERETURNVAL2; } // event function is called once per event APPMODULERETURNTYPE1 NTrkExample::event( AbsEvent* anEvent ) { if (_verbose.value()) { cout << name() << ": Event" << endl; } // get list of input track candidates HepAList* trkList; getTmpAList (anEvent, trkList, _btaChargedList.value() ); //histogram number of tracks in event _numTrkHisto->accumulate( trkList->length() ); // done return APPMODULERETURNVAL1; }