Go to the documentation of this file.00001
00002 #include <memory>
00003
00004
00005 #include "FWCore/Framework/interface/Frameworkfwd.h"
00006 #include "FWCore/Framework/interface/EDAnalyzer.h"
00007
00008 #include "FWCore/Framework/interface/Event.h"
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014
00015 #include "DataFormats/SiStripCluster/interface/SiStripClusterCollection.h"
00016 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00017 #include "DataFormats/Common/interface/DetSetVector.h"
00018 #include "DataFormats/Common/interface/DetSetVectorNew.h"
00019
00020 #include "DQMServices/Core/interface/DQMStore.h"
00021 #include "DQMServices/Core/interface/MonitorElement.h"
00022
00023 #include "TH1F.h"
00024 #include "TFile.h"
00025 #include "TCanvas.h"
00026 #include "TH1.h"
00027 #include "TH2F.h"
00028 #include "TH1D.h"
00029 #include "TProfile.h"
00030 #include "TStyle.h"
00031 #include "TTree.h"
00032
00033 #include <sstream>
00034 #include <iostream>
00035 #include <vector>
00036
00037
00038
00039
00040
00041 class APVValidationPlots : public edm::EDAnalyzer {
00042 public:
00043 explicit APVValidationPlots(const edm::ParameterSet&);
00044 ~APVValidationPlots();
00045
00046
00047 private:
00048 virtual void beginJob() ;
00049 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00050 virtual void endJob() ;
00051
00052 std::ostringstream oss;
00053
00054 DQMStore* dqmStore;
00055
00056 MonitorElement* tmp;
00057
00058
00059
00060
00061
00062
00063 TH2F* medianVsAbsoluteOccupancy[5][10];
00064 TH1F* medianOccupancy[5][10];
00065 TH1F* absoluteOccupancy[5][10];
00066
00067 std::vector<std::string> subDetName;
00068 std::vector<unsigned int> nLayers;
00069 std::vector<std::string> layerName;
00070
00071 std::string infilename;
00072 std::string outfilename;
00073
00074 TFile* infile;
00075 TTree* intree;
00076
00077
00078 Int_t DetRawId;
00079 Int_t SubDetId;
00080 Int_t Layer_Ring;
00081 Int_t Disc;
00082 Int_t IsBack;
00083 Int_t IsExternalString;
00084 Int_t IsZMinusSide;
00085 Int_t RodStringPetal;
00086 Int_t IsStereo;
00087 Int_t ModulePosition;
00088 Int_t NumberOfStrips;
00089 Float_t APVGlobalPositionX;
00090 Float_t APVGlobalPositionY;
00091 Float_t APVGlobalPositionZ;
00092 Int_t APVNumber;
00093 Int_t APVAbsoluteOccupancy;
00094 Double_t APVMedianOccupancy;
00095
00096
00097
00098
00099 };
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 APVValidationPlots::APVValidationPlots(const edm::ParameterSet& iConfig) : infilename(iConfig.getUntrackedParameter<std::string>("inputFilename","in.root")),
00113 outfilename(iConfig.getUntrackedParameter<std::string>("outputFilename","out.root"))
00114
00115 {
00116
00117
00118 }
00119
00120
00121 APVValidationPlots::~APVValidationPlots()
00122 {
00123
00124
00125
00126
00127 }
00128
00129
00130
00131
00132
00133
00134
00135 void
00136 APVValidationPlots::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00137 {
00138
00139 }
00140
00141
00142
00143 void
00144 APVValidationPlots::beginJob()
00145 {
00146 oss.str("");
00147 oss << 1;
00148
00149 dqmStore = edm::Service<DQMStore>().operator->();
00150 dqmStore->setCurrentFolder("ChannelStatusPlots");
00151
00152
00153 subDetName.push_back(""); subDetName.push_back("TIB"); subDetName.push_back("TID"); subDetName.push_back("TOB"); subDetName.push_back("TEC");
00154 nLayers.push_back(0); nLayers.push_back(4); nLayers.push_back(3); nLayers.push_back(6); nLayers.push_back(9);
00155 layerName.push_back(""); layerName.push_back("Layer"); layerName.push_back("Disk"); layerName.push_back("Layer"); layerName.push_back("Disk");
00156
00157 std::string histoName;
00158 std::string histoTitle;
00159 for(unsigned int i = 0; i < subDetName.size(); i++)
00160 {
00161 for(unsigned int j = 0; j <= nLayers[i]; j++)
00162 {
00163 histoName = "medianVsAbsoluteOccupancy" + subDetName[i];
00164 if(j!=0)
00165 {
00166 oss.str("");
00167 oss << j;
00168 histoName += layerName[i] + oss.str();
00169 }
00170 histoTitle = "Median APV occupancy vs. absolute APV occupancy";
00171 if(i!=0)
00172 histoTitle += " in " + subDetName[i];
00173 if(j!=0)
00174 {
00175 histoTitle += " " + layerName[i] + " " + oss.str();
00176 }
00177 tmp = dqmStore->book2D(histoName.c_str(), histoTitle.c_str(), 1000, 0., 6., 1000, -1., 3.);
00178 medianVsAbsoluteOccupancy[i][j] = tmp->getTH2F();
00179 medianVsAbsoluteOccupancy[i][j]->Rebin2D(10,10);
00180 medianVsAbsoluteOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Abs. Occupancy)");
00181 medianVsAbsoluteOccupancy[i][j]->GetYaxis()->SetTitle("log_{10}(Median Occupancy)");
00182
00183 histoName = "medianOccupancy" + subDetName[i];
00184 if(j!=0)
00185 {
00186 oss.str("");
00187 oss << j;
00188 histoName += layerName[i] + oss.str();
00189 }
00190 histoTitle = "Median APV occupancy";
00191 if(i!=0)
00192 histoTitle += " in " + subDetName[i];
00193 if(j!=0)
00194 {
00195 histoTitle += " " + layerName[i] + " " + oss.str();
00196 }
00197 tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, -1., 3.);
00198 medianOccupancy[i][j] = tmp->getTH1F();
00199 medianOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
00200 medianOccupancy[i][j]->GetYaxis()->SetTitle("APVs");
00201
00202 histoName = "absoluteOccupancy" + subDetName[i];
00203 if(j!=0)
00204 {
00205 oss.str("");
00206 oss << j;
00207 histoName += layerName[i] + oss.str();
00208 }
00209 histoTitle = "Absolute APV occupancy";
00210 if(i!=0)
00211 histoTitle += " in " + subDetName[i];
00212 if(j!=0)
00213 {
00214 histoTitle += " " + layerName[i] + " " + oss.str();
00215 }
00216 tmp = dqmStore->book1D(histoName.c_str(), histoTitle.c_str(), 1000, 0., 6.);
00217 absoluteOccupancy[i][j] = tmp->getTH1F();
00218 absoluteOccupancy[i][j]->GetXaxis()->SetTitle("log_{10}(Occupancy)");
00219 absoluteOccupancy[i][j]->GetYaxis()->SetTitle("APVs");
00220 }
00221 }
00222
00223 }
00224
00225
00226 void
00227 APVValidationPlots::endJob() {
00228
00229 infile = new TFile(infilename.c_str(),"READ");
00230 intree = (TTree*)infile->Get("moduleOccupancy");
00231
00232 intree->SetBranchAddress("DetRawId", &DetRawId);
00233 intree->SetBranchAddress("SubDetId", &SubDetId);
00234 intree->SetBranchAddress("Layer_Ring", &Layer_Ring);
00235 intree->SetBranchAddress("Disc", &Disc);
00236 intree->SetBranchAddress("IsBack", &IsBack);
00237 intree->SetBranchAddress("IsExternalString", &IsExternalString);
00238 intree->SetBranchAddress("IsZMinusSide", &IsZMinusSide);
00239 intree->SetBranchAddress("RodStringPetal", &RodStringPetal);
00240 intree->SetBranchAddress("IsStereo", &IsStereo);
00241 intree->SetBranchAddress("ModuleNumber", &ModulePosition);
00242 intree->SetBranchAddress("NumberOfStrips", &NumberOfStrips);
00243 intree->SetBranchAddress("APVGlobalPositionX", &APVGlobalPositionX);
00244 intree->SetBranchAddress("APVGlobalPositionY", &APVGlobalPositionY);
00245 intree->SetBranchAddress("APVGlobalPositionZ", &APVGlobalPositionZ);
00246 intree->SetBranchAddress("APVNumber", &APVNumber);
00247 intree->SetBranchAddress("APVAbsoluteOccupancy", &APVAbsoluteOccupancy);
00248 intree->SetBranchAddress("APVMedianOccupancy", &APVMedianOccupancy);
00249
00250 for (int i=0; i<intree->GetEntries(); i++)
00251 {
00252 intree->GetEntry(i);
00253
00254 double logMedianOccupancy = -1;
00255 double logAbsoluteOccupancy = -1;
00256
00257 if (APVMedianOccupancy>0) logMedianOccupancy = log10(APVMedianOccupancy);
00258 if (APVAbsoluteOccupancy>0) logAbsoluteOccupancy = log10(APVAbsoluteOccupancy);
00259
00260
00261 unsigned int layer = 0;
00262 if(SubDetId==3 || SubDetId==5)
00263 layer=Layer_Ring;
00264 else
00265 layer=Disc;
00266
00267
00268 medianVsAbsoluteOccupancy[0][0]->Fill(logAbsoluteOccupancy,logMedianOccupancy);
00269 medianOccupancy[0][0]->Fill(logMedianOccupancy);
00270 absoluteOccupancy[0][0]->Fill(logAbsoluteOccupancy);
00271
00272 medianVsAbsoluteOccupancy[SubDetId-2][0]->Fill(logAbsoluteOccupancy,logMedianOccupancy);
00273 medianOccupancy[SubDetId-2][0]->Fill(logMedianOccupancy);
00274 absoluteOccupancy[SubDetId-2][0]->Fill(logAbsoluteOccupancy);
00275
00276 medianVsAbsoluteOccupancy[SubDetId-2][layer]->Fill(logAbsoluteOccupancy,logMedianOccupancy);
00277 medianOccupancy[SubDetId-2][layer]->Fill(logMedianOccupancy);
00278 absoluteOccupancy[SubDetId-2][layer]->Fill(logAbsoluteOccupancy);
00279 }
00280
00281 dqmStore->cd();
00282 dqmStore->save(outfilename.c_str(),"ChannelStatusPlots");
00283
00284 }
00285
00286
00287 DEFINE_FWK_MODULE(APVValidationPlots);