CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/DQM/SiStripMonitorCluster/src/SiStripMonitorHLT.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    SiStripMonitorCluster
00004 // Class:      SiStripMonitorHLT
00005 // 
00006 //class SiStripMonitorHLT SiStripMonitorHLT.cc DQM/SiStripMonitorCluster/src/SiStripMonitorHLT.cc
00007 #include <vector>
00008 
00009 #include <numeric>
00010 #include <iostream>
00011 
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013 #include "FWCore/ServiceRegistry/interface/Service.h"
00014 
00015 
00016 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
00017 
00018 #include "DQM/SiStripMonitorCluster/interface/SiStripMonitorHLT.h"
00019 #include "DQMServices/Core/interface/DQMStore.h"
00020 
00021 
00022 SiStripMonitorHLT::SiStripMonitorHLT(const edm::ParameterSet& iConfig)
00023 {
00024   HLTDirectory="HLTResults";
00025   dqmStore_  = edm::Service<DQMStore>().operator->();
00026   conf_ = iConfig;
00027 }
00028 
00029 
00030 void SiStripMonitorHLT::beginJob(){
00031 
00032   dqmStore_->setCurrentFolder(HLTDirectory);
00033   std::string HLTProducer = conf_.getParameter<std::string>("HLTProducer");
00034   HLTDecision = dqmStore_->book1D(HLTProducer+"_HLTDecision", HLTProducer+"HLTDecision", 2, -0.5, 1.5);
00035   // all
00036   SumOfClusterCharges_all = dqmStore_->book1D("SumOfClusterCharges_all", "SumOfClusterCharges_all", 50, 0, 2000);
00037   ChargeOfEachClusterTIB_all = dqmStore_->book1D("ChargeOfEachClusterTIB_all", "ChargeOfEachClusterTIB_all", 400, -0.5, 400.5);
00038   ChargeOfEachClusterTOB_all = dqmStore_->book1D("ChargeOfEachClusterTOB_all", "ChargeOfEachClusterTOB_all", 400, -0.5, 400.5);
00039   ChargeOfEachClusterTEC_all = dqmStore_->book1D("ChargeOfEachClusterTEC_all", "ChargeOfEachClusterTEC_all", 400, -0.5, 400.5);
00040   NumberOfClustersAboveThreshold_all = dqmStore_->book1D("NumberOfClustersAboveThreshold_all", "NumberOfClustersAboveThreshold_all", 30, 30.5, 60.5);
00041   // 31 = TIB2, 32 = TIB2, 33 = TIB3, 51 = TOB1, 52=TOB2, 60 = TEC
00042   // accepted from HLT
00043   SumOfClusterCharges_hlt = dqmStore_->book1D("SumOfClusterCharges_hlt", "SumOfClusterCharges_hlt", 50, 0, 2000);
00044   ChargeOfEachClusterTIB_hlt = dqmStore_->book1D("ChargeOfEachClusterTIB_hlt", "ChargeOfEachClusterTIB_hlt", 400, -0.5, 400.5);
00045   ChargeOfEachClusterTOB_hlt = dqmStore_->book1D("ChargeOfEachClusterTOB_hlt", "ChargeOfEachClusterTOB_hlt", 400, -0.5, 400.5);
00046   ChargeOfEachClusterTEC_hlt = dqmStore_->book1D("ChargeOfEachClusterTEC_hlt", "ChargeOfEachClusterTEC_hlt", 400, -0.5, 400.5);
00047   NumberOfClustersAboveThreshold_hlt = dqmStore_->book1D("NumberOfClustersAboveThreshold_hlt", "NumberOfClustersAboveThreshold_hlt", 30, 30.5, 60.5);
00048 }
00049 
00050 void SiStripMonitorHLT::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00051 {
00052 
00053   // get from event
00054   std::string HLTProducer = conf_.getParameter<std::string>("HLTProducer");
00055   edm::Handle<int> filter_decision; iEvent.getByLabel(HLTProducer, "", filter_decision); // filter decision
00056   edm::Handle<uint> sum_of_clustch; iEvent.getByLabel(HLTProducer, "", sum_of_clustch); // sum of cluster charges
00057   // first element of pair: layer: TIB1, ...., TEC; second element: nr of clusters above threshold
00058   edm::Handle<std::map<uint,std::vector<SiStripCluster> > > clusters_in_subcomponents;
00059   if(HLTProducer=="ClusterMTCCFilter") iEvent.getByLabel(HLTProducer, "", clusters_in_subcomponents);
00060 
00061   // trigger decision
00062   HLTDecision->Fill(*filter_decision);
00063 
00064   // sum of charges of clusters
00065   SumOfClusterCharges_all->Fill(*sum_of_clustch);
00066   if(*filter_decision) SumOfClusterCharges_hlt->Fill(*sum_of_clustch);
00067 
00068   //clusters in different layers
00069   if(HLTProducer=="ClusterMTCCFilter"){
00070     // loop over layers ("subcomponents")
00071     for(std::map<uint,std::vector<SiStripCluster> >::const_iterator it = clusters_in_subcomponents->begin(); it != clusters_in_subcomponents->end(); it++){
00072       int generalized_layer = it->first;
00073       std::vector<SiStripCluster> theclusters = it->second;
00074       NumberOfClustersAboveThreshold_all->Fill( generalized_layer, theclusters.size() ); // number of clusters in this generalized layer
00075       if(*filter_decision) NumberOfClustersAboveThreshold_hlt->Fill( generalized_layer, theclusters.size() );
00076       //loop over clusters (and detids)
00077       for(std::vector<SiStripCluster>::const_iterator icluster = theclusters.begin(); icluster != theclusters.end(); icluster++){
00078         // calculate sum of amplitudes
00079         unsigned int amplclus=0;
00080         for(std::vector<uint8_t>::const_iterator ia=icluster->amplitudes().begin(); ia!=icluster->amplitudes().end(); ia++) {
00081           if ((*ia)>0) amplclus+=(*ia); // why should this be negative?
00082         }
00083         if(generalized_layer==31 || generalized_layer==32 || generalized_layer==33){ // you can also ask the detid here whether is TIB
00084           ChargeOfEachClusterTIB_all->Fill(amplclus,1.);
00085           if(*filter_decision) ChargeOfEachClusterTIB_hlt->Fill(amplclus,1.);
00086         }
00087         if(generalized_layer==51 || generalized_layer==52){
00088           ChargeOfEachClusterTOB_all->Fill(amplclus,1.);
00089           if(*filter_decision) ChargeOfEachClusterTOB_hlt->Fill(amplclus,1.);
00090         }
00091         if(generalized_layer==60 ){
00092           ChargeOfEachClusterTEC_all->Fill(amplclus,1.);
00093           if(*filter_decision) ChargeOfEachClusterTEC_hlt->Fill(amplclus,1.);
00094         }
00095       }
00096     }
00097   }
00098 }
00099 
00100 void SiStripMonitorHLT::endJob(void){
00101   edm::LogInfo("DQM|SiStripMonitorHLT")<<"Events rejected/accepted "<<HLTDecision->getBinContent(1)<<"/"<<HLTDecision->getBinContent(2);
00102   bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
00103   std::string outputFileName = conf_.getParameter<std::string>("OutputFileName");
00104   if(outputMEsInRootFile){
00105     dqmStore_->save(outputFileName);
00106   }
00107 
00108   // delete MEs
00109 //  LogInfo("SiStripTkDQM|SiStripMonitorHLT")<<"pwd="<<dqmStore_->pwd();
00111 //  dqmStore_->cd();
00112 //  std::string folder_to_delete = HLTDirectory;
00113 //  LogInfo("SiStripTkDQM|SiStripMonitorHLT")<<" Removing whole directory "<<folder_to_delete;
00114 //  dqmStore_->rmdir(folder_to_delete);
00115 
00116 }
00117