b762c2f6 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
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 | **************************************************************************/ |
15 | |
b9d0a01d |
16 | |
7118aef0 |
17 | #include <Riostream.h> |
b762c2f6 |
18 | |
19 | #include <TTree.h> |
20 | #include <TObjArray.h> |
21 | #include <TFile.h> |
22 | #include <TDirectory.h> |
23 | #include <TParticle.h> |
24 | |
aed240d4 |
25 | #include <AliRunLoader.h> |
26 | #include <AliLoader.h> |
88cb7938 |
27 | |
b762c2f6 |
28 | #include "AliRICHDigitizer.h" |
b762c2f6 |
29 | #include "AliRICH.h" |
b762c2f6 |
30 | #include "AliRunDigitizer.h" |
31 | |
32 | ClassImp(AliRICHDigitizer) |
33 | |
f3afb52f |
34 | //__________________________________________________________________________________________________ |
09c52ebc |
35 | Bool_t AliRICHDigitizer::Init() |
3582c1f9 |
36 | { |
09c52ebc |
37 | //This methode is called from AliRunDigitizer after the corresponding file is open |
38 | if(GetDebug())Info("Init","Start."); |
256c9e21 |
39 | AliRunLoader *pOutAL = |
40 | AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); |
41 | if (!pOutAL->GetAliRun()) pOutAL->LoadgAlice(); |
42 | fRich=(AliRICH*)pOutAL->GetAliRun()->GetDetector("RICH"); |
d4c94996 |
43 | Rich()->P()->GenSigmaThMap(); |
09c52ebc |
44 | return kTRUE; |
45 | }//Init() |
c60862bf |
46 | //__________________________________________________________________________________________________ |
aed240d4 |
47 | void AliRICHDigitizer::Exec(Option_t*) |
b762c2f6 |
48 | { |
09c52ebc |
49 | if(GetDebug())Info("Exec","Start with %i input(s) for event %i",fManager->GetNinputs(),fManager->GetOutputEventNr()); |
3582c1f9 |
50 | |
9416c50c |
51 | AliRunLoader *pInAL=0, *pOutAL;//in and out Run loaders |
52 | AliLoader *pInRL=0, *pOutRL;//in and out RICH loaders |
88cb7938 |
53 | |
c60862bf |
54 | pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); |
55 | pOutRL = pOutAL->GetLoader("RICHLoader"); |
9416c50c |
56 | pOutRL->MakeTree("D"); Rich()->MakeBranch("D"); //create TreeD with RICH branches in output stream |
d4c94996 |
57 | |
58 | TClonesArray tmpCA("AliRICHdigit");//tmp storage for sdigits sum up from all input files |
59 | Int_t total=0; |
9416c50c |
60 | for(Int_t inFileN=0;inFileN<fManager->GetNinputs();inFileN++){//files loop |
d4c94996 |
61 | pInAL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN)); |
62 | pInRL = pInAL->GetLoader("RICHLoader"); if(pInRL==0) continue;//no RICH in this input, check the next input |
256c9e21 |
63 | if (!pInAL->GetAliRun()) pInAL->LoadgAlice(); |
64 | AliRICH* rich=(AliRICH*)pInAL->GetAliRun()->GetDetector("RICH"); |
65 | pInRL->LoadSDigits(); pInRL->TreeS()->GetEntry(0); |
66 | Info("Exec","input %i has %i sdigits",inFileN,rich->SDigits()->GetEntries()); |
67 | for(Int_t i=0;i<rich->SDigits()->GetEntries();i++) new(tmpCA[total++]) AliRICHdigit(*(AliRICHdigit*)rich->SDigits()->At(i)); |
68 | pInRL->UnloadSDigits(); rich->ResetSDigits(); |
c60862bf |
69 | }//files loop |
88cb7938 |
70 | |
d4c94996 |
71 | tmpCA.Sort(); //sort them according to Id() methode |
72 | |
73 | Int_t chFbMip=0,chamber=0,x=0,y=0,tid[3],id=0; Double_t q=0; |
09c52ebc |
74 | Int_t iNdigitsPerPad=0;//how many sdigits for a given pad |
d4c94996 |
75 | for(Int_t i=0;i<tmpCA.GetEntries();i++){//sdigits loop (sorted) |
76 | AliRICHdigit *pSdig=(AliRICHdigit*)tmpCA.At(i);//get new sdigit |
09c52ebc |
77 | if(pSdig->Id()==id){//still the same pad |
d4c94996 |
78 | iNdigitsPerPad++; q+=pSdig->Q(); chFbMip+=pSdig->ChFbMi();//sum up charge and cfm |
09c52ebc |
79 | if(iNdigitsPerPad<=3) tid[iNdigitsPerPad-1]=pSdig->Tid(0); |
d4c94996 |
80 | else if(GetDebug())Warning("Exec","More then 3 sdigits for the given pad"); |
09c52ebc |
81 | }else{//new pad, add the pevious one |
d4c94996 |
82 | if(id!=kBad&&Rich()->P()->IsOverTh(chamber,x,y,q)) Rich()->AddDigit(chamber,x,y,(Int_t)q,chFbMip,tid); //add newly created dig |
83 | chFbMip=pSdig->ChFbMi(); chamber=pSdig->C(); id=pSdig->Id(); x=pSdig->X(); y=pSdig->Y(); q=pSdig->Q(); //init all values by current sdig |
09c52ebc |
84 | iNdigitsPerPad=1; tid[0]=pSdig->Tid(0); tid[1]=tid[2]=kBad; |
85 | } |
86 | }//sdigits loop (sorted) |
d4c94996 |
87 | if(tmpCA.GetEntries()&&Rich()->P()->IsOverTh(chamber,x,y,q)) Rich()->AddDigit(chamber,x,y,(Int_t)q,chFbMip,tid);//add the last dig |
88 | |
9416c50c |
89 | pOutRL->TreeD()->Fill(); //fill the tree with the list of digits |
90 | pOutRL->WriteDigits("OVERWRITE"); //serialize them to file |
d4c94996 |
91 | |
92 | tmpCA.Clear(); |
93 | pOutRL->UnloadDigits(); Rich()->ResetDigits(); |
9416c50c |
94 | |
09c52ebc |
95 | if(GetDebug())Info("Exec","Stop."); |
c60862bf |
96 | }//Exec() |
3582c1f9 |
97 | //__________________________________________________________________________________________________ |