]>
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$ | |
18 | Revision 1.3 2001/03/05 23:57:44 morsch | |
19 | Writing of digit tree moved to macro. | |
20 | ||
21 | Revision 1.2 2001/03/05 08:40:25 morsch | |
22 | Method SortTracks(..) imported from AliMUON. | |
23 | ||
24 | Revision 1.1 2001/02/02 14:11:53 morsch | |
25 | AliMUONMerger prototype to be called by the merge manager. | |
26 | ||
27 | */ | |
28 | ||
29 | #include <TTree.h> | |
30 | #include <TVector.h> | |
31 | #include <TObjArray.h> | |
32 | #include <TFile.h> | |
33 | #include <TDirectory.h> | |
34 | ||
35 | ||
36 | #include "AliFMDMerger.h" | |
37 | #include "AliFMD.h" | |
38 | #include "AliFMDSDigitizer.h" | |
39 | #include "AliFMDhit.h" | |
40 | #include "AliFMDdigit.h" | |
41 | ||
42 | #include "AliRun.h" | |
43 | #include "AliPDG.h" | |
44 | ||
45 | #include <stdlib.h> | |
46 | #include <iostream.h> | |
47 | #include <fstream.h> | |
48 | ||
49 | ClassImp(AliFMDMerger) | |
50 | ||
51 | //___________________________________________ | |
52 | AliFMDMerger::AliFMDMerger() | |
53 | { | |
54 | // Default constructor | |
55 | fEvNrSig = 0; | |
56 | fEvNrBgr = 0; | |
57 | fMerge =kDigitize; | |
58 | fFnBgr = 0; | |
59 | } | |
60 | ||
61 | //------------------------------------------------------------------------ | |
62 | AliFMDMerger::~AliFMDMerger() | |
63 | { | |
64 | // Destructor | |
65 | if(fSDigits) { | |
66 | fSDigits->Delete(); | |
67 | delete fSDigits ; | |
68 | fSDigits = 0; | |
69 | } | |
70 | } | |
71 | ||
72 | ||
73 | ||
74 | //------------------------------------------------------------------------ | |
75 | void AliFMDMerger::Init() | |
76 | { | |
77 | // Initialisation | |
78 | if (fMerge) fBgrFile = InitBgr(); | |
79 | ||
80 | } | |
81 | ||
82 | ||
83 | ||
84 | //------------------------------------------------------------------------ | |
85 | TFile* AliFMDMerger::InitBgr() | |
86 | { | |
87 | // Initialise background event | |
88 | TFile *file = new TFile(fFnBgr); | |
89 | // add error checking later | |
90 | printf("\n AliFMDMerger has opened %s file with background event \n", fFnBgr); | |
91 | return file; | |
92 | } | |
93 | ||
94 | //------------------------------------------------------------------------ | |
95 | void AliFMDMerger::Digitise() | |
96 | { | |
97 | ||
98 | // keep galice.root for signal and name differently the file for | |
99 | // background when add! otherwise the track info for signal will be lost ! | |
100 | ||
101 | ||
102 | ||
103 | #ifdef DEBUG | |
104 | cout<<"ALiFMD::>SDigits2Digits start...\n"; | |
105 | #endif | |
106 | ||
107 | AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ; | |
108 | ||
109 | Int_t chargeSum[10][20][150]; | |
110 | Int_t digit[5]; | |
111 | Int_t ivol, iSector, iRing; | |
112 | ||
113 | TFile *f1 =0; | |
114 | TTree *TK = gAlice->TreeK(); | |
115 | if (TK) f1 = TK->GetCurrentFile(); | |
116 | ||
117 | gAlice->GetEvent(fEvNrSig) ; | |
118 | ||
119 | if(gAlice->TreeD() == 0) | |
120 | gAlice->MakeTree("D") ; | |
121 | gAlice->TreeD()->Reset(); | |
122 | ||
123 | //Make branches | |
124 | ReadDigit( chargeSum, fEvNrSig); | |
125 | ||
126 | if(fMerge){ | |
127 | fBgrFile->cd(); | |
128 | // gAlice->TreeS()->Reset(); | |
129 | gAlice = (AliRun*)fBgrFile->Get("gAlice"); | |
130 | Int_t chargeBgr[10][20][150]; | |
131 | ReadDigit( chargeBgr,fEvNrBgr); | |
132 | for ( ivol=1; ivol<=5; ivol++) | |
133 | for ( iSector=1; iSector<=16; iSector++) | |
134 | for ( iRing=1; iRing<=128; iRing++) | |
135 | chargeSum[ivol][iSector][iRing]= | |
136 | chargeBgr[ivol][iSector][iRing]+ | |
137 | chargeSum[ivol][iSector][iRing]; | |
138 | ||
139 | } //if merge | |
140 | ||
141 | ||
142 | // Put noise and make ADC signal | |
143 | for ( ivol=1; ivol<=5; ivol++){ | |
144 | for ( iSector=1; iSector<=16; iSector++){ | |
145 | for ( iRing=1; iRing<=128; iRing++){ | |
146 | digit[0]=ivol; | |
147 | digit[1]=iSector; | |
148 | digit[2]=iRing; | |
149 | digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]); | |
150 | if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500; | |
151 | ||
152 | //dinamic diapason from MIP(0.155MeV) to 30MIP(4.65MeV) | |
153 | //1024 ADC channels | |
154 | Float_t channelWidth=(22400*50)/1024; | |
155 | digit[4]=Int_t(digit[3]/channelWidth); | |
156 | if (digit[4]>1024) digit[4]=1024; | |
157 | ||
158 | FMD->AddDigit(digit); | |
159 | ||
160 | } //ivol | |
161 | } //iSector | |
162 | } //iRing | |
163 | ||
164 | f1->cd(); | |
165 | ||
166 | //Make branch for digits | |
167 | FMD->MakeBranch("D"); | |
168 | ||
169 | gAlice->TreeD()->Reset(); | |
170 | gAlice->TreeD()->Fill(); | |
171 | ||
172 | fDigits = FMD->Digits(); | |
173 | ||
174 | gAlice->TreeD()->Write(0,TObject::kOverwrite) ; | |
175 | ||
176 | gAlice->ResetDigits(); | |
177 | ||
178 | } | |
179 | ||
180 | //--------------------------------------------------------------------- | |
181 | ||
182 | void AliFMDMerger::ReadDigit(Int_t chargeSum[][20][150], Int_t iEvNum) | |
183 | { | |
184 | AliFMDdigit *fmddigit; | |
185 | ||
186 | for (Int_t i=0; i<10; i++) | |
187 | for(Int_t j=0; j<20; j++) | |
188 | for(Int_t ij=0; ij<150; ij++) | |
189 | chargeSum[i][j][ij]=0; | |
190 | ||
191 | AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ; | |
192 | ||
193 | gAlice->GetEvent(iEvNum) ; | |
194 | if(gAlice->TreeS()==0) { | |
195 | cout<<" TreeS==0 -> return"<<gAlice->TreeS()<<endl; | |
196 | return ;} | |
197 | ||
198 | Int_t ndig, k; | |
199 | gAlice->ResetDigits(); | |
200 | gAlice->TreeS()->GetEvent(iEvNum); | |
201 | TClonesArray * FMDdigits = FMD->SDigits(); | |
202 | ||
203 | ndig=FMDdigits->GetEntries(); | |
204 | ||
205 | for (k=0; k<ndig; k++) { | |
206 | fmddigit= (AliFMDdigit*) FMDdigits->UncheckedAt(k); | |
207 | ||
208 | Int_t iVolume=fmddigit->Volume(); | |
209 | Int_t iNumberOfSector =fmddigit->NumberOfSector(); | |
210 | Int_t iNumberOfRing=fmddigit->NumberOfRing(); | |
211 | chargeSum[iVolume][iNumberOfSector][iNumberOfRing]=fmddigit->Charge(); | |
212 | } | |
213 | } | |
214 | ||
215 |