Commit 5f2c4854 authored by James Catmore's avatar James Catmore
Browse files

Merge branch 'revert-b7d65822' into '21.2'

Revert "Merge branch '21.2-egammaStrips' into '21.2'"

See merge request !4203

Former-commit-id: abe1b510790b58cd38385b8dbdbb84c0d89f97c9
parents e709ce36 8b148e9a
......@@ -55,10 +55,6 @@ class AODFix_r210(AODFix_base):
self.trklinks_postSystemRec(topSequence)
pass
if "egammaStrips" not in oldMetadataList:
self.egammaStrips_postSystemRec(topSequence)
pass
if "btagging" not in oldMetadataList:
self.btagging_postSystemRec(topSequence)
pass
......@@ -120,13 +116,3 @@ class AODFix_r210(AODFix_base):
print '#BTAG# --> ' + jet
print '#BTAG# --> ' + AuthorSubString[i]
def egammaStrips_postSystemRec(self, topSequence):
"""This fixes the strips shower shapes for electrons and photons
JIRA: https://its.cern.ch/jira/browse/ATLASRECTS-4121
"""
from egammaRec.egammaRecConf import egammaAODFixAlg
topSequence+=egammaAODFixAlg()
......@@ -83,12 +83,11 @@ egammaStripsShape::egammaStripsShape(const std::string& type,
//
// calculate quantities base on information in the strips in a region
// around the cluster.
//
// Use 2 strips in phi and cover a region of +-1.1875
// 5 cells in eta based on second sampling granularity ~0.025 in eta.
//Corresponds to ~19 strips in em barrel)
// times 0.025 in eta (corresponds to 19 strips in em barrel)
//
declareProperty("Neta",m_neta=5,
//calculate quantities based on information in a region around the cluster.
declareProperty("Neta",m_neta=2.5,
"Number of eta cell in each sampling in which to calculated shower shapes");
declareProperty("Nphi",m_nphi=2.,
......@@ -102,10 +101,6 @@ egammaStripsShape::egammaStripsShape(const std::string& type,
declareProperty("ExecOtherVariables",m_ExecOtherVariables=true,
"Calculate some less important variables");
// Use cluster cells or all cells
declareProperty("UseCellsFromCluster" ,m_UseCellsFromCluster=true,
"Use Cells from the cluster");
InitVariables();
// initialize the arrays
std::fill (m_enecell, m_enecell+STRIP_ARRAY_SIZE, 0);
......@@ -161,15 +156,19 @@ StatusCode egammaStripsShape::execute(const xAOD::CaloCluster *cluster,
{
//
// Estimate shower shapes from first compartment
// based on hottest cell in 2nd sampling , the deta,dphi,
// And the barycenter in the 1st sampling (seed)
// based on hottest cell and deta,dphi
// with eta = m_cluster->eta(sam)
// phi = m_cluster->phi(sam)
// and search for hottest cell based on granularity in the second sampling
//
ATH_MSG_DEBUG(" egammaStripsShape: execute");
// check if cluster is available
if(!cluster) {
ATH_MSG_DEBUG(" egammaStripsShape: Invalid pointer to cluster");
return StatusCode::SUCCESS;
}
// check if cell container is available
if(!cell_container) {
ATH_MSG_DEBUG(" egammaStripsShape: Invalid pointer to cell_container");
......@@ -211,7 +210,7 @@ StatusCode egammaStripsShape::execute(const xAOD::CaloCluster *cluster,
// From the original (eta,phi) position, find the location
// (sampling, barrel/end-cap, granularity)
if (!FindPosition()) {return StatusCode::SUCCESS;}
if (!FindPosition()) return StatusCode::SUCCESS;
// Fill the array in energy and eta from which all relevant
// quantities are estimated
......@@ -327,8 +326,8 @@ bool egammaStripsShape::FindPosition()
// check if cluster is in barrel or end-cap
// sam is used in SetArray to check that cells belong to strips
// samgran is used to estimated window to use cells in eta
// it is based on granularity of middle layer
// For phi we use the strip layer granularity
// it is based on granularity of middle
// NB: for phi we use the strip granularity !!!!!
bool in_barrel = m_egammaEnergyPositionAllSamples->inBarrel();
// define accordingly position of xAOD::CaloCluster
if (in_barrel) {
......@@ -368,7 +367,7 @@ bool egammaStripsShape::FindPosition()
// if no object then exit
if (!dde) return false;
// width in eta is granularity (dde->deta()) times number of cells (m_neta)
m_deta = dde->deta()*m_neta/2.0;
m_deta = dde->deta()*m_neta;
// use samgran = granularity in first sampling for phi !!!!
m_calo_dd->decode_sample(m_subcalo, m_barrel, m_sampling_or_module,
......@@ -378,9 +377,36 @@ bool egammaStripsShape::FindPosition()
// if no object then exit
if (!dde) return false;
// width in phi is granularity (dde->dphi()) times number of cells (m_nphi)
m_dphi = dde->dphi()*m_nphi/2.0;
m_dphi = dde->dphi()*m_nphi/2.;
// Calculate the size of the arrays
// granularity as for 1st sampling
CaloCell_ID::CaloSample samgran1;
if (in_barrel) {
samgran1 = CaloCell_ID::EMB1;
} else {
samgran1 = CaloCell_ID::EME1;
}
m_calo_dd->decode_sample(m_subcalo, m_barrel, m_sampling_or_module, samgran1);
dde = m_calo_dd->get_element(m_subcalo, m_sampling_or_module, m_barrel, m_etamax, m_phimax);
double deta1 = dde->deta();
// granularity as for 2nd sampling
if (in_barrel) {
samgran1 = CaloCell_ID::EMB2;
} else {
samgran1 = CaloCell_ID::EME2;
}
m_calo_dd->decode_sample(m_subcalo, m_barrel, m_sampling_or_module, samgran1);
dde = m_calo_dd->get_element(m_subcalo, m_sampling_or_module, m_barrel, m_etamax, m_phimax);
double deta2 = dde->deta();
m_sizearrayeta = (int)(2.*m_neta*deta2/deta1);
m_sizearrayeta = std::min((int)STRIP_ARRAY_SIZE,m_sizearrayeta);
// NB: actually we overwrite this logic as we use a constant size array now
m_sizearrayeta = (int)STRIP_ARRAY_SIZE;
//std::cout << " sizearrayeeta = " << m_sizearrayeta << std::endl;
return true;
}
......@@ -400,105 +426,66 @@ void egammaStripsShape::setArray(CaloSampling::CaloSample sam,
//
// two ways can be used to create the array
// 1- From the list of cells attached to the cluster
// 2 -Use a calo Cell List
// 1- from the list of cells attached to the cluster
// NB: one has to remember that a strip is added in cluster
// if phi(strip)-phi(layer2)<dphi/2.
// It can happen that in some areas were granularity is different
// that only one value of this is selected,
// and thus no merging is possible in phi
// temporary array of cell
StripArrayHelper stripArray[BIG_STRIP_ARRAY_SIZE];
StripArrayHelper stripArray[DOUBLE_STRIP_ARRAY_SIZE];
//Raw --> Calo Frame
//Other variables ATLAS Frame
//Difference is important in end-cap which is shifted by about 4 cm
//
// Convert eta, phi to raw.
// "raw" stands for Ideal/pointing positions (name is historical)
// the other variables, not labeled as raw, are real and sensitive
// to (mis)alignment
// in particular it is important in end-cap which is shifted by about 4 cm
double etaraw = eta;
double phiraw = phi;
// look for the corresponding DetDescrElement
const CaloDetDescrElement* dde =
m_calo_dd->get_element (sam == CaloSampling::EMB1 ? CaloCell_ID::EMB1 :
CaloCell_ID::EME1, eta, phi);
CaloCell_ID::EME1,
eta, phi);
// if dde is found
if (dde) {
etaraw = dde->eta_raw();
phiraw = dde->phi_raw();
}
else{
return;
etaraw += dde->eta_raw() - dde->eta();
phiraw += dde->phi_raw() - dde->phi();
} else {
// FIX-ME : what to do if dde=0 ! jusr keep (eta,phi) ?
}
//The selection will be done in Raw co-ordinates
//defines the boundaries around which to select cells
// defines the boundaries around which to select cells
double etamin = etaraw - deta;
double etamax = etaraw + deta;
double phimin = phiraw - dphi;
double phimax = phiraw + dphi;
double phimax = phiraw + dphi;
// index of elements of the array
int index_array = 0;
double eta_cell = 0.;
double phi_cell0 = 0.;
double phi_cell = 0.;
if(m_UseCellsFromCluster){
// Now loop over all cells in the cluster
xAOD::CaloCluster::const_cell_iterator first = m_cluster->cell_begin();
xAOD::CaloCluster::const_cell_iterator last = m_cluster->cell_end();
for (; first != last; ++first) {
// ensure we are in 1st sampling
const CaloCell* theCell = *first;
if (!theCell){
continue;
}
if( theCell->caloDDE()->getSampling() == sam ) {
// retrieve the eta,phi of the cell
eta_cell = theCell->caloDDE()->eta_raw();
// adjust for possible 2*pi offset.
phi_cell0 = theCell->caloDDE()->phi_raw();
phi_cell = proxim(phi_cell0,phiraw) ;
// check if we are within boundaries
if (eta_cell >= etamin && eta_cell <= etamax) {
if (phi_cell >= phimin && phi_cell <= phimax) {
// a protection is put to avoid to have an array larger
// than 2*STRIP_ARRAY_SIZE
if (index_array<BIG_STRIP_ARRAY_SIZE) {
// energy
stripArray[index_array].energy = theCell->energy()*(first.weight());
// eta
stripArray[index_array].eta = theCell->eta();
// eta raw
stripArray[index_array].etaraw = theCell->caloDDE()->eta_raw();
// eta granularity
stripArray[index_array].deta = theCell->caloDDE()->deta();
// index/number of cells in the array
stripArray[index_array].ncell++;
// increase index
index_array++;
}
}
}
}
}
}
else {
CaloCellList *ccl = new CaloCellList(m_cellContainer);
//CaloCellList uses ATLAS co-ordinates
ccl->select(dde->eta(),dde->phi_raw(),deta,dphi,sam);
// defines the cells interators
CaloCellList::list_iterator first=ccl->begin();
CaloCellList::list_iterator last =ccl->end();
for (; first != last; ++first) {
//Avoid EME1 being inner endcap
if(! ((*first)->caloDDE()->is_lar_em_endcap_inner()) )
// ensure we are in 1st sampling
if( (*first)->caloDDE()->getSampling() == sam ) {
// retrieve the eta,phi of the cell
eta_cell = (*first)->caloDDE()->eta_raw();
// adjust for possible 2*pi offset.
phi_cell0 = (*first)->caloDDE()->phi_raw();
phi_cell = proxim(phi_cell0,phiraw) ;
// check if we are within boundaries
// Now loop over all cells in the cluster
xAOD::CaloCluster::const_cell_iterator first = m_cluster->cell_begin();
xAOD::CaloCluster::const_cell_iterator last = m_cluster->cell_end();
for (; first != last; ++first) {
// ensure we are in 1st sampling
if( (*first)->caloDDE()->getSampling() == sam ) {
// retrieve the eta,phi of the cell
eta_cell = (*first)->caloDDE()->eta_raw();
// adjust for possible 2*pi offset.
phi_cell0 = (*first)->caloDDE()->phi_raw();
phi_cell = proxim(phi_cell0,phiraw) ;
// check if we are within boundaries
if (eta_cell >= etamin && eta_cell <= etamax) {
if (phi_cell >= phimin && phi_cell <= phimax) {
// a protection is put to avoid to have an array larger
// than 2*STRIP_ARRAY_SIZE
if (index_array<BIG_STRIP_ARRAY_SIZE) {
if (index_array<DOUBLE_STRIP_ARRAY_SIZE) {
// energy
stripArray[index_array].energy = (*first)->energy();
// eta
......@@ -514,15 +501,16 @@ void egammaStripsShape::setArray(CaloSampling::CaloSample sam,
}
}
}
}
}
}
// Exit early if no cells.
if (index_array == 0){
if (index_array == 0)
return;
}
// sort intermediate array with eta
std::sort(stripArray,stripArray+index_array);
// loop on intermediate array and merge two cells in phi (when they exist)
int ieta = 0;
......@@ -544,8 +532,6 @@ void egammaStripsShape::setArray(CaloSampling::CaloSample sam,
//if (fabs(stripArray[i].eta-stripArry[i+1]).eta>0.00001) next = true;
if (fabs(stripArray[i].etaraw-stripArray[i+1].etaraw)>0.00001) next = true;
if (next) {
//Increment the final array only if do not want to merge
//otherwise continue as to merge
ieta++;
next = false;
}
......@@ -553,25 +539,38 @@ void egammaStripsShape::setArray(CaloSampling::CaloSample sam,
}
// special case for last element which was not treated yet
int index = index_array-1;
//std::cout << " last index = " << index << " " << ieta << std::endl;
// if previous element had a different eta then append the array
// NB: this could happen if only one cell in phi was available
if (index == 0 ||
fabs(stripArray[index].etaraw-stripArray[index-1].etaraw)>0.00001){
fabs(stripArray[index].etaraw-stripArray[index-1].etaraw)>0.00001)
{
// energy
if (enecell_arr) enecell_arr[ieta] = stripArray[index].energy;
}
if (index != 0 &&
fabs(stripArray[index].etaraw-stripArray[index-1].etaraw)<0.00001){
fabs(stripArray[index].etaraw-stripArray[index-1].etaraw)<0.00001)
{
// energy
if (enecell_arr) {enecell_arr[ieta] += stripArray[index].energy;}
if (enecell_arr) enecell_arr[ieta] += stripArray[index].energy;
}
// eta
if (etacell_arr) {etacell_arr[ieta] = stripArray[index].eta;}
if (etacell_arr) etacell_arr[ieta] = stripArray[index].eta;
// eta granularity
if (gracell_arr) {gracell_arr[ieta] = stripArray[index].deta;}
if (gracell_arr) gracell_arr[ieta] = stripArray[index].deta;
// index/number of cells in the array
if (ncell_arr) {++ncell_arr[ieta];}
if (ncell_arr) ++ncell_arr[ieta];
//ieta++;
/*std::cout << " ieta = " << ieta << std::endl;
for (int i=0;i<40;i++) {
std::cout << " newetacell = " << i
<< " " << etacell_arr[i]
<< " " << gracell_arr[i]
<< " " << enecell_arr[i]
<< " " << ncell_arr[i]
<< std::endl;
}*/
return;
}
......@@ -592,7 +591,14 @@ void egammaStripsShape::setIndexSeed(double eta)
eta_min = m_etacell[ieta]-demi_eta;
eta_max = m_etacell[ieta]+demi_eta;
// Beware that list is arranged from larger values to smaller ones
/*std::cout << " eta = " << eta
<< " " << m_etacell[ieta]
<< " " << demi_eta
<< " " << eta_min
<< " " << eta_max
<< std::endl;*/
// beware that list is arranged from larger values to smaller ones
//if (fabs(eta)>fabs(m_etacellseed[ieta]) && fabs(eta)<=fabs(m_etacellseed[ieta+1]))
if ((fabs(eta)>fabs(eta_min) && fabs(eta)<=fabs(eta_max)) ||
(fabs(eta)<=fabs(eta_min) && fabs(eta)>fabs(eta_max)))
m_ncetaseed = ieta;
......@@ -860,18 +866,13 @@ int egammaStripsShape::setEmax2()
if (m_ncell[ieta] == 0) continue;
int ieta_left = ieta - 1;
while (ieta_left >= 0 && m_ncell[ieta_left] == 0){
while (ieta_left >= 0 && m_ncell[ieta_left] == 0)
--ieta_left;
}
if (ieta_left < 0) {continue;}
if (ieta_left < 0) continue;
int ieta_right = ieta + 1;
while (ieta_right < m_sizearrayeta && m_ncell[ieta_right] ==0){
while (ieta_right < m_sizearrayeta && m_ncell[ieta_right] ==0)
++ieta_right;
}
if (ieta_right >= m_sizearrayeta) {
continue;
}
if (ieta_right >= m_sizearrayeta) continue;
double e = m_enecell[ieta]/ m_gracell[ieta];
double e_left = m_enecell[ieta_left] / m_gracell[ieta_left];
......@@ -893,6 +894,7 @@ int egammaStripsShape::setEmax2()
m_esec = ecand;
//ncetasec = ieta;
}
// test energy of 2nd hottest local maximum
if(e>escalesec1){
escalesec1 = e;
......@@ -995,24 +997,24 @@ void egammaStripsShape::setFside()
{
//
// fraction of energy outside shower core
// (E(+/-3strips)-E(+/-1strips))/ E(+/-1strips)
// (E(+/-3strips)-E(+/-1strips))/ E(+/-1strips)
//
// NB: threshold defined by M. Seman for DC0 data (or before ?), never tuned since
double Ehsthr = 0.06*GeV;
// Local variable with max energy in strips
// local variable with max energy in strips
double e1 = m_emaxs1;
// left index defined as max-1
int ileft = m_ncetamax-1;
while (ileft > 0 && m_ncell[ileft] == 0){
while (ileft > 0 && m_ncell[ileft] == 0)
--ileft;
}
double eleft = ileft >= 0 ? m_enecell[ileft] : 0;
// right index defined as max+1
int iright = m_ncetamax+1;
while (iright < m_sizearrayeta-1 && m_ncell[iright] == 0){
while (iright < m_sizearrayeta-1 && m_ncell[iright] == 0)
++iright;
}
double eright = iright < m_sizearrayeta ? m_enecell[iright] : 0;
double fracm=0.;
......@@ -1022,6 +1024,7 @@ void egammaStripsShape::setFside()
// define index of the array from max+3 strips strips (if possible)
int nhi = std::min(m_ncetamax+3,m_sizearrayeta-1);
//std::cout << " e1 = " << e1 << " " << Ehsthr << std::endl;
if(e1>Ehsthr) {
for(int ieta=nlo;ieta<=nhi;ieta++){
if (m_ncell[ieta] == 0) continue;
......@@ -1057,9 +1060,9 @@ void egammaStripsShape::setF1core()
// total ennergy
double energy = m_cluster->e();
// build fraction only if both quantities are well defined
if ( fabs(energy) > 0. && e132 > x ){
if ( fabs(energy) > 0. && e132 > x )
m_f1core = e132/energy;
}
return;
}
......
......@@ -173,9 +173,6 @@ class egammaStripsShape : public AthAlgTool, virtual public IegammaStripsShape {
bool m_ExecAllVariables;
/** @brief boolean to calculate less important variables*/
bool m_ExecOtherVariables;
/** @brief boolean to use cluster cells or all cells */
bool m_UseCellsFromCluster;
// Calo variables
const CaloDetDescrManager* m_calo_dd;
......@@ -184,7 +181,7 @@ class egammaStripsShape : public AthAlgTool, virtual public IegammaStripsShape {
double m_dphi;
enum { STRIP_ARRAY_SIZE = 40 };
enum { BIG_STRIP_ARRAY_SIZE = STRIP_ARRAY_SIZE*3 };
enum { DOUBLE_STRIP_ARRAY_SIZE = 80 };
/** @brief array of cell energies*/
double m_enecell[STRIP_ARRAY_SIZE];
/** @brief array of cell eta*/
......
// Dear emacs, this is -*- c++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
#ifndef EGAMMAREC_EGAMMAAODFIXALG_H
#define EGAMMAREC_EGAMMAAODFIXALG_H
// System include(s):
#include <string>
// Athena/Gaudi include(s):
#include "AthenaBaseComps/AthAlgorithm.h"
// xAOD include
#include "xAODEgamma/ElectronContainerFwd.h"
#include "xAODEgamma/PhotonContainerFwd.h"
#include "xAODEgamma/EgammaFwd.h"
#include "StoreGate/ReadHandleKey.h"
/**
* @short Algorithm to fix AOD electrons and photons,
* based on mounAODFixAlg, by Edward Moyse
*
* @author Jovan Mitrevski <Jovan.Mitrevski@cern.ch>
*
*/
class CaloCellContainer;
class IegammaStripsShape;
class egammaAODFixAlg : public AthAlgorithm {
public:
/// Regular algorithm constructor
egammaAODFixAlg( const std::string& name, ISvcLocator* svcLoc );
/// Function initialising the algorithm
virtual StatusCode initialize() override;
/// Function executing the algorithm
virtual StatusCode execute() override;
private:
StatusCode fixEgamma(xAOD::Egamma* egamma,
const CaloCellContainer *cell_container);
// not really sure how to do this part with handles
std::string m_electronContainerName;
std::string m_photonContainerName;
SG::ReadHandleKey<CaloCellContainer> m_cellsKey;
ToolHandle<IegammaStripsShape> m_stripsShapeTool;
}; // class egammaAODFixAlg
#endif
......@@ -6,7 +6,6 @@
#include "egammaRec/egammaTrackSlimmer.h"
#include "egammaRec/egammaFinalizeClusters.h"
#include "egammaRec/egammaLockCollections.h"
#include "egammaRec/egammaAODFixAlg.h"
DECLARE_ALGORITHM_FACTORY( egammaBuilder )
......@@ -16,7 +15,6 @@ DECLARE_ALGORITHM_FACTORY( egammaTruthAssociationAlg)
DECLARE_ALGORITHM_FACTORY( egammaTrackSlimmer )
DECLARE_ALGORITHM_FACTORY( egammaFinalizeClusters )
DECLARE_ALGORITHM_FACTORY( egammaLockCollections )
DECLARE_ALGORITHM_FACTORY( egammaAODFixAlg )
DECLARE_FACTORY_ENTRIES(egammaRec) {
......@@ -27,6 +25,5 @@ DECLARE_FACTORY_ENTRIES(egammaRec) {
DECLARE_ALGORITHM( egammaTrackSlimmer )
DECLARE_ALGORITHM( egammaFinalizeClusters )
DECLARE_ALGORITHM( egammaLockCollections )
DECLARE_ALGORITHM( egammaAODFixAlg )
}
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// $Id$
// Gaudi/Athena include(s):
#include "StoreGate/ReadHandle.h"
// EDM include(s):
#include "CaloEvent/CaloCellContainer.h"
#include "egammaInterfaces/IegammaStripsShape.h"
#include "xAODEgamma/ElectronContainer.h"
#include "xAODEgamma/PhotonContainer.h"
#include "xAODEgamma/ElectronAuxContainer.h"
#include "xAODEgamma/PhotonAuxContainer.h"
#include "xAODEgamma/Electron.h"
#include "xAODEgamma/Photon.h"
// Local include(s):
#include "egammaRec/egammaAODFixAlg.h"
// Misc
#include <memory>
egammaAODFixAlg::egammaAODFixAlg( const std::string& name,
ISvcLocator* svcLoc )
: AthAlgorithm( name, svcLoc ),
m_stripsShapeTool("egammaStripsShape/egammastripsshape")
{
declareProperty("ElectronContainerName",
m_electronContainerName="Electrons",
"Name of Electron Container to be fixed");
declareProperty("PhotonContainerName",
m_photonContainerName="Photons",
"Name of Photon Container to be fixed");
declareProperty("CellsName", m_cellsKey = "AODCellContainer",
"The name of the topocluster collection");
declareProperty("egammaStripsShapeTool", m_stripsShapeTool, "Tool needed to recalculate strips");