CMS 3D CMS Logo

DQMPFCandidateAnalyzer.cc
Go to the documentation of this file.
1 
12 
25 
29 
50 
51 #include <string>
52 
53 #include <cmath>
54 
55 using namespace edm;
56 using namespace reco;
57 using namespace std;
58 
59 // ***********************************************************
61 //: trackPropagator_(new jetAnalysis::TrackPropagatorToCalo)//,
62  //sOverNCalculator_(new jetAnalysis::StripSignalOverNoiseCalculator)
63 {
64 
65  miniaodfilterdec=-1;
66 
67  candidateType_= pSet.getUntrackedParameter<std::string>("CandType");
68  //here only choice between miniaod or reco
69 
70  LSBegin_ = pSet.getParameter<int>("LSBegin");
71  LSEnd_ = pSet.getParameter<int>("LSEnd");
72 
73  isMiniAOD_= (std::string("Packed") == candidateType_);
74 
75  mInputCollection_ = pSet.getParameter<edm::InputTag>("PFCandidateLabel");
76 
77  if(isMiniAOD_){
78  pflowPackedToken_ = consumes<std::vector<pat::PackedCandidate> >(mInputCollection_);
79  }else{
80  pflowToken_ = consumes<std::vector<reco::PFCandidate> >(mInputCollection_);
81  }
82 
83  miniaodfilterdec=-1;
84 
85  // Smallest track pt
86  ptMinCand_ = pSet.getParameter<double>("ptMinCand");
87 
88  // Smallest raw HCAL energy linked to the track
89  hcalMin_ = pSet.getParameter<double>("hcalMin");
90 
91  diagnosticsParameters_ = pSet.getParameter<std::vector<edm::ParameterSet> >("METDiagonisticsParameters");
92 
93  edm::ConsumesCollector iC = consumesCollector();
94  //DCS
95  DCSFilter_ = new JetMETDQMDCSFilter(pSet.getParameter<ParameterSet>("DCSFilter"), iC );
96  if(isMiniAOD_){
97  METFilterMiniAODLabel_=pSet.getParameter<edm::InputTag>("FilterResultsLabelMiniAOD");
98  METFilterMiniAODToken_=consumes<edm::TriggerResults>(METFilterMiniAODLabel_);
99 
100  METFilterMiniAODLabel2_=pSet.getParameter<edm::InputTag>("FilterResultsLabelMiniAOD2");
101  METFilterMiniAODToken2_=consumes<edm::TriggerResults>(METFilterMiniAODLabel2_);
102 
103 
104  HBHENoiseStringMiniAOD = pSet.getParameter<std::string>("HBHENoiseLabelMiniAOD");
105  }
106 
107  if(!isMiniAOD_){
108  hbheNoiseFilterResultTag_ = pSet.getParameter<edm::InputTag>("HBHENoiseFilterResultLabel");
109  hbheNoiseFilterResultToken_=consumes<bool>(hbheNoiseFilterResultTag_);
110  }
111  //jet cleanup parameters
112  cleaningParameters_ = pSet.getParameter<ParameterSet>("CleaningParameters");
113 
114  //Vertex requirements
115  bypassAllPVChecks_ = cleaningParameters_.getParameter<bool>("bypassAllPVChecks");
116  bypassAllDCSChecks_ = cleaningParameters_.getParameter<bool>("bypassAllDCSChecks");
117  vertexTag_ = cleaningParameters_.getParameter<edm::InputTag>("vertexCollection");
118  vertexToken_ = consumes<std::vector<reco::Vertex> >(edm::InputTag(vertexTag_));
119 
120  verbose_= pSet.getParameter<int>("verbose");
121 }
122 
123 
124 // ***********************************************************
126 
127  delete DCSFilter_;
128  LogTrace("DQMPFCandidateAnalyzer")<<"[DQMPFCandidateAnalyzer] Saving the histos";
129 }
130 
131 // ***********************************************************
133  edm::Run const & iRun,
134  edm::EventSetup const & ) {
135 
136  ibooker.setCurrentFolder("JetMET/PFCandidates/"+mInputCollection_.label());
137  std::string DirName = "JetMET/PFCandidates/"+mInputCollection_.label();
138 
139  if(!isMiniAOD_){
140  if(!occupancyPFCandRECO_.empty())occupancyPFCandRECO_.clear();
141  if(!occupancyPFCand_nameRECO_.empty())occupancyPFCand_nameRECO_.clear();
142  if(!etaMinPFCandRECO_.empty())etaMinPFCandRECO_.clear();
143  if(!etaMaxPFCandRECO_.empty())etaMaxPFCandRECO_.clear();
144  if(!typePFCandRECO_.empty())typePFCandRECO_.clear();
145  if(!countsPFCandRECO_.empty())countsPFCandRECO_.clear();
146  if(!ptPFCandRECO_.empty())ptPFCandRECO_.clear();
147  if(!ptPFCand_nameRECO_.empty())ptPFCand_nameRECO_.clear();
148  if(!multiplicityPFCandRECO_.empty())multiplicityPFCandRECO_.clear();
149  if(!multiplicityPFCand_nameRECO_.empty())multiplicityPFCand_nameRECO_.clear();
150  for (std::vector<edm::ParameterSet>::const_iterator v = diagnosticsParameters_.begin(); v!=diagnosticsParameters_.end(); v++) {
151  int etaNBinsPFCand = v->getParameter<int>("etaNBins");
152  double etaMinPFCand = v->getParameter<double>("etaMin");
153  double etaMaxPFCand = v->getParameter<double>("etaMax");
154  int phiNBinsPFCand = v->getParameter<int>("phiNBins");
155  double phiMinPFCand = v->getParameter<double>("phiMin");
156  double phiMaxPFCand = v->getParameter<double>("phiMax");
157  int nMinPFCand = v->getParameter<int>("nMin");
158  int nMaxPFCand = v->getParameter<int>("nMax");
159  int nbinsPFCand = v->getParameter<double>("nbins");
160  etaMinPFCandRECO_.push_back(etaMinPFCand);
161  etaMaxPFCandRECO_.push_back(etaMaxPFCand);
162  typePFCandRECO_.push_back(v->getParameter<int>("type"));
163  countsPFCandRECO_.push_back(0);
164  multiplicityPFCandRECO_.push_back(ibooker.book1D(std::string(v->getParameter<std::string>("name")).append("_multiplicity_").c_str(),std::string(v->getParameter<std::string>("name"))+"multiplicity", nbinsPFCand, nMinPFCand, nMaxPFCand));
165  multiplicityPFCand_nameRECO_.push_back(std::string(v->getParameter<std::string>("name")).append("_multiplicity_"));
166  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+ multiplicityPFCand_nameRECO_[multiplicityPFCand_nameRECO_.size()-1], multiplicityPFCandRECO_[multiplicityPFCandRECO_.size()-1]));
167 
168  //push back names first, we need to create histograms with the name and fill it for endcap plots later
169  occupancyPFCand_nameRECO_.push_back(std::string(v->getParameter<std::string>("name")).append("_occupancy_"));
170 
171  ptPFCand_nameRECO_.push_back(std::string(v->getParameter<std::string>("name")).append("_pt_"));
172  //special booking for endcap plots, merge plots for eminus and eplus into one plot, using variable binning
173  //barrel plots have eta-boundaries on minus and plus side
174  //parameters start on minus side
175  if(etaMinPFCand*etaMaxPFCand<0){//barrel plots, plot only in barrel region
176  occupancyPFCandRECO_.push_back(ibooker.book2D(std::string(v->getParameter<std::string>("name")).append("_occupancy_").c_str(),std::string(v->getParameter<std::string>("name"))+"occupancy", etaNBinsPFCand, etaMinPFCand, etaMaxPFCand, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand));
177  ptPFCandRECO_.push_back(ibooker.book2D(std::string(v->getParameter<std::string>("name")).append("_pt_").c_str(),std::string(v->getParameter<std::string>("name"))+"pt", etaNBinsPFCand, etaMinPFCand, etaMaxPFCand, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand));
178  }else{//endcap or forward plots,
179  const int nbins_eta_endcap=2*(etaNBinsPFCand+1);
180  double eta_limits_endcap[nbins_eta_endcap];
181  for(int i=0;i<nbins_eta_endcap;i++){
182  if(i<(etaNBinsPFCand+1)){
183  eta_limits_endcap[i]=etaMinPFCand+i*(etaMaxPFCand-etaMinPFCand)/(double)etaNBinsPFCand;
184  }else{
185  eta_limits_endcap[i]= -etaMaxPFCand +(i- (etaNBinsPFCand+1) )*(etaMaxPFCand-etaMinPFCand)/(double)etaNBinsPFCand;
186  }
187  }
188  TH2F* hist_temp_occup = new TH2F((occupancyPFCand_nameRECO_[occupancyPFCand_nameRECO_.size()-1]).c_str(),"occupancy",nbins_eta_endcap-1, eta_limits_endcap, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand);
189  occupancyPFCandRECO_.push_back(ibooker.book2D(occupancyPFCand_nameRECO_[occupancyPFCand_nameRECO_.size()-1],hist_temp_occup));
190  TH2F* hist_temp_pt = new TH2F((ptPFCand_nameRECO_[ptPFCand_nameRECO_.size()-1]).c_str(),"pt",nbins_eta_endcap-1, eta_limits_endcap, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand);
191  ptPFCandRECO_.push_back(ibooker.book2D(ptPFCand_nameRECO_[ptPFCand_nameRECO_.size()-1], hist_temp_pt));
192  }
193 
194  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+ occupancyPFCand_nameRECO_[occupancyPFCand_nameRECO_.size()-1], occupancyPFCandRECO_[occupancyPFCandRECO_.size()-1]));
195  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+ ptPFCand_nameRECO_[ptPFCand_nameRECO_.size()-1], ptPFCandRECO_[ptPFCandRECO_.size()-1]));
196  }
197 
198  mProfileIsoPFChHad_TrackOccupancy=ibooker.book2D("IsoPfChHad_Track_profile","Isolated PFChHadron Tracker_occupancy", 108, -2.7, 2.7, 160, -M_PI,M_PI);
199  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_Track_profile" ,mProfileIsoPFChHad_TrackOccupancy));
200  mProfileIsoPFChHad_TrackPt=ibooker.book2D("IsoPfChHad_TrackPt","Isolated PFChHadron TrackPt", 108, -2.7, 2.7, 160, -M_PI,M_PI);
201  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_TrackPt" ,mProfileIsoPFChHad_TrackPt));
202 
203 
204  mProfileIsoPFChHad_EcalOccupancyCentral = ibooker.book2D("IsoPfChHad_ECAL_profile_central","IsolatedPFChHa ECAL occupancy (Barrel)", 180, -1.479, 1.479, 125, -M_PI,M_PI);
205  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_ECAL_profile_central" ,mProfileIsoPFChHad_EcalOccupancyCentral));
206  mProfileIsoPFChHad_EMPtCentral=ibooker.book2D("IsoPfChHad_EMPt_central","Isolated PFChHadron HadPt_central", 180, -1.479, 1.479, 360, -M_PI,M_PI);
207  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_EMPt_central" ,mProfileIsoPFChHad_EMPtCentral));
208 
209  mProfileIsoPFChHad_EcalOccupancyEndcap = ibooker.book2D("IsoPfChHad_ECAL_profile_endcap","IsolatedPFChHa ECAL occupancy (Endcap)", 110, -2.75, 2.75, 125, -M_PI,M_PI);
210  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_ECAL_profile_endcap" ,mProfileIsoPFChHad_EcalOccupancyEndcap));
211  mProfileIsoPFChHad_EMPtEndcap=ibooker.book2D("IsoPfChHad_EMPt_endcap","Isolated PFChHadron EMPt_endcap", 110, -2.75, 2.75, 125, -M_PI,M_PI);
212  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_EMPt_endcap" ,mProfileIsoPFChHad_EMPtEndcap));
213 
214  const int nbins_eta=16;
215 
216  double eta_limits[nbins_eta]={-2.650,-2.500,-2.322,-2.172,-2.043,-1.930,-1.830,-1.740,1.740,1.830,1.930,2.043,2.172,2.3122,2.500,2.650};
217 
218  TH2F* hist_temp_HCAL =new TH2F("IsoPfChHad_HCAL_profile_endcap","IsolatedPFChHa HCAL occupancy (outer endcap)",nbins_eta-1,eta_limits, 36, -M_PI,M_PI);
219  TH2F* hist_tempPt_HCAL=(TH2F*)hist_temp_HCAL->Clone("Isolated PFCHHadron HadPt (outer endcap)");
220 
221  mProfileIsoPFChHad_HcalOccupancyCentral = ibooker.book2D("IsoPfChHad_HCAL_profile_central","IsolatedPFChHa HCAL occupancy (Central Part)", 40, -1.740, 1.740, 72, -M_PI,M_PI);
222  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_HCAL_profile_central" ,mProfileIsoPFChHad_HcalOccupancyCentral));
223  mProfileIsoPFChHad_HadPtCentral=ibooker.book2D("IsoPfChHad_HadPt_central","Isolated PFChHadron HadPt_central", 40, -1.740, 1.740, 72, -M_PI,M_PI);
224  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_HadPt_central" ,mProfileIsoPFChHad_HadPtCentral));
225 
226  mProfileIsoPFChHad_HcalOccupancyEndcap = ibooker.book2D("IsoPfChHad_HCAL_profile_endcap",hist_temp_HCAL);
227  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_HCAL_profile_endcap" ,mProfileIsoPFChHad_HcalOccupancyEndcap));
228  mProfileIsoPFChHad_HadPtEndcap=ibooker.book2D("IsoPfChHad_HadPt_endcap",hist_tempPt_HCAL);
229  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"IsoPfChHad_HadPt_endcap" ,mProfileIsoPFChHad_HadPtEndcap));
230 
231  //actual HCAL segmentation in pseudorapidity -> reduce by a factor of two
232  //const int nbins_eta_hcal_total=54;
233  //double eta_limits_hcal_total[nbins_eta_hcal_total]=
234  // {-2.650,-2.500,-2.322,-2.172,-2.043,-1.930,-1.830,-1.740,-1.653,-1.566,-1.479,-1.392,-1.305,
235  // -1.218,-1.131,-1.044,-0.957,-0.870,-0.783,-0.696,-0.609,-0.522,-0.435,-0.348,-0.261,-0.174,-0.087,0.0,
236  // 0.087, 0.174, 0.261, 0.348, 0.435, 0.522, 0.609, 0.783, 0.870, 0.957, 1.044, 1.131, 1.218
237  // 1.305, 1.392, 1.479, 1.566, 1.653, 1.740, 1.830, 1.930, 2.043, 2.172, 2.322, 2.500, 2.650}
238  //
239 
240  const int nbins_eta_hcal_total=28;
241  double eta_limits_hcal_total[nbins_eta_hcal_total]={-2.650,-2.322,-2.043,-1.830,-1.653,-1.479,-1.305,-1.131,-0.957,-0.783,-0.609,-0.435,-0.261,-0.087,
242  0.087, 0.261, 0.435, 0.609, 0.783, 0.957, 1.131, 1.305, 1.479, 1.653, 1.830, 2.043, 2.322, 2.650};
243  float eta_limits_hcal_total_f[nbins_eta_hcal_total];
244  float log_bin_spacing = log(200.)/40.;
245  const int nbins_pt_total_hcal= 41;
246  double pt_limits_hcal[nbins_pt_total_hcal];
247  float pt_limits_hcal_f[nbins_pt_total_hcal];
248  for(int i=0;i<nbins_pt_total_hcal;i++){
249  pt_limits_hcal[i]=exp(i*log_bin_spacing);
250  pt_limits_hcal_f[i]=exp(i*log_bin_spacing);
251  }
252  for(int i=0;i<nbins_eta_hcal_total;i++){
253  eta_limits_hcal_total_f[i]=(float)eta_limits_hcal_total[i];
254  }
255  m_HOverTrackP_trackPtVsEta= ibooker.book2D("HOverTrackP_trackPtVsEta","HOverTrackP_trackPtVsEta",nbins_pt_total_hcal-1,pt_limits_hcal_f,nbins_eta_hcal_total-1,eta_limits_hcal_total_f);
256  m_HOverTrackPVsTrackP_Barrel = ibooker.bookProfile("HOverTrackPVsTrackP_Barrel","HOverTrackPVsTrackP_Barrel",nbins_pt_total_hcal-1,pt_limits_hcal, 0, 4, " ");
257  m_HOverTrackPVsTrackP_EndCap = ibooker.bookProfile("HOverTrackPVsTrackP_EndCap","HOverTrackPVsTrackP_EndCap",nbins_pt_total_hcal-1,pt_limits_hcal, 0, 4, " ");
258  m_HOverTrackPVsTrackPt_Barrel = ibooker.bookProfile("HOverTrackPVsTrackPt_Barrel","HOverTrackPVsTrackPt_Barrel",nbins_pt_total_hcal-1,pt_limits_hcal, 0, 4, " ");
259  m_HOverTrackPVsTrackPt_EndCap = ibooker.bookProfile("HOverTrackPVsTrackPt_EndCap","HOverTrackPVsTrackPt_EndCap",nbins_pt_total_hcal-1,pt_limits_hcal, 0, 4, " ");
260 
261  m_HOverTrackPVsEta_hPt_1_10 = ibooker.bookProfile("HOverTrackPVsEta_hPt_1_10","HOverTrackPVsEta, 1<hPt<10 GeV",nbins_eta_hcal_total-1, eta_limits_hcal_total, 0, 4, " ");
262  m_HOverTrackPVsEta_hPt_10_20 = ibooker.bookProfile("HOverTrackPVsEta_hPt_10_20","HOverTrackPVsEta, 10<hPt<20 GeV",nbins_eta_hcal_total-1, eta_limits_hcal_total, 0, 4, " ");
263  m_HOverTrackPVsEta_hPt_20_50 = ibooker.bookProfile("HOverTrackPVsEta_hPt_20_50","HOverTrackPVsEta, 20<hPt<50 GeV",nbins_eta_hcal_total-1, eta_limits_hcal_total, 0, 4, " ");
264  m_HOverTrackPVsEta_hPt_50 = ibooker.bookProfile("HOverTrackPVsEta_hPt_50","HOverTrackPVsEta, hPt>50 GeV",nbins_eta_hcal_total-1, eta_limits_hcal_total, 0, 4, " ");
265 
266  m_HOverTrackP_Barrel_hPt_1_10= ibooker.book1D("HOverTrackP_Barrel_hPt_1_10","HOverTrackP_B, 1<hPt<10 GeV",50,0,4);
267  m_HOverTrackP_Barrel_hPt_10_20= ibooker.book1D("HOverTrackP_Barrel_hPt_10_20","HOverTrackP_B, 10<hPt<20 GeV",50,0,4);
268  m_HOverTrackP_Barrel_hPt_20_50= ibooker.book1D("HOverTrackP_Barrel_hPt_20_50","HOverTrackP_B, 20<hPt<50 GeV",50,0,4);
269  m_HOverTrackP_Barrel_hPt_50= ibooker.book1D("HOverTrackP_Barrel_hPt_50","HOverTrackP_B, hPt>50 GeV",50,0,4);
270 
271  m_HOverTrackP_EndCap_hPt_1_10= ibooker.book1D("HOverTrackP_EndCap_hPt_1_10","HOverTrackP_E, 1<hPt<10 GeV",50,0,4);
272  m_HOverTrackP_EndCap_hPt_10_20= ibooker.book1D("HOverTrackP_EndCap_hPt_10_20","HOverTrackP_E, 10<hPt<20 GeV",50,0,4);
273  m_HOverTrackP_EndCap_hPt_20_50= ibooker.book1D("HOverTrackP_EndCap_hPt_20_50","HOverTrackP_E, 20<hPt<50 GeV",50,0,4);
274  m_HOverTrackP_EndCap_hPt_50= ibooker.book1D("HOverTrackP_EndCap_hPt_50","HOverTrackP_E, hPt>50 GeV",50,0,4);
275 
276  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_trackPtVsEta" ,m_HOverTrackP_trackPtVsEta));
277  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackPVsTrackP_Barrel" ,m_HOverTrackPVsTrackP_Barrel));
278  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackPVsTrackP_EndCap" ,m_HOverTrackPVsTrackP_EndCap));
279  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackPVsTrackPt_Barrel" ,m_HOverTrackPVsTrackPt_Barrel));
280  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackPVsTrackPt_EndCap" ,m_HOverTrackPVsTrackPt_EndCap));
281  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackPVsEta_hPt_1_10" ,m_HOverTrackPVsEta_hPt_1_10));
282  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackPVsEta_hPt_10_20" ,m_HOverTrackPVsEta_hPt_10_20));
283  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackPVsEta_hPt_20_50" ,m_HOverTrackPVsEta_hPt_20_50));
284  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackPVsEta_hPt_50" ,m_HOverTrackPVsEta_hPt_50));
285  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_Barrel_hPt_1_10" ,m_HOverTrackP_Barrel_hPt_1_10));
286  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_Barrel_hPt_10_20" ,m_HOverTrackP_Barrel_hPt_10_20));
287  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_Barrel_hPt_20_50" ,m_HOverTrackP_Barrel_hPt_20_50));
288  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_Barrel_hPt_50" ,m_HOverTrackP_Barrel_hPt_50));
289  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_EndCap_hPt_1_10" ,m_HOverTrackP_EndCap_hPt_1_10));
290  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_EndCap_hPt_10_20" ,m_HOverTrackP_EndCap_hPt_10_20));
291  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_EndCap_hPt_20_50" ,m_HOverTrackP_EndCap_hPt_20_50));
292  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"HOverTrackP_EndCap_hPt_50" ,m_HOverTrackP_EndCap_hPt_50));
293  }else{//MiniAOD workflow
294  if(!occupancyPFCand_.empty())occupancyPFCand_.clear();
295  if(!occupancyPFCand_name_.empty())occupancyPFCand_name_.clear();
296  if(!occupancyPFCand_puppiNolepWeight_.empty())occupancyPFCand_puppiNolepWeight_.clear();
297  if(!occupancyPFCand_name_puppiNolepWeight_.empty())occupancyPFCand_name_puppiNolepWeight_.clear();
298  if(!etaMinPFCand_.empty())etaMinPFCand_.clear();
299  if(!etaMaxPFCand_.empty())etaMaxPFCand_.clear();
300  if(!typePFCand_.empty())typePFCand_.clear();
301  if(!countsPFCand_.empty())countsPFCand_.clear();
302  if(!ptPFCand_.empty())ptPFCand_.clear();
303  if(!ptPFCand_name_.empty())ptPFCand_name_.clear();
304  if(!ptPFCand_puppiNolepWeight_.empty())ptPFCand_puppiNolepWeight_.clear();
305  if(!ptPFCand_name_puppiNolepWeight_.empty())ptPFCand_name_puppiNolepWeight_.clear();
306  if(!multiplicityPFCand_.empty())multiplicityPFCand_.clear();
307  if(!multiplicityPFCand_name_.empty())multiplicityPFCand_name_.clear();
308  for (std::vector<edm::ParameterSet>::const_iterator v = diagnosticsParameters_.begin(); v!=diagnosticsParameters_.end(); v++) {
309  int etaNBinsPFCand = v->getParameter<int>("etaNBins");
310  double etaMinPFCand = v->getParameter<double>("etaMin");
311  double etaMaxPFCand = v->getParameter<double>("etaMax");
312  int phiNBinsPFCand = v->getParameter<int>("phiNBins");
313  double phiMinPFCand = v->getParameter<double>("phiMin");
314  double phiMaxPFCand = v->getParameter<double>("phiMax");
315  int nMinPFCand = v->getParameter<int>("nMin");
316  int nMaxPFCand = v->getParameter<int>("nMax");
317  int nbinsPFCand = v->getParameter<double>("nbins");
318 
319  // etaNBins_.push_back(etaNBins);
320  etaMinPFCand_.push_back(etaMinPFCand);
321  etaMaxPFCand_.push_back(etaMaxPFCand);
322  typePFCand_.push_back(v->getParameter<int>("type"));
323  countsPFCand_.push_back(0);
324 
325  multiplicityPFCand_.push_back(ibooker.book1D(std::string(v->getParameter<std::string>("name")).append("_multiplicity_").c_str(),std::string(v->getParameter<std::string>("name"))+"multiplicity", nbinsPFCand, nMinPFCand, nMaxPFCand));
326  multiplicityPFCand_name_.push_back(std::string(v->getParameter<std::string>("name")).append("_multiplicity_"));
327  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+ multiplicityPFCand_name_[multiplicityPFCand_name_.size()-1], multiplicityPFCand_[multiplicityPFCand_.size()-1]));
328  //push back names first, we need to create histograms with the name and fill it for endcap plots later
329  occupancyPFCand_name_.push_back(std::string(v->getParameter<std::string>("name")).append("_occupancy_puppiWeight_"));
330  ptPFCand_name_.push_back(std::string(v->getParameter<std::string>("name")).append("_pt_puppiWeight_"));
331  //push back names first, we need to create histograms with the name and fill it for endcap plots later
332  occupancyPFCand_name_puppiNolepWeight_.push_back(std::string(v->getParameter<std::string>("name")).append("_occupancy_puppiNolepWeight_"));
333  ptPFCand_name_puppiNolepWeight_.push_back(std::string(v->getParameter<std::string>("name")).append("_pt_puppiNolepWeight_"));
334  //special booking for endcap plots, merge plots for eminus and eplus into one plot, using variable binning
335  //barrel plots have eta-boundaries on minus and plus side
336  //parameters start on minus side
337  if(etaMinPFCand*etaMaxPFCand<0){//barrel plots, plot only in barrel region
338  occupancyPFCand_.push_back(ibooker.book2D(std::string(v->getParameter<std::string>("name")).append("_occupancy_puppiWeight_").c_str(),std::string(v->getParameter<std::string>("name"))+"occupancy_puppiWeight_", etaNBinsPFCand, etaMinPFCand, etaMaxPFCand, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand));
339  ptPFCand_.push_back(ibooker.book2D(std::string(v->getParameter<std::string>("name")).append("_pt_puppiWeight_").c_str(),std::string(v->getParameter<std::string>("name"))+"pt_puppiWeight_", etaNBinsPFCand, etaMinPFCand, etaMaxPFCand, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand));
340  occupancyPFCand_puppiNolepWeight_.push_back(ibooker.book2D(std::string(v->getParameter<std::string>("name")).append("_occupancy_puppiNolepWeight_").c_str(),std::string(v->getParameter<std::string>("name"))+"occupancy_puppiNolepWeight", etaNBinsPFCand, etaMinPFCand, etaMaxPFCand, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand));
341  ptPFCand_puppiNolepWeight_.push_back(ibooker.book2D(std::string(v->getParameter<std::string>("name")).append("_pt_puppiNolepWeight_").c_str(),std::string(v->getParameter<std::string>("name"))+"pt_puppiNolepWeight", etaNBinsPFCand, etaMinPFCand, etaMaxPFCand, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand));
342  }else{//endcap or forward plots,
343  const int nbins_eta_endcap=2*(etaNBinsPFCand+1);
344  double eta_limits_endcap[nbins_eta_endcap];
345  for(int i=0;i<nbins_eta_endcap;i++){
346  if(i<(etaNBinsPFCand+1)){
347  eta_limits_endcap[i]=etaMinPFCand+i*(etaMaxPFCand-etaMinPFCand)/(double)etaNBinsPFCand;
348  }else{
349  eta_limits_endcap[i]= -etaMaxPFCand +(i- (etaNBinsPFCand+1) )*(etaMaxPFCand-etaMinPFCand)/(double)etaNBinsPFCand;
350  }
351  }
352  TH2F* hist_temp_occup = new TH2F((occupancyPFCand_name_[occupancyPFCand_name_.size()-1]).c_str(),(occupancyPFCand_name_[occupancyPFCand_name_.size()-1]).c_str(),nbins_eta_endcap-1, eta_limits_endcap, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand);
353  occupancyPFCand_.push_back(ibooker.book2D(occupancyPFCand_name_[occupancyPFCand_name_.size()-1],hist_temp_occup));
354  TH2F* hist_temp_pt = new TH2F((ptPFCand_name_[ptPFCand_name_.size()-1]).c_str(),(ptPFCand_name_[ptPFCand_name_.size()-1]).c_str(),nbins_eta_endcap-1, eta_limits_endcap, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand);
355  ptPFCand_.push_back(ibooker.book2D(ptPFCand_name_[ptPFCand_name_.size()-1], hist_temp_pt));
356  TH2F* hist_temp_occup_puppiNolepWeight = new TH2F((occupancyPFCand_name_puppiNolepWeight_[occupancyPFCand_name_puppiNolepWeight_.size()-1]).c_str(),(occupancyPFCand_name_puppiNolepWeight_[occupancyPFCand_name_puppiNolepWeight_.size()-1]).c_str(),nbins_eta_endcap-1, eta_limits_endcap, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand);
357  occupancyPFCand_puppiNolepWeight_.push_back(ibooker.book2D(occupancyPFCand_name_puppiNolepWeight_[occupancyPFCand_name_puppiNolepWeight_.size()-1],hist_temp_occup_puppiNolepWeight));
358  TH2F* hist_temp_pt_puppiNolepWeight = new TH2F((ptPFCand_name_puppiNolepWeight_[ptPFCand_name_puppiNolepWeight_.size()-1]).c_str(),(ptPFCand_name_puppiNolepWeight_[ptPFCand_name_puppiNolepWeight_.size()-1]).c_str(),nbins_eta_endcap-1, eta_limits_endcap, phiNBinsPFCand, phiMinPFCand, phiMaxPFCand);
359  ptPFCand_puppiNolepWeight_.push_back(ibooker.book2D(ptPFCand_name_puppiNolepWeight_[ptPFCand_name_puppiNolepWeight_.size()-1], hist_temp_pt_puppiNolepWeight));
360  }
361  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+ occupancyPFCand_name_puppiNolepWeight_[occupancyPFCand_name_puppiNolepWeight_.size()-1], occupancyPFCand_puppiNolepWeight_[occupancyPFCand_puppiNolepWeight_.size()-1]));
362  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+ ptPFCand_name_puppiNolepWeight_[ptPFCand_name_puppiNolepWeight_.size()-1], ptPFCand_puppiNolepWeight_[ptPFCand_puppiNolepWeight_.size()-1]));
363  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+ occupancyPFCand_name_[occupancyPFCand_name_.size()-1], occupancyPFCand_[occupancyPFCand_.size()-1]));
364  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+ ptPFCand_name_[ptPFCand_name_.size()-1], ptPFCand_[ptPFCand_.size()-1]));
365  }
366  }
367 
368 
369 }
370 
371 // ***********************************************************
373 {
374 
375  miniaodfilterindex=-1;
376 
377  if(isMiniAOD_){
378  bool changed_filter=true;
379  if (FilterhltConfig_.init(iRun,iSetup,METFilterMiniAODLabel_.process(),changed_filter)){
380  miniaodfilterdec=0;
381  for(unsigned int i=0;i<FilterhltConfig_.size();i++){
382  std::string search=FilterhltConfig_.triggerName(i).substr(5);//actual label of filter, the first 5 items are Flag_, so stripped off
383  std::string search2=HBHENoiseStringMiniAOD;//all filters end with DQM, which is not in the flag --> ONLY not for HBHEFilters
384  std::size_t found=search2.find(search);
385  if(found!=std::string::npos){
386  miniaodfilterindex=i;
387  }
388  }
389  }else if(FilterhltConfig_.init(iRun,iSetup,METFilterMiniAODLabel2_.process(),changed_filter)){
390  miniaodfilterdec=1;
391  for(unsigned int i=0;i<FilterhltConfig_.size();i++){
392  std::string search=FilterhltConfig_.triggerName(i).substr(5);//actual label of filter, the first 5 items are Flag_, so stripped off
393  std::string search2=HBHENoiseStringMiniAOD;//all filters end with DQM, which is not in the flag --> ONLY not for HBHEFilters
394  std::size_t found=search2.find(search);
395  if(found!=std::string::npos){
396  miniaodfilterindex=i;
397  }
398  }
399  }else{
400  edm::LogWarning("MiniAOD MET Filter HLT OBject version")<<"nothing found with both RECO and reRECO label"<<std::endl;
401  }
402  }
403 }
404 
405 // ***********************************************************
407 {
408 }
409 
410 // ***********************************************************
412 
413 
414  //Vertex information
415  Handle<VertexCollection> vertexHandle;
416  iEvent.getByToken(vertexToken_, vertexHandle);
417 
418  if (!vertexHandle.isValid()) {
419  LogDebug("") << "CaloMETAnalyzer: Could not find vertex collection" << std::endl;
420  if (verbose_) std::cout << "CaloMETAnalyzer: Could not find vertex collection" << std::endl;
421  }
422  numPV_ = 0;
423  if ( vertexHandle.isValid() ){
424  VertexCollection vertexCollection = *(vertexHandle.product());
425  numPV_ = vertexCollection.size();
426  }
427  bool bPrimaryVertex = (bypassAllPVChecks_ || (numPV_>0));
428 
429 
430  int myLuminosityBlock;
431  myLuminosityBlock = iEvent.luminosityBlock();
432 
433  if (myLuminosityBlock<LSBegin_) return;
434  if (myLuminosityBlock>LSEnd_ && LSEnd_>0) return;
435 
436 
437  if (verbose_) std::cout << "METAnalyzer analyze" << std::endl;
438 
439  std::string DirName = "JetMET/PFCandidates/"+mInputCollection_.label();
440 
441  bool hbhenoifilterdecision=true;
442  if(!isMiniAOD_){//not checked for MiniAOD -> for miniaod decision filled as "triggerResults" bool
443  edm::Handle<bool> HBHENoiseFilterResultHandle;
444  iEvent.getByToken(hbheNoiseFilterResultToken_, HBHENoiseFilterResultHandle);
445  if (!HBHENoiseFilterResultHandle.isValid()) {
446  LogDebug("") << "METAnalyzer: Could not find HBHENoiseFilterResult" << std::endl;
447  if (verbose_) std::cout << "METAnalyzer: Could not find HBHENoiseFilterResult" << std::endl;
448  }
449  hbhenoifilterdecision= *HBHENoiseFilterResultHandle;
450  }else{//need to check if we go for version 1 or version 2
451  edm::Handle<edm::TriggerResults> metFilterResults;
452  iEvent.getByToken(METFilterMiniAODToken_, metFilterResults);
453  if(metFilterResults.isValid()){
454  if(miniaodfilterindex!=-1){
455  hbhenoifilterdecision = metFilterResults->accept(miniaodfilterindex);
456  }
457  }else{
458  iEvent.getByToken(METFilterMiniAODToken2_, metFilterResults);
459  if(metFilterResults.isValid()){
460  if(miniaodfilterindex!=-1){
461  hbhenoifilterdecision = metFilterResults->accept(miniaodfilterindex);
462  }
463  }
464  }
465  }
466 
467  //DCS Filter
468  bool bDCSFilter = (bypassAllDCSChecks_ || DCSFilter_->filter(iEvent, iSetup));
469 
470  for (unsigned int i=0;i<countsPFCand_.size();i++) {
471  countsPFCand_[i]=0;
472  }
473  if(bDCSFilter && hbhenoifilterdecision && bPrimaryVertex){
474  if(isMiniAOD_){
476  iEvent.getByToken(pflowPackedToken_, packedParticleFlow);
477  //11, 13, 22 for el/mu/gamma, 211 chargedHadron, 130 neutralHadrons, 1 and 2 hadHF and EGammaHF
478  for (unsigned int i = 0; i < packedParticleFlow->size(); i++) {
479  const pat::PackedCandidate& c = packedParticleFlow->at(i);
480  for (unsigned int j=0; j<typePFCand_.size(); j++) {
481  if (abs(c.pdgId())==typePFCand_[j]) {
482  //second check for endcap, if inside barrel Max and Min symmetric around 0
483  if ( ((c.eta()>etaMinPFCand_[j]) && (c.eta()<etaMaxPFCand_[j])) || ((c.eta()> (-etaMaxPFCand_[j])) && (c.eta()< (-etaMinPFCand_[j]))) ){
484  countsPFCand_[j]+=1;
485  ptPFCand_[j] = map_of_MEs[DirName + "/"+ptPFCand_name_[j]];
486  if ( ptPFCand_[j] && ptPFCand_[j]->getRootObject()) ptPFCand_[j]->Fill(c.eta(), c.phi(), c.pt()*c.puppiWeight());
487  occupancyPFCand_[j] = map_of_MEs[DirName + "/"+occupancyPFCand_name_[j]];
488  if ( occupancyPFCand_[j] && occupancyPFCand_[j]->getRootObject()) occupancyPFCand_[j]->Fill(c.eta(), c.phi(),c.puppiWeight());
489  ptPFCand_puppiNolepWeight_[j] = map_of_MEs[DirName + "/"+ptPFCand_name_puppiNolepWeight_[j]];
490  if ( ptPFCand_puppiNolepWeight_[j] && ptPFCand_puppiNolepWeight_[j]->getRootObject()) ptPFCand_puppiNolepWeight_[j]->Fill(c.eta(), c.phi(), c.pt()*c.puppiWeightNoLep());
491  occupancyPFCand_puppiNolepWeight_[j] = map_of_MEs[DirName + "/"+occupancyPFCand_name_puppiNolepWeight_[j]];
492  if ( occupancyPFCand_puppiNolepWeight_[j] && occupancyPFCand_puppiNolepWeight_[j]->getRootObject()){ occupancyPFCand_puppiNolepWeight_[j]->Fill(c.eta(), c.phi(),c.puppiWeightNoLep());
493  }
494  }
495  }
496  }
497  }
498  for (unsigned int j=0; j<countsPFCand_.size(); j++) {
499  multiplicityPFCand_[j] = map_of_MEs[DirName + "/"+multiplicityPFCand_name_[j]];
500  if(multiplicityPFCand_[j] && multiplicityPFCand_[j]->getRootObject()){ multiplicityPFCand_[j]->Fill(countsPFCand_[j]);
501  }
502  }
503  }else{
505  iEvent.getByToken(pflowToken_, particleFlow);
506  for (unsigned int i = 0; i < particleFlow->size(); i++) {
507  const reco::PFCandidate& c = particleFlow->at(i);
508  for (unsigned int j=0; j<typePFCandRECO_.size(); j++) {
509  if (c.particleId()==typePFCandRECO_[j]) {
510  //second check for endcap, if inside barrel Max and Min symmetric around 0
511  if ( ((c.eta()>etaMinPFCandRECO_[j]) && (c.eta()<etaMaxPFCandRECO_[j])) || ((c.eta()> (-etaMaxPFCandRECO_[j])) && (c.eta()< (-etaMinPFCandRECO_[j]))) ){
512  countsPFCandRECO_[j]+=1;
513  ptPFCandRECO_[j] = map_of_MEs[DirName + "/"+ptPFCand_nameRECO_[j]];
514  if ( ptPFCandRECO_[j] && ptPFCandRECO_[j]->getRootObject()) ptPFCandRECO_[j]->Fill(c.eta(), c.phi(), c.pt());
515  occupancyPFCandRECO_[j] = map_of_MEs[DirName + "/"+occupancyPFCand_nameRECO_[j]];
516  if ( occupancyPFCandRECO_[j] && occupancyPFCandRECO_[j]->getRootObject()) occupancyPFCandRECO_[j]->Fill(c.eta(), c.phi());
517  }
518  //fill quantities for isolated charged hadron quantities
519  //only for charged hadrons
520  if ( c.particleId() == 1 && c.pt() > ptMinCand_ ){
521  // At least 1 GeV in HCAL
522  double ecalRaw = c.rawEcalEnergy();
523  double hcalRaw = c.rawHcalEnergy();
524  if ( (ecalRaw + hcalRaw) > hcalMin_ ){
525  const PFCandidate::ElementsInBlocks& theElements = c.elementsInBlocks();
526  if( theElements.empty() ) continue;
527  unsigned int iTrack=-999;
528  std::vector<unsigned int> iECAL;// =999;
529  std::vector<unsigned int> iHCAL;// =999;
530  const reco::PFBlockRef blockRef = theElements[0].first;
531  const edm::OwnVector<reco::PFBlockElement>& elements = blockRef->elements();
532  // Check that there is only one track in the block.
533  unsigned int nTracks = 0;
534  for(unsigned int iEle=0; iEle<elements.size(); iEle++) {
535  // Find the tracks in the block
536  PFBlockElement::Type type = elements[iEle].type();
537  switch( type ) {
538  case PFBlockElement::TRACK:
539  iTrack = iEle;
540  nTracks++;
541  break;
543  iECAL.push_back( iEle );
544  break;
546  iHCAL.push_back( iEle );
547  break;
548  default:
549  continue;
550  }
551  }
552  if ( nTracks == 1 ){
553  // Characteristics of the track
554  const reco::PFBlockElementTrack& et = dynamic_cast<const reco::PFBlockElementTrack &>( elements[iTrack] );
555  mProfileIsoPFChHad_TrackOccupancy=map_of_MEs[DirName+"/"+"IsoPfChHad_Track_profile"];
556  if (mProfileIsoPFChHad_TrackOccupancy && mProfileIsoPFChHad_TrackOccupancy->getRootObject()) mProfileIsoPFChHad_TrackOccupancy->Fill(et.trackRef()->eta(),et.trackRef()->phi());
557  mProfileIsoPFChHad_TrackPt=map_of_MEs[DirName+"/"+"IsoPfChHad_TrackPt"];
558  if (mProfileIsoPFChHad_TrackPt && mProfileIsoPFChHad_TrackPt->getRootObject()) mProfileIsoPFChHad_TrackPt->Fill(et.trackRef()->eta(),et.trackRef()->phi(),et.trackRef()->pt());
559  if(c.rawEcalEnergy()==0){//isolated hadron, nothing in ECAL
560  //right now take corrected hcalEnergy, do we want the rawHcalEnergy instead
561  m_HOverTrackP_trackPtVsEta=map_of_MEs[DirName+"/"+"HOverTrackP_trackPtVsEta"];
562  if(m_HOverTrackP_trackPtVsEta && m_HOverTrackP_trackPtVsEta->getRootObject()) m_HOverTrackP_trackPtVsEta->Fill(c.pt(), c.eta(), c.hcalEnergy()/et.trackRef()->p());
563  if(c.pt()>1 && c.pt()<10){
564  m_HOverTrackPVsEta_hPt_1_10=map_of_MEs[DirName+"/"+"HOverTrackPVsEta_hPt_1_10"];
565  if(m_HOverTrackPVsEta_hPt_1_10 && m_HOverTrackPVsEta_hPt_1_10->getRootObject()) m_HOverTrackPVsEta_hPt_1_10->Fill(c.eta(), c.hcalEnergy()/et.trackRef()->p());
566  }else if(c.pt()>10 && c.pt()<20){
567  m_HOverTrackPVsEta_hPt_10_20=map_of_MEs[DirName+"/"+"HOverTrackPVsEta_hPt_10_20"];
568  if(m_HOverTrackPVsEta_hPt_10_20 && m_HOverTrackPVsEta_hPt_10_20->getRootObject()) m_HOverTrackPVsEta_hPt_10_20->Fill(c.eta(), c.hcalEnergy()/et.trackRef()->p());
569  }else if(c.pt()>20 && c.pt()<50){
570  m_HOverTrackPVsEta_hPt_20_50=map_of_MEs[DirName+"/"+"HOverTrackPVsEta_hPt_20_50"];
571  if(m_HOverTrackPVsEta_hPt_20_50 && m_HOverTrackPVsEta_hPt_20_50->getRootObject()) m_HOverTrackPVsEta_hPt_20_50->Fill(c.eta(), c.hcalEnergy()/et.trackRef()->p());
572  }else if(c.pt()>50){
573  m_HOverTrackPVsEta_hPt_50=map_of_MEs[DirName+"/"+"HOverTrackPVsEta_hPt_50"];
574  if(m_HOverTrackPVsEta_hPt_50 && m_HOverTrackPVsEta_hPt_50->getRootObject()) m_HOverTrackPVsEta_hPt_50->Fill(c.eta(), c.hcalEnergy()/et.trackRef()->p());
575  }
576  if(fabs(c.eta()<1.392)){
577  if(c.pt()>1 && c.pt()<10){
578  m_HOverTrackP_Barrel_hPt_1_10=map_of_MEs[DirName+"/"+"HOverTrackP_Barrel_hPt_1_10"];
579  if(m_HOverTrackP_Barrel_hPt_1_10 && m_HOverTrackP_Barrel_hPt_1_10->getRootObject()) m_HOverTrackP_Barrel_hPt_1_10->Fill(c.hcalEnergy()/et.trackRef()->p());
580  }else if(c.pt()>10 && c.pt()<20){
581  m_HOverTrackP_Barrel_hPt_10_20=map_of_MEs[DirName+"/"+"HOverTrackP_Barrel_hPt_10_20"];
582  if(m_HOverTrackP_Barrel_hPt_10_20 && m_HOverTrackP_Barrel_hPt_10_20->getRootObject()) m_HOverTrackP_Barrel_hPt_10_20->Fill(c.hcalEnergy()/et.trackRef()->p());
583  }else if(c.pt()>20 && c.pt()<50){
584  m_HOverTrackP_Barrel_hPt_20_50=map_of_MEs[DirName+"/"+"HOverTrackP_Barrel_hPt_20_50"];
585  if(m_HOverTrackP_Barrel_hPt_20_50 && m_HOverTrackP_Barrel_hPt_20_50->getRootObject()) m_HOverTrackP_Barrel_hPt_20_50->Fill(c.hcalEnergy()/et.trackRef()->p());
586  }else if(c.pt()>50){
587  m_HOverTrackP_Barrel_hPt_50=map_of_MEs[DirName+"/"+"HOverTrackP_Barrel_hPt_50"];
588  if(m_HOverTrackP_Barrel_hPt_50 && m_HOverTrackP_Barrel_hPt_50->getRootObject()) m_HOverTrackP_Barrel_hPt_50->Fill(c.hcalEnergy()/et.trackRef()->p());
589  }
590  m_HOverTrackPVsTrackP_Barrel=map_of_MEs[DirName+"/"+"HOverTrackPVsTrackP_Barrel"];
591  if(m_HOverTrackPVsTrackP_Barrel && m_HOverTrackPVsTrackP_Barrel->getRootObject()) m_HOverTrackPVsTrackP_Barrel->Fill(et.trackRef()->p(), c.hcalEnergy()/et.trackRef()->p());
592  m_HOverTrackPVsTrackPt_Barrel=map_of_MEs[DirName+"/"+"HOverTrackPVsTrackPt_Barrel"];
593  if(m_HOverTrackPVsTrackPt_Barrel && m_HOverTrackPVsTrackPt_Barrel->getRootObject()) m_HOverTrackPVsTrackPt_Barrel->Fill(et.trackRef()->pt(), c.hcalEnergy()/et.trackRef()->p());
594  }else{
595  m_HOverTrackPVsTrackP_EndCap=map_of_MEs[DirName+"/"+"HOverTrackPVsTrackP_EndCap"];
596  if(m_HOverTrackPVsTrackP_EndCap && m_HOverTrackPVsTrackP_EndCap->getRootObject()) m_HOverTrackPVsTrackP_EndCap->Fill(et.trackRef()->p(), c.hcalEnergy()/et.trackRef()->p());
597  m_HOverTrackPVsTrackPt_EndCap=map_of_MEs[DirName+"/"+"HOverTrackPVsTrackPt_EndCap"];
598  if(m_HOverTrackPVsTrackPt_EndCap && m_HOverTrackPVsTrackPt_EndCap->getRootObject())m_HOverTrackPVsTrackPt_EndCap->Fill(et.trackRef()->pt(), c.hcalEnergy()/et.trackRef()->p());
599  if(c.pt()>1 && c.pt()<10){
600  m_HOverTrackP_EndCap_hPt_1_10=map_of_MEs[DirName+"/"+"HOverTrackP_EndCap_hPt_1_10"];
601  if(m_HOverTrackP_EndCap_hPt_1_10 && m_HOverTrackP_EndCap_hPt_1_10->getRootObject()) m_HOverTrackP_EndCap_hPt_1_10->Fill(c.hcalEnergy()/et.trackRef()->p());
602  }else if(c.pt()>10 && c.pt()<20){
603  m_HOverTrackP_EndCap_hPt_10_20=map_of_MEs[DirName+"/"+"HOverTrackP_EndCap_hPt_10_20"];
604  if(m_HOverTrackP_EndCap_hPt_10_20 && m_HOverTrackP_EndCap_hPt_10_20->getRootObject()) m_HOverTrackP_EndCap_hPt_10_20->Fill(c.hcalEnergy()/et.trackRef()->p());
605  }else if(c.pt()>20 && c.pt()<50){
606  m_HOverTrackP_EndCap_hPt_20_50=map_of_MEs[DirName+"/"+"HOverTrackP_EndCap_hPt_20_50"];
607  if(m_HOverTrackP_EndCap_hPt_20_50 && m_HOverTrackP_EndCap_hPt_20_50->getRootObject()) m_HOverTrackP_EndCap_hPt_20_50->Fill(c.hcalEnergy()/et.trackRef()->p());
608  }else if(c.pt()>50){
609  m_HOverTrackP_EndCap_hPt_50=map_of_MEs[DirName+"/"+"HOverTrackP_EndCap_hPt_50"];
610  if(m_HOverTrackP_EndCap_hPt_50 && m_HOverTrackP_EndCap_hPt_50->getRootObject()) m_HOverTrackP_EndCap_hPt_50->Fill(c.hcalEnergy()/et.trackRef()->p());
611  }
612  }
613  }
614  //ECAL element
615  for(unsigned int ii=0;ii<iECAL.size();ii++) {
616  const reco::PFBlockElementCluster& eecal = dynamic_cast<const reco::PFBlockElementCluster &>( elements[ iECAL[ii] ] );
617  if(fabs(eecal.clusterRef()->eta())<1.479){
618  mProfileIsoPFChHad_EcalOccupancyCentral=map_of_MEs[DirName+"/"+"IsoPfChHad_ECAL_profile_central"];
619  if (mProfileIsoPFChHad_EcalOccupancyCentral && mProfileIsoPFChHad_EcalOccupancyCentral->getRootObject()) mProfileIsoPFChHad_EcalOccupancyCentral->Fill(eecal.clusterRef()->eta(),eecal.clusterRef()->phi());
620  mProfileIsoPFChHad_EMPtCentral=map_of_MEs[DirName+"/"+"IsoPfChHad_EMPt_central"];
621  if (mProfileIsoPFChHad_EMPtCentral && mProfileIsoPFChHad_EMPtCentral->getRootObject()) mProfileIsoPFChHad_EMPtCentral->Fill(eecal.clusterRef()->eta(),eecal.clusterRef()->phi(),eecal.clusterRef()->pt());
622  }else{
623  mProfileIsoPFChHad_EcalOccupancyEndcap=map_of_MEs[DirName+"/"+"IsoPfChHad_ECAL_profile_endcap"];
624  if (mProfileIsoPFChHad_EcalOccupancyEndcap && mProfileIsoPFChHad_EcalOccupancyEndcap->getRootObject()) mProfileIsoPFChHad_EcalOccupancyEndcap->Fill(eecal.clusterRef()->eta(),eecal.clusterRef()->phi());
625  mProfileIsoPFChHad_EMPtEndcap=map_of_MEs[DirName+"/"+"IsoPfChHad_EMPt_endcap"];
626  if (mProfileIsoPFChHad_EMPtEndcap && mProfileIsoPFChHad_EMPtEndcap->getRootObject()) mProfileIsoPFChHad_EMPtEndcap->Fill(eecal.clusterRef()->eta(),eecal.clusterRef()->phi(),eecal.clusterRef()->pt());
627  }
628 
629 
630  }
631  //HCAL element
632  for(unsigned int ii=0;ii<iHCAL.size();ii++) {
633  const reco::PFBlockElementCluster& ehcal = dynamic_cast<const reco::PFBlockElementCluster &>( elements[ iHCAL[ii] ] );
634  if(fabs(ehcal.clusterRef()->eta())<1.740){
635  mProfileIsoPFChHad_HcalOccupancyCentral=map_of_MEs[DirName+"/"+"IsoPfChHad_HCAL_profile_central"];
636  if (mProfileIsoPFChHad_HcalOccupancyCentral && mProfileIsoPFChHad_HcalOccupancyCentral->getRootObject()) mProfileIsoPFChHad_HcalOccupancyCentral->Fill(ehcal.clusterRef()->eta(),ehcal.clusterRef()->phi());
637  mProfileIsoPFChHad_HadPtCentral=map_of_MEs[DirName+"/"+"IsoPfChHad_HadPt_central"];
638  if (mProfileIsoPFChHad_HadPtCentral && mProfileIsoPFChHad_HadPtCentral->getRootObject()) mProfileIsoPFChHad_HadPtCentral->Fill(ehcal.clusterRef()->eta(),ehcal.clusterRef()->phi(),ehcal.clusterRef()->pt());
639  }else{
640  mProfileIsoPFChHad_HcalOccupancyEndcap=map_of_MEs[DirName+"/"+"IsoPfChHad_HCAL_profile_endcap"];
641  if (mProfileIsoPFChHad_HcalOccupancyEndcap && mProfileIsoPFChHad_HcalOccupancyEndcap->getRootObject()) mProfileIsoPFChHad_HcalOccupancyEndcap->Fill(ehcal.clusterRef()->eta(),ehcal.clusterRef()->phi());
642  mProfileIsoPFChHad_HadPtEndcap=map_of_MEs[DirName+"/"+"IsoPfChHad_HadPt_endcap"];
643  if (mProfileIsoPFChHad_HadPtEndcap && mProfileIsoPFChHad_HadPtEndcap->getRootObject()) mProfileIsoPFChHad_HadPtEndcap->Fill(ehcal.clusterRef()->eta(),ehcal.clusterRef()->phi(),ehcal.clusterRef()->pt());
644  }
645  }
646  }
647  }
648  }
649  }
650  }
651  }
652  for (unsigned int j=0; j<countsPFCandRECO_.size(); j++) {
653  multiplicityPFCandRECO_[j] = map_of_MEs[DirName + "/"+multiplicityPFCand_nameRECO_[j]];
654  if(multiplicityPFCandRECO_[j] && multiplicityPFCandRECO_[j]->getRootObject()){ multiplicityPFCandRECO_[j]->Fill(countsPFCandRECO_[j]);
655  }
656  }
657  }//candidate loop for both miniaod and reco
658  }
659 }
#define LogDebug(id)
float puppiWeight() const
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void endRun(const edm::Run &, const edm::EventSetup &) override
Finish up a run.
const unsigned int nTracks(const reco::Vertex &sv)
void analyze(const edm::Event &, const edm::EventSetup &) override
Get the analysis.
double eta() const final
momentum pseudorapidity
double rawEcalEnergy() const
return corrected Ecal energy
Definition: PFCandidate.h:225
float puppiWeightNoLep() const
Weight from full PUPPI.
int pdgId() const override
PDG identifier.
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const PFClusterRef & clusterRef() const override
std::vector< T >::const_iterator search(const cond::Time_t &val, const std::vector< T > &container)
Definition: IOVProxy.cc:314
const reco::TrackRef & trackRef() const override
bool accept() const
Has at least one path accepted the event?
size_type size() const
Definition: OwnVector.h:264
DQMPFCandidateAnalyzer(const edm::ParameterSet &)
Constructor.
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Inizialize parameters for histo binning.
std::vector< ElementInBlock > ElementsInBlocks
Definition: PFCandidate.h:387
int iEvent
Definition: GenABIO.cc:224
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
~DQMPFCandidateAnalyzer() override
Destructor.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double pt() const override
transverse momentum
bool isValid() const
Definition: HandleBase.h:74
#define LogTrace(id)
ii
Definition: cuy.py:590
#define M_PI
double eta() const override
momentum pseudorapidity
double phi() const override
momentum azimuthal angle
T const * product() const
Definition: Handle.h:74
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
et
define resolution functions of each parameter
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:40
fixed size matrix
HLT enums.
double hcalEnergy() const
return corrected Hcal energy
Definition: PFCandidate.h:232
virtual ParticleType particleId() const
Definition: PFCandidate.h:374
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Initialize run-based parameters.
const ElementsInBlocks & elementsInBlocks() const
Definition: PFCandidate.cc:691
double phi() const final
momentum azimuthal angle
Definition: Run.h:45
double rawHcalEnergy() const
return raw Hcal energy
Definition: PFCandidate.h:235