Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 326 | f9daq | 1 | #include  "TString.h" | 
        
| 2 | #include  "TObjString.h" | 
        ||
| 3 | #include  "TObjArray.h" | 
        ||
| 4 | #include  "TDirectory.h" | 
        ||
| 5 | #include  "TFile.h" | 
        ||
| 6 | #include  "TSystem.h" | 
        ||
| 7 | |||
| 8 | int ifebsn[8]={21,23,22,25, 27,28,29,30};  | 
        ||
| 9 | |||
| 10 | int getsn(const char *fname="test.xml"){  | 
        ||
| 11 | const char *f= gDirectory->GetFile()->GetName();  | 
        ||
| 12 | const char *t= gDirectory->Get("hxy0_sum_0")->GetTitle();  | 
        ||
| 13 | const char *d= gDirectory->Get("h2d_0")->GetTitle();  | 
        ||
| 14 | char h0[0xFF];  | 
        ||
| 15 | sscanf(t,"HAPD=%s",h0);  | 
        ||
| 16 | TDatime c = gDirectory->GetFile()->GetCreationDate();  | 
        ||
| 17 | const char *date= c.AsString();  | 
        ||
| 18 | |||
| 19 | |||
| 20 | FILE *fp=fopen(fname,"a");  | 
        ||
| 21 | |||
| 22 | TString sdna(d);  | 
        ||
| 23 | TObjArray *tdna = sdna.Tokenize(" ");  | 
        ||
| 24 | TString x(h0);  | 
        ||
| 25 | TObjArray *tx = x.Tokenize(",");  | 
        ||
| 26 | char run[0xf];  | 
        ||
| 27 | strncpy(run,gSystem->BaseName(f),4);  | 
        ||
| 28 | run[4]=0;  | 
        ||
| 29 | fprintf(fp,"<run id='%s' date='%s'>\n",run, date);  | 
        ||
| 30 | |||
| 31 | for (Int_t i = 0; i < tx->GetEntries(); i++) {  | 
        ||
| 32 | const char *sn = ((TObjString *)(tx->At(i)))->GetString();  | 
        ||
| 33 | const char *dna =(tdna->GetEntries()>=4)? ((TObjString *)(tdna->At(i)))->GetString() : " ";  | 
        ||
| 34 | char *mdna = (char *)&dna[5];  | 
        ||
| 35 | char sfeb[20];  | 
        ||
| 36 | if (strstr(sn,"/")!=NULL){  | 
        ||
| 37 | TString ssn(sn);  | 
        ||
| 38 | TObjArray *tsn = ssn.Tokenize("/");  | 
        ||
| 39 | const char *hapdsn = ((TObjString *)(tsn->At(0)))->GetString();  | 
        ||
| 40 | const char *febsnc = "000";  | 
        ||
| 41 | const char *febsn = ((TObjString *)(tsn->At(1)))->GetString();  | 
        ||
| 42 | sprintf(sfeb,"%s",febsn);  | 
        ||
| 43 | fprintf(fp, "<pos id='%d'><hapd>%s</hapd><feb>%s</feb><dna>%s</dna></pos>\n", i, hapdsn, sfeb,mdna );  | 
        ||
| 44 | } else {  | 
        ||
| 45 | sprintf(sfeb,"%03d", ifebsn[(4*(atoi(run)-1)+i)%8]);  | 
        ||
| 46 | fprintf(fp, "<pos id='%d'><hapd>%s</hapd><feb>%s</feb><dna>%s</dna></pos>\n", i, sn, sfeb,mdna );  | 
        ||
| 47 |   } | 
        ||
| 48 | |||
| 49 | } | 
        ||
| 50 | //fprintf(fp,"</run>\n"); | 
        ||
| 51 | |||
| 52 | fprintf(stdout,"%s %s\n",gSystem->BaseName(f),t);  | 
        ||
| 53 | fclose(fp);  | 
        ||
| 54 | return 0;  | 
        ||
| 55 | } |