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 #include "Validation/EventGenerator/interface/TauDecay_CMSSW.h"
00018 #include "Validation/EventGenerator/interface/PdtPdgMini.h"
00019
00020 using namespace edm;
00021
00022 TauValidation::TauValidation(const edm::ParameterSet& iPSet):
00023 _wmanager(iPSet)
00024 ,hepmcCollection_(iPSet.getParameter<edm::InputTag>("hepmcCollection"))
00025 ,tauEtCut(iPSet.getParameter<double>("tauEtCutForRtau"))
00026 ,NJAKID(22)
00027 {
00028 dbe = 0;
00029 dbe = edm::Service<DQMStore>().operator->();
00030 }
00031
00032 TauValidation::~TauValidation() {}
00033
00034 void TauValidation::beginJob()
00035 {
00036 if(dbe){
00038 dbe->setCurrentFolder("Generator/Tau");
00039
00040
00041 nEvt = dbe->book1D("nEvt", "n analyzed Events", 1, 0., 1.);
00042
00043
00044 TauPt = dbe->book1D("TauPt","Tau pT", 100 ,0,100);
00045 TauEta = dbe->book1D("TauEta","Tau eta", 100 ,-2.5,2.5);
00046 TauPhi = dbe->book1D("TauPhi","Tau phi", 100 ,-3.14,3.14);
00047 TauProngs = dbe->book1D("TauProngs","Tau n prongs", 7 ,0,7);
00048 TauDecayChannels = dbe->book1D("TauDecayChannels","Tau decay channels", 12 ,0,12);
00049 TauDecayChannels->setBinLabel(1+undetermined,"?");
00050 TauDecayChannels->setBinLabel(1+electron,"e");
00051 TauDecayChannels->setBinLabel(1+muon,"mu");
00052 TauDecayChannels->setBinLabel(1+pi,"#pi^{#pm}");
00053 TauDecayChannels->setBinLabel(1+rho,"#rho^{#pm}");
00054 TauDecayChannels->setBinLabel(1+a1,"a_{1}^{#pm}");
00055 TauDecayChannels->setBinLabel(1+pi1pi0,"#pi^{#pm}#pi^{0}");
00056 TauDecayChannels->setBinLabel(1+pinpi0,"#pi^{#pm}n#pi^{0}");
00057 TauDecayChannels->setBinLabel(1+tripi,"3#pi^{#pm}");
00058
00059 TauDecayChannels->setBinLabel(1+K,"K");
00060 TauDecayChannels->setBinLabel(1+Kstar,"K^{*}");
00061 TauDecayChannels->setBinLabel(1+stable,"Stable");
00062
00063 TauMothers = dbe->book1D("TauMothers","Tau mother particles", 10 ,0,10);
00064 TauMothers->setBinLabel(1+other,"?");
00065 TauMothers->setBinLabel(1+B,"B Decays");
00066 TauMothers->setBinLabel(1+D,"D Decays");
00067 TauMothers->setBinLabel(1+gamma,"#gamma");
00068 TauMothers->setBinLabel(1+Z,"Z");
00069 TauMothers->setBinLabel(1+W,"W");
00070 TauMothers->setBinLabel(1+HSM,"H_{SM}/h^{0}");
00071 TauMothers->setBinLabel(1+H0,"H^{0}");
00072 TauMothers->setBinLabel(1+A0,"A^{0}");
00073 TauMothers->setBinLabel(1+Hpm,"H^{#pm}");
00074
00075 TauRtauW = dbe->book1D("TauRtauW","W->Tau p(leading track)/E(visible tau)", 50 ,0,1);
00076 TauRtauW->setAxisTitle("rtau");
00077 TauRtauHpm = dbe->book1D("TauRtauHpm","Hpm->Tau p(leading track)/E(visible tau)", 50 ,0,1);
00078 TauRtauHpm->setAxisTitle("rtau");
00079 TauSpinEffectsW = dbe->book1D("TauSpinEffectsW","Pion energy in W rest frame", 50 ,0,1);
00080 TauSpinEffectsW->setAxisTitle("Energy");
00081 TauSpinEffectsHpm = dbe->book1D("TauSpinEffectsHpm","Pion energy in Hpm rest frame", 50 ,0,1);
00082 TauSpinEffectsHpm->setAxisTitle("Energy");
00083 TauSpinEffectsZ = dbe->book1D("TauSpinEffectsZ","Mass of pi+ pi-", 22 ,0,1.1);
00084 TauSpinEffectsZ->setAxisTitle("M_{#pi^{+}#pi^{-}}");
00085
00086 TauPhotonsN = dbe->book1D("TauPhotonsN","Photons radiating from tau", 2 ,0,2);
00087 TauPhotonsN->setBinLabel(1,"Number of taus");
00088 TauPhotonsN->setBinLabel(2,"Number of taus radiating photons");
00089 TauPhotonsPt = dbe->book1D("TauPhotonsPt","Photon pt radiating from tau", 2 ,0,2);
00090 TauPhotonsPt->setBinLabel(1,"Sum of tau pt");
00091 TauPhotonsPt->setBinLabel(2,"Sum of tau pt radiated by photons");
00092
00093
00094 JAKID =dbe->book1D("JAKID","JAK ID",NJAKID+1,-0.5,NJAKID+0.5);
00095 for(unsigned int i=0; i<NJAKID+1;i++){
00096 JAKInvMass.push_back(std::vector<MonitorElement *>());
00097 TString tmp="JAKID";
00098 tmp+=i;
00099 JAKInvMass.at(i).push_back(dbe->book1D("M"+tmp,"M_{"+tmp+"} (GeV)", 80 ,0,2.0));
00100 if(i==TauDecay::JAK_A1_3PI ||
00101 i==TauDecay::JAK_KPIK ||
00102 i==TauDecay::JAK_KPIPI ){
00103 JAKInvMass.at(i).push_back(dbe->book1D("M13"+tmp,"M_{13,"+tmp+"} (GeV)", 80 ,0,2.0));
00104 JAKInvMass.at(i).push_back(dbe->book1D("M23"+tmp,"M_{23,"+tmp+"} (GeV)", 80 ,0,2.0));
00105 JAKInvMass.at(i).push_back(dbe->book1D("M12"+tmp,"M_{12,"+tmp+"} (GeV)", 80 ,0,2.0));
00106 }
00107 }
00108 }
00109
00110 return;
00111 }
00112
00113 void TauValidation::endJob(){
00114 return;
00115 }
00116
00117 void TauValidation::beginRun(const edm::Run& iRun,const edm::EventSetup& iSetup)
00118 {
00120 iSetup.getData( fPDGTable );
00121 return;
00122 }
00123 void TauValidation::endRun(const edm::Run& iRun,const edm::EventSetup& iSetup){return;}
00124 void TauValidation::analyze(const edm::Event& iEvent,const edm::EventSetup& iSetup)
00125 {
00126
00128 edm::Handle<HepMCProduct> evt;
00129 iEvent.getByLabel(hepmcCollection_, evt);
00130
00131
00132 HepMC::GenEvent *myGenEvent = new HepMC::GenEvent(*(evt->GetEvent()));
00133
00134 double weight = _wmanager.weight(iEvent);
00135
00136
00137 nEvt->Fill(0.5,weight);
00138
00139
00140 for(HepMC::GenEvent::particle_const_iterator iter = myGenEvent->particles_begin(); iter != myGenEvent->particles_end(); ++iter) {
00141 if(abs((*iter)->pdg_id())==15){
00142 if(tauMother(*iter,weight)!=-1){
00143 TauPt->Fill((*iter)->momentum().perp(),weight);
00144 TauEta->Fill((*iter)->momentum().eta(),weight);
00145 TauPhi->Fill((*iter)->momentum().phi(),weight);
00146 int mother = tauMother(*iter,weight);
00147 int decaychannel = tauDecayChannel(*iter,weight);
00148 tauProngs(*iter, weight);
00149 rtau(*iter,mother,decaychannel,weight);
00150 spinEffects(*iter,mother,decaychannel,weight);
00151 photons(*iter,weight);
00152 }
00153 if(abs((*iter)->pdg_id())==23){
00154 spinEffectsZ(*iter,weight);
00155 }
00157
00158
00159 TauDecay_CMSSW TD;
00160 unsigned int jak_id, TauBitMask;
00161 TD.AnalyzeTau((*iter),jak_id,TauBitMask,false,false);
00162 JAKID->Fill(jak_id,weight);
00163 if(jak_id<=NJAKID){
00164 int tcharge=(*iter)->pdg_id()/abs((*iter)->pdg_id());
00165 std::vector<HepMC::GenParticle*> part=TD.Get_TauDecayProducts();
00166 TLorentzVector LVQ(0,0,0,0);
00167 TLorentzVector LVS12(0,0,0,0);
00168 TLorentzVector LVS13(0,0,0,0);
00169 TLorentzVector LVS23(0,0,0,0);
00170 bool haspart1=false;
00171 for(unsigned int i=0;i<part.size();i++){
00172 if(TD.isTauFinalStateParticle(part.at(i)->pdg_id()) &&
00173 abs(part.at(i)->pdg_id())!=PdtPdgMini::nu_e &&
00174 abs(part.at(i)->pdg_id())!=PdtPdgMini::nu_mu &&
00175 abs(part.at(i)->pdg_id())!=PdtPdgMini::nu_tau ){
00176 TLorentzVector LV(part.at(i)->momentum().px(),part.at(i)->momentum().py(),part.at(i)->momentum().pz(),part.at(i)->momentum().e());
00177 LVQ+=LV;
00178 if(jak_id==TauDecay::JAK_A1_3PI ||
00179 jak_id==TauDecay::JAK_KPIK ||
00180 jak_id==TauDecay::JAK_KPIPI
00181 ){
00182 if((tcharge==part.at(i)->pdg_id()/abs(part.at(i)->pdg_id()) && TD.nProng(TauBitMask)==3) || (jak_id==TauDecay::JAK_A1_3PI && TD.nProng(TauBitMask)==1 && abs(part.at(i)->pdg_id())==PdtPdgMini::pi_plus) ){
00183 LVS13+=LV;
00184 LVS23+=LV;
00185 }
00186 else{
00187 LVS12+=LV;
00188 if(!haspart1 && ((jak_id==TauDecay::JAK_A1_3PI) || (jak_id!=TauDecay::JAK_A1_3PI && abs(part.at(i)->pdg_id())==PdtPdgMini::K_plus) )){
00189 LVS13+=LV;
00190 haspart1=true;
00191 }
00192 else{
00193 LVS23+=LV;
00194 }
00195 }
00196 }
00197 }
00198 }
00199 part.clear();
00200 JAKInvMass.at(jak_id).at(0)->Fill(LVQ.M(),weight);
00201 if(jak_id==TauDecay::JAK_A1_3PI ||
00202 jak_id==TauDecay::JAK_KPIK ||
00203 jak_id==TauDecay::JAK_KPIPI
00204 ){
00205 JAKInvMass.at(jak_id).at(1)->Fill(LVS13.M(),weight);
00206 JAKInvMass.at(jak_id).at(2)->Fill(LVS23.M(),weight);
00207 JAKInvMass.at(jak_id).at(3)->Fill(LVS12.M(),weight);
00208 }
00209 }
00210 }
00211 }
00212 delete myGenEvent;
00213 }
00214
00215 int TauValidation::findMother(const HepMC::GenParticle* tau){
00216 int mother_pid = 0;
00217
00218 if ( tau->production_vertex() ) {
00219 HepMC::GenVertex::particle_iterator mother;
00220 for (mother = tau->production_vertex()->particles_begin(HepMC::parents);
00221 mother!= tau->production_vertex()->particles_end(HepMC::parents); ++mother ) {
00222 mother_pid = (*mother)->pdg_id();
00223 if(mother_pid == tau->pdg_id()) mother_pid = -1;
00224
00225 }
00226 }
00227 return mother_pid;
00228 }
00229
00230 int TauValidation::tauMother(const HepMC::GenParticle* tau, double weight){
00231
00232 if(abs(tau->pdg_id()) != 15 ) return -1;
00233
00234 int mother_pid = findMother(tau);
00235 if(mother_pid == -1) return -1;
00236
00237 int label = other;
00238 if(abs(mother_pid) == 24) label = W;
00239 if(abs(mother_pid) == 23) label = Z;
00240 if(abs(mother_pid) == 22) label = gamma;
00241 if(abs(mother_pid) == 25) label = HSM;
00242 if(abs(mother_pid) == 35) label = H0;
00243 if(abs(mother_pid) == 36) label = A0;
00244 if(abs(mother_pid) == 37) label = Hpm;
00245
00246 int mother_shortpid=(abs(mother_pid)%10000);
00247 if(mother_shortpid>500 && mother_shortpid<600 )label = B;
00248 if(mother_shortpid>400 && mother_shortpid<500)label = D;
00249 TauMothers->Fill(label,weight);
00250 if(label==B || label == D || label == other) return -1;
00251
00252 return mother_pid;
00253 }
00254
00255 int TauValidation::tauProngs(const HepMC::GenParticle* tau, double weight){
00256
00257 int nProngs = 0;
00258 if ( tau->end_vertex() ) {
00259 HepMC::GenVertex::particle_iterator des;
00260 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00261 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00262 int pid = (*des)->pdg_id();
00263 if(abs(pid) == 15) return tauProngs(*des, weight);
00264 if((*des)->status() != 1) continue;
00265
00266 const HepPDT::ParticleData* pd = fPDGTable->particle((*des)->pdg_id ());
00267 int charge = (int) pd->charge();
00268 if(charge == 0) continue;
00269
00270
00271
00272 nProngs++;
00273 }
00274 }
00275 TauProngs->Fill(nProngs,weight);
00276 return nProngs;
00277 }
00278
00279 int TauValidation::findTauDecayChannel(const HepMC::GenParticle* tau){
00280
00281 int channel = undetermined;
00282 if(tau->status() == 1) channel = stable;
00283
00284 int allCount = 0,
00285 eCount = 0,
00286 muCount = 0,
00287 pi0Count = 0,
00288 piCount = 0,
00289 rhoCount = 0,
00290 a1Count = 0,
00291 KCount = 0,
00292 KstarCount = 0;
00293
00294 if ( tau->end_vertex() ) {
00295 HepMC::GenVertex::particle_iterator des;
00296 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00297 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00298
00299
00300 int pid = (*des)->pdg_id();
00301
00302
00303
00304
00305 if(abs(pid) == 15) return findTauDecayChannel(*des);
00306
00307 allCount++;
00308 if(abs(pid) == 11) eCount++;
00309 if(abs(pid) == 13) muCount++;
00310 if(abs(pid) == 111) pi0Count++;
00311 if(abs(pid) == 211) piCount++;
00312 if(abs(pid) == 213) rhoCount++;
00313 if(abs(pid) == 20213) a1Count++;
00314 if(abs(pid) == 321) KCount++;
00315 if(abs(pid) == 323) KstarCount++;
00316
00317 }
00318 }
00319
00320 if(KCount == 1 && allCount == 2) channel = K;
00321 if(KstarCount == 1 && allCount == 2) channel = Kstar;
00322 if(a1Count == 1 && allCount == 2) channel = a1;
00323 if(rhoCount == 1 && allCount == 2) channel = rho;
00324
00325 if(piCount == 1 && pi0Count == 0) channel = pi;
00326 if(piCount == 1 && pi0Count == 1) channel = pi1pi0;
00327 if(piCount == 1 && pi0Count > 1) channel = pinpi0;
00328
00329 if(piCount == 3 && pi0Count == 0) channel = tripi;
00330
00331
00332 if(eCount == 1) channel = electron;
00333 if(muCount == 1) channel = muon;
00334
00335 return channel;
00336 }
00337
00338 int TauValidation::tauDecayChannel(const HepMC::GenParticle* tau, double weight){
00339 int channel = findTauDecayChannel(tau);
00340 TauDecayChannels->Fill(channel,weight);
00341 return channel;
00342 }
00343
00344 void TauValidation::rtau(const HepMC::GenParticle* tau,int mother, int decay, double weight){
00345
00346 if(decay != pi1pi0) return;
00347
00348 if(tau->momentum().perp() < tauEtCut) return;
00349
00350 double rTau = 0;
00351 double ltrack = leadingPionMomentum(tau, weight);
00352 double visibleTauE = visibleTauEnergy(tau);
00353
00354 if(visibleTauE != 0) rTau = ltrack/visibleTauE;
00355
00356 if(abs(mother) == 24) TauRtauW->Fill(rTau,weight);
00357 if(abs(mother) == 37) TauRtauHpm->Fill(rTau,weight);
00358 }
00359
00360 void TauValidation::spinEffects(const HepMC::GenParticle* tau,int mother, int decay, double weight){
00361
00362 if(decay != pi) return;
00363
00364 TLorentzVector momP4 = motherP4(tau);
00365 TLorentzVector pionP4 = leadingPionP4(tau);
00366
00367 pionP4.Boost(-1*momP4.BoostVector());
00368
00369 double energy = pionP4.E()/(momP4.M()/2);
00370
00371 if(abs(mother) == 24) TauSpinEffectsW->Fill(energy,weight);
00372 if(abs(mother) == 37) TauSpinEffectsHpm->Fill(energy,weight);
00373 }
00374
00375 void TauValidation::spinEffectsZ(const HepMC::GenParticle* boson, double weight){
00376
00377 TLorentzVector tautau(0,0,0,0);
00378 TLorentzVector pipi(0,0,0,0);
00379
00380 int nSinglePionDecays = 0;
00381 if ( boson->end_vertex() ) {
00382 HepMC::GenVertex::particle_iterator des;
00383 for(des = boson->end_vertex()->particles_begin(HepMC::descendants);
00384 des!= boson->end_vertex()->particles_end(HepMC::descendants);++des ) {
00385
00386 int pid = (*des)->pdg_id();
00387
00388
00389
00390
00391
00392
00393 if(abs(findMother(*des)) != 15 &&
00394 abs(pid) == 15 && findTauDecayChannel(*des) == pi){
00395 nSinglePionDecays++;
00396 tautau += TLorentzVector((*des)->momentum().px(),
00397 (*des)->momentum().py(),
00398 (*des)->momentum().pz(),
00399 (*des)->momentum().e());
00400 pipi += leadingPionP4(*des);
00401 }
00402 }
00403 }
00404 if(nSinglePionDecays == 2 && tautau.M() != 0) {
00405 TauSpinEffectsZ->Fill(pipi.M()/tautau.M(),weight);
00406 }
00407 }
00408
00409 double TauValidation::leadingPionMomentum(const HepMC::GenParticle* tau, double weight){
00410 return leadingPionP4(tau).P();
00411 }
00412
00413 TLorentzVector TauValidation::leadingPionP4(const HepMC::GenParticle* tau){
00414
00415 TLorentzVector p4(0,0,0,0);
00416
00417 if ( tau->end_vertex() ) {
00418 HepMC::GenVertex::particle_iterator des;
00419 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00420 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00421 int pid = (*des)->pdg_id();
00422
00423 if(abs(pid) == 15) return leadingPionP4(*des);
00424
00425 if(abs(pid) != 211) continue;
00426
00427 if((*des)->momentum().rho() > p4.P()) {
00428 p4 = TLorentzVector((*des)->momentum().px(),
00429 (*des)->momentum().py(),
00430 (*des)->momentum().pz(),
00431 (*des)->momentum().e());
00432 }
00433 }
00434 }
00435
00436 return p4;
00437 }
00438
00439 TLorentzVector TauValidation::motherP4(const HepMC::GenParticle* tau){
00440
00441 TLorentzVector p4(0,0,0,0);
00442
00443 if ( tau->production_vertex() ) {
00444 HepMC::GenVertex::particle_iterator mother;
00445 for (mother = tau->production_vertex()->particles_begin(HepMC::parents);
00446 mother!= tau->production_vertex()->particles_end(HepMC::parents); ++mother ) {
00447
00448
00449 p4 = TLorentzVector((*mother)->momentum().px(),
00450 (*mother)->momentum().py(),
00451 (*mother)->momentum().pz(),
00452 (*mother)->momentum().e());
00453 }
00454 }
00455
00456 return p4;
00457 }
00458
00459 double TauValidation::visibleTauEnergy(const HepMC::GenParticle* tau){
00460 TLorentzVector p4(tau->momentum().px(),
00461 tau->momentum().py(),
00462 tau->momentum().pz(),
00463 tau->momentum().e());
00464
00465 if ( tau->end_vertex() ) {
00466 HepMC::GenVertex::particle_iterator des;
00467 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00468 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00469 int pid = (*des)->pdg_id();
00470
00471 if(abs(pid) == 15) return visibleTauEnergy(*des);
00472
00473 if(abs(pid) == 12 || abs(pid) == 14 || abs(pid) == 16) {
00474 p4 -= TLorentzVector((*des)->momentum().px(),
00475 (*des)->momentum().py(),
00476 (*des)->momentum().pz(),
00477 (*des)->momentum().e());
00478 }
00479 }
00480 }
00481
00482 return p4.E();
00483 }
00484
00485 void TauValidation::photons(const HepMC::GenParticle* tau, double weight){
00486
00487 if ( tau->end_vertex() ) {
00488 double photonFromTauPtSum = 0;
00489 bool photonFromTau = false;
00490 HepMC::GenVertex::particle_iterator des;
00491 for(des = tau->end_vertex()->particles_begin(HepMC::descendants);
00492 des!= tau->end_vertex()->particles_end(HepMC::descendants);++des ) {
00493 int pid = (*des)->pdg_id();
00494 if(pid == 22) {
00495 photonFromTauPtSum += (*des)->momentum().perp();
00496 photonFromTau = true;
00497 }
00498 }
00499
00500 TauPhotonsN->Fill(0.5,weight);
00501
00502 TauPhotonsPt->Fill(0.5,tau->momentum().perp());
00503 if(photonFromTau) {
00504 TauPhotonsN->Fill(1.5,weight);
00505
00506 TauPhotonsPt->Fill(1.5,photonFromTauPtSum);
00507 }
00508 }
00509 }
00510