1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 Revision 1.26.2.2 2001/11/12 18:41:44 hristov
19 All the changes from the head are merged to the release
21 Revision 1.27 2001/10/21 18:27:45 hristov
22 Several pointers were set to zero in the default constructors to avoid memory management problems
24 Revision 1.26 2001/10/04 14:30:28 coppedis
27 Revision 1.25 2001/10/04 14:24:15 coppedis
30 Revision 1.24 2001/09/26 16:03:41 coppedis
33 Revision 1.23 2001/05/15 13:44:57 coppedis
34 Changes in AddHit method
36 Revision 1.22 2001/05/14 09:53:32 coppedis
37 Adding functions ZMin and ZMax
39 Revision 1.21 2001/04/20 10:05:02 coppedis
42 Revision 1.20 2001/03/26 13:39:20 coppedis
45 Revision 1.19 2001/03/26 09:10:23 coppedis
46 Corrected bug in constructor (fIshunt has to be =1)
48 Revision 1.18 2001/03/20 08:21:55 coppedis
49 ZDC needs PIPE, ABSO, DIPO and SHIL
51 Revision 1.17 2001/03/16 16:18:03 coppedis
52 Correction for superposition of ZDC volumes with MUON arm one
54 Revision 1.16 2001/03/15 16:01:11 coppedis
57 Revision 1.15 2001/01/26 19:56:27 hristov
58 Major upgrade of AliRoot code
60 Revision 1.14 2000/12/12 13:17:01 coppedis
61 Minor corrections suggested by P. Hristov
63 Revision 1.12 2000/12/01 08:19:01 coppedis
64 Adding a message error if ZDC is constructed without DIPO
66 Revision 1.11 2000/11/30 17:21:03 coppedis
67 Introduce hit array fStHits reset only at the end of the event (for digitization)
69 Revision 1.10 2000/11/22 11:32:58 coppedis
72 Revision 1.9 2000/10/02 21:28:20 fca
73 Removal of useless dependecies via forward declarations
75 Revision 1.8 2000/07/10 13:58:01 fca
76 New version of ZDC from E.Scomparin & C.Oppedisano
78 Revision 1.7 2000/01/19 17:17:40 fca
80 Revision 1.6 1999/09/29 09:24:35 fca
81 Introduction of the Copyright and cvs Log
85 ///////////////////////////////////////////////////////////////////////////////
87 // Zero Degree Calorimeter //
88 // This class contains the basic functions for the ZDCs; //
89 // functions specific to one particular geometry are //
90 // contained in the derived classes //
92 ///////////////////////////////////////////////////////////////////////////////
100 #include <TGeometry.h>
103 #include <TDirectory.h>
106 // --- AliRoot header files
108 #include "AliZDCHit.h"
109 #include "AliZDCMergedHit.h"
110 #include "AliZDCMerger.h"
111 #include "AliZDCDigit.h"
112 #include "AliZDCReco.h"
113 #include "AliDetector.h"
114 #include "AliCallf77.h"
115 #include "AliConst.h"
118 #include "AliHeader.h"
123 //_____________________________________________________________________________
127 // Default constructor for the Zero Degree Calorimeter base class
149 //_____________________________________________________________________________
150 AliZDC::AliZDC(const char *name, const char *title)
151 : AliDetector(name,title)
154 // Standard constructor for the Zero Degree Calorimeter base class
161 // Allocate the hits array
162 fHits = new TClonesArray("AliZDCHit",1000);
163 gAlice->AddHitList(fHits);
164 // Allocate the merged hits array
165 fMergedHits = new TClonesArray("AliZDCMergedHit",1000);
167 // Allocate the digits array
168 fDigits = new TClonesArray("AliZDCDigit",1000);
177 //____________________________________________________________________________
186 if(fMerger) delete fMerger;
194 // fDigits->Delete();
199 //_____________________________________________________________________________
200 void AliZDC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
203 // Add a ZDC hit to the hit list.
204 // -> We make use of 2 array of hits:
205 // [1] fHits (the usual one) that contains hits for each PRIMARY
206 // [2] fStHits that contains hits for each EVENT and is used to
207 // obtain digits at the end of each event
210 static Float_t primKinEn, xImpact, yImpact, sFlag;
212 AliZDCHit *newquad, *curprimquad;
213 newquad = new AliZDCHit(fIshunt, track, vol, hits);
214 TClonesArray &lhits = *fHits;
217 // First hit -> setting flag for primary or secondary particle
218 Int_t primary = gAlice->GetPrimary(track);
219 if(track != primary){
220 newquad->fSFlag = 1; // SECONDARY particle entering the ZDC
222 else if(track == primary){
223 newquad->fSFlag = 0; // PRIMARY particle entering the ZDC
225 // fNPrimaryHits += 1;
226 sFlag = newquad->fSFlag;
227 primKinEn = newquad->fPrimKinEn;
228 xImpact = newquad->fXImpact;
229 yImpact = newquad->fYImpact;
232 newquad->fPrimKinEn = primKinEn;
233 newquad->fXImpact = xImpact;
234 newquad->fYImpact = yImpact;
235 newquad->fSFlag = sFlag;
239 for(j=0; j<fNhits; j++){
240 // If hits are equal (same track, same volume), sum them.
241 curprimquad = (AliZDCHit*) lhits[j];
242 if(*curprimquad == *newquad){
243 *curprimquad = *curprimquad+*newquad;
249 //Otherwise create a new hit
250 new(lhits[fNhits]) AliZDCHit(newquad);
256 //_____________________________________________________________________________
257 void AliZDC::AddDigit(Int_t *sect, Int_t digit)
260 AliZDCDigit *newdigit;
261 newdigit = new AliZDCDigit(sect, digit);
263 // printf("\n AddDigit -> sector[0] = %d, sector[1] = %d, digit = %d",
264 // sect[0], sect[1], digit);
265 new((*fDigits)[fNdigits]) AliZDCDigit(*newdigit);
270 //_____________________________________________________________________________
271 void AliZDC::BuildGeometry()
274 // Build the ROOT TNode geometry for event display
275 // in the Zero Degree Calorimeter
276 // This routine is dummy for the moment
281 const int kColorZDC = kBlue;
284 top=gAlice->GetGeometry()->GetNode("alice");
287 brik = new TBRIK("S_ZDC","ZDC box","void",300,300,5);
289 node = new TNode("ZDC","ZDC","S_ZDC",0,0,600,"");
290 node->SetLineColor(kColorZDC);
294 //_____________________________________________________________________________
295 Int_t AliZDC::DistancetoPrimitive(Int_t , Int_t )
298 // Distance from the mouse to the Zero Degree Calorimeter
304 //____________________________________________________________________________
305 Float_t AliZDC::ZMin(void) const
307 // Minimum dimension of the ZDC module in z
311 //____________________________________________________________________________
312 Float_t AliZDC::ZMax(void) const
314 // Maximum dimension of the ZDC module in z
319 //_____________________________________________________________________________
320 void AliZDC::MakeBranch(Option_t *opt, const char *file)
323 // Create Tree branches for the ZDC
327 sprintf(branchname,"%s",GetName());
329 AliDetector::MakeBranch(opt);
331 const char *cS = strstr(opt,"S");
333 if (gAlice->TreeS() && cS) {
334 if(fMergedHits!=0) fMergedHits->Clear();
335 else fMergedHits = new TClonesArray ("AliZDCMergedHit",1000);
336 MakeBranchInTree(gAlice->TreeS(),
337 branchname, &fMergedHits, fBufferSize, file) ;
338 printf("* AliZDC::MakeBranch * Making Branch %s for SDigits\n\n",branchname);
342 const char *cD = strstr(opt,"D");
344 if (gAlice->TreeD() && cD) {
345 if(fDigits!=0) fDigits->Clear();
346 else fDigits = new TClonesArray ("AliZDCDigit",1000);
347 MakeBranchInTree(gAlice->TreeD(),
348 branchname, &fDigits, fBufferSize, file) ;
349 printf("* AliZDC::MakeBranch * Making Branch %s for Digits\n\n",branchname);
353 const char *cR = strstr(opt,"R");
355 if (gAlice->TreeR() && cR) {
356 MakeBranchInTree(gAlice->TreeR(),
357 branchname, &fRecPoints, fBufferSize, file) ;
358 printf("* AliZDC::MakeBranch * Making Branch %s for RecPoints\n\n",branchname); }
362 //_____________________________________________________________________________
363 void AliZDC::MakeBranchInTreeSD(TTree *treeSD, const char *file)
366 const Int_t kBufferSize = 4000;
368 sprintf(branchname,"%s",GetName());
369 MakeBranchInTree(treeSD, branchname, &fMergedHits, kBufferSize, file) ;
370 printf("* AliZDC::MakeBranch * Making Branch %s for SDigits\n\n",branchname);
373 //_____________________________________________________________________________
374 void AliZDC::MakeBranchInTreeD(TTree *treeD, const char *file)
377 const Int_t kBufferSize = 4000;
379 sprintf(branchname,"%s",GetName());
380 MakeBranchInTree(treeD, branchname, &fDigits, kBufferSize, file) ;
381 printf("* AliZDC::MakeBranch * Making Branch %s for Digits\n\n",branchname);
384 //_____________________________________________________________________________
385 void AliZDC::MakeBranchInTreeR(TTree *treeR, const char *file)
388 const Int_t kBufferSize = 4000;
390 sprintf(branchname,"%s",GetName());
391 MakeBranchInTree(treeR, branchname, &fRecPoints, kBufferSize, file) ;
392 printf("* AliZDC::MakeBranch * Making Branch %s for RecPoints\n\n",branchname);
395 //_____________________________________________________________________________
396 void AliZDC::Hits2SDigits()
398 printf("\n Entering AliZDC::SDigits2Digits() ");
400 //----------------------------------------------------------------
402 printf(" ZDC digitization (without merging)\n");
404 AliZDCMergedHit *MHit;
409 TTree *treeH = gAlice->TreeH();
410 Int_t ntracks = (Int_t) treeH->GetEntries();
414 for(Int_t itrack=0; itrack<ntracks; itrack++){
415 treeH->GetEvent(itrack);
416 for(AliZDCHit* zdcHit=(AliZDCHit*)this->FirstHit(-1); zdcHit;
417 zdcHit = (AliZDCHit*)this->NextHit()){
419 for(j=0; j<2; j++) sector[j] = zdcHit->GetVolume(j);
420 MHits[0] = zdcHit->GetPrimKinEn();
421 MHits[1] = zdcHit->GetXImpact();
422 MHits[2] = zdcHit->GetYImpact();
423 MHits[3] = zdcHit->GetSFlag();
424 MHits[4] = zdcHit->GetLightPMQ();
425 MHits[5] = zdcHit->GetLightPMC();
426 MHits[6] = zdcHit->GetEnergy();
429 MHit = new AliZDCMergedHit(sector, MHits);
430 new((*fMergedHits)[fNMergedhits]) AliZDCMergedHit(*MHit);
431 TClonesArray &sdigits = *fMergedHits;
432 new (sdigits[fNMergedhits]) AliZDCMergedHit(*MHit);
436 // printf("\n ### Filling SDigits tree\n");
437 gAlice->TreeS()->Fill();
438 gAlice->TreeS()->Write(0,TObject::kOverwrite);
439 gAlice->TreeS()->Reset();
441 //----------------------------------------------------------------
443 printf(" ZDC merging and digitization\n");
444 // ### Initialise merging
445 fMerger -> InitMerging();
447 TFile *bgrFile = fMerger->BgrFile();
450 Int_t fNEvBgr = fMerger->EvNum();
451 char treeSDBgrName[20];
452 sprintf(treeSDBgrName,"TreeS%d",fNEvBgr);
453 fTreeSD = (TTree*)gDirectory->Get(treeSDBgrName); // TreeH
455 printf("\n ERROR -> Can't find TreeS%d in background file\n",fNEvBgr);
458 char branchSDname[20];
459 sprintf(branchSDname,"%s",GetName());
460 if(fTreeSD && fMergedHits){
461 TBranch *branchSD = fTreeSD->GetBranch(branchSDname);
462 if(branchSD) branchSD->SetAddress(&fMergedHits);
463 else if(!branchSD) MakeBranchInTreeSD(fTreeSD);
466 // ### Get TCA of MergedHits from AliZDCMerger
467 fMergedHits = fMerger->MergedHits();
468 fNMergedhits = fMerger->GetNMhits();
469 // printf("\n fNMergedhits (from AliZDCMerger) = %d\n", fNMergedhits);
470 AliZDCMergedHit *MHit;
471 TClonesArray &sdigits = *fMergedHits;
474 for(imhit=0; imhit<fNMergedhits; imhit++){
475 MHit = (AliZDCMergedHit*) fMergedHits->UncheckedAt(imhit);
476 new (sdigits[imhit]) AliZDCMergedHit(*MHit);
479 // printf("\n ### Filling SDigits tree\n");
482 fTreeSD->Write(0,TObject::kOverwrite);
487 //_____________________________________________________________________________
488 void AliZDC::SDigits2Digits()
490 //printf("\n Entering AliZDC::SDigits2Digits() ");
491 if(!fMerger){ // Only digitization
492 printf(" ZDC digitization (without merging) \n");
493 fMerger = new AliZDCMerger();
494 fMerger->Digitize(fNMergedhits, fMergedHits);
497 sprintf(hname,"TreeD%d",gAlice->GetHeader()->GetEvent());
498 gAlice->TreeD()->Fill();
499 gAlice->TreeD()->Write(0,TObject::kOverwrite);
500 gAlice->TreeD()->Reset();
502 else if(fMerger){ // Merging and digitization
503 printf(" ZDC merging and digitization\n");
504 fMerger->Digitize(fNMergedhits, fMergedHits);
506 TFile *bgrFile = fMerger->BgrFile();
509 Int_t fNEvBgr = fMerger->EvNum();
510 //printf(" fNEvBgr = %d\n",fNEvBgr);
511 char treeDBgrName[20];
512 sprintf(treeDBgrName,"TreeD%d",fNEvBgr);
513 fTreeMD = (TTree*)gDirectory->Get(treeDBgrName); // TreeH
515 printf("\n ERROR -> Can't find TreeD%d in background file\n",fNEvBgr);
518 char branchDname[20];
519 sprintf(branchDname,"%s",GetName());
520 if(fTreeMD && fDigits){
521 // printf("\n fTreeMD!=0 && fDigits!=0\n");
522 TBranch *branchD = fTreeMD->GetBranch(branchDname);
523 if(branchD) branchD->SetAddress(&fDigits);
524 else if(!branchD) MakeBranchInTreeD(fTreeMD);
528 fTreeMD->Write(0,TObject::kOverwrite);
533 //_____________________________________________________________________________
534 void AliZDC::Hits2Digits()
536 gAlice->Hits2SDigits();
537 gAlice->SDigits2Digits();
540 //_____________________________________________________________________________
541 void AliZDC::Digits2Reco()
543 //printf("\n Entering AliZDC::Digits2Reco() ");
545 Int_t fNEvBgr = fMerger->EvNum();
546 //printf(" fNEvBgr = %d\n",fNEvBgr);
547 gAlice->GetEvent(fNEvBgr);
549 AliDetector *ZDC = gAlice->GetDetector("ZDC");
550 TClonesArray *ZDCdigits = ZDC->Digits();
553 sprintf(tdname,"TreeD%d",fNEvBgr);
554 TTree *TD = (TTree*)gDirectory->Get(tdname);
555 //TTree *TD = gAlice->TreeD();
557 //printf(" TreeD found in gAlice object\n");
559 sprintf(brname,"%s",ZDC->GetName());
560 TBranch *br = TD->GetBranch(brname);
561 if(br) br->SetAddress(&ZDCdigits);
563 else if(!TD) printf(" ERROR -> TreeD NOT found in gAlice object\n");
565 Int_t nt = (Int_t) (TD->GetEntries());
566 //printf("\n #entries in TreeD = %d\n",nt);
567 gAlice->ResetDigits();
570 Int_t j, idig, ndigits, ZNraw=0, ZPraw=0, ZEMraw=0;
571 // --- Summing raw ADCs for each detector to obtain total light
574 ndigits = ZDCdigits->GetEntries();
575 //printf("\n Entry #%d, ndigits = %d",j,ndigits);
579 // --- Loop over event digits
580 for(idig=0; idig<ndigits; idig++){
581 dig = (AliZDCDigit*) ZDCdigits->UncheckedAt(idig);
582 if(dig->GetSector(0) == 1) ZNraw += dig->GetADCValue();
583 else if(dig->GetSector(0) == 2) ZPraw += dig->GetADCValue();
584 else if(dig->GetSector(0) == 3) ZEMraw += dig->GetADCValue();
586 } // TreeD entries loop
587 printf("\n --- ZNraw = %d, ZPraw = %d, ZEMraw = %d\n",ZNraw, ZPraw, ZEMraw);
589 // --- Pedestal subtraction
590 Int_t ZNcorr, ZPcorr, ZEMcorr, MeanPed=50;
591 ZNcorr = ZNraw - 5*MeanPed;
592 ZPcorr = ZPraw - 5*MeanPed;
593 ZEMcorr = ZEMraw - 2*MeanPed;
594 if(ZNcorr<0) ZNcorr=0;
595 if(ZPcorr<0) ZPcorr=0;
596 if(ZEMcorr<0) ZEMcorr=0;
597 printf("\n ZNcorr = %d, ZPcorr = %d, ZEMcorr = %d\n",ZNcorr,ZPcorr,ZEMcorr);
599 // --- ADCchannel -> photoelectrons
600 // NB-> PM gain = 10^(5), ADC resolution = 6.4*10^(-7)
601 Float_t ZNphe, ZPphe, ZEMphe, ConvFactor = 0.064;
602 ZNphe = ZNcorr/ConvFactor;
603 ZPphe = ZPcorr/ConvFactor;
604 ZEMphe = ZEMcorr/ConvFactor;
605 printf("\n ZNphe = %f, ZPphe = %f, ZEMphe = %f\n",ZNphe, ZPphe, ZEMphe);
607 // --- Energy calibration
608 // Conversion factors for hadronic ZDCs goes from phe yield to TRUE incident
609 // energy (conversion from GeV to TeV is included); while for EM calos
610 // conversion is from light yield to detected energy calculated by GEANT
611 // NB -> ZN and ZP conversion factors are constant since incident spectators
612 // have all the same energy, ZEM energy is obtained through a fit over the whole
613 // range of incident particle energies (obtained with full HIJING simulations)
614 Float_t ZNenergy, ZPenergy, ZEMenergy, ZDCenergy;
615 Float_t ZNphexTeV=329., ZPphexTeV=369.;
616 ZNenergy = ZNphe/ZNphexTeV;
617 ZPenergy = ZPphe/ZPphexTeV;
618 ZDCenergy = ZNenergy+ZPenergy;
619 ZEMenergy = -4.81+0.3238*ZEMphe;
620 if(ZEMenergy<0) ZEMenergy=0;
621 printf(" ZNenergy = %f TeV, ZPenergy = %f TeV, ZDCenergy = %f GeV, "
622 "\n ZEMenergy = %f TeV\n", ZNenergy, ZPenergy,
623 ZDCenergy, ZEMenergy);
626 printf("\n\n ### ATTENZIONE!!! -> ev# %d: ZNenergy = %f TeV, ZPenergy = %f TeV, ZDCenergy = %f GeV, "
627 " ZEMenergy = %f TeV\n\n", fNEvBgr, ZNenergy, ZPenergy, ZDCenergy, ZEMenergy);
629 // --- Number of incident spectator nucleons
630 Int_t NDetSpecN, NDetSpecP;
631 NDetSpecN = (Int_t) (ZNenergy/2.760);
632 NDetSpecP = (Int_t) (ZPenergy/2.760);
633 printf("\n NDetSpecN = %d, NDetSpecP = %d\n",NDetSpecN, NDetSpecP);
635 // --- Number of generated spectator nucleons and impact parameter
636 // Fit results for neutrons (Nspectator n true vs. EZN)
637 TF1 *fZNCen = new TF1("fZNCen",
638 "(-2.116909+sqrt(2.116909*2.116909-4*(-0.00651)*(14.556798-x)))/(2*(-0.00651))",0.,158.5);
639 TF1 *fZNPer = new TF1("fZNPer",
640 "(-34.695134-sqrt(34.695134*34.695134-4*(-0.174780)*(-1562.283443-x)))/(2*(-0.174780))",0.,158.5);
641 // Fit results for protons (Nspectator p true vs. EZP)
642 TF1 *fZPCen = new TF1("fZPCen",
643 "(-1.3217+sqrt(1.3217*1.3217-4*(-0.007934)*(4.742873-x)))/(2*(-0.007934))",0.,58.91);
644 TF1 *fZPPer = new TF1("fZPPer",
645 "(-15.788267-sqrt(15.788267*15.788267-4*(-0.133359)*(-383.800673-x)))/(2*(-0.133359))",0.,58.91);
646 // Fit results for total number of spectators (Nspectators true vs. EZDC)
647 TF1 *fZDCCen = new TF1("fZDCCen",
648 "(-1.867335+sqrt(1.867335*1.867335-4*(-0.004119)*(19.100289-x)))/(2*(-0.004119))",0.,220.4);
649 TF1 *fZDCPer = new TF1("fZDCPer",
650 "(-22.429097-sqrt(22.429097*22.429097-4*(-0.072435)*(-1482.034526-x)))/(2*(-0.072435))",0.,220.4);
651 // Fit results for b (b vs. EZDC)
652 //TF1 *fbCen = new TF1("fbCen","0.611543+0.052231*x-0.000112*x*x+0.000000374*x*x*x",0.,222.);
653 //TF1 *fbPer = new TF1("fbPer","16.552010-0.023866*x-0.00001*x*x",0.,222.);
654 TF1 *fbCen = new TF1("fbCen","0.612769+0.051929*x-0.0001074*x*x+0.0000003724*x*x*x",0.,225.);
655 TF1 *fbPer = new TF1("fbPer","16.6131016-0.026053*x+0.000006893*x*x",0.,225.);
656 // Evaluating Nspectators and b from ZEM energy
657 TF1 *fZEMn = new TF1("fZEMn","124.2-0.0566*x+0.000006014*x*x",0.,3500.);
658 TF1 *fZEMp = new TF1("fZEMp","81.3-0.03834*x+0.000004359*x*x",0.,3500.);
659 TF1 *fZEMsp = new TF1("fZEMsp","205.6-0.09567*x+0.00001056*x*x",0.,3500.);
660 TF1 *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.);
662 Int_t NGenSpecN=0, NGenSpecP=0, NGenSpec=0;
664 Float_t EZEMCut = 360.; // Cut value for Ezem (GeV)
665 if(ZEMenergy >= EZEMCut){
666 NGenSpecN = (Int_t) (fZNCen->Eval(ZNenergy));
667 NGenSpecP = (Int_t) (fZPCen->Eval(ZPenergy));
668 NGenSpec = (Int_t) (fZDCCen->Eval(ZDCenergy));
669 ImpPar = fbCen->Eval(ZDCenergy);
670 //printf(" fZNCen = %f, fZPCen = %f, fZDCCen = %f\n",fZNCen->Eval(ZNenergy),
671 // fZPCen->Eval(ZPenergy),fZDCCen->Eval(ZDCenergy));
673 else if(ZEMenergy < EZEMCut){
674 NGenSpecN = (Int_t) (fZNPer->Eval(ZNenergy));
675 NGenSpecP = (Int_t) (fZPPer->Eval(ZPenergy));
676 NGenSpec = (Int_t) (fZDCPer->Eval(ZDCenergy));
677 ImpPar = fbPer->Eval(ZDCenergy);
678 //printf(" fZNPer = %f, fZPPer = %f, fZDCPer = %f\n",fZNPer->Eval(ZNenergy),
679 // fZPPer->Eval(ZPenergy),fZDCPer->Eval(ZDCenergy));
681 if(ZNenergy>158.5) NGenSpecN = (Int_t) (fZEMn->Eval(ZEMenergy));
682 if(ZPenergy>58.91) NGenSpecP = (Int_t) (fZEMp->Eval(ZEMenergy));
683 if(ZDCenergy>220.4) NGenSpec = (Int_t)(fZEMsp->Eval(ZEMenergy));
684 if(ZDCenergy>225.) ImpPar = fZEMb->Eval(ZEMenergy);
685 /*if(ZNenergy>158.5) NGenSpecN = -999;
686 if(ZPenergy>58.91) NGenSpecP = -999;
687 if(ZDCenergy>220.4) NGenSpec = -999;
688 if(ZDCenergy>225.) ImpPar = -999;*/
690 if(NGenSpecN>125) NGenSpecN=125;
691 else if(NGenSpecN<0) NGenSpecN=0;
692 if(NGenSpecP>82) NGenSpecP=82;
693 else if(NGenSpecP<0) NGenSpecP=0;
694 if(NGenSpec>207) NGenSpec=207;
695 else if(NGenSpec<0) NGenSpec=0;
696 printf(" NRecSpecN = %d, NRecSpecP = %d, NRecSpec = %d\n",NGenSpecN,NGenSpecP,NGenSpec);
698 // --- Number of participants
699 Int_t NPart, NPartTot;
700 NPart = 208-NGenSpecN-NGenSpecP;
701 NPartTot = 208-NGenSpec;
702 printf(" ### NPart(ZP+ZN) = %d, NPart(ZDC) = %d, b = %f fm\n",NPart,NPartTot,ImpPar);
704 // --- Writing RecPoints TCA
705 // Allocate the RecPoints TCA
706 fRecPoints = new TClonesArray("AliZDCReco",1000);
707 AliZDCReco *reco = new AliZDCReco(ZNenergy,ZPenergy,ZDCenergy,ZEMenergy,
708 NDetSpecN,NDetSpecP,NGenSpecN,NGenSpecP,NGenSpec,NPartTot,ImpPar);
709 new((*fRecPoints)[fNRecPoints]) AliZDCReco(*reco);
710 //printf(" fNRecPoints = %d \n",fNRecPoints );
712 //fRecPoints->Dump();
716 TTree *treeR = gAlice->TreeR();
718 sprintf(tname,"TreeR%d",fNEvBgr);
719 if(!treeR) printf("\n ERROR -> Can't find TreeR%d in background file\n",fNEvBgr);
721 char branchRname[20];
722 sprintf(branchRname,"%s",GetName());
724 TBranch *branchR = treeR->GetBranch(branchRname);
725 if(branchR) branchR->SetAddress(&fRecPoints);
726 else if(!branchR) MakeBranchInTreeR(treeR);
729 treeR->Write(tname,TObject::kOverwrite);
734 //_____________________________________________________________________________
735 void AliZDC::SetMerger(AliZDCMerger* merger)
737 // Set pointer to merger
741 //_____________________________________________________________________________
742 AliZDCMerger* AliZDC::Merger()
744 // Return pointer to merger