Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "DQM/BeamMonitor/plugins/PixelVTXMonitor.h"
00013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00014 #include "FWCore/Framework/interface/LuminosityBlock.h"
00015 #include "FWCore/ServiceRegistry/interface/Service.h"
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "DataFormats/Common/interface/Handle.h"
00018 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
00019 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00020 #include "DataFormats/VertexReco/interface/Vertex.h"
00021 #include "DataFormats/Common/interface/TriggerResults.h"
00022 #include "TPRegexp.h"
00023
00024
00025
00026
00027
00028
00029 PixelVTXMonitor::PixelVTXMonitor( const edm::ParameterSet& ps ) : parameters_(ps) {
00030
00031
00032 moduleName_ = parameters_.getParameter<std::string>("ModuleName");
00033 folderName_ = parameters_.getParameter<std::string>("FolderName");
00034 pixelClusterInputTag_= parameters_.getParameter<edm::InputTag>("PixelClusterInputTag");
00035 pixelVertexInputTag_ = parameters_.getParameter<edm::InputTag>("PixelVertexInputTag");
00036 hltInputTag_ = parameters_.getParameter<edm::InputTag>("HLTInputTag");
00037 minVtxDoF_ = parameters_.getParameter<double>("MinVtxDoF");
00038 }
00039
00040 PixelVTXMonitor::~PixelVTXMonitor() {
00041
00042 }
00043
00044 void PixelVTXMonitor::bookHistograms() {
00045 std::vector<std::string> hltPathsOfInterest = parameters_.getParameter<std::vector<std::string> > ("HLTPathsOfInterest");
00046 if (hltPathsOfInterest.size() == 0) return;
00047
00048 const std::vector<std::string>& pathList = hltConfig_.triggerNames();
00049 std::vector<std::string> selectedPaths;
00050 for (std::vector<std::string>::const_iterator it = pathList.begin();
00051 it != pathList.end(); ++it) {
00052 int nmatch = 0;
00053 for (std::vector<std::string>::const_iterator kt = hltPathsOfInterest.begin();
00054 kt != hltPathsOfInterest.end(); ++kt) {
00055 nmatch += TPRegexp(*kt).Match(*it);
00056 }
00057 if (!nmatch) continue;
00058 else selectedPaths.push_back(*it);
00059 }
00060
00061 edm::ParameterSet ClusHistoPar = parameters_.getParameter<edm::ParameterSet>("TH1ClusPar");
00062 edm::ParameterSet VtxHistoPar = parameters_.getParameter<edm::ParameterSet>("TH1VtxPar");
00063
00064
00065 std::string currentFolder = moduleName_ + "/" + folderName_ ;
00066 dbe_->setCurrentFolder(currentFolder.c_str());
00067
00068 PixelMEs local_MEs;
00069 for (std::vector<std::string> ::iterator it = selectedPaths.begin();
00070 it != selectedPaths.end(); it++) {
00071 std::string tag = (*it) ;
00072 std::map<std::string, PixelMEs>::iterator iPos = histoMap_.find(tag);
00073 if (iPos == histoMap_.end()) {
00074
00075 std::string hname, htitle;
00076
00077 hname = "nPxlClus_";
00078 hname += tag;
00079 htitle= "# of Pixel Clusters (";
00080 htitle += tag +")";
00081 local_MEs.clusME= dbe_->book1D(hname, htitle,
00082 ClusHistoPar.getParameter<int32_t>("Xbins"),
00083 ClusHistoPar.getParameter<double>("Xmin"),
00084 ClusHistoPar.getParameter<double>("Xmax"));
00085
00086 hname = "nPxlVtx_";
00087 hname += tag;
00088 htitle= "# of Pixel Vertices (";
00089 htitle += tag +")";
00090 local_MEs.vtxME= dbe_->book1D(hname, htitle,
00091 VtxHistoPar.getParameter<int32_t>("Xbins"),
00092 VtxHistoPar.getParameter<double>("Xmin"),
00093 VtxHistoPar.getParameter<double>("Xmax"));
00094
00095 histoMap_.insert(std::make_pair(tag, local_MEs));
00096 }
00097 }
00098 }
00099
00100 void PixelVTXMonitor::beginJob() {
00101 dbe_ = edm::Service<DQMStore>().operator->();
00102
00103 }
00104
00105 void PixelVTXMonitor::beginRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
00106 bool changed = true;
00107 if (hltConfig_.init(iRun, iSetup, hltInputTag_.process(), changed)) {
00108
00109 edm::LogInfo("PixelVTXMonitor") << "HLT config with process name "
00110 << hltInputTag_.process() << " successfully extracted";
00111 } else {
00112
00113
00114 edm::LogError("PixelVTXMonotor") << "Error! HLT config extraction with process name "
00115 <<hltInputTag_.process() << " failed";
00116
00117 }
00118 bookHistograms();
00119
00120 }
00121 void PixelVTXMonitor::analyze(edm::Event const& iEvent, edm::EventSetup const& iSetup) {
00122 if (!histoMap_.size()) return;
00123
00124
00125 edm::Handle< SiPixelClusterCollectionNew > siPixelClusters;
00126 iEvent.getByLabel(pixelClusterInputTag_, siPixelClusters);
00127
00128 if(!siPixelClusters.isValid()) {
00129 edm::LogError("PixelVTXMonotor") << "Could not find Cluster Collection " << pixelClusterInputTag_;
00130 return;
00131 }
00132 unsigned nClusters = siPixelClusters->size();
00133
00134
00135
00136 edm::Handle<reco::VertexCollection> pixelVertices;
00137 iEvent.getByLabel(pixelVertexInputTag_,pixelVertices);
00138 if (!pixelVertices.isValid()) {
00139 edm::LogError("PixelVTXMonotor") << "Could not find Vertex Collection " << pixelVertexInputTag_;
00140 return;
00141 }
00142
00143 int nVtx = 0;
00144 for (reco::VertexCollection::const_iterator ivtx = pixelVertices->begin();
00145 ivtx != pixelVertices->end(); ++ivtx) {
00146 if (minVtxDoF_ == -1) nVtx++;
00147 else {
00148 if ((ivtx->isValid() == true) &&
00149 (ivtx->isFake() == false) &&
00150 (ivtx->ndof() >= minVtxDoF_) &&
00151 (ivtx->tracksSize() != 0)) nVtx++;
00152 }
00153 }
00154
00155 edm::Handle<edm::TriggerResults> triggerResults;
00156 iEvent.getByLabel(hltInputTag_, triggerResults);
00157 if (!triggerResults.isValid()) return;
00158
00159 for (std::map<std::string,PixelMEs>::iterator it = histoMap_.begin();
00160 it != histoMap_.end(); ++it) {
00161 std::string path = it->first;
00162 MonitorElement* me_clus = it->second.clusME;
00163 MonitorElement* me_vtx = it->second.vtxME;
00164 unsigned int index = hltConfig_.triggerIndex(path);
00165 if ( index < triggerResults->size() && triggerResults->accept(index)) {
00166 if (me_vtx) me_vtx->Fill(nVtx);
00167 if (me_clus) me_clus->Fill(nClusters);
00168 }
00169 }
00170 }
00171
00172
00173 void PixelVTXMonitor::endRun(edm::Run const& iRun, edm::EventSetup const& iSetup) {
00174
00175 }
00176
00177
00178 void PixelVTXMonitor::endJob() {
00179
00180 }
00181
00182 #include "FWCore/Framework/interface/MakerMacros.h"
00183 DEFINE_FWK_MODULE(PixelVTXMonitor);