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.3 2001/12/05 14:53:34 hristov
21 Revision 1.2 2001/11/07 14:50:31 hristov
22 Minor correction of the Log part
24 Revision 1.1 2001/11/02 15:37:26 hristov
25 Digitizer class created. Code cleaning and bug fixes (J.Chudoba)
30 #include <TObjArray.h>
32 #include <TDirectory.h>
33 #include <TParticle.h>
35 #include "AliRICHDigitizer.h"
36 #include "AliRICHChamber.h"
37 #include "AliHitMap.h"
38 #include "AliRICHHitMapA1.h"
40 #include "AliRICHHit.h"
41 #include "AliRICHSDigit.h"
42 #include "AliRICHDigit.h"
43 #include "AliRICHTransientDigit.h"
46 #include "AliRunDigitizer.h"
48 ClassImp(AliRICHDigitizer)
50 //___________________________________________
51 AliRICHDigitizer::AliRICHDigitizer()
53 // Default constructor - don't use it
60 ////////////////////////////////////////////////////////////////////////
61 AliRICHDigitizer::AliRICHDigitizer(AliRunDigitizer* manager)
62 :AliDigitizer(manager)
64 // ctor which should be used
71 cerr<<"AliRICHDigitizer::AliRICHDigitizer"
72 <<"(AliRunDigitizer* manager) was processed"<<endl;
75 ////////////////////////////////////////////////////////////////////////
76 AliRICHDigitizer::~AliRICHDigitizer()
87 for (Int_t i=0; i<kNCH; i++ )
96 //------------------------------------------------------------------------
97 Bool_t AliRICHDigitizer::Exists(const AliRICHSDigit *padhit)
99 return (fHitMap[fNch]->TestHit(padhit->PadX(),padhit->PadY()));
102 //------------------------------------------------------------------------
103 void AliRICHDigitizer::Update(AliRICHSDigit *padhit)
105 AliRICHTransientDigit *pdigit =
106 static_cast<AliRICHTransientDigit*>(
107 fHitMap[fNch]->GetHit(padhit->PadX(),padhit->PadY()));
111 Int_t iqpad = Int_t(padhit->QPad()); // charge per pad
112 pdigit->AddSignal(iqpad);
113 pdigit->AddPhysicsSignal(iqpad);
115 // update list of tracks
118 track = fTrack+fMask;
124 pdigit->UpdateTrackList(track,charge);
127 //------------------------------------------------------------------------
128 void AliRICHDigitizer::CreateNew(AliRICHSDigit *padhit)
130 fTDList->AddAtAndExpand(
131 new AliRICHTransientDigit(fNch,fDigits),fCounter);
132 fHitMap[fNch]->SetHit(padhit->PadX(),padhit->PadY(),fCounter);
134 AliRICHTransientDigit* pdigit =
135 static_cast<AliRICHTransientDigit*>(fTDList->Last());
140 charge = padhit->QPad();
145 pdigit->AddToTrackList(track,charge);
150 ////////////////////////////////////////////////////////////////////////
151 Bool_t AliRICHDigitizer::Init()
154 fHits = new TClonesArray("AliRICHHit",1000);
155 fSDigits = new TClonesArray("AliRICHSDigit",1000);
159 ////////////////////////////////////////////////////////////////////////
160 //void AliRICHDigitizer::Digitise(Int_t nev, Int_t flag)
161 void AliRICHDigitizer::Exec(Option_t* option)
163 TString optionString = option;
164 if (optionString.Data() == "deb") {
165 cout<<"AliMUONDigitizer::Exec: called with option deb "<<endl;
169 AliRICHChamber* iChamber;
170 AliSegmentation* segmentation;
172 fTDList = new TObjArray;
174 AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH");
175 pRICH->MakeBranchInTreeD(fManager->GetTreeD());
176 fHitMap= new AliHitMap* [kNCH];
178 for (Int_t i =0; i<kNCH; i++) {
179 iChamber= &(pRICH->Chamber(i));
180 segmentation=iChamber->GetSegmentationModel(1);
181 fHitMap[i] = new AliRICHHitMapA1(segmentation, fTDList);
184 // Loop over files to digitize
187 for (Int_t inputFile=0; inputFile<fManager->GetNinputs();
190 // Connect RICH branches
192 if (inputFile > 0 ) fSignal = kFALSE;
193 TBranch *branchHits = 0;
194 TBranch *branchSDigits = 0;
195 TTree *treeH = fManager->GetInputTreeH(inputFile);
197 cerr<<" inputFile "<<inputFile<<endl;
198 cerr<<" treeH, fHits "<<treeH<<" "<<fHits<<endl;
200 if (treeH && fHits) {
201 branchHits = treeH->GetBranch("RICH");
204 branchHits->SetAddress(&fHits);
207 Error("Exec","branch RICH was not found");
209 if (GetDebug()>2) cerr<<" branchHits = "<<branchHits<<endl;
211 if (treeH && fSDigits) {
212 branchSDigits = treeH->GetBranch("RICHSDigits");
214 branchSDigits->SetAddress(&fSDigits);
216 Error("exec","branch RICHSDigits was not found");
218 if (GetDebug()>2) cerr<<" branchSDigits = "<<branchSDigits<<endl;
225 Int_t ntracks =(Int_t) treeH->GetEntries();
226 for (fTrack=0; fTrack<ntracks; fTrack++) {
229 branchHits->GetEntry(fTrack);
230 branchSDigits->GetEntry(fTrack);
235 for(Int_t i = 0; i < fHits->GetEntriesFast(); ++i) {
236 AliRICHHit* mHit = static_cast<AliRICHHit*>(fHits->At(i));
237 fNch = mHit->Chamber()-1; // chamber number
239 cerr<<"AliRICHDigitizer: chamber nr. fNch out of range: "<<fNch<<endl;
240 cerr<<" track: "<<fTrack<<endl;
243 iChamber = &(pRICH->Chamber(fNch));
246 // Loop over pad hits
247 for (AliRICHSDigit* mPad=
248 (AliRICHSDigit*)pRICH->FirstPad(mHit,fSDigits);
250 mPad=(AliRICHSDigit*)pRICH->NextPad(fSDigits))
252 Int_t iqpad = mPad->QPad(); // charge per pad
253 fDigits[0]=mPad->PadX();
254 fDigits[1]=mPad->PadY();
257 fDigits[4]=mPad->HitNumber();
259 // build the list of fired pads and update the info
265 } //end loop over clusters
269 if (GetDebug()>2) cerr<<"END OF FILE LOOP"<<endl;
271 Int_t tracks[kMAXTRACKSPERRICHDIGIT];
272 Int_t charges[kMAXTRACKSPERRICHDIGIT];
273 Int_t nentries=fTDList->GetEntriesFast();
275 for (Int_t nent=0;nent<nentries;nent++) {
276 AliRICHTransientDigit *transDigit=(AliRICHTransientDigit*)fTDList->At(nent);
277 if (transDigit==0) continue;
278 Int_t ich=transDigit->GetChamber();
279 Int_t q=transDigit->Signal();
280 iChamber=&(pRICH->Chamber(ich));
281 AliRICHResponse * response=iChamber->GetResponseModel();
282 Int_t adcmax= (Int_t) response->MaxAdc();
285 // add white noise and do zero-suppression and signal truncation (new electronics,old electronics gaus 1.2,0.2)
286 //printf("Treshold: %d\n",iChamber->fTresh->GetHitIndex(transDigit->PadX(),transDigit->PadY()));
289 // Int_t pedestal = iChamber->fTresh->GetHitIndex(transDigit->PadX(),transDigit->PadY());
293 //printf("Pedestal:%d\n",pedestal);
295 Float_t treshold = (pedestal + 4*2.2);
297 Float_t meanNoise = gRandom->Gaus(2.2, 0.3);
298 Float_t noise = gRandom->Gaus(0, meanNoise);
299 q+=(Int_t)(noise + pedestal);
301 // magic number to be parametrised !!!
308 if ( q >= adcmax) q=adcmax;
309 fDigits[0]=transDigit->PadX();
310 fDigits[1]=transDigit->PadY();
312 fDigits[3]=transDigit->Physics();
313 fDigits[4]=transDigit->Hit();
315 Int_t nptracks = transDigit->GetNTracks();
317 // this was changed to accomodate the real number of tracks
318 if (nptracks > kMAXTRACKSPERRICHDIGIT) {
319 printf("Attention - tracks > 10 %d\n",nptracks);
320 nptracks=kMAXTRACKSPERRICHDIGIT;
323 printf("Attention - tracks > 2 %d \n",nptracks);
325 for (Int_t tr=0;tr<nptracks;tr++) {
326 tracks[tr]=transDigit->GetTrack(tr);
327 charges[tr]=transDigit->GetCharge(tr);
328 } //end loop over list of tracks for one pad
329 if (nptracks < kMAXTRACKSPERRICHDIGIT ) {
330 for (Int_t t=nptracks; t<kMAXTRACKSPERRICHDIGIT; t++) {
337 //fprintf(points,"%4d, %4d, %4d\n",digits[0],digits[1],digits[2]);
340 pRICH->AddDigits(ich,tracks,charges,fDigits);
342 fManager->GetTreeD()->Fill();
344 pRICH->ResetDigits();
345 fTDList->Delete(); // or fTDList->Clear(); ???
346 for(Int_t ii=0;ii<kNCH;++ii) {
353 TClonesArray *richDigits;
354 for (Int_t k=0;k<kNCH;k++) {
355 richDigits = pRICH->DigitsAddress(k);
356 Int_t ndigit=richDigits->GetEntriesFast();
357 printf ("Chamber %d digits %d \n",k,ndigit);
359 pRICH->ResetDigits(); /// ??? should it be here???
360 fManager->GetTreeD()->Write(0,TObject::kOverwrite);
364 if (fHits) fHits->Delete();
365 if (fSDigits) fSDigits->Delete();