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