CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoParticleFlow/PFClusterTools/interface/SpaceManager.h

Go to the documentation of this file.
00001 #ifndef SPACEMANAGER_HH_
00002 #define SPACEMANAGER_HH_
00003 #include "RecoParticleFlow/PFClusterTools/interface/SpaceVoxel.h"
00004 #include "RecoParticleFlow/PFClusterTools/interface/Calibrator.h"
00005 #include "RecoParticleFlow/PFClusterTools/interface/DetectorElement.h"
00006 #include "RecoParticleFlow/PFClusterTools/interface/Region.h"
00007 #include <map>
00008 #include <vector>
00009 #include <boost/shared_ptr.hpp>
00010 #include <iostream>
00011 #include <TGraph.h>
00012 #include <TF1.h>
00013 #include <TF2.h>
00014 #include <string>
00015 namespace pftools {
00023 class SpaceManager {
00024 public:
00025         SpaceManager(std::string name);
00026 
00027         virtual ~SpaceManager();
00028         
00029         std::string getName() {
00030                 return name_;
00031         }
00032 
00033         
00034         /*
00035          * Initialises the internal map of calibrators and space voxels according to the
00036          * type of calibrator supplied and the specified eta, phi and energy segmentation.
00037          */
00038         void createCalibrators(const Calibrator& toClone, const double etaSeg,
00039                         const double phiSeg, const double energySeg);
00040 
00041         /*
00042          * As above but only for the specified ranges. 
00043          * (Compare with ROOT TH3F histogram constructor!)
00044          */
00045         void createCalibrators(const Calibrator& toClone, const unsigned nEta,
00046                         const double etaMin, const double etaMax, const unsigned nPhi,
00047                         const double phiMin, const double phiMax, const unsigned nEnergy,
00048                         const double energyMin, const double energyMax) throw(PFToolsException&);
00049         
00050         void createCalibrators(const Calibrator& toClone);
00051 
00052         std::map<SpaceVoxelPtr, CalibratorPtr>* getCalibrators() {
00053                 std::map<SpaceVoxelPtr, CalibratorPtr>* ptr = &myAddressBook;
00054                 return ptr;
00055         }
00056 
00057         /* 
00058          * Adds a calibrator for the specified volume element.
00059          * Returns a pointer to it once it's been created, and returns a pointer to
00060          * any exisitng calibrator should that SpaceVoxel already exist.
00061          */
00062         CalibratorPtr createCalibrator(const Calibrator& toClone, SpaceVoxelPtr s);
00063 
00064         /*
00065          * Returns a pointer to the calibrator you need for the specified space point.
00066          * Returns 0 if it's not found.
00067          */
00068         CalibratorPtr findCalibrator(const double eta, const double phi,
00069                         const double energy = 0) const;
00070         
00071         void assignCalibration(CalibratorPtr c, std::map<DetectorElementPtr, double> result);
00072         
00073         std::map<DetectorElementPtr, double> getCalibration(CalibratorPtr c);
00074         
00075         std::ostream& printCalibrations(std::ostream& stream);
00076         
00077         TH1* extractEvolution(DetectorElementPtr det, Region region, TF1& f1, bool useTruth = true);
00078 
00079         void addEvolution(DetectorElementPtr det, Region region, TF1 f) {
00080                 if(region == BARREL_POS)
00081                         barrelPosEvolutions_[det] = f;
00082                 if(region == ENDCAP_POS)
00083                         endcapPosEvolutions_[det] = f;
00084         }
00085         
00086         double interpolateCoefficient(DetectorElementPtr det, double energy, double eta, double  phi);
00087         
00088         double evolveCoefficient(DetectorElementPtr det, double energy, double eta, double  phi);
00089         
00090         int getNCalibrations() {
00091                 return calibrationCoeffs_.size();
00092         }
00093         void clear();
00094         
00095         void makeInverseAddressBook();
00096         
00097         void setBarrelLimit(double limit) {
00098                 barrelLimit_ = limit;
00099         }
00100 
00101 private:
00102         
00103         std::string name_;
00104         
00105         double barrelLimit_;
00106         double transitionLimit_;
00107         double endcapLimit_;
00108         
00109         std::map<SpaceVoxelPtr, CalibratorPtr> myAddressBook;
00110         std::map<CalibratorPtr, SpaceVoxelPtr> inverseAddressBook_;
00111         std::map<CalibratorPtr, std::map<DetectorElementPtr, double> > calibrationCoeffs_;
00112         std::vector<SpaceVoxelPtr> myKnownSpaceVoxels;
00113         
00114         std::vector<SpaceVoxelPtr> barrelPosRegion_;
00115         std::vector<SpaceVoxelPtr> transitionPosRegion_;
00116         std::vector<SpaceVoxelPtr> endcapPosRegion_;
00117         
00118         std::map<DetectorElementPtr, TF1> barrelPosEvolutions_;
00119         std::map<DetectorElementPtr, TF1> endcapPosEvolutions_;
00120         
00121         std::map<Region, std::vector<SpaceVoxelPtr> > regionsToSVs_;
00122         
00123         
00124 };
00125 
00126 typedef boost::shared_ptr<SpaceManager> SpaceManagerPtr;
00127 
00128 }
00129 #endif /*SPACEMANAGER_HH_*/