CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
pftools::SpaceManager Class Reference

A tool to associate SpaceVoxels with Calibrator objects. More...

#include <SpaceManager.h>

Public Member Functions

void addEvolution (DetectorElementPtr det, Region region, TF1 f)
 
void assignCalibration (CalibratorPtr c, std::map< DetectorElementPtr, double > result)
 
void clear ()
 
CalibratorPtr createCalibrator (const Calibrator &toClone, SpaceVoxelPtr s)
 
void createCalibrators (const Calibrator &toClone, const double etaSeg, const double phiSeg, const double energySeg)
 
void createCalibrators (const Calibrator &toClone, const unsigned nEta, const double etaMin, const double etaMax, const unsigned nPhi, const double phiMin, const double phiMax, const unsigned nEnergy, const double energyMin, const double energyMax) throw (PFToolsException&)
 
void createCalibrators (const Calibrator &toClone)
 
double evolveCoefficient (DetectorElementPtr det, double energy, double eta, double phi)
 
TH1 * extractEvolution (DetectorElementPtr det, Region region, TF1 &f1, bool useTruth=true)
 
CalibratorPtr findCalibrator (const double eta, const double phi, const double energy=0) const
 
std::map< DetectorElementPtr,
double > 
getCalibration (CalibratorPtr c)
 
std::map< SpaceVoxelPtr,
CalibratorPtr > * 
getCalibrators ()
 
std::string getName ()
 
int getNCalibrations ()
 
double interpolateCoefficient (DetectorElementPtr det, double energy, double eta, double phi)
 
void makeInverseAddressBook ()
 
std::ostream & printCalibrations (std::ostream &stream)
 
void setBarrelLimit (double limit)
 
 SpaceManager (std::string name)
 
virtual ~SpaceManager ()
 

Private Attributes

double barrelLimit_
 
std::map< DetectorElementPtr, TF1 > barrelPosEvolutions_
 
std::vector< SpaceVoxelPtrbarrelPosRegion_
 
std::map< CalibratorPtr,
std::map< DetectorElementPtr,
double > > 
calibrationCoeffs_
 
double endcapLimit_
 
std::map< DetectorElementPtr, TF1 > endcapPosEvolutions_
 
std::vector< SpaceVoxelPtrendcapPosRegion_
 
std::map< CalibratorPtr,
SpaceVoxelPtr
inverseAddressBook_
 
std::map< SpaceVoxelPtr,
CalibratorPtr
myAddressBook
 
std::vector< SpaceVoxelPtrmyKnownSpaceVoxels
 
std::string name_
 
std::map< Region, std::vector
< SpaceVoxelPtr > > 
regionsToSVs_
 
double transitionLimit_
 
std::vector< SpaceVoxelPtrtransitionPosRegion_
 

Detailed Description

A tool to associate SpaceVoxels with Calibrator objects.

Author
Jamie Ballin
Date
April 2008

Definition at line 23 of file SpaceManager.h.

Constructor & Destructor Documentation

SpaceManager::SpaceManager ( std::string  name)

Definition at line 12 of file SpaceManager.cc.

References pftools::BARREL_POS, barrelPosRegion_, pftools::ENDCAP_POS, endcapPosRegion_, and regionsToSVs_.

12  :
16 }
std::vector< SpaceVoxelPtr > barrelPosRegion_
Definition: SpaceManager.h:114
std::map< Region, std::vector< SpaceVoxelPtr > > regionsToSVs_
Definition: SpaceManager.h:121
std::vector< SpaceVoxelPtr > endcapPosRegion_
Definition: SpaceManager.h:116
SpaceManager::~SpaceManager ( )
virtual

Definition at line 18 of file SpaceManager.cc.

18  {
19 
20 }

Member Function Documentation

void pftools::SpaceManager::addEvolution ( DetectorElementPtr  det,
Region  region,
TF1  f 
)
inline

Definition at line 79 of file SpaceManager.h.

References pftools::BARREL_POS, barrelPosEvolutions_, pftools::ENDCAP_POS, endcapPosEvolutions_, and f.

79  {
80  if(region == BARREL_POS)
81  barrelPosEvolutions_[det] = f;
82  if(region == ENDCAP_POS)
83  endcapPosEvolutions_[det] = f;
84  }
std::map< DetectorElementPtr, TF1 > barrelPosEvolutions_
Definition: SpaceManager.h:118
double f[11][100]
std::map< DetectorElementPtr, TF1 > endcapPosEvolutions_
Definition: SpaceManager.h:119
void SpaceManager::assignCalibration ( CalibratorPtr  c,
std::map< DetectorElementPtr, double >  result 
)

Definition at line 246 of file SpaceManager.cc.

References trackerHits::c, calibrationCoeffs_, makeInverseAddressBook(), and query::result.

247  {
250 }
tuple result
Definition: query.py:137
std::map< CalibratorPtr, std::map< DetectorElementPtr, double > > calibrationCoeffs_
Definition: SpaceManager.h:111
void SpaceManager::clear ( void  )

Definition at line 22 of file SpaceManager.cc.

References trackerHits::c, myAddressBook, and alignCSCRings::s.

Referenced by createCalibrators().

22  {
23  for (std::map<SpaceVoxelPtr, CalibratorPtr>::iterator it =
24  myAddressBook.begin(); it!= myAddressBook.end(); ++it) {
25  SpaceVoxelPtr s = (*it).first;
26  CalibratorPtr c = (*it).second;
27  }
28 }
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
CalibratorPtr SpaceManager::createCalibrator ( const Calibrator toClone,
SpaceVoxelPtr  s 
)

Definition at line 213 of file SpaceManager.cc.

References trackerHits::c, pftools::Calibrator::clone(), prof2calltree::count, myAddressBook, myKnownSpaceVoxels, and alignCSCRings::s.

214  {
216  int known = count(myKnownSpaceVoxels.begin(), myKnownSpaceVoxels.end(), s);
217  if (known == 0) {
218  myKnownSpaceVoxels.push_back(s);
219  c.reset(toClone.clone());
220  myAddressBook[s] = c;
221  } else {
222  c = myAddressBook[s];
223  }
224  assert(c != 0);
225  return c;
226 
227 }
std::vector< SpaceVoxelPtr > myKnownSpaceVoxels
Definition: SpaceManager.h:112
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
virtual Calibrator * clone() const =0
void SpaceManager::createCalibrators ( const Calibrator toClone,
const double  etaSeg,
const double  phiSeg,
const double  energySeg 
)

Definition at line 30 of file SpaceManager.cc.

References gather_cfg::cout.

31  {
32  std::cout << __PRETTY_FUNCTION__
33  << ": this method has not yet been implemented!\n";
34  PFToolsException me("Unimplemented method! Sorry!");
35  throw me;
36 
37 }
General purpose exception class for use by classes in the pftools namespace.
tuple cout
Definition: gather_cfg.py:121
void SpaceManager::createCalibrators ( const Calibrator toClone,
const unsigned  nEta,
const double  etaMin,
const double  etaMax,
const unsigned  nPhi,
const double  phiMin,
const double  phiMax,
const unsigned  nEnergy,
const double  energyMin,
const double  energyMax 
)
throw (PFToolsException &
)

Definition at line 168 of file SpaceManager.cc.

References trackerHits::c, hitfit::clear(), gather_cfg::cout, jptDQMConfig_cff::etaMax, jptDQMConfig_cff::etaMin, gen::k, prof2calltree::l, m, jptDQMConfig_cff::phiMax, and jptDQMConfig_cff::phiMin.

172  {
173  clear();
174 
175  if (nEta == 0|| nPhi ==0|| nEnergy == 0) {
177  me("Can't create calibrators with zero values for nEta, nPhi or nEnergy!");
178  throw me;
179  }
180 
181  double etaSeg = (etaMax - etaMin) / nEta;
182  double phiSeg = (phiMax - phiMin) / nPhi;
183  double energySeg = (energyMax - energyMin) / nEnergy;
184 
185  double eta1, eta2, phi1, phi2, energy1, energy2;
186  for (unsigned k(0); k < nEta; ++k) {
187  for (unsigned l(0); l < nPhi; ++l) {
188  for (unsigned m(0); m < nEnergy; ++m) {
189  eta1 = etaMin + k * etaSeg;
190  eta2 = eta1 + etaSeg;
191 
192  phi1 = phiMin + l * phiSeg;
193  phi2 = phi1 + phiSeg;
194 
195  energy1 = energyMin + m * energySeg;
196  energy2 = energy1 + energySeg;
197  SpaceVoxelPtr sv(new SpaceVoxel(eta1, eta2, phi1, phi2, energy1, energy2));
198  myKnownSpaceVoxels.push_back(sv);
199  CalibratorPtr c(toClone.clone());
200  myAddressBook[sv] = c;
201  }
202  }
203  }
204  unsigned nCalibrators = nEta * nPhi * nEnergy;
205  std::cout << "Created "<< nCalibrators << " calibrators.\n";
206  std::cout << "Address book size: \t\t"<< myAddressBook.size() << "\n";
207  std::cout << "Known space voxels size: \t"<< myKnownSpaceVoxels.size()
208  << "\n";
209  assert(myAddressBook.size() == myKnownSpaceVoxels.size());
211 
212 }
std::vector< SpaceVoxelPtr > myKnownSpaceVoxels
Definition: SpaceManager.h:112
A multi-dimensional volume element to subdivide the detector into different calibration regions...
Definition: SpaceVoxel.h:15
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
int k[5][pyjets_maxn]
virtual Calibrator * clone() const =0
General purpose exception class for use by classes in the pftools namespace.
tuple cout
Definition: gather_cfg.py:121
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
void SpaceManager::createCalibrators ( const Calibrator toClone)

Definition at line 39 of file SpaceManager.cc.

References barrelLimit_, barrelPosRegion_, trackerHits::c, clear(), pftools::Calibrator::clone(), gather_cfg::cout, endcapLimit_, endcapPosRegion_, myAddressBook, and myKnownSpaceVoxels.

39  {
40  clear();
41  std::cout << __PRETTY_FUNCTION__
42  << ": creating default calibration schema.\n";
43 
44  SpaceVoxelPtr sv(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 0, 3.0));
45  barrelPosRegion_.push_back(sv);
46  SpaceVoxelPtr sv1(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 3, 9.0));
47  barrelPosRegion_.push_back(sv1);
48  SpaceVoxelPtr sv2(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 9.0, 16.0));
49  barrelPosRegion_.push_back(sv2);
50  SpaceVoxelPtr sv3(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 16.0, 25.0));
51  barrelPosRegion_.push_back(sv3);
52  SpaceVoxelPtr sv4(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 25.0, 100.0));
53  barrelPosRegion_.push_back(sv4);
54  SpaceVoxelPtr sv5(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 100.0, 200.0));
55  barrelPosRegion_.push_back(sv5);
56  SpaceVoxelPtr sv6(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 200.0, 400.0));
57  barrelPosRegion_.push_back(sv6);
58 
59  // SpaceVoxelPtr sv(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 0, 2.0));
60  // barrelPosRegion_.push_back(sv);
61  // SpaceVoxelPtr sv1(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 1, 1.5));
62  // barrelPosRegion_.push_back(sv1);
63  // SpaceVoxelPtr sv2(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 1.5, 2.0));
64  // barrelPosRegion_.push_back(sv2);
65  // SpaceVoxelPtr sv3(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 2.0, 2.5));
66  // barrelPosRegion_.push_back(sv3);
67  // SpaceVoxelPtr sv4(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 2.5, 4.0));
68  // barrelPosRegion_.push_back(sv4);
69  // SpaceVoxelPtr sv41(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 4.0, 5.0));
70  // barrelPosRegion_.push_back(sv41);
71  // SpaceVoxelPtr sv5(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 5.0, 6.5));
72  // barrelPosRegion_.push_back(sv5);
73  // SpaceVoxelPtr sv51(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 6.5, 8.0));
74  // barrelPosRegion_.push_back(sv51);
75  // SpaceVoxelPtr sv6(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 8.0, 10.0));
76  // barrelPosRegion_.push_back(sv6);
77  // SpaceVoxelPtr sv61(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 10.0, 12.0));
78  // barrelPosRegion_.push_back(sv61);
79  // SpaceVoxelPtr sv7(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 12.0, 16.0));
80  // barrelPosRegion_.push_back(sv7);
81  // SpaceVoxelPtr sv8(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 16.0, 25.0));
82  // barrelPosRegion_.push_back(sv8);
83  // SpaceVoxelPtr sv9(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 25.0, 40.0));
84  // barrelPosRegion_.push_back(sv9);
85  // SpaceVoxelPtr sv10(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 40.0, 60.0));
86  // barrelPosRegion_.push_back(sv10);
87  // SpaceVoxelPtr sv11(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 60.0, 100.0));
88  // barrelPosRegion_.push_back(sv11);
89  // SpaceVoxelPtr sv12(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 100.0, 200.0));
90  // barrelPosRegion_.push_back(sv12);
91  // SpaceVoxelPtr sv13(new SpaceVoxel(-1.0*barrelLimit_, barrelLimit_, -3.2, 3.2, 200.0, 400.0));
92  // barrelPosRegion_.push_back(sv13);
93 
94  SpaceVoxelPtr sve(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 0, 3.0));
95  endcapPosRegion_.push_back(sve);
96  SpaceVoxelPtr sve0(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 3.0, 9.0));
97  endcapPosRegion_.push_back(sve0);
98  SpaceVoxelPtr sve1(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 9.0, 16.0));
99  endcapPosRegion_.push_back(sve1);
100  SpaceVoxelPtr sve2(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 16.0, 25.0));
101  endcapPosRegion_.push_back(sve2);
102  SpaceVoxelPtr sve3(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 25.0, 100.0));
103  endcapPosRegion_.push_back(sve3);
104  SpaceVoxelPtr sve4(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 100.0, 200.0));
105  endcapPosRegion_.push_back(sve4);
106  SpaceVoxelPtr sve5(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 200.0, 400.0));
107  endcapPosRegion_.push_back(sve5);
108 
109  // SpaceVoxelPtr sve(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 0, 0.5));
110  // endcapPosRegion_.push_back(sve);
111  // SpaceVoxelPtr sve0(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 0.5, 1.0));
112  // endcapPosRegion_.push_back(sve0);
113  // SpaceVoxelPtr sve1(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 1, 1.5));
114  // endcapPosRegion_.push_back(sve1);
115  // SpaceVoxelPtr sve2(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 1.5, 2.0));
116  // endcapPosRegion_.push_back(sve2);
117  // SpaceVoxelPtr sve3(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 2.0, 2.5));
118  // endcapPosRegion_.push_back(sve3);
119  // SpaceVoxelPtr sve4(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 2.5, 4.0));
120  // endcapPosRegion_.push_back(sve4);
121  // SpaceVoxelPtr sve5(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 4.0, 5.0));
122  // endcapPosRegion_.push_back(sve5);
123  // SpaceVoxelPtr sve51(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 5.0, 6.5));
124  // endcapPosRegion_.push_back(sve51);
125  // SpaceVoxelPtr sve6(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 6.5, 8.0));
126  // endcapPosRegion_.push_back(sve6);
127  // SpaceVoxelPtr sve61(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 8.0, 10.0));
128  // endcapPosRegion_.push_back(sve61);
129  // SpaceVoxelPtr sve62(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 10.0, 12.0));
130  // endcapPosRegion_.push_back(sve62);
131  // SpaceVoxelPtr sve7(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 12.0, 16.0));
132  // endcapPosRegion_.push_back(sve7);
133  // SpaceVoxelPtr sve8(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 16.0, 25.0));
134  // endcapPosRegion_.push_back(sve8);
135  // SpaceVoxelPtr sve9(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 25.0, 40.0));
136  // endcapPosRegion_.push_back(sve9);
137  // SpaceVoxelPtr sve10(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 40.0, 60.0));
138  // endcapPosRegion_.push_back(sve10);
139  // SpaceVoxelPtr sve11(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 60.0, 100.0));
140  // endcapPosRegion_.push_back(sve11);
141  // SpaceVoxelPtr sve12(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 100.0, 200.0));
142  // endcapPosRegion_.push_back(sve12);
143  // SpaceVoxelPtr sve13(new SpaceVoxel(barrelLimit_, endcapLimit_, -3.2, 3.2, 200.0, 400.0));
144  // endcapPosRegion_.push_back(sve13);
145 
146  for (std::vector<SpaceVoxelPtr>::iterator it = barrelPosRegion_.begin(); it
147  != barrelPosRegion_.end(); ++it) {
148  myKnownSpaceVoxels.push_back(*it);
149  }
150 
151  for (std::vector<SpaceVoxelPtr>::iterator it = endcapPosRegion_.begin(); it
152  != endcapPosRegion_.end(); ++it) {
153  myKnownSpaceVoxels.push_back(*it);
154  }
155 
156  for (std::vector<SpaceVoxelPtr>::iterator it = myKnownSpaceVoxels.begin(); it
157  != myKnownSpaceVoxels.end(); ++it) {
158  CalibratorPtr c(toClone.clone());
159  myAddressBook[*it] = c;
160  }
161  std::cout << "Address book size: \t\t"<< myAddressBook.size() << "\n";
162  std::cout << "Known space voxels size: \t"<< myKnownSpaceVoxels.size()
163  << "\n";
164  assert(myAddressBook.size() == myKnownSpaceVoxels.size());
165 
166 }
std::vector< SpaceVoxelPtr > barrelPosRegion_
Definition: SpaceManager.h:114
std::vector< SpaceVoxelPtr > myKnownSpaceVoxels
Definition: SpaceManager.h:112
A multi-dimensional volume element to subdivide the detector into different calibration regions...
Definition: SpaceVoxel.h:15
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
virtual Calibrator * clone() const =0
std::vector< SpaceVoxelPtr > endcapPosRegion_
Definition: SpaceManager.h:116
tuple cout
Definition: gather_cfg.py:121
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
double SpaceManager::evolveCoefficient ( DetectorElementPtr  det,
double  energy,
double  eta,
double  phi 
)

Definition at line 320 of file SpaceManager.cc.

References barrelLimit_, barrelPosEvolutions_, and endcapPosEvolutions_.

321  {
322  if (eta < barrelLimit_) {
323  TF1& func = barrelPosEvolutions_[det];
324  return func.Eval(energy);
325  }
326  TF1& func = endcapPosEvolutions_[det];
327  return func.Eval(energy);
328 }
std::map< DetectorElementPtr, TF1 > barrelPosEvolutions_
Definition: SpaceManager.h:118
T eta() const
std::map< DetectorElementPtr, TF1 > endcapPosEvolutions_
Definition: SpaceManager.h:119
TH1 * SpaceManager::extractEvolution ( DetectorElementPtr  det,
Region  region,
TF1 &  f1,
bool  useTruth = true 
)

Definition at line 256 of file SpaceManager.cc.

References pftools::BARREL_POS, barrelPosRegion_, trackerHits::c, calibrationCoeffs_, pftools::DetElNames, pftools::ENDCAP_POS, endcapPosRegion_, i, myAddressBook, mergeVDriftHistosByStation::name, profilereader::profile, pftools::RegionNames, alignCSCRings::s, and python.multivaluedict::sort().

257  {
258 
259  std::vector<SpaceVoxelPtr> region;
260  if (r == BARREL_POS)
261  region = barrelPosRegion_;
262  if (r == ENDCAP_POS)
263  region = endcapPosRegion_;
264  //region = regionsToSVs_[r];
265 
266  std::sort(region.begin(), region.end(), SpaceVoxel());
267 
268  std::string detElName = DetElNames[det->getType()];
269  std::string name("hDist_");
270  name.append(RegionNames[r]);
271  name.append("_");
272  name.append(DetElNames[det->getType()]);
273 
274  double minE(1000);
275  double maxE(0);
276 
277  TH2F hDist(name.c_str(), name.c_str(), 100, 0, 300, 50, 0.0, 2.5);
278  // TH3F hSurf(nameSurf.c_str(), nameSurf.c_str(), 30, 0, 50, 10, 0.0, 3.0, 30,
279  // 0.0, 2.5);
280  for (std::vector<SpaceVoxelPtr>::iterator i = region.begin(); i
281  != region.end(); ++i) {
282  SpaceVoxelPtr s = *i;
283  //double midE = (s->maxEnergy() + s->minEnergy()) / 2.0;
284  if (s->maxEnergy() > maxE)
285  maxE = s->maxEnergy();
286  if (s->minEnergy() < minE)
287  minE = s->minEnergy();
289  double coeff = calibrationCoeffs_[c][det];
290  if (coeff != 0.0) {
291  std::vector<ParticleDepositPtr> particles = c->getParticles();
292  for (std::vector<ParticleDepositPtr>::iterator it =
293  particles.begin(); it != particles.end(); ++it) {
294  if (useTruth)
295  hDist.Fill((*it)->getTruthEnergy(), coeff);
296  else
297  hDist.Fill((*it)->getRecEnergy(), coeff);
298  }
299  }
300  }
301 
302  hDist.FitSlicesY();
303  hDist.ProfileX();
304  hDist.Write();
305  std::string nameProfile(name);
306  nameProfile.append("_pfx");
307  name.append("_1");
308 
309  TH1D* slices = (TH1D*) gDirectory->Get(name.c_str());
310  //TH2D* slicesSurf = (TH2D*) gDirectory->Get(nameSurf.c_str());
311  TProfile* profile = (TProfile*) gDirectory->Get(nameProfile.c_str());
312  profile->Fit(&f1);
313  slices->Fit(&f1);
314  profile->Write();
315 
316  return slices;
317 
318 }
std::vector< SpaceVoxelPtr > barrelPosRegion_
Definition: SpaceManager.h:114
int i
Definition: DBlmapReader.cc:9
A multi-dimensional volume element to subdivide the detector into different calibration regions...
Definition: SpaceVoxel.h:15
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
const char *const RegionNames[]
Definition: Region.h:11
std::map< CalibratorPtr, std::map< DetectorElementPtr, double > > calibrationCoeffs_
Definition: SpaceManager.h:111
const char *const DetElNames[]
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
std::vector< SpaceVoxelPtr > endcapPosRegion_
Definition: SpaceManager.h:116
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
CalibratorPtr SpaceManager::findCalibrator ( const double  eta,
const double  phi,
const double  energy = 0 
) const

Definition at line 229 of file SpaceManager.cc.

References submit::answer, prof2calltree::count, myAddressBook, myKnownSpaceVoxels, alignCSCRings::s, and edm::second().

Referenced by interpolateCoefficient().

230  {
232  for (std::vector<SpaceVoxelPtr>::const_iterator cit =
233  myKnownSpaceVoxels.begin(); cit != myKnownSpaceVoxels.end(); ++cit) {
234  SpaceVoxelPtr s = *cit;
235  if (s->contains(eta, phi, energy)) {
236  assert(count(myKnownSpaceVoxels.begin(), myKnownSpaceVoxels.end(), s) != 0);
237  answer = (*myAddressBook.find(s)).second;
238  break;
239  } else {
240  //assert(count(myKnownSpaceVoxels.begin(), myKnownSpaceVoxels.end(), s) == 0);
241  }
242  }
243  return answer;
244 }
answer
Definition: submit.py:44
std::vector< SpaceVoxelPtr > myKnownSpaceVoxels
Definition: SpaceManager.h:112
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
T eta() const
U second(std::pair< T, U > const &p)
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
Definition: DDAxes.h:10
std::map< DetectorElementPtr, double > SpaceManager::getCalibration ( CalibratorPtr  c)

Definition at line 252 of file SpaceManager.cc.

References trackerHits::c, and calibrationCoeffs_.

252  {
253  return calibrationCoeffs_[c];
254 }
std::map< CalibratorPtr, std::map< DetectorElementPtr, double > > calibrationCoeffs_
Definition: SpaceManager.h:111
std::map<SpaceVoxelPtr, CalibratorPtr>* pftools::SpaceManager::getCalibrators ( )
inline

Definition at line 52 of file SpaceManager.h.

References myAddressBook.

52  {
53  std::map<SpaceVoxelPtr, CalibratorPtr>* ptr = &myAddressBook;
54  return ptr;
55  }
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
std::string pftools::SpaceManager::getName ( void  )
inline

Definition at line 29 of file SpaceManager.h.

References name_.

29  {
30  return name_;
31  }
int pftools::SpaceManager::getNCalibrations ( )
inline

Definition at line 90 of file SpaceManager.h.

References calibrationCoeffs_.

90  {
91  return calibrationCoeffs_.size();
92  }
std::map< CalibratorPtr, std::map< DetectorElementPtr, double > > calibrationCoeffs_
Definition: SpaceManager.h:111
double SpaceManager::interpolateCoefficient ( DetectorElementPtr  det,
double  energy,
double  eta,
double  phi 
)

Definition at line 330 of file SpaceManager.cc.

References trackerHits::c, calibrationCoeffs_, findCalibrator(), inverseAddressBook_, and alignCSCRings::s.

331  {
333 
335 
336  double midEnergy = (s->minEnergy() + s->maxEnergy())/2.0;
337  //interpolate left or right?
338  double diffEnergy = energy - midEnergy;
339  double thisCoeff = calibrationCoeffs_[c][det];
340 
341  double interpolatedCoeff = thisCoeff;
342  double adjacentCoeff = 0.0;
343  double adjacentEnergy = 0.0;
344  if (diffEnergy > 0) {
345  //look to higher energy calibrators
346  CalibratorPtr adjC = findCalibrator(eta, phi, s->maxEnergy() + 0.1);
347  if (adjC != 0) {
348  SpaceVoxelPtr adjS = inverseAddressBook_[adjC];
349  adjacentCoeff = calibrationCoeffs_[adjC][det];
350  adjacentEnergy = (adjS->minEnergy() + adjS->maxEnergy()) / 2.0;
351  }
352  } else {
353  //look to lower energy calibrations
354  CalibratorPtr adjC = findCalibrator(eta, phi, s->minEnergy() - 0.1);
355  if (adjC != 0) {
356  SpaceVoxelPtr adjS = inverseAddressBook_[adjC];
357  adjacentCoeff = calibrationCoeffs_[adjC][det];
358  adjacentEnergy = (adjS->minEnergy() + adjS->maxEnergy()) / 2.0;
359  }
360  }
361  if (adjacentCoeff != 0) {
362  interpolatedCoeff = thisCoeff + diffEnergy* (adjacentCoeff - thisCoeff)
363  / (adjacentEnergy - midEnergy);
364  }
365  return interpolatedCoeff;
366 }
T eta() const
std::map< CalibratorPtr, std::map< DetectorElementPtr, double > > calibrationCoeffs_
Definition: SpaceManager.h:111
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
CalibratorPtr findCalibrator(const double eta, const double phi, const double energy=0) const
std::map< CalibratorPtr, SpaceVoxelPtr > inverseAddressBook_
Definition: SpaceManager.h:110
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
Definition: DDAxes.h:10
void SpaceManager::makeInverseAddressBook ( )

Definition at line 393 of file SpaceManager.cc.

References trackerHits::c, inverseAddressBook_, myAddressBook, and alignCSCRings::s.

Referenced by assignCalibration().

393  {
394  inverseAddressBook_.clear();
395  for (std::map<SpaceVoxelPtr, CalibratorPtr>::iterator it =
396  myAddressBook.begin(); it != myAddressBook.end(); ++it) {
397  SpaceVoxelPtr s = (*it).first;
398  CalibratorPtr c = (*it).second;
400  }
401 }
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
std::map< CalibratorPtr, SpaceVoxelPtr > inverseAddressBook_
Definition: SpaceManager.h:110
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
std::ostream & SpaceManager::printCalibrations ( std::ostream &  stream)

Definition at line 368 of file SpaceManager.cc.

References b, trackerHits::c, calibrationCoeffs_, myAddressBook, myKnownSpaceVoxels, query::result, and alignCSCRings::s.

368  {
369  stream << "Calibration results: \n";
370  // std::sort(myKnownSpaceVoxels.begin(), myKnownSpaceVoxels.end(),
371  // SpaceVoxel());
372  stream << "WARNING! Haven't sorted space voxels properly!\n";
373  for (std::vector<SpaceVoxelPtr>::iterator it = myKnownSpaceVoxels.begin(); it
374  != myKnownSpaceVoxels.end(); ++it) {
375  SpaceVoxelPtr s = *it;
377  stream << *s << "\n";
378  stream << "\t[";
379  std::map<DetectorElementPtr, double> result = calibrationCoeffs_[c];
380  for (std::map<DetectorElementPtr, double>::iterator b = result.begin(); b
381  != result.end(); ++b) {
382  DetectorElementPtr d = (*b).first;
383  stream << *d << ": ";
384  double ans = (*b).second;
385  stream << ans << ", ";
386  }
387  stream << "]\n";
388  }
389 
390  return stream;
391 }
std::vector< SpaceVoxelPtr > myKnownSpaceVoxels
Definition: SpaceManager.h:112
std::map< SpaceVoxelPtr, CalibratorPtr > myAddressBook
Definition: SpaceManager.h:109
tuple result
Definition: query.py:137
std::map< CalibratorPtr, std::map< DetectorElementPtr, double > > calibrationCoeffs_
Definition: SpaceManager.h:111
boost::shared_ptr< Calibrator > CalibratorPtr
Definition: Calibrator.h:65
boost::shared_ptr< DetectorElement > DetectorElementPtr
double b
Definition: hdecay.h:120
boost::shared_ptr< SpaceVoxel > SpaceVoxelPtr
Definition: SpaceVoxel.h:89
void pftools::SpaceManager::setBarrelLimit ( double  limit)
inline

Definition at line 97 of file SpaceManager.h.

References barrelLimit_, and MessageLogger_cff::limit.

97  {
99  }

Member Data Documentation

double pftools::SpaceManager::barrelLimit_
private

Definition at line 105 of file SpaceManager.h.

Referenced by createCalibrators(), evolveCoefficient(), and setBarrelLimit().

std::map<DetectorElementPtr, TF1> pftools::SpaceManager::barrelPosEvolutions_
private

Definition at line 118 of file SpaceManager.h.

Referenced by addEvolution(), and evolveCoefficient().

std::vector<SpaceVoxelPtr> pftools::SpaceManager::barrelPosRegion_
private

Definition at line 114 of file SpaceManager.h.

Referenced by createCalibrators(), extractEvolution(), and SpaceManager().

std::map<CalibratorPtr, std::map<DetectorElementPtr, double> > pftools::SpaceManager::calibrationCoeffs_
private
double pftools::SpaceManager::endcapLimit_
private

Definition at line 107 of file SpaceManager.h.

Referenced by createCalibrators().

std::map<DetectorElementPtr, TF1> pftools::SpaceManager::endcapPosEvolutions_
private

Definition at line 119 of file SpaceManager.h.

Referenced by addEvolution(), and evolveCoefficient().

std::vector<SpaceVoxelPtr> pftools::SpaceManager::endcapPosRegion_
private

Definition at line 116 of file SpaceManager.h.

Referenced by createCalibrators(), extractEvolution(), and SpaceManager().

std::map<CalibratorPtr, SpaceVoxelPtr> pftools::SpaceManager::inverseAddressBook_
private

Definition at line 110 of file SpaceManager.h.

Referenced by interpolateCoefficient(), and makeInverseAddressBook().

std::map<SpaceVoxelPtr, CalibratorPtr> pftools::SpaceManager::myAddressBook
private
std::vector<SpaceVoxelPtr> pftools::SpaceManager::myKnownSpaceVoxels
private
std::string pftools::SpaceManager::name_
private

Definition at line 103 of file SpaceManager.h.

Referenced by getName().

std::map<Region, std::vector<SpaceVoxelPtr> > pftools::SpaceManager::regionsToSVs_
private

Definition at line 121 of file SpaceManager.h.

Referenced by SpaceManager().

double pftools::SpaceManager::transitionLimit_
private

Definition at line 106 of file SpaceManager.h.

std::vector<SpaceVoxelPtr> pftools::SpaceManager::transitionPosRegion_
private

Definition at line 115 of file SpaceManager.h.