]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONQAMappingCheck.cxx
Updated list of classes
[u/mrichter/AliRoot.git] / MUON / AliMUONQAMappingCheck.cxx
CommitLineData
45aad778 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/// \class AliMUONQAMappingCheck
19///
20/// Helper class for AliMUONQADataMakerRec, which takes care
21/// of building an AliMUONVTrackerData to store the location of
22/// all the clusters encountered during a run, and all the clusters
23/// that have charge on only one cathode (aka mono-cathode clusters).
24///
25/// This is to easily spot mapping errors and/or region of complete
26/// inefficiencies.
27///
28/// \author Laurent Aphecetche, Subatech
29///
30
31#include "AliMUONQAMappingCheck.h"
32
33#include "AliCDBManager.h"
34#include "AliLog.h"
35#include "AliMUON2DMap.h"
36#include "AliMUONDigitCalibrator.h"
37#include "AliMUONCalibParamND.h"
38#include "AliMUONGeometryTransformer.h"
39#include "AliMUONPadStatusMapMaker.h"
40#include "AliMUONTrackerData.h"
41#include "AliMUONVCluster.h"
42#include "AliMUONVDigit.h"
43#include "AliMpConstants.h"
44#include "AliMpDetElement.h"
45#include "AliMpDDLStore.h"
46#include "AliMpPad.h"
47#include "AliMpSegmentation.h"
48#include "AliMpVSegmentation.h"
49
1bacbb46 50#include "AliMpManuIterator.h"
51
45aad778 52/// \cond CLASSIMP
53ClassImp(AliMUONQAMappingCheck)
54/// \endcond
55
56//_____________________________________________________________________________
57AliMUONQAMappingCheck::AliMUONQAMappingCheck(Int_t runNumber)
58: TObject(),
59fStore(new AliMUON2DMap(kTRUE)),
60fGeometryTransformer(new AliMUONGeometryTransformer),
61fDigitCalibrator(new AliMUONDigitCalibrator(runNumber)),
62fNumberOfEvents(0),
63fNumberOfClusters(0),
64fNumberOfMonoCathodeClusters(0),
65fNumberOfLegitimateMonoCathodeClusters(0)
66{
67 /// Ctor
68
69 fGeometryTransformer->LoadGeometryData();
1bacbb46 70
71 // Init the store with all the manus. Note that this is not strictly necessary,
72 // but it helps not to get its growth (that would otherwise happen in
73 // AddClusterLocation each time we get a cluster associated with a manu where
74 // we got no cluster yet) confused with a memory leak...
75 AliMpManuIterator it;
76 Int_t detElemId, manuId;
77
78 while (it.Next(detElemId,manuId))
79 {
80 fStore->Add(new AliMUONCalibParamND(4,AliMpConstants::ManuNofChannels(),detElemId,manuId,0.0));
81 }
45aad778 82}
83
84//_____________________________________________________________________________
85AliMUONQAMappingCheck::~AliMUONQAMappingCheck()
86{
87 /// Dtor. Report on the global number of clusters encountered
88 AliInfo(Form("Nevents %d Nclusters %d Nmono-cathodes %d Nlegitimate-mono-cathodes %d",
89 fNumberOfEvents,
90 fNumberOfClusters,
91 fNumberOfMonoCathodeClusters,
92 fNumberOfLegitimateMonoCathodeClusters));
93 delete fStore;
94 delete fGeometryTransformer;
95 delete fDigitCalibrator;
96}
97
98//____________________________________________________________________________
99void AliMUONQAMappingCheck::AddClusterLocation(Int_t detElemId,
100 Int_t manuId, Int_t manuChannel,
101 Bool_t monoCathode,
102 Bool_t legitimateMonoCathode)
103{
104 /// Add one cluster location to our internal store
105 if ( manuId > 0 )
106 {
107 AliMUONVCalibParam* p = static_cast<AliMUONVCalibParam*>(fStore->FindObject(detElemId,manuId));
108 if (!p)
109 {
110 p = new AliMUONCalibParamND(4,AliMpConstants::ManuNofChannels(),detElemId,manuId,0.0);
111 fStore->Add(p);
112 }
113 if ( !monoCathode)
114 {
115 p->SetValueAsDouble(manuChannel,0,p->ValueAsDouble(manuChannel,0)+1.0);
116 }
117 else
118 {
119 p->SetValueAsDouble(manuChannel,1,p->ValueAsDouble(manuChannel,1)+1.0);
120 if (!legitimateMonoCathode)
121 {
122 p->SetValueAsDouble(manuChannel,2,p->ValueAsDouble(manuChannel,2)+1.0);
123 }
124 }
125 }
126}
127
128//____________________________________________________________________________
129void
130AliMUONQAMappingCheck::NewEvent()
131{
132 /// Increment number of events seen
133 ++fNumberOfEvents;
134}
135
136//____________________________________________________________________________
137AliMUONVTrackerData*
138AliMUONQAMappingCheck::CreateData(const char* name) const
139{
140 /// Make a trackerData from our internal store
141
142 AliMUONVStore* store = static_cast<AliMUONVStore*>(fStore->Clone());
143
144 TIter next(store->CreateIterator());
145 AliMUONVCalibParam* param;
146
147 while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
148 {
149 for ( Int_t i = 0; i < param->Size(); ++i )
150 {
151 param->SetValueAsDouble(i,3,fNumberOfEvents);
152 }
153 }
154
155 AliMUONTrackerData* data = new AliMUONTrackerData(name,name,4,kTRUE);
156 data->SetDimensionName(0,"all"); // all clusters
157 data->SetDimensionName(1,"mono"); // mono-cathode clusters
158 data->SetDimensionName(2,"suspect"); // not legitimate mono-cathode clusters
159 data->SetDimensionName(3,"Nevents"); // number of events
160 data->DisableChannelLevel();
161
162 data->Add(*store);
163
164 delete store;
165
166 return data;
167}
168
169//____________________________________________________________________________
170void
171AliMUONQAMappingCheck::GetClusterLocation(AliMUONVCluster& cluster,
172 Int_t& manuBending, Int_t& manuBendingChannel,
173 Int_t& manuNonBending, Int_t& manuNonBendingChannel,
174 Bool_t& monoCathode, Bool_t& legitimateMonoCathode)
175{
176 /// Get the pad under the center of the cluster, and whether or not this cluster
177 /// has charge on both cathodes
178
179 Int_t detElemId = cluster.GetDetElemId();
180
181 Double_t x,y,z;
182
183 fGeometryTransformer->Global2Local(detElemId,cluster.GetX(),cluster.GetY(),cluster.GetZ(),x,y,z);
184
185 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
186
187 const AliMpVSegmentation* segB = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,de->GetCathodType(AliMp::kBendingPlane));
188 const AliMpVSegmentation* segNB = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,de->GetCathodType(AliMp::kNonBendingPlane));
189
190 AliMpPad padB = segB->PadByPosition(x,y);
191 AliMpPad padNB = segNB->PadByPosition(x,y);
192
193 manuBending = padB.GetManuId();
194 manuBendingChannel = padB.GetManuChannel();
195
196 manuNonBending = padNB.GetManuId();
197 manuNonBendingChannel = padNB.GetManuChannel();
198
199 Bool_t bending(kFALSE);
200 Bool_t nonBending(kFALSE);
201
202 for ( Int_t i = 0; i < cluster.GetNDigits(); ++i )
203// for ( Int_t i = 0; i < cluster.GetNDigits() && !(bending && nonBending); ++i )
204 {
205 UInt_t digitId = cluster.GetDigitId(i);
206 Int_t manuId = AliMUONVDigit::ManuId(digitId);
207 if ( manuId > 0 )
208 {
209 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) )
210 {
211 nonBending = kTRUE;
212 }
213 else
214 {
215 bending = kTRUE;
216 }
217 }
218 }
219
220 monoCathode = ( bending != nonBending );
221
222 if ( monoCathode )
223 {
224 legitimateMonoCathode = kFALSE;
225 if (!bending)
226 {
227 if ( IsManuDead(detElemId,manuBending) ) legitimateMonoCathode = kTRUE;
228 }
229
230 if (!nonBending)
231 {
232
233 if ( IsManuDead(detElemId,manuNonBending) ) legitimateMonoCathode = kTRUE;
234 }
235 }
236
237 if (!bending) manuBending *= -1;
238 if (!nonBending) manuNonBending *= -1;
239
240 ++fNumberOfClusters;
241 if ( monoCathode )
242 {
243 ++fNumberOfMonoCathodeClusters;
244 if ( legitimateMonoCathode ) ++fNumberOfLegitimateMonoCathodeClusters;
245 }
246}
247
248//____________________________________________________________________________
249Bool_t AliMUONQAMappingCheck::IsManuDead(Int_t detElemId, Int_t manuId) const
250{
251 /// Using the statusmaker, tells if a given manu is to be considered
252 /// as dead (here dead means at least one manas dead)
253
254 if ( manuId <= 0 ) return kTRUE;
255
256 Int_t n(0);
257
258 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i)
259 {
260 if ( IsChannelDead(detElemId,manuId,i) ) ++n;
261 }
262 return n > 16;
263}
264
265//____________________________________________________________________________
266Bool_t AliMUONQAMappingCheck::IsChannelDead(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
267{
268 /// Using the statusmaker, tells if a given channel is dead
269
dd0be8a7 270 return ( fDigitCalibrator->StatusMap(detElemId,manuId,manuChannel) & (AliMUONPadStatusMapMaker::SelfDeadMask() != 0) );
45aad778 271}
272
273//____________________________________________________________________________
274void
275AliMUONQAMappingCheck::Store(AliMUONVCluster& cluster)
276{
277 /// Store information about a single cluster
278
279 if ( cluster.GetCharge() < 10 ) return;
280
281 Int_t manuBendingId, manuBendingChannel;
282 Int_t manuNonBendingId, manuNonBendingChannel;
283 Bool_t monoCathode, legitimateMonoCathode;
284
285 GetClusterLocation(cluster, manuBendingId, manuBendingChannel,manuNonBendingId, manuNonBendingChannel, monoCathode,legitimateMonoCathode);
286
287 AddClusterLocation(cluster.GetDetElemId(),manuBendingId,manuBendingChannel,monoCathode,legitimateMonoCathode);
288 AddClusterLocation(cluster.GetDetElemId(),manuNonBendingId,manuNonBendingChannel,monoCathode,legitimateMonoCathode);
289}