37 #include <sys/types.h> 41 #include <arpa/inet.h> 44 #include <sys/socket.h> 45 #include <sys/unistd.h> 56 inputModuleLabel_(
pset.getParameter<
std::
string>(
"InputModuleLabel")),
57 inputModuleLabelAlt_(
pset.existsAs<
std::
string>(
"InputModuleLabelAlt")
60 inputModuleLabelSummary_(
pset.getParameter<
std::
string>(
"SummaryInputModuleLabel")),
69 taskConfigurable_(
pset.getUntrackedParameter<
std::
string>(
"CommissioningTask",
"UNDEFINED")),
75 updateFreq_(
pset.getUntrackedParameter<
int>(
"HistoUpdateFreq", 1)),
77 view_(
pset.getUntrackedParameter<
std::
string>(
"View",
"Default")),
79 usesResource(
"DQMStore");
95 <<
" Constructing object...";
97 tasks_.resize(1024,
VecOfTasks(96, static_cast<CommissioningTask*>(
nullptr)));
112 <<
" Destructing object...";
119 std::stringstream
ss;
121 ss <<
"[SiStripCommissioningSource::" <<
method <<
"]" << std::endl;
123 ss <<
"[SiStripCommissioningSource]" << std::endl;
125 ss <<
" NULL pointer to DQMStore";
139 <<
" Configuring..." << std::endl;
145 <<
" DQMStore service: " <<
dqm_;
150 std::stringstream
dir(
"");
158 <<
"Initialized FED cabling. Number of FEDs is " <<
fedCabling_->
fedIds().size();
161 std::stringstream
ss;
162 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 163 <<
" Empty std::vector returned by FEC cabling object!" 164 <<
" Check if database connection failed...";
184 <<
" Halting..." << std::endl;
190 itask->second->updateHistograms();
199 tasks_[0][0]->updateHistograms();
207 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
208 if (!iconn->isConnected()) {
211 fed_id = iconn->fedId();
212 fed_ch = iconn->fedCh();
213 if (
tasks_[fed_id][fed_ch]) {
214 tasks_[fed_id][fed_ch]->updateHistograms();
215 delete tasks_[fed_id][fed_ch];
224 if (
filename_.find(
".root", 0) == std::string::npos) {
233 if (std::getenv(scratch.c_str()) !=
nullptr) {
234 dir = std::getenv(scratch.c_str());
238 std::stringstream
ss;
259 <<
" NULL value for RunNumber! No root file saved!";
263 <<
" NULL value for filename! No root file saved!";
267 <<
" Saved all histograms to file \"" <<
ss.str() <<
"\"";
299 <<
" Unknown/undefined RunType and NULL parameter values!" 300 <<
" It may be that the 'trigger FED' object was not found!";
308 run_ =
event.id().run();
314 std::stringstream
ss;
315 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 316 <<
" The last " <<
updateFreq_ <<
" events were processed at a rate of ";
354 std::stringstream
ss;
355 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 356 <<
" Requested DAQ_SCOPE_MODE but unknown FED" 357 <<
" readout mode retrieved from SiStripEventSummary: " 372 std::stringstream
ss;
373 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 375 <<
" Unable to establish FED readout mode and retrieve digi container!" 376 <<
" Check if SiStripEventSummary object is found/present in Event";
383 std::stringstream
ss;
384 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" << std::endl
385 <<
" NULL pointer to DetSetVector!" << std::endl
386 <<
" Unable to fill histograms!";
392 std::stringstream
ss;
393 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" << std::endl
394 <<
" NULL pointer to DetSetVector!" << std::endl
395 <<
" Unable to fill histograms!";
401 std::stringstream
ss;
402 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" << std::endl
403 <<
" NULL pointer to DetSetVector!" << std::endl
404 <<
" Unable to fill histograms!";
422 uint16_t lld_channel = (
summary->deviceId() & 0x3) + 1;
429 uint32_t fec_key = key_object.
key();
430 std::stringstream sss;
431 sss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 432 <<
" Found DcuId 0x" << std::hex << std::setw(8) << std::setfill(
'0') <<
summary->dcuId() <<
std::dec 433 <<
" with Crate/FEC/Ring/CCU/Module/LLD: " <<
module.key().fecCrate() <<
"/" <<
module.key().fecSlot() <<
"/" 434 <<
module.key().fecRing() <<
"/" <<
module.key().ccuAddr() <<
"/" <<
module.key().ccuChan() <<
"/" << lld_channel;
441 std::stringstream
ss;
442 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 443 <<
" DcuId 0x" << std::hex << std::setw(8) << std::setfill(
'0') <<
summary->dcuId() <<
std::dec 444 <<
" in 'DAQ register' field not found in cabling map!" 445 <<
" (NULL values returned for FEC path)";
458 std::map<uint16_t, float> medians;
460 std::map<uint16_t, float> medians1;
464 for (uint16_t ichan = 0; ichan < 96; ichan++) {
468 std::vector<edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.
find(fed_key);
469 if (digis != raw.
end()) {
470 if (digis->data.empty()) {
475 for (uint16_t idigi = 0; idigi < digis->data.size(); idigi++) {
476 ave.add(static_cast<uint32_t>(digis->data[idigi].adc()));
480 medians[ichan] =
params.median_;
481 medians1[ichan] = digis->data[0].adc();
488 std::map<uint16_t, float>::const_iterator
ii = medians.begin();
489 for (;
ii != medians.end();
ii++) {
495 std::stringstream
ss;
496 ss <<
"FED Averages:" << std::endl
497 <<
" nChans: " << medians.size() << std::endl
498 <<
" num/mean/median/rms/max/min: " <<
tmp.num_ <<
"/" <<
tmp.mean_ <<
"/" <<
tmp.median_ <<
"/" <<
tmp.rms_
499 <<
"/" <<
tmp.max_ <<
"/" <<
tmp.min_ << std::endl;
504 std::map<uint16_t, float>::const_iterator
jj = medians.begin();
505 for (;
jj != medians.end();
jj++) {
506 if (
jj->second <
tmp.median_ +
tmp.rms_) {
507 truncated.add(
jj->second);
513 std::stringstream ss1;
514 ss1 <<
"Truncated Averages:" << std::endl
515 <<
" nChans: " << medians.size() << std::endl
516 <<
" num/mean/median/rms/max/min: " <<
params.num_ <<
"/" <<
params.mean_ <<
"/" <<
params.median_ <<
"/" 521 std::stringstream ss2;
522 std::stringstream ss3;
524 std::map<uint16_t, float>::const_iterator ichan = medians.begin();
525 for (; ichan != medians.end(); ichan++) {
526 if (ichan->second > 200.) {
527 LogTrace(
mlTest_) <<
"TEST FOUND SIGNAL HIGH: " << *ifed <<
" " << ichan->first <<
" " << ichan->second;
528 channels[ichan->first] = ichan->second;
531 << ichan->second <<
" ";
533 << medians1[ichan->first] <<
" ";
546 std::stringstream
ss;
547 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 548 <<
" Filled histogram for '" <<
cablingTasks_[fec_key]->myName() <<
"' object with FecKey: 0x" << std::hex
549 << std::setfill(
'0') << std::setw(8) << fec_key <<
std::dec 550 <<
" and Crate/FEC/ring/CCU/module/LLDchan: " <<
path.fecCrate() <<
"/" <<
path.fecSlot() <<
"/" 551 <<
path.fecRing() <<
"/" <<
path.ccuAddr() <<
"/" <<
path.ccuChan() <<
"/" <<
path.channel();
556 std::stringstream
ss;
557 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 558 <<
" Unable to find CommissioningTask object with FecKey: 0x" << std::hex << std::setfill(
'0') << std::setw(8)
559 << fec_key <<
std::dec <<
" and Crate/FEC/ring/CCU/module/LLDchan: " <<
path.fecCrate() <<
"/" 560 <<
path.fecSlot() <<
"/" <<
path.fecRing() <<
"/" <<
path.ccuAddr() <<
"/" <<
path.ccuChan() <<
"/" 575 std::vector<uint16_t> stripOnClusters;
580 for (
auto iconn = conns.begin(); iconn != conns.end(); iconn++) {
584 if (!iconn->isConnected()) {
593 std::vector<edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.
find(fed_key);
596 std::vector<edm::DetSet<SiStripRawDigi> >::const_iterator digisAlt;
597 if (not rawAlt.
empty()) {
598 digisAlt = rawAlt.
find(fed_key);
599 if (digisAlt == rawAlt.
end())
604 stripOnClusters.clear();
608 if (DSViter->id() != iconn->detId())
612 if (DSiter->firstStrip() >= iconn->apvPairNumber() * 256 and
613 DSiter->firstStrip() < (1 + iconn->apvPairNumber()) * 256) {
614 for (
size_t istrip = 0; istrip < DSiter->amplitudes().size(); istrip++) {
615 stripOnClusters.push_back(DSiter->firstStrip() + istrip - iconn->apvPairNumber() * 256);
622 if (digis != raw.
end()) {
625 if (
tasks_[0][iconn->fecCrate() - 1]) {
626 tasks_[0][iconn->fecCrate() - 1]->fillHistograms(*
summary, *digis);
628 std::stringstream
ss;
629 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 630 <<
" Unable to find CommissioningTask for FEC crate " << iconn->fecCrate()
631 <<
". Unable to fill histograms!";
638 std::stringstream
ss;
639 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 640 <<
" Unable to find global CommissioningTask for FineDelay. Unable to fill histograms!";
644 if (
tasks_[iconn->fedId()][iconn->fedCh()]) {
645 if (not rawAlt.
empty()
or digisAlt == rawAlt.
end())
646 tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms(*
summary, *digis);
648 if (stripOnClusters.empty())
649 tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms(*
summary, *digis, *digisAlt);
651 tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms(*
summary, *digis, *digisAlt, stripOnClusters);
655 std::stringstream
ss;
656 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 657 <<
" Unable to find CommissioningTask object with FED key " << std::hex << std::setfill(
'0')
658 << std::setw(8) << fed_key <<
std::dec <<
" and FED id/ch " << iconn->fedId() <<
"/" << iconn->fedCh()
659 <<
" Unable to fill histograms!";
667 std::stringstream
ss;
668 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 669 <<
" Unable to find any DetSet containing digis for FED key " << std::hex << std::setfill(
'0')
670 << std::setw(8) << fed_key <<
std::dec <<
" and FED id/ch " << iconn->fedId() <<
"/" << iconn->fedCh();
684 <<
" NULL run number!";
690 std::stringstream
run;
704 std::stringstream
ss;
705 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 710 std::stringstream
ss;
711 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 712 <<
" NULL pointer to SiStripEventSummary!" 713 <<
" Check SiStripEventSummary is found/present in Event";
720 std::stringstream
ss;
721 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 725 task_ = configurable;
735 std::stringstream
ss;
736 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 737 <<
" Unexpected CommissioningTask found (" <<
static_cast<uint16_t
>(
task_) <<
") \"" 739 <<
" Unexpected value found in SiStripEventSummary and/or cfg file" 740 <<
" If SiStripEventSummary is not present in Event," 741 <<
" check 'CommissioningTask' configurable in cfg file";
745 std::stringstream
ss;
746 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 758 std::stringstream
ss;
759 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 764 <<
" Creating CommissioningTask objects and booking histograms...";
771 <<
" Finished booking histograms!";
780 for (std::vector<SiStripFecCrate>::const_iterator icrate =
fecCabling_->
crates().begin();
783 for (std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++) {
784 for (std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end();
786 for (std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end();
788 for (std::vector<SiStripModule>::const_iterator imodule = iccu->modules().begin();
789 imodule != iccu->modules().end();
793 icrate->fecCrate(), ifec->fecSlot(), iring->fecRing(), iccu->ccuAddr(), imodule->ccuChan());
796 if (!
path.isValid()) {
805 for (uint16_t ipair = 0; ipair < imodule->nApvPairs(); ipair++) {
819 imodule->nApvPairs());
827 imodule->lldChannel(ipair))
833 <<
" Unexpected NULL value for FEC key!";
843 <<
" Undefined CommissioningTask" 844 <<
" Unable to create FedCablingTask object!";
847 <<
" Unknown CommissioningTask" 848 <<
" Unable to create FedCablingTask object!";
851 <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 853 <<
" Unable to create FedCablingTask object!";
862 std::stringstream
ss;
863 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 864 <<
" Booking histograms for '" <<
cablingTasks_[
key]->myName() <<
"' object with key 0x" 865 << std::hex << std::setfill(
'0') << std::setw(8) <<
key <<
std::dec <<
" in directory \"" <<
dir 869 std::stringstream
ss;
870 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 871 <<
" NULL pointer to CommissioningTask for key 0x" << std::hex << std::setfill(
'0')
872 << std::setw(8) <<
key <<
std::dec <<
" in directory " <<
dir <<
" Unable to book histograms!";
876 std::stringstream
ss;
877 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 878 <<
" Unable to find CommissioningTask for key 0x" << std::hex << std::setfill(
'0') << std::setw(8)
879 <<
key <<
std::dec <<
" in directory " <<
dir <<
" Unable to book histograms!";
884 std::stringstream
ss;
885 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 886 <<
" CommissioningTask object already exists for key 0x" << std::hex << std::setfill(
'0')
888 <<
" Unable to create FedCablingTask object!";
900 <<
" Created " << booked <<
" CommissioningTask objects and booked histograms";
926 tasks_[0][0]->bookHistograms();
936 for (
auto iconn = conns.begin(); iconn != conns.end(); ++iconn) {
939 iconn->fecCrate(), iconn->fecSlot(), iconn->fecRing(), iconn->ccuAddr(), iconn->ccuChan());
943 if (!iconn->isConnected()) {
951 std::stringstream
dir;
953 if (
view_ ==
"Default") {
955 dir << fed_key.path();
957 dir << fec_key.path();
959 }
else if (
view_ ==
"FecView") {
960 dir << fec_key.path();
961 }
else if (
view_ ==
"FedView") {
962 dir << fed_key.path();
963 }
else if (
view_ ==
"DetView") {
968 <<
" Invalid view " <<
view_ << std::endl
969 <<
" Histograms will end up all in the top directory.";
974 if (!
tasks_[iconn->fedId()][iconn->fedCh()]) {
996 tasks_[iconn->fedId()][iconn->fedCh()] =
999 tasks_[iconn->fedId()][iconn->fedCh()] =
1003 <<
" Undefined CommissioningTask" 1004 <<
" Unable to create CommissioningTask object!";
1007 <<
" Unknown CommissioningTask" 1008 <<
" Unable to create CommissioningTask object!";
1012 if (
tasks_[iconn->fedId()][iconn->fedCh()]) {
1013 tasks_[iconn->fedId()][iconn->fedCh()]->eventSetup(&
setup);
1017 tasks_[iconn->fedId()][iconn->fedCh()]->bookHistograms();
1027 std::stringstream
ss;
1028 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 1029 <<
" NULL pointer to CommissioningTask for key 0x" << std::hex << std::setfill(
'0') << std::setw(8)
1030 << fed_key.key() <<
std::dec <<
" in directory " <<
dir.str() <<
" Unable to book histograms!";
1034 std::stringstream
ss;
1035 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" 1036 <<
" CommissioningTask object already exists for key 0x" << std::hex << std::setfill(
'0') << std::setw(8)
1037 << fed_key.key() <<
std::dec <<
" in directory " <<
dir.str()
1038 <<
" Unable to create CommissioningTask object!";
1045 <<
" Created " << booked <<
" CommissioningTask objects and booked histograms";
1055 if (itask->second) {
1056 delete itask->second;
1068 VecOfVecOfTasks::iterator ifed =
tasks_.begin();
1069 for (; ifed !=
tasks_.end(); ifed++) {
1070 VecOfTasks::iterator ichan = ifed->begin();
1071 for (; ichan != ifed->end(); ichan++) {
1077 ifed->resize(96,
nullptr);
1093 gethostname(hn,
sizeof(hn));
1095 he = gethostbyname(hn);
1102 host_ip =
std::string(inet_ntoa(*(
struct in_addr*)(
he->h_addr)));
1104 host_name =
"unknown.cern.ch";
1105 host_ip =
"255.255.255.255";
1110 std::stringstream ip;
1112 while (
pos != std::string::npos) {
1114 if (
tmp != std::string::npos) {
1115 ip << std::setw(3) << std::setfill(
'0') << host_ip.substr(
pos,
tmp -
pos) <<
".";
1118 ip << std::setw(3) << std::setfill(
'0') << host_ip.substr(
pos);
1119 pos = std::string::npos;
1124 pid_t pid = getpid();
1128 dir << std::setw(8) << std::setfill(
'0') <<
run_number <<
"_";
1130 dir << ip.str() <<
"_" << std::setw(5) << std::setfill(
'0') << pid;
static const char runNumber_[]
Log< level::Info, true > LogVerbatim
Device and connection information at the level of a front-end module.
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiReorderedToken_
void createCablingTasks()
iterator find(det_id_type id)
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiVirginRawToken_
const uint16_t & feChan() const
void createTask(const SiStripEventSummary *const, const edm::EventSetup &)
edm::ESGetToken< SiStripPedestals, SiStripPedestalsRcd > pedestalToken_
const uint16_t & feUnit() const
A container class for generic run and event-related info, information required by the commissioning a...
const SiStripModule & module(const FedChannelConnection &conn) 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 >())
void setCurrentFolder(std::string const &fullpath) override
static const char mlDqmSource_[]
SiStripCommissioningSource()=delete
void createTasks(sistrip::RunType, const edm::EventSetup &)
data_type const * const_iterator
bool empty() const
Return true if we contain no DetSets.
static const uint16_t valid_
static const char detectorView_[]
void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * bookString(TString const &name, TString const &value, FUNC onbooking=NOOP())
std::string inputModuleLabel_
void directory(std::stringstream &, uint32_t run_number=0)
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 &)
std::vector< CommissioningTask * > VecOfTasks
Class containning control, module, detector and connection information, at the level of a FED channel...
std::string inputModuleLabelAlt_
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 > &)
const uint32_t & key() const
static const char dqmSourceFileName_[]
static const char mlTest_[]
SiStripFecCabling * fecCabling_
key
prepare the HTCondor submission files and eventually submit them
std::string inputClusterLabel_
const std::vector< SiStripFecCrate > & crates() const
edm::ParameterSet parameters_
iterator end()
Return the off-the-end iterator.
std::string partitionName_
Log< level::Info, false > LogInfo
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiFineDelaySelectionToken_
~SiStripCommissioningSource() override
static const uint16_t invalid_
std::string inputModuleLabelSummary_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
edm::EDGetTokenT< SiStripEventSummary > inputModuleSummaryToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiScopeModeToken_
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
std::string taskConfigurable_
DQMStore *const dqm(std::string method="") const
SiStripFedCabling * fedCabling_
static const char root_[]
Log< level::Warning, false > LogWarning
std::pair< uint16_t, uint16_t > PairOfU16
FedsConstIterRange fedIds() const
ConnsConstIterRange fedConnections(uint16_t fed_id) const
edm::ESGetToken< SiStripFedCabling, SiStripFedCablingRcd > fedCablingToken_
edm::ESGetToken< SiStripNoises, SiStripNoisesRcd > noiseToken_
static std::string fedReadoutMode(const sistrip::FedReadoutMode &)