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
151 Float_t channelWidth = 24.4 ;
152 Int_t pmt, mcp, volume, qt;
153 //eqailized distance from IP
155 Float_t zdetA = 375.;
156 Float_t c = 0.0299792458; // cm/ps
157 Float_t eqdistance = (zdetA - zdetC) /c;
159 AliFITHits *startHit;
162 Int_t nFiles=fDigInput->GetNinputs();
163 for (Int_t inputFile=0; inputFile<nFiles; inputFile++) {
164 if (inputFile < nFiles-1) {
165 AliWarning(Form("ignoring input stream %d", inputFile));
169 for (Int_t i0=0; i0<160; i0++)
171 time[i0]=besttime[i0]=999999; countE[i0]=0;
173 AliRunLoader * inRL = AliRunLoader::GetRunLoader(fDigInput->GetInputFolderName(inputFile));
174 AliLoader * fitLoader = inRL->GetLoader("FITLoader");
175 if (!inRL->GetAliRun()) inRL->LoadgAlice();
178 fitLoader->LoadHits("READ");//probably it is necessary to load them before
179 fHits = fFIT->Hits ();
180 TTree *th = fitLoader->TreeH();
181 brHits = th->GetBranch("FIT");
183 fFIT->SetHitsAddressBranch(brHits);
185 AliWarning("Branch FIT hit not found for this event");
188 Int_t ntracks = (Int_t) th->GetEntries();
189 if (ntracks<=0) return;
190 // Start loop on tracks in the hits containers
191 for (Int_t track=0; track<ntracks;track++) {
192 brHits->GetEntry(track);
193 nhits = fHits->GetEntriesFast();
194 for (hit=0;hit<nhits;hit++)
196 startHit = (AliFITHits*) fHits->UncheckedAt(hit);
198 AliError("The unchecked hit doesn't exist");
201 pmt = startHit->Pmt();
202 mcp = startHit->MCP();
203 volume = startHit->Volume();
204 numpmt= volume*80 +4*(mcp) + (pmt-1);
205 besttime[numpmt] = startHit->Time();
206 if(besttime[numpmt]<time[numpmt]) time[numpmt]=besttime[numpmt];
211 for (Int_t ipmt=0; ipmt<160; ipmt++)
213 if (countE[ipmt]>threshold && time[ipmt]<50000 && time[ipmt]>0 ) {
217 qt= countE[ipmt] /*/ph2Mip*/; // 50mv/Mip amp in mV
219 if (ipmt<80) time[ipmt] = time[ipmt] + eqdistance;
220 timeCFD = Int_t (gRandom->Gaus(time[ipmt], 50)/channelWidth );
221 timeLED = Int_t (time[ipmt]/channelWidth );
223 timeQT1 = Int_t (qt ) ;
224 AliDebug(1,Form("Digits::::: numpmt %i time CFD %i QTC %i :: counts %i \n ", ipmt, timeCFD, timeQT1, countE[ipmt]) );
225 fFIT-> AddDigit(ipmt, timeCFD, timeLED, timeQT0, timeQT1, 0);
228 fitLoader->UnloadHits();
233 //____________________________________________________________________________
234 void AliFITDigitizer::AddSDigit(Int_t npmt,
235 Int_t timeCFD, Int_t timeLED, Int_t timeQT0,
241 TClonesArray &ldigits = *fDigits;
243 new(ldigits[fNdigits++]) AliFITDigit(npmt,
244 timeCFD, timeLED, timeQT0, timeQT1);
247 //____________________________________________________________________________
248 void AliFITDigitizer::ResetDigits()
254 if (fDigits) fDigits->Clear();