]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDPreprocessor.cxx
Modifications by Thomas
[u/mrichter/AliRoot.git] / TRD / AliTRDPreprocessor.cxx
index deeddd352bc9e8836ae6c12e301a86fd98b44e95..8b2bf56a9c85f677f73c553f1606cd5ef2428df3 100644 (file)
@@ -106,7 +106,8 @@ UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
   Log(Form("runtype %s\n",runType.Data()));
   
   // always process the configuration data
- if(ProcessDCSConfigData()) return 1; 
+  Int_t DCSConfigReturn = ProcessDCSConfigData();
+  if(DCSConfigReturn) return DCSConfigReturn; 
   
   if (runType=="PEDESTAL"){
     if(ExtractPedestals()) return 1;
@@ -903,17 +904,14 @@ UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
   // parse it/them and store TObjArrays in the CDB
   //
   // return 0 for success, otherwise:
-  //  5 : could not get the SOR file from the FXS
-  //  6 : could not get the EOR file from the FXS
-  //  7 : 
-  //  8 : something wrong with the SOR file
-  //  9 : something wrong with the EOR file
+  //  5 : Could not get the SOR and EOR file from the FXS
+  //  8 : Something wrong with the SOR file
+  //  9 : Something wrong with the EOR file
   // 10 : SOR XML is not well-formed
   // 11 : EOR XML is not well-formed
   // 12 : ERROR in XML SAX validation: something wrong with the content
-  // 13 :
   // 14 : ERROR while creating calibration objects in the handler
-  // 15 : error while storing data in the CDB
+  // 15 : ERROR while storing data in the CDB
   //
 
   Log("Processing the DCS config summary files.");
@@ -922,88 +920,121 @@ UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
   Log("Requesting the 2 summaryfiles from the FXS..");
   const char *xmlFileS = GetFile(kDCS,"CONFIGSUMMARYSOR","");
   const char *xmlFileE = GetFile(kDCS,"CONFIGSUMMARYEOR","");
-  // for the time being just request BOTH files from the FXS
-  // THEN it can be created online (otherwise the FXS would be messed up)
-  // the next step is to actually read BOTH files and store their informations
-  if (xmlFileS == NULL) {
-    Log(Form("ERROR: SOR File %s not found!",xmlFileS));
+  // Request EOR and SOR files from the fxs, if both are not found exit
+
+  if (xmlFileS == NULL && xmlFileE == NULL) {
+    Log(Form("ERROR: SOR and EOR Files %s and %s not found!",xmlFileS,xmlFileE));
     return 5;
+  } 
+
+  Bool_t fileExistE = true, fileExistS = true;
+
+  if (xmlFileS == NULL) {
+    Log(Form("Warning: SOR File %s not found!",xmlFileS));
+    fileExistE = false;
   } else if (xmlFileE == NULL) {
-    Log(Form("ERROR: EOR File %s not found!",xmlFileE));
-    return 6;
+    Log(Form("Warning: EOR File %s not found!",xmlFileE));
+    fileExistS = false;
   } else {
     Log(Form("Both Files (%s and %s) found.",xmlFileS,xmlFileE));
   }
-  
-  // test the files
-  std::ifstream fileTestS, fileTestE;
-  fileTestS.open(xmlFileS, std::ios_base::binary | std::ios_base::in);
-  fileTestE.open(xmlFileE, std::ios_base::binary | std::ios_base::in);
-  if (!fileTestS.good() || fileTestS.eof() || !fileTestS.is_open()) {
-    Log(Form("ERROR: File %s not valid!",xmlFileS));
-    return 8;
-  }
-  if (!fileTestE.good() || fileTestE.eof() || !fileTestE.is_open()) {
-    Log(Form("ERROR: File %s not valid!",xmlFileE));
-    return 9;
-  }
-  fileTestS.seekg(0, std::ios_base::end);
-  fileTestE.seekg(0, std::ios_base::end);
-  if (static_cast<int>(fileTestS.tellg()) < 2) {
-    Log(Form("ERROR: File %s is empty!",xmlFileS));
-    return 8;
-  }
-  if (static_cast<int>(fileTestE.tellg()) < 2) {
-    Log(Form("ERROR: File %s is empty!",xmlFileE));
-    return 9;
-  }
-  Log("Files are tested valid.");   
+
+  if (fileExistS) {
+    // test the files
+    std::ifstream fileTestS;
+    fileTestS.open(xmlFileS, std::ios_base::binary | std::ios_base::in);
+    if (!fileTestS.good() || fileTestS.eof() || !fileTestS.is_open()) {
+      Log(Form("ERROR: File %s not valid!",xmlFileS));
+      return 8;
+    }
+    fileTestS.seekg(0, std::ios_base::end);
+    if (static_cast<int>(fileTestS.tellg()) < 2) {
+      Log(Form("ERROR: File %s is empty!",xmlFileS));
+      return 8;
+    }
+  }
+
+  if (fileExistE) {
+    std::ifstream fileTestE;
+    fileTestE.open(xmlFileE, std::ios_base::binary | std::ios_base::in);
+    if (!fileTestE.good() || fileTestE.eof() || !fileTestE.is_open()) {
+      Log(Form("ERROR: File %s not valid!",xmlFileE));
+      return 9;
+    }
+    fileTestE.seekg(0, std::ios_base::end);
+    if (static_cast<int>(fileTestE.tellg()) < 2) {
+      Log(Form("ERROR: File %s is empty!",xmlFileE));
+      return 9;
+    }
+  }
+
+  Log("Tested files are valid.");   
 
   // make a robust XML validation
   TSAXParser testParser;
-  if (testParser.ParseFile(xmlFileS) < 0 ) {
+  if (fileExistS && testParser.ParseFile(xmlFileS) < 0 ) {
     Log("ERROR: XML content (SOR) is not well-formed.");
     return 10;
-  } else if (testParser.ParseFile(xmlFileE) < 0 ) {
+  } else if (fileExistE && testParser.ParseFile(xmlFileE) < 0 ) {
     Log("ERROR: XML content (EOR) is not well-formed.");
     return 11;
   }
   Log("XML contents are well-formed.");
-      
+
   // create parser and parse
   TSAXParser saxParserS, saxParserE;
   AliTRDSaxHandler saxHandlerS, saxHandlerE;
-  saxParserS.ConnectToHandler("AliTRDSaxHandler", &saxHandlerS);
-  saxParserS.ParseFile(xmlFileS);
-  saxParserE.ConnectToHandler("AliTRDSaxHandler", &saxHandlerE);
-  saxParserE.ParseFile(xmlFileE);
 
-  // report errors if present
-  if ((saxParserS.GetParseCode() == 0) && (saxParserE.GetParseCode() == 0)) {
+  if (fileExistS) {
+    saxParserS.ConnectToHandler("AliTRDSaxHandler", &saxHandlerS);
+    saxParserS.ParseFile(xmlFileS);
+  }
+  if (fileExistE) {
+    saxParserE.ConnectToHandler("AliTRDSaxHandler", &saxHandlerE);
+    saxParserE.ParseFile(xmlFileE);
+  }
+
+  // report errors if present 
+  if (((fileExistS && saxParserS.GetParseCode() == 0) || !fileExistS) && (!fileExistE || (fileExistE && saxParserE.GetParseCode() == 0))) {
     Log("XML file validation OK.");
   } else {
-    Log(Form("ERROR in XML file validation. Parsecodes: SOR: %s, EOR: %s", saxParserS.GetParseCode(), saxParserE.GetParseCode()));
+    if (fileExistS) {
+      Log(Form("ERROR in XML file validation. SOR Parse Code: %s", saxParserS.GetParseCode()));
+    }
+    if (fileExistE) {
+      Log(Form("ERROR in XML file validation. EOR Parse Code: %s", saxParserE.GetParseCode()));
+    }
     return 12;
   }
-  if ((saxHandlerS.GetHandlerStatus() == 0) && (saxHandlerE.GetHandlerStatus() == 0)) {
+  if (((fileExistS && saxHandlerS.GetHandlerStatus() == 0) || !fileExistS) && (!fileExistE || (saxHandlerE.GetHandlerStatus() == 0))) {
     Log("SAX handler reports no errors.");
   } else  {
-    Log(Form("ERROR while creating calibration objects. Error codes: SOR: %s, EOR: %s", saxHandlerS.GetHandlerStatus(), saxHandlerE.GetHandlerStatus()));
+    if (fileExistS) {
+      Log(Form("ERROR while creating calibration objects. SOR Error code: %s", saxHandlerS.GetHandlerStatus()));
+    }
+    if (fileExistE) {
+      Log(Form("ERROR while creating calibration objects. EOR Error code: %s", saxHandlerE.GetHandlerStatus()));
+    }
     return 14;
   }
 
-  // get the calibration object storing the data from the handler
-  AliTRDCalDCS* fCalDCSObjSOR = saxHandlerS.GetCalDCSObj();
-  AliTRDCalDCS* fCalDCSObjEOR = saxHandlerE.GetCalDCSObj();
-  fCalDCSObjSOR->EvaluateGlobalParameters();
-  fCalDCSObjEOR->EvaluateGlobalParameters();
-  
   // put both objects in one TObjArray to store them
   TObjArray* fCalObjArray = new TObjArray(2);
   fCalObjArray->SetOwner();
-  fCalObjArray->AddAt(fCalDCSObjSOR,0);
-  fCalObjArray->AddAt(fCalDCSObjEOR,1);
-  
+
+  // get the calibration object storing the data from the handler
+  if (fileExistS) {
+    AliTRDCalDCS* fCalDCSObjSOR = saxHandlerS.GetCalDCSObj();
+    fCalDCSObjSOR->EvaluateGlobalParameters();
+    fCalObjArray->AddAt(fCalDCSObjSOR,0);
+  }
+
+  if (fileExistE) {
+    AliTRDCalDCS* fCalDCSObjEOR = saxHandlerE.GetCalDCSObj();
+    fCalDCSObjEOR->EvaluateGlobalParameters();
+    fCalObjArray->AddAt(fCalDCSObjEOR,1);
+  }
+
   // store the DCS calib data in the CDB
   AliCDBMetaData metaData1;
   metaData1.SetBeamPeriod(0);