CMS 3D CMS Logo

SiStripCommissioningSource.cc
Go to the documentation of this file.
34 #include <boost/cstdint.hpp>
35 #include <memory>
36 #include <iomanip>
37 #include <sstream>
38 #include <ctime>
39 
40 #include <sys/types.h>
41 #include <unistd.h>
42 #include <iomanip>
43 
44 #include <arpa/inet.h>
45 #include <sys/unistd.h>
46 #include <sys/socket.h>
47 #include <netdb.h>
48 #include <cstdio>
49 
50 
51 using namespace sistrip;
52 
53 // -----------------------------------------------------------------------------
54 //
56  dqm_(nullptr),
57  fedCabling_(nullptr),
58  fecCabling_(nullptr),
59  inputModuleLabel_( pset.getParameter<std::string>( "InputModuleLabel" ) ),
60  inputModuleLabelAlt_(pset.existsAs<std::string>("InputModuleLabelAlt")?pset.getParameter<std::string>( "InputModuleLabelAlt" ):""),
61  inputModuleLabelSummary_( pset.getParameter<std::string>( "SummaryInputModuleLabel" ) ),
62  filename_( pset.getUntrackedParameter<std::string>("RootFileName",sistrip::dqmSourceFileName_) ),
63  run_(0),
64  partitionName_(pset.existsAs<std::string>("PartitionName") ? pset.getParameter<std::string>("PartitionName") : ""),
65  time_(0),
66  isSpy_(pset.existsAs<bool>("isSpy")?pset.getParameter<bool>("isSpy"):false),
67  taskConfigurable_( pset.getUntrackedParameter<std::string>("CommissioningTask","UNDEFINED") ),
69  tasks_(),
70  cablingTasks_(),
71  tasksExist_(false),
72  cablingTask_(false),
73  updateFreq_( pset.getUntrackedParameter<int>("HistoUpdateFreq",1) ),
74  base_(""),
75  view_( pset.getUntrackedParameter<std::string>("View", "Default") ),
76  parameters_(pset)
77 {
78  inputModuleSummaryToken_ = consumes<SiStripEventSummary>(edm::InputTag(inputModuleLabelSummary_) );
79  digiVirginRawToken_ = mayConsume<edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_,"VirginRaw") );
80  digiFineDelaySelectionToken_ = mayConsume<edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_,"FineDelaySelection") );
81  digiReorderedToken_ = mayConsume<edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_,"SpyReordered") );
82  if(not isSpy_)
83  digiScopeModeToken_ = mayConsume<edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_,"ScopeMode") );
84  else
85  digiScopeModeToken_ = mayConsume<edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabelAlt_,"ScopeRawDigis") );
86 
88  << "[SiStripCommissioningSource::" << __func__ << "]"
89  << " Constructing object...";
90  tasks_.clear();
91  tasks_.resize( 1024, VecOfTasks(96,static_cast<CommissioningTask*>(nullptr)) );
92 }
93 
94 // -----------------------------------------------------------------------------
95 //
98  << "[SiStripCommissioningSource::" << __func__ << "]"
99  << " Destructing object...";
100 }
101 
102 // -----------------------------------------------------------------------------
103 //
105  if ( !dqm_ ) {
106  std::stringstream ss;
107  if ( !method.empty() ) { ss << "[SiStripCommissioningSource::" << method << "]" << std::endl; }
108  else { ss << "[SiStripCommissioningSource]" << std::endl; }
109  ss << " NULL pointer to DQMStore";
110  edm::LogWarning(mlDqmSource_) << ss.str();
111  return nullptr;
112  } else { return dqm_; }
113 }
114 
115 // -----------------------------------------------------------------------------
116 // Retrieve DQM interface, control cabling and "control view" utility
117 // class, create histogram directory structure and generate "reverse"
118 // control cabling.
121  << "[SiStripCommissioningSource::" << __func__ << "]"
122  << " Configuring..." << std::endl;
123 
124  // ---------- DQM back-end interface ----------
125 
128  << "[SiStripCommissioningSource::" << __func__ << "]"
129  << " DQMStore service: "
130  << dqm_;
131  dqm(__func__);
132  dqm()->setVerbose(0);
133 
134  // ---------- Base directory ----------
135 
136  std::stringstream dir("");
137  base_ = dir.str();
138 
139  // ---------- FED and FEC cabling ----------
140 
142  setup.get<SiStripFedCablingRcd>().get( fed_cabling );
143  fedCabling_ = const_cast<SiStripFedCabling*>( fed_cabling.product() );
145  << "[SiStripCommissioningSource::" << __func__ << "]"
146  << "Initialized FED cabling. Number of FEDs is " << fedCabling_->fedIds().size();
147  fecCabling_ = new SiStripFecCabling( *fed_cabling );
148  if ( fecCabling_->crates().empty() ) {
149  std::stringstream ss;
150  ss << "[SiStripCommissioningSource::" << __func__ << "]"
151  << " Empty std::vector returned by FEC cabling object!"
152  << " Check if database connection failed...";
153  edm::LogWarning(mlDqmSource_) << ss.str();
154  }
155 
156  // ---------- Reset ----------
157 
158  tasksExist_ = false;
160  cablingTask_ = false;
161 
162  remove();
163 
165  clearTasks();
166 
167 }
168 
169 // -----------------------------------------------------------------------------
170 //
173  << "[SiStripCommissioningSource::" << __func__ << "]"
174  << " Halting..." << std::endl;
175 
176  // ---------- Update histograms ----------
177  // Cabling task
178  if(cablingTask_){
179  for ( TaskMap::iterator itask = cablingTasks_.begin(); itask != cablingTasks_.end(); itask++ ) {
180  if ( itask->second ) { itask->second->updateHistograms(); }
181  }
182  }
183 
184  if (task_ == sistrip::APV_LATENCY) {
185  for (uint16_t partition = 0; partition < 4; ++partition) {
186  tasks_[0][partition]->updateHistograms();
187  }
188  } else if (task_ == sistrip::FINE_DELAY ) {
189  tasks_[0][0]->updateHistograms();
190  } else {
191  // All tasks except cabling
192  uint16_t fed_id = 0;
193  uint16_t fed_ch = 0;
194  auto ifed = fedCabling_->fedIds().begin();
195  for ( ; ifed != fedCabling_->fedIds().end(); ifed++ ) {
196  auto conns = fedCabling_->fedConnections(*ifed);
197  for ( auto iconn = conns.begin(); iconn != conns.end(); iconn++ ) {
198  if ( !iconn->isConnected() ) { continue; }
199  fed_id = iconn->fedId();
200  fed_ch = iconn->fedCh();
201  if ( tasks_[fed_id][fed_ch] ) {
202  tasks_[fed_id][fed_ch]->updateHistograms();
203  delete tasks_[fed_id][fed_ch];
204  }
205  }
206  }
207  }
208  // ---------- Save histos to root file ----------
209  // Strip filename of ".root" extension
211  if ( filename_.find(".root",0) == std::string::npos ) { name = filename_; }
212  else { name = filename_.substr( 0, filename_.find(".root",0) ); }
213 
214  // Retrieve SCRATCH directory
215  std::string scratch = "SCRATCH"; //@@ remove trailing slash!!!
216  std::string dir = "";
217  if ( getenv(scratch.c_str()) != nullptr ) {
218  dir = getenv(scratch.c_str());
219  }
220 
221  // Add directory path
222  std::stringstream ss;
223  if ( !dir.empty() ) { ss << dir << "/"; }
224  else { ss << "/tmp/"; }
225 
226  // Add filename with run number, host ip, pid and .root extension
227  ss << name << "_";
228  if(task_ == sistrip::DAQ_SCOPE_MODE and not partitionName_.empty())
229  ss << partitionName_ << "_";
230  directory(ss,run_);
231  ss << ".root";
232 
233  // Save file with appropriate filename (if run number is known)
234  if ( !filename_.empty() ) {
235  if ( run_ != 0 ) { dqm()->save( ss.str() ); }
236  else {
238  << "[SiStripCommissioningSource::" << __func__ << "]"
239  << " NULL value for RunNumber! No root file saved!";
240  }
241  } else {
243  << "[SiStripCommissioningSource::" << __func__ << "]"
244  << " NULL value for filename! No root file saved!";
245  }
246 
248  << "[SiStripCommissioningSource::" << __func__ << "]"
249  << " Saved all histograms to file \""
250  << ss.str() << "\"";
251 
252  // ---------- Delete histograms ----------
253 
254  // Remove all MonitorElements in "SiStrip" dir and below
255  // remove();
256 
257  // Delete histogram objects
258  // clearCablingTasks();
259  // clearTasks();
260  // ---------- Delete cabling ----------
261  if ( fedCabling_ ) { fedCabling_ = nullptr; }
262  if ( fecCabling_ ) { delete fecCabling_; fecCabling_ = nullptr; }
263 }
264 
265 // ----------------------------------------------------------------------------
266 //
268  const edm::EventSetup& setup ) {
269  // Retrieve commissioning information from "event summary"
271  // event.getByLabel( inputModuleLabelSummary_, summary );
272  event.getByToken( inputModuleSummaryToken_,summary );
273 
274  // Check if EventSummary has info attached
275  if ( ( summary->runType() == sistrip::UNDEFINED_RUN_TYPE ||
276  summary->runType() == sistrip::UNKNOWN_RUN_TYPE ) &&
277  summary->nullParams() ) {
279  << "[SiStripCommissioningSource::" << __func__ << "]"
280  << " Unknown/undefined RunType and NULL parameter values!"
281  << " It may be that the 'trigger FED' object was not found!";
282  }
283 
284  // Check if need to rebuild FED/FEC cabling objects for connection run
285  //cablingForConnectionRun( summary->runType() ); //@@ do not use!
286 
287  // Extract run number and forward to client
288  if ( event.id().run() != run_ ) {
289  run_ = event.id().run();
290  createRunNumber();
291  }
292 
293  // Coarse event rate counter
294  if ( !(event.id().event()%updateFreq_) ) {
295  std::stringstream ss;
296  ss << "[SiStripCommissioningSource::" << __func__ << "]"
297  << " The last " << updateFreq_
298  << " events were processed at a rate of ";
299  if ( time(nullptr) == time_ ) { ss << ">" << updateFreq_ << " Hz"; }
300  else { ss << (updateFreq_/(time(nullptr)-time_)) << " Hz"; }
301  edm::LogVerbatim(mlDqmSource_) << ss.str();
302  time_ = time(nullptr);
303  }
304 
305  // Create commissioning task objects
306  if ( !tasksExist_ ) { createTask( summary.product(), setup ); }
307 
308  // Retrieve raw digis with mode appropriate to task
311  if ( task_ == sistrip::DAQ_SCOPE_MODE ) {
312  if ( not isSpy_ and summary->fedReadoutMode() == FED_VIRGIN_RAW ) {
313  event.getByToken( digiVirginRawToken_, raw );
314  } else if (not isSpy_ and summary->fedReadoutMode() == FED_SCOPE_MODE ) {
315  event.getByToken( digiScopeModeToken_, raw );
316  }
317  else if(isSpy_){ // spy case take both re-ordered and scope mode
318  event.getByToken( digiScopeModeToken_, rawAlt );
319  event.getByToken( digiReorderedToken_, raw );
320  } else {
321  std::stringstream ss;
322  ss << "[SiStripCommissioningSource::" << __func__ << "]"
323  << " Requested DAQ_SCOPE_MODE but unknown FED"
324  << " readout mode retrieved from SiStripEventSummary: "
326  edm::LogWarning(mlDqmSource_) << ss.str();
327  }
328  } else if ( task_ == sistrip::FAST_CABLING ||
332  task_ == sistrip::OPTO_SCAN ) {
333  // event.getByLabel( inputModuleLabel_, "ScopeMode", raw );
334  event.getByToken( digiScopeModeToken_, raw );
335  } else if ( task_ == sistrip::VPSP_SCAN ||
342  task_ == sistrip::NOISE ||
344  // event.getByLabel( inputModuleLabel_, "VirginRaw", raw );
345  event.getByToken( digiVirginRawToken_, raw );
346  } else if ( task_ == sistrip::APV_LATENCY ||
348  // event.getByLabel( inputModuleLabel_, "FineDelaySelection", raw );
349  event.getByToken( digiFineDelaySelectionToken_, raw );
350  } else {
351  std::stringstream ss;
352  ss << "[SiStripCommissioningSource::" << __func__ << "]"
353  << " Unknown CommissioningTask: "
355  << " Unable to establish FED readout mode and retrieve digi container!"
356  << " Check if SiStripEventSummary object is found/present in Event";
357  edm::LogWarning(mlDqmSource_) << ss.str();
358  return;
359  }
360 
361  // Check for NULL pointer to digi container
362  if ( &(*raw) == nullptr ) {
363  std::stringstream ss;
364  ss << "[SiStripCommissioningSource::" << __func__ << "]" << std::endl
365  << " NULL pointer to DetSetVector!" << std::endl
366  << " Unable to fill histograms!";
367  edm::LogWarning(mlDqmSource_) << ss.str();
368  return;
369  }
370 
371  if(isSpy_ and &(*rawAlt) == nullptr){
372  std::stringstream ss;
373  ss << "[SiStripCommissioningSource::" << __func__ << "]" << std::endl
374  << " NULL pointer to DetSetVector!" << std::endl
375  << " Unable to fill histograms!";
376  edm::LogWarning(mlDqmSource_) << ss.str();
377  return;
378  }
379 
380  if ( !cablingTask_ ) { fillHistos( summary.product(), *raw, rawAlt.product()); }
381  else { fillCablingHistos( summary.product(), *raw); }
382 
383 }
384 
385 // ----------------------------------------------------------------------------
386 //
388  const edm::DetSetVector<SiStripRawDigi>& raw ) {
389 
390  // Create FEC key using DCU id and LLD channel from SiStripEventSummary
391  const SiStripModule& module = fecCabling_->module( summary->dcuId() );
392  uint16_t lld_channel = ( summary->deviceId() & 0x3 ) + 1;
393  SiStripFecKey key_object( module.key().fecCrate(),
394  module.key().fecSlot(),
395  module.key().fecRing(),
396  module.key().ccuAddr(),
397  module.key().ccuChan(),
398  lld_channel );
399  uint32_t fec_key = key_object.key();
400  std::stringstream sss;
401  sss << "[SiStripCommissioningSource::" << __func__ << "]"
402  << " Found DcuId 0x"
403  << std::hex << std::setw(8) << std::setfill('0') << summary->dcuId() << std::dec
404  << " with Crate/FEC/Ring/CCU/Module/LLD: "
405  << module.key().fecCrate() << "/"
406  << module.key().fecSlot() << "/"
407  << module.key().fecRing() << "/"
408  << module.key().ccuAddr() << "/"
409  << module.key().ccuChan() << "/"
410  << lld_channel;
411  edm::LogWarning(mlDqmSource_) << sss.str();
412 
413  //LogTrace(mlTest_) << "TEST : " << key_object;
414 
415  // Check on whether DCU id is found
416  if ( key_object.isInvalid( sistrip::CCU_CHAN ) ) {
417  std::stringstream ss;
418  ss << "[SiStripCommissioningSource::" << __func__ << "]"
419  << " DcuId 0x"
420  << std::hex << std::setw(8) << std::setfill('0') << summary->dcuId() << std::dec
421  << " in 'DAQ register' field not found in cabling map!"
422  << " (NULL values returned for FEC path)";
423  edm::LogWarning(mlDqmSource_) << ss.str();
424  return;
425  }
426 
427  // Iterate through FED ids
428  for (auto ifed = fedCabling_->fedIds().begin() ; ifed != fedCabling_->fedIds().end(); ifed++ ) {
429 
430  // Check if FedId is non-zero
431  if ( *ifed == sistrip::invalid_ ) { continue; }
432 
433  // Container to hold median signal level for FED cabling task
434  std::map<uint16_t,float> medians; medians.clear();
435  std::map<uint16_t,float> medians1; medians1.clear();
436 
437  // Iterate through FED channels
438  for ( uint16_t ichan = 0; ichan < 96; ichan++ ) {
439 
440  // // Retrieve digis for given FED key
441  // uint32_t fed_key = SiStripFedKey( *ifed,
442  // SiStripFedKey::feUnit(ichan),
443  // SiStripFedKey::feChan(ichan) ).key();
444 
445  // Retrieve digis for given FED key
446  uint32_t fed_key = ( ( *ifed & sistrip::invalid_ ) << 16 ) | ( ichan & sistrip::invalid_ );
447 
448  std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.find( fed_key );
449  if ( digis != raw.end() ) {
450  if ( digis->data.empty() ) { continue; }
451 
452  // if ( digis->data[0].adc() > 500 ) {
453  // std::stringstream ss;
454  // ss << " HIGH SIGNAL " << digis->data[0].adc() << " FOR"
455  // << " FedKey: 0x" << std::hex << std::setw(8) << std::setfill('0') << fed_key << std::dec
456  // << " FedId/Ch: " << *ifed << "/" << ichan;
457  // LogTrace(mlDqmSource_) << ss.str();
458  // }
459 
460  Averages ave;
461  for ( uint16_t idigi = 0; idigi < digis->data.size(); idigi++ ) {
462  ave.add( static_cast<uint32_t>(digis->data[idigi].adc()) );
463  }
464  Averages::Params params;
465  ave.calc(params);
466  medians[ichan] = params.median_; // Store median signal level
467  medians1[ichan] = digis->data[0].adc();
468 
469  // if ( !digis->data.empty() ) { medians[ichan] = digis->data[0].adc(); }
470  // else {
471  // edm::LogWarning(mlTest_) << "TEST : NO DIGIS!";
472  // }
473 
474  // std::stringstream ss;
475  // ss << "Channel Averages:" << std::endl
476  // << " nDigis: " << digis->data.size() << std::endl
477  // << " num/mean/MEDIAN/rms/max/min: "
478  // << params.num_ << "/"
479  // << params.mean_ << "/"
480  // << params.median_ << "/"
481  // << params.rms_ << "/"
482  // << params.max_ << "/"
483  // << params.min_ << std::endl;
484  // LogTrace(mlDqmSource_) << ss.str();
485 
486  }
487 
488  } // fed channel loop
489 
490  // Calculate mean and spread on all (median) signal levels
491  Averages average;
492  std::map<uint16_t,float>::const_iterator ii = medians.begin();
493  for ( ; ii != medians.end(); ii++ ) { average.add( ii->second ); }
495  average.calc(tmp);
496 
497  // std::stringstream ss;
498  // ss << "FED Averages:" << std::endl
499  // << " nChans: " << medians.size() << std::endl
500  // << " num/mean/median/rms/max/min: "
501  // << tmp.num_ << "/"
502  // << tmp.mean_ << "/"
503  // << tmp.median_ << "/"
504  // << tmp.rms_ << "/"
505  // << tmp.max_ << "/"
506  // << tmp.min_ << std::endl;
507  // LogTrace(mlDqmSource_) << ss.str();
508 
509  // Calculate mean and spread on "filtered" data
510  Averages truncated;
511  std::map<uint16_t,float>::const_iterator jj = medians.begin();
512  for ( ; jj != medians.end(); jj++ ) {
513  if ( jj->second < tmp.median_+tmp.rms_ ) {
514  truncated.add( jj->second );
515  }
516  }
517  Averages::Params params;
518  truncated.calc(params);
519 
520  // std::stringstream ss1;
521  // ss1 << "Truncated Averages:" << std::endl
522  // << " nChans: " << medians.size() << std::endl
523  // << " num/mean/median/rms/max/min: "
524  // << params.num_ << "/"
525  // << params.mean_ << "/"
526  // << params.median_ << "/"
527  // << params.rms_ << "/"
528  // << params.max_ << "/"
529  // << params.min_ << std::endl;
530  // LogTrace(mlDqmSource_) << ss1.str();
531 
532  // Identify channels with signal
533  std::stringstream ss2;
534  std::stringstream ss3;
535  // ss2 << "Number of possible connections: " << medians.size()
536  // << " channel/signal: ";
537  std::map<uint16_t,float> channels;
538  std::map<uint16_t,float>::const_iterator ichan = medians.begin();
539  for ( ; ichan != medians.end(); ichan++ ) {
540  // cout << " mean: " << params.mean_
541  // << " rms: " << params.rms_
542  // << " thresh: " << params.mean_ + 5.*params.rms_
543  // << " value: " << ichan->second
544  // << " strip: " << ichan->first << std::endl;
545  //if ( ichan->second > params.mean_ + 5.*params.rms_ ) {
546  if ( ichan->second > 200. ) {
547  LogTrace(mlTest_) << "TEST FOUND SIGNAL HIGH: " << *ifed << " " << ichan->first << " " << ichan->second;
548  channels[ichan->first] = ichan->second;
549  }
550  ss2 //<< ichan->first << "/"
551  << ichan->second << " ";
552  ss3 //<< ichan->first << "/"
553  << medians1[ichan->first] << " ";
554  }
555 
556  ss2 << std::endl;
557  ss3 << std::endl;
558  LogTrace(mlTest_) << "DUMP for FED " << *ifed << ": " << ss2.str();
559  LogTrace(mlTest_) << "FIRST ADC VAL " << *ifed << ": " << ss3.str();
560 
561  // LogTrace(mlDqmSource_)
562  // << "[FedCablingTask::" << __func__ << "]"
563  // << " Found candidate connection between device: 0x"
564  // << std::setfill('0') << std::setw(8) << std::hex << summary.deviceId() << std::dec
565  // << " with Crate/FEC/Ring/CCU/Module/LLDchannel: "
566  // << connection().fecCrate() << "/"
567  // << connection().fecSlot() << "/"
568  // << connection().fecRing() << "/"
569  // << connection().ccuAddr() << "/"
570  // << connection().ccuChan() << "/"
571  // << connection().lldChannel()
572  // << " and FedId/Ch: "
573  // << fed_id << "/" << ichan->first
574  // << " with signal " << ichan->second
575  // << " [adc] over background " << "XXX +/- YYY [adc]"
576  // << " (S/N = " << "ZZZ" << ")";
577 
578 
579  // Fill cabling histograms
580  if ( cablingTasks_.find(fec_key) != cablingTasks_.end() ) {
581  if ( !channels.empty() ) {
582  cablingTasks_[fec_key]->fillHistograms( *summary, *ifed, channels );
583  SiStripFecKey path( fec_key );
584  std::stringstream ss;
585  ss << "[SiStripCommissioningSource::" << __func__ << "]"
586  << " Filled histogram for '" << cablingTasks_[fec_key]->myName()
587  << "' object with FecKey: 0x"
588  << std::hex << std::setfill('0') << std::setw(8) << fec_key << std::dec
589  << " and Crate/FEC/ring/CCU/module/LLDchan: "
590  << path.fecCrate() << "/"
591  << path.fecSlot() << "/"
592  << path.fecRing() << "/"
593  << path.ccuAddr() << "/"
594  << path.ccuChan() << "/"
595  << path.channel();
596  LogTrace(mlDqmSource_) << ss.str();
597  }
598  } else {
599  SiStripFecKey path( fec_key );
600  std::stringstream ss;
601  ss << "[SiStripCommissioningSource::" << __func__ << "]"
602  << " Unable to find CommissioningTask object with FecKey: 0x"
603  << std::hex << std::setfill('0') << std::setw(8) << fec_key << std::dec
604  << " and Crate/FEC/ring/CCU/module/LLDchan: "
605  << path.fecCrate() << "/"
606  << path.fecSlot() << "/"
607  << path.fecRing() << "/"
608  << path.ccuAddr() << "/"
609  << path.ccuChan() << "/"
610  << path.channel();
611  edm::LogWarning(mlDqmSource_) << ss.str();
612  }
613 
614  } // fed id loop
615 
616 }
617 
618 // ----------------------------------------------------------------------------
619 //
622  const edm::DetSetVector<SiStripRawDigi>* rawAlt) {
623 
624  // Iterate through FED ids and channels
625  auto ifed = fedCabling_->fedIds().begin();
626  for ( ; ifed != fedCabling_->fedIds().end(); ifed++ ) {
627 
628  // Iterate through connected FED channels
629  auto conns = fedCabling_->fedConnections(*ifed);
630  for (auto iconn = conns.begin() ; iconn != conns.end(); iconn++ ) {
631 
632  if ( !(iconn->fedId()) || iconn->fedId() > sistrip::valid_ ) { continue; }
633  if ( !iconn->isConnected() ) { continue; }
634 
635  // Create FED key and check if non-zero
636  // note: the key is not computed using the same formula as in commissioning histograms.
637  // beware that changes here must match changes in raw2digi and in SiStripFineDelayHit
638  uint32_t fed_key = ( ( iconn->fedId() & sistrip::invalid_ ) << 16 ) | ( iconn->fedCh() & sistrip::invalid_ );
639 
640  // Retrieve digis for given FED key and check if found
641  std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.find( fed_key );
642 
643  // only for spy data-taking --> tick measurement
644  std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digisAlt;
645  if(rawAlt != nullptr and not (*rawAlt).empty()){
646  digisAlt = (*rawAlt).find( fed_key );
647  if(digisAlt == (*rawAlt).end()) continue;
648  }
649 
650  if ( digis != raw.end() ) {
651  // tasks involving tracking have partition-level histos, so treat separately
652  if (task_ == sistrip::APV_LATENCY) {
653  if ( tasks_[0][iconn->fecCrate()-1] ) {
654  tasks_[0][iconn->fecCrate()-1]->fillHistograms( *summary, *digis );
655  } else {
656  std::stringstream ss;
657  ss << "[SiStripCommissioningSource::" << __func__ << "]"
658  << " Unable to find CommissioningTask for FEC crate "
659  << iconn->fecCrate() << ". Unable to fill histograms!";
660  edm::LogWarning(mlDqmSource_) << ss.str();
661  }
662  } else if (task_ == sistrip::FINE_DELAY) {
663  if ( tasks_[0][0] ) {
664  tasks_[0][0]->fillHistograms( *summary, *digis );
665  } else {
666  std::stringstream ss;
667  ss << "[SiStripCommissioningSource::" << __func__ << "]"
668  << " Unable to find global CommissioningTask for FineDelay. Unable to fill histograms!";
669  edm::LogWarning(mlDqmSource_) << ss.str();
670  }
671  // now do any other task
672  } else {
673  if ( tasks_[iconn->fedId()][iconn->fedCh()] ) {
674  if(rawAlt == nullptr or digisAlt == (*rawAlt).end())
675  tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms( *summary, *digis );
676  else
677  tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms( *summary, *digis, *digisAlt);
678  } else {
679  std::stringstream ss;
680  ss << "[SiStripCommissioningSource::" << __func__ << "]"
681  << " Unable to find CommissioningTask object with FED key "
682  << std::hex << std::setfill('0') << std::setw(8) << fed_key << std::dec
683  << " and FED id/ch "
684  << iconn->fedId() << "/"
685  << iconn->fedCh()
686  << " Unable to fill histograms!";
687  edm::LogWarning(mlDqmSource_) << ss.str();
688  }
689  }
690  } else {
691  // issue a warning only for standard runs, as latency and fine delay only deliver
692  // pseudo zero-suppressed data
693  if ( task_ != sistrip::APV_LATENCY &&
695  std::stringstream ss;
696  ss << "[SiStripCommissioningSource::" << __func__ << "]"
697  << " Unable to find any DetSet containing digis for FED key "
698  << std::hex << std::setfill('0') << std::setw(8) << fed_key << std::dec
699  << " and FED id/ch "
700  << iconn->fedId() << "/"
701  << iconn->fedCh();
702  edm::LogWarning(mlDqmSource_) << ss.str();
703  }
704  }
705  } // fed channel loop
706  } // fed id loop
707 }
708 
709 // -----------------------------------------------------------------------------
710 //
712 
713  // Set commissioning task to default ("undefined") value
714  if ( !run_ ) {
716  << "[SiStripCommissioningSource::" << __func__ << "]"
717  << " NULL run number!";
718  return;
719  }
720 
721  // Create MonitorElement that identifies run number
722  dqm()->setCurrentFolder( base_ + sistrip::root_ );
723  std::stringstream run;
724  run << run_;
725  dqm()->bookString( std::string(sistrip::runNumber_) + sistrip::sep_ + run.str(), run.str() );
726 
727 }
728 
729 // -----------------------------------------------------------------------------
730 //
732 
733  // Set commissioning task to default ("undefined") value
735 
736  // Retrieve commissioning task from EventSummary
737  if ( summary ) {
738  task_ = summary->runType();
739  std::stringstream ss;
740  ss << "[SiStripCommissioningSource::" << __func__ << "]"
741  << " Identified CommissioningTask from EventSummary to be \""
743  << "\"";
744  LogTrace(mlDqmSource_) << ss.str();
745  } else {
747  std::stringstream ss;
748  ss << "[SiStripCommissioningSource::" << __func__ << "]"
749  << " NULL pointer to SiStripEventSummary!"
750  << " Check SiStripEventSummary is found/present in Event";
751  edm::LogWarning(mlDqmSource_) << ss.str();
752  }
753 
754  // Override task with ParameterSet configurable (if defined)
756  if ( configurable != sistrip::UNDEFINED_RUN_TYPE &&
757  configurable != sistrip::UNKNOWN_RUN_TYPE ) {
758  std::stringstream ss;
759  ss << "[SiStripCommissioningSource::" << __func__ << "]"
760  << " Overriding CommissioningTask from EventSummary (\""
762  << "\") with value retrieved from .cfg file (\""
763  << SiStripEnumsAndStrings::runType( configurable )
764  << "\")!";
765  LogTrace(mlDqmSource_) << ss.str();
766  task_ = configurable;
767  }
768 
769  // Create ME (std::string) that identifies commissioning task
770  dqm()->setCurrentFolder( base_ + sistrip::root_ );
772  dqm()->bookString( std::string(sistrip::taskId_) + sistrip::sep_ + task_str, task_str );
773 
774  // Check commissioning task is known / defined
777  std::stringstream ss;
778  ss << "[SiStripCommissioningSource::" << __func__ << "]"
779  << " Unexpected CommissioningTask found ("
780  << static_cast<uint16_t>(task_) << ") \""
782  << " Unexpected value found in SiStripEventSummary and/or cfg file"
783  << " If SiStripEventSummary is not present in Event,"
784  << " check 'CommissioningTask' configurable in cfg file";
785  edm::LogWarning(mlDqmSource_) << ss.str();
786  return;
787  } else {
788  std::stringstream ss;
789  ss << "[SiStripCommissioningSource::" << __func__ << "]"
790  << " Identified CommissioningTask to be \""
792  << "\"";
793  LogTrace(mlDqmSource_) << ss.str();
794  }
795 
796  // Check if commissioning task is FED cabling
797  if ( task_ == sistrip::FED_CABLING ) { cablingTask_ = true; }
798  else { cablingTask_ = false; }
799 
800  std::stringstream ss;
801  ss << "[SiStripCommissioningSource::" << __func__ << "]"
802  << " CommissioningTask: "
803  << SiStripEnumsAndStrings::runType( summary->runType() );
804  LogTrace(mlDqmSource_) << ss.str();
805 
807  << "[SiStripCommissioningSource::" << __func__ << "]"
808  << " Creating CommissioningTask objects and booking histograms...";
809  if ( cablingTask_ ) { createCablingTasks(); }
810  else { createTasks( task_ , setup ); }
812  << "[SiStripCommissioningSource::" << __func__ << "]"
813  << " Finished booking histograms!";
814  tasksExist_ = true;
815 
816 }
817 
818 // -----------------------------------------------------------------------------
819 //
821 
822  // Iterate through FEC cabling and create commissioning task objects
823  uint16_t booked = 0;
824  for ( std::vector<SiStripFecCrate>::const_iterator icrate = fecCabling_->crates().begin(); icrate != fecCabling_->crates().end(); icrate++ ) {
825  for ( std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++ ) {
826  for ( std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++ ) {
827  for ( std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++ ) {
828  for ( std::vector<SiStripModule>::const_iterator imodule = iccu->modules().begin(); imodule != iccu->modules().end(); imodule++ ) {
829 
830  // Build FEC key
831  SiStripFecKey path( icrate->fecCrate(),
832  ifec->fecSlot(),
833  iring->fecRing(),
834  iccu->ccuAddr(),
835  imodule->ccuChan() );
836 
837  // Check if FEC key is invalid
838  if ( !path.isValid() ) { continue; }
839 
840  // Set working directory prior to booking histograms
841  std::string dir = base_ + path.path();
842  dqm()->setCurrentFolder( dir );
843 
844  // Iterate through all APV pairs for this module
845  for ( uint16_t ipair = 0; ipair < imodule->nApvPairs(); ipair++ ) {
846 
847  // Retrieve active APV devices
848  SiStripModule::PairOfU16 apvs = imodule->activeApvPair( imodule->lldChannel(ipair) );
849 
850  // Create connection object to hold all relevant info
851  FedChannelConnection conn( icrate->fecCrate(),
852  ifec->fecSlot(),
853  iring->fecRing(),
854  iccu->ccuAddr(),
855  imodule->ccuChan(),
856  apvs.first,
857  apvs.second,
858  imodule->dcuId(),
859  imodule->detId(),
860  imodule->nApvPairs() );
861 
862  // Define key encoding control path
863  uint32_t key = SiStripFecKey( icrate->fecCrate(),
864  ifec->fecSlot(),
865  iring->fecRing(),
866  iccu->ccuAddr(),
867  imodule->ccuChan(),
868  imodule->lldChannel(ipair) ).key();
869 
870  // Check key is non zero
871  if ( !key ) {
873  << "[SiStripCommissioningSource::" << __func__ << "]"
874  << " Unexpected NULL value for FEC key!";
875  continue;
876  }
877 
878  // Create cabling task objects if not already existing
879  if ( cablingTasks_.find( key ) == cablingTasks_.end() ) {
880 
881  if ( task_ == sistrip::FED_CABLING ) {
882  cablingTasks_[key] = new FedCablingTask( dqm(), conn );
883  } else if ( task_ == sistrip::UNDEFINED_RUN_TYPE ) {
885  << "[SiStripCommissioningSource::" << __func__ << "]"
886  << " Undefined CommissioningTask"
887  << " Unable to create FedCablingTask object!";
888  } else if ( task_ == sistrip::UNKNOWN_RUN_TYPE ) {
890  << "[SiStripCommissioningSource::" << __func__ << "]"
891  << " Unknown CommissioningTask"
892  << " Unable to create FedCablingTask object!";
893  } else {
895  << "[SiStripCommissioningSource::" << __func__ << "]"
896  << " Unexpected CommissioningTask: "
898  << " Unable to create FedCablingTask object!";
899  }
900 
901  // Check if key is found and, if so, book histos and set update freq
902  if ( cablingTasks_.find( key ) != cablingTasks_.end() ) {
903  if ( cablingTasks_[key] ) {
904  cablingTasks_[key]->bookHistograms();
905  cablingTasks_[key]->updateFreq(1); //@@ hardwired to update every event!!!
906  booked++;
907  //std::stringstream ss;
908  //ss << "[SiStripCommissioningSource::" << __func__ << "]"
909  //<< " Booking histograms for '" << cablingTasks_[key]->myName()
910  //<< "' object with key 0x" << std::hex << std::setfill('0') << std::setw(8) << key << std::dec
911  //<< " in directory \"" << dir << "\"";
912  //LogTrace(mlDqmSource_) << ss.str();
913  } else {
914  std::stringstream ss;
915  ss << "[SiStripCommissioningSource::" << __func__ << "]"
916  << " NULL pointer to CommissioningTask for key 0x"
917  << std::hex << std::setfill('0') << std::setw(8) << key << std::dec
918  << " in directory " << dir
919  << " Unable to book histograms!";
920  edm::LogWarning(mlDqmSource_) << ss.str();
921  }
922  } else {
923  std::stringstream ss;
924  ss << "[SiStripCommissioningSource::" << __func__ << "]"
925  << " Unable to find CommissioningTask for key 0x"
926  << std::hex << std::setfill('0') << std::setw(8) << key << std::dec
927  << " in directory " << dir
928  << " Unable to book histograms!";
929  edm::LogWarning(mlDqmSource_) << ss.str();
930  }
931 
932  } else {
933  std::stringstream ss;
934  ss << "[SiStripCommissioningSource::" << __func__ << "]"
935  << " CommissioningTask object already exists for key 0x"
936  << std::hex << std::setfill('0') << std::setw(8) << key << std::dec
937  << " in directory " << dir
938  << " Unable to create FedCablingTask object!";
939  edm::LogWarning(mlDqmSource_) << ss.str();
940  }
941 
942  } // loop through apv pairs
943  } // loop through modules
944  } // loop through ccus
945  } // loop through rings
946  } // loop through fecs
947  } // loop through crates
948 
950  << "[SiStripCommissioningSource::" << __func__ << "]"
951  << " Created " << booked
952  << " CommissioningTask objects and booked histograms";
953 
954 }
955 
956 // -----------------------------------------------------------------------------
957 //
959 
960  uint16_t booked = 0;
961 
962  // latency has partition-level histos, so treat separately
963  if (task_ == sistrip::APV_LATENCY) {
964 
965  for (uint16_t partition = 0; partition < 4; ++partition) {
966  // make a task for every partition; tracker-wide histo is shared
968  tasks_[0][partition]->eventSetup( &setup );
969  tasks_[0][partition]->bookHistograms();
970  tasks_[0][partition]->updateFreq( updateFreq_ );
971  booked++;
972  }
973 
974  // fine-delay has 1 histo for the whole tracker, so treat separately
975  } else if (task_ == sistrip::FINE_DELAY) {
976 
977  tasks_[0][0] = new FineDelayTask( dqm(), FedChannelConnection() );
978  tasks_[0][0]->eventSetup( &setup );
979  tasks_[0][0]->bookHistograms();
980  tasks_[0][0]->updateFreq( updateFreq_ );
981  booked++;
982 
983  } else { // now do any other task
984 
985  // Iterate through FED ids and channels
986  for (auto ifed = fedCabling_->fedIds().begin() ; ifed != fedCabling_->fedIds().end(); ++ifed ) {
987 
988  // Iterate through connected FED channels
989  // S.L.: currently copy the vector, because it changes later when
990  // reading in peds for calibration run -> not understood memory corruption!
991  auto conns = fedCabling_->fedConnections(*ifed);
992  for (auto iconn = conns.begin() ; iconn != conns.end(); ++iconn ) {
993 
994  // Create FEC key
995  SiStripFecKey fec_key( iconn->fecCrate(),
996  iconn->fecSlot(),
997  iconn->fecRing(),
998  iconn->ccuAddr(),
999  iconn->ccuChan() );
1000  // Create FED key and check if non-zero
1001  SiStripFedKey fed_key( iconn->fedId(),
1002  SiStripFedKey::feUnit(iconn->fedCh()),
1003  SiStripFedKey::feChan(iconn->fedCh()) );
1004  if ( !iconn->isConnected() ) { continue; }
1005 
1006  // define the view in which to work and paths for histograms
1007  // currently FecView (control view) and FedView (readout view)
1008  // DetView (detector view) implementation has started
1009  // Set working directory prior to booking histograms
1010  std::stringstream dir;
1011  dir << base_;
1012  if (view_ == "Default") { // default
1013  if ( run_type == sistrip::FAST_CABLING ) {
1014  dir << fed_key.path(); // cabling in fed view
1015  } else {
1016  dir << fec_key.path(); // all other runs in control view
1017  }
1018  } else if (view_ == "FecView") {
1019  dir << fec_key.path();
1020  } else if (view_ == "FedView") {
1021  dir << fed_key.path();
1022  } else if (view_ == "DetView") {
1023  // currently just by detid from the connection, which is empty...
1024  dir << sistrip::root_ << sistrip::dir_
1026  << iconn->detId();
1027  } else {
1029  << "[SiStripCommissioningSource::" << __func__ << "]"
1030  << " Invalid view " << view_ << std::endl
1031  << " Histograms will end up all in the top directory.";
1032  } // end if view_ == ...
1033  dqm()->setCurrentFolder( dir.str() );
1034 
1035  // Create commissioning task objects
1036  if ( !tasks_[iconn->fedId()][iconn->fedCh()] ) {
1037  if ( task_ == sistrip::FAST_CABLING ) {
1038  tasks_[iconn->fedId()][iconn->fedCh()] = new FastFedCablingTask( dqm(), *iconn );
1039  } else if ( task_ == sistrip::APV_TIMING ) {
1040  tasks_[iconn->fedId()][iconn->fedCh()] = new ApvTimingTask( dqm(), *iconn );
1041  } else if ( task_ == sistrip::FED_TIMING ) {
1042  tasks_[iconn->fedId()][iconn->fedCh()] = new FedTimingTask( dqm(), *iconn );
1043  } else if ( task_ == sistrip::OPTO_SCAN ) {
1044  tasks_[iconn->fedId()][iconn->fedCh()] = new OptoScanTask( dqm(), *iconn );
1045  } else if ( task_ == sistrip::VPSP_SCAN ) {
1046  tasks_[iconn->fedId()][iconn->fedCh()] = new VpspScanTask( dqm(), *iconn );
1047  } else if ( task_ == sistrip::PEDESTALS ) {
1048  tasks_[iconn->fedId()][iconn->fedCh()] = new PedestalsTask( dqm(), *iconn );
1049  } else if ( task_ == sistrip::PEDS_ONLY ) {
1050  tasks_[iconn->fedId()][iconn->fedCh()] = new PedsOnlyTask( dqm(), *iconn );
1051  } else if ( task_ == sistrip::NOISE ) {
1052  tasks_[iconn->fedId()][iconn->fedCh()] = new NoiseTask( dqm(), *iconn );
1053  } else if ( task_ == sistrip::PEDS_FULL_NOISE ) {
1054  tasks_[iconn->fedId()][iconn->fedCh()] = new PedsFullNoiseTask( dqm(), *iconn, parameters_ );
1055  } else if ( task_ == sistrip::DAQ_SCOPE_MODE ) {
1056  tasks_[iconn->fedId()][iconn->fedCh()] = new DaqScopeModeTask( dqm(), *iconn, parameters_ );
1057  } else if ( task_ == sistrip::CALIBRATION_SCAN ||
1059  tasks_[iconn->fedId()][iconn->fedCh()] = new CalibrationScanTask( dqm(),
1060  *iconn,
1061  task_,
1062  filename_.c_str(),
1063  run_,
1064  setup );
1065  } else if ( task_ == sistrip::CALIBRATION ||
1067  tasks_[iconn->fedId()][iconn->fedCh()] = new CalibrationTask( dqm(),
1068  *iconn,
1069  task_,
1070  filename_.c_str(),
1071  run_,
1072  setup );
1073  } else if ( task_ == sistrip::UNDEFINED_RUN_TYPE ) {
1075  << "[SiStripCommissioningSource::" << __func__ << "]"
1076  << " Undefined CommissioningTask"
1077  << " Unable to create CommissioningTask object!";
1078  } else {
1080  << "[SiStripCommissioningSource::" << __func__ << "]"
1081  << " Unknown CommissioningTask"
1082  << " Unable to create CommissioningTask object!";
1083  }
1084 
1085  // Check if fed_key is found and, if so, book histos and set update freq
1086 
1087  // Check if fed_key is found and, if so, book histos and set update freq
1088  if ( tasks_[iconn->fedId()][iconn->fedCh()] ) {
1089  tasks_[iconn->fedId()][iconn->fedCh()]->eventSetup( &setup );
1092  tasks_[iconn->fedId()][iconn->fedCh()]->bookHistograms();
1093 
1094  else{
1096  static_cast<CalibrationScanTask*>(tasks_[iconn->fedId()][iconn->fedCh()])->setCurrentFolder(dir.str());
1098  static_cast<CalibrationTask*>(tasks_[iconn->fedId()][iconn->fedCh()])->setCurrentFolder(dir.str());
1099  }
1100  tasks_[iconn->fedId()][iconn->fedCh()]->updateFreq( updateFreq_ );
1101  booked++;
1102  } else {
1103  std::stringstream ss;
1104  ss << "[SiStripCommissioningSource::" << __func__ << "]"
1105  << " NULL pointer to CommissioningTask for key 0x"
1106  << std::hex << std::setfill('0') << std::setw(8) << fed_key.key() << std::dec
1107  << " in directory " << dir.str()
1108  << " Unable to book histograms!";
1109  edm::LogWarning(mlDqmSource_) << ss.str();
1110  }
1111 
1112  } else {
1113  std::stringstream ss;
1114  ss << "[SiStripCommissioningSource::" << __func__ << "]"
1115  << " CommissioningTask object already exists for key 0x"
1116  << std::hex << std::setfill('0') << std::setw(8) << fed_key.key() << std::dec
1117  << " in directory " << dir.str()
1118  << " Unable to create CommissioningTask object!";
1119  edm::LogWarning(mlDqmSource_) << ss.str();
1120  }
1121 
1122  } // loop over fed channels
1123  } // loop over feds
1124  } // end other tasks
1125 
1127  << "[SiStripCommissioningSource::" << __func__ << "]"
1128  << " Created " << booked
1129  << " CommissioningTask objects and booked histograms";
1130 }
1131 
1132 // ----------------------------------------------------------------------------
1133 //
1135  if ( cablingTasks_.empty() ) { return; }
1136  for ( TaskMap::iterator itask = cablingTasks_.begin(); itask != cablingTasks_.end(); itask++ ) {
1137  if ( itask->second ) { delete itask->second; }
1138  }
1139  cablingTasks_.clear();
1140 }
1141 
1142 // ----------------------------------------------------------------------------
1143 //
1145  if ( tasks_.empty() ) { return; }
1146  VecOfVecOfTasks::iterator ifed = tasks_.begin();
1147  for ( ; ifed != tasks_.end(); ifed++ ) {
1148  VecOfTasks::iterator ichan = ifed->begin();
1149  for ( ; ichan != ifed->end(); ichan++ ) {
1150  if ( *ichan ) { delete *ichan; *ichan = nullptr; }
1151  }
1152  ifed->resize(96,nullptr);
1153  }
1154  tasks_.resize(1024);
1155 }
1156 
1157 // ----------------------------------------------------------------------------
1158 //
1160  dqm()->cd();
1161  dqm()->removeContents();
1162 
1163  if( dqm()->dirExists(sistrip::root_) ) {
1164  dqm()->rmdir(sistrip::root_);
1165  }
1166 }
1167 
1168 // -----------------------------------------------------------------------------
1169 //
1171  uint32_t run_number ) {
1172 
1173  // Get details about host
1174  char hn[256];
1175  gethostname( hn, sizeof(hn) );
1176  struct hostent* he;
1177  he = gethostbyname(hn);
1178 
1179  // Extract host name and ip
1180  std::string host_name;
1181  std::string host_ip;
1182  if ( he ) {
1183  host_name = std::string(he->h_name);
1184  host_ip = std::string( inet_ntoa( *(struct in_addr*)(he->h_addr) ) );
1185  } else {
1186  host_name = "unknown.cern.ch";
1187  host_ip = "255.255.255.255";
1188  }
1189 
1190  // Reformat IP address
1192  std::stringstream ip;
1193  //for ( uint16_t ii = 0; ii < 4; ++ii ) {
1194  while ( pos != std::string::npos ) {
1195  std::string::size_type tmp = host_ip.find(".",pos);
1196  if ( tmp != std::string::npos ) {
1197  ip << std::setw(3)
1198  << std::setfill('0')
1199  << host_ip.substr( pos, tmp-pos )
1200  << ".";
1201  pos = tmp+1; // skip the delimiter "."
1202  } else {
1203  ip << std::setw(3)
1204  << std::setfill('0')
1205  << host_ip.substr( pos );
1206  pos = std::string::npos;
1207  }
1208  }
1209 
1210  // Get pid
1211  pid_t pid = getpid();
1212 
1213  // Construct string
1214  if ( run_number ) {
1215  dir << std::setw(8)
1216  << std::setfill('0')
1217  << run_number
1218  << "_";
1219  }
1220  dir << ip.str()
1221  << "_"
1222  << std::setw(5)
1223  << std::setfill('0')
1224  << pid;
1225 
1226 }
1227 
1228 // -----------------------------------------------------------------------------
1229 //
1230 // void SiStripCommissioningSource::cablingForConnectionRun( const sistrip::RunType& type ) {
1231 
1232 // if ( type == sistrip::FED_CABLING ||
1233 // type == sistrip::QUITE_FAST_CABLING ||
1234 // type == sistrip::FAST_CABLING ) {
1235 // std::stringstream ss;
1236 // ss << "[SiStripCommissioningSource::" << __func__ << "]"
1237 // << " Run type is " << SiStripEnumsAndStrings::runType( type ) << "!"
1238 // << " Checking if cabling should be rebuilt using FED and device descriptions!...";
1239 // edm::LogVerbatim(mlDqmSource_) << ss.str();
1240 // } else { return; }
1241 
1242 // // Build and retrieve SiStripConfigDb object using service
1243 // SiStripConfigDb* db = edm::Service<SiStripConfigDb>().operator->(); //@@ NOT GUARANTEED TO BE THREAD SAFE!
1244 // LogTrace(mlCabling_)
1245 // << "[SiStripCommissioningSource::" << __func__ << "]"
1246 // << " Nota bene: using the SiStripConfigDb API"
1247 // << " as a \"service\" does not presently guarantee"
1248 // << " thread-safe behaviour!...";
1249 
1250 // if ( !db ) {
1251 // edm::LogError(mlCabling_)
1252 // << "[SiStripCommissioningSource::" << __func__ << "]"
1253 // << " NULL pointer to SiStripConfigDb returned by service!"
1254 // << " Cannot check if cabling needs to be rebuilt!";
1255 // return;
1256 // }
1257 
1258 // if ( db->getFedConnections().empty() ) {
1259 // edm::LogVerbatim(mlCabling_)
1260 // << "[SiStripCommissioningSource::" << __func__ << "]"
1261 // << " Datbase does not contain FED connections!"
1262 // << " Do not need to rebuild cabling object based on FED and device descriptions!";
1263 // return;
1264 // }
1265 
1266 // if ( fecCabling_ ) { delete fecCabling_; fecCabling_ = 0; }
1267 // if ( fedCabling_ ) { delete fedCabling_; fedCabling_ = 0; }
1268 
1269 // // Build FEC cabling
1270 // fecCabling_ = new SiStripFecCabling();
1271 // SiStripConfigDb::DcuDetIdMap mapping;
1272 // SiStripFedCablingBuilderFromDb::buildFecCablingFromDevices( db,
1273 // *fecCabling_,
1274 // mapping );
1275 // // Build FED cabling
1276 // fedCabling_ = new SiStripFedCabling();
1277 // SiStripFedCablingBuilderFromDb::getFedCabling( *fecCabling_,
1278 // *fedCabling_ );
1279 
1280 // edm::LogVerbatim(mlCabling_)
1281 // << "[SiStripCommissioningSource::" << __func__ << "]"
1282 // << " Cabling object rebuilt using on FED and device descriptions!";
1283 
1284 // }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
static const char runNumber_[]
Device and connection information at the level of a front-end module.
Definition: SiStripModule.h:24
EventNumber_t event() const
Definition: EventID.h:41
def dirExists(dir)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiReorderedToken_
iterator find(det_id_type id)
Definition: DetSetVector.h:290
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiVirginRawToken_
const uint16_t & fecRing() const
void createTask(const SiStripEventSummary *const, const edm::EventSetup &)
static const char dir_[]
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
const SiStripModule & module(const FedChannelConnection &conn) const
DQMStore *const dqm(std::string method="") const
const SiStripFecKey & key() const
static const char mlDqmSource_[]
void createTasks(sistrip::RunType, const edm::EventSetup &)
const std::vector< SiStripFecCrate > & crates() const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
const uint16_t & fecSlot() const
static const uint16_t valid_
Definition: Constants.h:17
#define nullptr
static const char detectorView_[]
uint16_t size_type
void analyze(const edm::Event &, const edm::EventSetup &) override
sistrip classes
void directory(std::stringstream &, uint32_t run_number=0)
const uint32_t & key() const
Definition: SiStripKey.h:125
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
void beginRun(edm::Run const &, const edm::EventSetup &) override
static std::string runType(const sistrip::RunType &)
const sistrip::RunType & runType() const
std::vector< CommissioningTask * > VecOfTasks
static const char sep_[]
Class containning control, module, detector and connection information, at the level of a FED channel...
FedsConstIterRange fedIds() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
static const char taskId_[]
void fillCablingHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
static const char dqmSourceFileName_[]
const uint32_t & dcuId() const
static const char mlTest_[]
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:361
#define LogTrace(id)
ii
Definition: cuy.py:589
const uint16_t & fecCrate() const
const uint32_t & deviceId() const
const uint16_t & feUnit() const
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiFineDelaySelectionToken_
const uint16_t & channel() const
Definition: SiStripKey.h:128
bool empty() const
Return true if we contain no DetSets.
Definition: DetSetVector.h:276
const uint16_t & ccuAddr() const
static const uint16_t invalid_
Definition: Constants.h:16
std::pair< uint16_t, uint16_t > PairOfU16
Definition: SiStripModule.h:42
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
const sistrip::FedReadoutMode & fedReadoutMode() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
edm::EDGetTokenT< SiStripEventSummary > inputModuleSummaryToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiScopeModeToken_
edm::EventID id() const
Definition: EventBase.h:60
const uint16_t & feChan() const
T get() const
Definition: EventSetup.h:63
static const char root_[]
const uint16_t & ccuChan() const
dbl *** dir
Definition: mlp_gen.cc:35
T const * product() const
Definition: ESHandle.h:86
Definition: vlib.h:208
Definition: event.py:1
Definition: Run.h:44
void fillHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &, const edm::DetSetVector< SiStripRawDigi > *=0)
static std::string fedReadoutMode(const sistrip::FedReadoutMode &)