]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHClusterFinder.cxx
Using new for arrays with undefined size
[u/mrichter/AliRoot.git] / RICH / AliRICHClusterFinder.cxx
CommitLineData
8265fa96 1/**************************************************************************
2 * Copyright(c) 1998-1999, 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
8265fa96 16
17#include "AliRICHClusterFinder.h"
237c933d 18#include "AliRICH.h"
543d5224 19#include "AliRICHMap.h"
543d5224 20#include "AliRICHParam.h"
cbaf35fb 21#include <AliLoader.h>
22#include <AliRun.h>
8265fa96 23
8265fa96 24
25ClassImp(AliRICHClusterFinder)
543d5224 26//__________________________________________________________________________________________________
27AliRICHClusterFinder::AliRICHClusterFinder(AliRICH *pRICH)
28{//main ctor
29 Info("main ctor","Start.");
30
cbaf35fb 31 fRICH = pRICH;
543d5224 32
cbaf35fb 33 fHitMap = 0;
543d5224 34
543d5224 35}//main ctor
36//__________________________________________________________________________________________________
eaf390d9 37void AliRICHClusterFinder::FindLocalMaxima(AliRICHcluster &rawCluster)
543d5224 38{// Split the cluster according to the number of maxima inside
6ce834b4 39 Info("SplitbyLocalMaxima","Start.");
cbaf35fb 40 Int_t Nlocal = 0;
41 Int_t localX[100],localY[100];
eaf390d9 42 for(Int_t iDig1=0;iDig1<rawCluster.Size();iDig1++) {
cbaf35fb 43 Int_t iNotMax = 0;
eaf390d9 44 AliRICHdigit *pDig1 = (AliRICHdigit *)rawCluster.Digits()->At(iDig1);
cbaf35fb 45 Int_t padX1 = pDig1->X();
46 Int_t padY1 = pDig1->Y();
47 Double_t padQ1 = pDig1->Q();
eaf390d9 48 for(Int_t iDig2=0;iDig2<rawCluster.Size();iDig2++) {
49 AliRICHdigit *pDig2 = (AliRICHdigit *)rawCluster.Digits()->At(iDig2);
cbaf35fb 50 Int_t padX2 = pDig2->X();
51 Int_t padY2 = pDig2->Y();
52 Double_t padQ2 = pDig2->Q();
53 if(iDig1==iDig2) continue;
54 Int_t diffx = TMath::Sign(padX1-padX2,1);
55 Int_t diffy = TMath::Sign(padY1-padY2,1);
56 if((diffx+diffy)<=1) {
57 if(padQ2>padQ1) iNotMax++;
58 }
8265fa96 59 }
cbaf35fb 60 if(iNotMax==0) {
61 localX[Nlocal] = padX1;
62 localY[Nlocal] = padY1;
63 Nlocal++;
8265fa96 64 }
cbaf35fb 65 }
66}//FindLocalMaxima()
543d5224 67//__________________________________________________________________________________________________
68void AliRICHClusterFinder::Exec()
237c933d 69{
543d5224 70 Info("Exec","Start.");
71
cbaf35fb 72
543d5224 73 Rich()->GetLoader()->LoadDigits();
74
75 for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events loop
76 gAlice->GetRunLoader()->GetEvent(iEventN);
237c933d 77
543d5224 78 Rich()->GetLoader()->MakeTree("R"); Rich()->MakeBranch("R");
cbaf35fb 79 Rich()->ResetDigits(); Rich()->ResetClusters();
543d5224 80
81 Rich()->GetLoader()->TreeD()->GetEntry(0);
cbaf35fb 82 for(Int_t iChamber=1;iChamber<=kNCH;iChamber++){//chambers loop
83 FindRawClusters(iChamber);
543d5224 84
85 }//chambers loop
86
87 Rich()->GetLoader()->TreeR()->Fill();
88 Rich()->GetLoader()->WriteRecPoints("OVERWRITE");
89 }//events loop
90 Rich()->GetLoader()->UnloadDigits(); Rich()->GetLoader()->UnloadRecPoints();
cbaf35fb 91 Rich()->ResetDigits(); Rich()->ResetClusters();
543d5224 92 Info("Exec","Stop.");
93}//Exec()
94//__________________________________________________________________________________________________
cbaf35fb 95void AliRICHClusterFinder::FindRawClusters(Int_t iChamber)
96{//finds neighbours and fill the tree with raw clusters
cbaf35fb 97 Int_t nDigits=Rich()->Digits(iChamber)->GetEntriesFast();
e33758d8 98 Info("FindRawClusters","Start for Chamber %i with %i digits.",iChamber,nDigits);
cbaf35fb 99 if(nDigits==0)return;
100
eaf390d9 101 fHitMap=new AliRICHMap(Rich()->Digits(iChamber));//create digit map for the given chamber
cbaf35fb 102
cbaf35fb 103 for(Int_t iDig=0;iDig<nDigits;iDig++){
e33758d8 104 AliRICHdigit *dig=(AliRICHdigit*)Rich()->Digits(iChamber)->At(iDig);
cbaf35fb 105 Int_t i=dig->X(); Int_t j=dig->Y();
106 if(fHitMap->TestHit(i,j)==kUsed) continue;
107
eaf390d9 108 AliRICHcluster rawCluster;
109 FormRawCluster(i,j,rawCluster);
cbaf35fb 110
111 if(AliRICHParam::IsResolveClusters()) {
eaf390d9 112 ResolveCluster(rawCluster); // ResolveCluster serialization will happen inside
cbaf35fb 113 } else {
eaf390d9 114 WriteRawCluster(rawCluster); // simply output of the RawCluster found without deconvolution
cbaf35fb 115 }
cbaf35fb 116
117 }//digits loop
118
119 delete fHitMap;
120 Info("FindRawClusters","Stop.");
121
122}//FindRawClusters()
123//__________________________________________________________________________________________________
eaf390d9 124void AliRICHClusterFinder::FormRawCluster(Int_t i, Int_t j, AliRICHcluster &rawCluster)
cbaf35fb 125{// Builder of the final Raw Cluster (before deconvolution)
126 Info("FormRawCluster","Start with digit(%i,%i)",i,j);
127
eaf390d9 128 rawCluster.AddDigit((AliRICHdigit*) fHitMap->GetHit(i,j));
cbaf35fb 129 fHitMap->FlagHit(i,j);// Flag hit as taken
130
131 Int_t listX[4], listY[4]; // Now look recursively for all neighbours
132 for (Int_t iNeighbour=0;iNeighbour<Rich()->Param()->PadNeighbours(i,j,listX,listY);iNeighbour++)
133 if(fHitMap->TestHit(listX[iNeighbour],listY[iNeighbour])==kUnused)
eaf390d9 134 FormRawCluster(listX[iNeighbour],listY[iNeighbour],rawCluster);
cbaf35fb 135}//AddDigit2Cluster()
136//__________________________________________________________________________________________________
eaf390d9 137void AliRICHClusterFinder::ResolveCluster(AliRICHcluster &rawCluster)
cbaf35fb 138{// Decluster algorithm
139 Info("ResolveCluster","Start.");
140
eaf390d9 141 rawCluster.SetStatus(kRaw);// just dummy to compile...
cbaf35fb 142
143}//ResolveCluster()
144//__________________________________________________________________________________________________
eaf390d9 145void AliRICHClusterFinder::WriteRawCluster(AliRICHcluster &rawCluster)
cbaf35fb 146{// out the current RawCluster
eaf390d9 147 Info("WriteRawCluster","Start.");
cbaf35fb 148
eaf390d9 149 rawCluster.CoG();
cbaf35fb 150
eaf390d9 151 Rich()->AddCluster(rawCluster);
cbaf35fb 152
153}//WriteRawCluster()
154//__________________________________________________________________________________________________