1 /**************************************************************************
2 * Copyright(c) 1998-2000, 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.1 2001/05/29 12:01:06 hristov
19 Last minute changes and new code for event mixing and reconstruction (A.Maevskaia)
21 Revision 1.3 2001/03/05 23:57:44 morsch
22 Writing of digit tree moved to macro.
24 Revision 1.2 2001/03/05 08:40:25 morsch
25 Method SortTracks(..) imported from AliMUON.
27 Revision 1.1 2001/02/02 14:11:53 morsch
28 AliMUONMerger prototype to be called by the merge manager.
34 #include <TObjArray.h>
36 #include <TDirectory.h>
39 #include "AliFMDMerger.h"
41 #include "AliFMDSDigitizer.h"
42 #include "AliFMDhit.h"
43 #include "AliFMDdigit.h"
52 ClassImp(AliFMDMerger)
54 //___________________________________________
55 AliFMDMerger::AliFMDMerger()
57 // Default constructor
64 //------------------------------------------------------------------------
65 AliFMDMerger::~AliFMDMerger()
76 //---------------------------------------------------------------------
77 void AliFMDMerger::SetRingsSi1(Int_t ringsSi1)
81 void AliFMDMerger::SetSectorsSi1(Int_t sectorsSi1)
83 fSectorsSi1=sectorsSi1;
85 void AliFMDMerger::SetRingsSi2(Int_t ringsSi2)
89 void AliFMDMerger::SetSectorsSi2(Int_t sectorsSi2)
91 fSectorsSi2=sectorsSi2;
93 //---------------------------------------------------------------------
95 //------------------------------------------------------------------------
96 void AliFMDMerger::Init()
99 if (fMerge) fBgrFile = InitBgr();
105 //------------------------------------------------------------------------
106 TFile* AliFMDMerger::InitBgr()
108 // Initialise background event
109 TFile *file = new TFile(fFnBgr);
110 // add error checking later
111 printf("\n AliFMDMerger has opened %s file with background event \n", fFnBgr);
115 //------------------------------------------------------------------------
116 void AliFMDMerger::Digitise()
119 // keep galice.root for signal and name differently the file for
120 // background when add! otherwise the track info for signal will be lost !
125 cout<<"ALiFMDMerger::>SDigits2Digits start...\n";
128 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
130 Int_t chargeSum[10][30][150];
132 Int_t ivol, iSector, iRing;
134 Int_t NumberOfRings[5]=
135 {fRingsSi1,fRingsSi2,fRingsSi1,fRingsSi2,fRingsSi1};
136 Int_t NumberOfSectors[5]=
137 {fSectorsSi1,fSectorsSi2,fSectorsSi1,fSectorsSi2,fSectorsSi1};
140 TTree *TK = gAlice->TreeK();
141 if (TK) f1 = TK->GetCurrentFile();
143 gAlice->GetEvent(fEvNrSig) ;
145 if(gAlice->TreeD() == 0)
146 gAlice->MakeTree("D") ;
147 gAlice->TreeD()->Reset();
150 ReadDigit( chargeSum, fEvNrSig);
154 // gAlice->TreeS()->Reset();
155 gAlice = (AliRun*)fBgrFile->Get("gAlice");
156 Int_t chargeBgr[10][30][150];
157 ReadDigit( chargeBgr,fEvNrBgr);
158 for ( ivol=1; ivol<=5; ivol++)
159 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++)
160 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++)
161 chargeSum[ivol][iSector][iRing]=
162 chargeBgr[ivol][iSector][iRing]+
163 chargeSum[ivol][iSector][iRing];
168 // Put noise and make ADC signal
169 for ( ivol=1; ivol<=5; ivol++){
170 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++){
171 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++){
175 digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]);
176 if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500;
178 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
180 Float_t channelWidth=(22400*50)/1024;
181 digit[4]=Int_t(digit[3]/channelWidth);
182 if (digit[4]>1024) digit[4]=1024;
184 FMD->AddDigit(digit);
192 //Make branch for digits
193 FMD->MakeBranch("D");
195 gAlice->TreeD()->Reset();
196 gAlice->TreeD()->Fill();
198 fDigits = FMD->Digits();
200 gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
202 gAlice->ResetDigits();
206 //---------------------------------------------------------------------
208 void AliFMDMerger::ReadDigit(Int_t chargeSum[][30][150], Int_t iEvNum)
210 AliFMDdigit *fmddigit;
212 for (Int_t i=0; i<10; i++)
213 for(Int_t j=0; j<30; j++)
214 for(Int_t ij=0; ij<150; ij++)
215 chargeSum[i][j][ij]=0;
217 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
219 gAlice->GetEvent(iEvNum) ;
220 if(gAlice->TreeS()==0) {
221 cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl;
225 gAlice->ResetDigits();
226 gAlice->TreeS()->GetEvent(iEvNum);
227 TClonesArray * FMDdigits = FMD->SDigits();
229 ndig=FMDdigits->GetEntries();
231 for (k=0; k<ndig; k++) {
232 fmddigit= (AliFMDdigit*) FMDdigits->UncheckedAt(k);
234 Int_t iVolume=fmddigit->Volume();
235 Int_t iNumberOfSector =fmddigit->NumberOfSector();
236 Int_t iNumberOfRing=fmddigit->NumberOfRing();
237 chargeSum[iVolume][iNumberOfSector][iNumberOfRing]=fmddigit->Charge();