CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SUSY_HLT_alphaT.cc
Go to the documentation of this file.
7 //#include "HLTriggerOffline/SUSYBSM/interface/AlphaT.h"
8 
9 typedef ROOT::Math::LorentzVector<ROOT::Math::PtEtaPhiM4D<double> > LorentzV;
10 
12 {
13  edm::LogInfo("SUSY_HLT_alphaT") << "Constructor SUSY_HLT_alphaT::SUSY_HLT_alphaT " << std::endl;
14  // Get parameters from configuration file
15  theTrigSummary_ = consumes<trigger::TriggerEvent>(ps.getParameter<edm::InputTag>("trigSummary"));
16  thePfJetCollection_ = consumes<reco::PFJetCollection>(ps.getParameter<edm::InputTag>("pfJetCollection"));
17  theCaloJetCollection_ = consumes<reco::CaloJetCollection>(ps.getParameter<edm::InputTag>("caloJetCollection"));
18  triggerResults_ = consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("TriggerResults"));
19  HLTProcess_ = ps.getParameter<std::string>("HLTProcess");
20  triggerPath_ = ps.getParameter<std::string>("TriggerPath");
21  triggerPathAuxiliaryForHadronic_ = ps.getParameter<std::string>("TriggerPathAuxiliaryForHadronic");
22  triggerFilter_ = ps.getParameter<edm::InputTag>("TriggerFilter");
23  triggerPreFilter_ = ps.getParameter<edm::InputTag>("TriggerPreFilter");
24  ptThrJet_ = ps.getUntrackedParameter<double>("PtThrJet");
25  etaThrJet_ = ps.getUntrackedParameter<double>("EtaThrJet");
26  caloAlphaTThrTurnon_ = ps.getUntrackedParameter<double>("caloAlphaTThrTurnon");
27  caloHtThrTurnon_ = ps.getUntrackedParameter<double>("caloHtThrTurnon");
28  pfAlphaTThrTurnon_ = ps.getUntrackedParameter<double>("pfAlphaTThrTurnon");
29  pfHtThrTurnon_ = ps.getUntrackedParameter<double>("pfHtThrTurnon");
30 }
31 
33 {
34  edm::LogInfo("SUSY_HLT_alphaT") << "Destructor SUSY_HLT_alphaT::~SUSY_HLT_alphaT " << std::endl;
35 }
36 
38 {
39 
40  bool changed;
41 
42  if (!fHltConfig.init(run, e, HLTProcess_, changed)) {
43  edm::LogError("SUSY_HLT_alphaT") << "Initialization of HLTConfigProvider failed!!";
44  return;
45  }
46 
47  bool pathFound = false;
48  const std::vector<std::string> allTrigNames = fHltConfig.triggerNames();
49  for(size_t j = 0; j <allTrigNames.size(); ++j) {
50  if(allTrigNames[j].find(triggerPath_) != std::string::npos) {
51  pathFound = true;
52  }
53  }
54 
55  if(!pathFound) {
56  LogDebug ("SUSY_HLT_alphaT") << "Path not found" << "\n";
57  return;
58  }
59  //std::vector<std::string> filtertags = fHltConfig.moduleLabels( triggerPath_ );
60  //triggerFilter_ = edm::InputTag(filtertags[filtertags.size()-1],"",fHltConfig.processName());
61  //triggerFilter_ = edm::InputTag("hltPFMET120Mu5L3PreFiltered", "", fHltConfig.processName());
62 
63  edm::LogInfo("SUSY_HLT_alphaT") << "SUSY_HLT_alphaT::beginRun" << std::endl;
64 }
65 
67 {
68  edm::LogInfo("SUSY_HLT_alphaT") << "SUSY_HLT_alphaT::bookHistograms" << std::endl;
69  //book at beginRun
70  bookHistos(ibooker_);
71 }
72 
74  edm::EventSetup const& context)
75 {
76  edm::LogInfo("SUSY_HLT_alphaT") << "SUSY_HLT_alphaT::beginLuminosityBlock" << std::endl;
77 }
78 
79 
80 
82  edm::LogInfo("SUSY_HLT_alphaT") << "SUSY_HLT_alphaT::analyze" << std::endl;
83 
84  //-------------------------------
85  //--- Trigger
86  //-------------------------------
88  e.getByToken(triggerResults_,hltresults);
89  if(!hltresults.isValid()){
90  edm::LogWarning ("SUSY_HLT_alphaT") << "invalid collection: TriggerResults" << "\n";
91  return;
92  }
94  e.getByToken(theTrigSummary_, triggerSummary);
95  if(!triggerSummary.isValid()) {
96  edm::LogWarning ("SUSY_HLT_alphaT") << "invalid collection: TriggerSummary" << "\n";
97  return;
98  }
99 
100  //-------------------------------
101  //--- Jets
102  //-------------------------------
103  edm::Handle<reco::PFJetCollection> pfJetCollection;
104  e.getByToken (thePfJetCollection_,pfJetCollection);
105  if ( !pfJetCollection.isValid() ){
106  edm::LogWarning ("SUSY_HLT_alphaT") << "invalid collection: PFJets" << "\n";
107  return;
108  }
109  edm::Handle<reco::CaloJetCollection> caloJetCollection;
110  e.getByToken (theCaloJetCollection_,caloJetCollection);
111  if ( !caloJetCollection.isValid() ){
112  edm::LogWarning ("SUSY_HLT_alphaT") << "invalid collection: CaloJets" << "\n";
113  return;
114  }
115 
116  //get online objects
117  //For now just get the jets and recalculate ht and alphaT
118  size_t filterIndex = triggerSummary->filterIndex( triggerFilter_ );
119  size_t preFilterIndex = triggerSummary->filterIndex( triggerPreFilter_ );
120  trigger::TriggerObjectCollection triggerObjects = triggerSummary->getObjects();
121 
122  //Get the PF objects from the filter
123  double hltPfHt=0.;
124  std::vector<LorentzV> hltPfJets;
125  if( !(filterIndex >= triggerSummary->sizeFilters()) ){
126  const trigger::Keys& keys = triggerSummary->filterKeys( filterIndex );
127 
128  for( size_t j = 0; j < keys.size(); ++j ){
129  trigger::TriggerObject foundObject = triggerObjects[keys[j]];
130 
131  // if(foundObject.id() == 85){ //It's a jet
132  if(foundObject.pt()>ptThrJet_ && fabs(foundObject.eta()) < etaThrJet_){
133  hltPfHt += foundObject.pt();
134  LorentzV JetLVec(foundObject.pt(),foundObject.eta(),foundObject.phi(),foundObject.mass());
135  hltPfJets.push_back(JetLVec);
136  }
137  // }
138  }
139  }
140 
141  //Get the Calo objects from the prefilter
142  double hltCaloHt=0.;
143  std::vector<LorentzV> hltCaloJets;
144  if( !(preFilterIndex >= triggerSummary->sizeFilters()) ){
145  const trigger::Keys& keys = triggerSummary->filterKeys( preFilterIndex );
146 
147  for( size_t j = 0; j < keys.size(); ++j ){
148  trigger::TriggerObject foundObject = triggerObjects[keys[j]];
149 
150  // if(foundObject.id() == 85){ //It's a jet
151  if(foundObject.pt()>ptThrJet_ && fabs(foundObject.eta()) < etaThrJet_){
152  hltCaloHt += foundObject.pt();
153  LorentzV JetLVec(foundObject.pt(),foundObject.eta(),foundObject.phi(),foundObject.mass());
154  hltCaloJets.push_back(JetLVec);
155  }
156  // }
157  }
158  }
159 
160  //Fill the alphaT and HT histograms
161  if(hltPfJets.size()>0){
162  double hltPfAlphaT = AlphaT(hltPfJets,true).value();
163  h_triggerPfAlphaT->Fill(hltPfAlphaT);
164  h_triggerPfHt->Fill(hltPfHt);
165  h_triggerPfAlphaT_triggerPfHt->Fill(hltPfHt, hltPfAlphaT);
166  }
167 
168  if(hltCaloJets.size()>0){
169  double hltCaloAlphaT = AlphaT(hltCaloJets,true).value();
170  h_triggerCaloAlphaT->Fill(hltCaloAlphaT);
171  h_triggerCaloHt->Fill(hltCaloHt);
172  h_triggerCaloAlphaT_triggerCaloHt->Fill(hltCaloHt, hltCaloAlphaT);
173  }
174 
175  bool hasFired = false;
176  bool hasFiredAuxiliaryForHadronicLeg = false;
177  const edm::TriggerNames& trigNames = e.triggerNames(*hltresults);
178  unsigned int numTriggers = trigNames.size();
179  for( unsigned int hltIndex=0; hltIndex<numTriggers; ++hltIndex ){
180  if (trigNames.triggerName(hltIndex).find(triggerPath_) != std::string::npos && hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex)) hasFired = true;
181  if (trigNames.triggerName(hltIndex).find(triggerPathAuxiliaryForHadronic_) != std::string::npos && hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex)) hasFiredAuxiliaryForHadronicLeg = true;
182 
183  }
184 
185  if(hasFiredAuxiliaryForHadronicLeg) {
186 
187  float pfHT = 0.0;
188  std::vector<LorentzV> pfJets;
189  for (reco::PFJetCollection::const_iterator i_pfjet = pfJetCollection->begin(); i_pfjet != pfJetCollection->end(); ++i_pfjet){
190  if (i_pfjet->pt() < ptThrJet_) continue;
191  if (fabs(i_pfjet->eta()) > etaThrJet_) continue;
192  pfHT += i_pfjet->pt();
193  LorentzV JetLVec(i_pfjet->pt(),i_pfjet->eta(),i_pfjet->phi(),i_pfjet->mass());
194  pfJets.push_back(JetLVec);
195  }
196 
197  //Make the gen Calo HT and AlphaT
198  float caloHT = 0.0;
199  std::vector<LorentzV> caloJets;
200  for (reco::CaloJetCollection::const_iterator i_calojet = caloJetCollection->begin(); i_calojet != caloJetCollection->end(); ++i_calojet){
201  if (i_calojet->pt() < ptThrJet_) continue;
202  if (fabs(i_calojet->eta()) > etaThrJet_) continue;
203  caloHT += i_calojet->pt();
204  LorentzV JetLVec(i_calojet->pt(),i_calojet->eta(),i_calojet->phi(),i_calojet->mass());
205  caloJets.push_back(JetLVec);
206  }
207 
208  //AlphaT aT = AlphaT(jets);
209  double caloAlphaT = AlphaT(caloJets).value();
210  double pfAlphaT = AlphaT(pfJets).value();
211 
212  //Fill the turnons
213  if(hasFired) {
214  if(caloHT>caloHtThrTurnon_) h_caloAlphaTTurnOn_num-> Fill(caloAlphaT);
215  if(caloAlphaT>caloAlphaTThrTurnon_) h_caloHtTurnOn_num-> Fill(caloHT);
216 
217  if(pfHT>pfHtThrTurnon_) h_pfAlphaTTurnOn_num-> Fill(pfAlphaT);
218  if(pfAlphaT>pfAlphaTThrTurnon_) h_pfHtTurnOn_num-> Fill(pfHT);
219  }
220  if(caloHT>caloHtThrTurnon_) h_caloAlphaTTurnOn_den-> Fill(caloAlphaT);
221  if(caloAlphaT>caloAlphaTThrTurnon_) h_caloHtTurnOn_den-> Fill(caloHT);
222 
223  if(pfHT>pfHtThrTurnon_) h_pfAlphaTTurnOn_den-> Fill(pfAlphaT);
224  if(pfAlphaT>pfAlphaTThrTurnon_) h_pfHtTurnOn_den-> Fill(pfHT);
225  }
226 }
227 
228 
230 {
231  edm::LogInfo("SUSY_HLT_alphaT") << "SUSY_HLT_alphaT::endLuminosityBlock" << std::endl;
232 }
233 
234 
236 {
237  edm::LogInfo("SUSY_HLT_alphaT") << "SUSY_HLT_alphaT::endRun" << std::endl;
238 }
239 
241 {
242  ibooker_.cd();
243  ibooker_.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
244 
245  //offline quantities
246 
247  //online quantities
248  h_triggerCaloHt = ibooker_.book1D("triggerCaloHt", "Trigger Calo Ht; HT (GeV)", 60, 0.0, 1500.0);
249  h_triggerCaloAlphaT = ibooker_.book1D("triggerCaloAlphaT", "Trigger Calo AlphaT; AlphaT", 80, 0., 1.0);
250  h_triggerCaloAlphaT_triggerCaloHt = ibooker_.book2D("triggerCaloAlphaT_triggerCaloHt","Trigger Calo HT vs Trigger Calo AlphaT; HT (GeV); AlphaT", 60,0.0,1500.,80,0.,1.0);
251  h_triggerPfHt = ibooker_.book1D("triggerPfHt", "Trigger PF Ht; HT (GeV)", 60, 0.0, 1500.0);
252  h_triggerPfAlphaT = ibooker_.book1D("triggerPfAlphaT", "Trigger PF AlphaT; AlphaT", 80, 0., 1.0);
253  h_triggerPfAlphaT_triggerPfHt = ibooker_.book2D("triggerPfAlphaT_triggerPfHt","Trigger PF HT vs Trigger PF AlphaT; HT (GeV); AlphaT", 60,0.0,1500.,80,0.,1.0);
254 
255 
256  //num and den hists to be divided in harvesting step to make turn on curves
257  h_caloAlphaTTurnOn_num = ibooker_.book1D("caloAlphaTTurnOn_num", "Calo AlphaT Turn On Numerator; AlphaT", 40, 0.0, 1.0 );
258  h_caloAlphaTTurnOn_den = ibooker_.book1D("caloAlphaTTurnOn_den", "Calo AlphaT Turn OnDenominator; AlphaT", 40, 0.0, 1.0 );
259  h_caloHtTurnOn_num = ibooker_.book1D("caloHtTurnOn_num", "Calo HT Turn On Numerator; HT (GeV)", 30, 0.0, 1500.0 );
260  h_caloHtTurnOn_den = ibooker_.book1D("caloHtTurnOn_den", "Calo HT Turn On Denominator; HT (GeV)", 30, 0.0, 1500.0 );
261 
262  h_pfAlphaTTurnOn_num = ibooker_.book1D("pfAlphaTTurnOn_num", "PF AlphaT Turn On Numerator; AlphaT", 40, 0.0, 1.0 );
263  h_pfAlphaTTurnOn_den = ibooker_.book1D("pfAlphaTTurnOn_den", "PF AlphaT Turn OnDenominator; AlphaT", 40, 0.0, 1.0 );
264  h_pfHtTurnOn_num = ibooker_.book1D("pfHtTurnOn_num", "PF HT Turn On Numerator; HT (GeV)", 30, 0.0, 1500.0 );
265  h_pfHtTurnOn_den = ibooker_.book1D("pfHtTurnOn_den", "PF HT Turn On Denominator; HT (GeV)", 30, 0.0, 1500.0 );
266 
267  ibooker_.cd();
268 }
269 
270 //define this as a plug-in
#define LogDebug(id)
double caloAlphaTThrTurnon_
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
edm::InputTag triggerFilter_
MonitorElement * h_triggerCaloAlphaT
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
Definition: AlphaT.h:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:208
virtual ~SUSY_HLT_alphaT()
MonitorElement * h_triggerCaloHt
MonitorElement * h_triggerPfHt
edm::EDGetTokenT< trigger::TriggerEvent > theTrigSummary_
edm::EDGetTokenT< reco::CaloJetCollection > theCaloJetCollection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
float phi() const
Definition: TriggerObject.h:58
void cd(void)
Definition: DQMStore.cc:266
MonitorElement * h_caloAlphaTTurnOn_num
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const std::vector< std::string > & triggerNames() const
names of trigger paths
MonitorElement * h_triggerPfAlphaT_triggerPfHt
Strings::size_type size() const
Definition: TriggerNames.cc:39
float eta() const
Definition: TriggerObject.h:57
MonitorElement * h_caloHtTurnOn_den
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
MonitorElement * h_caloAlphaTTurnOn_den
void analyze(edm::Event const &e, edm::EventSetup const &eSetup)
void Fill(long long x)
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
void bookHistos(DQMStore::IBooker &)
MonitorElement * h_pfAlphaTTurnOn_num
edm::EDGetTokenT< edm::TriggerResults > triggerResults_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
int j
Definition: DBlmapReader.cc:9
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup)
bool isValid() const
Definition: HandleBase.h:75
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > LorentzV
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup)
HLTConfigProvider fHltConfig
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::string triggerPathAuxiliaryForHadronic_
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
std::vector< size_type > Keys
MonitorElement * h_pfHtTurnOn_den
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
MonitorElement * h_triggerPfAlphaT
MonitorElement * h_pfAlphaTTurnOn_den
std::string HLTProcess_
std::string triggerPath_
MonitorElement * h_pfHtTurnOn_num
edm::EDGetTokenT< reco::PFJetCollection > thePfJetCollection_
MonitorElement * h_caloHtTurnOn_num
float mass() const
Definition: TriggerObject.h:59
edm::InputTag triggerPreFilter_
tuple pfJets
Definition: pfJets_cff.py:8
MonitorElement * h_triggerCaloAlphaT_triggerCaloHt
SUSY_HLT_alphaT(const edm::ParameterSet &ps)
double pfAlphaTThrTurnon_
double value(void) const
Definition: AlphaT.h:53
Definition: Run.h:41