X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FITSSPDPHYSda.cxx;h=7654da9fb0a7b30b968fc991b83489ed613fdb81;hb=52a564eeeed3ad431eba15a08cfc0a5f4594e891;hp=5940d1d53fcde97ea83a875aebbf3b7c18aa65a6;hpb=469c929f33270d43218c758ff29da2400586711c;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/ITSSPDPHYSda.cxx b/ITS/ITSSPDPHYSda.cxx index 5940d1d53fc..7654da9fb0a 100644 --- a/ITS/ITSSPDPHYSda.cxx +++ b/ITS/ITSSPDPHYSda.cxx @@ -35,12 +35,13 @@ extern "C" { #include "AliLog.h" #include #include -//#include +#include #include #include #include #include #include +#include int main(int argc, char **argv) { @@ -49,7 +50,9 @@ int main(int argc, char **argv) { return -1; } - // directory structure, hard coded + UInt_t nrErrors = 0; + + // directory structure, hard coded // FOR OFFLINE VERSION: char *saveDirDead = "./calibResults/Dead"; // may NOT delete content char *saveDirDeadToFXS = "./calibResults/DeadToFXS"; // may delete content char *saveDirDeadRef = "./calibResults/DeadReference"; // may delete content @@ -58,7 +61,17 @@ int main(int argc, char **argv) { char *saveDirNoisyRef = "./calibResults/NoisyReference"; // may delete content char *saveDirIdsToFXS = "./calibResults/IdsToFXS"; // may delete content char *configFilesDir = "./configFiles"; // may delete content - // make sure the directory structure is put up correctly: + // clean up and make sure the directory structure is put up correctly: +#ifndef SPD_DA_OFF + system("rm ./calibResults -rf >& /dev/null"); + system("rm ./ITS -rf >& /dev/null"); +#else + system("rm ./calibResults/DeadToFXS -rf >& /dev/null"); + system("rm ./calibResults/DeadReference -rf >& /dev/null"); + system("rm ./calibResults/NoisyToFXS -rf >& /dev/null"); + system("rm ./calibResults/NoisyReference -rf >& /dev/null"); + system("rm ./calibResults/IdsToFXS -rf >& /dev/null"); +#endif system("mkdir ./calibResults >& /dev/null"); system("mkdir ./calibResults/Dead >& /dev/null"); system("mkdir ./calibResults/DeadToFXS >& /dev/null"); @@ -68,6 +81,11 @@ int main(int argc, char **argv) { system("mkdir ./calibResults/NoisyReference >& /dev/null"); system("mkdir ./calibResults/IdsToFXS >& /dev/null"); system("mkdir ./configFiles >& /dev/null"); +#ifndef SPD_DA_OFF + system("mkdir ./ITS >& /dev/null"); + system("mkdir ./ITS/Calib >& /dev/null"); + system("mkdir ./ITS/Calib/SPDNoisy >& /dev/null"); +#endif // parameters config file TString paramsFileName = Form("%s/physics_params.txt",configFilesDir); @@ -80,9 +98,9 @@ int main(int argc, char **argv) { "TStreamerInfo()"); // turn off annoying warning messages - new AliLog; - AliLog::Instance()->SetGlobalDebugLevel(-20); - + // NB: Should not be handled here + AliLog* logger = AliLog::GetRootLogger(); + logger->SetGlobalDebugLevel(-20); // ********* STEP 0: Get configuration files from db (if there are any) , then read parameters********* UInt_t nrTuningParams = 0; @@ -96,6 +114,8 @@ int main(int argc, char **argv) { par_status=daqDA_DB_getFile(idp.Data(),paramsFileName.Data()); if (par_status) { printf("SPD DA: Failed to get config file %s: status=%d. Using default tuning parameters.\n",idp.Data(),par_status); + TString rmCmd = Form("rm -f %s",paramsFileName.Data()); + system(rmCmd.Data()); } #endif if (par_status==0) { @@ -133,17 +153,16 @@ int main(int argc, char **argv) { // Read silent=dead+inactive info from previous calibrations #ifndef SPD_DA_OFF - // remove previous files and read from DB instead - TString commandRemoveDead = Form("cd %s; rm -f *",saveDirDead); - system(commandRemoveDead.Data()); for (UInt_t eq=0; eq<20; eq++) { Int_t getPreviousDead_status = 0; TString idpd = Form("spd_previous_dead_%d",eq); TString fileName = Form("%s/SPD_Dead_%d.root",saveDirDead,eq); getPreviousDead_status = daqDA_DB_getFile(idpd.Data(),fileName.Data()); - // printf("daqDA_DB_getFile(%s,%s)\n",idpd.Data(),fileName.Data()); - if (par_status) { + // printf("daqDA_DB_getFile(%s,%s)\n",idpd.Data(),fileName.Data()); + if (getPreviousDead_status) { printf("SPD DA: Failed to get dead file %s: status=%d. Dead search will start from zero for this eq.\n",idpd.Data(),getPreviousDead_status); + TString rmCmd = Form("rm -f %s",fileName.Data()); + system(rmCmd.Data()); } } #endif @@ -151,6 +170,22 @@ int main(int argc, char **argv) { handler->ReadSilentFromFiles(); printf("SPD DA: Number of single dead pixels from previous runs: %d\n",handler->GetNrDead()); + // Read hit-maps from previous runs +#ifndef SPD_DA_OFF + for (UInt_t eq=0; eq<20; eq++) { + Int_t getPreviousHitmap_status = 0; + TString idph = Form("spd_previous_hitmap_%d",eq); + TString fileName = Form("%s/SPDphys_dead_run_0_0_eq_%d.root",saveDirDeadRefTmp,eq); + getPreviousHitmap_status = daqDA_DB_getFile(idph.Data(),fileName.Data()); + // printf("daqDA_DB_getFile(%s,%s)\n",idph.Data(),fileName.Data()); + if (getPreviousHitmap_status) { + printf("SPD DA: Failed to get previous hitmap file %s: status=%d. Dead search will start with empty hitmap for this eq.\n",idph.Data(),getPreviousHitmap_status); + TString rmCmd = Form("rm -f %s",fileName.Data()); + system(rmCmd.Data()); + } + } +#endif + @@ -351,18 +386,9 @@ int main(int argc, char **argv) { // ********* STEP 2: Analyze phys container files. ************************************************ - // time_t timeStamp = time(NULL); + time_t timeStamp = time(NULL); // printf("*** Start step2 , %d\n",time(NULL) - timeStamp); - // clear noisyToFXS dir: - TString command; - command = Form("cd %s; rm -f *",saveDirNoisyToFXS); - system(command.Data()); - // clear deadToFXS dir: - command = Form("cd %s; rm -f *",saveDirDeadToFXS); - system(command.Data()); - - UInt_t firstRunNrDead = runNr; @@ -381,8 +407,7 @@ int main(int argc, char **argv) { // check data in container if (noisyAnalyzer->GetEqNr() != eq) { if (noisyAnalyzer->GetEqNr() != 999) { - printf("SPD DA ERROR: Mismatching EqId in Container data and filename (%d!=%d). Skipping eq.\n", - noisyAnalyzer->GetEqNr(),eq); + printf("SPD DA ERROR: Mismatching EqId in Container data and filename (%d!=%d). Skipping eq.\n",noisyAnalyzer->GetEqNr(),eq); } delete noisyAnalyzer; continue; @@ -426,9 +451,11 @@ int main(int argc, char **argv) { delete noisyAnalyzer; #ifndef SPD_DA_OFF - daqDA_progressReport((unsigned int)((eq+1)*2.5)); + // daqDA_progressReport((unsigned int)((eq+1)*2.5)); + printf("SPD DA: progress: %d , %ld\n",(unsigned int)(50+(eq+1)*2.5), time(NULL) - timeStamp); #else - printf("SPD DA: progress: %d\n",(unsigned int)(50+(eq+1)*1.25)); + // printf("SPD DA: progress: %d\n",(unsigned int)(50+(eq+1)*1.25)); + printf("SPD DA: progress: %d , %ld\n",(unsigned int)(50+(eq+1)*1.25), time(NULL) - timeStamp); #endif } // *** *** *** end loop over equipments (eq_id) @@ -437,8 +464,18 @@ int main(int argc, char **argv) { handler->GetNrNoisy(),nrEnoughStatNoisy); handler->SetFileLocation(saveDirNoisyToFXS); UInt_t nrNoisyFilesProduced = handler->WriteNoisyToFiles(); - - +#ifndef SPD_DA_OFF + // save noisy to local OCDB + handler->WriteNoisyToDB(runNr,9999999,"."); + // store local OCDB file in daq Det DB + TString ocdb_fileName = Form("./ITS/Calib/SPDNoisy/Run%d_9999999_v0_s0.root",runNr); + TString idod = "spd_noisy_ocdb"; + Int_t ocdb_store_status = daqDA_DB_storeFile(ocdb_fileName.Data(),idod.Data()); + // printf("daqDA_DB_storeFile(%s,%s)\n",ocdb_fileName.Data(),idod.Data()); + if (ocdb_store_status) { + printf("SPD DA ERROR: Failed to store noisy ocdb file %s in daqDetDB: status=%d.\n",idod.Data(),ocdb_store_status); + } +#endif @@ -461,8 +498,7 @@ int main(int argc, char **argv) { // check data in container if (deadAnalyzer->GetEqNr() != eq) { if (deadAnalyzer->GetEqNr() != 999) { - printf("SPD DA ERROR: Mismatching EqId in Dead Container data and filename (%d!=%d). Skipping eq.\n", - deadAnalyzer->GetEqNr(),eq); + printf("SPD DA ERROR: Mismatching EqId in Dead Container data and filename (%d!=%d). Skipping eq.\n",deadAnalyzer->GetEqNr(),eq); } delete deadAnalyzer; nrDeadChips+=60; // since this eq is inactive... @@ -477,7 +513,8 @@ int main(int argc, char **argv) { deadAnalyzer->SetParam(((TObjString*)paramNames.At(i))->GetString().Data(),((TObjString*)paramVals.At(i))->GetString().Data()); } - printf("SPD DA: SPD phys STEP 2: Dead search for eq %d\n",eq); + UInt_t nrEventsCollected = physObj->GetNrEvents(); + printf("SPD DA: SPD phys STEP 2: Dead search for eq %d (%d events)\n",eq,nrEventsCollected); // search for dead pixels: nrEnoughStatChips += deadAnalyzer->ProcessDeadPixels(); @@ -488,9 +525,11 @@ int main(int argc, char **argv) { #ifndef SPD_DA_OFF - daqDA_progressReport((unsigned int)(50+(eq+1)*2.5)); + // daqDA_progressReport((unsigned int)(50+(eq+1)*2.5)); + printf("SPD DA: progress: %d , %ld\n",(unsigned int)(50+(eq+1)*2.5), time(NULL) - timeStamp); #else - printf("SPD DA: progress: %d\n",(unsigned int)(75+(eq+1)*1.25)); + // printf("SPD DA: progress: %d\n",(unsigned int)(75+(eq+1)*1.25)); + printf("SPD DA: progress: %d , %ld\n",(unsigned int)(75+(eq+1)*1.25), time(NULL) - timeStamp); #endif } // *** *** *** end loop over equipments (eq) @@ -507,7 +546,8 @@ int main(int argc, char **argv) { handler->WriteSilentToFilesAlways(); - printf("SPD DA: Opening id list file\n"); + // printf("SPD DA: Opening id list file\n"); + printf("SPD DA: Opening id list file , %ld\n",time(NULL) - timeStamp); TString idsFXSFileName = Form("%s/FXSids_run_%d.txt",saveDirIdsToFXS,runNr); ofstream idsFXSfile; idsFXSfile.open(idsFXSFileName.Data()); @@ -515,6 +555,7 @@ int main(int argc, char **argv) { // store dead+inactive pixels in DB, used as starting point for later runs #ifndef SPD_DA_OFF + printf("store previous dead in DB , %ld\n",time(NULL) - timeStamp); for (UInt_t eq=0; eq<20; eq++) { Int_t storePreviousDead_status = 0; TString idpd = Form("spd_previous_dead_%d",eq); @@ -542,11 +583,14 @@ int main(int argc, char **argv) { TString newFileName = Form("%s/SPDphys_dead_run_%d_%d_eq_%d.root",saveDirDeadRef,firstRunNrDead,runNr,eq); TString command = Form("mv -f %s %s",fileName.Data(),newFileName.Data()); system(command.Data()); - tarFiles.Append(Form("SPDphys_dead_run_%d_%d_eq_%d.root ",firstRunNrDead,runNr,eq)); + // create empty hitmap file to send to DB later + AliITSOnlineSPDphys* physObj = new AliITSOnlineSPDphys(fileName.Data()); + physObj->SetEqNr(eq); + delete physObj; } } - if (tarFiles.Length() > 0) { // make sure there are any files to send + if (tarFiles.Length() > 0) { // make sure there are some files to send TString send_command = Form("cd %s; tar -cf ref_phys_dead.tar %s",saveDirDeadRef,tarFiles.Data()); system(send_command.Data()); TString fileName = Form("%s/ref_phys_dead.tar",saveDirDeadRef); @@ -555,17 +599,33 @@ int main(int argc, char **argv) { status = daqDA_FES_storeFile(fileName.Data(),id.Data()); if (status!=0) { printf("SPD DA ERROR: Failed to export file %s , status %d\n",fileName.Data(),status); - return -1; + nrErrors++; } #endif idsFXSfile << Form("%s\n",id.Data()); } } + // store hitmaps (maybe empty) in DB, used as starting point for later runs: +#ifndef SPD_DA_OFF + printf("store previous hitmaps in DB , %ld\n",time(NULL) - timeStamp); + for (UInt_t eq=0; eq<20; eq++) { + Int_t storePreviousHitmap_status = 0; + TString idph = Form("spd_previous_hitmap_%d",eq); + TString fileName = Form("%s/SPDphys_dead_run_0_0_eq_%d.root",saveDirDeadRefTmp,eq); + storePreviousHitmap_status = daqDA_DB_storeFile(fileName.Data(),idph.Data()); + // printf("daqDA_DB_storeFile(%s,%s)\n",fileName.Data(),idph.Data()); + if (storePreviousHitmap_status) { + printf("SPD DA ERROR: Failed to store hitmap file %s in daqDetDB: status=%d.\n",idph.Data(),storePreviousHitmap_status); + } + } +#endif + // send (noisy) reference data for this run to FXS - printf("SPD DA: Preparing noisy reference data\n"); + // printf("SPD DA: Preparing physics reference data for this run\n"); + printf("SPD DA: Preparing physics reference data for this run , %ld\n",time(NULL) - timeStamp); TString tarFiles = ""; for (UInt_t eq=0; eq<20; eq++) { if (eqActiveNoisy[eq]) { @@ -581,7 +641,7 @@ int main(int argc, char **argv) { status = daqDA_FES_storeFile(fileName.Data(),id.Data()); if (status!=0) { printf("SPD DA ERROR: Failed to export file %s , status %d\n",fileName.Data(),status); - return -1; + nrErrors++; } #endif idsFXSfile << Form("%s\n",id.Data()); @@ -590,7 +650,8 @@ int main(int argc, char **argv) { // send dead pixels to FXS - printf("SPD DA: Preparing dead files for FXS\n"); + // printf("SPD DA: Preparing dead files for FXS\n"); + printf("SPD DA: Preparing dead files for FXS , %ld\n",time(NULL) - timeStamp); // send a tared file of all the dead files TString send_command = Form("cd %s; tar -cf dead_phys.tar *",saveDirDeadToFXS); // printf("\n\n%s\n\n",command.Data()); @@ -601,7 +662,7 @@ int main(int argc, char **argv) { Int_t send_status = daqDA_FES_storeFile(fileName.Data(),id.Data()); if (send_status!=0) { printf("SPD DA ERROR: Failed to export file %s , status %d\n",fileName.Data(),send_status); - return -1; + nrErrors++; } #endif idsFXSfile << Form("%s\n",id.Data()); @@ -610,7 +671,8 @@ int main(int argc, char **argv) { // send noisy pixels to FXS if (nrNoisyFilesProduced > 0) { // make sure there is at least one file created - printf("SPD DA: Preparing noisy files for FXS\n"); + // printf("SPD DA: Preparing noisy files for FXS\n"); + printf("SPD DA: Preparing noisy files for FXS , %ld\n",time(NULL) - timeStamp); // send a tared file of all the noisy files TString command = Form("cd %s; tar -cf noisy_phys.tar *",saveDirNoisyToFXS); // printf("\n\n%s\n\n",command.Data()); @@ -621,7 +683,7 @@ int main(int argc, char **argv) { status = daqDA_FES_storeFile(fileName.Data(),id.Data()); if (status!=0) { printf("SPD DA ERROR: Failed to export file %s , status %d\n",fileName.Data(),status); - return -1; + nrErrors++; } #endif idsFXSfile << Form("%s\n",id.Data()); @@ -636,7 +698,7 @@ int main(int argc, char **argv) { status = daqDA_FES_storeFile(idsFXSFileName.Data(),id.Data()); if (status!=0) { printf("SPD DA ERROR: Failed to export file %s , status %d\n",idsFXSFileName.Data(),status); - return -1; + nrErrors++; } #endif @@ -645,8 +707,10 @@ int main(int argc, char **argv) { delete handler; - // printf("*** End step2 , %d\n",time(NULL) - timeStamp); + printf("SPD DA: End of all operations, %d errors, %ld\n", nrErrors, time(NULL) - timeStamp); + if (nrErrors>0) return -1; return 0; + }