CMS 3D CMS Logo

DetIdSelectorTest.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripTools
4 // Class: DetIdSelectorTest
5 //
13 //
14 // Original Author: Andrea Venturi
15 // Created: Tue Jul 19 11:56:00 CEST 2009
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
23 #include <vector>
24 #include <string>
25 
28 
31 
33 
35 
38 
43 
47 
48 //******** Single include for the TkMap *************
51 //***************************************************
52 
53 //
54 // class decleration
55 //
56 
58 public:
59  explicit DetIdSelectorTest(const edm::ParameterSet&);
60  ~DetIdSelectorTest() override;
61 
62 private:
63  void beginJob() override;
64  void analyze(const edm::Event&, const edm::EventSetup&) override;
65  void endJob() override;
66 
67  // ----------member data ---------------------------
68 
69  std::vector<DetIdSelector> detidsels_;
70  std::unique_ptr<TkHistoMap> tkhisto_;
72 
75 };
76 
77 //
78 // constants, enums and typedefs
79 //
80 
81 //
82 // static data member definitions
83 //
84 
85 //
86 // constructors and destructor
87 //
89  : detidsels_(), tkhisto_(nullptr), tkmap_(), tkDetMapToken_(esConsumes()), geomDetToken_(esConsumes()) {
90  //now do what ever initialization is needed
91 
92  std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet> >("selections");
93 
94  for (std::vector<edm::ParameterSet>::const_iterator selconfig = selconfigs.begin(); selconfig != selconfigs.end();
95  ++selconfig) {
96  DetIdSelector selection(*selconfig);
97  detidsels_.push_back(selection);
98  }
99 
100  tkmap_.setPalette(1);
101  tkmap_.addPixel(true);
102 }
103 
105  // do anything here that needs to be done at desctruction time
106  // (e.g. close files, deallocate resources etc.)
107 }
108 
109 //
110 // member functions
111 //
112 
113 // ------------ method called to for each event ------------
115  using namespace edm;
116 
117  if (!tkhisto_) {
118  tkhisto_ = std::make_unique<TkHistoMap>(&iSetup.getData(tkDetMapToken_), "SelectorTest", "SelectorTest", -1);
119  }
120 
121  {
122  const auto detids = TrackerGeometryUtils::getSiStripDetIds(iSetup.getData(geomDetToken_));
123 
124  for (std::vector<uint32_t>::const_iterator detid = detids.begin(); detid != detids.end(); ++detid) {
125  LogDebug("DetID") << *detid;
126  int index = 0;
127  for (std::vector<DetIdSelector>::const_iterator detidsel = detidsels_.begin(); detidsel != detidsels_.end();
128  ++detidsel) {
129  if (detidsel->isSelected(*detid)) {
130  LogDebug("selected") << "Selected by selection " << index;
131  unsigned int det = *detid;
132  tkhisto_->add(det, index);
134  }
135  ++index;
136  }
137  }
138  }
139 
140  {
141  edm::FileInPath fp("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt");
142 
143  SiPixelDetInfoFileReader pxlreader(fp.fullPath());
144  const std::vector<uint32_t>& detids = pxlreader.getAllDetIds();
145 
146  for (std::vector<uint32_t>::const_iterator detid = detids.begin(); detid != detids.end(); ++detid) {
147  LogDebug("DetID") << *detid;
148  int index = 0;
149  for (std::vector<DetIdSelector>::const_iterator detidsel = detidsels_.begin(); detidsel != detidsels_.end();
150  ++detidsel) {
151  if (detidsel->isSelected(*detid)) {
152  LogDebug("selected") << "Selected by selection " << index;
153  unsigned int det = *detid;
154  // tkhisto_->add(det,index);
156  }
157  ++index;
158  }
159  }
160  }
161 
162  /*
163  edm::ESHandle<TrackerGeometry> pDD;
164  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
165 
166  for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
167 
168  if(dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
169  DetId detId = (*it)->geographicalId();
170  LogDebug("DetID") << detId.rawId();
171  int index=0;
172  for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
173  if(detidsel->isSelected(detId)) {
174  LogDebug("selected") << " Selected by selection " << index;
175  // tkhisto_->add(det,index);
176  tkmap_.fill_current_val(detId.rawId(),index);
177  }
178  ++index;
179  }
180 
181  }
182 
183  }
184  */
185 }
186 
187 // ------------ method called once each job just before starting event loop ------------
189 
190 // ------------ method called once each job just after ending the event loop ------------
192  // tkhisto_->dumpInTkMap(&tkmap);
193  std::string mapname = "SelectorTest.png";
194  tkmap_.save(true, 0, 0, mapname, 5700, 2400);
195 
196  std::string rootmapname = "TKMap_Selectortest.root";
197  tkhisto_->save(rootmapname);
198 }
199 
200 //define this as a plug-in
SiPixelDetInfoFileReader::getAllDetIds
const std::vector< uint32_t > & getAllDetIds() const
Definition: SiPixelDetInfoFileReader.cc:85
DetIdSelectorTest::endJob
void endJob() override
Definition: DetIdSelectorTest.cc:191
MessageLogger.h
TrackerGeometry.h
DetIdSelectorTest::tkhisto_
std::unique_ptr< TkHistoMap > tkhisto_
Definition: DetIdSelectorTest.cc:70
TrackerMap::setPalette
void setPalette(int numpalette)
Definition: TrackerMap.h:155
DetIdSelectorTest::tkmap_
TrackerMap tkmap_
Definition: DetIdSelectorTest.cc:71
edm
HLT enums.
Definition: AlignableModifier.h:19
DetIdSelectorTest::DetIdSelectorTest
DetIdSelectorTest(const edm::ParameterSet &)
Definition: DetIdSelectorTest.cc:88
TrackerMap::fill_current_val
void fill_current_val(int idmod, float current_val)
Definition: TrackerMap.cc:3258
personalPlayback.fp
fp
Definition: personalPlayback.py:523
DetIdSelectorTest::geomDetToken_
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
Definition: DetIdSelectorTest.cc:74
DetIdSelectorTest::tkDetMapToken_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
Definition: DetIdSelectorTest.cc:73
DetIdSelector.h
EDAnalyzer.h
TrackerGeometryUtils::getSiStripDetIds
std::vector< uint32_t > getSiStripDetIds(const GeometricDet &geomDet)
Definition: utils.cc:5
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
DetIdSelectorTest
Definition: DetIdSelectorTest.cc:57
FileInPath.h
DetIdSelectorTest::beginJob
void beginJob() override
Definition: DetIdSelectorTest.cc:188
SiPixelDetInfoFileReader
Definition: SiPixelDetInfoFileReader.h:28
edm::FileInPath
Definition: FileInPath.h:64
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TrackerMap::addPixel
void addPixel(bool addPixelfl)
Definition: TrackerMap.h:161
Service.h
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
TrackerMap
Definition: TrackerMap.h:76
DetIdSelectorTest::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: DetIdSelectorTest.cc:114
TkHistoMap.h
DetIdSelectorTest::~DetIdSelectorTest
~DetIdSelectorTest() override
Definition: DetIdSelectorTest.cc:104
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TFileService.h
TrackerDigiGeometryRecord.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition: GenABIO.cc:224
DetIdSelectorTest::detidsels_
std::vector< DetIdSelector > detidsels_
Definition: DetIdSelectorTest.cc:69
utils.h
edm::EventSetup
Definition: EventSetup.h:57
edm::ESGetToken< TkDetMap, TrackerTopologyRcd >
TrackerMap.h
SiPixelDetInfoFileReader.h
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:120
TrackerMap::save
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:810
Frameworkfwd.h
PixelGeomDetUnit.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
ParameterSet.h
edm::Event
Definition: Event.h:73
DetIdSelector
Definition: DetIdSelector.h:12