]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFPreprocessor.cxx
code cleanup, removing unused functionality; fully implemented in the AliHLTTPCDataCo...
[u/mrichter/AliRoot.git] / TOF / AliTOFPreprocessor.cxx
index c0b06988b814ae022e097ef5c6560edc2d544cfd..7611488adb6942178c242be191fd25f910b11186 100644 (file)
@@ -169,11 +169,9 @@ UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap *dcsAliasMap)
 
   // processing DCS
 
-  fData->SetFDRFlag(fFDRFlag);
-  
   if (!dcsAliasMap){
     Log("No DCS map found: TOF exiting from Shuttle");
-    if (fData){
+    if (fData) {
            delete fData;
            fData = 0;
     }
@@ -181,11 +179,18 @@ UInt_t AliTOFPreprocessor::ProcessDCSDataPoints(TMap *dcsAliasMap)
   }
   else {
 
-  // The processing of the DCS input data is forwarded to AliTOFDataDCS
+    if (!fData) {
+       Log("No DCSdata map initialized: TOF exiting from Shuttle");
+       return 0;// return error Code for DCS data map not initialized
+    }
+
+    fData->SetFDRFlag(fFDRFlag);
+  
+    // The processing of the DCS input data is forwarded to AliTOFDataDCS
     resultDCSMap=fData->ProcessData(*dcsAliasMap);
     if(!resultDCSMap){
       Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
-      if (fData){
+      if (fData) {
              delete fData;
              fData = 0;
       }
@@ -236,8 +241,6 @@ UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap *dcsAliasMap)
 
   // processing DCS HV and LV data points
 
-  fHVLVmaps->SetFDRFlag(fFDRFlag);
-  
   if (!dcsAliasMap){
     Log("No DCS map found: TOF exiting from Shuttle");
     if (fHVLVmaps){
@@ -248,8 +251,15 @@ UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap *dcsAliasMap)
   }
   else {
 
+    if (!fHVLVmaps) {
+       Log("No HVLVdata map initialized: TOF exiting from Shuttle");
+       return 200;// return error Code for HVLV data map not initialized
+    }
+
+    fHVLVmaps->SetFDRFlag(fFDRFlag);
+  
     // The processing of the DCS input data is forwarded to AliTOFDataDCS
-    //if (0) { // AdC
     resultDCSMap = fHVLVmaps->ProcessData(*dcsAliasMap);
     if (!resultDCSMap) {
       Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
@@ -335,7 +345,7 @@ UInt_t AliTOFPreprocessor::ProcessHVandLVdps(TMap *dcsAliasMap)
       */
 
     }
-    //} // AdC
+
   }
 
 
@@ -448,7 +458,7 @@ UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
                          integralThr = tmpstr.Atof();
                  }
                  else {
-                         Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %i",integralThr));
+                         Log(Form("No IntegralThr value found in Map from Config entry in CDB, using default value: IntegralThr = %f",integralThr));
                  }
                  TObjString *strThrPar = (TObjString*)configMap->GetValue("ThrPar");
                  if (strThrPar) {
@@ -456,7 +466,7 @@ UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
                          thrPar = tmpstr.Atof();
                  }
                  else {
-                         Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %i",thrPar));
+                         Log(Form("No ThrPar value found in Map from Config entry in CDB, using default value: ThrPar = %f",thrPar));
                  }
          }
   }
@@ -506,6 +516,10 @@ UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
                          list->Print();
                          for (Int_t jj=0;jj<list->GetEntries();jj++){
                                  TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
+                                 if (!str) {
+                                   AliError("dynamic_cast returned NULL");
+                                   return 4;
+                                 }
                                  AliInfo(Form("found source %s", str->String().Data()));
                                  // file to be stored run per run
                                  TString fileNameRun = GetFile(kDAQ, "RUNLevel", str->GetName());
@@ -558,7 +572,11 @@ UInt_t AliTOFPreprocessor::ProcessOnlineDelays()
                  AliInfo("The following sources produced files with the id DELAYS");
                  listTot->Print();
                  for (Int_t jj=0;jj<listTot->GetEntries();jj++){
-                         TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
+                   TObjString * str = dynamic_cast<TObjString*> (listTot->At(jj));
+                   if (!str) {
+                     AliError("dynamic_cast returned NULL");
+                                   return 4;
+                         }
                          AliInfo(Form("found source %s", str->String().Data()));
                          
                          // file with summed histos, to extract calib params
@@ -746,6 +764,21 @@ AliTOFPreprocessor::ProcessT0Fill()
   /* get params from OCDB */
   AliCDBEntry *cdbe = NULL;
 
+  /*
+   * check UseLHCClockPhase flag in RunParams.
+   * if set do nothing and return successfully
+   */
+  cdbe = GetFromOCDB("Calib", "RunParams");
+  if (!cdbe) {
+    Log("cannot get \"RunParams\" entry from OCDB");
+    return 21;
+  }
+  AliTOFRunParams *runparams = (AliTOFRunParams *)cdbe->GetObject();
+  if (runparams->GetUseLHCClockPhase()) {
+    Log("UseLHCClockPhase flag is set in RunParams: online T0-fill not computed");
+    return 0;
+  }
+
   /* 
    * at this stage status object is not on OCDB yet
    * since it will be stored later. nevertheless we
@@ -927,6 +960,11 @@ AliTOFPreprocessor::ProcessT0Fill()
     sigma = 200.;
   }
 
+  /* scratch values from the fit and use max bin center as t0-fill */
+  mean = maxBinCenter;
+  sigma = -1.;
+  Log(Form("do not care about fitted value, just use max bin as t0-fill: %f ps", mean));
+
   /* create RunParams object */
   UInt_t timestamp[1] = {0};
   Float_t t0[1] = {mean};
@@ -937,6 +975,7 @@ AliTOFPreprocessor::ProcessT0Fill()
   runParamsObject->SetT0(t0);
   runParamsObject->SetTOFResolution(tofReso);
   runParamsObject->SetT0Spread(t0Spread);
+  runParamsObject->SetUseLHCClockPhase(kFALSE);
 
   /* store reference data */
   if(fStoreRefData){
@@ -992,17 +1031,17 @@ AliTOFPreprocessor::ProcessNoiseCalibTrg()
   Float_t noiseThr = 1000.;   // setting default threshold for noise to 1000 Hz
   // reading config map
   AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise");
-  if (!cdbEntry) Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr));
+  if (!cdbEntry) Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %f",noiseThr));
   else {
     TMap *configMap = (TMap*)cdbEntry->GetObject();
-    if (!configMap) Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr));
+    if (!configMap) Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %f", noiseThr));
     else {
       TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr");
       if (strNoiseThr) {
        TString tmpstr = strNoiseThr->GetString();
        noiseThr = tmpstr.Atoi();
       }
-      else Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr));
+      else Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %f",noiseThr));
     }
   }
 
@@ -1045,6 +1084,8 @@ AliTOFPreprocessor::ProcessNoiseCalibTrg()
     rate_err /= fMatchingWindow[ich] * 1.e-9;
     hNoiseRate->SetBinContent(ich + 1, rate);
     hNoiseRate->SetBinError(ich + 1, rate_err);
+    /* check error */
+    if (rate_err == 0.) continue;
     /* check noise rate and set noise flags */
     if ((rate - 3. * rate_err) > noiseThr) {
       Log(Form("channel %d detected as noisy: rate = (%f +- %f) Hz", ich, rate, rate_err));
@@ -1251,6 +1292,10 @@ UInt_t AliTOFPreprocessor::ProcessPulserData()
                  for (Int_t jj=0;jj<listPulser->GetEntries();jj++){
                          Int_t nPulserSource = 0;
                          TObjString * str = dynamic_cast<TObjString*> (listPulser->At(jj));
+                         if (!str) {
+                           AliError("dynamic_cast returned NULL");
+                           return 4;
+                         }
                          AliInfo(Form("found source %s", str->String().Data()));
                          // file to be stored run per run
                          TString fileNamePulser = GetFile(kDAQ, "PULSER", str->GetName());
@@ -1379,9 +1424,7 @@ UInt_t AliTOFPreprocessor::ProcessPulserData()
     AliCDBMetaData metaDataHisto;
     metaDataHisto.SetBeamPeriod(0);
     metaDataHisto.SetResponsible("Chiara Zampolli");
-    char comment[200];
-    sprintf(comment,"This preprocessor stores the Ref data from a pulser run.");
-    metaDataHisto.SetComment(comment);
+    metaDataHisto.SetComment("This preprocessor stores the Ref data from a pulser run.");
     AliInfo("Storing Reference Data");
     resultPulserRef = StoreReferenceData("Calib","PulserData",htofPulser, &metaDataHisto);
     if (!resultPulserRef){
@@ -1426,12 +1469,12 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
   // reading config map
   AliCDBEntry *cdbEntry = GetFromOCDB("Calib","ConfigNoise");
   if (!cdbEntry) {
-         Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %d",noiseThr));
+         Log(Form("No Configuration entry found in CDB, using default values: NoiseThr = %f",noiseThr));
   }
   else {
          TMap *configMap = (TMap*)cdbEntry->GetObject();
          if (!configMap){
-                 Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %d", noiseThr));
+                 Log(Form("No map found in Config entry in CDB, using default values: NoiseThr = %f", noiseThr));
          }
          else{
                  TObjString *strNoiseThr = (TObjString*)configMap->GetValue("NoiseThr");
@@ -1440,7 +1483,7 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
                          noiseThr = tmpstr.Atoi();
                  }
                  else {
-                         Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %i",noiseThr));
+                         Log(Form("No NoiseThr value found in Map from ConfigNoise entry in CDB, using default value: NoiseThr = %f",noiseThr));
                  }
          }
   }
@@ -1481,6 +1524,10 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
                  for (Int_t jj=0;jj<listNoise->GetEntries();jj++){
                          Int_t nNoiseSource = 0;
                          TObjString * str = dynamic_cast<TObjString*> (listNoise->At(jj));
+                         if (!str) {
+                           AliError("dynamic_cast returned NULL");
+                           return 4;
+                         }
                          AliInfo(Form("found source %s", str->String().Data()));
                          // file to be stored run per run
                          TString fileNameNoise = GetFile(kDAQ, "NOISE", str->GetName());
@@ -1620,9 +1667,7 @@ UInt_t AliTOFPreprocessor::ProcessNoiseData()
     AliCDBMetaData metaDataHisto;
     metaDataHisto.SetBeamPeriod(0);
     metaDataHisto.SetResponsible("Chiara Zampolli");
-    char comment[200];
-    sprintf(comment,"This preprocessor stores the Ref data from a noise run. ");
-    metaDataHisto.SetComment(comment);
+    metaDataHisto.SetComment("This preprocessor stores the Ref data from a noise run. ");
     AliInfo("Storing Reference Data");
     resultNoiseRef = StoreReferenceData("Calib","NoiseData",htofNoise, &metaDataHisto);
     if (!resultNoiseRef){
@@ -1830,10 +1875,10 @@ UInt_t AliTOFPreprocessor::Process(TMap *dcsAliasMap)
     //    Int_t iresultDAQ = ProcessOnlineDelays();
     Int_t iresultDAQ = ProcessT0Fill();
     Int_t iresultNoiseCalib = ProcessNoiseCalibTrg();
-    //    Int_t iresultReadout = ProcessReadout();
+    Int_t iresultReadout = ProcessReadout();
     Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
     Int_t iResultHVandLVdps = ProcessHVandLVdps(dcsAliasMap);
-    return iresultDAQ+iresultNoiseCalib+iresultDCS+iResultHVandLVdps;
+    return iresultDAQ+iresultNoiseCalib+iresultDCS+iResultHVandLVdps+iresultReadout;
   }
 
   // storing
@@ -1908,6 +1953,7 @@ AliTOFPreprocessor::FillWithCableLengthMap(AliTOFChannelOnlineArray *cal)
            
            /* get channel index */
            index = AliTOFGeometry::GetIndex(det);
+           if (index < 0) continue;
            
            /* get cable time shift */
            cableTimeShift = AliTOFCableLengthMap::GetCableTimeShift(iddl, islot, ichain, itdc);