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.3 2001/10/21 18:36:31 hristov
19 Several pointers were set to zero in the default constructors to avoid memory management problems
21 Revision 1.2 2001/09/24 16:41:15 hristov
22 New version of FMD code (A.Maevskaia)
24 Revision 1.1 2001/05/29 12:01:06 hristov
25 Last minute changes and new code for event mixing and reconstruction (A.Maevskaia)
27 Revision 1.3 2001/03/05 23:57:44 morsch
28 Writing of digit tree moved to macro.
30 Revision 1.2 2001/03/05 08:40:25 morsch
31 Method SortTracks(..) imported from AliMUON.
33 Revision 1.1 2001/02/02 14:11:53 morsch
34 AliMUONMerger prototype to be called by the merge manager.
40 #include <TObjArray.h>
42 #include <TDirectory.h>
45 #include "AliFMDMerger.h"
47 #include "AliFMDSDigitizer.h"
48 #include "AliFMDhit.h"
49 #include "AliFMDdigit.h"
55 #include <Riostream.h>
56 #include <Riostream.h>
58 ClassImp(AliFMDMerger)
60 //___________________________________________
61 AliFMDMerger::AliFMDMerger()
63 // Default constructor
74 //------------------------------------------------------------------------
75 AliFMDMerger::~AliFMDMerger()
86 //---------------------------------------------------------------------
87 void AliFMDMerger::SetRingsSi1(Int_t ringsSi1)
91 void AliFMDMerger::SetSectorsSi1(Int_t sectorsSi1)
93 fSectorsSi1=sectorsSi1;
95 void AliFMDMerger::SetRingsSi2(Int_t ringsSi2)
99 void AliFMDMerger::SetSectorsSi2(Int_t sectorsSi2)
101 fSectorsSi2=sectorsSi2;
103 //---------------------------------------------------------------------
105 //------------------------------------------------------------------------
106 void AliFMDMerger::Init()
109 if (fMerge) fBgrFile = InitBgr();
115 //------------------------------------------------------------------------
116 TFile* AliFMDMerger::InitBgr()
118 // Initialise background event
119 TFile *file = new TFile(fFnBgr);
120 // add error checking later
121 printf("\n AliFMDMerger has opened %s file with background event \n", fFnBgr);
125 //------------------------------------------------------------------------
126 void AliFMDMerger::Digitise()
129 // keep galice.root for signal and name differently the file for
130 // background when add! otherwise the track info for signal will be lost !
135 cout<<"ALiFMDMerger::>SDigits2Digits start...\n";
138 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
140 Int_t chargeSum[10][30][150];
142 Int_t ivol, iSector, iRing;
144 Int_t NumberOfRings[5]=
145 {fRingsSi1,fRingsSi2,fRingsSi1,fRingsSi2,fRingsSi1};
146 Int_t NumberOfSectors[5]=
147 {fSectorsSi1,fSectorsSi2,fSectorsSi1,fSectorsSi2,fSectorsSi1};
150 TTree *TK = gAlice->TreeK();
151 if (TK) f1 = TK->GetCurrentFile();
153 gAlice->GetEvent(fEvNrSig) ;
155 if(gAlice->TreeD() == 0)
156 gAlice->MakeTree("D") ;
157 gAlice->TreeD()->Reset();
160 ReadDigit( chargeSum, fEvNrSig);
164 // gAlice->TreeS()->Reset();
165 gAlice = (AliRun*)fBgrFile->Get("gAlice");
166 Int_t chargeBgr[10][30][150];
167 ReadDigit( chargeBgr,fEvNrBgr);
168 for ( ivol=1; ivol<=5; ivol++)
169 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++)
170 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++)
171 chargeSum[ivol][iSector][iRing]=
172 chargeBgr[ivol][iSector][iRing]+
173 chargeSum[ivol][iSector][iRing];
178 // Put noise and make ADC signal
179 for ( ivol=1; ivol<=5; ivol++){
180 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++){
181 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++){
185 digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]);
186 if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500;
188 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
190 Float_t channelWidth=(22400*50)/1024;
191 digit[4]=Int_t(digit[3]/channelWidth);
192 if (digit[4]>1024) digit[4]=1024;
194 FMD->AddDigit(digit);
202 //Make branch for digits
203 FMD->MakeBranch("D");
205 gAlice->TreeD()->Reset();
206 gAlice->TreeD()->Fill();
208 fDigits = FMD->Digits();
210 gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
212 gAlice->ResetDigits();
216 //---------------------------------------------------------------------
218 void AliFMDMerger::ReadDigit(Int_t chargeSum[][30][150], Int_t iEvNum)
220 AliFMDdigit *fmddigit;
222 for (Int_t i=0; i<10; i++)
223 for(Int_t j=0; j<30; j++)
224 for(Int_t ij=0; ij<150; ij++)
225 chargeSum[i][j][ij]=0;
227 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
229 gAlice->GetEvent(iEvNum) ;
230 if(gAlice->TreeS()==0) {
231 cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl;
235 gAlice->ResetDigits();
236 gAlice->TreeS()->GetEvent(iEvNum);
237 TClonesArray * FMDdigits = FMD->SDigits();
239 ndig=FMDdigits->GetEntries();
241 for (k=0; k<ndig; k++) {
242 fmddigit= (AliFMDdigit*) FMDdigits->UncheckedAt(k);
244 Int_t iVolume=fmddigit->Volume();
245 Int_t iNumberOfSector =fmddigit->NumberOfSector();
246 Int_t iNumberOfRing=fmddigit->NumberOfRing();
247 chargeSum[iVolume][iNumberOfSector][iNumberOfRing]=fmddigit->Charge();