CMS 3D CMS Logo

DaqScopeModeTask.cc
Go to the documentation of this file.
8 
9 using namespace sistrip;
10 
11 // -----------------------------------------------------------------------------
12 //
14  const FedChannelConnection& conn,
15  const edm::ParameterSet & pset) :
16  CommissioningTask( dqm, conn, "DaqScopeModeTask" ),
17  scopeFrame_(),
18  nBins_(256), //@@ number of strips per FED channel
19  nBinsSpy_(298), //@@ in case of spy events includes header and trailing tick
20  parameters_(pset)
21 {}
22 
23 // -----------------------------------------------------------------------------
24 //
26 }
27 
28 // -----------------------------------------------------------------------------
29 //
31  LogTrace(mlDqmSource_) << "[CommissioningTask::" << __func__ << "]";
32 
34  if(not (parameters_.existsAs<bool>("isSpy") and parameters_.getParameter<bool>("isSpy"))){
35 
40  fedKey(),
42  connection().lldChannel(),
44 
45  scopeFrame_.histo( dqm()->book1D( title, title,
46  nBins_, -0.5, nBins_-0.5 ) );
47 
51  scopeFrame_.isProfile_ = false;
52  }
53  else{ // use spy run to measure pedestal and tick height
54 
55  std::string extra_info;
56  peds_.resize(2);
57  extra_info = sistrip::extrainfo::pedestals_;
58 
59  peds_[0].isProfile_ = true;
63  fedKey(),
65  connection().lldChannel(),
66  extra_info ).title();
67 
68  peds_[0].histo( dqm()->bookProfile( title, title,
69  nBins_, -0.5,nBins_*1.-0.5,
70  1025, 0., 1025. ) );
71 
72  peds_[0].vNumOfEntries_.resize(nBins_,0);
73  peds_[0].vSumOfContents_.resize(nBins_,0);
74  peds_[0].vSumOfSquares_.resize(nBins_,0);
75 
76  // Noise histogram
77  extra_info = sistrip::extrainfo::noise_;
78  peds_[1].isProfile_ = true;
79 
83  fedKey(),
85  connection().lldChannel(),
86  extra_info ).title();
87 
88  peds_[1].histo( dqm()->bookProfile( title, title,
89  nBins_, -0.5, nBins_*1.-0.5,
90  1025, 0., 1025. ) );
91 
92  peds_[1].vNumOfEntries_.resize(nBins_,0);
93  peds_[1].vSumOfContents_.resize(nBins_,0);
94  peds_[1].vSumOfSquares_.resize(nBins_,0);
95 
96  // Common mode histograms
97  cm_.resize(2);
98  int nbins = 1024;
99 
100  for ( uint16_t iapv = 0; iapv < 2; iapv++ ) {
104  fedKey(),
105  sistrip::APV,
106  connection().i2cAddr(iapv),
108 
109  cm_[iapv].histo( dqm()->book1D( title, title, nbins, -0.5, nbins*1.-0.5 ) );
110  cm_[iapv].isProfile_ = false;
111 
112  cm_[iapv].vNumOfEntries_.resize(nbins,0);
113  cm_[iapv].vNumOfEntries_.resize(nbins,0);
114  }
115 
116 
121  fedKey(),
123  connection().lldChannel(),
125 
126  scopeFrame_.histo( dqm()->bookProfile( title, title,
127  nBinsSpy_, -0.5, nBinsSpy_*1.-0.5,
128  1025, 0., 1025. ) );
129 
133  scopeFrame_.isProfile_ = true;
134 
135 
136  }
137 }
138 
139 // -----------------------------------------------------------------------------
140 //
142  const edm::DetSet<SiStripRawDigi>& digis ) {
143 
144  // Only fill every 'N' events
145  if(not (parameters_.existsAs<bool>("isSpy") and parameters_.getParameter<bool>("isSpy"))){
146  if ( !updateFreq() || fillCntr()%updateFreq() ) { return; }
147  }
148 
149  if ( digis.data.size() != nBins_ ) { //@@ check scope mode length?
151  << "[DaqScopeModeTask::" << __func__ << "]"
152  << " Unexpected number of digis ("
153  << digis.data.size()
154  << ") wrt number of histogram bins ("
155  << nBins_ << ")!";
156  }
157 
158 
159  if(not (parameters_.existsAs<bool>("isSpy") and parameters_.getParameter<bool>("isSpy"))){
160  uint16_t bins = digis.data.size() < nBins_ ? digis.data.size() : nBins_;
161  for ( uint16_t ibin = 0; ibin < bins; ibin++ ) {
162  updateHistoSet( scopeFrame_, ibin, digis.data[ibin].adc() );
163  }
164  }
165  else{
166  // fill the pedestal histograms as done in the pedestal task
167  // Check number of digis
168  uint16_t nbins = peds_[0].vNumOfEntries_.size();
169  if ( digis.data.size() < nbins ) { nbins = digis.data.size(); }
170 
171  uint16_t napvs = nbins / 128;
172  std::vector<uint32_t> cm; cm.resize(napvs,0);
173 
174  // Calc common mode for both APVs
175  std::vector<uint16_t> adc;
176  for ( uint16_t iapv = 0; iapv < napvs; iapv++ ) {
177  adc.clear(); adc.reserve(128);
178 
179  for ( uint16_t ibin = 0; ibin < 128; ibin++ ) {
180  if ( (iapv*128)+ibin < nbins ) {
181  adc.push_back( digis.data[(iapv*128)+ibin].adc() );
182  }
183  }
184 
185  sort( adc.begin(), adc.end() );
186  uint16_t index = adc.size()%2 ? adc.size()/2 : adc.size()/2-1;
187  if ( !adc.empty() ) { cm[iapv] = static_cast<uint32_t>( adc[index] ); }
188  }
189  for ( uint16_t ibin = 0; ibin < nbins; ibin++ ) {
190  float digiVal = digis.data[ibin].adc();
191  updateHistoSet( peds_[0], ibin, digiVal ); // peds and raw noise
192  float diff = digiVal - static_cast<float>( cm[ibin/128] );
193  updateHistoSet( peds_[1], ibin, diff ); // residuals and real noise
194  }
195 
196  if ( cm.size() < cm_.size() ) {
198  << "[PedestalsTask::" << __func__ << "]"
199  << " Fewer CM values than expected: " << cm.size();
200  }
201 
202  updateHistoSet( cm_[0], cm[0] );
203  updateHistoSet( cm_[1], cm[1] );
204  }
205 
206 }
207 
208 // -----------------------------------------------------------------------------
209 //
211  const edm::DetSet<SiStripRawDigi>& digis,
212  const edm::DetSet<SiStripRawDigi>& digisAlt) {
213 
214  // Only fill every 'N' events
215  if(not (parameters_.existsAs<bool>("isSpy") and parameters_.getParameter<bool>("isSpy"))){
216  if ( !updateFreq() || fillCntr()%updateFreq() ) { return; }
217  }
218 
219  if ( digis.data.size() != nBins_ ) { //@@ check scope mode length?
221  << "[DaqScopeModeTask::" << __func__ << "]"
222  << " Unexpected number of digis ("
223  << digis.data.size()
224  << ") wrt number of histogram bins ("
225  << nBins_ << ")!";
226  }
227 
228  if(not (parameters_.existsAs<bool>("isSpy") and parameters_.getParameter<bool>("isSpy"))){
229  uint16_t bins = digis.data.size() < nBins_ ? digis.data.size() : nBins_;
230  for ( uint16_t ibin = 0; ibin < bins; ibin++ ) {
231  updateHistoSet( scopeFrame_, ibin, digis.data[ibin].adc() );
232  }
233  }
234  else{
235  // fill the pedestal histograms as done in the pedestal task
236  // Check number of digis
237  uint16_t nbins = peds_[0].vNumOfEntries_.size();
238  if ( digis.data.size() < nbins ) { nbins = digis.data.size(); }
239 
240  uint16_t napvs = nbins / 128;
241  std::vector<uint32_t> cm; cm.resize(napvs,0);
242 
243  // Calc common mode for both APVs
244  std::vector<uint16_t> adc;
245  for ( uint16_t iapv = 0; iapv < napvs; iapv++ ) {
246  adc.clear(); adc.reserve(128);
247  for ( uint16_t ibin = 0; ibin < 128; ibin++ ) {
248  if ( (iapv*128)+ibin < nbins ) {
249  adc.push_back( digis.data[(iapv*128)+ibin].adc() );
250  }
251  }
252  sort( adc.begin(), adc.end() );
253  uint16_t index = adc.size()%2 ? adc.size()/2 : adc.size()/2-1;
254  if ( !adc.empty() ) { cm[iapv] = static_cast<uint32_t>( adc[index] ); }
255  }
256 
258  for ( uint16_t ibin = 0; ibin < nbins; ibin++ ) {
259  float digiVal = digis.data[ibin].adc();
260  updateHistoSet( peds_[0], ibin, digiVal ); // peds and raw noise
261  float diff = digiVal - static_cast<float>( cm[ibin/128] );
262  updateHistoSet( peds_[1], ibin, diff ); // residuals and real noise
263  }
264 
265  if ( cm.size() < cm_.size() ) {
267  << "[PedestalsTask::" << __func__ << "]"
268  << " Fewer CM values than expected: " << cm.size();
269  }
270 
271  updateHistoSet( cm_[0], cm[0] );
272  updateHistoSet( cm_[1], cm[1] );
273 
274  uint16_t bins = digisAlt.data.size() < nBinsSpy_ ? digisAlt.data.size() : nBinsSpy_;
275  for ( uint16_t ibin = 0; ibin < bins; ibin++ ) {
276  updateHistoSet( scopeFrame_, ibin, digisAlt.data[ibin].adc() );
277  }
278  }
279 }
280 
281 // -----------------------------------------------------------------------------
282 //
284 
285  if(not (parameters_.existsAs<bool>("isSpy") and parameters_.getParameter<bool>("isSpy")))
287  else{
288 
289  updateHistoSet( peds_[0] );
290  TProfile* histo = ExtractTObject<TProfile>().extract( peds_[1].histo() );
291  for ( uint16_t ii = 0; ii < peds_[1].vNumOfEntries_.size(); ++ii ) {
292 
293  float mean = 0.;
294  float spread = 0.;
295  float entries = peds_[1].vNumOfEntries_[ii];
296  if ( entries > 0. ) {
297  mean = peds_[1].vSumOfContents_[ii] / entries;
298  spread = sqrt( peds_[1].vSumOfSquares_[ii] / entries - mean * mean );
299  }
300 
301  float noise = spread;
302  float error = 0; // sqrt(entries) / entries;
303  UpdateTProfile::setBinContent( histo, ii+1, entries, noise, error );
304  }
305  updateHistoSet( cm_[0] );
306  updateHistoSet( cm_[1] );
308 
309  }
310 }
311 
312 
int adc(sample_type sample)
get the ADC sample (12 bits)
static const char noise_[]
T getParameter(std::string const &) const
std::vector< float > vNumOfEntries_
edm::ParameterSet parameters_
parameters useful for the spy
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:185
Utility class that holds histogram title.
const std::string & title() const
DaqScopeModeTask(DQMStore *, const FedChannelConnection &, const edm::ParameterSet &)
static const char mlDqmSource_[]
std::vector< float > vSumOfContents_
const uint32_t & updateFreq() const
sistrip classes
void updateHistoSet(HistoSet &, const uint32_t &bin, const float &value)
std::vector< HistoSet > peds_
void book() override
Class containning control, module, detector and connection information, at the level of a FED channel...
T sqrt(T t)
Definition: SSEVec.h:18
void fill(const SiStripEventSummary &, const edm::DetSet< SiStripRawDigi > &) override
static void setBinContent(TProfile *const profile, const uint32_t &bin, const double &entries, const double &mean, const double &spread)
static const char commonMode_[]
#define LogTrace(id)
std::vector< HistoSet > cm_
ii
Definition: cuy.py:590
int extract(std::vector< int > *output, const std::string &dati)
static const char pedestals_[]
~DaqScopeModeTask() override
DQMStore *const dqm() const
const uint32_t & fillCntr() const
void update() override
collection_type data
Definition: DetSet.h:78
void histo(MonitorElement *)
static const char scopeModeFrame_[]
const uint32_t & fedKey() const
std::vector< double > vSumOfSquares_
const FedChannelConnection & connection() const