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