]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONClusterReconstructor.cxx
Changes for removal of AliMpManuList (Laurent)
[u/mrichter/AliRoot.git] / MUON / AliMUONClusterReconstructor.cxx
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
16 /* $Id$ */
17
18 //-----------------------------------------------------------------------------
19 /// \class AliMUONClusterReconstructor
20 ///
21 /// This class is just a steering class to loop over detection elements of tracking chambers,
22 /// extract the relevant digits, and pass them to the actual clusterizer class,
23 /// which operate on a single detection element at a time.
24 ///
25 /// \author C. Finck and L. Aphecetche, Subatech
26 ///
27 //-----------------------------------------------------------------------------
28
29 #include "AliMUONClusterReconstructor.h"
30
31 #include "AliMUONCluster.h"
32 #include "AliMUONGeometryTransformer.h"
33 #include "AliMUONVCluster.h"
34 #include "AliMUONVClusterFinder.h"
35 #include "AliMUONVClusterStore.h"
36 #include "AliMUONVDigit.h"
37 #include "AliMUONVDigitStore.h"
38 #include "AliMUONPad.h"
39
40 #include "AliMpDEIterator.h"
41 #include "AliMpDEManager.h"
42 #include "AliMpSegmentation.h"
43
44 #include "AliLog.h"
45
46 #include <Riostream.h>
47 #include <float.h>
48
49 /// \cond CLASSIMP
50 ClassImp(AliMUONClusterReconstructor) // Class implementation in ROOT context
51 /// \endcond
52  
53 //__________________________________________________________________________
54 AliMUONClusterReconstructor::AliMUONClusterReconstructor(AliMUONVClusterFinder* clusterFinder,
55                                                          const AliMUONGeometryTransformer* transformer)
56 : TObject(),
57   fClusterFinder(clusterFinder),
58   fTransformer(transformer),
59   fClusterStore(0x0),
60   fNCluster(0)
61 {
62     /// Standard Constructor
63     /// Note that we adopt clusterFinder
64
65   if (!transformer && clusterFinder)
66   {
67     AliFatal("I require a geometry transformer, otherwise I cannot compute "
68              "global coordinates of the clusters !");    
69   }
70   
71 //  fRecModel->SetGhostChi2Cut(10);
72 }
73
74 //__________________________________________________________________________
75 AliMUONClusterReconstructor::~AliMUONClusterReconstructor(void)
76 {
77   /// Destructor
78   delete fClusterFinder;
79 }
80
81 //______________________________________________________________________________
82 void
83 AliMUONClusterReconstructor::ClusterizeOneDE(Int_t detElemId,
84                                              const AliMUONVDigitStore& digitStore)
85 {
86   /// Clusterize one detection element, which digits are in digitStore
87   
88 //  AliDebug(1,Form("detElemId=%d, %d digits",detElemId,digitStore.GetSize()));
89   
90   if ( digitStore.IsEmpty() ) return;
91   
92   const AliMpVSegmentation* seg[2] = 
93   { AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath0),
94     AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::kCath1)
95   };
96     
97   if (!fClusterFinder->Prepare(seg,digitStore)) AliWarning(Form("No hit pad for DE %d ?",detElemId));
98   
99   AliMUONCluster* cluster;
100   AliMUONVCluster *rawCluster;
101   Int_t nPad;
102   
103   // Converts cluster objects into ones suitable for output
104   while ( ( cluster = fClusterFinder->NextCluster() ) ) {
105     
106     // add new cluster to the store with information to build its ID
107     // increment the number of clusters into the store
108     rawCluster = fClusterStore->Add(AliMpDEManager::GetChamberId(detElemId), detElemId, fNCluster++);
109     
110     // fill array of Id of digits attached to this cluster
111     nPad = cluster->Multiplicity();
112     if (nPad < 1) AliWarning("no pad attached to the cluster");
113     for (Int_t iPad=0; iPad<nPad; iPad++) {
114       AliMUONPad *pad = cluster->Pad(iPad);
115       rawCluster->AddDigitId(pad->GetUniqueID());
116     }
117     
118     // fill charge and other cluster informations
119     rawCluster->SetCharge(cluster->Charge());
120     
121     Double_t xg, yg, zg;
122     fTransformer->Local2Global(detElemId, 
123                                 cluster->Position().X(), cluster->Position().Y(), 
124                                 0, xg, yg, zg);
125     rawCluster->SetXYZ(xg, yg, zg);
126     
127     AliDebug(1,Form("Adding RawCluster detElemId %4d mult %2d charge %e (xl,yl,zl)=(%e,%e,%e) (xg,yg,zg)=(%e,%e,%e)",
128                 detElemId,nPad,cluster->Charge(),
129                 cluster->Position().X(),cluster->Position().Y(),0.0,
130                 xg,yg,zg));
131   }
132   
133 }
134
135 //____________________________________________________________________
136 void AliMUONClusterReconstructor::Digits2Clusters(const AliMUONVDigitStore& digitStore,
137                                                   AliMUONVClusterStore& clusterStore)
138 {
139   /// Clusterize the digitStore to produce a clusterStore
140   
141   fClusterStore = &clusterStore;
142   fClusterStore->Clear();
143   fNCluster = 0;
144   
145   AliMpDEIterator deIt;
146   
147   deIt.First();
148   
149   while (!deIt.IsDone())
150   {
151     AliMUONVDigitStore* deDigits = digitStore.Create();
152     
153     Int_t currentDE = deIt.CurrentDEId();
154     AliMp::StationType stationType = AliMpDEManager::GetStationType(currentDE);
155     if (stationType!=AliMp::kStationTrigger) 
156     {
157       TIter next(digitStore.CreateIterator(currentDE,currentDE));
158       AliMUONVDigit* digit;
159
160       while ( ( digit = static_cast<AliMUONVDigit*>(next()) ) )
161       {
162         if ( ! digit->Charge() > 0 ) continue; // skip void digits.
163     
164         deDigits->Add(*digit,AliMUONVDigitStore::kIgnore);
165       }      
166       ClusterizeOneDE(currentDE,*deDigits);
167     }
168     delete deDigits;
169     deIt.Next();
170   }
171 }