CMS 3D CMS Logo

AlignmentMonitorBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: CommonAlignmentMonitor
4 // Class : AlignmentMonitorBase
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Jim Pivarski
10 // Created: Fri Mar 30 12:21:07 CDT 2007
11 // $Id: AlignmentMonitorBase.cc,v 1.11 2010/01/06 15:23:09 mussgill Exp $
12 //
13 
19 
21  const edm::ConsumesCollector &iC,
23  : m_beamSpotTag(cfg.getUntrackedParameter<edm::InputTag>("beamSpotTag", edm::InputTag("offlineBeamSpot"))),
24  m_iteration(0),
25  mp_tracker(nullptr),
26  mp_muon(nullptr),
27  mp_store(nullptr) {
28  edm::Service<TFileService> tFileService;
29  m_baseDirMap[std::vector<std::string>()] = new TFileDirectory(tFileService->mkdir(name));
30 }
31 
33  AlignableMuon *pMuon,
34  AlignmentParameterStore *pStore) {
36  mp_muon = pMuon;
37  mp_store = pStore;
38 
39  if (!pMuon)
41  else if (!pTracker)
43  else
45 }
46 
48  m_iteration++;
49 
50  for (std::map<std::vector<std::string>, TFileDirectory *>::const_iterator i = m_iterDirMap.begin();
51  i != m_iterDirMap.end();
52  ++i) {
53  delete i->second;
54  }
55  m_iterDirMap.clear();
56 
57  std::ostringstream dirName;
58  dirName << "iter" << iteration();
59  m_iterDirMap[std::vector<std::string>()] =
60  new TFileDirectory(m_baseDirMap[std::vector<std::string>()]->mkdir(dirName.str()));
61 
62  book();
63 }
64 
66  const edm::EventSetup &iSetup,
67  const ConstTrajTrackPairCollection &iTrajTracks) {
68  event(iEvent, iSetup, iTrajTracks);
69 }
70 
72 
74  std::string::size_type lastPos = dir.find_first_not_of('/', 0);
75  std::string::size_type pos = dir.find_first_of('/', lastPos);
76  std::vector<std::string> dirs;
77 
78  bool isIter = false;
79  if (dir.substr(lastPos, pos - lastPos) == std::string("iterN")) {
80  isIter = true;
81  lastPos = dir.find_first_not_of('/', pos);
82  pos = dir.find_first_of('/', lastPos);
83  }
84 
85  while (std::string::npos != pos || std::string::npos != lastPos) {
86  dirs.push_back(dir.substr(lastPos, pos - lastPos));
87  lastPos = dir.find_first_not_of('/', pos);
88  pos = dir.find_first_of('/', lastPos);
89  }
90 
91  std::map<std::vector<std::string>, TFileDirectory *> *theMap;
92  if (isIter)
93  theMap = &m_iterDirMap;
94  else
95  theMap = &m_baseDirMap;
96 
97  std::vector<std::string> partial;
98  TFileDirectory *last = (*theMap)[partial];
99  for (unsigned int i = 0; i < dirs.size(); i++) {
100  partial.push_back(dirs[i]);
101  if (theMap->find(partial) == theMap->end()) {
102  (*theMap)[partial] = new TFileDirectory(last->mkdir(dirs[i]));
103  }
104  last = (*theMap)[partial];
105  }
106  return last;
107 }
108 
110  std::string dir, std::string name, std::string title, int nchX, double lowX, double highX) {
111  return directory(dir)->make<TH1F>(name.c_str(), title.c_str(), nchX, lowX, highX);
112 }
113 
117  int nchX,
118  double lowX,
119  double highX,
120  int nchY,
121  double lowY,
122  double highY,
123  const char *option) {
124  if (lowY == highY) {
125  return directory(dir)->make<TProfile>(name.c_str(), title.c_str(), nchX, lowX, highX, option);
126  } else {
127  return directory(dir)->make<TProfile>(name.c_str(), title.c_str(), nchX, lowX, highX, lowY, highY, option);
128  }
129 }
130 
134  int nchX,
135  double lowX,
136  double highX,
137  int nchY,
138  double lowY,
139  double highY) {
140  return directory(dir)->make<TH2F>(name.c_str(), title.c_str(), nchX, lowX, highX, nchY, lowY, highY);
141 }
AlignmentParameterStore * pStore()
std::map< std::vector< std::string >, TFileDirectory * > m_baseDirMap
std::map< std::vector< std::string >, TFileDirectory * > m_iterDirMap
AlignmentMonitorBase(const edm::ParameterSet &cfg, const edm::ConsumesCollector &iC, std::string name)
Constructor.
virtual void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks)
Called for each event (by "run()"): may be reimplemented.
TH2F * book2D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
AlignmentParameterStore * mp_store
AlignableTracker * pTracker()
TProfile * bookProfile(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX, int nchY=1, double lowY=0., double highY=0., const char *option="s")
uint16_t size_type
T * make(const Args &...args) const
make new ROOT object
TFileDirectory * directory(std::string dir)
int iEvent
Definition: GenABIO.cc:224
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
TH1F * book1D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX)
AlignableTracker * mp_tracker
void beginOfJob(AlignableTracker *pTracker, AlignableMuon *pMuon, AlignmentParameterStore *pStore)
Called at beginning of job: don&#39;t reimplement.
virtual void afterAlignment()
AlignableNavigator * mp_navigator
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
HLT enums.
void startingNewLoop()
Called at beginning of loop: don&#39;t reimplement.
void duringLoop(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks)
Called for each event: don&#39;t reimplement.
virtual void book()=0
Book or retrieve histograms; MUST be reimplemented.
Constructor of the full muon geometry.
Definition: AlignableMuon.h:38
void endOfLoop()
Called at end of loop: don&#39;t reimplement.