66d2ede1 |
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 | #include <TTree.h> |
18 | #include <TVector.h> |
19 | #include <TObjArray.h> |
20 | #include <TFile.h> |
21 | #include <TDirectory.h> |
22 | #include <TRandom.h> |
23 | |
24 | |
25 | #include "AliFMDDigitizer.h" |
26 | #include "AliFMD.h" |
27 | #include "AliFMDSDigitizer.h" |
28 | #include "AliFMDhit.h" |
29 | #include "AliFMDdigit.h" |
30 | #include "AliRunDigitizer.h" |
31 | |
32 | #include "AliRun.h" |
33 | #include "AliPDG.h" |
34 | |
35 | #include <stdlib.h> |
36 | #include <iostream.h> |
37 | #include <fstream.h> |
38 | |
39 | ClassImp(AliFMDDigitizer) |
40 | |
41 | //___________________________________________ |
42 | AliFMDDigitizer::AliFMDDigitizer() :AliDigitizer() |
43 | { |
44 | // Default ctor - don't use it |
45 | ; |
46 | } |
47 | |
48 | //___________________________________________ |
49 | AliFMDDigitizer::AliFMDDigitizer(AliRunDigitizer* manager) |
50 | :AliDigitizer(manager) |
51 | { |
52 | cout<<"AliFMDDigitizer::AliFMDDigitizer"<<endl; |
53 | // ctor which should be used |
54 | // fDebug =0; |
55 | // if (GetDebug()>2) |
56 | // cerr<<"AliFMDDigitizer::AliFMDDigitizer" |
57 | // <<"(AliRunDigitizer* manager) was processed"<<endl; |
58 | |
59 | } |
60 | |
61 | //------------------------------------------------------------------------ |
62 | AliFMDDigitizer::~AliFMDDigitizer() |
63 | { |
64 | // Destructor |
65 | if(fSDigits) { |
66 | fSDigits->Delete(); |
67 | delete fSDigits ; |
68 | fSDigits = 0; |
69 | } |
70 | } |
71 | |
72 | //------------------------------------------------------------------------ |
73 | Bool_t AliFMDDigitizer::Init() |
74 | { |
75 | // Initialization |
76 | cout<<"AliFMDDigitizer::Init"<<endl; |
77 | return kTRUE; |
78 | } |
79 | |
80 | |
81 | //--------------------------------------------------------------------- |
82 | |
83 | void AliFMDDigitizer::Exec(Option_t* option) |
84 | { |
85 | |
86 | |
87 | |
88 | #ifdef DEBUG |
89 | cout<<"AliFMDDigitizer::>SDigits2Digits start...\n"; |
90 | #endif |
91 | |
92 | AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ; |
93 | cout<<" FMD "<<FMD<<endl; |
94 | if (gAlice->TreeD () == 0) |
95 | gAlice->MakeTree ("D"); |
96 | fDigits = FMD->Digits(); |
97 | |
98 | |
99 | Int_t chargeSum[10][50][300]; |
100 | Int_t digit[5]; |
101 | Int_t ivol, iSector, iRing; |
102 | for (Int_t i=0; i<10; i++) |
103 | for(Int_t j=0; j<50; j++) |
104 | for(Int_t ij=0; ij<300; ij++) |
105 | chargeSum[i][j][ij]=0; |
106 | Int_t NumberOfRings[5]= |
107 | {256,128,256,128,256}; |
108 | Int_t NumberOfSectors[5]= |
109 | {20,40,20,40,20}; |
110 | |
111 | |
112 | // Loop over files to digitize |
113 | |
114 | for (Int_t inputFile=0; inputFile<fManager->GetNinputs(); |
115 | inputFile++) { |
116 | |
117 | ReadDigit( chargeSum, inputFile); |
118 | |
119 | } |
120 | // Put noise and make ADC signal |
121 | for ( ivol=1; ivol<=5; ivol++){ |
122 | for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++){ |
123 | for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++){ |
124 | digit[0]=ivol; |
125 | digit[1]=iSector; |
126 | digit[2]=iRing; |
127 | digit[3]=PutNoise(chargeSum[ivol][iSector][iRing]); |
128 | if(chargeSum[ivol][iSector][iRing] <= 500) digit[3]=500; |
129 | //dynamic range from MIP(0.155MeV) to 30MIP(4.65MeV) |
130 | //1024 ADC channels |
131 | Float_t channelWidth=(22400*50)/1024; |
132 | digit[4]=Int_t(digit[3]/channelWidth); |
133 | if (digit[4]>1024) digit[4]=1024; |
134 | FMD->AddDigit(digit); |
135 | |
136 | } //ivol |
137 | } //iSector |
138 | } //iRing |
139 | TTree* treeD = fManager->GetTreeD(); |
140 | treeD->Reset(); |
141 | FMD->MakeBranch("D"); |
142 | treeD->Fill(); |
143 | |
144 | fManager->GetTreeD()->Write(0,TObject::kOverwrite); |
145 | |
146 | gAlice->ResetDigits(); |
147 | |
148 | } |
149 | |
150 | //--------------------------------------------------------------------- |
151 | |
152 | void AliFMDDigitizer::ReadDigit(Int_t chargeSum[][50][300], Int_t inputFile ) |
153 | { |
154 | cout<<" AliFMDDigitizer::ReadDigit "<<endl; |
155 | AliFMDdigit *fmddigit; |
156 | gAlice->GetEvent(0) ; |
157 | AliFMD * FMD = (AliFMD *) gAlice->GetDetector("FMD") ; |
158 | Int_t ndig, k; |
159 | gAlice->ResetDigits(); |
160 | treeS->GetEvent(0); |
161 | |
162 | treeS->GetEvent(0); |
163 | TClonesArray * FMDSdigits = FMD->SDigits(); |
164 | |
165 | ndig=FMDSdigits->GetEntries(); |
166 | |
167 | |
168 | for (k=0; k<ndig; k++) { |
169 | fmddigit= (AliFMDdigit*) FMDSdigits->UncheckedAt(k); |
170 | Int_t iVolume=fmddigit->Volume(); |
171 | Int_t iNumberOfSector =fmddigit->NumberOfSector(); |
172 | Int_t iNumberOfRing=fmddigit->NumberOfRing(); |
173 | chargeSum[iVolume][iNumberOfSector][iNumberOfRing]+=fmddigit->Charge(); |
174 | } |
175 | } |
176 | |
177 | |