--- /dev/null
+/**************************************************************************
+ * 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 <stdlib.h>
+
+// --- ROOT system
+#include <TTree.h>
+#include <TFile.h>
+#include <TNtuple.h>
+#include <TRandom.h>
+
+// --- 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;pl<numEvents;pl++){
+ rnd[pl] = (Int_t) (9999*gRandom->Rndm());
+ 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; i<nentries; i++){
+ zdcSignal->GetEvent(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(iev<numEvents);
+
+ file->Close();
+ 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);
+}
--- /dev/null
+#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
--- /dev/null
+/**************************************************************************
+ * 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;
+}
--- /dev/null
+#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 <TObject.h>
+
+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
--- /dev/null
+/**************************************************************************
+ * 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 <TF1.h>
+
+#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<b<15 fm (Dec 2001)
+ /*// Fit results for neutrons (Nspectator n true vs. EZN)
+ fZNCen = new TF1("fZNCen",
+ "(-2.116909+sqrt(2.116909*2.116909-4*(-0.00651)*(14.556798-x)))/(2*(-0.00651))",0.,158.5);
+ fZNPer = new TF1("fZNPer",
+ "(-34.695134-sqrt(34.695134*34.695134-4*(-0.174780)*(-1562.283443-x)))/(2*(-0.174780))",0.,158.5);
+ // Fit results for protons (Nspectator p true vs. EZP)
+ fZPCen = new TF1("fZPCen",
+ "(-1.3217+sqrt(1.3217*1.3217-4*(-0.007934)*(4.742873-x)))/(2*(-0.007934))",0.,58.91);
+ fZPPer = new TF1("fZPPer",
+ "(-15.788267-sqrt(15.788267*15.788267-4*(-0.133359)*(-383.800673-x)))/(2*(-0.133359))",0.,58.91);
+ // Fit results for total number of spectators (Nspectators true vs. EZDC)
+ fZDCCen = new TF1("fZDCCen",
+ "(-1.867335+sqrt(1.867335*1.867335-4*(-0.004119)*(19.100289-x)))/(2*(-0.004119))",0.,220.4);
+ fZDCPer = new TF1("fZDCPer",
+ "(-22.429097-sqrt(22.429097*22.429097-4*(-0.072435)*(-1482.034526-x)))/(2*(-0.072435))",0.,220.4);*/
+ // --------------------------------------------------------------------------------------------------
+ // [1] ### Results from a new production -> 0<b<18 fm (Apr 2002)
+ // Fit results for neutrons (Nspectator n true vs. EZN)
+ fZNCen = new TF1("fZNCen",
+ "(-2.287920+sqrt(2.287920*2.287920-4*(-0.007629)*(11.921710-x)))/(2*(-0.007629))",0.,164.);
+ fZNPer = new TF1("fZNPer",
+ "(-37.812280-sqrt(37.812280*37.812280-4*(-0.190932)*(-1709.249672-x)))/(2*(-0.190932))",0.,164.);
+ // Fit results for protons (Nspectator p true vs. EZP)
+ fZPCen = new TF1("fZPCen",
+ "(-1.321353+sqrt(1.321353*1.321353-4*(-0.007283)*(3.550697-x)))/(2*(-0.007283))",0.,60.);
+ fZPPer = new TF1("fZPPer",
+ "(-42.643308-sqrt(42.643308*42.643308-4*(-0.310786)*(-1402.945615-x)))/(2*(-0.310786))",0.,60.);
+ // Fit results for total number of spectators (Nspectators true vs. EZDC)
+ fZDCCen = new TF1("fZDCCen",
+ "(-1.934991+sqrt(1.934991*1.934991-4*(-0.004080)*(15.111124-x)))/(2*(-0.004080))",0.,225.);
+ fZDCPer = new TF1("fZDCPer",
+ "(-34.380639-sqrt(34.380639*34.380639-4*(-0.104251)*(-2612.189017-x)))/(2*(-0.104251))",0.,225.);
+ // --------------------------------------------------------------------------------------------------
+ // [1] ### Results in Chiara's PhD thesis -> 0<b<15 fm (Dec 2001)
+ /*// Fit results for b (b vs. EZDC)
+ //fbCen = new TF1("fbCen","0.611543+0.052231*x-0.000112*x*x+0.000000374*x*x*x",0.,222.);
+ //fbPer = new TF1("fbPer","16.552010-0.023866*x-0.00001*x*x",0.,222.);
+ fbCen = new TF1("fbCen","0.612769+0.051929*x-0.0001074*x*x+0.0000003724*x*x*x",0.,225.);
+ fbPer = new TF1("fbPer","16.6131016-0.026053*x+0.000006893*x*x",0.,225.);*/
+ // --------------------------------------------------------------------------------------------------
+ // [2] ### Results from a new production -> 0<b<18 fm (Apr 2002)
+ fbCen = new TF1("fbCen","-0.056923+0.079703*x-0.0004301*x*x+0.000001366*x*x*x",0.,220.);
+ fbPer = new TF1("fbPer","17.943998-0.046846*x+0.000074*x*x",0.,220.);
+ // --------------------------------------------------------------------------------------------------
+ // Evaluating Nspectators and b from ZEM energy
+ // [1] ### Results in Chiara's PhD thesis -> 0<b<15 fm (Dec 2001)
+ /*fZEMn = new TF1("fZEMn","124.2-0.0566*x+0.000006014*x*x",0.,3500.);
+ fZEMp = new TF1("fZEMp","81.3-0.03834*x+0.000004359*x*x",0.,3500.);
+ fZEMsp = new TF1("fZEMsp","205.6-0.09567*x+0.00001056*x*x",0.,3500.);
+ fZEMb = new TF1("fZEMb","15.8-0.02084*x+2.802e-5*x*x-2.007e-8*x*x*x+6.586e-12*x*x*x*x-8.042e-16*x*x*x*x*x",0.,3500.);*/
+ // --------------------------------------------------------------------------------------------------
+ // [2] ### Results from a new production -> 0<b<18 fm (Apr 2002)
+ fZEMn = new TF1("fZEMn","126.2-0.05399*x+0.000005679*x*x",0.,4000.);
+ fZEMp = new TF1("fZEMp","82.49-0.03611*x+0.00000385*x*x",0.,4000.);
+ fZEMsp = new TF1("fZEMsp","208.7-0.09006*x+0.000009526*x*x",0.,4000.);
+ fZEMb = new TF1("fZEMb","16.06-0.01633*x+1.44e-5*x*x-6.778e-9*x*x*x+1.438e-12*x*x*x*x-1.112e-16*x*x*x*x*x",0.,4000.);
+}
+
+//_____________________________________________________________________________
+AliZDCReconstructor::AliZDCReconstructor(const AliZDCReconstructor&
+ reconstructor):
+ AliReconstructor(reconstructor)
+{
+// copy constructor
+
+ Fatal("AliZDCReconstructor", "copy constructor not implemented");
+}
+
+//_____________________________________________________________________________
+AliZDCReconstructor& AliZDCReconstructor::operator =
+ (const AliZDCReconstructor& /*reconstructor*/)
+{
+// assignment operator
+
+ Fatal("operator =", "assignment operator not implemented");
+ return *this;
+}
+
+//_____________________________________________________________________________
+AliZDCReconstructor::~AliZDCReconstructor()
+{
+// destructor
+
+ delete fZNCen;
+ delete fZNPer;
+ delete fZPCen;
+ delete fZPPer;
+ delete fZDCCen;
+ delete fZDCPer;
+ delete fbCen;
+ delete fbPer;
+ delete fZEMn;
+ delete fZEMp;
+ delete fZEMsp;
+ delete fZEMb;
+}
+
+
+//_____________________________________________________________________________
+void AliZDCReconstructor::Reconstruct(AliRunLoader* runLoader) const
+{
+// local ZDC reconstruction
+
+ AliLoader* loader = runLoader->GetLoader("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<b<15 fm (Dec 2001)
+ //Float_t eZEMCut = 360.;
+ // [2] ### Results from a new production -> 0<b<18 fm (Apr 2002)
+ Float_t eZEMCut = 420.;
+ Float_t deltaEZEMSup = 690.;
+ Float_t deltaEZEMInf = 270.;
+ if(zemenergy > (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 -> 0<b<15 fm (Dec 2001)
+ /*if(znenergy>158.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 -> 0<b<18 fm (Apr 2002)
+ if(znenergy>162.) 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();
+}
--- /dev/null
+#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
--- /dev/null
+/**************************************************************************
+ * 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];
+}
--- /dev/null
+#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 <TObject.h>
+
+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
+
+++ /dev/null
-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
--- /dev/null
+#-*- Mode: Makefile -*-
+# $Id$
+
+SRCS= AliZDCDigit.cxx AliZDCRawStream.cxx
+
+HDRS= $(SRCS:.cxx=.h)
+
+DHDR:=ZDCbaseLinkDef.h
+
+EINCLUDE:=RAW
--- /dev/null
+#-*- Mode: Makefile -*-
+# $Id$
+
+SRCS= AliZDCReco.cxx AliZDCReconstructor.cxx
+
+HDRS= $(SRCS:.cxx=.h)
+
+DHDR:=ZDCrecLinkDef.h
+
+EINCLUDE:=RAW
--- /dev/null
+#-*- 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