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