]>
Commit | Line | Data |
---|---|---|
dc8af42e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | /* | |
17 | $Log$ | |
2685bf00 | 18 | Revision 1.2 2001/09/24 16:41:15 hristov |
19 | New version of FMD code (A.Maevskaia) | |
20 | ||
37c55dc0 | 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) | |
23 | ||
dc8af42e | 24 | Revision 1.3 2001/03/05 23:57:44 morsch |
25 | Writing of digit tree moved to macro. | |
26 | ||
27 | Revision 1.2 2001/03/05 08:40:25 morsch | |
28 | Method SortTracks(..) imported from AliMUON. | |
29 | ||
30 | Revision 1.1 2001/02/02 14:11:53 morsch | |
31 | AliMUONMerger prototype to be called by the merge manager. | |
32 | ||
33 | */ | |
34 | ||
35 | #include <TTree.h> | |
36 | #include <TVector.h> | |
37 | #include <TObjArray.h> | |
38 | #include <TFile.h> | |
39 | #include <TDirectory.h> | |
40 | ||
41 | ||
42 | #include "AliFMDMerger.h" | |
43 | #include "AliFMD.h" | |
44 | #include "AliFMDSDigitizer.h" | |
45 | #include "AliFMDhit.h" | |
46 | #include "AliFMDdigit.h" | |
47 | ||
48 | #include "AliRun.h" | |
49 | #include "AliPDG.h" | |
50 | ||
51 | #include <stdlib.h> | |
52 | #include <iostream.h> | |
53 | #include <fstream.h> | |
54 | ||
55 | ClassImp(AliFMDMerger) | |
56 | ||
57 | //___________________________________________ | |
58 | AliFMDMerger::AliFMDMerger() | |
59 | { | |
60 | // Default constructor | |
61 | fEvNrSig = 0; | |
62 | fEvNrBgr = 0; | |
2685bf00 | 63 | fMerge = kDigitize; |
64 | fDigits = 0; | |
65 | fSDigits = 0; | |
dc8af42e | 66 | fFnBgr = 0; |
2685bf00 | 67 | fFnSig = 0; |
68 | fBgrFile = 0; | |
dc8af42e | 69 | } |
70 | ||
71 | //------------------------------------------------------------------------ | |
72 | AliFMDMerger::~AliFMDMerger() | |
73 | { | |
74 | // Destructor | |
75 | if(fSDigits) { | |
76 | fSDigits->Delete(); | |
77 | delete fSDigits ; | |
78 | fSDigits = 0; | |
79 | } | |
80 | } | |
81 | ||
82 | ||
37c55dc0 | 83 | //--------------------------------------------------------------------- |
84 | void AliFMDMerger::SetRingsSi1(Int_t ringsSi1) | |
85 | { | |
86 | fRingsSi1=ringsSi1; | |
87 | } | |
88 | void AliFMDMerger::SetSectorsSi1(Int_t sectorsSi1) | |
89 | { | |
90 | fSectorsSi1=sectorsSi1; | |
91 | } | |
92 | void AliFMDMerger::SetRingsSi2(Int_t ringsSi2) | |
93 | { | |
94 | fRingsSi2=ringsSi2; | |
95 | } | |
96 | void AliFMDMerger::SetSectorsSi2(Int_t sectorsSi2) | |
97 | { | |
98 | fSectorsSi2=sectorsSi2; | |
99 | } | |
100 | //--------------------------------------------------------------------- | |
dc8af42e | 101 | |
102 | //------------------------------------------------------------------------ | |
103 | void AliFMDMerger::Init() | |
104 | { | |
105 | // Initialisation | |
106 | if (fMerge) fBgrFile = InitBgr(); | |
107 | ||
108 | } | |
109 | ||
110 | ||
111 | ||
112 | //------------------------------------------------------------------------ | |
113 | TFile* AliFMDMerger::InitBgr() | |
114 | { | |
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); | |
119 | return file; | |
120 | } | |
121 | ||
122 | //------------------------------------------------------------------------ | |
123 | void AliFMDMerger::Digitise() | |
124 | { | |
125 | ||
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 ! | |
128 | ||
129 | ||
130 | ||
131 | #ifdef DEBUG | |
37c55dc0 | 132 | cout<<"ALiFMDMerger::>SDigits2Digits start...\n"; |
dc8af42e | 133 | #endif |
134 | ||
135 | AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ; | |
136 | ||
37c55dc0 | 137 | Int_t chargeSum[10][30][150]; |
dc8af42e | 138 | Int_t digit[5]; |
139 | Int_t ivol, iSector, iRing; | |
140 | ||
37c55dc0 | 141 | Int_t NumberOfRings[5]= |
142 | {fRingsSi1,fRingsSi2,fRingsSi1,fRingsSi2,fRingsSi1}; | |
143 | Int_t NumberOfSectors[5]= | |
144 | {fSectorsSi1,fSectorsSi2,fSectorsSi1,fSectorsSi2,fSectorsSi1}; | |
145 | ||
dc8af42e | 146 | TFile *f1 =0; |
147 | TTree *TK = gAlice->TreeK(); | |
148 | if (TK) f1 = TK->GetCurrentFile(); | |
149 | ||
150 | gAlice->GetEvent(fEvNrSig) ; | |
151 | ||
152 | if(gAlice->TreeD() == 0) | |
153 | gAlice->MakeTree("D") ; | |
154 | gAlice->TreeD()->Reset(); | |
155 | ||
156 | //Make branches | |
157 | ReadDigit( chargeSum, fEvNrSig); | |
158 | ||
159 | if(fMerge){ | |
160 | fBgrFile->cd(); | |
161 | // gAlice->TreeS()->Reset(); | |
162 | gAlice = (AliRun*)fBgrFile->Get("gAlice"); | |
37c55dc0 | 163 | Int_t chargeBgr[10][30][150]; |
dc8af42e | 164 | ReadDigit( chargeBgr,fEvNrBgr); |
165 | for ( ivol=1; ivol<=5; ivol++) | |
37c55dc0 | 166 | for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++) |
167 | for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++) | |
dc8af42e | 168 | chargeSum[ivol][iSector][iRing]= |
169 | chargeBgr[ivol][iSector][iRing]+ | |
170 | chargeSum[ivol][iSector][iRing]; | |
171 | ||
172 | } //if merge | |
173 | ||
174 | ||
175 | // Put noise and make ADC signal | |
176 | for ( ivol=1; ivol<=5; ivol++){ | |
37c55dc0 | 177 | for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++){ |
178 | for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++){ | |
dc8af42e | 179 | digit[0]=ivol; |
180 | digit[1]=iSector; | |
181 | digit[2]=iRing; | |
182 | digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]); | |
183 | if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500; | |
184 | ||
185 | //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV) | |
186 | //1024 ADC channels | |
187 | Float_t channelWidth=(22400*50)/1024; | |
188 | digit[4]=Int_t(digit[3]/channelWidth); | |
189 | if (digit[4]>1024) digit[4]=1024; | |
190 | ||
191 | FMD->AddDigit(digit); | |
192 | ||
193 | } //ivol | |
194 | } //iSector | |
195 | } //iRing | |
196 | ||
197 | f1->cd(); | |
198 | ||
199 | //Make branch for digits | |
200 | FMD->MakeBranch("D"); | |
201 | ||
202 | gAlice->TreeD()->Reset(); | |
203 | gAlice->TreeD()->Fill(); | |
204 | ||
205 | fDigits = FMD->Digits(); | |
206 | ||
207 | gAlice->TreeD()->Write(0,TObject::kOverwrite) ; | |
208 | ||
209 | gAlice->ResetDigits(); | |
210 | ||
211 | } | |
212 | ||
213 | //--------------------------------------------------------------------- | |
214 | ||
37c55dc0 | 215 | void AliFMDMerger::ReadDigit(Int_t chargeSum[][30][150], Int_t iEvNum) |
dc8af42e | 216 | { |
217 | AliFMDdigit *fmddigit; | |
218 | ||
219 | for (Int_t i=0; i<10; i++) | |
37c55dc0 | 220 | for(Int_t j=0; j<30; j++) |
dc8af42e | 221 | for(Int_t ij=0; ij<150; ij++) |
222 | chargeSum[i][j][ij]=0; | |
223 | ||
224 | AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ; | |
225 | ||
226 | gAlice->GetEvent(iEvNum) ; | |
227 | if(gAlice->TreeS()==0) { | |
228 | cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl; | |
229 | return ;} | |
230 | ||
231 | Int_t ndig, k; | |
232 | gAlice->ResetDigits(); | |
233 | gAlice->TreeS()->GetEvent(iEvNum); | |
234 | TClonesArray * FMDdigits = FMD->SDigits(); | |
235 | ||
236 | ndig=FMDdigits->GetEntries(); | |
237 | ||
238 | for (k=0; k<ndig; k++) { | |
239 | fmddigit= (AliFMDdigit*) FMDdigits->UncheckedAt(k); | |
240 | ||
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(); | |
245 | } | |
246 | } | |
247 | ||
248 |