CMS 3D CMS Logo

BPHWriteSpecificDecay.h
Go to the documentation of this file.
1 #ifndef HeavyFlavorAnalysis_SpecificDecay_BPHWriteSpecificDecay_h
2 #define HeavyFlavorAnalysis_SpecificDecay_BPHWriteSpecificDecay_h
3 
5 
10 
14 
20 
23 
24 #include <string>
25 #include <vector>
26 #include <map>
27 #include <iostream>
28 #include <fstream>
29 
30 class TH1F;
31 class BPHRecoCandidate;
32 
33 class BPHWriteSpecificDecay : public BPHAnalyzerWrapper<BPHModuleWrapper::one_producer> {
34 public:
35  explicit BPHWriteSpecificDecay(const edm::ParameterSet& ps);
36  ~BPHWriteSpecificDecay() override;
37 
38  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
39 
40  void beginJob() override;
41  void produce(edm::Event& ev, const edm::EventSetup& es) override;
42  virtual void fill(edm::Event& ev, const edm::EventSetup& es);
43  void endJob() override;
44 
45 private:
52 
53  // token wrappers to allow running both on "old" and "new" CMSSW versions
60 
61  bool usePV;
62  bool usePM;
63  bool useCC;
64  bool usePF;
65  bool usePC;
66  bool useGP;
67 
74 
75  enum recoType { Onia, Pmm, Psi1, Psi2, Ups, Ups1, Ups2, Ups3, Kx0, Pkk, Bu, Bd, Bs };
76  enum parType {
94  };
95  std::map<std::string, recoType> rMap;
96  std::map<std::string, parType> pMap;
97  std::map<std::string, parType> fMap;
98  std::map<recoType, std::map<parType, double> > parMap;
99 
100  bool recoOnia;
101  bool recoKx0;
102  bool recoPkk;
103  bool recoBu;
104  bool recoBd;
105  bool recoBs;
106 
107  bool writeOnia;
108  bool writeKx0;
109  bool writePkk;
110  bool writeBu;
111  bool writeBd;
112  bool writeBs;
113 
116 
117  std::vector<BPHPlusMinusConstCandPtr> lFull;
118  std::vector<BPHPlusMinusConstCandPtr> lJPsi;
119  std::vector<BPHRecoConstCandPtr> lSd;
120  std::vector<BPHRecoConstCandPtr> lSs;
121  std::vector<BPHRecoConstCandPtr> lBu;
122  std::vector<BPHRecoConstCandPtr> lBd;
123  std::vector<BPHRecoConstCandPtr> lBs;
124 
125  std::map<const BPHRecoCandidate*, const BPHRecoCandidate*> jPsiOMap;
127  std::map<const BPHRecoCandidate*, vertex_ref> pvRefMap;
129  std::map<const BPHRecoCandidate*, compcc_ref> ccRefMap;
130 
131  void setRecoParameters(const edm::ParameterSet& ps);
132 
133  template <class T>
135  const std::vector<T>& list,
136  const std::string& name) {
138  int i;
139  int n = list.size();
140  std::map<const BPHRecoCandidate*, const BPHRecoCandidate*>::const_iterator jpoIter;
141  std::map<const BPHRecoCandidate*, const BPHRecoCandidate*>::const_iterator jpoIend = jPsiOMap.end();
142  std::map<const BPHRecoCandidate*, vertex_ref>::const_iterator pvrIter;
143  std::map<const BPHRecoCandidate*, vertex_ref>::const_iterator pvrIend = pvRefMap.end();
144  std::map<const BPHRecoCandidate*, compcc_ref>::const_iterator ccrIter;
145  std::map<const BPHRecoCandidate*, compcc_ref>::const_iterator ccrIend = ccRefMap.end();
146  for (i = 0; i < n; ++i) {
147  const T& ptr = list[i];
148  ccList->push_back(ptr->composite());
149  pat::CompositeCandidate& cc = ccList->back();
150  if ((pvrIter = pvRefMap.find(ptr.get())) != pvrIend)
151  cc.addUserData("primaryVertex", pvrIter->second);
152  const std::vector<std::string>& cNames = ptr->compNames();
153  int j = 0;
154  int m = cNames.size();
155  while (j < m) {
156  const std::string& compName = cNames[j++];
157  const BPHRecoCandidate* cptr = ptr->getComp(compName).get();
158  if ((ccrIter = ccRefMap.find(cptr)) == ccrIend) {
159  if ((jpoIter = jPsiOMap.find(cptr)) != jpoIend)
160  cptr = jpoIter->second;
161  else
162  cptr = nullptr;
163  }
164  if ((ccrIter = ccRefMap.find(cptr)) != ccrIend) {
165  compcc_ref cref = ccrIter->second;
166  if (cref.isNonnull())
167  cc.addUserData("refTo" + compName, cref);
168  }
169  }
170  const BPHPlusMinusCandidate* pmp = dynamic_cast<const BPHPlusMinusCandidate*>(ptr.get());
171  if (pmp != nullptr)
172  cc.addUserData("cowboy", pmp->isCowboy());
173  if (ptr->isEmpty()) {
174  if (writeVertex)
175  cc.addUserData("vertex", ptr->vertex());
176  continue;
177  }
178  if (writeVertex)
179  cc.addUserData("fitVertex", reco::Vertex(*ptr->currentDecayVertex()));
180  if (ptr->isValidFit()) {
181  const RefCountedKinematicParticle kinPart = ptr->currentParticle();
182  const KinematicState kinStat = kinPart->currentState();
183  cc.addUserFloat("fitMass", kinStat.mass());
184  if (writeMomentum)
185  cc.addUserData("fitMomentum", kinStat.kinematicParameters().momentum());
186  }
187  }
188  typedef std::unique_ptr<pat::CompositeCandidateCollection> ccc_pointer;
189  edm::OrphanHandle<pat::CompositeCandidateCollection> ccHandle = ev.put(ccc_pointer(ccList), name);
190  for (i = 0; i < n; ++i) {
191  const BPHRecoCandidate* ptr = list[i].get();
193  ccRefMap[ptr] = ccRef;
194  }
195  return ccHandle;
196  }
197 };
198 
199 #endif
Analysis-level particle class.
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
BPHTokenWrapper< std::vector< reco::Vertex > > pVertexToken
std::vector< BPHPlusMinusConstCandPtr > lJPsi
edm::Ref< std::vector< reco::Vertex > > vertex_ref
std::map< const BPHRecoCandidate *, compcc_ref > ccRefMap
std::vector< BPHPlusMinusConstCandPtr > lFull
std::map< std::string, recoType > rMap
edm::Ref< pat::CompositeCandidateCollection > compcc_ref
std::vector< BPHRecoConstCandPtr > lBs
BPHTokenWrapper< std::vector< BPHTrackReference::candidate > > pcCandsToken
bool ev
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:897
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void fill(edm::Event &ev, const edm::EventSetup &es)
ParticleMass mass() const
std::map< std::string, parType > pMap
std::vector< BPHRecoConstCandPtr > lSs
BPHWriteSpecificDecay(const edm::ParameterSet &ps)
BPHTokenWrapper< pat::MuonCollection > patMuonToken
BPHTokenWrapper< std::vector< reco::PFCandidate > > pfCandsToken
bool isCowboy() const
get cowboy/sailor classification
BPHTokenWrapper< std::vector< pat::CompositeCandidate > > ccCandsToken
std::vector< BPHRecoConstCandPtr > lSd
KinematicParameters const & kinematicParameters() const
BPHTokenWrapper< std::vector< pat::GenericParticle > > gpCandsToken
std::vector< CompositeCandidate > CompositeCandidateCollection
edm::OrphanHandle< pat::CompositeCandidateCollection > write(edm::Event &ev, const std::vector< T > &list, const std::string &name)
std::map< const BPHRecoCandidate *, vertex_ref > pvRefMap
std::vector< BPHRecoConstCandPtr > lBu
virtual BPHRecoConstCandPtr getComp(const std::string &name) const
std::map< recoType, std::map< parType, double > > parMap
std::map< const BPHRecoCandidate *, const BPHRecoCandidate * > jPsiOMap
long double T
void produce(edm::Event &ev, const edm::EventSetup &es) override
std::vector< BPHRecoConstCandPtr > lBd
void setRecoParameters(const edm::ParameterSet &ps)
std::map< std::string, parType > fMap
void addUserData(const std::string &label, const T &data, bool transientOnly=false, bool overwrite=false)
Definition: PATObject.h:353
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
GlobalVector momentum() const