34 #include <boost/cstdint.hpp>
40 #include <sys/types.h>
44 #include <arpa/inet.h>
45 #include <sys/unistd.h>
46 #include <sys/socket.h>
51 using namespace sistrip;
59 inputModuleLabel_( pset.getParameter<std::
string>(
"InputModuleLabel" ) ),
60 inputModuleLabelSummary_( pset.getParameter<std::
string>(
"SummaryInputModuleLabel" ) ),
64 taskConfigurable_( pset.getUntrackedParameter<std::
string>(
"CommissioningTask",
"UNDEFINED") ),
70 updateFreq_( pset.getUntrackedParameter<int>(
"HistoUpdateFreq",1) ),
72 view_( pset.getUntrackedParameter<std::
string>(
"View",
"Default") ),
81 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
82 <<
" Constructing object...";
91 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
92 <<
" Destructing object...";
100 if ( method !=
"" ) { ss <<
"[SiStripCommissioningSource::" << method <<
"]" << std::endl; }
101 else { ss <<
"[SiStripCommissioningSource]" << std::endl; }
102 ss <<
" NULL pointer to DQMStore";
105 }
else {
return dqm_; }
114 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
115 <<
" Configuring..." << std::endl;
121 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
122 <<
" DQMStore service: "
125 dqm()->setVerbose(0);
129 std::stringstream
dir(
"");
138 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
139 <<
"Initialized FED cabling. Number of FEDs is " <<
fedCabling_->
fedIds().size();
142 std::stringstream
ss;
143 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
144 <<
" Empty std::vector returned by FEC cabling object!"
145 <<
" Check if database connection failed...";
166 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
167 <<
" Halting..." << std::endl;
173 if ( itask->second ) { itask->second->updateHistograms(); }
177 for (uint16_t partition = 0; partition < 4; ++partition) {
178 tasks_[0][partition]->updateHistograms();
181 tasks_[0][0]->updateHistograms();
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];
211 if ( getenv(scratch.c_str()) !=
NULL ) {
212 dir = getenv(scratch.c_str());
216 std::stringstream
ss;
217 if ( !dir.empty() ) { ss << dir <<
"/"; }
218 else { ss <<
"/tmp/"; }
227 if (
run_ != 0 ) {
dqm()->save( ss.str() ); }
230 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
231 <<
" NULL value for RunNumber! No root file saved!";
235 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
236 <<
" NULL value for filename! No root file saved!";
240 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
241 <<
" Saved all histograms to file \""
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!";
284 run_ =
event.id().run();
290 std::stringstream
ss;
291 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
293 <<
" events were processed at a rate of ";
294 if (
time(
NULL) ==
time_ ) { ss <<
">" << updateFreq_ <<
" Hz"; }
313 std::stringstream
ss;
314 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
315 <<
" Requested DAQ_SCOPE_MODE but unknown FED"
316 <<
" readout mode retrieved from SiStripEventSummary: "
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";
354 if ( &(*raw) == 0 ) {
355 std::stringstream
ss;
356 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" << std::endl
357 <<
" NULL pointer to DetSetVector!" << std::endl
358 <<
" Unable to fill histograms!";
375 uint16_t lld_channel = ( summary->
deviceId() & 0x3 ) + 1;
382 uint32_t fec_key = key_object.
key();
383 std::stringstream sss;
384 sss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
386 << std::hex << std::setw(8) << std::setfill(
'0') << summary->
dcuId() <<
std::dec
387 <<
" with Crate/FEC/Ring/CCU/Module/LLD: "
400 std::stringstream
ss;
401 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
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)";
417 std::map<uint16_t,float> medians; medians.clear();
418 std::map<uint16_t,float> medians1; medians1.clear();
421 for ( uint16_t ichan = 0; ichan < 96; ichan++ ) {
431 std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.
find( fed_key );
432 if ( digis != raw.
end() ) {
433 if ( digis->data.empty() ) {
continue; }
444 for ( uint16_t idigi = 0; idigi < digis->data.size(); idigi++ ) {
445 ave.add( static_cast<uint32_t>(digis->data[idigi].adc()) );
449 medians[ichan] = params.
median_;
450 medians1[ichan] = digis->data[0].adc();
475 std::map<uint16_t,float>::const_iterator
ii = medians.begin();
476 for ( ; ii != medians.end(); ii++ ) { average.add( ii->second ); }
494 std::map<uint16_t,float>::const_iterator
jj = medians.begin();
495 for ( ; jj != medians.end(); jj++ ) {
497 truncated.add( jj->second );
501 truncated.calc(params);
516 std::stringstream ss2;
517 std::stringstream ss3;
520 std::map<uint16_t,float> channels;
521 std::map<uint16_t,float>::const_iterator ichan = medians.begin();
522 for ( ; ichan != medians.end(); ichan++ ) {
529 if ( ichan->second > 200. ) {
530 LogTrace(
mlTest_) <<
"TEST FOUND SIGNAL HIGH: " << *ifed <<
" " << ichan->first <<
" " << ichan->second;
531 channels[ichan->first] = ichan->second;
534 << ichan->second <<
" ";
536 << medians1[ichan->first] <<
" ";
564 if ( !channels.empty() ) {
565 cablingTasks_[fec_key]->fillHistograms( *summary, *ifed, channels );
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: "
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: "
612 for (
auto iconn = conns.begin() ; iconn != conns.end(); iconn++ ) {
614 if ( !(iconn->fedId()) || iconn->fedId() >
sistrip::valid_ ) {
continue; }
627 std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.
find( fed_key );
629 if ( digis != raw.
end() ) {
632 if (
tasks_[0][iconn->fecCrate()-1] ) {
633 tasks_[0][iconn->fecCrate()-1]->fillHistograms( *summary, *digis );
635 std::stringstream
ss;
636 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
637 <<
" Unable to find CommissioningTask for FEC crate "
638 << iconn->fecCrate() <<
". Unable to fill histograms!";
643 tasks_[0][0]->fillHistograms( *summary, *digis );
645 std::stringstream
ss;
646 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
647 <<
" Unable to find global CommissioningTask for FineDelay. Unable to fill histograms!";
652 if (
tasks_[iconn->fedId()][iconn->fedCh()] ) {
653 tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms( *summary, *digis );
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
660 << iconn->fedId() <<
"/"
662 <<
" Unable to fill histograms!";
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
676 << iconn->fedId() <<
"/"
693 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
694 <<
" NULL run number!";
700 std::stringstream
run;
716 std::stringstream
ss;
717 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
718 <<
" Identified CommissioningTask from EventSummary to be \""
724 std::stringstream
ss;
725 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
726 <<
" NULL pointer to SiStripEventSummary!"
727 <<
" Check SiStripEventSummary is found/present in Event";
735 std::stringstream
ss;
736 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
737 <<
" Overriding CommissioningTask from EventSummary (\""
739 <<
"\") with value retrieved from .cfg file (\""
743 task_ = configurable;
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";
765 std::stringstream
ss;
766 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
767 <<
" Identified CommissioningTask to be \""
777 std::stringstream
ss;
778 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
779 <<
" CommissioningTask: "
784 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
785 <<
" Creating CommissioningTask objects and booking histograms...";
789 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
790 <<
" Finished booking histograms!";
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++ ) {
812 imodule->ccuChan() );
815 if ( !
path.isValid() ) {
continue; }
819 dqm()->setCurrentFolder( dir );
822 for ( uint16_t ipair = 0; ipair < imodule->nApvPairs(); ipair++ ) {
837 imodule->nApvPairs() );
845 imodule->lldChannel(ipair) ).
key();
850 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
851 <<
" Unexpected NULL value for FEC key!";
862 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
863 <<
" Undefined CommissioningTask"
864 <<
" Unable to create FedCablingTask object!";
867 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
868 <<
" Unknown CommissioningTask"
869 <<
" Unable to create FedCablingTask object!";
872 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
873 <<
" Unexpected CommissioningTask: "
875 <<
" Unable to create FedCablingTask object!";
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!";
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!";
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!";
927 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
928 <<
" Created " << booked
929 <<
" CommissioningTask objects and booked histograms";
942 for (uint16_t partition = 0; partition < 4; ++partition) {
945 tasks_[0][partition]->eventSetup( &setup );
946 tasks_[0][partition]->bookHistograms();
955 tasks_[0][0]->eventSetup( &setup );
956 tasks_[0][0]->bookHistograms();
969 for (
auto iconn = conns.begin() ; iconn != conns.end(); ++iconn ) {
981 if ( !iconn->isConnected() ) {
continue; }
987 std::stringstream
dir;
989 if (
view_ ==
"Default") {
991 dir << fed_key.path();
993 dir << fec_key.path();
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") {
1006 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1007 <<
" Invalid view " <<
view_ << std::endl
1008 <<
" Histograms will end up all in the top directory.";
1010 dqm()->setCurrentFolder( dir.str() );
1013 if ( !
tasks_[iconn->fedId()][iconn->fedCh()] ) {
1052 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1053 <<
" Undefined CommissioningTask"
1054 <<
" Unable to create CommissioningTask object!";
1057 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1058 <<
" Unknown CommissioningTask"
1059 <<
" Unable to create CommissioningTask object!";
1063 if (
tasks_[iconn->fedId()][iconn->fedCh()] ) {
1064 tasks_[iconn->fedId()][iconn->fedCh()]->eventSetup( &setup );
1065 tasks_[iconn->fedId()][iconn->fedCh()]->bookHistograms();
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!";
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!";
1099 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1100 <<
" Created " << booked
1101 <<
" CommissioningTask objects and booked histograms";
1109 if ( itask->second ) {
delete itask->second; }
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 = 0; }
1133 dqm()->removeContents();
1147 gethostname( hn,
sizeof(hn) );
1149 he = gethostbyname(hn);
1156 host_ip =
std::string( inet_ntoa( *(
struct in_addr*)(he->h_addr) ) );
1158 host_name =
"unknown.cern.ch";
1159 host_ip =
"255.255.255.255";
1164 std::stringstream ip;
1166 while ( pos != std::string::npos ) {
1168 if ( tmp != std::string::npos ) {
1170 << std::setfill(
'0')
1171 << host_ip.substr( pos, tmp-pos )
1176 << std::setfill(
'0')
1177 << host_ip.substr( pos );
1178 pos = std::string::npos;
1183 pid_t
pid = getpid();
1188 << std::setfill(
'0')
1195 << std::setfill(
'0')
static const char runNumber_[]
Device and connection information at the level of a front-end module.
EventNumber_t event() const
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...
void beginRun(edm::Run const &, const edm::EventSetup &)
const SiStripModule & module(const FedChannelConnection &conn) const
DQMStore *const dqm(std::string method="") const
const SiStripFecKey & key() const
static const char mlDqmSource_[]
void createTasks(sistrip::RunType, const edm::EventSetup &)
const std::vector< SiStripFecCrate > & crates() const
const uint16_t & fecSlot() const
static const uint16_t valid_
static const char detectorView_[]
std::string inputModuleLabel_
void directory(std::stringstream &, uint32_t run_number=0)
const uint32_t & key() const
void analyze(const edm::Event &, const edm::EventSetup &)
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
static std::string runType(const sistrip::RunType &)
const sistrip::RunType & runType() const
std::vector< CommissioningTask * > VecOfTasks
tuple path
else: Piece not in the list, fine.
Class containning control, module, detector and connection information, at the level of a FED channel...
FedsConstIterRange fedIds() const
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_
edm::ParameterSet parameters_
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
iterator end()
Return the off-the-end iterator.
const uint16_t & fecCrate() const
const uint32_t & deviceId() const
const uint16_t & feUnit() const
T const * product() const
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiFineDelaySelectionToken_
const uint16_t & channel() const
T const * product() const
const uint16_t & ccuAddr() const
static const uint16_t invalid_
std::pair< uint16_t, uint16_t > PairOfU16
std::string inputModuleLabelSummary_
ConnsConstIterRange fedConnections(uint16_t fed_id) const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
std::vector< std::vector< double > > tmp
edm::EDGetTokenT< SiStripEventSummary > inputModuleSummaryToken_
edm::EDGetTokenT< edm::DetSetVector< SiStripRawDigi > > digiScopeModeToken_
std::string taskConfigurable_
SiStripFedCabling * fedCabling_
const uint16_t & feChan() const
static const char root_[]
const uint16_t & ccuChan() const
volatile std::atomic< bool > shutdown_flag false
~SiStripCommissioningSource()
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void fillHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
SiStripCommissioningSource()
static std::string fedReadoutMode(const sistrip::FedReadoutMode &)