]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Implementation of a function to parse the LHC data file only for a specific
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Apr 2010 14:59:56 +0000 (14:59 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Apr 2010 14:59:56 +0000 (14:59 +0000)
entry --> returning a TObjArray.
Corresponding changes in the GRP preprocessor.

STEER/AliGRPPreprocessor.cxx
STEER/AliLHCReader.cxx
STEER/AliLHCReader.h

index f3ad733c7d0a6d6c20d042cabc04e193d7b8b275..b5a658e6cce389bc7e8dcc75649326b0b2f4c49b 100644 (file)
@@ -618,134 +618,162 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
        if (fileName.Length()>0){
                AliInfo("Got The LHC Data file");
                AliLHCReader lhcReader;
-               TMap* lhcMap = (TMap*)lhcReader.ReadLHCDP(fileName.Data());
-               if (lhcMap) {
-                       Log(Form("LHCData map entries = %d",lhcMap->GetEntries()));
-                       
-                       // Processing data to be put in AliGRPObject
-                       // Energy
-                       TObjArray* energyArray = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[0]);
-                       if (energyArray){                       
-                               Float_t energy = ProcessEnergy(energyArray,timeStart,timeEnd);
-                               if (energy != -1) {
-                                       grpobj->SetBeamEnergy(energy);
-                                       grpobj->SetBeamEnergyIsSqrtSHalfGeV(kTRUE);
-                               }
+
+               // Processing data to be put in AliGRPObject
+
+               // Energy
+               TObjArray* energyArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[0]);
+               if (energyArray){                       
+                       Float_t energy = ProcessEnergy(energyArray,timeStart,timeEnd);
+                       if (energy != -1) {
+                               grpobj->SetBeamEnergy(energy);
+                               grpobj->SetBeamEnergyIsSqrtSHalfGeV(kTRUE);
                        }
-                       else {
-                               AliError("Energy not found in LHC Data file!!!");
-                       }       
-                       Double_t timeBeamMode = 0;
-                       Double_t timeMachineMode = 0;
-                       Double_t timeBeam = 0;
-                       Bool_t flagBeamMode = kFALSE;  //flag set true if at least one BeamMode measurement is found within DAQ_time_start and DAQ_time_end
-                       Bool_t flagMachineMode = kFALSE;  //flag set true if at least one MachineMode measurement is found within DAQ_time_start and DAQ_time_end
-                       Bool_t flagBeam = kFALSE;  //flag set true if at least one Beam Type measurement is found within DAQ_time_start and DAQ_time_end
-
-                       // BeamMode
-                       TObjArray* beamModeArray = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[2]);
-                       Int_t nBeamMode = -1;
-                       if (beamModeArray){     
-                               nBeamMode = beamModeArray->GetEntries();        
-                               if (nBeamMode==0){
-                                       AliInfo("Found zero entries for  the Beam Mode, leaving it empty");
+                       delete energyArray;
+               }
+               else {
+                       AliError("Energy not found in LHC Data file!!!");
+               }       
+
+               Double_t timeBeamMode = 0;
+               Double_t timeMachineMode = 0;
+               Double_t timeBeam = 0;
+               Bool_t flagBeamMode = kFALSE;  //flag set true if at least one BeamMode measurement is found within DAQ_time_start and DAQ_time_end
+               Bool_t flagMachineMode = kFALSE;  //flag set true if at least one MachineMode measurement is found within DAQ_time_start and DAQ_time_end
+               Bool_t flagBeam = kFALSE;  //flag set true if at least one Beam Type measurement is found within DAQ_time_start and DAQ_time_end
+               
+               // BeamMode
+               TObjArray* beamModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[2]);
+               Int_t nBeamMode = -1;
+               if (beamModeArray){     
+                       nBeamMode = beamModeArray->GetEntries();        
+                       if (nBeamMode==0){
+                               AliInfo("Found zero entries for  the Beam Mode, leaving it empty");
+                       }
+                       else{
+                               if (nBeamMode==1){
+                                       AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(0);
+                                       if (beamMode->GetTimeStamp()>=timeStart && beamMode->GetTimeStamp()<=timeEnd){
+                                               TObjString* beamModeString = beamMode->GetStringArray(0);
+                                               AliInfo(Form("LHC State (corresponding to BeamMode) = %s",(beamModeString->String()).Data()));
+                                               grpobj->SetLHCState(beamModeString->String());
+                                       }
+                                       else{
+                                               AliInfo("No Beam Mode found within DAQ_time_start and DAQ_time_end, leaving it empty");
+                                       }
                                }
-                               else{
-                                       if (nBeamMode==1){
-                                               AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(0);
+                               else {
+                                       for (Int_t iBeamMode = 0; iBeamMode<nBeamMode; iBeamMode++){
+                                               AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(iBeamMode);
                                                if (beamMode->GetTimeStamp()>=timeStart && beamMode->GetTimeStamp()<=timeEnd){
+                                                       AliDCSArray* beamMode1 = (AliDCSArray*)beamModeArray->At(iBeamMode+1);
+                                                       if (beamMode1->GetTimeStamp()>=timeStart && beamMode1->GetTimeStamp()<=timeEnd){
+                                                               timeBeamMode = beamMode1->GetTimeStamp();
+                                                               AliWarning(Form("The beam mode changed at timestamp %f! Setting it to the first value found and keeping track of the time of the change to set MaxTimeLHCValidity afterward",timeBeamMode));
+                                                       }
                                                        TObjString* beamModeString = beamMode->GetStringArray(0);
                                                        AliInfo(Form("LHC State (corresponding to BeamMode) = %s",(beamModeString->String()).Data()));
                                                        grpobj->SetLHCState(beamModeString->String());
-                                               }
-                                               else{
-                                                       AliInfo("No Beam Mode found within DAQ_time_start and DAQ_time_end, leaving it empty");
+                                                       flagBeamMode = kTRUE;
+                                                       break;
                                                }
                                        }
-                                       else {
-                                               for (Int_t iBeamMode = 0; iBeamMode<nBeamMode; iBeamMode++){
-                                                       AliDCSArray* beamMode = (AliDCSArray*)beamModeArray->At(iBeamMode);
-                                                       if (beamMode->GetTimeStamp()>=timeStart && beamMode->GetTimeStamp()<=timeEnd){
-                                                               AliDCSArray* beamMode1 = (AliDCSArray*)beamModeArray->At(iBeamMode+1);
-                                                               if (beamMode1->GetTimeStamp()>=timeStart && beamMode1->GetTimeStamp()<=timeEnd){
-                                                                       timeBeamMode = beamMode1->GetTimeStamp();
-                                                                       AliWarning(Form("The beam mode changed at timestamp %f! Setting it to the first value found and keeping track of the time of the change to set MaxTimeLHCValidity afterward",timeBeamMode));
-                                                               }
-                                                               TObjString* beamModeString = beamMode->GetStringArray(0);
-                                                               AliInfo(Form("LHC State (corresponding to BeamMode) = %s",(beamModeString->String()).Data()));
-                                                               grpobj->SetLHCState(beamModeString->String());
-                                                               flagBeamMode = kTRUE;
-                                                               break;
-                                                       }
-                                               }
-                                               if (!flagBeamMode){
-                                                       AliError("Found values for BeamMode, but none within DAQ_time_start and DAQ_time_end, leaving it empty");
-                                               }
+                                       if (!flagBeamMode){
+                                               AliError("Found values for BeamMode, but none within DAQ_time_start and DAQ_time_end, leaving it empty");
                                        }
                                }
                        }
-                       else{
-                               AliError("Beam mode array not found in LHC Data file!!!");
+                       delete beamModeArray;
+               }
+               else{
+                       AliError("Beam mode array not found in LHC Data file!!!");
+               }
+               
+               // MachineMode
+               TObjArray* machineModeArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[1]);
+               Int_t nMachineMode = -1;
+               if (machineModeArray){
+                       nMachineMode = machineModeArray->GetEntries();
+                       if (nMachineMode==0){
+                               AliInfo("No Machine Mode found, leaving it empty");
                        }
-
-                       // MachineMode
-                       TObjArray* machineModeArray = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[1]);
-                       Int_t nMachineMode = -1;
-                       if (machineModeArray){
-                               nMachineMode = machineModeArray->GetEntries();
-                               if (nMachineMode==0){
-                                       AliInfo("No Machine Mode found, leaving it empty");
+                       else{
+                               if (nMachineMode ==1) {
+                                       AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(0);
+                                       if (machineMode->GetTimeStamp()>=timeStart && machineMode->GetTimeStamp()<=timeEnd){
+                                               TObjString* machineModeString = machineMode->GetStringArray(0);
+                                               AliInfo(Form("Machine Mode = %s",(machineModeString->String()).Data()));
+                                               grpobj->SetMachineMode(machineModeString->String());
+                                       }
+                                       else{
+                                               AliInfo("No Machine Mode found within DAQ_time_start and DAQ_time_end, leaving it empty");
+                                       }
                                }
-                               else{
-                                       if (nMachineMode ==1) {
-                                               AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(0);
+                               else {
+                                       for (Int_t iMachineMode = 0; iMachineMode<nMachineMode; iMachineMode++){
+                                               AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(iMachineMode);
                                                if (machineMode->GetTimeStamp()>=timeStart && machineMode->GetTimeStamp()<=timeEnd){
+                                                       AliDCSArray* machineMode1 = (AliDCSArray*)machineModeArray->At(iMachineMode+1);
+                                                       if (machineMode1->GetTimeStamp()>=timeStart && machineMode1->GetTimeStamp()<=timeEnd){
+                                                               timeMachineMode = machineMode1->GetTimeStamp();
+                                                               AliWarning(Form("The machine mode changed at timestamp %f! Setting it to the first value found and keeping track of the time of the change to set MaxTimeLHCValidity afterwards",timeMachineMode));
+                                                       }
                                                        TObjString* machineModeString = machineMode->GetStringArray(0);
-                                                       AliInfo(Form("Machine Mode = %s",(machineModeString->String()).Data()));
+                                                       AliInfo(Form("Machine mode = %s",(machineModeString->String()).Data()));
                                                        grpobj->SetMachineMode(machineModeString->String());
+                                                       flagMachineMode = kTRUE;
+                                                       break;
+                                               }
+                                       }
+                                       if (!flagMachineMode){
+                                               AliError("Found values for MachineMode, but none within DAQ_time_start and DAQ_time_end, setting MachineMode to UNKNOWN");
+                                               grpobj->SetMachineMode("UNKONWN");
+                                       }
+                               }
+                       }
+                       delete machineModeArray;
+               }
+               else {
+                       AliError("Machine mode array not found in LHC Data file!!!");
+               }       
+               
+               // BeamType1 and BeamType2 - both put in the same string
+               TObjArray* beamArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[3]);
+               if (beamArray){                 
+                       Int_t nBeam = beamArray->GetEntries();
+                       if (nBeam==0){
+                               AliInfo("No Beam Type found, leaving it empty");
+                       }
+                       else{
+                               if (nBeam == 1){
+                                       AliDCSArray* beam = (AliDCSArray*)beamArray->At(0);
+                                       if (beam->GetTimeStamp()>=timeStart && beam->GetTimeStamp()<=timeEnd){
+                                               TObjString* beamString = beam->GetStringArray(0);
+                                               TString beamType = beamString->String();
+                                               AliInfo(Form("Beam Type = %s",beamType.Data()));        
+                                               if (beamType.CompareTo("PROTON",TString::kIgnoreCase)){
+                                                       grpobj->SetBeamType("p-p");
+                                               }
+                                               else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase)){
+                                                       grpobj->SetBeamType("Pb-Pb");
                                                }
                                                else{
-                                                       AliInfo("No Machine Mode found within DAQ_time_start and DAQ_time_end, leaving it empty");
+                                                       AliError("Beam Type not known, leaving it empty");
                                                }
                                        }
                                        else {
-                                               for (Int_t iMachineMode = 0; iMachineMode<nMachineMode; iMachineMode++){
-                                                       AliDCSArray* machineMode = (AliDCSArray*)machineModeArray->At(iMachineMode);
-                                                       if (machineMode->GetTimeStamp()>=timeStart && machineMode->GetTimeStamp()<=timeEnd){
-                                                               AliDCSArray* machineMode1 = (AliDCSArray*)machineModeArray->At(iMachineMode+1);
-                                                               if (machineMode1->GetTimeStamp()>=timeStart && machineMode1->GetTimeStamp()<=timeEnd){
-                                                                       timeMachineMode = machineMode1->GetTimeStamp();
-                                                                       AliWarning(Form("The machine mode changed at timestamp %f! Setting it to the first value found and keeping track of the time of the change to set MaxTimeLHCValidity afterwards",timeMachineMode));
-                                                               }
-                                                               TObjString* machineModeString = machineMode->GetStringArray(0);
-                                                               AliInfo(Form("Machine mode = %s",(machineModeString->String()).Data()));
-                                                               grpobj->SetMachineMode(machineModeString->String());
-                                                               flagMachineMode = kTRUE;
-                                                               break;
-                                                       }
-                                               }
-                                               if (!flagMachineMode){
-                                                       AliError("Found values for MachineMode, but none within DAQ_time_start and DAQ_time_end, setting MachineMode to UNKNOWN");
-                                                       grpobj->SetMachineMode("UNKONWN");
-                                               }
+                                               AliInfo("No Beam Type found within DAQ_time_start and DAQ_time_end, leaving it empty");
                                        }
                                }
-                       }
-                       else {
-                               AliError("Machine mode array not found in LHC Data file!!!");
-                       }       
-
-                       // BeamType1 and BeamType2 - both put in the same string
-                       TObjArray* beamArray = (TObjArray*)lhcMap->GetValue(fgkLHCDataPoints[3]);
-                       if (beamArray){                 
-                               Int_t nBeam = beamArray->GetEntries();
-                               if (nBeam==0){
-                                       AliInfo("No Beam Type found, leaving it empty");
-                               }
                                else{
-                                       if (nBeam == 1){
-                                               AliDCSArray* beam = (AliDCSArray*)beamArray->At(0);
+                                       for (Int_t iBeam=0; iBeam<nBeam; iBeam++){
+                                               AliDCSArray* beam = (AliDCSArray*)beamArray->At(iBeam);
                                                if (beam->GetTimeStamp()>=timeStart && beam->GetTimeStamp()<=timeEnd){
+                                                       AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(iBeam+1);
+                                                       if (beam1->GetTimeStamp()>=timeStart && beam1->GetTimeStamp()<=timeEnd){
+                                                               timeBeam = beam1->GetTimeStamp();
+                                                               AliWarning(Form("The Beam Type changed at timestamp %f! Setting it to the first value found and keeping track of the time of the change to set MaxTimeLHCValidity afterwards",timeBeam));
+                                                       }
                                                        TObjString* beamString = beam->GetStringArray(0);
                                                        TString beamType = beamString->String();
                                                        AliInfo(Form("Beam Type = %s",beamType.Data()));        
@@ -758,76 +786,56 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                                        else{
                                                                AliError("Beam Type not known, leaving it empty");
                                                        }
-                                               }
-                                               else {
-                                                       AliInfo("No Beam Type found within DAQ_time_start and DAQ_time_end, leaving it empty");
+                                                       flagBeam = kTRUE;
+                                                       break;
                                                }
                                        }
-                                       else{
-                                               for (Int_t iBeam=0; iBeam<nBeam; iBeam++){
-                                                       AliDCSArray* beam = (AliDCSArray*)beamArray->At(iBeam);
-                                                       if (beam->GetTimeStamp()>=timeStart && beam->GetTimeStamp()<=timeEnd){
-                                                               AliDCSArray* beam1 = (AliDCSArray*)beamArray->At(iBeam+1);
-                                                               if (beam1->GetTimeStamp()>=timeStart && beam1->GetTimeStamp()<=timeEnd){
-                                                                       timeBeam = beam1->GetTimeStamp();
-                                                                       AliWarning(Form("The Beam Type changed at timestamp %f! Setting it to the first value found and keeping track of the time of the change to set MaxTimeLHCValidity afterwards",timeBeam));
-                                                               }
-                                                               TObjString* beamString = beam->GetStringArray(0);
-                                                               TString beamType = beamString->String();
-                                                               AliInfo(Form("Beam Type = %s",beamType.Data()));        
-                                                               if (beamType.CompareTo("PROTON",TString::kIgnoreCase)){
-                                                                       grpobj->SetBeamType("p-p");
-                                                               }
-                                                               else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase)){
-                                                                       grpobj->SetBeamType("Pb-Pb");
-                                                               }
-                                                               else{
-                                                                       AliError("Beam Type not known, leaving it empty");
-                                                               }
-                                                               flagBeam = kTRUE;
-                                                               break;
-                                                       }
-                                               }
-                                               if (!flagBeam){
-                                                       AliError("Found values for Beam Type, but none within DAQ_time_start and DAQ_time_end, leaving it empty");
-                                               }
+                                       if (!flagBeam){
+                                               AliError("Found values for Beam Type, but none within DAQ_time_start and DAQ_time_end, leaving it empty");
                                        }
                                }
                        }
-                       else{
-                               AliError("BeamType array not found in LHC data file!!!");
-                       }                       
-                       
-                       // Setting minTimeLHCValidity
-                       if (timeBeamMode!=0 || timeMachineMode!=0 || timeBeam !=0){
-                               Double_t minTimeLHCValidity;
-                               if (timeBeamMode == 0 && timeMachineMode == 0 && timeBeam != 0){ // timeBeam only != 0
-                                       minTimeLHCValidity = timeBeam;
-                               }
-                               else if (timeBeamMode == 0 && timeMachineMode != 0 && timeBeam == 0){ // timeMachineMode only != 0
-                                       minTimeLHCValidity = timeMachineMode;
-                               }
-                               else if (timeBeamMode != 0 && timeMachineMode == 0 && timeBeam == 0){ // timeBeamMode only != 0
-                                       minTimeLHCValidity = timeBeamMode;
-                               }
-                               else if (timeBeamMode == 0 && timeMachineMode != 0 && timeBeam != 0){ // timeBeam and timeMachineMode only != 0
-                                       minTimeLHCValidity= TMath::Min(timeBeam,timeMachineMode);
-                               }
-                               else if (timeBeamMode != 0 && timeMachineMode == 0 && timeBeam != 0){ // timeBeam and timeBeamMode only != 0
-                                       minTimeLHCValidity= TMath::Min(timeBeam,timeBeamMode);
-                               }
-                               else if (timeBeamMode != 0 && timeMachineMode != 0 && timeBeam == 0){ // timeMachineMode and timeBeamMode only != 0
-                                       minTimeLHCValidity= TMath::Min(timeMachineMode,timeBeamMode);
-                               }
-                               else {
-                                       Double_t arrayTimes[3] = {timeBeamMode,timeMachineMode,timeBeam};
-                                       minTimeLHCValidity= TMath::MinElement(3,arrayTimes);
-                               }
-                               AliWarning(Form("Setting MaxTimeLHCValidity to %f",minTimeLHCValidity));
-                               grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
+                       delete beamArray;
+               }
+               else{
+                       AliError("BeamType array not found in LHC data file!!!");
+               }                       
+               
+               // Setting minTimeLHCValidity
+               if (timeBeamMode!=0 || timeMachineMode!=0 || timeBeam !=0){
+                       Double_t minTimeLHCValidity;
+                       if (timeBeamMode == 0 && timeMachineMode == 0 && timeBeam != 0){ // timeBeam only != 0
+                               minTimeLHCValidity = timeBeam;
                        }
+                       else if (timeBeamMode == 0 && timeMachineMode != 0 && timeBeam == 0){ // timeMachineMode only != 0
+                               minTimeLHCValidity = timeMachineMode;
+                       }
+                       else if (timeBeamMode != 0 && timeMachineMode == 0 && timeBeam == 0){ // timeBeamMode only != 0
+                               minTimeLHCValidity = timeBeamMode;
+                       }
+                       else if (timeBeamMode == 0 && timeMachineMode != 0 && timeBeam != 0){ // timeBeam and timeMachineMode only != 0
+                               minTimeLHCValidity= TMath::Min(timeBeam,timeMachineMode);
+                       }
+                       else if (timeBeamMode != 0 && timeMachineMode == 0 && timeBeam != 0){ // timeBeam and timeBeamMode only != 0
+                               minTimeLHCValidity= TMath::Min(timeBeam,timeBeamMode);
+                       }
+                       else if (timeBeamMode != 0 && timeMachineMode != 0 && timeBeam == 0){ // timeMachineMode and timeBeamMode only != 0
+                               minTimeLHCValidity= TMath::Min(timeMachineMode,timeBeamMode);
+                       }
+                       else {
+                               Double_t arrayTimes[3] = {timeBeamMode,timeMachineMode,timeBeam};
+                               minTimeLHCValidity= TMath::MinElement(3,arrayTimes);
+                       }
+                       AliWarning(Form("Setting MaxTimeLHCValidity to %f",minTimeLHCValidity));
+                       grpobj->SetMaxTimeLHCValidity(minTimeLHCValidity);
+               }
+               
+               // Processing data to go to AliLHCData object
+
+               TMap* lhcMap = (TMap*)lhcReader.ReadLHCDP(fileName.Data());
+               if (lhcMap) {
+                       Log(Form("LHCData map entries = %d",lhcMap->GetEntries()));
                        
-                       // Processing data to go to AliLHCData object
                        AliLHCData* dt = new AliLHCData(lhcMap,timeStart,timeEnd);
                        
                        // storing AliLHCData in OCDB
@@ -850,12 +858,12 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                        return 2;
                }
        }
-  
+       
        else {
                AliError("No LHCData file found in DCS FXS");
                return 1;
        }
-
+       
 }
 
 //_______________________________________________________________
index 5d24d8f2a1ac302b10be1dbb033577dd200a4ce0..66019fdb519f5cbc0e5c46e6c3d1cf4b5a2f1b99 100644 (file)
@@ -213,6 +213,137 @@ TMap* AliLHCReader::ReadLHCDP(TString filename)
        return mapLHC;
 }
 
+//--------------------------------------------------------------------------
+TObjArray* AliLHCReader::ReadSingleLHCDP(TString filename, TString alias)
+{
+       //
+       // reading the file with the inputs for the selected alias
+       // returning the TObjArray containing the information only for the current alias
+       //
+
+               if( gSystem->AccessPathName( filename.Data() ) ) {
+               AliError(Form( "file (%s) not found", filename.Data() ) );
+               return NULL;
+       }
+
+       TString selection = gSystem->GetFromPipe(Form("grep -P '^\\d+\\s+%s+\\s' %s",alias.Data(), filename.Data()));
+
+       if (selection.Length() == 0) {
+               AliError(Form("Alias %s not fouond in LHC Data file, returning a null pointer",alias.Data()));
+               return NULL;
+       }
+
+       Int_t nline =0;
+
+       TObjArray* tokenslines = selection.Tokenize("\n");
+       Int_t ntokenslines = tokenslines->GetEntriesFast();
+       AliDebug(3,Form("Number of tokenslines = %d",ntokenslines));
+
+       TObjArray* array = new TObjArray(); // array to be returned
+       array->SetOwner(1);
+
+       for (Int_t iline=0; iline<ntokenslines; iline++){
+               TString strLine = ((TObjString*)tokenslines->At(iline))->String();
+               AliDebug(4,Form("***************** line = %s\n",strLine.Data()));
+               TObjArray* tokens = strLine.Tokenize("\t");
+               Int_t ntokens = tokens->GetEntriesFast();
+               AliDebug(3,Form("Number of tokens = %d",ntokens));
+               if (ntokens < 4){  
+                       AliInfo(Form("Wrong number of tokens --> # tokens = %d at line %d",ntokens,nline));
+                       // requiring at least the index of the DP, the DP name, the format, and the number of entries
+                       delete tokens;
+                       continue;
+               }
+               Int_t lhcDPindex = (((TObjString*)tokens->At(0))->String()).Atoi();
+               AliDebug(2,Form("lhcDPindex = %d",lhcDPindex));
+               TObjString* lhcDPname = (TObjString*)tokens->At(1);
+               TString lhcDPtype = ((TObjString*)tokens->At(2))->String();
+               AliDebug(2,Form("lhcDPname = %s",(lhcDPname->String()).Data()));
+               AliDebug(2,Form("lhcDPtype = %s",lhcDPtype.Data()));
+               TObjArray* typeTokens = lhcDPtype.Tokenize(":");
+               if (typeTokens->GetEntriesFast() < 2 ){  
+                       // requiring the the type and the number of elements for each measurement
+                       AliError(Form("The format does not match the expected one, skipping the current line for DP = %s", lhcDPtype.Data()));
+                       delete typeTokens;
+                       delete tokens;
+                       continue;
+               }
+               TString type = ((TObjString*)typeTokens->At(0))->String();
+               AliDebug(2,Form("type = %s",type.Data()));
+               Int_t nelements = (((TObjString*)typeTokens->At(1))->String()).Atoi();
+               AliDebug(2,Form("nelements = %i",nelements));
+               Int_t nentries = (((TObjString*)tokens->At(3))->String()).Atoi();
+               AliDebug(2,Form("nentries = %i",nentries));
+               Int_t nValuesPerEntry = nelements+1;
+               Int_t nfixed = 4; // n. of fixed entries
+               for (Int_t ientry=0; ientry< nentries; ientry ++){
+                       Int_t indextime = nfixed+nValuesPerEntry*ientry+nelements;
+                       TString strTimestamp = ((TObjString*)tokens->At(indextime))->String();
+                       Double_t timestamp = strTimestamp.Atof();
+                       AliDebug(2,Form("Timestamp in unix time = %f (s)",timestamp));
+                       if (fStartTime!=0 && fEndTime!=0 && (fStartTime > timestamp || fEndTime < timestamp)){
+                               // error in case the measurement is not within the data taking time interval
+                               AliError(Form("Timestamp for entry %d of DP %s not in [%d,%d]", ientry, lhcDPtype.Data(),fStartTime,fEndTime));
+                               continue;
+                       }
+                       if (type == "i"){
+                               Int_t* value = new Int_t[nelements];
+                               for (Int_t ielement=0; ielement<nelements; ielement++){
+                                       value[ielement] = (((TObjString*)tokens->At(nfixed+ielement+ientry*nValuesPerEntry))->String()).Atoi();
+                                       AliDebug(2,Form("Value at index %d = %d",nfixed+ielement+ientry*nValuesPerEntry,value[ielement]));
+                               }
+                               AliDCSArray* dcs = new AliDCSArray(nelements,value,timestamp);
+                               array->Add(dcs);
+                               delete[] value;
+                       }
+                       else if (type == "b"){
+                               Bool_t* value = new Bool_t[nelements];
+                               for (Int_t ielement=0; ielement<nelements; ielement++){
+                                       value[ielement] = Bool_t((((TObjString*)tokens->At(nfixed+ielement+ientry*nValuesPerEntry))->String()).Atoi());
+                                       AliDebug(2,Form("Value at index %d = %d",nfixed+ielement+ientry*nValuesPerEntry,Int_t(value[ielement])));
+                               }
+                               AliDCSArray* dcs = new AliDCSArray(nelements,value,timestamp);
+                               array->Add(dcs);
+                               delete[] value;
+                       }
+                       else if (type == "f"){ // the floats should be considered as doubles
+                               Double_t* value = new Double_t[nelements];
+                               for (Int_t ielement=0; ielement<nelements; ielement++){
+                                       TString tempstr = (TString)(((TObjString*)tokens->At(nfixed+ielement+ientry*nValuesPerEntry))->String());
+                                       value[ielement] = (((TObjString*)tokens->At(nfixed+ielement+ientry*nValuesPerEntry))->String()).Atof();
+                                       AliDebug(2,Form("Value at index %d = %f from string %s",nfixed+ielement+ientry*nValuesPerEntry,value[ielement],tempstr.Data()));
+                               } 
+                               AliDCSArray* dcs = new AliDCSArray(nelements,value,timestamp);
+                               array->Add(dcs);
+                               delete[] value;
+                       } 
+                       else if (type == "s"){
+                               TObjArray* value = new TObjArray();
+                               value->SetOwner(1);
+                               for (Int_t ielement=0; ielement<nelements; ielement++){
+                                 TObjString* strobj = (new TObjString(((TObjString*)tokens->At(nfixed+ielement+ientry*nValuesPerEntry))->String()));
+                                       AliDebug(2,Form("Value at index %d = %s",nfixed+ielement+ientry*nValuesPerEntry,(strobj->String()).Data()));
+                                       value->Add(strobj);
+                               }
+                               AliDCSArray* dcs = new AliDCSArray(nelements,value,timestamp);
+                               array->Add(dcs);
+                               delete value;
+                       }
+                       else{
+                               AliError(Form("Non-expected type %s",type.Data()));
+                               delete typeTokens;
+                               delete tokens;  
+                               delete tokenslines;
+                               return NULL;
+                       } 
+               }
+               delete typeTokens;
+               delete tokens;
+       }
+       delete tokenslines;
+       return array;
+}
+
 
 
 
index 8d76419f2023aa3afb83030ea48827bcc63c0e4b..a45a2ef43acabdfb8f524bf071b67f0d94e5fe33 100644 (file)
@@ -15,6 +15,7 @@
 
 class TString;
 class TMap;
+class TObjArray;
 
 #include <TObject.h>
 
@@ -29,6 +30,7 @@ class AliLHCReader : public TObject{
 
        void SetStartTime(UInt_t startTime) {fStartTime=startTime;}
        void SetEndTime(UInt_t endTime) {fEndTime = endTime;}
+       TObjArray* ReadSingleLHCDP(TString filename, TString alias);
 
  private:
        AliLHCReader& operator=(const AliLHCReader *reader); // assignment operator