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 **************************************************************************/
17 /******************************************************************
18 * Produde digits from hits
19 * digits is TObject and includes
20 * We are writing array if C & A TDC
21 * C & A ADC (will need for slow simulation)
22 * TOF first particle C & A
23 * mean time and time difference (vertex position)
25 * Alla.Maevskaya@cern.ch
26 ****************************************************************/
38 #include "AliFITDigitizer.h"
40 #include "AliFITHits.h"
41 #include "AliFITDigit.h"
42 #include "AliDigitizationInput.h"
44 #include <AliLoader.h>
45 #include <AliRunLoader.h>
48 ClassImp(AliFITDigitizer)
50 //___________________________________________
51 AliFITDigitizer::AliFITDigitizer() :AliDigitizer(),
57 // Default ctor - don't use it
61 //___________________________________________
62 AliFITDigitizer::AliFITDigitizer(AliDigitizationInput* digInput)
63 :AliDigitizer(digInput),
69 // ctor which should be used
74 //------------------------------------------------------------------------
75 AliFITDigitizer::~AliFITDigitizer()
83 //------------------------------------------------------------------------
84 Bool_t AliFITDigitizer::Init()
92 //---------------------------------------------------------------------
93 void AliFITDigitizer::Digitize(Option_t* /*option*/)
97 Produde digits from hits
98 digits is TObject and includes
99 We are writing array if C & A for each channel CFD, LED, QT0 and QT1
100 C & A ADC (will need for slow simulation)
106 AliDebug(1,"start...");
109 // From hits to digits
112 AliRunLoader *outRL = AliRunLoader::GetRunLoader(fDigInput->GetOutputFolderName());
113 AliLoader * outFitLoader = outRL->GetLoader("FITLoader");
115 fFIT = static_cast<AliFIT*>(gAlice->GetDetector("FIT"));
117 AliError("Can not get FIT from gAlice");
125 outFitLoader->LoadDigits("UPDATE");
126 TTree *treeD = outFitLoader->TreeD();
128 outFitLoader->MakeTree("D");
129 treeD = outFitLoader->TreeD();
132 fFIT = (AliFIT*)outRL ->GetAliRun()->GetDetector("FIT");
133 // Make a branch in the tree
134 fFIT->MakeBranch("D");
137 outFitLoader->WriteDigits("OVERWRITE");
139 outFitLoader->UnloadDigits();
141 //____________________________________________________________________________
142 void AliFITDigitizer::DigitizeHits()
146 Float_t time[160], besttime[160];
148 Int_t timeCFD, timeLED, timeQT1, timeQT0;
150 Int_t threshold = 0; //photoelectrons
152 Float_t mip2qtc=0.005;
153 Float_t channelWidth = 24.4 ;
154 Int_t pmt, mcp, volume, qt;
155 //eqailized distance from IP
157 Float_t zdetA = 375.;
158 Float_t c = 0.0299792458; // cm/ps
159 Float_t eqdistance = (zdetA - zdetC) /c;
161 AliFITHits *startHit;
164 Int_t nFiles=fDigInput->GetNinputs();
165 for (Int_t inputFile=0; inputFile<nFiles; inputFile++) {
166 if (inputFile < nFiles-1) {
167 AliWarning(Form("ignoring input stream %d", inputFile));
171 for (Int_t i0=0; i0<160; i0++)
173 time[i0]=besttime[i0]=999999; countE[i0]=0;
175 AliRunLoader * inRL = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(inputFile));
176 AliLoader * fitLoader = inRL->GetLoader("FITLoader");
177 if (!inRL->GetAliRun()) inRL->LoadgAlice();
180 fitLoader->LoadHits("READ");//probably it is necessary to load them before
181 fHits = fFIT->Hits ();
182 TTree *th = fitLoader->TreeH();
183 brHits = th->GetBranch("FIT");
185 fFIT->SetHitsAddressBranch(brHits);
187 AliWarning("Branch FIT hit not found for this event");
190 Int_t ntracks = (Int_t) th->GetEntries();
191 if (ntracks<=0) return;
192 // Start loop on tracks in the hits containers
193 for (Int_t track=0; track<ntracks;track++) {
194 brHits->GetEntry(track);
195 nhits = fHits->GetEntriesFast();
196 for (hit=0;hit<nhits;hit++)
198 startHit = (AliFITHits*) fHits->UncheckedAt(hit);
200 AliError("The unchecked hit doesn't exist");
203 pmt = startHit->Pmt();
204 mcp = startHit->MCP();
205 volume = startHit->Volume();
206 numpmt= volume*80 +4*(mcp) + (pmt-1);
207 besttime[numpmt] = startHit->Time();
208 if(besttime[numpmt]<time[numpmt]) time[numpmt]=besttime[numpmt];
213 for (Int_t ipmt=0; ipmt<160; ipmt++)
215 if (countE[ipmt]>threshold && time[ipmt]<50000 && time[ipmt]>0 ) {
219 qt= countE[ipmt] /*/ph2Mip*/; // 50mv/Mip amp in mV
221 if (ipmt<80) time[ipmt] = time[ipmt] + eqdistance;
222 timeCFD = Int_t (gRandom->Gaus(time[ipmt], 50)/channelWidth );
223 timeLED = Int_t (time[ipmt]/channelWidth );
225 timeQT1 = Int_t (qt ) ;
226 AliDebug(1,Form("Digits::::: numpmt %i time CFD %i QTC %i :: counts %i \n ", ipmt, timeCFD, timeQT1, countE[ipmt]) );
227 fFIT-> AddDigit(ipmt, timeCFD, timeLED, timeQT0, timeQT1, 0);
230 fitLoader->UnloadHits();
235 //____________________________________________________________________________
236 void AliFITDigitizer::AddSDigit(Int_t npmt,
237 Int_t timeCFD, Int_t timeLED, Int_t timeQT0,
243 TClonesArray &ldigits = *fDigits;
245 new(ldigits[fNdigits++]) AliFITDigit(npmt,
246 timeCFD, timeLED, timeQT0, timeQT1);
249 //____________________________________________________________________________
250 void AliFITDigitizer::ResetDigits()
256 if (fDigits) fDigits->Clear();