Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:49

0001 #include <string>
0002 
0003 #include "DQM/L1TMonitor/interface/L1TdeGEMTPG.h"
0004 
0005 L1TdeGEMTPG::L1TdeGEMTPG(const edm::ParameterSet& ps)
0006     : data_token_(consumes<GEMPadDigiClusterCollection>(ps.getParameter<edm::InputTag>("data"))),
0007       emul_token_(consumes<GEMPadDigiClusterCollection>(ps.getParameter<edm::InputTag>("emul"))),
0008       monitorDir_(ps.getParameter<std::string>("monitorDir")),
0009       verbose_(ps.getParameter<bool>("verbose")),
0010 
0011       chambers_(ps.getParameter<std::vector<std::string>>("chambers")),
0012       dataEmul_(ps.getParameter<std::vector<std::string>>("dataEmul")),
0013 
0014       // variables
0015       clusterVars_(ps.getParameter<std::vector<std::string>>("clusterVars")),
0016 
0017       // binning
0018       clusterNBin_(ps.getParameter<std::vector<unsigned>>("clusterNBin")),
0019       clusterMinBin_(ps.getParameter<std::vector<double>>("clusterMinBin")),
0020       clusterMaxBin_(ps.getParameter<std::vector<double>>("clusterMaxBin")),
0021       useDataClustersOnlyInBX0_(ps.getParameter<bool>("useDataClustersOnlyInBX0")) {}
0022 
0023 L1TdeGEMTPG::~L1TdeGEMTPG() {}
0024 
0025 void L1TdeGEMTPG::bookHistograms(DQMStore::IBooker& iBooker, const edm::Run&, const edm::EventSetup&) {
0026   iBooker.setCurrentFolder(monitorDir_);
0027 
0028   // chamber type
0029   for (unsigned iType = 0; iType < chambers_.size(); iType++) {
0030     // data vs emulator
0031     for (unsigned iData = 0; iData < dataEmul_.size(); iData++) {
0032       // cluster variable
0033       for (unsigned iVar = 0; iVar < clusterVars_.size(); iVar++) {
0034         const std::string key("cluster_" + clusterVars_[iVar] + "_" + dataEmul_[iData]);
0035         const std::string histName(key + "_" + chambers_[iType]);
0036         const std::string histTitle(chambers_[iType] + " Cluster " + clusterVars_[iVar] + " (" + dataEmul_[iData] +
0037                                     ")");
0038         chamberHistos[iType][key] =
0039             iBooker.book1D(histName, histTitle, clusterNBin_[iVar], clusterMinBin_[iVar], clusterMaxBin_[iVar]);
0040         chamberHistos[iType][key]->getTH1()->SetMinimum(0);
0041       }
0042     }
0043   }
0044 }
0045 
0046 void L1TdeGEMTPG::analyze(const edm::Event& e, const edm::EventSetup& c) {
0047   if (verbose_)
0048     edm::LogInfo("L1TdeGEMTPG") << "L1TdeGEMTPG: analyzing collections" << std::endl;
0049 
0050   // handles
0051   edm::Handle<GEMPadDigiClusterCollection> dataClusters;
0052   edm::Handle<GEMPadDigiClusterCollection> emulClusters;
0053   e.getByToken(data_token_, dataClusters);
0054   e.getByToken(emul_token_, emulClusters);
0055 
0056   for (auto it = dataClusters->begin(); it != dataClusters->end(); it++) {
0057     auto range = dataClusters->get((*it).first);
0058     const int type = ((*it).first).station() - 1;
0059     for (auto cluster = range.first; cluster != range.second; cluster++) {
0060       if (cluster->isValid()) {
0061         // ignore data clusters in BX's other than BX0
0062         if (useDataClustersOnlyInBX0_ and cluster->bx() != 0)
0063           continue;
0064 
0065         chamberHistos[type]["cluster_size_data"]->Fill(cluster->pads().size());
0066         chamberHistos[type]["cluster_pad_data"]->Fill(cluster->pads().front());
0067         chamberHistos[type]["cluster_bx_data"]->Fill(cluster->bx());
0068       }
0069     }
0070   }
0071 
0072   for (auto it = emulClusters->begin(); it != emulClusters->end(); it++) {
0073     auto range = emulClusters->get((*it).first);
0074     const int type = ((*it).first).station() - 1;
0075     for (auto cluster = range.first; cluster != range.second; cluster++) {
0076       if (cluster->isValid()) {
0077         chamberHistos[type]["cluster_size_emul"]->Fill(cluster->pads().size());
0078         chamberHistos[type]["cluster_pad_emul"]->Fill(cluster->pads().front());
0079         chamberHistos[type]["cluster_bx_emul"]->Fill(cluster->bx());
0080       }
0081     }
0082   }
0083 }