MillePedeDQMModule

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
#ifndef Alignment_MillePedeAlignmentAlgorithm_MillePedeDQMModule_h
#define Alignment_MillePedeAlignmentAlgorithm_MillePedeDQMModule_h

/**
 * @package   Alignment/MillePedeAlignmentAlgorithm
 * @file      MillePedeDQMModule.h
 *
 * @author    Max Stark (max.stark@cern.ch)
 * @date      Oct 26, 2015
 *
 * @brief     DQM Plotter for PCL-Alignment
 */

/*** system includes ***/
#include <array>
#include <memory>

/*** core framework functionality ***/
#include "FWCore/Framework/interface/ESWatcher.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ServiceRegistry/interface/Service.h"

/*** Geometry ***/
#include "CondFormats/GeometryObjects/interface/PTrackerParameters.h"
#include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeomBuilderFromGeometricDet.h"
#include "Geometry/TrackerGeometryBuilder/interface/PixelTopologyMap.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"

/*** Thresholds from DB ***/
#include "CondFormats/DataRecord/interface/AlignPCLThresholdsHGRcd.h"

/*** Quality from DB ***/
#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h"

/*** DQM ***/
#include "DQMServices/Core/interface/DQMEDHarvester.h"
#include "DQMServices/Core/interface/DQMStore.h"

/*** Records for ESWatcher ***/
#include "Geometry/Records/interface/IdealGeometryRecord.h"
#include "Geometry/Records/interface/PTrackerParametersRcd.h"
#include "Geometry/Records/interface/PTrackerAdditionalParametersPerDetRcd.h"
#include "Geometry/Records/interface/TrackerTopologyRcd.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"

/*** MillePede ***/
#include "Alignment/MillePedeAlignmentAlgorithm/interface/MillePedeFileReader.h"

class MillePedeDQMModule : public DQMEDHarvester {
  //========================== PUBLIC METHODS ==================================
public:  //====================================================================
  MillePedeDQMModule(const edm::ParameterSet&);
  ~MillePedeDQMModule() override = default;

  void dqmEndJob(DQMStore::IBooker&, DQMStore::IGetter&) override;

  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

  enum { SIZE_LG_STRUCTS = 6, SIZE_HG_STRUCTS = 820, SIZE_INDEX = 8 };

  //========================= PRIVATE METHODS ==================================
private:  //===================================================================
  void beginRun(const edm::Run&, const edm::EventSetup&) override;

  void bookHistograms(DQMStore::IBooker&);

  void fillStatusHisto(MonitorElement* statusHisto);

  void fillStatusHistoHG(MonitorElement* statusHisto);

  void fillExpertHistos();

  void fillExpertHistos_HG();

  void fillExpertHisto(MonitorElement* histo,
                       const std::array<double, SIZE_INDEX>& cut,
                       const std::array<double, SIZE_INDEX>& sigCut,
                       const std::array<double, SIZE_INDEX>& maxMoveCut,
                       const std::array<double, SIZE_INDEX>& maxErrorCut,
                       const std::array<double, SIZE_LG_STRUCTS>& obs,
                       const std::array<double, SIZE_LG_STRUCTS>& obsErr);

  void fillExpertHisto_HG(std::map<std::string, MonitorElement*>& histo_map,
                          const std::array<double, SIZE_INDEX>& cut,
                          const std::array<double, SIZE_INDEX>& sigCut,
                          const std::array<double, SIZE_INDEX>& maxMoveCut,
                          const std::array<double, SIZE_INDEX>& maxErrorCut,
                          const std::array<double, SIZE_HG_STRUCTS>& obs,
                          const std::array<double, SIZE_HG_STRUCTS>& obsErr);

  bool setupChanged(const edm::EventSetup&);
  int getIndexFromString(const std::string& alignableId);

  //========================== PRIVATE DATA ====================================
  //============================================================================

  // esConsumes
  const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
  const edm::ESGetToken<GeometricDet, IdealGeometryRecord> gDetToken_;
  const edm::ESGetToken<PTrackerParameters, PTrackerParametersRcd> ptpToken_;
  const edm::ESGetToken<PTrackerAdditionalParametersPerDet, PTrackerAdditionalParametersPerDetRcd> ptitpToken_;
  const edm::ESGetToken<AlignPCLThresholdsHG, AlignPCLThresholdsHGRcd> aliThrToken_;
  const edm::ESGetToken<SiPixelQuality, SiPixelQualityFromDbRcd> siPixelQualityToken_;
  const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> geomToken_;

  const std::string outputFolder_;
  const edm::ParameterSet mpReaderConfig_;
  std::unique_ptr<AlignableTracker> tracker_;
  std::unique_ptr<MillePedeFileReader> mpReader_;
  std::shared_ptr<PixelTopologyMap> pixelTopologyMap_;
  std::shared_ptr<SiPixelQuality> pixelQuality_;

  std::vector<std::pair<std::string, int>> layerVec;

  edm::ESWatcher<TrackerTopologyRcd> watchTrackerTopologyRcd_;
  edm::ESWatcher<IdealGeometryRecord> watchIdealGeometryRcd_;
  edm::ESWatcher<PTrackerParametersRcd> watchPTrackerParametersRcd_;

  // Histograms
  MonitorElement* h_xPos;
  MonitorElement* h_xRot;
  MonitorElement* h_yPos;
  MonitorElement* h_yRot;
  MonitorElement* h_zPos;
  MonitorElement* h_zRot;

  std::map<std::string, MonitorElement*> h_xPos_HG;
  std::map<std::string, MonitorElement*> h_xRot_HG;
  std::map<std::string, MonitorElement*> h_yPos_HG;
  std::map<std::string, MonitorElement*> h_yRot_HG;
  std::map<std::string, MonitorElement*> h_zPos_HG;
  std::map<std::string, MonitorElement*> h_zRot_HG;

  MonitorElement* statusResults;
  MonitorElement* binariesAvalaible;
  MonitorElement* exitCode;
  MonitorElement* isVetoed;

  bool isHG_;
};

// define this as a plug-in
DEFINE_FWK_MODULE(MillePedeDQMModule);

#endif /* Alignment_MillePedeAlignmentAlgorithm_MillePedeDQMModule_h */