--- YodaProfiler/src/R2-D2.cpp 2007/11/09 09:13:56 1.11 +++ YodaProfiler/src/R2-D2.cpp 2008/03/04 15:21:56 1.15 @@ -32,13 +32,17 @@ printf("\n Options are:\n\n"); printf(" --version print informations about compilation and exit\n"); printf(" -h | --help print this help and exit \n"); - printf(" -v | --verbose be verbose [default: print nothing on STDOUT]\n"); + printf(" -v | --verbose be verbose [default]\n"); + printf(" -n | --neat used with '-filename' returns only the run ID number\n"); printf(" -idRun run ID_RUN: ID number of the run \n"); printf(" -filename file output yoda filename \n"); printf(" -l2filename file output amidala filename \n"); printf(" -host name of the DB host [default = $PAM_DBHOST or mysql://localhost/pamelaprod]\n"); printf(" -user username for the DB connection [default = $PAM_DBUSER or \"anonymous\"] \n"); printf(" -psw password for the DB connection [default = $PAM_DBPSW or \"\"]\n"); + printf(" -deps file shows dependencies of the given file\n"); + printf(" -splitat file shows dependenices of the given file and the following files (given by -nsplit)\n"); + printf(" -nsplit number number of files to be shown by -splitat [default 20]\n"); printf(" -tzone timezone the time zone: UTC,GMT,MSK,MSD,CET,CEST are accepted \n"); printf(" -convert dbtime convert the dbtime given in seconds (from the DB) to a string\n"); printf(" -runat date returns run number which contains the given date,\n"); @@ -68,6 +72,8 @@ // TString filename = ""; TString l2filename = ""; + TString splitat = ""; + UInt_t nsplit = 20; // TSQLServer *dbc = 0; TString host = "mysql://localhost/pamelaprod"; @@ -97,6 +103,7 @@ Bool_t ruti2 = false; Bool_t convobt = false; Bool_t convobtts = false; + Bool_t neat = false; // UInt_t runtime2 = 0; UInt_t obt = 0; @@ -105,6 +112,8 @@ // TSQLResult *pResult; TSQLRow *Row; + TSQLResult *pResult2 = 0; + TSQLRow *Row2; int t; int r; stringstream myquery; @@ -122,6 +131,9 @@ r2d2usage(); exit(0); }; + if ( !strcmp(inps[i],"-n") || !strcmp(inps[i],"--neat") ){ + neat = true; + }; if ( !strcmp(inps[i],"-idRun") ) { if ( numinp-1 < i+1 ) { r2d2usage(); @@ -136,6 +148,29 @@ }; filename = (TString)inps[i+1]; }; + if ( !strcmp(inps[i],"-splitat") ) { + if ( numinp-1 < i+1 ){ + r2d2usage(); + exit(-3); + }; + splitat = (TString)inps[i+1]; + }; + // + if ( !strcmp(inps[i],"-nsplit") ) { + if ( numinp-1 < i+1 ){ + r2d2usage(); + exit(-3); + }; + nsplit = (UInt_t)atoll(inps[i+1]); + }; + if ( !strcmp(inps[i],"-deps") ) { + if ( numinp-1 < i+1 ){ + r2d2usage(); + exit(-3); + }; + nsplit = 1; + splitat = (TString)inps[i+1]; + }; if ( !strcmp(inps[i],"-l2filename") ) { if ( numinp-1 < i+1 ){ r2d2usage(); @@ -529,7 +564,7 @@ }; delete pResult; if ( !ID && !ID_RAW ){ - printf("\n No file with name %s in the DB!\n",filename.Data()); + if ( !neat ) printf("\n No file with name %s in the DB!\n",filename.Data()); } else { myquery.str(""); myquery << "select "; @@ -540,9 +575,10 @@ Row = pResult->Next(); if( Row == NULL ) break; found = true; - if ( !r ) printf("\n File %s contains the following runs: \n\n",filename.Data()); + if ( !r && !neat ) printf("\n File %s contains the following runs: \n\n",filename.Data()); TString UTC=tzone.Data(); - printf(" => ID = %i --> the run started at %s %s ended at %s %s NEV = %u \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),tzone.Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data(),tzone.Data(),(UInt_t)atoll(Row->GetField(3))); + if ( !neat ) printf(" => ID = %u --> the run started at %s %s ended at %s %s NEV = %u \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),tzone.Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data(),tzone.Data(),(UInt_t)atoll(Row->GetField(3))); + if ( neat ) printf("%u\n",(UInt_t)atoll(Row->GetField(0))); }; delete pResult; myquery.str(""); @@ -553,13 +589,13 @@ for( r=0; r < 1000; r++){ Row = pResult->Next(); if( Row == NULL ) break; - if ( !r ) printf("\n File %s contains the following DELETED runs: \n\n",filename.Data()); + if ( !r && !neat ) printf("\n File %s contains the following DELETED runs: \n\n",filename.Data()); TString UTC=tzone.Data(); - printf(" => ID = %i --> the run started at %s %s ended at %s %s \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),tzone.Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data(),tzone.Data()); + if ( !neat ) printf(" => ID = %i --> the run started at %s %s ended at %s %s \n\n",(UInt_t)atoll(Row->GetField(0)),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(1))).Data(),tzone.Data(),dbtime->ConvertTime(UTC,(UInt_t)atoll(Row->GetField(2))).Data(),tzone.Data()); }; // if ( !found ){ - printf("\n No run associated to the file %s \n",filename.Data()); + if ( !neat ) printf("\n No run associated to the file %s \n",filename.Data()); }; myquery.str(""); myquery << "select "; @@ -575,7 +611,7 @@ }; }; delete pResult; - printf("\n File %s belongs to raw data file %s/%s \n",filename.Data(),rawpath,rawname); + if ( !neat ) printf("\n File %s belongs to raw data file %s/%s \n",filename.Data(),rawpath,rawname); }; }; // @@ -656,11 +692,281 @@ }; }; // + // + // Show relationship between files around file "splitat" + // + if ( strcmp(splitat.Data(),"") ){ + // ---------------- + Int_t ID = 0; + Int_t IDR = 0; + TString PATH; + TString NAME; + UInt_t atime1 = 0; + UInt_t atime2 = 0; + UInt_t minid = 0; + UInt_t maxid = 0; + // + myquery.str(""); + myquery << " select ID,PATH,NAME from GL_ROOT where NAME>=\"" << splitat.Data() << "\" order by NAME asc limit " << nsplit << ";"; + // printf(" myquery is %s \n",myquery.str().c_str()); + pResult = dbc->Query(myquery.str().c_str()); + GL_TIMESYNC *dbtime; + GL_S4_CALIB *glS4calib; + GL_ROOT *glroot; + for( r=0; r < 1000; r++){ + Row = pResult->Next(); + if( Row == NULL ) break; + printf("\n\n#################################################\n"); + Int_t s=0; + Int_t t=0; + Int_t c=0; + TString *s4files[500]; + TString *tfiles[500]; + TString *cfiles[2000]; + ID = atoi(Row->GetField(0)); + PATH = Row->GetField(1); + NAME = Row->GetField(2); + printf("\n FILE: %s/%s \n",PATH.Data(),NAME.Data()); + myquery.str(""); + myquery << " select ID,RUNHEADER_OBT,RUNTRAILER_OBT from GL_RUN where ID_ROOT_L0=" << ID << " order by ID;"; + pResult2 = dbc->Query(myquery.str().c_str()); + for( Int_t run=0; run < pResult2->GetRowCount(); run++){ + Row2 = pResult2->Next(); + if( Row2 == NULL ) break; + IDR = atoi(Row2->GetField(0)); + if ( run == 0 ) minid = IDR; + if ( run == pResult2->GetRowCount()-1 ) maxid = IDR; + // + // here we make queries to DB looking for needed files and print results + // + dbtime = new GL_TIMESYNC(ID,"ID",dbc); + // + atime1 = dbtime->DBabsTime((UInt_t)atoll(Row2->GetField(1))); + atime2 = dbtime->DBabsTime((UInt_t)atoll(Row2->GetField(2))); + // printf(" atime1 %u atime2 %u field 1 %s field2 %s \n",atime1,atime2,Row2->GetField(1),Row2->GetField(2)); + // + // S4 + // + glS4calib = new GL_S4_CALIB(); + glS4calib->Query_GL_S4_CALIB(atime1, dbc); + glroot = new GL_ROOT(); + glroot->Query_GL_ROOT(glS4calib->ID_ROOT_L0,dbc); + // + if ( s > 0 ){ + Bool_t found = false; + for (Int_t g=0; gNAME.Data(),s4files[g]->Data()) ){ + found = true; + }; + }; + if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ + s4files[s] = new TString(glroot->NAME.Data()); + s++; + }; + } else { + if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ + s4files[s] = new TString(glroot->NAME.Data()); + s++; + }; + }; + // + delete glS4calib; + delete dbtime; + delete glroot; + // + // TRACKER + // + GL_TRK_CALIB q2; + q2.Query_GL_TRK_CALIB(atime1,dbc); + GL_ROOT q3; + q3.Query_GL_ROOT(q2.ID_ROOT_L0,dbc); + // + if ( t > 0 ){ + Bool_t found = false; + for (Int_t gt=0; gtData()) ){ + found = true; + }; + }; + if ( !found && strcmp(q3.NAME.Data(),NAME.Data()) ){ + tfiles[t] = new TString(q3.NAME.Data()); + t++; + }; + } else { + if ( strcmp(q3.NAME.Data(),NAME.Data()) ){ + tfiles[t] = new TString(q3.NAME.Data()); + t++; + }; + }; + // + // CALO + // + GL_CALO_CALIB *glcalo = new GL_CALO_CALIB(); + GL_CALOPULSE_CALIB *glp = new GL_CALOPULSE_CALIB(); + GL_ROOT *glroot = new GL_ROOT(); + // + for (Int_t sc=0; sc<4; sc++){ + // + UInt_t pampli = 0; + glcalo->Query_GL_CALO_CALIB(atime1,pampli,sc,dbc); + glroot->Query_GL_ROOT(glcalo->ID_ROOT_L0,dbc); + if ( c > 0 ){ + Bool_t found = false; + for (Int_t gt=0; gtNAME.Data(),cfiles[gt]->Data()) ){ + found = true; + }; + }; + if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + } else { + if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + }; + // + pampli = 0; + glcalo->Query_GL_CALO_CALIB(atime2,pampli,sc,dbc); + glroot->Query_GL_ROOT(glcalo->ID_ROOT_L0,dbc); + if ( c > 0 ){ + Bool_t found = false; + for (Int_t gt=0; gtNAME.Data(),cfiles[gt]->Data()) ){ + found = true; + }; + }; + if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + } else { + if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + }; + // + pampli = 2; + glp->Query_GL_CALOPULSE_CALIB(atime1,sc,pampli,dbc); + glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); + if ( c > 0 ){ + Bool_t found = false; + for (Int_t gt=0; gtNAME.Data(),cfiles[gt]->Data()) ){ + found = true; + }; + }; + if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + } else { + if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + }; + // + pampli = 0; + glp->Query_GL_CALOPULSE_CALIB(atime1,sc,pampli,dbc); + glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); + if ( c > 0 ){ + Bool_t found = false; + for (Int_t gt=0; gtNAME.Data(),cfiles[gt]->Data()) ){ + found = true; + }; + }; + if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + } else { + if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + }; + // + pampli = 2; + glp->Query_GL_CALOPULSE_CALIB(atime2,sc,pampli,dbc); + glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); + if ( c > 0 ){ + Bool_t found = false; + for (Int_t gt=0; gtNAME.Data(),cfiles[gt]->Data()) ){ + found = true; + }; + }; + if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + } else { + if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + }; + // + pampli = 0; + glp->Query_GL_CALOPULSE_CALIB(atime2,sc,pampli,dbc); + glroot->Query_GL_ROOT(glp->ID_ROOT_L0,dbc); + if ( c > 0 ){ + Bool_t found = false; + for (Int_t gt=0; gtNAME.Data(),cfiles[gt]->Data()) ){ + found = true; + }; + }; + if ( !found && strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + } else { + if ( strcmp(glroot->NAME.Data(),NAME.Data()) ){ + cfiles[c] = new TString(glroot->NAME.Data()); + c++; + }; + }; + // + }; + }; + printf(" S4 requires:"); + for (Int_t f=0;fData()); + delete s4files[f]; + }; + printf("\n"); + printf(" Tracker requires:"); + for (Int_t f=0;fData()); + delete tfiles[f]; + }; + printf("\n"); + printf(" Calorimeter requires:"); + for (Int_t f=0;fData()); + delete cfiles[f]; + }; + printf("\n\n"); + printf(" Minimum ID number in the file: %u \n",minid); + printf(" Maximum ID number in the file: %u \n",maxid); + printf("\n#################################################\n"); + // + }; + delete pResult; + if ( pResult2 ) delete pResult2; + }; + // // Close the DB connection // if ( dbc ) dbc->Close(); // - printf("\n"); + if ( !neat ) printf("\n"); // exit(0); }