Commit 3de25f66 authored by Walter Lampl's avatar Walter Lampl Committed by Graeme Stewart
Browse files

migrate tool to AthAlgTool (LArCellRec-02-12-85)

parent 66c79d66
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef LARCELLREC_LArBadFebMaskingTool_H
#define LARCELLREC_LArBadFebMaskingTool_H
/**
@class LArBadFebMaskingTool
@brief Mask LAr cells in Febs with decoding errors or listed in the bad feb database
AlgTool properties (name defined in cxx file):
Handle for bad channel tool name
Switches to decide which Feb errors to mask
Created April 23, 2009 G.Unal
*/
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "CaloInterface/ICaloCellMakerTool.h"
#include "AthenaKernel/IOVSvcDefs.h"
class LArCablingService;
class StoreGateSvc;
class CaloCell_ID;
class LArOnlineID;
class ILArBadChanTool;
class LArBadFebMaskingTool: public AlgTool,
virtual public ICaloCellMakerTool
{
public:
LArBadFebMaskingTool(const std::string& type,
const std::string& name,
const IInterface* parent) ;
/** initialize the tool
*/
virtual StatusCode initialize() ;
/** finalize the tool
*/
virtual StatusCode finalize() ;
/** update theCellContainer, masking Feb with errors
*/
virtual StatusCode process( CaloCellContainer * theCellContainer) ;
/** Callback added to handle Data-driven GeoModel initialisation
*/
virtual StatusCode geoInit(IOVSVC_CALLBACK_ARGS);
private:
/** handle to bad channel tool (to get problematic Feb into)
*/
ToolHandle<ILArBadChanTool> m_badChannelTool;
/** handle to LAr cabling service
*/
ToolHandle<LArCablingService> m_cablingService;
/** flags to select which errors to mask
*/
bool m_maskParity;
bool m_maskSampleHeader;
bool m_maskEVTID;
bool m_maskScacStatus;
bool m_maskScaOutOfRange;
bool m_maskGainMismatch;
bool m_maskTypeMismatch;
bool m_maskNumOfSamples;
bool m_maskEmptyDataBlock;
bool m_maskDspBlockSize;
bool m_maskCheckSum;
bool m_maskMissingHeader;
bool m_maskBadGain;
/** key of larFebErrorSummary in storegate
*/
std::string m_larFebErrorSummaryKey;
/** compute bit mask of errors to mask
*/
uint16_t m_errorToMask;
/** pointers to storegateSvc and identifier helpers
*/
StoreGateSvc* m_storeGate;
StoreGateSvc* m_detStore;
const CaloCell_ID* m_calo_id;
const LArOnlineID* m_onlineID;
/** Number of events processed
*/
int m_evt;
/** Number of Feb masked
*/
int m_mask;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef LARCELLREC_LARCELLBUILDERFROMLARHITTOOL_H
#define LARCELLREC_LARCELLBUILDERFROMLARHITTOOL_H
/** @class LArCellBuilderFromLArHitTool
@brief Building LArCell objects from LArHit,
with the possibility to add the noise
implementation of the noise in LArCellBuilderFromLArHitTool.cxx
\verbatim
initialize()
------------
m_hitmap_init.Initialize(...)
loop on hitmap
noiseinfo = m_noisetool->GetNoiseInfo(id);
SIGMANOISE=noiseinfo.SIGMANOISE()
m_hitmap_init.SetSIGMANOISE(id,SIGMANOISE);
m_hitmap=m_hitmap_init
process(CaloCellContainer * theCellContainer)
---------
if(windows) m_hitmap=resize of m_hitmap_init
else reset hits on m_hitmap
loop on hits of LArHitContainer
m_hitmap.SetHit(id,hit);
loop on LArHitMap
choice of the gain
calculation of noise with SIGMANOISE(igain)
adds it to energy if switch WithNoise=true (default)
if(threshold good) makes the cell
adds it to CaloCellContainer
@endverbatim
*/
#include "GaudiKernel/AlgTool.h"
#include "CaloInterface/ICaloCellMakerTool.h"
#include "GaudiKernel/IIncidentListener.h"
#include "GaudiKernel/IIncidentSvc.h"
#include "GaudiKernel/Incident.h"
class CaloDetDescrManager;
class Identifier;
class StoreGateSvc;
class CaloDetDescrElement;
class IAtRndmGenSvc;
class LArG3Escale ;
#include "AtlasDetDescr/AtlasDetectorID.h"
#include "CaloIdentifier/LArID.h"
#include "Identifier/IdContext.h"
#include "AthenaKernel/IOVSvcDefs.h"
#include "StoreGate/DataHandle.h"
//#include "DataModel/DataPool.h"
#include "Identifier/IdentifierHash.h"
#include "CaloIdentifier/CaloCell_ID.h"
//#include "LArCellRec/LArHitMap.h"
#include "LArCellRec/LArHitInfo.h"
#include "CaloInterface/ICaloNoiseTool.h"
#include "CaloEvent/CaloCellContainer.h"
#include "LArElecCalib/ILArfSampl.h"
#include <CLHEP/Random/Randomize.h>
class LArCellBuilderFromLArHitTool: public AlgTool,
public IIncidentListener,
virtual public ICaloCellMakerTool
{
typedef std::vector<LArHitInfo*> CellPermanentCollection ;
public:
LArCellBuilderFromLArHitTool(
const std::string& type,
const std::string& name,
const IInterface* parent);
virtual StatusCode initialize();
virtual StatusCode process( CaloCellContainer * theCellContainer) ;
StatusCode finalize();
void handle(const Incident&);
/** Callback added to handle Data-driven GeoModel initialisation
*/
virtual StatusCode geoInit(IOVSVC_CALLBACK_ARGS);
private:
void MakeTheCell(CaloCellContainer* & cellcoll, Identifier & id,
const double & e,const double & t,const double & q);
void MakeTheCell(CaloCellContainer* & cellcoll,
const CaloDetDescrElement * & caloDDE,
const double & e,const double & t,const double & q,
const CaloGain::CaloGain & g);
StatusCode initializeCellPermamentCollection();
StatusCode resetCellPermanentCollection();
StatusCode buildWindowOnPermanentCollection();
StatusCode defineWindow();
int m_priority;
CaloCell_ID::SUBCALO m_caloNum;
const CaloDetDescrManager* m_calo_dd_man;
const CaloCell_ID* m_caloCID;
const AtlasDetectorID* m_atlas_id;
const LArEM_ID* m_emID;
const LArHEC_ID* m_hecID;
const LArFCAL_ID* m_fcalID;
const DataHandle<ILArfSampl> m_dd_fSampl;
//
std::string m_LArRegion; //Region to build
std::vector<std::string> m_HitContainers; //Hit containers
StoreGateSvc* m_storeGate;
StoreGateSvc* m_detStore;
//THRESHOLDS on E
bool m_applyHitEnergyThreshold ;
double m_eHitThreshold;
float m_ThresholdOnE;
float m_ThresholdOnAbsE;
float m_ThresholdOnEinSigma;
float m_ThresholdOnAbsEinSigma;
int m_ThresholdSelected;
int m_ThresholdSelectedNotInSigma;
//MAPs
// LArHitMap m_hitmap_init; // map to not touch after initialization
// LArHitMap m_hitmap; // map for "normal"
// replace LarHitMap
// permanent structure to sort the cell (one entry per cell in detector)
CellPermanentCollection m_cellPermanentCollection ;
// window collection
CellPermanentCollection m_windowOnPermanentCollection ;
//SWITCH on WINDOWS MODE
bool m_Windows;
float m_WindowsEtaSize;
float m_WindowsPhiSize;
std::vector<float> m_phiPart;
std::vector<float> m_etaPart;
IAtRndmGenSvc* m_AtRndmGenSvc;
//SWITCH on NOISE
bool m_WithNoise;
bool m_WithElecNoise;
bool m_WithPileUpNoise;
//NoiseTool
std::string m_NoiseToolName;
ICaloNoiseTool* m_noisetool;
//Switch to use the map
bool m_WithMap;
// MC event location
std::string m_mcEventName ;
};
#endif
//Dear emacs, this is -*- C++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef LARCELLREC_LARCELLBUILDERFROMLARRAWCHANNELTOOL_H
#define LARCELLREC_LARCELLBUILDERFROMLARRAWCHANNELTOOL_H
/**
@class LArCellBuilderFromLArRawChannelTool
@brief Building LArCell objects from LArRawChannel
AlgTool properties (name defined in cxx file):
RawChannelsName : input RawChannelContainer
EThreshold: energy threshold
Modified: Dec 4, 2002 Hong Ma
Use MakeLArCellFromRaw to make LArCell.
Modified: June 2, 2004, David Rousseau : converted to AlgTool
*/
#include "AthenaBaseComps/AthAlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "AthenaKernel/IOVSvcDefs.h"
#include "CaloInterface/ICaloCellMakerTool.h"
#include "Identifier/HWIdentifier.h"
#include "LArIdentifier/LArOnlineID.h"
#include "CaloDetDescr/CaloDetDescrElement.h"
#include "LArRawEvent/LArRawChannelContainer.h"
class CaloCellContainer ;
class LArCablingService;
class CaloDetDescrManager ;
class CaloCell_ID;
class CaloCellContainer ;
class ILArBadChanTool;
class LArCell;
/**
* @class LArCellBuilderFromLArRawChannelTool
* @brief An AlgTool class to create a LArCellContainer out of a LArRawChannel container.
*
* Inherits from ICaloCellMakerTool and should be called by an instance of the
* CaloCellMaker algorithm.
*
*/
class LArCellBuilderFromLArRawChannelTool: public AthAlgTool,
virtual public ICaloCellMakerTool
{
public:
/**
* @brief Standard AlgTool constructor
*/
LArCellBuilderFromLArRawChannelTool(const std::string& type,
const std::string& name,
const IInterface* parent);
/**
* @brief Destructor, deletes the MsgService.
*/
~LArCellBuilderFromLArRawChannelTool();
/**
* @brief Initialize method.
* @return Gaudi status code.
*
* Initialazes pointers to servies and private members variable.
* Sets the m_subCalo variable based on the m_lArRegion jobOption.
* Computes the total number of cells based on the subcalo hash-range.
*
*/
virtual StatusCode initialize();
/**
* @brief process method as defined in ICaloCellMaker interface
* @param theCellContainer Pointer to the CaloCellContainer we are working on
* @return Gaudi status code.
*
*/
virtual StatusCode process( CaloCellContainer * theCellContainer) ;
/** IOV Call Back for cabling service
*/
virtual StatusCode cablingSvc_CB (IOVSVC_CALLBACK_ARGS);
/** IOV Call Back for missing FEB tool/DB
*/
virtual StatusCode missingFEB_CB (IOVSVC_CALLBACK_ARGS);
/** Callback added to handle Data-driven GeoModel initialisation
*/
virtual StatusCode geoInit(IOVSVC_CALLBACK_ARGS);
private:
/**
* @brief Initializes @c m_hwHashToCaloDDEmap
*
* Iteratres over all CaloDetDescr elements, finds the corresponding online hash
* identifier and fill the corresponding entry in @c m_hwHashToCaloDDEmap
*(that is actually a vector) with the pointer to the CaloDDE. Elemtens that are
* not found are represented by a NULL pointer.
*
*/
StatusCode caloDDEsInitialize() ;
/**
* @brief Adds one cell to the cell container
* @param theCellContainer Pointer to the CaloCellContainer we are working on
* @param theRawChannel Pointer to the current LArRawChannel
* @param complete Wether we deal with a complete set of LArRawChannels or with a subset
*
* Transforms the LArRawChannel into a LArCell and adds it to the cell container.
* If @c complete is false, this is done by push_back, otherwise the cell is
* inserted at the position given by it's hash.
*
*/
/**
* @brief Converts one LArRawChannel into a LArCell
* @param theRawChannel Pointer to a LArRawChannel
* @param hash (output) Refernce to the hash index of the cell
* @return LArCell object (owned by a DataPool). NULL if no DDE is found.
*
*/
LArCell* getCell(const LArRawChannel& theRawChannel, IdentifierHash& hash);
/**
* @brief Gets a CaloDetectorDescriptionElement
* @param hwId Online identifier whose CaloDDE should be found.
* @return Pointer to a CaloDDE.
*
* This method uses the @c m_hwHashToCaloDDEmap to find a CaloDDE in a efficient way.
* It uses the @c LArOnlineID helper class to transform teh onlineID into a
* channel hash.
* Returns a NULL pointer if the element cannot be found.
*/
inline const CaloDetDescrElement * caloDDE (const HWIdentifier & hwId) const;
/**
* @brief Fast method to fill the LArCellContainer
* @param rawColl Pointer to the LArRawChannelContainer (input)
* @param theCellContainer Pointer to the LArCellContainer (output)
* @return Gaudi StatusCode, FAILURE if fast building failed.
*
*
*/
StatusCode fillCompleteCellCont(const LArRawChannelContainer * rawColl, CaloCellContainer * theCellContainer);
// Variables set by jobOptions
std::string m_rawChannelsName; //!< rdo container name (jO)
bool m_addDeadOTX; //!< activate addition of missing cells from dead OTX
int m_initialDataPoolSize; //!< Initial size of DataPool<LArCell>
//Internally used variables
unsigned m_nTotalCells; //!< Number of cells, set in Initialize()
const CaloDetDescrManager* m_caloDDM;
ToolHandle<LArCablingService> m_cablingSvc;
const LArOnlineID* m_onlineID;
const CaloCell_ID* m_caloCID;
ToolHandle<ILArBadChanTool> m_badChannelTool;
/// Association between online hash and pointer to CaloDDE
std::vector<const CaloDetDescrElement*> m_hwHashToCaloDDEmap;
/// vector of dummy LArRawChannels (to fill in dead cells)
std::vector<LArRawChannel> m_deadFEBChannels;
/// Number of dead FEBs:
unsigned m_nDeadFEBs;
};
inline const CaloDetDescrElement * LArCellBuilderFromLArRawChannelTool::caloDDE (const HWIdentifier & hwId) const {
const IdentifierHash hwIDhash=m_onlineID->channel_Hash(hwId);
return m_hwHashToCaloDDEmap[hwIDhash];
}
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file LArCellDeadOTXCorr.h
* @brief CaloCell energy correction tool for missing FEBs
*
*
* @author Deepak Kar
*
* @date 08/01/09
*
* @internal
* Created : 08/01/09
* Last update : 07/21/2010 10:49:12 AM
* by : JB Sauvan
*
* =====================================================================================
*/
#ifndef LARCELLDEADOTXCORR_H
#define LARCELLDEADOTXCORR_H
// CaloCell Energy Correction Tool for Missing FEBs
// by Deepak Kar with help from Guillaume Unal and Damien Prieur
// Version 1, Date Aug 1, 2009
// Headerfile
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/ToolHandle.h"
#include "GaudiKernel/Algorithm.h"
#include "GaudiKernel/Property.h"
#include "StoreGate/StoreGateSvc.h"
#include "CaloInterface/ICaloCellMakerTool.h"
#include "AthenaKernel/IOVSvcDefs.h"
#include "Identifier/Identifier.h"
#include "CaloConditions/Array.h"
#include "CaloRec/ToolWithConstantsMixin.h"
#include <string>
#include <vector>
#include <map>
class LArCablingService;
class StoreGateSvc;
class CaloCell_ID;
class LArOnlineID;
class CaloLVL1_ID;
class ILArBadChanTool;
class CaloTriggerTowerService;
// class L1CaloTTIdTools;
class CaloIdManager;
class L1CaloCondSvc;
/**
* @class LArCellDeadOTXCorr
* @brief Tool used to correct energy in missing FEBs
*
* This tool uses the trigger energy in order to fill cell energies in missing FEBs.\n
* Trigger energy is estimated with a Landau-Landau fit on ADC samples. Corrections depending on eta and on the energy are then applied.\n
* Known cell energies in the trigger tower are removed to this trigger energy, and the result is uniformly divided into the missing layer.
*/
class LArCellDeadOTXCorr : public AlgTool,
public CaloRec::ToolWithConstantsMixin,
virtual public ICaloCellMakerTool
{
public:
LArCellDeadOTXCorr(const std::string& type,
const std::string& name,
const IInterface* parent) ;
virtual ~LArCellDeadOTXCorr();
virtual StatusCode initialize() ;
virtual StatusCode process( CaloCellContainer * CellCont) ;
virtual StatusCode finalize();
// Callback added to handle Data-driven GeoModel initialisation
virtual StatusCode geoInit(IOVSVC_CALLBACK_ARGS);
using AlgTool::setProperty;
virtual StatusCode setProperty (const std::string& propname,
const std::string& value);
virtual StatusCode setProperty (const Property& p);