From 8309c1abbc933c11fa384333d6c14df5bb08e5c6 Mon Sep 17 00:00:00 2001 From: coppedis Date: Fri, 22 Oct 2004 10:38:59 +0000 Subject: [PATCH] Splitted libraries --- ZDC/AliZDCDigitizer.cxx | 325 +++++++++++++++++++++++++++++++ ZDC/AliZDCDigitizer.h | 59 ++++++ ZDC/AliZDCRawStream.cxx | 117 ++++++++++++ ZDC/AliZDCRawStream.h | 48 +++++ ZDC/AliZDCReconstructor.cxx | 370 ++++++++++++++++++++++++++++++++++++ ZDC/AliZDCReconstructor.h | 53 ++++++ ZDC/AliZDCSDigit.cxx | 48 +++++ ZDC/AliZDCSDigit.h | 40 ++++ ZDC/libZDC.pkg | 7 - ZDC/libZDCbase.pkg | 10 + ZDC/libZDCrec.pkg | 10 + ZDC/libZDCsim.pkg | 12 ++ 12 files changed, 1092 insertions(+), 7 deletions(-) create mode 100644 ZDC/AliZDCDigitizer.cxx create mode 100644 ZDC/AliZDCDigitizer.h create mode 100644 ZDC/AliZDCRawStream.cxx create mode 100644 ZDC/AliZDCRawStream.h create mode 100644 ZDC/AliZDCReconstructor.cxx create mode 100644 ZDC/AliZDCReconstructor.h create mode 100644 ZDC/AliZDCSDigit.cxx create mode 100644 ZDC/AliZDCSDigit.h delete mode 100644 ZDC/libZDC.pkg create mode 100644 ZDC/libZDCbase.pkg create mode 100644 ZDC/libZDCrec.pkg create mode 100644 ZDC/libZDCsim.pkg diff --git a/ZDC/AliZDCDigitizer.cxx b/ZDC/AliZDCDigitizer.cxx new file mode 100644 index 00000000000..ab23cb2a23d --- /dev/null +++ b/ZDC/AliZDCDigitizer.cxx @@ -0,0 +1,325 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +/////////////////////////////////////////////////////////////////////////////// +// // +// ZDC digitizer class // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include + +// --- ROOT system +#include +#include +#include +#include + +// --- AliRoot header files +#include "AliLog.h" +#include "AliRun.h" +#include "AliHeader.h" +#include "AliGenHijingEventHeader.h" +#include "AliRunDigitizer.h" +#include "AliRunLoader.h" +#include "AliZDCSDigit.h" +#include "AliZDCDigit.h" +#include "AliZDCFragment.h" +#include "AliZDCDigitizer.h" + +ClassImp(AliZDCDigitizer) + + +//____________________________________________________________________________ +AliZDCDigitizer::AliZDCDigitizer() +{ +// Default constructor + +} + +//____________________________________________________________________________ +AliZDCDigitizer::AliZDCDigitizer(AliRunDigitizer* manager): + AliDigitizer(manager) +{ +// Constructor + +} + +//____________________________________________________________________________ +AliZDCDigitizer::~AliZDCDigitizer() +{ +// Destructor + +} + + +//____________________________________________________________________________ +Bool_t AliZDCDigitizer::Init() +{ +// Initialize the digitizer + + for (Int_t i = 0; i < 3; i++) { + for(Int_t j = 0; j < 5; j++) { + fPMGain[i][j] = 100000.; + } + } + +// ADC Caen V965 + fADCRes[0] = 0.0000008; // ADC Resolution high gain: 200 fC/adcCh + fADCRes[1] = 0.0000064; // ADC Resolution low gain: 25 fC/adcCh + + return kTRUE; +} + +//____________________________________________________________________________ +void AliZDCDigitizer::Exec(Option_t* /*option*/) +{ +// Execute digitization + + Float_t pm[3][5]; + for (Int_t iSector1 = 0; iSector1 < 3; iSector1++) + for (Int_t iSector2 = 0; iSector2 < 5; iSector2++) { + pm[iSector1][iSector2] = 0; + } + // pm[0][...] = light in ZN [C, Q1, Q2, Q3, Q4] + // pm[1][...] = light in ZP [C, Q1, Q2, Q3, Q4] + // pm[2][...] = light in ZEM [x, 1, 2, x, x] + + // impact parameter and number of spectators + Float_t impPar = -1; + Int_t specN = 0; + Int_t specP = 0; + + // loop over input streams + for (Int_t iInput = 0; iInput < fManager->GetNinputs(); iInput++) { + + // get run loader and ZDC loader + AliRunLoader* runLoader = + AliRunLoader::GetRunLoader(fManager->GetInputFolderName(iInput)); + AliLoader* loader = runLoader->GetLoader("ZDCLoader"); + if (!loader) continue; + + // load sdigits + loader->LoadSDigits(); + TTree* treeS = loader->TreeS(); + if (!treeS) continue; + AliZDCSDigit sdigit; + AliZDCSDigit* psdigit = &sdigit; + treeS->SetBranchAddress("ZDC", &psdigit); + + // loop over sdigits + for (Int_t iSDigit = 0; iSDigit < treeS->GetEntries(); iSDigit++) { + treeS->GetEntry(iSDigit); + if (!psdigit) continue; + + if ((sdigit.GetSector(1) < 0) || (sdigit.GetSector(1) > 4)) { + AliError(Form("\nsector[0] = %d, sector[1] = %d\n", + sdigit.GetSector(0), sdigit.GetSector(1))); + continue; + } + pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)] += sdigit.GetLightPM(); + //printf("\n\t sector[0] = %d, sector[1] = %d, pm[%d][%d] = %f \n", + // sdigit.GetSector(0), sdigit.GetSector(1),sdigit.GetSector(0)-1, + // sdigit.GetSector(1), pm[sdigit.GetSector(0)-1][sdigit.GetSector(1)]); // Chiara debugging! + } + + // unload sdigits + loader->UnloadSDigits(); + + // get the impact parameter and the number of spectators in case of hijing + if (!runLoader->GetAliRun()) runLoader->LoadgAlice(); + AliHeader* header = runLoader->GetAliRun()->GetHeader(); + if (!header) continue; + AliGenEventHeader* genHeader = header->GenEventHeader(); + if (!genHeader) continue; + if (!genHeader->InheritsFrom(AliGenHijingEventHeader::Class())) continue; + impPar = ((AliGenHijingEventHeader*) genHeader)->ImpactParameter(); + // Until there is only 1 ZDC set the # of spectators must be divided by 2!!! + specN = ((AliGenHijingEventHeader*) genHeader)->Spectatorsn() / 2; + specP = ((AliGenHijingEventHeader*) genHeader)->Spectatorsp() / 2; + AliDebug(2, Form("\n b = %f fm, Nspecn = %d, Nspecp = %d\n", + impPar, specN, specP)); + } + + // add spectators + if (impPar >= 0) { + Int_t freeSpecN, freeSpecP; + Fragmentation(impPar, specN, specP, freeSpecN, freeSpecP); + SpectatorSignal(1, freeSpecN, pm); + SpectatorSignal(2, freeSpecP, pm); + } + + // get the output run loader and loader + AliRunLoader* runLoader = + AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); + AliLoader* loader = runLoader->GetLoader("ZDCLoader"); + if (!loader) { + AliError("no ZDC loader found"); + return; + } + + // create the output tree + const char* mode = "update"; + if (runLoader->GetEventNumber() == 0) mode = "recreate"; + loader->LoadDigits(mode); + loader->MakeTree("D"); + TTree* treeD = loader->TreeD(); + AliZDCDigit digit; + AliZDCDigit* pdigit = &digit; + const Int_t kBufferSize = 4000; + treeD->Branch("ZDC", "AliZDCDigit", &pdigit, kBufferSize); + + // Create digits + Int_t sector[2]; + Int_t digi[2]; + for (sector[0] = 1; sector[0] <= 3; sector[0]++) + for (sector[1] = 0; sector[1] < 5; sector[1]++) { + if ((sector[0] == 3) && ((sector[1] < 1) || (sector[1] > 2))) continue; + for (Int_t res = 0; res < 2; res++){ + digi[res] = Phe2ADCch(1, 0, pm[sector[0]-1][sector[1]], res) + + Pedestal(); + //printf("\n\t sector[0] = %d, sector[1] = %d, digi[%d] = %d\n", + // sector[0], sector[1], res, digi[res]); // Chiara debugging! + } + new(pdigit) AliZDCDigit(sector, digi); + treeD->Fill(); + } + + // write the output tree + loader->WriteDigits("OVERWRITE"); + loader->UnloadDigits(); +} + + +//_____________________________________________________________________________ +void AliZDCDigitizer::Fragmentation(Float_t impPar, Int_t specN, Int_t specP, + Int_t &freeSpecN, Int_t &freeSpecP) const +{ +// simulate fragmentation of spectators + + Int_t zz[100], nn[100]; + AliZDCFragment frag(impPar); + for (Int_t j=0; j<=99; j++){ + zz[j] =0; + nn[j] =0; + } + + // Fragments generation + Int_t nAlpha; + frag.GenerateIMF(zz, nAlpha); + + // Attach neutrons + Int_t ztot=0; + Int_t ntot=0; + frag.AttachNeutrons(zz, nn, ztot, ntot); + freeSpecN = specN-ntot-2*nAlpha; + freeSpecP = specP-ztot-2*nAlpha; + if(freeSpecN<0) freeSpecN=0; + if(freeSpecP<0) freeSpecP=0; + AliDebug(2, Form("FreeSpn = %d, FreeSpp = %d", freeSpecN, freeSpecP)); +} + +//_____________________________________________________________________________ +void AliZDCDigitizer::SpectatorSignal(Int_t SpecType, Int_t numEvents, + Float_t pm[3][5]) const +{ +// add signal of the spectators + + TFile* file = NULL; + if (SpecType == 1) { // --- Signal for spectator neutrons + file = TFile::Open("$ALICE/$ALICE_LEVEL/ZDC/ZNsignalntu.root"); + } else if (SpecType == 2) { // --- Signal for spectator protons + file = TFile::Open("$ALICE/$ALICE_LEVEL/ZDC/ZPsignalntu.root"); + } + if (!file || !file->IsOpen()) { + AliError("Opening of file failed"); + return; + } + + TNtuple* zdcSignal = (TNtuple*) file->Get("ZDCSignal"); + Int_t nentries = (Int_t) zdcSignal->GetEntries(); + + Float_t *entry, hitsSpec[7]; + Int_t pl, i, j, k, iev=0, rnd[125], volume[2]; + for(pl=0;pl<125;pl++){ + rnd[pl] = 0; + } + if (numEvents > 125) { + AliWarning(Form("numEvents (%d) is larger than 125", numEvents)); + numEvents = 125; + } + for(pl=0;plRndm()); + if(rnd[pl] >= 9998) rnd[pl] = 9997; + //printf(" rnd[%d] = %d\n",pl,rnd[pl]); + } + // Sorting vector in ascending order with C function QSORT + qsort((void*)rnd,numEvents,sizeof(Int_t),comp); + do{ + for(i=0; iGetEvent(i); + entry = zdcSignal->GetArgs(); + if(entry[0] == rnd[iev]){ + for(k=0; k<2; k++) volume[k] = (Int_t) entry[k+1]; + for(j=0; j<7; j++) hitsSpec[j] = entry[j+3]; + + Float_t lightQ = hitsSpec[4]; + Float_t lightC = hitsSpec[5]; + AliDebug(3, Form("volume = (%d, %d), lightQ = %.3f, lightC = %.3f", + volume[0], volume[1], lightQ, lightC)); + if (volume[0] < 3) { // ZN or ZP + pm[volume[0]-1][0] += lightC; + pm[volume[0]-1][volume[1]] += lightQ; + } else { + if (volume[1] == 1) pm[2][1] += lightC; + else pm[2][2] += lightQ; + } + + + } + else if(entry[0] > rnd[iev]){ + iev++; + continue; + } + } + }while(ievClose(); + delete file; +} + + +//_____________________________________________________________________________ +Int_t AliZDCDigitizer::Phe2ADCch(Int_t Det, Int_t Quad, Float_t Light, + Int_t Res) const +{ +// Evaluation of the ADC channel corresponding to the light yield Light + + return (Int_t) (Light * fPMGain[Det-1][Quad] * fADCRes[Res]); +} + +//_____________________________________________________________________________ +Int_t AliZDCDigitizer::Pedestal() const +{ + // --- Pedestal value -> extracted from a gaussian distribution + // obtained from the beam test on the ZEM prototype (Aug. 2000) + + Float_t pedMean = 50.; + Float_t pedWidth = 5.; + + return (Int_t) gRandom->Gaus(pedMean, pedWidth); +} diff --git a/ZDC/AliZDCDigitizer.h b/ZDC/AliZDCDigitizer.h new file mode 100644 index 00000000000..0536542969c --- /dev/null +++ b/ZDC/AliZDCDigitizer.h @@ -0,0 +1,59 @@ +#ifndef ALIZDCDIGITIZER_H +#define ALIZDCDIGITIZER_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +//////////////////////////////////////////////// +// Digitizer class for ZDC // +//////////////////////////////////////////////// + +#include "AliDigitizer.h" + +class AliRunDigitizer; + +class AliZDC; +class AliZDCHit; +class AliZDCMergedHit; +class AliZDCDigit; + +class AliZDCDigitizer: public AliDigitizer { + +public: + AliZDCDigitizer(); + AliZDCDigitizer(AliRunDigitizer* manager); + virtual ~AliZDCDigitizer(); + + virtual Bool_t Init(); + virtual void Exec(Option_t* option=0); + + // PM gain + void SetPMGain(Int_t det, Int_t pmDet, Int_t pmGain) + {fPMGain[det][pmDet] = pmGain;} + Float_t GetPMGain(Int_t det, Int_t pmDet) const + {return fPMGain[det][pmDet];} + // Conversion factor from charge to ADC channels + // F = 1.6E-19 / Resolution [Coulomb/ch] + void SetADCRes(Int_t *adcRes) + // Two conversion factor are needed for ADC CAEN V965 + {for (Int_t i=0;i<2;i++) fADCRes[i] = adcRes[i];} + Float_t GetADCRes(Int_t i) const {return fADCRes[i];} + +private: + void Fragmentation(Float_t impPar, Int_t specN, Int_t specP, + Int_t &freeSpecN, Int_t &freeSpecP) const; + void SpectatorSignal(Int_t SpecType, Int_t numEvents, + Float_t pm[3][5]) const; + + Int_t Phe2ADCch(Int_t Detector, Int_t Quadrant, Float_t Light, + Int_t Res) const; + Int_t Pedestal() const; + + Float_t fPMGain[3][5]; // PM gain + Float_t fADCRes[2]; // ADC conversion factors + + + ClassDef(AliZDCDigitizer, 2) // digitizer for ZDC +}; +#endif diff --git a/ZDC/AliZDCRawStream.cxx b/ZDC/AliZDCRawStream.cxx new file mode 100644 index 00000000000..344a3f41c5c --- /dev/null +++ b/ZDC/AliZDCRawStream.cxx @@ -0,0 +1,117 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +/////////////////////////////////////////////////////////////////////////////// +/// +/// This class provides access to ZDC digits in raw data. +/// +/// It loops over all ZDC digits in the raw data given by the AliRawReader. +/// The Next method goes to the next digit. If there are no digits left +/// it returns kFALSE. +/// Getters provide information about the current digit. +/// +/////////////////////////////////////////////////////////////////////////////// + +#include "AliZDCRawStream.h" +#include "AliRawReader.h" + +ClassImp(AliZDCRawStream) + + +//_____________________________________________________________________________ +AliZDCRawStream::AliZDCRawStream(AliRawReader* rawReader) : + fRawReader(rawReader), + fADCValue(-1) +{ +// create an object to read ZDC raw digits + + fSector[0] = 1; + fSector[1] = -1; + fRawReader->Select(kDDLOffset / 0x100); +} + +//_____________________________________________________________________________ +AliZDCRawStream::AliZDCRawStream(const AliZDCRawStream& stream) : + TObject(stream), + fADCValue(-1) +{ +// copy constructor + + Fatal("AliZDCRawStream", "copy constructor not implemented"); +} + +//_____________________________________________________________________________ +AliZDCRawStream& AliZDCRawStream::operator = (const AliZDCRawStream& + /* stream */) +{ +// assignment operator + + Fatal("operator =", "assignment operator not implemented"); + return *this; +} + +//_____________________________________________________________________________ +AliZDCRawStream::~AliZDCRawStream() +{ +// destructor + +} + + +//_____________________________________________________________________________ +Bool_t AliZDCRawStream::Next() +{ +// read the next raw digit +// returns kFALSE if there is no digit left + + if (!fRawReader->ReadNextInt((UInt_t&) fRawADC)) return kFALSE; + fIsADCDataWord = kFALSE; + + //ADC Header + if (fRawADC & 0x2000000) { + printf("This is the ADC Header\n"); + printf("%d data words will follow \n",2*((fRawADC & 0x3f00) >> 8)); + } + //ADC EOB + else if (fRawADC & 0x4000000) { + printf("This is the ADC End Of Block\n"); + printf("This was event number %d\n",(fRawADC & 0xffffff)); + } else + //ADC Data Words + { + printf("This is an ADC Data Word\n"); + printf("Channel %d range %d\n", + (fRawADC & 0x1e0000) >> 17, (fRawADC & 0x10000) >> 16); + if(fRawADC & 0x1000) printf("Data = overflow\n"); + fADCGain = (fRawADC & 0x10000) >> 16; + fADCValue = (fRawADC & 0xfff); + fIsADCDataWord = kTRUE; + + Int_t ADCChannel = (fRawADC & 0x1e0000) >> 17; + if (ADCChannel >= 0 && ADCChannel <= 4) { + fSector[0] = 1; + fSector[1] = ADCChannel; + } else if (ADCChannel >= 8 && ADCChannel <= 12) { + fSector[0] = 2; + fSector[1] = ADCChannel-8; + } else if (ADCChannel == 5 || ADCChannel == 13){ + fSector[0] = 3; + fSector[1] = (ADCChannel-5)/8; + } + } + return kTRUE; +} diff --git a/ZDC/AliZDCRawStream.h b/ZDC/AliZDCRawStream.h new file mode 100644 index 00000000000..034bb44e9ad --- /dev/null +++ b/ZDC/AliZDCRawStream.h @@ -0,0 +1,48 @@ +#ifndef ALIZDCRAWSTREAM_H +#define ALIZDCRAWSTREAM_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +/////////////////////////////////////////////////////////////////////////////// +/// +/// This class provides access to ZDC digits in raw data. +/// +/////////////////////////////////////////////////////////////////////////////// + +#include + +class AliRawReader; + + +class AliZDCRawStream: public TObject { + public : + AliZDCRawStream(AliRawReader* rawReader); + virtual ~AliZDCRawStream(); + + virtual Bool_t Next(); + + Int_t GetSector(Int_t i) const {return fSector[i];}; + Int_t GetADCValue() const {return fADCValue;}; + UInt_t GetADCRaw() const {return fRawADC;}; + Int_t GetADCGain() const {return fADCGain;}; + Bool_t IsADCDataWord() const {return fIsADCDataWord;}; + enum {kDDLOffset = 0xB00}; // offset for DDL numbers + + private : + AliZDCRawStream(const AliZDCRawStream& stream); + AliZDCRawStream& operator = (const AliZDCRawStream& stream); + + AliRawReader* fRawReader; // object for reading the raw data + + UInt_t fRawADC; // raw ADC + Int_t fSector[2]; // index of current sector + Int_t fADCValue; // ADC value; + Int_t fADCGain; // ADC gain (0=high range; 1=low range) + Bool_t fIsADCDataWord; //True when data word + + ClassDef(AliZDCRawStream, 1) // class for reading ZDC raw digits +}; + +#endif diff --git a/ZDC/AliZDCReconstructor.cxx b/ZDC/AliZDCReconstructor.cxx new file mode 100644 index 00000000000..c402397f90e --- /dev/null +++ b/ZDC/AliZDCReconstructor.cxx @@ -0,0 +1,370 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +/////////////////////////////////////////////////////////////////////////////// +// // +// class for ZDC reconstruction // +// // +/////////////////////////////////////////////////////////////////////////////// + + +#include + +#include "AliRunLoader.h" +#include "AliRawReader.h" +#include "AliESD.h" +#include "AliZDCDigit.h" +#include "AliZDCRawStream.h" +#include "AliZDCReco.h" +#include "AliZDCReconstructor.h" + + +ClassImp(AliZDCReconstructor) + + +//_____________________________________________________________________________ +AliZDCReconstructor:: AliZDCReconstructor() +{ +// default constructor + + // --- Number of generated spectator nucleons and impact parameter + // -------------------------------------------------------------------------------------------------- + // [1] ### Results in Chiara's PhD thesis -> 0 0 0 0 0 0GetLoader("ZDCLoader"); + if (!loader) return; + loader->LoadDigits("read"); + loader->LoadRecPoints("recreate"); + AliZDCDigit digit; + AliZDCDigit* pdigit = &digit; + + // Event loop + for (Int_t iEvent = 0; iEvent < runLoader->GetNumberOfEvents(); iEvent++) { + runLoader->GetEvent(iEvent); + + // load digits + loader->LoadDigits(); + TTree* treeD = loader->TreeD(); + if (!treeD) continue; + treeD->SetBranchAddress("ZDC", &pdigit); + + // loop over digits + Int_t znraw=0, zpraw=0, zemraw=0; + for (Int_t iDigit = 0; iDigit < treeD->GetEntries(); iDigit++) { + treeD->GetEntry(iDigit); + if (!pdigit) continue; + + if(digit.GetSector(0) == 1) znraw += digit.GetADCValue(0); + else if(digit.GetSector(0) == 2) zpraw += digit.GetADCValue(0); + else if(digit.GetSector(0) == 3) zemraw += digit.GetADCValue(0); + } + + // reconstruct the event + ReconstructEvent(loader, znraw, zpraw, zemraw); + } + + loader->UnloadDigits(); + loader->UnloadRecPoints(); +} + +//_____________________________________________________________________________ +void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader, + AliRawReader* rawReader) const +{ +// local ZDC reconstruction for raw data + + AliLoader* loader = runLoader->GetLoader("ZDCLoader"); + if (!loader) return; + loader->LoadRecPoints("recreate"); + // Event loop + Int_t iEvent = 0; + while (rawReader->NextEvent()) { + runLoader->GetEvent(iEvent++); + + // loop over raw data digits + Int_t znraw=0, zpraw=0, zemraw=0; + AliZDCRawStream digit(rawReader); + while (digit.Next()) { + if(digit.IsADCDataWord()){ + if(digit.GetADCGain() == 0){ + printf("ADC value = %d\n",digit.GetADCValue()); + if(digit.GetSector(0) == 1) znraw += digit.GetADCValue(); + else if(digit.GetSector(0) == 2) zpraw += digit.GetADCValue(); + else if(digit.GetSector(0) == 3) zemraw += digit.GetADCValue(); + } + } + } + // reconstruct the event + ReconstructEvent(loader, znraw, zpraw, zemraw); + } + + loader->UnloadRecPoints(); +} + +//_____________________________________________________________________________ +void AliZDCReconstructor::ReconstructEvent(AliLoader* loader, Int_t znraw, + Int_t zpraw, Int_t zemraw) const +{ +// reconstruct one event + +// if (GetDebug()) printf("\n --- znraw = %d, zpraw = %d, zemraw = %d\n",znraw, zpraw, zemraw); + + // --- Pedestal subtraction + Int_t zncorr, zpcorr, zemcorr, meanPed=50; + zncorr = znraw - 5*meanPed; + zpcorr = zpraw - 5*meanPed; + zemcorr = zemraw - 2*meanPed; + if(zncorr<0) zncorr=0; + if(zpcorr<0) zpcorr=0; + if(zemcorr<0) zemcorr=0; +// if (GetDebug()) printf("\n zncorr = %d, zpcorr = %d, zemcorr = %d\n",zncorr,zpcorr,zemcorr); + + // --- ADCchannel -> photoelectrons + // NB-> PM gain = 10^(5), ADC resolution = 6.4*10^(-7) + // Move to V965 (E.S.,15/09/04) NB-> PM gain = 10^(5), ADC resolution = 8*10^(-7) + Float_t znphe, zpphe, zemphe, convFactor = 0.08; + znphe = zncorr/convFactor; + zpphe = zpcorr/convFactor; + zemphe = zemcorr/convFactor; +// if (GetDebug()) printf("\n znphe = %f, zpphe = %f, zemphe = %f\n",znphe, zpphe, zemphe); + + // --- Energy calibration + // Conversion factors for hadronic ZDCs goes from phe yield to TRUE + // incident energy (conversion from GeV to TeV is included); while for EM + // calos conversion is from light yield to detected energy calculated by + // GEANT NB -> ZN and ZP conversion factors are constant since incident + // spectators have all the same energy, ZEM energy is obtained through a + // fit over the whole range of incident particle energies + // (obtained with full HIJING simulations) + Float_t znenergy, zpenergy, zemenergy, zdcenergy; + Float_t znphexTeV=329., zpphexTeV=369.; + znenergy = znphe/znphexTeV; + zpenergy = zpphe/zpphexTeV; + zdcenergy = znenergy+zpenergy; + zemenergy = -4.81+0.3238*zemphe; + if(zemenergy<0) zemenergy=0; +// if (GetDebug()) printf(" znenergy = %f TeV, zpenergy = %f TeV, zdcenergy = %f GeV, " +// "\n zemenergy = %f TeV\n", znenergy, zpenergy, +// zdcenergy, zemenergy); + +// if(zdcenergy==0) +// if (GetDebug()) printf("\n\n ### ATTENZIONE!!! -> ev# %d: znenergy = %f TeV, zpenergy = %f TeV, zdcenergy = %f GeV, " +// " zemenergy = %f TeV\n\n", fMerger->EvNum(), znenergy, zpenergy, zdcenergy, zemenergy); + + // --- Number of incident spectator nucleons + Int_t nDetSpecN, nDetSpecP; + nDetSpecN = (Int_t) (znenergy/2.760); + nDetSpecP = (Int_t) (zpenergy/2.760); +// if (GetDebug()) printf("\n nDetSpecN = %d, nDetSpecP = %d\n",nDetSpecN, nDetSpecP); + + Int_t nGenSpecN=0, nGenSpecP=0, nGenSpec=0; + Double_t impPar=0; + // Cut value for Ezem (GeV) + // [1] ### Results in Chiara's PhD thesis -> 0 0 (eZEMCut+deltaEZEMSup)){ + nGenSpecN = (Int_t) (fZNCen->Eval(znenergy)); + nGenSpecP = (Int_t) (fZPCen->Eval(zpenergy)); + nGenSpec = (Int_t) (fZDCCen->Eval(zdcenergy)); + impPar = fbCen->Eval(zdcenergy); + //printf(" fZNCen = %f, fZPCen = %f, fZDCCen = %f\n",fZNCen->Eval(znenergy), + // fZPCen->Eval(zpenergy),fZDCCen->Eval(zdcenergy)); + } + else if(zemenergy < (eZEMCut-deltaEZEMInf)){ + nGenSpecN = (Int_t) (fZNPer->Eval(znenergy)); + nGenSpecP = (Int_t) (fZPPer->Eval(zpenergy)); + nGenSpec = (Int_t) (fZDCPer->Eval(zdcenergy)); + impPar = fbPer->Eval(zdcenergy); + //printf(" fZNPer = %f, fZPPer = %f, fZDCPer = %f\n",fZNPer->Eval(znenergy), + // fZPPer->Eval(zpenergy),fZDCPer->Eval(zdcenergy)); + } + else if(zemenergy >= (eZEMCut-deltaEZEMInf) && zemenergy <= (eZEMCut+deltaEZEMSup)){ + nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy)); + nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy)); + nGenSpec = (Int_t)(fZEMsp->Eval(zemenergy)); + impPar = fZEMb->Eval(zemenergy); + //printf(" Nspec ZEM = %f, Nspec ZDC = %f\n",fZEMsp->Eval(znenergy),fZDCPer->Eval(zdcenergy)); + } + // [1] ### Results in Chiara's PhD thesis -> 0158.5) nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy)); + if(zpenergy>58.91) nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy)); + if(zdcenergy>220.4) nGenSpec = (Int_t)(fZEMsp->Eval(zemenergy)); + if(zdcenergy>225.) impPar = fZEMb->Eval(zemenergy);*/ + // [2] ### Results from a new production -> 0162.) nGenSpecN = (Int_t) (fZEMn->Eval(zemenergy)); + if(zpenergy>59.75) nGenSpecP = (Int_t) (fZEMp->Eval(zemenergy)); + if(zdcenergy>221.5) nGenSpec = (Int_t)(fZEMsp->Eval(zemenergy)); + if(zdcenergy>220.) impPar = fZEMb->Eval(zemenergy); + + if(nGenSpecN>125) nGenSpecN=125; + else if(nGenSpecN<0) nGenSpecN=0; + if(nGenSpecP>82) nGenSpecP=82; + else if(nGenSpecP<0) nGenSpecP=0; + if(nGenSpec>207) nGenSpec=207; + else if(nGenSpec<0) nGenSpec=0; + //printf(" NRecSpecN = %d, NRecSpecP = %d, NRecSpec = %d\n",nGenSpecN,nGenSpecP,nGenSpec); + + // --- Number of participants + Int_t nPart, nPartTot; + nPart = 207-nGenSpecN-nGenSpecP; + nPartTot = 207-nGenSpec; + //printf(" ### nPart(ZP+ZN) = %d, nPart(ZDC) = %d, b = %f fm\n",nPart,nPartTot,impPar); +// if (GetDebug()) printf(" ### nPart = %d, b = %f fm\n",nPartTot,impPar); + + // create the output tree + loader->MakeTree("R"); + TTree* treeR = loader->TreeR(); + AliZDCReco reco(znenergy, zpenergy, zdcenergy, zemenergy, + nDetSpecN, nDetSpecP, nGenSpecN, nGenSpecP, nGenSpec, + nPartTot, impPar); + AliZDCReco* preco = &reco; + const Int_t kBufferSize = 4000; + treeR->Branch("ZDC", "AliZDCReco", &preco, kBufferSize); + + // write the output tree + treeR->Fill(); + loader->WriteRecPoints("OVERWRITE"); +} + +//_____________________________________________________________________________ +void AliZDCReconstructor::FillESD(AliRunLoader* runLoader, + AliESD* esd) const +{ +// fill energies and number of participants to the ESD + + AliLoader* loader = runLoader->GetLoader("ZDCLoader"); + if (!loader) return; + loader->LoadRecPoints(); + + TTree* treeR = loader->TreeR(); + if (!treeR) return; + AliZDCReco reco; + AliZDCReco* preco = &reco; + treeR->SetBranchAddress("ZDC", &preco); + + treeR->GetEntry(0); + esd->SetZDC(reco.GetZNenergy(), reco.GetZPenergy(), reco.GetZEMenergy(), + reco.GetNPart()); + + loader->UnloadRecPoints(); +} diff --git a/ZDC/AliZDCReconstructor.h b/ZDC/AliZDCReconstructor.h new file mode 100644 index 00000000000..77c652ba551 --- /dev/null +++ b/ZDC/AliZDCReconstructor.h @@ -0,0 +1,53 @@ +#ifndef ALIZDCRECONSTRUCTOR_H +#define ALIZDCRECONSTRUCTOR_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +/////////////////////////////////////////////////////////////////////////////// +// // +// class for ZDC reconstruction // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "AliReconstructor.h" + +class TF1; +class AliLoader; + + +class AliZDCReconstructor: public AliReconstructor { +public: + AliZDCReconstructor(); + virtual ~AliZDCReconstructor(); + + virtual void Reconstruct(AliRunLoader* runLoader) const; + virtual void Reconstruct(AliRunLoader* runLoader, + AliRawReader* rawReader) const; + virtual void FillESD(AliRunLoader* runLoader, AliESD* esd) const; + +private: + AliZDCReconstructor(const AliZDCReconstructor& reconstructor); + AliZDCReconstructor& operator = (const AliZDCReconstructor& reconstructor); + + void ReconstructEvent(AliLoader* loader, Int_t znraw, + Int_t zpraw, Int_t zemraw) const; + + TF1* fZNCen; //! Nspectator n true vs. EZN + TF1* fZNPer; //! Nspectator n true vs. EZN + TF1* fZPCen; //! Nspectator p true vs. EZP + TF1* fZPPer; //! Nspectator p true vs. EZP + TF1* fZDCCen; //! Nspectators true vs. EZDC + TF1* fZDCPer; //! Nspectators true vs. EZDC + TF1* fbCen; //! b vs. EZDC + TF1* fbPer; //! b vs. EZDC + TF1* fZEMn; //! Nspectators n from ZEM energy + TF1* fZEMp; //! Nspectators p from ZEM energy + TF1* fZEMsp; //! Nspectators from ZEM energy + TF1* fZEMb; //! b from ZEM energy + + ClassDef(AliZDCReconstructor, 0) // class for the ZDC reconstruction +}; + +#endif diff --git a/ZDC/AliZDCSDigit.cxx b/ZDC/AliZDCSDigit.cxx new file mode 100644 index 00000000000..e9d760d4eb1 --- /dev/null +++ b/ZDC/AliZDCSDigit.cxx @@ -0,0 +1,48 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +/* $Id$ */ + +///_________________________________________________________________________ +/// +/// +/// ZDC summable digit = Cerenkov light for each PM +/// +///_________________________________________________________________________ + +#include "AliZDCSDigit.h" + + +ClassImp(AliZDCSDigit) + +//____________________________________________________________________________ +AliZDCSDigit::AliZDCSDigit() : + fLightPM(0) +{ + // Default constructor + + fSector[0] = 0; + fSector[1] = 0; +} + +//____________________________________________________________________________ +AliZDCSDigit::AliZDCSDigit(Int_t* sector, Float_t lightPM) : + fLightPM(lightPM) +{ + // Constructor + + fSector[0] = sector[0]; + fSector[1] = sector[1]; +} diff --git a/ZDC/AliZDCSDigit.h b/ZDC/AliZDCSDigit.h new file mode 100644 index 00000000000..316cd52348c --- /dev/null +++ b/ZDC/AliZDCSDigit.h @@ -0,0 +1,40 @@ +#ifndef ALIZDCSDIGIT_H +#define ALIZDCSDIGIT_H +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/* $Id$ */ + +///_________________________________________________________________________ +/// +/// +/// ZDC summable digit = Cerenkov light for each PM +/// +///_________________________________________________________________________ + +#include + +class AliZDCSDigit : public TObject { + + public: + + AliZDCSDigit() ; + AliZDCSDigit(Int_t* sector, Float_t lightPM); + virtual ~AliZDCSDigit() {} + + // Getters + Int_t GetSector(Int_t i) const {return fSector[i];} + Float_t GetLightPM() const {return fLightPM;} + + protected: + + //Data members + Int_t fSector[2]; // Detector and tower in which light is produced + Float_t fLightPM; // Cerenkov light seen by the PM + + ClassDef(AliZDCSDigit, 1) // Summable digit in ZDC + +} ; + +#endif // ALIZDCSDIGIT_H + diff --git a/ZDC/libZDC.pkg b/ZDC/libZDC.pkg deleted file mode 100644 index c61fbe845e4..00000000000 --- a/ZDC/libZDC.pkg +++ /dev/null @@ -1,7 +0,0 @@ -SRCS= AliZDC.cxx AliZDCv1.cxx AliZDCv2.cxx AliZDCHit.cxx AliZDCDigit.cxx \ - AliGenZDC.cxx AliZDCFragment.cxx AliZDCMerger.cxx \ - AliZDCMergedHit.cxx AliZDCReco.cxx - -HDRS= $(SRCS:.cxx=.h) - -DHDR:=ZDCLinkDef.h diff --git a/ZDC/libZDCbase.pkg b/ZDC/libZDCbase.pkg new file mode 100644 index 00000000000..78309447931 --- /dev/null +++ b/ZDC/libZDCbase.pkg @@ -0,0 +1,10 @@ +#-*- Mode: Makefile -*- +# $Id$ + +SRCS= AliZDCDigit.cxx AliZDCRawStream.cxx + +HDRS= $(SRCS:.cxx=.h) + +DHDR:=ZDCbaseLinkDef.h + +EINCLUDE:=RAW diff --git a/ZDC/libZDCrec.pkg b/ZDC/libZDCrec.pkg new file mode 100644 index 00000000000..f53af0377c7 --- /dev/null +++ b/ZDC/libZDCrec.pkg @@ -0,0 +1,10 @@ +#-*- Mode: Makefile -*- +# $Id$ + +SRCS= AliZDCReco.cxx AliZDCReconstructor.cxx + +HDRS= $(SRCS:.cxx=.h) + +DHDR:=ZDCrecLinkDef.h + +EINCLUDE:=RAW diff --git a/ZDC/libZDCsim.pkg b/ZDC/libZDCsim.pkg new file mode 100644 index 00000000000..41bffd5a07f --- /dev/null +++ b/ZDC/libZDCsim.pkg @@ -0,0 +1,12 @@ +#-*- Mode: Makefile -*- +# $Id$ + +SRCS= AliZDC.cxx AliZDCv1.cxx AliZDCv2.cxx \ + AliZDCHit.cxx AliZDCSDigit.cxx AliZDCFragment.cxx AliZDCDigitizer.cxx \ + AliGenZDC.cxx AliZDCMergedHit.cxx AliZDCMerger.cxx + +HDRS= $(SRCS:.cxx=.h) + +DHDR:=ZDCsimLinkDef.h + +EINCLUDE:=RAW -- 2.43.5