Removed usage of removed class AliMpManuList
[u/mrichter/AliRoot.git] / MUON / AliMUON2DStoreValidator.cxx
CommitLineData
ea199e33 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#include "AliMUON2DStoreValidator.h"
19
20#include "AliLog.h"
ea199e33 21#include "AliMUONCheckItem.h"
22#include "AliMUONCheckItemIterator.h"
be0c6f1f 23#include "AliMUONVCalibParam.h"
8971f761 24#include "AliMUONVStore.h"
25#include "AliMpConstants.h"
26#include "AliMpDDLStore.h"
ea199e33 27#include "AliMpDEManager.h"
8971f761 28#include "AliMpDetElement.h"
29#include "AliMpManuIterator.h"
be0c6f1f 30#include <Riostream.h>
31#include <TList.h>
32#include <TObjArray.h>
33#include <TObjString.h>
ea199e33 34
3d1463c8 35//-----------------------------------------------------------------------------
ea199e33 36/// \class AliMUON2DStoreValidator
37///
38/// Determine which channels, manus, DEs, stations are missing
a0eca509 39/// from a VStore, which must be 2D, and the 2 dimensions must be
40/// (detElemId,manuId).
41/// This is mainly to be used during (shuttle) preprocessing
ea199e33 42/// to insure that what we'll put in the CDB is as complete as possible,
43/// and to detect possible problem.
44///
45/// We made an effort to present the result of the validation in the most
46/// concise way (i.e. if all channels of a DE are missing, we do not list
47/// them, we just write "DE dead" ;-) )
48///
49/// The list of missing things is kept in a structure of objects defined as :
50///
51/// fMissing = TObjArray[0..N tracking chambers]
a0eca509 52///
ea199e33 53/// fMissing[iChamber] = AliMUONCheckItem which contains n AliMUONCheckItem,
54/// where n is the number of DE for that chamber
a0eca509 55///
ea199e33 56/// fMissing[iChamber]->GetItem(de) = AliMUONCheckItem which contains m
57/// AliMUONCheckItem where m is the number of Manu for that DE
a0eca509 58///
ea199e33 59/// fMissing[iChamber]->GetItem(de)->GetItem(manu) = AliMUONCheckItem which
60/// contains k TObjString = Form("%d",manuChannel)
61///
62/// \author Laurent Aphecetche
3d1463c8 63//-----------------------------------------------------------------------------
ea199e33 64
65/// \cond CLASSIMP
66ClassImp(AliMUON2DStoreValidator)
67/// \endcond
68
69//_____________________________________________________________________________
70AliMUON2DStoreValidator::AliMUON2DStoreValidator()
71: TObject(),
9b955acc 72 fChambers(0x0),
73 fStatus(0x0)
ea199e33 74{
75 /// ctor
76}
77
78//_____________________________________________________________________________
79AliMUON2DStoreValidator::~AliMUON2DStoreValidator()
80{
81 /// dtor
ea199e33 82 delete fChambers;
9b955acc 83 delete fStatus;
ea199e33 84}
85
86//_____________________________________________________________________________
87AliMUONCheckItem*
88AliMUON2DStoreValidator::GetChamber(Int_t chamberID)
89{
90 /// Return (and create if not present) the given chamber
91 /// chamberID in 0..NCh()
92
be0c6f1f 93 if ( chamberID < 0 || chamberID >= AliMpConstants::NofTrackingChambers() )
ea199e33 94 {
95 AliFatal(Form("Invalid chamber number %d",chamberID));
96 return 0x0;
97 }
98
99 if (!fChambers)
100 {
be0c6f1f 101 fChambers = new TObjArray(AliMpConstants::NofTrackingChambers());
ea199e33 102 }
103
104 AliMUONCheckItem* chamber =
105 static_cast<AliMUONCheckItem*>(fChambers->At(chamberID));
106
107 if (!chamber)
108 {
109 chamber = new AliMUONCheckItem(chamberID,
110 AliMpDEManager::GetNofDEInChamber(chamberID),
111 "Chamber");
112 fChambers->AddAt(chamber,chamberID);
113 }
114 return chamber;
115}
116
117//_____________________________________________________________________________
118AliMUONCheckItem*
119AliMUON2DStoreValidator::GetDE(Int_t detElemId)
120{
121 /// Return (and create if not present) a given detection element
122
123 Int_t chamberID = AliMpDEManager::GetChamberId(detElemId);
124 AliMUONCheckItem* chamber = GetChamber(chamberID);
125 AliMUONCheckItem* de =
126 static_cast<AliMUONCheckItem*>(chamber->GetItem(detElemId));
127 if (!de)
128 {
129 AliDebug(3,Form("Did not find DE %4d into chamber %d, will create it",
130 detElemId,chamberID));
131 de = new AliMUONCheckItem(detElemId,
8971f761 132 AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofManus(),
ea199e33 133 "Detection Element");
134 Bool_t ok = chamber->AddItem(detElemId,de);
135 if (!ok)
136 {
137 AliError(Form("Could not add DE %4d into chamber %2d",detElemId,chamberID));
138 }
139 }
140 return de;
141}
142
143//_____________________________________________________________________________
144AliMUONCheckItem*
145AliMUON2DStoreValidator::GetManu(Int_t detElemId, Int_t manuId)
146{
147 /// Return (and create) a given manu
148
149 AliMUONCheckItem* de = GetDE(detElemId);
150 AliMUONCheckItem* manu = static_cast<AliMUONCheckItem*>(de->GetItem(manuId));
151 if (!manu)
152 {
8971f761 153 manu = new AliMUONCheckItem(manuId,AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofChannelsInManu(manuId),"Manu");
ea199e33 154 Bool_t ok = de->AddItem(manuId,manu);
155 if (!ok)
156 {
157 AliError(Form("Could not add manu %4d into DE %4d",manuId,detElemId));
158 }
159
160 }
161 return manu;
162}
163
164//_____________________________________________________________________________
165void
166AliMUON2DStoreValidator::AddMissingChannel(Int_t detElemId,
167 Int_t manuId, Int_t manuChannel)
168{
169 /// Add one missing channel to the list of missing things
170
171 AliDebug(3,Form("DE %4d Manu %4d Channel %2d is missing",
172 detElemId,manuId,manuChannel));
173
174 AliMUONCheckItem* manu = GetManu(detElemId,manuId);
175 Bool_t ok = manu->AddItem(manuChannel,new TObjString(Form("%2d",manuChannel)));
176 if (!ok)
177 {
178 AliError(Form("Could not add channel %2d to manuId %4d in DE %4d",
179 manuChannel,manuId,detElemId));
180 }
181}
182
183//_____________________________________________________________________________
184void
185AliMUON2DStoreValidator::AddMissingManu(Int_t detElemId, Int_t manuId)
186{
187 /// Add one missing manu to the list of missing things
188
189 AliDebug(3,Form("DE %4d Manu %4d is completely missing",
190 detElemId,manuId));
191
8971f761 192 Int_t n(AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofChannelsInManu(manuId));
ea199e33 193
194 for ( Int_t i = 0; i < n; ++i )
195 {
196 AddMissingChannel(detElemId,manuId,i);
197 }
198}
199
200//_____________________________________________________________________________
201void
9b955acc 202AliMUON2DStoreValidator::ReportManu(TList& lines, AliMUONCheckItem& manu)
ea199e33 203{
204 /// Report list of missing channels from this manu
205
206 TObjString* channel(0x0);
207 AliMUONCheckItemIterator it(manu);
208
209 it.First();
210
211 while ( ( channel = static_cast<TObjString*>(it.Next()) ) )
212 {
9b955acc 213 lines.Add(new TObjString(Form("\t\t\tChannel %s is missing or dead",
214 channel->GetString().Data())));
ea199e33 215 }
216
217}
218
219//_____________________________________________________________________________
220void
9b955acc 221AliMUON2DStoreValidator::ReportDE(TList& lines, AliMUONCheckItem& de)
ea199e33 222{
223 /// Report list of missing manus from this de
224 AliMUONCheckItem* manu(0x0);
225 AliMUONCheckItemIterator it(de);
226
9b955acc 227 lines.Add(new TObjString(Form("DE %5d",de.GetID())));
ea199e33 228
229 it.First();
230
231 while ( ( manu = static_cast<AliMUONCheckItem*>(it.Next()) ) )
232 {
233 if ( manu->IsDead() )
234 {
9b955acc 235 lines.Add(new TObjString(Form("\t\tManu %4d is missing or dead",manu->GetID())));
ea199e33 236 }
237 else
238 {
9b955acc 239 ReportManu(lines,*manu);
ea199e33 240 }
241 }
242}
243
244//_____________________________________________________________________________
245void
9b955acc 246AliMUON2DStoreValidator::ReportChamber(TList& lines, AliMUONCheckItem& chamber)
ea199e33 247{
248 /// Report list of missing de from this chamber
249
250 AliMUONCheckItem* de(0x0);
251 AliMUONCheckItemIterator it(chamber);
252
253 it.First();
254
255 while ( ( de = static_cast<AliMUONCheckItem*>(it.Next()) ) )
256 {
257 if ( de->IsDead() )
258 {
9b955acc 259 lines.Add(new TObjString(Form("\tDE %4d is missing or dead",de->GetID())));
ea199e33 260 }
261 else
262 {
9b955acc 263 ReportDE(lines,*de);
ea199e33 264 }
265 }
266}
267
268//_____________________________________________________________________________
269void
9b955acc 270AliMUON2DStoreValidator::Report(TList& lines) const
271{
272 ///
273 if (fChambers)
274 {
275 Report(lines,*fChambers);
276 }
277}
278
279//_____________________________________________________________________________
280void
281AliMUON2DStoreValidator::Report(TList& lines, const TObjArray& chambers)
ea199e33 282{
283 /// Reports what is missing, trying to be as concise as possible.
284
285 for ( Int_t iChamber = 0; iChamber <= chambers.GetLast(); ++iChamber )
286 {
287 AliMUONCheckItem* chamber = static_cast<AliMUONCheckItem*>(chambers.At(iChamber));
288 if ( chamber )
289 {
290 if ( chamber->IsDead() )
291 {
9b955acc 292 lines.Add(new TObjString(Form("Chamber %2d is missing or dead",iChamber)));
ea199e33 293 }
294 else
295 {
9b955acc 296 ReportChamber(lines,*chamber);
297 }
298 }
299 }
300}
301
044b7e8a 302//_____________________________________________________________________________
303TObjArray*
a0eca509 304AliMUON2DStoreValidator::Validate(const AliMUONVStore& store)
044b7e8a 305{
306 /// Validate the store. Check only the presence of all manus (i.e.
307 /// check nothing about the values themselves)
308
309 Bool_t (*kCheck)(const AliMUONVCalibParam&,Int_t) = 0x0;
310 return Validate(store,kCheck);
311}
312
9b955acc 313//_____________________________________________________________________________
314TObjArray*
a0eca509 315AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
9b955acc 316 Bool_t (*check)(const AliMUONVCalibParam&,Int_t))
317{
318 /// Validate the store.
319 /// The check method is used to decide if a store content value
320 /// is valid or not.
321
322 delete fChambers;
323 fChambers = 0x0;
324
9b955acc 325 // Now checks if some full manus are missing
8971f761 326
327 AliMpManuIterator it;
328
329 Int_t detElemId;
330 Int_t manuId;
9b955acc 331
8971f761 332 while ( it.Next(detElemId,manuId) )
9b955acc 333 {
9b955acc 334 AliMUONVCalibParam* test =
a0eca509 335 static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
9b955acc 336 if (!test)
337 {
338 // completely missing manu
339 AddMissingManu(detElemId,manuId);
340 }
341 else
342 {
343 if (!check) continue;
8971f761 344
345 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
346
9b955acc 347 // manu is there, check all its channels
348 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
349 {
8971f761 350 if ( de->IsConnectedChannel(manuId,manuChannel) &&
9b955acc 351 !check(*test,manuChannel) )
352 {
353 AddMissingChannel(detElemId,manuId,manuChannel);
354 }
ea199e33 355 }
356 }
357 }
9b955acc 358 return fChambers;
359
ea199e33 360}
361
9b955acc 362
ea199e33 363//_____________________________________________________________________________
364TObjArray*
a0eca509 365AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
ea199e33 366 Float_t invalidFloatValue)
367{
368 /// Validate the store.
369 /// The invalidFloatValue is used to decide if a store content value
370 /// is valid or not.
371
372 delete fChambers;
373 fChambers = 0x0;
374
ea199e33 375 // Now checks if some full manus are missing
ea199e33 376
8971f761 377 AliMpManuIterator it;
378 Int_t detElemId;
379 Int_t manuId;
380
381 while ( it.Next(detElemId,manuId) )
ea199e33 382 {
ea199e33 383 AliMUONVCalibParam* test =
a0eca509 384 static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
ea199e33 385 if (!test)
386 {
387 // completely missing manu
388 AddMissingManu(detElemId,manuId);
389 }
390 else
391 {
392 // manu is there, check all its channels
8971f761 393 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
394
ea199e33 395 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
396 {
8971f761 397 if ( de->IsConnectedChannel(manuId,manuChannel) &&
ea199e33 398 ( test->ValueAsFloat(manuChannel,0) == invalidFloatValue ||
399 test->ValueAsFloat(manuChannel,1) == invalidFloatValue ) )
400 {
401 AddMissingChannel(detElemId,manuId,manuChannel);
402 }
403 }
404 }
405 }
406 return fChambers;
407}
408
409