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
19 
24 
25 #include <iostream>
26 
27 using namespace edm;
28 using namespace std;
29 
31  : theEvents(0),
32  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  theDTGeom = context.getHandle(dtGeometryToken_);
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 
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 
75  {
76  // Set Lumi scope in order to save histo every LS
77  auto scope = DQMStore::IBooker::UseLumiScope(ibooker);
79  ibooker.book1D("hActiveUnits" + wheel_str.str(), "Active Untis x LS Wh" + wheel_str.str(), 2, 0.5, 2.5);
80  hActiveUnits.push_back(ME);
81  }
82  }
83 }
84 
86  theLumis++;
87 
88  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
89  << "[DTDCSByLumiTask]: Begin of processed lumi # " << lumiSeg.id().luminosityBlock() << " " << theLumis
90  << " lumi processed by this job" << endl;
91 
92  for (int wheel = 0; wheel < 5; wheel++) {
93  hActiveUnits[wheel]->Reset(); // Cb by lumi histo need to be resetted in between lumi boundaries
94  }
95 }
96 
98  const DTHVStatus* dtHVStatus = nullptr;
99  if (DTHVRecordFound) {
100  dtHVStatus = &context.getData(dtHVStatusToken_);
101  }
102 
103  vector<const DTLayer*>::const_iterator layersIt = theDTGeom->layers().begin();
104  vector<const DTLayer*>::const_iterator layersEnd = theDTGeom->layers().end();
105 
106  for (; layersIt != layersEnd; ++layersIt) {
107  int wheel = (*layersIt)->id().wheel();
108 
109  int nWiresLayer = (*layersIt)->specificTopology().channels();
110  hActiveUnits[wheel + 2]->Fill(1, nWiresLayer); // CB first bin is # of layers
111  int nActiveWires = nWiresLayer;
112 
113  int flagA = -100;
114  int flagC = -100;
115  int flagS = -100;
116  int first = -100;
117  int last = -100;
118 
119  // CB info is not stored if HV is ON -> in this case get returns 1
120  // process all other cases and removed wires with "BAD HV" from active
121  // wires list
122 
123  if (DTHVRecordFound) {
124  if (!dtHVStatus->get((*layersIt)->id(), 0, first, last, flagA, flagC, flagS) && (flagA || flagC || flagS)) {
125  nActiveWires -= (last - first + 1);
126  }
127 
128  if (!dtHVStatus->get((*layersIt)->id(), 1, first, last, flagA, flagC, flagS) && (flagA || flagC || flagS)) {
129  nActiveWires -= (last - first + 1);
130  }
131  } else {
132  nActiveWires = -1.;
133  }
134 
135  hActiveUnits[wheel + 2]->Fill(2, nActiveWires); // CB 2nd bin is the list of wires wit HV ON
136  }
137 }
138 
140 
141 string DTDCSByLumiTask::topFolder() const { return string("DT/EventInfo/DCSContents"); }
142 
143 // Local Variables:
144 // show-trailing-whitespace: t
145 // truncate-lines: t
146 // End:
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:70
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
LuminosityBlockNumber_t luminosityBlock() const
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
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
#define LogTrace(id)
edm::ESGetToken< DTHVStatus, DTHVStatusRcd > dtHVStatusToken_
Definition: ME.h:11
~DTDCSByLumiTask() override
Destructor.
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< DTGeometry > theDTGeom
Transition
Definition: Transition.h:12
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeometryToken_
void dqmEndLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &) override
By Lumi DCS DB Operation.
UseScope< MonitorElementData::Scope::LUMI > UseLumiScope
Definition: DQMStore.h:549
LuminosityBlockID id() const
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void dqmBeginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &) override
By Lumi DCS DB Operation.
HLT enums.
DTDCSByLumiTask(const edm::ParameterSet &ps)
Constructor.
void analyze(const edm::Event &e, const edm::EventSetup &) override
Analyze.
const std::vector< const DTLayer * > & layers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:88
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::string topFolder() const
std::vector< MonitorElement * > hActiveUnits
Definition: Run.h:45