file ExRunEventInfo.h =========================== #ifndef ExRunEventInfo_h #define ExRunEventInfo_h /** \file Workspace/ExRunEventInfo.h * Most simple analysis observer dumping run and event number. */ #include "Utilities/Notification/interface/Observer.h" // forward declare classes we have only pointers to class G3EventProxy; /** Most simple analysis observer dumping run and event number. * This is the class where the analysis is actually done, * it inherits from ActiveObserver. When a new event is read by ORCA the private * method "upDate" is called for all instantiated observers. * \author Stephan Wynhoff, CERN */ class ExRunEventInfo : private ActiveObserver { public: ExRunEventInfo(); //!< default constructor ~ExRunEventInfo(); //!< default destructor /// this method will do the user analysis void myAnalysis(G3EventProxy * ev); private: /// don't change the name "upDate" - this method is mandatory. void upDate(G3EventProxy * ev) { if (ev!=0) myAnalysis(ev);} private: unsigned int eventsAnalysed; //!< just to count events that have been analysed unsigned int PUeventsUsed; //!< just to count events that have been analysed unsigned int runsAnalysed; //!< count the runs unsigned int lastrun; //!< to remember the last run analysed }; #endif file ExRunEvent.cpp =========================== // ----------------------------------------------------------------------------- // Example program to dump run/event numbers for signal // and pile-up events // This part only registers the analysis class (ExRunEventInfo) to CARF. // ----------------------------------------------------------------------------- // $Date: 2000/04/04 13:02:12 $ // $Revision: 1.4 $ // ----------------------------------------------------------------------------- // Author: Stephan Wynhoff - CERN (Email: Stephan.Wynhoff@cern.ch) // ----------------------------------------------------------------------------- #include "Utilities/Configuration/interface/Architecture.h" #include "Utilities/Notification/interface/PackageInitializer.h" #include "Workspace/ExRunEventInfo.h" PKBuilder mybuilder("ExRunEventInfoBuilder"); file ExRunEventInfo.cc ========================= #include "Utilities/Configuration/interface/Architecture.h" #include "Workspace/ExRunEventInfo.h" #include "CARF/G3Event/interface/G3EventProxy.h" #include // ----------------------------------------------------------------------------- // In the constructor we can initialize. It is automatically called when an // instance of the class is created. // ----------------------------------------------------------------------------- ExRunEventInfo::ExRunEventInfo() { cout << "===========================================================" << endl; cout << "=== Start create new ExRunEventInfo ===" << endl; eventsAnalysed = 0; PUeventsUsed = 0; runsAnalysed = 0; lastrun = 0; cout << "=== Done create new ExRunEventInfo ===" << endl; cout << "===========================================================" << endl; } // ----------------------------------------------------------------------------- // In the destructor we can print some summary or even fill some histogram // with results calculated. It is automatically called when an instance of // is deleted. // ----------------------------------------------------------------------------- ExRunEventInfo::~ExRunEventInfo() { cout << "===========================================================" << endl; cout << "=== Start delete ExRunEventInfo ===" << endl; cout << " Number of events analysed: " << eventsAnalysed << endl; cout << " Number of pileup events used: " << PUeventsUsed << endl; cout << " Number of runs analysed: " << runsAnalysed << endl; cout << "=== Done delete ExRunEventInfo ===" << endl; cout << "===========================================================" << endl; } // ----------------------------------------------------------------------------- // This is an example method to do the actual analysis. It gets a pointer // to an event as argument. // ----------------------------------------------------------------------------- void ExRunEventInfo::myAnalysis(G3EventProxy * ev) { // Just print the signal event number (see CARF/G3Event/interface/G3EventHeader.h) cout << "===========================================================" << endl; cout << "=== Private analysis of event #"<< ev->simTrigger()->id().eventInRun() << " in run #" << ev->simTrigger()->id().runNumber() << endl; eventsAnalysed++; // some statistics: count events and runs processed // And now the event numbers of all pileup events cout << "--- PileUp events are: " ; G3EventProxy::pu_range PUrange = ev->pileups(); for (G3EventProxy::pu_iterator ipu = PUrange.first; ipu != PUrange.second; ipu++) { PUeventsUsed++; // count them if (ipu != PUrange.first) { cout << ", "; } cout << (*ipu).id().eventInRun(); } cout << endl; if (ev->simTrigger()->id().runNumber() != lastrun) { lastrun = (unsigned int) ev->simTrigger()->id().runNumber(); runsAnalysed++; } cout << "===========================================================" << endl; };