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 }
runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
AlignmentMonitorBase::mp_tracker
AlignableTracker * mp_tracker
Definition: AlignmentMonitorBase.h:127
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
AlignmentMonitorBase::mp_navigator
AlignableNavigator * mp_navigator
Definition: AlignmentMonitorBase.h:130
AlignmentMonitorBase::pTracker
AlignableTracker * pTracker()
Definition: AlignmentMonitorBase.h:112
heppy_check.dirs
dirs
Definition: heppy_check.py:26
edm
HLT enums.
Definition: AlignableModifier.h:19
AlignmentMonitorBase::directory
TFileDirectory * directory(std::string dir)
Definition: AlignmentMonitorBase.cc:73
pos
Definition: PixelAliasList.h:18
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
AlignmentMonitorBase::pStore
AlignmentParameterStore * pStore()
Definition: AlignmentMonitorBase.h:114
AlignmentMonitorBase::event
virtual void event(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks)
Called for each event (by "run()"): may be reimplemented.
Definition: AlignmentMonitorBase.h:77
AlignmentMonitorBase::afterAlignment
virtual void afterAlignment()
Definition: AlignmentMonitorBase.h:83
AlignmentMonitorBase::m_iteration
int m_iteration
Definition: AlignmentMonitorBase.h:126
TFileDirectory
Definition: TFileDirectory.h:24
fileinputsource_cfi.option
option
Definition: fileinputsource_cfi.py:94
AlignmentMonitorBase::book2D
TH2F * book2D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Definition: AlignmentMonitorBase.cc:131
AlignmentMonitorBase::mp_store
AlignmentParameterStore * mp_store
Definition: AlignmentMonitorBase.h:129
dqmdumpme.last
last
Definition: dqmdumpme.py:56
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
AlignmentMonitorBase::duringLoop
void duringLoop(const edm::Event &iEvent, const edm::EventSetup &iSetup, const ConstTrajTrackPairCollection &iTrajTracks)
Called for each event: don't reimplement.
Definition: AlignmentMonitorBase.cc:65
Service.h
AlignmentMonitorBase::endOfLoop
void endOfLoop()
Called at end of loop: don't reimplement.
Definition: AlignmentMonitorBase.cc:71
AlignableTracker
Definition: AlignableTracker.h:17
eostools.mkdir
def mkdir(path)
Definition: eostools.py:251
AlignableNavigator
Definition: AlignableNavigator.h:25
TFileService.h
AlignmentMonitorBase::m_baseDirMap
std::map< std::vector< std::string >, TFileDirectory * > m_baseDirMap
Definition: AlignmentMonitorBase.h:132
TFileService::mkdir
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
edm::ParameterSet
Definition: ParameterSet.h:47
AlignmentMonitorBase::bookProfile
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")
Definition: AlignmentMonitorBase.cc:114
AlignmentMonitorBase.h
AlignmentMonitorBase::beginOfJob
void beginOfJob(AlignableTracker *pTracker, AlignableMuon *pMuon, AlignmentParameterStore *pStore)
Called at beginning of job: don't reimplement.
Definition: AlignmentMonitorBase.cc:32
AlignableMuon
Constructor of the full muon geometry.
Definition: AlignableMuon.h:38
edm::Service< TFileService >
iEvent
int iEvent
Definition: GenABIO.cc:224
AlignmentMonitorBase::mp_muon
AlignableMuon * mp_muon
Definition: AlignmentMonitorBase.h:128
edm::EventSetup
Definition: EventSetup.h:58
AlignmentMonitorBase::book
virtual void book()=0
Book or retrieve histograms; MUST be reimplemented.
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
looper.cfg
cfg
Definition: looper.py:296
AlignmentMonitorBase::book1D
TH1F * book1D(std::string dir, std::string name, std::string title, int nchX, double lowX, double highX)
Definition: AlignmentMonitorBase.cc:109
AlignmentMonitorBase::iteration
int iteration()
Definition: AlignmentMonitorBase.h:111
AlignmentMonitorBase::startingNewLoop
void startingNewLoop()
Called at beginning of loop: don't reimplement.
Definition: AlignmentMonitorBase.cc:47
AlignmentParameterStore
Definition: AlignmentParameterStore.h:23
TFileDirectory::make
T * make(const Args &...args) const
make new ROOT object
Definition: TFileDirectory.h:53
TrackerOfflineValidation_Dqm_cff.dirName
dirName
Definition: TrackerOfflineValidation_Dqm_cff.py:55
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentMonitorBase::ConstTrajTrackPairCollection
std::vector< ConstTrajTrackPair > ConstTrajTrackPairCollection
Definition: AlignmentMonitorBase.h:46
genParticles_cff.map
map
Definition: genParticles_cff.py:11
AlignmentMonitorBase::m_iterDirMap
std::map< std::vector< std::string >, TFileDirectory * > m_iterDirMap
Definition: AlignmentMonitorBase.h:132
ParameterSet.h
edm::Event
Definition: Event.h:73
AlignmentMonitorBase::pMuon
AlignableMuon * pMuon()
Definition: AlignmentMonitorBase.h:113
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
AlignmentMonitorBase::AlignmentMonitorBase
AlignmentMonitorBase(const edm::ParameterSet &cfg, const edm::ConsumesCollector &iC, std::string name)
Constructor.
Definition: AlignmentMonitorBase.cc:20