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 
30 #include <iostream>
31 
32 
33 using namespace edm;
34 using namespace std;
35 
36 
37 DTDCSByLumiTask::DTDCSByLumiTask(const edm::ParameterSet& ps) : theEvents(0) , theLumis(0) {
38 
39  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
40  << "[DTDCSByLumiTask]: Constructor" << endl;
41 
42  // If needed put getParameter here
43  // dtDCSByLumiLabel = ps.getParameter<InputTag>("dtDCSByLumiLabel");
44 
45 }
46 
47 
49 
50  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
51  << "DTDCSByLumiTask: processed " << theEvents <<
52  " events in " << theLumis << " lumi sections" << endl;
53 
54 }
55 
57 
58  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
59  << "[DTDCSByLumiTask]: begin run" << endl;
60 
61  context.get<MuonGeometryRecord>().get(theDTGeom);
62 
63  DTHVRecordFound=true;
64 
66 
67  std::vector<eventsetup::EventSetupRecordKey> recordKeys;
68  context.fillAvailableRecordKeys(recordKeys);
69  vector<eventsetup::EventSetupRecordKey>::iterator it = find(recordKeys.begin(),recordKeys.end(),recordKey);
70 
71  if( it == recordKeys.end() ) {
72  //record not found
73  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")<<"Record DTHVStatusRcd does not exist "<<std::endl;
74 
75  DTHVRecordFound=false;
76  }
77 
78 }
79 
80 
81 void DTDCSByLumiTask::bookHistograms(DQMStore::IBooker & ibooker, edm::Run const & iRun, edm::EventSetup const & context) {
82 
83  // Book bylumi histo (# of bins as reduced as possible)
84  ibooker.setCurrentFolder(topFolder());
85 
86  for(int wheel=-2; wheel <=2; wheel++) {
87 
88  stringstream wheel_str; wheel_str << wheel;
89 
90  MonitorElement* ME = ibooker.book1D("hActiveUnits"+wheel_str.str(),"Active Untis x LS Wh"+wheel_str.str(),2,0.5,2.5);
91  ME->setLumiFlag();// Set LumiFlag in order to save histo every LS
92 
93  hActiveUnits.push_back(ME);
94  }
95 }
96 
98 
99  theLumis++;
100 
101  LogTrace("DTDQM|DTMonitorModule|DTDCSByLumiTask")
102  << "[DTDCSByLumiTask]: Begin of processed lumi # " << lumiSeg.id().luminosityBlock()
103  << " " << theLumis << " lumi processed by this job" << endl;
104 
105  for(int wheel=0; wheel <5; wheel++) {
106  hActiveUnits[wheel]->Reset(); // Cb by lumi histo need to be resetted in between lumi boundaries
107  }
108 
109 }
110 
111 
113 
114 
115  if(DTHVRecordFound) context.get<DTHVStatusRcd>().get(hvStatus);
116 
117  vector<const DTLayer*>::const_iterator layersIt = theDTGeom->layers().begin();
118  vector<const DTLayer*>::const_iterator layersEnd = theDTGeom->layers().end();
119 
120  for(; layersIt!=layersEnd; ++layersIt) {
121 
122  int wheel = (*layersIt)->id().wheel();
123 
124  int nWiresLayer = (*layersIt)->specificTopology().channels();
125 
126  hActiveUnits[wheel+2]->Fill(1,nWiresLayer); // CB first bin is # of layers
127  int nActiveWires = nWiresLayer;
128 
129  int flagA = -100;
130  int flagC = -100;
131  int flagS = -100;
132  int first = -100;
133  int last = -100;
134 
135  // CB info is not stored if HV is ON -> in this case get returns 1
136  // process all other cases and removed wires with "BAD HV" from active
137  // wires list
138 
139  if( DTHVRecordFound ) {
140  if ( !hvStatus->get((*layersIt)->id(),0,first,last,flagA,flagC,flagS)
141  && (flagA || flagC || flagS) ) {
142  nActiveWires -= (last - first + 1);
143  }
144 
145  if ( !hvStatus->get((*layersIt)->id(),1,first,last,flagA,flagC,flagS)
146  && (flagA || flagC || flagS) ) {
147  nActiveWires -= (last - first + 1);
148  }
149  } else {
150  nActiveWires=-1.;
151  }
152 
153  hActiveUnits[wheel+2]->Fill(2,nActiveWires); // CB 2nd bin is the list of wires wit HV ON
154 
155  }
156 }
157 
158 
160 
161  theEvents++;
162 
163 }
164 
165 
167 
168  return string("DT/EventInfo/DCSContents");
169 
170 }
171 
172 // Local Variables:
173 // show-trailing-whitespace: t
174 // truncate-lines: t
175 // End:
LuminosityBlockID id() const
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:76
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:84
edm::ESHandle< DTHVStatus > hvStatus
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context) override
By Lumi DCS DB Operation.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
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:20
virtual ~DTDCSByLumiTask()
Destructor.
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &setup) override
By Lumi DCS DB Operation.
Definition: ME.h:11
edm::ESHandle< DTGeometry > theDTGeom
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.cc:102
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
#define LogTrace(id)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
const std::vector< const DTLayer * > & layers() const
Return a vector of all SuperLayer.
Definition: DTGeometry.cc:95
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
const T & get() const
Definition: EventSetup.h:56
LuminosityBlockNumber_t luminosityBlock() const
HLT enums.
DTDCSByLumiTask(const edm::ParameterSet &ps)
Constructor.
std::string topFolder() const
void setLumiFlag(void)
this ME is meant to be stored for each luminosity section
std::vector< MonitorElement * > hActiveUnits
Definition: event.py:1
Definition: Run.h:42