Go to the documentation of this file.00001 #include "DQM/SiStripMonitorSummary/plugins/SiStripPlotGain.h"
00002
00003 #include "DataFormats/SiStripDetId/interface/TIBDetId.h"
00004 #include "DataFormats/SiStripDetId/interface/TOBDetId.h"
00005 #include "DataFormats/SiStripDetId/interface/TECDetId.h"
00006 #include "DataFormats/SiStripDetId/interface/TIDDetId.h"
00007
00008
00009
00010 SiStripPlotGain::SiStripPlotGain(const edm::ParameterSet& iConfig):
00011 cacheID(0xFFFFFFFF)
00012 {
00013
00014 if(!edm::Service<SiStripDetInfoFileReader>().isAvailable()){
00015 edm::LogError("TkLayerMap") <<
00016 "\n------------------------------------------"
00017 "\nUnAvailable Service SiStripDetInfoFileReader: please insert in the configuration file an instance like"
00018 "\n\tprocess.SiStripDetInfoFileReader = cms.Service(\"SiStripDetInfoFileReader\")"
00019 "\n------------------------------------------";
00020 }
00021
00022 fr=edm::Service<SiStripDetInfoFileReader>().operator->();
00023 file = new TFile("correlTest.root","RECREATE");
00024 tkmap = new TrackerMap();
00025 }
00026
00027
00028 SiStripPlotGain::~SiStripPlotGain()
00029 {}
00030
00031
00032
00033 void
00034 SiStripPlotGain::beginRun(const edm::Run& run, const edm::EventSetup& es){
00035
00036 if(getCache(es)==cacheID )
00037 return;
00038 cacheID=getCache(es);
00039
00040 edm::LogInfo("") << "[SiStripPlotGain::beginRun] cacheID " << cacheID << std::endl;
00041
00042 es.get<SiStripApvGainRcd>().get(Handle_);
00043 DoAnalysis(*Handle_.product());
00044
00045
00046 }
00047
00048 void
00049 SiStripPlotGain::DoAnalysis(const SiStripApvGain& gain){
00050
00051 edm::LogInfo("") << "[Doanalysis]";
00052
00053 std::vector<TH1F *>histos;
00054
00055 SiStripApvGain::RegistryPointers p=gain.getRegistryPointers();
00056 SiStripApvGain::RegistryConstIterator iter, iterE;
00057 iter=p.detid_begin;
00058 iterE=p.detid_end;
00059
00060 float value;
00061
00062
00063 for(;iter!=iterE;++iter){
00064 getHistos(*iter,histos);
00065 SiStripApvGain::Range range=SiStripApvGain::Range(p.getFirstElement(iter),p.getLastElement(iter));
00066
00067 edm::LogInfo("") << "[Doanalysis] detid " << *iter << " range " << range.second-range.first;
00068 size_t apv=0, apvE= (range.second-range.first);
00069 for (;apv<apvE;apv+=2){
00070 value=gain.getApvGain(apv,range);
00071 tkmap->fill(*iter,value);
00072 for(size_t i=0;i<histos.size();++i)
00073 histos[i]->Fill(value);
00074 }
00075
00076 }
00077 }
00078
00079
00080 void
00081 SiStripPlotGain::getHistos(const uint32_t& detid,std::vector<TH1F*>& histos){
00082
00083 histos.clear();
00084
00085 int subdet=-999; int component=-999;
00086 SiStripDetId a(detid);
00087 if ( a.subdetId() == 3 ){
00088 subdet=0;
00089 component=TIBDetId(detid).layer();
00090 } else if ( a.subdetId() == 4 ) {
00091 subdet=1;
00092 component=TIDDetId(detid).side()==2?TIDDetId(detid).wheel():TIDDetId(detid).wheel()+3;
00093 } else if ( a.subdetId() == 5 ) {
00094 subdet=2;
00095 component=TOBDetId(detid).layer();
00096 } else if ( a.subdetId() == 6 ) {
00097 subdet=3;
00098 component=TECDetId(detid).side()==2?TECDetId(detid).wheel():TECDetId(detid).wheel()+9;
00099 }
00100
00101 int index=100+subdet*100+component;
00102
00103
00104 histos.push_back(getHisto(subdet+1));
00105 histos.push_back(getHisto(index));
00106
00107 }
00108
00109 TH1F*
00110 SiStripPlotGain::getHisto(const long unsigned int& index){
00111 if(vTH1.size()<index+1)
00112 vTH1.resize(index+1,0);
00113
00114 if(vTH1[index]==0){
00115 char name[128];
00116 sprintf(name,"%lu",index);
00117 edm::LogInfo("")<<"[getHisto] creating index " << index << std::endl;
00118 vTH1[index]=new TH1F(name,name,150,0.,5.);
00119 }
00120
00121 return vTH1[index];
00122 }
00123
00124 void
00125 SiStripPlotGain::endJob() {
00126 for(size_t i=0;i<vTH1.size();i++)
00127 if(vTH1[i]!=0)
00128 vTH1[i]->Write();
00129
00130 file->Write();
00131 file->Close();
00132
00133 tkmap->save(false,0,0,"testTkMap.png");
00134
00135 }
00136