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