CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiStripMonitorHLT.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: SiStripMonitorCluster
4 // Class: SiStripMonitorHLT
5 //
6 //class SiStripMonitorHLT SiStripMonitorHLT.cc DQM/SiStripMonitorCluster/src/SiStripMonitorHLT.cc
7 #include <vector>
8 
9 #include <numeric>
10 #include <iostream>
11 
14 
15 
17 
20 
21 
23 {
24  HLTDirectory="HLTResults";
26  conf_ = iConfig;
27 
28  filerDecisionToken_ = consumes<int>(conf_.getParameter<std::string>("HLTProducer") );
29  sumOfClusterToken_ = consumes<uint>(conf_.getParameter<std::string>("HLTProducer") );
30  clusterInSubComponentsToken_ = consumes<std::map<uint,std::vector<SiStripCluster> > >(conf_.getParameter<std::string>("HLTProducer") );
31 }
32 
33 
35 
37  std::string HLTProducer = conf_.getParameter<std::string>("HLTProducer");
38  HLTDecision = dqmStore_->book1D(HLTProducer+"_HLTDecision", HLTProducer+"HLTDecision", 2, -0.5, 1.5);
39  // all
40  SumOfClusterCharges_all = dqmStore_->book1D("SumOfClusterCharges_all", "SumOfClusterCharges_all", 50, 0, 2000);
41  ChargeOfEachClusterTIB_all = dqmStore_->book1D("ChargeOfEachClusterTIB_all", "ChargeOfEachClusterTIB_all", 400, -0.5, 400.5);
42  ChargeOfEachClusterTOB_all = dqmStore_->book1D("ChargeOfEachClusterTOB_all", "ChargeOfEachClusterTOB_all", 400, -0.5, 400.5);
43  ChargeOfEachClusterTEC_all = dqmStore_->book1D("ChargeOfEachClusterTEC_all", "ChargeOfEachClusterTEC_all", 400, -0.5, 400.5);
44  NumberOfClustersAboveThreshold_all = dqmStore_->book1D("NumberOfClustersAboveThreshold_all", "NumberOfClustersAboveThreshold_all", 30, 30.5, 60.5);
45  // 31 = TIB2, 32 = TIB2, 33 = TIB3, 51 = TOB1, 52=TOB2, 60 = TEC
46  // accepted from HLT
47  SumOfClusterCharges_hlt = dqmStore_->book1D("SumOfClusterCharges_hlt", "SumOfClusterCharges_hlt", 50, 0, 2000);
48  ChargeOfEachClusterTIB_hlt = dqmStore_->book1D("ChargeOfEachClusterTIB_hlt", "ChargeOfEachClusterTIB_hlt", 400, -0.5, 400.5);
49  ChargeOfEachClusterTOB_hlt = dqmStore_->book1D("ChargeOfEachClusterTOB_hlt", "ChargeOfEachClusterTOB_hlt", 400, -0.5, 400.5);
50  ChargeOfEachClusterTEC_hlt = dqmStore_->book1D("ChargeOfEachClusterTEC_hlt", "ChargeOfEachClusterTEC_hlt", 400, -0.5, 400.5);
51  NumberOfClustersAboveThreshold_hlt = dqmStore_->book1D("NumberOfClustersAboveThreshold_hlt", "NumberOfClustersAboveThreshold_hlt", 30, 30.5, 60.5);
52 }
53 
55 {
56 
57  // get from event
58  std::string HLTProducer = conf_.getParameter<std::string>("HLTProducer");
59  /*
60  edm::Handle<int> filter_decision; iEvent.getByLabel(HLTProducer, "", filter_decision); // filter decision
61  edm::Handle<uint> sum_of_clustch; iEvent.getByLabel(HLTProducer, "", sum_of_clustch); // sum of cluster charges
62  // first element of pair: layer: TIB1, ...., TEC; second element: nr of clusters above threshold
63  edm::Handle<std::map<uint,std::vector<SiStripCluster> > > clusters_in_subcomponents;
64  if(HLTProducer=="ClusterMTCCFilter") iEvent.getByLabel(HLTProducer, "", clusters_in_subcomponents);
65  */
66  edm::Handle<int> filter_decision; iEvent.getByToken(filerDecisionToken_,filter_decision); // filter decision
67  edm::Handle<uint> sum_of_clustch; iEvent.getByToken(sumOfClusterToken_, sum_of_clustch); // sum of cluster charges
68  // first element of pair: layer: TIB1, ...., TEC; second element: nr of clusters above threshold
69  edm::Handle<std::map<uint,std::vector<SiStripCluster> > > clusters_in_subcomponents;
70  if(HLTProducer=="ClusterMTCCFilter") iEvent.getByToken(clusterInSubComponentsToken_,clusters_in_subcomponents);
71 
72  // trigger decision
73  HLTDecision->Fill(*filter_decision);
74 
75  // sum of charges of clusters
76  SumOfClusterCharges_all->Fill(*sum_of_clustch);
77  if(*filter_decision) SumOfClusterCharges_hlt->Fill(*sum_of_clustch);
78 
79  //clusters in different layers
80  if(HLTProducer=="ClusterMTCCFilter"){
81  // loop over layers ("subcomponents")
82  for(std::map<uint,std::vector<SiStripCluster> >::const_iterator it = clusters_in_subcomponents->begin(); it != clusters_in_subcomponents->end(); it++){
83  int generalized_layer = it->first;
84  std::vector<SiStripCluster> theclusters = it->second;
85  NumberOfClustersAboveThreshold_all->Fill( generalized_layer, theclusters.size() ); // number of clusters in this generalized layer
86  if(*filter_decision) NumberOfClustersAboveThreshold_hlt->Fill( generalized_layer, theclusters.size() );
87  //loop over clusters (and detids)
88  for(std::vector<SiStripCluster>::const_iterator icluster = theclusters.begin(); icluster != theclusters.end(); icluster++){
89  // calculate sum of amplitudes
90  unsigned int amplclus=0;
91  for(std::vector<uint8_t>::const_iterator ia=icluster->amplitudes().begin(); ia!=icluster->amplitudes().end(); ia++) {
92  if ((*ia)>0) amplclus+=(*ia); // why should this be negative?
93  }
94  if(generalized_layer==31 || generalized_layer==32 || generalized_layer==33){ // you can also ask the detid here whether is TIB
95  ChargeOfEachClusterTIB_all->Fill(amplclus,1.);
96  if(*filter_decision) ChargeOfEachClusterTIB_hlt->Fill(amplclus,1.);
97  }
98  if(generalized_layer==51 || generalized_layer==52){
99  ChargeOfEachClusterTOB_all->Fill(amplclus,1.);
100  if(*filter_decision) ChargeOfEachClusterTOB_hlt->Fill(amplclus,1.);
101  }
102  if(generalized_layer==60 ){
103  ChargeOfEachClusterTEC_all->Fill(amplclus,1.);
104  if(*filter_decision) ChargeOfEachClusterTEC_hlt->Fill(amplclus,1.);
105  }
106  }
107  }
108  }
109 }
110 
112  edm::LogInfo("DQM|SiStripMonitorHLT")<<"Events rejected/accepted "<<HLTDecision->getBinContent(1)<<"/"<<HLTDecision->getBinContent(2);
113  bool outputMEsInRootFile = conf_.getParameter<bool>("OutputMEsInRootFile");
115  if(outputMEsInRootFile){
116  dqmStore_->save(outputFileName);
117  }
118 
119  // delete MEs
120 // LogInfo("SiStripTkDQM|SiStripMonitorHLT")<<"pwd="<<dqmStore_->pwd();
122 // dqmStore_->cd();
123 // std::string folder_to_delete = HLTDirectory;
124 // LogInfo("SiStripTkDQM|SiStripMonitorHLT")<<" Removing whole directory "<<folder_to_delete;
125 // dqmStore_->rmdir(folder_to_delete);
126 
127 }
128 
T getParameter(std::string const &) const
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
MonitorElement * NumberOfClustersAboveThreshold_all
void Fill(long long x)
MonitorElement * SumOfClusterCharges_all
int iEvent
Definition: GenABIO.cc:243
MonitorElement * ChargeOfEachClusterTEC_hlt
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::string HLTDirectory
MonitorElement * ChargeOfEachClusterTIB_all
MonitorElement * NumberOfClustersAboveThreshold_hlt
MonitorElement * HLTDecision
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2296
MonitorElement * ChargeOfEachClusterTEC_all
MonitorElement * SumOfClusterCharges_hlt
edm::EDGetTokenT< std::map< uint, std::vector< SiStripCluster > > > clusterInSubComponentsToken_
virtual void beginJob()
MonitorElement * ChargeOfEachClusterTOB_hlt
SiStripMonitorHLT(const edm::ParameterSet &)
double getBinContent(int binx) const
get content of bin (1-D)
edm::EDGetTokenT< int > filerDecisionToken_
MonitorElement * ChargeOfEachClusterTIB_hlt
MonitorElement * ChargeOfEachClusterTOB_all
virtual void endJob()
edm::ParameterSet conf_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
edm::EDGetTokenT< uint > sumOfClusterToken_