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()
70 //_____________________________________________________________________________
71 AliMUON2DStoreValidator::~AliMUON2DStoreValidator()
78 //_____________________________________________________________________________
80 AliMUON2DStoreValidator::GetChamber(Int_t chamberID)
82 /// Return (and create if not present) the given chamber
83 /// chamberID in 0..NCh()
85 if ( chamberID < 0 || chamberID >= AliMUONConstants::NCh() )
87 AliFatal(Form("Invalid chamber number %d",chamberID));
93 fChambers = new TObjArray(AliMUONConstants::NCh());
96 AliMUONCheckItem* chamber =
97 static_cast<AliMUONCheckItem*>(fChambers->At(chamberID));
101 chamber = new AliMUONCheckItem(chamberID,
102 AliMpDEManager::GetNofDEInChamber(chamberID),
104 fChambers->AddAt(chamber,chamberID);
109 //_____________________________________________________________________________
111 AliMUON2DStoreValidator::GetDE(Int_t detElemId)
113 /// Return (and create if not present) a given detection element
115 Int_t chamberID = AliMpDEManager::GetChamberId(detElemId);
116 AliMUONCheckItem* chamber = GetChamber(chamberID);
117 AliMUONCheckItem* de =
118 static_cast<AliMUONCheckItem*>(chamber->GetItem(detElemId));
121 AliDebug(3,Form("Did not find DE %4d into chamber %d, will create it",
122 detElemId,chamberID));
123 de = new AliMUONCheckItem(detElemId,
124 AliMpManuList::NumberOfManus(detElemId),
125 "Detection Element");
126 Bool_t ok = chamber->AddItem(detElemId,de);
129 AliError(Form("Could not add DE %4d into chamber %2d",detElemId,chamberID));
135 //_____________________________________________________________________________
137 AliMUON2DStoreValidator::GetManu(Int_t detElemId, Int_t manuId)
139 /// Return (and create) a given manu
141 AliMUONCheckItem* de = GetDE(detElemId);
142 AliMUONCheckItem* manu = static_cast<AliMUONCheckItem*>(de->GetItem(manuId));
145 manu = new AliMUONCheckItem(manuId,AliMpManuList::NumberOfChannels(detElemId,manuId),"Manu");
146 Bool_t ok = de->AddItem(manuId,manu);
149 AliError(Form("Could not add manu %4d into DE %4d",manuId,detElemId));
156 //_____________________________________________________________________________
158 AliMUON2DStoreValidator::AddMissingChannel(Int_t detElemId,
159 Int_t manuId, Int_t manuChannel)
161 /// Add one missing channel to the list of missing things
163 AliDebug(3,Form("DE %4d Manu %4d Channel %2d is missing",
164 detElemId,manuId,manuChannel));
166 AliMUONCheckItem* manu = GetManu(detElemId,manuId);
167 Bool_t ok = manu->AddItem(manuChannel,new TObjString(Form("%2d",manuChannel)));
170 AliError(Form("Could not add channel %2d to manuId %4d in DE %4d",
171 manuChannel,manuId,detElemId));
175 //_____________________________________________________________________________
177 AliMUON2DStoreValidator::AddMissingManu(Int_t detElemId, Int_t manuId)
179 /// Add one missing manu to the list of missing things
181 AliDebug(3,Form("DE %4d Manu %4d is completely missing",
184 Int_t n(AliMpManuList::NumberOfChannels(detElemId,manuId));
186 for ( Int_t i = 0; i < n; ++i )
188 AddMissingChannel(detElemId,manuId,i);
192 //_____________________________________________________________________________
194 AliMUON2DStoreValidator::ReportManu(AliMUONCheckItem& manu)
196 /// Report list of missing channels from this manu
198 TObjString* channel(0x0);
199 AliMUONCheckItemIterator it(manu);
203 while ( ( channel = static_cast<TObjString*>(it.Next()) ) )
205 cout << Form("\t\t\tChannel %s is missing",channel->GetString().Data()) << endl;
210 //_____________________________________________________________________________
212 AliMUON2DStoreValidator::ReportDE(AliMUONCheckItem& de)
214 /// Report list of missing manus from this de
215 AliMUONCheckItem* manu(0x0);
216 AliMUONCheckItemIterator it(de);
218 cout << Form("\tDE %4d",de.GetID()) << endl;
222 while ( ( manu = static_cast<AliMUONCheckItem*>(it.Next()) ) )
224 if ( manu->IsDead() )
226 cout << Form("\t\tManu %4d is missing",manu->GetID()) << endl;
235 //_____________________________________________________________________________
237 AliMUON2DStoreValidator::ReportChamber(AliMUONCheckItem& chamber)
239 /// Report list of missing de from this chamber
241 AliMUONCheckItem* de(0x0);
242 AliMUONCheckItemIterator it(chamber);
246 while ( ( de = static_cast<AliMUONCheckItem*>(it.Next()) ) )
250 cout << Form("\tDE %4d is missing",de->GetID()) << endl;
259 //_____________________________________________________________________________
261 AliMUON2DStoreValidator::Report(const TObjArray& chambers)
263 /// Reports what is missing, trying to be as concise as possible.
265 for ( Int_t iChamber = 0; iChamber <= chambers.GetLast(); ++iChamber )
267 AliMUONCheckItem* chamber = static_cast<AliMUONCheckItem*>(chambers.At(iChamber));
270 if ( chamber->IsDead() )
272 cout << Form("Chamber %2d is missing",iChamber) << endl;
276 ReportChamber(*chamber);
282 //_____________________________________________________________________________
284 AliMUON2DStoreValidator::Validate(const AliMUONV2DStore& store,
285 Float_t invalidFloatValue)
287 /// Validate the store.
288 /// The invalidFloatValue is used to decide if a store content value
294 if (!fManuList) fManuList = AliMpManuList::ManuList();
296 // Now checks if some full manus are missing
297 TIter next(fManuList);
300 while ( ( p = (AliMpIntPair*)next() ) )
302 Int_t detElemId = p->GetFirst();
303 Int_t manuId = p->GetSecond();
304 AliMUONVCalibParam* test =
305 static_cast<AliMUONVCalibParam*>(store.Get(detElemId,manuId));
308 // completely missing manu
309 AddMissingManu(detElemId,manuId);
313 // manu is there, check all its channels
314 for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
316 if ( AliMpManuList::DoesChannelExist(detElemId,manuId,manuChannel) &&
317 ( test->ValueAsFloat(manuChannel,0) == invalidFloatValue ||
318 test->ValueAsFloat(manuChannel,1) == invalidFloatValue ) )
320 AddMissingChannel(detElemId,manuId,manuChannel);