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" ) ),
61 filename_( pset.getUntrackedParameter<std::string>(
"RootFileName",sistrip::
dqmSourceFileName_) ),
64 taskConfigurable_( pset.getUntrackedParameter<std::string>(
"CommissioningTask",
"UNDEFINED") ),
70 updateFreq_( pset.getUntrackedParameter<int>(
"HistoUpdateFreq",1) ),
72 view_( pset.getUntrackedParameter<std::string>(
"View",
"Default") ),
76 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
77 <<
" Constructing object...";
86 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
87 <<
" Destructing object...";
95 if ( method !=
"" ) { ss <<
"[SiStripCommissioningSource::" << method <<
"]" << std::endl; }
96 else { ss <<
"[SiStripCommissioningSource]" << std::endl; }
97 ss <<
" NULL pointer to DQMStore";
100 }
else {
return dqm_; }
109 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
110 <<
" Configuring..." << std::endl;
116 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
117 <<
" DQMStore service: "
124 std::stringstream
dir(
"");
133 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
134 <<
"Initialized FED cabling. Number of FEDs is " <<
fedCabling_->
feds().size();
137 std::stringstream ss;
138 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
139 <<
" Empty std::vector returned by FEC cabling object!"
140 <<
" Check if database connection failed...";
161 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
162 <<
" Halting..." << std::endl;
168 if ( itask->second ) { itask->second->updateHistograms(); }
172 for (uint16_t partition = 0; partition < 4; ++partition) {
173 tasks_[0][partition]->updateHistograms();
176 tasks_[0][0]->updateHistograms();
181 std::vector<uint16_t>::const_iterator ifed =
fedCabling_->
feds().begin();
184 std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
185 for ( ; iconn != conns.end(); iconn++ ) {
186 if ( !iconn->isConnected() ) {
continue; }
187 fed_id = iconn->fedId();
188 fed_ch = iconn->fedCh();
189 if (
tasks_[fed_id][fed_ch] ) {
190 tasks_[fed_id][fed_ch]->updateHistograms();
191 delete tasks_[fed_id][fed_ch];
205 std::string scratch =
"SCRATCH";
206 std::string
dir =
"";
207 if ( getenv(scratch.c_str()) !=
NULL ) {
208 dir = getenv(scratch.c_str());
212 std::stringstream ss;
213 if ( !dir.empty() ) { ss << dir <<
"/"; }
214 else { ss <<
"/tmp/"; }
226 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
227 <<
" NULL value for RunNumber! No root file saved!";
231 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
232 <<
" NULL value for filename! No root file saved!";
236 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
237 <<
" Saved all histograms to file \""
267 summary->nullParams() ) {
269 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
270 <<
" Unknown/undefined RunType and NULL parameter values!"
271 <<
" It may be that the 'trigger FED' object was not found!";
279 run_ =
event.id().run();
285 std::stringstream ss;
286 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
288 <<
" events were processed at a rate of ";
289 if (
time(
NULL) ==
time_ ) { ss <<
">" << updateFreq_ <<
" Hz"; }
306 std::stringstream ss;
307 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
308 <<
" Requested DAQ_SCOPE_MODE but unknown FED"
309 <<
" readout mode retrieved from SiStripEventSummary: "
333 std::stringstream ss;
334 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
335 <<
" Unknown CommissioningTask: "
337 <<
" Unable to establish FED readout mode and retrieve digi container!"
338 <<
" Check if SiStripEventSummary object is found/present in Event";
344 if ( &(*raw) == 0 ) {
345 std::stringstream ss;
346 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]" << std::endl
347 <<
" NULL pointer to DetSetVector!" << std::endl
348 <<
" Unable to fill histograms!";
365 uint16_t lld_channel = ( summary->
deviceId() & 0x3 ) + 1;
372 uint32_t fec_key = key_object.
key();
373 std::stringstream sss;
374 sss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
376 << std::hex << std::setw(8) << std::setfill(
'0') << summary->
dcuId() << std::dec
377 <<
" with Crate/FEC/Ring/CCU/Module/LLD: "
390 std::stringstream ss;
391 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
393 << std::hex << std::setw(8) << std::setfill(
'0') << summary->
dcuId() << std::dec
394 <<
" in 'DAQ register' field not found in cabling map!"
395 <<
" (NULL values returned for FEC path)";
401 std::vector<uint16_t>::const_iterator ifed =
fedCabling_->
feds().begin();
408 std::map<uint16_t,float> medians; medians.clear();
409 std::map<uint16_t,float> medians1; medians1.clear();
412 for ( uint16_t ichan = 0; ichan < 96; ichan++ ) {
422 std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.
find( fed_key );
423 if ( digis != raw.
end() ) {
424 if ( digis->data.empty() ) {
continue; }
435 for ( uint16_t idigi = 0; idigi < digis->data.size(); idigi++ ) {
436 ave.
add( static_cast<uint32_t>(digis->data[idigi].adc()) );
440 medians[ichan] = params.
median_;
441 medians1[ichan] = digis->data[0].adc();
466 std::map<uint16_t,float>::const_iterator ii = medians.begin();
467 for ( ; ii != medians.end(); ii++ ) { average.
add( ii->second ); }
485 std::map<uint16_t,float>::const_iterator
jj = medians.begin();
486 for ( ; jj != medians.end(); jj++ ) {
488 truncated.
add( jj->second );
492 truncated.
calc(params);
507 std::stringstream ss2;
508 std::stringstream ss3;
511 std::map<uint16_t,float> channels;
512 std::map<uint16_t,float>::const_iterator ichan = medians.begin();
513 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] <<
" ";
555 if ( !channels.empty() ) {
556 cablingTasks_[fec_key]->fillHistograms( *summary, *ifed, channels );
558 std::stringstream ss;
559 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
560 <<
" Filled histogram for '" <<
cablingTasks_[fec_key]->myName()
561 <<
"' object with FecKey: 0x"
562 << std::hex << std::setfill(
'0') << std::setw(8) << fec_key << std::dec
563 <<
" and Crate/FEC/ring/CCU/module/LLDchan: "
574 std::stringstream ss;
575 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
576 <<
" Unable to find CommissioningTask object with FecKey: 0x"
577 << std::hex << std::setfill(
'0') << std::setw(8) << fec_key << std::dec
578 <<
" and Crate/FEC/ring/CCU/module/LLDchan: "
598 std::vector<uint16_t>::const_iterator ifed =
fedCabling_->
feds().begin();
603 std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
604 for ( ; iconn != conns.end(); iconn++ ) {
606 if ( !(iconn->fedId()) || iconn->fedId() >
sistrip::valid_ ) {
continue; }
619 std::vector< edm::DetSet<SiStripRawDigi> >::const_iterator digis = raw.
find( fed_key );
621 if ( digis != raw.
end() ) {
624 if (
tasks_[0][iconn->fecCrate()-1] ) {
625 tasks_[0][iconn->fecCrate()-1]->fillHistograms( *summary, *digis );
627 std::stringstream ss;
628 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
629 <<
" Unable to find CommissioningTask for FEC crate "
630 << iconn->fecCrate() <<
". Unable to fill histograms!";
635 tasks_[0][0]->fillHistograms( *summary, *digis );
637 std::stringstream ss;
638 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
639 <<
" Unable to find global CommissioningTask for FineDelay. Unable to fill histograms!";
644 if (
tasks_[iconn->fedId()][iconn->fedCh()] ) {
645 tasks_[iconn->fedId()][iconn->fedCh()]->fillHistograms( *summary, *digis );
647 std::stringstream ss;
648 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
649 <<
" Unable to find CommissioningTask object with FED key "
650 << std::hex << std::setfill(
'0') << std::setw(8) << fed_key << std::dec
652 << iconn->fedId() <<
"/"
654 <<
" Unable to fill histograms!";
663 std::stringstream ss;
664 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
665 <<
" Unable to find any DetSet containing digis for FED key "
666 << std::hex << std::setfill(
'0') << std::setw(8) << fed_key << std::dec
668 << iconn->fedId() <<
"/"
685 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
686 <<
" NULL run number!";
692 std::stringstream
run;
708 std::stringstream ss;
709 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
710 <<
" Identified CommissioningTask from EventSummary to be \""
716 std::stringstream ss;
717 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
718 <<
" NULL pointer to SiStripEventSummary!"
719 <<
" Check SiStripEventSummary is found/present in Event";
727 std::stringstream ss;
728 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
729 <<
" Overriding CommissioningTask from EventSummary (\""
731 <<
"\") with value retrieved from .cfg file (\""
735 task_ = configurable;
746 std::stringstream ss;
747 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
748 <<
" Unexpected CommissioningTask found ("
749 <<
static_cast<uint16_t
>(
task_) <<
") \""
751 <<
" Unexpected value found in SiStripEventSummary and/or cfg file"
752 <<
" If SiStripEventSummary is not present in Event,"
753 <<
" check 'CommissioningTask' configurable in cfg file";
757 std::stringstream ss;
758 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
759 <<
" Identified CommissioningTask to be \""
769 std::stringstream ss;
770 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
771 <<
" CommissioningTask: "
776 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
777 <<
" Creating CommissioningTask objects and booking histograms...";
781 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
782 <<
" Finished booking histograms!";
794 for ( std::vector<SiStripFec>::const_iterator ifec = icrate->fecs().begin(); ifec != icrate->fecs().end(); ifec++ ) {
795 for ( std::vector<SiStripRing>::const_iterator iring = ifec->rings().begin(); iring != ifec->rings().end(); iring++ ) {
796 for ( std::vector<SiStripCcu>::const_iterator iccu = iring->ccus().begin(); iccu != iring->ccus().end(); iccu++ ) {
797 for ( std::vector<SiStripModule>::const_iterator imodule = iccu->modules().begin(); imodule != iccu->modules().end(); imodule++ ) {
804 imodule->ccuChan() );
807 if ( !
path.isValid() ) {
continue; }
814 for ( uint16_t ipair = 0; ipair < imodule->nApvPairs(); ipair++ ) {
829 imodule->nApvPairs() );
837 imodule->lldChannel(ipair) ).
key();
842 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
843 <<
" Unexpected NULL value for FEC key!";
854 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
855 <<
" Undefined CommissioningTask"
856 <<
" Unable to create FedCablingTask object!";
859 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
860 <<
" Unknown CommissioningTask"
861 <<
" Unable to create FedCablingTask object!";
864 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
865 <<
" Unexpected CommissioningTask: "
867 <<
" Unable to create FedCablingTask object!";
883 std::stringstream ss;
884 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
885 <<
" NULL pointer to CommissioningTask for key 0x"
886 << std::hex << std::setfill(
'0') << std::setw(8) << key << std::dec
887 <<
" in directory " << dir
888 <<
" Unable to book histograms!";
892 std::stringstream ss;
893 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
894 <<
" Unable to find CommissioningTask for key 0x"
895 << std::hex << std::setfill(
'0') << std::setw(8) << key << std::dec
896 <<
" in directory " << dir
897 <<
" Unable to book histograms!";
902 std::stringstream ss;
903 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
904 <<
" CommissioningTask object already exists for key 0x"
905 << std::hex << std::setfill(
'0') << std::setw(8) << key << std::dec
906 <<
" in directory " << dir
907 <<
" Unable to create FedCablingTask object!";
919 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
920 <<
" Created " << booked
921 <<
" CommissioningTask objects and booked histograms";
934 for (uint16_t partition = 0; partition < 4; ++partition) {
937 tasks_[0][partition]->eventSetup( &setup );
938 tasks_[0][partition]->bookHistograms();
947 tasks_[0][0]->eventSetup( &setup );
948 tasks_[0][0]->bookHistograms();
955 std::vector<uint16_t>::const_iterator ifed =
fedCabling_->
feds().begin();
962 std::vector<FedChannelConnection>::const_iterator iconn = conns.begin();
963 for ( ; iconn != conns.end(); iconn++ ) {
975 if ( !iconn->isConnected() ) {
continue; }
981 std::stringstream
dir;
983 if (
view_ ==
"Default") {
985 dir << fed_key.path();
987 dir << fec_key.path();
989 }
else if (
view_ ==
"FecView") {
990 dir << fec_key.path();
991 }
else if (
view_ ==
"FedView") {
992 dir << fed_key.path();
993 }
else if (
view_ ==
"DetView") {
1000 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1001 <<
" Invalid view " <<
view_ << std::endl
1002 <<
" Histograms will end up all in the top directory.";
1007 if ( !
tasks_[iconn->fedId()][iconn->fedCh()] ) {
1046 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1047 <<
" Undefined CommissioningTask"
1048 <<
" Unable to create CommissioningTask object!";
1051 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1052 <<
" Unknown CommissioningTask"
1053 <<
" Unable to create CommissioningTask object!";
1057 if (
tasks_[iconn->fedId()][iconn->fedCh()] ) {
1058 tasks_[iconn->fedId()][iconn->fedCh()]->eventSetup( &setup );
1059 tasks_[iconn->fedId()][iconn->fedCh()]->bookHistograms();
1069 std::stringstream ss;
1070 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1071 <<
" NULL pointer to CommissioningTask for key 0x"
1072 << std::hex << std::setfill(
'0') << std::setw(8) << fed_key.key() << std::dec
1073 <<
" in directory " << dir.str()
1074 <<
" Unable to book histograms!";
1079 std::stringstream ss;
1080 ss <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1081 <<
" CommissioningTask object already exists for key 0x"
1082 << std::hex << std::setfill(
'0') << std::setw(8) << fed_key.key() << std::dec
1083 <<
" in directory " << dir.str()
1084 <<
" Unable to create CommissioningTask object!";
1093 <<
"[SiStripCommissioningSource::" << __func__ <<
"]"
1094 <<
" Created " << booked
1095 <<
" CommissioningTask objects and booked histograms";
1103 if ( itask->second ) {
delete itask->second; }
1111 if (
tasks_.empty() ) {
return; }
1112 VecOfVecOfTasks::iterator ifed =
tasks_.begin();
1113 for ( ; ifed !=
tasks_.end(); ifed++ ) {
1114 VecOfTasks::iterator ichan = ifed->begin();
1115 for ( ; ichan != ifed->end(); ichan++ ) {
1116 if ( *ichan ) {
delete *ichan; *ichan = 0; }
1137 uint32_t run_number ) {
1141 gethostname( hn,
sizeof(hn) );
1143 he = gethostbyname(hn);
1146 std::string host_name;
1147 std::string host_ip;
1149 host_name = std::string(he->h_name);
1150 host_ip = std::string( inet_ntoa( *(
struct in_addr*)(he->h_addr) ) );
1152 host_name =
"unknown.cern.ch";
1153 host_ip =
"255.255.255.255";
1158 std::stringstream ip;
1160 while ( pos != std::string::npos ) {
1162 if ( tmp != std::string::npos ) {
1164 << std::setfill(
'0')
1165 << host_ip.substr( pos, tmp-pos )
1170 << std::setfill(
'0')
1171 << host_ip.substr( pos );
1172 pos = std::string::npos;
1177 pid_t
pid = getpid();
1182 << std::setfill(
'0')
1189 << 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()
const std::vector< uint16_t > & feds() const
iterator find(det_id_type id)
const uint16_t & fecRing() const
void createTask(const SiStripEventSummary *const, const edm::EventSetup &)
void rmdir(const std::string &fullpath)
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
void cd(void)
go to top directory (ie. root)
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
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
void removeContents(void)
erase all monitoring elements in current directory (not including subfolders);
MonitorElement * bookString(const char *name, const char *value)
Book string.
Class containning control, module, detector and connection information, at the level of a FED channel...
void add(const float &value, const float &weight)
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_
void setVerbose(unsigned level)
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
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_
T const * product() const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
std::vector< std::vector< double > > tmp
std::string taskConfigurable_
SiStripFedCabling * fedCabling_
const uint16_t & feChan() const
static const char root_[]
const uint16_t & ccuChan() const
~SiStripCommissioningSource()
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
void fillHistos(const SiStripEventSummary *const, const edm::DetSetVector< SiStripRawDigi > &)
void setCurrentFolder(const std::string &fullpath)
const std::vector< FedChannelConnection > & connections(uint16_t fed_id) const
SiStripCommissioningSource()
static std::string fedReadoutMode(const sistrip::FedReadoutMode &)