Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 326 | f9daq | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
||
| 3 | #include <TROOT.h> |
||
| 4 | #include <TF1.h> |
||
| 5 | #include <TH1F.h> |
||
| 6 | #include <TH1D.h> |
||
| 7 | #include <TH2D.h> |
||
| 8 | #include <TTree.h> |
||
| 9 | #include <TCanvas.h> |
||
| 10 | #include <TStyle.h> |
||
| 11 | #include <TSystem.h> |
||
| 12 | #include <TFile.h> |
||
| 13 | #include <TDirectory.h> |
||
| 14 | #include <TGraph.h> |
||
| 15 | #include <TLegend.h> |
||
| 16 | |||
| 17 | #include <TPaveText.h> |
||
| 18 | |||
| 19 | #include "TXMLEngine.h" |
||
| 20 | |||
| 21 | // const char nodes[][20]={"TMON0","TMON1", "dna", "VDD", "V2P","V2N","VSS","VTH1","VTH2","VCC12","VCC15","VCC25","V38P",0}; |
||
| 22 | const char nodes[][20]={ "VDD", "V2P","V2N","VSS","VTH1","VTH2","VCC12","VCC15","VCC25","V38P",0}; |
||
| 23 | const double ul[20] ={ 1.7 , 2.1, -1.85, -1.61, 3, 3, 1.31, 1.61 , 2.61 , 3.91 }; |
||
| 24 | const double ll[20] ={ 1.61, 1.85, -2.09, -1.69 , 0, 0, 1.09, 1.39 , 2.39 , 3.69 }; |
||
| 25 | |||
| 26 | Int_t mid=0; |
||
| 27 | void hinit( int id){ |
||
| 28 | int i=0; |
||
| 29 | char name[0xFF]; |
||
| 30 | sprintf(name,"title%d",id); |
||
| 31 | //printf("ime naslova=%s\n", name); |
||
| 32 | TPaveText *pt = new TPaveText(.2,.2,.7,.7); |
||
| 33 | pt->SetName(name); |
||
| 34 | gDirectory->GetList()->Add(pt); |
||
| 35 | |||
| 36 | do { |
||
| 37 | sprintf(name,"%s_%d",nodes[i],id); |
||
| 38 | printf("name=%s\n",name); |
||
| 39 | TGraph *g= new TGraph(); |
||
| 40 | g->SetName(name); |
||
| 41 | g->SetLineColor(i%9+1); |
||
| 42 | g->SetLineWidth(3); |
||
| 43 | gDirectory->GetList()->Add(g); |
||
| 44 | i++; |
||
| 45 | } while (strlen(nodes[i])> 1); |
||
| 46 | } |
||
| 47 | |||
| 48 | void hplot(int id){ |
||
| 49 | int i=0; |
||
| 50 | char name[0xFF]; |
||
| 51 | char title[0xFF]= "Feb Test"; |
||
| 52 | |||
| 53 | TLegend *leg = new TLegend(0.60,0.1,0.99,0.9); |
||
| 54 | //leg->SetHeader("Legend"); |
||
| 55 | do { |
||
| 56 | sprintf(name,"%s_%d",nodes[i],id); |
||
| 57 | if (gROOT->FindObject(name) ) { |
||
| 58 | TGraph *g = (TGraph *) (gROOT->FindObject(name)) ; |
||
| 59 | if (i==0) { |
||
| 60 | TH2F *frame = new TH2F("frame",title,g->GetN(),0,g->GetN()+5,40,-2.5,4.5); |
||
| 61 | frame->SetStats(0); |
||
| 62 | frame->Draw(); |
||
| 63 | } |
||
| 64 | double x, y; |
||
| 65 | g->GetPoint(g->GetN()-1,x,y); |
||
| 66 | if (y>ll[i] && y<ul[i]){ |
||
| 67 | sprintf(title,"%s\t=%2.2f V",nodes[i], y); |
||
| 68 | } else { |
||
| 69 | sprintf(title,"%s\t=%2.2f V ERROR",nodes[i], y); |
||
| 70 | } |
||
| 71 | leg->AddEntry(g,title,"l"); |
||
| 72 | g->Draw("ls"); |
||
| 73 | } else { |
||
| 74 | printf("%s not found!\n",name); |
||
| 75 | } |
||
| 76 | i++; |
||
| 77 | } while (strlen(nodes[i])> 1); |
||
| 78 | leg->Draw(); |
||
| 79 | } |
||
| 80 | |||
| 81 | void hpt( int id ){ |
||
| 82 | char name[0xFF]; |
||
| 83 | sprintf(name,"title%d",id); |
||
| 84 | |||
| 85 | //printf("title=%s\n", name); |
||
| 86 | TPaveText *pt = (TPaveText *) (gROOT->FindObject(name)); |
||
| 87 | if (pt) pt->Draw(); |
||
| 88 | |||
| 89 | |||
| 90 | |||
| 91 | } |
||
| 92 | |||
| 93 | void hend(){ |
||
| 94 | TCanvas *c= new TCanvas("slowcontrol"); |
||
| 95 | c->Divide(2,2); |
||
| 96 | for (int i=0;i<4;i++) { |
||
| 97 | c->cd(i+1); |
||
| 98 | hplot(i); |
||
| 99 | } |
||
| 100 | c->Modified(); |
||
| 101 | c->Update(); |
||
| 102 | } |
||
| 103 | |||
| 104 | |||
| 105 | void DisplayNode(TXMLEngine* xml, XMLNodePointer_t node, Int_t level) |
||
| 106 | { |
||
| 107 | // this function display all accessible information about xml node and its children |
||
| 108 | |||
| 109 | //printf("%*c node: %s\n",level,' ', xml->GetNodeName(node)); |
||
| 110 | |||
| 111 | // display namespace |
||
| 112 | XMLNsPointer_t ns = xml->GetNS(node); |
||
| 113 | if (ns!=0) |
||
| 114 | printf("%*c namespace: %s refer: %s\n",level+2,' ', xml->GetNSName(ns), xml->GetNSReference(ns)); |
||
| 115 | |||
| 116 | // display attributes |
||
| 117 | XMLAttrPointer_t attr = xml->GetFirstAttr(node); |
||
| 118 | while (attr!=0) { |
||
| 119 | //printf("%*c attr: %s value: %s\n",level+2,' ', xml->GetAttrName(attr), xml->GetAttrValue(attr)); |
||
| 120 | attr = xml->GetNextAttr(attr); |
||
| 121 | } |
||
| 122 | |||
| 123 | // display content (if exists) |
||
| 124 | const char* content = xml->GetNodeContent(node); |
||
| 125 | |||
| 126 | if (content!=0){ |
||
| 127 | //printf("%*c cont: %s\n",level+2,' ', content); |
||
| 128 | if (strcmp(xml->GetNodeName(node),"time")==0) { |
||
| 129 | // printf("Time=%s\n", content); |
||
| 130 | char name[0xFF]; |
||
| 131 | //sprintf(name,"Cas kki ga hocem=\t%s",content); |
||
| 132 | //printf("Time=%s\n", name); |
||
| 133 | for (int ii=0;ii<4;ii++){ |
||
| 134 | sprintf(name,"title%d",ii); |
||
| 135 | printf("title=%s\n",name); |
||
| 136 | TPaveText *pt = (TPaveText *) (gROOT->FindObject(name)) ; |
||
| 137 | if (pt) { |
||
| 138 | pt->AddText("ARICH FEB QA test"); |
||
| 139 | sprintf(name,"Time= %s",content); |
||
| 140 | pt->AddText(name); |
||
| 141 | |||
| 142 | |||
| 143 | } |
||
| 144 | } |
||
| 145 | } |
||
| 146 | |||
| 147 | if (strcmp(xml->GetNodeName(node),"id")==0) { |
||
| 148 | mid=atoi(content); |
||
| 149 | //printf("ID---->%d\n",mid); |
||
| 150 | } else { |
||
| 151 | char name[0xFF]; |
||
| 152 | sprintf(name,"%s_%d",xml->GetNodeName(node),mid); |
||
| 153 | TGraph *g = (TGraph *) (gROOT->FindObject(name)) ; |
||
| 154 | if (g) g->SetPoint(g->GetN(), g->GetN() ,atof(content)); |
||
| 155 | else printf("%s not found!\n",name); |
||
| 156 | } |
||
| 157 | } |
||
| 158 | // display all child nodes |
||
| 159 | XMLNodePointer_t child = xml->GetChild(node); |
||
| 160 | while (child!=0) { |
||
| 161 | DisplayNode(xml, child, level+2); |
||
| 162 | child = xml->GetNext(child); |
||
| 163 | } |
||
| 164 | } |
||
| 165 | |||
| 166 | |||
| 167 | void slowcxml2root(const char* filename = "febslowc_0044.xml") |
||
| 168 | { |
||
| 169 | TTree *run = new TTree("run", "run"); |
||
| 170 | |||
| 171 | // First create engine |
||
| 172 | TXMLEngine* xml = new TXMLEngine; |
||
| 173 | |||
| 174 | // Now try to parse xml file |
||
| 175 | // Only file with restricted xml syntax are supported |
||
| 176 | XMLDocPointer_t xmldoc = xml->ParseFile(filename); |
||
| 177 | if (xmldoc==0) { |
||
| 178 | delete xml; |
||
| 179 | return; |
||
| 180 | } |
||
| 181 | |||
| 182 | // take access to main node |
||
| 183 | XMLNodePointer_t mainnode = xml->DocGetRootElement(xmldoc); |
||
| 184 | |||
| 185 | // display recursively all nodes and subnodes |
||
| 186 | for (int i=0;i<4;i++) hinit(i); |
||
| 187 | DisplayNode(xml, mainnode, 1); |
||
| 188 | //hend(); |
||
| 189 | // Release memory before exit |
||
| 190 | xml->FreeDoc(xmldoc); |
||
| 191 | delete xml; |
||
| 192 | } |
||
| 193 |