ATLAS Offline Software
CaloCompactCellTool.h
Go to the documentation of this file.
1 //Dear emacs, this is -*-c++-*-
2 /*
3  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
4 */
5 
6 #ifndef CALOTPCNV_CALOCOMPACTCELLTOOL_H
7 #define CALOTPCNV_CALOCOMPACTCELLTOOL_H
8 
18 #include "CLHEP/Units/SystemOfUnits.h"
19 
20 #include <math.h>
21 
22 
23 class IChronoStatSvc;
24 namespace SG {
25  class ThinningDecisionBase;
26 }
27 
29 {
30  public:
32  VERSION_400 = 400,
33  VERSION_500 = 500,
34  VERSION_501 = 501,
35  VERSION_502 = 502,
36  VERSION_503 = 503,
37  VERSION_504 = 504,
38 
39  // Select the latest version.
40  VERSION_LATEST = -1
41  };
42 
44 
45  StatusCode getTransient(const CaloCompactCellContainer & theCompactContainer,
46  CaloCellContainer * theCellContainer);
47  // fills a CaloCellContainer ; caller has the responsibility
48  // of creating and deleting the object again
49 
50  StatusCode getPersistent(const CaloCellContainer & theCellContainer,
51  CaloCompactCellContainer * theCompactContainer,
52  const SG::ThinningDecisionBase* dec,
53  int theVersion = VERSION_LATEST);
54  // fills a CaloCompactCellContainer ; caller has the responsibility
55  // of creating and deleting the object again
56 
57  private:
58 
59  int getLogCompact(const double & x, const double & log_x0, const double & log_x1, const int & n);
60 
61  double unpackLog(const int & log_x, const double & log_x0, const double & log_x1, const int & n);
62 
63  int getCubRootCompact(const double & x, const double & cbrt_x1, const int & n);
64 
65  double unpackCubRoot(const int & cbrt_x, const double & cbrt_x1, const int & n);
66 
67 };
68 
69 inline int CaloCompactCellTool::getLogCompact(const double & x,
70  const double & log_x0,
71  const double & log_x1,
72  const int & n)
73 {
74  int result = 0;
75  if ( x > 0 ) {
76  double log_x = log(x);
77  if ( log_x >= log_x1 ) {
78  result = (1<<n)-1;
79  }
80  else if ( log_x > log_x0 ) {
81  int nmax=1<<n;
82  result = (int)((log_x - log_x0)/(log_x1 - log_x0)*nmax);
83  }
84  }
85  return result;
86 }
87 
88 inline int CaloCompactCellTool::getCubRootCompact(const double & x,
89  const double & cbrt_x1,
90  const int & n){
91  int result = 0;
92  double cbrt_x=cbrt(x);
93  if ( cbrt_x >= cbrt_x1 ) {
94  result = (1<<n)-1;
95  } else {
96  int nmax=1<<n;
97  result = (int)(cbrt_x/cbrt_x1*nmax);
98  }
99  return result;
100 }
101 
102 inline double CaloCompactCellTool::unpackLog(const int & log_x,
103  const double & log_x0,
104  const double & log_x1,
105  const int & n){
106  double result = 0;
107  if ( log_x > 0 ) {
108  int nmax=1<<n;
109  result = exp((log_x+0.5)*(log_x1-log_x0)/nmax+log_x0);
110  }
111  return result;
112 }
113 
114 inline double CaloCompactCellTool::unpackCubRoot(const int & cbrt_x,
115  const double & cbrt_x1,
116  const int & n){
117  double result = 0;
118  if ( cbrt_x > 0 ) {
119  int nmax=1<<n;
120  double r = (cbrt_x+0.5)*cbrt_x1/nmax;
121  result =r*r*r;
122  }
123  return result;
124 }
125 
126 
127 #endif
128 
beamspotman.r
def r
Definition: beamspotman.py:676
CaloCompactCellTool::KNOWN_VERSIONS
KNOWN_VERSIONS
Definition: CaloCompactCellTool.h:31
get_generator_info.result
result
Definition: get_generator_info.py:21
CaloCompactCellTool::VERSION_501
@ VERSION_501
Definition: CaloCompactCellTool.h:34
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
CaloCompactCellContainer.h
CaloCompactCellTool::VERSION_500
@ VERSION_500
Definition: CaloCompactCellTool.h:33
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
SG::ThinningDecisionBase
Hold thinning decisions for one container.
Definition: ThinningDecisionBase.h:39
CaloCompactCellTool::VERSION_400
@ VERSION_400
Definition: CaloCompactCellTool.h:32
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
x
#define x
CaloCell_ID.h
CaloCompactCellTool::VERSION_503
@ VERSION_503
Definition: CaloCompactCellTool.h:36
CaloCompactCellTool::unpackCubRoot
double unpackCubRoot(const int &cbrt_x, const double &cbrt_x1, const int &n)
Definition: CaloCompactCellTool.h:114
CaloCompactCellContainer
container class for CaloCompactCell objects
Definition: CaloCompactCellContainer.h:31
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CaloCompactCellTool::VERSION_504
@ VERSION_504
Definition: CaloCompactCellTool.h:37
CaloCompactCellTool::VERSION_502
@ VERSION_502
Definition: CaloCompactCellTool.h:35
CaloCompactCellTool::getPersistent
StatusCode getPersistent(const CaloCellContainer &theCellContainer, CaloCompactCellContainer *theCompactContainer, const SG::ThinningDecisionBase *dec, int theVersion=VERSION_LATEST)
Definition: CaloCompactCellTool.cxx:67
CaloCompactCellTool::getCubRootCompact
int getCubRootCompact(const double &x, const double &cbrt_x1, const int &n)
Definition: CaloCompactCellTool.h:88
CaloCompactCellTool::VERSION_LATEST
@ VERSION_LATEST
Definition: CaloCompactCellTool.h:40
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloCompactCellTool
helper to convert from CaloCellContainer to CaloCompactCellContainer and back
Definition: CaloCompactCellTool.h:29
CaloCompactCellTool::getTransient
StatusCode getTransient(const CaloCompactCellContainer &theCompactContainer, CaloCellContainer *theCellContainer)
Definition: CaloCompactCellTool.cxx:31
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CaloCompactCellTool::unpackLog
double unpackLog(const int &log_x, const double &log_x0, const double &log_x1, const int &n)
Definition: CaloCompactCellTool.h:102
CaloCompactCellTool::getLogCompact
int getLogCompact(const double &x, const double &log_x0, const double &log_x1, const int &n)
Definition: CaloCompactCellTool.h:69
CaloCompactCellTool::CaloCompactCellTool
CaloCompactCellTool()
Definition: CaloCompactCellTool.cxx:28
nmax
const int nmax(200)