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> |
93bdec82 |
36 | #include <Riostream.h> |
37 | #include <Riostream.h> |
66d2ede1 |
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; |
66d2ede1 |
58 | } |
59 | |
60 | //------------------------------------------------------------------------ |
61 | AliFMDDigitizer::~AliFMDDigitizer() |
62 | { |
63 | // Destructor |
66d2ede1 |
64 | } |
65 | |
66 | //------------------------------------------------------------------------ |
ab256e65 |
67 | /* |
68 | Bool_t AliFMDDigitizer::Init() |
66d2ede1 |
69 | { |
66d2ede1 |
70 | cout<<"AliFMDDigitizer::Init"<<endl; |
71 | return kTRUE; |
72 | } |
73 | |
ab256e65 |
74 | */ |
66d2ede1 |
75 | //--------------------------------------------------------------------- |
76 | |
77 | void AliFMDDigitizer::Exec(Option_t* option) |
78 | { |
ab256e65 |
79 | /* |
80 | Conver hits to digits: |
81 | - number of detector; |
82 | - number of ring; |
83 | - number of sector; |
84 | - ADC signal in this channel |
85 | */ |
66d2ede1 |
86 | |
87 | |
88 | #ifdef DEBUG |
89 | cout<<"AliFMDDigitizer::>SDigits2Digits start...\n"; |
90 | #endif |
91 | |
4110645f |
92 | // cout<<" FMD "<<FMD<<endl; |
66d2ede1 |
93 | |
4110645f |
94 | Int_t volume, sector, ring, charge; |
95 | Float_t e; |
ab256e65 |
96 | Float_t de[10][50][800]; |
4110645f |
97 | Int_t hit; |
66d2ede1 |
98 | Int_t digit[5]; |
99 | Int_t ivol, iSector, iRing; |
100 | for (Int_t i=0; i<10; i++) |
101 | for(Int_t j=0; j<50; j++) |
ab256e65 |
102 | for(Int_t ij=0; ij<800; ij++) |
4110645f |
103 | de[i][j][ij]=0; |
ab256e65 |
104 | Int_t numberOfRings[5]= |
105 | {768,384,768,384,768}; |
106 | Int_t numberOfSector[5]= |
66d2ede1 |
107 | {20,40,20,40,20}; |
108 | |
4110645f |
109 | AliFMDhit *fmdHit=0; |
ab256e65 |
110 | TTree *tH=0; |
4110645f |
111 | TBranch *brHits=0; |
4110645f |
112 | |
113 | AliFMD * fFMD = (AliFMD *) gAlice->GetDetector("FMD") ; |
66d2ede1 |
114 | |
115 | // Loop over files to digitize |
116 | |
4110645f |
117 | Int_t nFiles=GetManager()->GetNinputs(); |
118 | for (Int_t inputFile=0; inputFile<nFiles; |
66d2ede1 |
119 | inputFile++) { |
120 | |
4110645f |
121 | cout<<" event "<<fManager->GetOutputEventNr()<<endl; |
122 | if (fFMD) |
123 | { |
124 | TClonesArray *FMDhits = fFMD->Hits (); |
ab256e65 |
125 | tH = fManager->GetInputTreeH(inputFile); |
126 | brHits = tH->GetBranch("FMD"); |
4110645f |
127 | if (brHits) { |
128 | fFMD->SetHitsAddressBranch(brHits); |
129 | }else{ |
130 | cerr<<"EXEC Branch FMD hit not found"<<endl; |
131 | exit(111); |
132 | } |
ab256e65 |
133 | Int_t ntracks = (Int_t) tH->GetEntries(); |
4110645f |
134 | |
135 | for (Int_t track = 0; track < ntracks; track++) |
136 | { |
137 | brHits->GetEntry(track); |
138 | Int_t nhits = FMDhits->GetEntries (); |
139 | |
140 | for (hit = 0; hit < nhits; hit++) |
141 | { |
142 | fmdHit = (AliFMDhit *) FMDhits->UncheckedAt (hit); |
143 | |
144 | volume = fmdHit->Volume (); |
145 | sector = fmdHit->NumberOfSector (); |
146 | ring = fmdHit->NumberOfRing (); |
147 | e = fmdHit->Edep (); |
148 | de[volume][sector][ring] += e; |
149 | |
150 | } //hit loop |
151 | } //track loop |
152 | } //if FMD |
66d2ede1 |
153 | |
4110645f |
154 | |
66d2ede1 |
155 | // Put noise and make ADC signal |
ab256e65 |
156 | Float_t iP = 1.664 * 0.04 * 2.33 / 22400; // = 0.69e-6; |
4110645f |
157 | for ( ivol=1; ivol<=5; ivol++){ |
ab256e65 |
158 | for ( iSector=1; iSector<=numberOfSector[ivol-1]; iSector++){ |
159 | for ( iRing=1; iRing<=numberOfRings[ivol-1]; iRing++){ |
66d2ede1 |
160 | digit[0]=ivol; |
161 | digit[1]=iSector; |
162 | digit[2]=iRing; |
ab256e65 |
163 | charge = Int_t (de[ivol][iSector][iRing] / iP); |
4110645f |
164 | digit[3]=PutNoise(charge); |
165 | if(digit[3]<= 500) digit[3]=500; |
66d2ede1 |
166 | //dynamic range from MIP(0.155MeV) to 30MIP(4.65MeV) |
167 | //1024 ADC channels |
168 | Float_t channelWidth=(22400*50)/1024; |
169 | digit[4]=Int_t(digit[3]/channelWidth); |
170 | if (digit[4]>1024) digit[4]=1024; |
4110645f |
171 | fFMD->AddDigit(digit); |
66d2ede1 |
172 | } //ivol |
173 | } //iSector |
174 | } //iRing |
4110645f |
175 | |
66d2ede1 |
176 | TTree* treeD = fManager->GetTreeD(); |
4110645f |
177 | treeD->Clear(); |
66d2ede1 |
178 | treeD->Reset(); |
4110645f |
179 | fFMD->MakeBranchInTreeD(treeD); |
66d2ede1 |
180 | treeD->Fill(); |
181 | |
182 | fManager->GetTreeD()->Write(0,TObject::kOverwrite); |
183 | |
184 | gAlice->ResetDigits(); |
66d2ede1 |
185 | } |
186 | } |
187 | |