CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
25 
26 #include <iostream>
27 
28 using namespace edm;
29 using namespace std;
30 
32  : theEvents(0),
33  theLumis(0),
34  dtGeometryToken_(esConsumes<DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun>()),
35  dtHVStatusToken_(esConsumes<DTHVStatus, DTHVStatusRcd, edm::Transition::EndLuminosityBlock>()) {
36  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "[DTDCSByLumiTask]: Constructor" << endl;
37 
38  // If needed put getParameter here
39  // dtDCSByLumiLabel = ps.getParameter<InputTag>("dtDCSByLumiLabel");
40 }
41 
43  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
44  << "DTDCSByLumiTask: processed " << theEvents << " events in " << theLumis << " lumi sections" << endl;
45 }
46 
48  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "[DTDCSByLumiTask]: begin run" << endl;
49 
51 
52  DTHVRecordFound = true;
53 
55 
56  std::vector<eventsetup::EventSetupRecordKey> recordKeys;
57  context.fillAvailableRecordKeys(recordKeys);
58  vector<eventsetup::EventSetupRecordKey>::iterator it = find(recordKeys.begin(), recordKeys.end(), recordKey);
59 
60  if (it == recordKeys.end()) {
61  //record not found
62  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask") << "Record DTHVStatusRcd does not exist " << std::endl;
63 
64  DTHVRecordFound = false;
65  }
66 }
67 
69  // Book bylumi histo (# of bins as reduced as possible)
70  ibooker.setCurrentFolder(topFolder());
71 
72  for (int wheel = -2; wheel <= 2; wheel++) {
73  stringstream wheel_str;
74  wheel_str << wheel;
75 
76  {
77  // Set Lumi scope in order to save histo every LS
78  auto scope = DQMStore::IBooker::UseLumiScope(ibooker);
80  ibooker.book1D("hActiveUnits" + wheel_str.str(), "Active Untis x LS Wh" + wheel_str.str(), 2, 0.5, 2.5);
81  hActiveUnits.push_back(ME);
82  }
83  }
84 }
85 
87  theLumis++;
88 
89  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
90  << "[DTDCSByLumiTask]: Begin of processed lumi # " << lumiSeg.id().luminosityBlock() << " " << theLumis
91  << " lumi processed by this job" << endl;
92 
93  for (int wheel = 0; wheel < 5; wheel++) {
94  hActiveUnits[wheel]->Reset(); // Cb by lumi histo need to be resetted in between lumi boundaries
95  }
96 }
97 
99  const DTHVStatus* dtHVStatus = nullptr;
100  if (DTHVRecordFound) {
101  dtHVStatus = &context.getData(dtHVStatusToken_);
102  }
103 
104  vector<const DTLayer*>::const_iterator layersIt = theDTGeom->layers().begin();
105  vector<const DTLayer*>::const_iterator layersEnd = theDTGeom->layers().end();
106 
107  for (; layersIt != layersEnd; ++layersIt) {
108  int wheel = (*layersIt)->id().wheel();
109 
110  int nWiresLayer = (*layersIt)->specificTopology().channels();
111  hActiveUnits[wheel + 2]->Fill(1, nWiresLayer); // CB first bin is # of layers
112  int nActiveWires = nWiresLayer;
113 
114  int flagA = -100;
115  int flagC = -100;
116  int flagS = -100;
117  int first = -100;
118  int last = -100;
119 
120  // CB info is not stored if HV is ON -> in this case get returns 1
121  // process all other cases and removed wires with "BAD HV" from active
122  // wires list
123 
124  if (DTHVRecordFound) {
125  if (!dtHVStatus->get((*layersIt)->id(), 0, first, last, flagA, flagC, flagS) && (flagA || flagC || flagS)) {
126  nActiveWires -= (last - first + 1);
127  }
128 
129  if (!dtHVStatus->get((*layersIt)->id(), 1, first, last, flagA, flagC, flagS) && (flagA || flagC || flagS)) {
130  nActiveWires -= (last - first + 1);
131  }
132  } else {
133  nActiveWires = -1.;
134  }
135 
136  hActiveUnits[wheel + 2]->Fill(2, nActiveWires); // CB 2nd bin is the list of wires wit HV ON
137  }
138 }
139 
141 
142 string DTDCSByLumiTask::topFolder() const { return string("DT/EventInfo/DCSContents"); }
143 
144 // Local Variables:
145 // show-trailing-whitespace: t
146 // truncate-lines: t
147 // End:
LuminosityBlockID id() const
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:70
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
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
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)
bool getData(T &iHolder) const
Definition: EventSetup.h:122
edm::ESGetToken< DTHVStatus, DTHVStatusRcd > dtHVStatusToken_
Definition: ME.h:11
~DTDCSByLumiTask() override
Destructor.
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:540
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:177
void dqmBeginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &) override
By Lumi DCS DB Operation.
DTDCSByLumiTask(const edm::ParameterSet &ps)
Constructor.
void analyze(const edm::Event &e, const edm::EventSetup &) override
Analyze.
std::string topFolder() const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
tuple last
Definition: dqmdumpme.py:56
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
std::vector< MonitorElement * > hActiveUnits
Definition: Run.h:45