5 #include <xercesc/dom/DOMNode.hpp> 6 #include <xercesc/dom/DOM.hpp> 7 #include <xercesc/parsers/XercesDOMParser.hpp> 9 #include <xercesc/util/XMLString.hpp> 10 #include <xercesc/sax/SAXException.hpp> 11 #include <xercesc/framework/LocalFileFormatTarget.hpp> 34 : m_name(ps.getUntrackedParameter<
std::
string>(
"name",
"EcalSRPHandler")) {
54 std::ostringstream ss;
57 unsigned long long max_since = 1;
66 <<
"\n retrieved last payload " << std::endl;
96 std::cout <<
"Retrieving DAQ status from OMDS DB ... " << std::endl;
98 std::cout <<
"Connection done" << std::endl;
101 std::cout <<
" Problem with OMDS: connection parameters " <<
m_sid <<
"/" <<
m_user << std::endl;
119 min_run= (
int)max_since+1;
125 std::cout <<
"min_run " << min_run <<
" max_run " << max_run << std::endl;
130 sprintf(outfile,
"SRP_run%d.txt",min_run);
132 fout <<
" ORCOFF last run max_since : " << max_since << std::endl;
139 std::vector<RunIOV> run_vec = my_list.
getRuns();
140 int num_runs = run_vec.size();
143 fout <<
" number of runs is : " << num_runs << std::endl;
145 unsigned long irun = 0;
147 int fe_conf_id_old = 0;
150 for(
int kr = 0; kr < num_runs; kr++) {
152 std::string geneTag = run_vec[kr].getRunTag().getGeneralTag();
153 if(geneTag !=
"GLOBAL") {
155 fout <<
"\n New run " << irun <<
" with tag " << geneTag <<
" giving up " << std::endl;
159 fout <<
"\n New run " << irun <<
" geneTag " << geneTag << std::endl;
162 std::map<EcalLogicID, RunConfigDat>
dataset;
165 int myconfig_version = 0;
166 std::map< EcalLogicID, RunConfigDat>::const_iterator it;
167 if(dataset.size() != 1) {
168 std::cout <<
"\n\n run " << irun <<
" strange number of dataset " 169 << dataset.size() << std::endl;
171 fout <<
"\n\n run " << irun <<
" strange number of dataset " 172 << dataset.size() <<
" giving up " << std::endl;
176 it = dataset.begin();
179 if(myconfig_tag.substr(0,15) ==
"ZeroSuppression") {
181 fout <<
" run " << irun <<
" tag " << myconfig_tag <<
" giving up " << std::endl;
186 typedef std::map<EcalLogicID, RunFEConfigDat>::const_iterator feConfIter;
187 std::map<EcalLogicID, RunFEConfigDat> feconfig;
189 if(feconfig.size() != 1) {
191 fout <<
"\n\n run " << irun <<
" strange number of FE config " 192 << feconfig.size() <<
" giving up " << std::endl;
197 feConfIter
p=feconfig.begin();
203 fout <<
" run " << irun <<
" tag " << myconfig_tag
204 <<
" version " << myconfig_version
205 <<
" Fe config " << fe_conf_id << std::endl;
207 if(myconfig_tag !=
m_i_tag || myconfig_version !=
m_i_version || fe_conf_id != fe_conf_id_old) {
209 fout <<
" run= " << irun
210 <<
" different tag ... retrieving last config set from DB" << std::endl;
212 bool FromCLOB =
false;
219 od_run_info.
setTag(myconfig_tag);
223 econn-> fetchConfigSet(&od_run_info);
224 int config_id = od_run_info.
getId();
229 econn-> fetchConfigSet(&seq);
234 econn-> fetchConfigSet(&ecal_cycle);
235 int cycle_id = ecal_cycle.
getId();
239 fout <<
" no SRP config for this run, give up " << std::endl;
245 fout <<
" cycleid " << cycle_id <<
" SRP id " << srp_id <<
" DCC id " << dcc_id << std::endl;
251 econn-> fetchConfigSet(&srp);
259 for (std::string::iterator it = SRPClob.begin() ; it < SRPClob.end(); it++ )
262 std::ifstream
f(
"srp.txt");
264 throw cms::Exception(
"EcalSRPHandler") <<
" Failed to open file srp.txt";
266 fout <<
" Failed to open file srp.txt" << std::endl;
270 int rv = system(
"rm srp.txt");
271 if(
m_debug && rv != 0) fout <<
"rm srp.txt result code: " << rv <<
"\n";
281 econn-> fetchConfigSet(&dcc);
284 fout <<
" DCC weightsMode " << weightsMode << std::endl
286 if(weightsMode ==
"CLOB") {
289 fout <<
" will read weights from DCC CLOB " << std::endl;
295 std::ostringstream osd;
299 for (std::string::iterator it = DCCClob.begin() ; it < DCCClob.end(); it++ )
305 rv = system(
"rm dcc.txt");
306 if(
m_debug && rv != 0) fout <<
"rm dcc.txt result code: " << rv <<
"\n";
310 std::cout <<
"ERROR: This config does not exist: tag " << myconfig_tag
311 <<
" version "<< myconfig_version<< std::endl;
313 fout <<
"ERROR: This config does not exist: tag " << myconfig_tag
314 <<
" version "<< myconfig_version<< std::endl;
318 fout <<
" FromCLOB " << FromCLOB << std::endl;
322 myconfig.
setId(fe_conf_id);
328 fout <<
" WEI_ID " << mywei << std::endl;
336 fout <<
" SAMPLE_ID " << mySample << std::endl;
340 weights.
setId(mywei);
343 std::vector<std::vector<float> > my_dccw = weights.
getWeight();
344 int imax = my_dccw.size();
346 fout <<
" weight size before check " << imax << std::endl;
348 bool WeightsChange =
false, WeightsChangeEB =
false, WeightsChangeEE =
false;
349 for (
int i = 1;
i < 61200 ;
i++)
350 for (
int ich = 0; ich < 6 ; ich++)
351 if(my_dccw[
i][ich] != my_dccw[0][ich]) WeightsChangeEB =
true;
353 fout <<
" WeightsChangeEB " << WeightsChangeEB << std::endl;
354 for(
int i = 61201;
i < 75848 ;
i++)
355 for (
int ich = 0; ich < 6 ; ich++)
356 if(my_dccw[
i][ich] != my_dccw[61200][ich]) WeightsChangeEE =
true;
358 fout <<
" WeightsChangeEE " << WeightsChangeEE << std::endl;
359 for(
int ich = 0; ich < 6 ; ich++)
360 if(my_dccw[0][ich] != my_dccw[61200][ich]) WeightsChange =
true;
362 fout <<
" WeightsChange " << WeightsChange << std::endl;
364 if(WeightsChangeEB || WeightsChangeEE)
366 else if (WeightsChange) {
367 std::vector<float> dccwRowEB, dccwRowEE;
368 for (
int ich = 0; ich < 6 ; ich++) {
369 dccwRowEB.push_back(my_dccw[0][ich]);
370 dccwRowEE.push_back(my_dccw[61200][ich]);
376 std::vector<float> dccwRow;
377 for (
int ich = 0; ich < 6 ; ich++) {
378 dccwRow.push_back(my_dccw[0][ich]);
383 for(
int ich = 0; ich < 6 ; ich++)
400 float def[] = {-1215, 20, 297, 356, 308, 232};
401 std::vector<float> dccw(def,def+6);
403 fout <<
" default weights " ;
404 for(
int i = 0;
i < 6;
i++) {
406 fout <<
" i " <<
i <<
" def " << def [
i] <<
" dccw " << dccw[
i] <<
" \n";
413 fout <<
" weight size " << imax <<
" normalized weights : "<< std::endl;
414 for(
int i = 0;
i < imax ;
i++)
415 for(
int ich = 0; ich < 6 ; ich++) {
425 fout <<
" checking for change " << std::endl;
426 bool nochange =
true;
427 int imaxref, imaxnew;
434 if(imaxref != imaxnew) {
435 fout <<
" deltaEta_ size ref " << imaxref <<
" now " << imaxnew << std::endl;
438 for(
int i = 0;
i < imaxref ;
i++) {
440 fout <<
" deltaEta_[" <<
i <<
"] ref "<< sref->
deltaEta_[
i]
453 if(imaxref != imaxnew) {
454 fout <<
" deltaPhi size ref " << imaxref <<
" now " << imaxnew << std::endl;
457 for(
int i = 0;
i < imaxref ;
i++) {
459 fout <<
" deltaPhi[" <<
i <<
"] ref "<< sref->
deltaPhi_[
i]
472 if(imaxref != imaxnew) {
473 fout <<
" ecalDccZs1stSample size ref " << imaxref <<
" now " << imaxnew << std::endl;
476 for(
int i = 0;
i < imaxref ;
i++) {
498 if(imaxref != imaxnew) {
499 fout <<
" dccNormalizedWeights size ref " << imaxref <<
" now " << imaxnew << std::endl;
503 for(
int ich = 0; ich < 6 ; ich++) {
505 fout <<
" dccNormalizedWeights_[" << i <<
"][" << ich <<
"] ref " 519 if(imaxref != imaxnew) {
520 fout <<
" symetricZS size ref " << imaxref <<
" now " << imaxnew << std::endl;
523 for(
int i = 0;
i < imaxref ;
i++) {
525 fout <<
" symetricZS[" <<
i <<
"] ref "<< sref->
symetricZS_[
i]
538 if(imaxref != imaxnew) {
539 fout <<
" srpLowInterestChannelZS size ref " << imaxref <<
" now " << imaxnew << std::endl;
542 for(
int i = 0;
i < imaxref ;
i++) {
557 if(imaxref != imaxnew) {
558 fout <<
" srpHighInterestChannelZS size ref " << imaxref <<
" now " << imaxnew << std::endl;
561 for(
int i = 0;
i < imaxref ;
i++) {
574 for(
int i = 0;
i < 4;
i++) {
576 fout <<
" actions " <<
i <<
" ref " << sref->
actions_[
i]
577 <<
" now " << sr->
actions_[
i] << std::endl;
586 for(
int i = 0;
i < 108;
i++) {
598 for(
int i = 0;
i < 12;
i++) {
599 for(
int ich = 0; ich < 8; ich++) {
612 for(
int i = 0;
i < 54;
i++) {
614 fout <<
" dccMasks " <<
i <<
" ref " << sref->
dccMasks_[
i]
624 for(
int i = 0;
i < 12;
i++) {
626 fout <<
" srfMasks " <<
i <<
" ref " << sref->
srfMasks_[
i]
636 for(
int i = 0;
i < 12;
i++) {
637 for(
int ich = 0; ich < 68; ich++) {
639 fout <<
" substitutionSrfs " <<
i <<
" " << ich <<
" ref " << sref->
substitutionSrfs_[
i][ich]
650 for(
int i = 0;
i < 12;
i++) {
660 for(
int i = 0;
i < 12;
i++) {
669 for(
int i = 0;
i < 12;
i++) {
678 for(
int i = 0;
i < 12;
i++) {
687 for(
int i = 0;
i < 12;
i++) {
688 fout <<
" bxOffsets " <<
i <<
" ref " << sref->
bxOffsets_[
i]
716 fout <<
" no change has been found " << std::endl;
717 std::ostringstream ss;
718 ss <<
"Run=" << irun <<
"_SRPunchanged_"<<std::endl;
723 fout <<
" Change has been found !\n New payload :" << std::endl;
732 std::ostringstream ss;
733 ss <<
"Run=" << irun <<
"_SRPchanged_"<<std::endl;
741 fe_conf_id_old = fe_conf_id;
755 XercesDOMParser*
parser =
new XercesDOMParser;
756 parser->setValidationScheme( XercesDOMParser::Val_Never );
757 parser->setDoNamespaces(
false );
758 parser->setDoSchema(
false );
760 parser->parse(filename.c_str());
762 DOMDocument* xmlDoc = parser->getDocument();
764 std::cout <<
"importDccConfigFile Error parsing document" << std::endl;
767 DOMElement* element = xmlDoc->getDocumentElement();
772 int L1ZS[2] = {0, 0}, L2ZS[2] = {0, 0};
773 for (DOMNode* childNode = element->getFirstChild();
774 childNode; childNode = childNode->getNextSibling()) {
775 if (childNode->getNodeType() == DOMNode::ELEMENT_NODE) {
777 DOMElement *
child =
static_cast<DOMElement *
>(childNode);
778 DOMNamedNodeMap *attributes = child->getAttributes();
779 unsigned int numAttributes = attributes->getLength();
780 for (
unsigned int j = 0; j < numAttributes; ++j) {
781 DOMNode *attributeNode = attributes->item(j);
782 DOMAttr *attribute =
static_cast<DOMAttr *
>(attributeNode);
785 if(info ==
"_scope") {
786 if(scope.substr(0,2) ==
"EE") EBEE = 1;
791 for (DOMNode* subchildNode = childNode->getFirstChild();
792 subchildNode; subchildNode = subchildNode->getNextSibling()) {
793 if (subchildNode->getNodeType() == DOMNode::ELEMENT_NODE) {
796 for (DOMNode* subsubchildNode = subchildNode->getFirstChild();
797 subsubchildNode; subsubchildNode = subsubchildNode->getNextSibling()) {
798 if (subsubchildNode->getNodeType() == DOMNode::ELEMENT_NODE) {
800 if(subName ==
"L1ZSUPPRESSION")
802 if(subName ==
"L2ZSUPPRESSION")
804 if(subName ==
"FIRSTZSSAMPLE") {
809 if(subName ==
"CXTALWEIGHTS") {
810 std::vector<float> dcc(6);
812 for(
int iw = 0; iw < 6; iw++) {
834 fout <<
" deltaEta[" << imax <<
"] ";
835 for(
int i = 0;
i < imax ;
i++) {
841 fout <<
" deltaPhi[" << imax <<
"] ";
842 for(
int i = 0;
i < imax ;
i++) {
848 fout <<
" ecalDccZs1stSample[" << imax <<
"] ";
849 for(
int i = 0;
i < imax ;
i++) {
858 fout <<
" dccNormalizedWeights" << std::endl;
860 fout <<
" Channel " <<
i;
867 fout <<
" symetricZS["<< imax <<
"] ";
868 for(
int i = 0;
i < imax ;
i++) {
874 fout <<
" srpLowInterestChannelZS["<< imax <<
"] ";
875 for(
int i = 0;
i < imax ;
i++) {
881 fout <<
" srpHighInterestChannelZS["<< imax <<
"] ";
882 for(
int i = 0;
i < imax ;
i++) {
888 fout <<
" actions["<< imax <<
"] ";
889 for(
int i = 0;
i < imax ;
i++) {
895 fout <<
" tccMasksFromConfig["<< imax <<
"] ";
896 for(
int i = 0;
i < imax ;
i++) {
901 fout <<
" srpMasksFromConfig" << std::endl;
909 fout <<
" dccMasks[" << imax <<
"] ";
910 for(
int i = 0;
i < imax ;
i++) {
916 fout <<
" srfMasks[" << imax <<
"] ";
917 for(
int i = 0;
i < imax ;
i++) {
922 fout <<
"substitutionSrfs" << std::endl;
930 fout <<
" testerTccEmuSrpIds[" << imax <<
"] ";
931 for(
int i = 0;
i < imax ;
i++) {
937 fout <<
" testerSrpEmuSrpIds[" << imax <<
"] ";
938 for(
int i = 0;
i < imax ;
i++) {
944 fout <<
" testerDccTestSrpIds[" << imax <<
"] ";
945 for(
int i = 0;
i < imax ;
i++) {
950 imax = sr. testerSrpTestSrpIds_.size();
951 fout <<
" testerSrpTestSrpIds[" << imax <<
"] ";
952 for(
int i = 0;
i < imax ;
i++) {
958 fout <<
" bxOffsets[" << imax <<
"] ";
959 for(
int i = 0;
i < imax ;
i++) {
T getParameter(std::string const &) const
void setRunTypeDef(const RunTypeDef &runTypeDef)
void setSequenceId(int x)
unsigned int getDCCClobSize() const
std::vector< RunIOV > getRuns()
std::string m_userTextLog
edm::Ref< Container > Ref
EcalCondDBInterface * econn
void setSequenceNumber(int x)
std::vector< short > srfMasks_
EcalSRPHandler(edm::ParameterSet const &)
std::vector< std::vector< float > > dccNormalizedWeights_
std::vector< int > testerSrpEmuSrpIds_
unsigned int getSRPClobSize() const
void fetchConfigSet(ICONF *iconf) noexcept(false)
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
OldContainer m_to_transfer
std::vector< float > srpHighInterestChannelZS_
int getSequenceId() const
std::vector< int > actions_
int getAutomaticMasks() const
std::string toString(XMLCh const *toTranscode)
cond::ValidityInterval lastInterval
std::vector< std::vector< short > > substitutionSrfs_
std::vector< int > testerDccTestSrpIds_
void ChangePayload(EcalSRSettings &sref, EcalSRSettings &sr)
int getConfigVersion() const
std::vector< int > ecalDccZs1stSample_
int getAutomaticSrpSelect() const
std::string getDCCWeightsMode() const
std::vector< short > tccMasksFromConfig_
void setLocationDef(const LocationDef &locDef)
std::vector< short > bxOffsets_
int getSRP0BunchAdjustPosition() const
std::vector< short > dccMasks_
std::vector< int > deltaPhi_
RunList fetchRunListByLocation(const RunTag &tag, int min_run, int max_run, const LocationDef &locDef) noexcept(false)
unsigned char * getDCCClob() const
void getNewObjects() override
unsigned char * getSRPClob() const
std::vector< std::vector< float > > getWeight() const
def getRunNumber(filename)
void GetNodeData(xercesc::DOMNode *node, T &value)
get the node data
std::vector< int > symetricZS_
void setRunType(std::string runtype)
float ebDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EB.
void importDccConfigFile(EcalSRSettings &sr, const std::string &filename, bool debug=false)
std::vector< int > testerTccEmuSrpIds_
void setEcalConfigId(int x)
std::vector< float > srpLowInterestChannelZS_
std::vector< int > deltaEta_
std::string getConfigTag() const
std::vector< int > testerSrpTestSrpIds_
void setTag(std::string x)
~EcalSRPHandler() override
void setLocation(std::string loc)
float eeDccAdcToGeV_
ADC to GeV conversion factor used in ZS filter for EE.
void setGeneralTag(std::string tag)
void PrintPayload(EcalSRSettings &sr, std::ofstream &fout)
std::vector< std::vector< short > > srpMasksFromConfig_
cond::TagInfo_t const & tagInfo() const