CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SpaceManager.h
Go to the documentation of this file.
1 #ifndef SPACEMANAGER_HH_
2 #define SPACEMANAGER_HH_
7 #include <map>
8 #include <vector>
9 #include <boost/shared_ptr.hpp>
10 #include <iostream>
11 #include <TGraph.h>
12 #include <TF1.h>
13 #include <TF2.h>
14 #include <string>
15 namespace pftools {
23 class SpaceManager {
24 public:
26 
27  virtual ~SpaceManager();
28 
30  return name_;
31  }
32 
33 
34  /*
35  * Initialises the internal map of calibrators and space voxels according to the
36  * type of calibrator supplied and the specified eta, phi and energy segmentation.
37  */
38  void createCalibrators(const Calibrator& toClone, const double etaSeg,
39  const double phiSeg, const double energySeg);
40 
41  /*
42  * As above but only for the specified ranges.
43  * (Compare with ROOT TH3F histogram constructor!)
44  */
45  void createCalibrators(const Calibrator& toClone, const unsigned nEta,
46  const double etaMin, const double etaMax, const unsigned nPhi,
47  const double phiMin, const double phiMax, const unsigned nEnergy,
48  const double energyMin, const double energyMax) noexcept(false);
49 
50  void createCalibrators(const Calibrator& toClone);
51 
52  std::map<SpaceVoxelPtr, CalibratorPtr>* getCalibrators() {
53  std::map<SpaceVoxelPtr, CalibratorPtr>* ptr = &myAddressBook;
54  return ptr;
55  }
56 
57  /*
58  * Adds a calibrator for the specified volume element.
59  * Returns a pointer to it once it's been created, and returns a pointer to
60  * any exisitng calibrator should that SpaceVoxel already exist.
61  */
63 
64  /*
65  * Returns a pointer to the calibrator you need for the specified space point.
66  * Returns 0 if it's not found.
67  */
68  CalibratorPtr findCalibrator(const double eta, const double phi,
69  const double energy = 0) const;
70 
71  void assignCalibration(const CalibratorPtr& c, const std::map<DetectorElementPtr, double>& result);
72 
73  std::map<DetectorElementPtr, double> getCalibration(CalibratorPtr c);
74 
75  std::ostream& printCalibrations(std::ostream& stream);
76 
77  TH1* extractEvolution(DetectorElementPtr det, Region region, TF1& f1, bool useTruth = true);
78 
79  void addEvolution(const DetectorElementPtr& det, Region region, const TF1& f) {
80  if(region == BARREL_POS)
81  barrelPosEvolutions_[det] = f;
82  if(region == ENDCAP_POS)
83  endcapPosEvolutions_[det] = f;
84  }
85 
86  double interpolateCoefficient(DetectorElementPtr det, double energy, double eta, double phi);
87 
88  double evolveCoefficient(DetectorElementPtr det, double energy, double eta, double phi);
89 
91  return calibrationCoeffs_.size();
92  }
93  void clear();
94 
96 
97  void setBarrelLimit(double limit) {
99  }
100 
101 private:
102 
104 
105  double barrelLimit_;
107  double endcapLimit_;
108 
109  std::map<SpaceVoxelPtr, CalibratorPtr> myAddressBook;
110  std::map<CalibratorPtr, SpaceVoxelPtr> inverseAddressBook_;
111  std::map<CalibratorPtr, std::map<DetectorElementPtr, double> > calibrationCoeffs_;
112  std::vector<SpaceVoxelPtr> myKnownSpaceVoxels;
113 
114  std::vector<SpaceVoxelPtr> barrelPosRegion_;
115  std::vector<SpaceVoxelPtr> transitionPosRegion_;
116  std::vector<SpaceVoxelPtr> endcapPosRegion_;
117 
118  std::map<DetectorElementPtr, TF1> barrelPosEvolutions_;
119  std::map<DetectorElementPtr, TF1> endcapPosEvolutions_;
120 
121  std::map<Region, std::vector<SpaceVoxelPtr> > regionsToSVs_;
122 
123 
124 };
125 
126 typedef boost::shared_ptr<SpaceManager> SpaceManagerPtr;
127 
128 }
129 #endif /*SPACEMANAGER_HH_*/
std::vector< SpaceVoxelPtr > barrelPosRegion_
Definition: SpaceManager.h:114
std::vector< SpaceVoxelPtr > myKnownSpaceVoxels
Definition: SpaceManager.h:112
std::map< Region, std::vector< SpaceVoxelPtr > > regionsToSVs_
Definition: SpaceManager.h:121
#define noexcept
std::map< SpaceVoxelPtr, CalibratorPtr > * getCalibrators()
Definition: SpaceManager.h:52
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
A tool to associate SpaceVoxels with Calibrator objects.
Definition: SpaceManager.h:23
std::map< DetectorElementPtr, TF1 > barrelPosEvolutions_
Definition: SpaceManager.h:118
double evolveCoefficient(DetectorElementPtr det, double energy, double eta, double phi)
tuple result
Definition: mps_fire.py:84
void setBarrelLimit(double limit)
Definition: SpaceManager.h:97
std::vector< SpaceVoxelPtr > transitionPosRegion_
Definition: SpaceManager.h:115
boost::shared_ptr< SpaceManager > SpaceManagerPtr
Definition: SpaceManager.h:126
CalibratorPtr createCalibrator(const Calibrator &toClone, SpaceVoxelPtr s)
std::map< CalibratorPtr, std::map< DetectorElementPtr, double > > calibrationCoeffs_
Definition: SpaceManager.h:111
Region
Definition: Region.h:7
double f[11][100]
void createCalibrators(const Calibrator &toClone, const double etaSeg, const double phiSeg, const double energySeg)
Definition: SpaceManager.cc:30
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:64
boost::shared_ptr< DetectorElement > DetectorElementPtr
std::string getName()
Definition: SpaceManager.h:29
Abstract base class for Particle Flow calibration algorithms.
Definition: Calibrator.h:21
std::map< DetectorElementPtr, double > getCalibration(CalibratorPtr c)
TH1 * extractEvolution(DetectorElementPtr det, Region region, TF1 &f1, bool useTruth=true)
std::vector< SpaceVoxelPtr > endcapPosRegion_
Definition: SpaceManager.h:116
void assignCalibration(const CalibratorPtr &c, const std::map< DetectorElementPtr, double > &result)
CalibratorPtr findCalibrator(const double eta, const double phi, const double energy=0) const
std::map< DetectorElementPtr, TF1 > endcapPosEvolutions_
Definition: SpaceManager.h:119
SpaceManager(std::string name)
Definition: SpaceManager.cc:12
double interpolateCoefficient(DetectorElementPtr det, double energy, double eta, double phi)
std::ostream & printCalibrations(std::ostream &stream)
std::map< CalibratorPtr, SpaceVoxelPtr > inverseAddressBook_
Definition: SpaceManager.h:110
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
void addEvolution(const DetectorElementPtr &det, Region region, const TF1 &f)
Definition: SpaceManager.h:79