]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDDigitizer.cxx
Minor changes
[u/mrichter/AliRoot.git] / FMD / AliFMDDigitizer.cxx
CommitLineData
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"
66d2ede1 27#include "AliFMDhit.h"
28#include "AliFMDdigit.h"
29#include "AliRunDigitizer.h"
30
31#include "AliRun.h"
32#include "AliPDG.h"
88cb7938 33#include "AliLoader.h"
34#include "AliRunLoader.h"
66d2ede1 35
36#include <stdlib.h>
93bdec82 37#include <Riostream.h>
38#include <Riostream.h>
66d2ede1 39
40ClassImp(AliFMDDigitizer)
41
42//___________________________________________
43 AliFMDDigitizer::AliFMDDigitizer() :AliDigitizer()
44{
45// Default ctor - don't use it
46 ;
47}
48
49//___________________________________________
50AliFMDDigitizer::AliFMDDigitizer(AliRunDigitizer* manager)
51 :AliDigitizer(manager)
52{
88cb7938 53 cout<<"AliFMDDigitizer::AliFMDDigitizer"<<endl;
66d2ede1 54// ctor which should be used
55// fDebug =0;
56 // if (GetDebug()>2)
57 // cerr<<"AliFMDDigitizer::AliFMDDigitizer"
58 // <<"(AliRunDigitizer* manager) was processed"<<endl;
66d2ede1 59}
60
61//------------------------------------------------------------------------
62AliFMDDigitizer::~AliFMDDigitizer()
63{
64// Destructor
66d2ede1 65}
66
67 //------------------------------------------------------------------------
88cb7938 68Bool_t AliFMDDigitizer::Init()
66d2ede1 69{
88cb7938 70// Initialization
66d2ede1 71 cout<<"AliFMDDigitizer::Init"<<endl;
72 return kTRUE;
73}
74
88cb7938 75
66d2ede1 76//---------------------------------------------------------------------
77
46501dfb 78void AliFMDDigitizer::Exec(Option_t * option)
66d2ede1 79{
88cb7938 80
ab256e65 81 /*
82 Conver hits to digits:
83 - number of detector;
84 - number of ring;
85 - number of sector;
86 - ADC signal in this channel
87 */
88cb7938 88 cout<<"AliFMDDigitizer::Exec Nachali Exec>> "<<endl;
66d2ede1 89
88cb7938 90 AliRunLoader *inRL, *outRL;//in and out Run Loaders
91 AliLoader *ingime, *outgime;// in and out ITSLoaders
92
93 outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
94 outgime = outRL->GetLoader("FMDLoader");
95 cout<<"AliFMDDigitizer::Exec >> "<<outgime<<endl;
66d2ede1 96
97#ifdef DEBUG
98 cout<<"AliFMDDigitizer::>SDigits2Digits start...\n";
99#endif
100
66d2ede1 101
88cb7938 102 Int_t volume, sector, ring, charge;
4110645f 103 Float_t e;
88cb7938 104 Float_t de[10][50][520];
4110645f 105 Int_t hit;
66d2ede1 106 Int_t digit[5];
107 Int_t ivol, iSector, iRing;
108 for (Int_t i=0; i<10; i++)
109 for(Int_t j=0; j<50; j++)
88cb7938 110 for(Int_t ij=0; ij<520; ij++)
111 de[i][j][ij]=0;
112 Int_t NumberOfRings[5]=
113 {512,256,512,256,512};
114 Int_t NumberOfSectors[5]=
66d2ede1 115 {20,40,20,40,20};
116
4110645f 117 AliFMDhit *fmdHit=0;
88cb7938 118 TTree *TH=0;
4110645f 119 TBranch *brHits=0;
88cb7938 120 TBranch *brD=0;
4110645f 121
88cb7938 122 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
123 if (inRL == 0x0)
124 {
125 Error("Exec","Can not find Run Loader for input stream 0");
126 return;
127 }
128 Info("Exec","inRL->GetAliRun() %#x",inRL->GetAliRun());
129
130 inRL->LoadgAlice();
131
132 AliFMD * fFMD = (AliFMD *) inRL->GetAliRun()->GetDetector("FMD");
133 Info("Exec","inRL->GetAliRun(): %#x, FMD: %#x, InRL %#x.",inRL->GetAliRun(),fFMD,inRL);
134 if (fFMD == 0x0)
135 {
136 Error("Exec","Can not get FMD from gAlice");
137 return;
138 }
66d2ede1 139// Loop over files to digitize
140
4110645f 141 Int_t nFiles=GetManager()->GetNinputs();
88cb7938 142 for (Int_t inputFile=0; inputFile<nFiles;inputFile++)
143 {
4110645f 144 cout<<" event "<<fManager->GetOutputEventNr()<<endl;
145 if (fFMD)
88cb7938 146 {
147
148 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
149 ingime = inRL->GetLoader("FMDLoader");
150 ingime->LoadHits("READ");//probably it is necessary to load them before
151
152
153 TH = ingime->TreeH();
154 if (TH == 0x0)
155 {
156 ingime->LoadHits("read");
157 TH = ingime->TreeH();
158 }
159 brHits = TH->GetBranch("FMD");
4110645f 160 if (brHits) {
88cb7938 161 // brHits->SetAddress(&fHits);
162 fFMD->SetHitsAddressBranch(brHits);
4110645f 163 }else{
88cb7938 164 Fatal("Exec","EXEC Branch FMD hit not found");
46501dfb 165 }
88cb7938 166 TClonesArray *FMDhits = fFMD->Hits ();
46501dfb 167
88cb7938 168 Int_t ntracks = (Int_t) TH->GetEntries();
169 cout<<"Number of tracks TreeH"<<ntracks<<endl;
170 for (Int_t track = 0; track < ntracks; track++)
171 {
172 brHits->GetEntry(track);
173 Int_t nhits = FMDhits->GetEntries ();
174 // if(nhits>0) cout<<"nhits "<<nhits<<endl;
175 for (hit = 0; hit < nhits; hit++)
176 {
177 fmdHit = (AliFMDhit *) FMDhits->UncheckedAt(hit);
178
179 volume = fmdHit->Volume ();
180 sector = fmdHit->NumberOfSector ();
181 ring = fmdHit->NumberOfRing ();
182 e = fmdHit->Edep ();
183 de[volume][sector][ring] += e;
184 // if (fManager->GetOutputEventNr()>1)
185 // cout<<" "<<volume<<" "<<sector<<" "<<ring<<endl;
186 } //hit loop
187 } //track loop
188 }
189//if FMD
66d2ede1 190
4110645f 191
66d2ede1 192 // Put noise and make ADC signal
88cb7938 193 Float_t I = 1.664 * 0.04 * 2.33 / 22400; // = 6.923e-6;
194 for ( ivol=1; ivol<=5; ivol++){
195 for ( iSector=1; iSector<=NumberOfSectors[ivol-1]; iSector++){
196 for ( iRing=1; iRing<=NumberOfRings[ivol-1]; iRing++){
197 digit[0]=ivol;
198 digit[1]=iSector;
199 digit[2]=iRing;
200 charge = Int_t (de[ivol][iSector][iRing] / I);
201 Int_t pedestal=Int_t(gRandom->Gaus(500,250));
202 // digit[3]=PutNoise(charge);
203 digit[3]=charge + pedestal;
204 if(digit[3]<= 500) digit[3]=500;
66d2ede1 205 //dynamic range from MIP(0.155MeV) to 30MIP(4.65MeV)
206 //1024 ADC channels
88cb7938 207 Float_t channelWidth=(22400*50)/1024;
208 digit[4]=Int_t(digit[3]/channelWidth);
209 if (digit[4]>1024) digit[4]=1024;
210 fFMD->AddDigit(digit);
211 } //ivol
212 } //iSector
213 } //iRing
214
215 TTree* treeD = outgime->TreeD();
216 cout<<" treeD "<<treeD;
217 if (treeD == 0x0) {
218 outgime->MakeTree("D");
219 treeD = outgime->TreeD();
220 cout<<" After MakeTree "<<treeD<<endl;
221 }
222 cout<<" Before reset "<<treeD<<endl;
223 // treeD->Clear();
224 treeD->Reset();
225 fFMD->MakeBranchInTreeD(treeD);
226 brD = treeD->GetBranch("FMD");
227 cout<<" Make branch "<<brD<<endl;
228
229 treeD->Fill(); //this operator does not work for events >1
230 treeD->Print();
231 outgime->WriteDigits("OVERWRITE");
66d2ede1 232
88cb7938 233 gAlice->ResetDigits();
234 }
66d2ede1 235}
88cb7938 236
237
238
239
66d2ede1 240