ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/UHHAnalysis/SFrameTools/src/Utils.cxx
(Generate patch)

Comparing UserCode/UHHAnalysis/SFrameTools/src/Utils.cxx (file contents):
Revision 1.10 by rkogler, Mon Feb 4 12:40:46 2013 UTC vs.
Revision 1.12 by hoeing, Tue Mar 26 13:15:59 2013 UTC

# Line 1 | Line 1
1   #include "../include/Utils.h"
2  
3 + #include <fastjet/JetDefinition.hh>
4 + #include <fastjet/PseudoJet.hh>
5 + #include <fastjet/ClusterSequence.hh>
6 + #include <fastjet/ClusterSequenceArea.hh>
7 + #include <fastjet/GhostedAreaSpec.hh>
8 + namespace external {
9 + #include "../include/HEPTopTagger.h"
10 + }
11 +
12 +
13 +
14 + //subjet b-tagger, returns number of b-tagged subjets
15 +
16 + int subJetBTag(TopJet topjet, E_BtagType type){
17 +  int nBTagsSub = 0;
18 +  float discriminator_cut;
19 +  if(type==e_CSVL) discriminator_cut = 0.244;
20 +  if(type==e_CSVM) discriminator_cut = 0.679;
21 +  if(type==e_CSVT) discriminator_cut = 0.898;
22 +
23 +  //Create a vector of subjets
24 +  std::vector<Particle> subjets_top;
25 +  //Create a float vector of the subjets discriminators
26 +  std::vector<float> btagsub_combinedSecondaryVertex_top;
27 +
28 +  //Fill the vector of subjets with the subjets of a topjet
29 +  subjets_top=topjet.subjets();
30 +  //Fill the vector of discriminators with the discriminators of the subjets of a certain topjet
31 +  btagsub_combinedSecondaryVertex_top=topjet.btagsub_combinedSecondaryVertex();
32 +
33 +  //Looping over subjets and checking if they are b-tagged
34 +  for(unsigned int i=0; i < btagsub_combinedSecondaryVertex_top.size(); ++i){
35 +    float test=btagsub_combinedSecondaryVertex_top[i];
36 +    if(test>discriminator_cut){
37 +      nBTagsSub += 1;
38 +      //This means it is b-tagged
39 +    }
40 +  }
41 +  return nBTagsSub;
42 + }
43 +
44 +
45 + bool HiggsTag(TopJet topjet, E_BtagType type1, E_BtagType type2){
46 +  int nBTagsSub1 = 0;
47 +  int nBTagsSub2 = 0;
48 +  float discriminator_cut1;
49 +  float discriminator_cut2;
50 +  if(type1==e_CSVL) discriminator_cut1 = 0.244;
51 +  if(type1==e_CSVM) discriminator_cut1 = 0.679;
52 +  if(type1==e_CSVT) discriminator_cut1 = 0.898;
53 +  if(type2==e_CSVL) discriminator_cut2 = 0.244;
54 +  if(type2==e_CSVM) discriminator_cut2 = 0.679;
55 +  if(type2==e_CSVT) discriminator_cut2 = 0.898;
56 +  // std::cout << "discriminator_cut1: " <<  discriminator_cut1 << " discriminator_cut2: "<< discriminator_cut1 << std::endl;
57 +  //Create a vector of subjets
58 +  std::vector<Particle> subjets_top;
59 +  //Create a float vector of the subjets discriminators
60 +  std::vector<float> btagsub_combinedSecondaryVertex_top;
61 +
62 +  //Fill the vector of subjets with the subjets of a topjet
63 +  subjets_top=topjet.subjets();
64 +  //Fill the vector of discriminators with the discriminators of the subjets of a certain topjet
65 +  btagsub_combinedSecondaryVertex_top=topjet.btagsub_combinedSecondaryVertex();
66 +
67 +  //Looping over subjets and checking if they are b-tagged
68 +  for(unsigned int i=0; i < btagsub_combinedSecondaryVertex_top.size(); ++i){
69 +    float test=btagsub_combinedSecondaryVertex_top[i];
70 +    if (nBTagsSub1 != 0 && test>discriminator_cut2) nBTagsSub2 =+ 1;
71 +    if(test>discriminator_cut1){
72 +      if(test>discriminator_cut2 && nBTagsSub2==0) nBTagsSub2+=1;
73 +      else nBTagsSub1 += 1;      //This means it is b-tagged  
74 +
75 +    }
76 +  }
77 +  if (nBTagsSub1!=0 && nBTagsSub2!=0) return true;
78 +  else return false;
79 + }
80 +
81 +
82 + bool HepTopTagFull(TopJet topjet){
83 +
84 +  //Transform the SFrame TopJet object in a fastjet::PseudoJet
85 +
86 +  std::vector<fastjet::PseudoJet> jetpart;
87 +  std::vector<Particle> pfconstituents_jet;
88 +
89 +  fastjet::ClusterSequence* JetFinder;
90 +  fastjet::JetDefinition* JetDef ;
91 +
92 +  pfconstituents_jet=topjet.pfconstituents();
93 +  
94 +  for(unsigned int ic=0; ic<pfconstituents_jet.size(); ++ic){
95 +  
96 +    jetpart.push_back( fastjet::PseudoJet(
97 + pfconstituents_jet[ic].pt()*cos(pfconstituents_jet[ic].phi()),
98 + pfconstituents_jet[ic].pt()*sin(pfconstituents_jet[ic].phi()),
99 + pfconstituents_jet[ic].pt()*sinh(pfconstituents_jet[ic].eta()),
100 + pfconstituents_jet[ic].energy() ) );
101 +
102 +  }
103 +
104 +  //Clustering definition
105 +  double conesize=3;
106 +  JetDef = new
107 + fastjet::JetDefinition(fastjet::cambridge_algorithm,conesize);
108 +
109 +  JetFinder = new fastjet::ClusterSequence(jetpart, *JetDef);
110 +
111 +  std::vector<fastjet::PseudoJet> tops = JetFinder->inclusive_jets(10.);
112 +
113 +  if (tops.size() != 1){
114 +    std::cout << "Problem! Doesn't give exactly one jet!!!!!!!!!!!!!!Gives " << tops.size() << " jets" << std::endl;
115 +    delete JetFinder;
116 +    delete JetDef;
117 +    return false;
118 +  }
119 +
120 +  std::vector<fastjet::PseudoJet> SortedJets = sorted_by_pt(tops);
121 +
122 +
123 +  //Run the HEPTopTagger
124 +  external::HEPTopTagger tagger(*JetFinder, SortedJets[0]);
125 +
126 +  //Mass window to be applied in a second step
127 +  tagger.set_top_range(0.0, 10000.0);
128 +  tagger.set_mass_drop_threshold(0.8);
129 +  tagger.set_max_subjet_mass(30);
130 +
131 +  tagger.run_tagger();
132 +
133 +  delete JetFinder;
134 +  delete JetDef;
135 +
136 +  if (tagger.is_masscut_passed()) return true;
137 +  else return false;
138 +
139 +  return true;
140 +
141 + }
142 +
143 +
144  
145   // global function to define a tagged jet
146  
# Line 327 | Line 468 | int JetFlavor(Jet *jet)
468              GenParticle genp = genparticles->at(i);
469  
470              //only take status 3 particles into account
471 <            if(genp.status()!=3) continue;
471 >            //if(genp.status()!=3) continue;
472  
473              if(jet->deltaR(genp)<0.5)
474                  matched_genparticle_ids.push_back(genp.pdgId());

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines