CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTDigiForNoiseTask.cc
Go to the documentation of this file.
1  /*
2  * \file DTDigiForNoiseTask.cc
3  *
4  * \author G. Mila - INFN Torino
5  *
6  */
7 
9 
10 // Framework
12 
13 // Digis
16 
17 // Geometry
22 
25 
26 #include <stdio.h>
27 #include <sstream>
28 #include <math.h>
29 
30 using namespace edm;
31 using namespace std;
32 
33 
35 
36  debug = ps.getUntrackedParameter<bool>("debug", false);
37  dtDigisToken_ = consumes<DTDigiCollection>(
38  edm::InputTag(ps.getUntrackedParameter<std::string>("diDigisLabel", "dtunpacker")));
39 
40  if(debug)
41  cout<<"[DTDigiForNoiseTask]: Constructor"<<endl;
42 
43  parameters = ps;
44 
45  nevents = 0;
46 }
47 
48 
50 
51  if(debug)
52  cout << "DTDigiForNoiseTask: analyzed " << nevents << " events" << endl;
53 
54 }
55 
57 {
58 
59  // Get the geometry
60  setup.get<MuonGeometryRecord>().get(muonGeom);
61  return;
62 }
63 
65  edm::Run const & run,
66  edm::EventSetup const & context) {
67 
68  if(debug)
69  cout<<"[DTDigiForNoiseTask]: boojHistograms"<<endl;
70 
71 }
72 
74 
75  if(debug)
76  cout<<"[DTDigiForNoiseTask]: Begin of LS transition"<<endl;
77 
78  if(lumiSeg.id().luminosityBlock()%parameters.getUntrackedParameter<int>("ResetCycle", 3) == 0) {
79  for(map< DTLayerId, MonitorElement* > ::const_iterator histo = digiHistos.begin();
80  histo != digiHistos.end();
81  histo++) {
82  (*histo).second->Reset();
83  }
84  }
85 
86 }
87 
89 
90  if (debug) cout<<"[DTDigiForNoiseTask]: booking"<<endl;
91 
92  const DTSuperLayerId dtSLId = lId.superlayerId();
93  const DTChamberId dtChId = dtSLId.chamberId();
94  stringstream layer; layer << lId.layer();
95  stringstream superLayer; superLayer << dtSLId.superlayer();
96  stringstream wheel; wheel << dtChId.wheel();
97  stringstream station; station << dtChId.station();
98  stringstream sector; sector << dtChId.sector();
99 
100  ibooker.setCurrentFolder("DT/DTDigiForNoiseTask/Wheel" + wheel.str() +
101  "/Station" + station.str() +
102  "/Sector" + sector.str() + "/DigiPerEvent");
103 
104  if (debug){
105  cout<<"[DTDigiForNoiseTask]: folder "<< "DT/DTDigiTask/Wheel" + wheel.str() +
106  "/Station" + station.str() +
107  "/Sector" + sector.str() + "/DigiPerEvent"<<endl;
108  }
109 
110  string histoName =
111  "DigiPerEvent_W" + wheel.str()
112  + "_St" + station.str()
113  + "_Sec" + sector.str()
114  + "_SL" + superLayer.str()
115  + "_L" + layer.str();
116 
117  if (debug) cout<<"[DTDigiTask]: histoName "<<histoName<<endl;
118 
119  const DTTopology& dtTopo = muonGeom->layer(lId)->specificTopology();
120  const int firstWire = dtTopo.firstChannel();
121  const int lastWire = dtTopo.lastChannel();
122  int nWires = lastWire-firstWire+1;
123 
124  digiHistos[lId] = ibooker.book2D(histoName,histoName,nWires,firstWire,lastWire,10,-0.5,9.5);
125 
126 // dynamic bookings staticized
127  // Loop over all the chambers
128  auto ch_it = muonGeom->chambers().begin();
129  auto ch_end = muonGeom->chambers().end();
130  // Loop over the SLs
131  for (; ch_it != ch_end; ++ch_it) {
132  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
133  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
134  // Loop over the SLs
135  for(; sl_it != sl_end; ++sl_it) {
136  vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
137  vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
138  // Loop over the Ls
139  for(; l_it != l_end; ++l_it) {
140  DTLayerId layerId = (*l_it)->id();
141 
142  bookHistos(ibooker,layerId);
143  }
144  }
145  }
146 
147 }
148 
149 
151 
152  nevents++;
153  if (nevents%1000 == 0 && debug) {}
154 
156  e.getByToken(dtDigisToken_, dtdigis);
157 
158  std::map< int,int > DigiPerWirePerEvent;
159 
160  // Loop over all the chambers
161  auto ch_it = muonGeom->chambers().begin();
162  auto ch_end = muonGeom->chambers().end();
163  // Loop over the SLs
164  for (; ch_it != ch_end; ++ch_it) {
165  vector<const DTSuperLayer*>::const_iterator sl_it = (*ch_it)->superLayers().begin();
166  vector<const DTSuperLayer*>::const_iterator sl_end = (*ch_it)->superLayers().end();
167  // Loop over the SLs
168  for(; sl_it != sl_end; ++sl_it) {
169  vector<const DTLayer*>::const_iterator l_it = (*sl_it)->layers().begin();
170  vector<const DTLayer*>::const_iterator l_end = (*sl_it)->layers().end();
171  // Loop over the Ls
172  for(; l_it != l_end; ++l_it) {
173  DTLayerId layerId = (*l_it)->id();
174 
175  DTDigiCollection::Range layerDigi= dtdigis->get(layerId);
176  if(layerDigi.first != layerDigi.second){
177 
178  const DTTopology& dtTopo = muonGeom->layer(layerId)->specificTopology();
179  const int firstWire = dtTopo.firstChannel();
180  const int lastWire = dtTopo.lastChannel();
181 
182  if (digiHistos.find(layerId) != digiHistos.end()){
183  for (int wire=firstWire; wire-lastWire <= 0; wire++) {
184  DigiPerWirePerEvent[wire]= 0;
185  }
186 
187  for (DTDigiCollection::const_iterator digi = layerDigi.first;
188  digi!=layerDigi.second;
189  ++digi){
190  DigiPerWirePerEvent[(*digi).wire()]+=1;
191  }
192 
193  for (int wire=firstWire; wire-lastWire<=0; wire++) {
194  digiHistos.find(layerId)->second->Fill(wire,DigiPerWirePerEvent[wire]);
195  }
196  }
197  }
198 
199  } //Loop Ls
200  } //Loop SLs
201  } //Loop over chambers
202 
203 }
204 
205 // Local Variables:
206 // show-trailing-whitespace: t
207 // truncate-lines: t
208 // End:
209 
210 
211 
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
dictionary parameters
Definition: Parameters.py:2
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
DTChamberId chamberId() const
Return the corresponding ChamberId.
void beginLuminosityBlock(edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
To reset the MEs.
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:78
void bookHistos()
Definition: Histogram.h:33
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:80
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
begin run
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
bookHistograms
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
virtual ~DTDigiForNoiseTask()
Destructor.
int superlayer() const
Return the superlayer number (deprecated method name)
#define debug
Definition: HDRShower.cc:19
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
const T & get() const
Definition: EventSetup.h:55
LuminosityBlockNumber_t luminosityBlock() const
std::vector< DTDigi >::const_iterator const_iterator
int sector() const
Definition: DTChamberId.h:61
std::pair< const_iterator, const_iterator > Range
tuple cout
Definition: gather_cfg.py:121
DTDigiForNoiseTask(const edm::ParameterSet &ps)
Constructor.
void bookHistos(DQMStore::IBooker &, const DTLayerId &dtSL)
Book the ME.
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Definition: Run.h:41