Blame |
Last modification |
View Log
| RSS feed
#include "TString.h"
#include "TObjString.h"
#include "TObjArray.h"
#include "TDirectory.h"
#include "TFile.h"
#include "TSystem.h"
int ifebsn[8]={21,23,22,25, 27,28,29,30};
int getsn(const char *fname="test.xml"){
const char *f= gDirectory->GetFile()->GetName();
const char *t= gDirectory->Get("hxy0_sum_0")->GetTitle();
const char *d= gDirectory->Get("h2d_0")->GetTitle();
char h0[0xFF];
sscanf(t,"HAPD=%s",h0);
TDatime c = gDirectory->GetFile()->GetCreationDate();
const char *date= c.AsString();
FILE *fp=fopen(fname,"a");
TString sdna(d);
TObjArray *tdna = sdna.Tokenize(" ");
TString x(h0);
TObjArray *tx = x.Tokenize(",");
char run[0xf];
strncpy(run,gSystem->BaseName(f),4);
run[4]=0;
fprintf(fp,"<run id='%s' date='%s'>\n",run, date);
for (Int_t i = 0; i < tx->GetEntries(); i++) {
const char *sn = ((TObjString *)(tx->At(i)))->GetString();
const char *dna =(tdna->GetEntries()>=4)? ((TObjString *)(tdna->At(i)))->GetString() : " ";
char *mdna = (char *)&dna[5];
char sfeb[20];
if (strstr(sn,"/")!=NULL){
TString ssn(sn);
TObjArray *tsn = ssn.Tokenize("/");
const char *hapdsn = ((TObjString *)(tsn->At(0)))->GetString();
const char *febsnc = "000";
const char *febsn = ((TObjString *)(tsn->At(1)))->GetString();
sprintf(sfeb,"%s",febsn);
fprintf(fp, "<pos id='%d'><hapd>%s</hapd><feb>%s</feb><dna>%s</dna></pos>\n", i, hapdsn, sfeb,mdna );
} else {
sprintf(sfeb,"%03d", ifebsn[(4*(atoi(run)-1)+i)%8]);
fprintf(fp, "<pos id='%d'><hapd>%s</hapd><feb>%s</feb><dna>%s</dna></pos>\n", i, sn, sfeb,mdna );
}
}
//fprintf(fp,"</run>\n");
fprintf(stdout,"%s %s\n",gSystem->BaseName(f),t);
fclose(fp);
return 0;
}