]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDPreprocessor.cxx
Bugfixes enabling buffer navigation
[u/mrichter/AliRoot.git] / TRD / AliTRDPreprocessor.cxx
index 08d04ef177c56269775de562a152936c1446ee22..0d0fdf607aae543b0b3bc5c316ef01668d9d47db 100644 (file)
@@ -122,11 +122,13 @@ UInt_t AliTRDPreprocessor::Process(TMap* dcsAliasMap)
       //TString runPar = GetRunParameter("HLTStatus");
       //if(runPar=="1") {
       if(GetHLTStatus()) {
-       if(ExtractHLT()) return 1; // for testing!
+       //if(ExtractHLT()) return 1; // for testing!
+       ExtractHLT();
       } 
       // DAQ if HLT failed
       if(!fVdriftHLT) {
-       if(ExtractDriftVelocityDAQ()) return 1; // for testing!
+       //if(ExtractDriftVelocityDAQ()) return 1; 
+       ExtractDriftVelocityDAQ(); // for testing!
       }
     }
   }
@@ -679,13 +681,16 @@ Bool_t AliTRDPreprocessor::ExtractDriftVelocityDAQ()
       Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
        + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
       Int_t nbfit        = calibra->GetNumberFit();
+      Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
       Int_t nbE        = calibra->GetNumberEnt();
       
       // if enough statistics store the results
       if ((nbtg >                  0) && 
-         (nbfit        >= 0.5*nbE)) {
+         (nbfit        >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
        // create the cal objects
+       calibra->RemoveOutliers(1,kTRUE);
        calibra->PutMeanValueOtherVectorFit(1,kTRUE);
+       calibra->RemoveOutliers2(kTRUE);
        calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
        TObjArray object      = calibra->GetVectorFit();
        AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
@@ -796,7 +801,7 @@ Bool_t AliTRDPreprocessor::ExtractHLT()
       Int_t nbE         = calibra->GetNumberEnt();
       // enough statistics
       if ((nbtg >                  0) && 
-         (nbfit        >= 0.5*nbE)) {
+         (nbfit        >= 0.5*nbE) && (nbE > 30)) {
        // create the cal objects
        calibra->PutMeanValueOtherVectorFit(1,kTRUE);
        TObjArray object           = calibra->GetVectorFit();
@@ -832,12 +837,15 @@ Bool_t AliTRDPreprocessor::ExtractHLT()
       Int_t nbtg = 6*4*18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb0(1))
        + 6*  18*((Int_t) ((AliTRDCalibraMode *)calibra->GetCalibraMode())->GetDetChamb2(1));
       Int_t nbfit        = calibra->GetNumberFit();
+      Int_t nbfitSuccess = calibra->GetNumberFitSuccess();
       Int_t nbE          = calibra->GetNumberEnt();
       // enough statistics
       if ((nbtg >                  0) && 
-         (nbfit        >= 0.5*nbE)) {
+         (nbfit        >= 0.5*nbE) && (nbE > 30) && (nbfitSuccess > 30)) {
        // create the cal objects
+       calibra->RemoveOutliers(1,kTRUE);
        calibra->PutMeanValueOtherVectorFit(1,kTRUE);
+       calibra->RemoveOutliers2(kTRUE);
        calibra->PutMeanValueOtherVectorFit2(1,kTRUE);
        TObjArray object  = calibra->GetVectorFit();
        AliTRDCalDet *objdriftvelocitydet = calibra->CreateDetObjectVdrift(&object,kTRUE);
@@ -886,7 +894,7 @@ Bool_t AliTRDPreprocessor::ExtractHLT()
       Int_t nbE          = calibra->GetNumberEnt();
       // enough statistics
       if ((nbtg >                  0) && 
-         (nbfit        >= 0.95*nbE)) {
+         (nbfit        >= 0.95*nbE) && (nbE > 30)) {
        // create cal pad objects 
        TObjArray object            = calibra->GetVectorFit();
        TObject *objPRFpad          = calibra->CreatePadObjectPRF(&object);
@@ -914,7 +922,7 @@ UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
   // parse it/them and store TObjArrays in the CDB
   //
   // return 0 for success, otherwise:
-  //  5 : Could not get the SOR and EOR file from the FXS
+  //  5 : Could not get the (SOR and EOR) or SOR file from the FXS
   //  8 : Both files are not valid
   // 10 : SOR XML is not well-formed
   // 11 : EOR XML is not well-formed
@@ -929,67 +937,77 @@ UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
 
   // get the XML files
   Log("Requesting the 2 summaryfiles from the FXS..");
-  const char *xmlFileS = GetFile(kDCS,"CONFIGSUMMARYSOR","");
-  const char *xmlFileE = GetFile(kDCS,"CONFIGSUMMARYEOR","");
+  TString xmlFileS = GetFile(kDCS,"CONFIGSUMMARYSOR","");
+  TString xmlFileE = GetFile(kDCS,"CONFIGSUMMARYEOR","");
   // 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;
+  Bool_t fileExistE = kTRUE, fileExistS = kTRUE;
 
   // check if the files are there
-  if (xmlFileS == NULL) {
-    Log(Form("Warning: SOR File %s not found!",xmlFileS));
-    fileExistS = false;
-  } else if (xmlFileE == NULL) {
-    Log(Form("Warning: EOR File %s not found!",xmlFileE));
-    fileExistE = false;
-  } else {
-    Log(Form("Both Files (%s and %s) found.",xmlFileS,xmlFileE));
+  if (xmlFileS.IsNull()) {
+         Log(Form("Warning: SOR file %s not found!", xmlFileS.Data()));
+    fileExistS = kFALSE;
+  } else Log(Form("SOR file found: %s", xmlFileS.Data()));
+
+  if (xmlFileE.IsNull()) {
+    Log(Form("Warning: EOR file %s not found!", xmlFileE.Data()));
+    fileExistE = kFALSE;
+  } else Log(Form("EOR file found: %s", xmlFileE.Data()));
+
+  if (fileExistS==0 && fileExistE==0) {
+    Log(Form("ERROR: SOR and EOR files not found: %s and %s", xmlFileS.Data(), xmlFileE.Data()));
+    return 5;
   }
 
   // test the files
   if (fileExistS) {
+    Log("Checking if SOR file is valid.");
     std::ifstream fileTestS;
-    fileTestS.open(xmlFileS, std::ios_base::binary | std::ios_base::in);
+    fileTestS.open(xmlFileS.Data(), std::ios_base::binary | std::ios_base::in);
     if (!fileTestS.good() || fileTestS.eof() || !fileTestS.is_open()) {
-      Log(Form("Warning: File %s not valid!",xmlFileS));
-      fileExistS = false;
+      Log(Form("Warning: File %s not valid!",xmlFileS.Data()));
+      fileExistS = kFALSE;
+      return 5;
     }
+    Log("Checking if SOR file is not empty.");
     fileTestS.seekg(0, std::ios_base::end);
     if (static_cast<int>(fileTestS.tellg()) < 2) {
-      Log(Form("Warning: File %s is empty!",xmlFileS));
-      fileExistS = false;
+      Log(Form("Warning: File %s is empty!",xmlFileS.Data()));
+      fileExistS = kFALSE;
+      return 5;
     }
   }
+
+
   if (fileExistE) {
+    Log("Checking if EOR file is valid.");
     std::ifstream fileTestE;
-    fileTestE.open(xmlFileE, std::ios_base::binary | std::ios_base::in);
+    fileTestE.open(xmlFileE.Data(), std::ios_base::binary | std::ios_base::in);
     if (!fileTestE.good() || fileTestE.eof() || !fileTestE.is_open()) {
-      Log(Form("Warning: File %s not valid!",xmlFileE));
-      fileExistE = false;
+      Log(Form("Warning: File %s not valid!",xmlFileE.Data()));
+      fileExistE = kFALSE;
     }
+    Log("Checking if EOR file is not empty.");
     fileTestE.seekg(0, std::ios_base::end);
     if (static_cast<int>(fileTestE.tellg()) < 2) {
-      Log(Form("Warning: File %s is empty!",xmlFileE));
-      fileExistE = false;
+      Log(Form("Warning: File %s is empty!",xmlFileE.Data()));
+      fileExistE = kFALSE;
     }
   }
-  if (!fileExistS && !fileExistE) {
+
+  if (fileExistS==0 && fileExistE==0) {
     Log("ERROR: Both files (SOR/EOR) are not valid!");
     return 8;
   }
+
   Log("One or both of the tested files are valid.");
 
   // make a robust XML validation
   TSAXParser testParser;
-  if (fileExistS && testParser.ParseFile(xmlFileS) < 0 ) {
+  if (fileExistS && testParser.ParseFile(xmlFileS.Data()) < 0 ) {
     Log("ERROR: XML content (SOR) is not well-formed.");
     return 10;
-  } else if (fileExistE && testParser.ParseFile(xmlFileE) < 0 ) {
+  } else if (fileExistE && testParser.ParseFile(xmlFileE.Data()) < 0 ) {
     Log("ERROR: XML content (EOR) is not well-formed.");
     return 11;
   }
@@ -1000,11 +1018,11 @@ UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
   AliTRDSaxHandler saxHandlerS, saxHandlerE;
   if (fileExistS) {
     saxParserS.ConnectToHandler("AliTRDSaxHandler", &saxHandlerS);
-    saxParserS.ParseFile(xmlFileS);
+    saxParserS.ParseFile(xmlFileS.Data());
   }
   if (fileExistE) {
     saxParserE.ConnectToHandler("AliTRDSaxHandler", &saxHandlerE);
-    saxParserE.ParseFile(xmlFileE);
+    saxParserE.ParseFile(xmlFileE.Data());
   }
   // report errors of the parser if present
   if (fileExistS && saxParserS.GetParseCode() != 0) {
@@ -1070,3 +1088,4 @@ UInt_t AliTRDPreprocessor::ProcessDCSConfigData()
   return 0;
 }
 
+