LCOV - code coverage report
Current view: top level - MUON/MUONcalib - AliMUON2DStoreValidator.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 128 0.8 %
Date: 2016-06-14 17:26:59 Functions: 1 19 5.3 %

          Line data    Source code
       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"
      21             : #include "AliMUONCheckItem.h"
      22             : #include "AliMUONVCalibParam.h"
      23             : #include "AliMUONVStore.h"
      24             : #include "AliMpConstants.h"
      25             : #include "AliMpDDLStore.h"
      26             : #include "AliMpDEManager.h"
      27             : #include "AliMpDetElement.h"
      28             : #include "AliMpManuIterator.h"
      29             : #include <Riostream.h>
      30             : #include <TList.h>
      31             : #include <TObjArray.h>
      32             : #include <TObjString.h>
      33             : 
      34             : //-----------------------------------------------------------------------------
      35             : /// \class AliMUON2DStoreValidator
      36             : ///
      37             : /// Determine which channels, manus, DEs, stations are missing
      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
      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]
      51             : ///
      52             : /// fMissing[iChamber] = AliMUONCheckItem which contains n AliMUONCheckItem, 
      53             : /// where n is the number of DE for that chamber
      54             : ///
      55             : /// fMissing[iChamber]->GetItem(de) = AliMUONCheckItem which contains m
      56             : /// AliMUONCheckItem where m is the number of Manu for that DE
      57             : ///
      58             : /// fMissing[iChamber]->GetItem(de)->GetItem(manu) = AliMUONCheckItem which 
      59             : /// contains k TObjString = Form("%d",manuChannel)
      60             : ///
      61             : /// \author Laurent Aphecetche
      62             : //-----------------------------------------------------------------------------
      63             : 
      64             : /// \cond CLASSIMP
      65          18 : ClassImp(AliMUON2DStoreValidator)
      66             : /// \endcond
      67             : 
      68             : //_____________________________________________________________________________
      69             : AliMUON2DStoreValidator::AliMUON2DStoreValidator() 
      70           0 : : TObject(),
      71           0 :   fChambers(0x0),
      72           0 :   fStatus(0x0)
      73           0 : {
      74             :     /// ctor
      75           0 : }
      76             : 
      77             : //_____________________________________________________________________________
      78             : AliMUON2DStoreValidator::~AliMUON2DStoreValidator()
      79           0 : {
      80             :   /// dtor
      81           0 :   delete fChambers;
      82           0 :   delete fStatus;
      83           0 : }
      84             : 
      85             : //_____________________________________________________________________________
      86             : AliMUONCheckItem* 
      87             : AliMUON2DStoreValidator::GetChamber(Int_t chamberID)
      88             : {
      89             :   /// Return (and create if not present) the given chamber
      90             :   /// chamberID in 0..NCh()
      91             :   
      92           0 :   if ( chamberID < 0 || chamberID >= AliMpConstants::NofTrackingChambers() )
      93             :   {
      94           0 :     AliFatal(Form("Invalid chamber number %d",chamberID));
      95           0 :     return 0x0;
      96             :   }
      97             :   
      98           0 :   if (!fChambers) 
      99             :   {
     100           0 :     fChambers = new TObjArray(AliMpConstants::NofTrackingChambers());
     101           0 :   }
     102             :     
     103             :   AliMUONCheckItem* chamber = 
     104           0 :     static_cast<AliMUONCheckItem*>(fChambers->At(chamberID));
     105             :   
     106           0 :   if (!chamber)
     107             :   {
     108           0 :     chamber = new AliMUONCheckItem(chamberID,
     109           0 :                                    AliMpDEManager::GetNofDEInChamber(chamberID),
     110             :                                    "Chamber");
     111           0 :     fChambers->AddAt(chamber,chamberID);
     112           0 :   }
     113             :   return chamber;
     114           0 : }
     115             : 
     116             : //_____________________________________________________________________________
     117             : AliMUONCheckItem* 
     118             : AliMUON2DStoreValidator::GetDE(Int_t detElemId)
     119             : {
     120             :   /// Return (and create if not present) a given detection element
     121             :   
     122           0 :   Int_t chamberID = AliMpDEManager::GetChamberId(detElemId);
     123           0 :   AliMUONCheckItem* chamber = GetChamber(chamberID);  
     124             :   AliMUONCheckItem* de = 
     125           0 :     static_cast<AliMUONCheckItem*>(chamber->GetItem(detElemId));
     126           0 :   if (!de)
     127             :   {
     128           0 :     AliDebug(3,Form("Did not find DE %4d into chamber %d, will create it",
     129             :                     detElemId,chamberID));
     130           0 :     de = new AliMUONCheckItem(detElemId,
     131           0 :                               AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofManus(),
     132             :                               "Detection Element");
     133           0 :     Bool_t ok = chamber->AddItem(detElemId,de);
     134           0 :     if (!ok)
     135             :     {
     136           0 :       AliError(Form("Could not add DE %4d into chamber %2d",detElemId,chamberID));
     137           0 :     }
     138           0 :   }
     139           0 :   return de;
     140           0 : }
     141             : 
     142             : //_____________________________________________________________________________
     143             : AliMUONCheckItem* 
     144             : AliMUON2DStoreValidator::GetManu(Int_t detElemId, Int_t manuId)
     145             : {
     146             :   /// Return (and create) a given manu
     147             :   
     148           0 :   AliMUONCheckItem* de = GetDE(detElemId);
     149           0 :   AliMUONCheckItem* manu = static_cast<AliMUONCheckItem*>(de->GetItem(manuId));
     150           0 :   if (!manu)
     151             :   {
     152           0 :     manu = new AliMUONCheckItem(manuId,AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofChannelsInManu(manuId),"Manu");
     153           0 :     Bool_t ok = de->AddItem(manuId,manu);
     154           0 :     if (!ok)
     155             :     {
     156           0 :       AliError(Form("Could not add manu %4d into DE %4d",manuId,detElemId));
     157           0 :     }
     158             :     
     159           0 :   }
     160           0 :   return manu;
     161           0 : }
     162             : 
     163             : //_____________________________________________________________________________
     164             : void
     165             : AliMUON2DStoreValidator::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           0 :   AliDebug(3,Form("DE %4d Manu %4d Channel %2d is missing",
     171             :                   detElemId,manuId,manuChannel));
     172             : 
     173           0 :   AliMUONCheckItem* manu = GetManu(detElemId,manuId);
     174           0 :   Bool_t ok = manu->AddItem(manuChannel,new TObjString(Form("%2d",manuChannel)));
     175           0 :   if (!ok)
     176             :   {
     177           0 :     AliError(Form("Could not add channel %2d to manuId %4d in DE %4d",
     178             :                     manuChannel,manuId,detElemId));
     179           0 :   }
     180           0 : }
     181             : 
     182             : //_____________________________________________________________________________
     183             : void
     184             : AliMUON2DStoreValidator::AddMissingManu(Int_t detElemId, Int_t manuId)
     185             : {
     186             :   /// Add one missing manu to the list of missing things
     187             :   
     188           0 :   AliDebug(3,Form("DE %4d Manu %4d is completely missing",
     189             :                   detElemId,manuId));
     190             : 
     191           0 :   Int_t n(AliMpDDLStore::Instance()->GetDetElement(detElemId)->NofChannelsInManu(manuId));
     192             : 
     193           0 :   for ( Int_t i = 0; i < n; ++i )
     194             :   {
     195           0 :     AddMissingChannel(detElemId,manuId,i);
     196             :   }
     197           0 : }
     198             : 
     199             : //_____________________________________________________________________________
     200             : void
     201             : AliMUON2DStoreValidator::ReportManu(TList& lines, const AliMUONCheckItem& manu)
     202             : {  
     203             :   /// Report list of missing channels from this manu
     204             :   
     205             :   TObjString* channel(0x0);
     206           0 :   TIter next(manu.CreateIterator());
     207             :   
     208           0 :   while ( ( channel = static_cast<TObjString*>(next()) ) )
     209             :   {
     210           0 :     lines.Add(new TObjString(Form("\t\t\tChannel %s is missing or dead",
     211           0 :                                   channel->GetString().Data())));
     212             :   }
     213             :   
     214           0 : }
     215             : 
     216             : //_____________________________________________________________________________
     217             : void
     218             : AliMUON2DStoreValidator::ReportDE(TList& lines, const AliMUONCheckItem& de)
     219             : {  
     220             :   /// Report list of missing manus from this de
     221             :   AliMUONCheckItem* manu(0x0);
     222             :   
     223           0 :   TIter next(de.CreateIterator());
     224             :   
     225           0 :   lines.Add(new TObjString(Form("DE %5d",de.GetID())));
     226             :   
     227             :   
     228           0 :   while ( ( manu = static_cast<AliMUONCheckItem*>(next()) ) )
     229             :   {
     230           0 :     if ( manu->IsDead() )
     231             :     {
     232           0 :       lines.Add(new TObjString(Form("\t\tManu %4d is missing or dead",manu->GetID())));
     233             :     }
     234             :     else
     235             :     {
     236           0 :       ReportManu(lines,*manu);
     237             :     }
     238             :   }
     239           0 : }
     240             : 
     241             : //_____________________________________________________________________________
     242             : void
     243             : AliMUON2DStoreValidator::ReportChamber(TList& lines, const AliMUONCheckItem& chamber)
     244             : {  
     245             :   /// Report list of missing de from this chamber
     246             :   
     247             :   AliMUONCheckItem* de(0x0);
     248           0 :   TIter next(chamber.CreateIterator());
     249             :   
     250           0 :   while ( ( de = static_cast<AliMUONCheckItem*>(next()) ) )
     251             :   {
     252           0 :     if ( de->IsDead() )
     253             :     {
     254           0 :       lines.Add(new TObjString(Form("\tDE %4d is missing or dead",de->GetID())));
     255             :     }
     256             :     else
     257             :     {
     258           0 :       ReportDE(lines,*de);
     259             :     }
     260             :   }
     261           0 : }
     262             : 
     263             : //_____________________________________________________________________________
     264             : void
     265             : AliMUON2DStoreValidator::Report(TList& lines) const
     266             : { 
     267             :   /// 
     268           0 :   if (fChambers) 
     269             :   {
     270           0 :     Report(lines,*fChambers); 
     271           0 :   }
     272           0 : }
     273             : 
     274             : //_____________________________________________________________________________
     275             : void
     276             : AliMUON2DStoreValidator::Report(TList& lines, const TObjArray& chambers)
     277             : {
     278             :   /// Reports what is missing, trying to be as concise as possible.
     279             :   
     280           0 :   for ( Int_t iChamber = 0; iChamber <= chambers.GetLast(); ++iChamber )
     281             :   {
     282           0 :     AliMUONCheckItem* chamber = static_cast<AliMUONCheckItem*>(chambers.At(iChamber));
     283           0 :     if ( chamber )
     284             :     {
     285           0 :       if ( chamber->IsDead() )
     286             :       {
     287           0 :         lines.Add(new TObjString(Form("Chamber %2d is missing or dead",iChamber)));
     288           0 :       }
     289             :       else
     290             :       {
     291           0 :         ReportChamber(lines,*chamber);
     292             :       }
     293             :     }
     294             :   }
     295           0 : }
     296             : 
     297             : //_____________________________________________________________________________
     298             : TObjArray* 
     299             : AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
     300             :                                   AliMUONVStore* config)
     301             : {                                  
     302             :   /// Validate the store. Check only the presence of all manus (i.e.
     303             :   /// check nothing about the values themselves). 
     304             :   /// Absence of manus which are not in the config is considered as normal.
     305             :   
     306             :   Bool_t (*kCheck)(const AliMUONVCalibParam&,Int_t) = 0x0;
     307           0 :   return Validate(store,kCheck,config);
     308             : }
     309             : 
     310             : //_____________________________________________________________________________
     311             : TObjArray* 
     312             : AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
     313             :                                   Bool_t (*check)(const AliMUONVCalibParam&,Int_t),
     314             :                                   AliMUONVStore* config)
     315             : {
     316             :   /// Validate the store. 
     317             :   /// The check method is used to decide if a store content value
     318             :   /// is valid or not.
     319             :   
     320           0 :   delete fChambers;
     321           0 :   fChambers = 0x0;
     322             :   
     323             :   // Now checks if some full manus are missing
     324             : 
     325           0 :   AliMpManuIterator it;
     326             : 
     327           0 :   Int_t detElemId;
     328           0 :   Int_t manuId;
     329             :   
     330           0 :   while ( it.Next(detElemId,manuId) )
     331             :   {
     332             :     AliMUONVCalibParam* test = 
     333           0 :       static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
     334           0 :     if (!test)
     335             :     {
     336             :       // completely missing manu
     337           0 :       if ( !config || ( config && config->FindObject(detElemId,manuId ) ) )
     338             :       {
     339             :         // manu is in the config but not in the store : that's an error
     340           0 :         AddMissingManu(detElemId,manuId);
     341             :       }
     342             :     }
     343             :     else
     344             :     {
     345           0 :       if (!check) continue;
     346             :       
     347           0 :       AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
     348             :       
     349             :       // manu is there, check all its channels
     350           0 :       for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
     351             :       {
     352           0 :         if ( de->IsConnectedChannel(manuId,manuChannel) &&
     353           0 :              !check(*test,manuChannel) )             
     354             :         {
     355           0 :           AddMissingChannel(detElemId,manuId,manuChannel);
     356             :         }
     357             :       }
     358             :     }
     359           0 :   }
     360           0 :   return fChambers;
     361             :   
     362           0 : }
     363             : 
     364             : 
     365             : //_____________________________________________________________________________
     366             : TObjArray* 
     367             : AliMUON2DStoreValidator::Validate(const AliMUONVStore& store,
     368             :                                   Float_t invalidFloatValue,
     369             :                                   AliMUONVStore* config)
     370             : {
     371             :   /// Validate the store. 
     372             :   /// The invalidFloatValue is used to decide if a store content value
     373             :   /// is valid or not.
     374             :   
     375           0 :   delete fChambers;
     376           0 :   fChambers = 0x0;
     377             :   
     378             :   // Now checks if some full manus are missing
     379             : 
     380           0 :   AliMpManuIterator it;
     381           0 :   Int_t detElemId;
     382           0 :   Int_t manuId;
     383             :   
     384           0 :   while ( it.Next(detElemId,manuId) )
     385             :   {
     386             :     AliMUONVCalibParam* test = 
     387           0 :       static_cast<AliMUONVCalibParam*>(store.FindObject(detElemId,manuId));
     388           0 :     if (!test)
     389             :     {
     390           0 :       if ( !config || ( config && config->FindObject(detElemId,manuId ) ) )
     391             :       {
     392             :         // completely missing manu
     393           0 :         AddMissingManu(detElemId,manuId);
     394             :       }
     395             :     }
     396             :     else
     397             :     {
     398             :       // manu is there, check all its channels
     399           0 :       AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
     400             :       
     401           0 :       for ( Int_t manuChannel = 0 ; manuChannel < test->Size(); ++manuChannel )
     402             :       {
     403           0 :         if ( de->IsConnectedChannel(manuId,manuChannel) &&
     404           0 :              ( test->ValueAsFloat(manuChannel,0) == invalidFloatValue ||
     405           0 :                test->ValueAsFloat(manuChannel,1) == invalidFloatValue ) )             
     406             :         {
     407           0 :           AddMissingChannel(detElemId,manuId,manuChannel);
     408             :         }
     409             :       }
     410             :     }
     411             :   }
     412           0 :   return fChambers;
     413           0 : }
     414             : 
     415             : 

Generated by: LCOV version 1.11