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