]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUON2DStoreValidator.cxx
add un-use functionality to clusters
[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"
be0c6f1f 22#include "AliMUONVCalibParam.h"
8971f761 23#include "AliMUONVStore.h"
24#include "AliMpConstants.h"
25#include "AliMpDDLStore.h"
ea199e33 26#include "AliMpDEManager.h"
8971f761 27#include "AliMpDetElement.h"
28#include "AliMpManuIterator.h"
be0c6f1f 29#include <Riostream.h>
30#include <TList.h>
31#include <TObjArray.h>
32#include <TObjString.h>
ea199e33 33
3d1463c8 34//-----------------------------------------------------------------------------
ea199e33 35/// \class AliMUON2DStoreValidator
36///
37/// Determine which channels, manus, DEs, stations are missing
a0eca509 38/// from a VStore, which must be 2D, and the 2 dimensions must be
39/// (detElemId,manuId).
40/// This is mainly to be used during (shuttle) preprocessing
ea199e33 41/// to insure that what we'll put in the CDB is as complete as possible,
42/// and to detect possible problem.
43///
44/// We made an effort to present the result of the validation in the most
45/// concise way (i.e. if all channels of a DE are missing, we do not list
46/// them, we just write "DE dead" ;-) )
47///
48/// The list of missing things is kept in a structure of objects defined as :
49///
50/// fMissing = TObjArray[0..N tracking chambers]
a0eca509 51///
ea199e33 52/// fMissing[iChamber] = AliMUONCheckItem which contains n AliMUONCheckItem,
53/// where n is the number of DE for that chamber
a0eca509 54///
ea199e33 55/// fMissing[iChamber]->GetItem(de) = AliMUONCheckItem which contains m
56/// AliMUONCheckItem where m is the number of Manu for that DE
a0eca509 57///
ea199e33 58/// fMissing[iChamber]->GetItem(de)->GetItem(manu) = AliMUONCheckItem which
59/// contains k TObjString = Form("%d",manuChannel)
60///
61/// \author Laurent Aphecetche
3d1463c8 62//-----------------------------------------------------------------------------
ea199e33 63
64/// \cond CLASSIMP
65ClassImp(AliMUON2DStoreValidator)
66/// \endcond
67
68//_____________________________________________________________________________
69AliMUON2DStoreValidator::AliMUON2DStoreValidator()
70: TObject(),
9b955acc 71 fChambers(0x0),
72 fStatus(0x0)
ea199e33 73{
74 /// ctor
75}
76
77//_____________________________________________________________________________
78AliMUON2DStoreValidator::~AliMUON2DStoreValidator()
79{
80 /// dtor
ea199e33 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,
8971f761 131 AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofManus(),
ea199e33 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 {
8971f761 152 manu = new AliMUONCheckItem(manuId,AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofChannelsInManu(manuId),"Manu");
ea199e33 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
8971f761 191 Int_t n(AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofChannelsInManu(manuId));
ea199e33 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);
24dbd5dd 206 TIter next(manu.CreateIterator());
ea199e33 207
24dbd5dd 208 while ( ( channel = static_cast<TObjString*>(next()) ) )
ea199e33 209 {
9b955acc 210 lines.Add(new TObjString(Form("\t\t\tChannel %s is missing or dead",
211 channel->GetString().Data())));
ea199e33 212 }
213
214}
215
216//_____________________________________________________________________________
217void
9b955acc 218AliMUON2DStoreValidator::ReportDE(TList& lines, AliMUONCheckItem& de)
ea199e33 219{
220 /// Report list of missing manus from this de
221 AliMUONCheckItem* manu(0x0);
24dbd5dd 222
223 TIter next(de.CreateIterator());
ea199e33 224
9b955acc 225 lines.Add(new TObjString(Form("DE %5d",de.GetID())));
ea199e33 226
ea199e33 227
24dbd5dd 228 while ( ( manu = static_cast<AliMUONCheckItem*>(next()) ) )
ea199e33 229 {
230 if ( manu->IsDead() )
231 {
9b955acc 232 lines.Add(new TObjString(Form("\t\tManu %4d is missing or dead",manu->GetID())));
ea199e33 233 }
234 else
235 {
9b955acc 236 ReportManu(lines,*manu);
ea199e33 237 }
238 }
239}
240
241//_____________________________________________________________________________
242void
9b955acc 243AliMUON2DStoreValidator::ReportChamber(TList& lines, AliMUONCheckItem& chamber)
ea199e33 244{
245 /// Report list of missing de from this chamber
246
247 AliMUONCheckItem* de(0x0);
24dbd5dd 248 TIter next(chamber.CreateIterator());
ea199e33 249
24dbd5dd 250 while ( ( de = static_cast<AliMUONCheckItem*>(next()) ) )
ea199e33 251 {
252 if ( de->IsDead() )
253 {
9b955acc 254 lines.Add(new TObjString(Form("\tDE %4d is missing or dead",de->GetID())));
ea199e33 255 }
256 else
257 {
9b955acc 258 ReportDE(lines,*de);
ea199e33 259 }
260 }
261}
262
263//_____________________________________________________________________________
264void
9b955acc 265AliMUON2DStoreValidator::Report(TList& lines) const
266{
267 ///
268 if (fChambers)
269 {
270 Report(lines,*fChambers);
271 }
272}
273
274//_____________________________________________________________________________
275void
276AliMUON2DStoreValidator::Report(TList& lines, const TObjArray& chambers)
ea199e33 277{
278 /// Reports what is missing, trying to be as concise as possible.
279
280 for ( Int_t iChamber = 0; iChamber <= chambers.GetLast(); ++iChamber )
281 {
282 AliMUONCheckItem* chamber = static_cast<AliMUONCheckItem*>(chambers.At(iChamber));
283 if ( chamber )
284 {
285 if ( chamber->IsDead() )
286 {
9b955acc 287 lines.Add(new TObjString(Form("Chamber %2d is missing or dead",iChamber)));
ea199e33 288 }
289 else
290 {
9b955acc 291 ReportChamber(lines,*chamber);
292 }
293 }
294 }
295}
296
044b7e8a 297//_____________________________________________________________________________
298TObjArray*
a0eca509 299AliMUON2DStoreValidator::Validate(const AliMUONVStore& store)
044b7e8a 300{
301 /// Validate the store. Check only the presence of all manus (i.e.
302 /// check nothing about the values themselves)
303
304 Bool_t (*kCheck)(const AliMUONVCalibParam&,Int_t) = 0x0;
305 return Validate(store,kCheck);
306}
307
9b955acc 308//_____________________________________________________________________________
309TObjArray*
a0eca509 310AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
9b955acc 311 Bool_t (*check)(const AliMUONVCalibParam&,Int_t))
312{
313 /// Validate the store.
314 /// The check method is used to decide if a store content value
315 /// is valid or not.
316
317 delete fChambers;
318 fChambers = 0x0;
319
9b955acc 320 // Now checks if some full manus are missing
8971f761 321
322 AliMpManuIterator it;
323
324 Int_t detElemId;
325 Int_t manuId;
9b955acc 326
8971f761 327 while ( it.Next(detElemId,manuId) )
9b955acc 328 {
9b955acc 329 AliMUONVCalibParam* test =
a0eca509 330 static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
9b955acc 331 if (!test)
332 {
333 // completely missing manu
334 AddMissingManu(detElemId,manuId);
335 }
336 else
337 {
338 if (!check) continue;
8971f761 339
340 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
341
9b955acc 342 // manu is there, check all its channels
343 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
344 {
8971f761 345 if ( de->IsConnectedChannel(manuId,manuChannel) &&
9b955acc 346 !check(*test,manuChannel) )
347 {
348 AddMissingChannel(detElemId,manuId,manuChannel);
349 }
ea199e33 350 }
351 }
352 }
9b955acc 353 return fChambers;
354
ea199e33 355}
356
9b955acc 357
ea199e33 358//_____________________________________________________________________________
359TObjArray*
a0eca509 360AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
ea199e33 361 Float_t invalidFloatValue)
362{
363 /// Validate the store.
364 /// The invalidFloatValue is used to decide if a store content value
365 /// is valid or not.
366
367 delete fChambers;
368 fChambers = 0x0;
369
ea199e33 370 // Now checks if some full manus are missing
ea199e33 371
8971f761 372 AliMpManuIterator it;
373 Int_t detElemId;
374 Int_t manuId;
375
376 while ( it.Next(detElemId,manuId) )
ea199e33 377 {
ea199e33 378 AliMUONVCalibParam* test =
a0eca509 379 static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
ea199e33 380 if (!test)
381 {
382 // completely missing manu
383 AddMissingManu(detElemId,manuId);
384 }
385 else
386 {
387 // manu is there, check all its channels
8971f761 388 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
389
ea199e33 390 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
391 {
8971f761 392 if ( de->IsConnectedChannel(manuId,manuChannel) &&
ea199e33 393 ( test->ValueAsFloat(manuChannel,0) == invalidFloatValue ||
394 test->ValueAsFloat(manuChannel,1) == invalidFloatValue ) )
395 {
396 AddMissingChannel(detElemId,manuId,manuChannel);
397 }
398 }
399 }
400 }
401 return fChambers;
402}
403
404