ROOT logo
/**************************************************************************
* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
*                                                                        
* Author: The ALICE Off-line Project.                                    * 
* Contributors are mentioned in the code where appropriate.              *
*                                                                        *
* Permission to use, copy, modify and distribute this software and its   *
* documentation strictly for non-commercial purposes is hereby granted   *
* without fee, provided that the above copyright notice appears in all   *
* copies and that both the copyright notice and this permission notice   *
* appear in the supporting documentation. The authors make no claims     *
* about the suitability of this software for any purpose. It is          *
* provided "as is" without express or implied warranty.                  *
**************************************************************************/

// $Id$

#include "AliMUONGain.h"
#include "AliMUONPedestal.h"
#include "AliMUONErrorCounter.h"
#include "AliMUON2DMap.h"
#include "AliMUONVCalibParam.h"
#include "AliMUONVStore.h"
#include "AliMpIntPair.h"

#include <TString.h>
#include <THashList.h>
#include <TTimeStamp.h>
#include <TTree.h>
#include <TFile.h>
#include <TF1.h>
#include <TGraphErrors.h>
#include <TMath.h>
#include <Riostream.h>

#include <sstream>
#include <cstdio>

#define  NFITPARAMS 4

//-----------------------------------------------------------------------------
/// \class AliMUONGain
///
/// Implementation of calibration computing
///
/// add
/// 
///
/// \author Alberto Baldisseri, JL Charvet 
//-----------------------------------------------------------------------------




// functions

namespace {
  
  //______________________________________________________________________________
  Double_t funcLin (const Double_t *x, const Double_t *par)
  {
    /// Linear function
    return par[0] + par[1]*x[0];
  }
  
  //______________________________________________________________________________
  Double_t funcParabolic (const Double_t *x, const Double_t *par)
  {
    /// Parabolic function
    return par[0]*x[0]*x[0];
  }
  
  //______________________________________________________________________________
  Double_t funcCalib (const Double_t *x, const Double_t *par)  
  {
    /// Calibration function
    Double_t xLim= par[3];
    
    if(x[0] <= xLim) return par[0] + par[1]*x[0];
    
    Double_t yLim = par[0]+ par[1]*xLim;
    return yLim + par[1]*(x[0] - xLim) + par[2]*(x[0] - xLim)*(x[0] - xLim);
  }
  
}

using std::endl;
using std::cout;
using std::istringstream;
using std::ostringstream;
/// \cond CLASSIMP
ClassImp(AliMUONGain)
/// \endcond

//______________________________________________________________________________
AliMUONGain::AliMUONGain()
: AliMUONPedestal(),
fInjCharge(0), 
fRootDataFileName(),
fnInit(1),
fnEntries(11),
fnbpf1(6),
fPrintLevel(0), 
fPlotLevel(0)
{
/// Default constructor

}
  
//______________________________________________________________________________
AliMUONGain::~AliMUONGain()
{
/// Destructor
}

//______________________________________________________________________________
TString AliMUONGain::WriteDummyHeader(void) 
{
///

  ostringstream stream;
  stream<<"//DUMMY FILE (to prevent Shuttle failure)"<< endl;
  stream<<"//================================================" << endl;
  stream<<"//       MUONTRKGAINda: Calibration run  " << endl;
  stream<<"//================================================" << endl;
  stream<<"//   * Run           : " << fRunNumber << endl; 
  stream<<"//   * Date          : " << fDate->AsString("l") <<endl;
  stream<<"//   * DAC           : " << fInjCharge << endl;
  stream<<"//-------------------------------------------------" << endl;

  return TString(stream.str().c_str());
}

//______________________________________________________________________________
void AliMUONGain::MakePedStoreForGain(TString shuttleFile)
{
/// Store Pedmean and sigma to pedestal-like ascii file

  ofstream fileout;
  TString tempstring;
  TString flatFile;
  TString outputFile;
  
  // Store pedestal map in root file
  TTree* tree = 0x0;

  // write dummy ascii file -> Shuttle
  if(fIndex<fnEntries)
    {  
      FILE *pfilew=0;
      pfilew = fopen (shuttleFile,"w");

      fprintf(pfilew,"//DUMMY FILE (to prevent Shuttle failure)\n");
      fprintf(pfilew,"//================================================\n");
      fprintf(pfilew,"//       MUONTRKGAINda: Calibration run  \n");
      fprintf(pfilew,"//=================================================\n");
      fprintf(pfilew,"//   * Run           : %d \n",fRunNumber); 
      fprintf(pfilew,"//   * Date          : %s \n",fDate->AsString("l"));
      fprintf(pfilew,"//   * DAC           : %d \n",fInjCharge);
      fprintf(pfilew,"//-------------------------------------------------\n");
      fclose(pfilew);
    }



  Finalize();
  MakeControlHistos();
  if(fPrintLevel>0)
    {
      // compute and store mean DAC values (like pedestals)
      flatFile = Form("%s.ped",fPrefixDA.Data());
      outputFile=flatFile;
      cout << "\n" << fPrefixLDC.Data() << " : Flat file  generated  : " << flatFile.Data() << "\n";
      if (!outputFile.IsNull())  
      {
        ofstream out(outputFile.Data());
	MakeASCIIoutput(out);
	out.close();
      }      
    }

  TString mode("UPDATE");

  if (fIndex==1) {
    mode = "RECREATE";
  }
  TFile* histoFile = new TFile(fRootDataFileName.Data(), mode.Data(), "MUON Tracking Gains");

  // second argument should be the injected charge, taken from config crocus file
  // put also info about run number could be usefull
  AliMpIntPair* pair   = new AliMpIntPair(fRunNumber,fInjCharge );

  if (mode.CompareTo("UPDATE") == 0) {
    tree = (TTree*)histoFile->Get("t");
    tree->SetBranchAddress("run",&pair);
    tree->SetBranchAddress("ped",&fPedestalStore);

  } else {
    tree = new TTree("t","Pedestal tree");
    tree->Branch("run", "AliMpIntPair",&pair);
    tree->Branch("ped", "AliMUON2DMap",&fPedestalStore);
    tree->SetBranchAddress("run",&pair);
    tree->SetBranchAddress("ped",&fPedestalStore);

  }

  tree->Fill();
  tree->Write("t", TObject::kOverwrite); // overwrite the tree
  histoFile->Close();

  delete pair;
}

//______________________________________________________________________________
TString AliMUONGain::WriteGainHeader(Int_t nInit, Int_t nEntries, Int_t nbpf2, Int_t *numrun, Double_t *injCharge) 
{
/// Header of the calibration output file

  ostringstream stream;


  stream<<"//=======================================================" << endl;
  stream<<"//      Calibration file calculated by " << fPrefixDA.Data() <<endl;
  stream<<"//=======================================================" << endl;
  stream<<"//   * Run           : " << fRunNumber << endl; 
  stream<<"//   * Date          : " << fDate->AsString("l") <<endl;
  stream<<"//   * Statictics    : " << fNEvents << endl;
  if(fConfig)
  stream<<"//   * # of MANUS    : " << fNManuConfig << " read in the Det. config. " << endl;
  stream<<"//   * # of MANUS    : " << fNManu << " read in raw data " << endl;
  stream<<"//   * # of MANUS    : " << fNChannel/64 << " written in calibration file " << endl;
  stream<<"//   * # of channels : " << fNChannel << endl;
  stream<<"//-------------------------------------------------------" << endl;

  if(nInit==0)
    stream<<"//  "<< nEntries <<" DAC values  fit: "<< fnbpf1 << " pts (1st order) " << nbpf2 << " pts (2nd order)" << endl;
  if(nInit==1)
    stream<<"//  "<< nEntries <<" DAC values  fit: "<< fnbpf1 << " pts (1st order) " << nbpf2 << " pts (2nd order) DAC=0 excluded" << endl;
  stream<<"//   *  nInit = " << nInit << "  *  f1nbp = " << fnbpf1 << "  *  f2nbp = " <<  nbpf2 << endl; 

  stream<<"//   RUN     DAC   " << endl;
  stream<<"//-----------------" << endl;
  for (Int_t i = 0; i < nEntries; ++i) {
 	stream<<Form("//   %d    %5.0f \n",numrun[i],injCharge[i]);
  }
  stream<<"//=======================================" << endl;
  stream<<"// BP MANU CH.   a1      a2     thres. q " << endl;
  stream<<"//=======================================" << endl;

  return TString(stream.str().c_str());
}

//______________________________________________________________________________
TString AliMUONGain::WriteGainData(Int_t BP, Int_t Manu, Int_t ch, Double_t p1, Double_t p2, Int_t threshold, Int_t q) 
{
/// Write calibration parameters per channel

  ostringstream stream("");
  stream << Form("%4i %5i %2i %7.4f %10.3e %4i %2x\n",BP,Manu,ch,p1,p2,threshold,q);
  return TString(stream.str().c_str());

}

//_______________________________________________________________________________
void AliMUONGain::MakeGainStore(TString shuttleFile)
{
  Int_t status=0;
  /// Store gains in ASCII files
  ofstream fileout;
  ofstream filcouc;
  TString tempstring;	
  TString filename; 
  char* detail;

  Double_t goodA1Min =  0.5;
  Double_t goodA1Max =  2.;
//   Double_t goodA2Min = -0.5E-03;
//   Double_t goodA2Max =  1.E-03;
  Double_t goodA2Min = -0.5E-01; // changed 28/10/2009 (JLC) <=> enlarged condition on a2
  Double_t goodA2Max =  1.E-01;
  // Table for uncalibrated  buspatches and manus
  THashList* uncalBuspatchManuTable = new THashList(1000,2);

  Int_t numrun[11];

  // open file MUONTRKda_gain_data.root
  // read again the pedestal for the calibration runs (11 runs)
  // need the injection charge from config file (to be done)
  // For each channel make a TGraphErrors (mean, sigma) vs injected charge
  // Fit with a polynomial fct
  // store the result in a flat file.

  if(fIndex==0)cout << " Root data file = " << fRootDataFileName.Data() << endl;  
  TFile*  histoFile = new TFile(fRootDataFileName.Data());

  AliMUON2DMap* map[11];
  AliMUONVCalibParam* ped[11];
  AliMpIntPair* run[11];

  //read back from root file
  TTree* tree = (TTree*)histoFile->Get("t");
  Int_t nEntries = tree->GetEntries();

  Int_t nbpf2 = nEntries - (fnInit + fnbpf1) + 1; // nb pts used for 2nd order fit

  // read back info
  for (Int_t i = 0; i < nEntries; ++i) {
    map[i] = 0x0;
    run[i] = 0x0;
    tree->SetBranchAddress("ped",&map[i]);
    tree->SetBranchAddress("run",&run[i]);
    tree->GetEvent(i);
    //        std::cout << map[i] << " " << run[i] << std::endl;
  }
  // RunNumber extracted from Root data fil
  if(fIndex==0)fRunNumber=(UInt_t)run[nEntries-1]->GetFirst();
  //     sscanf(getenv("DATE_RUN_NUMBER"),"%d",&gAliRunNumber);

  Double_t pedMean[11];
  Double_t pedSigma[11];
  for ( Int_t i=0 ; i<11 ; i++) {pedMean[i]=0.;pedSigma[i]=1.;};
  Double_t injCharge[11];
  Double_t injChargeErr[11];
  for ( Int_t i=0 ; i<11 ; i++) {injCharge[i]=0.;injChargeErr[i]=1.;};

  //  print out in .log file
  detail=Form("\n%s : ------  MUONTRKGAINda for Gain computing (Last Run = %d) ------\n",fPrefixLDC.Data(),fRunNumber); printf("%s",detail);
  (*fFilcout)<<"\n\n//=================================================" << endl;
  (*fFilcout)<<"//    MUONTRKGAINda: Gain Computing  Run = " << fRunNumber << endl;
  (*fFilcout)<<"//    RootDataFile  = "<< fRootDataFileName.Data() << endl;
  (*fFilcout)<<"//=================================================" << endl;
  (*fFilcout)<<"//* Date          : " << fDate->AsString("l") << "\n" << endl;

  (*fFilcout) << " Entries = " << nEntries << " DAC values \n" << endl; 
  for (Int_t i = 0; i < nEntries; ++i) {
    (*fFilcout) << " Run = " << run[i]->GetFirst() << "    DAC = " << run[i]->GetSecond() << endl;
    numrun[i] = run[i]->GetFirst();
    injCharge[i] = run[i]->GetSecond();
    injChargeErr[i] = 0.01*injCharge[i];
    if(injChargeErr[i] <= 1.) injChargeErr[i]=1.;
  }
  detail=Form("%s : .... Fitting .... \n",fPrefixLDC.Data()); printf("%s",detail);


  // why 2 files ? (Ch. F.)  => second file contains detailed results
    FILE *pfilen = 0;
    if(fPrintLevel>1)
      {
        filename=Form("%s.param",fPrefixDA.Data());
	detail=Form("%s : Second fit parameter file        = %s\n",fPrefixLDC.Data(),filename.Data()); printf("%s",detail);
	//       cout << " Second fit parameter file        = " << filename.Data() << "\n";
        pfilen = fopen (filename.Data(),"w");

        fprintf(pfilen,"//===================================================================\n");
        fprintf(pfilen,"//  BP MANU CH. par[0]     [1]     [2]     [3]      xlim          P(chi2) p1        P(chi2)2  p2\n");
        fprintf(pfilen,"//===================================================================\n");
        fprintf(pfilen,"//   * Run           : %d \n",fRunNumber); 
        fprintf(pfilen,"//===================================================================\n");
      }


  // file outputs for gain

  ofstream pfilew;
  pfilew.open(shuttleFile.Data());
  // Write Header Data of the .par file
  pfilew << WriteGainHeader(fnInit,nEntries,nbpf2,numrun,injCharge);

  // print mean and sigma values in file
  FILE *pfilep = 0;
  if(fPrintLevel>1)
    {
      filename=Form("%s.peak",fPrefixDA.Data());
      detail=Form("%s : File containing Peak mean values = %s\n",fPrefixLDC.Data(),filename.Data()); printf("%s",detail);
      //      cout << " File containing Peak mean values = " << filename << "\n";
      pfilep = fopen (filename,"w");

      fprintf(pfilep,"//==============================================================================================================================\n");
      fprintf(pfilep,"//   * Run           : %d \n",fRunNumber); 
      fprintf(pfilep,"//==============================================================================================================================\n");
      fprintf(pfilep,"// BP  MANU  CH.    Ped.     <0>      <1>      <2>      <3>      <4>      <5>      <6>      <7>      <8>      <9>     <10> \n"); 
      fprintf(pfilep,"//==============================================================================================================================\n");
      fprintf(pfilep,"//                 DAC= %9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f  fC\n",injCharge[0],injCharge[1],injCharge[2],injCharge[3],injCharge[4],injCharge[5],injCharge[6],injCharge[7],injCharge[8],injCharge[9],injCharge[10]);
      fprintf(pfilep,"//                      %9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f\n",injChargeErr[0],injChargeErr[1],injChargeErr[2],injChargeErr[3],injChargeErr[4],injChargeErr[5],injChargeErr[6],injChargeErr[7],injChargeErr[8],injChargeErr[9],injChargeErr[10]);
      fprintf(pfilep,"//==============================================================================================================================\n");
    }

  Double_t chi2    = 0.;
  Double_t chi2P2  = 0.;
  Double_t prChi2  = 0; 
  Double_t prChi2P2 =0;
  Double_t a0=0.,a1=1.,a2=0.;
  Int_t busPatchId ;
  Int_t manuId     ;
  Int_t channelId ;
  Int_t threshold = 0;
  Int_t q = 0;
  Int_t p1 =0;
  Int_t p2 =0;
  Double_t gain=10.; // max value (= bad value)
  Double_t capa=0.2; // internal capacitor (pF)

  //  plot out 

  TTree* tg = 0x0;
  if(fPlotLevel>0)
    {
      fHistoFileName=Form("%s.root",fPrefixDA.Data());
      new TFile(fHistoFileName.Data(),"RECREATE","MUON Tracking gains");
      tg = new TTree("tg","TTree avec class Manu_DiMu");

      tg->Branch("bp",&busPatchId, "busPatchId/I");
      tg->Branch("manu",&manuId, "manuId/I");
      tg->Branch("channel",&channelId, "channelId/I");

      tg->Branch("a0",&a0, "a0/D");
      tg->Branch("a1",&a1, "a1/D");
      tg->Branch("a2",&a2, "a2/D");
      tg->Branch("Pchi2",&prChi2, "prChi2/D");
      tg->Branch("Pchi2_2",&prChi2P2, "prChi2P2/D");
      tg->Branch("Threshold",&threshold, "threshold/I");
      tg->Branch("q",&q, "q/I");
      tg->Branch("p1",&p1, "p1/I");
      tg->Branch("p2",&p2, "p2/I");
      tg->Branch("gain",&gain, "gain/D");
    }

  char graphName[256];

  // iterates over the first pedestal run
  TIter next(map[0]->CreateIterator());
  AliMUONVCalibParam* p;

  Int_t    nmanu         = 0;
  Int_t    nGoodChannel   = 0;
  Int_t    nBadChannel   = 0;
  Int_t    noFitChannel   = 0;
  Int_t    nplot=0;
  Double_t sumProbChi2   = 0.;
  Double_t sumA1         = 0.;
  Double_t sumProbChi2P2 = 0.;
  Double_t sumA2         = 0.;

  Double_t x[11], xErr[11], y[11], yErr[11];
  Double_t xp[11], xpErr[11], yp[11], ypErr[11];

  Int_t uncalcountertotal=0 ;
  Int_t unparabolicfit=0;

  while ( ( p = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
    {
      ped[0]  = p;
      unparabolicfit=0;

      busPatchId = p->ID0();
      manuId     = p->ID1();

      // read back pedestal from the other runs for the given (bupatch, manu)
      for (Int_t i = 1; i < nEntries; ++i) {
	ped[i] = static_cast<AliMUONVCalibParam*>(map[i]->FindObject(busPatchId, manuId));
      }

      // compute for each channel the gain parameters
      for ( channelId = 0; channelId < ped[0]->Size() ; ++channelId ) 
	{

	  Int_t n = 0;
	  for (Int_t i = 0; i < nEntries; ++i) {

	    if (!ped[i]) continue; //shouldn't happen.
	    pedMean[i]      = ped[i]->ValueAsDouble(channelId, 0);
	    pedSigma[i]     = ped[i]->ValueAsDouble(channelId, 1);

	    if (pedMean[i] < 0) continue; // not connected

	    if (pedSigma[i] <= 0) pedSigma[i] = 1.; // should not happen.
	    n++;
	  }

	  // print_peak_mean_values
	  if(fPrintLevel>1)
	    {

	      fprintf(pfilep,"%4i%5i%5i%10.3f",busPatchId,manuId,channelId,0.);
	      fprintf(pfilep,"%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f%9.1f \n",pedMean[0],pedMean[1],pedMean[2],pedMean[3],pedMean[4],pedMean[5],pedMean[6],pedMean[7],pedMean[8],pedMean[9],pedMean[10]);
	      fprintf(pfilep,"                   sig= %9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f \n",pedSigma[0],pedSigma[1],pedSigma[2],pedSigma[3],pedSigma[4],pedSigma[5],pedSigma[6],pedSigma[7],pedSigma[8],pedSigma[9],pedSigma[10]);
	    }

	  // makegain
	  // Fit Method:  Linear fit over gAlinbpf1 points + parabolic fit  over nbpf2  points) 
	  // nInit=1 : 1st pt DAC=0 excluded

	  // 1. - linear fit over gAlinbpf1 points

	  Double_t par[4] = {0.,0.5,0.,static_cast<Double_t>(ADCMax())};
	  Int_t nbs   = nEntries - fnInit;
	  if(nbs < fnbpf1)fnbpf1=nbs;

	  Int_t fitproceed=1;
	  Int_t nbpf2Dynamic=nbpf2;
	  Int_t adcLimit=4090; // when RMS < 0.5 (in other cases mean values forced to 4095, see DA_PED)
	  for (Int_t j = 0; j < nbs; ++j)
	    {
	      Int_t k = j + fnInit;
	      x[j]    = pedMean[k];
	      if(x[j]<=0.){fitproceed=0; break;}
	      //	      if(x[j]>= ADCMax())
	      if(x[j]>= adcLimit)
		{
		  if(j < nbs-1){fitproceed=0; break;}
		  else { nbpf2Dynamic=nbpf2-1; break;}
		}
	      xErr[j] = pedSigma[k];
	      y[j]    = injCharge[k];
	      yErr[j] = injChargeErr[k];

	    }

	  TGraphErrors *graphErr;
	  if(!fitproceed) { p1=0; p2=0; noFitChannel++;}

	  if(fitproceed)
	    {
		      
	      TF1 *f1 = new TF1("f1",funcLin,0.,ADCMax(),2);
	      graphErr = new TGraphErrors(fnbpf1, x, y, xErr, yErr);

	      f1->SetParameters(0,0);

	      graphErr->Fit("f1","RQ");

	      chi2 = f1->GetChisquare();
	      f1->GetParameters(par);

	      delete graphErr;
	      graphErr=0;
	      delete f1;

	      prChi2 = TMath::Prob(chi2, fnbpf1 - 2);

	      Double_t xLim = pedMean[fnInit + fnbpf1 - 1];
	      Double_t yLim = par[0]+par[1] * xLim;

	      a0 = par[0];
	      a1 = par[1];

	      // 2. - Translation : new origin (xLim, yLim) + parabolic fit over nbf2 points
	      //checking:         if(busPatchId ==1841 && manuId==4)nbpf2Dynamic=2;
	      if(nbpf2Dynamic > 2)
		{
		  for (Int_t j = 0; j < nbpf2Dynamic; j++)
		    {
		      Int_t k  = j + (fnInit + fnbpf1) - 1;
		      xp[j]    = pedMean[k] - xLim;
		      xpErr[j] = pedSigma[k];

		      yp[j]    = injCharge[k] - yLim - par[1]*xp[j];
		      ypErr[j] = injChargeErr[k];
		    }

		  TF1 *f2 = new TF1("f2",funcParabolic,0.,ADCMax(),1);
		  graphErr = new TGraphErrors(nbpf2Dynamic, xp, yp, xpErr, ypErr);

		  graphErr->Fit(f2,"RQ");
		  chi2P2 = f2->GetChisquare();
		  f2->GetParameters(par);

		  delete graphErr;
		  graphErr=0;
		  delete f2;

		  prChi2P2 = TMath::Prob(chi2P2, nbpf2Dynamic-1);
		  a2 = par[0];
		}
	      else 
		{ 
		  unparabolicfit++;
		  (*fFilcout) << " Warning : BP = " << busPatchId << " Manu = " << manuId <<  " Channel = " << channelId <<": parabolic fit not possible (nbpf2=" <<  nbpf2Dynamic  << ") => a2=0 and linear fit OK" << std::endl;
		  if(unparabolicfit==1) std::cout << " Warning : BP = " << busPatchId << " Manu = " << manuId <<  ": no parabolic fit for some channels (nbpf2=" <<  nbpf2Dynamic  << "), linear fit is OK (see .log for details)" << std::endl;
		  a2=0. ; prChi2P2=0. ;
		}

	      par[0] = a0;
	      par[1] = a1;
	      par[2] = a2;
	      par[3] = xLim;

	      if(prChi2>0.999999)prChi2=0.999999 ; if(prChi2P2>0.999999)prChi2P2=0.9999999; // avoiding Pr(Chi2)=1 value
	      p1 = TMath::Nint(floor(prChi2*15))+1;    // round down value : floor(2.8)=2.
	      p2 = TMath::Nint(floor(prChi2P2*15))+1;
	      q  = p1*16 + p2;  // fit quality 

	      Double_t x0 = -par[0]/par[1]; // value of x corresponding to à 0 fC 
	      threshold = TMath::Nint(ceil(par[3]-x0)); // linear if x < threshold

	      if(fPrintLevel>1)
		{
		  fprintf(pfilen,"%4i %4i %2i",busPatchId,manuId,channelId);
		  fprintf(pfilen," %6.2f %6.4f %10.3e %4.2f %4i          %8.6f %8.6f   %x          %8.6f  %8.6f   %x\n",
			  par[0], par[1], par[2], par[3], threshold, prChi2, floor(prChi2*15), p1,  prChi2P2, floor(prChi2P2*15),p2);
		}


	      // tests
	      if(par[1]< goodA1Min ||  par[1]> goodA1Max) p1=0;
	      if(par[2]< goodA2Min ||  par[2]> goodA2Max) p2=0;

	    } // fitproceed

	  if(fitproceed && p1>0 && p2>0) 
	    {
	      nGoodChannel++;
	      sumProbChi2   += prChi2;
	      sumA1         += par[1];
	      sumProbChi2P2   += prChi2P2;
	      sumA2         += par[2];
	    }
	  else // bad calibration
	    {
	      nBadChannel++;
	      q=0;  
	      par[1]=0.5; a1=0.5; p1=0;
	      par[2]=0.;  a2=0.;  p2=0;
	      threshold=ADCMax();	

	      // bad calibration counter
	      char bpmanuname[256];
	      AliMUONErrorCounter* uncalcounter;

	      snprintf(bpmanuname,256,"bp%dmanu%d",busPatchId,manuId);
	      if (!(uncalcounter = (AliMUONErrorCounter*)uncalBuspatchManuTable->FindObject(bpmanuname)))
		{
		  // New buspatch_manu name
		  uncalcounter= new AliMUONErrorCounter (busPatchId,manuId);
		  uncalcounter->SetName(bpmanuname);
		  uncalBuspatchManuTable->Add(uncalcounter);
		}
	      else
		{
		  // Existing buspatch_manu name
		  uncalcounter->Increment();
		}
	      //			    uncalcounter->Print_uncal()
	      uncalcountertotal ++;
	    }
	  gain=1./(par[1]*capa); // mv/fC

	  if(fPlotLevel>0)
	    {if(fPlotLevel>1)
		{
		  //		      if(q==0  and  nplot < 100)
		  // 	  if(p1>1 && p2==0  and  nplot < 100)
		  //		  	    if(p1>10 && p2>10  and  nplot < 100)
		  //	if(p1>=1 and p1<=2  and  nplot < 100)
//		  if((p1==1 || p2==1) and  nplot < 100)
		  	    if(nbpf2Dynamic<nbpf2  and  nplot < 100)
		    {
		      nplot++;
		      // 	      cout << " nplot = " << nplot << endl;
		      TF1 *f2Calib = new TF1("f2Calib",funcCalib,0.,ADCMax(),NFITPARAMS);

		      graphErr = new TGraphErrors(nEntries,pedMean,injCharge,pedSigma,injChargeErr);

		      snprintf(graphName,256,"BusPatch_%d_Manu_%d_Ch_%d",busPatchId, manuId,channelId);

		      graphErr->SetTitle(graphName);
		      graphErr->SetMarkerColor(3);
		      graphErr->SetMarkerStyle(12);
		      graphErr->Write(graphName);

		      snprintf(graphName,256,"f2_BusPatch_%d_Manu_%d_Ch_%d",busPatchId, manuId,channelId);
		      f2Calib->SetTitle(graphName);
		      f2Calib->SetLineColor(4);
		      f2Calib->SetParameters(par);
		      f2Calib->Write(graphName);

		      delete graphErr;
		      graphErr=0;
		      delete f2Calib;
		    }
		}
	      tg->Fill();
	    }
	  pfilew << WriteGainData(busPatchId,manuId,channelId,par[1],par[2],threshold,q);
	}
      nmanu++;
      Int_t step=500;
      if(nmanu % step == 0)printf("%s : Nb manu = %d\n",fPrefixLDC.Data(),nmanu);
    }

  //      print in logfile
  if (uncalBuspatchManuTable->GetSize())
    {
      uncalBuspatchManuTable->Sort();  // use compare
      TIterator* iter = uncalBuspatchManuTable->MakeIterator();
      AliMUONErrorCounter* uncalcounter;
      (*fFilcout) << "\n List of problematic BusPatch and Manu " << endl;
      (*fFilcout) << " ========================================" << endl;
      (*fFilcout) << "        BP       Manu        Nb Channel  " << endl ;
      (*fFilcout) << " ========================================" << endl;
      while((uncalcounter = (AliMUONErrorCounter*) iter->Next()))
	{
	  (*fFilcout) << "\t" << uncalcounter->BusPatch() << "\t " << uncalcounter->ManuId() << "\t\t"   << uncalcounter->Events() << endl;
	}
      (*fFilcout) << " ========================================" << endl;

      (*fFilcout) << " Number of bad calibrated Manu    = " << uncalBuspatchManuTable->GetSize() << endl ;
      (*fFilcout) << " Number of bad calibrated channel = " << uncalcountertotal << endl;
	
    }
  if(nmanu && nGoodChannel) 
    {
      Double_t ratio_limit=0.25;
      Double_t ratio=float (nBadChannel)/float (nmanu*64);

      detail=Form("\n%s : Nb of channels in raw data = %d (%d Manu)",fPrefixLDC.Data(),nmanu*64,nmanu); 
      (*fFilcout) << detail ; printf("%s",detail);
      detail=Form("\n%s : Nb of calibrated channel   = %d  (%4.2f <a1< %4.2f and %4.2f <a2< %4.2f)",fPrefixLDC.Data(),nGoodChannel,goodA1Min,goodA1Max, goodA2Min,goodA2Max);
      (*fFilcout) << detail ; printf("%s",detail);
      detail=Form("\n%s : Nb of uncalibrated channel = %d  [%6.4f] (%d unfitted channels) ",fPrefixLDC.Data(),nBadChannel,ratio,noFitChannel);
      (*fFilcout) << detail ; printf("%s",detail);

      if(ratio > ratio_limit) { status=-1;
      	detail=Form("\n%s : !!!!! WARNING : Nb of uncalibrated channels very large : %6.4f > %6.4f (status= %d) ",fPrefixLDC.Data(),ratio,ratio_limit,status);
      	(*fFilcout) << detail ; printf("%s",detail); 
      }

      Double_t meanA1         = sumA1/(nGoodChannel);
      Double_t meanProbChi2   = sumProbChi2/(nGoodChannel);
      Double_t meanA2         = sumA2/(nGoodChannel);
      Double_t meanProbChi2P2 = sumProbChi2P2/(nGoodChannel);
      Double_t capaManu = 0.2; // pF
      (*fFilcout) << "\n linear fit   : <a1> = " << meanA1 << "     Prob(chi2)>  = " <<  meanProbChi2 <<  "    <gain>  = " <<  1./(meanA1*capaManu) 
		  << " mV/fC (capa= " << capaManu << " pF)" << endl;
      (*fFilcout)   <<" parabolic fit: <a2> = " << meanA2  << "    Prob(chi2)>  = " <<  meanProbChi2P2 << "\n" <<  endl;
 
      detail=Form("\n%s : <gain>  = %7.5f  mV/fC (capa= %3.1f pF)  Prob(chi2) = %5.3f\n" ,fPrefixLDC.Data(),1./(meanA1*capaManu),capaManu,meanProbChi2);
      printf("%s",detail);
    }
  else 
    { status=-1;
      detail=Form("\n%s : !!!!! ERROR :  Nb of Manu = %d or Nb calibrated channel = %d !!!!! (status= %d)\n",fPrefixLDC.Data(),nmanu,nGoodChannel,status);
      (*fFilcout) << detail ; printf("%s",detail);
    }
  pfilew.close();

  if(fPlotLevel>0){tg->Write();histoFile->Close();}
  if(fPrintLevel>1){fclose(pfilep); fclose(pfilen);}
  SetStatusDA(status);
}
 AliMUONGain.cxx:1
 AliMUONGain.cxx:2
 AliMUONGain.cxx:3
 AliMUONGain.cxx:4
 AliMUONGain.cxx:5
 AliMUONGain.cxx:6
 AliMUONGain.cxx:7
 AliMUONGain.cxx:8
 AliMUONGain.cxx:9
 AliMUONGain.cxx:10
 AliMUONGain.cxx:11
 AliMUONGain.cxx:12
 AliMUONGain.cxx:13
 AliMUONGain.cxx:14
 AliMUONGain.cxx:15
 AliMUONGain.cxx:16
 AliMUONGain.cxx:17
 AliMUONGain.cxx:18
 AliMUONGain.cxx:19
 AliMUONGain.cxx:20
 AliMUONGain.cxx:21
 AliMUONGain.cxx:22
 AliMUONGain.cxx:23
 AliMUONGain.cxx:24
 AliMUONGain.cxx:25
 AliMUONGain.cxx:26
 AliMUONGain.cxx:27
 AliMUONGain.cxx:28
 AliMUONGain.cxx:29
 AliMUONGain.cxx:30
 AliMUONGain.cxx:31
 AliMUONGain.cxx:32
 AliMUONGain.cxx:33
 AliMUONGain.cxx:34
 AliMUONGain.cxx:35
 AliMUONGain.cxx:36
 AliMUONGain.cxx:37
 AliMUONGain.cxx:38
 AliMUONGain.cxx:39
 AliMUONGain.cxx:40
 AliMUONGain.cxx:41
 AliMUONGain.cxx:42
 AliMUONGain.cxx:43
 AliMUONGain.cxx:44
 AliMUONGain.cxx:45
 AliMUONGain.cxx:46
 AliMUONGain.cxx:47
 AliMUONGain.cxx:48
 AliMUONGain.cxx:49
 AliMUONGain.cxx:50
 AliMUONGain.cxx:51
 AliMUONGain.cxx:52
 AliMUONGain.cxx:53
 AliMUONGain.cxx:54
 AliMUONGain.cxx:55
 AliMUONGain.cxx:56
 AliMUONGain.cxx:57
 AliMUONGain.cxx:58
 AliMUONGain.cxx:59
 AliMUONGain.cxx:60
 AliMUONGain.cxx:61
 AliMUONGain.cxx:62
 AliMUONGain.cxx:63
 AliMUONGain.cxx:64
 AliMUONGain.cxx:65
 AliMUONGain.cxx:66
 AliMUONGain.cxx:67
 AliMUONGain.cxx:68
 AliMUONGain.cxx:69
 AliMUONGain.cxx:70
 AliMUONGain.cxx:71
 AliMUONGain.cxx:72
 AliMUONGain.cxx:73
 AliMUONGain.cxx:74
 AliMUONGain.cxx:75
 AliMUONGain.cxx:76
 AliMUONGain.cxx:77
 AliMUONGain.cxx:78
 AliMUONGain.cxx:79
 AliMUONGain.cxx:80
 AliMUONGain.cxx:81
 AliMUONGain.cxx:82
 AliMUONGain.cxx:83
 AliMUONGain.cxx:84
 AliMUONGain.cxx:85
 AliMUONGain.cxx:86
 AliMUONGain.cxx:87
 AliMUONGain.cxx:88
 AliMUONGain.cxx:89
 AliMUONGain.cxx:90
 AliMUONGain.cxx:91
 AliMUONGain.cxx:92
 AliMUONGain.cxx:93
 AliMUONGain.cxx:94
 AliMUONGain.cxx:95
 AliMUONGain.cxx:96
 AliMUONGain.cxx:97
 AliMUONGain.cxx:98
 AliMUONGain.cxx:99
 AliMUONGain.cxx:100
 AliMUONGain.cxx:101
 AliMUONGain.cxx:102
 AliMUONGain.cxx:103
 AliMUONGain.cxx:104
 AliMUONGain.cxx:105
 AliMUONGain.cxx:106
 AliMUONGain.cxx:107
 AliMUONGain.cxx:108
 AliMUONGain.cxx:109
 AliMUONGain.cxx:110
 AliMUONGain.cxx:111
 AliMUONGain.cxx:112
 AliMUONGain.cxx:113
 AliMUONGain.cxx:114
 AliMUONGain.cxx:115
 AliMUONGain.cxx:116
 AliMUONGain.cxx:117
 AliMUONGain.cxx:118
 AliMUONGain.cxx:119
 AliMUONGain.cxx:120
 AliMUONGain.cxx:121
 AliMUONGain.cxx:122
 AliMUONGain.cxx:123
 AliMUONGain.cxx:124
 AliMUONGain.cxx:125
 AliMUONGain.cxx:126
 AliMUONGain.cxx:127
 AliMUONGain.cxx:128
 AliMUONGain.cxx:129
 AliMUONGain.cxx:130
 AliMUONGain.cxx:131
 AliMUONGain.cxx:132
 AliMUONGain.cxx:133
 AliMUONGain.cxx:134
 AliMUONGain.cxx:135
 AliMUONGain.cxx:136
 AliMUONGain.cxx:137
 AliMUONGain.cxx:138
 AliMUONGain.cxx:139
 AliMUONGain.cxx:140
 AliMUONGain.cxx:141
 AliMUONGain.cxx:142
 AliMUONGain.cxx:143
 AliMUONGain.cxx:144
 AliMUONGain.cxx:145
 AliMUONGain.cxx:146
 AliMUONGain.cxx:147
 AliMUONGain.cxx:148
 AliMUONGain.cxx:149
 AliMUONGain.cxx:150
 AliMUONGain.cxx:151
 AliMUONGain.cxx:152
 AliMUONGain.cxx:153
 AliMUONGain.cxx:154
 AliMUONGain.cxx:155
 AliMUONGain.cxx:156
 AliMUONGain.cxx:157
 AliMUONGain.cxx:158
 AliMUONGain.cxx:159
 AliMUONGain.cxx:160
 AliMUONGain.cxx:161
 AliMUONGain.cxx:162
 AliMUONGain.cxx:163
 AliMUONGain.cxx:164
 AliMUONGain.cxx:165
 AliMUONGain.cxx:166
 AliMUONGain.cxx:167
 AliMUONGain.cxx:168
 AliMUONGain.cxx:169
 AliMUONGain.cxx:170
 AliMUONGain.cxx:171
 AliMUONGain.cxx:172
 AliMUONGain.cxx:173
 AliMUONGain.cxx:174
 AliMUONGain.cxx:175
 AliMUONGain.cxx:176
 AliMUONGain.cxx:177
 AliMUONGain.cxx:178
 AliMUONGain.cxx:179
 AliMUONGain.cxx:180
 AliMUONGain.cxx:181
 AliMUONGain.cxx:182
 AliMUONGain.cxx:183
 AliMUONGain.cxx:184
 AliMUONGain.cxx:185
 AliMUONGain.cxx:186
 AliMUONGain.cxx:187
 AliMUONGain.cxx:188
 AliMUONGain.cxx:189
 AliMUONGain.cxx:190
 AliMUONGain.cxx:191
 AliMUONGain.cxx:192
 AliMUONGain.cxx:193
 AliMUONGain.cxx:194
 AliMUONGain.cxx:195
 AliMUONGain.cxx:196
 AliMUONGain.cxx:197
 AliMUONGain.cxx:198
 AliMUONGain.cxx:199
 AliMUONGain.cxx:200
 AliMUONGain.cxx:201
 AliMUONGain.cxx:202
 AliMUONGain.cxx:203
 AliMUONGain.cxx:204
 AliMUONGain.cxx:205
 AliMUONGain.cxx:206
 AliMUONGain.cxx:207
 AliMUONGain.cxx:208
 AliMUONGain.cxx:209
 AliMUONGain.cxx:210
 AliMUONGain.cxx:211
 AliMUONGain.cxx:212
 AliMUONGain.cxx:213
 AliMUONGain.cxx:214
 AliMUONGain.cxx:215
 AliMUONGain.cxx:216
 AliMUONGain.cxx:217
 AliMUONGain.cxx:218
 AliMUONGain.cxx:219
 AliMUONGain.cxx:220
 AliMUONGain.cxx:221
 AliMUONGain.cxx:222
 AliMUONGain.cxx:223
 AliMUONGain.cxx:224
 AliMUONGain.cxx:225
 AliMUONGain.cxx:226
 AliMUONGain.cxx:227
 AliMUONGain.cxx:228
 AliMUONGain.cxx:229
 AliMUONGain.cxx:230
 AliMUONGain.cxx:231
 AliMUONGain.cxx:232
 AliMUONGain.cxx:233
 AliMUONGain.cxx:234
 AliMUONGain.cxx:235
 AliMUONGain.cxx:236
 AliMUONGain.cxx:237
 AliMUONGain.cxx:238
 AliMUONGain.cxx:239
 AliMUONGain.cxx:240
 AliMUONGain.cxx:241
 AliMUONGain.cxx:242
 AliMUONGain.cxx:243
 AliMUONGain.cxx:244
 AliMUONGain.cxx:245
 AliMUONGain.cxx:246
 AliMUONGain.cxx:247
 AliMUONGain.cxx:248
 AliMUONGain.cxx:249
 AliMUONGain.cxx:250
 AliMUONGain.cxx:251
 AliMUONGain.cxx:252
 AliMUONGain.cxx:253
 AliMUONGain.cxx:254
 AliMUONGain.cxx:255
 AliMUONGain.cxx:256
 AliMUONGain.cxx:257
 AliMUONGain.cxx:258
 AliMUONGain.cxx:259
 AliMUONGain.cxx:260
 AliMUONGain.cxx:261
 AliMUONGain.cxx:262
 AliMUONGain.cxx:263
 AliMUONGain.cxx:264
 AliMUONGain.cxx:265
 AliMUONGain.cxx:266
 AliMUONGain.cxx:267
 AliMUONGain.cxx:268
 AliMUONGain.cxx:269
 AliMUONGain.cxx:270
 AliMUONGain.cxx:271
 AliMUONGain.cxx:272
 AliMUONGain.cxx:273
 AliMUONGain.cxx:274
 AliMUONGain.cxx:275
 AliMUONGain.cxx:276
 AliMUONGain.cxx:277
 AliMUONGain.cxx:278
 AliMUONGain.cxx:279
 AliMUONGain.cxx:280
 AliMUONGain.cxx:281
 AliMUONGain.cxx:282
 AliMUONGain.cxx:283
 AliMUONGain.cxx:284
 AliMUONGain.cxx:285
 AliMUONGain.cxx:286
 AliMUONGain.cxx:287
 AliMUONGain.cxx:288
 AliMUONGain.cxx:289
 AliMUONGain.cxx:290
 AliMUONGain.cxx:291
 AliMUONGain.cxx:292
 AliMUONGain.cxx:293
 AliMUONGain.cxx:294
 AliMUONGain.cxx:295
 AliMUONGain.cxx:296
 AliMUONGain.cxx:297
 AliMUONGain.cxx:298
 AliMUONGain.cxx:299
 AliMUONGain.cxx:300
 AliMUONGain.cxx:301
 AliMUONGain.cxx:302
 AliMUONGain.cxx:303
 AliMUONGain.cxx:304
 AliMUONGain.cxx:305
 AliMUONGain.cxx:306
 AliMUONGain.cxx:307
 AliMUONGain.cxx:308
 AliMUONGain.cxx:309
 AliMUONGain.cxx:310
 AliMUONGain.cxx:311
 AliMUONGain.cxx:312
 AliMUONGain.cxx:313
 AliMUONGain.cxx:314
 AliMUONGain.cxx:315
 AliMUONGain.cxx:316
 AliMUONGain.cxx:317
 AliMUONGain.cxx:318
 AliMUONGain.cxx:319
 AliMUONGain.cxx:320
 AliMUONGain.cxx:321
 AliMUONGain.cxx:322
 AliMUONGain.cxx:323
 AliMUONGain.cxx:324
 AliMUONGain.cxx:325
 AliMUONGain.cxx:326
 AliMUONGain.cxx:327
 AliMUONGain.cxx:328
 AliMUONGain.cxx:329
 AliMUONGain.cxx:330
 AliMUONGain.cxx:331
 AliMUONGain.cxx:332
 AliMUONGain.cxx:333
 AliMUONGain.cxx:334
 AliMUONGain.cxx:335
 AliMUONGain.cxx:336
 AliMUONGain.cxx:337
 AliMUONGain.cxx:338
 AliMUONGain.cxx:339
 AliMUONGain.cxx:340
 AliMUONGain.cxx:341
 AliMUONGain.cxx:342
 AliMUONGain.cxx:343
 AliMUONGain.cxx:344
 AliMUONGain.cxx:345
 AliMUONGain.cxx:346
 AliMUONGain.cxx:347
 AliMUONGain.cxx:348
 AliMUONGain.cxx:349
 AliMUONGain.cxx:350
 AliMUONGain.cxx:351
 AliMUONGain.cxx:352
 AliMUONGain.cxx:353
 AliMUONGain.cxx:354
 AliMUONGain.cxx:355
 AliMUONGain.cxx:356
 AliMUONGain.cxx:357
 AliMUONGain.cxx:358
 AliMUONGain.cxx:359
 AliMUONGain.cxx:360
 AliMUONGain.cxx:361
 AliMUONGain.cxx:362
 AliMUONGain.cxx:363
 AliMUONGain.cxx:364
 AliMUONGain.cxx:365
 AliMUONGain.cxx:366
 AliMUONGain.cxx:367
 AliMUONGain.cxx:368
 AliMUONGain.cxx:369
 AliMUONGain.cxx:370
 AliMUONGain.cxx:371
 AliMUONGain.cxx:372
 AliMUONGain.cxx:373
 AliMUONGain.cxx:374
 AliMUONGain.cxx:375
 AliMUONGain.cxx:376
 AliMUONGain.cxx:377
 AliMUONGain.cxx:378
 AliMUONGain.cxx:379
 AliMUONGain.cxx:380
 AliMUONGain.cxx:381
 AliMUONGain.cxx:382
 AliMUONGain.cxx:383
 AliMUONGain.cxx:384
 AliMUONGain.cxx:385
 AliMUONGain.cxx:386
 AliMUONGain.cxx:387
 AliMUONGain.cxx:388
 AliMUONGain.cxx:389
 AliMUONGain.cxx:390
 AliMUONGain.cxx:391
 AliMUONGain.cxx:392
 AliMUONGain.cxx:393
 AliMUONGain.cxx:394
 AliMUONGain.cxx:395
 AliMUONGain.cxx:396
 AliMUONGain.cxx:397
 AliMUONGain.cxx:398
 AliMUONGain.cxx:399
 AliMUONGain.cxx:400
 AliMUONGain.cxx:401
 AliMUONGain.cxx:402
 AliMUONGain.cxx:403
 AliMUONGain.cxx:404
 AliMUONGain.cxx:405
 AliMUONGain.cxx:406
 AliMUONGain.cxx:407
 AliMUONGain.cxx:408
 AliMUONGain.cxx:409
 AliMUONGain.cxx:410
 AliMUONGain.cxx:411
 AliMUONGain.cxx:412
 AliMUONGain.cxx:413
 AliMUONGain.cxx:414
 AliMUONGain.cxx:415
 AliMUONGain.cxx:416
 AliMUONGain.cxx:417
 AliMUONGain.cxx:418
 AliMUONGain.cxx:419
 AliMUONGain.cxx:420
 AliMUONGain.cxx:421
 AliMUONGain.cxx:422
 AliMUONGain.cxx:423
 AliMUONGain.cxx:424
 AliMUONGain.cxx:425
 AliMUONGain.cxx:426
 AliMUONGain.cxx:427
 AliMUONGain.cxx:428
 AliMUONGain.cxx:429
 AliMUONGain.cxx:430
 AliMUONGain.cxx:431
 AliMUONGain.cxx:432
 AliMUONGain.cxx:433
 AliMUONGain.cxx:434
 AliMUONGain.cxx:435
 AliMUONGain.cxx:436
 AliMUONGain.cxx:437
 AliMUONGain.cxx:438
 AliMUONGain.cxx:439
 AliMUONGain.cxx:440
 AliMUONGain.cxx:441
 AliMUONGain.cxx:442
 AliMUONGain.cxx:443
 AliMUONGain.cxx:444
 AliMUONGain.cxx:445
 AliMUONGain.cxx:446
 AliMUONGain.cxx:447
 AliMUONGain.cxx:448
 AliMUONGain.cxx:449
 AliMUONGain.cxx:450
 AliMUONGain.cxx:451
 AliMUONGain.cxx:452
 AliMUONGain.cxx:453
 AliMUONGain.cxx:454
 AliMUONGain.cxx:455
 AliMUONGain.cxx:456
 AliMUONGain.cxx:457
 AliMUONGain.cxx:458
 AliMUONGain.cxx:459
 AliMUONGain.cxx:460
 AliMUONGain.cxx:461
 AliMUONGain.cxx:462
 AliMUONGain.cxx:463
 AliMUONGain.cxx:464
 AliMUONGain.cxx:465
 AliMUONGain.cxx:466
 AliMUONGain.cxx:467
 AliMUONGain.cxx:468
 AliMUONGain.cxx:469
 AliMUONGain.cxx:470
 AliMUONGain.cxx:471
 AliMUONGain.cxx:472
 AliMUONGain.cxx:473
 AliMUONGain.cxx:474
 AliMUONGain.cxx:475
 AliMUONGain.cxx:476
 AliMUONGain.cxx:477
 AliMUONGain.cxx:478
 AliMUONGain.cxx:479
 AliMUONGain.cxx:480
 AliMUONGain.cxx:481
 AliMUONGain.cxx:482
 AliMUONGain.cxx:483
 AliMUONGain.cxx:484
 AliMUONGain.cxx:485
 AliMUONGain.cxx:486
 AliMUONGain.cxx:487
 AliMUONGain.cxx:488
 AliMUONGain.cxx:489
 AliMUONGain.cxx:490
 AliMUONGain.cxx:491
 AliMUONGain.cxx:492
 AliMUONGain.cxx:493
 AliMUONGain.cxx:494
 AliMUONGain.cxx:495
 AliMUONGain.cxx:496
 AliMUONGain.cxx:497
 AliMUONGain.cxx:498
 AliMUONGain.cxx:499
 AliMUONGain.cxx:500
 AliMUONGain.cxx:501
 AliMUONGain.cxx:502
 AliMUONGain.cxx:503
 AliMUONGain.cxx:504
 AliMUONGain.cxx:505
 AliMUONGain.cxx:506
 AliMUONGain.cxx:507
 AliMUONGain.cxx:508
 AliMUONGain.cxx:509
 AliMUONGain.cxx:510
 AliMUONGain.cxx:511
 AliMUONGain.cxx:512
 AliMUONGain.cxx:513
 AliMUONGain.cxx:514
 AliMUONGain.cxx:515
 AliMUONGain.cxx:516
 AliMUONGain.cxx:517
 AliMUONGain.cxx:518
 AliMUONGain.cxx:519
 AliMUONGain.cxx:520
 AliMUONGain.cxx:521
 AliMUONGain.cxx:522
 AliMUONGain.cxx:523
 AliMUONGain.cxx:524
 AliMUONGain.cxx:525
 AliMUONGain.cxx:526
 AliMUONGain.cxx:527
 AliMUONGain.cxx:528
 AliMUONGain.cxx:529
 AliMUONGain.cxx:530
 AliMUONGain.cxx:531
 AliMUONGain.cxx:532
 AliMUONGain.cxx:533
 AliMUONGain.cxx:534
 AliMUONGain.cxx:535
 AliMUONGain.cxx:536
 AliMUONGain.cxx:537
 AliMUONGain.cxx:538
 AliMUONGain.cxx:539
 AliMUONGain.cxx:540
 AliMUONGain.cxx:541
 AliMUONGain.cxx:542
 AliMUONGain.cxx:543
 AliMUONGain.cxx:544
 AliMUONGain.cxx:545
 AliMUONGain.cxx:546
 AliMUONGain.cxx:547
 AliMUONGain.cxx:548
 AliMUONGain.cxx:549
 AliMUONGain.cxx:550
 AliMUONGain.cxx:551
 AliMUONGain.cxx:552
 AliMUONGain.cxx:553
 AliMUONGain.cxx:554
 AliMUONGain.cxx:555
 AliMUONGain.cxx:556
 AliMUONGain.cxx:557
 AliMUONGain.cxx:558
 AliMUONGain.cxx:559
 AliMUONGain.cxx:560
 AliMUONGain.cxx:561
 AliMUONGain.cxx:562
 AliMUONGain.cxx:563
 AliMUONGain.cxx:564
 AliMUONGain.cxx:565
 AliMUONGain.cxx:566
 AliMUONGain.cxx:567
 AliMUONGain.cxx:568
 AliMUONGain.cxx:569
 AliMUONGain.cxx:570
 AliMUONGain.cxx:571
 AliMUONGain.cxx:572
 AliMUONGain.cxx:573
 AliMUONGain.cxx:574
 AliMUONGain.cxx:575
 AliMUONGain.cxx:576
 AliMUONGain.cxx:577
 AliMUONGain.cxx:578
 AliMUONGain.cxx:579
 AliMUONGain.cxx:580
 AliMUONGain.cxx:581
 AliMUONGain.cxx:582
 AliMUONGain.cxx:583
 AliMUONGain.cxx:584
 AliMUONGain.cxx:585
 AliMUONGain.cxx:586
 AliMUONGain.cxx:587
 AliMUONGain.cxx:588
 AliMUONGain.cxx:589
 AliMUONGain.cxx:590
 AliMUONGain.cxx:591
 AliMUONGain.cxx:592
 AliMUONGain.cxx:593
 AliMUONGain.cxx:594
 AliMUONGain.cxx:595
 AliMUONGain.cxx:596
 AliMUONGain.cxx:597
 AliMUONGain.cxx:598
 AliMUONGain.cxx:599
 AliMUONGain.cxx:600
 AliMUONGain.cxx:601
 AliMUONGain.cxx:602
 AliMUONGain.cxx:603
 AliMUONGain.cxx:604
 AliMUONGain.cxx:605
 AliMUONGain.cxx:606
 AliMUONGain.cxx:607
 AliMUONGain.cxx:608
 AliMUONGain.cxx:609
 AliMUONGain.cxx:610
 AliMUONGain.cxx:611
 AliMUONGain.cxx:612
 AliMUONGain.cxx:613
 AliMUONGain.cxx:614
 AliMUONGain.cxx:615
 AliMUONGain.cxx:616
 AliMUONGain.cxx:617
 AliMUONGain.cxx:618
 AliMUONGain.cxx:619
 AliMUONGain.cxx:620
 AliMUONGain.cxx:621
 AliMUONGain.cxx:622
 AliMUONGain.cxx:623
 AliMUONGain.cxx:624
 AliMUONGain.cxx:625
 AliMUONGain.cxx:626
 AliMUONGain.cxx:627
 AliMUONGain.cxx:628
 AliMUONGain.cxx:629
 AliMUONGain.cxx:630
 AliMUONGain.cxx:631
 AliMUONGain.cxx:632
 AliMUONGain.cxx:633
 AliMUONGain.cxx:634
 AliMUONGain.cxx:635
 AliMUONGain.cxx:636
 AliMUONGain.cxx:637
 AliMUONGain.cxx:638
 AliMUONGain.cxx:639
 AliMUONGain.cxx:640
 AliMUONGain.cxx:641
 AliMUONGain.cxx:642
 AliMUONGain.cxx:643
 AliMUONGain.cxx:644
 AliMUONGain.cxx:645
 AliMUONGain.cxx:646
 AliMUONGain.cxx:647
 AliMUONGain.cxx:648
 AliMUONGain.cxx:649
 AliMUONGain.cxx:650
 AliMUONGain.cxx:651
 AliMUONGain.cxx:652
 AliMUONGain.cxx:653
 AliMUONGain.cxx:654
 AliMUONGain.cxx:655
 AliMUONGain.cxx:656
 AliMUONGain.cxx:657
 AliMUONGain.cxx:658
 AliMUONGain.cxx:659
 AliMUONGain.cxx:660
 AliMUONGain.cxx:661
 AliMUONGain.cxx:662
 AliMUONGain.cxx:663
 AliMUONGain.cxx:664
 AliMUONGain.cxx:665
 AliMUONGain.cxx:666
 AliMUONGain.cxx:667
 AliMUONGain.cxx:668
 AliMUONGain.cxx:669
 AliMUONGain.cxx:670
 AliMUONGain.cxx:671
 AliMUONGain.cxx:672
 AliMUONGain.cxx:673
 AliMUONGain.cxx:674
 AliMUONGain.cxx:675
 AliMUONGain.cxx:676
 AliMUONGain.cxx:677
 AliMUONGain.cxx:678
 AliMUONGain.cxx:679
 AliMUONGain.cxx:680
 AliMUONGain.cxx:681
 AliMUONGain.cxx:682
 AliMUONGain.cxx:683
 AliMUONGain.cxx:684
 AliMUONGain.cxx:685
 AliMUONGain.cxx:686
 AliMUONGain.cxx:687
 AliMUONGain.cxx:688
 AliMUONGain.cxx:689
 AliMUONGain.cxx:690
 AliMUONGain.cxx:691
 AliMUONGain.cxx:692
 AliMUONGain.cxx:693
 AliMUONGain.cxx:694
 AliMUONGain.cxx:695
 AliMUONGain.cxx:696
 AliMUONGain.cxx:697
 AliMUONGain.cxx:698
 AliMUONGain.cxx:699
 AliMUONGain.cxx:700
 AliMUONGain.cxx:701
 AliMUONGain.cxx:702
 AliMUONGain.cxx:703
 AliMUONGain.cxx:704
 AliMUONGain.cxx:705
 AliMUONGain.cxx:706
 AliMUONGain.cxx:707
 AliMUONGain.cxx:708
 AliMUONGain.cxx:709
 AliMUONGain.cxx:710
 AliMUONGain.cxx:711
 AliMUONGain.cxx:712
 AliMUONGain.cxx:713
 AliMUONGain.cxx:714
 AliMUONGain.cxx:715
 AliMUONGain.cxx:716
 AliMUONGain.cxx:717
 AliMUONGain.cxx:718
 AliMUONGain.cxx:719
 AliMUONGain.cxx:720
 AliMUONGain.cxx:721
 AliMUONGain.cxx:722
 AliMUONGain.cxx:723
 AliMUONGain.cxx:724
 AliMUONGain.cxx:725
 AliMUONGain.cxx:726
 AliMUONGain.cxx:727
 AliMUONGain.cxx:728
 AliMUONGain.cxx:729
 AliMUONGain.cxx:730
 AliMUONGain.cxx:731
 AliMUONGain.cxx:732
 AliMUONGain.cxx:733
 AliMUONGain.cxx:734
 AliMUONGain.cxx:735
 AliMUONGain.cxx:736
 AliMUONGain.cxx:737
 AliMUONGain.cxx:738
 AliMUONGain.cxx:739
 AliMUONGain.cxx:740
 AliMUONGain.cxx:741
 AliMUONGain.cxx:742
 AliMUONGain.cxx:743
 AliMUONGain.cxx:744
 AliMUONGain.cxx:745
 AliMUONGain.cxx:746
 AliMUONGain.cxx:747
 AliMUONGain.cxx:748
 AliMUONGain.cxx:749
 AliMUONGain.cxx:750