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 
20 // system include files
21 #include <memory>
22 
23 // user include files
24 #include <vector>
25 #include <string>
26 
29 
32 
34 
36 
39 
43 
48 
49 //******** Single include for the TkMap *************
52 //***************************************************
53 
54 //
55 // class decleration
56 //
57 
59 public:
60  explicit DetIdSelectorTest(const edm::ParameterSet&);
61  ~DetIdSelectorTest() override;
62 
63 
64 private:
65  void beginJob() override ;
66  void analyze(const edm::Event&, const edm::EventSetup&) override;
67  void endJob() override ;
68 
69  // ----------member data ---------------------------
70 
71 
72  std::vector<DetIdSelector> detidsels_;
73  std::unique_ptr<TkHistoMap> tkhisto_;
75 
76 
77 };
78 
79 //
80 // constants, enums and typedefs
81 //
82 
83 //
84 // static data member definitions
85 //
86 
87 //
88 // constructors and destructor
89 //
92 {
93  //now do what ever initialization is needed
94 
95  std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet> >("selections");
96 
97  for(std::vector<edm::ParameterSet>::const_iterator selconfig=selconfigs.begin();selconfig!=selconfigs.end();++selconfig) {
98  DetIdSelector selection(*selconfig);
99  detidsels_.push_back(selection);
100  }
101 
102  tkmap_.setPalette(1);
103  tkmap_.addPixel(true);
104 
105 }
106 
107 
109 {
110 
111  // do anything here that needs to be done at desctruction time
112  // (e.g. close files, deallocate resources etc.)
113 
114 }
115 
116 
117 //
118 // member functions
119 //
120 
121 // ------------ method called to for each event ------------
122 void
124 {
125  using namespace edm;
126 
127  if ( ! tkhisto_ ) {
128  edm::ESHandle<TkDetMap> tkDetMapHandle;
129  iSetup.get<TrackerTopologyRcd>().get(tkDetMapHandle);
130  tkhisto_ = std::make_unique<TkHistoMap>(tkDetMapHandle.product(), "SelectorTest","SelectorTest",-1);
131  }
132 
133  {
135 
136  // SiStripDetInfoFileReader reader(edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
137  // SiStripDetInfoFileReader reader;
138 
139  const std::vector<uint32_t>& detids = reader->getAllDetIds();
140 
141  for(std::vector<uint32_t>::const_iterator detid=detids.begin();detid!=detids.end();++detid) {
142 
143  LogDebug("DetID") << *detid;
144  int index=0;
145  for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
146  if(detidsel->isSelected(*detid)) {
147  LogDebug("selected") << "Selected by selection " << index;
148  unsigned int det = *detid;
149  tkhisto_->add(det,index);
150  tkmap_.fill_current_val(det,index);
151  }
152  ++index;
153  }
154 
155  }
156  }
157 
158  {
159  edm::FileInPath fp("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt");
160 
161  SiPixelDetInfoFileReader pxlreader(fp.fullPath());
162  const std::vector<uint32_t>& detids = pxlreader.getAllDetIds();
163 
164  for(std::vector<uint32_t>::const_iterator detid=detids.begin();detid!=detids.end();++detid) {
165 
166  LogDebug("DetID") << *detid;
167  int index=0;
168  for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
169  if(detidsel->isSelected(*detid)) {
170  LogDebug("selected") << "Selected by selection " << index;
171  unsigned int det = *detid;
172  // tkhisto_->add(det,index);
173  tkmap_.fill_current_val(det,index);
174  }
175  ++index;
176  }
177 
178  }
179  }
180 
181 
182  /*
183  edm::ESHandle<TrackerGeometry> pDD;
184  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
185 
186  for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
187 
188  if(dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
189  DetId detId = (*it)->geographicalId();
190  LogDebug("DetID") << detId.rawId();
191  int index=0;
192  for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
193  if(detidsel->isSelected(detId)) {
194  LogDebug("selected") << " Selected by selection " << index;
195  // tkhisto_->add(det,index);
196  tkmap_.fill_current_val(detId.rawId(),index);
197  }
198  ++index;
199  }
200 
201  }
202 
203  }
204  */
205 }
206 
207 // ------------ method called once each job just before starting event loop ------------
208 void
210 {
211 
212 }
213 
214 // ------------ method called once each job just after ending the event loop ------------
215 void
217 
218 
219  // tkhisto_->dumpInTkMap(&tkmap);
220  std::string mapname = "SelectorTest.png";
221  tkmap_.save(true,0,0,mapname,5700,2400);
222 
223  std::string rootmapname = "TKMap_Selectortest.root";
224  tkhisto_->save(rootmapname);
225 }
226 
227 
228 //define this as a plug-in
#define LogDebug(id)
T getParameter(std::string const &) const
const std::vector< uint32_t > & getAllDetIds() const
void addPixel(bool addPixelfl)
Definition: TrackerMap.h:135
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void endJob() override
selection
main part
Definition: corrVsCorr.py:99
std::unique_ptr< TkHistoMap > tkhisto_
void beginJob() override
#define nullptr
void analyze(const edm::Event &, const edm::EventSetup &) override
~DetIdSelectorTest() override
DetIdSelectorTest(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:230
const std::vector< uint32_t > & getAllDetIds() const
void setPalette(int numpalette)
Definition: TrackerMap.h:129
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:699
std::vector< DetIdSelector > detidsels_
HLT enums.
T get() const
Definition: EventSetup.h:68
std::string fullPath() const
Definition: FileInPath.cc:197
void fill_current_val(int idmod, float current_val)
Definition: TrackerMap.cc:2759
T const * product() const
Definition: ESHandle.h:84