LCOV - code coverage report
Current view: top level - MUON/MUONrec - AliMUONQAMappingCheck.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 100 1.0 %
Date: 2016-06-14 17:26:59 Functions: 1 13 7.7 %

          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             : /// \class AliMUONQAMappingCheck
      19             : /// 
      20             : /// Helper class for AliMUONQADataMakerRec, which takes care
      21             : /// of building an AliMUONVTrackerData to store the location of
      22             : /// all the clusters encountered during a run, and all the clusters
      23             : /// that have charge on only one cathode (aka mono-cathode clusters).
      24             : ///
      25             : /// This is to easily spot mapping errors and/or region of complete
      26             : /// inefficiencies.
      27             : ///
      28             : /// \author Laurent Aphecetche, Subatech
      29             : ///
      30             : 
      31             : #include "AliMUONQAMappingCheck.h"
      32             : 
      33             : #include "AliCDBManager.h"
      34             : #include "AliCodeTimer.h"
      35             : #include "AliLog.h"
      36             : #include "AliMUON2DMap.h"
      37             : #include "AliMUONDigitCalibrator.h"
      38             : #include "AliMUONCalibParamND.h"
      39             : #include "AliMUONGeometryTransformer.h"
      40             : #include "AliMUONPadStatusMapMaker.h"
      41             : #include "AliMUONTrackerData.h"
      42             : #include "AliMUONVCluster.h"
      43             : #include "AliMUONVDigit.h"
      44             : #include "AliMpConstants.h"
      45             : #include "AliMpDetElement.h"
      46             : #include "AliMpDDLStore.h"
      47             : #include "AliMpPad.h"
      48             : #include "AliMpSegmentation.h"
      49             : #include "AliMpVSegmentation.h"
      50             : 
      51             : #include "AliMpManuIterator.h"
      52             : 
      53             : /// \cond CLASSIMP
      54          18 : ClassImp(AliMUONQAMappingCheck)
      55             : /// \endcond
      56             : 
      57             : //_____________________________________________________________________________
      58             : AliMUONQAMappingCheck::AliMUONQAMappingCheck(Int_t runNumber)
      59           0 : : TObject(),
      60           0 : fStore(new AliMUON2DMap(kTRUE)),
      61           0 : fGeometryTransformer(new AliMUONGeometryTransformer),
      62           0 : fDigitCalibrator(new AliMUONDigitCalibrator(runNumber)),
      63           0 : fNumberOfEvents(0),
      64           0 : fNumberOfClusters(0),
      65           0 : fNumberOfMonoCathodeClusters(0),
      66           0 : fNumberOfLegitimateMonoCathodeClusters(0)
      67           0 : {
      68             :   /// Ctor
      69             :   
      70           0 :   AliCodeTimerAuto(Form("RUN %d",runNumber),0);
      71             :   
      72           0 :   fGeometryTransformer->LoadGeometryData();
      73             :   
      74             :   // Init the store with all the manus. Note that this is not strictly necessary, 
      75             :   // but it helps not to get its growth (that would otherwise happen in
      76             :   // AddClusterLocation each time we get a cluster associated with a manu where
      77             :   // we got no cluster yet) confused with a memory leak...
      78           0 :   AliMpManuIterator it;
      79           0 :   Int_t detElemId, manuId;
      80             :   
      81           0 :   while (it.Next(detElemId,manuId))
      82             :   {
      83           0 :     fStore->Add(new AliMUONCalibParamND(4,AliMpConstants::ManuNofChannels(),detElemId,manuId,0.0));
      84             :   }
      85           0 : }
      86             : 
      87             : //_____________________________________________________________________________
      88             : AliMUONQAMappingCheck::~AliMUONQAMappingCheck()
      89           0 : {
      90             :   /// Dtor. Report on the global number of clusters encountered
      91           0 :   AliInfo(Form("Nevents %d Nclusters %d Nmono-cathodes %d Nlegitimate-mono-cathodes %d",
      92             :                fNumberOfEvents,
      93             :                fNumberOfClusters,
      94             :                fNumberOfMonoCathodeClusters,
      95             :                fNumberOfLegitimateMonoCathodeClusters));
      96           0 :   delete fStore;
      97           0 :   delete fGeometryTransformer;
      98           0 :   delete fDigitCalibrator;
      99           0 : }
     100             : 
     101             : //____________________________________________________________________________
     102             : void AliMUONQAMappingCheck::AddClusterLocation(Int_t detElemId,
     103             :                                                Int_t manuId, Int_t manuChannel, 
     104             :                                                Bool_t monoCathode,
     105             :                                                Bool_t legitimateMonoCathode)
     106             : {
     107             :   /// Add one cluster location to our internal store
     108           0 :   if ( manuId > 0 )
     109             :   {
     110           0 :     AliMUONVCalibParam* p = static_cast<AliMUONVCalibParam*>(fStore->FindObject(detElemId,manuId));
     111           0 :     if (!p)
     112             :     {
     113           0 :       p = new AliMUONCalibParamND(4,AliMpConstants::ManuNofChannels(),detElemId,manuId,0.0);
     114           0 :       fStore->Add(p);
     115           0 :     }
     116             : 
     117           0 :     p->SetValueAsDouble(manuChannel,0,p->ValueAsDouble(manuChannel,0)+1.0);
     118             :     
     119           0 :     if ( monoCathode )
     120             :     {
     121           0 :       p->SetValueAsDouble(manuChannel,1,p->ValueAsDouble(manuChannel,1)+1.0); 
     122           0 :       if (!legitimateMonoCathode)
     123             :       {
     124           0 :         p->SetValueAsDouble(manuChannel,2,p->ValueAsDouble(manuChannel,2)+1.0); 
     125           0 :       }
     126             :     }
     127           0 :   }
     128           0 : }
     129             : 
     130             : //____________________________________________________________________________ 
     131             : void 
     132             : AliMUONQAMappingCheck::NewEvent()
     133             : {
     134             :   /// Increment number of events seen
     135           0 :   ++fNumberOfEvents;
     136           0 : }
     137             : 
     138             : //____________________________________________________________________________ 
     139             : AliMUONVTrackerData* 
     140             : AliMUONQAMappingCheck::CreateData(const char* name) const
     141             : {
     142             :   /// Make a trackerData from our internal store
     143             :   
     144           0 :   AliMUONVStore* store = static_cast<AliMUONVStore*>(fStore->Clone());
     145             :   
     146           0 :   TIter next(store->CreateIterator());
     147             :   AliMUONVCalibParam* param;
     148             :   
     149           0 :   while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
     150             :   {
     151           0 :     for ( Int_t i = 0; i < param->Size(); ++i ) 
     152             :     {
     153           0 :       param->SetValueAsDouble(i,3,fNumberOfEvents);
     154             :     }
     155             :   }
     156             :   
     157           0 :   AliMUONTrackerData* data = new AliMUONTrackerData(name,name,4,kTRUE);
     158           0 :   data->SetDimensionName(0,"all"); // all clusters
     159           0 :   data->SetDimensionName(1,"mono"); // mono-cathode clusters
     160           0 :   data->SetDimensionName(2,"suspect"); // not legitimate mono-cathode clusters
     161           0 :   data->SetDimensionName(3,"Nevents"); // number of events
     162           0 :   data->DisableChannelLevel();
     163             :   
     164           0 :   data->Add(*store);
     165             :   
     166           0 :   delete store;
     167             :   
     168           0 :   return data;
     169           0 : }
     170             : 
     171             : //____________________________________________________________________________ 
     172             : void 
     173             : AliMUONQAMappingCheck::GetClusterLocation(AliMUONVCluster& cluster, 
     174             :                                           Int_t& manuBending, Int_t& manuBendingChannel, 
     175             :                                           Int_t& manuNonBending, Int_t& manuNonBendingChannel,
     176             :                                           Bool_t& monoCathode, Bool_t& legitimateMonoCathode)
     177             : {
     178             :   /// Get the pad under the center of the cluster, and whether or not this cluster
     179             :   /// has charge on both cathodes
     180             :   
     181           0 :   Int_t detElemId = cluster.GetDetElemId();
     182             :   
     183           0 :   Double_t x,y,z;
     184             :   
     185           0 :   fGeometryTransformer->Global2Local(detElemId,cluster.GetX(),cluster.GetY(),cluster.GetZ(),x,y,z);
     186             :   
     187           0 :   AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
     188             :   
     189           0 :   const AliMpVSegmentation* segB = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,de->GetCathodType(AliMp::kBendingPlane));
     190           0 :   const AliMpVSegmentation* segNB = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,de->GetCathodType(AliMp::kNonBendingPlane));
     191             :   
     192           0 :   AliMpPad padB = segB->PadByPosition(x,y);
     193           0 :   AliMpPad padNB = segNB->PadByPosition(x,y);
     194             :   
     195           0 :   manuBending = padB.GetManuId();
     196           0 :   manuBendingChannel = padB.GetManuChannel();
     197             :   
     198           0 :   manuNonBending = padNB.GetManuId();
     199           0 :   manuNonBendingChannel = padNB.GetManuChannel();
     200             :   
     201             :   Bool_t bending(kFALSE);
     202             :   Bool_t nonBending(kFALSE);
     203             :   
     204           0 :   for ( Int_t i = 0; i < cluster.GetNDigits(); ++i ) 
     205             : //    for ( Int_t i = 0; i < cluster.GetNDigits() && !(bending && nonBending); ++i ) 
     206             :   {
     207           0 :     UInt_t digitId = cluster.GetDigitId(i);
     208           0 :     Int_t manuId = AliMUONVDigit::ManuId(digitId);
     209           0 :     if ( manuId > 0 )
     210             :     {
     211           0 :       if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) )
     212             :       {
     213             :         nonBending = kTRUE;
     214           0 :       }
     215             :       else
     216             :       {
     217             :         bending = kTRUE;
     218             :       }
     219             :     }
     220             :   }
     221             :   
     222           0 :   monoCathode = ( bending != nonBending );
     223             :   
     224           0 :   if ( monoCathode ) 
     225             :   {
     226           0 :     legitimateMonoCathode = kFALSE;
     227           0 :     if (!bending) 
     228             :     {
     229           0 :       if ( IsManuDead(detElemId,manuBending) ) legitimateMonoCathode = kTRUE;    
     230             :     }
     231             :     
     232           0 :     if (!nonBending) 
     233             :     {
     234             :     
     235           0 :       if ( IsManuDead(detElemId,manuNonBending) ) legitimateMonoCathode = kTRUE;
     236             :     }
     237             :   }
     238             :   
     239           0 :   if (!bending) manuBending *= -1;
     240           0 :   if (!nonBending) manuNonBending *= -1;
     241             :   
     242           0 :   ++fNumberOfClusters;
     243           0 :   if ( monoCathode ) 
     244             :   {
     245           0 :     ++fNumberOfMonoCathodeClusters;
     246           0 :     if ( legitimateMonoCathode ) ++fNumberOfLegitimateMonoCathodeClusters;  
     247             :   }
     248           0 : }
     249             : 
     250             : //____________________________________________________________________________ 
     251             : Bool_t AliMUONQAMappingCheck::IsManuDead(Int_t detElemId, Int_t manuId) const
     252             : {
     253             :   /// Using the statusmaker, tells if a given manu is to be considered 
     254             :   /// as dead (here dead means at least one manas dead)
     255             :   
     256           0 :   if ( manuId <= 0 ) return kTRUE;
     257             :   
     258             :   Int_t n(0);
     259             :   
     260           0 :   for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i) 
     261             :   {
     262           0 :     if ( IsChannelDead(detElemId,manuId,i) ) ++n;
     263             :   }
     264           0 :   return n > 16;
     265           0 : }
     266             : 
     267             : //____________________________________________________________________________ 
     268             : Bool_t AliMUONQAMappingCheck::IsChannelDead(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
     269             : {
     270             :   /// Using the statusmaker, tells if a given channel is dead
     271             :   
     272           0 :   return ( fDigitCalibrator->StatusMap(detElemId,manuId,manuChannel) & (AliMUONPadStatusMapMaker::SelfDeadMask() != 0) );
     273             : }
     274             : 
     275             : //____________________________________________________________________________ 
     276             : void 
     277             : AliMUONQAMappingCheck::Store(AliMUONVCluster& cluster)
     278             : {
     279             :   /// Store information about a single cluster
     280             :                                       
     281           0 :   if ( cluster.GetCharge() < 10 ) return;
     282             :   
     283           0 :   Int_t manuBendingId, manuBendingChannel;
     284           0 :   Int_t manuNonBendingId, manuNonBendingChannel;
     285           0 :   Bool_t monoCathode, legitimateMonoCathode;
     286             :   
     287           0 :   GetClusterLocation(cluster, manuBendingId, manuBendingChannel,manuNonBendingId, manuNonBendingChannel, monoCathode,legitimateMonoCathode);
     288             :   
     289           0 :   AddClusterLocation(cluster.GetDetElemId(),manuBendingId,manuBendingChannel,monoCathode,legitimateMonoCathode);
     290           0 :   AddClusterLocation(cluster.GetDetElemId(),manuNonBendingId,manuNonBendingChannel,monoCathode,legitimateMonoCathode);    
     291           0 : }

Generated by: LCOV version 1.11