Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ]   [ 15.*.* ] 

001 ////////////////////////////////////////////////////////////////////////////////// 
002 /// Analysis skeleton
003 /// also for distributed analysis examples
004 /// Author: Ketevi A. Assamagan
005 /// BNL, July 22, 2004
006 ///
007 /// DESCRIPTION:
008 ///
009 /// This class is an analysis skeleton - The user can implement his analysis here
010 /// This class is also used for the demonstration of the distributed analysis
011 /// Some electron histograms are used for the distributed case. The user may
012 /// remove the histograms and the electron stuff if not needed.
013 /// Note t:he single algorithm structure as an analysis code does not scale
014 /// For detailed analysis examples, look in CVS: PhysicsAnalysis/AnalysisCommon/AnalysisExamples/
015 /// Ketevi A. Assamagan on June 22, 2004
016 ///
017 ///////////////////////////////////////////////////////////////////////////////////////////////////////
018 
019 
020 //////////////////////////////////////////////////////////////////////////////////
021 
022 #include "GaudiKernel/MsgStream.h"
023 #include "GaudiKernel/AlgFactory.h"
024 #include "GaudiKernel/IToolSvc.h"
025 
026 #include "StoreGate/StoreGateSvc.h"
027 
028 #include "egammaEvent/ElectronContainer.h"
029 #include "egammaEvent/EMShower.h"
030 #include "egammaEvent/egammaParamDefs.h"
031 
032 #include "McParticleEvent/TruthParticleContainer.h"
033 
034 #include "VxVertex/VxContainer.h"
035 #include "Particle/TrackParticleContainer.h"
036 #include "CaloEvent/CaloClusterContainer.h"
037 
038 #include "muonEvent/MuonContainer.h"
039 #include "egammaEvent/PhotonContainer.h"
040 #include "tauEvent/TauJetContainer.h"
041 #include "JetEvent/JetCollection.h"
042 #include "MissingETEvent/MissingET.h"
043 
044 #include "NavFourMom/IParticleContainer.h"
045 #include "NavFourMom/INavigable4MomentumCollection.h"
046 
047 #include "GaudiKernel/ITHistSvc.h"
048 #include "TTree.h"
049 #include "CLHEP/Vector/LorentzVector.h"
050 
051 #include "JetTagInfo/TruthInfo.h"
052 
053 #include "TrigDecisionTool/ChainGroup.h"
054 
055 #include "UserAnalysis/AnalysisSkeleton.h"
056 
057 #include "TrigParticle/TrigTau.h"
058 #include "tauEvent/TauJet.h"
059 #include "tauEvent/TauJetContainer.h"
060 #include "tauEvent/TauDetailsContainer.h"
061 #include "tauEvent/Tau1P3PDetails.h"
062 #include "tauEvent/TauRecDetails.h"
063 #include "AnalysisTriggerEvent/Jet_ROI.h"
064 #include "AnalysisTriggerEvent/EmTau_ROI.h"
065 #include "TrigSteeringEvent/TrigRoiDescriptor.h"
066 #include "TrigSteeringEvent/TrigRoiDescriptorCollection.h"
067 #include "TrigParticle/TrigTau.h"
068 #include "TrigCaloEvent/TrigT2Jet.h"
069 #include "TrigCaloEvent/TrigTauCluster.h"
070 #include "TrigInDetEvent/TrigInDetTrackCollection.h"
071 
072 #include <algorithm>
073 #include <math.h>
074 #include <functional>
075 #include <iostream>
076 
077 static const double mZ = 91.19*GeV;
078 static const int  MAX_PARTICLES = 20;
079 
080 using namespace Analysis;
081 using namespace Rec;
082 
083 //////////////////////////////////////////////////////////////////////////////////////
084 /// Constructor
085 
086 AnalysisSkeleton::AnalysisSkeleton(const std::string& name, ISvcLocator* pSvcLocator) :
087   CBNT_AthenaAwareBase(name, pSvcLocator),
088   m_analysisTools( "AnalysisTools" ),
089   m_analysisSelectionTool( "UserAnalysisSelectionTool" ),
090   m_analysisPreparationTool( "UserAnalysisPreparationTool" ),
091   m_analysisOverlapCheckingTool( "UserAnalysisOverlapCheckingTool" ),
092   m_analysisOverlapRemovalTool( "UserAnalysisOverlapRemovalTool" ),
093   m_trigDec("Trig::TrigDecisionTool"),
094   m_doTrigger(true),
095   m_investigateChain("EF_tau16i_loose_2j23")
096 {
097 
098   /** switches to control the analysis through job options */
099 
100   declareProperty( "AnalysisTools",               m_analysisTools );
101   declareProperty( "AnalysisSelectionTool",       m_analysisSelectionTool);
102   declareProperty( "AnalysisPreparationTool",     m_analysisPreparationTool);
103   declareProperty( "AnalysisOverlapCheckingTool", m_analysisOverlapCheckingTool);
104   declareProperty( "AnalysisOverlapRemovalTool",  m_analysisOverlapRemovalTool);
105   declareProperty( "TrigDecisionTool",            m_trigDec, "The tool to access TrigDecision");
106 
107   declareProperty("ElectronContainer", m_electronContainerName="ElectronAODCollection"); 
108   declareProperty("McParticleContainer", m_truthParticleContainerName = "SpclMC");
109   declareProperty("MissingETObject",m_missingETObjectName="MET_RefFinal");
110 
111   /** the cuts - default values - to be modified in job options */
112 
113   declareProperty("DeltaRMatchCut", m_deltaRMatchCut = 0.2);
114   declareProperty("MaxDeltaR", m_maxDeltaR = 0.9999);
115 
116   /** additiona cuts for electrons */
117   declareProperty("ElectronEtCut", m_etElecCut = 10.0*GeV);
118   declareProperty("ElectronEtaCut", m_etaElecCut = 2.5);
119   declareProperty("ElectronCone", m_elecCone = 0.9);
120 
121   /** additional cuts for bjet tagging */
122   declareProperty("bjetWt_IP3DSV1Cut", m_bjetWt_ip3dsv1Cut = 6);
123   declareProperty("bjet_etaCut", m_bjet_etaCut = 2.5);
124   declareProperty("bjet_etCut", m_bjet_etCut = 15.0*GeV);
125 
126   /** missing ET options */
127   declareProperty("MissingETCut",m_missingETCut=20.0*GeV);
128 
129   /** is this AtlFast */
130   declareProperty("IsAtlFastData",m_isAtlFastData="False");
131 
132   /** count number of jets with ET > min value - for SUSY studies */
133   declareProperty("SusyJetMinEt", m_SusyJetMinEt = 50*GeV);
134 
135   /** trigger properties */
136   declareProperty("DoTrigger", m_doTrigger, "enable trigger example");
137   declareProperty("StatTriggerChains", m_triggerChains, "list of triggers for which to print statistics");
138   declareProperty("InvestigateChain", m_investigateChain, "chain to investigate");
139 
140 }
141 
142 /////////////////////////////////////////////////////////////////////////////////////
143 /// Destructor - check up memory allocation
144 /// delete any memory allocation on the heap
145 
146 AnalysisSkeleton::~AnalysisSkeleton() {}
147 
148 ////////////////////////////////////////////////////////////////////////////////////
149 /// Initialize
150 /// initialize StoreGate
151 /// get a handle on the analysis tools
152 /// book histograms
153 
154 StatusCode AnalysisSkeleton::CBNT_initializeBeforeEventLoop() {
155   MsgStream mLog( messageService(), name() );
156 
157   mLog << MSG::DEBUG << "Initializing AnalysisSkeleton (before eventloop)" << endreq;
158 
159   // retrieve trigger decision tool
160   // needs to be done before the first run/event since a number of
161   // BeginRun/BeginEvents are registered by dependent services
162   StatusCode sc = StatusCode::SUCCESS;
163 
164   if ( m_doTrigger ) {
165      sc = m_trigDec.retrieve();
166      if ( sc.isFailure() ){
167         mLog << MSG::ERROR << "Can't get handle on TrigDecisionTool" << endreq;
168      } else {
169        mLog << MSG::DEBUG << "Got handle on TrigDecisionTool" << endreq;
170      }
171   }
172 
173   // Initialize the trigger passed counters
174   // this can not be done before initialize, since the properties need to be set from job-options first
175   std::vector<std::string>::const_iterator it;
176   for(it = m_triggerChains.begin();it != m_triggerChains.end(); it++)
177      m_triggersPassed[*it] = 0;
178 
179   return sc;
180 } 
181 
182 StatusCode AnalysisSkeleton::CBNT_initialize() {
183 
184   MsgStream mLog( messageService(), name() );
185 
186   mLog << MSG::DEBUG << "Initializing AnalysisSkeleton" << endreq;
187 
188   /** get a handle of StoreGate for access to the Event Store */
189   StatusCode sc = service("StoreGateSvc", m_storeGate);
190   if (sc.isFailure()) {
191      mLog << MSG::ERROR
192           << "Unable to retrieve pointer to StoreGateSvc"
193           << endreq;
194      return sc;
195   }
196   
197   /// get a handle on the analysis tools
198   sc = m_analysisTools.retrieve();
199   if ( sc.isFailure() ) {
200       mLog << MSG::ERROR << "Can't get handle on analysis tools" << endreq;
201       return sc;
202   }
203 
204   /// get a handle on the preparartion analysis tools
205   sc = m_analysisSelectionTool.retrieve();
206   if ( sc.isFailure() ) {
207       mLog << MSG::ERROR << "Can't get handle on analysis selection tool" << endreq;
208       return sc;
209   }
210 
211   sc = m_analysisPreparationTool.retrieve();
212   if ( sc.isFailure() ) {
213       mLog << MSG::ERROR << "Can't get handle on analysis preparation tool" << endreq;
214       return sc;
215   }
216 
217   sc = m_analysisOverlapCheckingTool.retrieve();
218   if ( sc.isFailure() ) {
219       mLog << MSG::ERROR << "Can't get handle on analysis overlap checking tool" << endreq;
220       return sc;
221   }
222 
223   sc = m_analysisOverlapRemovalTool.retrieve();
224   if ( sc.isFailure() ) {
225       mLog << MSG::ERROR << "Can't get handle on analysis overlap removal tool" << endreq;
226       return sc;
227   }
228 
229   /** get a handle on the NTuple and histogramming service */
230   sc = service("THistSvc", m_thistSvc);
231   if (sc.isFailure()) {
232      mLog << MSG::ERROR
233           << "Unable to retrieve pointer to THistSvc"
234           << endreq;
235      return sc;
236   }
237 
238   /** Print out bjet cut values */
239   mLog << MSG::DEBUG << "b jet cuts: Et/eta/IP3DSV1 wt. "<<m_bjet_etCut<< ","<<m_bjet_etaCut <<","<<m_bjetWt_ip3dsv1Cut<<endreq;
240 
241 
242   /** now add branches and leaves to the AAN tree */
243 
244   addBranch("NElectrons",    m_aan_size, "NElectrons/i");
245   addBranch("ElectronEta",   m_aan_eta);
246   addBranch("ElectronPt",    m_aan_pt);
247   addBranch("ElecPtRatio",   m_aan_elecetres);
248 
249   addBranch("NJets",          m_aan_njets, "NJets/i");
250   addBranch("NJets_etaLT25",  m_aan_njets_etaLT25, "NJets_etaLT25/i");
251   addBranch("NJets_SusyETCut",m_aan_njets_SusyETCut, "NJets_SusyETCut/i");
252   addBranch("JetsEta"        ,m_aan_JetEta);
253   addBranch("JetsEt"         ,m_aan_JetEt);
254   addBranch("JetsBTagWt"     ,m_aan_JetBTagWt);
255   addBranch("MissingET",      m_aan_ptMiss, "MissingET/d");
256   addBranch("EffMass",        m_aan_effmass, "EffMass/d");
257   addBranch("HT",             m_aan_ht,"HT/d");
258   addBranch("NBJets",         m_aan_nbjets, "NBJets/i");
259   addBranch("MaxJetET",       m_aan_maxJetET, "MaxJetET/d");
260 
261   addBranch("NFinalEl",       m_aan_NFinalEl, "NFinalEl/i");
262   addBranch("FinalElEta",     m_aan_FinalElEta);
263   addBranch("FinalElPt",      m_aan_FinalElPt);
264   addBranch("FinalElEtCone20",m_aan_FinalElEtCone20);
265 
266   addBranch("NFinalMu",       m_aan_NFinalMu, "NFinalMu/i");
267   addBranch("FinalMuEta",     m_aan_FinalMuEta);
268   addBranch("FinalMuPt",      m_aan_FinalMuPt);
269   addBranch("FinalMuEtCone20",m_aan_FinalMuEtCone20);
270   addBranch("FinalMuBestMat", m_aan_FinalMuBestMat);
271   addBranch("FinalMuMatChi2", m_aan_FinalMuMatChi2);
272 
273   addBranch("FinalLepEtSum",  m_aan_FinalLepEtSum, "FinalLepEtSum/d");
274   addBranch("FinalElEtSum",   m_aan_FinalElEtSum, "FinalElEtSum/d");
275   addBranch("FinalMuEtSum",   m_aan_FinalMuEtSum, "FinalMuEtSum/d");
276 
277   addBranch("NumberTopQ",     m_aan_NumTopQ, "NumberTopQ/i");
278   addBranch("pTtop1",         m_aan_pTtop1,  "pTtop1/d");
279   addBranch("pTtop2",         m_aan_pTtop2,  "pTtop2/d");
280 
281   addBranch("Trig_efJet_et",       m_aan_Trig_efJet_et  ,             "Trig_efJet_et/f");
282   addBranch("Trig_efJet_eta",      m_aan_Trig_efJet_eta ,             "Trig_efJet_eta/f");
283   addBranch("Trig_efJet_phi",      m_aan_Trig_efJet_phi ,             "Trig_efJet_phi/f");
284   addBranch("Trig_l2Jet_et",       m_aan_Trig_l2Jet_et  ,             "Trig_l2Jet_et/f");
285   addBranch("Trig_l2Jet_eta",      m_aan_Trig_l2Jet_eta ,             "Trig_l2Jet_eta/f");
286   addBranch("Trig_l2Jet_phi",      m_aan_Trig_l2Jet_phi ,             "Trig_l2Jet_phi/f");
287   addBranch("Trig_l1Jet_et88",     m_aan_Trig_l1Jet_et88,             "Trig_l1Jet_et88/f");
288   addBranch("Trig_l1Jet_eta",      m_aan_Trig_l1Jet_eta ,             "Trig_l1Jet_eta/f");
289   addBranch("Trig_l1Jet_phi",      m_aan_Trig_l1Jet_phi ,             "Trig_l1Jet_phi/f");
290 
291   /// ROOT histograms ---------------------------------------
292 
293   /// electrons
294   m_h_elecpt     = new TH1F("elec_pt","pt el",50,0,250.*GeV);
295   sc = m_thistSvc->regHist("/AANT/Electron/elec_pt",m_h_elecpt);
296 
297   m_h_eleceta    = new TH1F("elec_eta","eta el",70,-3.5,3.5);
298   sc = m_thistSvc->regHist("/AANT/Electron/elec_eta",m_h_eleceta);
299 
300   m_h_elec_deltaRMatch    = new TH1F("elec_deltaRMatch","elec reco/MC deltaR",50,0.,1.);
301   sc = m_thistSvc->regHist("/AANT/Electron/elec_deltaRMatch",m_h_elec_deltaRMatch);
302 
303   /// jets - before OverlapRemoval
304   m_h_jet_eta_beforeOR = new TH1F("jet_eta_beforeOR","jet_eta before OR",50,-5.,5.);
305   sc = m_thistSvc->regHist("/AANT/Jet/jet_eta_beforeOR",m_h_jet_eta_beforeOR);
306 
307   m_h_jet_et_beforeOR = new TH1F("jet_et_beforeOR","jet_et before OR",100,0.,500.);
308   sc = m_thistSvc->regHist("/AANT/Jet/jet_et_beforeOR",m_h_jet_et_beforeOR);
309 
310   m_h_jet_ip3dsv1Wt_beforeOR = new TH1F("jet_ip3dsv1Wt_beforeOR","jet_ip3dsv1Wt before OR",120,-20.,40.);
311   sc = m_thistSvc->regHist("/AANT/Jet/jet_ip3dsv1Wt_beforeOR",m_h_jet_ip3dsv1Wt_beforeOR);
312 
313   m_h_jet_label_beforeOR = new TH1F("jet_label_beforeOR","jet_label before OR",20,0.,20.);
314   sc = m_thistSvc->regHist("/AANT/Jet/jet_label_beforeOR",m_h_jet_label_beforeOR);
315 
316   m_h_jet_ip3dsv1Wt_bjet_beforeOR = new TH1F("jet_ip3dsv1Wt_bjet_beforeOR","b jet_ip3dsv1Wt before OR",120,-20.,40.);
317   sc = m_thistSvc->regHist("/AANT/Jet/jet_ip3dsv1Wt_bjet_beforeOR",m_h_jet_ip3dsv1Wt_bjet_beforeOR);
318 
319   m_h_jet_ip3dsv1Wt_ujet_beforeOR = new TH1F("jet_ip3dsv1Wt_ujet_beforeOR","u jet_ip3dsv1Wt before OR",120,-20.,40.);
320   sc = m_thistSvc->regHist("/AANT/Jet/jet_ip3dsv1Wt_ujet_beforeOR",m_h_jet_ip3dsv1Wt_ujet_beforeOR);
321 
322   /// jets - after OverlapRemoval
323   m_h_jet_eta_afterOR = new TH1F("jet_eta_afterOR","jet_eta after OR",50,-5.,5.);
324   sc = m_thistSvc->regHist("/AANT/Jet/jet_eta_afterOR",m_h_jet_eta_afterOR);
325 
326   m_h_jet_et_afterOR = new TH1F("jet_et_afterOR","jet_et after OR",100,0.,500.);
327   sc = m_thistSvc->regHist("/AANT/Jet/jet_et_afterOR",m_h_jet_et_afterOR);
328 
329   m_h_jet_ip3dsv1Wt_afterOR = new TH1F("jet_ip3dsv1Wt_afterOR","jet_ip3dsv1Wt after OR",120,-20.,40.);
330   sc = m_thistSvc->regHist("/AANT/Jet/jet_ip3dsv1Wt_afterOR",m_h_jet_ip3dsv1Wt_afterOR);
331 
332   m_h_jet_label_afterOR = new TH1F("jet_label_afterOR","jet_label after OR",20,0.,20.);
333   sc = m_thistSvc->regHist("/AANT/Jet/jet_label_afterOR",m_h_jet_label_afterOR);
334 
335   m_h_jet_ip3dsv1Wt_bjet_afterOR = new TH1F("jet_ip3dsv1Wt_bjet_afterOR","b jet_ip3dsv1Wt after OR",120,-20.,40.);
336   sc = m_thistSvc->regHist("/AANT/Jet/jet_ip3dsv1Wt_bjet_afterOR",m_h_jet_ip3dsv1Wt_bjet_afterOR);
337 
338   m_h_jet_ip3dsv1Wt_ujet_afterOR = new TH1F("jet_ip3dsv1Wt_ujet_afterOR","u jet_ip3dsv1Wt after OR",120,-20.,40.);
339   sc = m_thistSvc->regHist("/AANT/Jet/jet_ip3dsv1Wt_ujet_afterOR",m_h_jet_ip3dsv1Wt_ujet_afterOR);
340 
341   /// missing ET
342 
343   m_pxMis   = new TH1F("MissingPx", "MissingPx",200,-500.0*GeV,500.*GeV);
344   sc = m_thistSvc->regHist("/AANT/MissingET/MissingPx", m_pxMis);
345   m_pyMis   = new TH1F("MissingPy","MissingPy",200,-500.0*GeV,500.*GeV);
346   sc = m_thistSvc->regHist("/AANT/MissingET/MissingPy", m_pyMis);
347   m_ptMis   = new TH1F("MissingPt","MissingPt",100,0.0,500.*GeV);
348   sc = m_thistSvc->regHist("/AANT/MissingET/MissingPt", m_ptMis);
349 
350   // trigger
351 
352   m_triggerAccepts = new TH1F("TriggerAccepts", "TriggerAccepts",3,0,3);
353   sc = m_thistSvc->regHist("/AANT/Trigger/TriggerAccepts", m_triggerAccepts);
354 
355 
356 
357 
358   if (sc.isFailure()) { 
359      mLog << MSG::ERROR << "ROOT Hist registration failed" << endreq; 
360      return sc; 
361   }
362   /// end ROOT Histograms ------------------------------------------
363 
364   // define chain groups using regular expressions and relying on the
365   // trigger chain name convention: all L1 items start their name from
366   // L1_ etc; in fact, the TrigDecisionTool already defines these
367   // groups by default, but let's do it again as an example
368   m_all   = m_trigDec->getChainGroup(".*");
369   m_allL1 = m_trigDec->getChainGroup("L1_.*"); 
370   m_allL2 = m_trigDec->getChainGroup("L2_.*");
371   m_allEF = m_trigDec->getChainGroup("EF_.*");
372 
373   m_eventNr=0;
374 
375   return StatusCode::SUCCESS;
376 }                
377 
378 ///////////////////////////////////////////////////////////////////////////////////
379 /// Finalize - delete any memory allocation from the heap
380 
381 StatusCode AnalysisSkeleton::CBNT_finalize() {
382   MsgStream mLog( messageService(), name() );
383   
384 
385   if(m_doTrigger) {
386      // print trigger statistics
387      mLog << MSG::INFO << "STAT Trigger Statistics on " << m_eventNr << " processed events" << endreq;
388      for(  std::vector<std::string>::const_iterator it = m_triggerChains.begin();it != m_triggerChains.end(); it++)
389         mLog << MSG::INFO << "STAT Passed events for chain " << *it << "  " << m_triggersPassed[*it] << " ("<< 100.*m_triggersPassed[*it]/m_eventNr <<"%)" << endreq;
390   }
391   return StatusCode::SUCCESS;
392 
393 }
394 
395 ///////////////////////////////////////////////////////////////////////////////////
396 /// Clear - clear CBNT members
397 StatusCode AnalysisSkeleton::CBNT_clear() {
398   /// For Athena-Aware NTuple
399 
400   m_aan_size = 0;
401   m_aan_eta->clear();
402   m_aan_pt->clear();
403   m_aan_elecetres->clear();
404 
405   m_aan_njets=0;
406   m_aan_maxJetET = -1000.;
407   m_aan_JetEta->clear();
408   m_aan_JetEt->clear();
409   m_aan_JetBTagWt->clear();  
410   //
411   m_aan_njets_etaLT25=0;
412   m_aan_njets_SusyETCut = 0;
413 
414   m_aan_ptMiss = -1.;
415   m_aan_effmass = 0.;
416   m_aan_ht = 0;
417   m_aan_nbjets = 0;
418 
419   //
420   m_aan_NFinalEl = 0;
421   m_aan_FinalElPt->clear();
422   m_aan_FinalElEta->clear();
423   m_aan_FinalElEtCone20->clear();
424 
425 
426   m_aan_NFinalMu = 0;
427   m_aan_FinalMuPt->clear();
428   m_aan_FinalMuBestMat->clear();
429   m_aan_FinalMuEta->clear();
430   m_aan_FinalMuEtCone20->clear();
431   m_aan_FinalMuMatChi2->clear();
432 
433   //
434   m_aan_FinalLepEtSum = 0.;
435   m_aan_FinalElEtSum  = 0.;
436   m_aan_FinalMuEtSum  = 0.;
437 
438   // 
439   m_aan_NumTopQ=0;
440   m_aan_pTtop1=-1;
441   m_aan_pTtop2=-1;
442 
443   return StatusCode::SUCCESS;
444 }
445 
446 //////////////////////////////////////////////////////////////////////////////////
447 /// Execute - on event by event
448 
449 StatusCode AnalysisSkeleton::CBNT_execute() {
450   MsgStream mLog( messageService(), name() );
451   m_eventNr++;
452   mLog << MSG::DEBUG << "in execute()" << endreq;
453 
454   StatusCode sc;
455 
456   /** it shows how to get the Electron and the TruthParticle
457       containers shows matching between reconstructed and MC electrons
458 
459       Can be commented out if you want to do so If you do so, some of
460       the electron histograms/ntuple variables will be unfilled */
461 
462   // this method is discussed in the Computing workbook - uncomment
463   // VJ Oct. 29'08
464   sc = electronSkeleton();
465   if (sc.isFailure()) {
466     mLog << MSG::WARNING << "The method electronSkeleton() failed" << endreq;
467     return StatusCode::SUCCESS;
468   }
469 
470   /** an minimal example using the TrigDecisionTool */
471   if ( m_doTrigger ) {
472     sc = triggerSkeleton();
473     if (sc.isFailure()) {
474       mLog << MSG::WARNING << "The method triggerSkeleton() failed" << endreq;
475       return StatusCode::SUCCESS;
476     }
477   }
478  
479   /** an example of analysis preparation, including:
480       - pre-selections based on the reocmmendations of performance groups
481       - overlap checking
482       - overlap removal */
483 
484   /** Do not comment the next method. This is where we do all the
485       selection/overlap removal Those results are then used in the
486       methods later on */
487 
488   sc = analysisPreparation();
489   if ( sc.isFailure() ) {
490      mLog << MSG::WARNING << "Analysis Preparation Failed " << endreq;
491      return StatusCode::SUCCESS;
492   }
493 
494   /** The following methods were added by Vivek Jain They just show
495       you how to access different variables and store them in
496       histograms and/or ntuples */
497 
498   /** look at bjet tagging information in the jets after overlap
499       removal */
500 
501   sc = bjetInfo();
502   if ( sc.isFailure() ) {
503      mLog << MSG::WARNING << "Failure in bjetInfo " << endreq;
504      return StatusCode::SUCCESS;
505   } 
506 
507   /** get missing Et information */
508 
509   sc = getMissingET();
510   if( sc.isFailure() ) {
511     mLog << MSG::WARNING
512          << "Failed to retrieve Et object found in TDS"
513          << endreq; 
514     return StatusCode::SUCCESS;
515   }  
516 
517   /** do SUSY studies */
518 
519   sc = SusyStudies();
520   if( sc.isFailure() ) {
521     mLog << MSG::WARNING
522          << "Failed to do SUSY studies"
523          << endreq; 
524     return StatusCode::SUCCESS;
525   }  
526 
527 
528 
529   return StatusCode::SUCCESS;
530 }
531 
532 //////////////////////////////////////////////////////////////////////////////////
533 /// Trigger method - called by execute() on event by event
534 /// to be removed if not needed
535 
536 StatusCode AnalysisSkeleton::triggerSkeleton() {
537   MsgStream mLog( messageService(), name() );
538 
539   mLog << MSG::INFO << "Event Number " << m_eventNr << endreq;
540 
541   // print out list of chains in each level for the first event:
542   if (m_eventNr==1) {
543     mLog << MSG::INFO << "L1 Items : " << m_allL1->getListOfTriggers() << endreq;
544     mLog << MSG::INFO << "L2 Chains: " << m_allL2->getListOfTriggers() << endreq;
545     mLog << MSG::INFO << "EF Chains: " << m_allEF->getListOfTriggers() << endreq;
546   }
547 
548   // simple example of isPassed():
549   // isPassed([chain], [condition]) is called with the default argument condition = Physics
550   // a ChainGroup is defined implicitly by the regular expression given by "EF.*" in the call to isPassed()
551   mLog << MSG::INFO << "Pass state L1 = " << m_trigDec->isPassed("L1_.*") << endreq;
552   mLog << MSG::INFO << "Pass state L2 = " << m_trigDec->isPassed("L2_.*") << endreq;
553   mLog << MSG::INFO << "Pass state EF = " << m_trigDec->isPassed("EF_.*") << endreq;
554 
555   mLog << MSG::INFO << "Pass state L2_tau16i_loose_3j23 = " << m_trigDec->isPassed("L2_tau16i_loose_3j23") << endreq;
556   mLog << MSG::INFO << "Pass state EF_mu10              = " << m_trigDec->isPassed("EF_mu10") << endreq;
557   mLog << MSG::INFO << "Pass state EF_mu20              = " << m_trigDec->isPassed("EF_mu20") << endreq;
558   mLog << MSG::INFO << "Pass state EF_e15_medium        = " << m_trigDec->isPassed("EF_e15_medium") << endreq;
559   mLog << MSG::INFO << "Pass state EF_e20_loose         = " << m_trigDec->isPassed("EF_e20_loose") << endreq;
560 
561   // on the first event we are printing out prescale factors for all
562   // EF chains
563   // note that the prescales
564 
565   std::vector<std::string>::const_iterator it;
566   if (m_eventNr==1) {
567      const std::vector<std::string> allEF = m_allEF->getListOfTriggers();
568      for(it = allEF.begin(); it != allEF.end(); it++) {
569         mLog << MSG::INFO << "Prescale info: chain " << std::left << *it << " has prescale " << m_trigDec->getPrescale(*it) << endreq;
570      }
571      mLog << MSG::INFO << "Stream info: " << m_trigDec->getListOfStreams() << endreq;
572 
573      for(it = m_triggerChains.begin();it != m_triggerChains.end(); it++) {
574         std::vector<std::string> chgrcnt = m_trigDec->getChainGroup(*it)->getListOfTriggers();
575         for(std::vector<std::string>::iterator chgrit = chgrcnt.begin(); chgrit != chgrcnt.end(); chgrit++) {
576            mLog << MSG::INFO << "Chain belonging to " << *it << ": " << *chgrit << endreq;
577         }
578      }
579   }
580   
581   
582   // Now we'd like to collect some trigger statistics for the chains specified in 
583   for(it = m_triggerChains.begin();it != m_triggerChains.end(); it++)
584      if( m_trigDec->isPassed(*it) ) {
585         m_triggersPassed[*it]++;
586         m_triggerAccepts->Fill(it->c_str(),1);
587      }
588 
589 
590   std::string chain(m_investigateChain);
591 
592   mLog << MSG::INFO << "FLAT Pass state " << chain << " = " << m_trigDec->isPassed(chain) << endreq;
593 
594   // first declare a FeatureContainer; fill it using the features(std::string chain_name) method 
595   FeatureContainer f = m_trigDec->features(chain /*, broken in 15.2.0: TrigDefs::alsoDeactivateTEs*/ );
596   
597   std::vector< Feature<JetCollection> > jetColls = f.get<JetCollection>();
598   mLog << MSG::INFO << "FLAT Number of JetCollections in " << chain << ": " << jetColls.size() << endreq;
599   if(jetColls.size()>0) {
600 
601      m_aan_Trig_efJet_et   = 0;
602      m_aan_Trig_efJet_eta  = 0;
603      m_aan_Trig_efJet_phi  = 0;
604      m_aan_Trig_l2Jet_et   = 0;
605      m_aan_Trig_l2Jet_eta  = 0;
606      m_aan_Trig_l2Jet_phi  = 0;
607      m_aan_Trig_l1Jet_et88 = 0;
608      m_aan_Trig_l1Jet_eta  = 0;
609      m_aan_Trig_l1Jet_phi  = 0;
610      
611      const Feature<JetCollection>& jcf = jetColls[0];
612      mLog << MSG::INFO << "FLAT TE Label: " << jcf.label() << endreq;
613      const JetCollection* jc = jcf.cptr();
614      mLog << MSG::INFO << "FLAT Number of Jets in JetCollection: " << jc->size() << endreq;
615      JetCollection::const_iterator jIt = jc->begin();
616      for (; jIt != jc->end(); ++jIt ) {
617         Jet* jet = *jIt;
618         mLog << MSG::INFO << "FLAT Jet e   : " << jet->e()   << endreq;
619         mLog << MSG::INFO << "FLAT     eta : " << jet->eta() << endreq;
620         mLog << MSG::INFO << "FLAT     phi : " << jet->phi() << endreq;
621         mLog << MSG::INFO << "FLAT     pt  : " << jet->pt()  << endreq;
622         mLog << MSG::INFO << "FLAT     et  : " << jet->et()  << endreq;
623         m_aan_Trig_efJet_et   = jet->et();
624         m_aan_Trig_efJet_eta  = jet->eta();
625         m_aan_Trig_efJet_phi  = jet->phi();
626      }
627 
628      // let us find the corresponding jets in Lvl2
629      Feature<TrigT2Jet> l2jetF = m_trigDec->ancestor<TrigT2Jet>(jcf);
630      mLog << MSG::INFO << "FLAT Found " << (l2jetF.empty()?"no ":"") << "corresponding L2 Jet." << endreq;
631      if ( !l2jetF.empty() ) {
632         const TrigT2Jet* t2jet = l2jetF.cptr();
633         mLog << MSG::INFO << "FLAT    e    : " << t2jet->e()   << endreq; 
634         mLog << MSG::INFO << "FLAT    eta  : " << t2jet->eta() << endreq; 
635         mLog << MSG::INFO << "FLAT    phi  : " << t2jet->phi() << endreq; 
636         mLog << MSG::INFO << "FLAT    ehad : " << t2jet->ehad0() << endreq; 
637         mLog << MSG::INFO << "FLAT    eem  : " << t2jet->eem0() << endreq; 
638         m_aan_Trig_l2Jet_et   = t2jet->e()/cosh(t2jet->eta());
639         m_aan_Trig_l2Jet_eta  = t2jet->eta();
640         m_aan_Trig_l2Jet_phi  = t2jet->phi();
641      }
642      
643      // we can also access the L1 Jet_ROI using the ancestor method of the TrigDecisionTool
644      Feature<Jet_ROI> jRoIF =  m_trigDec->ancestor<Jet_ROI>(jcf);
645      mLog << MSG::INFO << "FLAT Found " << (jRoIF.empty()?"no ":"") << "corresponding Jet_ROI" << endreq; 
646      if ( !jRoIF.empty() ) {
647         const Jet_ROI* jroi = jRoIF.cptr();
648         mLog << MSG::INFO << "FLAT Passed thresholds" << jroi->getThresholdNames() << endreq; 
649         mLog << MSG::INFO << "FLAT    ET4x4 : " << jroi->getET4x4() << endreq; 
650         mLog << MSG::INFO << "FLAT    ET6x6 : " << jroi->getET6x6() << endreq; 
651         mLog << MSG::INFO << "FLAT    ET8x8 : " << jroi->getET8x8() << endreq;
652         mLog << MSG::INFO << "FLAT    eta   : " << jroi->eta() << endreq; 
653         mLog << MSG::INFO << "FLAT    phi   : " << jroi->phi() << endreq; 
654         m_aan_Trig_l1Jet_et88 = jroi->getET8x8();
655         m_aan_Trig_l1Jet_eta  = jroi->eta();
656         m_aan_Trig_l1Jet_phi  = jroi->phi();
657      }
658   }
659 
660 
661   // now we like to look at the Combinations of jets and tau that make up the chain decision
662   const std::vector<Trig::Combination>& tauJetCombinations = f.getCombinations();
663   mLog << MSG::INFO << "COMB Pass state " << chain << " = " << m_trigDec->isPassed(chain) << endreq;
664   mLog << MSG::INFO << "COMB Number of TauJetCombinations in " << chain << ": " << tauJetCombinations.size() << endreq; 
665   std::vector<Trig::Combination>::const_iterator cIt;
666   for ( cIt = tauJetCombinations.begin(); cIt != tauJetCombinations.end(); ++cIt ) {
667 
668      const Trig::Combination& comb = *cIt;
669      
670      std::vector< Feature<TauJetContainer> > tauC = comb.get<TauJetContainer>();
671      std::vector< Feature<JetCollection> >   jetC = comb.get<JetCollection>();
672 
673      mLog << MSG::INFO << "COMB Combination was " << (comb.active()?"":"not ") << "active." << endreq;
674 
675      if(tauC.size()>0 || jetC.size()>0) {
676         mLog << MSG::INFO << "COMB Combination has " << tauC.size() << " TauJetContainer Fs and " 
677              << jetC.size() << " JetCollection Fs" << endreq;
678 
679         const TauJetContainer* taus = tauC[0];
680         const JetCollection* jets = jetC[0];
681         
682         mLog << MSG::INFO << "COMB In the TauJetContainer are " << taus->size() << " taus and in the JetCollection are "
683              << jets->size() << " jets." << endreq; 
684      } else {
685         mLog << MSG::INFO << "COMB TauJetContainer or JetCollection missing." <<endreq; 
686      }
687 
688      std::vector< Feature<TrigTau> >   tauFV = comb.get<TrigTau>();
689      std::vector< Feature<TrigT2Jet> > jetFV = comb.get<TrigT2Jet>();
690 
691      mLog << MSG::INFO << "COMB Combination has " << tauFV.size() << " TrigTau Fs and " << jetFV.size() << " TrigT2Jet Fs." << endreq; 
692     
693   }
694     
695    
696   return StatusCode::SUCCESS;
697 }
698 
699 
700 
701 
702 
703 
704 //////////////////////////////////////////////////////////////////////////////////
705 /// Electron method - called by execute() on event by event
706 /// to be removed if not needed
707 
708 StatusCode AnalysisSkeleton::electronSkeleton() {
709   MsgStream mLog( messageService(), name() );
710   
711   mLog << MSG::DEBUG << "in electronSkeleton()" << endreq;
712 
713   /** get the MC truth particle AOD container from StoreGate */
714   const TruthParticleContainer*  mcpartTES = 0;
715   StatusCode sc=m_storeGate->retrieve( mcpartTES, m_truthParticleContainerName);
716   if( sc.isFailure()  ||  !mcpartTES ) {
717      mLog << MSG::WARNING
718           << "No AOD MC truth particle container found in TDS"
719           << endreq; 
720      return StatusCode::SUCCESS;
721   }
722   mLog <<MSG::DEBUG << "MC Truth Container Successfully Retrieved" << endreq;
723   
724   /** get the container of the original AOD electron - without any selection */
725   /** get the AOD electron container for TES */
726   const ElectronContainer* elecTES = 0;
727   sc=m_storeGate->retrieve( elecTES, m_electronContainerName);
728   if( sc.isFailure()  ||  !elecTES ) {
729      mLog << MSG::WARNING
730           << "No AOD electron container found in TDS"
731           << endreq; 
732      return StatusCode::FAILURE;
733   }  
734   mLog << MSG::DEBUG << "ElectronContainer successfully retrieved - size is " << elecTES->size() << " electrons " << endreq;
735 
736 
737   /** iterators over the electron container - the pre-selected ones or the original ones */ 
738   ElectronContainer::const_iterator elecItr  = elecTES->begin();
739   ElectronContainer::const_iterator elecItrE = elecTES->end();
740 
741   for (; elecItr != elecItrE; ++elecItr) {
742 
743     /** apply further selections if necessary */
744     /** check for the author of the electron */
745     bool author = (*elecItr)->author(egammaParameters::AuthorElectron);
746     if ( !author || (*elecItr)->pt() < m_etElecCut ) continue;
747 
748     m_aan_size++;
749 
750 
751     /** fill histograms */
752     m_h_elecpt->Fill( (*elecItr)->pt(), 1.);
753     m_h_eleceta->Fill( (*elecItr)->eta(), 1.);
754 
755     /** fill Athena-Aware NTuple */
756     m_aan_eta->push_back((*elecItr)->eta());
757     m_aan_pt->push_back((*elecItr)->pt());
758 
759     /** find a match to this electron in the MC truth container
760         the index and deltaR are returned */
761     int index = -1;
762     double deltaRMatch;
763     if( (*elecItr)->trackParticle() && (*elecItr)->pt()> m_etElecCut ) {
764        const TruthParticleContainer * truthContainer = mcpartTES;
765        bool findAMatch = m_analysisTools->matchR((*elecItr), truthContainer, 
766                        index, deltaRMatch, (*elecItr)->pdgId());
767        if (findAMatch) {
768           deltaRMatch = (deltaRMatch > m_maxDeltaR) ? m_maxDeltaR : deltaRMatch;
769 
770           m_h_elec_deltaRMatch->Fill(deltaRMatch);
771           mLog << MSG::DEBUG << "Electron: MC/Reco DeltaR " << deltaRMatch << endreq;
772           /** check for good match */
773           if ( deltaRMatch < m_deltaRMatchCut) {
774              const TruthParticle*  electronMCMatch = (*mcpartTES)[index]; 
775              double res = (*elecItr)->pt() / electronMCMatch->pt();
776              m_aan_elecetres->push_back(res);
777           }
778        }
779     }    
780   }
781 
782   mLog << MSG::DEBUG << "electronSkeleton() succeeded" << endreq;
783                 
784   return StatusCode::SUCCESS;
785 }
786 
787 //////////////////////////////////////////////////////////////////////////////////
788 /// Analysis Preparation method - called by execute() on event by event
789 /// A lot of the AOD container are read in
790 /// pre-selection is done using the UserAnalysisSelectionTool
791 /// An example of overlap checking is demonstrated
792 /// An example of overlap removal is demonstration
793 StatusCode AnalysisSkeleton::analysisPreparation() {
794 
795   MsgStream mLog( messageService(), name() );
796 
797   mLog << MSG::DEBUG << "in analysisPreparation()" << endreq;
798 
799   /** loop over Electrons from the AOD and see which pass the recommended electron selection 
800       These selections are defined in m_analysisSelectionTool - to be changed if necessary */
801   const ElectronContainer* elecTES = 0;
802   StatusCode sc=m_storeGate->retrieve( elecTES, m_electronContainerName);
803   if( sc.isFailure()  ||  !elecTES ) {
804      mLog << MSG::WARNING
805           << "No AOD electron container found in TDS"
806           << endreq;
807   }
808   ElectronContainer::const_iterator elecItr  = elecTES->begin();
809   ElectronContainer::const_iterator elecItrE = elecTES->end();
810   for (; elecItr != elecItrE; ++elecItr) {
811      bool passedSelection = m_analysisSelectionTool->isSelected( *elecItr );
812      if ( passedSelection ) mLog << MSG::DEBUG<<"Found a potential good Electron " << endreq;
813   }
814 
815   /** do analysis preparation using the AnalysisPreparationTool
816       selections based or recommended selections from performance groups  
817       The tool outputs various containers of pre-selected objects */
818   sc = m_analysisPreparationTool->execute();
819   if ( sc.isFailure() ) {
820     mLog << MSG::WARNING << "AnalysisPreparation Failed - selection " << endreq;
821     return StatusCode::SUCCESS;
822   }
823 
824 
825   /** get the pre-selected Electrons - given by the AnalysisPreparationTool */
826   const ElectronContainer* preselectedElecTES = m_analysisPreparationTool->selectedElectrons();
827   if ( !preselectedElecTES ) {
828     mLog << MSG::WARNING << "Selected Electrons Not Found " << endreq;
829   }
830   mLog << MSG::DEBUG << "Pre-selected Electrons successfully retrieved - size is " << preselectedElecTES->size() << " electrons " << endreq;
831 
832   /** get the pre-selected Muons - given by the AnalysisPreparationTool */
833   const MuonContainer* preselectedMuonTES = m_analysisPreparationTool->selectedMuons();
834   if ( !preselectedMuonTES ) {
835     mLog << MSG::WARNING << "Selected Muons Not Found " << endreq;
836   }
837   mLog << MSG::DEBUG << "Pre-selected Muons successfully retrieved - size is " << preselectedMuonTES->size() << " muons " << endreq;
838 
839   /** Check if the leading Electron and the Leadign Muon overlap or not */
840   double deltaR = -1.0;
841   if ( preselectedElecTES->size() > 0 && preselectedMuonTES->size() > 0) {
842      const Electron * leadingElectron = preselectedElecTES->at(0);
843      const Analysis::Muon     * leadingMuon     = preselectedMuonTES->at(0);
844      bool areOverlapping = m_analysisOverlapCheckingTool->overlap( leadingElectron, leadingMuon, deltaR ); 
845      if ( areOverlapping ) mLog << MSG::INFO << "Leading Electron and Leading Muon overlap - deltaR = " << endreq;
846   }
847 
848   /** now remove the overlaps using this tool 
849       The input to the tool is the collection of pre-selected obeject obtained from the AnalysisPreparationTool 
850       The output is various collections of final state non-overlapping particles 
851       You can change the order of the overlap removal by change the input to the tool in job options */
852   sc = m_analysisOverlapRemovalTool->execute();
853   if ( sc.isFailure() ) {
854     mLog << MSG::WARNING << "AnalysisPreparation Failed - overlap removal " << endreq;
855     return StatusCode::SUCCESS;
856   }
857 
858   /** get the final state Electrons - given by the AnalysisOverlapRemovalTool */
859   const ElectronContainer* finalStateElecTES = m_analysisOverlapRemovalTool->finalStateElectrons();
860   if ( !finalStateElecTES ) {
861 
862     mLog << MSG::WARNING << "Final State Electrons Not Found " << endreq;
863   }
864   mLog << MSG::DEBUG << "Final State Electrons successfully retrieved - size is " << finalStateElecTES->size() << " electrons " << endreq;
865 
866 
867 
868 
869   mLog << MSG::DEBUG << "AnalysisPreparation() succeeded" << endreq;
870  
871   return StatusCode::SUCCESS;
872 
873 }
874 //////////////////////////////////////////////////////////////////////////////////
875 /// Method to look at bjetInfo - called by execute() on event by event
876 /// Use jets after overlap removal and look at the b-tagging weights within
877 ///
878 //////////////////////////////////////////////////////////////////////////////////
879 StatusCode AnalysisSkeleton::bjetInfo() {
880 
881   MsgStream mLog( messageService(), name() );
882 
883   mLog << MSG::DEBUG << "in bjetInfo()" << endreq;
884 
885   /** loop over jet container after overlap removal 
886       As a check first get the container after selection cuts, but BEFORE Overlap Removal */
887 
888   const JetCollection* selectedJetTES = m_analysisPreparationTool->selectedJets();
889   if ( !selectedJetTES ) {
890     mLog << MSG::WARNING << "Selected Particle Jets Not Found " << endreq;
891   }
892   else{
893     mLog << MSG::DEBUG << "Selected Jets successfully retrieved - size is " << selectedJetTES->size() << " jets " << endreq;}
894   // 
895   const JetCollection* finalStateJetTES = m_analysisOverlapRemovalTool->finalStateJets();
896   if ( !finalStateJetTES ) {
897     mLog << MSG::WARNING << "Final State Particle Jets Not Found " << endreq;
898     return StatusCode::SUCCESS;
899   }
900   mLog << MSG::DEBUG << "Final State Jets successfully retrieved - size is " << finalStateJetTES->size() << " jets " << endreq;
901 
902   /** now look at some variables before and after overlap removal */
903 
904   int iflav;
905   JetCollection::const_iterator jetItr_sel  = selectedJetTES->begin();
906   JetCollection::const_iterator jetItrE_sel = selectedJetTES->end();
907   for (; jetItr_sel != jetItrE_sel; ++jetItr_sel) {
908 
909     HepLorentzVector p4((*jetItr_sel)->px(),
910                         (*jetItr_sel)->py(),
911                         (*jetItr_sel)->pz(),
912                         (*jetItr_sel)->e());
913 
914     m_h_jet_eta_beforeOR->Fill(p4.pseudoRapidity());
915     m_h_jet_et_beforeOR->Fill(p4.et()/1000.);
916 
917     /** get b-tagging info */
918 
919     double w_cmb = (*jetItr_sel)->getFlavourTagWeight(); // weight for IP3DSV1
920     m_h_jet_ip3dsv1Wt_beforeOR->Fill(w_cmb);
921 
922     /** get quark flavour that originates this jet */
923     iflav = getQuarkJetFlavour(jetItr_sel);
924     m_h_jet_label_beforeOR->Fill((float) iflav);
925 
926     if(p4.et() > m_bjet_etCut && fabs(p4.pseudoRapidity()) < m_bjet_etaCut) {
927       if(iflav==5) m_h_jet_ip3dsv1Wt_bjet_beforeOR->Fill(w_cmb);
928       if(iflav==0) m_h_jet_ip3dsv1Wt_ujet_beforeOR->Fill(w_cmb);
929     }
930 
931   }
932   /** after overlapRemoval */
933   JetCollection::const_iterator jetItr_fin  = finalStateJetTES->begin();
934   JetCollection::const_iterator jetItrE_fin = finalStateJetTES->end();
935   for (; jetItr_fin != jetItrE_fin; ++jetItr_fin) {
936 
937     HepLorentzVector p4((*jetItr_fin)->px(),
938                         (*jetItr_fin)->py(),
939                         (*jetItr_fin)->pz(),
940                         (*jetItr_fin)->e());
941 
942     m_h_jet_eta_afterOR->Fill(p4.pseudoRapidity());
943     m_h_jet_et_afterOR->Fill(p4.et()/1000.);
944 
945     /** get b-tagging info */
946 
947 
948 
949     if(p4.et() > m_bjet_etCut && fabs(p4.pseudoRapidity()) < m_bjet_etaCut) {
950 
951       double w_cmb = (*jetItr_fin)->getFlavourTagWeight(); // weight for IP3DSV1
952       m_h_jet_ip3dsv1Wt_afterOR->Fill(w_cmb);
953 
954       /** get quark flavour that originates this jet */
955       iflav = getQuarkJetFlavour(jetItr_fin);
956       m_h_jet_label_afterOR->Fill((float) iflav);
957       //
958 
959       if(w_cmb > m_bjetWt_ip3dsv1Cut) m_aan_nbjets++; // count # of bjets in event
960 
961       if(iflav==5) m_h_jet_ip3dsv1Wt_bjet_afterOR->Fill(w_cmb);
962       if(iflav==0) m_h_jet_ip3dsv1Wt_ujet_afterOR->Fill(w_cmb);
963     }
964 
965   }
966 
967   return StatusCode::SUCCESS;
968 
969 }
970 ////////
971 
972 int AnalysisSkeleton::getQuarkJetFlavour(JetCollection::const_iterator jetItr) {
973 
974     MsgStream mLog( messageService(), name() );
975 
976     /** flavour of quark that originated this jet */
977     // --- get the true label of the jet from MC Truth
978 
979     std::string label("N/A");
980     
981     const Analysis::TruthInfo* mcinfo = (*jetItr)->tagInfo<Analysis::TruthInfo>("TruthInfo");
982     if(mcinfo) {
983       label = mcinfo->jetTruthLabel();
984     } else {
985       mLog << MSG::VERBOSE << "could not find TruthInfo for matching jet" << endreq;
986     }
987     int iflav(0);
988     if(label=="B") {
989       return iflav = 5;
990     }
991     if(label=="C") {
992       return iflav = 4;
993     }
994     if(label=="T") {
995       return iflav = 15;
996     }
997 
998     return iflav;
999 }
1000 ////////////////////////////////////////////////////////////////////////////////////////////////
1001 /// missing Et object
1002 
1003 StatusCode AnalysisSkeleton::getMissingET() {
1004 
1005   MsgStream mLog(messageService(), name());
1006   mLog << MSG::DEBUG << "in getMissingEt()" << endreq;
1007 
1008   StatusCode sc = StatusCode::SUCCESS;
1009 
1010   if (!m_isAtlFastData) {
1011     /// retrieve the missing Et object from TDS
1012     sc = m_storeGate->retrieve(m_pMissing,m_missingETObjectName);
1013     if (sc.isFailure()) {
1014        mLog << MSG::ERROR << "Could not retrieve MissingET Object" << endreq;
1015        return StatusCode::SUCCESS;
1016     }
1017     else{ mLog<< MSG::DEBUG <<" retreived missing ET from AOD"<<endreq;}
1018 
1019     m_pxMiss = m_pMissing->etx();
1020     m_pyMiss = m_pMissing->ety();
1021     m_ptMiss = m_pMissing->et();
1022   } else {
1023     /// retrieve the missing Et object from TDS
1024     sc=m_storeGate->retrieve(m_pMissing, "AtlfastMissingEt");
1025     if( sc.isFailure()  ||  !m_pMissing ) {
1026       mLog << MSG::WARNING
1027            << "No Atlfast missing Et object found in TDS"
1028            << endreq; 
1029       return StatusCode::SUCCESS;
1030     }  
1031     m_pxMiss = m_pMissing->etx();
1032     m_pyMiss = m_pMissing->ety();
1033     m_ptMiss = m_pMissing->et();
1034   }
1035 
1036   /// fill missing energy histograms
1037   m_pxMis->Fill(m_pxMiss);
1038   m_pyMis->Fill(m_pyMiss);
1039   m_ptMis->Fill(m_ptMiss);
1040 
1041   m_aan_ptMiss = m_ptMiss;
1042 
1043   return sc;
1044 
1045 }
1046 ////////////////////////////////////////////////////////
1047 StatusCode AnalysisSkeleton::SusyStudies() {
1048 
1049   /** Make some introductory plots */
1050 
1051   MsgStream mLog( messageService(), name() );
1052 
1053   mLog << MSG::DEBUG << "in SusyStudies()" << endreq;
1054 
1055   /** loop over truth container and get pT of the earliest top quarks */
1056 
1057   double pTtop1;
1058   double pTtop2;
1059   int numTops;
1060 
1061   StatusCode sc = getTopQpT(numTops, pTtop1, pTtop2);  
1062   if(!sc) mLog << MSG::DEBUG << "Something wrong with finding top quark pT"<<endreq;
1063   else{
1064 
1065     m_aan_NumTopQ = 2;
1066     m_aan_pTtop1 = pTtop1;
1067     m_aan_pTtop2 = pTtop2;
1068   }
1069 
1070   /** loop over jet container after overlap removal */
1071 
1072   const JetCollection* finalStateJetTES = m_analysisOverlapRemovalTool->finalStateJets();
1073   if ( !finalStateJetTES ) {
1074     mLog << MSG::WARNING << "Final State Particle Jets Not Found " << endreq;
1075     return StatusCode::SUCCESS;
1076   }
1077   mLog << MSG::DEBUG << "Final State Jets successfully retrieved - size is " << finalStateJetTES->size() << " jets " << endreq;
1078 
1079   double w_cmb=-100;
1080   JetCollection::const_iterator jetItr_fin  = finalStateJetTES->begin();
1081   JetCollection::const_iterator jetItrE_fin = finalStateJetTES->end();
1082   for (; jetItr_fin != jetItrE_fin; ++jetItr_fin) {
1083 
1084     HepLorentzVector p4((*jetItr_fin)->px(),
1085                         (*jetItr_fin)->py(),
1086                         (*jetItr_fin)->pz(),
1087                         (*jetItr_fin)->e());
1088 
1089     /** variables for the ntuple  */
1090     m_aan_njets++;
1091     if(fabs(p4.pseudoRapidity()) < m_bjet_etaCut ) m_aan_njets_etaLT25++;
1092     if(p4.et()> m_SusyJetMinEt ) m_aan_njets_SusyETCut++;
1093 
1094     m_aan_JetEta->push_back((*jetItr_fin)->eta());
1095     m_aan_JetEt->push_back(p4.et());
1096 
1097     w_cmb = -100;
1098     if(p4.et() > m_bjet_etCut && fabs(p4.pseudoRapidity()) < m_bjet_etaCut) {
1099       w_cmb = (*jetItr_fin)->getFlavourTagWeight();} // weight for IP3DSV1
1100     m_aan_JetBTagWt->push_back(w_cmb);
1101 
1102     m_aan_ht += p4.et(); // scalar sum of jet ET
1103     if(p4.et()>m_aan_maxJetET) m_aan_maxJetET = p4.et(); // Jet with max ET
1104 
1105   } // loop over jets
1106 
1107   /** Get final state leptons. We need these in the determination of effective mass
1108       We should also store the leptons in the ntuple, so that we can re-do the calculation later */
1109   
1110   /** First do electrons */
1111 
1112   const ElectronContainer* finalStateElecTES = m_analysisOverlapRemovalTool->finalStateElectrons();
1113   if ( !finalStateElecTES ) {
1114 
1115     mLog << MSG::WARNING << "SusyStudies: Final State Electrons Not Found " << endreq;
1116     return StatusCode::SUCCESS;
1117   }
1118   mLog << MSG::DEBUG << "SusyStudies: Final State Electrons successfully retrieved - size is " << finalStateElecTES->size() << " electrons " << endreq;
1119 
1120 
1121   /** iterators over the electron container - final state */ 
1122   ElectronContainer::const_iterator felecItr  = finalStateElecTES->begin();
1123   ElectronContainer::const_iterator felecItrE = finalStateElecTES->end();
1124 
1125   double sum_elET=0;
1126 
1127   for (; felecItr != felecItrE; ++felecItr) {
1128 
1129     /** apply further selections if necessary */
1130     /** check for the author of the electron */
1131     bool author = (*felecItr)->author(egammaParameters::AuthorElectron);
1132     if ( !author || (*felecItr)->pt() < m_etElecCut ) continue;
1133 
1134 
1135     const EMShower* eshow = (*felecItr)->detail<EMShower>("egDetailAOD");
1136     double etisol = -1;
1137     if( eshow ) etisol = eshow->parameter(egammaParameters::etcone20);
1138 
1139     mLog << MSG::DEBUG << "SusyStudies:isEM/etisol "<< (*felecItr)->isem()<<","<<etisol<<endreq;
1140 
1141     m_aan_NFinalEl++;
1142     m_aan_FinalElPt->push_back((*felecItr)->pt());
1143     m_aan_FinalElEta->push_back((*felecItr)->eta());
1144     m_aan_FinalElEtCone20->push_back(etisol);
1145     
1146     /** isEM cut already picks out isolated electrons, so this is just a sanity check */
1147     if(etisol/1000.<10) sum_elET += (*felecItr)->pt();
1148   }
1149 
1150 
1151   /** Now look at muons */
1152 
1153   const MuonContainer* finalStateMuonTES = m_analysisOverlapRemovalTool->finalStateMuons();
1154   if ( !finalStateMuonTES ) {
1155 
1156     mLog << MSG::WARNING << "SusyStudies: Final State Muons Not Found " << endreq;
1157     return StatusCode::SUCCESS;
1158   }
1159   mLog << MSG::DEBUG << "SusyStudies: Final State Muons successfully retrieved - size is " << finalStateMuonTES->size() << " muons " << endreq;
1160 
1161 
1162   /** iterators over the muon container - final state  */ 
1163   MuonContainer::const_iterator fmuonItr  = finalStateMuonTES->begin();
1164   MuonContainer::const_iterator fmuonItrE = finalStateMuonTES->end();
1165 
1166   double sum_muET = 0;
1167 
1168   for (; fmuonItr != fmuonItrE; ++fmuonItr) {
1169 
1170     /** apply further selections if necessary */
1171     /** check for the author of the muon */
1172 
1173     double etIsol = (*fmuonItr)->parameter( static_cast<MuonParameters::ParamDef>(1) ); // dR of 0.2
1174 
1175     mLog << MSG::DEBUG << "SusyStudies:Muon etisol/best match "<< etIsol<<","<<(*fmuonItr)->bestMatch()<<endreq;
1176    
1177     m_aan_NFinalMu++;
1178     m_aan_FinalMuPt->push_back( (*fmuonItr)->pt());
1179     m_aan_FinalMuEta->push_back( (*fmuonItr)->eta());
1180     m_aan_FinalMuEtCone20->push_back( etIsol);
1181     m_aan_FinalMuBestMat->push_back( (*fmuonItr)->bestMatch());
1182     m_aan_FinalMuMatChi2->push_back((*fmuonItr)->matchChi2());
1183 
1184     /** require bestMatch, chi2 and isolation cuts */
1185     if((*fmuonItr)->bestMatch()==1 && (*fmuonItr)->matchChi2() <100. && etIsol/1000. < 10) sum_muET +=(*fmuonItr)->pt();
1186 
1187   }
1188 
1189 
1190   /** now calculate effmass */
1191   m_aan_FinalLepEtSum = sum_elET + sum_muET; // keep leptons separate for now.
1192   m_aan_FinalElEtSum  = sum_elET;
1193   m_aan_FinalMuEtSum  = sum_muET;
1194 
1195   m_aan_effmass = m_aan_ptMiss + m_aan_ht; // scalar sum of jet ET + missing ET 
1196 
1197   return StatusCode::SUCCESS;
1198 
1199 }
1200 StatusCode AnalysisSkeleton::getTopQpT(int& numTops, double& top1, double& top2) {
1201 
1202   MsgStream mLog( messageService(), name() );
1203 
1204   mLog << MSG::DEBUG << "in getTopQpT()" << endreq;
1205 
1206   //
1207   top1 = -1; top2 = -1;
1208   //
1209   double topPt[2];
1210   topPt[0]=-1;
1211   topPt[1]=-1;
1212   //
1213   /** get the MC truth particle AOD container from StoreGate */
1214 
1215   const TruthParticleContainer*  mcpartTES = 0;
1216   StatusCode sc=m_storeGate->retrieve( mcpartTES, m_truthParticleContainerName);
1217   if( sc.isFailure()  ||  !mcpartTES ) {
1218      mLog << MSG::WARNING
1219           << "No AOD MC truth particle container found in TDS"
1220           << endreq; 
1221      return StatusCode::SUCCESS;
1222   }
1223   mLog <<MSG::DEBUG << "MC Truth Container Successfully Retrieved" << endreq;
1224 
1225   /** loop over particles and get the top quarks produced at the hard scatter */
1226 
1227   TruthParticleContainer::const_iterator mcpItr  = mcpartTES->begin();
1228   TruthParticleContainer::const_iterator mcpItrE = mcpartTES->end();
1229 
1230   numTops=0;
1231   for (; mcpItr != mcpItrE; ++mcpItr) {
1232 
1233     const HepMC::GenParticle* part =(*mcpItr)->genParticle();
1234     int pdgid = part->pdg_id();
1235 
1236     if(numTops==2) break; // quit if we have two already
1237 
1238     if(abs(pdgid)==6) { // it is a top
1239 
1240       HepMC::GenVertex* prod_vtx = part->production_vertex();
1241       int vtx_barcode = 1;
1242       if(prod_vtx) vtx_barcode = prod_vtx->barcode();
1243 
1244       if(vtx_barcode == -1) {
1245 
1246         topPt[numTops] = (part->momentum()).perp();
1247         numTops++;
1248 
1249       }
1250     
1251 
1252     }
1253   }
1254 
1255   top1 = topPt[0];
1256   top2 = topPt[1];
1257   return StatusCode::SUCCESS;
1258 }

source navigation ] diff markup ] identifier search ] general search ]

Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems
This page was automatically generated by the LXR engine. Valid HTML 4.01!