00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "Validation/EventGenerator/interface/TauValidation.h"
00010
00011 #include "CLHEP/Units/defs.h"
00012 #include "CLHEP/Units/PhysicalConstants.h"
00013
00014 #include "DataFormats/Math/interface/LorentzVector.h"
00015
00016 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
00017
00018 using namespace edm;
00019
00020 TauValidation::TauValidation(const edm::ParameterSet& iPSet):
00021 hepmcCollection_(iPSet.getParameter<edm::InputTag>("hepmcCollection")),
00022 tauEtCut(iPSet.getParameter<double>("tauEtCutForRtau"))
00023 {
00024 dbe = 0;
00025 dbe = edm::Service<DQMStore>().operator->();
00026 }
00027
00028 TauValidation::~TauValidation() {}
00029
00030 void TauValidation::beginJob()
00031 {
00032 if(dbe){
00034 dbe->setCurrentFolder("Generator/Tau");
00035
00036
00037 nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.);
00038
00039
00040 TauPt = dbe->book1D("TauPt","Tau pT", 100 ,0,100);
00041 TauEta = dbe->book1D("TauEta","Tau eta", 100 ,-2.5,2.5);
00042 TauPhi = dbe->book1D("TauPhi","Tau phi", 100 ,-3.14,3.14);
00043 TauProngs = dbe->book1D("TauProngs","Tau n prongs", 7 ,0,7);
00044 TauDecayChannels = dbe->book1D("TauDecayChannels","Tau decay channels", 12 ,0,12);
00045 TauDecayChannels->setBinLabel(1+undetermined,"?");
00046 TauDecayChannels->setBinLabel(1+electron,"e");
00047 TauDecayChannels->setBinLabel(1+muon,"mu");
00048 TauDecayChannels->setBinLabel(1+pi,"#pi^{#pm}");
00049 TauDecayChannels->setBinLabel(1+rho,"#rho^{#pm}");
00050 TauDecayChannels->setBinLabel(1+a1,"a_{1}^{#pm}");
00051 TauDecayChannels->setBinLabel(1+pi1pi0,"#pi^{#pm}#pi^{0}");
00052 TauDecayChannels->setBinLabel(1+pinpi0,"#pi^{#pm}n#pi^{0}");
00053 TauDecayChannels->setBinLabel(1+tripi,"3#pi^{#pm}");
00054
00055 TauDecayChannels->setBinLabel(1+K,"K");
00056 TauDecayChannels->setBinLabel(1+Kstar,"K^{*}");
00057 TauDecayChannels->setBinLabel(1+stable,"Stable");
00058
00059 TauMothers = dbe->book1D("TauMothers","Tau mother particles", 10 ,0,10);
00060 TauMothers->setBinLabel(1+other,"?");
00061 TauMothers->setBinLabel(1+gamma,"#gamma");
00062 TauMothers->setBinLabel(1+Z,"Z");
00063 TauMothers->setBinLabel(1+W,"W");
00064 TauMothers->setBinLabel(1+HSM,"H_{SM}/h^{0}");
00065 TauMothers->setBinLabel(1+H0,"H^{0}");
00066 TauMothers->setBinLabel(1+A0,"A^{0}");
00067 TauMothers->setBinLabel(1+Hpm,"H^{#pm}");
00068
00069 TauRtauW = dbe->book1D("TauRtauW","W->Tau p(leading track)/E(visible tau)", 50 ,0,1);
00070 TauRtauW->setAxisTitle("rtau");
00071 TauRtauHpm = dbe->book1D("TauRtauHpm","Hpm->Tau p(leading track)/E(visible tau)", 50 ,0,1);
00072 TauRtauHpm->setAxisTitle("rtau");
00073 TauSpinEffectsW = dbe->book1D("TauSpinEffectsW","Pion energy in W rest frame", 50 ,0,1);
00074 TauSpinEffectsW->setAxisTitle("Energy");
00075 TauSpinEffectsHpm = dbe->book1D("TauSpinEffectsHpm","Pion energy in Hpm rest frame", 50 ,0,1);
00076 TauSpinEffectsHpm->setAxisTitle("Energy");
00077 TauSpinEffectsZ = dbe->book1D("TauSpinEffectsZ","Mass of pi+ pi-", 22 ,0,1.1);
00078 TauSpinEffectsZ->setAxisTitle("M_{#pi^{+}#pi^{-}}");
00079
00080 TauPhotonsN = dbe->book1D("TauPhotonsN","Photons radiating from tau", 2 ,0,2);
00081 TauPhotonsN->setBinLabel(1,"Number of taus");
00082 TauPhotonsN->setBinLabel(2,"Number of taus radiating photons");
00083 TauPhotonsPt = dbe->book1D("TauPhotonsPt","Photon pt radiating from tau", 2 ,0,2);
00084 TauPhotonsPt->setBinLabel(1,"Sum of tau pt");
00085 TauPhotonsPt->setBinLabel(2,"Sum of tau pt radiated by photons");
00086 }
00087
00088 return;
00089 }
00090
00091 void TauValidation::endJob(){
00092 return;
00093 }
00094
00095 void TauValidation::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup)
00096 {
00098 iSetup.getData( fPDGTable );
00099 return;
00100 }
00101 void TauValidation::endRun(const edm::Run& iRun,const edm::EventSetup& iSetup){return;}
00102 void TauValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup)
00103 {
00104
00106 edm::Handle<HepMCProduct> evt;
00107 iEvent.getByLabel(hepmcCollection_, evt);
00108
00109
00110 HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
00111
00112 nEvt->Fill(0.5);
00113
00114
00115 for(HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter) {
00116 if(abs((*iter)->pdg_id())==15){
00117 TauPt->Fill((*iter)->momentum().perp());
00118 TauEta->Fill((*iter)->momentum().eta());
00119 TauPhi->Fill((*iter)->momentum().phi());
00120 int mother = tauMother(*iter);
00121 int decaychannel = tauDecayChannel(*iter);
00122 tauProngs(*iter);
00123 rtau(*iter,mother,decaychannel);
00124 spinEffects(*iter,mother,decaychannel);
00125 photons(*iter);
00126 }
00127 if(abs((*iter)->pdg_id())==23){
00128 spinEffectsZ(*iter);
00129 }
00130 }
00131
00132 delete myGenEvent;
00133 }
00134
00135 int TauValidation::findMother(const HepMC::GenParticle* tau){
00136 int mother_pid = 0;
00137
00138 if ( tau->production_vertex() ) {
00139 HepMC::GenVertex::particle_iterator mother;
00140 for (mother = tau->production_vertex()->particles_begin(HepMC::parents);
00141 mother!= tau->production_vertex()->particles_end(HepMC::parents); ++mother ) {
00142 mother_pid = (*mother)->pdg_id();
00143 if(mother_pid == tau->pdg_id()) mother_pid = -1;
00144
00145 }
00146 }
00147 return mother_pid;
00148 }
00149
00150 int TauValidation::tauMother(const HepMC::GenParticle* tau){
00151
00152 if(abs(tau->pdg_id()) != 15 ) return -1;
00153
00154 int mother_pid = findMother(tau);
00155 if(mother_pid == -1) return -1;
00156
00157 int label = other;
00158 if(abs(mother_pid) == 24) label = W;
00159 if(abs(mother_pid) == 23) label = Z;
00160 if(abs(mother_pid) == 22) label = gamma;
00161 if(abs(mother_pid) == 25) label = HSM;
00162 if(abs(mother_pid) == 35) label = H0;
00163 if(abs(mother_pid) == 36) label = A0;
00164 if(abs(mother_pid) == 37) label = Hpm;
00165
00166 TauMothers->Fill(label);
00167
00168 return mother_pid;
00169 }
00170
00171 int TauValidation::tauProngs(const HepMC::GenParticle* tau){
00172
00173 int nProngs = 0;
00174 if ( tau->end_vertex() ) {
00175 HepMC::GenVertex::particle_iterator des;
00176 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00177 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00178 int pid = (*des)->pdg_id();
00179 if(abs(pid) == 15) return tauProngs(*des);
00180 if((*des)->status() != 1) continue;
00181
00182 const HepPDT::ParticleData* pd = fPDGTable->particle((*des)->pdg_id ());
00183 int charge = (int) pd->charge();
00184 if(charge == 0) continue;
00185
00186
00187
00188 nProngs++;
00189 }
00190 }
00191 TauProngs->Fill(nProngs);
00192 return nProngs;
00193 }
00194
00195 int TauValidation::findTauDecayChannel(const HepMC::GenParticle* tau){
00196
00197 int channel = undetermined;
00198 if(tau->status() == 1) channel = stable;
00199
00200 int allCount = 0,
00201 eCount = 0,
00202 muCount = 0,
00203 pi0Count = 0,
00204 piCount = 0,
00205 rhoCount = 0,
00206 a1Count = 0,
00207 KCount = 0,
00208 KstarCount = 0;
00209
00210 if ( tau->end_vertex() ) {
00211 HepMC::GenVertex::particle_iterator des;
00212 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00213 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00214
00215 if(abs(tauMother(*des)) != 15) continue;
00216 int pid = (*des)->pdg_id();
00217
00218
00219
00220
00221 if(abs(pid) == 15) return findTauDecayChannel(*des);
00222
00223 allCount++;
00224 if(abs(pid) == 11) eCount++;
00225 if(abs(pid) == 13) muCount++;
00226 if(abs(pid) == 111) pi0Count++;
00227 if(abs(pid) == 211) piCount++;
00228 if(abs(pid) == 213) rhoCount++;
00229 if(abs(pid) == 20213) a1Count++;
00230 if(abs(pid) == 321) KCount++;
00231 if(abs(pid) == 323) KstarCount++;
00232
00233 }
00234 }
00235
00236 if(KCount == 1 && allCount == 2) channel = K;
00237 if(KstarCount == 1 && allCount == 2) channel = Kstar;
00238 if(a1Count == 1 && allCount == 2) channel = a1;
00239 if(rhoCount == 1 && allCount == 2) channel = rho;
00240
00241 if(piCount == 1 && pi0Count == 0) channel = pi;
00242 if(piCount == 1 && pi0Count == 1) channel = pi1pi0;
00243 if(piCount == 1 && pi0Count > 1) channel = pinpi0;
00244
00245 if(piCount == 3 && pi0Count == 0) channel = tripi;
00246
00247
00248 if(eCount == 1) channel = electron;
00249 if(muCount == 1) channel = muon;
00250
00251 return channel;
00252 }
00253
00254 int TauValidation::tauDecayChannel(const HepMC::GenParticle* tau){
00255 int channel = findTauDecayChannel(tau);
00256 TauDecayChannels->Fill(channel);
00257 return channel;
00258 }
00259
00260 void TauValidation::rtau(const HepMC::GenParticle* tau,int mother, int decay){
00261
00262 if(decay != pi1pi0) return;
00263
00264 if(tau->momentum().perp() < tauEtCut) return;
00265
00266 double rTau = 0;
00267 double ltrack = leadingPionMomentum(tau);
00268 double visibleTauE = visibleTauEnergy(tau);
00269
00270 if(visibleTauE != 0) rTau = ltrack/visibleTauE;
00271
00272 if(abs(mother) == 24) TauRtauW->Fill(rTau);
00273 if(abs(mother) == 37) TauRtauHpm->Fill(rTau);
00274 }
00275
00276 void TauValidation::spinEffects(const HepMC::GenParticle* tau,int mother, int decay){
00277
00278 if(decay != pi) return;
00279
00280 TLorentzVector momP4 = motherP4(tau);
00281 TLorentzVector pionP4 = leadingPionP4(tau);
00282
00283 pionP4.Boost(-1*momP4.BoostVector());
00284
00285 double energy = pionP4.E()/(momP4.M()/2);
00286
00287 if(abs(mother) == 24) TauSpinEffectsW->Fill(energy);
00288 if(abs(mother) == 37) TauSpinEffectsHpm->Fill(energy);
00289 }
00290
00291 void TauValidation::spinEffectsZ(const HepMC::GenParticle* boson){
00292
00293 TLorentzVector tautau(0,0,0,0);
00294 TLorentzVector pipi(0,0,0,0);
00295
00296 int nSinglePionDecays = 0;
00297 if ( boson->end_vertex() ) {
00298 HepMC::GenVertex::particle_iterator des;
00299 for(des = boson->end_vertex()->particles_begin(HepMC::descendants);
00300 des!= boson->end_vertex()->particles_end(HepMC::descendants);++des ) {
00301
00302 int pid = (*des)->pdg_id();
00303
00304
00305
00306
00307
00308
00309 if(abs(findMother(*des)) != 15 &&
00310 abs(pid) == 15 && findTauDecayChannel(*des) == pi){
00311 nSinglePionDecays++;
00312 tautau += TLorentzVector((*des)->momentum().px(),
00313 (*des)->momentum().py(),
00314 (*des)->momentum().pz(),
00315 (*des)->momentum().e());
00316 pipi += leadingPionP4(*des);
00317 }
00318 }
00319 }
00320 if(nSinglePionDecays == 2 && tautau.M() != 0) {
00321 TauSpinEffectsZ->Fill(pipi.M()/tautau.M());
00322 }
00323 }
00324
00325 double TauValidation::leadingPionMomentum(const HepMC::GenParticle* tau){
00326 return leadingPionP4(tau).P();
00327 }
00328
00329 TLorentzVector TauValidation::leadingPionP4(const HepMC::GenParticle* tau){
00330
00331 TLorentzVector p4(0,0,0,0);
00332
00333 if ( tau->end_vertex() ) {
00334 HepMC::GenVertex::particle_iterator des;
00335 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00336 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00337 int pid = (*des)->pdg_id();
00338
00339 if(abs(pid) == 15) return leadingPionP4(*des);
00340
00341 if(abs(pid) != 211) continue;
00342
00343 if((*des)->momentum().rho() > p4.P()) {
00344 p4 = TLorentzVector((*des)->momentum().px(),
00345 (*des)->momentum().py(),
00346 (*des)->momentum().pz(),
00347 (*des)->momentum().e());
00348 }
00349 }
00350 }
00351
00352 return p4;
00353 }
00354
00355 TLorentzVector TauValidation::motherP4(const HepMC::GenParticle* tau){
00356
00357 TLorentzVector p4(0,0,0,0);
00358
00359 if ( tau->production_vertex() ) {
00360 HepMC::GenVertex::particle_iterator mother;
00361 for (mother = tau->production_vertex()->particles_begin(HepMC::parents);
00362 mother!= tau->production_vertex()->particles_end(HepMC::parents); ++mother ) {
00363
00364
00365 p4 = TLorentzVector((*mother)->momentum().px(),
00366 (*mother)->momentum().py(),
00367 (*mother)->momentum().pz(),
00368 (*mother)->momentum().e());
00369 }
00370 }
00371
00372 return p4;
00373 }
00374
00375 double TauValidation::visibleTauEnergy(const HepMC::GenParticle* tau){
00376 TLorentzVector p4(tau->momentum().px(),
00377 tau->momentum().py(),
00378 tau->momentum().pz(),
00379 tau->momentum().e());
00380
00381 if ( tau->end_vertex() ) {
00382 HepMC::GenVertex::particle_iterator des;
00383 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00384 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00385 int pid = (*des)->pdg_id();
00386
00387 if(abs(pid) == 15) return visibleTauEnergy(*des);
00388
00389 if(abs(pid) == 12 || abs(pid) == 14 || abs(pid) == 16) {
00390 p4 -= TLorentzVector((*des)->momentum().px(),
00391 (*des)->momentum().py(),
00392 (*des)->momentum().pz(),
00393 (*des)->momentum().e());
00394 }
00395 }
00396 }
00397
00398 return p4.E();
00399 }
00400
00401 void TauValidation::photons(const HepMC::GenParticle* tau){
00402
00403 if ( tau->end_vertex() ) {
00404 double photonFromTauPtSum = 0;
00405 bool photonFromTau = false;
00406 HepMC::GenVertex::particle_iterator des;
00407 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00408 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00409 int pid = (*des)->pdg_id();
00410 if(pid == 22) {
00411 photonFromTauPtSum += (*des)->momentum().perp();
00412 photonFromTau = true;
00413 }
00414 }
00415
00416 TauPhotonsN->Fill(0.5);
00417 TauPhotonsPt->Fill(0.5,tau->momentum().perp());
00418 if(photonFromTau) {
00419 TauPhotonsN->Fill(1.5);
00420 TauPhotonsPt->Fill(1.5,photonFromTauPtSum);
00421 }
00422 }
00423 }
00424