CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
AlignmentTwoBoyDecayTrackSelector.cc
Go to the documentation of this file.
1 //Framework
3 
6 
7 //DataFormats
12 
13 //STL
14 #include <math.h>
15 //ROOT
16 #include "TLorentzVector.h"
17 
19 //TODO put those namespaces into functions?
20 using namespace std;
21 using namespace edm;
22 // constructor ----------------------------------------------------------------
23 
25  theMissingETSource("met")
26 {
27  LogDebug("Alignment") << "> applying two body decay Trackfilter ...";
28  theMassrangeSwitch = cfg.getParameter<bool>( "applyMassrangeFilter" );
29  if (theMassrangeSwitch){
30  theMinMass = cfg.getParameter<double>( "minXMass" );
31  theMaxMass = cfg.getParameter<double>( "maxXMass" );
32  theDaughterMass = cfg.getParameter<double>( "daughterMass" );
33  LogDebug("Alignment") << "> Massrange min,max : " << theMinMass << "," << theMaxMass
34  << "\n> Mass of daughter Particle : " << theDaughterMass;
35 
36  }else{
37  theMinMass = 0;
38  theMaxMass = 0;
39  theDaughterMass = 0;
40  }
41  theChargeSwitch = cfg.getParameter<bool>( "applyChargeFilter" );
42  if(theChargeSwitch){
43  theCharge = cfg.getParameter<int>( "charge" );
44  theUnsignedSwitch = cfg.getParameter<bool>( "useUnsignedCharge" );
45  if(theUnsignedSwitch)
47  LogDebug("Alignment") << "> Desired Charge, unsigned: "<<theCharge<<" , "<<theUnsignedSwitch;
48  }else{
49  theCharge =0;
50  theUnsignedSwitch = true;
51  }
52  theMissingETSwitch = cfg.getParameter<bool>( "applyMissingETFilter" );
54  theMissingETSource = cfg.getParameter<InputTag>( "missingETSource" );
55  LogDebug("Alignment") << "> missing Et Source: "<< theMissingETSource;
56  }
57  theAcoplanarityFilterSwitch = cfg.getParameter<bool>( "applyAcoplanarityFilter" );
59  theAcoplanarDistance = cfg.getParameter<double>( "acoplanarDistance" );
60  LogDebug("Alignment") << "> Acoplanar Distance: "<<theAcoplanarDistance;
61  }
62 
63 }
64 
65 // destructor -----------------------------------------------------------------
66 
68 {}
69 
70 
73 {
75 }
76 
77 // do selection ---------------------------------------------------------------
78 
81 {
83 
84  if(theMassrangeSwitch){
86  result = checkMETMass(result,iEvent);
87  else
88  result = checkMass(result);
89  }
90  if(theChargeSwitch)
91  result = checkCharge(result);
94  result = checkMETAcoplanarity(result,iEvent);
95  else
96  result = checkAcoplanarity(result);
97  }
98  LogDebug("Alignment") << "> TwoBodyDecay tracks all,kept: " << tracks.size() << "," << result.size();
99  // LogDebug("AlignmentTwoBodyDecayTrackSelector")<<"> o kept:";
100  //printTracks(result);
101  return result;
102 
103 }
104 
108 {
109  Tracks result; result.clear();
110  //TODO perhaps try combinations if there are more than 2 tracks ....
111  if(cands.size() == 2){
112  //TODO use other vectors here
113  TLorentzVector track0(cands.at(0)->px(),cands.at(0)->py(),cands.at(0)->pz(),
114  sqrt((cands.at(0)->p()*cands.at(0)->p())+theDaughterMass*theDaughterMass));
115  TLorentzVector track1(cands.at(1)->px(),cands.at(1)->py(),cands.at(1)->pz(),
116  sqrt((cands.at(1)->p()*cands.at(1)->p())+theDaughterMass*theDaughterMass));
117  TLorentzVector mother = track0+track1;
118  if(mother.M() > theMinMass && mother.M() < theMaxMass)
119  result = cands;
120  LogDebug("Alignment") <<"> mass of mother: "<<mother.M()<<"GeV";
121  }
122  return result;
123 }
124 
128 {
129  Tracks result; result.clear();
130  if(cands.size() == 1){
132  iEvent.getByLabel(theMissingETSource ,missingET);
133  if(missingET.isValid()){
134  //TODO use the one with highest pt instead of the first one?
135  // for(reco::CaloMETCollection::const_iterator itMET = missingET->begin(); itMET != missingET->end() ; ++itMET){
136  // cout <<"missingET p = ("<<(*itMET).px()<<","<<(*itMET).py()<<","<<(*itMET).pz()<<")"<<endl;
137  //}
138  TLorentzVector track(cands.at(0)->px(),cands.at(0)->py(),cands.at(0)->pz(),
139  sqrt((cands.at(0)->p()*cands.at(0)->p())+theDaughterMass*theDaughterMass));
140  TLorentzVector met((*missingET).at(0).px(),(*missingET).at(0).py(),(*missingET).at(0).pz(),
141  (*missingET).at(0).p());//ignoring nuetralino masses for now ;)
142  TLorentzVector motherSystem = track + met;
143  if(motherSystem.M() > theMinMass && motherSystem.M() < theMaxMass)
144  result = cands;
145  LogDebug("Alignment") <<"> mass of motherSystem: "<<motherSystem.M()<<"GeV";
146  }else
147  LogError("Alignment")<<"@SUB=AlignmentTwoBodyDecayTrackSelector::checkMETMass"
148  <<"> could not optain missingET Collection!";
149  }
150  return cands;
151 }
152 
156 {
157  Tracks result; result.clear();
158  int sumCharge = 0;
159  for(Tracks::const_iterator it = cands.begin();it < cands.end();++it)
160  sumCharge += (*it)->charge();
162  sumCharge = std::abs(sumCharge);
163  if(sumCharge == theCharge)
164  result = cands;
165 
166  return result;
167 }
168 
172 {
173  Tracks result; result.clear();
174  //TODO return the biggest set of acoplanar tracks or two tracks with smallest distance?
175  if(cands.size() == 2){
176  LogDebug("Alignment") <<"> Acoplanarity: "<<fabs(fabs(deltaPhi(cands.at(0)->phi(),cands.at(1)->phi()))-M_PI)<<endl;
177  if(fabs(fabs(deltaPhi(cands.at(0)->phi(),cands.at(1)->phi()))-M_PI)<theAcoplanarDistance)
178  result = cands;
179  }
180  return result;
181 }
185 {
186  Tracks result; result.clear();
187  if(cands.size() == 1){
189  iEvent.getByLabel(theMissingETSource ,missingET);
190  if(missingET.isValid()){
191  //TODO return the biggest set of acoplanar tracks or the one with smallest distance?
192  LogDebug("Alignment") <<"> METAcoplanarity: "<<fabs(fabs(deltaPhi(cands.at(0)->phi(),(*missingET).at(0).phi()))-M_PI)<<endl;
193  if(fabs(fabs(deltaPhi(cands.at(0)->phi(),(*missingET).at(0).phi()))-M_PI)<theAcoplanarDistance)
194  result = cands;
195 
196  }else
197  LogError("Alignment")<<"@SUB=AlignmentTwoBodyDecayTrackSelector::checkMETAcoplanarity"
198  <<"> could not optain missingET Collection!";
199  }
200  return result;
201 }
202 
203 //===================HELPERS===================
204 
207 {
208  int count = 0;
209  LogDebug("Alignment") << ">......................................";
210  for(Tracks::const_iterator it = col.begin();it < col.end();++it,++count){
211  LogDebug("Alignment")
212  <<"> Track No. "<< count <<": p = ("<<(*it)->px()<<","<<(*it)->py()<<","<<(*it)->pz()<<")\n"
213  <<"> pT = "<<(*it)->pt()<<" eta = "<<(*it)->eta()<<" charge = "<<(*it)->charge();
214  }
215  LogDebug("Alignment") << ">......................................";
216 }
217 
218 
#define LogDebug(id)
T getParameter(std::string const &) const
double deltaPhi(float phi1, float phi2)
Definition: VectorUtil.h:30
Tracks checkMETAcoplanarity(const Tracks &cands, const edm::Event &iEvent) const
checks if [cands] contains a acoplanar track w.r.t missing ET (returns empty set if not) ...
Tracks select(const Tracks &tracks, const edm::Event &iEvent)
select tracks
#define abs(x)
Definition: mlp_lapack.h:159
int iEvent
Definition: GenABIO.cc:243
T sqrt(T t)
Definition: SSEVec.h:28
bool useThisFilter()
returns if any of the Filters is used.
tuple result
Definition: query.py:137
void printTracks(const Tracks &col) const
print Information on Track-Collection
Tracks checkAcoplanarity(const Tracks &cands) const
checks if the [cands] are acoplanar (returns empty set if not)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
#define M_PI
Definition: BFit3D.cc:3
tuple tracks
Definition: testEve_cfg.py:39
AlignmentTwoBodyDecayTrackSelector(const edm::ParameterSet &cfg)
constructor
Tracks checkCharge(const Tracks &cands) const
checks if the mother has charge = [theCharge]
Tracks checkMETMass(const Tracks &cands, const edm::Event &iEvent) const
checks if the mass of the mother is in the mass region adding missing E_T
Tracks checkMass(const Tracks &cands) const
checks if the mass of the mother is in the mass region