CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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.10 2009/09/15 17:09:50 pivarski Exp $
12 //
13 
14 // system include files
15 
16 // user include files
22 
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
34 
35 // AlignmentMonitorBase::AlignmentMonitorBase(const AlignmentMonitorBase& rhs)
36 // {
37 // // do actual copying here;
38 // }
39 
41  : m_iteration(0), mp_tracker(0), mp_muon(0), mp_store(0) {
42  edm::Service<TFileService> tFileService;
43  m_baseDirMap[std::vector<std::string>()] = new TFileDirectory(tFileService->mkdir(name));
44 }
45 
46 //
47 // assignment operators
48 //
49 // const AlignmentMonitorBase& AlignmentMonitorBase::operator=(const AlignmentMonitorBase& rhs)
50 // {
51 // //An exception safe implementation is
52 // AlignmentMonitorBase temp(rhs);
53 // swap(rhs);
54 //
55 // return *this;
56 // }
57 
58 //
59 // member functions
60 //
61 
64  mp_muon = pMuon;
65  mp_store = pStore;
66 
67  if (!pMuon) mp_navigator = new AlignableNavigator(pTracker);
68  else if (!pTracker) mp_navigator = new AlignableNavigator(pMuon);
69  else mp_navigator = new AlignableNavigator(pTracker, pMuon);
70 }
71 
73  m_iteration++;
74 
75  for (std::map<std::vector<std::string>, TFileDirectory*>::const_iterator i = m_iterDirMap.begin(); i != m_iterDirMap.end(); ++i) {
76  delete i->second;
77  }
78  m_iterDirMap.clear();
79 
80  std::ostringstream dirName;
81  dirName << "iter" << iteration();
82  m_iterDirMap[std::vector<std::string>()] = new TFileDirectory(m_baseDirMap[std::vector<std::string>()]->mkdir(dirName.str()));
83 
84  book();
85 }
86 
88  event(iEvent, iSetup, iTrajTracks);
89 }
90 
92  afterAlignment(iSetup);
93 }
94 
96 }
97 
99  std::string::size_type lastPos = dir.find_first_not_of("/", 0);
100  std::string::size_type pos = dir.find_first_of("/", lastPos);
101  std::vector<std::string> dirs;
102 
103  bool isIter = false;
104  if (dir.substr(lastPos, pos - lastPos) == std::string("iterN")) {
105  isIter = true;
106  lastPos = dir.find_first_not_of("/", pos);
107  pos = dir.find_first_of("/", lastPos);
108  }
109 
110  while (std::string::npos != pos || std::string::npos != lastPos) {
111  dirs.push_back(dir.substr(lastPos, pos - lastPos));
112  lastPos = dir.find_first_not_of("/", pos);
113  pos = dir.find_first_of("/", lastPos);
114  }
115 
116  std::map<std::vector<std::string>, TFileDirectory*> *theMap;
117  if (isIter) theMap = &m_iterDirMap;
118  else theMap = &m_baseDirMap;
119 
120  std::vector<std::string> partial;
121  TFileDirectory *last = (*theMap)[partial];
122  for (unsigned int i = 0; i < dirs.size(); i++) {
123  partial.push_back(dirs[i]);
124  if (theMap->find(partial) == theMap->end()) {
125  (*theMap)[partial] = new TFileDirectory(last->mkdir(dirs[i]));
126  }
127  last = (*theMap)[partial];
128  }
129  return last;
130 }
131 
132 TH1F *AlignmentMonitorBase::book1D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX) {
133  return directory(dir)->make<TH1F>(name.c_str(), title.c_str(), nchX, lowX, highX);
134 }
135 
136 TProfile *AlignmentMonitorBase::bookProfile(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option) {
137  if (lowY == highY) {
138  return directory(dir)->make<TProfile>(name.c_str(), title.c_str(), nchX, lowX, highX, option);
139  }
140  else {
141  return directory(dir)->make<TProfile>(name.c_str(), title.c_str(), nchX, lowX, highX, lowY, highY, option);
142  }
143 }
144 
145 TH2F *AlignmentMonitorBase::book2D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY) {
146  return directory(dir)->make<TH2F>(name.c_str(), title.c_str(), nchX, lowX, highX, nchY, lowY, highY);
147 }
148 
149 //
150 // const member functions
151 //
152 
153 //
154 // static member functions
155 //
AlignableMuon * pMuon()
int i
Definition: DBlmapReader.cc:9
AlignmentParameterStore * pStore()
std::map< std::vector< std::string >, TFileDirectory * > m_baseDirMap
virtual void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks)
Called for each event (by &quot;run()&quot;): 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)
std::map< std::vector< std::string >, TFileDirectory * > m_iterDirMap
AlignmentParameterStore * mp_store
AlignmentMonitorBase(const edm::ParameterSet &cfg, std::string name)
Constructor.
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
dictionary map
Definition: Association.py:160
TFileDirectory * directory(std::string dir)
int iEvent
Definition: GenABIO.cc:243
void endOfJob()
Called at end of processing: don&#39;t implement.
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.
AlignableNavigator * mp_navigator
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
void startingNewLoop()
Called at beginning of loop: don&#39;t reimplement.
T * make() const
make new ROOT object
void endOfLoop(const edm::EventSetup &iSetup)
Called at end 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 afterAlignment(const edm::EventSetup &iSetup)
virtual void book()=0
Book or retrieve histograms; MUST be reimplemented.
dbl *** dir
Definition: mlp_gen.cc:35
Constructor of the full muon geometry.
Definition: AlignableMuon.h:39