CMS 3D CMS Logo

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 edm::EDConsumerBase

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
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginRun (edm::Run const &, const edm::EventSetup &) override
 
void endJob () override
 
 SiStripCommissioningSource (const edm::ParameterSet &)
 
 ~SiStripCommissioningSource () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

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 ()=delete
 

Private Attributes

std::string base_
 
bool cablingTask_
 
TaskMap cablingTasks_
 
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiFineDelaySelectionToken_
 
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiScopeModeToken_
 
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiVirginRawToken_
 
DQMStoredqm_
 
SiStripFecCablingfecCabling_
 
SiStripFedCablingfedCabling_
 
std::string filename_
 
std::string inputModuleLabel_
 
std::string inputModuleLabelSummary_
 
edm::EDGetTokenT< SiStripEventSummaryinputModuleSummaryToken_
 
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)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 27 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 32 of file SiStripCommissioningSource.h.

Definition at line 33 of file SiStripCommissioningSource.h.

Definition at line 34 of file SiStripCommissioningSource.h.

Constructor & Destructor Documentation

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

Definition at line 55 of file SiStripCommissioningSource.cc.

References digiFineDelaySelectionToken_, digiScopeModeToken_, digiVirginRawToken_, inputModuleLabel_, inputModuleLabelSummary_, inputModuleSummaryToken_, LogTrace, sistrip::mlDqmSource_, and tasks_.

55  :
56  dqm_(nullptr),
57  fedCabling_(nullptr),
58  fecCabling_(nullptr),
59  inputModuleLabel_( pset.getParameter<std::string>( "InputModuleLabel" ) ),
60  inputModuleLabelSummary_( pset.getParameter<std::string>( "SummaryInputModuleLabel" ) ),
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 {
75  inputModuleSummaryToken_ = consumes<SiStripEventSummary>(edm::InputTag(inputModuleLabelSummary_) );
76  digiVirginRawToken_ = mayConsume<edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_,"VirginRaw") );
77  digiScopeModeToken_ = mayConsume<edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_,"ScopeMode") );
78  digiFineDelaySelectionToken_ = mayConsume<edm::DetSetVector<SiStripRawDigi> >(edm::InputTag(inputModuleLabel_,"FineDelaySelection") );
79 
81  << "[SiStripCommissioningSource::" << __func__ << "]"
82  << " Constructing object...";
83  tasks_.clear();
84  tasks_.resize( 1024, VecOfTasks(96,static_cast<CommissioningTask*>(nullptr)) );
85 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiVirginRawToken_
static const char mlDqmSource_[]
std::vector< CommissioningTask * > VecOfTasks
static const char dqmSourceFileName_[]
#define LogTrace(id)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiFineDelaySelectionToken_
edm::EDGetTokenT< SiStripEventSummary > inputModuleSummaryToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiScopeModeToken_
SiStripCommissioningSource::~SiStripCommissioningSource ( )
override

Definition at line 89 of file SiStripCommissioningSource.cc.

References LogTrace, and sistrip::mlDqmSource_.

89  {
91  << "[SiStripCommissioningSource::" << __func__ << "]"
92  << " Destructing object...";
93 }
static const char mlDqmSource_[]
#define LogTrace(id)
SiStripCommissioningSource::SiStripCommissioningSource ( )
privatedelete

Private default constructor.

Member Function Documentation

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

Definition at line 262 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, digiFineDelaySelectionToken_, digiScopeModeToken_, digiVirginRawToken_, edm::EventID::event(), sistrip::FAST_CABLING, sistrip::FED_CABLING, sistrip::FED_SCOPE_MODE, sistrip::FED_TIMING, sistrip::FED_VIRGIN_RAW, SiStripEnumsAndStrings::fedReadoutMode(), SiStripEventSummary::fedReadoutMode(), fillCablingHistos(), fillHistos(), sistrip::FINE_DELAY, edm::EventBase::id(), inputModuleSummaryToken_, sistrip::mlDqmSource_, sistrip::NOISE, SiStripEventSummary::nullParams(), sistrip::OPTO_SCAN, sistrip::PEDESTALS, sistrip::PEDS_FULL_NOISE, sistrip::PEDS_ONLY, edm::Handle< T >::product(), edm::EventID::run(), run_, SiStripEnumsAndStrings::runType(), SiStripEventSummary::runType(), GeneralSetup::setup(), heppy_report::summary, task_, tasksExist_, ntuplemaker::time, time_, sistrip::UNDEFINED_RUN_TYPE, sistrip::UNKNOWN_RUN_TYPE, updateFreq_, and sistrip::VPSP_SCAN.

263  {
264  // Retrieve commissioning information from "event summary"
266  // event.getByLabel( inputModuleLabelSummary_, summary );
267  event.getByToken( inputModuleSummaryToken_,summary );
268 
269  // Check if EventSummary has info attached
270  if ( ( summary->runType() == sistrip::UNDEFINED_RUN_TYPE ||
271  summary->runType() == sistrip::UNKNOWN_RUN_TYPE ) &&
272  summary->nullParams() ) {
274  << "[SiStripCommissioningSource::" << __func__ << "]"
275  << " Unknown/undefined RunType and NULL parameter values!"
276  << " It may be that the 'trigger FED' object was not found!";
277  }
278 
279  // Check if need to rebuild FED/FEC cabling objects for connection run
280  //cablingForConnectionRun( summary->runType() ); //@@ do not use!
281 
282  // Extract run number and forward to client
283  if ( event.id().run() != run_ ) {
284  run_ = event.id().run();
285  createRunNumber();
286  }
287 
288  // Coarse event rate counter
289  if ( !(event.id().event()%updateFreq_) ) {
290  std::stringstream ss;
291  ss << "[SiStripCommissioningSource::" << __func__ << "]"
292  << " The last " << updateFreq_
293  << " events were processed at a rate of ";
294  if ( time(nullptr) == time_ ) { ss << ">" << updateFreq_ << " Hz"; }
295  else { ss << (updateFreq_/(time(nullptr)-time_)) << " Hz"; }
296  edm::LogVerbatim(mlDqmSource_) << ss.str();
297  time_ = time(nullptr);
298  }
299 
300  // Create commissioning task objects
301  if ( !tasksExist_ ) { createTask( summary.product(), setup ); }
302 
303  // Retrieve raw digis with mode appropriate to task
305  if ( task_ == sistrip::DAQ_SCOPE_MODE ) {
306  if ( summary->fedReadoutMode() == FED_VIRGIN_RAW ) {
307  // event.getByLabel( inputModuleLabel_, "VirginRaw", raw );
308  event.getByToken( digiVirginRawToken_, raw );
309  } else if ( summary->fedReadoutMode() == FED_SCOPE_MODE ) {
310  // event.getByLabel( inputModuleLabel_, "ScopeMode", raw );
311  event.getByToken( digiScopeModeToken_, raw );
312  } else {
313  std::stringstream ss;
314  ss << "[SiStripCommissioningSource::" << __func__ << "]"
315  << " Requested DAQ_SCOPE_MODE but unknown FED"
316  << " readout mode retrieved from SiStripEventSummary: "
318  edm::LogWarning(mlDqmSource_) << ss.str();
319  }
320  } else if ( task_ == sistrip::FAST_CABLING ||
324  task_ == sistrip::OPTO_SCAN ) {
325  // event.getByLabel( inputModuleLabel_, "ScopeMode", raw );
326  event.getByToken( digiScopeModeToken_, raw );
327  } else if ( task_ == sistrip::VPSP_SCAN ||
334  task_ == sistrip::NOISE ||
336  // event.getByLabel( inputModuleLabel_, "VirginRaw", raw );
337  event.getByToken( digiVirginRawToken_, raw );
338  } else if ( task_ == sistrip::APV_LATENCY ||
340  // event.getByLabel( inputModuleLabel_, "FineDelaySelection", raw );
341  event.getByToken( digiFineDelaySelectionToken_, raw );
342  } else {
343  std::stringstream ss;
344  ss << "[SiStripCommissioningSource::" << __func__ << "]"
345  << " Unknown CommissioningTask: "
347  << " Unable to establish FED readout mode and retrieve digi container!"
348  << " Check if SiStripEventSummary object is found/present in Event";
349  edm::LogWarning(mlDqmSource_) << ss.str();
350  return;
351  }
352 
353  // Check for NULL pointer to digi container
354  if ( &(*raw) == nullptr ) {
355  std::stringstream ss;
356  ss << "[SiStripCommissioningSource::" << __func__ << "]" << std::endl
357  << " NULL pointer to DetSetVector!" << std::endl
358  << " Unable to fill histograms!";
359  edm::LogWarning(mlDqmSource_) << ss.str();
360  return;
361  }
362 
363  if ( !cablingTask_ ) { fillHistos( summary.product(), *raw ); }
364  else { fillCablingHistos( summary.product(), *raw ); }
365 
366 }
RunNumber_t run() const
Definition: EventID.h:39
EventNumber_t event() const
Definition: EventID.h:41
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiVirginRawToken_
void createTask(const SiStripEventSummary *const, const edm::EventSetup &)
static const char mlDqmSource_[]
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
static std::string runType(const sistrip::RunType &)
const sistrip::RunType & runType() const
void fillCablingHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiFineDelaySelectionToken_
const sistrip::FedReadoutMode & fedReadoutMode() const
edm::EDGetTokenT< SiStripEventSummary > inputModuleSummaryToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiScopeModeToken_
edm::EventID id() const
Definition: EventBase.h:60
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 
)
override

Definition at line 112 of file SiStripCommissioningSource.cc.

References base_, cablingTask_, clearCablingTasks(), clearTasks(), SiStripFecCabling::crates(), dir, dqm(), dqm_, fecCabling_, fedCabling_, SiStripFedCabling::fedIds(), edm::EventSetup::get(), LogDebug, LogTrace, sistrip::mlDqmSource_, Utilities::operator, edm::ESHandle< T >::product(), task_, tasksExist_, and sistrip::UNDEFINED_RUN_TYPE.

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

Definition at line 1106 of file SiStripCommissioningSource.cc.

References cablingTasks_.

Referenced by beginRun().

1106  {
1107  if ( cablingTasks_.empty() ) { return; }
1108  for ( TaskMap::iterator itask = cablingTasks_.begin(); itask != cablingTasks_.end(); itask++ ) {
1109  if ( itask->second ) { delete itask->second; }
1110  }
1111  cablingTasks_.clear();
1112 }
void SiStripCommissioningSource::clearTasks ( )
private

Definition at line 1116 of file SiStripCommissioningSource.cc.

References tasks_.

Referenced by beginRun().

1116  {
1117  if ( tasks_.empty() ) { return; }
1118  VecOfVecOfTasks::iterator ifed = tasks_.begin();
1119  for ( ; ifed != tasks_.end(); ifed++ ) {
1120  VecOfTasks::iterator ichan = ifed->begin();
1121  for ( ; ichan != ifed->end(); ichan++ ) {
1122  if ( *ichan ) { delete *ichan; *ichan = nullptr; }
1123  }
1124  ifed->resize(96,nullptr);
1125  }
1126  tasks_.resize(1024);
1127 }
void SiStripCommissioningSource::createCablingTasks ( )
private

Definition at line 797 of file SiStripCommissioningSource.cc.

References base_, cablingTasks_, SiStripFecCabling::crates(), TauDecayModes::dec, dir, dqm(), fecCabling_, sistrip::FED_CABLING, crabWrapper::key, sistrip::mlDqmSource_, callgraph::path, SiStripEnumsAndStrings::runType(), AlCaHLTBitMon_QueryRunRegistry::string, task_, sistrip::UNDEFINED_RUN_TYPE, and sistrip::UNKNOWN_RUN_TYPE.

Referenced by createTask().

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

Definition at line 688 of file SiStripCommissioningSource.cc.

References base_, dqm(), sistrip::mlDqmSource_, sistrip::root_, findQualityFiles::run, run_, sistrip::runNumber_, sistrip::sep_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze().

688  {
689 
690  // Set commissioning task to default ("undefined") value
691  if ( !run_ ) {
693  << "[SiStripCommissioningSource::" << __func__ << "]"
694  << " NULL run number!";
695  return;
696  }
697 
698  // Create MonitorElement that identifies run number
699  dqm()->setCurrentFolder( base_ + sistrip::root_ );
700  std::stringstream run;
701  run << run_;
702  dqm()->bookString( std::string(sistrip::runNumber_) + sistrip::sep_ + run.str(), run.str() );
703 
704 }
static const char runNumber_[]
DQMStore *const dqm(std::string method="") const
static const char mlDqmSource_[]
static const char sep_[]
static const char root_[]
void SiStripCommissioningSource::createTask ( const SiStripEventSummary * const  summary,
const edm::EventSetup setup 
)
private

Definition at line 708 of file SiStripCommissioningSource.cc.

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

Referenced by analyze().

708  {
709 
710  // Set commissioning task to default ("undefined") value
712 
713  // Retrieve commissioning task from EventSummary
714  if ( summary ) {
715  task_ = summary->runType();
716  std::stringstream ss;
717  ss << "[SiStripCommissioningSource::" << __func__ << "]"
718  << " Identified CommissioningTask from EventSummary to be \""
720  << "\"";
721  LogTrace(mlDqmSource_) << ss.str();
722  } else {
724  std::stringstream ss;
725  ss << "[SiStripCommissioningSource::" << __func__ << "]"
726  << " NULL pointer to SiStripEventSummary!"
727  << " Check SiStripEventSummary is found/present in Event";
728  edm::LogWarning(mlDqmSource_) << ss.str();
729  }
730 
731  // Override task with ParameterSet configurable (if defined)
733  if ( configurable != sistrip::UNDEFINED_RUN_TYPE &&
734  configurable != sistrip::UNKNOWN_RUN_TYPE ) {
735  std::stringstream ss;
736  ss << "[SiStripCommissioningSource::" << __func__ << "]"
737  << " Overriding CommissioningTask from EventSummary (\""
739  << "\") with value retrieved from .cfg file (\""
740  << SiStripEnumsAndStrings::runType( configurable )
741  << "\")!";
742  LogTrace(mlDqmSource_) << ss.str();
743  task_ = configurable;
744  }
745 
746  // Create ME (std::string) that identifies commissioning task
747  dqm()->setCurrentFolder( base_ + sistrip::root_ );
749  dqm()->bookString( std::string(sistrip::taskId_) + sistrip::sep_ + task_str, task_str );
750 
751  // Check commissioning task is known / defined
754  std::stringstream ss;
755  ss << "[SiStripCommissioningSource::" << __func__ << "]"
756  << " Unexpected CommissioningTask found ("
757  << static_cast<uint16_t>(task_) << ") \""
759  << " Unexpected value found in SiStripEventSummary and/or cfg file"
760  << " If SiStripEventSummary is not present in Event,"
761  << " check 'CommissioningTask' configurable in cfg file";
762  edm::LogWarning(mlDqmSource_) << ss.str();
763  return;
764  } else {
765  std::stringstream ss;
766  ss << "[SiStripCommissioningSource::" << __func__ << "]"
767  << " Identified CommissioningTask to be \""
769  << "\"";
770  LogTrace(mlDqmSource_) << ss.str();
771  }
772 
773  // Check if commissioning task is FED cabling
774  if ( task_ == sistrip::FED_CABLING ) { cablingTask_ = true; }
775  else { cablingTask_ = false; }
776 
777  std::stringstream ss;
778  ss << "[SiStripCommissioningSource::" << __func__ << "]"
779  << " CommissioningTask: "
780  << SiStripEnumsAndStrings::runType( summary->runType() );
781  LogTrace(mlDqmSource_) << ss.str();
782 
784  << "[SiStripCommissioningSource::" << __func__ << "]"
785  << " Creating CommissioningTask objects and booking histograms...";
786  if ( cablingTask_ ) { createCablingTasks(); }
787  else { createTasks( task_ , setup ); }
789  << "[SiStripCommissioningSource::" << __func__ << "]"
790  << " Finished booking histograms!";
791  tasksExist_ = true;
792 
793 }
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_[]
static const char taskId_[]
#define LogTrace(id)
static const char root_[]
void SiStripCommissioningSource::createTasks ( sistrip::RunType  run_type,
const edm::EventSetup setup 
)
private

Definition at line 935 of file SiStripCommissioningSource.cc.

References sistrip::APV_LATENCY, sistrip::APV_TIMING, base_, sistrip::CALIBRATION, sistrip::CALIBRATION_DECO, sistrip::CALIBRATION_SCAN, sistrip::CALIBRATION_SCAN_DECO, sistrip::DAQ_SCOPE_MODE, TauDecayModes::dec, sistrip::detectorView_, dir, sistrip::dir_, dqm(), sistrip::FAST_CABLING, SiStripFedKey::feChan(), sistrip::FED_TIMING, fedCabling_, SiStripFedCabling::fedConnections(), SiStripFedCabling::fedIds(), 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_, GeneralSetup::setup(), task_, tasks_, sistrip::UNDEFINED_RUN_TYPE, updateFreq_, view_, and sistrip::VPSP_SCAN.

Referenced by createTask().

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

Definition at line 1142 of file SiStripCommissioningSource.cc.

References hcalSimParameters_cfi::he, sysUtil::pid, AlCaHLTBitMon_QueryRunRegistry::string, and tmp.

Referenced by endJob().

1143  {
1144 
1145  // Get details about host
1146  char hn[256];
1147  gethostname( hn, sizeof(hn) );
1148  struct hostent* he;
1149  he = gethostbyname(hn);
1150 
1151  // Extract host name and ip
1152  std::string host_name;
1153  std::string host_ip;
1154  if ( he ) {
1155  host_name = std::string(he->h_name);
1156  host_ip = std::string( inet_ntoa( *(struct in_addr*)(he->h_addr) ) );
1157  } else {
1158  host_name = "unknown.cern.ch";
1159  host_ip = "255.255.255.255";
1160  }
1161 
1162  // Reformat IP address
1164  std::stringstream ip;
1165  //for ( uint16_t ii = 0; ii < 4; ++ii ) {
1166  while ( pos != std::string::npos ) {
1167  std::string::size_type tmp = host_ip.find(".",pos);
1168  if ( tmp != std::string::npos ) {
1169  ip << std::setw(3)
1170  << std::setfill('0')
1171  << host_ip.substr( pos, tmp-pos )
1172  << ".";
1173  pos = tmp+1; // skip the delimiter "."
1174  } else {
1175  ip << std::setw(3)
1176  << std::setfill('0')
1177  << host_ip.substr( pos );
1178  pos = std::string::npos;
1179  }
1180  }
1181 
1182  // Get pid
1183  pid_t pid = getpid();
1184 
1185  // Construct string
1186  if ( run_number ) {
1187  dir << std::setw(8)
1188  << std::setfill('0')
1189  << run_number
1190  << "_";
1191  }
1192  dir << ip.str()
1193  << "_"
1194  << std::setw(5)
1195  << std::setfill('0')
1196  << pid;
1197 
1198 }
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 97 of file SiStripCommissioningSource.cc.

References dqm_, and sistrip::mlDqmSource_.

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

97  {
98  if ( !dqm_ ) {
99  std::stringstream ss;
100  if ( method != "" ) { ss << "[SiStripCommissioningSource::" << method << "]" << std::endl; }
101  else { ss << "[SiStripCommissioningSource]" << std::endl; }
102  ss << " NULL pointer to DQMStore";
103  edm::LogWarning(mlDqmSource_) << ss.str();
104  return nullptr;
105  } else { return dqm_; }
106 }
static const char mlDqmSource_[]
void SiStripCommissioningSource::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 164 of file SiStripCommissioningSource.cc.

References sistrip::APV_LATENCY, cablingTasks_, dir, directory(), dqm(), fecCabling_, fedCabling_, SiStripFedCabling::fedConnections(), SiStripFedCabling::fedIds(), filename_, sistrip::FINE_DELAY, LogTrace, sistrip::mlDqmSource_, dataset::name, run_, AlCaHLTBitMon_QueryRunRegistry::string, task_, and tasks_.

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

Definition at line 370 of file SiStripCommissioningSource.cc.

References cablingTasks_, sistrip::CCU_CHAN, SiStripFecKey::ccuAddr(), SiStripFecKey::ccuChan(), SiStripKey::channel(), SiStripEventSummary::dcuId(), TauDecayModes::dec, SiStripEventSummary::deviceId(), edm::DetSetVector< T >::end(), fecCabling_, SiStripFecKey::fecCrate(), SiStripFecKey::fecRing(), SiStripFecKey::fecSlot(), fedCabling_, SiStripFedCabling::fedIds(), edm::DetSetVector< T >::find(), cuy::ii, sistrip::invalid_, findQualityFiles::jj, SiStripKey::key(), SiStripModule::key(), LogTrace, Averages::Params::median_, sistrip::mlDqmSource_, sistrip::mlTest_, SiStripFecCabling::module(), callgraph::path, Averages::Params::rms_, and tmp.

Referenced by analyze().

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

Definition at line 603 of file SiStripCommissioningSource.cc.

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

Referenced by analyze().

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

Definition at line 1131 of file SiStripCommissioningSource.cc.

References CommonMethods::dirExists(), dqm(), and sistrip::root_.

1131  {
1132  dqm()->cd();
1133  dqm()->removeContents();
1134 
1135  if( dqm()->dirExists(sistrip::root_) ) {
1136  dqm()->rmdir(sistrip::root_);
1137  }
1138 }
def dirExists(dir)
DQMStore *const dqm(std::string method="") const
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 136 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 130 of file SiStripCommissioningSource.h.

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

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > SiStripCommissioningSource::digiFineDelaySelectionToken_
private

Definition at line 103 of file SiStripCommissioningSource.h.

Referenced by analyze(), and SiStripCommissioningSource().

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > SiStripCommissioningSource::digiScopeModeToken_
private

Definition at line 102 of file SiStripCommissioningSource.h.

Referenced by analyze(), and SiStripCommissioningSource().

edm::EDGetTokenT<edm::DetSetVector<SiStripRawDigi> > SiStripCommissioningSource::digiVirginRawToken_
private

Definition at line 101 of file SiStripCommissioningSource.h.

Referenced by analyze(), and SiStripCommissioningSource().

DQMStore* SiStripCommissioningSource::dqm_
private

Interface to Data Quality Monitoring framework.

Definition at line 91 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 110 of file SiStripCommissioningSource.h.

Referenced by createTasks(), and endJob().

std::string SiStripCommissioningSource::inputModuleLabel_
private

Name of digi input module.

Definition at line 106 of file SiStripCommissioningSource.h.

Referenced by SiStripCommissioningSource().

std::string SiStripCommissioningSource::inputModuleLabelSummary_
private

Definition at line 107 of file SiStripCommissioningSource.h.

Referenced by SiStripCommissioningSource().

edm::EDGetTokenT<SiStripEventSummary> SiStripCommissioningSource::inputModuleSummaryToken_
private

Definition at line 100 of file SiStripCommissioningSource.h.

Referenced by analyze(), and SiStripCommissioningSource().

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

Run number used for naming of root file.

Definition at line 113 of file SiStripCommissioningSource.h.

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

sistrip::RunType SiStripCommissioningSource::task_
private

Identifies commissioning task.

Definition at line 124 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 121 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 127 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 133 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 116 of file SiStripCommissioningSource.h.

Referenced by analyze().

int SiStripCommissioningSource::updateFreq_
private

Update frequency for histograms (ignored for cabling).

Definition at line 139 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 145 of file SiStripCommissioningSource.h.

Referenced by createTasks().