Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:10

0001 #ifndef CommonAlignmentMonitor_AlignmentMonitorBase_h
0002 #define CommonAlignmentMonitor_AlignmentMonitorBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     CommonAlignmentMonitor
0006 // Class  :     AlignmentMonitorBase
0007 //
0008 /**\class AlignmentMonitorBase AlignmentMonitorBase.h Alignment/CommonAlignmentMonitor/interface/AlignmentMonitorBase.h
0009 
0010  Description: <one line class summary>
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Jim Pivarski
0018 //         Created:  Fri Mar 30 12:21:02 CDT 2007
0019 // $Id: AlignmentMonitorBase.h,v 1.11 2010/01/06 15:23:09 mussgill Exp $
0020 //
0021 
0022 // system include files
0023 
0024 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0025 #include "Alignment/CommonAlignment/interface/AlignableNavigator.h"
0026 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
0027 #include "Alignment/MuonAlignment/interface/AlignableMuon.h"
0028 #include "FWCore/Framework/interface/Frameworkfwd.h"
0029 #include "FWCore/Framework/interface/Event.h"
0030 #include "Alignment/CommonAlignmentAlgorithm/interface/AlignmentParameterStore.h"
0031 #include "DataFormats/TrackReco/interface/Track.h"
0032 
0033 // user include files
0034 #include "CommonTools/Utils/interface/TFileDirectory.h"
0035 #include "TH1F.h"
0036 #include "TH2F.h"
0037 #include "TProfile.h"
0038 #include "TTree.h"
0039 #include "FWCore/Framework/interface/ConsumesCollector.h"
0040 
0041 // forward declarations
0042 
0043 class AlignmentMonitorBase {
0044 public:
0045   typedef std::pair<const Trajectory *, const reco::Track *> ConstTrajTrackPair;
0046   typedef std::vector<ConstTrajTrackPair> ConstTrajTrackPairCollection;
0047 
0048   /// Constructor
0049   AlignmentMonitorBase(const edm::ParameterSet &cfg, const edm::ConsumesCollector &iC, std::string name);
0050 
0051   /// Destructor
0052   virtual ~AlignmentMonitorBase() {}
0053 
0054   /// Called at beginning of job: don't reimplement
0055   void beginOfJob(AlignableTracker *pTracker, AlignableMuon *pMuon, AlignmentParameterStore *pStore);
0056 
0057   /// Called at beginning of loop: don't reimplement
0058   void startingNewLoop();
0059 
0060   /// Called for each event: don't reimplement
0061   void duringLoop(const edm::Event &iEvent,
0062                   const edm::EventSetup &iSetup,
0063                   const ConstTrajTrackPairCollection &iTrajTracks);
0064 
0065   /// Called at end of loop: don't reimplement
0066   void endOfLoop();
0067 
0068   /// Called at end of processing: don't implement
0069   void endOfJob() {}
0070 
0071   /////////////////////////////////////////////////////
0072 
0073   /// Book or retrieve histograms; MUST be reimplemented
0074   virtual void book() = 0;
0075 
0076   /// Called for each event (by "run()"): may be reimplemented
0077   virtual void event(const edm::Event &iEvent,
0078                      const edm::EventSetup &iSetup,
0079                      const ConstTrajTrackPairCollection &iTrajTracks) {}
0080 
0081   /// Called after updating AlignableTracker and AlignableMuon (by
0082   /// "endOfLoop()"): may be reimplemented
0083   virtual void afterAlignment() {}
0084 
0085 protected:
0086   /// Use this every time you book a histogram (so that
0087   /// AlignmentMonitorBase can find your histograms in a
0088   /// collector (parallel-processing) job)
0089   TH1F *book1D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX);
0090   TProfile *bookProfile(std::string dir,
0091                         std::string name,
0092                         std::string title,
0093                         int nchX,
0094                         double lowX,
0095                         double highX,
0096                         int nchY = 1,
0097                         double lowY = 0.,
0098                         double highY = 0.,
0099                         const char *option = "s");
0100   TH2F *book2D(std::string dir,
0101                std::string name,
0102                std::string title,
0103                int nchX,
0104                double lowX,
0105                double highX,
0106                int nchY,
0107                double lowY,
0108                double highY);
0109   TFileDirectory *directory(std::string dir);
0110 
0111   int iteration() { return m_iteration; }
0112   AlignableTracker *pTracker() { return mp_tracker; }
0113   AlignableMuon *pMuon() { return mp_muon; }
0114   AlignmentParameterStore *pStore() { return mp_store; }
0115   AlignableNavigator *pNavigator() { return mp_navigator; }
0116 
0117   const edm::InputTag m_beamSpotTag;
0118 
0119 public:
0120   AlignmentMonitorBase(const AlignmentMonitorBase &) = delete;                   // stop default
0121   const AlignmentMonitorBase &operator=(const AlignmentMonitorBase &) = delete;  // stop default
0122 
0123 private:
0124   // ---------- member data --------------------------------
0125 
0126   int m_iteration;
0127   AlignableTracker *mp_tracker;
0128   AlignableMuon *mp_muon;
0129   AlignmentParameterStore *mp_store;
0130   AlignableNavigator *mp_navigator;
0131 
0132   std::map<std::vector<std::string>, TFileDirectory *> m_baseDirMap, m_iterDirMap;
0133 };
0134 
0135 /*** Global typedefs ***/
0136 using AlignmentMonitors = std::vector<std::unique_ptr<AlignmentMonitorBase> >;
0137 
0138 #endif