Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include "Geometry/EcalTestBeam/interface/EcalTBCrystalMap.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "CLHEP/Random/RandFlat.h"

#include <string>

int main() {
  edm::FileInPath dataFile("Geometry/EcalTestBeam/data/BarrelSM1CrystalCenterElectron120GeV.dat");
  EcalTBCrystalMap theTestMap(dataFile.fullPath());

  long nCrystal = 1700;

  for (int i = 0; i < 10; ++i) {
    int thisCrystal = CLHEP::RandFlat::shootInt(nCrystal);
    double thisEta = 0.;
    double thisPhi = 0.;

    theTestMap.findCrystalAngles(thisCrystal, thisEta, thisPhi);

    edm::LogVerbatim("EcalTestBeam") << "Crystal number " << thisCrystal << " eta = " << thisEta
                                     << " phi = " << thisPhi;

    int checkThisCrystal = theTestMap.CrystalIndex(thisEta, thisPhi);

    edm::LogVerbatim("EcalTestBeam") << "(eta,phi) = " << thisEta << " , " << thisPhi
                                     << " corresponds to crystal n. = " << checkThisCrystal;
  }

  return 0;
}