1 /**************************************************************************
2 * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
19 #include <TObjArray.h>
21 #include <TDirectory.h>
25 #include "AliFMDDigitizer.h"
27 #include "AliFMDhit.h"
28 #include "AliFMDdigit.h"
29 #include "AliRunDigitizer.h"
33 #include "AliLoader.h"
34 #include "AliRunLoader.h"
37 #include <Riostream.h>
38 #include <Riostream.h>
40 ClassImp(AliFMDDigitizer)
42 //___________________________________________
43 AliFMDDigitizer::AliFMDDigitizer() :AliDigitizer()
45 // Default ctor - don't use it
49 //___________________________________________
50 AliFMDDigitizer::AliFMDDigitizer(AliRunDigitizer* manager)
51 :AliDigitizer(manager)
53 cout<<"AliFMDDigitizer::AliFMDDigitizer"<<endl;
54 // ctor which should be used
57 // cerr<<"AliFMDDigitizer::AliFMDDigitizer"
58 // <<"(AliRunDigitizer* manager) was processed"<<endl;
61 //------------------------------------------------------------------------
62 AliFMDDigitizer::~AliFMDDigitizer()
67 //------------------------------------------------------------------------
68 Bool_t AliFMDDigitizer::Init()
71 cout<<"AliFMDDigitizer::Init"<<endl;
76 //---------------------------------------------------------------------
78 void AliFMDDigitizer::Exec(Option_t * option)
82 Conver hits to digits:
86 - ADC signal in this channel
88 cout<<"AliFMDDigitizer::Exec Nachali Exec>> "<<endl;
90 AliRunLoader *inRL, *outRL;//in and out Run Loaders
91 AliLoader *ingime, *outgime;// in and out ITSLoaders
93 outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
94 outgime = outRL->GetLoader("FMDLoader");
95 cout<<"AliFMDDigitizer::Exec >> "<<outgime<<endl;
98 cout<<"AliFMDDigitizer::>SDigits2Digits start...\n";
102 Int_t volume, sector, ring, charge;
104 Float_t de[10][50][520];
107 Int_t ivol, iSector, iRing;
108 for (Int_t i=0; i<10; i++)
109 for(Int_t j=0; j<50; j++)
110 for(Int_t ij=0; ij<520; ij++)
112 Int_t NumberOfRings[5]=
113 {512,256,512,256,512};
114 Int_t NumberOfSectors[5]=
122 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(0));
125 Error("Exec","Can not find Run Loader for input stream 0");
128 Info("Exec","inRL->GetAliRun() %#x",inRL->GetAliRun());
132 AliFMD * fFMD = (AliFMD *) inRL->GetAliRun()->GetDetector("FMD");
133 Info("Exec","inRL->GetAliRun(): %#x, FMD: %#x, InRL %#x.",inRL->GetAliRun(),fFMD,inRL);
136 Error("Exec","Can not get FMD from gAlice");
139 // Loop over files to digitize
141 Int_t nFiles=GetManager()->GetNinputs();
142 for (Int_t inputFile=0; inputFile<nFiles;inputFile++)
144 cout<<" event "<<fManager->GetOutputEventNr()<<endl;
148 inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
149 ingime = inRL->GetLoader("FMDLoader");
150 ingime->LoadHits("READ");//probably it is necessary to load them before
153 TH = ingime->TreeH();
156 ingime->LoadHits("read");
157 TH = ingime->TreeH();
159 brHits = TH->GetBranch("FMD");
161 // brHits->SetAddress(&fHits);
162 fFMD->SetHitsAddressBranch(brHits);
164 Fatal("Exec","EXEC Branch FMD hit not found");
166 TClonesArray *FMDhits = fFMD->Hits ();
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++)
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++)
177 fmdHit = (AliFMDhit *) FMDhits->UncheckedAt(hit);
179 volume = fmdHit->Volume ();
180 sector = fmdHit->NumberOfSector ();
181 ring = fmdHit->NumberOfRing ();
183 de[volume][sector][ring] += e;
184 // if (fManager->GetOutputEventNr()>1)
185 // cout<<" "<<volume<<" "<<sector<<" "<<ring<<endl;
192 // Put noise and make ADC signal
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++){
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;
205 //dynamic range from MIP(0.155MeV) to 30MIP(4.65MeV)
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);
215 TTree* treeD = outgime->TreeD();
216 cout<<" treeD "<<treeD;
218 outgime->MakeTree("D");
219 treeD = outgime->TreeD();
220 cout<<" After MakeTree "<<treeD<<endl;
222 cout<<" Before reset "<<treeD<<endl;
225 fFMD->MakeBranchInTreeD(treeD);
226 brD = treeD->GetBranch("FMD");
227 cout<<" Make branch "<<brD<<endl;
229 treeD->Fill(); //this operator does not work for events >1
231 outgime->WriteDigits("OVERWRITE");
233 gAlice->ResetDigits();