CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalDeadChannelRecoveryAlgos Class Reference

#include <RecoLocalCalo/EcalDeadChannelRecoveryAlgos/src/EcalDeadChannelRecoveryAlgos.cc>

List of all members.

Public Member Functions

EcalRecHit Correct (const EBDetId Id, const EcalRecHitCollection *hit_collection, std::string algo_, double Sum8Cut)
EcalRecHit correct (const EBDetId Id, const EcalRecHitCollection *hit_collection, std::string algo_, double Sum8Cut)
 EcalDeadChannelRecoveryAlgos ()
 EcalDeadChannelRecoveryAlgos (const CaloTopology *theCaloTopology)
 ~EcalDeadChannelRecoveryAlgos ()

Private Member Functions

double MakeNxNMatrice (EBDetId itID, const EcalRecHitCollection *hit_collection, int *IndDeadChannel, double *MNxN)

Private Attributes

const CaloTopologycalotopo

Detailed Description

Date:
2010/08/06 20:24:54
Revision:
1.7

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 35 of file EcalDeadChannelRecoveryAlgos.h.


Constructor & Destructor Documentation

EcalDeadChannelRecoveryAlgos::EcalDeadChannelRecoveryAlgos ( const CaloTopology theCaloTopology)

Definition at line 51 of file EcalDeadChannelRecoveryAlgos.cc.

{
  //now do what ever initialization is needed
  calotopo = theCaloTopology;
}
EcalDeadChannelRecoveryAlgos::EcalDeadChannelRecoveryAlgos ( )
EcalDeadChannelRecoveryAlgos::~EcalDeadChannelRecoveryAlgos ( )

Definition at line 59 of file EcalDeadChannelRecoveryAlgos.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

EcalRecHit EcalDeadChannelRecoveryAlgos::Correct ( const EBDetId  Id,
const EcalRecHitCollection hit_collection,
std::string  algo_,
double  Sum8Cut 
)

Definition at line 109 of file EcalDeadChannelRecoveryAlgos.cc.

{
        return correct(Id, hit_collection, algo_, Sum8Cut);
}
EcalRecHit EcalDeadChannelRecoveryAlgos::correct ( const EBDetId  Id,
const EcalRecHitCollection hit_collection,
std::string  algo_,
double  Sum8Cut 
)

Definition at line 73 of file EcalDeadChannelRecoveryAlgos.cc.

References CorrectDeadChannelsClassic(), CorrectDeadChannelsNN(), and EBDetId::ieta().

{
  double NewEnergy=0.0;
  
  double MNxN[121];
  int IndDeadChannel[1]={-1};

  double sum8 = MakeNxNMatrice(Id,hit_collection,IndDeadChannel,MNxN);

  if(algo_=="Spline"){
     
    if(sum8>Sum8Cut){
      if(IndDeadChannel[0]>0)NewEnergy = CorrectDeadChannelsClassic(MNxN,Id.ieta());
    }
  }else if(algo_=="NeuralNetworks"){
    if(sum8>Sum8Cut){
      if(IndDeadChannel[0]>0)NewEnergy = CorrectDeadChannelsNN(MNxN);
    }
  }
  
  // protect against non physical high values
  // < sum(energy in neighbours) > = 0.8 * xtal with maximum energy
  // => can choose 5 as highest possible energy to be assigned to 
  //    the dead channel
  uint32_t flag = 0;
  if ( NewEnergy > 5. * sum8 ) {
          NewEnergy = 0;
          //flag = EcalRecHit::kDead;
  }

  EcalRecHit NewHit(Id,NewEnergy,0, flag);
  return NewHit;

}
double EcalDeadChannelRecoveryAlgos::MakeNxNMatrice ( EBDetId  itID,
const EcalRecHitCollection hit_collection,
int *  IndDeadChannel,
double *  MNxN 
) [private]

Definition at line 121 of file EcalDeadChannelRecoveryAlgos.cc.

References abs, DetId::Ecal, EcalBarrel, edm::SortedCollection< T, SORT >::end(), edm::SortedCollection< T, SORT >::find(), CaloSubdetectorTopology::getWindow(), i, EBDetId::ieta(), EBDetId::iphi(), DetId::null(), and findQualityFiles::size.

                                                                                                                                             {

  //  std::cout<<" In MakeNxNMatrice "<<std::endl;

  //Build NxN around a given cristal
  for(int i=0; i<121;i++)MNxN[i]=0.0;
  
//   std::cout<<"===================================================================="<<std::endl;
//   std::cout<<" Dead Cell CENTRAL  eta = "<< itID.ieta()<<" ,  phi = "<< itID.iphi()<<std::endl;

  const CaloSubdetectorTopology* topology=calotopo->getSubdetectorTopology(DetId::Ecal,EcalBarrel);
  int size =5;
  std::vector<DetId> NxNaroundDC = topology->getWindow(itID,size,size);
  //  std::cout<<"===================================================================="<<std::endl;
  
  
  //  std::cout<<"NxNaroundDC size is = "<<NxNaroundDC.size()<<std::endl;
  std::vector<DetId>::const_iterator theCells;
  
  EBDetId EBCellMax = itID;
  double EnergyMax = 0.0;

  for(theCells=NxNaroundDC.begin();theCells<NxNaroundDC.end();theCells++){
    EBDetId EBCell = EBDetId(*theCells);
      
    // We Will look for the cristal with maximum energy 
    if(!EBCell.null()){
      EcalRecHitCollection::const_iterator goS_it = hit_collection->find(EBCell);
      if( goS_it !=  hit_collection->end() && goS_it->energy()>=EnergyMax){EnergyMax=goS_it->energy(); EBCellMax = EBCell;}
    }else{
      continue; 
    }
  } 
  if(EBCellMax.null()){/*cout<<" Error No maximum found around dead channel, no corrections applied"<<std::endl;*/return 0;}
  //  std::cout << " Max Cont Crystal eta phi E = " << EBCellMax.ieta() <<" "<< EBCellMax.iphi() <<" "<< EnergyMax<<std::endl;


  
  //NxNaroundMaxCont with N==11
  // 000 is now the maximum containement one:
  //Any modification of the following parameters will require changes in the Correction algos
  // The window is large enought to avoid modification of the number.
  int FixedSize =11;
  std::vector<DetId> NxNaroundMaxCont = topology->getWindow(EBCellMax,FixedSize,FixedSize);

  double ESUMis=0.0;
  int theIndex=0;

  std::vector<DetId>::const_iterator itCells;
  for(itCells=NxNaroundMaxCont.begin();itCells<NxNaroundMaxCont.end();itCells++){
    EBDetId EBitCell = EBDetId(*itCells);
    int CReta = EBitCell.ieta();
    int CRphi = EBitCell.iphi();

    double Energy = 0.0;
    if(!EBitCell.null()){
      EcalRecHitCollection::const_iterator goS_it = hit_collection->find(EBitCell);
      if( goS_it !=  hit_collection->end() ) Energy=goS_it->energy();
    }

    //    std::cout<<"Around DC we have eta,phi,E "<<CReta<<" "<<CRphi<<" "<<Energy<<std::endl;

    //============
    int ietaCorr = 0;
    if((CReta * EBCellMax.ieta()) < 0 && EBCellMax.ieta()>0 )ietaCorr= -1;
    if((CReta * EBCellMax.ieta()) < 0 && EBCellMax.ieta()<0 )ietaCorr=  1;
    if((CReta * EBCellMax.ieta()) > 0 )ietaCorr= 0;
    int ieta = -( (CReta -ietaCorr) - EBCellMax.ieta() ) + int((FixedSize - 1)/2);

    int iphiCorr = 0;
    if((CRphi - EBCellMax.iphi())> 50)iphiCorr= 360;
    if((CRphi - EBCellMax.iphi())<-50)iphiCorr=-360;
    int iphi = CRphi - EBCellMax.iphi() - iphiCorr + int((FixedSize - 1)/2);

    int MIndex = ieta+iphi*FixedSize;
    if(abs(CReta)<=85)
    MNxN[MIndex]=Energy;
    if(EBitCell == itID)IndDeadChannel[0]= MIndex;

    
    //============



    
    //We add up the energy in 5x5 around the MaxCont to decide if we will correct for DCs
    //  if(theIndex>=36 && theIndex<=40)ESUMis +=  Energy;
    //SB: Modify to sum8 only
    if(theIndex>=48 && theIndex<=50)ESUMis +=  Energy;
    if(theIndex>=59 && theIndex<=61)ESUMis +=  Energy;
    if(theIndex>=70 && theIndex<=72)ESUMis +=  Energy;
    //    if(theIndex>=80 && theIndex<=84)ESUMis +=  Energy;
    theIndex++;
  }
  //  std::cout<<"Around MaxCont Collected Energy in 5x5 is =  "<< ESUMis  <<std::endl;
  //So now, we have a vector which is ordered around the Maximum containement and which contains a dead channel as:
    //Filling of the vector : NxNaroundDC with N==11 Typo are possible...
    // 000 is Maximum containement which is in +/- 5 from DC
    //
    // 120 119 118 117 116 115 114 113 112 111 110  
    // 109 108 107 106 105 104 103 102 101 100 099 
    // 098 097 096 095 094 093 092 091 090 089 088
    // 087 086 085 084 083 082 081 080 079 078 077
    // 076 075 074 073 072 071 070 069 068 067 066
    // 065 064 063 062 061 060 059 058 057 056 055
    // 054 053 052 051 050 049 048 047 046 045 044
    // 043 042 041 040 039 038 037 036 035 034 033
    // 032 031 030 029 028 027 026 025 024 023 022
    // 021 020 019 018 017 016 015 014 013 012 011
    // 010 009 008 007 006 005 004 003 002 001 000
  

  
  //================

  return ESUMis;
}

Member Data Documentation

Definition at line 47 of file EcalDeadChannelRecoveryAlgos.h.