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 #include <Riostream.h>
20 #include <TObjArray.h>
22 #include <TDirectory.h>
23 #include <TParticle.h>
25 #include <AliRunLoader.h>
26 #include <AliLoader.h>
28 #include "AliRICHDigitizer.h"
30 #include "AliRunDigitizer.h"
32 ClassImp(AliRICHDigitizer)
34 //__________________________________________________________________________________________________
35 Bool_t AliRICHDigitizer::Init()
37 //This methode is called from AliRunDigitizer after the corresponding file is open
38 if(GetDebug())Info("Init","Start.");
39 fRich=(AliRICH*)gAlice->GetDetector("RICH");
40 Rich()->Param()->GenSigmaThMap();
43 //__________________________________________________________________________________________________
44 void AliRICHDigitizer::Exec(Option_t*)
46 if(GetDebug())Info("Exec","Start with %i input(s) for event %i",fManager->GetNinputs(),fManager->GetOutputEventNr());
48 AliRunLoader *pInAL=0, *pOutAL;//in and out Run loaders
49 AliLoader *pInRL=0, *pOutRL;//in and out RICH loaders
51 pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
52 pOutRL = pOutAL->GetLoader("RICHLoader");
53 pOutRL->MakeTree("D"); Rich()->MakeBranch("D"); //create TreeD with RICH branches in output stream
54 for(Int_t inFileN=0;inFileN<fManager->GetNinputs();inFileN++){//files loop
55 pInAL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN)); pInRL = pInAL->GetLoader("RICHLoader");
56 pInRL->LoadSDigits(); pInAL->GetEvent(fManager->GetOutputEventNr()); pInRL->TreeS()->GetEntry(0);
57 pInRL->UnloadSDigits();
60 Rich()->SDigits()->Sort(); //sort them according to Id() methode
61 Int_t combiPid=0,chamber=0,x=0,y=0,tid[3],id=0; Double_t q=0;
62 Int_t iNdigitsPerPad=0;//how many sdigits for a given pad
63 for(Int_t i=0;i<Rich()->SDigits()->GetEntries();i++){//sdigits loop (sorted)
64 AliRICHdigit *pSdig=(AliRICHdigit*)Rich()->SDigits()->At(i);
65 if(pSdig->Id()==id){//still the same pad
66 iNdigitsPerPad++; q+=pSdig->Q(); combiPid+=pSdig->CombiPid();//sum up charge and cfm
67 if(iNdigitsPerPad<=3) tid[iNdigitsPerPad-1]=pSdig->Tid(0);
68 else Warning("SDigits2Digits","More then 3 sdigits for the given pad");
69 }else{//new pad, add the pevious one
70 if(id!=kBad&&Rich()->Param()->IsOverTh(chamber,x,y,q)) Rich()->AddDigit(chamber,x,y,(Int_t)q,combiPid,tid); //add newly created dig
71 combiPid=pSdig->CombiPid(); chamber=pSdig->C(); id=pSdig->Id(); x=pSdig->X(); y=pSdig->Y(); q=pSdig->Q(); //init all values by current sdig
72 iNdigitsPerPad=1; tid[0]=pSdig->Tid(0); tid[1]=tid[2]=kBad;
74 }//sdigits loop (sorted)
75 if(Rich()->SDigits()->GetEntries()&&Rich()->Param()->IsOverTh(chamber,x,y,q)) Rich()->AddDigit(chamber,x,y,(Int_t)q,combiPid,tid);//add the last dig
76 pOutRL->TreeD()->Fill(); //fill the tree with the list of digits
77 pOutRL->WriteDigits("OVERWRITE"); //serialize them to file
79 if(GetDebug())Info("Exec","Stop.");
81 //__________________________________________________________________________________________________