New treatment of the beam type in the AliGRPObject (with corresponding changes in...
authorzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Nov 2011 12:48:44 +0000 (12:48 +0000)
committerzampolli <zampolli@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 14 Nov 2011 12:48:44 +0000 (12:48 +0000)
AliGRPObject::GetBeamType() --> returns "A-A", "p-p", "p-A", as needed for the reconstruction
ALiGRPObject::GetBeamTypeFromLHC --> returns string containing EXACTLY what is published by LHC (e.g. "PB82-PB82")
AliGRPObject::GetSingleBeamType(Int_t i) --> returns the beam type for each beam, defined as a string with the convention: beam type = A*1000+Z

STEER/STEER/AliGRPObject.cxx
STEER/STEER/AliGRPObject.h
STEER/STEER/AliGRPPreprocessor.cxx
STEER/STEER/AliGRPPreprocessor.h

index 650db5f..cda3c28 100644 (file)
@@ -113,7 +113,8 @@ AliGRPObject::AliGRPObject():
        fQACloningRequest(0x0),
        fMaxTimeLHCValidity(0),
        fNFalseDataQualityFlag(0),
-       fFalseDataQualityFlag(0x0)
+       fFalseDataQualityFlag(0x0),
+       fBeamTypeFromLHC(fgkInvalidString)
 {
 
        //
@@ -182,7 +183,8 @@ AliGRPObject::AliGRPObject(const AliGRPObject &obj):
        fQACloningRequest(obj.fQACloningRequest),
        fMaxTimeLHCValidity(obj.fMaxTimeLHCValidity),
        fNFalseDataQualityFlag(obj.fNFalseDataQualityFlag),
-       fFalseDataQualityFlag(obj.fFalseDataQualityFlag)
+       fFalseDataQualityFlag(obj.fFalseDataQualityFlag),
+       fBeamTypeFromLHC(obj.fBeamTypeFromLHC)
 
 
 {
@@ -268,6 +270,7 @@ AliGRPObject& AliGRPObject:: operator=(const AliGRPObject & obj)
 
        this->fNFalseDataQualityFlag = obj.fNFalseDataQualityFlag;
        this->fFalseDataQualityFlag = obj.fFalseDataQualityFlag;
+       this->fBeamTypeFromLHC = obj.fBeamTypeFromLHC;
 
        return *this;
 }
index e64f8c6..039bc5b 100644 (file)
@@ -159,7 +159,7 @@ class AliGRPObject : public TObject {
        void ReadValuesFromMap(const TMap* map);        \r
 \r
        void SetSingleBeamType(Int_t ibeamType, TString beamType)  {fSeparateBeamType[ibeamType] = beamType;}\r
-       TString   GetSingleBeamType(Int_t ibeamType) const {return fBeamType[ibeamType];}\r
+       TString   GetSingleBeamType(Int_t ibeamType) const {return fSeparateBeamType[ibeamType];}\r
 \r
        void SetNFalseDataQualityFlag(Int_t nFalses) {fNFalseDataQualityFlag = nFalses;}\r
        Int_t GetNFalseDataQualityFlag() const {return fNFalseDataQualityFlag;}\r
@@ -170,6 +170,9 @@ class AliGRPObject : public TObject {
        Double_t GetStartFalseDataQualityFlag(Int_t iperiod) const;\r
        Double_t GetEndFalseDataQualityFlag(Int_t iperiod) const;\r
 \r
+       void SetBeamTypeFromLHC(TString beamTypeFromLHC)  {fBeamTypeFromLHC = beamTypeFromLHC;}\r
+       TString   GetBeamTypeFromLHC() const {return fBeamTypeFromLHC;}\r
+\r
  private:\r
 \r
        static const Float_t fgkInvalidFloat;   // value to identify invalid data - float\r
@@ -219,8 +222,9 @@ class AliGRPObject : public TObject {
        Int_t fNFalseDataQualityFlag;    // number of times the data quality flag turned to FALSE\r
        TArrayD* fFalseDataQualityFlag;  // array of starts (even positions) and ends (odd poistions) of the periods\r
                                         // when the data quality flag was FALSE\r
+       TString fBeamTypeFromLHC;        // string containing the information about the beam types AS SENT BY LHC (in the form "beam1-beam2")\r
        \r
-       ClassDef(AliGRPObject,9)\r
+       ClassDef(AliGRPObject,10)\r
 \r
 };\r
 \r
index 8d5af0a..b71e5dc 100644 (file)
@@ -30,6 +30,7 @@
 #include <TObjArray.h>
 #include <TGraph.h>
 #include <TString.h>
+#include <TPRegexp.h>
 #include <TFile.h>
 
 #include <float.h>
@@ -981,7 +982,8 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                // BeamType1 and BeamType2 - in separete string
                Log("*************BeamType, 1 and 2 ");
                Int_t indexBeamTypeString = 6;  // index of the string with the alias of BeanType1 in the array fgkLHCDataPoints
-               TString combinedBeamType = "-";  // combined beam tyope, built from beam type 1 and beam type 2
+               TString combinedBeamType = "-";  // combined beam type, built from beam type 1 and beam type 2
+               TString combinedBeamTypeFromLHC = "-";  // combined beam type, built from beam type 1 and beam type 2 AS SENT FROM LHC
                for (Int_t ibeamType = 0; ibeamType<2; ibeamType++){
                        beamArray = lhcReader.ReadSingleLHCDP(fileName.Data(),fgkLHCDataPoints[indexBeamTypeString+ibeamType]);
                        if (beamArray){                 
@@ -1010,19 +1012,22 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                                                AliDCSArray* beam = (AliDCSArray*)beamArray->At(indexBeam);
                                                TObjString* beamString = beam->GetStringArray(0);
                                                TString beamType = beamString->String();
-                                               AliInfo(Form("Beam Type (for %s) = %s", fgkLHCDataPoints[indexBeamTypeString+ibeamType], beamType.Data()));     
+                                               AliInfo(Form("Beam Type (for %s) = %s", fgkLHCDataPoints[indexBeamTypeString+ibeamType], beamType.Data()));
+                                               TString singleBeam = ParseBeamTypeString(beamType,ibeamType);
+                                               AliInfo(Form("Single Beam Type for beam %d set to %s", ibeamType, singleBeam.Data()));
+                                               grpobj->SetSingleBeamType(ibeamType, singleBeam);
                                                if (beamType.CompareTo("PROTON",TString::kIgnoreCase) == 0){
-                                                       AliInfo(Form("Setting beam type %s to p", fgkLHCDataPoints[indexBeamTypeString+ibeamType]));
-                                                       grpobj->SetSingleBeamType(ibeamType,"p");
-                                                       if (ibeamType == 0) combinedBeamType.Prepend("p");
+                                                       AliInfo(Form("Setting beam %d for combined beam type to p", ibeamType));
+                                                       if (ibeamType == 0) combinedBeamType.Prepend("p"); 
                                                        else combinedBeamType.Append("p");
                                                }
                                                else { // if there is no PROTON beam, we suppose it is Pb, and we put A-A
-                                                       AliInfo("Setting beam type to A");
-                                                       grpobj->SetSingleBeamType(ibeamType,"A");
+                                                       AliInfo(Form("Setting beam %d for combined beam type to A",ibeamType));
                                                        if (ibeamType == 0) combinedBeamType.Prepend("A");
                                                        else combinedBeamType.Append("A");
                                                }
+                                               if (ibeamType == 0) combinedBeamTypeFromLHC.Prepend(beamType); 
+                                               else combinedBeamTypeFromLHC.Append(beamType);
                                                /*
                                                  else if (beamType.CompareTo("LEAD82",TString::kIgnoreCase) == 0){
                                                  AliInfo("Setting beam type to Pb-Pb");
@@ -1060,6 +1065,8 @@ UInt_t AliGRPPreprocessor::ProcessLHCData(AliGRPObject *grpobj)
                }
                AliInfo(Form("Setting combined beam type to %s",combinedBeamType.Data()));
                grpobj->SetBeamType(combinedBeamType);
+               AliInfo(Form("Setting combined beam type form LHC to %s",combinedBeamTypeFromLHC.Data()));
+               grpobj->SetBeamTypeFromLHC(combinedBeamTypeFromLHC);
                
                // Setting minTimeLHCValidity
                if (flagBeamMode == kTRUE || flagMachineMode == kTRUE || flagBeam == kTRUE || flagBeamType[0] == kTRUE || flagBeamType[1] == kTRUE){ 
@@ -3111,3 +3118,50 @@ AliLHCClockPhase* AliGRPPreprocessor::ProcessLHCClockPhase(TObjArray *beam1phase
 
   return phaseObj;
 }
+//------------------------------------------------------------------------------------------------------
+TString AliGRPPreprocessor::ParseBeamTypeString(TString beamType, Int_t iBeamType)
+{
+       // Method to return the convention for the separate beam type
+       // in the form A*1000+Z
+       // e.g.: Pb82 --> 208000 + 82 = 208082
+       //       p --> 1000 + 1 = 1001
+
+       Int_t a = 0;
+       Int_t z = 0;
+       TString separateString("");
+       Log(Form("Setting Beam Type for beam %d to A*1000+Z",iBeamType));
+       if (beamType.CompareTo("PROTON",TString::kIgnoreCase) == 0){
+               Log(Form("Beam type %d is PROTON --> The single beam type will be set to 1001 (A = 1, Z = 1)",iBeamType));
+               separateString = "1001";
+               return separateString;
+       }
+       else { 
+               TPRegexp regexpA("\\D+");
+               TPRegexp regexpZ("\\d+");
+               TObjArray* arrayA = regexpA.MatchS(beamType);
+               TObjArray* arrayZ = regexpZ.MatchS(beamType);
+               if (arrayA->GetEntries() != 1 || arrayZ->GetEntries() != 1){
+                       Log(Form("The beamType string for beam %d does not contain the necessary information! Returning the info as published by LHC (i.e. %s)",iBeamType, beamType.Data()));
+                       return beamType;
+               }
+               else{
+                       TString strA = ((TObjString*)(arrayA->At(0)))->String();
+                       TString strZ = ((TObjString*)(arrayZ->At(0)))->String();
+                       if (strA.CompareTo("LEAD",TString::kIgnoreCase) == 0 || strA.CompareTo("PB",TString::kIgnoreCase) == 0){
+                               Log(Form("Beam %d is %s --> A = 208",iBeamType, strA.Data()));
+                               a = 208;
+                       }
+                       else{
+                               Log(Form("This beam was not foreseen so far, leaving A=0"));
+                       }
+                       z = strZ.Atoi();
+                       Log(Form("Beam %d has Z = %d",iBeamType, z));
+                       separateString = Form("%d",a*1000+z);
+                       return separateString;
+               }                                            
+       }
+              
+       return separateString;
+
+}
+           
index da9ff1b..7ba30ba 100644 (file)
@@ -108,7 +108,8 @@ class AliGRPPreprocessor: public AliPreprocessor {
    Float_t ProcessEnergy(TObjArray* array, Double_t timeStart);
    AliLHCClockPhase* ProcessLHCClockPhase(TObjArray *beam1phase,TObjArray *beam2phase,
                                          Double_t timeEnd);
-
+   TString ParseBeamTypeString(TString beamType, Int_t iBeamType);
+   
  private:
  
   static const Int_t   fgknDAQLbPar;            //! number of DAQ lb parameters for PHYSICS runs