]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliGRPPreprocessor.cxx
Coverity fixes.
[u/mrichter/AliRoot.git] / STEER / AliGRPPreprocessor.cxx
index 6663b9e7869b16a9f3e912275b13b4670b8c0d55..8ff30685d0464f24cbb8bc80ae7695e4ea5a9966 100644 (file)
 
 #include "AliTriggerConfiguration.h"
 #include "AliTriggerRunScalers.h"
+#include "AliTriggerInput.h"
 
 #include "AliCDBMetaData.h"
 #include "AliESDVertex.h"
 #include "AliLHCReader.h"
 #include "AliLHCData.h"
 #include "AliDCSArray.h"
+#include "AliDAQ.h"
+#include "AliLTUConfig.h"
 
 class AliLog;
 class AliDCSValue;
@@ -197,7 +200,8 @@ ClassImp(AliGRPPreprocessor)
                   "(SPD Mean Vertex ERROR)",
                   "(DCS FXS Error for LHC Data)",
                   "(LHC Data Error)",
-                  "(LHC Clock Phase Error (from LHC Data))"
+                  "(LHC Clock Phase Error (from LHC Data))",
+                  "(LTU Configuration Error)"
   };
 
 //_______________________________________________________________
@@ -518,6 +522,90 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                error |= 32;
        }
 
+        //===========================//
+       // LTU Configuration         //
+        //===========================//
+
+       Log("*************** Processing LTU Configuration");
+       
+       if (partition.IsNull() && !detector.IsNull()){ // standalone partition
+               Log("STANDALONE partition for current run, using LTU configuration dummy value");
+               AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyLTUConfig");
+               if (!cdbEntry) {
+                       Log(Form("No dummy LTU Config entry found, going into error..."));
+                       error |= 2048;
+               }
+               else{
+                       TObjArray *ltuConfig = (TObjArray*)cdbEntry->GetObject();
+                       if (!ltuConfig){
+                               Log(Form("dummy LTU Config not found in OCDB entry, going into error..."));
+                               error |= 2048;
+                       }
+                       else {
+                               AliCDBMetaData metadata;
+                               metadata.SetResponsible("Roman Lietava");
+                               metadata.SetComment("LTU Config from dummy entry in OCDB");
+                               if (!Store("CTP","LTUConfig", ltuConfig, &metadata, 0, 0)) {
+                                       Log("Unable to store the dummy LTU Config object to OCDB!");
+                                       error |= 2048;
+                               }
+                       }
+               }
+       }
+
+       else if (!partition.IsNull() && detector.IsNull()){ // global partition
+       
+               Log("GLOBAL partition for current run, getting LTU Config from DAQ Logbook (logbook_detectors table)");
+               UInt_t  detectorMask = (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi());
+               Printf ("detectormask = %d",detectorMask);
+               TObjArray * ltuarray = new TObjArray();
+               ltuarray->SetOwner(1);
+               Bool_t isLTUok = kTRUE;
+               for(Int_t i = 0; i<AliDAQ::kNDetectors-2; i++){
+                       if ((detectorMask >> i) & 0x1) {
+                               TString det = AliDAQ::OfflineModuleName(i);
+                               TString detCTPName = AliTriggerInput::fgkCTPDetectorName[i];
+                               if (detCTPName == "CTP") {
+                                       detCTPName="TRG"; // converting according to what is found in DAQ logbook_detectors                                     
+                                       Printf("Processing CTP (CTP Detector name %s) --> SKIPPING, CTP does not have any LTU!!!!!!",detCTPName.Data());
+                                       continue;
+                               }                               
+                               Printf("Processing detector %s (CTP Detector name %s)",det.Data(),detCTPName.Data());
+                               TString* ltu = GetLTUConfig(detCTPName.Data());
+                               if (!ltu){
+                                       Log(Form("No LTU Configuration from DAQ logbook for detector %s (BUT it was expected)! The corresponding CDB entry will not be filled!",detCTPName.Data()));
+                                       error |= 2048;
+                                       isLTUok = kFALSE;
+                                       break;
+                               }
+                               else{
+                                       Float_t ltuFineDelay1 = ltu[0].Atof();
+                                       Float_t ltuFineDelay2 = ltu[1].Atof();
+                                       Float_t ltuBCDelayAdd = ltu[2].Atof();
+                                       const char* name = AliDAQ::DetectorName(i);
+                                       AliLTUConfig* ltuConfig = new AliLTUConfig((UChar_t)AliDAQ::DetectorID(name),ltuFineDelay1,ltuFineDelay2,ltuBCDelayAdd);
+                                       ltuarray->AddAtAndExpand(ltuConfig,i);
+                               }                               
+                       }
+               }
+               if (isLTUok){
+                       AliCDBMetaData metadata;
+                       metadata.SetBeamPeriod(0);
+                       metadata.SetResponsible("Roman Lietava");
+                       metadata.SetComment("LTU Configuration for current run");
+                       if (!Store("CTP","LTUConfig", ltuarray, &metadata, 0, 0)) {
+                               Log("Unable to store the LTU Config object to OCDB!");
+                               error |= 2048;
+                       }               
+               }
+               if (ltuarray) delete ltuarray;
+       }
+
+       else {
+               Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger timing parameters...",partition.Data(),detector.Data()));
+               error |= 32;
+       }
+
 
        //=================//
        // LHC Data        //
@@ -582,7 +670,7 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                Log("GRP Preprocessor Success");
                return 0;
        } else {
-               Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s%s%s%s%s%s%s",
+               Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s%s%s%s%s%s%s%s",
                          kppError[(error&1)?1:0],
                          kppError[(error&2)?2:0],
                          kppError[(error&4)?3:0],
@@ -593,7 +681,8 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                          kppError[(error&128)?8:0],
                          kppError[(error&256)?9:0],
                          kppError[(error&512)?10:0],
-                         kppError[(error&1024)?11:0]
+                         kppError[(error&1024)?11:0],
+                         kppError[(error&2048)?12:0]
                          ));
                return error;
        }
@@ -803,7 +892,7 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                        }
                                }
                                if (!foundBeamStart){
-                                       AliInfo("No value for the Machine Mode found before start of run, the Machine Mode will remain empty");
+                                       AliInfo("No value for the Beam Type found before start of run, the Machine Mode will remain empty");
                                }
                                else {
                                        AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam);
@@ -814,13 +903,19 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                                AliInfo("Setting beam type to p-p");
                                                grpobj->SetBeamType("p-p");
                                        }
-                                       else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){
+                                       else { // if there is no PROTON beam, we suppose it is Pb, and we put A-A
+                                               AliInfo("Setting beam type to A-A");
+                                               grpobj->SetBeamType("A-A");
+                                       }
+                                       /*
+                                         else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){
                                                AliInfo("Setting beam type to Pb-Pb");
                                                grpobj->SetBeamType("Pb-Pb");
                                        }
                                        else{
                                                AliError("Beam Type not known, leaving it empty");
                                        }
+                                       */
                                        if (indexBeam < nBeam-1){
                                                AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(indexBeam+1);
                                                if (beam1){
@@ -2340,7 +2435,7 @@ Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* db
        
        // main logbook
        TString sqlQuery;
-       sqlQuery.Form("SELECT DAQ_time_start, run_type, detectorMask, L3_magnetCurrent, Dipole_magnetCurrent FROM logbook WHERE run = %d", run);
+       sqlQuery.Form("SELECT DAQ_time_start, run_type, detectorMask, L3_magnetCurrent, Dipole_magnetCurrent,beamType FROM logbook WHERE run = %d", run);
        TSQLResult* result = server->Query(sqlQuery);
        if (!result)
                {
@@ -2368,12 +2463,16 @@ Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* db
        TString detectorMaskString(row->GetField(2));
        TString l3CurrentString(row->GetField(3));
        TString dipoleCurrentString(row->GetField(4));
+       TString beamTypeString(row->GetField(5));
        time_t timeStart = (time_t)(timeStartString.Atoi());
        UInt_t detectorMask = (UInt_t)(detectorMaskString.Atoi());
        Float_t l3Current = (Float_t)(TMath::Abs(l3CurrentString.Atof()));
        Float_t dipoleCurrent = (Float_t)(TMath::Abs(dipoleCurrentString.Atof()));
        Char_t l3Polarity = (l3CurrentString.Atof() < 0) ? 1 : 0;
        Char_t dipolePolarity = (dipoleCurrentString.Atof() < 0) ? 1 : 0;
+       if (beamTypeString.CompareTo("Pb-Pb",TString::kIgnoreCase) == 0){
+               beamTypeString="A-A";
+       }
        
        AliGRPObject * grpObj = new AliGRPObject();
        grpObj->SetTimeStart(timeStart); 
@@ -2384,6 +2483,7 @@ Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* db
        grpObj->SetL3Polarity(l3Polarity);
        grpObj->SetDipolePolarity(dipolePolarity);
        grpObj->SetPolarityConventionLHC();  // after the dipole cables swap we comply with LHC convention
+       grpObj->SetBeamType(beamTypeString);
 
        delete row;
        row = 0;