No return in void function (Alpha)
[u/mrichter/AliRoot.git] / RICH / AliRICHDigitizer.cxx
CommitLineData
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
32ClassImp(AliRICHDigitizer)
33
c60862bf 34//__________________________________________________________________________________________________
09c52ebc 35Bool_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.");
e42a7b46 39 AliRunLoader *pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
256c9e21 40 if (!pOutAL->GetAliRun()) pOutAL->LoadgAlice();
e42a7b46 41 fRich=(AliRICH*)pOutAL->GetAliRun()->GetDetector("RICH");//retrive RICH pointer from OUTPUT stream
09c52ebc 42 return kTRUE;
43}//Init()
c60862bf 44//__________________________________________________________________________________________________
aed240d4 45void AliRICHDigitizer::Exec(Option_t*)
b762c2f6 46{
e42a7b46 47//this method invoked
09c52ebc 48 if(GetDebug())Info("Exec","Start with %i input(s) for event %i",fManager->GetNinputs(),fManager->GetOutputEventNr());
3582c1f9 49
9416c50c 50 AliRunLoader *pInAL=0, *pOutAL;//in and out Run loaders
51 AliLoader *pInRL=0, *pOutRL;//in and out RICH loaders
88cb7938 52
c60862bf 53 pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
54 pOutRL = pOutAL->GetLoader("RICHLoader");
e42a7b46 55 pOutRL->MakeTree("D"); R()->MakeBranch("D"); //create TreeD with RICH branches in output stream
d4c94996 56
57 TClonesArray tmpCA("AliRICHdigit");//tmp storage for sdigits sum up from all input files
58 Int_t total=0;
9416c50c 59 for(Int_t inFileN=0;inFileN<fManager->GetNinputs();inFileN++){//files loop
e42a7b46 60 pInAL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inFileN));//get run loader from current input
d4c94996 61 pInRL = pInAL->GetLoader("RICHLoader"); if(pInRL==0) continue;//no RICH in this input, check the next input
256c9e21 62 if (!pInAL->GetAliRun()) pInAL->LoadgAlice();
63 AliRICH* rich=(AliRICH*)pInAL->GetAliRun()->GetDetector("RICH");
64 pInRL->LoadSDigits(); pInRL->TreeS()->GetEntry(0);
e42a7b46 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
89924db8 67 new(tmpCA[total++]) AliRICHdigit(*(AliRICHdigit*)rich->SDigits()->At(i));
68 ((AliRICHdigit*)tmpCA[total-1])->AddTidOffset(fManager->GetMask(inFileN));
69 }
256c9e21 70 pInRL->UnloadSDigits(); rich->ResetSDigits();
c60862bf 71 }//files loop
88cb7938 72
e42a7b46 73 tmpCA.Sort(); //sort them according to Id() method
d4c94996 74
e42a7b46 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};
09c52ebc 80 Int_t iNdigitsPerPad=0;//how many sdigits for a given pad
d4c94996 81 for(Int_t i=0;i<tmpCA.GetEntries();i++){//sdigits loop (sorted)
82 AliRICHdigit *pSdig=(AliRICHdigit*)tmpCA.At(i);//get new sdigit
09c52ebc 83 if(pSdig->Id()==id){//still the same pad
e42a7b46 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);
d4c94996 87 else if(GetDebug())Warning("Exec","More then 3 sdigits for the given pad");
09c52ebc 88 }else{//new pad, add the pevious one
e42a7b46 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;
09c52ebc 92 }
93 }//sdigits loop (sorted)
e42a7b46 94 if(tmpCA.GetEntries()&&R()->P()->IsOverTh(chamber,pad,q)) R()->AddDigit(chamber,pad,(Int_t)q,cfm,tid);//add the last dig
d4c94996 95
9416c50c 96 pOutRL->TreeD()->Fill(); //fill the tree with the list of digits
97 pOutRL->WriteDigits("OVERWRITE"); //serialize them to file
d4c94996 98
99 tmpCA.Clear();
e42a7b46 100 pOutRL->UnloadDigits(); R()->ResetDigits();
9416c50c 101
09c52ebc 102 if(GetDebug())Info("Exec","Stop.");
c60862bf 103}//Exec()
3582c1f9 104//__________________________________________________________________________________________________