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