39 #include <sys/types.h> 43 #include <arpa/inet.h> 46 #include <sys/socket.h> 47 #include <sys/unistd.h> 58 inputModuleLabel_(pset.getParameter<
std::
string>(
"InputModuleLabel")),
59 inputModuleLabelAlt_(pset.existsAs<
std::
string>(
"InputModuleLabelAlt")
60 ? pset.getParameter<
std::
string>(
"InputModuleLabelAlt")
62 inputModuleLabelSummary_(pset.getParameter<
std::
string>(
"SummaryInputModuleLabel")),
64 pset.existsAs<
std::
string>(
"InputClusterLabel") ? pset.getParameter<
std::
string>(
"InputClusterLabel") :
""),
67 partitionName_(pset.existsAs<
std::
string>(
"PartitionName") ? pset.getParameter<
std::
string>(
"PartitionName")
70 isSpy_(pset.existsAs<
bool>(
"isSpy") ? pset.getParameter<
bool>(
"isSpy") :
false),
71 taskConfigurable_(pset.getUntrackedParameter<
std::
string>(
"CommissioningTask",
"UNDEFINED")),
77 updateFreq_(pset.getUntrackedParameter<
int>(
"HistoUpdateFreq", 1)),
79 view_(pset.getUntrackedParameter<
std::
string>(
"View",
"Default")),
96 <<
" Constructing object...";
98 tasks_.resize(1024,
VecOfTasks(96, static_cast<CommissioningTask*>(
nullptr)));
105 <<
" Destructing object...";
112 std::stringstream
ss;
113 if (!method.empty()) {
114 ss <<
"[SiStripCommissioningSource::" << method <<
"]" << std::endl;
116 ss <<
"[SiStripCommissioningSource]" << std::endl;
118 ss <<
" NULL pointer to DQMStore";
132 <<
" Configuring..." << std::endl;
138 <<
" DQMStore service: " <<
dqm_;
143 std::stringstream
dir(
"");
152 <<
"Initialized FED cabling. Number of FEDs is " <<
fedCabling_->
fedIds().size();
155 std::stringstream
ss;
156 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 157 <<
" Empty std::vector returned by FEC cabling object!" 158 <<
" Check if database connection failed...";
178 <<
" Halting..." << std::endl;
184 itask->second->updateHistograms();
189 for (uint16_t partition = 0; partition < 4; ++partition) {
190 tasks_[0][partition]->updateHistograms();
193 tasks_[0][0]->updateHistograms();
201 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
202 if (!iconn->isConnected()) {
205 fed_id = iconn->fedId();
206 fed_ch = iconn->fedCh();
207 if (
tasks_[fed_id][fed_ch]) {
208 tasks_[fed_id][fed_ch]->updateHistograms();
209 delete tasks_[fed_id][fed_ch];
218 if (
filename_.find(
".root", 0) == std::string::npos) {
227 if (std::getenv(scratch.c_str()) !=
nullptr) {
228 dir = std::getenv(scratch.c_str());
232 std::stringstream
ss;
253 <<
" NULL value for RunNumber! No root file saved!";
257 <<
" NULL value for filename! No root file saved!";
261 <<
" Saved all histograms to file \"" << ss.str() <<
"\"";
293 <<
" Unknown/undefined RunType and NULL parameter values!" 294 <<
" It may be that the 'trigger FED' object was not found!";
302 run_ =
event.id().run();
308 std::stringstream
ss;
309 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 310 <<
" The last " <<
updateFreq_ <<
" events were processed at a rate of ";
312 ss <<
">" << updateFreq_ <<
" Hz";
314 ss << (updateFreq_ / (
time(
nullptr) -
time_)) <<
" Hz";
326 t->eventSetup(&setup);
348 std::stringstream
ss;
349 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 350 <<
" Requested DAQ_SCOPE_MODE but unknown FED" 351 <<
" readout mode retrieved from SiStripEventSummary: " 366 std::stringstream
ss;
367 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 369 <<
" Unable to establish FED readout mode and retrieve digi container!" 370 <<
" Check if SiStripEventSummary object is found/present in Event";
377 std::stringstream
ss;
378 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" << std::endl
379 <<
" NULL pointer to DetSetVector!" << std::endl
380 <<
" Unable to fill histograms!";
386 std::stringstream
ss;
387 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" << std::endl
388 <<
" NULL pointer to DetSetVector!" << std::endl
389 <<
" Unable to fill histograms!";
395 std::stringstream
ss;
396 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" << std::endl
397 <<
" NULL pointer to DetSetVector!" << std::endl
398 <<
" Unable to fill histograms!";
416 uint16_t lld_channel = (summary->
deviceId() & 0x3) + 1;
423 uint32_t fec_key = key_object.
key();
424 std::stringstream sss;
425 sss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 426 <<
" Found DcuId 0x" << std::hex << std::setw(8) << std::setfill(
'0') << summary->
dcuId() <<
std::dec 427 <<
" with Crate/FEC/Ring/CCU/Module/LLD: " << module.
key().
fecCrate() <<
"/" << module.
key().
fecSlot() <<
"/" 435 std::stringstream
ss;
436 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 437 <<
" DcuId 0x" << std::hex << std::setw(8) << std::setfill(
'0') << summary->
dcuId() <<
std::dec 438 <<
" in 'DAQ register' field not found in cabling map!" 439 <<
" (NULL values returned for FEC path)";
452 std::map<uint16_t, float> medians;
454 std::map<uint16_t, float> medians1;
458 for (uint16_t ichan = 0; ichan < 96; ichan++) {
462 std::vector<edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.
find(fed_key);
463 if (digis != raw.
end()) {
464 if (digis->data.empty()) {
469 for (uint16_t idigi = 0; idigi < digis->data.size(); idigi++) {
470 ave.add(static_cast<uint32_t>(digis->data[idigi].adc()));
474 medians[ichan] = params.
median_;
475 medians1[ichan] = digis->data[0].adc();
482 std::map<uint16_t, float>::const_iterator
ii = medians.begin();
483 for (; ii != medians.end(); ii++) {
484 average.add(ii->second);
489 std::stringstream
ss;
490 ss <<
"FED Averages:" << std::endl
491 <<
" nChans: " << medians.size() << std::endl
492 <<
" num/mean/median/rms/max/min: " << tmp.
num_ <<
"/" << tmp.
mean_ <<
"/" << tmp.
median_ <<
"/" << tmp.
rms_ 493 <<
"/" << tmp.
max_ <<
"/" << tmp.
min_ << std::endl;
498 std::map<uint16_t, float>::const_iterator
jj = medians.begin();
499 for (; jj != medians.end(); jj++) {
501 truncated.add(jj->second);
505 truncated.calc(params);
507 std::stringstream ss1;
508 ss1 <<
"Truncated Averages:" << std::endl
509 <<
" nChans: " << medians.size() << std::endl
510 <<
" num/mean/median/rms/max/min: " << params.
num_ <<
"/" << params.
mean_ <<
"/" << params.
median_ <<
"/" 511 << params.
rms_ <<
"/" << params.
max_ <<
"/" << params.
min_ << std::endl;
515 std::stringstream ss2;
516 std::stringstream ss3;
518 std::map<uint16_t, float>::const_iterator ichan = medians.begin();
519 for (; ichan != medians.end(); ichan++) {
520 if (ichan->second > 200.) {
521 LogTrace(
mlTest_) <<
"TEST FOUND SIGNAL HIGH: " << *ifed <<
" " << ichan->first <<
" " << ichan->second;
522 channels[ichan->first] = ichan->second;
525 << ichan->second <<
" ";
527 << medians1[ichan->first] <<
" ";
537 if (!channels.empty()) {
538 cablingTasks_[fec_key]->fillHistograms(*summary, *ifed, channels);
540 std::stringstream
ss;
541 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 542 <<
" Filled histogram for '" <<
cablingTasks_[fec_key]->myName() <<
"' object with FecKey: 0x" << std::hex
543 << std::setfill(
'0') << std::setw(8) << fec_key <<
std::dec 544 <<
" and Crate/FEC/ring/CCU/module/LLDchan: " << path.
fecCrate() <<
"/" << path.
fecSlot() <<
"/" 550 std::stringstream
ss;
551 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 552 <<
" Unable to find CommissioningTask object with FecKey: 0x" << std::hex << std::setfill(
'0') << std::setw(8)
553 << fec_key <<
std::dec <<
" and Crate/FEC/ring/CCU/module/LLDchan: " << path.
fecCrate() <<
"/" 569 std::vector<uint16_t> stripOnClusters;
574 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
578 if (!iconn->isConnected()) {
587 std::vector<edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.
find(fed_key);
590 std::vector<edm::DetSet<SiStripRawDigi> >::const_iterator digisAlt;
591 if (not rawAlt.
empty()) {
592 digisAlt = rawAlt.
find(fed_key);
593 if (digisAlt == rawAlt.
end())
598 stripOnClusters.clear();
599 if (not clusters.
empty()) {
602 if (DSViter->id() != iconn->detId())
606 if (DSiter->firstStrip() >= iconn->apvPairNumber() * 256 and
607 DSiter->firstStrip() < (1 + iconn->apvPairNumber()) * 256) {
608 for (
size_t istrip = 0; istrip < DSiter->amplitudes().size(); istrip++) {
609 stripOnClusters.push_back(DSiter->firstStrip() + istrip - iconn->apvPairNumber() * 256);
616 if (digis != raw.
end()) {
619 if (
tasks_[0][iconn->fecCrate() - 1]) {
620 tasks_[0][iconn->fecCrate() - 1]->fillHistograms(*summary, *digis);
622 std::stringstream
ss;
623 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 624 <<
" Unable to find CommissioningTask for FEC crate " << iconn->fecCrate()
625 <<
". Unable to fill histograms!";
630 tasks_[0][0]->fillHistograms(*summary, *digis);
632 std::stringstream
ss;
633 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 634 <<
" Unable to find global CommissioningTask for FineDelay. Unable to fill histograms!";
638 if (
tasks_[iconn->fedId()][iconn->fedCh()]) {
639 if (not rawAlt.
empty()
or digisAlt == rawAlt.
end())
640 tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms(*summary, *digis);
642 if (stripOnClusters.empty())
643 tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms(*summary, *digis, *digisAlt);
645 tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms(*summary, *digis, *digisAlt, stripOnClusters);
649 std::stringstream
ss;
650 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 651 <<
" Unable to find CommissioningTask object with FED key " << std::hex << std::setfill(
'0')
652 << std::setw(8) << fed_key <<
std::dec <<
" and FED id/ch " << iconn->fedId() <<
"/" << iconn->fedCh()
653 <<
" Unable to fill histograms!";
661 std::stringstream
ss;
662 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 663 <<
" Unable to find any DetSet containing digis for FED key " << std::hex << std::setfill(
'0')
664 << std::setw(8) << fed_key <<
std::dec <<
" and FED id/ch " << iconn->fedId() <<
"/" << iconn->fedCh();
678 <<
" NULL run number!";
684 std::stringstream
run;
698 std::stringstream
ss;
699 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 704 std::stringstream
ss;
705 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 706 <<
" NULL pointer to SiStripEventSummary!" 707 <<
" Check SiStripEventSummary is found/present in Event";
714 std::stringstream
ss;
715 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 719 task_ = configurable;
729 std::stringstream
ss;
730 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 731 <<
" Unexpected CommissioningTask found (" <<
static_cast<uint16_t
>(
task_) <<
") \"" 733 <<
" Unexpected value found in SiStripEventSummary and/or cfg file" 734 <<
" If SiStripEventSummary is not present in Event," 735 <<
" check 'CommissioningTask' configurable in cfg file";
739 std::stringstream
ss;
740 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 752 std::stringstream
ss;
753 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 758 <<
" Creating CommissioningTask objects and booking histograms...";
765 <<
" Finished booking histograms!";
774 for (std::vector<SiStripFecCrate>::const_iterator icrate =
fecCabling_->
crates().begin();
777 for (std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++) {
778 for (std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end();
780 for (std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end();
782 for (std::vector<SiStripModule>::const_iterator imodule = iccu->modules().begin();
783 imodule != iccu->modules().end();
787 icrate->fecCrate(), ifec->fecSlot(), iring->fecRing(), iccu->ccuAddr(), imodule->ccuChan());
790 if (!
path.isValid()) {
799 for (uint16_t ipair = 0; ipair < imodule->nApvPairs(); ipair++) {
813 imodule->nApvPairs());
821 imodule->lldChannel(ipair))
827 <<
" Unexpected NULL value for FEC key!";
837 <<
" Undefined CommissioningTask" 838 <<
" Unable to create FedCablingTask object!";
841 <<
" Unknown CommissioningTask" 842 <<
" Unable to create FedCablingTask object!";
845 <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 847 <<
" Unable to create FedCablingTask object!";
856 std::stringstream
ss;
857 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 858 <<
" Booking histograms for '" <<
cablingTasks_[
key]->myName() <<
"' object with key 0x" 859 << std::hex << std::setfill(
'0') << std::setw(8) << key <<
std::dec <<
" in directory \"" << dir
863 std::stringstream
ss;
864 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 865 <<
" NULL pointer to CommissioningTask for key 0x" << std::hex << std::setfill(
'0')
866 << std::setw(8) << key <<
std::dec <<
" in directory " << dir <<
" Unable to book histograms!";
870 std::stringstream
ss;
871 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 872 <<
" Unable to find CommissioningTask for key 0x" << std::hex << std::setfill(
'0') << std::setw(8)
873 << key <<
std::dec <<
" in directory " << dir <<
" Unable to book histograms!";
878 std::stringstream
ss;
879 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 880 <<
" CommissioningTask object already exists for key 0x" << std::hex << std::setfill(
'0')
881 << std::setw(8) << key <<
std::dec <<
" in directory " << dir
882 <<
" Unable to create FedCablingTask object!";
894 <<
" Created " << booked <<
" CommissioningTask objects and booked histograms";
904 for (uint16_t partition = 0; partition < 4; ++partition) {
910 tasks_[0][partition]->eventSetup(&setup);
911 tasks_[0][partition]->bookHistograms();
919 tasks_[0][0]->eventSetup(&setup);
920 tasks_[0][0]->bookHistograms();
930 for (
auto iconn = conns.begin(); iconn != conns.end(); ++iconn) {
933 iconn->fecCrate(), iconn->fecSlot(), iconn->fecRing(), iconn->ccuAddr(), iconn->ccuChan());
937 if (!iconn->isConnected()) {
945 std::stringstream
dir;
947 if (
view_ ==
"Default") {
949 dir << fed_key.path();
951 dir << fec_key.path();
953 }
else if (
view_ ==
"FecView") {
954 dir << fec_key.path();
955 }
else if (
view_ ==
"FedView") {
956 dir << fed_key.path();
957 }
else if (
view_ ==
"DetView") {
962 <<
" Invalid view " <<
view_ << std::endl
963 <<
" Histograms will end up all in the top directory.";
968 if (!
tasks_[iconn->fedId()][iconn->fedCh()]) {
990 tasks_[iconn->fedId()][iconn->fedCh()] =
993 tasks_[iconn->fedId()][iconn->fedCh()] =
997 <<
" Undefined CommissioningTask" 998 <<
" Unable to create CommissioningTask object!";
1001 <<
" Unknown CommissioningTask" 1002 <<
" Unable to create CommissioningTask object!";
1006 if (
tasks_[iconn->fedId()][iconn->fedCh()]) {
1007 tasks_[iconn->fedId()][iconn->fedCh()]->eventSetup(&setup);
1011 tasks_[iconn->fedId()][iconn->fedCh()]->bookHistograms();
1021 std::stringstream
ss;
1022 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 1023 <<
" NULL pointer to CommissioningTask for key 0x" << std::hex << std::setfill(
'0') << std::setw(8)
1024 << fed_key.key() <<
std::dec <<
" in directory " << dir.str() <<
" Unable to book histograms!";
1028 std::stringstream
ss;
1029 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 1030 <<
" CommissioningTask object already exists for key 0x" << std::hex << std::setfill(
'0') << std::setw(8)
1031 << fed_key.key() <<
std::dec <<
" in directory " << dir.str()
1032 <<
" Unable to create CommissioningTask object!";
1039 <<
" Created " << booked <<
" CommissioningTask objects and booked histograms";
1049 if (itask->second) {
1050 delete itask->second;
1062 VecOfVecOfTasks::iterator ifed =
tasks_.begin();
1063 for (; ifed !=
tasks_.end(); ifed++) {
1064 VecOfTasks::iterator ichan = ifed->begin();
1065 for (; ichan != ifed->end(); ichan++) {
1071 ifed->resize(96,
nullptr);
1087 gethostname(hn,
sizeof(hn));
1089 he = gethostbyname(hn);
1096 host_ip =
std::string(inet_ntoa(*(
struct in_addr*)(he->h_addr)));
1098 host_name =
"unknown.cern.ch";
1099 host_ip =
"255.255.255.255";
1104 std::stringstream ip;
1106 while (pos != std::string::npos) {
1108 if (tmp != std::string::npos) {
1109 ip << std::setw(3) << std::setfill(
'0') << host_ip.substr(pos, tmp - pos) <<
".";
1112 ip << std::setw(3) << std::setfill(
'0') << host_ip.substr(pos);
1113 pos = std::string::npos;
1118 pid_t pid = getpid();
1122 dir << std::setw(8) << std::setfill(
'0') << run_number <<
"_";
1124 dir << ip.str() <<
"_" << std::setw(5) << std::setfill(
'0') << pid;
MonitorElement * bookString(char_string const &name, char_string const &value)
Book string.
static const char runNumber_[]
Device and connection information at the level of a front-end module.
EventNumber_t event() const
const_iterator end(bool update=false) const
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiReorderedToken_
void createCablingTasks()
iterator find(det_id_type id)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiVirginRawToken_
const uint16_t & fecRing() const
void createTask(const SiStripEventSummary *const, const edm::EventSetup &)
A container class for generic run and event-related info, information required by the commissioning a...
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const SiStripModule & module(const FedChannelConnection &conn) const
const SiStripFecKey & key() const
edm::EDGetTokenT< edmNew::DetSetVector< SiStripCluster > > clustersToken_
void fillHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &, const edm::DetSetVector< SiStripRawDigi > &=edm::DetSetVector< SiStripRawDigi >(), const edmNew::DetSetVector< SiStripCluster > &=edmNew::DetSetVector< SiStripCluster >())
static const char mlDqmSource_[]
SiStripCommissioningSource()=delete
void createTasks(sistrip::RunType, const edm::EventSetup &)
const std::vector< SiStripFecCrate > & crates() const
data_type const * const_iterator
const uint16_t & fecSlot() const
static const uint16_t valid_
static const char detectorView_[]
void analyze(const edm::Event &, const edm::EventSetup &) override
std::string inputModuleLabel_
void directory(std::stringstream &, uint32_t run_number=0)
const uint32_t & key() const
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
void beginRun(edm::Run const &, const edm::EventSetup &) override
static std::string runType(const sistrip::RunType &)
const sistrip::RunType & runType() const
std::vector< CommissioningTask * > VecOfTasks
Class containning control, module, detector and connection information, at the level of a FED channel...
std::string inputModuleLabelAlt_
FedsConstIterRange fedIds() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
static const char taskId_[]
void fillCablingHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
static const char dqmSourceFileName_[]
const uint32_t & dcuId() const
static const char mlTest_[]
SiStripFecCabling * fecCabling_
std::string inputClusterLabel_
edm::ParameterSet parameters_
iterator end()
Return the off-the-end iterator.
std::string partitionName_
const uint16_t & fecCrate() const
const uint32_t & deviceId() const
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
const uint16_t & feUnit() const
T const * product() const
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiFineDelaySelectionToken_
const uint16_t & channel() const
~SiStripCommissioningSource() override
bool empty() const
Return true if we contain no DetSets.
const uint16_t & ccuAddr() const
static const uint16_t invalid_
std::string inputModuleLabelSummary_
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
void setCurrentFolder(std::string const &fullpath)
const sistrip::FedReadoutMode & fedReadoutMode() const
edm::EDGetTokenT< SiStripEventSummary > inputModuleSummaryToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiScopeModeToken_
std::string taskConfigurable_
SiStripFedCabling * fedCabling_
const uint16_t & feChan() const
static const char root_[]
DQMStore *const dqm(std::string method="") const
const uint16_t & ccuChan() const
std::pair< uint16_t, uint16_t > PairOfU16
T const * product() const
void save(std::string const &filename, std::string const &path="", std::string const &pattern="", std::string const &rewrite="", uint32_t run=0, uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, std::string const &fileupdate="RECREATE")
const_iterator begin(bool update=false) const
static std::string fedReadoutMode(const sistrip::FedReadoutMode &)