#include <TF1.h>
+#include <TMap.h>
#include "AliRunLoader.h"
#include "AliRawReader.h"
+#include "AliGRPObject.h"
#include "AliESDEvent.h"
#include "AliESDZDC.h"
#include "AliZDCDigit.h"
//_____________________________________________________________________________
AliZDCReconstructor:: AliZDCReconstructor() :
fPedData(GetPedData()),
- fECalibData(GetECalibData())
+ fECalibData(GetECalibData()),
+ fRecoMode(0),
+ fBeamEnergy(0.),
+ fPedSubMode(0)
{
// **** Default constructor
+ SetRecoMode();
}
if(fECalibData) delete fECalibData;
}
+//____________________________________________________________________________
+void AliZDCReconstructor::SetRecoMode()
+{
+ // Setting reconstruction mode
+
+ // Initialization of the GRP entry
+ AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
+ AliGRPObject* grpData = 0x0;
+ if(entry){
+ TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
+ if(m){
+ m->Print();
+ grpData = new AliGRPObject();
+ grpData->ReadValuesFromMap(m);
+ }
+ else{
+ grpData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
+ entry->SetOwner(0);
+ }
+ AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
+ }
+ if(!grpData) AliError("No GRP entry found in OCDB!");
+
+ TString beamType = grpData->GetBeamType();
+ if(beamType==AliGRPObject::GetInvalidString()){
+ AliError("GRP/GRP/Data entry: missing value for the beam energy !");
+ AliError("\t ZDC does not reconstruct event 4 UNKNOWN beam type\n");
+ return;
+ }
+ //
+ if((beamType.CompareTo("p-p")) == 0){
+ fRecoMode=0;
+ fRecoParam = (AliZDCRecoParampp*) AliZDCRecoParampp::GetppRecoParam();
+ }
+ else if((beamType.CompareTo("A-A")) == 0){
+ fRecoMode=1;
+ fRecoParam = (AliZDCRecoParamPbPb*) AliZDCRecoParamPbPb::GetPbPbRecoParam();
+ }
+
+ fBeamEnergy = grpData->GetBeamEnergy();
+ if(fBeamEnergy==AliGRPObject::GetInvalidFloat()) {
+ AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
+ fBeamEnergy = 0.;
+ }
+
+ printf("\n ***** ZDC reconstruction initialized for %s @ %1.3f GeV\n\n",beamType.Data(), fBeamEnergy);
+}
+
//_____________________________________________________________________________
void AliZDCReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
{
// Works on the current event
// Retrieving calibration data
- Float_t meanPed[48];
+ // Parameters for mean value pedestal subtraction
+ Float_t meanPed[48];
for(Int_t jj=0; jj<48; jj++) meanPed[jj] = fPedData->GetMeanPed(jj);
+ // Parameters pedestal subtraction through correlation with out-of-time signals
+ Float_t corrCoeff0[48], corrCoeff1[48];
+ for(Int_t jj=0; jj<48; jj++){
+ corrCoeff0[jj] = fPedData->GetPedCorrCoeff0(jj);
+ corrCoeff1[jj] = fPedData->GetPedCorrCoeff1(jj);
+ }
// get digits
AliZDCDigit digit;
tZN1Corr[i] = tZP1Corr[i] = tZN2Corr[i] = tZP2Corr[i] = 0.;
if(i<2) dZEM1Corr[i] = dZEM2Corr[i] = PMRef1[i] = PMRef2[i] = 0.;
}
- //
- for (Int_t iDigit = 0; iDigit < (digitsTree->GetEntries()/2); iDigit++) {
+
+ Int_t digNentries = digitsTree->GetEntries();
+ int const kNch = 24;
+ Float_t ootDigi[kNch];
+ // -- Reading out-of-time signals (last kNch entries) for current event
+ if(fPedSubMode==1){
+ for(Int_t iDigit=kNch; iDigit<digNentries; iDigit++){
+ ootDigi[iDigit] = digitsTree->GetEntry(iDigit);
+ }
+ }
+
+ for(Int_t iDigit=0; iDigit<(digNentries/2); iDigit++) {
digitsTree->GetEntry(iDigit);
if (!pdigit) continue;
//
Int_t det = digit.GetSector(0);
Int_t quad = digit.GetSector(1);
- Int_t pedindex = -1, kNch = 24;
- //printf("\n\t Digit #%d det %d quad %d", iDigit, det, quad);
+ Int_t pedindex = -1;
+ Float_t ped2SubHg=0., ped2SubLg=0.;
+ if(quad!=5){
+ if(det==1) pedindex = quad;
+ else if(det==2) pedindex = quad+5;
+ else if(det==3) pedindex = quad+9;
+ else if(det==4) pedindex = quad+12;
+ else if(det==5) pedindex = quad+17;
+ }
+ else pedindex = (det-1)/3+22;
//
+ if(fPedSubMode==0){
+ ped2SubHg = meanPed[pedindex];
+ ped2SubLg = meanPed[pedindex+kNch];
+ }
+ else if(fPedSubMode==1){
+ ped2SubHg = corrCoeff1[pedindex]*ootDigi[pedindex]+corrCoeff0[pedindex];
+ ped2SubLg = corrCoeff1[pedindex+kNch]*ootDigi[pedindex+kNch]+corrCoeff0[pedindex+kNch];
+ }
+
+ //printf("\n\t Digit #%d det %d quad %d", iDigit, det, quad);
+
if(quad != 5){ // ZDC (not reference PTMs!)
if(det == 1){ // *** ZNC
- pedindex = quad;
- tZN1Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+ tZN1Corr[quad] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
+ tZN1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
if(tZN1Corr[quad]<0.) tZN1Corr[quad] = 0.;
- tZN1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
- if(tZN1Corr[quad+5]<0.) tZN1Corr[quad] = 0.;
+ if(tZN1Corr[quad+5]<0.) tZN1Corr[quad+5] = 0.;
//printf("\t pedindex %d tZN1Corr[%d] = %1.0f tZN1Corr[%d] = %1.0f",
// pedindex, quad, tZN1Corr[quad], quad+5, tZN1Corr[quad+5]);
}
else if(det == 2){ // *** ZP1
- pedindex = quad+5;
- tZP1Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+ tZP1Corr[quad] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
if(tZP1Corr[quad]<0.) tZP1Corr[quad] = 0.;
- tZP1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
- if(tZP1Corr[quad+5]<0.) tZP1Corr[quad] = 0.;
+ tZP1Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
+ if(tZP1Corr[quad+5]<0.) tZP1Corr[quad+5] = 0.;
//printf("\t pedindex %d tZP1Corr[%d] = %1.0f tZP1Corr[%d] = %1.0f",
// pedindex, quad, tZP1Corr[quad], quad+5, tZP1Corr[quad+5]);
}
else if(det == 3){
- pedindex = quad+9;
if(quad == 1){ // *** ZEM1
- dZEM1Corr[0] += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+ dZEM1Corr[0] += (Float_t) (digit.GetADCValue(0)-ped2SubHg);
if(dZEM1Corr[0]<0.) dZEM1Corr[0] = 0.;
- dZEM1Corr[1] += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+ dZEM1Corr[1] += (Float_t) (digit.GetADCValue(1)-ped2SubLg);
if(dZEM1Corr[1]<0.) dZEM1Corr[1] = 0.;
//printf("\t pedindex %d tZEM1Corr[%d] = %1.0f tZEM1Corr[%d] = %1.0f",
// pedindex, quad, tZEM1Corr[quad], quad+1, tZEM1Corr[quad+1]);
}
else if(quad == 2){ // *** ZEM2
- dZEM2Corr[0] += (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+ dZEM2Corr[0] += (Float_t) (digit.GetADCValue(0)-ped2SubHg);
if(dZEM2Corr[0]<0.) dZEM2Corr[0] = 0.;
- dZEM2Corr[1] += (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+ dZEM2Corr[1] += (Float_t) (digit.GetADCValue(1)-ped2SubLg);
if(dZEM2Corr[1]<0.) dZEM2Corr[1] = 0.;
//printf("\t pedindex %d tZEM2Corr[%d] = %1.0f tZEM2Corr[%d] = %1.0f",
// pedindex, quad, tZEM2Corr[quad], quad+1, tZEM2Corr[quad+1]);
}
}
else if(det == 4){ // *** ZN2
- pedindex = quad+12;
- tZN2Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+ tZN2Corr[quad] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
if(tZN2Corr[quad]<0.) tZN2Corr[quad] = 0.;
- tZN2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+ tZN2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
if(tZN2Corr[quad+5]<0.) tZN2Corr[quad+5] = 0.;
//printf("\t pedindex %d tZN2Corr[%d] = %1.0f tZN2Corr[%d] = %1.0f\n",
// pedindex, quad, tZN2Corr[quad], quad+5, tZN2Corr[quad+5]);
}
else if(det == 5){ // *** ZP2
- pedindex = quad+17;
- tZP2Corr[quad] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+ tZP2Corr[quad] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
if(tZP2Corr[quad]<0.) tZP2Corr[quad] = 0.;
- tZP2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+ tZP2Corr[quad+5] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
if(tZP2Corr[quad+5]<0.) tZP2Corr[quad+5] = 0.;
//printf("\t pedindex %d tZP2Corr[%d] = %1.0f tZP2Corr[%d] = %1.0f\n",
// pedindex, quad, tZP2Corr[quad], quad+5, tZP2Corr[quad+5]);
}
}
else{ // Reference PMs
- pedindex = (det-1)/3+22;
if(det == 1){
- PMRef1[0] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+ PMRef1[0] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
if(PMRef1[0]<0.) PMRef1[0] = 0.;
- PMRef1[1] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+ PMRef1[1] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
if(PMRef2[1]<0.) PMRef1[1] = 0.;
}
else if(det == 4){
- PMRef2[0] = (Float_t) (digit.GetADCValue(0)-meanPed[pedindex]);
+ PMRef2[0] = (Float_t) (digit.GetADCValue(0)-ped2SubHg);
if(PMRef2[0]<0.) PMRef2[0] = 0.;
- PMRef2[1] = (Float_t) (digit.GetADCValue(1)-meanPed[pedindex+kNch]);
+ PMRef2[1] = (Float_t) (digit.GetADCValue(1)-ped2SubLg);
if(PMRef2[1]<0.) PMRef2[1] = 0.;
}
}
}
// reconstruct the event
- ReconstructEventpp(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
+ if(fRecoMode==0)
+ ReconstructEventpp(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
+ dZEM1Corr, dZEM2Corr, PMRef1, PMRef2);
+ else if(fRecoMode==1)
+ ReconstructEventPbPb(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
dZEM1Corr, dZEM2Corr, PMRef1, PMRef2);
}
// Works on the current event
// Retrieving calibration data
- Float_t meanPed[48];
+ // Parameters for mean value pedestal subtraction
+ Float_t meanPed[48];
for(Int_t jj=0; jj<48; jj++) meanPed[jj] = fPedData->GetMeanPed(jj);
+ // Parameters pedestal subtraction through correlation with out-of-time signals
+ Float_t corrCoeff0[48], corrCoeff1[48];
+ for(Int_t jj=0; jj<48; jj++){
+ corrCoeff0[jj] = fPedData->GetPedCorrCoeff0(jj);
+ corrCoeff1[jj] = fPedData->GetPedCorrCoeff1(jj);
+ }
rawReader->Reset();
}
//
AliZDCRawStream rawData(rawReader);
- Int_t kNch = 24;
- while (rawData.Next()) {
+ Int_t const kNch = 24;
+ while(rawData.Next()) {
if(rawData.IsADCDataWord()){
Int_t det = rawData.GetSector(0);
Int_t quad = rawData.GetSector(1);
}
// reconstruct the event
- ReconstructEventpp(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
+ if(fRecoMode==0)
+ ReconstructEventpp(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
+ dZEM1Corr, dZEM2Corr, PMRef1, PMRef2);
+ else if(fRecoMode==1)
+ ReconstructEventPbPb(clustersTree, tZN1Corr, tZP1Corr, tZN2Corr, tZP2Corr,
dZEM1Corr, dZEM2Corr, PMRef1, PMRef2);
}
}
// --- Energy calibration factors ------------------------------------
Float_t calibEne[4];
- // *********************************************************************
- // **** Until the beam type info isn't known @ reconstruction level ****
- // **** the energy calibration coefficient are manually set to 1 ****
- // **** as it will be in real life for pp data taking ****
- // *********************************************************************
+ // **** Energy calibration coefficient set to 1
+ // **** (no trivial way to calibrate in p-p runs)
//for(Int_t ij=0; ij<4; ij++) calibEne[ij] = fECalibData->GetEnCalib(ij);
for(Int_t ij=0; ij<4; ij++) calibEne[ij] = 1.;
calibSumZP2[1] += calibTowZP2[gi];
}
}
-
- //
- // --- Reconstruction parameters ------------------
- if(!fRecoParam) fRecoParam = (AliZDCRecoParampp*) AliZDCRecoParampp::GetppRecoParam();
// --- Number of detected spectator nucleons
- // *** N.B. -> It works only in Pb-Pb
- Int_t nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight;
- Float_t beamE = fRecoParam->GetBeamEnergy();
- nDetSpecNLeft = (Int_t) (calibSumZN1[0]/beamE);
- nDetSpecPLeft = (Int_t) (calibSumZP1[0]/beamE);
- nDetSpecNRight = (Int_t) (calibSumZN2[0]/beamE);
- nDetSpecPRight = (Int_t) (calibSumZP2[0]/beamE);
+ // *** N.B. -> It works only in Pb-Pb!!!!!!!!!!!!
+ // Variables calculated to comply with ESD structure
+ Int_t nDetSpecNLeft=0, nDetSpecPLeft=0, nDetSpecNRight=0, nDetSpecPRight=0;
+ if(fBeamEnergy!=0){
+ nDetSpecNLeft = (Int_t) (calibSumZN1[0]/fBeamEnergy);
+ nDetSpecPLeft = (Int_t) (calibSumZP1[0]/fBeamEnergy);
+ nDetSpecNRight = (Int_t) (calibSumZN2[0]/fBeamEnergy);
+ nDetSpecPRight = (Int_t) (calibSumZP2[0]/fBeamEnergy);
+ }
+ else AliWarning(" ATTENTION -> fBeamEnergy = 0\n");
/*printf("\n\t AliZDCReconstructor -> nDetSpecNLeft %d, nDetSpecPLeft %d,"
" nDetSpecNRight %d, nDetSpecPRight %d\n",nDetSpecNLeft, nDetSpecPLeft,
nDetSpecNRight, nDetSpecPRight);*/
// create the output tree
AliZDCReco reco(calibSumZN1, calibSumZP1, calibSumZN2, calibSumZP2,
- calibTowZN1, calibTowZN2, calibTowZP1, calibTowZP2,
+ calibTowZN1, calibTowZP1, calibTowZN2, calibTowZP2,
ZEM1ADCCorr, ZEM2ADCCorr, PMRef1, PMRef2,
nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight,
nGenSpecNLeft, nGenSpecPLeft, nGenSpecLeft, nGenSpecNRight,
// --- Number of detected spectator nucleons
// *** N.B. -> It works only in Pb-Pb
- Int_t nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight;
- Float_t beamE = fRecoParam->GetBeamEnergy();
- nDetSpecNLeft = (Int_t) (calibSumZN1[0]/beamE);
- nDetSpecPLeft = (Int_t) (calibSumZP1[0]/beamE);
- nDetSpecNRight = (Int_t) (calibSumZN2[0]/beamE);
- nDetSpecPRight = (Int_t) (calibSumZP2[0]/beamE);
+ Int_t nDetSpecNLeft=0, nDetSpecPLeft=0, nDetSpecNRight=0, nDetSpecPRight=0;
+ if(fBeamEnergy!=0){
+ nDetSpecNLeft = (Int_t) (calibSumZN1[0]/fBeamEnergy);
+ nDetSpecPLeft = (Int_t) (calibSumZP1[0]/fBeamEnergy);
+ nDetSpecNRight = (Int_t) (calibSumZN2[0]/fBeamEnergy);
+ nDetSpecPRight = (Int_t) (calibSumZP2[0]/fBeamEnergy);
+ }
+ else AliWarning(" ATTENTION -> fBeamEnergy = 0\n");
/*printf("\n\t AliZDCReconstructor -> nDetSpecNLeft %d, nDetSpecPLeft %d,"
" nDetSpecNRight %d, nDetSpecPRight %d\n",nDetSpecNLeft, nDetSpecPLeft,
nDetSpecNRight, nDetSpecPRight);*/
// create the output tree
AliZDCReco reco(calibSumZN1, calibSumZP1, calibSumZN2, calibSumZP2,
- calibTowZN1, calibTowZN2, calibTowZP1, calibTowZP2,
+ calibTowZN1, calibTowZP1, calibTowZN2, calibTowZP2,
ZEM1ADCCorr, ZEM2ADCCorr, PMRef1, PMRef2,
nDetSpecNLeft, nDetSpecPLeft, nDetSpecNRight, nDetSpecPRight,
nGenSpecNLeft, nGenSpecPLeft, nGenSpecLeft, nGenSpecNRight,
//
esd->SetZDC(reco.GetZN1HREnergy(), reco.GetZP1HREnergy(), reco.GetZEM1HRsignal(),
reco.GetZEM2HRsignal(), reco.GetZN2HREnergy(), reco.GetZP2HREnergy(),
- reco.GetNPartLeft());
+ reco.GetNPartLeft(), reco.GetNPartRight());
//
}