#include <TH1.h>
+// needed for ReceivePromptRecoParameters
+#include <TSQLServer.h>
+#include <TSQLResult.h>
+#include <TSQLRow.h>
+#include <AliCDBManager.h>
+#include <AliCDBMetaData.h>
+#include <AliCDBId.h>
+#include <AliTriggerConfiguration.h>
+
const Double_t kFitFraction = 0.7; // Fraction of DCS sensor fits required
ClassImp(AliGRPPreprocessor)
//_______________________________________________________________
const char* AliGRPPreprocessor::fgkDCSDataPoints[12] = {"LHCState","LHCPeriod","LHCLuminosity","BeamIntensity","L3Current","L3Polarity","DipoleCurrent","DipolePolarity","CavernTemperature","CavernAtmosPressure","gva_cr5AtmosphericPressure","gva_meyrinAtmosphericPressure"};
-//_______________________________________________________________
-AliGRPPreprocessor::AliGRPPreprocessor():
- AliPreprocessor("GRP",0), fPressure(0) {
- // default constructor - Don't use this!
-
-}
-
//_______________________________________________________________
AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
AliPreprocessor("GRP",shuttle), fPressure(0) {
// constructor - shuttle must be instantiated!
-
+
+ AddRunType("PHYSICS");
}
//_______________________________________________________________
//_______________________________________________________________
void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime) {
// Initialize preprocessor
-
- AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
-
- fRun = run;
- fStartTime = startTime;
- fEndTime = endTime;
+
+ AliPreprocessor::Initialize(run, startTime, endTime);
+
AliInfo("Initialization of the GRP preprocessor.");
TClonesArray * array = new TClonesArray("AliDCSSensor",2);
Log(Form("Problem with the DAQ logbook parameters!!!"));
return 1;
}
- TMap *m1 = (TMap *)daqlblist->At(0);
- TObjString *s1 = (TObjString *)m1->GetValue("fAliceStartTime");
- UInt_t iStartTime = atoi(s1->String().Data());
- TMap *m2 = (TMap *)daqlblist->At(1);
- TObjString *s2 = (TObjString *)m2->GetValue("fAliceStopTime");
- UInt_t iStopTime = atoi(s2->String().Data());
//=================//
// DAQ FXS //
//=================//
// DCS data points //
//=================//
- TList *dcsdplist = ProcessDcsDPs(valueMap, iStartTime, iStopTime);
+ TList *dcsdplist = ProcessDcsDPs(valueMap);
if(!dcsdplist) {
Log(Form("Problem with the DCS data points!!!"));
return 1;
// return 0;
// }
- TList * list = new TList();
- list = GetGlobalList(daqlblist,dcsdplist);
- list->SetOwner(1);
- AliInfo(Form("Final list entries: %d",list->GetEntries()));
+ daqlblist->AddAll(dcsdplist);
+ daqlblist->SetOwner(1);
+ AliInfo(Form("Final list entries: %d",daqlblist->GetEntries()));
AliCDBMetaData md;
md.SetResponsible("Panos Christakoglou");
md.SetComment("Output parameters from the GRP preprocessor.");
- Bool_t result = Store("GRP", "Data", list, &md);
+ Bool_t result = Store("GRP", "Data", daqlblist, &md);
- delete list;
+ delete daqlblist;
if (result)
return 0;
return 1;
}
-//_______________________________________________________________
-TList *AliGRPPreprocessor::GetGlobalList(TList *l1, TList *l2) {
- //Getting the global output TList
- TList *list = new TList();
- TMap *map = new TMap();
- for(Int_t i = 0; i < l1->GetEntries(); i++)
- list->AddLast(map = (TMap *)l1->At(i));
- for(Int_t i = 0; i < l2->GetEntries(); i++)
- list->AddLast(map = (TMap *)l2->At(i));
-
- return list;
-}
-
//_______________________________________________________________
TList *AliGRPPreprocessor::ProcessDaqLB() {
//Getting the DAQ lb informnation
list->Add(mapDAQ3); list->Add(mapDAQ4);
list->Add(mapDAQ5); list->Add(mapDAQ6);
list->Add(mapDAQ7);
+
+ TMap* mapDAQ8 = new TMap;
+ mapDAQ8->Add(new TObjString("fRunType"), new TObjString(GetRunType()));
+ list->Add(mapDAQ8);
return list;
}
}
//_______________________________________________________________
-TList *AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, UInt_t iStartTime, UInt_t iStopTime) {
+TList *AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap) {
//Getting the DCS dps
//===========//
Log(Form("LHCState not found!!!"));
return list;
}
- AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,iStartTime,iStopTime);
+ AliGRPDCS *dcs1 = new AliGRPDCS(aliasLHCState,fStartTime,fEndTime);
TString sLHCState = dcs1->ProcessDCS(3);
if (sLHCState) {
Log(Form("<LHCState> for run %d: %s",fRun, sLHCState.Data()));
Log(Form("LHCPeriod not found!!!"));
return list;
}
- AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,iStartTime,iStopTime);
+ AliGRPDCS *dcs2 = new AliGRPDCS(aliasLHCPeriod,fStartTime,fEndTime);
TString sLHCPeriod = dcs2->ProcessDCS(3);
if (sLHCPeriod) {
Log(Form("<LHCPeriod> for run %d: %s",fRun, sLHCPeriod.Data()));
Log(Form("LHCLuminosity not found!!!"));
return list;
}
- AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,iStartTime,iStopTime);
+ AliGRPDCS *dcs3 = new AliGRPDCS(aliasLHCLuminosity,fStartTime,fEndTime);
TString sMeanLHCLuminosity = dcs3->ProcessDCS(2);
if (sMeanLHCLuminosity) {
Log(Form("<LHCLuminosity> for run %d: %s",fRun, sMeanLHCLuminosity.Data()));
Log(Form("BeamIntensity not found!!!"));
return list;
}
- AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,iStartTime,iStopTime);
+ AliGRPDCS *dcs4 = new AliGRPDCS(aliasBeamIntensity,fStartTime,fEndTime);
TString sMeanBeamIntensity = dcs4->ProcessDCS(2);
if (sMeanBeamIntensity) {
Log(Form("<BeamIntensity> for run %d: %s",fRun, sMeanBeamIntensity.Data()));
Log(Form("L3Current not found!!!"));
return list;
}
- AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,iStartTime,iStopTime);
+ AliGRPDCS *dcs5 = new AliGRPDCS(aliasL3Current,fStartTime,fEndTime);
TString sMeanL3Current = dcs5->ProcessDCS(2);
if (sMeanL3Current) {
Log(Form("<L3Current> for run %d: %s",fRun, sMeanL3Current.Data()));
Log(Form("L3Polarity not found!!!"));
return list;
}
- AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,iStartTime,iStopTime);
+ AliGRPDCS *dcs6 = new AliGRPDCS(aliasL3Polarity,fStartTime,fEndTime);
TString sL3Polarity = dcs6->ProcessDCS(4);
if (sL3Polarity) {
Log(Form("<L3Polarity> for run %d: %s",fRun, sL3Polarity.Data()));
Log(Form("DipoleCurrent not found!!!"));
return list;
}
- AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,iStartTime,iStopTime);
+ AliGRPDCS *dcs7 = new AliGRPDCS(aliasDipoleCurrent,fStartTime,fEndTime);
TString sMeanDipoleCurrent = dcs7->ProcessDCS(2);
if (sMeanDipoleCurrent) {
Log(Form("<DipoleCurrent> for run %d: %s",fRun, sMeanDipoleCurrent.Data()));
Log(Form("DipolePolarity not found!!!"));
return list;
}
- AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,iStartTime,iStopTime);
+ AliGRPDCS *dcs8 = new AliGRPDCS(aliasDipolePolarity,fStartTime,fEndTime);
TString sDipolePolarity = dcs8->ProcessDCS(4);
if (sDipolePolarity) {
Log(Form("<DipolePolarity> for run %d: %s",fRun, sDipolePolarity.Data()));
Log(Form("CavernTemperature not found!!!"));
return list;
}
- AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,iStartTime,iStopTime);
+ AliGRPDCS *dcs9 = new AliGRPDCS(aliasCavernTemperature,fStartTime,fEndTime);
TString sMeanCavernTemperature = dcs9->ProcessDCS(2);
if (sMeanCavernTemperature) {
Log(Form("<CavernTemperature> for run %d: %s",fRun, sMeanCavernTemperature.Data()));
Log(Form("CavernPressure not found!!!"));
return list;
}
- AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,iStartTime,iStopTime);
+ AliGRPDCS *dcs10 = new AliGRPDCS(aliasCavernPressure,fStartTime,fEndTime);
TString sMeanCavernPressure = dcs10->ProcessDCS(2);
if (sMeanCavernPressure) {
Log(Form("<CavernPressure> for run %d: %s",fRun, sMeanCavernPressure.Data()));
return result;
}*/
+
+
+//_______________________________________________________________
+Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char* logbookTable, const char* triggerTable, const char *cdbRoot)
+{
+ //
+ // Retrieves logbook and trigger information from the online logbook
+ // This information is needed for prompt reconstruction
+ //
+ // Parameters are:
+ // Run number
+ // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable
+ // cdbRoot
+ //
+ // returns 0 on success
+ // negative on error
+ //
+ // This function is NOT called during the preprocessor run in the Shuttle!
+ //
+
+ // CDB connection
+ AliCDBManager* cdb = AliCDBManager::Instance();
+ cdb->SetDefaultStorage(cdbRoot);
+
+ // SQL connection
+ TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password);
+
+ if (!server)
+ {
+ Printf("ERROR: Could not connect to DAQ LB");
+ return -1;
+ }
+
+ // main logbook
+ TString sqlQuery;
+ sqlQuery.Form("SELECT time_start, run_type, detectorMask FROM %s WHERE run = %d", logbookTable, run);
+ TSQLResult* result = server->Query(sqlQuery);
+ if (!result)
+ {
+ Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
+ return -2;
+ }
+
+ if (result->GetRowCount() == 0)
+ {
+ Printf("ERROR: Run %d not found", run);
+ delete result;
+ return -3;
+ }
+
+ TSQLRow* row = result->Next();
+ if (!row)
+ {
+ Printf("ERROR: Could not receive data from run %d", run);
+ delete result;
+ return -4;
+ }
+
+ TMap grpData;
+ grpData.Add(new TObjString("time_start"), new TObjString(row->GetField(0)));
+ grpData.Add(new TObjString("run_type"), new TObjString(row->GetField(1)));
+ grpData.Add(new TObjString("detectorMask"), new TObjString(row->GetField(2)));
+
+ delete row;
+ row = 0;
+
+ delete result;
+ result = 0;
+
+ Printf("Storing GRP/GRP/Data object with the following content");
+ grpData.Print();
+
+ AliCDBMetaData metadata;
+ metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus");
+ metadata.SetComment("GRP Output parameters received during online running");
+
+ AliCDBId id("GRP/GRP/Data", run, run);
+ Bool_t success = cdb->Put(&grpData, id, &metadata);
+
+ grpData.DeleteAll();
+
+ if (!success)
+ {
+ Printf("ERROR: Could not store GRP/GRP/Data into OCDB");
+ return -5;
+ }
+
+ sqlQuery.Form("SELECT configFile FROM %s WHERE run = %d", triggerTable, run);
+ result = server->Query(sqlQuery);
+ if (!result)
+ {
+ Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
+ return -11;
+ }
+
+ if (result->GetRowCount() == 0)
+ {
+ Printf("ERROR: Run %d not found in logbook_trigger_config", run);
+ delete result;
+ return -12;
+ }
+
+ row = result->Next();
+ if (!row)
+ {
+ Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run);
+ delete result;
+ return -13;
+ }
+
+ TString triggerConfig(row->GetField(0));
+
+ delete row;
+ row = 0;
+
+ delete result;
+ result = 0;
+
+ Printf("Found trigger configuration: %s", triggerConfig.Data());
+
+ // add a function that takes the configuration from a string...
+ AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig);
+ if (!runcfg)
+ {
+ Printf("ERROR: Could not create CTP configuration object");
+ return -14;
+ }
+
+ metadata.SetComment("CTP run configuration received during online running");
+
+ AliCDBId id2("GRP/CTP/Config", run, run);
+ success = cdb->Put(runcfg, id2, &metadata);
+
+ delete runcfg;
+ runcfg = 0;
+
+ if (!success)
+ {
+ Printf("ERROR: Could not store GRP/CTP/Config into OCDB");
+ return -15;
+ }
+
+ server->Close();
+ delete server;
+ server = 0;
+
+ return 0;
+}