Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-02-25 23:40:00

0001 // -*- C++ -*-
0002 //
0003 // Package:    SiStripMonitorCluster
0004 // Class:      SiStripMonitorHLT
0005 //
0006 // class SiStripMonitorHLT SiStripMonitorHLT.cc
0007 // DQM/SiStripMonitorCluster/src/SiStripMonitorHLT.cc
0008 
0009 #include <vector>
0010 #include <iostream>
0011 #include <numeric>
0012 
0013 #include "DQM/SiStripMonitorCluster/interface/SiStripMonitorHLT.h"
0014 #include "DQMServices/Core/interface/DQMStore.h"
0015 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0016 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0017 #include "FWCore/ServiceRegistry/interface/Service.h"
0018 
0019 SiStripMonitorHLT::SiStripMonitorHLT(const edm::ParameterSet& iConfig) {
0020   HLTDirectory = "HLTResults";
0021   conf_ = iConfig;
0022 
0023   filerDecisionToken_ = consumes<int>(conf_.getParameter<std::string>("HLTProducer"));
0024   sumOfClusterToken_ = consumes<uint>(conf_.getParameter<std::string>("HLTProducer"));
0025   clusterInSubComponentsToken_ =
0026       consumes<std::map<uint, std::vector<SiStripCluster> > >(conf_.getParameter<std::string>("HLTProducer"));
0027 }
0028 
0029 void SiStripMonitorHLT::bookHistograms(DQMStore::IBooker& ibooker, const edm::Run& run, const edm::EventSetup& es) {
0030   ibooker.setCurrentFolder(HLTDirectory);
0031   std::string HLTProducer = conf_.getParameter<std::string>("HLTProducer");
0032   HLTDecision = ibooker.book1D(HLTProducer + "_HLTDecision", HLTProducer + "HLTDecision", 2, -0.5, 1.5);
0033   // all
0034   SumOfClusterCharges_all = ibooker.book1D("SumOfClusterCharges_all", "SumOfClusterCharges_all", 50, 0, 2000);
0035   ChargeOfEachClusterTIB_all =
0036       ibooker.book1D("ChargeOfEachClusterTIB_all", "ChargeOfEachClusterTIB_all", 400, -0.5, 400.5);
0037   ChargeOfEachClusterTOB_all =
0038       ibooker.book1D("ChargeOfEachClusterTOB_all", "ChargeOfEachClusterTOB_all", 400, -0.5, 400.5);
0039   ChargeOfEachClusterTEC_all =
0040       ibooker.book1D("ChargeOfEachClusterTEC_all", "ChargeOfEachClusterTEC_all", 400, -0.5, 400.5);
0041   NumberOfClustersAboveThreshold_all =
0042       ibooker.book1D("NumberOfClustersAboveThreshold_all", "NumberOfClustersAboveThreshold_all", 30, 30.5, 60.5);
0043   // 31 = TIB2, 32 = TIB2, 33 = TIB3, 51 = TOB1, 52=TOB2, 60 = TEC
0044   // accepted from HLT
0045   SumOfClusterCharges_hlt = ibooker.book1D("SumOfClusterCharges_hlt", "SumOfClusterCharges_hlt", 50, 0, 2000);
0046   ChargeOfEachClusterTIB_hlt =
0047       ibooker.book1D("ChargeOfEachClusterTIB_hlt", "ChargeOfEachClusterTIB_hlt", 400, -0.5, 400.5);
0048   ChargeOfEachClusterTOB_hlt =
0049       ibooker.book1D("ChargeOfEachClusterTOB_hlt", "ChargeOfEachClusterTOB_hlt", 400, -0.5, 400.5);
0050   ChargeOfEachClusterTEC_hlt =
0051       ibooker.book1D("ChargeOfEachClusterTEC_hlt", "ChargeOfEachClusterTEC_hlt", 400, -0.5, 400.5);
0052   NumberOfClustersAboveThreshold_hlt =
0053       ibooker.book1D("NumberOfClustersAboveThreshold_hlt", "NumberOfClustersAboveThreshold_hlt", 30, 30.5, 60.5);
0054 }
0055 
0056 void SiStripMonitorHLT::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0057   // get from event
0058   std::string HLTProducer = conf_.getParameter<std::string>("HLTProducer");
0059   edm::Handle<int> filter_decision;
0060   iEvent.getByToken(filerDecisionToken_, filter_decision);  // filter decision
0061   edm::Handle<uint> sum_of_clustch;
0062   iEvent.getByToken(sumOfClusterToken_,
0063                     sum_of_clustch);  // sum of cluster charges
0064   // first element of pair: layer: TIB1, ...., TEC; second element: nr of
0065   // clusters above threshold
0066   edm::Handle<std::map<uint, std::vector<SiStripCluster> > > clusters_in_subcomponents;
0067   if (HLTProducer == "ClusterMTCCFilter")
0068     iEvent.getByToken(clusterInSubComponentsToken_, clusters_in_subcomponents);
0069 
0070   // trigger decision
0071   HLTDecision->Fill(*filter_decision);
0072 
0073   // sum of charges of clusters
0074   SumOfClusterCharges_all->Fill(*sum_of_clustch);
0075   if (*filter_decision)
0076     SumOfClusterCharges_hlt->Fill(*sum_of_clustch);
0077 
0078   // clusters in different layers
0079   if (HLTProducer == "ClusterMTCCFilter") {
0080     // loop over layers ("subcomponents")
0081     for (std::map<uint, std::vector<SiStripCluster> >::const_iterator it = clusters_in_subcomponents->begin();
0082          it != clusters_in_subcomponents->end();
0083          it++) {
0084       int generalized_layer = it->first;
0085       std::vector<SiStripCluster> theclusters = it->second;
0086       NumberOfClustersAboveThreshold_all->Fill(generalized_layer,
0087                                                theclusters.size());  // number of clusters in this generalized layer
0088       if (*filter_decision)
0089         NumberOfClustersAboveThreshold_hlt->Fill(generalized_layer, theclusters.size());
0090       // loop over clusters (and detids)
0091       for (std::vector<SiStripCluster>::const_iterator icluster = theclusters.begin(); icluster != theclusters.end();
0092            icluster++) {
0093         // calculate sum of amplitudes
0094         unsigned int amplclus = 0;
0095         for (auto ia = icluster->amplitudes().begin(); ia != icluster->amplitudes().end(); ia++) {
0096           if ((*ia) > 0)
0097             amplclus += (*ia);  // why should this be negative?
0098         }
0099         if (generalized_layer == 31 || generalized_layer == 32 ||
0100             generalized_layer == 33) {  // you can also ask the detid here whether is TIB
0101           ChargeOfEachClusterTIB_all->Fill(amplclus, 1.);
0102           if (*filter_decision)
0103             ChargeOfEachClusterTIB_hlt->Fill(amplclus, 1.);
0104         }
0105         if (generalized_layer == 51 || generalized_layer == 52) {
0106           ChargeOfEachClusterTOB_all->Fill(amplclus, 1.);
0107           if (*filter_decision)
0108             ChargeOfEachClusterTOB_hlt->Fill(amplclus, 1.);
0109         }
0110         if (generalized_layer == 60) {
0111           ChargeOfEachClusterTEC_all->Fill(amplclus, 1.);
0112           if (*filter_decision)
0113             ChargeOfEachClusterTEC_hlt->Fill(amplclus, 1.);
0114         }
0115       }
0116     }
0117   }
0118 }