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 "AliMUONVCalibParam.h"
24 #include "AliMUONVStore.h"
25 #include "AliMpConstants.h"
26 #include "AliMpDDLStore.h"
27 #include "AliMpDEManager.h"
28 #include "AliMpDetElement.h"
29 #include "AliMpManuIterator.h"
30 #include <Riostream.h>
32 #include <TObjArray.h>
33 #include <TObjString.h>
35 //-----------------------------------------------------------------------------
36 /// \class AliMUON2DStoreValidator
38 /// Determine which channels, manus, DEs, stations are missing
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
42 /// to insure that what we'll put in the CDB is as complete as possible,
43 /// and to detect possible problem.
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" ;-) )
49 /// The list of missing things is kept in a structure of objects defined as :
51 /// fMissing = TObjArray[0..N tracking chambers]
53 /// fMissing[iChamber] = AliMUONCheckItem which contains n AliMUONCheckItem,
54 /// where n is the number of DE for that chamber
56 /// fMissing[iChamber]->GetItem(de) = AliMUONCheckItem which contains m
57 /// AliMUONCheckItem where m is the number of Manu for that DE
59 /// fMissing[iChamber]->GetItem(de)->GetItem(manu) = AliMUONCheckItem which
60 /// contains k TObjString = Form("%d",manuChannel)
62 /// \author Laurent Aphecetche
63 //-----------------------------------------------------------------------------
66 ClassImp(AliMUON2DStoreValidator)
69 //_____________________________________________________________________________
70 AliMUON2DStoreValidator::AliMUON2DStoreValidator()
78 //_____________________________________________________________________________
79 AliMUON2DStoreValidator::~AliMUON2DStoreValidator()
86 //_____________________________________________________________________________
88 AliMUON2DStoreValidator::GetChamber(Int_t chamberID)
90 /// Return (and create if not present) the given chamber
91 /// chamberID in 0..NCh()
93 if ( chamberID < 0 || chamberID >= AliMpConstants::NofTrackingChambers() )
95 AliFatal(Form("Invalid chamber number %d",chamberID));
101 fChambers = new TObjArray(AliMpConstants::NofTrackingChambers());
104 AliMUONCheckItem* chamber =
105 static_cast<AliMUONCheckItem*>(fChambers->At(chamberID));
109 chamber = new AliMUONCheckItem(chamberID,
110 AliMpDEManager::GetNofDEInChamber(chamberID),
112 fChambers->AddAt(chamber,chamberID);
117 //_____________________________________________________________________________
119 AliMUON2DStoreValidator::GetDE(Int_t detElemId)
121 /// Return (and create if not present) a given detection element
123 Int_t chamberID = AliMpDEManager::GetChamberId(detElemId);
124 AliMUONCheckItem* chamber = GetChamber(chamberID);
125 AliMUONCheckItem* de =
126 static_cast<AliMUONCheckItem*>(chamber->GetItem(detElemId));
129 AliDebug(3,Form("Did not find DE %4d into chamber %d, will create it",
130 detElemId,chamberID));
131 de = new AliMUONCheckItem(detElemId,
132 AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofManus(),
133 "Detection Element");
134 Bool_t ok = chamber->AddItem(detElemId,de);
137 AliError(Form("Could not add DE %4d into chamber %2d",detElemId,chamberID));
143 //_____________________________________________________________________________
145 AliMUON2DStoreValidator::GetManu(Int_t detElemId, Int_t manuId)
147 /// Return (and create) a given manu
149 AliMUONCheckItem* de = GetDE(detElemId);
150 AliMUONCheckItem* manu = static_cast<AliMUONCheckItem*>(de->GetItem(manuId));
153 manu = new AliMUONCheckItem(manuId,AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofChannelsInManu(manuId),"Manu");
154 Bool_t ok = de->AddItem(manuId,manu);
157 AliError(Form("Could not add manu %4d into DE %4d",manuId,detElemId));
164 //_____________________________________________________________________________
166 AliMUON2DStoreValidator::AddMissingChannel(Int_t detElemId,
167 Int_t manuId, Int_t manuChannel)
169 /// Add one missing channel to the list of missing things
171 AliDebug(3,Form("DE %4d Manu %4d Channel %2d is missing",
172 detElemId,manuId,manuChannel));
174 AliMUONCheckItem* manu = GetManu(detElemId,manuId);
175 Bool_t ok = manu->AddItem(manuChannel,new TObjString(Form("%2d",manuChannel)));
178 AliError(Form("Could not add channel %2d to manuId %4d in DE %4d",
179 manuChannel,manuId,detElemId));
183 //_____________________________________________________________________________
185 AliMUON2DStoreValidator::AddMissingManu(Int_t detElemId, Int_t manuId)
187 /// Add one missing manu to the list of missing things
189 AliDebug(3,Form("DE %4d Manu %4d is completely missing",
192 Int_t n(AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofChannelsInManu(manuId));
194 for ( Int_t i = 0; i < n; ++i )
196 AddMissingChannel(detElemId,manuId,i);
200 //_____________________________________________________________________________
202 AliMUON2DStoreValidator::ReportManu(TList& lines, AliMUONCheckItem& manu)
204 /// Report list of missing channels from this manu
206 TObjString* channel(0x0);
207 AliMUONCheckItemIterator it(manu);
211 while ( ( channel = static_cast<TObjString*>(it.Next()) ) )
213 lines.Add(new TObjString(Form("\t\t\tChannel %s is missing or dead",
214 channel->GetString().Data())));
219 //_____________________________________________________________________________
221 AliMUON2DStoreValidator::ReportDE(TList& lines, AliMUONCheckItem& de)
223 /// Report list of missing manus from this de
224 AliMUONCheckItem* manu(0x0);
225 AliMUONCheckItemIterator it(de);
227 lines.Add(new TObjString(Form("DE %5d",de.GetID())));
231 while ( ( manu = static_cast<AliMUONCheckItem*>(it.Next()) ) )
233 if ( manu->IsDead() )
235 lines.Add(new TObjString(Form("\t\tManu %4d is missing or dead",manu->GetID())));
239 ReportManu(lines,*manu);
244 //_____________________________________________________________________________
246 AliMUON2DStoreValidator::ReportChamber(TList& lines, AliMUONCheckItem& chamber)
248 /// Report list of missing de from this chamber
250 AliMUONCheckItem* de(0x0);
251 AliMUONCheckItemIterator it(chamber);
255 while ( ( de = static_cast<AliMUONCheckItem*>(it.Next()) ) )
259 lines.Add(new TObjString(Form("\tDE %4d is missing or dead",de->GetID())));
268 //_____________________________________________________________________________
270 AliMUON2DStoreValidator::Report(TList& lines) const
275 Report(lines,*fChambers);
279 //_____________________________________________________________________________
281 AliMUON2DStoreValidator::Report(TList& lines, const TObjArray& chambers)
283 /// Reports what is missing, trying to be as concise as possible.
285 for ( Int_t iChamber = 0; iChamber <= chambers.GetLast(); ++iChamber )
287 AliMUONCheckItem* chamber = static_cast<AliMUONCheckItem*>(chambers.At(iChamber));
290 if ( chamber->IsDead() )
292 lines.Add(new TObjString(Form("Chamber %2d is missing or dead",iChamber)));
296 ReportChamber(lines,*chamber);
302 //_____________________________________________________________________________
304 AliMUON2DStoreValidator::Validate(const AliMUONVStore& store)
306 /// Validate the store. Check only the presence of all manus (i.e.
307 /// check nothing about the values themselves)
309 Bool_t (*kCheck)(const AliMUONVCalibParam&,Int_t) = 0x0;
310 return Validate(store,kCheck);
313 //_____________________________________________________________________________
315 AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
316 Bool_t (*check)(const AliMUONVCalibParam&,Int_t))
318 /// Validate the store.
319 /// The check method is used to decide if a store content value
325 // Now checks if some full manus are missing
327 AliMpManuIterator it;
332 while ( it.Next(detElemId,manuId) )
334 AliMUONVCalibParam* test =
335 static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
338 // completely missing manu
339 AddMissingManu(detElemId,manuId);
343 if (!check) continue;
345 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
347 // manu is there, check all its channels
348 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
350 if ( de->IsConnectedChannel(manuId,manuChannel) &&
351 !check(*test,manuChannel) )
353 AddMissingChannel(detElemId,manuId,manuChannel);
363 //_____________________________________________________________________________
365 AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
366 Float_t invalidFloatValue)
368 /// Validate the store.
369 /// The invalidFloatValue is used to decide if a store content value
375 // Now checks if some full manus are missing
377 AliMpManuIterator it;
381 while ( it.Next(detElemId,manuId) )
383 AliMUONVCalibParam* test =
384 static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
387 // completely missing manu
388 AddMissingManu(detElemId,manuId);
392 // manu is there, check all its channels
393 AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
395 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
397 if ( de->IsConnectedChannel(manuId,manuChannel) &&
398 ( test->ValueAsFloat(manuChannel,0) == invalidFloatValue ||
399 test->ValueAsFloat(manuChannel,1) == invalidFloatValue ) )
401 AddMissingChannel(detElemId,manuId,manuChannel);