CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalDQMDbInterface.cc
Go to the documentation of this file.
2 
3 XERCES_CPP_NAMESPACE_USE
4 
5 namespace {
6  template <class T> XMLCh* transcode (const T& fInput) {
7  std::ostringstream ost;
8  ost << fInput;
9  return XMLString::transcode(ost.str().c_str());
10  }
11 }
12 
13 DOMElement* HcalDQMDbInterface::createElement(DOMDocument* doc, DOMElement* parent, const char* name){
14  DOMElement* elem = doc->createElement(XML(name));
15  parent->appendChild(elem);
16  return elem;
17 }
18 
19 DOMElement* HcalDQMDbInterface::createElement(DOMDocument* doc, DOMElement* parent, const char* name, const char* value){
20  DOMElement* elem = createElement(doc,parent,name);
21  elem->appendChild(doc->createTextNode(XML(value)));
22  return elem;
23 }
24 
26  DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(XML("Core"));
27  return impl->createDocument(0,XML("ROOT"),0);
28 }
29 
30 void HcalDQMDbInterface::writeDocument(DOMDocument* doc, const char* xmlFile){
31  DOMImplementation* impl = DOMImplementationRegistry::getDOMImplementation(XML("Core"));
32  DOMWriter *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
33  if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
34  theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
35  if (theSerializer->canSetFeature(XMLUni::fgDOMWRTBOM, true))
36  theSerializer->setFeature(XMLUni::fgDOMWRTBOM, true);
37  XMLFormatTarget *myFormTarget = new LocalFileFormatTarget(xmlFile);
38  theSerializer->writeNode(myFormTarget, *doc);
39  delete theSerializer;
40  delete myFormTarget;
41 }
42 
43 DOMElement* HcalDQMDbInterface::createFooter(DOMDocument* doc,
44  unsigned long long fIovBegin, unsigned long long fIovEnd,
45  const char* fTagName, const char* fDetectorName, const char* fComment){
46 
47  DOMElement* parent = doc->getDocumentElement();
48  DOMElement* elems = createElement(doc,parent,"ELEMENTS");
49  DOMElement* dataset = createElement(doc, elems, "DATA_SET");
50  dataset->setAttribute(transcode("id"), transcode("-1"));
51  createIOV(doc,elems,fIovBegin,fIovEnd);
52  createTag(doc,elems,fTagName,fDetectorName,fComment);
53 
54  DOMElement* maps = createElement(doc,parent, "MAPS");
55  DOMElement* mapTag = makeMapTag(doc,maps);
56  DOMElement* mapIov = makeMapIOV(doc,mapTag);
57  makeMapDataset(doc,mapIov);
58 
59  return elems;
60 }
61 
62 DOMElement* HcalDQMDbInterface::makeMapTag(DOMDocument* doc,DOMElement* fMap) {
63  DOMElement* tag = createElement(doc, fMap, "TAG");
64  tag->setAttribute(transcode("idref"), transcode("TAG_ID"));
65  return tag;
66 }
67 
68 DOMElement* HcalDQMDbInterface::makeMapIOV(DOMDocument* doc,DOMElement* fTag) {
69  DOMElement* iov = createElement(doc,fTag, "IOV");
70  iov->setAttribute(transcode("idref"), transcode("IOV_ID"));
71  return iov;
72 }
73 
74 DOMElement* HcalDQMDbInterface::makeMapDataset(DOMDocument* doc,DOMElement* fIov) {
75  DOMElement* element = createElement(doc,fIov, "DATA_SET");
76  element->setAttribute(transcode("idref"), transcode("-1"));
77  return element;
78 }
79 
80 DOMElement* HcalDQMDbInterface::createIOV(DOMDocument* doc,DOMElement* parent,
81  unsigned long long fIovBegin, unsigned long long fIovEnd) {
82  DOMElement* iov = createElement(doc,parent,"IOV");
83  iov->setAttribute(transcode("id"), transcode("IOV_ID"));
84 
85  createElement(doc,iov,"INTERVAL_OF_VALIDITY_BEGIN", itoa(fIovBegin));
86  if(fIovEnd) {
87  createElement(doc,iov,"INTERVAL_OF_VALIDITY_END", itoa(fIovEnd));
88  }
89  return iov;
90 }
91 
92 DOMElement* HcalDQMDbInterface::createTag(DOMDocument* doc,DOMElement* parent,
93  const char* fTagName, const char* fDetectorName, const char* fComment) {
94  DOMElement* tag = createElement(doc,parent,"TAG");
95  tag->setAttribute(transcode("id"), transcode ("TAG_ID"));
96  tag->setAttribute(transcode("mode"), transcode ("auto"));
97 
98  createElement(doc,tag,"TAG_NAME", fTagName);
99  createElement(doc,tag,"DETECTOR_NAME", fDetectorName);
100  createElement(doc,tag,"COMMENT_DESCRIPTION", fComment);
101 
102  return tag;
103 }
104 
105 
106 void HcalHotCellDbInterface::createHeader(DOMDocument* doc, unsigned int runno, const char* startTime){
107  DOMElement* parent = doc->getDocumentElement();
108  DOMElement* headerElem = createElement(doc,parent,"HEADER");
109  DOMElement* typeElem = createElement(doc,headerElem,"TYPE");
110  createElement(doc,typeElem,"EXTENSION_TABLE_NAME","HCAL_CHANNEL_ON_OFF_STATES");
111  createElement(doc,typeElem,"NAME","HCAL channel on off states");
112  DOMElement* runElem = createElement(doc,headerElem,"RUN");
113  createElement(doc,runElem,"RUN_TYPE","hcal-dqm-onoff-test");
114  createElement(doc,runElem,"RUN_NUMBER",itoa(runno));
115  createElement(doc,runElem,"RUN_BEGIN_TIMESTAMP",startTime);
116  createElement(doc,runElem,"COMMENT_DESCRIPTION","dqm data");
117 }
118 
119 DOMElement* HcalDQMDbInterface::createChannel(DOMDocument* doc,DOMElement* parent, HcalDetId id){
120  HcalText2DetIdConverter converter(id);
121  DOMElement* chanElem = createElement(doc,parent,"CHANNEL");
122  createElement(doc,chanElem,"EXTENSION_TABLE_NAME","HCAL_CHANNELS");
123  createElement(doc,chanElem,"ETA",itoa(id.ietaAbs()));
124  createElement(doc,chanElem,"PHI",itoa(id.iphi()));
125  createElement(doc,chanElem,"DEPTH",itoa(id.depth()));
126  createElement(doc,chanElem,"Z",itoa(id.zside()));
127  createElement(doc,chanElem,"DETECTOR_NAME",converter.getFlavor().c_str());
128  createElement(doc,chanElem,"HCAL_CHANNEL_ID",itoa(id.rawId()));
129  return chanElem;
130 }
131 
132 DOMElement* HcalHotCellDbInterface::createData(DOMDocument* doc,DOMElement* parent, const HcalDQMChannelQuality::Item& item){
133  DOMElement* dataElem = createElement(doc,parent,"DATA");
134  createElement(doc,dataElem,"CHANNEL_ON_OFF_STATE",itoa(item.mMasked));
135  createElement(doc,dataElem,"CHANNEL_STATUS_WORD",itoa(item. mQuality));
136  createElement(doc,dataElem,"COMMENT_DESCRIPTION",item.mComment.c_str());
137  return dataElem;
138 }
139 
140 
142  const HcalDQMChannelQuality::Item& item,
143  const char* gmtime,
144  const char* version){
145 
146  DOMElement* parent = doc->getDocumentElement();
147  DOMElement* dataSetElem = createElement(doc,parent,"DATA_SET");
148  createElement(doc,dataSetElem,"VERSION",version);
149  createElement(doc,dataSetElem,"CREATION_TIMESTAMP",gmtime);
150  createElement(doc,dataSetElem,"CREATED_BY","wfisher");
151 
152  HcalDetId id(item.mId);
153  createChannel(doc, dataSetElem, id);
154  createData(doc, dataSetElem,item);
155 }
156 
158  DOMElement* parent = doc->getDocumentElement();
159  DOMElement* headerElem = createElement(doc,parent,"HEADER");
160  DOMElement* typeElem = createElement(doc,headerElem,"TYPE");
161  createElement(doc,typeElem,"EXTENSION_TABLE_NAME","HCAL_HLX_MASKS_TYPE01");
162  createElement(doc,typeElem,"NAME","HCAL HLX masks [type 1]");
163  DOMElement* element= createElement(doc,headerElem,"RUN");
164  element->setAttribute(transcode("mode"), transcode("no-run"));
165 }
166 
167 void HcalHLXMaskDbInterface::createData(DOMDocument* doc,DOMElement* parent, const HcalHLXMask& masks){
168  DOMElement* dataElem = createElement(doc,parent,"DATA");
169  createElement(doc, dataElem, "FPGA", masks.position);
170  char tmp[5] = "fooo";
171  sprintf(tmp,"%i",masks.occMask);
172  createElement(doc, dataElem, "OCC_MASK", tmp);
173  sprintf(tmp,"%i",masks.lhcMask);
174  createElement(doc, dataElem, "LHC_MASK", tmp);
175  sprintf(tmp,"%i",masks.sumEtMask);
176  createElement(doc, dataElem, "SUM_ET_MASK", tmp);
177 }
178 
179 DOMElement* HcalHLXMaskDbInterface::createDataset(DOMDocument* doc,
180  const HcalHLXMask& masks,
181  const char* gmtime,
182  const char* version, const char* subversion){
183 
184  DOMElement* parent = doc->getDocumentElement();
185  DOMElement* dataSetElem = createElement(doc,parent,"DATA_SET");
186  createElement(doc,dataSetElem,"VERSION",version);
187  createElement(doc,dataSetElem,"SUBVERSION",subversion);
188  createElement(doc,dataSetElem,"CREATION_TIMESTAMP",gmtime);
189  createElement(doc,dataSetElem,"CREATED_BY","jwerner");
190 
191  DOMElement* partAssElem = createElement(doc,dataSetElem,"PART_ASSEMBLY");
192  DOMElement* parentPartAssElem = createElement(doc,partAssElem,"PARENT_PART");
193  createElement(doc, parentPartAssElem, "KIND_OF_PART", "HCAL HTR Crate");
194  char tmp[5];
195  if(masks.crateId <10){ sprintf(tmp,"CRATE0%i",masks.crateId);}
196  else{ sprintf(tmp,"CRATE%i",masks.crateId);}
197  createElement(doc, parentPartAssElem, "NAME_LABEL",tmp);
198  //end PARENT_PART
199  DOMElement* childUniqueIdByElem = createElement(doc,partAssElem,"CHILD_UNIQUELY_IDENTIFIED_BY");
200  createElement(doc, childUniqueIdByElem, "KIND_OF_PART", "HCAL HTR Crate Slot");
201  DOMElement* attributeElem = createElement(doc,childUniqueIdByElem,"ATTRIBUTE");
202  createElement(doc, attributeElem, "NAME", "HCAL HTR Slot Number");
203  createElement(doc, attributeElem, "VALUE", itoa(masks.slotId));
204  //end attribute
205  //end child uni...
206  //end part assembly
207 
208  return dataSetElem;
209 }
XERCES_CPP_NAMESPACE::DOMElement * createIOV(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *parent, unsigned long long fIovBegin, unsigned long long fIovEnd)
XERCES_CPP_NAMESPACE::DOMElement * makeMapDataset(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *fIov)
XERCES_CPP_NAMESPACE::DOMElement * createData(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *parent, const HcalDQMChannelQuality::Item &item)
unsigned int lhcMask
Definition: HcalHLXMask.h:10
void createData(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *parent, const HcalHLXMask &mask)
int zside(DetId const &)
XERCES_CPP_NAMESPACE::DOMElement * createElement(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *parent, const char *name)
XERCES_CPP_NAMESPACE::DOMDocument * createDocument()
unsigned int sumEtMask
Definition: HcalHLXMask.h:11
unsigned int occMask
Definition: HcalHLXMask.h:9
#define XML(str)
XERCES_CPP_NAMESPACE::DOMElement * createTag(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *parent, const char *fTagName, const char *fDetectorName, const char *fComment)
XERCES_CPP_NAMESPACE::DOMElement * createChannel(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *parent, HcalDetId id)
tuple iov
Definition: o2o.py:307
unsigned int crateId
Definition: HcalHLXMask.h:7
void writeDocument(XERCES_CPP_NAMESPACE::DOMDocument *doc, const char *xmlFile)
XMLCh * transcode(const T &fInput)
void createHeader(XERCES_CPP_NAMESPACE::DOMDocument *doc)
char * position
Definition: HcalHLXMask.h:6
void createDataset(XERCES_CPP_NAMESPACE::DOMDocument *doc, const HcalDQMChannelQuality::Item &item, const char *gmtime, const char *version)
XERCES_CPP_NAMESPACE::DOMElement * makeMapIOV(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *fTag)
void createHeader(XERCES_CPP_NAMESPACE::DOMDocument *doc, unsigned int runno, const char *startTime)
bool xmlFile(const std::string fParam)
const char * itoa(int i)
XERCES_CPP_NAMESPACE::DOMElement * createDataset(XERCES_CPP_NAMESPACE::DOMDocument *doc, const HcalHLXMask &mask, const char *gmtime, const char *version, const char *subversion)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
constexpr uint32_t masks[]
Definition: CaloRecHit.cc:12
unsigned int slotId
Definition: HcalHLXMask.h:8
const std::string & getFlavor() const
XERCES_CPP_NAMESPACE::DOMElement * createFooter(XERCES_CPP_NAMESPACE::DOMDocument *doc, unsigned long long fIovBegin, unsigned long long fIovEnd, const char *fTagName, const char *fDetectorName, const char *fComment)
long double T
XERCES_CPP_NAMESPACE::DOMElement * makeMapTag(XERCES_CPP_NAMESPACE::DOMDocument *doc, XERCES_CPP_NAMESPACE::DOMElement *fMap)