CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
SiStripCommissioningSource Class Reference

#include <SiStripCommissioningSource.h>

Inheritance diagram for SiStripCommissioningSource:
edm::EDAnalyzer

Public Types

typedef std::map< unsigned int,
CommissioningTask * > 
TaskMap
 
typedef std::vector
< CommissioningTask * > 
VecOfTasks
 
typedef std::vector< VecOfTasksVecOfVecOfTasks
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &)
 
void beginRun (edm::Run const &, const edm::EventSetup &)
 
void endJob ()
 
 SiStripCommissioningSource (const edm::ParameterSet &)
 
 ~SiStripCommissioningSource ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

void clearCablingTasks ()
 
void clearTasks ()
 
void createCablingTasks ()
 
void createRunNumber ()
 
void createTask (const SiStripEventSummary *const, const edm::EventSetup &)
 
void createTasks (sistrip::RunType, const edm::EventSetup &)
 
void directory (std::stringstream &, uint32_t run_number=0)
 
DQMStore *const dqm (std::string method="") const
 
void fillCablingHistos (const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
 
void fillHistos (const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
 
void remove ()
 
 SiStripCommissioningSource ()
 

Private Attributes

std::string base_
 
bool cablingTask_
 
TaskMap cablingTasks_
 
DQMStoredqm_
 
SiStripFecCablingfecCabling_
 
SiStripFedCablingfedCabling_
 
std::string filename_
 
std::string inputModuleLabel_
 
std::string inputModuleLabelSummary_
 
edm::ParameterSet parameters_
 
uint32_t run_
 
sistrip::RunType task_
 
std::string taskConfigurable_
 
VecOfVecOfTasks tasks_
 
bool tasksExist_
 
int32_t time_
 
int updateFreq_
 
std::string view_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 26 of file SiStripCommissioningSource.h.

Member Typedef Documentation

typedef std::map<unsigned int, CommissioningTask*> SiStripCommissioningSource::TaskMap

Map of task objects, identified through FedChanelId

Definition at line 31 of file SiStripCommissioningSource.h.

Definition at line 32 of file SiStripCommissioningSource.h.

Definition at line 33 of file SiStripCommissioningSource.h.

Constructor & Destructor Documentation

SiStripCommissioningSource::SiStripCommissioningSource ( const edm::ParameterSet pset)

Definition at line 55 of file SiStripCommissioningSource.cc.

References LogTrace, sistrip::mlDqmSource_, and tasks_.

55  :
56  dqm_(0),
57  fedCabling_(0),
58  fecCabling_(0),
59  inputModuleLabel_( pset.getParameter<std::string>( "InputModuleLabel" ) ),
60  inputModuleLabelSummary_( pset.getParameter<std::string>( "SummaryInputModuleLabel" ) ),
61  filename_( pset.getUntrackedParameter<std::string>("RootFileName",sistrip::dqmSourceFileName_) ),
62  run_(0),
63  time_(0),
64  taskConfigurable_( pset.getUntrackedParameter<std::string>("CommissioningTask","UNDEFINED") ),
66  tasks_(),
67  cablingTasks_(),
68  tasksExist_(false),
69  cablingTask_(false),
70  updateFreq_( pset.getUntrackedParameter<int>("HistoUpdateFreq",1) ),
71  base_(""),
72  view_( pset.getUntrackedParameter<std::string>("View", "Default") ),
73  parameters_(pset)
74 {
76  << "[SiStripCommissioningSource::" << __func__ << "]"
77  << " Constructing object...";
78  tasks_.clear();
79  tasks_.resize( 1024, VecOfTasks(96,static_cast<CommissioningTask*>(0)) );
80 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
static const char mlDqmSource_[]
std::vector< CommissioningTask * > VecOfTasks
static const char dqmSourceFileName_[]
#define LogTrace(id)
SiStripCommissioningSource::~SiStripCommissioningSource ( )

Definition at line 84 of file SiStripCommissioningSource.cc.

References LogTrace, and sistrip::mlDqmSource_.

84  {
86  << "[SiStripCommissioningSource::" << __func__ << "]"
87  << " Destructing object...";
88 }
static const char mlDqmSource_[]
#define LogTrace(id)
SiStripCommissioningSource::SiStripCommissioningSource ( )
private

Private default constructor.

Member Function Documentation

void SiStripCommissioningSource::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 258 of file SiStripCommissioningSource.cc.

References sistrip::APV_LATENCY, sistrip::APV_TIMING, cablingTask_, sistrip::CALIBRATION, sistrip::CALIBRATION_DECO, sistrip::CALIBRATION_SCAN, sistrip::CALIBRATION_SCAN_DECO, createRunNumber(), createTask(), sistrip::DAQ_SCOPE_MODE, edm::EventID::event(), sistrip::FAST_CABLING, sistrip::FED_CABLING, sistrip::FED_SCOPE_MODE, sistrip::FED_TIMING, sistrip::FED_VIRGIN_RAW, SiStripEnumsAndStrings::fedReadoutMode(), fillCablingHistos(), fillHistos(), sistrip::FINE_DELAY, edm::EventBase::id(), inputModuleLabel_, inputModuleLabelSummary_, sistrip::mlDqmSource_, sistrip::NOISE, NULL, sistrip::OPTO_SCAN, sistrip::PEDESTALS, sistrip::PEDS_FULL_NOISE, sistrip::PEDS_ONLY, edm::Handle< T >::product(), runTheMatrix_dev::raw, edm::EventID::run(), run_, SiStripEnumsAndStrings::runType(), HcalObjRepresent::setup(), summarizeEdmComparisonLogfiles::summary, task_, tasksExist_, cond::rpcobgas::time, time_, sistrip::UNDEFINED_RUN_TYPE, sistrip::UNKNOWN_RUN_TYPE, updateFreq_, and sistrip::VPSP_SCAN.

259  {
260  // Retrieve commissioning information from "event summary"
262  event.getByLabel( inputModuleLabelSummary_, summary );
263 
264  // Check if EventSummary has info attached
265  if ( ( summary->runType() == sistrip::UNDEFINED_RUN_TYPE ||
266  summary->runType() == sistrip::UNKNOWN_RUN_TYPE ) &&
267  summary->nullParams() ) {
269  << "[SiStripCommissioningSource::" << __func__ << "]"
270  << " Unknown/undefined RunType and NULL parameter values!"
271  << " It may be that the 'trigger FED' object was not found!";
272  }
273 
274  // Check if need to rebuild FED/FEC cabling objects for connection run
275  //cablingForConnectionRun( summary->runType() ); //@@ do not use!
276 
277  // Extract run number and forward to client
278  if ( event.id().run() != run_ ) {
279  run_ = event.id().run();
280  createRunNumber();
281  }
282 
283  // Coarse event rate counter
284  if ( !(event.id().event()%updateFreq_) ) {
285  std::stringstream ss;
286  ss << "[SiStripCommissioningSource::" << __func__ << "]"
287  << " The last " << updateFreq_
288  << " events were processed at a rate of ";
289  if ( time(NULL) == time_ ) { ss << ">" << updateFreq_ << " Hz"; }
290  else { ss << (updateFreq_/(time(NULL)-time_)) << " Hz"; }
291  edm::LogVerbatim(mlDqmSource_) << ss.str();
292  time_ = time(NULL);
293  }
294 
295  // Create commissioning task objects
296  if ( !tasksExist_ ) { createTask( summary.product(), setup ); }
297 
298  // Retrieve raw digis with mode appropriate to task
300  if ( task_ == sistrip::DAQ_SCOPE_MODE ) {
301  if ( summary->fedReadoutMode() == FED_VIRGIN_RAW ) {
302  event.getByLabel( inputModuleLabel_, "VirginRaw", raw );
303  } else if ( summary->fedReadoutMode() == FED_SCOPE_MODE ) {
304  event.getByLabel( inputModuleLabel_, "ScopeMode", raw );
305  } else {
306  std::stringstream ss;
307  ss << "[SiStripCommissioningSource::" << __func__ << "]"
308  << " Requested DAQ_SCOPE_MODE but unknown FED"
309  << " readout mode retrieved from SiStripEventSummary: "
310  << SiStripEnumsAndStrings::fedReadoutMode( summary->fedReadoutMode() );
311  edm::LogWarning(mlDqmSource_) << ss.str();
312  }
313  } else if ( task_ == sistrip::FAST_CABLING ||
317  task_ == sistrip::OPTO_SCAN ) {
318  event.getByLabel( inputModuleLabel_, "ScopeMode", raw );
319  } else if ( task_ == sistrip::VPSP_SCAN ||
326  task_ == sistrip::NOISE ||
328  event.getByLabel( inputModuleLabel_, "VirginRaw", raw );
329  } else if ( task_ == sistrip::APV_LATENCY ||
331  event.getByLabel( inputModuleLabel_, "FineDelaySelection", raw );
332  } else {
333  std::stringstream ss;
334  ss << "[SiStripCommissioningSource::" << __func__ << "]"
335  << " Unknown CommissioningTask: "
337  << " Unable to establish FED readout mode and retrieve digi container!"
338  << " Check if SiStripEventSummary object is found/present in Event";
339  edm::LogWarning(mlDqmSource_) << ss.str();
340  return;
341  }
342 
343  // Check for NULL pointer to digi container
344  if ( &(*raw) == 0 ) {
345  std::stringstream ss;
346  ss << "[SiStripCommissioningSource::" << __func__ << "]" << std::endl
347  << " NULL pointer to DetSetVector!" << std::endl
348  << " Unable to fill histograms!";
349  edm::LogWarning(mlDqmSource_) << ss.str();
350  return;
351  }
352 
353  if ( !cablingTask_ ) { fillHistos( summary.product(), *raw ); }
354  else { fillCablingHistos( summary.product(), *raw ); }
355 
356 }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
void createTask(const SiStripEventSummary *const, const edm::EventSetup &)
static const char mlDqmSource_[]
#define NULL
Definition: scimark2.h:8
static std::string runType(const sistrip::RunType &)
void fillCablingHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
T const * product() const
Definition: Handle.h:74
edm::EventID id() const
Definition: EventBase.h:56
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void fillHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
static std::string fedReadoutMode(const sistrip::FedReadoutMode &)
void SiStripCommissioningSource::beginRun ( edm::Run const &  run,
const edm::EventSetup setup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 107 of file SiStripCommissioningSource.cc.

References base_, cablingTask_, clearCablingTasks(), clearTasks(), SiStripFecCabling::crates(), dir, dqm(), dqm_, fecCabling_, fedCabling_, SiStripFedCabling::feds(), edm::EventSetup::get(), LogDebug, LogTrace, sistrip::mlDqmSource_, cmsCodeRules.cppFunctionSkipper::operator, edm::ESHandle< class >::product(), DQMStore::setVerbose(), task_, tasksExist_, and sistrip::UNDEFINED_RUN_TYPE.

107  {
109  << "[SiStripCommissioningSource::" << __func__ << "]"
110  << " Configuring..." << std::endl;
111 
112  // ---------- DQM back-end interface ----------
113 
116  << "[SiStripCommissioningSource::" << __func__ << "]"
117  << " DQMStore service: "
118  << dqm_;
119  dqm(__func__);
120  dqm()->setVerbose(0);
121 
122  // ---------- Base directory ----------
123 
124  std::stringstream dir("");
125  base_ = dir.str();
126 
127  // ---------- FED and FEC cabling ----------
128 
130  setup.get<SiStripFedCablingRcd>().get( fed_cabling );
131  fedCabling_ = const_cast<SiStripFedCabling*>( fed_cabling.product() );
133  << "[SiStripCommissioningSource::" << __func__ << "]"
134  << "Initialized FED cabling. Number of FEDs is " << fedCabling_->feds().size();
135  fecCabling_ = new SiStripFecCabling( *fed_cabling );
136  if ( fecCabling_->crates().empty() ) {
137  std::stringstream ss;
138  ss << "[SiStripCommissioningSource::" << __func__ << "]"
139  << " Empty std::vector returned by FEC cabling object!"
140  << " Check if database connection failed...";
141  edm::LogWarning(mlDqmSource_) << ss.str();
142  }
143 
144  // ---------- Reset ----------
145 
146  tasksExist_ = false;
148  cablingTask_ = false;
149 
150  remove();
151 
153  clearTasks();
154 
155 }
#define LogDebug(id)
const std::vector< uint16_t > & feds() const
DQMStore *const dqm(std::string method="") const
static const char mlDqmSource_[]
const std::vector< SiStripFecCrate > & crates() const
void setVerbose(unsigned level)
Definition: DQMStore.cc:196
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
dbl *** dir
Definition: mlp_gen.cc:35
void SiStripCommissioningSource::clearCablingTasks ( )
private

Definition at line 1100 of file SiStripCommissioningSource.cc.

References cablingTasks_.

Referenced by beginRun().

1100  {
1101  if ( cablingTasks_.empty() ) { return; }
1102  for ( TaskMap::iterator itask = cablingTasks_.begin(); itask != cablingTasks_.end(); itask++ ) {
1103  if ( itask->second ) { delete itask->second; }
1104  }
1105  cablingTasks_.clear();
1106 }
void SiStripCommissioningSource::clearTasks ( )
private

Definition at line 1110 of file SiStripCommissioningSource.cc.

References tasks_.

Referenced by beginRun().

1110  {
1111  if ( tasks_.empty() ) { return; }
1112  VecOfVecOfTasks::iterator ifed = tasks_.begin();
1113  for ( ; ifed != tasks_.end(); ifed++ ) {
1114  VecOfTasks::iterator ichan = ifed->begin();
1115  for ( ; ichan != ifed->end(); ichan++ ) {
1116  if ( *ichan ) { delete *ichan; *ichan = 0; }
1117  }
1118  ifed->resize(96,0);
1119  }
1120  tasks_.resize(1024);
1121 }
void SiStripCommissioningSource::createCablingTasks ( )
private

Definition at line 789 of file SiStripCommissioningSource.cc.

References base_, cablingTasks_, SiStripFecCabling::crates(), dir, dqm(), fecCabling_, sistrip::FED_CABLING, combine::key, sistrip::mlDqmSource_, path(), SiStripEnumsAndStrings::runType(), DQMStore::setCurrentFolder(), task_, sistrip::UNDEFINED_RUN_TYPE, and sistrip::UNKNOWN_RUN_TYPE.

Referenced by createTask().

789  {
790 
791  // Iterate through FEC cabling and create commissioning task objects
792  uint16_t booked = 0;
793  for ( std::vector<SiStripFecCrate>::const_iterator icrate = fecCabling_->crates().begin(); icrate != fecCabling_->crates().end(); icrate++ ) {
794  for ( std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++ ) {
795  for ( std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++ ) {
796  for ( std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++ ) {
797  for ( std::vector<SiStripModule>::const_iterator imodule = iccu->modules().begin(); imodule != iccu->modules().end(); imodule++ ) {
798 
799  // Build FEC key
800  SiStripFecKey path( icrate->fecCrate(),
801  ifec->fecSlot(),
802  iring->fecRing(),
803  iccu->ccuAddr(),
804  imodule->ccuChan() );
805 
806  // Check if FEC key is invalid
807  if ( !path.isValid() ) { continue; }
808 
809  // Set working directory prior to booking histograms
810  std::string dir = base_ + path.path();
811  dqm()->setCurrentFolder( dir );
812 
813  // Iterate through all APV pairs for this module
814  for ( uint16_t ipair = 0; ipair < imodule->nApvPairs(); ipair++ ) {
815 
816  // Retrieve active APV devices
817  SiStripModule::PairOfU16 apvs = imodule->activeApvPair( imodule->lldChannel(ipair) );
818 
819  // Create connection object to hold all relevant info
820  FedChannelConnection conn( icrate->fecCrate(),
821  ifec->fecSlot(),
822  iring->fecRing(),
823  iccu->ccuAddr(),
824  imodule->ccuChan(),
825  apvs.first,
826  apvs.second,
827  imodule->dcuId(),
828  imodule->detId(),
829  imodule->nApvPairs() );
830 
831  // Define key encoding control path
832  uint32_t key = SiStripFecKey( icrate->fecCrate(),
833  ifec->fecSlot(),
834  iring->fecRing(),
835  iccu->ccuAddr(),
836  imodule->ccuChan(),
837  imodule->lldChannel(ipair) ).key();
838 
839  // Check key is non zero
840  if ( !key ) {
842  << "[SiStripCommissioningSource::" << __func__ << "]"
843  << " Unexpected NULL value for FEC key!";
844  continue;
845  }
846 
847  // Create cabling task objects if not already existing
848  if ( cablingTasks_.find( key ) == cablingTasks_.end() ) {
849 
850  if ( task_ == sistrip::FED_CABLING ) {
851  cablingTasks_[key] = new FedCablingTask( dqm(), conn );
852  } else if ( task_ == sistrip::UNDEFINED_RUN_TYPE ) {
854  << "[SiStripCommissioningSource::" << __func__ << "]"
855  << " Undefined CommissioningTask"
856  << " Unable to create FedCablingTask object!";
857  } else if ( task_ == sistrip::UNKNOWN_RUN_TYPE ) {
859  << "[SiStripCommissioningSource::" << __func__ << "]"
860  << " Unknown CommissioningTask"
861  << " Unable to create FedCablingTask object!";
862  } else {
864  << "[SiStripCommissioningSource::" << __func__ << "]"
865  << " Unexpected CommissioningTask: "
867  << " Unable to create FedCablingTask object!";
868  }
869 
870  // Check if key is found and, if so, book histos and set update freq
871  if ( cablingTasks_.find( key ) != cablingTasks_.end() ) {
872  if ( cablingTasks_[key] ) {
873  cablingTasks_[key]->bookHistograms();
874  cablingTasks_[key]->updateFreq(1); //@@ hardwired to update every event!!!
875  booked++;
876  //std::stringstream ss;
877  //ss << "[SiStripCommissioningSource::" << __func__ << "]"
878  //<< " Booking histograms for '" << cablingTasks_[key]->myName()
879  //<< "' object with key 0x" << std::hex << std::setfill('0') << std::setw(8) << key << std::dec
880  //<< " in directory \"" << dir << "\"";
881  //LogTrace(mlDqmSource_) << ss.str();
882  } else {
883  std::stringstream ss;
884  ss << "[SiStripCommissioningSource::" << __func__ << "]"
885  << " NULL pointer to CommissioningTask for key 0x"
886  << std::hex << std::setfill('0') << std::setw(8) << key << std::dec
887  << " in directory " << dir
888  << " Unable to book histograms!";
889  edm::LogWarning(mlDqmSource_) << ss.str();
890  }
891  } else {
892  std::stringstream ss;
893  ss << "[SiStripCommissioningSource::" << __func__ << "]"
894  << " Unable to find CommissioningTask for key 0x"
895  << std::hex << std::setfill('0') << std::setw(8) << key << std::dec
896  << " in directory " << dir
897  << " Unable to book histograms!";
898  edm::LogWarning(mlDqmSource_) << ss.str();
899  }
900 
901  } else {
902  std::stringstream ss;
903  ss << "[SiStripCommissioningSource::" << __func__ << "]"
904  << " CommissioningTask object already exists for key 0x"
905  << std::hex << std::setfill('0') << std::setw(8) << key << std::dec
906  << " in directory " << dir
907  << " Unable to create FedCablingTask object!";
908  edm::LogWarning(mlDqmSource_) << ss.str();
909  }
910 
911  } // loop through apv pairs
912  } // loop through modules
913  } // loop through ccus
914  } // loop through rings
915  } // loop through fecs
916  } // loop through crates
917 
919  << "[SiStripCommissioningSource::" << __func__ << "]"
920  << " Created " << booked
921  << " CommissioningTask objects and booked histograms";
922 
923 }
DQMStore *const dqm(std::string method="") const
static const char mlDqmSource_[]
const std::vector< SiStripFecCrate > & crates() const
int path() const
Definition: HLTadd.h:3
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:46
static std::string runType(const sistrip::RunType &)
Class containning control, module, detector and connection information, at the level of a FED channel...
std::pair< uint16_t, uint16_t > PairOfU16
Definition: SiStripModule.h:43
list key
Definition: combine.py:13
dbl *** dir
Definition: mlp_gen.cc:35
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void SiStripCommissioningSource::createRunNumber ( )
private

Definition at line 680 of file SiStripCommissioningSource.cc.

References base_, DQMStore::bookString(), dqm(), sistrip::mlDqmSource_, sistrip::root_, DTTTrigCorrFirst::run, run_, sistrip::runNumber_, sistrip::sep_, and DQMStore::setCurrentFolder().

Referenced by analyze().

680  {
681 
682  // Set commissioning task to default ("undefined") value
683  if ( !run_ ) {
685  << "[SiStripCommissioningSource::" << __func__ << "]"
686  << " NULL run number!";
687  return;
688  }
689 
690  // Create MonitorElement that identifies run number
692  std::stringstream run;
693  run << run_;
694  dqm()->bookString( std::string(sistrip::runNumber_) + sistrip::sep_ + run.str(), run.str() );
695 
696 }
static const char runNumber_[]
DQMStore *const dqm(std::string method="") const
static const char mlDqmSource_[]
static const char sep_[]
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:480
static const char root_[]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void SiStripCommissioningSource::createTask ( const SiStripEventSummary * const  summary,
const edm::EventSetup setup 
)
private

Definition at line 700 of file SiStripCommissioningSource.cc.

References base_, DQMStore::bookString(), cablingTask_, createCablingTasks(), createTasks(), dqm(), sistrip::FED_CABLING, LogTrace, sistrip::mlDqmSource_, sistrip::root_, SiStripEnumsAndStrings::runType(), SiStripEventSummary::runType(), sistrip::sep_, DQMStore::setCurrentFolder(), task_, taskConfigurable_, sistrip::taskId_, tasksExist_, sistrip::UNDEFINED_RUN_TYPE, and sistrip::UNKNOWN_RUN_TYPE.

Referenced by analyze().

700  {
701 
702  // Set commissioning task to default ("undefined") value
704 
705  // Retrieve commissioning task from EventSummary
706  if ( summary ) {
707  task_ = summary->runType();
708  std::stringstream ss;
709  ss << "[SiStripCommissioningSource::" << __func__ << "]"
710  << " Identified CommissioningTask from EventSummary to be \""
712  << "\"";
713  LogTrace(mlDqmSource_) << ss.str();
714  } else {
716  std::stringstream ss;
717  ss << "[SiStripCommissioningSource::" << __func__ << "]"
718  << " NULL pointer to SiStripEventSummary!"
719  << " Check SiStripEventSummary is found/present in Event";
720  edm::LogWarning(mlDqmSource_) << ss.str();
721  }
722 
723  // Override task with ParameterSet configurable (if defined)
725  if ( configurable != sistrip::UNDEFINED_RUN_TYPE &&
726  configurable != sistrip::UNKNOWN_RUN_TYPE ) {
727  std::stringstream ss;
728  ss << "[SiStripCommissioningSource::" << __func__ << "]"
729  << " Overriding CommissioningTask from EventSummary (\""
731  << "\") with value retrieved from .cfg file (\""
732  << SiStripEnumsAndStrings::runType( configurable )
733  << "\")!";
734  LogTrace(mlDqmSource_) << ss.str();
735  task_ = configurable;
736  }
737 
738  // Create ME (std::string) that identifies commissioning task
740  std::string task_str = SiStripEnumsAndStrings::runType( task_ );
741  dqm()->bookString( std::string(sistrip::taskId_) + sistrip::sep_ + task_str, task_str );
742 
743  // Check commissioning task is known / defined
746  std::stringstream ss;
747  ss << "[SiStripCommissioningSource::" << __func__ << "]"
748  << " Unexpected CommissioningTask found ("
749  << static_cast<uint16_t>(task_) << ") \""
751  << " Unexpected value found in SiStripEventSummary and/or cfg file"
752  << " If SiStripEventSummary is not present in Event,"
753  << " check 'CommissioningTask' configurable in cfg file";
754  edm::LogWarning(mlDqmSource_) << ss.str();
755  return;
756  } else {
757  std::stringstream ss;
758  ss << "[SiStripCommissioningSource::" << __func__ << "]"
759  << " Identified CommissioningTask to be \""
761  << "\"";
762  LogTrace(mlDqmSource_) << ss.str();
763  }
764 
765  // Check if commissioning task is FED cabling
766  if ( task_ == sistrip::FED_CABLING ) { cablingTask_ = true; }
767  else { cablingTask_ = false; }
768 
769  std::stringstream ss;
770  ss << "[SiStripCommissioningSource::" << __func__ << "]"
771  << " CommissioningTask: "
772  << SiStripEnumsAndStrings::runType( summary->runType() );
773  LogTrace(mlDqmSource_) << ss.str();
774 
776  << "[SiStripCommissioningSource::" << __func__ << "]"
777  << " Creating CommissioningTask objects and booking histograms...";
778  if ( cablingTask_ ) { createCablingTasks(); }
779  else { createTasks( task_ , setup ); }
781  << "[SiStripCommissioningSource::" << __func__ << "]"
782  << " Finished booking histograms!";
783  tasksExist_ = true;
784 
785 }
DQMStore *const dqm(std::string method="") const
static const char mlDqmSource_[]
void createTasks(sistrip::RunType, const edm::EventSetup &)
static std::string runType(const sistrip::RunType &)
const sistrip::RunType & runType() const
static const char sep_[]
MonitorElement * bookString(const char *name, const char *value)
Book string.
Definition: DQMStore.cc:480
static const char taskId_[]
#define LogTrace(id)
static const char root_[]
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
void SiStripCommissioningSource::createTasks ( sistrip::RunType  run_type,
const edm::EventSetup setup 
)
private

Definition at line 927 of file SiStripCommissioningSource.cc.

References sistrip::APV_LATENCY, sistrip::APV_TIMING, base_, sistrip::CALIBRATION, sistrip::CALIBRATION_DECO, sistrip::CALIBRATION_SCAN, sistrip::CALIBRATION_SCAN_DECO, SiStripFedCabling::connections(), sistrip::DAQ_SCOPE_MODE, sistrip::detectorView_, dir, sistrip::dir_, dqm(), sistrip::FAST_CABLING, SiStripFedKey::feChan(), sistrip::FED_TIMING, fedCabling_, SiStripFedCabling::feds(), SiStripFedKey::feUnit(), filename_, sistrip::FINE_DELAY, sistrip::invalid_, sistrip::mlDqmSource_, sistrip::NOISE, sistrip::OPTO_SCAN, parameters_, sistrip::PEDESTALS, sistrip::PEDS_FULL_NOISE, sistrip::PEDS_ONLY, sistrip::root_, run_, DQMStore::setCurrentFolder(), HcalObjRepresent::setup(), task_, tasks_, sistrip::UNDEFINED_RUN_TYPE, updateFreq_, view_, and sistrip::VPSP_SCAN.

Referenced by createTask().

927  {
928 
929  uint16_t booked = 0;
930 
931  // latency has partition-level histos, so treat separately
932  if (task_ == sistrip::APV_LATENCY) {
933 
934  for (uint16_t partition = 0; partition < 4; ++partition) {
935  // make a task for every partition; tracker-wide histo is shared
937  tasks_[0][partition]->eventSetup( &setup );
938  tasks_[0][partition]->bookHistograms();
939  tasks_[0][partition]->updateFreq( updateFreq_ );
940  booked++;
941  }
942 
943  // fine-delay has 1 histo for the whole tracker, so treat separately
944  } else if (task_ == sistrip::FINE_DELAY) {
945 
946  tasks_[0][0] = new FineDelayTask( dqm(), FedChannelConnection() );
947  tasks_[0][0]->eventSetup( &setup );
948  tasks_[0][0]->bookHistograms();
949  tasks_[0][0]->updateFreq( updateFreq_ );
950  booked++;
951 
952  } else { // now do any other task
953 
954  // Iterate through FED ids and channels
955  std::vector<uint16_t>::const_iterator ifed = fedCabling_->feds().begin();
956  for ( ; ifed != fedCabling_->feds().end(); ifed++ ) {
957 
958  // Iterate through connected FED channels
959  // S.L.: currently copy the vector, because it changes later when
960  // reading in peds for calibration run -> not understood memory corruption!
961  std::vector<FedChannelConnection> conns = fedCabling_->connections(*ifed);
962  std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
963  for ( ; iconn != conns.end(); iconn++ ) {
964 
965  // Create FEC key
966  SiStripFecKey fec_key( iconn->fecCrate(),
967  iconn->fecSlot(),
968  iconn->fecRing(),
969  iconn->ccuAddr(),
970  iconn->ccuChan() );
971  // Create FED key and check if non-zero
972  SiStripFedKey fed_key( iconn->fedId(),
973  SiStripFedKey::feUnit(iconn->fedCh()),
974  SiStripFedKey::feChan(iconn->fedCh()) );
975  if ( !iconn->isConnected() ) { continue; }
976 
977  // define the view in which to work and paths for histograms
978  // currently FecView (control view) and FedView (readout view)
979  // DetView (detector view) implementation has started
980  // Set working directory prior to booking histograms
981  std::stringstream dir;
982  dir << base_;
983  if (view_ == "Default") { // default
984  if ( run_type == sistrip::FAST_CABLING ) {
985  dir << fed_key.path(); // cabling in fed view
986  } else {
987  dir << fec_key.path(); // all other runs in control view
988  }
989  } else if (view_ == "FecView") {
990  dir << fec_key.path();
991  } else if (view_ == "FedView") {
992  dir << fed_key.path();
993  } else if (view_ == "DetView") {
994  // currently just by detid from the connection, which is empty...
995  dir << sistrip::root_ << sistrip::dir_
997  << iconn->detId();
998  } else {
1000  << "[SiStripCommissioningSource::" << __func__ << "]"
1001  << " Invalid view " << view_ << std::endl
1002  << " Histograms will end up all in the top directory.";
1003  } // end if view_ == ...
1004  dqm()->setCurrentFolder( dir.str() );
1005 
1006  // Create commissioning task objects
1007  if ( !tasks_[iconn->fedId()][iconn->fedCh()] ) {
1008  if ( task_ == sistrip::FAST_CABLING ) {
1009  tasks_[iconn->fedId()][iconn->fedCh()] = new FastFedCablingTask( dqm(), *iconn );
1010  } else if ( task_ == sistrip::APV_TIMING ) {
1011  tasks_[iconn->fedId()][iconn->fedCh()] = new ApvTimingTask( dqm(), *iconn );
1012  } else if ( task_ == sistrip::FED_TIMING ) {
1013  tasks_[iconn->fedId()][iconn->fedCh()] = new FedTimingTask( dqm(), *iconn );
1014  } else if ( task_ == sistrip::OPTO_SCAN ) {
1015  tasks_[iconn->fedId()][iconn->fedCh()] = new OptoScanTask( dqm(), *iconn );
1016  } else if ( task_ == sistrip::VPSP_SCAN ) {
1017  tasks_[iconn->fedId()][iconn->fedCh()] = new VpspScanTask( dqm(), *iconn );
1018  } else if ( task_ == sistrip::PEDESTALS ) {
1019  tasks_[iconn->fedId()][iconn->fedCh()] = new PedestalsTask( dqm(), *iconn );
1020  } else if ( task_ == sistrip::PEDS_ONLY ) {
1021  tasks_[iconn->fedId()][iconn->fedCh()] = new PedsOnlyTask( dqm(), *iconn );
1022  } else if ( task_ == sistrip::NOISE ) {
1023  tasks_[iconn->fedId()][iconn->fedCh()] = new NoiseTask( dqm(), *iconn );
1024  } else if ( task_ == sistrip::PEDS_FULL_NOISE ) {
1025  tasks_[iconn->fedId()][iconn->fedCh()] = new PedsFullNoiseTask( dqm(), *iconn, parameters_ );
1026  } else if ( task_ == sistrip::DAQ_SCOPE_MODE ) {
1027  tasks_[iconn->fedId()][iconn->fedCh()] = new DaqScopeModeTask( dqm(), *iconn );
1028  } else if ( task_ == sistrip::CALIBRATION_SCAN ||
1030  tasks_[iconn->fedId()][iconn->fedCh()] = new CalibrationScanTask( dqm(),
1031  *iconn,
1032  task_,
1033  filename_.c_str(),
1034  run_,
1035  setup );
1036  } else if ( task_ == sistrip::CALIBRATION ||
1038  tasks_[iconn->fedId()][iconn->fedCh()] = new CalibrationTask( dqm(),
1039  *iconn,
1040  task_,
1041  filename_.c_str(),
1042  run_,
1043  setup );
1044  } else if ( task_ == sistrip::UNDEFINED_RUN_TYPE ) {
1046  << "[SiStripCommissioningSource::" << __func__ << "]"
1047  << " Undefined CommissioningTask"
1048  << " Unable to create CommissioningTask object!";
1049  } else {
1051  << "[SiStripCommissioningSource::" << __func__ << "]"
1052  << " Unknown CommissioningTask"
1053  << " Unable to create CommissioningTask object!";
1054  }
1055 
1056  // Check if fed_key is found and, if so, book histos and set update freq
1057  if ( tasks_[iconn->fedId()][iconn->fedCh()] ) {
1058  tasks_[iconn->fedId()][iconn->fedCh()]->eventSetup( &setup );
1059  tasks_[iconn->fedId()][iconn->fedCh()]->bookHistograms();
1060  tasks_[iconn->fedId()][iconn->fedCh()]->updateFreq( updateFreq_ );
1061  booked++;
1062  //std::stringstream ss;
1063  //ss << "[SiStripCommissioningSource::" << __func__ << "]"
1064  //<< " Booking histograms for '" << tasks_[iconn->fedId()][iconn->fedCh()]->myName()
1065  //<< "' object with key 0x" << std::hex << std::setfill('0') << std::setw(8) << fed_key.key() << std::dec
1066  //<< " in directory " << dir.str();
1067  //LogTrace(mlDqmSource_) << ss.str();
1068  } else {
1069  std::stringstream ss;
1070  ss << "[SiStripCommissioningSource::" << __func__ << "]"
1071  << " NULL pointer to CommissioningTask for key 0x"
1072  << std::hex << std::setfill('0') << std::setw(8) << fed_key.key() << std::dec
1073  << " in directory " << dir.str()
1074  << " Unable to book histograms!";
1075  edm::LogWarning(mlDqmSource_) << ss.str();
1076  }
1077 
1078  } else {
1079  std::stringstream ss;
1080  ss << "[SiStripCommissioningSource::" << __func__ << "]"
1081  << " CommissioningTask object already exists for key 0x"
1082  << std::hex << std::setfill('0') << std::setw(8) << fed_key.key() << std::dec
1083  << " in directory " << dir.str()
1084  << " Unable to create CommissioningTask object!";
1085  edm::LogWarning(mlDqmSource_) << ss.str();
1086  }
1087 
1088  } // loop over fed channels
1089  } // loop over feds
1090  } // end other tasks
1091 
1093  << "[SiStripCommissioningSource::" << __func__ << "]"
1094  << " Created " << booked
1095  << " CommissioningTask objects and booked histograms";
1096 }
const std::vector< uint16_t > & feds() const
static const char dir_[]
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:57
DQMStore *const dqm(std::string method="") const
static const char mlDqmSource_[]
static const char detectorView_[]
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:46
Class containning control, module, detector and connection information, at the level of a FED channel...
const uint16_t & feUnit() const
static const uint16_t invalid_
Definition: Constants.h:17
const uint16_t & feChan() const
static const char root_[]
dbl *** dir
Definition: mlp_gen.cc:35
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:232
const std::vector< FedChannelConnection > & connections(uint16_t fed_id) const
void SiStripCommissioningSource::directory ( std::stringstream &  dir,
uint32_t  run_number = 0 
)
private

Definition at line 1136 of file SiStripCommissioningSource.cc.

References evf::utils::pid, pos, and tmp.

Referenced by endJob().

1137  {
1138 
1139  // Get details about host
1140  char hn[256];
1141  gethostname( hn, sizeof(hn) );
1142  struct hostent* he;
1143  he = gethostbyname(hn);
1144 
1145  // Extract host name and ip
1146  std::string host_name;
1147  std::string host_ip;
1148  if ( he ) {
1149  host_name = std::string(he->h_name);
1150  host_ip = std::string( inet_ntoa( *(struct in_addr*)(he->h_addr) ) );
1151  } else {
1152  host_name = "unknown.cern.ch";
1153  host_ip = "255.255.255.255";
1154  }
1155 
1156  // Reformat IP address
1158  std::stringstream ip;
1159  //for ( uint16_t ii = 0; ii < 4; ++ii ) {
1160  while ( pos != std::string::npos ) {
1161  std::string::size_type tmp = host_ip.find(".",pos);
1162  if ( tmp != std::string::npos ) {
1163  ip << std::setw(3)
1164  << std::setfill('0')
1165  << host_ip.substr( pos, tmp-pos )
1166  << ".";
1167  pos = tmp+1; // skip the delimiter "."
1168  } else {
1169  ip << std::setw(3)
1170  << std::setfill('0')
1171  << host_ip.substr( pos );
1172  pos = std::string::npos;
1173  }
1174  }
1175 
1176  // Get pid
1177  pid_t pid = getpid();
1178 
1179  // Construct string
1180  if ( run_number ) {
1181  dir << std::setw(8)
1182  << std::setfill('0')
1183  << run_number
1184  << "_";
1185  }
1186  dir << ip.str()
1187  << "_"
1188  << std::setw(5)
1189  << std::setfill('0')
1190  << pid;
1191 
1192 }
uint16_t size_type
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
dbl *** dir
Definition: mlp_gen.cc:35
DQMStore *const SiStripCommissioningSource::dqm ( std::string  method = "") const
private

Definition at line 92 of file SiStripCommissioningSource.cc.

References dqm_, and sistrip::mlDqmSource_.

Referenced by beginRun(), createCablingTasks(), createRunNumber(), createTask(), createTasks(), endJob(), and remove().

92  {
93  if ( !dqm_ ) {
94  std::stringstream ss;
95  if ( method != "" ) { ss << "[SiStripCommissioningSource::" << method << "]" << std::endl; }
96  else { ss << "[SiStripCommissioningSource]" << std::endl; }
97  ss << " NULL pointer to DQMStore";
98  edm::LogWarning(mlDqmSource_) << ss.str();
99  return 0;
100  } else { return dqm_; }
101 }
static const char mlDqmSource_[]
void SiStripCommissioningSource::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 159 of file SiStripCommissioningSource.cc.

References sistrip::APV_LATENCY, cablingTasks_, SiStripFedCabling::connections(), dir, directory(), dqm(), fecCabling_, fedCabling_, SiStripFedCabling::feds(), filename_, sistrip::FINE_DELAY, LogTrace, sistrip::mlDqmSource_, mergeVDriftHistosByStation::name, NULL, run_, DQMStore::save(), task_, and tasks_.

159  {
161  << "[SiStripCommissioningSource::" << __func__ << "]"
162  << " Halting..." << std::endl;
163 
164  // ---------- Update histograms ----------
165 
166  // Cabling task
167  for ( TaskMap::iterator itask = cablingTasks_.begin(); itask != cablingTasks_.end(); itask++ ) {
168  if ( itask->second ) { itask->second->updateHistograms(); }
169  }
170 
171  if (task_ == sistrip::APV_LATENCY) {
172  for (uint16_t partition = 0; partition < 4; ++partition) {
173  tasks_[0][partition]->updateHistograms();
174  }
175  } else if (task_ == sistrip::FINE_DELAY ) {
176  tasks_[0][0]->updateHistograms();
177  } else {
178  // All tasks except cabling
179  uint16_t fed_id = 0;
180  uint16_t fed_ch = 0;
181  std::vector<uint16_t>::const_iterator ifed = fedCabling_->feds().begin();
182  for ( ; ifed != fedCabling_->feds().end(); ifed++ ) {
183  const std::vector<FedChannelConnection>& conns = fedCabling_->connections(*ifed);
184  std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
185  for ( ; iconn != conns.end(); iconn++ ) {
186  if ( !iconn->isConnected() ) { continue; }
187  fed_id = iconn->fedId();
188  fed_ch = iconn->fedCh();
189  if ( tasks_[fed_id][fed_ch] ) {
190  tasks_[fed_id][fed_ch]->updateHistograms();
191  delete tasks_[fed_id][fed_ch];
192  }
193  }
194  }
195  }
196 
197  // ---------- Save histos to root file ----------
198 
199  // Strip filename of ".root" extension
200  std::string name;
201  if ( filename_.find(".root",0) == std::string::npos ) { name = filename_; }
202  else { name = filename_.substr( 0, filename_.find(".root",0) ); }
203 
204  // Retrieve SCRATCH directory
205  std::string scratch = "SCRATCH"; //@@ remove trailing slash!!!
206  std::string dir = "";
207  if ( getenv(scratch.c_str()) != NULL ) {
208  dir = getenv(scratch.c_str());
209  }
210 
211  // Add directory path
212  std::stringstream ss;
213  if ( !dir.empty() ) { ss << dir << "/"; }
214  else { ss << "/tmp/"; }
215 
216  // Add filename with run number, host ip, pid and .root extension
217  ss << name << "_";
218  directory(ss,run_);
219  ss << ".root";
220 
221  // Save file with appropriate filename (if run number is known)
222  if ( !filename_.empty() ) {
223  if ( run_ != 0 ) { dqm()->save( ss.str() ); }
224  else {
226  << "[SiStripCommissioningSource::" << __func__ << "]"
227  << " NULL value for RunNumber! No root file saved!";
228  }
229  } else {
231  << "[SiStripCommissioningSource::" << __func__ << "]"
232  << " NULL value for filename! No root file saved!";
233  }
234 
236  << "[SiStripCommissioningSource::" << __func__ << "]"
237  << " Saved all histograms to file \""
238  << ss.str() << "\"";
239 
240  // ---------- Delete histograms ----------
241 
242  // Remove all MonitorElements in "SiStrip" dir and below
243  // remove();
244 
245  // Delete histogram objects
246  // clearCablingTasks();
247  // clearTasks();
248 
249  // ---------- Delete cabling ----------
250 
251  if ( fedCabling_ ) { fedCabling_ = 0; }
252  if ( fecCabling_ ) { delete fecCabling_; fecCabling_ = 0; }
253 
254 }
const std::vector< uint16_t > & feds() const
DQMStore *const dqm(std::string method="") const
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:1898
static const char mlDqmSource_[]
#define NULL
Definition: scimark2.h:8
void directory(std::stringstream &, uint32_t run_number=0)
#define LogTrace(id)
dbl *** dir
Definition: mlp_gen.cc:35
const std::vector< FedChannelConnection > & connections(uint16_t fed_id) const
void SiStripCommissioningSource::fillCablingHistos ( const SiStripEventSummary * const  summary,
const edm::DetSetVector< SiStripRawDigi > &  raw 
)
private

Definition at line 360 of file SiStripCommissioningSource.cc.

References Averages::add(), PDRates::average, cablingTasks_, Averages::calc(), sistrip::CCU_CHAN, SiStripFecKey::ccuAddr(), SiStripFecKey::ccuChan(), SiStripKey::channel(), SiStripEventSummary::dcuId(), SiStripEventSummary::deviceId(), edm::DetSetVector< T >::end(), fecCabling_, SiStripFecKey::fecCrate(), SiStripFecKey::fecRing(), SiStripFecKey::fecSlot(), fedCabling_, SiStripFedCabling::feds(), edm::DetSetVector< T >::find(), sistrip::invalid_, SiStripKey::key(), SiStripModule::key(), LogTrace, Averages::Params::median_, sistrip::mlDqmSource_, sistrip::mlTest_, SiStripFecCabling::module(), path(), Averages::Params::rms_, and tmp.

Referenced by analyze().

361  {
362 
363  // Create FEC key using DCU id and LLD channel from SiStripEventSummary
364  const SiStripModule& module = fecCabling_->module( summary->dcuId() );
365  uint16_t lld_channel = ( summary->deviceId() & 0x3 ) + 1;
366  SiStripFecKey key_object( module.key().fecCrate(),
367  module.key().fecSlot(),
368  module.key().fecRing(),
369  module.key().ccuAddr(),
370  module.key().ccuChan(),
371  lld_channel );
372  uint32_t fec_key = key_object.key();
373  std::stringstream sss;
374  sss << "[SiStripCommissioningSource::" << __func__ << "]"
375  << " Found DcuId 0x"
376  << std::hex << std::setw(8) << std::setfill('0') << summary->dcuId() << std::dec
377  << " with Crate/FEC/Ring/CCU/Module/LLD: "
378  << module.key().fecCrate() << "/"
379  << module.key().fecSlot() << "/"
380  << module.key().fecRing() << "/"
381  << module.key().ccuAddr() << "/"
382  << module.key().ccuChan() << "/"
383  << lld_channel;
384  edm::LogWarning(mlDqmSource_) << sss.str();
385 
386  //LogTrace(mlTest_) << "TEST : " << key_object;
387 
388  // Check on whether DCU id is found
389  if ( key_object.isInvalid( sistrip::CCU_CHAN ) ) {
390  std::stringstream ss;
391  ss << "[SiStripCommissioningSource::" << __func__ << "]"
392  << " DcuId 0x"
393  << std::hex << std::setw(8) << std::setfill('0') << summary->dcuId() << std::dec
394  << " in 'DAQ register' field not found in cabling map!"
395  << " (NULL values returned for FEC path)";
396  edm::LogWarning(mlDqmSource_) << ss.str();
397  return;
398  }
399 
400  // Iterate through FED ids
401  std::vector<uint16_t>::const_iterator ifed = fedCabling_->feds().begin();
402  for ( ; ifed != fedCabling_->feds().end(); ifed++ ) {
403 
404  // Check if FedId is non-zero
405  if ( *ifed == sistrip::invalid_ ) { continue; }
406 
407  // Container to hold median signal level for FED cabling task
408  std::map<uint16_t,float> medians; medians.clear();
409  std::map<uint16_t,float> medians1; medians1.clear();
410 
411  // Iterate through FED channels
412  for ( uint16_t ichan = 0; ichan < 96; ichan++ ) {
413 
414  // // Retrieve digis for given FED key
415  // uint32_t fed_key = SiStripFedKey( *ifed,
416  // SiStripFedKey::feUnit(ichan),
417  // SiStripFedKey::feChan(ichan) ).key();
418 
419  // Retrieve digis for given FED key
420  uint32_t fed_key = ( ( *ifed & sistrip::invalid_ ) << 16 ) | ( ichan & sistrip::invalid_ );
421 
422  std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.find( fed_key );
423  if ( digis != raw.end() ) {
424  if ( digis->data.empty() ) { continue; }
425 
426  // if ( digis->data[0].adc() > 500 ) {
427  // std::stringstream ss;
428  // ss << " HIGH SIGNAL " << digis->data[0].adc() << " FOR"
429  // << " FedKey: 0x" << std::hex << std::setw(8) << std::setfill('0') << fed_key << std::dec
430  // << " FedId/Ch: " << *ifed << "/" << ichan;
431  // LogTrace(mlDqmSource_) << ss.str();
432  // }
433 
434  Averages ave;
435  for ( uint16_t idigi = 0; idigi < digis->data.size(); idigi++ ) {
436  ave.add( static_cast<uint32_t>(digis->data[idigi].adc()) );
437  }
438  Averages::Params params;
439  ave.calc(params);
440  medians[ichan] = params.median_; // Store median signal level
441  medians1[ichan] = digis->data[0].adc();
442 
443  // if ( !digis->data.empty() ) { medians[ichan] = digis->data[0].adc(); }
444  // else {
445  // edm::LogWarning(mlTest_) << "TEST : NO DIGIS!";
446  // }
447 
448  // std::stringstream ss;
449  // ss << "Channel Averages:" << std::endl
450  // << " nDigis: " << digis->data.size() << std::endl
451  // << " num/mean/MEDIAN/rms/max/min: "
452  // << params.num_ << "/"
453  // << params.mean_ << "/"
454  // << params.median_ << "/"
455  // << params.rms_ << "/"
456  // << params.max_ << "/"
457  // << params.min_ << std::endl;
458  // LogTrace(mlDqmSource_) << ss.str();
459 
460  }
461 
462  } // fed channel loop
463 
464  // Calculate mean and spread on all (median) signal levels
466  std::map<uint16_t,float>::const_iterator ii = medians.begin();
467  for ( ; ii != medians.end(); ii++ ) { average.add( ii->second ); }
469  average.calc(tmp);
470 
471  // std::stringstream ss;
472  // ss << "FED Averages:" << std::endl
473  // << " nChans: " << medians.size() << std::endl
474  // << " num/mean/median/rms/max/min: "
475  // << tmp.num_ << "/"
476  // << tmp.mean_ << "/"
477  // << tmp.median_ << "/"
478  // << tmp.rms_ << "/"
479  // << tmp.max_ << "/"
480  // << tmp.min_ << std::endl;
481  // LogTrace(mlDqmSource_) << ss.str();
482 
483  // Calculate mean and spread on "filtered" data
484  Averages truncated;
485  std::map<uint16_t,float>::const_iterator jj = medians.begin();
486  for ( ; jj != medians.end(); jj++ ) {
487  if ( jj->second < tmp.median_+tmp.rms_ ) {
488  truncated.add( jj->second );
489  }
490  }
491  Averages::Params params;
492  truncated.calc(params);
493 
494  // std::stringstream ss1;
495  // ss1 << "Truncated Averages:" << std::endl
496  // << " nChans: " << medians.size() << std::endl
497  // << " num/mean/median/rms/max/min: "
498  // << params.num_ << "/"
499  // << params.mean_ << "/"
500  // << params.median_ << "/"
501  // << params.rms_ << "/"
502  // << params.max_ << "/"
503  // << params.min_ << std::endl;
504  // LogTrace(mlDqmSource_) << ss1.str();
505 
506  // Identify channels with signal
507  std::stringstream ss2;
508  std::stringstream ss3;
509  // ss2 << "Number of possible connections: " << medians.size()
510  // << " channel/signal: ";
511  std::map<uint16_t,float> channels;
512  std::map<uint16_t,float>::const_iterator ichan = medians.begin();
513  for ( ; ichan != medians.end(); ichan++ ) {
514  // cout << " mean: " << params.mean_
515  // << " rms: " << params.rms_
516  // << " thresh: " << params.mean_ + 5.*params.rms_
517  // << " value: " << ichan->second
518  // << " strip: " << ichan->first << std::endl;
519  //if ( ichan->second > params.mean_ + 5.*params.rms_ ) {
520  if ( ichan->second > 200. ) {
521  LogTrace(mlTest_) << "TEST FOUND SIGNAL HIGH: " << *ifed << " " << ichan->first << " " << ichan->second;
522  channels[ichan->first] = ichan->second;
523  }
524  ss2 //<< ichan->first << "/"
525  << ichan->second << " ";
526  ss3 //<< ichan->first << "/"
527  << medians1[ichan->first] << " ";
528  }
529 
530  ss2 << std::endl;
531  ss3 << std::endl;
532  LogTrace(mlTest_) << "DUMP for FED " << *ifed << ": " << ss2.str();
533  LogTrace(mlTest_) << "FIRST ADC VAL " << *ifed << ": " << ss3.str();
534 
535  // LogTrace(mlDqmSource_)
536  // << "[FedCablingTask::" << __func__ << "]"
537  // << " Found candidate connection between device: 0x"
538  // << std::setfill('0') << std::setw(8) << std::hex << summary.deviceId() << std::dec
539  // << " with Crate/FEC/Ring/CCU/Module/LLDchannel: "
540  // << connection().fecCrate() << "/"
541  // << connection().fecSlot() << "/"
542  // << connection().fecRing() << "/"
543  // << connection().ccuAddr() << "/"
544  // << connection().ccuChan() << "/"
545  // << connection().lldChannel()
546  // << " and FedId/Ch: "
547  // << fed_id << "/" << ichan->first
548  // << " with signal " << ichan->second
549  // << " [adc] over background " << "XXX +/- YYY [adc]"
550  // << " (S/N = " << "ZZZ" << ")";
551 
552 
553  // Fill cabling histograms
554  if ( cablingTasks_.find(fec_key) != cablingTasks_.end() ) {
555  if ( !channels.empty() ) {
556  cablingTasks_[fec_key]->fillHistograms( *summary, *ifed, channels );
557  SiStripFecKey path( fec_key );
558  std::stringstream ss;
559  ss << "[SiStripCommissioningSource::" << __func__ << "]"
560  << " Filled histogram for '" << cablingTasks_[fec_key]->myName()
561  << "' object with FecKey: 0x"
562  << std::hex << std::setfill('0') << std::setw(8) << fec_key << std::dec
563  << " and Crate/FEC/ring/CCU/module/LLDchan: "
564  << path.fecCrate() << "/"
565  << path.fecSlot() << "/"
566  << path.fecRing() << "/"
567  << path.ccuAddr() << "/"
568  << path.ccuChan() << "/"
569  << path.channel();
570  LogTrace(mlDqmSource_) << ss.str();
571  }
572  } else {
573  SiStripFecKey path( fec_key );
574  std::stringstream ss;
575  ss << "[SiStripCommissioningSource::" << __func__ << "]"
576  << " Unable to find CommissioningTask object with FecKey: 0x"
577  << std::hex << std::setfill('0') << std::setw(8) << fec_key << std::dec
578  << " and Crate/FEC/ring/CCU/module/LLDchan: "
579  << path.fecCrate() << "/"
580  << path.fecSlot() << "/"
581  << path.fecRing() << "/"
582  << path.ccuAddr() << "/"
583  << path.ccuChan() << "/"
584  << path.channel();
585  edm::LogWarning(mlDqmSource_) << ss.str();
586  }
587 
588  } // fed id loop
589 
590 }
Device and connection information at the level of a front-end module.
Definition: SiStripModule.h:25
const std::vector< uint16_t > & feds() const
iterator find(det_id_type id)
Definition: DetSetVector.h:285
const uint16_t & fecRing() const
const SiStripModule & module(const FedChannelConnection &conn) const
const SiStripFecKey & key() const
static const char mlDqmSource_[]
const uint16_t & fecSlot() const
const uint32_t & key() const
Definition: SiStripKey.h:126
int path() const
Definition: HLTadd.h:3
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:46
void add(const float &value, const float &weight)
Definition: Averages.cc:36
const uint32_t & dcuId() const
static const char mlTest_[]
void calc(Params &)
Definition: Averages.cc:60
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
#define LogTrace(id)
const uint16_t & fecCrate() const
const uint32_t & deviceId() const
const uint16_t & ccuAddr() const
static const uint16_t invalid_
Definition: Constants.h:17
int average
Definition: PDRates.py:137
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
const uint16_t & ccuChan() const
Definition: vlib.h:209
void SiStripCommissioningSource::fillHistos ( const SiStripEventSummary * const  summary,
const edm::DetSetVector< SiStripRawDigi > &  raw 
)
private

Definition at line 594 of file SiStripCommissioningSource.cc.

References sistrip::APV_LATENCY, SiStripFedCabling::connections(), edm::DetSetVector< T >::end(), fedCabling_, SiStripFedCabling::feds(), edm::DetSetVector< T >::find(), sistrip::FINE_DELAY, sistrip::invalid_, sistrip::mlDqmSource_, task_, tasks_, and sistrip::valid_.

Referenced by analyze().

595  {
596 
597  // Iterate through FED ids and channels
598  std::vector<uint16_t>::const_iterator ifed = fedCabling_->feds().begin();
599  for ( ; ifed != fedCabling_->feds().end(); ifed++ ) {
600 
601  // Iterate through connected FED channels
602  const std::vector<FedChannelConnection>& conns = fedCabling_->connections(*ifed);
603  std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
604  for ( ; iconn != conns.end(); iconn++ ) {
605 
606  if ( !(iconn->fedId()) || iconn->fedId() > sistrip::valid_ ) { continue; }
607 
608  // // Create FED key and check if non-zero
609  // uint32_t fed_key = SiStripFedKey( iconn->fedId(),
610  // SiStripFedKey::feUnit(iconn->fedCh()),
611  // SiStripFedKey::feChan(iconn->fedCh()) ).key();
612 
613  // Create FED key and check if non-zero
614  // note: the key is not computed using the same formula as in commissioning histograms.
615  // beware that changes here must match changes in raw2digi and in SiStripFineDelayHit
616  uint32_t fed_key = ( ( iconn->fedId() & sistrip::invalid_ ) << 16 ) | ( iconn->fedCh() & sistrip::invalid_ );
617 
618  // Retrieve digis for given FED key and check if found
619  std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.find( fed_key );
620 
621  if ( digis != raw.end() ) {
622  // tasks involving tracking have partition-level histos, so treat separately
623  if (task_ == sistrip::APV_LATENCY) {
624  if ( tasks_[0][iconn->fecCrate()-1] ) {
625  tasks_[0][iconn->fecCrate()-1]->fillHistograms( *summary, *digis );
626  } else {
627  std::stringstream ss;
628  ss << "[SiStripCommissioningSource::" << __func__ << "]"
629  << " Unable to find CommissioningTask for FEC crate "
630  << iconn->fecCrate() << ". Unable to fill histograms!";
631  edm::LogWarning(mlDqmSource_) << ss.str();
632  }
633  } else if (task_ == sistrip::FINE_DELAY) {
634  if ( tasks_[0][0] ) {
635  tasks_[0][0]->fillHistograms( *summary, *digis );
636  } else {
637  std::stringstream ss;
638  ss << "[SiStripCommissioningSource::" << __func__ << "]"
639  << " Unable to find global CommissioningTask for FineDelay. Unable to fill histograms!";
640  edm::LogWarning(mlDqmSource_) << ss.str();
641  }
642  // now do any other task
643  } else {
644  if ( tasks_[iconn->fedId()][iconn->fedCh()] ) {
645  tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms( *summary, *digis );
646  } else {
647  std::stringstream ss;
648  ss << "[SiStripCommissioningSource::" << __func__ << "]"
649  << " Unable to find CommissioningTask object with FED key "
650  << std::hex << std::setfill('0') << std::setw(8) << fed_key << std::dec
651  << " and FED id/ch "
652  << iconn->fedId() << "/"
653  << iconn->fedCh()
654  << " Unable to fill histograms!";
655  edm::LogWarning(mlDqmSource_) << ss.str();
656  }
657  }
658  } else {
659  // issue a warning only for standard runs, as latency and fine delay only deliver
660  // pseudo zero-suppressed data
661  if ( task_ != sistrip::APV_LATENCY &&
663  std::stringstream ss;
664  ss << "[SiStripCommissioningSource::" << __func__ << "]"
665  << " Unable to find any DetSet containing digis for FED key "
666  << std::hex << std::setfill('0') << std::setw(8) << fed_key << std::dec
667  << " and FED id/ch "
668  << iconn->fedId() << "/"
669  << iconn->fedCh();
670  edm::LogWarning(mlDqmSource_) << ss.str();
671  }
672  }
673  } // fed channel loop
674  } // fed id loop
675 
676 }
const std::vector< uint16_t > & feds() const
iterator find(det_id_type id)
Definition: DetSetVector.h:285
static const char mlDqmSource_[]
static const uint16_t valid_
Definition: Constants.h:18
iterator end()
Return the off-the-end iterator.
Definition: DetSetVector.h:356
static const uint16_t invalid_
Definition: Constants.h:17
const std::vector< FedChannelConnection > & connections(uint16_t fed_id) const
void SiStripCommissioningSource::remove ( )
private

Definition at line 1125 of file SiStripCommissioningSource.cc.

References DQMStore::cd(), CommonMethods::dirExists(), dqm(), DQMStore::removeContents(), DQMStore::rmdir(), and sistrip::root_.

1125  {
1126  dqm()->cd();
1127  dqm()->removeContents();
1128 
1129  if( dqm()->dirExists(sistrip::root_) ) {
1130  dqm()->rmdir(sistrip::root_);
1131  }
1132 }
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2311
DQMStore *const dqm(std::string method="") const
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:209
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
Definition: DQMStore.cc:2345
static const char root_[]

Member Data Documentation

std::string SiStripCommissioningSource::base_
private
bool SiStripCommissioningSource::cablingTask_
private

Flag to indicate whether task is FED cabling or not.

Definition at line 131 of file SiStripCommissioningSource.h.

Referenced by analyze(), beginRun(), and createTask().

TaskMap SiStripCommissioningSource::cablingTasks_
private

Map of cabling task objects (indexed using FEC key).

Definition at line 125 of file SiStripCommissioningSource.h.

Referenced by clearCablingTasks(), createCablingTasks(), endJob(), and fillCablingHistos().

DQMStore* SiStripCommissioningSource::dqm_
private

Interface to Data Quality Monitoring framework.

Definition at line 90 of file SiStripCommissioningSource.h.

Referenced by beginRun(), and dqm().

SiStripFecCabling* SiStripCommissioningSource::fecCabling_
private
SiStripFedCabling* SiStripCommissioningSource::fedCabling_
private
std::string SiStripCommissioningSource::filename_
private

Filename of output root file containing source histos.

Definition at line 105 of file SiStripCommissioningSource.h.

Referenced by createTasks(), and endJob().

std::string SiStripCommissioningSource::inputModuleLabel_
private

Name of digi input module.

Definition at line 101 of file SiStripCommissioningSource.h.

Referenced by analyze().

std::string SiStripCommissioningSource::inputModuleLabelSummary_
private

Definition at line 102 of file SiStripCommissioningSource.h.

Referenced by analyze().

edm::ParameterSet SiStripCommissioningSource::parameters_
private
uint32_t SiStripCommissioningSource::run_
private

Run number used for naming of root file.

Definition at line 108 of file SiStripCommissioningSource.h.

Referenced by analyze(), createRunNumber(), createTasks(), and endJob().

sistrip::RunType SiStripCommissioningSource::task_
private

Identifies commissioning task.

Definition at line 119 of file SiStripCommissioningSource.h.

Referenced by analyze(), beginRun(), createCablingTasks(), createTask(), createTasks(), endJob(), and fillHistos().

std::string SiStripCommissioningSource::taskConfigurable_
private

Identifies commissioning task read from cfg file.

Definition at line 116 of file SiStripCommissioningSource.h.

Referenced by createTask().

VecOfVecOfTasks SiStripCommissioningSource::tasks_
private

Vector of vector of task objects (indexed using FED id.ch.

Definition at line 122 of file SiStripCommissioningSource.h.

Referenced by clearTasks(), createTasks(), endJob(), fillHistos(), and SiStripCommissioningSource().

bool SiStripCommissioningSource::tasksExist_
private

Flag to indicate whether histo objects exist or not.

Definition at line 128 of file SiStripCommissioningSource.h.

Referenced by analyze(), beginRun(), and createTask().

int32_t SiStripCommissioningSource::time_
private

Record of time used to calculate event rate.

Definition at line 111 of file SiStripCommissioningSource.h.

Referenced by analyze().

int SiStripCommissioningSource::updateFreq_
private

Update frequency for histograms (ignored for cabling).

Definition at line 134 of file SiStripCommissioningSource.h.

Referenced by analyze(), and createTasks().

std::string SiStripCommissioningSource::view_
private

flag for choosing the organizational 'view' the DQM histogram tree

Definition at line 140 of file SiStripCommissioningSource.h.

Referenced by createTasks().