CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
AnaL1CaloCleaner Class Reference
Inheritance diagram for AnaL1CaloCleaner:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 AnaL1CaloCleaner (const edm::ParameterSet &)
 
 ~AnaL1CaloCleaner ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 

Private Attributes

Float_t calo_upara_
 
Float_t calo_uperp_
 
Int_t charge_
 
edm::InputTag colCaloDepositsMinus_
 
edm::InputTag colCaloDepositsPlus_
 
edm::InputTag colCaloLengthsMinus_
 
edm::InputTag colCaloLengthsPlus_
 
edm::InputTag colCaloMET_
 
edm::InputTag colGenParticles_
 
edm::InputTag colL1ETM_
 
edm::InputTag colMuons_
 
Float_t dep_ecal_
 
Float_t dep_hcal_
 
Float_t dep_ho_
 
Float_t eta_
 
Float_t l1_upara_
 
Float_t l1_uperp_
 
Float_t len_ecal_
 
Float_t len_hcal_
 
Float_t len_ho_
 
Float_t p_
 
Float_t phi_
 
Float_t pt_
 
TTree * tree_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 37 of file AnaL1CaloCleaner.cc.

Constructor & Destructor Documentation

AnaL1CaloCleaner::AnaL1CaloCleaner ( const edm::ParameterSet iConfig)
explicit

Definition at line 132 of file AnaL1CaloCleaner.cc.

References calo_upara_, calo_uperp_, charge_, dep_ecal_, dep_hcal_, dep_ho_, eta_, l1_upara_, l1_uperp_, len_ecal_, len_hcal_, len_ho_, TFileService::make(), p_, phi_, pt_, and tree_.

132  :
133  colCaloLengthsMinus_(iConfig.getParameter<edm::InputTag>("caloLengthsMinus")),
134  colCaloLengthsPlus_(iConfig.getParameter<edm::InputTag>("caloLengthsPlus")),
135  colCaloDepositsMinus_(iConfig.getParameter<edm::InputTag>("caloDepositsMinus")),
136  colCaloDepositsPlus_(iConfig.getParameter<edm::InputTag>("caloDepositsPlus")),
137  colL1ETM_(iConfig.getParameter<edm::InputTag>("l1ETM")),
138  colCaloMET_(iConfig.getParameter<edm::InputTag>("caloMET")),
139  colGenParticles_(iConfig.getParameter<edm::InputTag>("genParticles")),
140  colMuons_(iConfig.getParameter<edm::InputTag>("muons"))
141 {
143  tree_ = fs->make<TTree>("L1AnaTree", "L1AnaTree");
144 
145  tree_->Branch("pt", &pt_, "pt/F");
146  tree_->Branch("p", &p_, "p/F");
147  tree_->Branch("eta", &eta_, "eta/F");
148  tree_->Branch("phi", &phi_, "phi/F");
149  tree_->Branch("len_ecal", &len_ecal_, "len_ecal/F");
150  tree_->Branch("len_hcal", &len_hcal_, "len_hcal/F");
151  tree_->Branch("len_ho", &len_ho_, "len_ho/F");
152  tree_->Branch("dep_ecal", &dep_ecal_, "dep_ecal/F");
153  tree_->Branch("dep_hcal", &dep_hcal_, "dep_hcal/F");
154  tree_->Branch("dep_ho", &dep_ho_, "dep_ho/F");
155  tree_->Branch("l1_upara", &l1_upara_, "l1_upara/F");
156  tree_->Branch("l1_uperp", &l1_uperp_, "l1_uperp/F");
157  tree_->Branch("calo_upara", &calo_upara_, "calo_upara/F");
158  tree_->Branch("calo_uperp", &calo_uperp_, "calo_uperp/F");
159  tree_->Branch("charge", &charge_, "charge/I");
160 }
T getParameter(std::string const &) const
edm::InputTag colCaloDepositsMinus_
edm::InputTag colGenParticles_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
edm::InputTag colCaloLengthsMinus_
edm::InputTag colCaloMET_
edm::InputTag colL1ETM_
edm::InputTag colCaloDepositsPlus_
edm::InputTag colCaloLengthsPlus_
edm::InputTag colMuons_
AnaL1CaloCleaner::~AnaL1CaloCleaner ( )

Definition at line 270 of file AnaL1CaloCleaner.cc.

271 {
272 }

Member Function Documentation

void AnaL1CaloCleaner::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 163 of file AnaL1CaloCleaner.cc.

References Abs(), assert(), calo_upara_, calo_uperp_, reco::LeafCandidate::charge(), charge_, colCaloDepositsMinus_, colCaloDepositsPlus_, colCaloLengthsMinus_, colCaloLengthsPlus_, colCaloMET_, colGenParticles_, colL1ETM_, colMuons_, compMEtProjU(), HLT_25ns14e33_v1_cff::DeltaR, dep_ecal_, dep_hcal_, dep_ho_, DetId::det(), DetId::Ecal, reco::LeafCandidate::eta(), eta_, relval_steps::gen(), edm::Event::getByLabel(), DetId::Hcal, HcalOuter, reco::Muon::isGlobalMuon(), l1_upara_, l1_uperp_, len_ecal_, len_hcal_, len_ho_, RPCpg::mu, NULL, reco::LeafCandidate::p(), reco::LeafCandidate::p4(), p_, reco::LeafCandidate::pdgId(), reco::LeafCandidate::phi(), phi_, reco::LeafCandidate::pt(), pt_, reco::LeafCandidate::status(), DetId::subdetId(), and tree_.

164 {
165  // Find the (only) status-1 genlevel muon
167  iEvent.getByLabel(colGenParticles_, genHandle);
168  const reco::GenParticle* genMuon = NULL;
169  for(std::vector<reco::GenParticle>::const_iterator iter = genHandle->begin(); iter != genHandle->end(); ++iter)
170  {
171  const reco::GenParticle& gen = *iter;
172  if(TMath::Abs(gen.pdgId()) != 13) continue;
173  if(gen.status() != 1) continue;
174  if(genMuon) return; // There should only be one muon, or the whole method does not work
175  genMuon = &gen;
176  }
177 
178  // There should be at least one such muon
179  if(!genMuon) return;
180 
181  // Next, find the matching reco muon, if any
183  iEvent.getByLabel(colMuons_, muonsHandle);
184  const reco::Muon* recoMuon = NULL;
185  for(std::vector<reco::Muon>::const_iterator iter = muonsHandle->begin(); iter != muonsHandle->end(); ++iter)
186  {
187  const reco::Muon& mu = *iter;
188  if(!mu.isGlobalMuon()) continue;
189  if(ROOT::Math::VectorUtil::DeltaR(genMuon->p4(), mu.p4()) > 0.1) continue;
190  if(recoMuon && ROOT::Math::VectorUtil::DeltaR(genMuon->p4(), mu.p4()) > ROOT::Math::VectorUtil::DeltaR(genMuon->p4(), recoMuon->p4())) continue;
191  recoMuon = &mu;
192  }
193 
194  // We need a reco muon
195  if(!recoMuon) return;
196 
197  // Next, read the pathlength the muon travelled in the calorimeter
198  edm::Handle<std::map<unsigned int,float> > hLengthsMinus, hLengthsPlus;
199  edm::Handle<std::map<unsigned int,float> > hDepositsMinus, hDepositsPlus;
200  iEvent.getByLabel(colCaloLengthsMinus_, hLengthsMinus);
201  iEvent.getByLabel(colCaloLengthsPlus_, hLengthsPlus);
202  iEvent.getByLabel(colCaloDepositsMinus_, hDepositsMinus);
203  iEvent.getByLabel(colCaloDepositsPlus_, hDepositsPlus);
204  const std::map<unsigned int,float>& caloLengths = recoMuon->charge() < 0 ? *hLengthsMinus : *hLengthsPlus;
205  const std::map<unsigned int,float>& caloDeposits = recoMuon->charge() < 0 ? *hDepositsMinus : *hDepositsPlus;
206  float len_ecal = 0.0f, len_hcal = 0.0f, len_ho = 0.0f;
207  float dep_ecal = 0.0f, dep_hcal = 0.0f, dep_ho = 0.0f;
208  for(std::map<unsigned int, float>::const_iterator iter = caloLengths.begin(); iter != caloLengths.end(); ++iter)
209  {
210  const DetId det(iter->first);
211  std::map<unsigned int, float>::const_iterator dep_iter = caloDeposits.find(det);
212  const float dep = (dep_iter != caloDeposits.end()) ? dep_iter->second : 0.0f;
213 
214  //std::string name = getKey(det);
215  //std::cout << name << ": " << iter->second << std::endl;
216  // val = (hDeposits->find(entry.first))->second;
217  if(det.det() == DetId::Ecal)
218  {
219  len_ecal += iter->second;
220  dep_ecal += dep;
221  }
222  else if(det.det() == DetId::Hcal && det.subdetId() != HcalOuter)
223  {
224  len_hcal += iter->second;
225  dep_hcal += dep;
226  }
227  else if(det.det() == DetId::Hcal && det.subdetId() == HcalOuter)
228  {
229  len_ho += iter->second;
230  dep_ho += dep;
231  }
232  }
233 
234  // Compute the parallel and perpendicular projection wrt. the genmuon axis
236  iEvent.getByLabel(colL1ETM_, hl1Etm);
237  assert(hl1Etm->size() == 1);
238  int errorFlag = 0;
239  std::pair<double, double> l1_u1u2 = compMEtProjU(genMuon->p4(), (*hl1Etm)[0].px(), (*hl1Etm)[0].py(), errorFlag);
240  if(errorFlag) return;
241 
242  // Do the same with calo MET for reference
244  iEvent.getByLabel(colCaloMET_, hCaloMet);
245  assert(hCaloMet->size() == 1);
246  errorFlag = 0;
247  std::pair<double, double> calo_u1u2 = compMEtProjU(genMuon->p4(), (*hCaloMet)[0].px(), (*hCaloMet)[0].py(), errorFlag);
248  if(errorFlag) return;
249 
250  // And finally fill the tree
251  pt_ = recoMuon->pt();
252  p_ = recoMuon->p();
253  eta_ = recoMuon->eta();
254  phi_ = recoMuon->phi();
255  len_ecal_ = len_ecal;
256  len_hcal_ = len_hcal;
257  len_ho_ = len_ho;
258  dep_ecal_ = dep_ecal;
259  dep_hcal_ = dep_hcal;
260  dep_ho_ = dep_ho;
261  l1_upara_ = l1_u1u2.first;
262  l1_uperp_ = l1_u1u2.second;
263  calo_upara_ = calo_u1u2.first;
264  calo_uperp_ = calo_u1u2.second;
265  charge_ = recoMuon->charge();
266 
267  tree_->Fill();
268 }
virtual int pdgId() const
PDG identifier.
virtual double p() const
magnitude of momentum vector
edm::InputTag colCaloDepositsMinus_
edm::InputTag colGenParticles_
virtual int status() const
status word
assert(m_qm.get())
bool isGlobalMuon() const
Definition: Muon.h:218
#define NULL
Definition: scimark2.h:8
edm::InputTag colCaloLengthsMinus_
virtual double eta() const
momentum pseudorapidity
virtual double pt() const
transverse momentum
edm::InputTag colCaloMET_
edm::InputTag colL1ETM_
edm::InputTag colCaloDepositsPlus_
edm::InputTag colCaloLengthsPlus_
T Abs(T a)
Definition: MathUtil.h:49
virtual int charge() const
electric charge
Definition: LeafCandidate.h:91
const int mu
Definition: Constants.h:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
std::pair< double, double > compMEtProjU(const reco::Candidate::LorentzVector &zP4, double metPx, double metPy, int &errorFlag)
Definition: DetId.h:18
virtual double phi() const
momentum azimuthal angle
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
edm::InputTag colMuons_
void AnaL1CaloCleaner::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 276 of file AnaL1CaloCleaner.cc.

References edm::ConfigurationDescriptions::addDefault(), and edm::ParameterSetDescription::setUnknown().

276  {
277  //The following says we do not know what parameters are allowed so do no validation
278  // Please change this to state exactly what you do use, even if it is no parameters
280  desc.setUnknown();
281  descriptions.addDefault(desc);
282 }
void addDefault(ParameterSetDescription const &psetDescription)

Member Data Documentation

Float_t AnaL1CaloCleaner::calo_upara_
private

Definition at line 69 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::calo_uperp_
private

Definition at line 70 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Int_t AnaL1CaloCleaner::charge_
private

Definition at line 71 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

edm::InputTag AnaL1CaloCleaner::colCaloDepositsMinus_
private

Definition at line 49 of file AnaL1CaloCleaner.cc.

Referenced by analyze().

edm::InputTag AnaL1CaloCleaner::colCaloDepositsPlus_
private

Definition at line 50 of file AnaL1CaloCleaner.cc.

Referenced by analyze().

edm::InputTag AnaL1CaloCleaner::colCaloLengthsMinus_
private

Definition at line 47 of file AnaL1CaloCleaner.cc.

Referenced by analyze().

edm::InputTag AnaL1CaloCleaner::colCaloLengthsPlus_
private

Definition at line 48 of file AnaL1CaloCleaner.cc.

Referenced by analyze().

edm::InputTag AnaL1CaloCleaner::colCaloMET_
private

Definition at line 52 of file AnaL1CaloCleaner.cc.

Referenced by analyze().

edm::InputTag AnaL1CaloCleaner::colGenParticles_
private

Definition at line 53 of file AnaL1CaloCleaner.cc.

Referenced by analyze().

edm::InputTag AnaL1CaloCleaner::colL1ETM_
private

Definition at line 51 of file AnaL1CaloCleaner.cc.

Referenced by analyze().

edm::InputTag AnaL1CaloCleaner::colMuons_
private

Definition at line 54 of file AnaL1CaloCleaner.cc.

Referenced by analyze().

Float_t AnaL1CaloCleaner::dep_ecal_
private

Definition at line 64 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::dep_hcal_
private

Definition at line 65 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::dep_ho_
private

Definition at line 66 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::eta_
private

Definition at line 59 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::l1_upara_
private

Definition at line 67 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::l1_uperp_
private

Definition at line 68 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::len_ecal_
private

Definition at line 61 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::len_hcal_
private

Definition at line 62 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::len_ho_
private

Definition at line 63 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::p_
private

Definition at line 58 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::phi_
private

Definition at line 60 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

Float_t AnaL1CaloCleaner::pt_
private

Definition at line 57 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().

TTree* AnaL1CaloCleaner::tree_
private

Definition at line 56 of file AnaL1CaloCleaner.cc.

Referenced by AnaL1CaloCleaner(), and analyze().