Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <memory>
00022
00023
00024 #include <vector>
00025 #include <string>
00026
00027 #include "FWCore/Framework/interface/Frameworkfwd.h"
00028 #include "FWCore/Framework/interface/EDAnalyzer.h"
00029
00030 #include "FWCore/Framework/interface/Event.h"
00031 #include "FWCore/Framework/interface/MakerMacros.h"
00032
00033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00034
00035 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00036
00037 #include "FWCore/ServiceRegistry/interface/Service.h"
00038 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00039
00040 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00041 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00042 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00043
00044 #include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h"
00045 #include "CalibTracker/SiPixelESProducers/interface/SiPixelDetInfoFileReader.h"
00046 #include "CommonTools/UtilAlgos/interface/DetIdSelector.h"
00047 #include "FWCore/ParameterSet/interface/FileInPath.h"
00048
00049
00050 #include "DQM/SiStripCommon/interface/TkHistoMap.h"
00051 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
00052
00053
00054
00055
00056
00057
00058 class DetIdSelectorTest : public edm::EDAnalyzer {
00059 public:
00060 explicit DetIdSelectorTest(const edm::ParameterSet&);
00061 ~DetIdSelectorTest();
00062
00063
00064 private:
00065 virtual void beginJob() ;
00066 virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
00067 virtual void endRun(const edm::Run&, const edm::EventSetup&) ;
00068 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00069 virtual void endJob() ;
00070
00071
00072
00073
00074 std::vector<DetIdSelector> detidsels_;
00075 TkHistoMap *tkhisto_;
00076 TrackerMap tkmap_;
00077
00078
00079 };
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 DetIdSelectorTest::DetIdSelectorTest(const edm::ParameterSet& iConfig):
00093 detidsels_(), tkhisto_(new TkHistoMap("SelectorTest","SelectorTest",-1)),tkmap_()
00094 {
00095
00096
00097 std::vector<edm::ParameterSet> selconfigs = iConfig.getParameter<std::vector<edm::ParameterSet> >("selections");
00098
00099 for(std::vector<edm::ParameterSet>::const_iterator selconfig=selconfigs.begin();selconfig!=selconfigs.end();++selconfig) {
00100 DetIdSelector selection(*selconfig);
00101 detidsels_.push_back(selection);
00102 }
00103
00104 tkmap_.setPalette(1);
00105 tkmap_.addPixel(true);
00106
00107 }
00108
00109
00110 DetIdSelectorTest::~DetIdSelectorTest()
00111 {
00112
00113
00114
00115
00116 }
00117
00118
00119
00120
00121
00122
00123
00124 void
00125 DetIdSelectorTest::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00126 {
00127 using namespace edm;
00128
00129 {
00130 SiStripDetInfoFileReader * reader=edm::Service<SiStripDetInfoFileReader>().operator->();
00131
00132
00133
00134
00135 const std::vector<uint32_t>& detids = reader->getAllDetIds();
00136
00137 for(std::vector<uint32_t>::const_iterator detid=detids.begin();detid!=detids.end();++detid) {
00138
00139 LogDebug("DetID") << *detid;
00140 int index=0;
00141 for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
00142 if(detidsel->isSelected(*detid)) {
00143 LogDebug("selected") << "Selected by selection " << index;
00144 unsigned int det = *detid;
00145 tkhisto_->add(det,index);
00146 tkmap_.fill_current_val(det,index);
00147 }
00148 ++index;
00149 }
00150
00151 }
00152 }
00153
00154 {
00155 edm::FileInPath fp("CalibTracker/SiPixelESProducers/data/PixelSkimmedGeometry.txt");
00156
00157 SiPixelDetInfoFileReader pxlreader(fp.fullPath());
00158 const std::vector<uint32_t>& detids = pxlreader.getAllDetIds();
00159
00160 for(std::vector<uint32_t>::const_iterator detid=detids.begin();detid!=detids.end();++detid) {
00161
00162 LogDebug("DetID") << *detid;
00163 int index=0;
00164 for(std::vector<DetIdSelector>::const_iterator detidsel=detidsels_.begin();detidsel!=detidsels_.end();++detidsel) {
00165 if(detidsel->isSelected(*detid)) {
00166 LogDebug("selected") << "Selected by selection " << index;
00167 unsigned int det = *detid;
00168
00169 tkmap_.fill_current_val(det,index);
00170 }
00171 ++index;
00172 }
00173
00174 }
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 }
00202
00203 void
00204 DetIdSelectorTest::beginRun(const edm::Run& iRun, const edm::EventSetup&)
00205 {}
00206
00207 void
00208 DetIdSelectorTest::endRun(const edm::Run& iRun, const edm::EventSetup&)
00209 {
00210 }
00211
00212
00213
00214 void
00215 DetIdSelectorTest::beginJob()
00216 {
00217
00218 }
00219
00220
00221 void
00222 DetIdSelectorTest::endJob() {
00223
00224
00225
00226 std::string mapname = "SelectorTest.png";
00227 tkmap_.save(true,0,0,mapname);
00228
00229 std::string rootmapname = "TKMap_Selectortest.root";
00230 tkhisto_->save(rootmapname);
00231 }
00232
00233
00234
00235 DEFINE_FWK_MODULE(DetIdSelectorTest);