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