Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:25

0001 #include "Validation/RecoB/plugins/BDHadronTrackMonitoringHarvester.h"
0002 
0003 using namespace edm;
0004 using namespace std;
0005 using namespace RecoBTag;
0006 
0007 // intialize category map
0008 // std::map<unsigned int, std::string>
0009 // BDHadronTrackMonitoringAnalyzer::TrkHistCat(map_start_values,
0010 // map_start_values
0011 // + map_start_values_size);
0012 
0013 // typedef std::map<unsigned int, std::string>::iterator it_type;
0014 
0015 BDHadronTrackMonitoringHarvester::BDHadronTrackMonitoringHarvester(const edm::ParameterSet &pSet) {}
0016 
0017 BDHadronTrackMonitoringHarvester::~BDHadronTrackMonitoringHarvester() {}
0018 
0019 void BDHadronTrackMonitoringHarvester::beginJob() {}
0020 
0021 void BDHadronTrackMonitoringHarvester::dqmEndJob(DQMStore::IBooker &ibook, DQMStore::IGetter &iget) {
0022   // ***********************
0023   //
0024   // Book all new histograms.
0025   //
0026   // ***********************
0027   RecoBTag::setTDRStyle();
0028   ibook.setCurrentFolder("BDHadronTracks/JetContent");
0029 
0030   // b jets
0031   // absolute average number of tracks
0032   nTrk_absolute_bjet = ibook.book1D("nTrk_absolute_bjet", "absolute average number of tracks in b jets", 6, -0.5, 5.5);
0033   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0034     nTrk_absolute_bjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0035   }
0036   nTrk_absolute_bjet->setAxisRange(0, 5, 2);
0037   nTrk_absolute_bjet->setAxisTitle("average number of tracks", 2);
0038 
0039   // relative (in percent) average number of tracks
0040   nTrk_relative_bjet = ibook.book1D("nTrk_relative_bjet", "relative average number of tracks in b jets", 6, -0.5, 5.5);
0041   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0042     nTrk_relative_bjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0043   }
0044   nTrk_relative_bjet->setAxisRange(0, 1, 2);
0045   nTrk_relative_bjet->setAxisTitle("average fraction of tracks", 2);
0046 
0047   // standard deviation of number of tracks
0048   nTrk_std_bjet = ibook.book1D("nTrk_std_bjet", "RMS of number of tracks in b jets", 6, -0.5, 5.5);
0049   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0050     nTrk_std_bjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0051   }
0052   nTrk_std_bjet->setAxisRange(0, 3, 2);
0053   nTrk_std_bjet->setAxisTitle("RMS of number of tracks", 2);
0054 
0055   // c jets
0056   nTrk_absolute_cjet = ibook.book1D("nTrk_absolute_cjet", "absolute average number of tracks in c jets", 6, -0.5, 5.5);
0057   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0058     nTrk_absolute_cjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0059   }
0060   nTrk_absolute_cjet->setAxisRange(0, 5, 2);
0061   nTrk_absolute_cjet->setAxisTitle("average number of tracks", 2);
0062 
0063   nTrk_relative_cjet = ibook.book1D("nTrk_relative_cjet", "relative average number of tracks in c jets", 6, -0.5, 5.5);
0064   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0065     nTrk_relative_cjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0066   }
0067   nTrk_relative_cjet->setAxisRange(0, 1, 2);
0068   nTrk_relative_cjet->setAxisTitle("average fraction of tracks", 2);
0069 
0070   nTrk_std_cjet = ibook.book1D("nTrk_std_cjet", "RMS of number of tracks in c jets", 6, -0.5, 5.5);
0071   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0072     nTrk_std_cjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0073   }
0074   nTrk_std_cjet->setAxisRange(0, 3, 2);
0075   nTrk_std_cjet->setAxisTitle("RMS of number of tracks", 2);
0076 
0077   // udsg jets
0078   nTrk_absolute_dusgjet =
0079       ibook.book1D("nTrk_absolute_dusgjet", "absolute average number of tracks in dusg jets", 6, -0.5, 5.5);
0080   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0081     nTrk_absolute_dusgjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0082   }
0083   nTrk_absolute_dusgjet->setAxisRange(0, 5, 2);
0084   nTrk_absolute_dusgjet->setAxisTitle("average number of tracks", 2);
0085 
0086   nTrk_relative_dusgjet =
0087       ibook.book1D("nTrk_relative_dusgjet", "relative average number of tracks in dusg jets", 6, -0.5, 5.5);
0088   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0089     nTrk_relative_dusgjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0090   }
0091   nTrk_relative_dusgjet->setAxisRange(0, 1, 2);
0092   nTrk_relative_dusgjet->setAxisTitle("average fraction of tracks", 2);
0093 
0094   nTrk_std_dusgjet = ibook.book1D("nTrk_std_dusgjet", "RMS of number of tracks in dusg jets", 6, -0.5, 5.5);
0095   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0096     nTrk_std_dusgjet->setBinLabel(i + 1, BDHadronTrackMonitoringAnalyzer::TrkHistCat[i], 1);
0097   }
0098   nTrk_std_dusgjet->setAxisRange(0, 3, 2);
0099   nTrk_std_dusgjet->setAxisTitle("RMS of number of tracks", 2);
0100 
0101   // ***********************
0102   //
0103   // get all the old histograms
0104   //
0105   // ***********************
0106 
0107   // b jets
0108   MonitorElement *nTrk_bjet[6];
0109   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0110     nTrk_bjet[i] = iget.get("BDHadronTracks/JetContent/nTrk_bjet_" + BDHadronTrackMonitoringAnalyzer::TrkHistCat[i]);
0111   }
0112   MonitorElement *nTrkAll_bjet = iget.get("BDHadronTracks/JetContent/nTrkAll_bjet");
0113 
0114   // c jets
0115   MonitorElement *nTrk_cjet[6];
0116   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0117     nTrk_cjet[i] = iget.get("BDHadronTracks/JetContent/nTrk_cjet_" + BDHadronTrackMonitoringAnalyzer::TrkHistCat[i]);
0118   }
0119   MonitorElement *nTrkAll_cjet = iget.get("BDHadronTracks/JetContent/nTrkAll_cjet");
0120 
0121   // dusg jets
0122   MonitorElement *nTrk_dusgjet[6];
0123   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0124     nTrk_dusgjet[i] =
0125         iget.get("BDHadronTracks/JetContent/nTrk_dusgjet_" + BDHadronTrackMonitoringAnalyzer::TrkHistCat[i]);
0126   }
0127   MonitorElement *nTrkAll_dusgjet = iget.get("BDHadronTracks/JetContent/nTrkAll_dusgjet");
0128 
0129   // ***********************
0130   //
0131   // Calculate contents of new histograms
0132   //
0133   // ***********************
0134 
0135   // b jets
0136   float mean_bjets[6];
0137   float std_bjets[6];
0138   float meanAll_bjets;
0139   meanAll_bjets = std::max(0.01, nTrkAll_bjet->getMean(1));
0140   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0141     mean_bjets[i] = nTrk_bjet[i]->getMean(1);  // mean number of tracks per category
0142     std_bjets[i] = nTrk_bjet[i]->getRMS(1);
0143     nTrk_absolute_bjet->setBinContent(i + 1, mean_bjets[i]);
0144     nTrk_relative_bjet->setBinContent(i + 1, mean_bjets[i] / meanAll_bjets);
0145     nTrk_std_bjet->setBinContent(i + 1, std_bjets[i]);
0146   }
0147 
0148   // c jets
0149   float mean_cjets[6];
0150   float std_cjets[6];
0151   float meanAll_cjets;
0152   meanAll_cjets = std::max(0.01, nTrkAll_cjet->getMean(1));
0153   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0154     mean_cjets[i] = nTrk_cjet[i]->getMean(1);  // mean number of tracks per category
0155     std_cjets[i] = nTrk_cjet[i]->getRMS(1);
0156     nTrk_absolute_cjet->setBinContent(i + 1, mean_cjets[i]);
0157     nTrk_relative_cjet->setBinContent(i + 1, mean_cjets[i] / meanAll_cjets);
0158     nTrk_std_cjet->setBinContent(i + 1, std_cjets[i]);
0159   }
0160 
0161   // dusg jets
0162   float mean_dusgjets[6];
0163   float std_dusgjets[6];
0164   float meanAll_dusgjets;
0165   meanAll_dusgjets = std::max(0.01, nTrkAll_dusgjet->getMean(1));
0166   for (unsigned int i = 0; i < BDHadronTrackMonitoringAnalyzer::TrkHistCat.size(); i++) {
0167     mean_dusgjets[i] = nTrk_dusgjet[i]->getMean(1);  // mean number of tracks per category
0168     std_dusgjets[i] = nTrk_dusgjet[i]->getRMS(1);
0169     nTrk_absolute_dusgjet->setBinContent(i + 1, mean_dusgjets[i]);
0170     nTrk_relative_dusgjet->setBinContent(i + 1, mean_dusgjets[i] / meanAll_dusgjets);
0171     nTrk_std_dusgjet->setBinContent(i + 1, std_dusgjets[i]);
0172   }
0173 }
0174 
0175 // define this as a plug-in
0176 DEFINE_FWK_MODULE(BDHadronTrackMonitoringHarvester);