CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalEleCalibLooper Class Reference

ECAL TB 2006 calibration with matrix inversion technique. More...

#include <EcalEleCalibLooper.h>

Inheritance diagram for EcalEleCalibLooper:
edm::EDLooper edm::EDLooperBase

List of all members.

Public Member Functions

void beginOfJob ()
 BeginOfJob.
Status duringLoop (const edm::Event &, const edm::EventSetup &)
 EcalEleCalibLooper (const edm::ParameterSet &)
 ctor
void endOfJob ()
Status endOfLoop (const edm::EventSetup &, unsigned int iCounter)
void startingNewLoop (unsigned int)
 ~EcalEleCalibLooper ()
 dtor

Private Member Functions

int EBregionCheck (const int eta, const int phi) const
 Tells if you are in the region to be calibrated.
void EBRegionDefinition ()
 DS EB Region Definition.
int EBRegionId (const int, const int) const
 Reg Id generator EB ----- for the barrel.
int EBregionsNum () const
 DS number of regions in EB.
int EEregionCheck (const int, const int) const
 returns zero if the coordinates are in the right place.
void EERegionDefinition ()
int EERegionId (const int, const int) const
 Gives the id of the region.
int EEregionsNum () const
 DS Number of regions in EE.
int etaShifter (const int) const
 LP Change the coordinate system.
double giveLimit (int)
 copes with the infinitives of the tangent

Private Attributes

bool isfirstcall_
edm::InputTag m_barrelAlCa
 EcalBarrel Input Collection name.
std::vector< DetIdm_barrelCells
EcalIntercalibConstantMap m_barrelMap
 the maps of recalib coeffs
std::vector< VEcalCalibBlock * > m_EcalCalibBlocks
 single blocks calibrators
edm::InputTag m_ElectronLabel
 To take the electrons.
edm::InputTag m_endcapAlCa
 EcalEndcap Input Collection name.
std::vector< DetIdm_endcapCells
EcalIntercalibConstantMap m_endcapMap
int m_etaEnd
 eta end of the region of interest
int m_etaStart
 phi size of the additive border to the sub-matrix
int m_etaWidth
 eta size of the sub-matrix
unsigned int m_loops
 DS sets the number of loops to do.
VFillMapm_MapFiller
double m_maxCoeff
 maximum coefficient accepted (RAW)
double m_maxEnergyPerCrystal
 maximum energy per crystal cut
int m_maxSelectedNumPerXtal
 maximum number of events per crystal
double m_minCoeff
 minimum coefficient accepted (RAW)
double m_minEnergyPerCrystal
 minimum energy per crystal cut
int m_phiEndEB
 phi end of the region of interest
int m_phiEndEE
int m_phiStartEB
 phi start of the region of interest
int m_phiStartEE
int m_phiWidthEB
 eta size of the additive border to the sub-matrix
int m_phiWidthEE
int m_radEnd
int m_radStart
 DS For the EE.
int m_radWidth
int m_recoWindowSidex
 reconstruction window size
int m_recoWindowSidey
std::vector< int > m_regions
int m_usingBlockSolver
 to exclude the blocksolver
std::map< int, int > m_xtalNumOfHits
std::map< int, int > m_xtalPositionInRegion
std::map< int, int > m_xtalRegionId

Detailed Description

ECAL TB 2006 calibration with matrix inversion technique.

Date:
2010/01/18 21:31:47
Revision:
1.5
Author:

Definition at line 34 of file EcalEleCalibLooper.h.


Constructor & Destructor Documentation

EcalEleCalibLooper::EcalEleCalibLooper ( const edm::ParameterSet iConfig) [explicit]

ctor

LP ctor.

Graphs to ckeck the region definition

End of Graphs

Definition at line 36 of file EcalEleCalibLooper.cc.

References algorithm(), EBRegionDefinition(), EBregionsNum(), EERegionDefinition(), EEregionsNum(), eta, cmsRelvalreport::exit, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_barrelMap, m_EcalCalibBlocks, m_endcapMap, m_etaEnd, m_etaStart, m_etaWidth, m_MapFiller, m_maxEnergyPerCrystal, m_minEnergyPerCrystal, m_radEnd, m_radStart, m_radWidth, m_recoWindowSidex, m_recoWindowSidey, m_regions, m_xtalPositionInRegion, m_xtalRegionId, dbtoconf::out, phi, AlCaHLTBitMon_QueryRunRegistry::string, EBDetId::unhashIndex(), EEDetId::validDetId(), x, and detailsBasic3DVector::y.

                                                                      :
      m_barrelAlCa (iConfig.getParameter<edm::InputTag> ("alcaBarrelHitCollection")) ,
      m_endcapAlCa (iConfig.getParameter<edm::InputTag> ("alcaEndcapHitCollection")) ,
      m_recoWindowSidex (iConfig.getParameter<int> ("recoWindowSidex")) ,
      m_recoWindowSidey (iConfig.getParameter<int> ("recoWindowSidey")) ,
      m_etaWidth (iConfig.getParameter<int> ("etaWidth")) ,
      m_phiWidthEB (iConfig.getParameter<int> ("phiWidthEB")) ,
      m_etaStart (etaShifter (iConfig.getParameter<int> ("etaStart"))) , 
      m_etaEnd (etaShifter (iConfig.getParameter<int> ("etaEnd"))) ,
      m_phiStartEB (iConfig.getParameter<int> ("phiStartEB")) , 
      m_phiEndEB (iConfig.getParameter<int> ("phiEndEB")),
      m_radStart (iConfig.getParameter<int> ("radStart")) , 
      m_radEnd (iConfig.getParameter<int> ("radEnd")) ,
      m_radWidth (iConfig.getParameter<int> ("radWidth")) ,
      m_phiStartEE (iConfig.getParameter<int> ("phiStartEE")) ,
      m_phiEndEE (iConfig.getParameter<int> ("phiEndEE")) ,
      m_phiWidthEE (iConfig.getParameter<int> ("phiWidthEE")) ,
      m_maxSelectedNumPerXtal (iConfig.getParameter<int> ("maxSelectedNumPerCrystal")) ,  
      m_minEnergyPerCrystal (iConfig.getParameter<double> ("minEnergyPerCrystal")),
      m_maxEnergyPerCrystal (iConfig.getParameter<double> ("maxEnergyPerCrystal")) ,
      m_minCoeff (iConfig.getParameter<double> ("minCoeff")) ,
      m_maxCoeff (iConfig.getParameter<double> ("maxCoeff")) ,
      m_usingBlockSolver (iConfig.getParameter<int> ("usingBlockSolver")) ,
      m_loops (iConfig.getParameter<int> ("loops")),
      m_ElectronLabel (iConfig.getParameter<edm::InputTag> ("electronLabel"))
{
  edm::LogInfo ("IML") << "[EcalEleCalibLooper][ctor] asserts" ;
  assert (!((m_etaEnd - m_etaStart )%m_etaWidth)); 

  assert (m_etaStart >=0 && m_etaStart <= 171);
  assert (m_etaEnd >= m_etaStart && m_etaEnd <= 171);
  assert ( (m_radEnd - m_radStart)%m_radWidth == 0) ; 
  assert (m_radStart >=0 && m_radStart <= 50);
  assert (m_radEnd >= m_radStart && m_radEnd <= 50);
  edm::LogInfo ("IML") << "[EcalEleCalibLooper][ctor] entering " ;
  edm::LogInfo ("IML") << "[EcalEleCalibLooper][ctor] region definition" ;
  EBRegionDefinition () ;
  EERegionDefinition () ;
  TH2F * EBRegion = new TH2F ("EBRegion","EBRegion",170,0,170,360,0,360) ;
  for (int eta = 0; eta<170; ++eta)
     for (int phi = 0; phi <360; ++phi){
        EBRegion->Fill (eta, phi,m_xtalRegionId[EBDetId::unhashIndex(eta*360+phi).rawId()] );
      }
  TH2F * EERegion = new TH2F ("EERegion", "EERegion",100,0,100,100,0,100);
  for (int x = 0; x<100; ++x)
     for (int y = 0; y<100;++y){
   if(EEDetId::validDetId(x+1,y+1,1))
             EERegion->Fill(x,y,m_xtalRegionId[EEDetId(x+1,y+1,-1).rawId()]);
     }
         
  TFile out ("EBZone.root", "recreate");
    EBRegion->Write ();
    EERegion->Write ();
  out.Close ();
  delete EERegion;
  delete EBRegion;

  //PG build the calibration algorithms for the regions
  //PG ------------------------------------------------

  edm::LogInfo ("IML") << "[EcalEleCalibLooper][ctor] Calib Block" ;
  std::string algorithm = iConfig.getParameter<std::string> ("algorithm") ;
  int eventWeight = iConfig.getUntrackedParameter<int> ("L3EventWeight",1) ;

  //PG loop over the regions set
  for (int region = 0 ; 
       region < EBregionsNum () + 2 * EEregionsNum () ; 
       ++region)
    {   
      if (algorithm == "IMA")
        m_EcalCalibBlocks.push_back (
            new IMACalibBlock (m_regions.at (region))
          ) ; 
      else if (algorithm == "L3")
        m_EcalCalibBlocks.push_back (
            new L3CalibBlock (m_regions.at (region), eventWeight)
          ) ; 
      else
        {
          edm::LogError ("building") << algorithm 
                          << " is not a valid calibration algorithm" ;
          exit (1) ;    
        }    
    } //PG loop over the regions set
  std::string mapFiller = iConfig.getParameter<std::string> ("FillType");
  if (mapFiller == "Cluster") m_MapFiller= new ClusterFillMap (
        m_recoWindowSidex ,m_recoWindowSidey ,
        m_xtalRegionId ,m_minEnergyPerCrystal ,
        m_maxEnergyPerCrystal , m_xtalPositionInRegion ,
        & m_barrelMap ,
        & m_endcapMap ); 
  if (mapFiller == "Matrix") m_MapFiller = new MatrixFillMap (
        m_recoWindowSidex ,m_recoWindowSidey ,
        m_xtalRegionId , m_minEnergyPerCrystal ,
        m_maxEnergyPerCrystal , m_xtalPositionInRegion ,
        & m_barrelMap ,
        & m_endcapMap); 
 } //end ctor
EcalEleCalibLooper::~EcalEleCalibLooper ( )

dtor

LP destructor.

Definition at line 142 of file EcalEleCalibLooper.cc.

References m_EcalCalibBlocks.

{
  edm::LogInfo ("IML") << "[EcalEleCalibLooper][dtor]" ;
  for (std::vector<VEcalCalibBlock *>::iterator calibBlock = m_EcalCalibBlocks.begin () ;
       calibBlock != m_EcalCalibBlocks.end () ;
       ++calibBlock) 
    delete (*calibBlock) ;

}

Member Function Documentation

void EcalEleCalibLooper::beginOfJob ( ) [virtual]

BeginOfJob.

Reimplemented from edm::EDLooperBase.

Definition at line 158 of file EcalEleCalibLooper.cc.

References isfirstcall_.

{
  isfirstcall_=true;
 
}
edm::EDLooper::Status EcalEleCalibLooper::duringLoop ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

duringLoop return the status Kcontinue, fills the calibBlock with the recHits

Implements edm::EDLooper.

Definition at line 194 of file EcalEleCalibLooper.cc.

References DetId::det(), DetId::Ecal, EcalBarrel, EcalEndcap, HcalObjRepresent::Fill(), VFillMap::fillMap(), first, geometry, edm::EventSetup::get(), edm::Event::getByLabel(), EcalClusterTools::getMaximum(), CaloGeometry::getValidDetIds(), isfirstcall_, edm::HandleBase::isValid(), edm::EDLooperBase::kContinue, m_barrelAlCa, m_barrelCells, m_barrelMap, m_EcalCalibBlocks, m_ElectronLabel, m_endcapAlCa, m_endcapCells, m_endcapMap, m_MapFiller, m_maxSelectedNumPerXtal, m_xtalNumOfHits, m_xtalRegionId, siStripFEDMonitor_P5_cff::Max, edm::Handle< T >::product(), and DetId::rawId().

{

  // this chunk used to belong to beginJob(isetup). Moved here
  // with the beginJob without arguments migration
  
  if (isfirstcall_){
  edm::ESHandle<CaloGeometry> geoHandle;
  iSetup.get<CaloGeometryRecord> ().get (geoHandle);
  const CaloGeometry& geometry = *geoHandle;
  m_barrelCells = geometry.getValidDetIds (DetId::Ecal, EcalBarrel);
  m_endcapCells = geometry.getValidDetIds (DetId::Ecal, EcalEndcap);
    for (std::vector<DetId>::const_iterator barrelIt=m_barrelCells.begin();
         barrelIt!=m_barrelCells.end();++barrelIt){
      m_barrelMap[*barrelIt]=1;
      m_xtalNumOfHits[barrelIt->rawId()]=0;
    }
    for (std::vector<DetId>::const_iterator endcapIt=m_endcapCells.begin();
         endcapIt!=m_endcapCells.end();++endcapIt){
      m_endcapMap[*endcapIt]=1;
      m_xtalNumOfHits[endcapIt->rawId()]=0;
    }
    
    isfirstcall_=false; 
  }
  


 //take the collection of recHits in the barrel
 const EBRecHitCollection* barrelHitsCollection = 0;
 edm::Handle<EBRecHitCollection> barrelRecHitsHandle ;
 iEvent.getByLabel (m_barrelAlCa, barrelRecHitsHandle) ;
 barrelHitsCollection = barrelRecHitsHandle.product () ;
 if (!barrelRecHitsHandle.isValid ()) {
     edm::LogError ("reading") << "[EcalEleCalibLooper] barrel rec hits not found" ;
     return  kContinue ;
    }

 //take the collection of rechis in the endcap
 const EERecHitCollection * endcapHitsCollection = 0 ;
 edm::Handle<EERecHitCollection> endcapRecHitsHandle ;
 iEvent.getByLabel (m_endcapAlCa, endcapRecHitsHandle) ;
 endcapHitsCollection = endcapRecHitsHandle.product () ;
 if (!endcapRecHitsHandle.isValid ()) {  
     edm::LogError ("reading") << "[EcalEleCalibLooper] endcap rec hits not found" ; 
     return kContinue;
   }

 //Takes the electron collection of the pixel detector
 edm::Handle<reco::GsfElectronCollection> pElectrons;
 iEvent.getByLabel (m_ElectronLabel,pElectrons);
 if (!pElectrons.isValid ()) {
     edm::LogError ("reading")<< "[EcalEleCalibLooper] electrons not found" ;
     return kContinue;
   }

 //Start the loop over the electrons 
 for (reco::GsfElectronCollection::const_iterator eleIt = pElectrons->begin ();
      eleIt != pElectrons->end ();
      ++eleIt )
   {
     double pSubtract = 0 ;
     double pTk = 0 ;
     std::map<int , double> xtlMap;
     DetId Max =0;
     if (fabs(eleIt->eta()<1.49))
             Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(),barrelHitsCollection).first;
     else 
             Max = EcalClusterTools::getMaximum(eleIt->superCluster()->hitsAndFractions(),endcapHitsCollection).first;
     if (Max.det()==0) continue;
     m_MapFiller->fillMap(eleIt->superCluster ()->hitsAndFractions (),Max, 
                           barrelHitsCollection,endcapHitsCollection, xtlMap,pSubtract);
     if (m_maxSelectedNumPerXtal > 0 && 
        m_xtalNumOfHits[Max.rawId ()] > m_maxSelectedNumPerXtal ) continue;
     ++m_xtalNumOfHits[Max.rawId()];
     if (m_xtalRegionId[Max.rawId()]==-1) continue;
     pTk = eleIt->trackMomentumAtVtx ().R ();
     m_EcalCalibBlocks.at (m_xtalRegionId[Max.rawId()])->Fill (xtlMap.begin (), 
                                                   xtlMap.end (),pTk,pSubtract) ;
   } //End of the loop over the electron collection

  return  kContinue;
} //end of duringLoop
int EcalEleCalibLooper::EBregionCheck ( const int  eta,
const int  phi 
) const [private]

Tells if you are in the region to be calibrated.

Definition at line 397 of file EcalEleCalibLooper.cc.

References m_etaEnd, m_etaStart, m_phiEndEB, and m_phiStartEB.

Referenced by EBRegionId().

 {
   if (eta < m_etaStart) return 1 ;
   if (eta >= m_etaEnd)   return 2 ;
   if (phi < m_phiStartEB) return 3 ;
   if (phi >= m_phiEndEB)   return 4 ;
   return 0 ;
 }
void EcalEleCalibLooper::EBRegionDefinition ( ) [private]

DS EB Region Definition.

Definition at line 519 of file EcalEleCalibLooper.cc.

References EBRegionId(), EBregionsNum(), eta, m_regions, m_xtalPositionInRegion, m_xtalRegionId, phi, DetId::rawId(), and EBDetId::unhashIndex().

Referenced by EcalEleCalibLooper().

{
 int reg=-1;
 for (int it = 0 ; it < EBregionsNum () ; ++it) m_regions.push_back (0) ;   
 for (int eta = 0 ; eta < 170  ; ++eta)
   for (int phi = 0 ; phi < 360 ; ++phi)
      {
        reg = EBRegionId (eta,phi) ;
        m_xtalRegionId[EBDetId::unhashIndex (eta*360+phi).rawId ()] = reg ; 
        if (reg==-1) continue;
        m_xtalPositionInRegion[EBDetId::unhashIndex (eta*360+phi).rawId ()] = m_regions.at (reg) ;
        ++m_regions.at (reg);
      }
}
int EcalEleCalibLooper::EBRegionId ( const int  etaXtl,
const int  phiXtl 
) const [private]

Reg Id generator EB ----- for the barrel.

Definition at line 455 of file EcalEleCalibLooper.cc.

References EBregionCheck(), m_etaStart, m_etaWidth, m_phiEndEB, m_phiStartEB, and m_phiWidthEB.

Referenced by EBRegionDefinition().

{
 if (EBregionCheck(etaXtl,phiXtl)) return -1;
 int phifake = m_phiStartEB;
 if (m_phiStartEB>m_phiEndEB) phifake = m_phiStartEB - 360;
 int Nphi = (m_phiEndEB-phifake)/m_phiWidthEB ;
 int etaI = (etaXtl-m_etaStart) / m_etaWidth ;  
 int phiI = (phiXtl-m_phiStartEB) / m_phiWidthEB ; 
 int regionNumEB = phiI + Nphi*etaI ;
 return (int) regionNumEB;
}
int EcalEleCalibLooper::EBregionsNum ( ) const [inline, private]

DS number of regions in EB.

Definition at line 507 of file EcalEleCalibLooper.cc.

References m_etaEnd, m_etaStart, m_etaWidth, m_phiEndEB, m_phiStartEB, m_phiWidthEB, and phi.

Referenced by EBRegionDefinition(), EcalEleCalibLooper(), and EERegionDefinition().

int EcalEleCalibLooper::EEregionCheck ( const int  ics,
const int  ips 
) const [private]

returns zero if the coordinates are in the right place.

Definition at line 576 of file EcalEleCalibLooper.cc.

References degrees(), m_phiEndEE, m_phiStartEE, m_radEnd, m_radStart, phi, x, and detailsBasic3DVector::y.

Referenced by EERegionId().

{
  int x = ics-50;
  int y = ips-50;
  double radius2 = x*x + y*y ;
  if (radius2 < 10*10) return 1;  //center of the donut
  if (radius2 > 50*50) return 1;  //outer part of the donut
  if (radius2 < m_radStart * m_radStart) return 2 ;
  if (radius2 >= m_radEnd * m_radEnd) return 2 ;
  double phi = atan2 (static_cast<double> (y),static_cast<double> (x));
  phi = degrees (phi);
  if (phi < 0) phi += 360; 
  if (m_phiStartEE < m_phiEndEE 
     && phi > m_phiStartEE && phi < m_phiEndEE ) return 0; 
  if (m_phiStartEE > m_phiEndEE 
      && (phi > m_phiStartEE || phi < m_phiEndEE )) return 0; 
   return 3;
}
void EcalEleCalibLooper::EERegionDefinition ( ) [private]

Definition at line 539 of file EcalEleCalibLooper.cc.

References bsc_activity_cfg::EBnum, EBregionsNum(), bsc_activity_cfg::EEnum, EERegionId(), EEregionsNum(), h2_mapping_cfi::ics, m_regions, m_xtalPositionInRegion, m_xtalRegionId, DetId::rawId(), and EEDetId::validDetId().

Referenced by EcalEleCalibLooper().

{
 // reset
 int EBnum=EBregionsNum();
 int EEnum=EEregionsNum();
 for (int it = 0 ; it < 2* EEnum ; ++it) m_regions.push_back (0) ;   
 // loop sui xtl 
 int reg=-1;
 for (int ics = 0 ; ics < 100 ; ++ics)
  for (int ips = 0 ; ips < 100 ; ++ips)
    {
     int ireg = EERegionId(ics, ips);
     if (ireg==-1) reg =-1;
     else reg = EBnum + ireg;
     if (EEDetId::validDetId (ics+1, ips+1, 1))
      {
        m_xtalRegionId[EEDetId (ics+1, ips+1, 1).rawId ()] = reg ; 
        if (reg==-1) continue;
        m_xtalPositionInRegion[EEDetId (ics+1, ips+1, 1).rawId ()] = m_regions.at (reg) ;
        ++m_regions.at(reg);
      }
     if (reg!=-1) reg += EEnum; 
     if (EEDetId::validDetId (ics+1, ips+1, -1))
      {
        m_xtalRegionId[EEDetId (ics+1, ips+1, -1).rawId ()] = reg ; 
        if (reg==-1) continue;
        m_xtalPositionInRegion[EEDetId (ics+1, ips+1, -1).rawId ()] = m_regions.at (reg) ;
        ++m_regions.at (reg) ;
       }
    }
}
int EcalEleCalibLooper::EERegionId ( const int  ics,
const int  ips 
) const [private]

Gives the id of the region.

Definition at line 472 of file EcalEleCalibLooper.cc.

References degrees(), EEregionCheck(), m_phiEndEE, m_phiStartEE, m_phiWidthEE, m_radStart, m_radWidth, phi, CosmicsPD_Skims::radius, and mathSSE::sqrt().

Referenced by EERegionDefinition().

{
 if (EEregionCheck(ics,ips)) return -1;
 int phifake = m_phiStartEE;
 if (m_phiStartEE>m_phiEndEE) phifake = m_phiStartEE - 360;
 double radius = (ics-50) * (ics-50) + (ips-50) * (ips-50) ;
 radius = sqrt (radius) ;
 int Nphi = (m_phiEndEE - phifake)/m_phiWidthEE ;
 double phi = atan2 (static_cast<double> (ips-50), 
                     static_cast<double> (ics-50)) ;
 phi = degrees (phi);
 if (phi < 0) phi += 360; 
 int radI = static_cast<int> ((radius-m_radStart) / m_radWidth) ;
 int phiI = static_cast<int> ((m_phiEndEE-phi) / m_phiWidthEE) ;
 int regionNumEE = phiI + Nphi*radI ;
 return  regionNumEE ;
}
int EcalEleCalibLooper::EEregionsNum ( ) const [inline, private]

DS Number of regions in EE.

Definition at line 495 of file EcalEleCalibLooper.cc.

References m_phiEndEE, m_phiStartEE, m_phiWidthEE, m_radEnd, m_radStart, and m_radWidth.

Referenced by EcalEleCalibLooper(), and EERegionDefinition().

{
  int phifake = m_phiStartEE;
  if (m_phiStartEE>m_phiEndEE) phifake = m_phiStartEE - 360;
  return ( (m_radEnd - m_radStart)/m_radWidth) * ( (m_phiEndEE - phifake)/m_phiWidthEE) ;
}
void EcalEleCalibLooper::endOfJob ( ) [virtual]

LP endOfJob writes the coefficients in the xml format and exits

Reimplemented from edm::EDLooperBase.

Definition at line 365 of file EcalEleCalibLooper.cc.

References EcalBarrel, EcalEndcap, m_barrelCells, m_barrelMap, m_endcapCells, m_endcapMap, and calibXMLwriter::writeLine().

{
 edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfJob] saving calib coeffs" ;

//Writes the coeffs 
 calibXMLwriter barrelWriter (EcalBarrel);
 calibXMLwriter endcapWriter (EcalEndcap);
 for (std::vector<DetId>::const_iterator barrelIt = m_barrelCells.begin (); 
       barrelIt!=m_barrelCells.end (); 
       ++barrelIt) 
   {
     EBDetId eb (*barrelIt);
     barrelWriter.writeLine (eb,m_barrelMap[*barrelIt]);
   }
 for (std::vector<DetId>::const_iterator endcapIt = m_endcapCells.begin ();
      endcapIt!=m_endcapCells.end ();
      ++endcapIt) 
   {
     EEDetId ee (*endcapIt);
     endcapWriter.writeLine (ee,m_endcapMap[*endcapIt]);
   }
 edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfJob] Exiting" ;    
}
edm::EDLooper::Status EcalEleCalibLooper::endOfLoop ( const edm::EventSetup dumb,
unsigned int  iCounter 
) [virtual]

EndOfLoop Return kContinue if there's still another loop to be done; otherwise stops returnig kStop; Takes the coefficients solving the calibBlock;

Implements edm::EDLooperBase.

Definition at line 286 of file EcalEleCalibLooper.cc.

References lut2db_cfg::filename, EBDetId::ieta(), getHLTprescales::index, EBDetId::iphi(), EEDetId::ix(), EEDetId::iy(), edm::EDLooperBase::kContinue, edm::EDLooperBase::kStop, m_barrelCells, m_barrelMap, m_EcalCalibBlocks, m_endcapCells, m_endcapMap, m_loops, m_maxCoeff, m_minCoeff, m_usingBlockSolver, m_xtalPositionInRegion, m_xtalRegionId, and EEDetId::zside().

{
 edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfLoop] entering..." ;
 for (std::vector<VEcalCalibBlock *>::iterator calibBlock = m_EcalCalibBlocks.begin ();
       calibBlock!=m_EcalCalibBlocks.end ();
       ++calibBlock) 
   (*calibBlock)->solve (m_usingBlockSolver, m_minCoeff,m_maxCoeff);

  TH1F * EBcoeffEnd = new TH1F ("EBRegion","EBRegion",100,0.5,2.1) ;
  TH2F * EBcoeffMap = new TH2F ("EBcoeff","EBcoeff",171,-85,85,360,1,361);
  TH1F * EEPcoeffEnd = new TH1F ("EEPRegion", "EEPRegion",100,0.5,2.1);
  TH1F * EEMcoeffEnd = new TH1F ("EEMRegion", "EEMRegion",100,0.5,2.1);
  TH2F * EEPcoeffMap = new TH2F ("EEPcoeffMap","EEPcoeffMap",101,1,101,101,0,101);
  TH2F * EEMcoeffMap = new TH2F ("EEMcoeffMap","EEMcoeffMap",101,1,101,101,0,101);
 //loop over the barrel xtals to get the coeffs
 for (std::vector<DetId>::const_iterator barrelIt=m_barrelCells.begin();
       barrelIt!=m_barrelCells.end();++barrelIt)
        {
          EBDetId ee (*barrelIt);
          int index= barrelIt->rawId();
          if(m_xtalRegionId[index]==-1)continue;
          m_barrelMap[*barrelIt] *= 
              m_EcalCalibBlocks.at(m_xtalRegionId[index])->at(m_xtalPositionInRegion[index]);
          EBcoeffEnd->Fill(m_barrelMap[*barrelIt]);
          EBcoeffMap->Fill(ee.ieta(),ee.iphi(),m_barrelMap[*barrelIt]);
        } //PG loop over phi

  // loop over the EndCap to get the recalib coefficients
    for(std::vector<DetId>::const_iterator endcapIt=m_endcapCells.begin();
         endcapIt!=m_endcapCells.end();++endcapIt)
    {
     EEDetId ee (*endcapIt);
     int index =endcapIt->rawId(); 
     if (ee.zside()>0) 
        { 
          if (m_xtalRegionId[index]==-1) continue ;
          m_endcapMap[*endcapIt] *= 
             m_EcalCalibBlocks.at (m_xtalRegionId[index])->at (m_xtalPositionInRegion[index]);
          EEPcoeffEnd->Fill (m_endcapMap[*endcapIt]) ;
          EEPcoeffMap->Fill (ee.ix(),ee.iy(),m_endcapMap[*endcapIt]) ;
        }
      else
        {
          m_endcapMap[*endcapIt] *= 
            m_EcalCalibBlocks.at (m_xtalRegionId[index])->at (m_xtalPositionInRegion[index]);
          EEMcoeffEnd->Fill (m_endcapMap[*endcapIt]) ;
          EEMcoeffMap->Fill (ee.ix(),ee.iy(),m_endcapMap[*endcapIt]) ;
        }
    } // loop over the EndCap to get the recalib coefficients

  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][endOfLoop] End of endOfLoop" ;

  char filename[80];
  sprintf(filename,"coeffs%d.root",iCounter);
  TFile zout (filename, "recreate");
  EBcoeffEnd->Write () ;
  EBcoeffMap->Write () ;
  EEPcoeffEnd->Write () ;
  EEPcoeffMap->Write () ;
  EEMcoeffEnd->Write () ;
  EEMcoeffMap->Write () ;
  zout.Close () ;
  delete EBcoeffEnd;
  delete EBcoeffMap;
  delete EEPcoeffEnd;
  delete EEMcoeffEnd;
  delete EEPcoeffMap;
  delete EEMcoeffMap;
  if (iCounter < m_loops-1 ) return kContinue ;
  else return kStop; 
}
int EcalEleCalibLooper::etaShifter ( const int  etaOld) const [private]

LP Change the coordinate system.

Definition at line 600 of file EcalEleCalibLooper.cc.

   {
     if (etaOld < 0) return etaOld + 85;
     else if (etaOld > 0) return etaOld + 84;
     assert(0!=etaOld); // etaOld = 0, apparently not a foreseen value, so fail
     return 999; // dummy statement to silence compiler warning
   }
double EcalEleCalibLooper::giveLimit ( int  degrees) [private]

copes with the infinitives of the tangent

Definition at line 431 of file EcalEleCalibLooper.cc.

References radiants(), and funct::tan().

  {
    //PG 200 > atan (50/0.5)
    if (degrees == 90) return 90 ; 
    return tan (radiants (degrees)) ;      
  } 
void EcalEleCalibLooper::startingNewLoop ( unsigned int  ciclo) [virtual]

startingNewLoop empties the map of the calibBlock so that it can be filled

Implements edm::EDLooperBase.

Definition at line 170 of file EcalEleCalibLooper.cc.

References m_EcalCalibBlocks, and m_xtalNumOfHits.

{
  edm::LogInfo ("IML") << "[InvMatrixCalibLooper][Start] entering loop " << ciclo;

 

  for (std::vector<VEcalCalibBlock *>::iterator calibBlock = m_EcalCalibBlocks.begin () ;
       calibBlock != m_EcalCalibBlocks.end () ;
       ++calibBlock) 
          (*calibBlock)->reset ();
  for (std::map<int,int>::iterator it= m_xtalNumOfHits.begin();
       it!=m_xtalNumOfHits.end();
       ++it)
    it->second = 0 ;
 return ;
}

Member Data Documentation

Definition at line 145 of file EcalEleCalibLooper.h.

Referenced by beginOfJob(), and duringLoop().

EcalBarrel Input Collection name.

Definition at line 70 of file EcalEleCalibLooper.h.

Referenced by duringLoop().

std::vector<DetId> EcalEleCalibLooper::m_barrelCells [private]

Definition at line 138 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), endOfJob(), and endOfLoop().

the maps of recalib coeffs

Definition at line 121 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), EcalEleCalibLooper(), endOfJob(), and endOfLoop().

single blocks calibrators

Definition at line 108 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), EcalEleCalibLooper(), endOfLoop(), startingNewLoop(), and ~EcalEleCalibLooper().

To take the electrons.

Definition at line 127 of file EcalEleCalibLooper.h.

Referenced by duringLoop().

EcalEndcap Input Collection name.

Definition at line 72 of file EcalEleCalibLooper.h.

Referenced by duringLoop().

std::vector<DetId> EcalEleCalibLooper::m_endcapCells [private]

Definition at line 139 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), endOfJob(), and endOfLoop().

Definition at line 122 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), EcalEleCalibLooper(), endOfJob(), and endOfLoop().

eta end of the region of interest

Definition at line 90 of file EcalEleCalibLooper.h.

Referenced by EBregionCheck(), EBregionsNum(), and EcalEleCalibLooper().

phi size of the additive border to the sub-matrix

eta start of the region of interest

Definition at line 88 of file EcalEleCalibLooper.h.

Referenced by EBregionCheck(), EBRegionId(), EBregionsNum(), and EcalEleCalibLooper().

eta size of the sub-matrix

Definition at line 79 of file EcalEleCalibLooper.h.

Referenced by EBRegionId(), EBregionsNum(), and EcalEleCalibLooper().

unsigned int EcalEleCalibLooper::m_loops [private]

DS sets the number of loops to do.

Definition at line 125 of file EcalEleCalibLooper.h.

Referenced by endOfLoop().

Definition at line 129 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), and EcalEleCalibLooper().

maximum coefficient accepted (RAW)

Definition at line 116 of file EcalEleCalibLooper.h.

Referenced by endOfLoop().

maximum energy per crystal cut

Definition at line 112 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper().

maximum number of events per crystal

Definition at line 105 of file EcalEleCalibLooper.h.

Referenced by duringLoop().

minimum coefficient accepted (RAW)

Definition at line 114 of file EcalEleCalibLooper.h.

Referenced by endOfLoop().

minimum energy per crystal cut

Definition at line 110 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper().

phi end of the region of interest

Definition at line 94 of file EcalEleCalibLooper.h.

Referenced by EBregionCheck(), EBRegionId(), and EBregionsNum().

Definition at line 101 of file EcalEleCalibLooper.h.

Referenced by EEregionCheck(), EERegionId(), and EEregionsNum().

phi start of the region of interest

Definition at line 92 of file EcalEleCalibLooper.h.

Referenced by EBregionCheck(), EBRegionId(), and EBregionsNum().

Definition at line 100 of file EcalEleCalibLooper.h.

Referenced by EEregionCheck(), EERegionId(), and EEregionsNum().

eta size of the additive border to the sub-matrix

phi size of the sub-matrix

Definition at line 83 of file EcalEleCalibLooper.h.

Referenced by EBRegionId(), and EBregionsNum().

Definition at line 102 of file EcalEleCalibLooper.h.

Referenced by EERegionId(), and EEregionsNum().

Definition at line 97 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper(), EEregionCheck(), and EEregionsNum().

DS For the EE.

Definition at line 96 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper(), EEregionCheck(), EERegionId(), and EEregionsNum().

Definition at line 98 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper(), EERegionId(), and EEregionsNum().

reconstruction window size

Definition at line 75 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper().

Definition at line 76 of file EcalEleCalibLooper.h.

Referenced by EcalEleCalibLooper().

std::vector<int> EcalEleCalibLooper::m_regions [private]

to exclude the blocksolver

Definition at line 118 of file EcalEleCalibLooper.h.

Referenced by endOfLoop().

std::map<int,int> EcalEleCalibLooper::m_xtalNumOfHits [private]

Definition at line 143 of file EcalEleCalibLooper.h.

Referenced by duringLoop(), and startingNewLoop().

std::map<int,int> EcalEleCalibLooper::m_xtalPositionInRegion [private]
std::map<int,int> EcalEleCalibLooper::m_xtalRegionId [private]