CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTTestPulsesTask.cc
Go to the documentation of this file.
1 /*
2  * \file DTTestPulsesTask.cc
3  *
4  * \author M. Zanetti - INFN Padova
5  *
6 */
7 
9 
10 // Framework
12 
13 // Digis
15 
16 // Geometry
21 
22 // Pedestals
28 
29 
30 using namespace edm;
31 using namespace std;
32 
33 
35 
36 
37  cout<<"[DTTestPulseTask]: Constructor"<<endl;
38  dtDigisToken_ = consumes<DTDigiCollection>(
39  edm::InputTag(ps.getUntrackedParameter<std::string>("dtdigis", "dtunpacker")));
40 
41  parameters = ps;
42 
43 
44  t0sPeakRange = make_pair( parameters.getUntrackedParameter<int>("t0sRangeLowerBound", -100),
45  parameters.getUntrackedParameter<int>("t0sRangeUpperBound", 100));
46 
47 
48  dbe = edm::Service<DQMStore>().operator->();
49 
50 }
51 
53 
54  cout <<"[DTTestPulsesTask]: analyzed " << nevents << " events" << endl;
55 
56 }
57 
58 
60 
61  cout<<"[DTTestPulsesTask]: BeginJob"<<endl;
62 
63  nevents = 0;
64 
65 }
66 
68 
69  // Get the geometry
70  context.get<MuonGeometryRecord>().get(muonGeom);
71 
72  // Get the pedestals tTrig (always get it, even if the TPRange is taken from conf)
73  //context.get<DTRangeT0Rcd>().get(t0RangeMap);
74 
75 }
76 
77 void DTTestPulsesTask::bookHistos(const DTLayerId& dtLayer, string folder, string histoTag) {
78 
79 
80  stringstream wheel; wheel << dtLayer.wheel();
81  stringstream station; station << dtLayer.station();
82  stringstream sector; sector << dtLayer.sector();
83  stringstream superLayer; superLayer << dtLayer.superlayer();
84  stringstream layer; layer << dtLayer.layer();
85 
86  cout<<"[DTTestPulseTask]: booking"<<endl;
87 
88  // TP Profiles
89  if ( folder == "TPProfile" ) {
90 
91  const int nWires = muonGeom->layer(DTLayerId(dtLayer.wheel(),
92  dtLayer.station(),
93  dtLayer.sector(),
94  dtLayer.superlayer(),
95  dtLayer.layer()))->specificTopology().channels();
96 
97  dbe->setCurrentFolder("DT/DTTestPulsesTask/Wheel" + wheel.str() +
98  "/Station" + station.str() +
99  "/Sector" + sector.str() +
100  "/SuperLayer" + superLayer.str() +
101  "/" +folder);
102 
103  string histoName = histoTag
104  + "_W" + wheel.str()
105  + "_St" + station.str()
106  + "_Sec" + sector.str()
107  + "_SL" + superLayer.str()
108  + "_L" + layer.str();
109 
110  // Setting the range
111  if ( parameters.getUntrackedParameter<bool>("readDB", false) ) {
112  t0RangeMap->slRangeT0( dtLayer.superlayerId() , t0sPeakRange.first, t0sPeakRange.second);
113  }
114 
115 
116  cout<<"t0sRangeLowerBound "<<t0sPeakRange.first<<"; "
117  <<"t0sRangeUpperBound "<<t0sPeakRange.second<<endl;
118 
119 
120  testPulsesProfiles[int(DTLayerId(dtLayer.wheel(),
121  dtLayer.station(),
122  dtLayer.sector(),
123  dtLayer.superlayer(),
124  dtLayer.layer()).rawId())] =
125  dbe->bookProfile(histoName,histoName,
126  nWires, 0, nWires, // Xaxis: channels
127  t0sPeakRange.first - t0sPeakRange.second, t0sPeakRange.first, t0sPeakRange.second); // Yaxis: times
128  }
129 
130  // TP Occupancies
131  else if ( folder == "TPOccupancy" ) {
132 
133  dbe->setCurrentFolder("DT/DTTestPulsesTask/Wheel" + wheel.str() +
134  "/Station" + station.str() +
135  "/Sector" + sector.str() +
136  "/SuperLayer" + superLayer.str() +
137  "/" +folder);
138 
139  string histoName = histoTag
140  + "_W" + wheel.str()
141  + "_St" + station.str()
142  + "_Sec" + sector.str()
143  + "_SL" + superLayer.str()
144  + "_L" + layer.str();
145 
146  const int nWires = muonGeom->layer(DTLayerId(dtLayer.wheel(),
147  dtLayer.station(),
148  dtLayer.sector(),
149  dtLayer.superlayer(),
150  dtLayer.layer()))->specificTopology().channels();
151 
152  testPulsesOccupancies[int(DTLayerId(dtLayer.wheel(),
153  dtLayer.station(),
154  dtLayer.sector(),
155  dtLayer.superlayer(),
156  dtLayer.layer()).rawId())] =
157  dbe->book1D(histoName, histoName, nWires, 0, nWires);
158  }
159 
160  // Time Box per Chamber
161  else if ( folder == "TPTimeBox" ) {
162 
163  dbe->setCurrentFolder("DT/DTTestPulsesTask/Wheel" + wheel.str() +
164  "/Station" + station.str() +
165  "/Sector" + sector.str() +
166  "/" +folder);
167 
168  string histoName = histoTag
169  + "_W" + wheel.str()
170  + "_St" + station.str()
171  + "_Sec" + sector.str();
172 
173  testPulsesTimeBoxes[int( DTLayerId(dtLayer.wheel(),
174  dtLayer.station(),
175  dtLayer.sector(),
176  dtLayer.superlayer(),
177  dtLayer.layer()).chamberId().rawId())] =
178  dbe->book1D(histoName, histoName, 10000, 0, 10000); // Overview of the TP (and noise) times
179  }
180 
181 }
182 
183 
185 
186  nevents++;
187 
189  e.getByToken(dtDigisToken_, dtdigis);
190 
192  for (dtLayerId_It=dtdigis->begin(); dtLayerId_It!=dtdigis->end(); ++dtLayerId_It){
193 
194  for (DTDigiCollection::const_iterator digiIt = ((*dtLayerId_It).second).first;
195  digiIt!=((*dtLayerId_It).second).second; ++digiIt){
196 
197  // for clearness..
198  int layerIndex = ((*dtLayerId_It).first).rawId();
199  int chIndex = ((*dtLayerId_It).first).chamberId().rawId();
200 
201 
202  if ((int)(*digiIt).countsTDC() > t0sPeakRange.first &&
203  (int)(*digiIt).countsTDC() < t0sPeakRange.second ) {
204 
205  // Occupancies
206  if (testPulsesOccupancies.find(layerIndex) != testPulsesOccupancies.end())
207  testPulsesOccupancies.find(layerIndex)->second->Fill((*digiIt).wire());
208  else {
209  bookHistos( (*dtLayerId_It).first , string("TPOccupancy"), string("TestPulses") );
210  testPulsesOccupancies.find(layerIndex)->second->Fill((*digiIt).wire());
211  }
212 
213  // Profiles
214  if (testPulsesProfiles.find(layerIndex) != testPulsesProfiles.end())
215  testPulsesProfiles.find(layerIndex)->second->Fill((*digiIt).wire(),(*digiIt).countsTDC());
216  else {
217  bookHistos( (*dtLayerId_It).first , string("TPProfile"), string("TestPulses2D") );
218  testPulsesProfiles.find(layerIndex)->second->Fill((*digiIt).wire(),(*digiIt).countsTDC());
219  }
220  }
221 
222  // Time Box
223  if (testPulsesTimeBoxes.find(chIndex) != testPulsesTimeBoxes.end())
224  testPulsesTimeBoxes.find(chIndex)->second->Fill((*digiIt).countsTDC());
225  else {
226  bookHistos( (*dtLayerId_It).first , string("TPTimeBox"), string("TestPulsesTB") );
227  testPulsesTimeBoxes.find(chIndex)->second->Fill((*digiIt).countsTDC());
228  }
229  }
230  }
231 
232 }
233 
234 
235 // Local Variables:
236 // show-trailing-whitespace: t
237 // truncate-lines: t
238 // End:
T getUntrackedParameter(std::string const &, T const &) const
dictionary parameters
Definition: Parameters.py:2
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
void bookHistos()
Definition: Histogram.h:33
U second(std::pair< T, U > const &p)
void beginRun(const edm::Run &, const edm::EventSetup &)
BeginRun.
int nevents
void bookHistos(const DTLayerId &dtLayer, std::string folder, std::string histoTag)
Book the ME.
DTTestPulsesTask(const edm::ParameterSet &ps)
Constructor.
int superlayer() const
Return the superlayer number (deprecated method name)
const T & get() const
Definition: EventSetup.h:55
std::vector< DTDigi >::const_iterator const_iterator
int sector() const
Definition: DTChamberId.h:61
virtual ~DTTestPulsesTask()
Destructor.
tuple cout
Definition: gather_cfg.py:121
void beginJob()
BeginJob.
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
Definition: Run.h:41