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:$ */

/// \ingroup macros
/// \file MUONSurveyCh4.C
/// \brief Macro to process survey and photogrammetry data of chamber 4
/// 
/// Macro loads the survey data from .txt file using AliSurveyObj.
/// Macro uses AliMUONSurvey... classes.
/// The transformations of the detection elements or chambers can be obtained 
/// in three ways:
/// - A: Fit of local to global transformation using the fixed button targets.
/// - B: Fit a plane to the sticker targets -> psi, theta
///      Use above psi and theta and fit remaining 4 parameters using the fixed 
///      button targets
/// -  C: Fit a plane to the sticker targets -> psi, theta
///      Use above psi and theta to calculate xc, yc, zc and phi by solving 
///      the equations from a local to global transformation of the fixed button 
///      targets
///
/// Methods A and B are prefered to C, and B is better if sticker targets are 
/// available and lie on a plane!
/// For slats only methods B and C can be used.
/// Various histograms are filled and printed for monitoring.
/// MisAlignment object is then created.
///
/// \author Javier Castillo

#if !defined(__CINT__) || defined(__MAKECINT__)

#include "AliMUONGeometryTransformer.h"
#include "AliMUONGeometryModuleTransformer.h"
#include "AliMUONGeometryDetElement.h"
#include "AliMUONGeometryMisAligner.h"
#include "AliMUONSurveyChamber.h"
#include "AliMUONSurveyDetElem.h"
#include "AliMUONSurveyUtil.h"

#include "AliSurveyObj.h"
#include "AliSurveyPoint.h"
#include "AliGeomManager.h"
#include "AliCDBManager.h"
#include "AliCDBMetaData.h"
#include "AliCDBId.h"
#include "AliAlignObjMatrix.h"
#include "AliAlignObj.h"

#include <TROOT.h>
#include <TGeoManager.h>
#include <TClonesArray.h>
#include <TObjArray.h>
#include <TArrayD.h>
#include <TMath.h>
#include <TString.h>
#include <TFitter.h>
#include <TH2.h>
#include <TF2.h>
#include <TGraphErrors.h>
#include <TCanvas.h>
#include <TPad.h>
#include <TLine.h>
#include <TPostScript.h>
#include <TPaveLabel.h>
#include <TStyle.h>
#include <TFile.h>
#include <TMatrixDSym.h>

#include <fstream>

#endif

void MUONSurveyCh4() {
  
  TString str;
  TString title;
  
  Bool_t bMonitor = kTRUE;
  Bool_t bOCDB = kTRUE;
  Bool_t saveps = kFALSE;
  const int cWidth = (int)(700*(29./21.));
  const int cHeight = 700;
  const int filetype  = 112; // landscape  

  Int_t chId = 3;
  Int_t nChs = 2;
  Int_t nDetElems = 4;
  Int_t nDetElemsI = 2;
  //  Int_t nDetElemsO = 2;
  Int_t iDetElemToDetElemId[4] = {400,401,402,403};
  Int_t iDetElemPseudoIdToDetElem[4] = {0,1,2,3};
  Int_t iDetElemsOfChamber[2][2] = {{0,3},
				    {1,2}};
  
  TObjArray *myChamberArray = new TObjArray(); 
  myChamberArray->Add(new AliMUONSurveyChamber(chId));  
  myChamberArray->Add(new AliMUONSurveyChamber(chId));  

  AliMUONSurveyChamber *myChamberI = 0x0;
  AliMUONSurveyChamber *myChamberO = 0x0;
  AliMUONSurveyChamber *myChamber = 0x0;
  AliMUONSurveyDetElem *myDetElem = 0x0;

  myChamberI = (AliMUONSurveyChamber*)myChamberArray->At(0);
  myChamberI->GetSurveyObj()->FillFromLocalFile("../Reports/AliceSt2_TC4_4971d.txt");
  myChamberO = (AliMUONSurveyChamber*)myChamberArray->At(1);
  myChamberO->GetSurveyObj()->FillFromLocalFile("../Reports/AliceSt2_TC4_4971d.txt");

  myChamber = myChamberI;
  myChamber->PrintSurveyReport();

  // Chamber & DetElems button targets local coordinates
  AliSurveyObj *lSO = new AliSurveyObj();    
  lSO->FillFromLocalFile("$ALICE_ROOT/MUON/data/MUONTrackingTargetsLocal.txt");

  // Set survey targets for chambers 
  myChamberI->AddGButtonTargets(TString("T1_4520"),3);
  myChamberI->AddStickerTargets(TString("T1_4620"),6);
  myChamberI->AddLButtonTargets(lSO->GetData(),Form("%d_520",chId+1),3);
  myChamberI->AddGButtonTargets(TString("T1_4510"),3);
  myChamberI->AddStickerTargets(TString("T1_4610"),6);
  myChamberI->AddLButtonTargets(lSO->GetData(),Form("%d_510",chId+1),3);
  myChamberO->AddGButtonTargets(TString("T1_4520"),3);
  myChamberO->AddStickerTargets(TString("T1_4620"),6);
  myChamberO->AddLButtonTargets(lSO->GetData(),Form("%d_520",chId+1),3);
  myChamberO->AddGButtonTargets(TString("T1_4510"),3);
  myChamberO->AddStickerTargets(TString("T1_4610"),6);
  myChamberO->AddLButtonTargets(lSO->GetData(),Form("%d_510",chId+1),3);

  // Set survey targets for detection elements 
  for (int iCh =0; iCh<=1; iCh++) {
    myChamber = (AliMUONSurveyChamber*)myChamberArray->At(iCh);
    for (int iDetElemI=0; iDetElemI<nDetElemsI; iDetElemI++){
      Int_t iDetElem = iDetElemsOfChamber[iCh][iDetElemI];
      myChamber->AddSurveyDetElem(iDetElemToDetElemId[iDetElem]);
      TString baseName;
      myDetElem =  myChamber->GetDetElem(iDetElemI);
      if (myDetElem) {
	baseName = Form("T1_453%d",iDetElem+1);
	myDetElem->AddGButtonTargets(baseName,3);
	baseName = Form("T1_463%d",iDetElem+1);
	myDetElem->AddStickerTargets(baseName,6);
	baseName = Form("%d_53%d",chId+1,iDetElem+1);
	myDetElem->AddLButtonTargets(lSO->GetData(),baseName,3);
      }
    }
  }
  printf("All targets added! \n");

  Double_t **lCenDetElem = new Double_t*[nDetElems+nChs];
  Double_t **lRotDetElem = new Double_t*[nDetElems+nChs];
  Double_t **lDiffCenDetElem0 = new Double_t*[nDetElems+nChs];
  Double_t **lDiffRotDetElem0 = new Double_t*[nDetElems+nChs];
  Double_t **lDiffThCenDetElem0 = new Double_t*[nDetElems+nChs];
  Double_t **lDiffThRotDetElem0 = new Double_t*[nDetElems+nChs];
  Double_t **lDeltaDiffCenDetElem0 = new Double_t*[nDetElems+nChs];
  Double_t **lDeltaDiffRotDetElem0 = new Double_t*[nDetElems+nChs];

  for (int iDetElem=0; iDetElem<nDetElems+nChs; iDetElem++) {
    lCenDetElem[iDetElem] = new Double_t[3];
    lRotDetElem[iDetElem] = new Double_t[3];
    lDiffCenDetElem0[iDetElem] = new Double_t[3];
    lDiffRotDetElem0[iDetElem] = new Double_t[3];
    lDiffThCenDetElem0[iDetElem] = new Double_t[3];
    lDiffThRotDetElem0[iDetElem] = new Double_t[3];
    lDeltaDiffCenDetElem0[iDetElem] = new Double_t[3];
    lDeltaDiffRotDetElem0[iDetElem] = new Double_t[3];
  }

  TGeoCombiTrans dtrfDetElem[nDetElems+nChs];
  TGeoCombiTrans localTrfDetElem[nDetElems+nChs];
  TGeoCombiTrans localTrfThDetElem[nDetElems+nChs];

  // Import TGeo geometry 
  char* geoFilename = "geometry.root";
  if ( ! AliGeomManager::GetGeometry() ) {
    AliGeomManager::LoadGeometry(geoFilename);
    if (! AliGeomManager::GetGeometry() ) {
      printf("MUONSurveyCh%d: getting geometry from file %s failed\n", chId+1,geoFilename);
      return;
    }
    cout << "geometry imported" << endl;
  }

  AliMUONGeometryTransformer *transform = new AliMUONGeometryTransformer();
  transform->LoadGeometryData();

  TGeoCombiTrans trfThChamber;
  TGeoCombiTrans trfThDetElem;

  for (int iCh =0; iCh<=1; iCh++) {
    myChamber = (AliMUONSurveyChamber*)myChamberArray->At(iCh);

    trfThChamber = TGeoCombiTrans(*transform->GetModuleTransformerByDEId(iDetElemToDetElemId[iCh*nDetElemsI])->GetTransformation());
    trfThChamber.Print();
    myChamber->SetLocalTransformation(new TGeoCombiTrans(trfThChamber),kTRUE);

    // Set Chamber plane function
    cout << "Setting plane for Chamber" << iCh+1 << " ..." << endl;
    myChamber->SetPlane(Form("fChamber%d",iCh+1));
    myChamber->SetPlaneParameters(0.,0.,0.);

    // Fit a plane to sticker targets
    Double_t lCChi2 = myChamber->FitPlane();
    cout << "... chi2 = " << lCChi2 << " ..." << endl; 
    
    // Get best transformation from fitting method 
    // (local to global transformation)
    cout << "Trying fitting method for chamber " << iCh << endl;
    myChamber->SurveyToAlign();    
    //    myChamber->SurveyToAlign(myChamber->GetPlane()->GetParameter(0),myChamber->GetPlane()->GetParameter(1),myChamber->GetPlane()->GetParError(0),myChamber->GetPlane()->GetParError(1));    
    
    for (int iDetElemI=0; iDetElemI<nDetElemsI; iDetElemI++){
      myDetElem =  myChamber->GetDetElem(iDetElemI);
      Int_t iDetElem = iDetElemsOfChamber[iCh][iDetElemI];

      trfThDetElem.Clear();
      trfThDetElem = TGeoCombiTrans(*transform->GetDetElement(iDetElemToDetElemId[iDetElem])->GetLocalTransformation());
      trfThDetElem.Print();
      myDetElem->SetLocalTransformation(new TGeoCombiTrans(trfThDetElem),kTRUE);

      for (int iCor=0; iCor<3; iCor++){
	lCenDetElem[iDetElem][iCor] = 0;
	lRotDetElem[iDetElem][iCor] = 0;
      }

      if (bMonitor){
	// MONITOR: Draw graph with sticker targets for plane fitting
	myDetElem->DrawSTargets();
	gPad->Update();
      }

      // Get DetElem transformation. 
      // Psi and Theta are obtained by fitting a plane to the sticker targets.
      // Then Xc, Yc, Zc and Phi are obtained by solving the equations to the ref.
      // syst. transformation of the button targets

      // Set DetElem plane function
      cout << "Setting plane for DetElem" << iDetElem+1 << " ..." << endl;
      myDetElem->SetPlane(Form("fDetElem%d",iDetElem+1));
      myDetElem->SetPlaneParameters(0.,0.,3.)
;
      // Fit a plane to sticker targets
      Double_t lChi2 = myDetElem->FitPlane();
      cout << "... chi2 = " << lChi2 << " ..." << endl; 
      
      lRotDetElem[iDetElem][0]=TMath::ATan(myDetElem->GetPlane()->GetParameter(0));
      lRotDetElem[iDetElem][1]=TMath::ATan(myDetElem->GetPlane()->GetParameter(1));
      
      // Calculate Mean transformation using previous plane fit 
      // and pairs of button targets
      myDetElem->CalculateMeanTransf(lCenDetElem[iDetElem],lRotDetElem[iDetElem]);
    
      cout << "DetElem" << iDetElem+1 << " : mycen(" << lCenDetElem[iDetElem][0] << "," << lCenDetElem[iDetElem][1] << "," << lCenDetElem[iDetElem][2] << "); rot(" << lRotDetElem[iDetElem][0] << "," << lRotDetElem[iDetElem][1] << "," << lRotDetElem[iDetElem][2] << ")"  << endl;  	
      
     
      // Get best transformation from fitting method 
      // (local to global transformation)
      cout << "Trying fitting method for DetElemId " << iDetElemToDetElemId[iDetElem] << endl;
      //      myDetElem->SurveyToAlign();     
      myDetElem->SurveyToAlign(lRotDetElem[iDetElem][0],lRotDetElem[iDetElem][1],myDetElem->GetPlane()->GetParError(0),myDetElem->GetPlane()->GetParError(1));    
    }
  }

  // Print found transformation of Detection Element (plane fit + loop)        
  for (int iCh =0; iCh<=1; iCh++) {
    for (int iDetElemI=0; iDetElemI<nDetElemsI; iDetElemI++){
      Int_t iDetElem = iDetElemsOfChamber[iCh][iDetElemI];
      cout << "DetElem" << iDetElem+1 << " : mycen(" << lCenDetElem[iDetElem][0] << "," << lCenDetElem[iDetElem][1] << "," << lCenDetElem[iDetElem][2] << "); rot(" << lRotDetElem[iDetElem][0] << "," << lRotDetElem[iDetElem][1] << "," << lRotDetElem[iDetElem][2] << ")"  << endl;  	
    }
  }

  // Print Theoretical transformation of Detection Element
  for (int iCh =0; iCh<=1; iCh++) {
    myChamber = (AliMUONSurveyChamber*)myChamberArray->At(iCh);
    for (int iDetElemI=0; iDetElemI<nDetElemsI; iDetElemI++){
      myChamber->GetDetElem(iDetElemI)->PrintLocalTrf();
    }
  }

  // Print found delta transformation of Detection Element
  for (int iCh =0; iCh<=1; iCh++) {
    myChamber = (AliMUONSurveyChamber*)myChamberArray->At(iCh);      
    for (int iDetElemI=0; iDetElemI<nDetElemsI; iDetElemI++){
      myChamber->GetDetElem(iDetElemI)->PrintAlignTrf();
    }
  }

  //
  // Compare transformations to expected ones 
  //
  Int_t iDetElemToPos[18] = {0, 1, 2, 3};
 
  TGraphErrors *gDeltaDiffCenXDetElem0 = new TGraphErrors(nDetElems);
  TGraphErrors *gDeltaDiffCenYDetElem0 = new TGraphErrors(nDetElems);
  TGraphErrors *gDeltaDiffCenZDetElem0 = new TGraphErrors(nDetElems);
  TGraphErrors *gDeltaDiffPsiDetElem0 = new TGraphErrors(nDetElems);
  TGraphErrors *gDeltaDiffThtDetElem0 = new TGraphErrors(nDetElems);
  TGraphErrors *gDeltaDiffPhiDetElem0 = new TGraphErrors(nDetElems);

  for (int iCh =0; iCh<=1; iCh++) {
    myChamber = (AliMUONSurveyChamber*)myChamberArray->At(iCh);      
    for (int iDetElemI=0; iDetElemI<nDetElemsI; iDetElemI++){
      myChamber->GetDetElem(iDetElemI)->GetAlignTrf()->Print();
    }
  }

  for (int iCh =0; iCh<=1; iCh++) {
    myChamber = (AliMUONSurveyChamber*)myChamberArray->At(iCh);
    // Store delta transformations to use for CDB entry creation
    dtrfDetElem[nDetElems+iCh].Clear();
    dtrfDetElem[nDetElems+iCh] = *(myChamber->GetAlignTrf());

    // Those are for checks and visualizations
    localTrfDetElem[nDetElems+iCh].Clear();
    localTrfDetElem[nDetElems+iCh] = (*(myChamber->GetLocalTrf())*(*(myChamber->GetAlignTrf())));
    localTrfDetElem[nDetElems+iCh].Print();
    lDiffCenDetElem0[nDetElems+iCh] = (Double_t*)localTrfDetElem[nDetElems+iCh].GetTranslation();
    AliMUONSurveyUtil::MatrixToAngles(localTrfDetElem[nDetElems+iCh].GetRotationMatrix(),lDiffRotDetElem0[nDetElems+iCh]);
    
    localTrfThDetElem[nDetElems+iCh].Clear();
    localTrfThDetElem[nDetElems+iCh] = (*(myChamber->GetLocalTrf()));
    localTrfThDetElem[nDetElems+iCh].Print();
    lDiffThCenDetElem0[nDetElems+iCh] = (Double_t*)localTrfThDetElem[nDetElems+iCh].GetTranslation();
    AliMUONSurveyUtil::MatrixToAngles(localTrfThDetElem[nDetElems+iCh].GetRotationMatrix(),lDiffThRotDetElem0[nDetElems+iCh]);

    for (int iCor=0; iCor<3; iCor++){
      lDeltaDiffCenDetElem0[nDetElems+iCh][iCor] = lDiffCenDetElem0[nDetElems+iCh][iCor]-lDiffThCenDetElem0[nDetElems+iCh][iCor];
      lDeltaDiffRotDetElem0[nDetElems+iCh][iCor] = lDiffRotDetElem0[nDetElems+iCh][iCor]-lDiffThRotDetElem0[nDetElems+iCh][iCor];
      if (lDeltaDiffRotDetElem0[nDetElems+iCh][iCor]>TMath::Pi()) lDeltaDiffRotDetElem0[nDetElems+iCh][iCor]-=TMath::TwoPi();
      if (lDeltaDiffRotDetElem0[nDetElems+iCh][iCor]<-TMath::Pi()) lDeltaDiffRotDetElem0[nDetElems+iCh][iCor]+=TMath::TwoPi();
    }      

    for (int iDetElemI=0; iDetElemI<nDetElemsI; iDetElemI++){
      Int_t iDetElem = iDetElemsOfChamber[iCh][iDetElemI];
      myDetElem =  myChamber->GetDetElem(iDetElemI);
      // Store delta transformations to use for CDB entry creation
      dtrfDetElem[iDetElem].Clear();
      dtrfDetElem[iDetElem] = *(myDetElem->GetAlignTrf());

      // Those are for checks and visualizations
      localTrfDetElem[iDetElem].Clear();
      localTrfDetElem[iDetElem] = (*(myDetElem->GetLocalTrf())*(*(myDetElem->GetAlignTrf())));
      //      localTrfDetElem[iDetElem] = (*(myDetElem->GetBaseTrf())*(*(myDetElem->GetAlignTrf())));
      localTrfDetElem[iDetElem].Print();
      lDiffCenDetElem0[iDetElem] = (Double_t*)localTrfDetElem[iDetElem].GetTranslation();
      AliMUONSurveyUtil::MatrixToAngles(localTrfDetElem[iDetElem].GetRotationMatrix(),lDiffRotDetElem0[iDetElem]);
//       lDiffCenDetElem0[iDetElem] = lCenDetElem[iDetElem];
//       lDiffRotDetElem0[iDetElem] = lRotDetElem[iDetElem];

      localTrfThDetElem[iDetElem].Clear();
      localTrfThDetElem[iDetElem] = (*(myDetElem->GetLocalTrf()));
      //      localTrfThDetElem[iDetElem] = (*(myDetElem->GetBaseTrf()));
      localTrfThDetElem[iDetElem].Print();
      lDiffThCenDetElem0[iDetElem] = (Double_t*)localTrfThDetElem[iDetElem].GetTranslation();
      AliMUONSurveyUtil::MatrixToAngles(localTrfThDetElem[iDetElem].GetRotationMatrix(),lDiffThRotDetElem0[iDetElem]);
      
      for (int iCor=0; iCor<3; iCor++){
	lDeltaDiffCenDetElem0[iDetElem][iCor] = lDiffCenDetElem0[iDetElem][iCor]-lDiffThCenDetElem0[iDetElem][iCor];
	lDeltaDiffRotDetElem0[iDetElem][iCor] = lDiffRotDetElem0[iDetElem][iCor]-lDiffThRotDetElem0[iDetElem][iCor];
	if (lDeltaDiffRotDetElem0[iDetElem][iCor]>TMath::Pi()) lDeltaDiffRotDetElem0[iDetElem][iCor]-=TMath::TwoPi();
	if (lDeltaDiffRotDetElem0[iDetElem][iCor]<-TMath::Pi()) lDeltaDiffRotDetElem0[iDetElem][iCor]+=TMath::TwoPi();
      }

      gDeltaDiffCenXDetElem0->SetPoint(iDetElem,1e1*lDeltaDiffCenDetElem0[iDetElem][0],iDetElemToPos[iDetElem]+1);
      gDeltaDiffCenYDetElem0->SetPoint(iDetElem,1e1*lDeltaDiffCenDetElem0[iDetElem][1],iDetElemToPos[iDetElem]+1);
      gDeltaDiffCenZDetElem0->SetPoint(iDetElem,1e1*lDeltaDiffCenDetElem0[iDetElem][2],iDetElemToPos[iDetElem]+1);
      gDeltaDiffPsiDetElem0->SetPoint(iDetElem,1e3*lDeltaDiffRotDetElem0[iDetElem][0],iDetElemToPos[iDetElem]+1);
      gDeltaDiffThtDetElem0->SetPoint(iDetElem,1e3*lDeltaDiffRotDetElem0[iDetElem][1],iDetElemToPos[iDetElem]+1);
      gDeltaDiffPhiDetElem0->SetPoint(iDetElem,1e3*lDeltaDiffRotDetElem0[iDetElem][2],iDetElemToPos[iDetElem]+1);
      gDeltaDiffCenXDetElem0->SetPointError(iDetElem,1e1*myDetElem->GetFitter()->GetParError(0),0.);
      gDeltaDiffCenYDetElem0->SetPointError(iDetElem,1e1*myDetElem->GetFitter()->GetParError(1),0.);
      gDeltaDiffCenZDetElem0->SetPointError(iDetElem,1e1*myDetElem->GetFitter()->GetParError(2),0.);
      gDeltaDiffPsiDetElem0->SetPointError(iDetElem,1e3*myDetElem->GetFitter()->GetParError(3),0.);
      gDeltaDiffThtDetElem0->SetPointError(iDetElem,1e3*myDetElem->GetFitter()->GetParError(4),0.);
      gDeltaDiffPhiDetElem0->SetPointError(iDetElem,1e3*myDetElem->GetFitter()->GetParError(5),0.);  
    }
  }

  // Apply the found misalignments to the geometry
  AliMUONGeometryTransformer *newTransform = AliMUONSurveyUtil::ReAlign(transform,chId,nDetElems,iDetElemPseudoIdToDetElem,dtrfDetElem,true); 
  newTransform->WriteTransformations(Form("transform2ReAlignSurveyCh%d.dat",chId+1));

  if(bOCDB){
    // Generate realigned data in local cdb
    const TClonesArray* array = newTransform->GetMisAlignmentData();
    
    // Set the alignment resolution in the align objects for this chamber
    Double_t chResX = myChamberI->GetAlignResX();
    Double_t chResY = myChamberI->GetAlignResY();
    Double_t deResX = (myChamberI->GetMeanDetElemAlignResX()+myChamberO->GetMeanDetElemAlignResX())/2.;
    Double_t deResY = (myChamberI->GetMeanDetElemAlignResY()+myChamberO->GetMeanDetElemAlignResY())/2.;
    printf("Chamber alignment resolutions: resX=%f , resY=%f\n",chResX,chResY); 
    printf("Detection Elements alignment resolutions: resX=%f , resY=%f\n",deResX,deResY); 
    chResX = TMath::Sqrt(0.1*0.1+chResX*chResX);
    chResY = TMath::Sqrt(0.1*0.1+chResY*chResY);
    AliMUONSurveyUtil::SetAlignmentResolution(array,chId,chResX,chResY,deResX,deResY);
    
    // CDB manager
    AliCDBManager* cdbManager = AliCDBManager::Instance();
    cdbManager->SetDefaultStorage(Form("local://ReAlignSurveyCh%dCDB",chId+1));
    
    AliCDBMetaData* cdbData = new AliCDBMetaData();
    cdbData->SetResponsible("Dimuon Offline project");
    cdbData->SetComment("MUON alignment objects with survey realignment");
    AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity()); 
    cdbManager->Put(const_cast<TClonesArray*>(array), id, cdbData);
  }

  for(Int_t iCor=0; iCor<3; iCor++){
    for(Int_t iDetElem=0; iDetElem<nDetElems; iDetElem++){
      cout << lDeltaDiffCenDetElem0[iDetElem][iCor] << " " << lDiffCenDetElem0[iDetElem][iCor] << " " << lDiffThCenDetElem0[iDetElem][iCor] << endl;
    }
    cout << endl;
  }
  cout << endl;
  for(Int_t iCor=0; iCor<3; iCor++){
    for(Int_t iDetElem=0; iDetElem<nDetElems; iDetElem++){
      cout << lDeltaDiffRotDetElem0[iDetElem][iCor] << " " << lDiffRotDetElem0[iDetElem][iCor] << " " << lDiffThRotDetElem0[iDetElem][iCor] << endl;
    }
    cout << endl;
  }

  TH1F *myDetElemDeltaDiffCenX = new TH1F("myDetElemDeltaDiffCenX","myDetElemDeltaDiffCenX",100,-10,10);
  myDetElemDeltaDiffCenX->SetMaximum(nDetElems+1);
  myDetElemDeltaDiffCenX->SetMinimum(0);
  TH1F *myDetElemDeltaDiffCenY = new TH1F("myDetElemDeltaDiffCenY","myDetElemDeltaDiffCenY",100,-10,10);
  myDetElemDeltaDiffCenY->SetMaximum(nDetElems+1);
  myDetElemDeltaDiffCenY->SetMinimum(0);
  TH1F *myDetElemDeltaDiffCenZ = new TH1F("myDetElemDeltaDiffCenZ","myDetElemDeltaDiffCenZ",100,-20,20);
  myDetElemDeltaDiffCenZ->SetMaximum(nDetElems+1);
  myDetElemDeltaDiffCenZ->SetMinimum(0);

  TH1F *myDetElemDeltaDiffRotX = new TH1F("myDetElemDeltaDiffRotX","myDetElemDeltaDiffRotX",100,-15,15);
  myDetElemDeltaDiffRotX->SetMaximum(nDetElems+1);
  myDetElemDeltaDiffRotX->SetMinimum(0);
  TH1F *myDetElemDeltaDiffRotY = new TH1F("myDetElemDeltaDiffRotY","myDetElemDeltaDiffRotY",100,-15,15);
  myDetElemDeltaDiffRotY->SetMaximum(nDetElems+1);
  myDetElemDeltaDiffRotY->SetMinimum(0);
  TH1F *myDetElemDeltaDiffRotZ = new TH1F("myDetElemDeltaDiffRotZ","myDetElemDeltaDiffRotZ",100,-5,5);
  myDetElemDeltaDiffRotZ->SetMaximum(nDetElems+1);
  myDetElemDeltaDiffRotZ->SetMinimum(0);

  //
  // ******** Starting plots 
  //
  TCanvas *canvas;
  TPad *pad;
  TPaveLabel *theTitle;
  gStyle->SetPalette(1);

  TPostScript *ps = 0;
  
  if( saveps ){
    ps = new TPostScript(Form("surveyChamber%d",chId+1),filetype); 
    ps->NewPage();
  }

  // Observed misalignments
  str = Form("Chamber %d",chId+1);
  TCanvas *cvn2 = new TCanvas("cvn2",str,cWidth,cHeight);
  canvas = cvn2;
  canvas->Range(0,0,21,29);
  
  title = Form(" MisAlignments Chamber %d - PL2G - In Single Frame ",chId+1);
  TPaveLabel *theTitle2 = new TPaveLabel(3,27.0,18,28.5,title,"br");
  theTitle = theTitle2;
  theTitle->SetFillColor(18);
  theTitle->SetTextFont(32);
  theTitle->SetTextSize(0.4);
  theTitle->SetTextColor(1);
  theTitle->Draw();
 
  TPad *pad2 = new TPad("pad2","pad2",0.01,0.01,0.98,0.91,0);
  pad = pad2;
  pad->Draw();
  TLine *ch0Line = new TLine(0,1,0,2);
  TLine *ch1Line = new TLine(0,1,0,2);
  ch1Line->SetLineStyle(2);
  pad->Divide(3,2);
  
  pad->cd(1);
  myDetElemDeltaDiffCenX->Draw();
  myDetElemDeltaDiffCenX->SetXTitle("#Delta[xc_{i}^{m}-xc_{i}^{th}] (mm)");
  myDetElemDeltaDiffCenX->SetYTitle("DetElem arbitrary ordering");
  gDeltaDiffCenXDetElem0->SetMarkerStyle(20);
  gDeltaDiffCenXDetElem0->Draw("P");
  ch0Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+0][0],0.5,1e1*lDeltaDiffCenDetElem0[nDetElems+0][0],1.5);
  ch0Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+0][0],3.5,1e1*lDeltaDiffCenDetElem0[nDetElems+0][0],4.5);
  ch1Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+1][0],1.5,1e1*lDeltaDiffCenDetElem0[nDetElems+1][0],3.5);

  pad->cd(2);
  myDetElemDeltaDiffCenY->Draw();
  myDetElemDeltaDiffCenY->SetXTitle("#Delta[yc_{i}^{m}-yc_{i}^{th}] (mm)");
  myDetElemDeltaDiffCenY->SetYTitle("DetElem arbitrary ordering");
  gDeltaDiffCenYDetElem0->SetMarkerStyle(20);
  gDeltaDiffCenYDetElem0->Draw("P");
  ch0Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+0][1],0.5,1e1*lDeltaDiffCenDetElem0[nDetElems+0][1],1.5);
  ch0Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+0][1],3.5,1e1*lDeltaDiffCenDetElem0[nDetElems+0][1],4.5);
  ch1Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+1][1],1.5,1e1*lDeltaDiffCenDetElem0[nDetElems+1][1],3.5);

  pad->cd(3);
  myDetElemDeltaDiffCenZ->Draw();
  myDetElemDeltaDiffCenZ->SetXTitle("#Delta[zc_{i}^{m}-zc_{i}^{th}] (mm)");
  myDetElemDeltaDiffCenZ->SetYTitle("DetElem arbitrary ordering");
  gDeltaDiffCenZDetElem0->SetMarkerStyle(20);
  gDeltaDiffCenZDetElem0->Draw("P");
  ch0Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+0][2],0.5,1e1*lDeltaDiffCenDetElem0[nDetElems+0][2],1.5);
  ch0Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+0][2],3.5,1e1*lDeltaDiffCenDetElem0[nDetElems+0][2],4.5);
  ch1Line->DrawLine(1e1*lDeltaDiffCenDetElem0[nDetElems+1][2],1.5,1e1*lDeltaDiffCenDetElem0[nDetElems+1][2],3.5);

  pad->cd(4);
  myDetElemDeltaDiffRotX->Draw();
  myDetElemDeltaDiffRotX->SetXTitle("#Delta[#psi_{i}^{m}-#psi_{i}^{th}] (mrad)");
  myDetElemDeltaDiffRotX->SetYTitle("DetElem arbitrary ordering");
  gDeltaDiffPsiDetElem0->SetMarkerStyle(20);
  gDeltaDiffPsiDetElem0->Draw("P");
  ch0Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+0][0],0.5,1e3*lDeltaDiffRotDetElem0[nDetElems+0][0],1.5);
  ch0Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+0][0],3.5,1e3*lDeltaDiffRotDetElem0[nDetElems+0][0],4.5);
  ch1Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+1][0],1.5,1e3*lDeltaDiffRotDetElem0[nDetElems+1][0],3.5);

  pad->cd(5);
  myDetElemDeltaDiffRotY->Draw();
  myDetElemDeltaDiffRotY->SetXTitle("#Delta[#theta_{i}^{m}-#theta_{i}^{th}] (mrad)");
  myDetElemDeltaDiffRotY->SetYTitle("DetElem arbitrary ordering");
  gDeltaDiffThtDetElem0->SetMarkerStyle(20);
  gDeltaDiffThtDetElem0->Draw("P");
  ch0Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+0][1],0.5,1e3*lDeltaDiffRotDetElem0[nDetElems+0][1],1.5);
  ch0Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+0][1],3.5,1e3*lDeltaDiffRotDetElem0[nDetElems+0][1],4.5);
  ch1Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+1][1],1.5,1e3*lDeltaDiffRotDetElem0[nDetElems+1][1],3.5);

  pad->cd(6);
  myDetElemDeltaDiffRotZ->Draw();
  myDetElemDeltaDiffRotZ->SetXTitle("#Delta[#phi_{i}^{m}-#phi_{i}^{th}] (mrad)");
  myDetElemDeltaDiffRotZ->SetYTitle("DetElem arbitrary ordering");
  gDeltaDiffPhiDetElem0->SetMarkerStyle(20);
  gDeltaDiffPhiDetElem0->Draw("P");
  ch0Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+0][2],0.5,1e3*lDeltaDiffRotDetElem0[nDetElems+0][2],1.5);
  ch0Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+0][2],3.5,1e3*lDeltaDiffRotDetElem0[nDetElems+0][2],4.5);
  ch1Line->DrawLine(1e3*lDeltaDiffRotDetElem0[nDetElems+1][2],1.5,1e3*lDeltaDiffRotDetElem0[nDetElems+1][2],3.5);

  pad->Update();
 
  if(bMonitor){    
    // MONITOR: Histograms for monitoring
    TH2F *hCPSTa = new TH2F("hCPSTa","hCPSTa",100,-200,200,100,-200,200);
    TH2F *hCPSTc = new TH2F("hCPSTc","hCPSTc",100,-200,200,100,-200,200);
    TH2F *hSSTa = new TH2F("hSSTa","hSSTa",100,-200,200,100,-200,200);
    TH2F *hSSTc = new TH2F("hSSTc","hSSTc",100,-200,200,100,-200,200);
    TH2F *hSSTap = new TH2F("hSSTap","hSSTap",800,-200,200,800,-200,200);
    TH2F *hSSTcp = new TH2F("hSSTcp","hSSTcp",800,-200,200,800,-200,200);
    
    // MONITOR: Fill histograms with chambers and slats sticker target positions
    for (int iCh =0; iCh<=1; iCh++) {
      myChamber = (AliMUONSurveyChamber*)myChamberArray->At(iCh);            
      cout << "Filling histograms of sticker target for chamber" << iCh+1 << " ..." << endl;
      //    myChamber->FillCPSTHistograms(TString("C"),hCPSTc);
      myChamber->FillDESTHistograms(TString("T1_46"),hSSTc);

      for (int iDetElemI=0; iDetElemI<nDetElemsI; iDetElemI++){
	//	Int_t iDetElem = iDetElemsOfChamber[iCh][iDetElemI];
	myDetElem =  myChamber->GetDetElem(iDetElemI);
	// MONITOR: Fill slat plane for fit monitor.
	Double_t pl[3] = {0};
	Double_t pg[3] = {0};
	AliSurveyPoint *pointSBT0 = myDetElem->GetLButtonTarget(0);
	AliSurveyPoint *pointSBT1 = myDetElem->GetLButtonTarget(2);
	if(pointSBT0&&pointSBT1) {
	  if (pointSBT0->GetX()>pointSBT1->GetX()){
	    pointSBT0=myDetElem->GetLButtonTarget(2);
	    pointSBT1=myDetElem->GetLButtonTarget(0);
	  }
	  Double_t lX = pointSBT0->GetX();
	  while(lX<pointSBT1->GetX()){
	    Double_t lY = pointSBT0->GetY()-50;
	    while(lY<pointSBT0->GetY()+50){
	      pl[0] = lX;  pl[1] = lY;  pl[2] = 0.;
	      (TGeoCombiTrans((*(myDetElem->GetBaseTrf()))*(*(myDetElem->GetAlignTrf())))).LocalToMaster(pl,pg);
	      if(myDetElem->GetGButtonTarget(0)->GetPointName().Contains("A")){
		if (hSSTap->GetBinContent(hSSTap->FindBin(pg[0],pg[1]))==0)
		  hSSTap->Fill(pg[0],pg[1],-pg[2]);
	      }
	      else {
		if (hSSTcp->GetBinContent(hSSTcp->FindBin(pg[0],pg[1]))==0)
		  hSSTcp->Fill(pg[0],pg[1],-pg[2]);
	      }
	      lY+=hSSTap->GetYaxis()->GetBinWidth(1);
	    }
	    lX+=hSSTap->GetXaxis()->GetBinWidth(1);
	  }
	}
      }
    }

    if( saveps ){
      ps->NewPage();
    }

    // View from side A
    str = Form("Chamber %d - side A",chId+1);
    TCanvas *cvn0 = new TCanvas("cvn0",str,cWidth,cHeight);
    canvas = cvn0;
    canvas->Range(0,0,21,29);
  
    title = Form(" Deformations of chamber %d - View from side A ",chId+1);
    TPaveLabel *theTitle0 = new TPaveLabel(3,27.0,18,28.5,title,"br");
    theTitle = theTitle0;
    theTitle->SetFillColor(18);
    theTitle->SetTextFont(32);
    theTitle->SetTextSize(0.4);
    theTitle->SetTextColor(1);
    theTitle->Draw();
 
    TPad *pad0 = new TPad("pad0","pad0",0.01,0.01,0.98,0.91,0);
    pad = pad0;
    pad->Draw();
    pad->Divide(2,2);

    pad->cd(1);
    hCPSTa->SetMinimum(950);
    hCPSTa->SetMaximum(975);
    hCPSTa->Draw("lego2z");

    pad->cd(2);
    hSSTa->SetMinimum(950);
    hSSTa->SetMaximum(980);
    hSSTa->Draw("lego2z");

    pad->cd(3);

    pad->cd(4);
    hSSTap->SetMinimum(950);
    hSSTap->SetMaximum(980);
    hSSTap->Draw("surf2z");

    pad->Update();
    if(saveps){
      ps->NewPage();
    }

    // Inv Mass, Multiplicity
    str = Form("Chamber %d - side C",chId+1);
    TCanvas *cvn1 = new TCanvas("cvn1",str,cWidth,cHeight);
    canvas = cvn1;
    canvas->Range(0,0,21,29);

    title = Form(" Deformations of chamber %d - View from side C ",chId+1);
    TPaveLabel *theTitle1 = new TPaveLabel(3,27.0,18,28.5,title,"br");
    theTitle = theTitle1;
    theTitle->SetFillColor(18);
    theTitle->SetTextFont(32);
    theTitle->SetTextSize(0.4);
    theTitle->SetTextColor(1);
    theTitle->Draw();
 
    TPad *pad1 = new TPad("pad1","pad1",0.01,0.01,0.98,0.91,0);
    pad = pad1;
    pad->Draw();
    pad->Divide(2,2);

    Double_t lMin, lMax;

    pad->cd(1);
//     hCPSTc->SetMinimum(955);
//     hCPSTc->SetMaximum(985);
//     hCPSTc->Draw("lego2z");

    pad->cd(2);
    lMin = hSSTc->GetMinimum(0);
    hSSTc->SetMinimum(TMath::Floor(lMin));
    lMax = hSSTc->GetMaximum();
    hSSTc->SetMaximum(TMath::Ceil(lMax));
    hSSTc->Draw("lego2z");

    pad->cd(3);

    pad->cd(4);
    lMin = hSSTcp->GetMinimum(0);
    hSSTcp->SetMinimum(TMath::Floor(lMin));
    lMax = hSSTcp->GetMaximum();
    hSSTcp->SetMaximum(TMath::Ceil(lMax));
    hSSTcp->Draw("surf2z");
  }

  pad->Update();
  if( saveps ){
    ps->Close();
  }

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