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 #include "AliMUON2DStoreValidator.h"
21 #include "AliMUONCalibParam1I.h"
22 #include "AliMpIntPair.h"
23 #include "AliMpManuList.h"
24 #include "AliMUONV2DStore.h"
26 #include "TObjArray.h"
27 #include "AliMUONCheckItem.h"
28 #include "AliMUONCheckItemIterator.h"
29 #include "AliMpDEManager.h"
30 #include "TObjString.h"
31 #include "AliMUONConstants.h"
32 #include "Riostream.h"
34 /// \class AliMUON2DStoreValidator
36 /// Determine which channels, manus, DEs, stations are missing
37 /// from a 2DStore. This is mainly to be used during (shuttle) preprocessing
38 /// to insure that what we'll put in the CDB is as complete as possible,
39 /// and to detect possible problem.
41 /// We made an effort to present the result of the validation in the most
42 /// concise way (i.e. if all channels of a DE are missing, we do not list
43 /// them, we just write "DE dead" ;-) )
45 /// The list of missing things is kept in a structure of objects defined as :
47 /// fMissing = TObjArray[0..N tracking chambers]
48 /// fMissing[iChamber] = AliMUONCheckItem which contains n AliMUONCheckItem,
49 /// where n is the number of DE for that chamber
50 /// fMissing[iChamber]->GetItem(de) = AliMUONCheckItem which contains m
51 /// AliMUONCheckItem where m is the number of Manu for that DE
52 /// fMissing[iChamber]->GetItem(de)->GetItem(manu) = AliMUONCheckItem which
53 /// contains k TObjString = Form("%d",manuChannel)
55 /// \author Laurent Aphecetche
58 ClassImp(AliMUON2DStoreValidator)
61 //_____________________________________________________________________________
62 AliMUON2DStoreValidator::AliMUON2DStoreValidator()
71 //_____________________________________________________________________________
72 AliMUON2DStoreValidator::~AliMUON2DStoreValidator()
80 //_____________________________________________________________________________
82 AliMUON2DStoreValidator::GetChamber(Int_t chamberID)
84 /// Return (and create if not present) the given chamber
85 /// chamberID in 0..NCh()
87 if ( chamberID < 0 || chamberID >= AliMUONConstants::NCh() )
89 AliFatal(Form("Invalid chamber number %d",chamberID));
95 fChambers = new TObjArray(AliMUONConstants::NCh());
98 AliMUONCheckItem* chamber =
99 static_cast<AliMUONCheckItem*>(fChambers->At(chamberID));
103 chamber = new AliMUONCheckItem(chamberID,
104 AliMpDEManager::GetNofDEInChamber(chamberID),
106 fChambers->AddAt(chamber,chamberID);
111 //_____________________________________________________________________________
113 AliMUON2DStoreValidator::GetDE(Int_t detElemId)
115 /// Return (and create if not present) a given detection element
117 Int_t chamberID = AliMpDEManager::GetChamberId(detElemId);
118 AliMUONCheckItem* chamber = GetChamber(chamberID);
119 AliMUONCheckItem* de =
120 static_cast<AliMUONCheckItem*>(chamber->GetItem(detElemId));
123 AliDebug(3,Form("Did not find DE %4d into chamber %d, will create it",
124 detElemId,chamberID));
125 de = new AliMUONCheckItem(detElemId,
126 AliMpManuList::NumberOfManus(detElemId),
127 "Detection Element");
128 Bool_t ok = chamber->AddItem(detElemId,de);
131 AliError(Form("Could not add DE %4d into chamber %2d",detElemId,chamberID));
137 //_____________________________________________________________________________
139 AliMUON2DStoreValidator::GetManu(Int_t detElemId, Int_t manuId)
141 /// Return (and create) a given manu
143 AliMUONCheckItem* de = GetDE(detElemId);
144 AliMUONCheckItem* manu = static_cast<AliMUONCheckItem*>(de->GetItem(manuId));
147 manu = new AliMUONCheckItem(manuId,AliMpManuList::NumberOfChannels(detElemId,manuId),"Manu");
148 Bool_t ok = de->AddItem(manuId,manu);
151 AliError(Form("Could not add manu %4d into DE %4d",manuId,detElemId));
158 //_____________________________________________________________________________
160 AliMUON2DStoreValidator::AddMissingChannel(Int_t detElemId,
161 Int_t manuId, Int_t manuChannel)
163 /// Add one missing channel to the list of missing things
165 AliDebug(3,Form("DE %4d Manu %4d Channel %2d is missing",
166 detElemId,manuId,manuChannel));
168 AliMUONCheckItem* manu = GetManu(detElemId,manuId);
169 Bool_t ok = manu->AddItem(manuChannel,new TObjString(Form("%2d",manuChannel)));
172 AliError(Form("Could not add channel %2d to manuId %4d in DE %4d",
173 manuChannel,manuId,detElemId));
177 //_____________________________________________________________________________
179 AliMUON2DStoreValidator::AddMissingManu(Int_t detElemId, Int_t manuId)
181 /// Add one missing manu to the list of missing things
183 AliDebug(3,Form("DE %4d Manu %4d is completely missing",
186 Int_t n(AliMpManuList::NumberOfChannels(detElemId,manuId));
188 for ( Int_t i = 0; i < n; ++i )
190 AddMissingChannel(detElemId,manuId,i);
194 //_____________________________________________________________________________
196 AliMUON2DStoreValidator::ReportManu(TList& lines, AliMUONCheckItem& manu)
198 /// Report list of missing channels from this manu
200 TObjString* channel(0x0);
201 AliMUONCheckItemIterator it(manu);
205 while ( ( channel = static_cast<TObjString*>(it.Next()) ) )
207 lines.Add(new TObjString(Form("\t\t\tChannel %s is missing or dead",
208 channel->GetString().Data())));
213 //_____________________________________________________________________________
215 AliMUON2DStoreValidator::ReportDE(TList& lines, AliMUONCheckItem& de)
217 /// Report list of missing manus from this de
218 AliMUONCheckItem* manu(0x0);
219 AliMUONCheckItemIterator it(de);
221 lines.Add(new TObjString(Form("DE %5d",de.GetID())));
225 while ( ( manu = static_cast<AliMUONCheckItem*>(it.Next()) ) )
227 if ( manu->IsDead() )
229 lines.Add(new TObjString(Form("\t\tManu %4d is missing or dead",manu->GetID())));
233 ReportManu(lines,*manu);
238 //_____________________________________________________________________________
240 AliMUON2DStoreValidator::ReportChamber(TList& lines, AliMUONCheckItem& chamber)
242 /// Report list of missing de from this chamber
244 AliMUONCheckItem* de(0x0);
245 AliMUONCheckItemIterator it(chamber);
249 while ( ( de = static_cast<AliMUONCheckItem*>(it.Next()) ) )
253 lines.Add(new TObjString(Form("\tDE %4d is missing or dead",de->GetID())));
262 //_____________________________________________________________________________
264 AliMUON2DStoreValidator::Report(TList& lines) const
269 Report(lines,*fChambers);
273 //_____________________________________________________________________________
275 AliMUON2DStoreValidator::Report(TList& lines, const TObjArray& chambers)
277 /// Reports what is missing, trying to be as concise as possible.
279 for ( Int_t iChamber = 0; iChamber <= chambers.GetLast(); ++iChamber )
281 AliMUONCheckItem* chamber = static_cast<AliMUONCheckItem*>(chambers.At(iChamber));
284 if ( chamber->IsDead() )
286 lines.Add(new TObjString(Form("Chamber %2d is missing or dead",iChamber)));
290 ReportChamber(lines,*chamber);
296 //_____________________________________________________________________________
298 AliMUON2DStoreValidator::Validate(const AliMUONV2DStore& store)
300 /// Validate the store. Check only the presence of all manus (i.e.
301 /// check nothing about the values themselves)
303 Bool_t (*kCheck)(const AliMUONVCalibParam&,Int_t) = 0x0;
304 return Validate(store,kCheck);
307 //_____________________________________________________________________________
309 AliMUON2DStoreValidator::Validate(const AliMUONV2DStore& store,
310 Bool_t (*check)(const AliMUONVCalibParam&,Int_t))
312 /// Validate the store.
313 /// The check method is used to decide if a store content value
319 if (!fManuList) fManuList = AliMpManuList::ManuList();
321 // Now checks if some full manus are missing
322 TIter next(fManuList);
325 while ( ( p = (AliMpIntPair*)next() ) )
327 Int_t detElemId = p->GetFirst();
328 Int_t manuId = p->GetSecond();
329 AliMUONVCalibParam* test =
330 static_cast<AliMUONVCalibParam*>(store.Get(detElemId,manuId));
333 // completely missing manu
334 AddMissingManu(detElemId,manuId);
338 if (!check) continue;
339 // manu is there, check all its channels
340 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
342 if ( AliMpManuList::DoesChannelExist(detElemId,manuId,manuChannel) &&
343 !check(*test,manuChannel) )
345 AddMissingChannel(detElemId,manuId,manuChannel);
355 //_____________________________________________________________________________
357 AliMUON2DStoreValidator::Validate(const AliMUONV2DStore& store,
358 Float_t invalidFloatValue)
360 /// Validate the store.
361 /// The invalidFloatValue is used to decide if a store content value
367 if (!fManuList) fManuList = AliMpManuList::ManuList();
369 // Now checks if some full manus are missing
370 TIter next(fManuList);
373 while ( ( p = (AliMpIntPair*)next() ) )
375 Int_t detElemId = p->GetFirst();
376 Int_t manuId = p->GetSecond();
377 AliMUONVCalibParam* test =
378 static_cast<AliMUONVCalibParam*>(store.Get(detElemId,manuId));
381 // completely missing manu
382 AddMissingManu(detElemId,manuId);
386 // manu is there, check all its channels
387 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
389 if ( AliMpManuList::DoesChannelExist(detElemId,manuId,manuChannel) &&
390 ( test->ValueAsFloat(manuChannel,0) == invalidFloatValue ||
391 test->ValueAsFloat(manuChannel,1) == invalidFloatValue ) )
393 AddMissingChannel(detElemId,manuId,manuChannel);