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_;
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 //
91  detidsels_(), tkhisto_(new TkHistoMap("SelectorTest","SelectorTest",-1)),tkmap_()
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  {
129 
130  // SiStripDetInfoFileReader reader(edm::FileInPath("CalibTracker/SiStripCommon/data/SiStripDetInfo.dat"));
131  // SiStripDetInfoFileReader reader;
132 
133  const std::vector<uint32_t>& detids = reader->getAllDetIds();
134 
135  for(std::vector<uint32_t>::const_iterator detid=detids.begin();detid!=detids.end();++detid) {
136 
137  LogDebug("DetID") << *detid;
138  int index=0;
139  for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
140  if(detidsel->isSelected(*detid)) {
141  LogDebug("selected") << "Selected by selection " << index;
142  unsigned int det = *detid;
143  tkhisto_->add(det,index);
144  tkmap_.fill_current_val(det,index);
145  }
146  ++index;
147  }
148 
149  }
150  }
151 
152  {
153  edm::FileInPath fp("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt");
154 
155  SiPixelDetInfoFileReader pxlreader(fp.fullPath());
156  const std::vector<uint32_t>& detids = pxlreader.getAllDetIds();
157 
158  for(std::vector<uint32_t>::const_iterator detid=detids.begin();detid!=detids.end();++detid) {
159 
160  LogDebug("DetID") << *detid;
161  int index=0;
162  for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
163  if(detidsel->isSelected(*detid)) {
164  LogDebug("selected") << "Selected by selection " << index;
165  unsigned int det = *detid;
166  // tkhisto_->add(det,index);
167  tkmap_.fill_current_val(det,index);
168  }
169  ++index;
170  }
171 
172  }
173  }
174 
175 
176  /*
177  edm::ESHandle<TrackerGeometry> pDD;
178  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
179 
180  for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
181 
182  if(dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
183  DetId detId = (*it)->geographicalId();
184  LogDebug("DetID") << detId.rawId();
185  int index=0;
186  for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
187  if(detidsel->isSelected(detId)) {
188  LogDebug("selected") << " Selected by selection " << index;
189  // tkhisto_->add(det,index);
190  tkmap_.fill_current_val(detId.rawId(),index);
191  }
192  ++index;
193  }
194 
195  }
196 
197  }
198  */
199 }
200 
201 // ------------ method called once each job just before starting event loop ------------
202 void
204 {
205 
206 }
207 
208 // ------------ method called once each job just after ending the event loop ------------
209 void
211 
212 
213  // tkhisto_->dumpInTkMap(&tkmap);
214  std::string mapname = "SelectorTest.png";
215  tkmap_.save(true,0,0,mapname,5700,2400);
216 
217  std::string rootmapname = "TKMap_Selectortest.root";
218  tkhisto_->save(rootmapname);
219 }
220 
221 
222 //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:98
void beginJob() override
void analyze(const edm::Event &, const edm::EventSetup &) override
~DetIdSelectorTest() override
DetIdSelectorTest(const edm::ParameterSet &)
void save(std::string filename)
Definition: TkHistoMap.cc:57
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.
std::string fullPath() const
Definition: FileInPath.cc:184
void fill_current_val(int idmod, float current_val)
Definition: TrackerMap.cc:2759
void add(uint32_t &detid, float value)
Definition: TkHistoMap.cc:213