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.2 2001/09/24 16:41:15 hristov
19 New version of FMD code (A.Maevskaia)
21 Revision 1.1 2001/05/29 12:01:06 hristov
22 Last minute changes and new code for event mixing and reconstruction (A.Maevskaia)
24 Revision 1.3 2001/03/05 23:57:44 morsch
25 Writing of digit tree moved to macro.
27 Revision 1.2 2001/03/05 08:40:25 morsch
28 Method SortTracks(..) imported from AliMUON.
30 Revision 1.1 2001/02/02 14:11:53 morsch
31 AliMUONMerger prototype to be called by the merge manager.
37 #include <TObjArray.h>
39 #include <TDirectory.h>
42 #include "AliFMDMerger.h"
44 #include "AliFMDSDigitizer.h"
45 #include "AliFMDhit.h"
46 #include "AliFMDdigit.h"
55 ClassImp(AliFMDMerger)
57 //___________________________________________
58 AliFMDMerger::AliFMDMerger()
60 // Default constructor
71 //------------------------------------------------------------------------
72 AliFMDMerger::~AliFMDMerger()
83 //---------------------------------------------------------------------
84 void AliFMDMerger::SetRingsSi1(Int_t ringsSi1)
88 void AliFMDMerger::SetSectorsSi1(Int_t sectorsSi1)
90 fSectorsSi1=sectorsSi1;
92 void AliFMDMerger::SetRingsSi2(Int_t ringsSi2)
96 void AliFMDMerger::SetSectorsSi2(Int_t sectorsSi2)
98 fSectorsSi2=sectorsSi2;
100 //---------------------------------------------------------------------
102 //------------------------------------------------------------------------
103 void AliFMDMerger::Init()
106 if (fMerge) fBgrFile = InitBgr();
112 //------------------------------------------------------------------------
113 TFile* AliFMDMerger::InitBgr()
115 // Initialise background event
116 TFile *file = new TFile(fFnBgr);
117 // add error checking later
118 printf("\n AliFMDMerger has opened %s file with background event \n", fFnBgr);
122 //------------------------------------------------------------------------
123 void AliFMDMerger::Digitise()
126 // keep galice.root for signal and name differently the file for
127 // background when add! otherwise the track info for signal will be lost !
132 cout<<"ALiFMDMerger::>SDigits2Digits start...\n";
135 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
137 Int_t chargeSum[10][30][150];
139 Int_t ivol, iSector, iRing;
141 Int_t NumberOfRings[5]=
142 {fRingsSi1,fRingsSi2,fRingsSi1,fRingsSi2,fRingsSi1};
143 Int_t NumberOfSectors[5]=
144 {fSectorsSi1,fSectorsSi2,fSectorsSi1,fSectorsSi2,fSectorsSi1};
147 TTree *TK = gAlice->TreeK();
148 if (TK) f1 = TK->GetCurrentFile();
150 gAlice->GetEvent(fEvNrSig) ;
152 if(gAlice->TreeD() == 0)
153 gAlice->MakeTree("D") ;
154 gAlice->TreeD()->Reset();
157 ReadDigit( chargeSum, fEvNrSig);
161 // gAlice->TreeS()->Reset();
162 gAlice = (AliRun*)fBgrFile->Get("gAlice");
163 Int_t chargeBgr[10][30][150];
164 ReadDigit( chargeBgr,fEvNrBgr);
165 for ( ivol=1; ivol<=5; ivol++)
166 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++)
167 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++)
168 chargeSum[ivol][iSector][iRing]=
169 chargeBgr[ivol][iSector][iRing]+
170 chargeSum[ivol][iSector][iRing];
175 // Put noise and make ADC signal
176 for ( ivol=1; ivol<=5; ivol++){
177 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++){
178 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++){
182 digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]);
183 if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500;
185 //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV)
187 Float_t channelWidth=(22400*50)/1024;
188 digit[4]=Int_t(digit[3]/channelWidth);
189 if (digit[4]>1024) digit[4]=1024;
191 FMD->AddDigit(digit);
199 //Make branch for digits
200 FMD->MakeBranch("D");
202 gAlice->TreeD()->Reset();
203 gAlice->TreeD()->Fill();
205 fDigits = FMD->Digits();
207 gAlice->TreeD()->Write(0,TObject::kOverwrite) ;
209 gAlice->ResetDigits();
213 //---------------------------------------------------------------------
215 void AliFMDMerger::ReadDigit(Int_t chargeSum[][30][150], Int_t iEvNum)
217 AliFMDdigit *fmddigit;
219 for (Int_t i=0; i<10; i++)
220 for(Int_t j=0; j<30; j++)
221 for(Int_t ij=0; ij<150; ij++)
222 chargeSum[i][j][ij]=0;
224 AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ;
226 gAlice->GetEvent(iEvNum) ;
227 if(gAlice->TreeS()==0) {
228 cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl;
232 gAlice->ResetDigits();
233 gAlice->TreeS()->GetEvent(iEvNum);
234 TClonesArray * FMDdigits = FMD->SDigits();
236 ndig=FMDdigits->GetEntries();
238 for (k=0; k<ndig; k++) {
239 fmddigit= (AliFMDdigit*) FMDdigits->UncheckedAt(k);
241 Int_t iVolume=fmddigit->Volume();
242 Int_t iNumberOfSector =fmddigit->NumberOfSector();
243 Int_t iNumberOfRing=fmddigit->NumberOfRing();
244 chargeSum[iVolume][iNumberOfSector][iNumberOfRing]=fmddigit->Charge();