Changing handling of the errors according to discussion following
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 7 Aug 2009 16:06:00 +0000 (16:06 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 7 Aug 2009 16:06:00 +0000 (16:06 +0000)
ALICE Offline Weekly Meeting (6 Aug 2009) and ALICE Trigger Meeting
(7 Aug 2009) - see:

http://indico.cern.ch/conferenceDisplay.py?confId=65472

and

http://indico.cern.ch/conferenceDisplay.py?confId=65383

Included in the commit, the macro to test the GRPPreprocessor,
simulating different types of errors, and an example macro on how to create
dummy entries for CTP Config and Scalers.

GRP/MakeCTPDummyEntries.C [new file with mode: 0644]
GRP/TestGRPPreprocessor.C
STEER/AliGRPPreprocessor.cxx
STEER/AliGRPPreprocessor.h

diff --git a/GRP/MakeCTPDummyEntries.C b/GRP/MakeCTPDummyEntries.C
new file mode 100644 (file)
index 0000000..0ca7a72
--- /dev/null
@@ -0,0 +1,25 @@
+void MakeCTPDummyEntries(){
+
+       // macro to put in OCDB the dummy entries for CTP configuration and scalers
+
+       AliCDBManager *man = AliCDBManager::Instance();
+       man->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+       Char_t * filenameConfig = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
+       Char_t * filenameScalers = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt");
+
+       AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(filenameConfig);
+       AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(filenameScalers);
+
+       AliCDBMetaData* metaconfig = new AliCDBMetaData();
+       metaconfig->SetResponsible("Roman Lietava");
+       metaconfig->SetComment("Dummy CTP configuration for standalone runs");
+       AliCDBId idconfig("GRP/CTP/DummyConfig",0,AliCDBRunRange::Infinity());
+       man->Put(runcfg,idconfig, metaconfig);
+
+       AliCDBMetaData* metascalers = new AliCDBMetaData();
+       metascalers->SetResponsible("Roman Lietava");
+       metascalers->SetComment("Dummy CTP scalers for standalone runs");
+       AliCDBId idscalers("GRP/CTP/DummyScalers",0,AliCDBRunRange::Infinity());
+       man->Put(scalers,idscalers, metascalers);
+       return;
+}
index 6aa1733..c9ffcf2 100644 (file)
@@ -7,71 +7,61 @@
 //   ReadDCSAliasMap() reads from a file
 //   CreateInputFilesMap() creates a list of local files, that can be accessed by the shuttle
   
+// Taking as input runtype and errorLevel
+// errorLevel used to simulate errors:
+// 0 --> no error
+// 1 --> DAQ logbook error
+// 2 --> DAQ FXS error
+// 3 --> DAQ logbook_trigger_config erro
+// 4 --> DCS FXS error
+// 5 --> DCS DPs error
+// 6 --> Missing beamEnergy
+// 7 --> null buffer for Trigger Config
+
+// Need to include dummy files in TestShuttle/TestCDB for CTP Configuration and Scalers 
+// (see macro $ALICE_ROOT/GRP/MakeCTPDummyEntries.C)
+
+// Modified by C. Zampolli 
+
+
 #include <iostream>
 #include <fstream>
 using namespace std;
 
-void TestGRPPreprocessor()
+void TestGRPPreprocessor(const char* runtype="PHYSICS", TString partition="ALICE", TString detector="", TString beamType = "p-p", Int_t errorLevel=0)
 {
-  // load library
-//  gSystem->Load("libSTEER.so");        // needed for AliGRPPreprocessor
   gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle.so");
 
-  // create AliTestShuttle instance
-  // The parameters are run, startTime, endTime
   Int_t kRun = 7;
   AliTestShuttle* shuttle = new AliTestShuttle(kRun, 1, 10);
 
-  // by default they are set to $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB and TestReference
-  AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestCDB");
-  AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/OCDB/SHUTTLE/TestShuttle/TestReference");
+  AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB");
+  AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference");
 
   printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data());
   printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data());
 
+  // setting runtype
+  shuttle->SetInputRunType(runtype);
 
-  // The shuttle can read DCS data, if the preprocessor should be tested to process DCS data,
-  // some fake data has to be created.
-  //
-  // The "fake" input data can be taken using either (a) or (b):
-  // (a) data from a file: Use ReadDCSAliasMap()
-  //     the format of the file is explained in ReadDCSAliasMap()
-  //     To use it uncomment the following line:
-  //
-  //TMap* dcsAliasMap = ReadDCSAliasMap();
-  //
-  // (b) generated in this macro: Use CreateDCSAliasMap() and its documentation
-  //     To use it uncomment the following line:
-  //
-  TMap* dcsAliasMap = CreateDCSAliasMap();
-
-  // now give the alias map to the shuttle
+  // simulating DCS DPs
+  TMap* dcsAliasMap = CreateDCSAliasMap(errorLevel);
   shuttle->SetDCSInput(dcsAliasMap);
 
-  // The shuttle can also process files that originate from DCS, DAQ and HLT.
-  // To test it, we provide some local files and locations where these would be found when
-  // the online machinery would be there.
-  // In real life this functions would be produces by the sub-detectors
-  // calibration programs in DCS, DAQ or HLT. These files can then be retrieved using the Shuttle.
-  //
-  // Files are added with the function AliTestShuttle::AddInputFile. The syntax is:
-  // AddInputFile(<system>, <detector>, <id>, <source>, <local-file>)
-  // In this example we add a file originating from the GDC with the id PEDESTALS
-  // Three files originating from different LDCs but with the same id are also added
-  // Note that the test preprocessor name is TPC. The name of the detector's preprocessor must follow
-  // the "online" naming convention ALICE-INT-2003-039.
-  //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test000.tag.root", "GDC0", "runTags01.root");
-  //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test001.tag.root", "GDC1", "runTags02.root");
-  //shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "Period_test002.tag.root", "GDC2", "runTags03.root");
-
-  shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
-  shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
-  shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
-  shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root");
-       
-  shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_runconfig", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg"));
-  shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "DCS FXS", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
-  
+  // simulating input from DAQ FXS
+  if (errorLevel != 2){
+         shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
+         shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021390_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021390_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
+         shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root", "GDC0", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc0_Period_TDSMtest.Seq_0.tag.root");
+         shuttle->AddInputFile(AliShuttleInterface::kDAQ, "GRP", "run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root", "GDC1", "$ALICE_ROOT/GRP/ShuttleInput/run000021391_GRP_gdc1_Period_TDSMtest.Seq_0.tag.root");
+         
+  }
+
+  // simulating input from DCS FXS
+  if (errorLevel != 4 && !partition.IsNull() && detector.IsNull()){
+         shuttle->AddInputFile(AliShuttleInterface::kDCS, "GRP", "CTP_xcounters", "", gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/xcounters.txt"));
+  }
+
   Char_t * filename = gSystem->ExpandPathName("$ALICE_ROOT/GRP/CTP/p-p.cfg");
   ifstream is;
   is.open(filename);
@@ -81,40 +71,36 @@ void TestGRPPreprocessor()
   is.seekg(0,ios::beg);
   is.read(buffer,length);
   is.close();
+  const char *emptybuffer = NULL;
 
-  shuttle->SetInputTriggerConfiguration(buffer);
+  // simulating input from DAQ logbook_trigger_config
+  if {
+         (errorLevel != 3 errorLevel != 7 && !partition.IsNull() && detector.IsNull()) shuttle->SetInputTriggerConfiguration(buffer);
+  }
+  else if (errorLevel == 7) {
+         shuttle->SetInputTriggerConfiguration(emptybuffer);
+  }
   
-  // The shuttle can read run type stored in the DAQ logbook.
-  // To test it, we must provide the run type manually. They will be retrieved in the preprocessor
-  // using GetRunType function.
-  shuttle->SetInputRunType("PHYSICS");
-
-  // The shuttle can read run parameters stored in the DAQ run logbook.
-  // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
-  // using GetRunParameter function.
-  shuttle->AddInputRunParameter("time_start", "1233213.22");
-  shuttle->AddInputRunParameter("time_end",   "1345645.22");
-  shuttle->AddInputRunParameter("beamEnergy", "1400.");
-  shuttle->AddInputRunParameter("beamType",    "p-p");
+  // simulating input from DAQ logbook
+  if (errorLevel != 1){
+       shuttle->AddInputRunParameter("DAQ_time_start", "1233213.22");
+  }
+  if (errorLevel != 6){
+       shuttle->AddInputRunParameter("beamEnergy", "1400.");
+  }
+
+  shuttle->AddInputRunParameter("DAQ_time_end",   "1345645.22");
+  shuttle->AddInputRunParameter("beamType",    beamType);
   shuttle->AddInputRunParameter("numberOfDetectors", "5");
   shuttle->AddInputRunParameter("detectorMask", "34555");
   shuttle->AddInputRunParameter("LHCperiod",    "LHC08b");
+  shuttle->AddInputRunParameter("partition",partition);
+  shuttle->AddInputRunParameter("detector",detector);
 
-//  shuttle->AddInputRunParameter("totalEvents", "30000");
-//  shuttle->AddInputRunParameter("NumberOfGDCs", "15");
-
-  // TODO(5) NOT NEEDED
-  //
-  // This is for preprocessor that require data from HLT.
-  // Since HLT may be switched off, the preprocessor should first query the Run logbook where
-  // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns
-  // a bool directly. 1 = HLT ON, 0 = HLT OFF
-  //
-
+  // simulating HLT
   Bool_t hltStatus = kTRUE;
   shuttle->SetInputHLTStatus(hltStatus);
 
-
   // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
   AliPreprocessor* test = new AliGRPPreprocessor(shuttle);
 
@@ -123,10 +109,6 @@ void TestGRPPreprocessor()
 
   printf("\n\n");
 
-  // In the preprocessor AliShuttleInterface::Store should be called to put the final
-  // data to the CDB. To check if all went fine have a look at the files produced in
-  // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data
-  //
   // Check the file which should have been created
   AliCDBEntry* chkEntry = AliCDBManager::Instance()->GetStorage(AliShuttleInterface::GetMainCDB())
                        ->Get("GRP/GRP/Data", kRun);
@@ -138,38 +120,67 @@ void TestGRPPreprocessor()
   chkEntry->GetObject()->Print();
   printf("\n\n");
 
-  AliDCSSensor* sen = (AliDCSSensor*)(((TMap*)chkEntry->GetObject())->GetValue("fP2Pressure"));
-  if(sen)
-    sen->GetFit()->MakeGraph(1.5, 9.5, 15)->Draw();
-
-//  AliTestDataDCS* output = dynamic_cast<AliTestDataDCS*> (chkEntry->GetObject());
-  // If everything went fine, draw the result
-//  if (output) {
-//    output->Print();
-//  }
-
-
 }
 
-TMap* CreateDCSAliasMap()
+TMap* CreateDCSAliasMap(Int_t errorLevel)
 {
   // Creates a DCS structure
   // The structure is the following:
-  //   TMap (key --> value)
-  //     <DCSAlias> --> <valueList>
-  //     <DCSAlias> is a string
-  //     <valueList> is a TObjArray of AliDCSValue
-  //     An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
+  // TMap (key --> value)
+  // <DCSAlias> --> <valueList>
+  // <DCSAlias> is a string
+  // <valueList> is a TObjArray of AliDCSValue
+  // An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
   
-  const Int_t fgknDCSDP = 10;
+  const Int_t fgknDCSDP = 50;
   const char* fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
-                   "LHCState",
+                   "LHCState",              // missing in DCS
                    "L3Polarity",
                    "DipolePolarity",
-                   "LHCLuminosity",
-                   "BeamIntensity",
+                   "LHCLuminosity",         // missing in DCS
+                   "BeamIntensity",         // missing in DCS
                    "L3Current",
                    "DipoleCurrent",
+                  "L3_BSF17_H1",
+                  "L3_BSF17_H2",
+                  "L3_BSF17_H3",
+                  "L3_BSF17_Temperature",
+                  "L3_BSF4_H1",
+                  "L3_BSF4_H2",
+                  "L3_BSF4_H3",
+                  "L3_BSF4_Temperature",
+                  "L3_BKF17_H1",
+                  "L3_BKF17_H2",
+                  "L3_BKF17_H3",
+                  "L3_BKF17_Temperature",
+                  "L3_BKF4_H1",
+                  "L3_BKF4_H2",
+                  "L3_BKF4_H3",
+                  "L3_BKF4_Temperature",
+                  "L3_BSF13_H1",
+                  "L3_BSF13_H2",
+                  "L3_BSF13_H3",
+                  "L3_BSF13_Temperature",
+                  "L3_BSF8_H1",
+                  "L3_BSF8_H2",
+                  "L3_BSF8_H3",
+                  "L3_BSF8_Temperature",
+                  "L3_BKF13_H1",
+                  "L3_BKF13_H2",
+                  "L3_BKF13_H3",
+                  "L3_BKF13_Temperature",
+                  "L3_BKF8_H1",
+                  "L3_BKF8_H2",
+                  "L3_BKF8_H3",
+                  "L3_BKF8_Temperature",
+                  "Dipole_Inside_H1",
+                  "Dipole_Inside_H2",
+                  "Dipole_Inside_H3",
+                  "Dipole_Inside_Temperature",
+                  "Dipole_Outside_H1",
+                  "Dipole_Outside_H2",
+                  "Dipole_Outside_H3",
+                  "Dipole_Outside_Temperature",
                    "CavernTemperature",
                    "CavernAtmosPressure",
                    "SurfaceAtmosPressure"
@@ -185,39 +196,69 @@ TMap* CreateDCSAliasMap()
   // LHCState
   valueSet = new TObjArray;
   valueSet->SetOwner(1);
-  dcsVal = new AliDCSValue( 'F', 0 );
+  dcsVal = new AliDCSValue( 'F', 2 );
   valueSet->Add(dcsVal);
-//  aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet );
+  aliasMap->Add( new TObjString(fgkDCSDataPoints[0]), valueSet );
 
   // L3Polarity
   valueSet = new TObjArray;
   valueSet->SetOwner(1);
-  dcsVal = new AliDCSValue( kTRUE, 0 );
+  dcsVal = new AliDCSValue( kTRUE, 2 );
   valueSet->Add(dcsVal);
   aliasMap->Add( new TObjString(fgkDCSDataPoints[1]), valueSet );
   
   // DipolePolarity
   valueSet = new TObjArray;
   valueSet->SetOwner(1);
-  dcsVal = new AliDCSValue( kTRUE, 0 );
+  dcsVal = new AliDCSValue( kTRUE, 2 );
   valueSet->Add(dcsVal);
   aliasMap->Add( new TObjString(fgkDCSDataPoints[2]), valueSet );
   
   TRandom random;
 
-  //  for( int nAlias=3; nAlias<fgknDCSDP-1; nAlias++)  {
-  for( int nAlias=3; nAlias<fgknDCSDP; nAlias++)  {
+  Int_t maxDPindex = 0;
+  if (errorLevel != 5) {
+         maxDPindex = fgknDCSDP;
+  }
+  else {
+         maxDPindex = 3;  // simulating only a few DP in case errorLevel=5
+  }
+
+  for( int nAlias=3; nAlias<maxDPindex; nAlias++)  {
+         if (nAlias>=7 && nAlias < 47) continue; 
     valueSet = new TObjArray;
     valueSet->SetOwner(1);
 
-    for (int timeStamp=0; timeStamp<100; timeStamp++) {
-      dcsVal = new AliDCSValue((Float_t) (random.Gaus()+5*nAlias), timeStamp);
-      //printf("%s\n",dcsVal->ToString().Data());
+    for (int timeStamp=0; timeStamp<10; timeStamp++) {
+      dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*nAlias), timeStamp+1);
       valueSet->Add(dcsVal);
     }
     aliasMap->Add( new TObjString( fgkDCSDataPoints[nAlias]), valueSet );
   }
 
+  // Hall Probes
+  TString probe1[3] = {"L3_BSF","L3_BKF","Dipole_"};
+  TString probe2[6] = {"17_","4_","13_","8_","Inside_","Outside_"};
+  TString probe3[4] = {"H1","H2","H3","Temperature"};
+  Int_t hp = 0;
+
+  for (Int_t i=0;i<3;i++){
+         for (Int_t j=0;j<6;j++){
+                 for (Int_t k=0;k<4;k++){
+                         TString dpAlias = probe1[i]+probe2[j]+probe3[k];
+                         valueSet = new TObjArray;
+                         valueSet->SetOwner(1);
+                         for (int timeStamp=0; timeStamp<10; timeStamp++) {
+                                 dcsVal = new AliDCSValue((Float_t) (timeStamp+1+10*hp), timeStamp+1);
+                                 valueSet->Add(dcsVal);
+                                 //cout << " hall probe = " << dpAlias << " with value = " << dcsVal->GetFloat() << endl;
+                         }
+                         aliasMap->Add( new TObjString(dpAlias), valueSet );
+                         hp++;
+                 }
+         }
+  }
+
   return aliasMap;
 }
 
@@ -241,7 +282,7 @@ void WriteDCSAliasMap()
 {
   // This writes the output from CreateDCSAliasMap to a CDB file
 
-  TMap* dcsAliasMap = CreateDCSAliasMap();
+  TMap* dcsAliasMap = CreateDCSAliasMap(Int_t errorLevel);
 
   AliCDBMetaData metaData;
   metaData.SetBeamPeriod(0);
index e0500b1..74d175c 100644 (file)
@@ -20,6 +20,7 @@
 //                  Global Run Parameters (GRP) preprocessor
 //    Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
 //    Modified: Ernesto.Lopez.Torres@cern.ch  CEADEN-CERN
+//    Modified: Chiara.Zampolli@cern.ch  CERN
 //-------------------------------------------------------------------------
 
 #include <TChain.h>
@@ -59,7 +60,8 @@ ClassImp(AliGRPPreprocessor)
 
 //_______________________________________________________________
 
-  const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook
+  const Int_t AliGRPPreprocessor::fgknDAQLbPar = 8; // num parameters in the logbook for PHYSICS runs, when beamType from DAQ logbook != cosmic
+  const Int_t AliGRPPreprocessor::fgknDAQLbParReduced = 7; // num parameters in the logbook for the other cases
   const Int_t AliGRPPreprocessor::fgknDCSDP = 50;   // number of dcs dps
   const Int_t AliGRPPreprocessor::fgknDCSDPHallProbes = 40;   // number of dcs dps
   const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
@@ -180,7 +182,8 @@ ClassImp(AliGRPPreprocessor)
                    "(DAQ FXS ERROR)",
                    "(DCS FXS ERROR)",
                    "(DCS data points ERROR)",
-                   "(Trigger Configuration ERROR)"
+                   "(Trigger Configuration ERROR)",
+                   "(DAQ logbook ERROR determining partition of the run)"
   };
 
 //_______________________________________________________________
@@ -232,7 +235,6 @@ void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
   }
   AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
 
-  //  fPressure = new AliDCSSensorArray(fStartTime, fEndTime, array);
   fPressure = new AliDCSSensorArray(GetStartTimeDCSQuery(), GetEndTimeDCSQuery(), array);
 }
 
@@ -242,6 +244,13 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
 {
        // process data retrieved by the Shuttle
        
+       // retrieving "partition" and "detector" fields from DAQ logbook to 
+       // determine the partition in which the run was taken
+       // the partition is used to decide how to react in case of errors for CTP
+
+       TString partition = (TString)GetRunParameter("partition");  
+       TString detector = (TString)GetRunParameter("detector");   
+
        AliGRPObject *grpobj = new AliGRPObject();  // object to store data
 
        //=================//
@@ -249,7 +258,15 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
        //=================//
        UInt_t error = 0;
        
-       grpobj = ProcessDaqLB();
+       Int_t iDaqLB = ProcessDaqLB(grpobj);
+       TString runType = (TString)GetRunType();
+       TString beamType = (TString)GetRunParameter("beamType");
+       if((runType == "PHYSICS" && iDaqLB == fgknDAQLbPar && beamType!="cosmic") ||  (runType == "PHYSICS" && iDaqLB == fgknDAQLbParReduced && beamType=="cosmic") || (runType != "PHYSICS" && iDaqLB == fgknDAQLbParReduced)) {
+               Log(Form("DAQ Logbook, successful!"));
+       } else {
+               Log(Form("DAQ Logbook, could not get all expected entries!!!"));
+               error |= 1;
+       }
 
        //=================//
        // DAQ FXS         //
@@ -265,12 +282,15 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
        //=================//
        // DCS FXS         //
        //=================//
-       UInt_t iDcsFxs = ProcessDcsFxs();
+       UInt_t iDcsFxs = ProcessDcsFxs(partition, detector);
        if( iDcsFxs == 0 ) {
                Log(Form("DCS FXS, successful!"));
-       } else {
+       } else  if (iDcsFxs ==1) {
                Log(Form("DCS FXS, Could not store CTP scalers!!!"));
                error |= 4;
+       } else{
+               Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without CTP scalers...",partition.Data(),detector.Data()));
+               error |= 32;
        }
        
        //=================//
@@ -287,64 +307,72 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
        //=======================//
        // Trigger Configuration //
        //=======================//
-       // either from DAQ logbook.....
+
        const char * triggerConf = GetTriggerConfiguration();
-       if (triggerConf!= NULL) {
-               Log("Found trigger configuration in DAQ logbook");
-               AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConf);      
-               if (!runcfg) {
-                       Log("Bad CTP run configuration file from DAQ logbook! The corresponding CDB entry will not be filled!");
+
+       if (partition.IsNull() && !detector.IsNull()){ // standalone partition
+               Log("STANDALONE partition for current run, using Trigger Configuration dummy value");
+               AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyConfig");
+               if (!cdbEntry) {
+                       Log(Form("No dummy CTP configuration entry found, going into error..."));
                        error |= 16;
                }
-               else {
-                       TString titleCTPcfg = Form("CTP cfg for run %i from DAQ",fRun);
-                       runcfg->SetTitle(titleCTPcfg);
-                       AliCDBMetaData metaData;
-                       metaData.SetBeamPeriod(0);
-                       metaData.SetResponsible("Roman Lietava");
-                       metaData.SetComment("CTP run configuration from DAQ logbook");
-                       if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) {
-                               Log("Unable to store the CTP run configuration object to OCDB!");
+               else{
+                       AliTriggerConfiguration *runcfg = (AliTriggerConfiguration*)cdbEntry->GetObject();
+                       if (!runcfg){
+                               Log(Form("dummy CTP config not found in OCDB entry, going into error..."));
                                error |= 16;
                        }
+                       else {
+                               TString titleCTPcfg = Form("CTP cfg for run %i from Dummy entry in OCDB",fRun);
+                               runcfg->SetTitle(titleCTPcfg);
+                               AliCDBMetaData metaData;
+                               metaData.SetResponsible("Roman Lietava");
+                               metaData.SetComment("CTP run configuration from dummy entry in OCDB");
+                               if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) {
+                                       Log("Unable to store the dummy CTP run configuration object to OCDB!");
+                                       error |= 16;
+                               }
+                       }
                }
        }
-       else {
-               Log("Trigger configuration NOT FOUND in DAQ logbook");
-               error |= 16;
-       }
 
-       /*  the DCS should not been used any more to access this stuff!!!
-       // ...or from DCS FXS
-       else{
-               Log("No trigger configuration found in the DAQ logbook!! Trying reading from DCS FXS...");
-               TString runcfgfile = GetFile(kDCS, "CTP_runconfig", "");
-               if (runcfgfile.IsNull()) {
-                       Log("No CTP runconfig files has been found in DCS FXS!");
-                       error |= 16;
-               }
-               else {
-                       Log(Form("File with Id CTP_runconfig found! Copied to %s",runcfgfile.Data()));
-                       AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfiguration(runcfgfile);
+       else if (!partition.IsNull() && detector.IsNull()){ // global partition
+               Log("GLOBAL partition for current run, using Trigger Configuration from DAQ Logbook");
+               if (triggerConf!= NULL) {
+                       Log("Found trigger configuration in DAQ logbook");
+                       AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConf);      
                        if (!runcfg) {
-                               Log("Bad CTP run configuration file from DCS FXS! The corresponding CDB entry will not be filled!");
-                               error |= 16;;
+                               Log("Bad CTP run configuration file from DAQ logbook! The corresponding CDB entry will not be filled!");
+                               error |= 16;
                        }
                        else {
-                               TString titleCTPcfg = Form("CTP cfg for run %i from DCS",fRun);
+                               TString titleCTPcfg = Form("CTP cfg for run %i from DAQ",fRun);
                                runcfg->SetTitle(titleCTPcfg);
                                AliCDBMetaData metaData;
                                metaData.SetBeamPeriod(0);
                                metaData.SetResponsible("Roman Lietava");
-                               metaData.SetComment("CTP run configuration from DCS FXS");
+                               metaData.SetComment("CTP run configuration from DAQ logbook");
                                if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) {
                                        Log("Unable to store the CTP run configuration object to OCDB!");
                                        error |= 16;
                                }
                        }
                }
+
+               else {
+                       Log("Trigger configuration NULL in DAQ logbook");
+                       error |= 16;
+               }
+       }
+
+       else {
+               Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger configuration...",partition.Data(),detector.Data()));
+               error |= 32;
        }
-       */
+
+       // storing AliGRPObject in OCDB
+
        AliCDBMetaData md;
        md.SetResponsible("Ernesto Lopez Torres");
        md.SetComment("Output parameters from the GRP preprocessor.");
@@ -357,12 +385,13 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
                Log("GRP Preprocessor Success");
                return 0;
        } else {
-               Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s",
+               Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s%s",
                          kppError[(error&1)?1:0],
                          kppError[(error&2)?2:0],
                          kppError[(error&4)?3:0],
                          kppError[(error&8)?4:0],
-                         kppError[(error&16)?5:0]
+                         kppError[(error&16)?5:0],
+                         kppError[(error&32)?6:0]
                          ));
                return error;
        }
@@ -370,24 +399,24 @@ UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
 
 //_______________________________________________________________
 
-AliGRPObject* AliGRPPreprocessor::ProcessDaqLB()
+Int_t AliGRPPreprocessor::ProcessDaqLB(AliGRPObject* grpObj)
 {
        //Getting the DAQ lb information
        
-       time_t timeStart         = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi());
-       time_t timeEnd         = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi());
-       Float_t beamEnergy         = (Float_t)(((TString)GetRunParameter("beamEnergy")).Atof());
+       time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi());
+       time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi());
+       Float_t beamEnergy = (Float_t)(((TString)GetRunParameter("beamEnergy")).Atof());
        TString beamType = (TString)GetRunParameter("beamType");
        Char_t numberOfDetectors = (Char_t)(((TString)GetRunParameter("numberOfDetectors")).Atoi());
-       UInt_t  detectorMask= (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi());
+       UInt_t  detectorMask = (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi());
        TString lhcPeriod = (TString)GetRunParameter("LHCperiod");
        TString runType = (TString)GetRunType();
 
-       AliGRPObject* grpObj = new AliGRPObject();
-
+       UInt_t nparameter = 0;
        if (timeStart != 0){
                grpObj->SetTimeStart(timeStart);
                Log(Form("Start time for run %d: %d",fRun, (Int_t)timeStart));
+               nparameter++;
        } 
        else {
                Log(Form("Start time not put in logbook, setting to invalid in GRP entry!"));
@@ -396,6 +425,7 @@ AliGRPObject* AliGRPPreprocessor::ProcessDaqLB()
        if (timeEnd != 0){
                grpObj->SetTimeEnd(timeEnd);
                Log(Form("End time for run %d: %i",fRun, (Int_t)timeEnd));
+               nparameter++;
        } 
        else {
                Log(Form("End time not put in logbook, setting to invalid in GRP entry!"));
@@ -404,16 +434,24 @@ AliGRPObject* AliGRPPreprocessor::ProcessDaqLB()
        if (beamEnergy != 0){
                grpObj->SetBeamEnergy(beamEnergy);
                Log(Form("Beam Energy for run %d: %f",fRun, beamEnergy));
+               if ((runType == "PHYSICS" && beamType!="cosmic")){
+                       nparameter++; // increasing nparameters only in case we're in PHYSICS runs with beamType != cosmic
+               }
        } 
        else {
-               Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry!"));
+               if ((runType == "PHYSICS" && beamType!="cosmic")){
+                       Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry, and producing an error (beamType = %s, runType = %s)",beamType.Data(), runType.Data()));
+               }
+               else{
+                       Log(Form("Beam Energy not put in logbook, setting to invalid in GRP entry, but not producing any error (beamType = %s, runType = %s)",beamType.Data(), runType.Data()));
+               }
        }
 
-               Log(Form("Beam Type for run %d: %s",fRun, beamType.Data()));
                
        if (beamType.Length() != 0){
                grpObj->SetBeamType(beamType);
                Log(Form("Beam Type for run %d: %s",fRun, beamType.Data()));
+               nparameter++; 
        } 
        else {
                Log(Form("Beam Type not put in logbook, setting to invalid in GRP entry!"));
@@ -422,6 +460,7 @@ AliGRPObject* AliGRPPreprocessor::ProcessDaqLB()
        if (numberOfDetectors != 0){
                grpObj->SetNumberOfDetectors(numberOfDetectors);
                Log(Form("Number Of Detectors for run %d: %d",fRun, (Int_t)numberOfDetectors));
+               nparameter++;
        } 
        else {
                Log(Form("Number Of Detectors not put in logbook, setting to invalid in GRP entry!"));
@@ -430,6 +469,7 @@ AliGRPObject* AliGRPPreprocessor::ProcessDaqLB()
        if (detectorMask != 0){
                grpObj->SetDetectorMask(detectorMask);
                Log(Form("Detector Mask for run %d: %d",fRun, detectorMask));
+               nparameter++;
        } 
        else {
                Log(Form("Detector Mask not put in logbook, setting to invalid in GRP entry!"));
@@ -438,17 +478,21 @@ AliGRPObject* AliGRPPreprocessor::ProcessDaqLB()
        if (lhcPeriod.Length() != 0) {
                grpObj->SetLHCPeriod(lhcPeriod);
                Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod.Data()));
-       } else {
+               nparameter++;
+       } 
+       else {
                Log(Form("LHCperiod not put in logbook, setting to invalid in GRP entry!"));
        }
        if (runType.Length() != 0) {
                grpObj->SetRunType(runType);
                Log(Form("Run Type (DAQ) for run %d: %s",fRun, runType.Data()));
-       } else {
+               nparameter++;
+       } 
+       else {
                Log(Form("Run Type not put in logbook, setting to invalid in GRP entry!"));
        }
 
-       return grpObj;
+       return nparameter;
 }
 
 //_______________________________________________________________
@@ -535,56 +579,75 @@ UInt_t AliGRPPreprocessor::ProcessDaqFxs()
 }
 
 //_______________________________________________________________
-UInt_t AliGRPPreprocessor::ProcessDcsFxs()
+UInt_t AliGRPPreprocessor::ProcessDcsFxs(TString partition, TString detector)
 {
 
        // processing the info
        // stored in the DCS FXS
        // coming from the trigger
 
-       {
-               // Get the CTP counters information
-               TList* list = GetFileSources(kDCS,"CTP_xcounters");  
-               if (!list) {
-                       Log("No CTP counters file: connection problems with DCS FXS logbook!");
+       // Get the CTP counters information
+
+       if (partition.IsNull() && !detector.IsNull()){ // standalone partition
+               Log("STANDALONE partition for current run, using Trigger Configuration dummy value");
+               AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyScalers");
+               if (!cdbEntry) {
+                       Log(Form("No dummy CTP scalers entry found, going into error..."));
                        return 1;
                }
-               
-               if (list->GetEntries() == 0) {
-                       Log("No CTP counters file to be processed!");
+               else{
+                       AliTriggerRunScalers *scalers = (AliTriggerRunScalers*)cdbEntry->GetObject();
+                       if (!scalers){
+                               Log(Form("CTP dummy scalers not found in OCDB entry, going into error..."));
+                               return 1;
+                       }
+                       else {
+                               AliCDBMetaData metaData;
+                               metaData.SetResponsible("Roman Lietava");
+                               metaData.SetComment("CTP scalers from dummy entry in OCDB");
+                               if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
+                                       Log("Unable to store the dummy CTP scalers object to OCDB!");
+                                       return 1;
+                               }
+                       }
+               }
+       }
+
+       else if (!partition.IsNull() && detector.IsNull()){ // global partition
+               Log("GLOBAL partition for current run, using CTP scalers from DCS FXS");
+               TString countersfile = GetFile(kDCS, "CTP_xcounters","");
+               if (countersfile.IsNull()) {
+                       Log("No CTP counters files has been found: empty source!");
                        return 1;
                }
                else {
-                       TIter iter(list);
-                       TObjString *source;
-                       while ((source = dynamic_cast<TObjString *> (iter.Next()))) {
-                               TString countersfile = GetFile(kDCS, "CTP_xcounters", source->GetName());
-                               if (countersfile.IsNull()) {
-                                       Log("No CTP counters files has been found: empty source!");
-                               }
-                               else {
-                                       Log(Form("File with Id CTP_xcounters found in source %s! Copied to %s",source->GetName(),countersfile.Data()));
-                                       AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile);
-                                       if (!scalers) {
-                                               Log("Bad CTP counters file! The corresponding CDB entry will not be filled!");
-                                               return 1;
-                                       }
-                                       else {
-                                               AliCDBMetaData metaData;
-                                               metaData.SetBeamPeriod(0);
-                                               metaData.SetResponsible("Roman Lietava");
-                                               metaData.SetComment("CTP scalers");
-                                               if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
-                                                       Log("Unable to store the CTP scalers object to OCDB!");
-                                               }
-                                       }
+                       Log(Form("File with Id CTP_xcounters found in DCS FXS! Copied to %s",countersfile.Data()));
+                       AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile);
+                       if (!scalers) {
+                               Log("Bad CTP counters file! The corresponding CDB entry will not be filled!");
+                               return 1;
+                       }
+                       else {
+                               AliCDBMetaData metaData;
+                               metaData.SetBeamPeriod(0);
+                               metaData.SetResponsible("Roman Lietava");
+                               metaData.SetComment("CTP scalers");
+                               if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
+                                       Log("Unable to store the CTP scalers object to OCDB!");
+                                       return 1;
                                }
                        }
                }
-               delete list;
        }
        
+
+       else{   
+               Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error...",partition.Data(),detector.Data()));
+               return 2;
+       }
+
        return 0;
+
 }
 //_______________________________________________________________
 
@@ -787,46 +850,6 @@ Int_t AliGRPPreprocessor::ProcessEnvDPs(TMap* valueMap, AliGRPObject* grpObj)
                
        }
 
-       /*      indexDP = kCavernAtmosPressure;
-       array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
-       if(!array) {
-               Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
-       } 
-       else {
-               Float_t *floatDCS = ProcessFloatAll(array);
-               grpObj->SetCavernAtmosPressure(floatDCS);
-               delete floatDCS;
-               nEnvEntries++;
-       }
-       
-
-       if (array) array = 0x0;
-
-       AliInfo(Form("==========SurfaceAtmosPressure==========="));
-       indexDP = kSurfaceAtmosPressure;
-       AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap);
-       dcsSensorArray->Print();
-       AliInfo(Form("fPressure = %p",fPressure));
-       AliInfo(Form("dcsSensorArray = %p",dcsSensorArray));
-       if( fPressure->NumFits()==0 ) {
-               Log("Problem with the pressure sensor values!!!");
-       } 
-       else {
-               AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
-               AliDebug(2,Form("sensorP2 = %p", sensorP2));
-               if( sensorP2->GetFit() ) {
-                       Log(Form("<%s> for run %d: Sensor Fit found",fgkDCSDataPoints[indexDP], fRun));
-                       grpObj->SetSurfaceAtmosPressure(sensorP2);
-                       nEnvEntries++;
-               } 
-               //if (sensorP2) delete sensorP2;
-               else {
-                       Log(Form("ERROR Sensor Fit for %s not found: ", fgkDCSDataPoints[indexDP] ));
-               }
-               
-       }
-       */
-
        return nEnvEntries;
 }
 //_______________________________________________________________
@@ -990,7 +1013,7 @@ AliSplineFit* AliGRPPreprocessor::GetSplineFit(const TObjArray *array, const TSt
                v = (AliDCSValue*)array->At(iarray);
                value[iarray] = v->GetFloat();
                time[iarray] = v->GetTimeStamp();
-               AliInfo(Form("iarray = %d, value = %f, time = %f",iarray,value[iarray],time[iarray]));
+               AliDebug(2,Form("iarray = %d, value = %f, time = %f",iarray,value[iarray],time[iarray]));
        }
        TGraph* gr = new TGraph(entriesarray,value,time);
        if (!gr ) {
@@ -1134,8 +1157,8 @@ Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
        parameters[3] = aDCSArraySDMean;
        parameters[4] = aDCSArraySDMedian;
 
-       //      AliDebug(2,Form("mean = %f, truncated mean = %f, median = %f, SD wrt mean = %f, SD wrt median = %f ",parameters[0],parameters[1],parameters[2],parameters[3],parameters[4]));
-       AliInfo(Form("mean = %f, truncated mean = %f, median = %f, SD wrt mean = %f, SD wrt median = %f ",parameters[0],parameters[1],parameters[2],parameters[3],parameters[4]));
+       AliDebug(2,Form("mean = %f, truncated mean = %f, median = %f, SD wrt mean = %f, SD wrt median = %f ",parameters[0],parameters[1],parameters[2],parameters[3],parameters[4]));
+       //AliInfo(Form("mean = %f, truncated mean = %f, median = %f, SD wrt mean = %f, SD wrt median = %f ",parameters[0],parameters[1],parameters[2],parameters[3],parameters[4]));
 
        return parameters;
 }
index 6264f4d..b605f15 100644 (file)
@@ -77,9 +77,9 @@ class AliGRPPreprocessor: public AliPreprocessor {
   
   virtual     UInt_t   Process(TMap* valueSet);
 
-                AliGRPObject*  ProcessDaqLB();
+               Int_t   ProcessDaqLB(AliGRPObject* grpobj);
               UInt_t   ProcessDaqFxs();
-              UInt_t   ProcessDcsFxs();
+              UInt_t   ProcessDcsFxs(TString partition="", TString detector="");
                Int_t   ProcessDcsDPs(TMap* valueSet, AliGRPObject* grpobj);
                Int_t   ProcessLHCDPs(const TMap* valueSet, AliGRPObject* grpobj);
                Int_t   ProcessL3DPs(const TMap* valueSet, AliGRPObject* grpobj);
@@ -98,7 +98,8 @@ class AliGRPPreprocessor: public AliPreprocessor {
 
  private:
  
-  static const Int_t   fgknDAQLbPar;            //! number of DAQ lb parameters
+  static const Int_t   fgknDAQLbPar;            //! number of DAQ lb parameters for PHYSICS runs
+  static const Int_t   fgknDAQLbParReduced;     //! number of DAQ lb parameters for non PHYSICS runs
   static const Int_t   fgknDCSDP;               //! number of dcs dps
   static const char*   fgkDCSDataPoints[];      //! names of dcs dps
   static const char*   fgkLHCState[];           //! names of LHC States