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 "AliMUONCheckItem.h"
22 #include "AliMUONCheckItemIterator.h"
23 #include "AliMpConstants.h"
24 #include "AliMUONVStore.h"
25 #include "AliMUONVCalibParam.h"
26 #include "AliMpDEManager.h"
27 #include "AliMpIntPair.h"
28 #include "AliMpManuList.h"
29 #include <Riostream.h>
31 #include <TObjArray.h>
32 #include <TObjString.h>
34 /// \class AliMUON2DStoreValidator
36 /// Determine which channels, manus, DEs, stations are missing
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
40 /// to insure that what we'll put in the CDB is as complete as possible,
41 /// and to detect possible problem.
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" ;-) )
47 /// The list of missing things is kept in a structure of objects defined as :
49 /// fMissing = TObjArray[0..N tracking chambers]
51 /// fMissing[iChamber] = AliMUONCheckItem which contains n AliMUONCheckItem,
52 /// where n is the number of DE for that chamber
54 /// fMissing[iChamber]->GetItem(de) = AliMUONCheckItem which contains m
55 /// AliMUONCheckItem where m is the number of Manu for that DE
57 /// fMissing[iChamber]->GetItem(de)->GetItem(manu) = AliMUONCheckItem which
58 /// contains k TObjString = Form("%d",manuChannel)
60 /// \author Laurent Aphecetche
63 ClassImp(AliMUON2DStoreValidator)
66 //_____________________________________________________________________________
67 AliMUON2DStoreValidator::AliMUON2DStoreValidator()
76 //_____________________________________________________________________________
77 AliMUON2DStoreValidator::~AliMUON2DStoreValidator()
85 //_____________________________________________________________________________
87 AliMUON2DStoreValidator::GetChamber(Int_t chamberID)
89 /// Return (and create if not present) the given chamber
90 /// chamberID in 0..NCh()
92 if ( chamberID < 0 || chamberID >= AliMpConstants::NofTrackingChambers() )
94 AliFatal(Form("Invalid chamber number %d",chamberID));
100 fChambers = new TObjArray(AliMpConstants::NofTrackingChambers());
103 AliMUONCheckItem* chamber =
104 static_cast<AliMUONCheckItem*>(fChambers->At(chamberID));
108 chamber = new AliMUONCheckItem(chamberID,
109 AliMpDEManager::GetNofDEInChamber(chamberID),
111 fChambers->AddAt(chamber,chamberID);
116 //_____________________________________________________________________________
118 AliMUON2DStoreValidator::GetDE(Int_t detElemId)
120 /// Return (and create if not present) a given detection element
122 Int_t chamberID = AliMpDEManager::GetChamberId(detElemId);
123 AliMUONCheckItem* chamber = GetChamber(chamberID);
124 AliMUONCheckItem* de =
125 static_cast<AliMUONCheckItem*>(chamber->GetItem(detElemId));
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);
136 AliError(Form("Could not add DE %4d into chamber %2d",detElemId,chamberID));
142 //_____________________________________________________________________________
144 AliMUON2DStoreValidator::GetManu(Int_t detElemId, Int_t manuId)
146 /// Return (and create) a given manu
148 AliMUONCheckItem* de = GetDE(detElemId);
149 AliMUONCheckItem* manu = static_cast<AliMUONCheckItem*>(de->GetItem(manuId));
152 manu = new AliMUONCheckItem(manuId,AliMpManuList::NumberOfChannels(detElemId,manuId),"Manu");
153 Bool_t ok = de->AddItem(manuId,manu);
156 AliError(Form("Could not add manu %4d into DE %4d",manuId,detElemId));
163 //_____________________________________________________________________________
165 AliMUON2DStoreValidator::AddMissingChannel(Int_t detElemId,
166 Int_t manuId, Int_t manuChannel)
168 /// Add one missing channel to the list of missing things
170 AliDebug(3,Form("DE %4d Manu %4d Channel %2d is missing",
171 detElemId,manuId,manuChannel));
173 AliMUONCheckItem* manu = GetManu(detElemId,manuId);
174 Bool_t ok = manu->AddItem(manuChannel,new TObjString(Form("%2d",manuChannel)));
177 AliError(Form("Could not add channel %2d to manuId %4d in DE %4d",
178 manuChannel,manuId,detElemId));
182 //_____________________________________________________________________________
184 AliMUON2DStoreValidator::AddMissingManu(Int_t detElemId, Int_t manuId)
186 /// Add one missing manu to the list of missing things
188 AliDebug(3,Form("DE %4d Manu %4d is completely missing",
191 Int_t n(AliMpManuList::NumberOfChannels(detElemId,manuId));
193 for ( Int_t i = 0; i < n; ++i )
195 AddMissingChannel(detElemId,manuId,i);
199 //_____________________________________________________________________________
201 AliMUON2DStoreValidator::ReportManu(TList& lines, AliMUONCheckItem& manu)
203 /// Report list of missing channels from this manu
205 TObjString* channel(0x0);
206 AliMUONCheckItemIterator it(manu);
210 while ( ( channel = static_cast<TObjString*>(it.Next()) ) )
212 lines.Add(new TObjString(Form("\t\t\tChannel %s is missing or dead",
213 channel->GetString().Data())));
218 //_____________________________________________________________________________
220 AliMUON2DStoreValidator::ReportDE(TList& lines, AliMUONCheckItem& de)
222 /// Report list of missing manus from this de
223 AliMUONCheckItem* manu(0x0);
224 AliMUONCheckItemIterator it(de);
226 lines.Add(new TObjString(Form("DE %5d",de.GetID())));
230 while ( ( manu = static_cast<AliMUONCheckItem*>(it.Next()) ) )
232 if ( manu->IsDead() )
234 lines.Add(new TObjString(Form("\t\tManu %4d is missing or dead",manu->GetID())));
238 ReportManu(lines,*manu);
243 //_____________________________________________________________________________
245 AliMUON2DStoreValidator::ReportChamber(TList& lines, AliMUONCheckItem& chamber)
247 /// Report list of missing de from this chamber
249 AliMUONCheckItem* de(0x0);
250 AliMUONCheckItemIterator it(chamber);
254 while ( ( de = static_cast<AliMUONCheckItem*>(it.Next()) ) )
258 lines.Add(new TObjString(Form("\tDE %4d is missing or dead",de->GetID())));
267 //_____________________________________________________________________________
269 AliMUON2DStoreValidator::Report(TList& lines) const
274 Report(lines,*fChambers);
278 //_____________________________________________________________________________
280 AliMUON2DStoreValidator::Report(TList& lines, const TObjArray& chambers)
282 /// Reports what is missing, trying to be as concise as possible.
284 for ( Int_t iChamber = 0; iChamber <= chambers.GetLast(); ++iChamber )
286 AliMUONCheckItem* chamber = static_cast<AliMUONCheckItem*>(chambers.At(iChamber));
289 if ( chamber->IsDead() )
291 lines.Add(new TObjString(Form("Chamber %2d is missing or dead",iChamber)));
295 ReportChamber(lines,*chamber);
301 //_____________________________________________________________________________
303 AliMUON2DStoreValidator::Validate(const AliMUONVStore& store)
305 /// Validate the store. Check only the presence of all manus (i.e.
306 /// check nothing about the values themselves)
308 Bool_t (*kCheck)(const AliMUONVCalibParam&,Int_t) = 0x0;
309 return Validate(store,kCheck);
312 //_____________________________________________________________________________
314 AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
315 Bool_t (*check)(const AliMUONVCalibParam&,Int_t))
317 /// Validate the store.
318 /// The check method is used to decide if a store content value
324 if (!fManuList) fManuList = AliMpManuList::ManuList();
326 // Now checks if some full manus are missing
327 TIter next(fManuList);
330 while ( ( p = (AliMpIntPair*)next() ) )
332 Int_t detElemId = p->GetFirst();
333 Int_t manuId = p->GetSecond();
334 AliMUONVCalibParam* test =
335 static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
338 // completely missing manu
339 AddMissingManu(detElemId,manuId);
343 if (!check) continue;
344 // manu is there, check all its channels
345 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
347 if ( AliMpManuList::DoesChannelExist(detElemId,manuId,manuChannel) &&
348 !check(*test,manuChannel) )
350 AddMissingChannel(detElemId,manuId,manuChannel);
360 //_____________________________________________________________________________
362 AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
363 Float_t invalidFloatValue)
365 /// Validate the store.
366 /// The invalidFloatValue is used to decide if a store content value
372 if (!fManuList) fManuList = AliMpManuList::ManuList();
374 // Now checks if some full manus are missing
375 TIter next(fManuList);
378 while ( ( p = (AliMpIntPair*)next() ) )
380 Int_t detElemId = p->GetFirst();
381 Int_t manuId = p->GetSecond();
382 AliMUONVCalibParam* test =
383 static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
386 // completely missing manu
387 AddMissingManu(detElemId,manuId);
391 // manu is there, check all its channels
392 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
394 if ( AliMpManuList::DoesChannelExist(detElemId,manuId,manuChannel) &&
395 ( test->ValueAsFloat(manuChannel,0) == invalidFloatValue ||
396 test->ValueAsFloat(manuChannel,1) == invalidFloatValue ) )
398 AddMissingChannel(detElemId,manuId,manuChannel);