1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Class AliGRPPreprocessor
20 // Global Run Parameters (GRP) preprocessor
21 // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
22 // Modified: Ernesto.Lopez.Torres@cern.ch CEADEN-CERN
23 // Modified: Chiara.Zampolli@cern.ch CERN
24 //-------------------------------------------------------------------------
29 #include <TObjString.h>
30 #include <TObjArray.h>
37 #include "AliGRPPreprocessor.h"
38 #include "AliGRPObject.h"
39 #include "AliDCSSensor.h"
40 #include "AliSplineFit.h"
41 #include "AliDCSSensorArray.h"
42 #include "AliRawEventHeaderVersions.h"
44 #include "AliTriggerConfiguration.h"
45 #include "AliTriggerRunScalers.h"
46 #include "AliTriggerInput.h"
48 #include "AliCDBMetaData.h"
49 #include "AliESDVertex.h"
50 #include "AliLHCReader.h"
51 #include "AliLHCData.h"
52 #include "AliDCSArray.h"
54 #include "AliLTUConfig.h"
58 class AliShuttleInterface;
60 // needed for ReceivePromptRecoParameters
62 #include <TSQLServer.h>
63 #include <TSQLResult.h>
65 #include <AliCDBManager.h>
66 #include <AliCDBMetaData.h>
68 #include <AliTriggerConfiguration.h>
69 #include "AliCTPTimeParams.h"
70 #include "AliLHCClockPhase.h"
72 const Double_t kFitFraction = -1.; // Fraction of DCS sensor fits required
74 ClassImp(AliGRPPreprocessor)
76 //_______________________________________________________________
78 const Int_t AliGRPPreprocessor::fgknDAQLbPar = 6; // num parameters in the logbook used to fill the GRP object
79 const Int_t AliGRPPreprocessor::fgknDCSDP = 48; // number of dcs dps
80 const Int_t AliGRPPreprocessor::fgknDCSDPHallProbes = 40; // number of dcs dps
81 const Int_t AliGRPPreprocessor::fgknLHCDP = 9; // number of dcs dps from LHC data
82 const Int_t AliGRPPreprocessor::fgkDCSDPHallTopShift = 4; // shift from the top to get tp the Hall Probes names in the list of DCS DPs
83 const Int_t AliGRPPreprocessor::fgkDCSDPNonWorking = 5; // number of non working DCS DPs
84 const char* AliGRPPreprocessor::fgkDCSDataPoints[AliGRPPreprocessor::fgknDCSDP] = {
92 "L3_BSF17_Temperature",
96 "L3_BSF4_Temperature",
100 "L3_BKF17_Temperature",
104 "L3_BKF4_Temperature",
108 "L3_BSF13_Temperature",
112 "L3_BSF8_Temperature",
116 "L3_BKF13_Temperature",
120 "L3_BKF8_Temperature",
124 "Dipole_Inside_Temperature",
128 "Dipole_Outside_Temperature",
130 "CavernAtmosPressure",
131 "SurfaceAtmosPressure",
132 "CavernAtmosPressure2"
135 const char* AliGRPPreprocessor::fgkDCSDataPointsHallProbes[AliGRPPreprocessor::fgknDCSDPHallProbes] = {
139 "L3_BSF17_Temperature",
143 "L3_BSF4_Temperature",
147 "L3_BKF17_Temperature",
151 "L3_BKF4_Temperature",
155 "L3_BSF13_Temperature",
159 "L3_BSF8_Temperature",
163 "L3_BKF13_Temperature",
167 "L3_BKF8_Temperature",
171 "Dipole_Inside_Temperature",
175 "Dipole_Outside_Temperature"
178 const Short_t kSensors = 45; // start index position of sensor in DCS DPs
179 const Short_t kNumSensors = 3; // Number of sensors in DCS DPs (CavernAtmosPressure, SurfaceAtmosPressure, CavernAtmosPressure2)
182 const char* AliGRPPreprocessor::fgkLHCDataPoints[AliGRPPreprocessor::fgknLHCDP] = {
186 "LHC_Beams_Particle_Type",
187 "BPTX_Phase_Shift_B1",
188 "BPTX_Phase_Shift_B2",
189 "LHC_Particle_Type_B1",
190 "LHC_Particle_Type_B2",
191 "LHC_Data_Quality_Flag"
194 const char* kppError[] = {
196 "(DAQ logbook ERROR)",
198 "(Trigger Scalers not found in DCS FXS - ERROR)",
199 "(DCS data points ERROR)",
200 "(Trigger Configuration ERROR)",
201 "(DAQ logbook ERROR determining partition of the run)",
202 "(CTP timing ERROR)",
203 "(SPD Mean Vertex ERROR)",
204 "(DCS FXS Error for LHC Data)",
206 "(LHC Clock Phase Error (from LHC Data))",
207 "(LTU Configuration Error)",
211 //_______________________________________________________________
213 AliGRPPreprocessor::AliGRPPreprocessor(AliShuttleInterface* shuttle):
214 AliPreprocessor("GRP",shuttle), fPressure(0), fmaxFloat(0), fminFloat(0),fmaxDouble(0), fminDouble(0), fmaxInt(0), fminInt(0), fmaxUInt(0), fminUInt(0),fdaqStartEndTimeOk(kTRUE),ffailedDPs(new TObjArray(fgknDCSDP))
216 // constructor - shuttle must be instantiated!
218 AddRunType("COSMIC");
220 AddRunType("PHYSICS");
221 AddRunType("CALIBRATION_BC");
222 AddRunType("CALIBRATION_CENTRAL");
223 AddRunType("CALIBRATION_EMD");
224 AddRunType("CALIBRATION_MB");
225 AddRunType("CALIBRATION_SEMICENTRAL");
226 AddRunType("CALIBRATION");
227 AddRunType("PEDESTAL");
228 AddRunType("STANDALONE");
231 AddRunType("PULSER");
232 AddRunType("STANDALONE_PULSER");
233 AddRunType("STANDALONE_BC");
236 fminFloat = -FLT_MAX;
237 fmaxDouble = DBL_MAX;
238 fminDouble = -DBL_MAX;
244 AliInfo(Form("Max allowed float = %6.5e",fmaxFloat));
245 AliInfo(Form("Min allowed float = %6.5e",fminFloat));
246 AliInfo(Form("Max allowed double = %6.5e",fmaxDouble));
247 AliInfo(Form("Min allowed double = %6.5e",fminDouble));
248 AliInfo(Form("Max allowed integer = %d",fmaxInt));
249 AliInfo(Form("Min allowed integer = %d",fminInt));
250 AliInfo(Form("Max allowed unsigned integer = %u",(Int_t)fmaxUInt));
251 AliInfo(Form("Min allowed unsigned integer = %u",(Int_t)fminUInt));
253 ffailedDPs->SetOwner(kTRUE);
256 //_______________________________________________________________
258 AliGRPPreprocessor::~AliGRPPreprocessor()
267 //_______________________________________________________________
269 void AliGRPPreprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
271 // Initialize preprocessor
273 AliPreprocessor::Initialize(run, startTime, endTime);
275 AliInfo("Initialization of the GRP preprocessor.");
276 AliInfo(Form("Start Time DCS = %d",GetStartTimeDCSQuery()));
277 AliInfo(Form("End Time DCS = %d",GetEndTimeDCSQuery()));
278 TClonesArray * array = new TClonesArray("AliDCSSensor",kNumSensors);
279 for(Int_t j = 0; j < kNumSensors; j++) {
280 AliDCSSensor * sens = new ((*array)[j])AliDCSSensor;
281 sens->SetStringID(fgkDCSDataPoints[j+kSensors]);
283 AliInfo(Form("Pressure Entries: %d",array->GetEntries()));
285 fPressure = new AliDCSSensorArray(GetStartTimeDCSQuery(), GetEndTimeDCSQuery(), array);
287 ffailedDPs->Clear(); // cleaning ffailedDPs for current run
288 for (Int_t iDP=0; iDP < fgknDCSDP; iDP++){
289 TObjString* dp = new TObjString(fgkDCSDataPoints[iDP]);
290 ffailedDPs->AddAt(dp,iDP);
295 //_______________________________________________________________
297 UInt_t AliGRPPreprocessor::Process(TMap* valueMap)
299 // process data retrieved by the Shuttle
301 // retrieving "partition" and "detector" fields from DAQ logbook to
302 // determine the partition in which the run was taken
303 // the partition is used to decide how to react in case of errors for CTP
305 TString partition = (TString)GetRunParameter("partition");
306 TString detector = (TString)GetRunParameter("detector");
308 AliGRPObject *grpobj = new AliGRPObject(); // object to store data
309 grpobj->SetBeamEnergyIsSqrtSHalfGeV(); // new format
311 //=================//
313 //=================//
315 Log("*************** Processing DAQ logbook");
319 Int_t iDaqLB = ProcessDaqLB(grpobj);
320 TString runType = (TString)GetRunType();
321 TString beamType = (TString)GetRunParameter("beamType");
322 if(iDaqLB == fgknDAQLbPar) {
323 Log(Form("DAQ Logbook, successful! Retrieved %d/%d entries",iDaqLB,fgknDAQLbPar));
325 Log(Form("DAQ Logbook, could not get all expected entries!!! Retrieved only %d/%d entries",iDaqLB,fgknDAQLbPar));
329 //=================//
331 //=================//
333 Log("*************** Processing DAQ FXS");
335 UInt_t iDaqFxs = ProcessDaqFxs();
337 Log(Form("DAQ FXS, successful!"));
339 Log(Form("DAQ FXS, could not store run raw tag file!!!"));
343 //=================//
345 //=================//
347 Log("*************** Processing DCS FXS");
349 UInt_t iDcsFxs = ProcessDcsFxs(partition, detector);
351 Log(Form("DCS FXS, successful!"));
352 } else if (iDcsFxs ==1) {
353 Log(Form("DCS FXS, Could not store CTP scalers!!!"));
356 Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without CTP scalers...",partition.Data(),detector.Data()));
360 //=================//
361 // DCS data points //
362 //=================//
364 Log("*************** Processing DCS DPs");
366 Log(Form("Starting DCS Query at %d and finishing at %d",GetStartTimeDCSQuery(),GetEndTimeDCSQuery()));
367 Int_t entries = ProcessDcsDPs( valueMap, grpobj );
368 Log(Form("entries found = %d (should be %d)",entries, fgknDCSDP-fgkDCSDPNonWorking));
369 if (fdaqStartEndTimeOk){
370 if( entries < fgknDCSDP - fgkDCSDPNonWorking ) { // L3_BSF4_H3, L3_BSF17_H1, L3_BSF17_H2, L3_BSF17_H3, L3_BSF17_Temperature are not working yet...
371 Log(Form("Possible problem with the DCS data points!!! Only %d/%d entries found - Please read further for more details",entries,fgknDCSDP-fgkDCSDPNonWorking));
372 Log(Form("The DPs giving problems were:"));
373 for (Int_t iDP = 0; iDP < fgknDCSDP; iDP++){
374 TObjString *dpString = (TObjString*)ffailedDPs->At(iDP);
376 TString name = dpString->String();
377 if (name != "L3_BSF4_H3" && name != "L3_BSF17_H1" && name != "L3_BSF17_H2" && name != "L3_BSF17_H3" && name != "L3_BSF17_Temperature" ){
378 Log(Form("******** %s ******** not present, but foreseen --> causing an ERROR",name.Data()));
381 Log(Form(" %s is not present, but was not generating any error since it is not ready in DCS - check the other DPs in this list!",name.Data()));
387 else Log(Form("DCS data points, successful!"));
389 else Log(Form("Statistical values for DCS DPs could not be computed due to missing DAQ_time_start and DAQ_time_end fields in DAQ logbook"));
391 //=======================//
392 // Trigger Configuration //
393 //=======================//
395 Log("*************** Processing Trigger Configuration");
397 const char * triggerConf = GetTriggerConfiguration();
399 if (partition.IsNull() && !detector.IsNull()){ // standalone partition
400 Log("STANDALONE partition for current run, using Trigger Configuration dummy value");
401 AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyConfig");
403 Log(Form("No dummy CTP configuration entry found, going into error..."));
407 AliTriggerConfiguration *runcfg = (AliTriggerConfiguration*)cdbEntry->GetObject();
409 Log(Form("dummy CTP config not found in OCDB entry, going into error..."));
413 TString titleCTPcfg = Form("CTP cfg for run %i from Dummy entry in OCDB",fRun);
414 runcfg->SetTitle(titleCTPcfg);
415 AliCDBMetaData metaData;
416 metaData.SetResponsible("Roman Lietava");
417 metaData.SetComment("CTP run configuration from dummy entry in OCDB");
418 if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) {
419 Log("Unable to store the dummy CTP run configuration object to OCDB!");
426 else if (!partition.IsNull() && detector.IsNull()){ // global partition
427 Log("GLOBAL partition for current run, using Trigger Configuration from DAQ Logbook");
428 if (triggerConf!= NULL) {
429 Log("Found trigger configuration in DAQ logbook");
430 AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConf);
432 Log("Bad CTP run configuration file from DAQ logbook! The corresponding CDB entry will not be filled!");
436 TString titleCTPcfg = Form("CTP cfg for run %i from DAQ",fRun);
437 runcfg->SetTitle(titleCTPcfg);
438 AliCDBMetaData metaData;
439 metaData.SetBeamPeriod(0);
440 metaData.SetResponsible("Roman Lietava");
441 metaData.SetComment("CTP run configuration from DAQ logbook");
442 if (!Store("CTP","Config", runcfg, &metaData, 0, 0)) {
443 Log("Unable to store the CTP run configuration object to OCDB!");
450 Log("Trigger configuration NULL in DAQ logbook");
456 Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger configuration...",partition.Data(),detector.Data()));
460 //===========================//
461 // Trigger Timing Parameters //
462 //===========================//
464 Log("*************** Processing Trigger Time Params");
466 const char * triggerCTPtiming = GetCTPTimeParams();
468 if (partition.IsNull() && !detector.IsNull()){ // standalone partition
469 Log("STANDALONE partition for current run, using CTP timing params dummy value");
470 AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyCTPtime");
472 Log(Form("No dummy CTP timing parameters entry found, going into error..."));
476 AliCTPTimeParams *runCTPtiming = (AliCTPTimeParams*)cdbEntry->GetObject();
478 Log(Form("dummy CTP timing parameters not found in OCDB entry, going into error..."));
482 TString titleCTPtiming = Form("CTP timing params for run %i from Dummy entry in OCDB",fRun);
483 runCTPtiming->SetTitle(titleCTPtiming);
484 AliCDBMetaData metadata;
485 metadata.SetResponsible("Roman Lietava");
486 metadata.SetComment("CTP run timing parameters from dummy entry in OCDB");
487 if (!Store("CTP","CTPtiming", runCTPtiming, &metadata, 0, 0)) {
488 Log("Unable to store the dummy CTP timing params object to OCDB!");
495 else if (!partition.IsNull() && detector.IsNull()){ // global partition
496 Log("GLOBAL partition for current run, using Trigger Timing Parameters from DAQ Logbook");
497 if (triggerCTPtiming!= NULL) {
498 Log("Found trigger timing params in DAQ logbook");
499 AliDebug(2,Form("%s",triggerCTPtiming));
500 AliCTPTimeParams *runCTPtiming = AliCTPTimeParams::LoadCTPTimeParamsFromString(triggerCTPtiming);
502 Log("Bad CTP trigger timing params file from DAQ logbook! The corresponding CDB entry will not be filled!");
506 TString titleCTPtiming = Form("CTP timing params for run %i from DAQ",fRun);
507 runCTPtiming->SetTitle(titleCTPtiming);
508 AliCDBMetaData metadata;
509 metadata.SetBeamPeriod(0);
510 metadata.SetResponsible("Roman Lietava");
511 metadata.SetComment("CTP timing params from DAQ logbook");
512 if (!Store("CTP","CTPtiming", runCTPtiming, &metadata, 0, 0)) {
513 Log("Unable to store the CTP timing params object to OCDB!");
520 Log("Trigger timing params NULL in DAQ logbook");
526 Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger timing parameters...",partition.Data(),detector.Data()));
530 //===========================//
531 // LTU Configuration //
532 //===========================//
534 Log("*************** Processing LTU Configuration");
536 if (partition.IsNull() && !detector.IsNull()){ // standalone partition
537 Log("STANDALONE partition for current run, using LTU configuration dummy value");
538 AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyLTUConfig");
540 Log(Form("No dummy LTU Config entry found, going into error..."));
544 TObjArray *ltuConfig = (TObjArray*)cdbEntry->GetObject();
546 Log(Form("dummy LTU Config not found in OCDB entry, going into error..."));
550 AliCDBMetaData metadata;
551 metadata.SetResponsible("Roman Lietava");
552 metadata.SetComment("LTU Config from dummy entry in OCDB");
553 if (!Store("CTP","LTUConfig", ltuConfig, &metadata, 0, 0)) {
554 Log("Unable to store the dummy LTU Config object to OCDB!");
561 else if (!partition.IsNull() && detector.IsNull()){ // global partition
563 Log("GLOBAL partition for current run, getting LTU Config from DAQ Logbook (logbook_detectors table)");
564 UInt_t detectorMask = (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi());
565 Printf ("detectormask = %d",detectorMask);
566 TObjArray * ltuarray = new TObjArray();
567 ltuarray->SetOwner(1);
568 Bool_t isLTUok = kTRUE;
569 for(Int_t i = 0; i<AliDAQ::kNDetectors-2; i++){
570 if ((detectorMask >> i) & 0x1) {
571 TString det = AliDAQ::OfflineModuleName(i);
572 TString detCTPName = AliTriggerInput::fgkCTPDetectorName[i];
573 if (detCTPName == "CTP") {
574 detCTPName="TRG"; // converting according to what is found in DAQ logbook_detectors
575 Printf("Processing CTP (CTP Detector name %s) --> SKIPPING, CTP does not have any LTU!!!!!!",detCTPName.Data());
578 Printf("Processing detector %s (CTP Detector name %s)",det.Data(),detCTPName.Data());
579 TString* ltu = GetLTUConfig(detCTPName.Data());
581 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()));
587 Float_t ltuFineDelay1 = ltu[0].Atof();
588 Float_t ltuFineDelay2 = ltu[1].Atof();
589 Float_t ltuBCDelayAdd = ltu[2].Atof();
590 const char* name = AliDAQ::DetectorName(i);
591 AliLTUConfig* ltuConfig = new AliLTUConfig((UChar_t)AliDAQ::DetectorID(name),ltuFineDelay1,ltuFineDelay2,ltuBCDelayAdd);
592 ltuarray->AddAtAndExpand(ltuConfig,i);
597 AliCDBMetaData metadata;
598 metadata.SetBeamPeriod(0);
599 metadata.SetResponsible("Roman Lietava");
600 metadata.SetComment("LTU Configuration for current run");
601 if (!Store("CTP","LTUConfig", ltuarray, &metadata, 0, 0)) {
602 Log("Unable to store the LTU Config object to OCDB!");
610 Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error without trigger timing parameters...",partition.Data(),detector.Data()));
615 //=================//
617 //=================//
619 if (runType == "PHYSICS"){ // processing the LHC file only in PHYSICS runs
620 Log("*************** Processing LHC Data");
622 UInt_t iLHCData = ProcessLHCData(grpobj);
624 if( iLHCData == 0 ) {
625 Log(Form("LHC Data from DCS FXS, successful!"));
626 } else if (iLHCData == 1) {
627 Log(Form("LHC Data, problems with DCS FXS!"));
629 } else if (iLHCData == 2) {
630 Log(Form("LHC Data, problems with DAQ_time_start/DAQ_time_end!"));
632 } else if (iLHCData ==3){
633 Log(Form("Problems in storing LHC Phase - going into Error"));
635 } else if (iLHCData ==4){
636 Log(Form("Problems with LHC Phase - going into Error"));
639 Log(Form("LHC Data problems"));
645 //==================//
646 // SPD Mean Vertex //
647 //==================//
649 Log("*************** Processing SPD Mean Vertex");
651 if (runType == "PHYSICS"){
652 UInt_t iSPDMeanVertex = ProcessSPDMeanVertex();
653 if( iSPDMeanVertex == 1 ) {
654 Log(Form("SPD Mean Vertex, successful!"));
656 Log(Form("SPD Mean Vertex failed!!!"));
661 Log("SPD Mean Vertex not processed since runType != PHYSICS");
664 //=================//
666 //=================//
668 Log("*************** Processing DQM FXS");
670 UInt_t iDqmFxs = ProcessDqmFxs();
672 Log(Form("DQM FXS, successful!"));
674 Log(Form("DQM FXS failed!!!"));
678 // storing AliGRPObject in OCDB
681 md.SetResponsible("Chiara Zampolli");
682 md.SetComment("Output parameters from the GRP preprocessor.");
684 Bool_t result = kTRUE;
685 result = Store("GRP", "Data", grpobj, &md);
688 if (result && !error ) {
689 Log("GRP Preprocessor Success");
692 Log( Form("GRP Preprocessor FAILS!!! %s%s%s%s%s%s%s%s%s%s%s%s%s",
693 kppError[(error&1)?1:0],
694 kppError[(error&2)?2:0],
695 kppError[(error&4)?3:0],
696 kppError[(error&8)?4:0],
697 kppError[(error&16)?5:0],
698 kppError[(error&32)?6:0],
699 kppError[(error&64)?7:0],
700 kppError[(error&128)?8:0],
701 kppError[(error&256)?9:0],
702 kppError[(error&512)?10:0],
703 kppError[(error&1024)?11:0],
704 kppError[(error&2048)?12:0],
705 kppError[(error&4096)?12:0]
713 //_______________________________________________________________
715 UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
718 //Getting the LHC Data from DCS FXS
721 TString timeStartString = (TString)GetRunParameter("DAQ_time_start");
722 TString timeEndString = (TString)GetRunParameter("DAQ_time_end");
723 if (timeStartString.IsNull() || timeEndString.IsNull()){
724 if (timeStartString.IsNull()){
725 AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid");
727 else if (timeEndString.IsNull()){
728 AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid");
733 Double_t timeStart = timeStartString.Atof();
734 Double_t timeEnd = timeEndString.Atof();
736 TString fileName = GetFile(kDCS, "LHCData","");
737 if (fileName.Length()>0){
738 AliInfo("Got The LHC Data file");
739 AliLHCReader lhcReader;
741 // Processing data to be put in AliGRPObject
744 Log("*************Energy ");
745 TObjArray* energyArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[0]);
747 Float_t energy = ProcessEnergy(energyArray,timeStart);
749 grpobj->SetBeamEnergy(energy);
750 grpobj->SetBeamEnergyIsSqrtSHalfGeV(kTRUE);
755 AliError("Energy not found in LHC Data file!!!");
758 Double_t timeBeamModeEnd = timeEnd; // max validity for Beam Mode
759 Double_t timeMachineModeEnd = timeEnd; // max validity for Machine Mode
760 Double_t timeBeamEnd = timeEnd; // max validity for Beam Type
761 Double_t timeBeamTypeEnd[2] = {timeEnd, timeEnd}; // max validity for Beam Type1,2
762 Double_t timeBeamModeStart = -1; // min validity for Beam Mode
763 Double_t timeMachineModeStart = -1; // min validity for Machine Mode
764 Double_t timeBeamStart = -1; // min validity for Beam Type
765 Double_t timeBeamTypeStart[2] = {-1,-1}; // min validity for Beam Type1,2
766 Int_t indexBeamMode = -1; // index of measurement used to set Beam Mode
767 Int_t indexMachineMode = -1; // index of measurement used to set Machine Mode
768 Int_t indexBeam = -1; // index of measurement used to set Beam Type
769 Int_t indexBeamType[2] = {-1, -1}; // index of measurement used to set Beam Type1,2
770 Bool_t foundBeamModeStart = kFALSE; // flag to be set in case an entry for the Beam Mode is found before (or at) SOR
771 Bool_t foundMachineModeStart = kFALSE; // flag to be set in case an entry for the Machine Mode is found before (or at) SOR
772 Bool_t foundBeamStart = kFALSE; // flag to be set in case an entry for the Beam Type is found before (or at) SOR
773 Bool_t foundBeamTypeStart[2] = {kFALSE, kFALSE}; // flag to be set in case an entry for the Beam Type1,2 is found before (or at) SOR
774 Bool_t flagBeamMode = kFALSE; //flag set true if a changed occurred in BeamMode
775 Bool_t flagMachineMode = kFALSE; //flag set true if a changed occurred in MachineMode
776 Bool_t flagBeam = kFALSE; //flag set true if a changed occurred in BeamType
777 Bool_t flagBeamType[2] = {kFALSE, kFALSE}; //flag set true if a changed occurred in BeamType1,2
779 Double_t arrayTimes[5]={2.E9, 2.E9, 2.E9, 2.E9, 2.E9}; // array to keep track of the times of the possible changes of the LHC DPs; each entry set to Wed May 18 2033, 03:33:20 GMT (ALICE should not be running anymore...)
780 // arrayTimes elements order correspond to the one used in the array of the strings fgkLHCDataPoints, i.e.:
781 // arrayTimes[0] --> MachineMode
782 // arrayTimes[1] --> BeamMode
783 // arrayTimes[2] --> BeamType (when written together)
784 // arrayTimes[3] --> BeamType1 (when written separate)
785 // arrayTimes[4] --> BeamType2 (when written separate)
788 Log("*************BeamMode (LHCState) ");
789 TObjArray* beamModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[2]);
790 Int_t nBeamMode = -1;
792 nBeamMode = beamModeArray->GetEntries();
794 AliInfo("Found zero entries for the Beam Mode, leaving it empty");
797 for (Int_t iBeamMode = 0; iBeamMode<nBeamMode; iBeamMode++){
798 AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(iBeamMode);
800 if (beamMode->GetTimeStamp()<=timeStart && beamMode->GetTimeStamp()>=timeBeamModeStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
801 timeBeamModeStart = beamMode->GetTimeStamp();
802 indexBeamMode = iBeamMode;
803 foundBeamModeStart = kTRUE;
811 if (!foundBeamModeStart){
812 AliInfo("No value for the Beam Mode found before start of run, the Beam Mode will remain empty");
815 AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(indexBeamMode);
816 TObjString* beamModeString = beamMode->GetStringArray(0);
817 AliInfo(Form("LHC State (corresponding to BeamMode) = %s (set at %f)",(beamModeString->String()).Data(),beamMode->GetTimeStamp()));
818 grpobj->SetLHCState(beamModeString->String());
819 if (indexBeamMode < nBeamMode-1){
820 AliDCSArray* beamMode1 = (AliDCSArray*)beamModeArray->At(indexBeamMode+1);
822 if (beamMode1->GetTimeStamp()<=timeStart){
823 AliError("you did not choose the correct value! there is still something before (or at) SOR, but later than this!");
825 else if (beamMode1->GetTimeStamp()>timeStart && beamMode1->GetTimeStamp()<=timeEnd){
826 timeBeamModeEnd = beamMode1->GetTimeStamp();
827 TObjString* beamModeString1 = beamMode1->GetStringArray(0);
828 TString bmString0 = beamModeString->String();
829 TString bmString1 = beamModeString1->String();
830 if (bmString0.CompareTo(bmString1.Data(),TString::kIgnoreCase) == -1){
831 AliWarning(Form("The beam mode changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",bmString0.Data(), bmString1.Data(), timeBeamModeEnd, bmString0.Data()));
832 flagBeamMode = kTRUE;
833 arrayTimes[1]=timeBeamModeEnd;
839 AliInfo("Invalid pointer for the first entry for Beam Mode after the first valid one, not considering anything after what has already been found");
844 delete beamModeArray;
847 AliError("Beam mode array not found in LHC Data file!!!");
851 Log("*************MachineMode ");
852 TObjArray* machineModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[1]);
853 Int_t nMachineMode = -1;
854 if (machineModeArray){
855 nMachineMode = machineModeArray->GetEntries();
856 if (nMachineMode==0){
857 AliInfo("No Machine Mode found, leaving it empty");
860 for (Int_t iMachineMode = 0; iMachineMode<nMachineMode; iMachineMode++){
861 AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(iMachineMode);
863 if (machineMode->GetTimeStamp()<=timeStart && machineMode->GetTimeStamp()>=timeMachineModeStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
864 timeMachineModeStart = machineMode->GetTimeStamp();
865 indexMachineMode = iMachineMode;
866 foundMachineModeStart = kTRUE;
873 if (!foundMachineModeStart){
874 AliInfo("No value for the Machine Mode found before start of run, the Machine Mode will remain empty");
877 AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(indexMachineMode);
878 TObjString* machineModeString = machineMode->GetStringArray(0);
879 AliInfo(Form("MachineMode = %s (set at %f)",(machineModeString->String()).Data(),machineMode->GetTimeStamp()));
880 grpobj->SetMachineMode(machineModeString->String());
881 if (indexMachineMode < nMachineMode-1){
882 AliDCSArray* machineMode1 = (AliDCSArray*)machineModeArray->At(indexMachineMode+1);
884 if (machineMode1->GetTimeStamp()>timeStart && machineMode1->GetTimeStamp()<=timeEnd){
885 timeMachineModeEnd = machineMode1->GetTimeStamp();
886 TObjString* machineModeString1 = machineMode1->GetStringArray(0);
887 TString mmString0 = machineModeString->String();
888 TString mmString1 = machineModeString1->String();
889 if (mmString0.CompareTo(mmString1.Data(),TString::kIgnoreCase) == -1){
890 AliWarning(Form("The machine mode changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",mmString0.Data(),mmString1.Data(),timeMachineModeEnd,mmString0.Data()));
891 flagMachineMode = kTRUE;
892 arrayTimes[0]=timeMachineModeEnd;
897 AliInfo("Invalid pointer for the first entry for Machine Mode after the first valid one, not considering anything after what has already been found");
902 delete machineModeArray;
905 AliError("Machine mode array not found in LHC Data file!!!");
908 // BeamType1 and BeamType2 - both put in the same string
909 Log("*************BeamType ");
910 TObjArray* beamArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[3]);
912 Int_t nBeam = beamArray->GetEntries();
914 AliInfo("No Beam Type found, leaving it empty");
917 for (Int_t iBeam = 0; iBeam<nBeam; iBeam++){
918 AliDCSArray* beam = (AliDCSArray*)beamArray->At(iBeam);
920 if (beam->GetTimeStamp()<=timeStart && beam->GetTimeStamp()>=timeBeamStart){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
921 timeBeamStart = beam->GetTimeStamp();
923 foundBeamStart = kTRUE;
930 if (!foundBeamStart){
931 AliInfo("No value for the Beam Type found before start of run, the (common) Beam Type will remain empty");
934 AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam);
935 TObjString* beamString = beam->GetStringArray(0);
936 TString beamType = beamString->String();
937 AliInfo(Form("Beam Type = %s",beamType.Data()));
938 if (beamType.CompareTo("PROTON",TString::kIgnoreCase) == 0){
939 AliInfo("Setting beam type to p-p");
940 grpobj->SetBeamType("p-p");
942 else { // if there is no PROTON beam, we suppose it is Pb, and we put A-A
943 AliInfo("Setting beam type to A-A");
944 grpobj->SetBeamType("A-A");
947 else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){
948 AliInfo("Setting beam type to Pb-Pb");
949 grpobj->SetBeamType("Pb-Pb");
952 AliError("Beam Type not known, leaving it empty");
955 if (indexBeam < nBeam-1){
956 AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(indexBeam+1);
958 if (beam1->GetTimeStamp()>timeStart && beam1->GetTimeStamp()<=timeEnd){
959 timeBeamEnd = beam1->GetTimeStamp();
960 TObjString* beamString1 = beam1->GetStringArray(0);
961 TString beamType1 = beamString1->String();
962 if (beamType.CompareTo(beamType1.Data(),TString::kIgnoreCase) == -1){
963 AliWarning(Form("The Beam Type changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",beamType.Data(),(beamString1->String()).Data(),timeBeamEnd,beamType.Data()));
965 arrayTimes[2] = timeBeamEnd;
970 AliInfo("Invalid pointer for the first entry for Beam Type after the first valid one, not considering anything after what has already been found");
978 AliError("Beam Type array not found in LHC Data file!!!");
981 // BeamType1 and BeamType2 - in separete string
982 Log("*************BeamType, 1 and 2 ");
983 Int_t indexBeamTypeString = 6; // index of the string with the alias of BeanType1 in the array fgkLHCDataPoints
984 TString combinedBeamType = "-"; // combined beam tyope, built from beam type 1 and beam type 2
985 for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
986 beamArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[indexBeamTypeString+ibeamType]);
988 Int_t nBeam = beamArray->GetEntries();
990 AliInfo(Form("No Beam Type %s found, leaving it empty",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
993 for (Int_t iBeam = 0; iBeam<nBeam; iBeam++){
994 AliDCSArray* beam = (AliDCSArray*)beamArray->At(iBeam);
996 if (beam->GetTimeStamp()<=timeStart && beam->GetTimeStamp()>=timeBeamTypeStart[ibeamType]){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
997 timeBeamTypeStart[ibeamType] = beam->GetTimeStamp();
998 indexBeamType[ibeamType] = iBeam;
999 foundBeamTypeStart[ibeamType] = kTRUE;
1006 if (!foundBeamTypeStart[ibeamType]){
1007 AliInfo(Form("No value for the Beam Type %s found before start of run, the Beam Type %d will remain empty", fgkLHCDataPoints[indexBeamTypeString+ibeamType], ibeamType));
1010 AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam);
1011 TObjString* beamString = beam->GetStringArray(0);
1012 TString beamType = beamString->String();
1013 AliInfo(Form("Beam Type (for %s) = %s", fgkLHCDataPoints[indexBeamTypeString+ibeamType], beamType.Data()));
1014 if (beamType.CompareTo("PROTON",TString::kIgnoreCase) == 0){
1015 AliInfo(Form("Setting beam type %s to p", fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
1016 grpobj->SetSingleBeamType(ibeamType,"p");
1017 if (ibeamType == 0) combinedBeamType.Prepend("p");
1018 else combinedBeamType.Append("p");
1020 else { // if there is no PROTON beam, we suppose it is Pb, and we put A-A
1021 AliInfo("Setting beam type to A");
1022 grpobj->SetSingleBeamType(ibeamType,"A");
1023 if (ibeamType == 0) combinedBeamType.Prepend("A");
1024 else combinedBeamType.Append("A");
1027 else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){
1028 AliInfo("Setting beam type to Pb-Pb");
1029 grpobj->SetSingleBeamType(ibeamType, "Pb-Pb");
1032 AliError("Beam Type not known, leaving it empty");
1035 if (indexBeamType[ibeamType] < nBeam-1){
1036 AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(indexBeam+1);
1038 if (beam1->GetTimeStamp()>timeStart && beam1->GetTimeStamp()<=timeEnd){
1039 timeBeamTypeEnd[ibeamType] = beam1->GetTimeStamp();
1040 TObjString* beamString1 = beam1->GetStringArray(0);
1041 TString beamType1 = beamString1->String();
1042 if (beamType.CompareTo(beamType1.Data(),TString::kIgnoreCase) == -1){
1043 AliWarning(Form("The Beam Type for %s changed from %s to %s during the run at timestamp %f! Setting it to %s and keeping track of the time of the change to set MaxTimeLHCValidity afterward",fgkLHCDataPoints[indexBeamTypeString+ibeamType],beamType.Data(),(beamString1->String()).Data(),timeBeamEnd,beamType.Data()));
1044 flagBeamType[ibeamType] = kTRUE;
1045 arrayTimes[3+ibeamType] = timeBeamTypeEnd[ibeamType];
1050 AliInfo(Form("Invalid pointer for the first entry for Beam Type %s after the first valid one, not considering anything after what has already been found",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
1058 AliError(Form("Beam Type %s array not found in LHC Data file!!!",fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
1061 AliInfo(Form("Setting combined beam type to %s",combinedBeamType.Data()));
1062 grpobj->SetBeamType(combinedBeamType);
1064 // Setting minTimeLHCValidity
1065 if (flagBeamMode == kTRUE || flagMachineMode == kTRUE || flagBeam == kTRUE || flagBeamType[0] == kTRUE || flagBeamType[1] == kTRUE){
1066 Double_t minTimeLHCValidity= TMath::MinElement(5,arrayTimes);
1067 AliWarning(Form("Setting MaxTimeLHCValidity to %f",minTimeLHCValidity));
1068 grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
1071 // Old way to determine the Maximum Time during which the LHC info is valid
1072 if (timeBeamModeEnd!=0 || timeMachineModeEnd!=0 || timeBeamEnd !=0){
1073 Double_t minTimeLHCValidity;
1074 if (flagBeamMode == kFALSE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam only true --> it is the only one that changed
1075 minTimeLHCValidity = timeBeamEnd;
1077 else if (flagBeamMode == kFALSE && flagMachineMode == kTRUE && flagBeam == kFALSE){ // flagMachineMode only true
1078 minTimeLHCValidity = timeMachineModeEnd;
1080 else if (flagBeamMode == kTRUE && flagMachineMode == kFALSE && flagBeam == kFALSE){ // flagBeamMode only true
1081 minTimeLHCValidity = timeBeamModeEnd;
1083 else if (flagBeamMode == kFALSE && flagMachineMode == kTRUE && flagBeam == kTRUE){ // flagBeam and flagMachineMode only true
1084 minTimeLHCValidity= TMath::Min(timeBeamEnd,timeMachineModeEnd);
1086 else if (flagBeamMode == kTRUE && flagMachineMode == kFALSE && flagBeam == kTRUE){ // flagBeam and flagBeamMode only true
1087 minTimeLHCValidity= TMath::Min(timeBeamEnd,timeBeamModeEnd);
1089 else if (flagBeamMode == kTRUE && flagMachineMode == kTRUE && flagBeam == kFALSE){ // flagMachineMode and flagBeamMode only true
1090 minTimeLHCValidity= TMath::Min(timeMachineModeEnd,timeBeamModeEnd);
1093 Double_t arrayTimes[3] = {timeBeamModeEnd,timeMachineModeEnd,timeBeamEnd};// flagMachineMode and flagBeamMode and flagBeam
1094 minTimeLHCValidity= TMath::MinElement(3,arrayTimes);
1096 AliWarning(Form("Setting MaxTimeLHCValidity to %f",minTimeLHCValidity));
1097 grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
1101 // Data Quality Flag --> storing start and end values of periods within the run during which the value was found to be FALSE
1102 Log("*************Data Quality Flag ");
1103 TObjArray* dataQualityArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[8]);
1104 Int_t nDataQuality = -1;
1105 Double_t timeDataQualityStart = -1; // min validity for Data Quality Flag
1106 Int_t indexDataQuality = -1; // index of first measurement used to set Data Quality Flag
1107 Bool_t foundDataQualityStart = kFALSE; // flag to be set in case an entry for the Data Quality Flag is found before (or at) SOR
1109 if (dataQualityArray){
1110 nDataQuality = dataQualityArray->GetEntries();
1111 if (nDataQuality==0){
1112 AliInfo("No Data Quality Flag found, leaving it empty");
1115 for (Int_t iDataQuality = 0; iDataQuality<nDataQuality; iDataQuality++){
1116 AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
1118 if (dataQuality->GetTimeStamp()<=timeStart && dataQuality->GetTimeStamp()>=timeDataQualityStart){// taking always the very last entry: if two measurements have the same timestamp, the last one is taken
1119 timeDataQualityStart = dataQuality->GetTimeStamp();
1120 indexDataQuality = iDataQuality;
1121 foundDataQualityStart = kTRUE;
1124 // we suppose here that if the first measurement is not before SOR, then none will be (they MUST be in chronological order!!!)
1129 if (!foundDataQualityStart){
1130 // The Data Quality Flag should be found and TRUE at the start of the run. For the time being, if it is not found, don't do anything, but it means there is a problem..
1131 AliInfo("No value for the Data Quality Flag found before start of run, the Data Quality Flag will remain empty");
1134 // counting how many FALSE values there are
1135 Bool_t foundEndOfFalse = kFALSE;
1137 for (Int_t iDataQuality = indexDataQuality; iDataQuality < nDataQuality; iDataQuality ++){
1138 AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
1139 AliDebug(4,Form("dataQuality->GetTimeStamp() = %f, timeDataQualityStart = %f, timeEnd = %f", dataQuality->GetTimeStamp(), timeDataQualityStart, timeEnd ));
1140 if (dataQuality->GetTimeStamp()>=timeDataQualityStart && dataQuality->GetTimeStamp()<=timeEnd){ // considering only values between the first valid and the end of the run
1141 Bool_t dataQualityFlag = dataQuality->GetBool(0);
1142 AliDebug(3,Form("DataQuality = %d (set at %f)",(Int_t)dataQualityFlag,dataQuality->GetTimeStamp()));
1143 if (dataQualityFlag != kTRUE){
1144 if (iDataQuality == indexDataQuality) { // the first Data Quality value should be TRUE, but ignoring the problem now...
1145 AliError("The first value for the Data Quality MUST be TRUE! Ignoring for now...");
1152 AliInfo(Form("Found %d FALSE values for the Data Quality Flag",nFalse));
1153 Double_t falses[nFalse*2]; // dimensioning this to the maximum possible, as if each false value was followed by a true one --> the false periods correspond to the number of falses
1155 Int_t iDataQuality = indexDataQuality;
1158 // filling the info about the periods when the flag was set to FALSE
1159 // starting, like for the other DPS, from the measurement closest to SOR (the index of which is iDataQuality)
1160 while (iDataQuality < nDataQuality){
1161 AliDebug(3,Form("iDataQuality = %d",iDataQuality));
1162 AliDCSArray* dataQuality = (AliDCSArray*)dataQualityArray->At(iDataQuality);
1163 if (dataQuality->GetTimeStamp()>=timeDataQualityStart && dataQuality->GetTimeStamp()<=timeEnd){ // considering only values between the first valid and the end of the run
1164 Bool_t dataQualityFlag = dataQuality->GetBool(0);
1165 AliDebug(3,Form("DataQuality = %d (set at %f)",(Int_t)dataQualityFlag,dataQuality->GetTimeStamp()));
1166 if (dataQualityFlag == kTRUE){
1167 // found TRUE value, continuing
1173 // the check was already done before
1174 if (iDataQuality == indexDataQuality) { // the first Data Quality value should be TRUE, but ignoring the problem now...
1175 AliError("The first value for the Data Quality MUST be TRUE! Ignoring for now...");
1178 falses[iFalse*2] = dataQuality->GetTimeStamp();
1179 foundEndOfFalse = kFALSE;
1180 Int_t iDataQualityNext = iDataQuality+1;
1181 while (iDataQualityNext < nDataQuality){
1182 AliDCSArray* dataQualityNext = (AliDCSArray*)dataQualityArray->At(iDataQualityNext);
1183 if (dataQualityNext->GetTimeStamp()>timeDataQualityStart && dataQualityNext->GetTimeStamp()<=timeEnd && dataQualityNext->GetTimeStamp() > dataQuality->GetTimeStamp()){ // considering only values between the first valid and the end of the run, and subsequent to the current value
1184 Bool_t dataQualityFlagNext = dataQualityNext->GetBool(0);
1185 AliDebug(3,Form("DataQualityNext = %d (set at %f)",(Int_t)dataQualityFlagNext,dataQualityNext->GetTimeStamp()));
1186 if (dataQualityFlagNext == kTRUE){
1187 // found TRUE value, first FALSE period completed
1188 foundEndOfFalse = kTRUE;
1189 falses[iFalse*2+1] = dataQualityNext->GetTimeStamp();
1196 if (!foundEndOfFalse) {
1197 AliInfo("Please, note that the last FALSE value lasted until the end of the run");
1198 falses[iFalse*2+1] = timeEnd;
1202 iDataQuality = iDataQualityNext+1;
1206 grpobj->SetNFalseDataQualityFlag(iFalse);
1207 grpobj->SetFalseDataQualityFlagPeriods(falses);
1211 delete dataQualityArray;
1214 AliError("Data Quality Flag array not found in LHC Data file!!!");
1217 // Processing data to go to AliLHCData object
1218 AliLHCData* dt = new AliLHCData(fileName.Data(),timeStart,timeEnd);
1219 // storing AliLHCData in OCDB
1221 AliInfo(Form("Filled %d records to AliLHCData object",dt->GetData().GetEntriesFast()));
1223 md.SetResponsible("Ruben Shahoyan");
1224 md.SetComment("LHC data from the GRP preprocessor.");
1225 Bool_t result = kTRUE;
1226 result = Store("GRP", "LHCData", dt, &md);
1229 Log(Form("Problems in storing LHC Data - but not going into Error"));
1233 // processing LHC Phase
1235 TObjArray *beam1phase = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[4]);
1236 TObjArray *beam2phase = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[5]);
1237 if (beam1phase == 0x0 || beam2phase == 0x0){
1238 Log(Form("Problems in retrieving LHC Clock data from LHC file"));
1241 AliLHCClockPhase *phaseObj = ProcessLHCClockPhase(beam1phase,beam2phase,timeEnd);
1245 AliInfo(Form("LHC Phase found"));
1246 AliCDBMetaData mdPhase;
1247 mdPhase.SetResponsible("Cvetan Cheshkov");
1248 mdPhase.SetComment("LHC Clock Phase");
1249 Bool_t result = kTRUE;
1250 result = Store("Calib", "LHCClockPhase", phaseObj, &mdPhase);
1252 if (!result) return 3;
1258 AliError("No LHCData file found in DCS FXS");
1265 //_______________________________________________________________
1267 UInt_t AliGRPPreprocessor::ProcessSPDMeanVertex()
1270 //Getting the SPD Mean Vertex
1273 TList* list = GetForeignFileSources("SPD", kDAQ, "VertexDiamond");
1274 Bool_t storeResult = kTRUE;
1275 if (list !=0x0 && list->GetEntries()!=0)
1277 AliInfo("The following sources produced files with the id VertexDiamond from SPD");
1279 for (Int_t jj=0;jj<list->GetEntries();jj++){
1280 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
1282 AliError(Form("Expecting a TObjString in the list for the %d-th source, but something else was found.",jj));
1285 AliInfo(Form("found source %s", str->String().Data()));
1286 TString fileNameRun = GetForeignFile("SPD", kDAQ, "VertexDiamond", str->GetName());
1287 if (fileNameRun.Length()>0){
1288 AliInfo(Form("Got the file %s", fileNameRun.Data()));
1289 TFile daqFile(fileNameRun.Data(),"READ");
1290 if (daqFile.IsOpen()) {
1291 AliESDVertex* meanVtx = dynamic_cast<AliESDVertex*>(daqFile.Get("MeanVertexPos"));
1294 // storing in the OCDB
1296 md.SetResponsible("Cvetan Cheshkov");
1297 md.SetComment("SPD Mean Vertex");
1298 storeResult = Store("Calib", "MeanVertexSPD", meanVtx, &md, 0, kTRUE);
1301 AliWarning("No SPD Mean Vertex object found in file");
1305 AliError("Can't open file");
1306 storeResult = kFALSE;
1310 AliWarning("No file found for current source for SPD Mean Vertex");
1315 AliWarning("No list found for SPD Mean Vertex");
1318 if (list) delete list;
1322 //_______________________________________________________________
1324 UInt_t AliGRPPreprocessor::ProcessDqmFxs()
1327 // Processing DQM fxs information
1330 TList* list = GetFileSources(kDQM, "TriggerClassesAndHistosToClone");
1331 Bool_t storeResult = kTRUE;
1332 if (list !=0x0 && list->GetEntries()!=0){
1333 AliInfo("The following sources produced files with the id TriggerClassesAndHistosToClone for GRP");
1335 for (Int_t jj=0;jj<list->GetEntries();jj++){
1336 TObjString * str = dynamic_cast<TObjString*> (list->At(jj));
1338 AliError(Form("Expecting a TObjString in the list for the %d-th source, but something else was found.",jj));
1341 AliInfo(Form("found source %s", str->String().Data()));
1342 TString fileNameRun = GetFile(kDQM, "TriggerClassesAndHistosToClone", str->GetName());
1343 if (fileNameRun.Length()>0){
1344 AliInfo(Form("Got the file %s", fileNameRun.Data()));
1345 TFile dqmFile(fileNameRun.Data(),"READ");
1346 if (dqmFile.IsOpen()) {
1350 AliError("Can't open file");
1351 storeResult = kFALSE;
1355 AliWarning("No file found for current source for DQM TriggerClassesAndHistosToClone");
1360 AliWarning("No list found for DQM TriggerClassesAndHistosToClone");
1363 if (list) delete list;
1365 // return storeResult;
1366 return kTRUE; // temporary!!
1370 //_______________________________________________________________
1372 Int_t AliGRPPreprocessor::ProcessDaqLB(AliGRPObject* grpObj)
1374 //Getting the DAQ lb information
1376 time_t timeStart = (time_t)(((TString)GetRunParameter("DAQ_time_start")).Atoi());
1377 time_t timeEnd = (time_t)(((TString)GetRunParameter("DAQ_time_end")).Atoi());
1378 Float_t beamEnergy = (Float_t)(((TString)GetRunParameter("beamEnergy")).Atof());
1379 TString beamType = (TString)GetRunParameter("beamType");
1380 Char_t numberOfDetectors = (Char_t)(((TString)GetRunParameter("numberOfDetectors")).Atoi());
1381 UInt_t detectorMask = (UInt_t)(((TString)GetRunParameter("detectorMask")).Atoi());
1382 TString lhcPeriod = (TString)GetRunParameter("LHCperiod");
1383 TString runType = (TString)GetRunType();
1385 if (timeEnd >= 2.E9) AliFatal("ALICE run finshed later than Wed May 18 2033, 03:33:20 GMT, maximum time allowed for LHC data --> fix the GRP preprocessor!!!");
1387 UInt_t nparameter = 0;
1388 if (timeStart != 0){
1389 grpObj->SetTimeStart(timeStart);
1390 Log(Form("Start time for run %d: %d",fRun, (Int_t)timeStart));
1394 Log(Form("Start time not put in logbook, setting to invalid in GRP entry, and causing an error!"));
1398 grpObj->SetTimeEnd(timeEnd);
1399 Log(Form("End time for run %d: %i",fRun, (Int_t)timeEnd));
1403 Log(Form("End time not put in logbook, setting to invalid in GRP entry, and causing an error!"));
1406 if (beamEnergy != 0){
1407 Log(Form("Beam Energy for run %d: %f (NOT USING IT TO FILL THE GRP OBJECT, taking it from the LHC file)",fRun, beamEnergy));
1410 Log(Form("Beam Energy not put in logbook, but not using it anyway for the GRP object (taking it from the LHC file)"));
1414 if (beamType.Length() != 0){
1415 Log(Form("Beam Type for run %d: %s (NOT USING IT TO FILL THE GRP OBJECT, taking it from the LHC file)",fRun, beamType.Data()));
1418 Log(Form("Beam Type not put in logbook, but not using it anyway for the GRP entry (taking it from the LHC file)"));
1421 if (numberOfDetectors != 0){
1422 grpObj->SetNumberOfDetectors(numberOfDetectors);
1423 Log(Form("Number Of Detectors for run %d: %d",fRun, (Int_t)numberOfDetectors));
1427 Log(Form("Number Of Detectors not put in logbook, setting to invalid in GRP entry, and causing an error!"));
1430 if (detectorMask != 0){
1431 grpObj->SetDetectorMask(detectorMask);
1432 Log(Form("Detector Mask for run %d: %d",fRun, detectorMask));
1436 Log(Form("Detector Mask not put in logbook, setting to invalid in GRP entry, and causing an error!"));
1439 if (lhcPeriod.Length() != 0) {
1440 grpObj->SetLHCPeriod(lhcPeriod);
1441 Log(Form("LHC period (DAQ) for run %d: %s",fRun, lhcPeriod.Data()));
1445 Log(Form("LHCperiod not put in logbook, setting to invalid in GRP entry, and causing an error!"));
1447 if (runType.Length() != 0) {
1448 grpObj->SetRunType(runType);
1449 Log(Form("Run Type (DAQ) for run %d: %s",fRun, runType.Data()));
1453 Log(Form("Run Type not put in logbook, setting to invalid in GRP entry, and causing an error!"));
1458 //_______________________________________________________________
1460 UInt_t AliGRPPreprocessor::ProcessDaqFxs()
1462 //======DAQ FXS======//
1464 AliRawEventHeaderV3_9::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_9 - temporary fix
1465 AliRawEventHeaderV3_11::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_11 - temporary fix
1466 AliRawEventHeaderV3_12::Class()->IgnoreTObjectStreamer(); // to avoid trying reading TObject store in AliRawEventHeaderV3_12 - temporary fix
1467 TList* list = GetFileSources(kDAQ);
1469 Log("No raw data tag list: connection problems with DAQ FXS logbook!");
1473 if (list->GetEntries() == 0) {
1474 Log("no raw data tags in this run: nothing to merge!");
1475 delete list; list=0;
1479 TChain *fRawTagChain = new TChain("T");
1481 TIterator* iter = list->MakeIterator();
1483 while ((obj = iter->Next())) {
1484 TObjString* objStr = dynamic_cast<TObjString*> (obj);
1486 Log(Form("Found source %s", objStr->String().Data()));
1487 TList* list2 = GetFileIDs(kDAQ, objStr->String());
1489 Log("No list with ids from DAQ was found: connection problems with DAQ FXS logbook!");
1490 delete fRawTagChain; fRawTagChain=0;
1493 Log(Form("Number of ids: %d",list2->GetEntries()));
1494 for(Int_t i = 0; i < list2->GetEntries(); i++) {
1495 TObjString *idStr = (TObjString *)list2->At(i);
1496 if (idStr->String().CompareTo("QAThreshold") == 0 || idStr->String().CompareTo("TriggerClassesAndHistosToClone") == 0) {
1497 Log(Form("Skipping file with Id %s",idStr->String().Data()));
1500 TString fileName = GetFile(kDAQ,idStr->String().Data(),objStr->String().Data());
1501 if (fileName.Length() > 0) {
1502 Log(Form("Adding file in the chain: %s",fileName.Data()));
1503 fRawTagChain->Add(fileName.Data());
1506 Log(Form("Could not retrieve file with id %s from source %s: "
1507 "connection problems with DAQ FXS!",
1508 idStr->String().Data(), objStr->String().Data()));
1509 delete list; list=0;
1510 delete list2; list2=0;
1511 delete fRawTagChain; fRawTagChain=0;
1519 TString fRawDataFileName = "GRP_Merged.tag.root";
1520 Log(Form("Merging %d raw data tags into file: %s", nFiles, fRawDataFileName.Data()));
1522 if( fRawTagChain->Merge(fRawDataFileName) < 1 ) {
1523 Log("Error merging raw data files!!!");
1527 TString outputfile = Form("Run%d.Merged.RAW.tag.root", fRun);
1528 Bool_t result = StoreRunMetadataFile(fRawDataFileName.Data(),outputfile.Data());
1531 Log("Problem storing raw data tags in local file!!!");
1533 Log("Raw data tags merged successfully!!");
1538 delete fRawTagChain; fRawTagChain=0;
1540 if (result == kFALSE) {
1548 //_______________________________________________________________
1549 UInt_t AliGRPPreprocessor::ProcessDcsFxs(TString partition, TString detector)
1552 // processing the info
1553 // stored in the DCS FXS
1554 // coming from the trigger
1556 // Get the CTP counters information
1558 if (partition.IsNull() && !detector.IsNull()){ // standalone partition
1559 Log("STANDALONE partition for current run, using Trigger Scalers dummy value");
1560 AliCDBEntry *cdbEntry = GetFromOCDB("CTP","DummyScalers");
1562 Log(Form("No dummy CTP scalers entry found, going into error..."));
1566 AliTriggerRunScalers *scalers = (AliTriggerRunScalers*)cdbEntry->GetObject();
1568 Log(Form("CTP dummy scalers not found in OCDB entry, going into error..."));
1572 AliCDBMetaData metaData;
1573 metaData.SetResponsible("Roman Lietava");
1574 metaData.SetComment("CTP scalers from dummy entry in OCDB");
1575 if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
1576 Log("Unable to store the dummy CTP scalers object to OCDB!");
1583 else if (!partition.IsNull() && detector.IsNull()){ // global partition
1584 Log("GLOBAL partition for current run, using CTP scalers from DCS FXS");
1585 TString countersfile = GetFile(kDCS, "CTP_xcounters","");
1586 if (countersfile.IsNull()) {
1587 Log("No CTP counters files has been found: empty source!");
1591 Log(Form("File with Id CTP_xcounters found in DCS FXS! Copied to %s",countersfile.Data()));
1592 AliTriggerRunScalers *scalers = AliTriggerRunScalers::ReadScalers(countersfile);
1594 Log("Bad CTP counters file! The corresponding CDB entry will not be filled!");
1598 AliCDBMetaData metaData;
1599 metaData.SetBeamPeriod(0);
1600 metaData.SetResponsible("Roman Lietava");
1601 metaData.SetComment("CTP scalers");
1602 if (!Store("CTP","Scalers", scalers, &metaData, 0, 0)) {
1603 Log("Unable to store the CTP scalers object to OCDB!");
1614 Log(Form("Incorrect field in DAQ logbook for partition = %s and detector = %s, going into error...",partition.Data(),detector.Data()));
1621 //_______________________________________________________________
1623 Int_t AliGRPPreprocessor::ProcessDcsDPs(TMap* valueMap, AliGRPObject* grpObj)
1627 // processing DCS DPs
1630 Int_t entries = 0; // counting the entries that are in the DCS DB, not taking care whether they have values or not
1631 Int_t nL3Entries = 0;
1632 Int_t nDipoleEntries = 0;
1633 Int_t nEnvEntries = 0;
1634 Int_t nHallProbesEntries = 0;
1635 nL3Entries = ProcessL3DPs(valueMap, grpObj);
1636 nDipoleEntries = ProcessDipoleDPs(valueMap, grpObj);
1637 nEnvEntries = ProcessEnvDPs(valueMap, grpObj);
1638 nHallProbesEntries = ProcessHPDPs(valueMap, grpObj);
1639 grpObj->SetPolarityConventionLHC(); // after the dipole cables swap we comply with LHC convention
1640 Log(Form("L3Entries = %d, nDipoleEntries =%d, nEnvEntries = %d, nHallProbesEntries = %d", nL3Entries, nDipoleEntries, nEnvEntries, nHallProbesEntries));
1641 entries = nL3Entries + nDipoleEntries + nEnvEntries + nHallProbesEntries;
1646 //_______________________________________________________________
1648 Int_t AliGRPPreprocessor::ProcessL3DPs(const TMap* valueMap, AliGRPObject* grpObj)
1655 Int_t nL3Entries = 0;
1657 TObjArray *array = 0x0;
1659 Bool_t isZero = kTRUE; // flag to monitor L3Current. If set to true, the magnet is OFF, and the polarity can change
1661 AliInfo(Form("==========L3Current==========="));
1662 Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range
1663 indexDP = kL3Current;
1664 array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
1666 Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
1669 if (array->GetEntries() == 0){
1670 AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP]));
1673 Float_t *floatDCS = ProcessFloatAllMagnet(array, indexDP, isZero);
1674 if (floatDCS != NULL){
1675 grpObj->SetL3Current(floatDCS);
1687 ffailedDPs->RemoveAt(indexDP);
1691 if (array) array = 0x0;
1693 AliInfo(Form("==========L3Polarity==========="));
1694 indexDP = kL3Polarity;
1695 array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
1697 Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
1700 if (array->GetEntries() == 0){
1701 AliError(Form("No entries found in array! setting %s Polarity to invalid...",fgkDCSDataPoints[indexDP]));
1704 Bool_t change = kFALSE;
1705 Char_t charDCS = ProcessBool(array,change);
1706 if (change == kFALSE){
1707 grpObj->SetL3Polarity(charDCS);
1708 AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetL3Polarity())));
1709 ffailedDPs->RemoveAt(indexDP);
1713 AliInfo(Form("%s set to invalid, but magnet was OFF (according to the current), DP not considered wrong",fgkDCSDataPoints[indexDP]));
1714 ffailedDPs->RemoveAt(indexDP);
1718 AliError(Form("%s value changed within the run, while the magnet was ON (according to the current), setting it to invalid and considering the DP as wrong",fgkDCSDataPoints[indexDP]));
1726 //_______________________________________________________________
1728 Int_t AliGRPPreprocessor::ProcessDipoleDPs(const TMap* valueMap, AliGRPObject* grpObj)
1734 Int_t nDipoleEntries = 0;
1735 TObjArray *array = 0x0;
1737 Bool_t isZero = kTRUE; // flag to monitor L3Current. If set to true, the magnet is OFF, and the polarity can change
1739 AliInfo(Form("==========DipoleCurrent==========="));
1740 Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range
1741 indexDP = kDipoleCurrent;
1742 array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
1744 Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
1747 if (array->GetEntries() == 0){
1748 AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP]));
1751 Float_t *floatDCS = ProcessFloatAllMagnet(array, indexDP, isZero);
1752 if (floatDCS != NULL){
1753 grpObj->SetDipoleCurrent(floatDCS);
1765 ffailedDPs->RemoveAt(indexDP);
1769 if (array) array = 0x0;
1771 AliInfo(Form("==========DipolePolarity==========="));
1772 indexDP = kDipolePolarity;
1773 array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
1775 Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
1778 if (array->GetEntries() == 0){
1779 AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP]));
1782 Bool_t change = kFALSE;
1783 Char_t charDCS = ProcessBool(array,change);
1785 grpObj->SetDipolePolarity(charDCS);
1786 AliInfo(Form("%s set to %d",fgkDCSDataPoints[indexDP],(Int_t)(grpObj->GetDipolePolarity())));
1787 ffailedDPs->RemoveAt(indexDP);
1791 AliInfo(Form("%s set to invalid, but magnet was OFF (according to the current), DP not considered wrong",fgkDCSDataPoints[indexDP]));
1792 ffailedDPs->RemoveAt(indexDP);
1796 AliError(Form("%s value changed within the run while the magnet was ON (according to the current), setting it to invalid and considering the DP as wrong", fgkDCSDataPoints[indexDP]));
1801 return nDipoleEntries;
1804 //_______________________________________________________________
1806 Int_t AliGRPPreprocessor::ProcessEnvDPs(TMap* valueMap, AliGRPObject* grpObj)
1810 // evironment conditions (temperature, pressure) info
1812 Int_t nEnvEntries = 0;
1813 TObjArray *array = 0x0;
1816 AliInfo(Form("==========CavernTemperature==========="));
1817 Bool_t outOfRange = kFALSE; // flag to monitor if any value collected by DCS is out of range
1818 indexDP = kCavernTemperature;
1819 array = (TObjArray *)valueMap->GetValue(fgkDCSDataPoints[indexDP]);
1821 Log(Form("%s not found in the map!!!",fgkDCSDataPoints[indexDP]));
1824 if (array->GetEntries() == 0){
1825 AliError(Form("No entries found in array! setting %s to invalid...",fgkDCSDataPoints[indexDP]));
1828 Float_t *floatDCS = ProcessFloatAll(array);
1829 if (floatDCS != NULL){
1830 grpObj->SetCavernTemperature(floatDCS);
1841 ffailedDPs->RemoveAt(indexDP);
1846 if (array) array = 0x0;
1848 AliInfo(Form("========== AtmosPressures (Cavern + Surface + Cavern2) ==========="));
1849 AliDCSSensorArray *dcsSensorArray = GetPressureMap(valueMap);
1850 //dcsSensorArray->Print();
1851 if( fPressure->NumFits()<kNumSensors ) {
1852 Log(Form("Check the pressure sensor values! Not all the %d pressure sensors have been fit",kNumSensors));
1854 Log(Form("Number of fits performed = %d",fPressure->NumFits()));
1856 AliInfo(Form("==========CavernAtmosPressure==========="));
1857 indexDP = kCavernAtmosPressure;
1858 AliDCSSensor* sensorCavernP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
1859 TGraph* graph = sensorCavernP2->GetGraph();
1860 AliDebug(3,Form("index = %d",indexDP));
1861 AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP]));
1862 AliDebug(2,Form("graph = %p",graph));
1863 AliDebug(3,Form("sensorCavernP2 = %p", sensorCavernP2));
1864 if(sensorCavernP2->GetFit() || graph) {
1865 if (sensorCavernP2->GetFit()){
1866 Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP]));
1869 Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP]));
1871 grpObj->SetCavernAtmosPressure(sensorCavernP2);
1872 ffailedDPs->RemoveAt(indexDP);
1875 //if (sensorP2) delete sensorP2;
1877 Log(Form("ERROR!!! Neither graph nor fit found for sensor %s - this will not increase the number of found DCS DPs and will cause an error", fgkDCSDataPoints[indexDP] ));
1880 AliInfo(Form("==========SurfaceAtmosPressure==========="));
1881 indexDP = kSurfaceAtmosPressure;
1882 AliDCSSensor* sensorP2 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
1883 graph = sensorP2->GetGraph();
1884 AliDebug(3,Form("index = %d",indexDP));
1885 AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP]));
1886 AliDebug(2,Form("graph = %p",graph));
1887 AliDebug(3,Form("sensorP2 = %p", sensorP2));
1888 if(sensorP2->GetFit() || graph) {
1889 if (sensorP2->GetFit()){
1890 Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP]));
1893 Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP]));
1895 grpObj->SetSurfaceAtmosPressure(sensorP2);
1896 ffailedDPs->RemoveAt(indexDP);
1899 //if (sensorP2) delete sensorP2;
1901 Log(Form("ERROR!!! Neither graph nor fit found for sensor %s - this will not increase the number of found DCS DPs and will cause an error", fgkDCSDataPoints[indexDP] ));
1904 AliInfo(Form("==========CavernAtmosPressure2==========="));
1905 indexDP = kCavernAtmosPressure2;
1906 AliDCSSensor* sensorCavernP22 = dcsSensorArray->GetSensor(fgkDCSDataPoints[indexDP]);
1907 graph = sensorCavernP22->GetGraph();
1908 AliDebug(3,Form("index = %d",indexDP));
1909 AliDebug(3,Form("name = %s",fgkDCSDataPoints[indexDP]));
1910 AliDebug(2,Form("graph = %p",graph));
1911 AliDebug(3,Form("sensorCavernP2_2 = %p", sensorCavernP22));
1912 if(sensorCavernP22->GetFit() || graph) {
1913 if (sensorCavernP22->GetFit()){
1914 Log(Form("Fit for sensor %s found",fgkDCSDataPoints[indexDP]));
1917 Log(Form("Fit for sensor %s not found, but the graph is there - NOT going into error",fgkDCSDataPoints[indexDP]));
1919 grpObj->SetCavernAtmosPressure2(sensorCavernP22);
1920 ffailedDPs->RemoveAt(indexDP);
1923 //if (sensorP2) delete sensorP2;
1925 Log(Form("ERROR!!! Neither graph nor fit found for sensor %s - this will not increase the number of found DCS DPs and will cause an error", fgkDCSDataPoints[indexDP] ));
1931 //_______________________________________________________________
1933 Int_t AliGRPPreprocessor::ProcessHPDPs(const TMap* valueMap, AliGRPObject* grpObj)
1939 Int_t nHPEntries = 0;
1940 TObjArray *array = 0x0;
1942 Bool_t outOfRange; // flag to monitor if any value collected by DCS is out of range
1944 if (fgknDCSDPHallProbes != AliGRPObject::GetNumberOfHP()){
1945 AliError(Form("Number of Hall probes expected in GRP Preprocessor (i.e. %d) different from number of Hall Probes foreseen in GRP object (i.e. %d). Looping on entries from GRP object anyway.", fgknDCSDPHallProbes, AliGRPObject::GetNumberOfHP()));
1947 for (indexDP = 0; indexDP < AliGRPObject::GetNumberOfHP(); indexDP++){
1948 outOfRange = kFALSE; // resetting outOfRange flag at each HP
1949 AliInfo(Form("==========%s===========",AliGRPObject::GetHPDP(indexDP)));
1950 array = (TObjArray *)valueMap->GetValue(AliGRPObject::GetHPDP(indexDP));
1952 Log(Form("%s not found in the map!!!",AliGRPObject::GetHPDP(indexDP)));
1955 if (array->GetEntries() == 0){
1956 AliError(Form("No entries found in array! setting %s to invalid...",AliGRPObject::GetHPDP(indexDP)));
1959 Float_t *floatDCS = ProcessFloatAll(array);
1960 if (floatDCS != NULL){
1961 AliDebug(2,Form("value[0] = %f, value[1] = %f, value[2] = %f, value[3] = %f, value[4] = %f",floatDCS[0],floatDCS[1],floatDCS[2],floatDCS[3],floatDCS[4]));
1962 grpObj->SetHallProbes((AliGRPObject::DP_HallProbes)indexDP,floatDCS);
1963 for (Int_t kk = 0 ; kk< 5; kk++){
1964 AliDebug(2,Form("HallProbe[%d][%d]=%f",indexDP,kk,grpObj->GetHallProbes((AliGRPObject::DP_HallProbes)indexDP,(AliGRPObject::Stats)kk)));
1976 ffailedDPs->RemoveAt(indexDP + fgkDCSDPHallTopShift); // 7 = shift in the complete list of DPs to get to the Hall Probes
1982 Log(Form("Hall Probes = %d ", nHPEntries));
1986 //_________________________________________________________________________
1988 AliSplineFit* AliGRPPreprocessor::GetSplineFit(const TObjArray *array, const TString& stringID){
1992 // returning Spline Fit
1995 Int_t entriesarray = array->GetEntries();
1996 Float_t* value = new Float_t[entriesarray];
1997 Float_t* time = new Float_t[entriesarray];
1998 AliDCSValue* v = 0x0;
1999 for (Int_t iarray = 0; iarray < entriesarray; iarray++){
2000 v = (AliDCSValue*)array->At(iarray);
2001 value[iarray] = v->GetFloat();
2002 time[iarray] = v->GetTimeStamp();
2003 AliDebug(2,Form("iarray = %d, value = %f, time = %f",iarray,value[iarray],time[iarray]));
2005 TGraph* gr = new TGraph(entriesarray,value,time);
2007 AliWarning(Form("%s: no input graph to compute SplineFit",stringID.Data()));
2010 AliSplineFit *fit = new AliSplineFit();
2011 fit->SetMinPoints(10);
2012 fit->InitKnots(gr,10,10,0.0);
2018 //_________________________________________________________________________
2020 TString AliGRPPreprocessor::ProcessChar(const TObjArray *array)
2027 TString aDCSString="";
2029 AliDCSValue *v = 0x0;
2030 for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) {
2031 v = (AliDCSValue *)array->At(iCount);
2032 if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) {
2033 AliError(Form("DCS values for the parameter outside the queried interval"));
2037 if (aDCSString != v->GetChar())
2038 AliError(Form("DCS values for the parameter changed from %s to %c within the queried interval", aDCSString.Data(), (Char_t)v->GetChar()));
2040 aDCSString = (TString)v->GetChar(); // keeping always last value in the array
2045 //__________________________________________________________________________________________________________________
2047 Float_t* AliGRPPreprocessor::ProcessFloatAll(const TObjArray* array)
2050 // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median
2052 // parameters[0] = mean
2053 // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean
2054 // parameters[2] = median
2055 // parameters[3] = standard deviation wrt mean
2056 // parameters[4] = standard deviation wrt median
2059 TString timeStartString = (TString)GetRunParameter("DAQ_time_start");
2060 TString timeEndString = (TString)GetRunParameter("DAQ_time_end");
2061 if (timeStartString.IsNull() || timeStartString.IsNull()){
2062 if (timeStartString.IsNull()){
2063 AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid");
2065 else if (timeStartString.IsNull()){
2066 AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid");
2068 fdaqStartEndTimeOk = kFALSE;
2072 Int_t timeStart = (Int_t)(timeStartString.Atoi());
2073 Int_t timeEnd = (Int_t)(timeEndString.Atoi());
2074 Float_t* parameters = new Float_t[5];
2076 Int_t iCountsRun = 0;
2077 Int_t nCounts = array->GetEntries();
2078 Float_t valueBeforeSOR = 0;
2079 Float_t valueAfterEOR = 0;
2080 Int_t timestampBeforeSOR = -1;
2081 Int_t timestampAfterEOR = -1;
2082 Int_t ientrySOR = -1;
2083 Int_t ientryEOR = -1;
2084 Float_t* arrayValues = 0x0;
2085 Double_t* arrayWeights = 0x0;
2086 Bool_t truncMeanFlag = kTRUE; // flag to indicate whether Truncated Mean should be calculated or not
2087 Bool_t sdFlag = kTRUE; // flag to indicate whether SD (wrt Mean/Median) should be calculated or not
2089 for(Int_t i = 0; i < nCounts; i++) {
2090 AliDCSValue *v = (AliDCSValue *)array->At(i);
2091 if ((v->GetFloat() <= fminFloat) || (v->GetFloat() >= fmaxFloat)) {
2092 AliError(Form("Error! Float value found in DCS map at %d-th entry is OUT OF RANGE: value = %6.5e",i,v->GetFloat()));
2093 if (v->GetFloat() < fminFloat) AliInfo(Form("The value is smaller than %6.5e",fminFloat));
2094 if (v->GetFloat() > fmaxFloat) AliInfo(Form("The value is greater than %6.5e",fmaxFloat));
2095 delete [] parameters;
2098 if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
2099 AliDebug(2,Form("%d-th entry = %f at timestamp %i",i,v->GetFloat(),v->GetTimeStamp()));
2101 // look for the last value before SOR and the first value before EOR
2102 if (((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) && (Int_t)(v->GetTimeStamp()) < timeStart) {
2103 timestampBeforeSOR = (Int_t)(v->GetTimeStamp());
2104 AliDebug(2,Form("timestamp of last value before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart));
2105 valueBeforeSOR = v->GetFloat();
2107 else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){
2108 timestampAfterEOR = (Int_t)(v->GetTimeStamp());
2109 valueAfterEOR = v->GetFloat();
2110 AliDebug(2,Form("timestamp of first value after EOR = %d, with DAQ_time_end = %d",timestampAfterEOR,timeEnd));
2112 // check if there are DPs between DAQ_time_start and DAQ_time_end
2113 if(((Int_t)(v->GetTimeStamp()) >= timeStart) &&((Int_t)(v->GetTimeStamp()) <= timeEnd)) {
2114 if (ientrySOR == -1) ientrySOR = i; // first entry after SOR
2115 if (ientryEOR < i) ientryEOR = i; // last entry before EOR
2116 AliDebug(2,Form("entry between SOR and EOR"));
2121 AliError(Form("DCS values for the parameter outside the queried interval: timestamp = %d",v->GetTimeStamp()));
2125 if (timestampBeforeSOR == -1){
2126 AliWarning("No value found before SOR");
2128 if (timestampAfterEOR == -1){
2129 AliWarning("No value found after EOR");
2132 AliDebug(2,Form("Number of valid entries (within DCS query interval) = %i, from a total amount of %i entries",iCounts,nCounts));
2133 AliDebug(2,Form("Last value before DAQ_time_start (SOR) = %f at timestamp = %d",valueBeforeSOR,timestampBeforeSOR));
2134 AliDebug(2,Form("First value after DAQ_time_end (EOR) = %f at timestamp = %d",valueAfterEOR,timestampAfterEOR));
2135 AliInfo(Form("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)",iCountsRun));
2136 AliDebug(2,Form("Index of first entry after DAQ_time_start (SOR) = %d ",ientrySOR));
2137 AliDebug(2,Form("Index of first entry before DAQ_time_end (EOR) = %d ",ientryEOR));
2139 Int_t nentriesUsed = 0;
2140 if (iCountsRun > 1){
2141 AliInfo("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)");
2142 AliDebug(2,"Calculating (weighted) Mean and Median");
2143 arrayValues = new Float_t[iCountsRun];
2144 arrayWeights = new Double_t[iCountsRun];
2145 nentriesUsed = iCountsRun;
2146 for (Int_t i = ientrySOR; i <= ientryEOR; i++){
2147 AliDCSValue *v = (AliDCSValue *)array->At(i);
2148 Int_t timestamp2 = 0;
2150 AliDCSValue *v1 = (AliDCSValue *)array->At(i+1);
2151 timestamp2 = (Int_t)v1->GetTimeStamp();
2154 timestamp2 = timeEnd+1;
2156 arrayWeights[i-ientrySOR] = (Double_t)(timestamp2 - (Int_t)v->GetTimeStamp());
2157 arrayValues[i-ientrySOR] = v->GetFloat();
2159 parameters[0] = TMath::Mean(iCountsRun,arrayValues,arrayWeights);
2160 parameters[2] = TMath::Median(iCountsRun,arrayValues,arrayWeights);
2162 else if (iCountsRun == 1){
2163 AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR);
2165 if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)v->GetTimeStamp()){
2166 AliWarning("Using single entry between DAQ_time_start (SOR) and DAQ_time_end (EOR) and last entry before SOR. Truncated mean won't be calculated.");
2167 arrayValues = new Float_t[2];
2168 arrayWeights = new Double_t[2];
2169 arrayValues[0] = valueBeforeSOR;
2170 arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR);
2171 arrayValues[1] = v->GetFloat();
2172 arrayWeights[1] = (Double_t)(timeEnd+1-(Int_t)v->GetTimeStamp());
2173 AliDebug(2, Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0]));
2174 AliDebug(2, Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1]));
2175 parameters[0] = TMath::Mean(2,arrayValues,arrayWeights);
2176 parameters[2] = TMath::Median(2,arrayValues,arrayWeights);
2177 truncMeanFlag = kFALSE;
2180 AliError("Cannot calculate mean, truncated mean, median, SD wrt mean, SD wrt median for current DP - only one value collected during the run, but no value before with which to calculate the statistical quantities");
2181 parameters[0] = AliGRPObject::GetInvalidFloat();
2182 parameters[1] = AliGRPObject::GetInvalidFloat();
2183 parameters[2] = AliGRPObject::GetInvalidFloat();
2184 parameters[3] = AliGRPObject::GetInvalidFloat();
2185 parameters[4] = AliGRPObject::GetInvalidFloat();
2189 else { // iCountsRun == 0, using only the point immediately before SOR
2190 if (timestampBeforeSOR == -1){
2191 AliError("Cannot set mean, truncated mean, median, SD wrt mean, SD wrt median for current DP - no points during the run collected, and point before SOR missing");
2192 parameters[0] = AliGRPObject::GetInvalidFloat();
2193 parameters[1] = AliGRPObject::GetInvalidFloat();
2194 parameters[2] = AliGRPObject::GetInvalidFloat();
2195 parameters[3] = AliGRPObject::GetInvalidFloat();
2196 parameters[4] = AliGRPObject::GetInvalidFloat();
2200 AliWarning("Using only last entry before SOR. Truncated mean and Standard deviations (wrt mean/median) won't be calculated.");
2201 AliDebug(2,Form("value = %f",valueBeforeSOR));
2202 parameters[0] = valueBeforeSOR;
2203 parameters[2] = valueBeforeSOR;
2204 truncMeanFlag = kFALSE;
2211 Float_t sumweights = 0;
2212 Int_t entriesTruncMean = 0;
2213 Float_t* arrayValuesTruncMean = new Float_t[nentriesUsed];
2214 Double_t* arrayWeightsTruncMean = new Double_t[nentriesUsed];
2216 // calculating SD wrt Mean and Median
2217 AliDebug(2,"Calculating SD wrt Mean and SD wrt Median");
2219 for (Int_t i =0; i< nentriesUsed; i++){
2220 AliDebug(2,Form("Entry %d: value = %f, weight = %f",i,arrayValues[i],arrayWeights[i]));
2221 temp += (arrayValues[i]-parameters[2])*(arrayValues[i]-parameters[2]);
2222 temp1 += arrayWeights[i]*(arrayValues[i]-parameters[0])*(arrayValues[i]-parameters[0]);
2223 sumweights += arrayWeights[i];
2225 // setting SD wrt Mean
2226 if (sumweights != 0 ){
2227 parameters[3] = TMath::Sqrt(temp1/sumweights);
2230 AliError("Sum of weights to calculate Standard Deviation (wrt mean) <= 0, setting the SD to invalid");
2231 parameters[3] = AliGRPObject::GetInvalidFloat();
2233 // setting SD wrt Median
2234 if (nentriesUsed != 0){
2235 parameters[4] = TMath::Sqrt(temp/nentriesUsed);
2238 AliError("Number of entries used to calculate Standard Deviation (wrt median) <= 0, setting the SD to invalid");
2239 parameters[4] = AliGRPObject::GetInvalidFloat();
2243 parameters[3] = AliGRPObject::GetInvalidFloat();
2244 parameters[4] = AliGRPObject::GetInvalidFloat();
2247 // calculating truncated mean (this comes afterwards since you need the SD wrt Mean)
2249 AliDebug(2,"Calculating Truncated Mean");
2250 for (Int_t i =0; i< nentriesUsed; i++){
2251 AliDebug(2,Form("Entry %d: value = %f, weight = %f",i,arrayValues[i],arrayWeights[i]));
2252 if ((arrayValues[i]<=parameters[0]+3*parameters[3]) && (arrayValues[i]>=parameters[0]-3*parameters[3])){
2253 arrayValuesTruncMean[entriesTruncMean]=arrayValues[i];
2254 arrayWeightsTruncMean[entriesTruncMean]=arrayWeights[i];
2255 AliDebug(2,Form("For Truncated Mean: Entry %d: value = %f, weight = %f",entriesTruncMean,arrayValuesTruncMean[entriesTruncMean],arrayWeightsTruncMean[entriesTruncMean]));
2259 AliDebug(2,"Discarding entry");
2262 // setting truncated mean
2263 if (entriesTruncMean >1){
2264 AliDebug(2,Form("%d entries used for truncated mean",entriesTruncMean));
2265 parameters[1] = TMath::Mean(entriesTruncMean,arrayValuesTruncMean,arrayWeightsTruncMean);
2268 AliDebug(2,Form("Too few entries (%d) to calculate truncated mean",entriesTruncMean));
2269 parameters[1] = AliGRPObject::GetInvalidFloat();
2273 parameters[1] = AliGRPObject::GetInvalidFloat();
2277 delete [] arrayValues;
2280 delete [] arrayWeights;
2282 delete [] arrayValuesTruncMean;
2283 delete [] arrayWeightsTruncMean;
2285 AliInfo(Form("(weighted) mean = %f ",parameters[0]));
2286 AliInfo(Form("(weighted) truncated mean = %f ",parameters[1]));
2287 AliInfo(Form("median = %f ",parameters[2]));
2288 AliInfo(Form("(weighted) standard deviation with (weighted) mean = %f ",parameters[3]));
2289 AliInfo(Form("standard deviation with median = %f ",parameters[4]));
2294 //__________________________________________________________________________________________________________________
2296 Float_t* AliGRPPreprocessor::ProcessFloatAllMagnet(const TObjArray* array, Int_t indexDP, Bool_t &isZero)
2299 // processing Float values using Mean, Median, Standard Deviation wrt Mean, Standar Deviation wrt Median
2300 // used for L3 and Dipole magnets, using isZero flag to decide whther the magnet was OFF/ON
2301 // the flag is set according to the L3/Dipole current value
2302 // current threshold for L3 = 350 A (value provided by DCS)
2303 // current threshold for Dipole = 450 A (value provided by DCS)
2305 // parameters[0] = mean
2306 // parameters[1] = truncated mean (calculated excluding points outside +/- 3RMS from mean
2307 // parameters[2] = median
2308 // parameters[3] = standard deviation wrt mean
2309 // parameters[4] = standard deviation wrt median
2312 AliInfo(Form("indexDP = %d",indexDP));
2314 Int_t nCounts = array->GetEntries();
2315 for(Int_t i = 0; i < nCounts; i++) {
2316 AliDCSValue *v = (AliDCSValue *)array->At(i);
2317 if ((v->GetFloat() <= fminFloat) || (v->GetFloat() >= fmaxFloat)) {
2318 AliError(Form("Error! Float value found in DCS map at %d-th entry is OUT OF RANGE: value = %6.5e",i,v->GetFloat()));
2319 if (v->GetFloat() < fminFloat) AliInfo(Form("The value is smaller than %6.5e",fminFloat));
2320 if (v->GetFloat() > fmaxFloat) AliInfo(Form("The value is greater than %6.5e",fmaxFloat));
2323 if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
2324 AliDebug(2,Form("%d-th entry = %f",i,v->GetFloat()));
2325 if (indexDP == kL3Current && v->GetFloat() > 350 && isZero == kTRUE) isZero=kFALSE;
2326 if (indexDP == kDipoleCurrent && v->GetFloat() > 450 && isZero == kTRUE) isZero=kFALSE;
2329 AliError(Form("DCS values for the parameter outside the queried interval"));
2333 return ProcessFloatAll(array);
2337 //_______________________________________________________________
2339 Char_t AliGRPPreprocessor::ProcessBool(const TObjArray* array, Bool_t &change)
2342 // processing Boolean values
2345 Bool_t aDCSBool = kTRUE;
2347 AliDCSValue *v = 0x0;
2349 for(Int_t iCount = 0; iCount < array->GetEntries(); iCount++) {
2350 v = (AliDCSValue *)array->At(iCount);
2351 if (((Int_t)(v->GetTimeStamp()) < (Int_t)GetStartTimeDCSQuery()) || ((Int_t)(v->GetTimeStamp()) > (Int_t)GetEndTimeDCSQuery())) {
2352 AliError(Form("DCS values for the parameter outside the queried interval"));
2356 if (aDCSBool != v->GetBool()) {
2357 AliError(Form("DCS values for the parameter changed from %d to %d within the queried interval", (UInt_t)aDCSBool, (UInt_t)v->GetBool()));
2361 aDCSBool = v->GetBool(); // always keeping last value
2362 AliDebug(2,Form("Bool = %d",(Int_t)aDCSBool));
2365 Char_t caDCSBool = (Char_t) aDCSBool;
2370 //_______________________________________________________________
2372 Float_t AliGRPPreprocessor::ProcessInt(const TObjArray* array)
2375 // processing Int values, returning mean
2376 // AliGRPObject::GetInvalidFloat() is returned if any of the DCS values
2377 // are outside the queried time interval or their value is out of range
2380 TString timeStartString = (TString)GetRunParameter("DAQ_time_start");
2381 TString timeEndString = (TString)GetRunParameter("DAQ_time_end");
2382 if (timeStartString.IsNull() || timeStartString.IsNull()){
2383 if (timeStartString.IsNull()){
2384 AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid");
2386 else if (timeStartString.IsNull()){
2387 AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid");
2392 Int_t timeStart = (Int_t)(timeStartString.Atoi());
2393 Int_t timeEnd = (Int_t)(timeEndString.Atoi());
2394 Float_t aDCSArrayMean = 0.0;
2396 Float_t valueBeforeSOR = 0;
2397 Float_t valueAfterEOR = 0;
2398 Int_t timestampBeforeSOR = -1;
2399 Int_t timestampAfterEOR = -1;
2400 Int_t ientrySOR = -1;
2401 Int_t ientryEOR = -1;
2402 Float_t* arrayValues = 0x0;
2403 Double_t* arrayWeights = 0x0;
2404 Int_t iCountsRun = 0;
2405 Int_t nCounts = array->GetEntries();
2407 for(Int_t i = 0; i < nCounts; i++) {
2408 AliDCSValue* v = (AliDCSValue *)array->At(i);
2409 if ((v->GetInt() < fminInt) || (v->GetInt() > fmaxInt)) {
2410 AliError(Form("Error! Int value found in DCS map at %d-th entry is OUT OF RANGE: value = %d",i, v->GetInt()));
2411 return AliGRPObject::GetInvalidFloat();
2413 if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
2414 AliDebug(2,Form("%d-th entry = %d at timestamp %i",i,v->GetInt(),v->GetTimeStamp()));
2416 // look for the last value before SOR and the first value before EOR
2417 if (((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) && (Int_t)(v->GetTimeStamp()) < timeStart) {
2418 timestampBeforeSOR = (Int_t)(v->GetTimeStamp());
2419 AliDebug(2,Form("timestamp of last entry before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart));
2420 valueBeforeSOR = (Float_t) v->GetInt();
2422 else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){
2423 timestampAfterEOR = (Int_t)(v->GetTimeStamp());
2424 valueAfterEOR = (Float_t) v->GetInt();
2425 AliDebug(2,Form("timestamp of first entry after EOR = %d, with DAQ_time_end = %d",timestampAfterEOR,timeEnd));
2427 // check if there are DPs between DAQ_time_start and DAQ_time_end
2428 if(((Int_t)(v->GetTimeStamp()) >= timeStart) &&((Int_t)(v->GetTimeStamp()) <= timeEnd)) {
2429 if (ientrySOR == -1) ientrySOR = i; // first entry after SOR
2430 if (ientryEOR < i) ientryEOR = i; // last entry before EOR
2431 AliDebug(2,Form("entry between SOR and EOR"));
2436 AliError(Form("DCS values for the parameter outside the queried interval: timestamp = %d",v->GetTimeStamp()));
2440 if (timestampBeforeSOR == -1){
2441 AliWarning("No value found before SOR!");
2443 if (timestampAfterEOR == -1){
2444 AliWarning("No value found after EOR!");
2447 AliDebug(2,Form("Number of valid entries (within query interval) = %i, starting from %i entries",iCounts,nCounts));
2448 AliDebug(2,Form("Last value before DAQ_time_start (SOR) = %f at timestamp = %d",valueBeforeSOR,timestampBeforeSOR));
2449 AliDebug(2,Form("First value after DAQ_time_end (EOR) = %f at timestamp = %d",valueAfterEOR,timestampAfterEOR));
2450 AliInfo(Form("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)",iCountsRun));
2451 AliDebug(2,Form("Index of first entry after DAQ_time_start (SOR) = %d ",ientrySOR));
2452 AliDebug(2,Form("Index of first entry before DAQ_time_end (EOR) = %d ",ientryEOR));
2454 Int_t nentriesUsed = 0;
2455 if (iCountsRun > 1){
2456 AliInfo("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)");
2457 AliDebug(2,"Calculating (weighted) Mean");
2458 arrayValues = new Float_t[iCountsRun];
2459 arrayWeights = new Double_t[iCountsRun];
2460 nentriesUsed = iCountsRun;
2461 for (Int_t i = ientrySOR; i <= ientryEOR; i++){
2462 AliDCSValue *v = (AliDCSValue *)array->At(i);
2463 Int_t timestamp2 = 0;
2465 AliDCSValue *v1 = (AliDCSValue *)array->At(i+1);
2466 timestamp2 = (Int_t)v1->GetTimeStamp();
2469 timestamp2 = timeEnd+1;
2471 arrayWeights[i-ientrySOR] = (Double_t)(timestamp2 - (Int_t)v->GetTimeStamp());
2472 arrayValues[i-ientrySOR] = (Float_t)v->GetInt();
2474 aDCSArrayMean = TMath::Mean(iCountsRun,arrayValues,arrayWeights);
2475 delete [] arrayValues;
2476 delete [] arrayWeights;
2478 else if (iCountsRun == 1){
2479 AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR);
2481 if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)v->GetTimeStamp()){
2482 AliWarning("Using single entry between DAQ_time_start (SOR) and DAQ_time_end (EOR) and last entry before SOR.");
2483 arrayValues = new Float_t[2];
2484 arrayWeights = new Double_t[2];
2485 arrayValues[0] = valueBeforeSOR;
2486 arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR);
2487 arrayValues[1] = (Float_t)v->GetInt();
2488 arrayWeights[1] = (Double_t)(timeEnd+1-(Int_t)v->GetTimeStamp());
2489 AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0]));
2490 AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1]));
2491 aDCSArrayMean = TMath::Mean(2,arrayValues,arrayWeights);
2492 delete [] arrayValues;
2493 delete [] arrayWeights;
2496 AliError("Cannot calculate mean - only one value collected during the run, but no value before with which to calculate the statistical quantities");
2497 return AliGRPObject::GetInvalidFloat();
2500 else { // iCountsRun == 0, using the point immediately before SOR and the one immediately after EOR
2501 if (timestampBeforeSOR == -1 || timestampAfterEOR == -1){
2502 if (timestampBeforeSOR == -1){
2503 AliError("Cannot calculate mean - no points during the run collected, and point before SOR missing");
2505 if (timestampAfterEOR == -1){
2506 AliError("Cannot calculate maen - no points during the run collected, and point after EOR missing");
2508 return AliGRPObject::GetInvalidFloat();
2511 AliWarning("Using last entry before SOR and first entry after EOR.");
2513 arrayValues = new Float_t[2];
2514 arrayWeights = new Double_t[2];
2515 arrayValues[0] = valueBeforeSOR;
2516 arrayWeights[0] = (Double_t)(timestampAfterEOR - timestampBeforeSOR);
2517 arrayValues[1] = valueAfterEOR;
2518 arrayWeights[1] = 1.;
2519 AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0]));
2520 AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1]));
2521 aDCSArrayMean = TMath::Mean(1,arrayValues,arrayWeights);
2522 delete [] arrayValues;
2523 delete [] arrayWeights;
2527 AliInfo(Form("mean = %f ", aDCSArrayMean));
2528 return aDCSArrayMean;
2531 //_______________________________________________________________
2533 Float_t AliGRPPreprocessor::ProcessUInt(const TObjArray* array)
2536 // processing Int values, returning mean
2537 // AliGRPObject::GetInvalidFloat() is returned if any of the DCS values
2538 // are outside the queried time interval or their value is out of range
2541 TString timeStartString = (TString)GetRunParameter("DAQ_time_start");
2542 TString timeEndString = (TString)GetRunParameter("DAQ_time_end");
2543 if (timeStartString.IsNull() || timeStartString.IsNull()){
2544 if (timeStartString.IsNull()){
2545 AliError("DAQ_time_start not set in logbook! Setting statistical values for current DP to invalid");
2547 else if (timeStartString.IsNull()){
2548 AliError("DAQ_time_end not set in logbook! Setting statistical values for current DP to invalid");
2553 Int_t timeStart = (Int_t)(timeStartString.Atoi());
2554 Int_t timeEnd = (Int_t)(timeEndString.Atoi());
2555 Float_t aDCSArrayMean = 0.0;
2557 Float_t valueBeforeSOR = 0;
2558 Float_t valueAfterEOR = 0;
2559 Int_t timestampBeforeSOR = -1;
2560 Int_t timestampAfterEOR = -1;
2561 Int_t ientrySOR = -1;
2562 Int_t ientryEOR = -1;
2563 Float_t* arrayValues = 0x0;
2564 Double_t* arrayWeights = 0x0;
2565 Int_t iCountsRun = 0;
2566 Int_t nCounts = array->GetEntries();
2568 for(Int_t i = 0; i < nCounts; i++) {
2569 AliDCSValue* v = (AliDCSValue *)array->At(i);
2570 if ((v->GetUInt() < fminUInt) || (v->GetUInt() > fmaxUInt)) {
2571 AliError(Form("Error! UInt value found in DCS map at %d-th entry is OUT OF RANGE: value = %u",i,v->GetUInt()));
2572 return AliGRPObject::GetInvalidFloat();
2574 if(((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) &&((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery())) {
2575 AliDebug(2,Form("%d-th entry = %d at timestamp %i",i,v->GetUInt(),v->GetTimeStamp()));
2577 // look for the last value before SOR and the first value before EOR
2578 if (((Int_t)(v->GetTimeStamp()) >= (Int_t)GetStartTimeDCSQuery()) && (Int_t)(v->GetTimeStamp()) < timeStart) {
2579 timestampBeforeSOR = (Int_t)(v->GetTimeStamp());
2580 AliDebug(2,Form("timestamp of last entry before SOR = %d, with DAQ_time_start = %d",timestampBeforeSOR,timeStart));
2581 valueBeforeSOR = (Float_t)v->GetUInt();
2583 else if ((Int_t)(v->GetTimeStamp()) <= (Int_t)GetEndTimeDCSQuery() && (Int_t)(v->GetTimeStamp()) > timeEnd && timestampAfterEOR == -1){
2584 timestampAfterEOR = (Int_t)(v->GetTimeStamp());
2585 valueAfterEOR = (Float_t)v->GetUInt();
2586 AliDebug(2,Form("timestamp of first entry after EOR = %d, with DAQ_time_end = %d",timestampAfterEOR,timeEnd));
2588 // check if there are DPs between DAQ_time_start and DAQ_time_end
2589 if(((Int_t)(v->GetTimeStamp()) >= timeStart) &&((Int_t)(v->GetTimeStamp()) <= timeEnd)) {
2590 if (ientrySOR == -1) ientrySOR = i; // first entry after SOR
2591 if (ientryEOR < i) ientryEOR = i; // last entry before EOR
2592 AliDebug(2,Form("entry between SOR and EOR"));
2597 AliError(Form("DCS values for the parameter outside the queried interval: timestamp = %d",v->GetTimeStamp()));
2601 if (timestampBeforeSOR == -1){
2602 AliWarning("No value found before SOR!");
2604 if (timestampAfterEOR == -1){
2605 AliWarning("No value found after EOR!");
2608 AliDebug(2,Form("Number of valid entries (within query interval) = %i, starting from %i entries",iCounts,nCounts));
2609 AliDebug(2,Form("Last value before DAQ_time_start (SOR) = %f at timestamp = %d",valueBeforeSOR,timestampBeforeSOR));
2610 AliDebug(2,Form("First value after DAQ_time_end (EOR) = %f at timestamp = %d",valueAfterEOR,timestampAfterEOR));
2611 AliInfo(Form("Found %d entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)",iCountsRun));
2612 AliDebug(2,Form("Index of first entry after DAQ_time_start (SOR) = %d ",ientrySOR));
2613 AliDebug(2,Form("Index of first entry before DAQ_time_end (EOR) = %d ",ientryEOR));
2615 Int_t nentriesUsed = 0;
2616 if (iCountsRun > 1){
2617 AliInfo("Using entries between DAQ_time_start (SOR) and DAQ_time_end (EOR)");
2618 AliDebug(2,"Calculating (weighted) Mean");
2619 arrayValues = new Float_t[iCountsRun];
2620 arrayWeights = new Double_t[iCountsRun];
2621 nentriesUsed = iCountsRun;
2622 for (Int_t i = ientrySOR; i <= ientryEOR; i++){
2623 AliDCSValue *v = (AliDCSValue *)array->At(i);
2624 Int_t timestamp2 = 0;
2626 AliDCSValue *v1 = (AliDCSValue *)array->At(i+1);
2627 timestamp2 = (Int_t)v1->GetTimeStamp();
2630 timestamp2 = timeEnd+1;
2632 arrayWeights[i-ientrySOR] = (Double_t)(timestamp2 - (Int_t)v->GetTimeStamp());
2633 arrayValues[i-ientrySOR] = (Float_t)v->GetUInt();
2635 aDCSArrayMean = TMath::Mean(iCountsRun,arrayValues,arrayWeights);
2636 delete [] arrayValues;
2637 delete [] arrayWeights;
2639 else if (iCountsRun == 1){
2640 AliDCSValue* v = (AliDCSValue *)array->At(ientrySOR);
2642 if (timestampBeforeSOR != -1 && timestampBeforeSOR != (Int_t)v->GetTimeStamp()){
2643 AliWarning("Using single entry between DAQ_time_start (SOR) and DAQ_time_end (EOR) and last entry before SOR.");
2644 arrayValues = new Float_t[2];
2645 arrayWeights = new Double_t[2];
2646 arrayValues[0] = valueBeforeSOR;
2647 arrayWeights[0] = (Double_t)((Int_t)v->GetTimeStamp()-timestampBeforeSOR);
2648 arrayValues[1] = (Float_t)v->GetUInt();
2649 arrayWeights[1] = (Double_t)(timeEnd+1-(Int_t)v->GetTimeStamp());
2650 AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0]));
2651 AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1]));
2652 aDCSArrayMean = TMath::Mean(2,arrayValues,arrayWeights);
2653 delete [] arrayValues;
2654 delete [] arrayWeights;
2657 AliError("Cannot calculate mean - only one value collected during the run, but no value before with which to calculate the statistical quantities");
2658 return AliGRPObject::GetInvalidFloat();
2661 else { // iCountsRun == 0, using the point immediately before SOR and the one immediately after EOR
2662 if (timestampBeforeSOR == -1 || timestampAfterEOR == -1){
2663 if (timestampBeforeSOR == -1){
2664 AliError("Cannot calculate mean - no points during the run collected, and point before SOR missing");
2666 if (timestampAfterEOR == -1){
2667 AliError("Cannot calculate maen - no points during the run collected, and point after EOR missing");
2669 return AliGRPObject::GetInvalidFloat();
2672 AliWarning("Using last entry before SOR and first entry after EOR.");
2674 arrayValues = new Float_t[2];
2675 arrayWeights = new Double_t[2];
2676 arrayValues[0] = valueBeforeSOR;
2677 arrayWeights[0] = (Double_t)(timestampAfterEOR - timestampBeforeSOR);
2678 arrayValues[1] = valueAfterEOR;
2679 arrayWeights[1] = 1.;
2680 AliDebug(2,Form("value0 = %f, with weight = %f",arrayValues[0],arrayWeights[0]));
2681 AliDebug(2,Form("value1 = %f, with weight = %f",arrayValues[1],arrayWeights[1]));
2682 aDCSArrayMean = TMath::Mean(1,arrayValues,arrayWeights);
2683 delete [] arrayValues;
2684 delete [] arrayWeights;
2688 AliInfo(Form("mean = %f ",aDCSArrayMean));
2689 return aDCSArrayMean;
2694 //_______________________________________________________________
2696 AliDCSSensorArray *AliGRPPreprocessor::GetPressureMap(TMap* dcsAliasMap)
2698 // extract DCS pressure maps. Perform fits to save space
2700 TMap *map = fPressure->ExtractDCS(dcsAliasMap);
2702 AliDebug(2,Form("Map has %d entries",map->GetEntries()));
2703 fPressure->MakeSplineFit(map);
2704 Double_t fitFraction = fPressure->NumFits()/fPressure->NumSensors();
2705 if (fitFraction > kFitFraction ) {
2706 AliInfo(Form("Pressure values extracted, %d fits performed for %d sensors.", fPressure->NumFits(),fPressure->NumSensors()));
2708 AliInfo("Too few pressure maps fitted!!!");
2711 AliInfo("no atmospheric pressure map extracted!!!");
2720 //_______________________________________________________________
2721 Int_t AliGRPPreprocessor::ReceivePromptRecoParameters(UInt_t run, const char* dbHost, Int_t dbPort, const char* dbName, const char* user, const char* password, const char *cdbRoot, TString &gdc)
2724 // Retrieves logbook and trigger information from the online logbook
2725 // This information is needed for prompt reconstruction
2729 // DAQ params: dbHost, dbPort, dbName, user, password, logbookTable, triggerTable
2733 // positive on success: the return code is the run number of last run processed of the same run type already processed by the SHUTTLE
2734 // 0 on success and no run was found
2735 // negative on error
2737 // This function is NOT called during the preprocessor run in the Shuttle!
2745 AliCDBManager* cdb = AliCDBManager::Instance();
2746 cdb->SetDefaultStorage(cdbRoot);
2749 TSQLServer* server = TSQLServer::Connect(Form("mysql://%s:%d/%s", dbHost, dbPort, dbName), user, password);
2753 Printf("ERROR: Could not connect to DAQ LB");
2759 sqlQuery.Form("SELECT DAQ_time_start, run_type, detectorMask, L3_magnetCurrent, Dipole_magnetCurrent,beamType FROM logbook WHERE run = %d", run);
2760 TSQLResult* result = server->Query(sqlQuery);
2763 Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
2767 if (result->GetRowCount() == 0)
2769 Printf("ERROR: Run %d not found", run);
2774 TSQLRow* row = result->Next();
2777 Printf("ERROR: Could not receive data from run %d", run);
2782 TString timeStartString(row->GetField(0));
2783 TString runType(row->GetField(1));
2784 TString detectorMaskString(row->GetField(2));
2785 TString l3CurrentString(row->GetField(3));
2786 TString dipoleCurrentString(row->GetField(4));
2787 TString beamTypeString(row->GetField(5));
2788 time_t timeStart = (time_t)(timeStartString.Atoi());
2789 UInt_t detectorMask = (UInt_t)(detectorMaskString.Atoi());
2790 Float_t l3Current = (Float_t)(TMath::Abs(l3CurrentString.Atof()));
2791 Float_t dipoleCurrent = (Float_t)(TMath::Abs(dipoleCurrentString.Atof()));
2792 Char_t l3Polarity = (l3CurrentString.Atof() < 0) ? 1 : 0;
2793 Char_t dipolePolarity = (dipoleCurrentString.Atof() < 0) ? 1 : 0;
2794 if (beamTypeString.CompareTo("Pb-Pb",TString::kIgnoreCase) == 0){
2795 beamTypeString="A-A";
2798 AliGRPObject * grpObj = new AliGRPObject();
2799 grpObj->SetTimeStart(timeStart);
2800 grpObj->SetRunType((TString)(row->GetField(1)));
2801 grpObj->SetDetectorMask(detectorMask);
2802 grpObj->SetL3Current(l3Current,(AliGRPObject::Stats)0);
2803 grpObj->SetDipoleCurrent(dipoleCurrent,(AliGRPObject::Stats)0);
2804 grpObj->SetL3Polarity(l3Polarity);
2805 grpObj->SetDipolePolarity(dipolePolarity);
2806 grpObj->SetPolarityConventionLHC(); // after the dipole cables swap we comply with LHC convention
2807 grpObj->SetBeamType(beamTypeString);
2815 Printf("Storing GRP/GRP/Data object with the following content");
2818 AliCDBMetaData metadata;
2819 metadata.SetResponsible("Jan Fiete Grosse-Oetringhaus & Chiara Zampolli");
2820 metadata.SetComment("GRP Output parameters received during online running");
2822 AliCDBId id("GRP/GRP/Data", run, run);
2823 Bool_t success = cdb->Put(grpObj, id, &metadata);
2829 Printf("ERROR: Could not store GRP/GRP/Data into OCDB");
2833 // Receive trigger information
2834 sqlQuery.Form("SELECT configFile FROM logbook_trigger_config WHERE run = %d", run);
2835 result = server->Query(sqlQuery);
2838 Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
2842 if (result->GetRowCount() == 0)
2844 Printf("ERROR: Run %d not found in logbook_trigger_config", run);
2849 row = result->Next();
2852 Printf("ERROR: Could not receive logbook_trigger_config data from run %d", run);
2857 TString triggerConfig(row->GetField(0));
2865 Printf("Found trigger configuration: %s", triggerConfig.Data());
2867 AliTriggerConfiguration *runcfg = AliTriggerConfiguration::LoadConfigurationFromString(triggerConfig);
2870 Printf("ERROR: Could not create CTP configuration object");
2874 metadata.SetComment("CTP run configuration received during online running");
2876 AliCDBId id2("GRP/CTP/Config", run, run);
2877 success = cdb->Put(runcfg, id2, &metadata);
2884 Printf("ERROR: Could not store GRP/CTP/Config into OCDB");
2889 // Receive list of GDCs for this run
2890 sqlQuery.Form("SELECT GDC FROM logbook_stats_GDC WHERE run = %d", run);
2891 result = server->Query(sqlQuery);
2894 Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
2898 if (result->GetRowCount() == 0)
2900 Printf("ERROR: Run %d not found in logbook_stats_GDC", run);
2906 for (Int_t iGDC = 0; iGDC < result->GetRowCount(); iGDC++) {
2907 row = result->Next();
2910 Printf("ERROR: Could not receive logbook_stats_GDC data from run %d", run);
2914 gdc += row->GetField(0);
2924 Printf("Found GDC: %s", gdc.Data());
2926 // get last run with same run type that was already processed by the SHUTTLE
2928 sqlQuery.Form("SELECT max(logbook.run) FROM logbook LEFT JOIN logbook_shuttle ON logbook_shuttle.run = logbook.run WHERE run_type = '%s' AND shuttle_done = 1", runType.Data());
2929 result = server->Query(sqlQuery);
2932 Printf("ERROR: Can't execute query <%s>!", sqlQuery.Data());
2936 if (result->GetRowCount() == 0)
2938 Printf("ERROR: No result with query <%s>", sqlQuery.Data());
2943 row = result->Next();
2946 Printf("ERROR: Could not receive data for query <%s>", sqlQuery.Data());
2951 TString lastRunStr(row->GetField(0));
2952 Int_t lastRun = lastRunStr.Atoi();
2954 Printf("Last run with same run type %s is %d", runType.Data(), lastRun);
2968 //------------------------------------------------------------------------------------------------------
2969 Float_t AliGRPPreprocessor::ProcessEnergy(TObjArray* const array, Double_t timeStart){
2972 // Method to processo LHC Energy information
2973 // Only the first value is returned, provided that it is withing DAQ_time_start and DAQ_time_end
2976 Int_t nCounts = array->GetEntries();
2977 Float_t energy = -1;
2978 Double_t timeEnergy = -1;
2979 Int_t indexEnergy = -1;
2980 Bool_t foundEnergy = kFALSE;
2982 AliDebug(2,Form("Energy measurements = %d\n",nCounts));
2984 AliWarning("No Energy values found! Beam Energy remaining invalid!");
2987 for (Int_t i = 0; i < nCounts; i++){
2988 AliDCSArray *dcs = (AliDCSArray*)array->At(i);
2990 if (dcs->GetTimeStamp()<=timeStart && dcs->GetTimeStamp()>=timeEnergy){// taking always the very last entry: of two measurements have the same timestamp, the last one is taken
2991 timeEnergy = dcs->GetTimeStamp();
2993 foundEnergy = kTRUE;
3001 AliInfo("No value for the Energy found before start of run, the Energy will remain invalid");
3004 AliDCSArray* dcs = (AliDCSArray*)array->At(indexEnergy);
3005 energy = (Float_t)(TMath::Nint(((Double_t)(dcs->GetInt(0)))*120/1000)); // sqrt(s)/2 energy in GeV
3006 AliInfo(Form("Energy value found = %d (at %f), converting --> sqrt(s)/2 = %f (GeV)", dcs->GetInt(0),dcs->GetTimeStamp(),energy));
3012 //------------------------------------------------------------------------------------------------------
3013 AliLHCClockPhase* AliGRPPreprocessor::ProcessLHCClockPhase(TObjArray *beam1phase,TObjArray *beam2phase, Double_t timeEnd)
3016 // Method to process LHC-Clock Phase data
3017 // Only the values between DAQ_time_start and DAQ_time_end are kept
3019 AliLHCClockPhase *phaseObj = new AliLHCClockPhase;
3021 Bool_t foundBeam1Phase = kFALSE, foundBeam2Phase = kFALSE;
3022 const Float_t threshold = 0.050; // we store the measurement only in case they differ with more 50ps from the previous one
3024 TString timeCreatedStr = GetRunParameter("time_created");
3025 Double_t timeCreated = timeCreatedStr.Atof();
3027 Int_t nCounts = beam1phase->GetEntries();
3028 AliDebug(2,Form("Beam1 phase measurements = %d\n",nCounts));
3030 AliWarning("No beam1 LHC clock phase values found!");
3035 Double_t prevPhase = 0;
3036 for (Int_t i = 0; i < nCounts; i++){
3037 AliDCSArray *dcs = (AliDCSArray*)beam1phase->At(i);
3039 //if (dcs->GetTimeStamp()>=timeStart && dcs->GetTimeStamp()<=timeEnd) {
3040 if (dcs->GetTimeStamp()>=timeCreated && dcs->GetTimeStamp()<=timeEnd) {
3041 if ((i == 0) || (i == (nCounts-1)) ||
3043 (TMath::Abs(dcs->GetDouble(0)-prevPhase) > threshold)) {
3044 prevPhase = dcs->GetDouble(0);
3045 foundBeam1Phase = kTRUE;
3046 AliInfo(Form("B1 Clk Phase = %f at TS = %f",
3047 (Float_t)dcs->GetDouble(0),dcs->GetTimeStamp()));
3048 phaseObj->AddPhaseB1DP((UInt_t)dcs->GetTimeStamp(),(Float_t)dcs->GetDouble(0));
3053 if (!foundBeam1Phase){
3054 AliError("No beam1 LHC clock phase values found within the run!");
3060 nCounts = beam2phase->GetEntries();
3061 AliDebug(2,Form("Beam2 phase measurements = %d\n",nCounts));
3063 AliWarning("No beam2 LHC clock phase values found!");
3068 Double_t prevPhase = 0;
3069 for (Int_t i = 0; i < nCounts; i++){
3070 AliDCSArray *dcs = (AliDCSArray*)beam2phase->At(i);
3072 if (dcs->GetTimeStamp()>=timeCreated && dcs->GetTimeStamp()<=timeEnd) {
3073 if ((i == 0) || (i == (nCounts-1)) ||
3075 (TMath::Abs(dcs->GetDouble(0)-prevPhase) > threshold)) {
3076 prevPhase = dcs->GetDouble(0);
3077 foundBeam2Phase = kTRUE;
3078 AliInfo(Form("B2 Clk Phase = %f at TS = %f",
3079 (Float_t)dcs->GetDouble(0),dcs->GetTimeStamp()));
3080 phaseObj->AddPhaseB2DP((UInt_t)dcs->GetTimeStamp(),(Float_t)dcs->GetDouble(0));
3085 if (!foundBeam2Phase){
3086 AliError("No beam2 LHC clock phase values found within the run!");