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