1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /// \class AliMUONQAMappingCheck
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).
25 /// This is to easily spot mapping errors and/or region of complete
28 /// \author Laurent Aphecetche, Subatech
31 #include "AliMUONQAMappingCheck.h"
33 #include "AliCDBManager.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"
47 #include "AliMpSegmentation.h"
48 #include "AliMpVSegmentation.h"
50 #include "AliMpManuIterator.h"
53 ClassImp(AliMUONQAMappingCheck)
56 //_____________________________________________________________________________
57 AliMUONQAMappingCheck::AliMUONQAMappingCheck(Int_t runNumber)
59 fStore(new AliMUON2DMap(kTRUE)),
60 fGeometryTransformer(new AliMUONGeometryTransformer),
61 fDigitCalibrator(new AliMUONDigitCalibrator(runNumber)),
64 fNumberOfMonoCathodeClusters(0),
65 fNumberOfLegitimateMonoCathodeClusters(0)
69 fGeometryTransformer->LoadGeometryData();
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...
76 Int_t detElemId, manuId;
78 while (it.Next(detElemId,manuId))
80 fStore->Add(new AliMUONCalibParamND(4,AliMpConstants::ManuNofChannels(),detElemId,manuId,0.0));
84 //_____________________________________________________________________________
85 AliMUONQAMappingCheck::~AliMUONQAMappingCheck()
87 /// Dtor. Report on the global number of clusters encountered
88 AliInfo(Form("Nevents %d Nclusters %d Nmono-cathodes %d Nlegitimate-mono-cathodes %d",
91 fNumberOfMonoCathodeClusters,
92 fNumberOfLegitimateMonoCathodeClusters));
94 delete fGeometryTransformer;
95 delete fDigitCalibrator;
98 //____________________________________________________________________________
99 void AliMUONQAMappingCheck::AddClusterLocation(Int_t detElemId,
100 Int_t manuId, Int_t manuChannel,
102 Bool_t legitimateMonoCathode)
104 /// Add one cluster location to our internal store
107 AliMUONVCalibParam* p = static_cast<AliMUONVCalibParam*>(fStore->FindObject(detElemId,manuId));
110 p = new AliMUONCalibParamND(4,AliMpConstants::ManuNofChannels(),detElemId,manuId,0.0);
115 p->SetValueAsDouble(manuChannel,0,p->ValueAsDouble(manuChannel,0)+1.0);
119 p->SetValueAsDouble(manuChannel,1,p->ValueAsDouble(manuChannel,1)+1.0);
120 if (!legitimateMonoCathode)
122 p->SetValueAsDouble(manuChannel,2,p->ValueAsDouble(manuChannel,2)+1.0);
128 //____________________________________________________________________________
130 AliMUONQAMappingCheck::NewEvent()
132 /// Increment number of events seen
136 //____________________________________________________________________________
138 AliMUONQAMappingCheck::CreateData(const char* name) const
140 /// Make a trackerData from our internal store
142 AliMUONVStore* store = static_cast<AliMUONVStore*>(fStore->Clone());
144 TIter next(store->CreateIterator());
145 AliMUONVCalibParam* param;
147 while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
149 for ( Int_t i = 0; i < param->Size(); ++i )
151 param->SetValueAsDouble(i,3,fNumberOfEvents);
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();
169 //____________________________________________________________________________
171 AliMUONQAMappingCheck::GetClusterLocation(AliMUONVCluster& cluster,
172 Int_t& manuBending, Int_t& manuBendingChannel,
173 Int_t& manuNonBending, Int_t& manuNonBendingChannel,
174 Bool_t& monoCathode, Bool_t& legitimateMonoCathode)
176 /// Get the pad under the center of the cluster, and whether or not this cluster
177 /// has charge on both cathodes
179 Int_t detElemId = cluster.GetDetElemId();
183 fGeometryTransformer->Global2Local(detElemId,cluster.GetX(),cluster.GetY(),cluster.GetZ(),x,y,z);
185 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
187 const AliMpVSegmentation* segB = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,de->GetCathodType(AliMp::kBendingPlane));
188 const AliMpVSegmentation* segNB = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,de->GetCathodType(AliMp::kNonBendingPlane));
190 AliMpPad padB = segB->PadByPosition(x,y);
191 AliMpPad padNB = segNB->PadByPosition(x,y);
193 manuBending = padB.GetManuId();
194 manuBendingChannel = padB.GetManuChannel();
196 manuNonBending = padNB.GetManuId();
197 manuNonBendingChannel = padNB.GetManuChannel();
199 Bool_t bending(kFALSE);
200 Bool_t nonBending(kFALSE);
202 for ( Int_t i = 0; i < cluster.GetNDigits(); ++i )
203 // for ( Int_t i = 0; i < cluster.GetNDigits() && !(bending && nonBending); ++i )
205 UInt_t digitId = cluster.GetDigitId(i);
206 Int_t manuId = AliMUONVDigit::ManuId(digitId);
209 if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) )
220 monoCathode = ( bending != nonBending );
224 legitimateMonoCathode = kFALSE;
227 if ( IsManuDead(detElemId,manuBending) ) legitimateMonoCathode = kTRUE;
233 if ( IsManuDead(detElemId,manuNonBending) ) legitimateMonoCathode = kTRUE;
237 if (!bending) manuBending *= -1;
238 if (!nonBending) manuNonBending *= -1;
243 ++fNumberOfMonoCathodeClusters;
244 if ( legitimateMonoCathode ) ++fNumberOfLegitimateMonoCathodeClusters;
248 //____________________________________________________________________________
249 Bool_t AliMUONQAMappingCheck::IsManuDead(Int_t detElemId, Int_t manuId) const
251 /// Using the statusmaker, tells if a given manu is to be considered
252 /// as dead (here dead means at least one manas dead)
254 if ( manuId <= 0 ) return kTRUE;
258 for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i)
260 if ( IsChannelDead(detElemId,manuId,i) ) ++n;
265 //____________________________________________________________________________
266 Bool_t AliMUONQAMappingCheck::IsChannelDead(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
268 /// Using the statusmaker, tells if a given channel is dead
270 return ( fDigitCalibrator->StatusMap(detElemId,manuId,manuChannel) & (AliMUONPadStatusMapMaker::SelfDeadMask() != 0) );
273 //____________________________________________________________________________
275 AliMUONQAMappingCheck::Store(AliMUONVCluster& cluster)
277 /// Store information about a single cluster
279 if ( cluster.GetCharge() < 10 ) return;
281 Int_t manuBendingId, manuBendingChannel;
282 Int_t manuNonBendingId, manuNonBendingChannel;
283 Bool_t monoCathode, legitimateMonoCathode;
285 GetClusterLocation(cluster, manuBendingId, manuBendingChannel,manuNonBendingId, manuNonBendingChannel, monoCathode,legitimateMonoCathode);
287 AddClusterLocation(cluster.GetDetElemId(),manuBendingId,manuBendingChannel,monoCathode,legitimateMonoCathode);
288 AddClusterLocation(cluster.GetDetElemId(),manuNonBendingId,manuNonBendingChannel,monoCathode,legitimateMonoCathode);