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 **************************************************************************/
18 Revision 1.4 2002/05/28 07:53:10 morsch
19 Wrong order of arguments in for-statement corrected.
21 Revision 1.3 2001/12/05 14:53:34 hristov
24 Revision 1.2 2001/11/07 14:50:31 hristov
25 Minor correction of the Log part
27 Revision 1.1 2001/11/02 15:37:26 hristov
28 Digitizer class created. Code cleaning and bug fixes (J.Chudoba)
33 #include <TObjArray.h>
35 #include <TDirectory.h>
36 #include <TParticle.h>
38 #include "AliRICHDigitizer.h"
39 #include "AliRICHChamber.h"
40 #include "AliHitMap.h"
41 #include "AliRICHHitMapA1.h"
43 #include "AliRICHHit.h"
44 #include "AliRICHSDigit.h"
45 #include "AliRICHDigit.h"
46 #include "AliRICHTransientDigit.h"
49 #include "AliRunDigitizer.h"
51 ClassImp(AliRICHDigitizer)
53 //___________________________________________
54 AliRICHDigitizer::AliRICHDigitizer()
56 // Default constructor - don't use it
63 ////////////////////////////////////////////////////////////////////////
64 AliRICHDigitizer::AliRICHDigitizer(AliRunDigitizer* manager)
65 :AliDigitizer(manager)
67 // ctor which should be used
74 cerr<<"AliRICHDigitizer::AliRICHDigitizer"
75 <<"(AliRunDigitizer* manager) was processed"<<endl;
78 ////////////////////////////////////////////////////////////////////////
79 AliRICHDigitizer::~AliRICHDigitizer()
90 for (Int_t i=0; i<kNCH; i++ )
99 //------------------------------------------------------------------------
100 Bool_t AliRICHDigitizer::Exists(const AliRICHSDigit *padhit)
102 return (fHitMap[fNch]->TestHit(padhit->PadX(),padhit->PadY()));
105 //------------------------------------------------------------------------
106 void AliRICHDigitizer::Update(AliRICHSDigit *padhit)
108 AliRICHTransientDigit *pdigit =
109 static_cast<AliRICHTransientDigit*>(
110 fHitMap[fNch]->GetHit(padhit->PadX(),padhit->PadY()));
114 Int_t iqpad = Int_t(padhit->QPad()); // charge per pad
115 pdigit->AddSignal(iqpad);
116 pdigit->AddPhysicsSignal(iqpad);
118 // update list of tracks
121 track = fTrack+fMask;
127 pdigit->UpdateTrackList(track,charge);
130 //------------------------------------------------------------------------
131 void AliRICHDigitizer::CreateNew(AliRICHSDigit *padhit)
133 fTDList->AddAtAndExpand(
134 new AliRICHTransientDigit(fNch,fDigits),fCounter);
135 fHitMap[fNch]->SetHit(padhit->PadX(),padhit->PadY(),fCounter);
137 AliRICHTransientDigit* pdigit =
138 static_cast<AliRICHTransientDigit*>(fTDList->Last());
143 charge = padhit->QPad();
148 pdigit->AddToTrackList(track,charge);
153 ////////////////////////////////////////////////////////////////////////
154 Bool_t AliRICHDigitizer::Init()
157 fHits = new TClonesArray("AliRICHHit",1000);
158 fSDigits = new TClonesArray("AliRICHSDigit",1000);
162 ////////////////////////////////////////////////////////////////////////
163 //void AliRICHDigitizer::Digitise(Int_t nev, Int_t flag)
164 void AliRICHDigitizer::Exec(Option_t* option)
166 TString optionString = option;
167 if (optionString.Data() == "deb") {
168 cout<<"AliMUONDigitizer::Exec: called with option deb "<<endl;
172 AliRICHChamber* iChamber;
173 AliSegmentation* segmentation;
175 fTDList = new TObjArray;
177 AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH");
178 pRICH->MakeBranchInTreeD(fManager->GetTreeD());
179 fHitMap= new AliHitMap* [kNCH];
181 for (Int_t i =0; i<kNCH; i++) {
182 iChamber= &(pRICH->Chamber(i));
183 segmentation=iChamber->GetSegmentationModel(1);
184 fHitMap[i] = new AliRICHHitMapA1(segmentation, fTDList);
187 // Loop over files to digitize
190 for (Int_t inputFile=0; inputFile<fManager->GetNinputs();
193 // Connect RICH branches
195 if (inputFile > 0 ) fSignal = kFALSE;
196 TBranch *branchHits = 0;
197 TBranch *branchSDigits = 0;
198 TTree *treeH = fManager->GetInputTreeH(inputFile);
200 cerr<<" inputFile "<<inputFile<<endl;
201 cerr<<" treeH, fHits "<<treeH<<" "<<fHits<<endl;
203 if (treeH && fHits) {
204 branchHits = treeH->GetBranch("RICH");
207 branchHits->SetAddress(&fHits);
210 Error("Exec","branch RICH was not found");
212 if (GetDebug()>2) cerr<<" branchHits = "<<branchHits<<endl;
214 if (treeH && fSDigits) {
215 branchSDigits = treeH->GetBranch("RICHSDigits");
217 branchSDigits->SetAddress(&fSDigits);
219 Error("exec","branch RICHSDigits was not found");
221 if (GetDebug()>2) cerr<<" branchSDigits = "<<branchSDigits<<endl;
228 Int_t ntracks =(Int_t) treeH->GetEntries();
229 for (fTrack=0; fTrack<ntracks; fTrack++) {
232 branchHits->GetEntry(fTrack);
233 branchSDigits->GetEntry(fTrack);
238 for(Int_t i = 0; i < fHits->GetEntriesFast(); ++i) {
239 AliRICHHit* mHit = static_cast<AliRICHHit*>(fHits->At(i));
240 fNch = mHit->Chamber()-1; // chamber number
242 cerr<<"AliRICHDigitizer: chamber nr. fNch out of range: "<<fNch<<endl;
243 cerr<<" track: "<<fTrack<<endl;
246 iChamber = &(pRICH->Chamber(fNch));
249 // Loop over pad hits
250 for (AliRICHSDigit* mPad=
251 (AliRICHSDigit*)pRICH->FirstPad(mHit,fSDigits);
253 mPad=(AliRICHSDigit*)pRICH->NextPad(fSDigits))
255 Int_t iqpad = mPad->QPad(); // charge per pad
256 fDigits[0]=mPad->PadX();
257 fDigits[1]=mPad->PadY();
260 fDigits[4]=mPad->HitNumber();
262 // build the list of fired pads and update the info
268 } //end loop over clusters
272 if (GetDebug()>2) cerr<<"END OF FILE LOOP"<<endl;
274 Int_t tracks[kMAXTRACKSPERRICHDIGIT];
275 Int_t charges[kMAXTRACKSPERRICHDIGIT];
276 Int_t nentries=fTDList->GetEntriesFast();
278 for (Int_t nent=0;nent<nentries;nent++) {
279 AliRICHTransientDigit *transDigit=(AliRICHTransientDigit*)fTDList->At(nent);
280 if (transDigit==0) continue;
281 Int_t ich=transDigit->GetChamber();
282 Int_t q=transDigit->Signal();
283 iChamber=&(pRICH->Chamber(ich));
284 AliRICHResponse * response=iChamber->GetResponseModel();
285 Int_t adcmax= (Int_t) response->MaxAdc();
288 // add white noise and do zero-suppression and signal truncation (new electronics,old electronics gaus 1.2,0.2)
289 //printf("Treshold: %d\n",iChamber->fTresh->GetHitIndex(transDigit->PadX(),transDigit->PadY()));
292 // Int_t pedestal = iChamber->fTresh->GetHitIndex(transDigit->PadX(),transDigit->PadY());
296 //printf("Pedestal:%d\n",pedestal);
298 Float_t treshold = (pedestal + 4*2.2);
300 Float_t meanNoise = gRandom->Gaus(2.2, 0.3);
301 Float_t noise = gRandom->Gaus(0, meanNoise);
302 q+=(Int_t)(noise + pedestal);
304 // magic number to be parametrised !!!
311 if ( q >= adcmax) q=adcmax;
312 fDigits[0]=transDigit->PadX();
313 fDigits[1]=transDigit->PadY();
315 fDigits[3]=transDigit->Physics();
316 fDigits[4]=transDigit->Hit();
318 Int_t nptracks = transDigit->GetNTracks();
320 // this was changed to accomodate the real number of tracks
321 if (nptracks > kMAXTRACKSPERRICHDIGIT) {
322 printf("Attention - tracks > 10 %d\n",nptracks);
323 nptracks=kMAXTRACKSPERRICHDIGIT;
326 printf("Attention - tracks > 2 %d \n",nptracks);
328 for (Int_t tr=0;tr<nptracks;tr++) {
329 tracks[tr]=transDigit->GetTrack(tr);
330 charges[tr]=transDigit->GetCharge(tr);
331 } //end loop over list of tracks for one pad
332 if (nptracks < kMAXTRACKSPERRICHDIGIT ) {
333 for (Int_t t=nptracks; t<kMAXTRACKSPERRICHDIGIT; t++) {
340 //fprintf(points,"%4d, %4d, %4d\n",digits[0],digits[1],digits[2]);
343 pRICH->AddDigits(ich,tracks,charges,fDigits);
345 fManager->GetTreeD()->Fill();
347 pRICH->ResetDigits();
348 fTDList->Delete(); // or fTDList->Clear(); ???
349 for(Int_t ii=0;ii<kNCH;++ii) {
356 TClonesArray *richDigits;
357 for (Int_t k=0;k<kNCH;k++) {
358 richDigits = pRICH->DigitsAddress(k);
359 Int_t ndigit=richDigits->GetEntriesFast();
360 printf ("Chamber %d digits %d \n",k,ndigit);
362 pRICH->ResetDigits(); /// ??? should it be here???
363 fManager->GetTreeD()->Write(0,TObject::kOverwrite);
367 if (fHits) fHits->Delete();
368 if (fSDigits) fSDigits->Delete();