LCOV - code coverage report
Current view: top level - MUON/MUONcalib - AliMUONPedestal.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 290 0.3 %
Date: 2016-06-14 17:26:59 Functions: 1 15 6.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             : #include "AliMUONPedestal.h"
      19             : #include "AliMUONErrorCounter.h"
      20             : #include "AliMUONVStore.h"
      21             : #include "AliMUON2DMap.h"
      22             : #include "AliMUONCalibParamND.h"
      23             : #include "AliMpConstants.h"
      24             : #include <TString.h>
      25             : #include <TTimeStamp.h>
      26             : #include <TMath.h>
      27             : #include <TTree.h>
      28             : #include <TFile.h>
      29             : #include <TH1F.h>
      30             : #include <THashList.h>
      31             : #include <Riostream.h>
      32             : 
      33             : #include <sstream>
      34             : 
      35             : //-----------------------------------------------------------------------------
      36             : /// \class AliMUONPedestal
      37             : ///
      38             : /// Implementation of the pedestal computing
      39             : ///
      40             : /// add
      41             : /// 
      42             : ///
      43             : /// \author Alberto Baldisseri, JL Charvet (05/05/2009)
      44             : //-----------------------------------------------------------------------------
      45             : 
      46             : using std::ostream;
      47             : using std::ifstream;
      48             : using std::endl;
      49             : using std::cout;
      50             : using std::ios;
      51             : /// \cond CLASSIMP
      52          18 : ClassImp(AliMUONPedestal)
      53             : /// \endcond
      54             : 
      55             : //______________________________________________________________________________
      56             : AliMUONPedestal::AliMUONPedestal()
      57           0 : : TObject(),
      58             : //fN(0),
      59           0 : fNCurrentEvents(0),
      60           0 : fNEvthreshold(0),
      61           0 : fSorting(0),
      62           0 : fNEvents(0),
      63           0 : fRunNumber(0),
      64           0 : fNChannel(0),
      65           0 : fNManu(0),
      66           0 : fNManuConfig(0),
      67           0 : fConfig(1),
      68           0 : fStatusDA(0),
      69           0 : fHistos(0),
      70           0 : fErrorBuspatchTable(new AliMUON2DMap(kFALSE)),
      71           0 : fManuBuspatchTable(new AliMUON2DMap(kFALSE)),
      72           0 : fManuBPoutofconfigTable(new AliMUON2DMap(kFALSE)),
      73           0 : fDate(new TTimeStamp()),
      74           0 : fFilcout(0),
      75           0 : fHistoFileName(),
      76           0 : fPedestalStore(new AliMUON2DMap(kTRUE)),
      77           0 : fIndex(-1),
      78           0 : fPrefixDA(),
      79           0 : fPrefixLDC(),
      80           0 : fHistoFile(0),
      81           0 : fTree(0)
      82           0 : {
      83             : /// Default constructor
      84           0 : }
      85             : //______________________________________________________________________________
      86             : AliMUONPedestal::AliMUONPedestal(TRootIOCtor* /*dummy*/)
      87           0 : : TObject(),
      88             : //fN(0),
      89           0 : fNCurrentEvents(0),
      90           0 : fNEvthreshold(0),
      91           0 : fSorting(0),
      92           0 : fNEvents(0),
      93           0 : fRunNumber(0),
      94           0 : fNChannel(0),
      95           0 : fNManu(0),
      96           0 : fNManuConfig(0),
      97           0 : fConfig(1),
      98           0 : fStatusDA(0),
      99           0 : fHistos(0),
     100           0 : fErrorBuspatchTable(0),
     101           0 : fManuBuspatchTable(0),
     102           0 : fManuBPoutofconfigTable(0),
     103           0 : fDate(0),
     104           0 : fFilcout(0),
     105           0 : fHistoFileName(),
     106           0 : fPedestalStore(0),
     107           0 : fIndex(-1),
     108           0 : fPrefixDA(),
     109           0 : fPrefixLDC(),
     110           0 : fHistoFile(0),
     111           0 : fTree(0)
     112           0 : {
     113             : /// Root IO constructor
     114           0 : }
     115             : 
     116             : //______________________________________________________________________________
     117             : AliMUONPedestal::~AliMUONPedestal()
     118           0 : {
     119             : /// Destructor
     120           0 :   delete fErrorBuspatchTable;
     121           0 :   delete fManuBuspatchTable;
     122           0 :   delete fPedestalStore;
     123           0 :   delete fManuBPoutofconfigTable;
     124           0 : }
     125             : 
     126             : //______________________________________________________________________________
     127             : const char* 
     128             : AliMUONPedestal::GetHistoFileName() const
     129             : {
     130             :   /// Return the name of file we use to store histograms
     131           0 :   return fHistoFileName.Data();
     132             : }
     133             : 
     134             : //______________________________________________________________________________
     135             : void AliMUONPedestal::LoadConfig(const char* dbfile)
     136             : {
     137             :   /// Load MUONTRK configuration from ascii file "dbfile" (in DetDB)
     138             : 
     139           0 :   Int_t manuId;
     140           0 :   Int_t busPatchId;
     141             : 
     142           0 :   ifstream filein(dbfile,ios::in);
     143             :   
     144           0 :   while (!filein.eof())
     145             :     { 
     146           0 :       filein >> busPatchId >> manuId;
     147             : 
     148             :       AliMUONVCalibParam* ped = 
     149           0 :         static_cast<AliMUONVCalibParam*>(fPedestalStore ->FindObject(busPatchId, manuId));
     150             : 
     151           0 :       if (!ped) {
     152           0 :         fNManuConfig++;
     153           0 :         fNChannel+=64;
     154           0 :   ped = new AliMUONCalibParamND(2, AliMpConstants::ManuNofChannels(),busPatchId, manuId, -1.); // put default wise -1, not connected channel
     155           0 :         fPedestalStore ->Add(ped);  
     156             : 
     157           0 :         if ( ! fManuBuspatchTable->FindObject(busPatchId,manuId) )
     158             :           {
     159             :             // New (buspatch,manu)
     160           0 :             AliMUONErrorCounter* manuCounter = new AliMUONErrorCounter(busPatchId,manuId);
     161           0 :             fManuBuspatchTable->Add(manuCounter);
     162           0 :           }
     163             :       }
     164             :     }
     165           0 : } 
     166             : //______________________________________________________________________________
     167             : void AliMUONPedestal::MakePed(Int_t busPatchId, Int_t manuId, Int_t channelId, Int_t charge)
     168             : {
     169             :   static Int_t tree_charge=0;
     170             :   static Int_t warn=0;
     171           0 :   Int_t DDL= busPatchId/100+2560;
     172             :   /// Compute pedestals values
     173             :   AliMUONVCalibParam* ped = 
     174           0 :     static_cast<AliMUONVCalibParam*>(fPedestalStore ->FindObject(busPatchId, manuId));
     175             : 
     176             : 
     177           0 :   if(!tree_charge && fHistos==2)
     178             :     {
     179           0 :       fTree = new TTree("tc","Charge tree");
     180           0 :       fTree->Branch("bp",&busPatchId,"bp/I");
     181           0 :       fTree->Branch("manu",&manuId,",manu/I");
     182           0 :       fTree->Branch("channel",&channelId,",channel/I");
     183           0 :       fTree->Branch("DDL",&DDL,",DDL/I");
     184           0 :       fTree->Branch("charge",&charge,"charge/I");
     185             :       //      fTree->Branch("Pedestal",&Pedestal,"Pedestal/D");
     186             :       //      fTree->Branch("chargetrue",&chargeminusPed,"chargetrue/D");
     187             :       //      fTree->Branch("evt",&evt,"evt/I");
     188           0 :       tree_charge=1;
     189           0 :     }
     190             : 
     191             : 
     192           0 :   if (!ped)   
     193             :     {
     194           0 :       if(fConfig) 
     195             :         {  // Fill out_of_config (buspatch,manu) table
     196           0 :           if (!(static_cast<AliMUONErrorCounter*>(fManuBPoutofconfigTable->FindObject(busPatchId,manuId))))
     197           0 :             fManuBPoutofconfigTable->Add(new AliMUONErrorCounter(busPatchId,manuId));
     198           0 :           if(warn<10) cout << fPrefixLDC.Data() << " : !!! WARNING  : busPatchId = " << busPatchId << " manuId = " << manuId << " not in the Detector configuration " << endl;
     199           0 :           else if(warn==10) cout << fPrefixLDC.Data() << " : !!! see .log file for an exhaustive list of (busPatchId, manuId) out of Detector configuration \n" << endl; 
     200           0 :            warn++;
     201           0 :            (*fFilcout) <<" !!! WARNING  : busPatchId = " << busPatchId << " manuId = " << manuId << " not in the Detector configuration " << endl; 
     202           0 :         }
     203           0 :       else {fNManu++;}
     204           0 :       fNChannel+=64;
     205             :       // put default wise -1, not connected channel
     206           0 :       ped = new AliMUONCalibParamND(2, AliMpConstants::ManuNofChannels(),busPatchId, manuId, -1.); 
     207           0 :       fPedestalStore ->Add(ped);  
     208           0 :     }
     209             : 
     210             :   // Initialization for the first value
     211           0 :   if (ped->ValueAsDouble(channelId, 0) == -1)  
     212             :     { 
     213           0 :       if(fConfig && channelId == 0){fNManu++;}
     214           0 :       ped->SetValueAsDouble(channelId, 0, 0.);
     215           0 :     }
     216           0 :   if (ped->ValueAsDouble(channelId, 1) == -1) ped->SetValueAsDouble(channelId, 1, 0.);
     217             : 
     218           0 :   if(fHistos==2) fTree->Fill();  
     219             : 
     220           0 :   Double_t pedMean  = ped->ValueAsDouble(channelId, 0) + (Double_t) charge;
     221           0 :   Double_t pedSigma = ped->ValueAsDouble(channelId, 1) + (Double_t) charge*charge;
     222             : 
     223           0 :   ped->SetValueAsDouble(channelId, 0, pedMean);
     224           0 :   ped->SetValueAsDouble(channelId, 1, pedSigma);
     225             : 
     226             :   AliMUONErrorCounter* manuCounter;
     227           0 :   if (!(manuCounter = static_cast<AliMUONErrorCounter*>(fManuBuspatchTable->FindObject(busPatchId,manuId))))
     228             :     {
     229             :       // New (buspatch,manu)
     230           0 :       manuCounter = new AliMUONErrorCounter(busPatchId,manuId);
     231           0 :       fManuBuspatchTable->Add(manuCounter);
     232           0 :     }
     233             :   else
     234             :     {
     235             :       // Existing buspatch
     236           0 :       manuCounter->Increment();
     237             :     }   
     238           0 : }
     239             : //______________________________________________________________________________
     240             : void AliMUONPedestal::Finalize()
     241             : {
     242             :   /// final polishing of the store
     243             :   
     244             :   Double_t pedMean;
     245             :   Double_t pedSigma;
     246             :   Double_t pedSigmalimit=0.5;
     247             :   Int_t busPatchId;
     248             :   Int_t manuId;
     249             :   Int_t channelId;
     250             :   Int_t status=0;
     251             : 
     252             :   // print in logfile
     253           0 :   if (fErrorBuspatchTable->GetSize())
     254             :     {
     255           0 :       cout<< "\n" << fPrefixLDC.Data() << " : See list of Buspatches with lower statistics (due to parity errors) in .log or .ped file "<<endl;
     256           0 :       (*fFilcout)<<"\nWarning: Buspatches with less statistics (due to parity errors)"<<endl;
     257           0 :       TIter nextParityError(fErrorBuspatchTable->CreateIterator());
     258             :       AliMUONErrorCounter* parityerror;
     259           0 :       while((parityerror = static_cast<AliMUONErrorCounter*>(nextParityError())))
     260             :         {
     261             :           //      cout<<"  bp "<<parityerror->BusPatch()<<": used events = "<<fNEvents-parityerror->Events()<<endl;
     262           0 :           (*fFilcout)<<"  bp "<<parityerror->BusPatch()<<": used events = "<<fNEvents-parityerror->Events()<<endl;
     263             :         }
     264           0 :     }
     265             :   
     266             :   Int_t nADC4090=0;
     267             :   Int_t nADCmax=0;
     268             :   // iterator over pedestal
     269           0 :   TIter next(fPedestalStore ->CreateIterator());
     270             :   AliMUONVCalibParam* ped;
     271             : 
     272           0 :   while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
     273             :     {
     274           0 :       busPatchId              = ped->ID0();
     275           0 :       manuId                  = ped->ID1();
     276           0 :       if(manuId==0)
     277             :         {
     278           0 :           cout << fPrefixLDC.Data() << " : Warning: ManuId = " << manuId << " !!! in  BP = " << busPatchId << endl;
     279           0 :           (*fFilcout) << "Warning: ManuId = " << manuId << " !!! in  BP = " << busPatchId << endl;
     280             :         }
     281             :       Int_t eventCounter;
     282             :       // Correct the number of events for buspatch with errors
     283             :       AliMUONErrorCounter* errorCounter;
     284           0 :       if ((errorCounter = (AliMUONErrorCounter*)fErrorBuspatchTable->FindObject(busPatchId)))
     285             :         {
     286           0 :           eventCounter = fNEvents - errorCounter->Events();
     287           0 :         }
     288             :       else
     289             :         {
     290             :           eventCounter = fNEvents;
     291             :         }
     292             :       Int_t occupancy=0; // channel missing in raw data or read but rejected (case of parity error)
     293             :       // value of (buspatch, manu) occupancy
     294             :       AliMUONErrorCounter* manuCounter;
     295           0 :       manuCounter = static_cast<AliMUONErrorCounter*>(fManuBuspatchTable->FindObject(busPatchId,manuId));
     296           0 :       if(eventCounter>0)occupancy = manuCounter->Events()/64/eventCounter;
     297           0 :       if(occupancy>1)
     298             :         {
     299           0 :           cout << fPrefixLDC.Data() << " : Warning: ManuId = " << manuId << " !!! in  BP = " << busPatchId << " occupancy (>1) = " << occupancy << endl;
     300           0 :           (*fFilcout) << "Warning: ManuId = " << manuId << " !!! in  BP = " << busPatchId << " occupancy (>1) = " << occupancy <<endl;
     301             :         }
     302             : 
     303           0 :       for (channelId = 0; channelId < ped->Size() ; ++channelId) 
     304             :         {
     305           0 :           pedMean  = ped->ValueAsDouble(channelId, 0);
     306             : 
     307           0 :           if (pedMean >= 0) // connected channels
     308             :             {
     309           0 :               ped->SetValueAsDouble(channelId, 0, pedMean/(Double_t)eventCounter);
     310           0 :               pedMean  = ped->ValueAsDouble(channelId, 0);
     311           0 :               pedSigma = ped->ValueAsDouble(channelId, 1);
     312           0 :               ped->SetValueAsDouble(channelId, 1, TMath::Sqrt(TMath::Abs(pedSigma/(Double_t)eventCounter - pedMean*pedMean)));
     313             : 
     314           0 :               if(eventCounter < fNEvthreshold )
     315           0 :                 { nADCmax++; ped->SetValueAsDouble(channelId, 0, ADCMax());
     316           0 :                   ped->SetValueAsDouble(channelId, 1, ADCMax());}
     317           0 :               if( ped->ValueAsDouble(channelId, 1) < pedSigmalimit )
     318           0 :                 { nADC4090++; ped->SetValueAsDouble(channelId, 0, ADCMax()-5);
     319           0 :                   ped->SetValueAsDouble(channelId, 1, ADCMax()-5);}
     320           0 :               if(manuId == 0 || occupancy>1)
     321           0 :                 { nADCmax++; ped->SetValueAsDouble(channelId, 0, ADCMax());
     322           0 :                   ped->SetValueAsDouble(channelId, 1, ADCMax());
     323           0 :                   if(occupancy>1 && channelId==0)ped->SetValueAsDouble(channelId, 0, ADCMax()+occupancy);}
     324             :             }
     325             :           else
     326           0 :             { nADCmax++; ped->SetValueAsDouble(channelId, 0, ADCMax());
     327           0 :               ped->SetValueAsDouble(channelId, 1, ADCMax());}
     328             :         }
     329             :     }
     330             : 
     331             :   float frac1=0. , frac2=0. ;
     332             :   float frac_badped = 0.25 ; // maximal acceptable ratio of bad pedestals
     333             :   char* detail;
     334             :  
     335           0 :   if(fNChannel)
     336             :     {
     337           0 :       if(nADCmax>0)
     338           0 :         { frac1 = float(nADCmax)/float(fNChannel); 
     339           0 :           detail=Form("%s : Warning: Nb of Channels with bad Pedestal (Ped=4095) = %d over %d (%6.2f%)",fPrefixLDC.Data(),nADCmax,fNChannel,frac1*100.);
     340           0 :           printf("%s\n",detail);
     341           0 :           (*fFilcout) <<  detail << endl;}
     342             : 
     343           0 :       if(nADC4090>0)
     344           0 :         { frac2 = 1.*nADC4090/fNChannel; 
     345           0 :           detail=Form("%s : Warning: Nb of Channels with PedSigma<0.5 (Ped=4090) = %d over %d (%6.2f%)",fPrefixLDC.Data(),nADC4090,fNChannel,frac2*100.);
     346           0 :           printf("%s\n",detail);
     347           0 :           (*fFilcout) <<  detail << endl; }
     348             : 
     349           0 :       if (frac1+frac2 > frac_badped) { status=-1 ;
     350           0 :         detail=Form("\n%s !!! ERROR : fraction of Channels with Pedestal>=4090 = %6.2f% (> %5.2f%)  (status= %d) \n",fPrefixLDC.Data(),(frac1+frac2)*100.,frac_badped*100.,status);
     351             :         //2015-02-08    (*fFilcout) <<  detail << endl; printf("%s",detail) ;}
     352           0 :         (*fFilcout) <<  detail << endl; fprintf(stderr,"%s",detail) ;}
     353             :     }
     354             :   else { status= -1;
     355           0 :     detail=Form("\n%s !!! ERROR : Nb good channel = 0 (all pedestals are forced to 4095) !!! (status= %d)\n",fPrefixLDC.Data(),status); 
     356             :     //2015-02-08    cout << detail; 
     357           0 :     (*fFilcout) << detail ; fprintf(stderr,"%s",detail) ; } 
     358             :    
     359           0 :   SetStatusDA(status);
     360           0 : }
     361             : //______________________________________________________________________________
     362             : void AliMUONPedestal::MakeASCIIoutput(ostream& out) const
     363             : {
     364             : /// put pedestal store in the output stream
     365             : 
     366           0 :   out<<"//===========================================================================" << endl;
     367           0 :   out<<"//                 Pedestal file calculated by "<< fPrefixDA.Data() << endl;
     368           0 :   out<<"//===========================================================================" << endl;
     369           0 :   out<<"//     * Run           : " << fRunNumber << endl; 
     370           0 :   out<<"//     * Date          : " << fDate->AsString("l") <<endl;
     371           0 :   out<<"//     * Statictics    : " << fNEvents << endl;
     372           0 :   if(fConfig)
     373           0 :     out<<"//     * Nb of MANUS   : " << fNManuConfig << " read in the Det. config. " << endl;
     374           0 :   out<<"//     * Nb of MANUS   : " << fNManu << " read in raw data " << endl;
     375           0 :   out<<"//     * Nb of MANUS   : " << fNChannel/64 << " written in pedestal file " << endl;
     376           0 :   out<<"//     * Nb of channels: " << fNChannel << endl;
     377           0 :   out<<"//"<<endl;
     378           0 :   out<<"//     * Below " << fNEvthreshold << " events=> Ped.&sig.=4095" << endl;
     379           0 :   out<<"//     * PedSigma < 0.5 => Ped.&sig.=4090" << endl;
     380             : 
     381           0 :   if (fErrorBuspatchTable->GetSize())
     382             :     {
     383           0 :       out<<"//"<<endl;
     384           0 :       out<<"//    * Buspatches with less statistics (due to parity errors)"<<endl;
     385           0 :       TIter next(fErrorBuspatchTable->CreateIterator());
     386             :       AliMUONErrorCounter* parityerror;
     387           0 :       while((parityerror = static_cast<AliMUONErrorCounter*>(next())))
     388             :         {
     389           0 :           if(fNEvents-parityerror->Events()>fNEvthreshold)
     390           0 :             { out<<"//      BusPatch = "<<parityerror->BusPatch()<<"\t Nevents used = "<<fNEvents-parityerror->Events()<<endl; }
     391             :           else
     392           0 :             { out<<"//      BusPatch = "<<parityerror->BusPatch()<<"\t Nevents used = "<<fNEvents-parityerror->Events()<< " (Ped.&sig.=4095)" << endl; }
     393             :         }
     394           0 :     }  
     395             :   Int_t writitle=0;
     396             :   Int_t occupancy=1;
     397           0 :   if(occupancy)
     398             :     {
     399           0 :       TIter next(fPedestalStore ->CreateIterator());
     400             :       AliMUONVCalibParam* ped;
     401           0 :       while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
     402             :         {
     403           0 :           Int_t busPatchId = ped->ID0();
     404           0 :           Int_t manuId = ped->ID1();
     405           0 :           Double_t pedMean  = ped->ValueAsDouble(0, 0); // check pedestal value for channelId=0
     406             : 
     407           0 :           if(pedMean>ADCMax()) 
     408             :             {
     409           0 :               writitle++;
     410           0 :               if(writitle==1){ 
     411           0 :                 out<<"//"<<endl;
     412           0 :                 out<<"//    * Puzzling (Buspatch,Manu) read in raw data ? (Ped.&sig.=4095)"<<endl;}
     413           0 :               occupancy=TMath::Nint(pedMean-ADCMax());
     414           0 :               ped->SetValueAsDouble(0, 0, ADCMax());
     415           0 :               out<<"//      BusPatch = "<< busPatchId <<"\t ManuId =  "<< manuId << "\t occupancy = " << occupancy  << endl;
     416             :             }
     417             : 
     418           0 :           if (manuId==0 || (fConfig && static_cast<AliMUONErrorCounter*>(fManuBPoutofconfigTable->FindObject(busPatchId,manuId))))
     419             :             {
     420           0 :               writitle++;
     421           0 :               if(writitle==1){ 
     422           0 :                 out<<"//"<<endl;
     423           0 :                 out<<"//    * Puzzling (Buspatch,Manu) read in raw data ? (Ped.&sig.=4095)"<<endl;}
     424           0 :               out<<"//      BusPatch = "<< busPatchId <<"\t ManuId =  "<< manuId << "\t missing in the mapping" << endl;
     425             :             }
     426             :         }
     427           0 :     }
     428           0 :   out<<"//"<<endl;
     429           0 :   out<<"//---------------------------------------------------------------------------" << endl;
     430           0 :   out<<"//---------------------------------------------------------------------------" << endl;
     431           0 :   out<<"//      BP     MANU     CH.      MEAN    SIGMA"<<endl;
     432           0 :   out<<"//---------------------------------------------------------------------------" << endl;
     433             : 
     434           0 :   TIter next(fPedestalStore->CreateIterator());
     435             :   AliMUONVCalibParam* ped;  
     436             : 
     437             :   // Sorting 
     438           0 :   if  (fSorting)
     439             :     {
     440           0 :       printf("%s : ..... sorting pedestal values .....\n",fPrefixLDC.Data());
     441           0 :       THashList pedtable(100,2);
     442           0 :       while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
     443             :       {
     444           0 :         pedtable.Add(ped);
     445             :       }
     446           0 :       pedtable.Sort();
     447             :       //      iterator over sorted pedestal
     448           0 :       TIter nextSorted(&pedtable);
     449           0 :       while ( (ped = (AliMUONVCalibParam*)(nextSorted()) ) )
     450             :       {
     451           0 :         Int_t busPatchId = ped->ID0();
     452           0 :         Int_t manuId = ped->ID1();
     453           0 :         for ( Int_t channelId = 0; channelId < ped->Size(); ++channelId ) 
     454             :         {
     455           0 :           Double_t pedMean  = ped->ValueAsDouble(channelId, 0);
     456           0 :           Double_t pedSigma = ped->ValueAsDouble(channelId, 1);
     457           0 :           out << "\t" << busPatchId << "\t" << manuId <<"\t"<< channelId << "\t" << pedMean <<"\t"<< pedSigma << endl;
     458             :         }
     459             :       }
     460           0 :     }
     461             :   else
     462             :     {
     463           0 :       while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
     464             :         {
     465           0 :           Int_t busPatchId = ped->ID0();
     466           0 :           Int_t manuId = ped->ID1();
     467           0 :           for ( Int_t channelId = 0; channelId < ped->Size(); ++channelId ) 
     468             :             {
     469           0 :               Double_t pedMean  = ped->ValueAsDouble(channelId, 0);
     470           0 :               Double_t pedSigma = ped->ValueAsDouble(channelId, 1);
     471           0 :               out << "\t" << busPatchId << "\t" << manuId <<"\t"<< channelId << "\t" << pedMean <<"\t"<< pedSigma << endl;
     472             :             }
     473             :         }
     474             :     }
     475           0 : }
     476             : 
     477             : //______________________________________________________________________________
     478             : void AliMUONPedestal::CreateControlHistos()
     479             : {
     480             : // Create histo 
     481           0 :   fHistoFileName=Form("%s.root",fPrefixDA.Data());
     482           0 :   fHistoFile = new TFile(fHistoFileName,"RECREATE","MUON Tracking pedestals");
     483           0 : }
     484             : //______________________________________________________________________________
     485             : void AliMUONPedestal::MakeControlHistos()
     486             : {
     487             :   /// Create control histograms
     488           0 :   if (fIndex>=0) return; // Pedestal run (fIndex=-1)
     489             : 
     490           0 :   Double_t pedMean;
     491           0 :   Double_t pedSigma;
     492           0 :   Double_t evt;
     493           0 :   Int_t busPatchId;
     494           0 :   Int_t manuId;
     495           0 :   Int_t channelId;
     496           0 :   Int_t DDL;
     497             : 
     498             : // histo
     499             : //  TFile*  histoFile = 0;
     500             :   TTree* tree = 0;
     501             :   TH1F* pedMeanHisto = 0;
     502             :   TH1F* pedSigmaHisto = 0;
     503             :     
     504             :   //  fHistoFileName=Form("%s.root",fPrefixDA.Data());
     505             :   //  histoFile = new TFile(fHistoFileName,"RECREATE","MUON Tracking pedestals");
     506             : 
     507           0 :   Int_t nx = ADCMax()+1;
     508             :   Int_t xmin = 0;
     509           0 :   Int_t xmax = ADCMax(); 
     510           0 :   pedMeanHisto = new TH1F("pedmean_allch","Pedestal mean all channels",nx,xmin,xmax);
     511           0 :   pedMeanHisto->SetDirectory(fHistoFile);
     512             : 
     513             :   nx = 201;
     514             :   xmin = 0;
     515             :   xmax = 200; 
     516           0 :   pedSigmaHisto = new TH1F("pedsigma_allch","Pedestal sigma all channels",nx,xmin,xmax);
     517           0 :   pedSigmaHisto->SetDirectory(fHistoFile);
     518             : 
     519           0 :   tree = new TTree("t","Pedestal tree");
     520           0 :   tree->Branch("DDL",&DDL,",DDL/I");
     521           0 :   tree->Branch("bp",&busPatchId,"bp/I");
     522           0 :   tree->Branch("manu",&manuId,",manu/I");
     523           0 :   tree->Branch("channel",&channelId,",channel/I");
     524           0 :   tree->Branch("pedMean",&pedMean,",pedMean/D");
     525           0 :   tree->Branch("pedSigma",&pedSigma,",pedSigma/D");
     526           0 :   tree->Branch("nevt",&evt,",evt/D");
     527             : 
     528             :   // iterator over pedestal
     529           0 :   TIter next(fPedestalStore ->CreateIterator());
     530             :   AliMUONVCalibParam* ped;
     531             :   AliMUONErrorCounter* manuCounter;
     532             :   
     533           0 :   while ( ( ped = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
     534             :   {
     535           0 :     busPatchId = ped->ID0();
     536           0 :     manuId = ped->ID1();
     537           0 :     DDL= busPatchId/100+2560;
     538             :     
     539           0 :     for ( channelId = 0; channelId < ped->Size(); ++channelId ) 
     540             :     {
     541           0 :       pedMean  = ped->ValueAsDouble(channelId, 0);
     542           0 :       pedSigma = ped->ValueAsDouble(channelId, 1);
     543           0 :       manuCounter = static_cast<AliMUONErrorCounter*>(fManuBuspatchTable->FindObject(busPatchId,manuId));
     544           0 :       evt = manuCounter->Events()/64;
     545             :           
     546           0 :       pedMeanHisto->Fill(pedMean);
     547           0 :       pedSigmaHisto->Fill(pedSigma);
     548           0 :       tree->Fill();  
     549             :     }
     550             :   }
     551             :     
     552           0 :   fHistoFile->Write();  
     553           0 :   fHistoFile->Close(); 
     554             : 
     555           0 : }

Generated by: LCOV version 1.11