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