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