CMS 3D CMS Logo

DTDCSByLumiTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTDCSByLumiTask.cc
3  *
4  * \author C. Battilana - CIEMAT
5  * \author P. Bellan - INFN PD
6  * \author A. Branca = INFN PD
7 
8  *
9  */
10 
12 
13 // Framework
15 
16 // Geometry
21 
24 
29 #include <iostream>
30 
31 using namespace edm;
32 using namespace std;
33 
34 DTDCSByLumiTask::DTDCSByLumiTask(const edm::ParameterSet& ps) : theEvents(0), theLumis(0) {
35  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "[DTDCSByLumiTask]: Constructor" << endl;
36 
37  // If needed put getParameter here
38  // dtDCSByLumiLabel = ps.getParameter<InputTag>("dtDCSByLumiLabel");
39 }
40 
42  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
43  << "DTDCSByLumiTask: processed " << theEvents << " events in " << theLumis << " lumi sections" << endl;
44 }
45 
47  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "[DTDCSByLumiTask]: begin run" << endl;
48 
49  context.get<MuonGeometryRecord>().get(theDTGeom);
50 
51  DTHVRecordFound = true;
52 
54 
55  std::vector<eventsetup::EventSetupRecordKey> recordKeys;
56  context.fillAvailableRecordKeys(recordKeys);
57  vector<eventsetup::EventSetupRecordKey>::iterator it = find(recordKeys.begin(), recordKeys.end(), recordKey);
58 
59  if (it == recordKeys.end()) {
60  //record not found
61  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "Record DTHVStatusRcd does not exist " << std::endl;
62 
63  DTHVRecordFound = false;
64  }
65 }
66 
67 void DTDCSByLumiTask::bookHistograms(DQMStore::IBooker& ibooker, edm::Run const& iRun, edm::EventSetup const& context) {
68  // Book bylumi histo (# of bins as reduced as possible)
69  ibooker.setCurrentFolder(topFolder());
70 
71  for (int wheel = -2; wheel <= 2; wheel++) {
72  stringstream wheel_str;
73  wheel_str << wheel;
74 
76  ibooker.book1D("hActiveUnits" + wheel_str.str(), "Active Untis x LS Wh" + wheel_str.str(), 2, 0.5, 2.5);
77  ME->setLumiFlag(); // Set LumiFlag in order to save histo every LS
78 
79  hActiveUnits.push_back(ME);
80  }
81 }
82 
84  theLumis++;
85 
86  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
87  << "[DTDCSByLumiTask]: Begin of processed lumi # " << lumiSeg.id().luminosityBlock() << " " << theLumis
88  << " lumi processed by this job" << endl;
89 
90  for (int wheel = 0; wheel < 5; wheel++) {
91  hActiveUnits[wheel]->Reset(); // Cb by lumi histo need to be resetted in between lumi boundaries
92  }
93 }
94 
96  if (DTHVRecordFound) {
97  context.get<DTHVStatusRcd>().get(hvStatus);
98  }
99 
100  vector<const DTLayer*>::const_iterator layersIt = theDTGeom->layers().begin();
101  vector<const DTLayer*>::const_iterator layersEnd = theDTGeom->layers().end();
102 
103  for (; layersIt != layersEnd; ++layersIt) {
104  int wheel = (*layersIt)->id().wheel();
105 
106  int nWiresLayer = (*layersIt)->specificTopology().channels();
107  hActiveUnits[wheel + 2]->Fill(1, nWiresLayer); // CB first bin is # of layers
108  int nActiveWires = nWiresLayer;
109 
110  int flagA = -100;
111  int flagC = -100;
112  int flagS = -100;
113  int first = -100;
114  int last = -100;
115 
116  // CB info is not stored if HV is ON -> in this case get returns 1
117  // process all other cases and removed wires with "BAD HV" from active
118  // wires list
119 
120  if (DTHVRecordFound) {
121  if (!hvStatus->get((*layersIt)->id(), 0, first, last, flagA, flagC, flagS) && (flagA || flagC || flagS)) {
122  nActiveWires -= (last - first + 1);
123  }
124 
125  if (!hvStatus->get((*layersIt)->id(), 1, first, last, flagA, flagC, flagS) && (flagA || flagC || flagS)) {
126  nActiveWires -= (last - first + 1);
127  }
128  } else {
129  nActiveWires = -1.;
130  }
131 
132  hActiveUnits[wheel + 2]->Fill(2, nActiveWires); // CB 2nd bin is the list of wires wit HV ON
133  }
134 }
135 
137 
138 string DTDCSByLumiTask::topFolder() const { return string("DT/EventInfo/DCSContents"); }
139 
140 // Local Variables:
141 // show-trailing-whitespace: t
142 // truncate-lines: t
143 // End:
LuminosityBlockID id() const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:69
int get(int wheelId, int stationId, int sectorId, int slId, int layerId, int partId, int &fCell, int &lCell, int &flagA, int &flagC, int &flagS) const
get content
Definition: DTHVStatus.cc:56
edm::ESHandle< DTHVStatus > hvStatus
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
void setLumiFlag()
this ME is meant to be stored for each luminosity section
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Begin Run.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
Definition: ME.h:11
void dqmEndLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &setup) override
By Lumi DCS DB Operation.
~DTDCSByLumiTask() override
Destructor.
void dqmBeginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context) override
By Lumi DCS DB Operation.
edm::ESHandle< DTGeometry > theDTGeom
#define LogTrace(id)
const std::vector< const DTLayer * > & layers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:88
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
LuminosityBlockNumber_t luminosityBlock() const
void fillAvailableRecordKeys(std::vector< eventsetup::EventSetupRecordKey > &oToFill) const
clears the oToFill vector and then fills it with the keys for all available records ...
Definition: EventSetup.h:167
HLT enums.
DTDCSByLumiTask(const edm::ParameterSet &ps)
Constructor.
T get() const
Definition: EventSetup.h:73
std::string topFolder() const
std::vector< MonitorElement * > hActiveUnits
Definition: event.py:1
Definition: Run.h:45