32#include "CaloEvent/CaloCluster.h"
74 unsigned int varTypePattern,
75 unsigned int clusterSize)
154 bool isExternalShowerThere =
false;
156 if (*(pCluster->
m_dataLink) !=
nullptr) isExternalShowerThere =
true;
215 bool isExternalShowerThere =
false;
217 if (*(rCluster.
m_dataLink) !=
nullptr) isExternalShowerThere =
true;
277 if (!theCell->
caloDDE())
return;
279 double theEnergyNoWeight = theCell->
e();
280 double theEnergy = weight * theEnergyNoWeight;
281 double cellEta = theCell->
eta();
282 double cellPhi = theCell->
phi();
285 double theAbsEnergy = weight * fabs(theEnergyNoWeight);
286 double thePhi =
proxim(cellPhi,this->
phi());
289 double theNewPhi =
m_posNorm * this->
phi() + theAbsEnergy * thePhi;
290 double theNewEnergy = this->
e() + theEnergy;
304 this->
setE(theNewEnergy);
314 if ( sam == CaloSampling::Unknown )
return;
317 if (sam != CaloSampling::PreSamplerB &&
318 sam != CaloSampling::PreSamplerE)
329 double theTimeNorm = fabs(weight) * theEnergy * theEnergyNoWeight;
332 + theTimeNorm * theCell->
time();
370 if ( pEStore !=
nullptr )
391 if ( pPhiStore !=
nullptr )
393 double& refPhiSamp = pPhiStore->
retrieveData(typePhi,sam);
394 thePhi =
proxim(cellPhi,refPhiSamp);
395 theNewPhi = theNewNorm != 0.
405 if ( pDPhiStore !=
nullptr )
408 double& refDPhiSamp = pDPhiStore->
retrieveData(typeDPhi,sam);
411 ( refDPhiSamp*refDPhiSamp + refPhiSamp*refPhiSamp)
412 + theAbsEnergy * thePhi * thePhi;
413 refDPhiSamp = theNewNorm != 0.
414 ? wP2 / theNewNorm - theNewPhi*theNewPhi
416 if ( refDPhiSamp > 0. )
418 refDPhiSamp = sqrt(refDPhiSamp);
422 refDPhiSamp = double(0);
427 refPhiSamp = theNewPhi;
441 if ( pEtaStore !=
nullptr )
443 double& refEtaSamp = pEtaStore->
retrieveData(typeEta,sam);
444 double theNewEta = theNewNorm != 0.
445 ? (theOldNorm*refEtaSamp+theAbsEnergy* cellEta)/theNewNorm
454 if ( pDEtaStore !=
nullptr )
456 double& refDEtaSamp = pDEtaStore->
retrieveData(typeDEta,sam);
457 double wE2 = theOldNorm * (refDEtaSamp * refDEtaSamp +
458 refEtaSamp * refEtaSamp )
459 + theAbsEnergy * cellEta * cellEta;
460 refDEtaSamp = theNewNorm != 0
461 ? wE2 / theNewNorm - theNewEta * theNewEta
463 if ( refDEtaSamp > 0. )
465 refDEtaSamp = sqrt(refDEtaSamp);
469 refDEtaSamp = double(0.0);
474 refEtaSamp = theNewEta;
486 if ( pEMaxStore !=
nullptr )
488 double& refEMaxSamp = pEMaxStore->
retrieveData(typeEMax,sam);
489 if ( refEMaxSamp < theEnergy )
492 refEMaxSamp = theEnergy;
500 if ( pEtaMaxStore !=
nullptr )
513 if ( pPhiMaxStore !=
nullptr )
531 case CaloSampling::PreSamplerE:
532 case CaloSampling::EME1:
533 case CaloSampling::EME2:
534 case CaloSampling::EME3:
535 case CaloSampling::HEC0:
536 case CaloSampling::HEC1:
537 case CaloSampling::HEC2:
538 case CaloSampling::HEC3:
539 case CaloSampling::FCAL0:
540 case CaloSampling::FCAL1:
541 case CaloSampling::FCAL2:
569 CellAccum (
double& the_posNorm,
570 std::vector<double>& the_posSamNorm,
573 double& the_timeNorm)
578 EtaMaxEnergyInSample(),
579 PhiMaxEnergyInSample(),
586 posNorm (the_posNorm),
587 posSamNorm (the_posSamNorm),
588 nBarrel (the_nBarrel),
589 nEndcap (the_nEndcap),
590 timeNorm (the_timeNorm)
592 double EnergyInSample[CaloSampling::Unknown];
593 double EtaInSample[CaloSampling::Unknown];
594 double PhiInSample[CaloSampling::Unknown];
595 double MaxEnergyInSample[CaloSampling::Unknown];
596 double EtaMaxEnergyInSample[CaloSampling::Unknown];
597 double PhiMaxEnergyInSample[CaloSampling::Unknown];
598 bool PresenceInSample[CaloSampling::Unknown];
606 std::vector<double>& posSamNorm;
617 double operator() (
const CaloCell& cell)
const
619 return m_cl.getCellWeight (&cell);
628 double operator() (
const CaloCell&)
const {
return 1; }
632template <
class WEIGHT>
634void accumCell (
const CaloCell& cell, CellAccum& accum,
const WEIGHT& w)
639 double fabsweight = fabs (weight);
641 double theEnergyNoWeight =
cell.e();
645 double theAbsEnergy =
weight * fabs(theEnergyNoWeight);
648 accum.PresenceInSample[sam] =
true;
649 double cellEta = dde->
eta();
650 double cellPhi = dde->
phi();
655 if (accum.phi0 < -900) {
656 thePhi = accum.phi0 = cellPhi;
659 thePhi =
proxim (cellPhi, accum.phi0);
661 accum.theNewEta += theAbsEnergy * cellEta;
662 accum.theNewPhi += theAbsEnergy * thePhi;
663 if ( accum.MaxEnergyInSample[sam] < theEnergy ) {
664 accum.MaxEnergyInSample[sam] =
theEnergy;
665 accum.EtaMaxEnergyInSample[sam] = cellEta;
666 accum.PhiMaxEnergyInSample[sam] = cellPhi;
669 accum.posSamNorm[sam] += theAbsEnergy;
670 accum.posNorm += theAbsEnergy;
672 accum.EtaInSample[sam] += theAbsEnergy * cellEta;
673 accum.PhiInSample[sam] += theAbsEnergy * thePhi;
680 case CaloSampling::PreSamplerE:
681 case CaloSampling::EME1:
682 case CaloSampling::EME2:
683 case CaloSampling::EME3:
684 case CaloSampling::HEC0:
685 case CaloSampling::HEC1:
686 case CaloSampling::HEC2:
687 case CaloSampling::HEC3:
688 case CaloSampling::FCAL0:
689 case CaloSampling::FCAL1:
690 case CaloSampling::FCAL2:
691 accum.nEndcap += (
weight<0?-1:1);
693 case CaloSampling::EMB1:
694 case CaloSampling::EMB2:
696 accum.nBarrel += (
weight<0?-1:1);
700 if (sam != CaloSampling::PreSamplerB &&
701 sam != CaloSampling::PreSamplerE)
703 unsigned int pmask = dde->
is_tile() ? 0x8080 : 0x2000;
706 if (
cell.provenance() & pmask ) {
708 double theTimeNorm = fabsweight *
theEnergy * theEnergyNoWeight;
709 accum.theNewTime += theTimeNorm *
cell.time();
710 accum.timeNorm += theTimeNorm;
717template <
class WEIGHT>
719void accumCells (
CaloCluster& cl, CellAccum& accum,
const WEIGHT& w)
728 accumCell (**it, accum, w);
759 accum.theNewPhi = this->
phi();
761 accumCells (*
this, accum, AccumWeight(
this));
763 accumCells (*
this, accum, AccumNoWeight());
768 this->
setEta(accum.theNewEta * inorm);
777 this->
setE(accum.theNewEnergy);
789 if ( !updateLayers )
return;
793 for(
int i=0;i<(int)CaloSampling::Unknown;i++) {
794 if ( !accum.PresenceInSample[i] )
continue;
800 accum.EtaInSample[i] *= inorm;
805#define SETVAR(v, a) maybeSetVariable(v, a, (a)+sizeof(a)/sizeof((a)[0]))
842 return pDataStore !=
nullptr
858 std::vector<double>& varList,
862 return pDataStore !=
nullptr ? pDataStore->
retrieveData(varType,varList) :
false;
874 const double& varData,
886 return pDataStore !=
nullptr
887 ? pDataStore->
storeData(varType,samType,varData)
893 const std::vector<double>& varList,
897 return pDataStore !=
nullptr
954 const int& sam)
const
957 unsigned int iSamp((
unsigned int)sam);
964 unsigned int bOff = (
unsigned int)CaloSampling::PreSamplerB;
965 unsigned int eOff = (
unsigned int)CaloSampling::PreSamplerE;
975 double vBarrel = this->
getVariable(varType,bSample,
true);
993 double eSum = eBarrel + eEndCap;
1008 vAverage = ( eBarrel * vBarrel + eEndCap * vEndCap ) / eSum;
1027 unsigned int bOff = (
unsigned int)CaloSampling::PreSamplerB;
1036 unsigned int eOff = (
unsigned int)CaloSampling::PreSamplerE;
1075 return &((*m_dataLink)->getSamplingStore());
1109 return &(
m_shower->getSamplingStore());
1149 pSecndMomStore !=
nullptr && pSecndMomStore->
size() > 0
1150 ? pSecndMomStore->
end()
1151 : pFirstMomStore->
end();
1167 return &((*m_dataLink)->getMomentStore());
1187 return &(
m_shower->getMomentStore());
1211 return pMomStore !=
nullptr && pMomStore->
contains(momType)
1226 pSecndMomStore =
nullptr;
1228 if ( pFirstMomStore ==
nullptr || pFirstMomStore->size() == 0 )
1237 pSecndMomStore = useLink ? this->
getMomentStore(useLink) :
nullptr;
1239 return pFirstMomStore !=
nullptr;
1254 if ( pMomStore !=
nullptr ) pMomStore->
insert(momType,momData);
1272 return pMomStore !=
nullptr
1273 ? pMomStore->
retrieve(momType,momData)
1307 return ! this->
isLocked(bitPattern);
1441 unsigned int size = 0;
1463 unsigned int size = 0;
1484CLHEP::HepLorentzVector
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition of CaloDetDescrManager.
CaloPhiRange class declaration.
Simple store for CaloCell links.
Data object for each calorimeter readout cell.
float time() const
get time (data member)
virtual double e() const override final
get energy (data member) (synonym to method energy()
virtual double phi() const override final
get phi (through CaloDetDescrElement)
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
uint16_t provenance() const
get provenance (data member)
virtual double eta() const override final
get eta (through CaloDetDescrElement)
Stores CaloClusterMoment in a keyed map.
virtual moment_iterator end() const
iterator loop terminator
CaloClusterMomentIterator moment_iterator
External moment iterator type.
virtual void insert(const moment_type &rMomType, const moment_value &rMomData)
Insert key/data pair.
virtual bool retrieve(const moment_type &rMomType, moment_value &rMomData) const
Retrieve cluster moment for a given key.
size_t size() const
Number of stored moments.
virtual bool contains(const moment_type &rMomType) const
Containment check.
virtual moment_iterator begin() const
{
defines enums and data types for different moments of CaloCluster
const double & getValue() const
returns the value of this moment
CaloCellLink * getCellLink()
CaloClusterNavigable()
default constructor
const CaloClusterMoment & operator*() const
Operator access to CaloClusterMoment.
const moment_store * m_secndStore
Pointer to second CaloClusterMomentStore.
MomentStoreIter prev()
Step back iterator.
bool operator==(const MomentStoreIter &anOther) const
Equality comparator.
const moment_store * m_firstStore
Pointer to first CaloClusterMomentStore.
MomentStoreIter operator--()
Post-step back operator.
MomentStoreIter next()
Advance iterator.
MomentStoreIter()
Default constructor builds unusable iterator.
~MomentStoreIter()
Destructor.
moment_iterator_i m_iter
Actual iterator on CaloClusterMomentStore.
bool operator!=(const MomentStoreIter &anOther) const
Inequality comparator.
moment_type getMomentType() const
Function access to moment type.
MomentStoreIter operator++()
Post-advance operator.
const CaloClusterMoment & getMoment() const
Function access to CaloClusterMoment.
Principal data class for CaloCell clusters.
void setphimax(sampling_type sampling, double m)
Set the of cell with maximum energy in a given sampling.
bool getMomentStorePtrs(const CaloClusterMomentStore *&pFirstStore, const CaloClusterMomentStore *&pSecndStore, bool useLink) const
double eta0() const
Returns raw of cluster seed.
void setRawEta(double eta)
Set raw eta.
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
bool retrieveMoment(const moment_type &momType, moment_value &momValue, bool useLink=true) const
Retrieve individual moment.
virtual CLHEP::HepLorentzVector hlv() const
redefine hlv() here to avoid ambiguities
double m_time
Cluster timing.
SET_VALUE m_setM
Pointer to setter functions.
double getAltM() const
Access to calibrated (cell weight) m.
MomentStoreIter moment_iterator
Moment iterator type for CaloCluster clients.
CaloClusterMomentStore m_momentStore
cluster moments
double m_rawEta
Stores raw signal.
void calculateKine(const bool useweight=true, const bool updateLayers=true)
Calculate cluster kinematics from contained cells.
void setRawM(double m)
Set raw m.
void resetBadChannel()
Reset Bad channel list.
unsigned int getClusterEtaSize() const
bool setStateRaw()
Helper to switch to raw state.
unsigned int m_samplingPattern
Sampling pattern.
double m_altE
Stores calibrated (cell weight) signal.
virtual ~CaloCluster()
Destructor.
virtual double m() const
Retrieve mass independent of signal state.
double getRawPhi() const
Access to raw phi.
void addBadChannel(const CaloClusterBadChannelData &badChannel)
Add Bad channel information.
virtual double e() const
Retrieve energy independent of signal state.
CaloCompositeCellBase< CaloClusterNavigable >::cell_iterator cell_iterator
Iterator on CaloCell s.
virtual bool hasSignalState(signalstate_t s) const
check if signal state exists for current implementation
double m_altPhi
Stores calibrated (cell weight) signal.
void setCalPhi(double phi)
Set calibrated (LC) phi.
double variableBE(const variable_type &theVariable, const int &samplingIndex) const
Rewrite as for calculation.
virtual bool setSignalState(signalstate_t s)
Sets signal state.
int m_nEndcap
Counter for number of endcap cells with non-zero weight and energy.
SET_VALUE m_setE
Pointer to setter functions.
double getCalEta() const
Access to calibrated (LC) eta.
double getAltE() const
Access to calibrated (cell weight) energy.
std::vector< CaloClusterBadChannelData > badChannelList
Get Bad Channel information.
double getRawM() const
Access to raw mass.
void setetamax(sampling_type sampling, double m)
Set the of cell with maximum energy in a given sampling.
void insertMoment(const moment_type &momType, const moment_value &momValue, bool useLink=true)
Set individual moment.
void setAltE(double e)
Set calibrated (cell weight) energy.
signalstate_t m_signalState
Stores actual signal state.
double getRawEta() const
Access to raw eta.
void setCalE(double e)
Set calibrated (LC) energy.
bool setVariable(const variable_type &varType, const sampling_type &samType, const double &varData, bool useLink=false)
General sampling variable setter.
bool lockVariable(const variable_type &varType)
Lock variable (protect against future updates)
void setRawPhi(double phi)
Set raw phi.
virtual double eta() const
Retrieve eta independent of signal state.
CaloVariableType::VariableType variable_type
Data type indicator.
bool setStateCal()
Helper to switch to calibrated (LC) state.
double getTime() const
Access cluster time.
virtual void setEta(double eta)
Set eta.
double m_phi0
Cluster seed .
signalstate_t m_defSigState
Stores default signal state.
virtual bool isAtSignalState(signalstate_t s) const
check if we are at the passed state
moment_iterator beginMoment(bool useLink=true) const
First iterator on moment store.
void setRawE(double e)
Set raw energy.
void setCalM(double m)
Set calibrated (LC) m.
CaloSamplingData * getDataStore(const variable_type &theVariable, bool useLink=true)
virtual void resetSignalState()
reset the signal state
bool m_endcap
Flag is true if at least one cell in EMB.
double getAltPhi() const
Access to calibrated (cell weight) phi.
std::vector< double > m_posSamNorm
Stores the normalization e.g.
CaloCluster(double eta0=0, double phi0=0, unsigned int varTypePattern=0x00000000, unsigned int clusterSize=CaloCluster::SW_55ele)
Constructor.
moment_store::moment_iterator moment_iterator_i
Cluster moment store iterator type.
double getCalPhi() const
Access to calibrated (LC) phi.
double getCalM() const
Access to calibrated (LC) m.
bool isLocked(const variable_type &varType) const
Check lock status of variable.
bool unlockVariable(const variable_type &varType)
Unlock variable (remove lock)
double m_altM
Stores calibrated (cell weight) signal.
double getCalE() const
Access to calibrated (LC) energy.
double m_rawM
Stores raw signal.
moment_iterator endMoment(bool useLink=true) const
Last iterator on moment store.
double getVariable(const variable_type &varType, const sampling_type &samType, bool useLink=true) const
General sampling variable access.
bool setStateAlt()
Helper to switch to calibrated (cell weight) state.
unsigned int samplingPattern() const
Get sampling bitmask.
bool setDefaultSignalState(signalstate_t s)
Sets default signal state.
const badChannelList * getBadChannel() const
double getAltEta() const
Access to calibrated (cell weight) eta.
double m_timeNorm
Stores the normalization for time calculation e.g.
SET_VALUE m_setPhi
Pointer to setter functions.
void setTime(double theTime)
Set cluster time.
bool inEndcap() const
Returns true if at least one clustered cell in EMEC.
SET_VALUE m_setEta
Pointer to setter functions.
bool isEMSampling(const sampling_type &theSampling) const
Checks if cells from a given sampling in EMB and EMEC are in the cluster.
bool hasSampling(const sampling_type &theSampling) const
Checks if certain sampling contributes to cluster.
unsigned int getClusterPhiSize() const
badChannelList m_badChannelData
bool setStores(CaloShower *pData, CaloCellLink *pLink, bool ownStores=true)
Setup internal store.
moment_store::moment_value moment_value
Cluster moment value type.
double m_posNorm
Stores the normalization e.g.
CaloClusterMomentStore * getMomentStore(bool useLink=true)
GET_VALUE m_getPhi
Pointer to getter functions.
data_link_type m_dataLink
{
virtual double phi() const
Retrieve phi independent of signal state.
bool allLocked() const
Check if all variables are locked.
double getRawE() const
Access to raw energy.
P4SignalState::State signalstate_t
CaloClusterMomentStore moment_store
Store type for cluster moments.
static const double m_errorValue
Internal error return for real numbers.
void setenergymax(sampling_type sampling, double m)
Set the maximum energy in a given sampling.
void setphisize(sampling_type sampling, double size)
Set the cluster size in for a given sampling.
CaloSamplingData m_dataStore
{\ brief Cached Stores
double m_eta0
Cluster seed .
virtual void updateKine(const CaloCell *theCell, double weight)
Updates cluster kinematics when cell is added.
moment_store::moment_type moment_type
Cluster moment indicator type.
GET_VALUE m_getEta
Pointer to getter functions.
GET_VALUE m_getM
Pointer to getter functions.
void setAltPhi(double phi)
Set calibrated (cell weight) phi.
unsigned int m_clusterSize
Cluster size (e.g.
void setCalEta(double eta)
Set calibrated (LC) eta.
CaloSampling::CaloSample sampling_type
Sampling indicator.
double phi0() const
Returns raw of cluster seed.
int m_nBarrel
Counter for number of barrel cells with non-zero weight and energy.
void setAltM(double m)
Set calibrated (cell weight) m.
void setetasize(sampling_type sampling, double size)
Set the cluster size in for a given sampling.
bool m_barrel
Flag is true if at least one cell in EMB.
virtual void setPhi(double phi)
Set phi.
GET_VALUE m_getE
Pointer to getter functions.
double m_altEta
Stores calibrated (cell weight) signal.
double m_rawPhi
Stores raw signal.
double m_basicSignal
Stores basic energy signal.
unsigned int m_lockPattern
Variable lock pattern.
void setAltEta(double eta)
Set calibrated (cell weight) eta.
bool inBarrel() const
Returns true if at least one clustered cell in EMB.
double m_rawE
Stores raw signal.
virtual void setE(double e)
Set energy.
void setRecoStatus(const CaloRecoStatus &recStatus)
Set the reconstruction status.
const CaloRecoStatus & getRecoStatus() const
Retrieve the reconstruction status.
CaloCompositeKineBase()
Constructor.
This class groups all DetDescr information related to a CaloCell.
bool is_tile() const
cell belongs to Tile
CaloCell_ID::CaloSample getSampling() const
cell sampling
float eta() const
cell eta
float phi() const
cell phi
static double fix(double phi)
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
Simple data object to store all variables in calorimeter samplings.
value_type retrieveData(variable_key_type theVariable, sampling_key_type theSampling) const
Retrieve const reference to individual variable.
bool storeData(variable_key_type theVariable, sampling_key_type theSampling, value_type theData)
}
static unsigned int getSamplingBit(const CaloSample &rSample)
Return a unique bit set for a given sampling.
provides Calorimeter Sampling enum
Data class for cluster variables associated with a CaloCluster.
bool isValid() const
Test to see if the link can be dereferenced.
I4Momentum is an abstract base class providing 4-momentum behavior.
ISignalState is an abstract base class providing support for various Signal States to be associated w...
P4EEtaPhiMBase is a base class for classes with 4-momentum behavior, for which E, eta,...
virtual void setM(double theM)
set mass data member
virtual double e() const
get energy data member
virtual double phi() const
get phi data member
virtual void setEta(double theEta)
set eta data member
P4EEtaPhiM(const double e, const double eta, const double phi, const double m)
constructor with all data members
virtual void setE(double theE)
set energy data member
virtual double eta() const
get eta data member
virtual void setPhi(double thePhi)
set phi data member
virtual double m() const
get mass data member
void nextDDE(Iter iter, Iter endIter)
Prefetch next CaloDDE.
void prefetchObj(const T *ptr)
Generic prefetch of the object of specific types (sizes).
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Functions to prefetch blocks of memory.
double proxim(double b, double a)
static unsigned int getVariableBit(const VariableType &varType)