CMS 3D CMS Logo

PixelVTXMonitor.cc
Go to the documentation of this file.
1 /*
2  * \file PixelVTXMonitor.cc
3  * \author S. Dutta
4  * Last Update:
5  *
6  * Description: Pixel Vertex Monitoring for different HLT paths
7  *
8 */
16 #include "TPRegexp.h"
17 
18 // -----------------------------
19 // constructors and destructor
20 // -----------------------------
21 
26  consumes<SiPixelClusterCollectionNew>(parameters_.getParameter<edm::InputTag>("PixelClusterInputTag"));
28  consumes<reco::VertexCollection>(parameters_.getParameter<edm::InputTag>("PixelVertexInputTag"));
29  hltInputTagToken_ = consumes<edm::TriggerResults>(parameters_.getParameter<edm::InputTag>("HLTInputTag"));
33  minVtxDoF_ = parameters_.getParameter<double>("MinVtxDoF");
34 }
35 
37 
39  std::vector<std::string> hltPathsOfInterest =
40  parameters_.getParameter<std::vector<std::string> >("HLTPathsOfInterest");
41  if (hltPathsOfInterest.empty())
42  return;
43 
44  const std::vector<std::string>& pathList = hltConfig_.triggerNames();
45  std::vector<std::string> selectedPaths;
46  for (std::vector<std::string>::const_iterator it = pathList.begin(); it != pathList.end(); ++it) {
47  int nmatch = 0;
48  for (std::vector<std::string>::const_iterator kt = hltPathsOfInterest.begin(); kt != hltPathsOfInterest.end();
49  ++kt) {
50  nmatch += TPRegexp(*kt).Match(*it);
51  }
52  if (!nmatch)
53  continue;
54  else
55  selectedPaths.push_back(*it);
56  }
57 
58  edm::ParameterSet ClusHistoPar = parameters_.getParameter<edm::ParameterSet>("TH1ClusPar");
59  edm::ParameterSet VtxHistoPar = parameters_.getParameter<edm::ParameterSet>("TH1VtxPar");
60 
61  std::string currentFolder = moduleName_ + "/" + folderName_;
62  dbe_->setCurrentFolder(currentFolder);
63 
64  PixelMEs local_MEs;
65  for (std::vector<std::string>::iterator it = selectedPaths.begin(); it != selectedPaths.end(); it++) {
66  std::string tag = (*it);
67  std::map<std::string, PixelMEs>::iterator iPos = histoMap_.find(tag);
68  if (iPos == histoMap_.end()) {
69  std::string hname, htitle;
70 
71  hname = "nPxlClus_";
72  hname += tag;
73  htitle = "# of Pixel Clusters (";
74  htitle += tag + ")";
75  local_MEs.clusME = dbe_->book1D(hname,
76  htitle,
77  ClusHistoPar.getParameter<int32_t>("Xbins"),
78  ClusHistoPar.getParameter<double>("Xmin"),
79  ClusHistoPar.getParameter<double>("Xmax"));
80 
81  hname = "nPxlVtx_";
82  hname += tag;
83  htitle = "# of Pixel Vertices (";
84  htitle += tag + ")";
85  local_MEs.vtxME = dbe_->book1D(hname,
86  htitle,
87  VtxHistoPar.getParameter<int32_t>("Xbins"),
88  VtxHistoPar.getParameter<double>("Xmin"),
89  VtxHistoPar.getParameter<double>("Xmax"));
90 
91  histoMap_.insert(std::make_pair(tag, local_MEs));
92  }
93  }
94 }
95 
97 
98 void PixelVTXMonitor::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
99  bool changed = true;
100  if (hltConfig_.init(iRun, iSetup, hltInputTag_.process(), changed)) {
101  // if init returns TRUE, initialisation has succeeded!
102  edm::LogInfo("PixelVTXMonitor") << "HLT config with process name " << hltInputTag_.process()
103  << " successfully extracted";
104  } else {
105  // if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
106  // with the file and/or code and needs to be investigated!
107  edm::LogError("PixelVTXMonotor") << "Error! HLT config extraction with process name " << hltInputTag_.process()
108  << " failed";
109  // In this case, all access methods will return empty values!
110  }
111  bookHistograms();
112 }
114  if (histoMap_.empty())
115  return;
116 
117  //Access Pixel Clusters
120 
121  if (!siPixelClusters.isValid()) {
122  edm::LogError("PixelVTXMonotor") << "Could not find Cluster Collection " << pixelClusterInputTag_;
123  return;
124  }
125  unsigned nClusters = siPixelClusters->size();
126 
127  //Access Pixel Verteces
130  if (!pixelVertices.isValid()) {
131  edm::LogError("PixelVTXMonotor") << "Could not find Vertex Collection " << pixelVertexInputTag_;
132  return;
133  }
134 
135  int nVtx = 0;
136  for (reco::VertexCollection::const_iterator ivtx = pixelVertices->begin(); ivtx != pixelVertices->end(); ++ivtx) {
137  if (minVtxDoF_ == -1)
138  nVtx++;
139  else {
140  if ((ivtx->isValid() == true) && (ivtx->isFake() == false) && (ivtx->ndof() >= minVtxDoF_) &&
141  (ivtx->tracksSize() != 0))
142  nVtx++;
143  }
144  }
145  // Access Trigger Results
148  if (!triggerResults.isValid())
149  return;
150 
151  for (std::map<std::string, PixelMEs>::iterator it = histoMap_.begin(); it != histoMap_.end(); ++it) {
152  std::string path = it->first;
153  MonitorElement* me_clus = it->second.clusME;
154  MonitorElement* me_vtx = it->second.vtxME;
155  unsigned int index = hltConfig_.triggerIndex(path);
156  if (index < triggerResults->size() && triggerResults->accept(index)) {
157  if (me_vtx)
158  me_vtx->Fill(nVtx);
159  if (me_clus)
160  me_clus->Fill(nClusters);
161  }
162  }
163 }
164 
165 void PixelVTXMonitor::endRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {}
166 
168 // Define this as a plug-in
171 
172 // Local Variables:
173 // show-trailing-whitespace: t
174 // truncate-lines: t
175 // End:
heavyionUCCDQM_cfi.nClusters
nClusters
Definition: heavyionUCCDQM_cfi.py:9
Handle.h
MessageLogger.h
PixelVTXMonitor::hltConfig_
HLTConfigProvider hltConfig_
Definition: PixelVTXMonitor.h:60
edm::Run
Definition: Run.h:45
PixelVTXMonitor::PixelMEs
Definition: PixelVTXMonitor.h:62
LuminosityBlock.h
PixelVTXMonitor::PixelMEs::clusME
MonitorElement * clusME
Definition: PixelVTXMonitor.h:63
SiPixelCluster.h
PixelVTXMonitor::endJob
void endJob() override
Definition: PixelVTXMonitor.cc:167
triggerResults
static const std::string triggerResults
Definition: EdmProvDump.cc:45
PixelVTXMonitor::analyze
void analyze(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
Definition: PixelVTXMonitor.cc:113
edm::InputTag::process
std::string const & process() const
Definition: InputTag.h:40
dqm::legacy::MonitorElement
Definition: MonitorElement.h:462
PixelVTXMonitor::minVtxDoF_
float minVtxDoF_
Definition: PixelVTXMonitor.h:57
PixelVTXMonitor::dbe_
DQMStore * dbe_
Definition: PixelVTXMonitor.h:59
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
edm::Handle
Definition: AssociativeIterator.h:50
PixelVTXMonitor::moduleName_
std::string moduleName_
Definition: PixelVTXMonitor.h:49
PixelVTXMonitor::pixelVertexInputTag_
edm::InputTag pixelVertexInputTag_
Definition: PixelVTXMonitor.h:55
MakerMacros.h
PixelVTXMonitor::pixelClusterInputTagToken_
edm::EDGetTokenT< SiPixelClusterCollectionNew > pixelClusterInputTagToken_
Definition: PixelVTXMonitor.h:51
HIInitialJetCoreClusterSplitting_cff.siPixelClusters
siPixelClusters
Definition: HIInitialJetCoreClusterSplitting_cff.py:27
PixelVTXMonitor::PixelMEs::vtxME
MonitorElement * vtxME
Definition: PixelVTXMonitor.h:64
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
PixelVTXMonitor::hltInputTag_
edm::InputTag hltInputTag_
Definition: PixelVTXMonitor.h:56
Service.h
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
PixelVTXMonitor::beginJob
void beginJob() override
Definition: PixelVTXMonitor.cc:96
L1TkPrimaryVertexProducer_cfi.nVtx
nVtx
Definition: L1TkPrimaryVertexProducer_cfi.py:14
PixelVTXMonitor::pixelVertexInputTagToken_
edm::EDGetTokenT< reco::VertexCollection > pixelVertexInputTagToken_
Definition: PixelVTXMonitor.h:52
PixelVTXMonitor::hltInputTagToken_
edm::EDGetTokenT< edm::TriggerResults > hltInputTagToken_
Definition: PixelVTXMonitor.h:53
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
makeGlobalPositionRcd_cfg.tag
tag
Definition: makeGlobalPositionRcd_cfg.py:6
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
PixelVTXMonitor::pixelClusterInputTag_
edm::InputTag pixelClusterInputTag_
Definition: PixelVTXMonitor.h:54
edm::EventSetup
Definition: EventSetup.h:58
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLTConfigProvider::triggerIndex
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
Definition: HLTConfigProvider.h:73
PixelVTXMonitor::parameters_
edm::ParameterSet parameters_
Definition: PixelVTXMonitor.h:47
PixelVTXMonitor::beginRun
void beginRun(edm::Run const &iRun, edm::EventSetup const &iSetup) override
Definition: PixelVTXMonitor.cc:98
HLTConfigProvider::init
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d'tor
Definition: HLTConfigProvider.cc:36
PixelVTXMonitor::PixelVTXMonitor
PixelVTXMonitor(const edm::ParameterSet &)
Definition: PixelVTXMonitor.cc:22
PixelVTXMonitor
Definition: PixelVTXMonitor.h:30
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
HLTConfigProvider::triggerNames
const std::vector< std::string > & triggerNames() const
names of trigger paths
Definition: HLTConfigProvider.h:69
TrackingDataMCValidation_Standalone_cff.hltPathsOfInterest
hltPathsOfInterest
Definition: TrackingDataMCValidation_Standalone_cff.py:18
PixelVTXMonitor::~PixelVTXMonitor
~PixelVTXMonitor() override
Definition: PixelVTXMonitor.cc:36
edm::Event
Definition: Event.h:73
PixelVTXMonitor::folderName_
std::string folderName_
Definition: PixelVTXMonitor.h:50
PixelVTXMonitor.h
edm::InputTag
Definition: InputTag.h:15
PixelVTXMonitor::histoMap_
std::map< std::string, PixelMEs > histoMap_
Definition: PixelVTXMonitor.h:67
PixelVTXMonitor::bookHistograms
void bookHistograms()
Definition: PixelVTXMonitor.cc:38
PixelVTXMonitor::endRun
void endRun(edm::Run const &iRun, edm::EventSetup const &iSetup) override
Definition: PixelVTXMonitor.cc:165
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443
beam_dqm_sourceclient-live_cfg.pixelVertices
pixelVertices
Definition: beam_dqm_sourceclient-live_cfg.py:321