]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/AliVZEROReconstructor.cxx
Introduction of V0 equalization factors in the ESD and their filling inside the V0...
[u/mrichter/AliRoot.git] / VZERO / AliVZEROReconstructor.cxx
index 4dee93c95f37938b1b6cb2b74d6ce6cf531c0200..440db6e4ed4b72bdbc5b98a25c359833ff72495e 100644 (file)
@@ -52,7 +52,10 @@ AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
                         fESD(0x0),
                         fESDVZEROfriend(0x0),
                         fCalibData(NULL),
+                        fTriggerData(NULL),
                         fTimeSlewing(NULL),
+                        fSaturationCorr(NULL),
+                        fEqFactors(NULL),
                         fCollisionMode(0),
                         fBeamEnergy(0.),
                         fDigitsArray(0)
@@ -86,14 +89,26 @@ AliVZEROReconstructor:: AliVZEROReconstructor(): AliReconstructor(),
 
   for(Int_t i = 0 ; i < 64; ++i) {
     Int_t board = AliVZEROCalibData::GetBoardNumber(i);
-    fTimeOffset[i] = (((Float_t)fCalibData->GetTriggerCountOffset(board)-
-                       (Float_t)fCalibData->GetRollOver(board))*25.0+
+    fTimeOffset[i] = (((Float_t)fCalibData->GetRollOver(board)-
+                      (Float_t)fCalibData->GetTriggerCountOffset(board))*25.0+
                       fCalibData->GetTimeOffset(i)-
                       l1Delay-
                       phase->GetMeanPhase()+
                       delays->GetBinContent(i+1)+
                       kV0Offset);
   }
+
+  AliCDBEntry *entry5 =  AliCDBManager::Instance()->Get("VZERO/Calib/Saturation");
+  if (!entry5) AliFatal("Saturation entry is not found in OCDB !");
+  fSaturationCorr = (TObjArray*)entry5->GetObject();
+
+  AliCDBEntry *entry6 = AliCDBManager::Instance()->Get("VZERO/Trigger/Data");
+  if (!entry6) AliFatal("VZERO trigger config data is not found in OCDB !");
+  fTriggerData = (AliVZEROTriggerData*)entry6->GetObject();
+
+  AliCDBEntry *entry7 = AliCDBManager::Instance()->Get("VZERO/Calib/EqualizationFactors");
+  if (!entry7) AliFatal("VZERO equalization factors are not found in OCDB !");
+  fEqFactors = (TH1F*)entry7->GetObject();
 }
 
 
@@ -201,6 +216,7 @@ void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
     }  
 
     // Filling the global part of esd friend object that is available only for raw data
+    rawStream.FillTriggerBits(fTriggerData);
     fESDVZEROfriend->SetTriggerInputs(rawStream.GetTriggerInputs());
     fESDVZEROfriend->SetTriggerInputsMask(rawStream.GetTriggerInputsMask());
 
@@ -216,6 +232,12 @@ void AliVZEROReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digits
     digitsTree->GetUserInfo()->Add(new TParameter<int>("BGflagsV0A",aBGflagsV0A));
     digitsTree->GetUserInfo()->Add(new TParameter<int>("BGflagsV0C",aBGflagsV0C));
 
+    UShort_t chargeA,chargeC;
+    rawStream.CalculateChargeForCentrTriggers(fTriggerData,chargeA,chargeC);
+    digitsTree->GetUserInfo()->Add(new TParameter<int>("ChargeA",(Int_t)chargeA));
+    digitsTree->GetUserInfo()->Add(new TParameter<int>("ChargeC",(Int_t)chargeC));
+    digitsTree->GetUserInfo()->Add(new TParameter<int>("TriggerInputs",(Int_t)rawStream.GetTriggerInputs()));
+
     digitsTree->Fill();
   }
 
@@ -260,27 +282,35 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
   if (digitsTree->GetUserInfo()->FindObject("BBflagsV0A")) {
     aBBflagsV0A = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BBflagsV0A"))->GetVal();
   }
-  else
-    AliWarning("V0A beam-beam flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+  else {
+    if (esd && (esd->GetEventType() == 7))
+      AliWarning("V0A beam-beam flags not found in digits tree UserInfo!");
+  }
 
   if (digitsTree->GetUserInfo()->FindObject("BBflagsV0C")) {
     aBBflagsV0C = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BBflagsV0C"))->GetVal();
   }
-  else
-    AliWarning("V0C beam-beam flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+  else {
+    if (esd && (esd->GetEventType() == 7))
+      AliWarning("V0C beam-beam flags not found in digits tree UserInfo!");
+  }
 
   if (digitsTree->GetUserInfo()->FindObject("BGflagsV0A")) {
     aBGflagsV0A = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BGflagsV0A"))->GetVal();
   }
-  else
-    AliWarning("V0A beam-gas flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
+  else {
+    if (esd && (esd->GetEventType() == 7))
+      AliWarning("V0A beam-gas flags not found in digits tree UserInfo!");
+  }
 
   if (digitsTree->GetUserInfo()->FindObject("BGflagsV0C")) {
     aBGflagsV0C = ((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("BGflagsV0C"))->GetVal();
   }
-  else
-    AliWarning("V0C beam-gas flags not found in digits tree UserInfo! The flags will not be written to the raw-data stream!");
-  
+  else {
+    if (esd && (esd->GetEventType() == 7))
+      AliWarning("V0C beam-gas flags not found in digits tree UserInfo!");
+  }
+
   // Beam-beam and beam-gas flags (hardware)
   for (Int_t iChannel = 0; iChannel < 64; ++iChannel) {
     if(iChannel < 32) {
@@ -293,6 +323,39 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
     }
   }
 
+  // Fill the trigger charges and bits
+  UShort_t chargeA = 0;
+  UShort_t chargeC = 0;
+  UShort_t triggerInputs = 0;
+  if (digitsTree->GetUserInfo()->FindObject("ChargeA")) {
+    chargeA = (UShort_t)(((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("ChargeA"))->GetVal());
+  }
+  else {
+    if (esd && (esd->GetEventType() == 7))
+      AliWarning("V0A trigger charge not found in digits tree UserInfo!");
+  }
+
+  if (digitsTree->GetUserInfo()->FindObject("ChargeC")) {
+    chargeC = (UShort_t)(((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("ChargeC"))->GetVal());
+  }
+  else {
+    if (esd && (esd->GetEventType() == 7))
+      AliWarning("V0C trigger charge not found in digits tree UserInfo!");
+  }
+
+  if (digitsTree->GetUserInfo()->FindObject("TriggerInputs")) {
+    triggerInputs = (UShort_t)(((TParameter<int>*)digitsTree->GetUserInfo()->FindObject("TriggerInputs"))->GetVal());
+  }
+  else {
+    if (esd && (esd->GetEventType() == 7))
+      AliWarning("V0C trigger charge not found in digits tree UserInfo!");
+  }
+
+  fESDVZERO->SetTriggerChargeA(chargeA);
+  fESDVZERO->SetTriggerChargeC(chargeC);
+  fESDVZERO->SetTriggerBits(triggerInputs);
+  fESDVZERO->SetBit(AliESDVZERO::kTriggerChargeBitsFilled,kTRUE);
+
   Int_t nEntries = (Int_t)digitsTree->GetEntries();
   for (Int_t e=0; e<nEntries; e++) {
     digitsTree->GetEvent(e);
@@ -350,7 +413,10 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
                          aBBflag[pmNumber],aBGflag[pmNumber]));
            };
 
-       mult[pmNumber] = adc[pmNumber]*fCalibData->GetMIPperADC(pmNumber);
+       TF1 *saturationFunc = (TF1*)fSaturationCorr->UncheckedAt(pmNumber);
+       if (!saturationFunc) AliFatal(Form("Saturation correction for channel %d is not found!",pmNumber));
+       AliDebug(1,Form("Saturation PM=%d   %f %f",pmNumber,adc[pmNumber],saturationFunc->Eval(adc[pmNumber])));
+       mult[pmNumber] = saturationFunc->Eval(adc[pmNumber])*fCalibData->GetMIPperADC(pmNumber);
 
        // Fill ESD friend object
        for (Int_t iEv = 0; iEv < AliESDVZEROfriend::kNEvOfInt; iEv++) {
@@ -371,16 +437,32 @@ void AliVZEROReconstructor::FillESD(TTree* digitsTree, TTree* /*clustersTree*/,
   fESDVZERO->SetBit(AliESDVZERO::kOnlineBitsFilled,kTRUE);
   fESDVZERO->SetBBFlag(aBBflag);
   fESDVZERO->SetBGFlag(aBGflag);
+  fESDVZERO->SetBit(AliESDVZERO::kCorrectedForSaturation,kTRUE);
 
   // now fill the V0 decision and channel flags
   {
     AliVZEROTriggerMask triggerMask;
+    triggerMask.SetRecoParam(GetRecoParam());
     triggerMask.FillMasks(fESDVZERO, fCalibData, fTimeSlewing);
   }
 
   if (esd) { 
      AliDebug(1, Form("Writing VZERO data to ESD tree"));
      esd->SetVZEROData(fESDVZERO);
+     const AliESDRun *esdRun = esd->GetESDRun();
+     if (esdRun) {
+       Float_t factors[64];
+       Float_t factorSum = 0;
+       for(Int_t i = 0; i < 64; ++i) {
+        factors[i] = fEqFactors->GetBinContent(i+1)*fCalibData->GetMIPperADC(i);
+        factorSum += factors[i];
+       }
+       for(Int_t i = 0; i < 64; ++i) factors[i] *= (64./factorSum);
+       
+       esd->SetVZEROEqFactors(factors);
+     }
+     else
+       AliError("AliESDRun object is not available! Cannot write the equalization factors!");
   }
 
   if (esd) {