CMS 3D CMS Logo

HcalDQMDbInterface.cc

Go to the documentation of this file.
00001 #include "DQM/HcalMonitorClient/interface/HcalDQMDbInterface.h"
00002 
00003 using namespace std;
00004 
00005 namespace {
00006   template <class T> XMLCh* transcode (const T& fInput) {
00007     ostringstream ost;
00008     ost << fInput;
00009     return XMLString::transcode(ost.str().c_str());
00010   } 
00011 }
00012 
00013 DOMElement* HcalDQMDbInterface::createElement(DOMDocument* doc, DOMElement* parent, char* name){
00014   DOMElement*  elem = doc->createElement(XML(name));
00015   parent->appendChild(elem);
00016   return elem;
00017 }
00018 
00019 DOMElement* HcalDQMDbInterface::createElement(DOMDocument* doc, DOMElement* parent, char* name, char* value){
00020   DOMElement*  elem = createElement(doc,parent,name);
00021   elem->appendChild(doc->createTextNode(XML(value)));
00022   return elem;
00023 }
00024 
00025 DOMElement* HcalDQMDbInterface::createElement(DOMDocument* doc, DOMElement* parent, char* name, const char* value){
00026   DOMElement*  elem = createElement(doc,parent,name);
00027   elem->appendChild(doc->createTextNode(XML(value)));
00028   return elem;
00029 }
00030 
00031 DOMDocument* HcalDQMDbInterface::createDocument(){
00032   DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(XML("Core"));
00033   return impl->createDocument(0,XML("ROOT"),0);
00034 }
00035 
00036 void HcalDQMDbInterface::writeDocument(DOMDocument* doc, const char* xmlFile){
00037   DOMImplementation* impl =  DOMImplementationRegistry::getDOMImplementation(XML("Core"));
00038   DOMWriter *theSerializer = ((DOMImplementationLS*)impl)->createDOMWriter();
00039   if (theSerializer->canSetFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true))
00040     theSerializer->setFeature(XMLUni::fgDOMWRTFormatPrettyPrint, true);
00041   if (theSerializer->canSetFeature(XMLUni::fgDOMWRTBOM, true))
00042     theSerializer->setFeature(XMLUni::fgDOMWRTBOM, true);
00043   XMLFormatTarget *myFormTarget = new LocalFileFormatTarget(xmlFile);
00044   theSerializer->writeNode(myFormTarget, *doc);
00045   delete theSerializer;
00046   delete myFormTarget;
00047 }
00048 
00049 DOMElement* HcalDQMDbInterface::createFooter(DOMDocument* doc,
00050                                              unsigned long long fIovBegin, unsigned long long fIovEnd,
00051                                              const char* fTagName, const char* fDetectorName, const char* fComment){
00052   
00053   DOMElement* parent = doc->getDocumentElement();
00054   DOMElement* elems = createElement(doc,parent,"ELEMENTS");
00055   DOMElement* dataset = createElement(doc, elems, "DATA_SET");
00056   dataset->setAttribute(transcode("id"), transcode("-1"));
00057   createIOV(doc,elems,fIovBegin,fIovEnd);
00058   createTag(doc,elems,fTagName,fDetectorName,fComment);
00059 
00060   DOMElement* maps = createElement(doc,parent,"MAPS");
00061   DOMElement* mapTag = makeMapTag(doc,maps);
00062   DOMElement* mapIov = makeMapIOV(doc,mapTag);
00063   makeMapDataset(doc,mapIov);
00064 
00065   return elems;
00066 }
00067 
00068 DOMElement* HcalDQMDbInterface::makeMapTag(DOMDocument* doc,DOMElement* fMap) {
00069   DOMElement* tag = createElement(doc, fMap, "TAG");
00070   tag->setAttribute(transcode("idref"), transcode("TAG_ID"));
00071   return tag;
00072 }
00073 
00074 DOMElement* HcalDQMDbInterface::makeMapIOV(DOMDocument* doc,DOMElement* fTag) {
00075   DOMElement* iov = createElement(doc,fTag, "IOV");
00076   iov->setAttribute(transcode("idref"), transcode("IOV_ID"));
00077   return iov;
00078 }
00079 
00080 DOMElement* HcalDQMDbInterface::makeMapDataset(DOMDocument* doc,DOMElement* fIov) {
00081   DOMElement* element = createElement(doc,fIov, "DATA_SET");
00082   element->setAttribute(transcode("idref"), transcode("-1"));
00083   return element;
00084 }
00085 
00086 DOMElement* HcalDQMDbInterface::createIOV(DOMDocument* doc,DOMElement*  parent, 
00087                                           unsigned long long fIovBegin, unsigned long long fIovEnd) {
00088   DOMElement* iov = createElement(doc,parent,"IOV");
00089   iov->setAttribute(transcode("id"), transcode("IOV_ID"));
00090   
00091   createElement(doc,iov,"INTERVAL_OF_VALIDITY_BEGIN", itoa(fIovBegin));
00092   if(fIovEnd) {
00093     createElement(doc,iov,"INTERVAL_OF_VALIDITY_END", itoa(fIovEnd));
00094   }
00095   return iov;
00096 }
00097 
00098 DOMElement* HcalDQMDbInterface::createTag(DOMDocument* doc,DOMElement*  parent, 
00099                                            const char* fTagName, const char* fDetectorName, const char* fComment) {
00100   DOMElement* tag = createElement(doc,parent,"TAG");
00101   tag->setAttribute(transcode("id"), transcode ("TAG_ID"));
00102   tag->setAttribute(transcode("mode"), transcode ("auto"));
00103 
00104   createElement(doc,tag,"TAG_NAME", fTagName);
00105   createElement(doc,tag,"DETECTOR_NAME", fDetectorName);
00106   createElement(doc,tag,"COMMENT_DESCRIPTION", fComment);
00107 
00108   return tag;
00109 }
00110 
00111 
00112 void HcalHotCellDbInterface::createHeader(DOMDocument* doc, unsigned int runno, const char* startTime){
00113   DOMElement*  parent = doc->getDocumentElement();
00114   DOMElement*  headerElem = createElement(doc,parent,"HEADER");
00115   DOMElement*  typeElem = createElement(doc,headerElem,"TYPE");
00116   createElement(doc,typeElem,"EXTENSION_TABLE_NAME","HCAL_CHANNEL_ON_OFF_STATES");
00117   createElement(doc,typeElem,"NAME","HCAL channel on off states");
00118   DOMElement*  runElem = createElement(doc,headerElem,"RUN");
00119   createElement(doc,runElem,"RUN_TYPE","hcal-dqm-onoff-test");
00120   createElement(doc,runElem,"RUN_NUMBER",itoa(runno));
00121   createElement(doc,runElem,"RUN_BEGIN_TIMESTAMP",startTime);
00122   createElement(doc,runElem,"COMMENT_DESCRIPTION","dqm data");
00123 }
00124 
00125 DOMElement* HcalDQMDbInterface::createChannel(DOMDocument* doc,DOMElement* parent, HcalDetId id){
00126   HcalText2DetIdConverter converter(id);
00127   DOMElement*  chanElem = createElement(doc,parent,"CHANNEL");
00128   createElement(doc,chanElem,"EXTENSION_TABLE_NAME","HCAL_CHANNELS");
00129   createElement(doc,chanElem,"ETA",itoa(id.ietaAbs()));
00130   createElement(doc,chanElem,"PHI",itoa(id.iphi()));
00131   createElement(doc,chanElem,"DEPTH",itoa(id.depth()));
00132   createElement(doc,chanElem,"Z",itoa(id.zside()));
00133   createElement(doc,chanElem,"DETECTOR_NAME",converter.getFlavor().c_str());
00134   createElement(doc,chanElem,"HCAL_CHANNEL_ID",itoa(id.rawId()));
00135   return chanElem;
00136 }
00137 
00138 DOMElement* HcalHotCellDbInterface::createData(DOMDocument* doc,DOMElement* parent, HcalDQMChannelQuality::Item item){
00139   DOMElement*  dataElem = createElement(doc,parent,"DATA");
00140   createElement(doc,dataElem,"CHANNEL_ON_OFF_STATE",itoa(item.mMasked));
00141   createElement(doc,dataElem,"CHANNEL_STATUS_WORD",itoa(item. mQuality));
00142   createElement(doc,dataElem,"COMMENT_DESCRIPTION",item.mComment.c_str());
00143   return dataElem;
00144 }
00145 
00146 
00147 void HcalHotCellDbInterface::createDataset(DOMDocument* doc,
00148                                            HcalDQMChannelQuality::Item item,
00149                                            const char* gmtime,
00150                                            const char* version){
00151 
00152   DOMElement*  parent = doc->getDocumentElement();
00153   DOMElement*  dataSetElem = createElement(doc,parent,"DATA_SET");
00154   createElement(doc,dataSetElem,"VERSION",version);
00155   createElement(doc,dataSetElem,"CREATION_TIMESTAMP",gmtime);
00156   createElement(doc,dataSetElem,"CREATED_BY","wfisher");
00157 
00158   HcalDetId id(item.mId);
00159   createChannel(doc, dataSetElem, id);
00160   createData(doc, dataSetElem,item);
00161 }
00162 
00163 void HcalHLXMaskDbInterface::createHeader(DOMDocument* doc){
00164   DOMElement*  parent = doc->getDocumentElement();
00165   DOMElement*  headerElem = createElement(doc,parent,"HEADER");
00166   DOMElement*  typeElem = createElement(doc,headerElem,"TYPE");
00167   createElement(doc,typeElem,"EXTENSION_TABLE_NAME","HCAL_HLX_MASKS_TYPE01");
00168   createElement(doc,typeElem,"NAME","HCAL HLX masks [type 1]");
00169   DOMElement* element= createElement(doc,headerElem,"RUN");
00170   element->setAttribute(transcode("mode"), transcode("no-run"));
00171 }
00172 
00173 void HcalHLXMaskDbInterface::createData(DOMDocument* doc,DOMElement* parent, HcalHLXMask masks){
00174   DOMElement*  dataElem = createElement(doc,parent,"DATA");
00175   createElement(doc, dataElem, "FPGA", masks.position);
00176   char tmp[5] = "fooo";
00177   sprintf(tmp,"%i",masks.occMask);
00178   createElement(doc, dataElem, "OCC_MASK", tmp);
00179   sprintf(tmp,"%i",masks.lhcMask);
00180   createElement(doc, dataElem, "LHC_MASK", tmp);
00181   sprintf(tmp,"%i",masks.sumEtMask);
00182   createElement(doc, dataElem, "SUM_ET_MASK", tmp);
00183 }
00184 
00185 DOMElement* HcalHLXMaskDbInterface::createDataset(DOMDocument* doc,
00186                                                   const HcalHLXMask masks,
00187                                                   const char* gmtime,
00188                                                   const char* version, const char* subversion){
00189 
00190   DOMElement*  parent = doc->getDocumentElement();
00191   DOMElement*  dataSetElem = createElement(doc,parent,"DATA_SET");
00192   createElement(doc,dataSetElem,"VERSION",version);
00193   createElement(doc,dataSetElem,"SUBVERSION",subversion);
00194   createElement(doc,dataSetElem,"CREATION_TIMESTAMP",gmtime);
00195   createElement(doc,dataSetElem,"CREATED_BY","jwerner");
00196 
00197   DOMElement*  partAssElem = createElement(doc,dataSetElem,"PART_ASSEMBLY");
00198   DOMElement* parentPartAssElem = createElement(doc,partAssElem,"PARENT_PART");
00199   createElement(doc, parentPartAssElem, "KIND_OF_PART", "HCAL HTR Crate");
00200   char tmp[5];
00201   if(masks.crateId <10){ sprintf(tmp,"CRATE0%i",masks.crateId);}
00202   else{ sprintf(tmp,"CRATE%i",masks.crateId);}
00203   createElement(doc, parentPartAssElem, "NAME_LABEL",tmp);
00204   //end PARENT_PART 
00205   DOMElement* childUniqueIdByElem = createElement(doc,partAssElem,"CHILD_UNIQUELY_IDENTIFIED_BY");
00206   createElement(doc, childUniqueIdByElem, "KIND_OF_PART", "HCAL HTR Crate Slot");
00207   DOMElement* attributeElem = createElement(doc,childUniqueIdByElem,"ATTRIBUTE");
00208   createElement(doc, attributeElem, "NAME", "HCAL HTR Slot Number");
00209   createElement(doc, attributeElem, "VALUE", itoa(masks.slotId));
00210   //end attribute                                                                                                                  
00211   //end child uni...                                                                                                               
00212   //end part assembly                                                                                                              
00213 
00214   return dataSetElem;
00215 }

Generated on Tue Jun 9 17:32:55 2009 for CMSSW by  doxygen 1.5.4