]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - RICH/AliRICHDigitizer.cxx
No return in void function (Alpha)
[u/mrichter/AliRoot.git] / RICH / AliRICHDigitizer.cxx
... / ...
CommitLineData
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
16
17#include <Riostream.h>
18
19#include <TTree.h>
20#include <TObjArray.h>
21#include <TFile.h>
22#include <TDirectory.h>
23#include <TParticle.h>
24
25#include <AliRunLoader.h>
26#include <AliLoader.h>
27
28#include "AliRICHDigitizer.h"
29#include "AliRICH.h"
30#include "AliRunDigitizer.h"
31
32ClassImp(AliRICHDigitizer)
33
34//__________________________________________________________________________________________________
35Bool_t AliRICHDigitizer::Init()
36{
37//This methode is called from AliRunDigitizer after the corresponding file is open
38 if(GetDebug())Info("Init","Start.");
39 AliRunLoader *pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
40 if (!pOutAL->GetAliRun()) pOutAL->LoadgAlice();
41 fRich=(AliRICH*)pOutAL->GetAliRun()->GetDetector("RICH");//retrive RICH pointer from OUTPUT stream
42 return kTRUE;
43}//Init()
44//__________________________________________________________________________________________________
45void AliRICHDigitizer::Exec(Option_t*)
46{
47//this method invoked
48 if(GetDebug())Info("Exec","Start with %i input(s) for event %i",fManager->GetNinputs(),fManager->GetOutputEventNr());
49
50 AliRunLoader *pInAL=0, *pOutAL;//in and out Run loaders
51 AliLoader *pInRL=0, *pOutRL;//in and out RICH loaders
52
53 pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
54 pOutRL = pOutAL->GetLoader("RICHLoader");
55 pOutRL->MakeTree("D"); R()->MakeBranch("D"); //create TreeD with RICH branches in output stream
56
57 TClonesArray tmpCA("AliRICHdigit");//tmp storage for sdigits sum up from all input files
58 Int_t total=0;
59 for(Int_t inFileN=0;inFileN<fManager->GetNinputs();inFileN++){//files loop
60 pInAL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN));//get run loader from current input
61 pInRL = pInAL->GetLoader("RICHLoader"); if(pInRL==0) continue;//no RICH in this input, check the next input
62 if (!pInAL->GetAliRun()) pInAL->LoadgAlice();
63 AliRICH* rich=(AliRICH*)pInAL->GetAliRun()->GetDetector("RICH");
64 pInRL->LoadSDigits(); pInRL->TreeS()->GetEntry(0);
65 if(GetDebug())Info("Exec","input %i has %i sdigits",inFileN,rich->SDigits()->GetEntries());
66 for(Int_t i=0;i<rich->SDigits()->GetEntries();i++){//collect sdigits from current input to tmpCA
67 new(tmpCA[total++]) AliRICHdigit(*(AliRICHdigit*)rich->SDigits()->At(i));
68 ((AliRICHdigit*)tmpCA[total-1])->AddTidOffset(fManager->GetMask(inFileN));
69 }
70 pInRL->UnloadSDigits(); rich->ResetSDigits();
71 }//files loop
72
73 tmpCA.Sort(); //sort them according to Id() method
74
75 if(GetDebug()) {tmpCA.Print();Info("Exec","Totally %i sdigits in %i inputs",tmpCA.GetEntries(),fManager->GetNinputs());}
76 Int_t cfm=0,chamber=0,id=0; //cfm is cerenkov feedback mip mixture
77 TVector pad(2); pad[0]=0;pad[1]=0;
78 Double_t q=0;
79 Int_t tid[3]={0,0,0};
80 Int_t iNdigitsPerPad=0;//how many sdigits for a given pad
81 for(Int_t i=0;i<tmpCA.GetEntries();i++){//sdigits loop (sorted)
82 AliRICHdigit *pSdig=(AliRICHdigit*)tmpCA.At(i);//get new sdigit
83 if(pSdig->Id()==id){//still the same pad
84 iNdigitsPerPad++; q+=pSdig->Q(); cfm+=pSdig->ChFbMi();//sum up charge and cfm
85 if(pSdig->ChFbMi()==1) tid[0] = pSdig->GetTrack(0); // force the first tid to be mip's tid if it exists in the current pad
86 if(iNdigitsPerPad<=3) tid[iNdigitsPerPad-1]=pSdig->GetTrack(0);
87 else if(GetDebug())Warning("Exec","More then 3 sdigits for the given pad");
88 }else{//new pad, add the pevious one
89 if(id!=kBad&&R()->P()->IsOverTh(chamber,pad,q)) R()->AddDigit(chamber,pad,(Int_t)q,cfm,tid); //add newly created dig
90 cfm=pSdig->ChFbMi(); chamber=pSdig->C(); id=pSdig->Id(); pad=pSdig->Pad(); q=pSdig->Q(); //init all values by current sdig
91 iNdigitsPerPad=1; tid[0]=pSdig->GetTrack(0); tid[1]=tid[2]=kBad;
92 }
93 }//sdigits loop (sorted)
94 if(tmpCA.GetEntries()&&R()->P()->IsOverTh(chamber,pad,q)) R()->AddDigit(chamber,pad,(Int_t)q,cfm,tid);//add the last dig
95
96 pOutRL->TreeD()->Fill(); //fill the tree with the list of digits
97 pOutRL->WriteDigits("OVERWRITE"); //serialize them to file
98
99 tmpCA.Clear();
100 pOutRL->UnloadDigits(); R()->ResetDigits();
101
102 if(GetDebug())Info("Exec","Stop.");
103}//Exec()
104//__________________________________________________________________________________________________