Changes in modules/TreeWriter.cc [341014c:0e0f211] in git
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/TreeWriter.cc
r341014c r0e0f211 17 17 */ 18 18 19 19 20 /** \class TreeWriter 20 21 * … … 31 32 #include "classes/DelphesFormula.h" 32 33 34 #include "ExRootAnalysis/ExRootResult.h" 35 #include "ExRootAnalysis/ExRootFilter.h" 33 36 #include "ExRootAnalysis/ExRootClassifier.h" 34 #include "ExRootAnalysis/ExRootFilter.h"35 #include "ExRootAnalysis/ExRootResult.h"36 37 #include "ExRootAnalysis/ExRootTreeBranch.h" 37 38 39 #include "TROOT.h" 40 #include "TMath.h" 41 #include "TString.h" 42 #include "TFormula.h" 43 #include "TRandom3.h" 44 #include "TObjArray.h" 38 45 #include "TDatabasePDG.h" 39 #include "TFormula.h"40 46 #include "TLorentzVector.h" 41 #include "TMath.h"42 #include "TObjArray.h"43 #include "TROOT.h"44 #include "TRandom3.h"45 #include "TString.h"46 47 47 48 #include <algorithm> 49 #include <stdexcept> 48 50 #include <iostream> 49 51 #include <sstream> 50 #include <stdexcept>51 52 52 53 using namespace std; … … 83 84 84 85 TBranchMap::iterator itBranchMap; 85 map< TClass *, TProcessMethod>::iterator itClassMap;86 map< TClass *, TProcessMethod >::iterator itClassMap; 86 87 87 88 // read branch configuration and … … 96 97 97 98 size = param.GetSize(); 98 for(i = 0; i < size /3; ++i)99 { 100 branchInputArray = param[i *3].GetString();101 branchName = param[i *3 + 1].GetString();102 branchClassName = param[i *3 + 2].GetString();99 for(i = 0; i < size/3; ++i) 100 { 101 branchInputArray = param[i*3].GetString(); 102 branchName = param[i*3 + 1].GetString(); 103 branchClassName = param[i*3 + 2].GetString(); 103 104 104 105 branchClass = gROOT->GetClass(branchClassName); … … 122 123 fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array))); 123 124 } 125 124 126 } 125 127 … … 137 139 it1.Reset(); 138 140 array->Clear(); 139 while((candidate = static_cast<Candidate 141 while((candidate = static_cast<Candidate*>(it1.Next()))) 140 142 { 141 143 TIter it2(candidate->GetCandidates()); … … 149 151 150 152 // track 151 candidate = static_cast<Candidate 153 candidate = static_cast<Candidate*>(candidate->GetCandidates()->At(0)); 152 154 if(candidate->GetCandidates()->GetEntriesFast() == 0) 153 155 { … … 158 160 // tower 159 161 it2.Reset(); 160 while((candidate = static_cast<Candidate 162 while((candidate = static_cast<Candidate*>(it2.Next()))) 161 163 { 162 164 array->Add(candidate->GetCandidates()->At(0)); … … 178 180 // loop over all particles 179 181 iterator.Reset(); 180 while((candidate = static_cast<Candidate 182 while((candidate = static_cast<Candidate*>(iterator.Next()))) 181 183 { 182 184 const TLorentzVector &momentum = candidate->Momentum; 183 185 const TLorentzVector &position = candidate->Position; 184 186 185 entry = static_cast<GenParticle 187 entry = static_cast<GenParticle*>(branch->NewEntry()); 186 188 187 189 entry->SetBit(kIsReferenced); … … 191 193 cosTheta = TMath::Abs(momentum.CosTheta()); 192 194 signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0; 193 eta = (cosTheta == 1.0 ? signPz *999.9 : momentum.Eta());194 rapidity = (cosTheta == 1.0 ? signPz *999.9 : momentum.Rapidity());195 eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta()); 196 rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity()); 195 197 196 198 entry->PID = candidate->PID; … … 213 215 entry->Pz = momentum.Pz(); 214 216 215 entry->D0 = candidate->D0;216 entry->DZ = candidate->DZ;217 entry->P = candidate->P;218 entry->PT = candidate->PT;219 entry->CtgTheta = candidate->CtgTheta;220 entry->Phi = candidate->Phi;217 entry->D0 = candidate->D0; 218 entry->DZ = candidate->DZ; 219 entry->P = candidate->P; 220 entry->PT = candidate->PT; 221 entry->CtgTheta = candidate->CtgTheta; 222 entry->Phi = candidate->Phi; 221 223 222 224 entry->Eta = eta; … … 229 231 entry->Y = position.Y(); 230 232 entry->Z = position.Z(); 231 entry->T = position.T() * 1.0E-3 /c_light;233 entry->T = position.T()*1.0E-3/c_light; 232 234 } 233 235 } … … 253 255 // loop over all vertices 254 256 iterator.Reset(); 255 while((candidate = static_cast<Candidate 257 while((candidate = static_cast<Candidate*>(iterator.Next()))) 256 258 { 257 259 … … 267 269 y = candidate->Position.Y(); 268 270 z = candidate->Position.Z(); 269 t = candidate->Position.T() * 1.0E-3 /c_light;270 271 xError = candidate->PositionError.X ();272 yError = candidate->PositionError.Y ();273 zError = candidate->PositionError.Z ();274 tError = candidate->PositionError.T () * 1.0E-3 /c_light;275 276 entry = static_cast<Vertex 271 t = candidate->Position.T()*1.0E-3/c_light; 272 273 xError = candidate->PositionError.X (); 274 yError = candidate->PositionError.Y (); 275 zError = candidate->PositionError.Z (); 276 tError = candidate->PositionError.T ()*1.0E-3/c_light; 277 278 entry = static_cast<Vertex*>(branch->NewEntry()); 277 279 278 280 entry->Index = index; … … 294 296 entry->ErrorT = tError; 295 297 298 296 299 TIter itConstituents(candidate->GetCandidates()); 297 300 itConstituents.Reset(); 298 301 entry->Constituents.Clear(); 299 while((constituent = static_cast<Candidate 302 while((constituent = static_cast<Candidate*>(itConstituents.Next()))) 300 303 { 301 304 entry->Constituents.Add(constituent); 302 305 } 303 } 304 } 306 307 } 308 } 309 305 310 306 311 //------------------------------------------------------------------------------ … … 317 322 // loop over all tracks 318 323 iterator.Reset(); 319 while((candidate = static_cast<Candidate 324 while((candidate = static_cast<Candidate*>(iterator.Next()))) 320 325 { 321 326 const TLorentzVector &position = candidate->Position; … … 323 328 cosTheta = TMath::Abs(position.CosTheta()); 324 329 signz = (position.Pz() >= 0.0) ? 1.0 : -1.0; 325 eta = (cosTheta == 1.0 ? signz *999.9 : position.Eta());326 rapidity = (cosTheta == 1.0 ? signz *999.9 : position.Rapidity());327 328 entry = static_cast<Track 330 eta = (cosTheta == 1.0 ? signz*999.9 : position.Eta()); 331 rapidity = (cosTheta == 1.0 ? signz*999.9 : position.Rapidity()); 332 333 entry = static_cast<Track*>(branch->NewEntry()); 329 334 330 335 entry->SetBit(kIsReferenced); … … 341 346 entry->YOuter = position.Y(); 342 347 entry->ZOuter = position.Z(); 343 entry->TOuter = position.T() * 1.0E-3 /c_light;348 entry->TOuter = position.T()*1.0E-3/c_light; 344 349 345 350 entry->L = candidate->L; 346 351 347 entry->D0 = candidate->D0;348 entry->ErrorD0 = candidate->ErrorD0;349 entry->DZ = candidate->DZ;350 entry->ErrorDZ = candidate->ErrorDZ;351 352 entry->ErrorP = candidate->ErrorP;353 entry->ErrorPT = candidate->ErrorPT;352 entry->D0 = candidate->D0; 353 entry->ErrorD0 = candidate->ErrorD0; 354 entry->DZ = candidate->DZ; 355 entry->ErrorDZ = candidate->ErrorDZ; 356 357 entry->ErrorP = candidate->ErrorP; 358 entry->ErrorPT = candidate->ErrorPT; 354 359 entry->ErrorCtgTheta = candidate->ErrorCtgTheta; 355 entry->ErrorPhi = candidate->ErrorPhi;360 entry->ErrorPhi = candidate->ErrorPhi; 356 361 357 362 entry->Xd = candidate->Xd; … … 364 369 p = momentum.P(); 365 370 phi = momentum.Phi(); 366 ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1 /TMath::Tan(momentum.Theta()) : 1e10;371 ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1/TMath::Tan(momentum.Theta()) : 1e10; 367 372 368 373 cosTheta = TMath::Abs(momentum.CosTheta()); 369 374 signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0; 370 eta = (cosTheta == 1.0 ? signz *999.9 : momentum.Eta());371 rapidity = (cosTheta == 1.0 ? signz *999.9 : momentum.Rapidity());375 eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta()); 376 rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity()); 372 377 373 378 entry->P = p; 374 entry->PT = pt;379 entry->PT = pt; 375 380 entry->Eta = eta; 376 381 entry->Phi = phi; 377 382 entry->CtgTheta = ctgTheta; 378 383 379 particle = static_cast<Candidate 384 particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0)); 380 385 const TLorentzVector &initialPosition = particle->Position; 381 386 … … 383 388 entry->Y = initialPosition.Y(); 384 389 entry->Z = initialPosition.Z(); 385 entry->T = initialPosition.T() * 1.0E-3 /c_light;390 entry->T = initialPosition.T()*1.0E-3/c_light; 386 391 387 392 entry->Particle = particle; 388 393 389 394 entry->VertexIndex = candidate->ClusterIndex; 395 390 396 } 391 397 } … … 403 409 // loop over all towers 404 410 iterator.Reset(); 405 while((candidate = static_cast<Candidate 411 while((candidate = static_cast<Candidate*>(iterator.Next()))) 406 412 { 407 413 const TLorentzVector &momentum = candidate->Momentum; … … 411 417 cosTheta = TMath::Abs(momentum.CosTheta()); 412 418 signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0; 413 eta = (cosTheta == 1.0 ? signPz *999.9 : momentum.Eta());414 rapidity = (cosTheta == 1.0 ? signPz *999.9 : momentum.Rapidity());415 416 entry = static_cast<Tower 419 eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta()); 420 rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity()); 421 422 entry = static_cast<Tower*>(branch->NewEntry()); 417 423 418 424 entry->SetBit(kIsReferenced); … … 430 436 entry->Edges[3] = candidate->Edges[3]; 431 437 432 entry->T = position.T() * 1.0E-3 /c_light;438 entry->T = position.T()*1.0E-3/c_light; 433 439 entry->NTimeHits = candidate->NTimeHits; 434 440 … … 451 457 // loop over all photons 452 458 iterator.Reset(); 453 while((candidate = static_cast<Candidate 459 while((candidate = static_cast<Candidate*>(iterator.Next()))) 454 460 { 455 461 TIter it1(candidate->GetCandidates()); … … 460 466 cosTheta = TMath::Abs(momentum.CosTheta()); 461 467 signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0; 462 eta = (cosTheta == 1.0 ? signPz *999.9 : momentum.Eta());463 rapidity = (cosTheta == 1.0 ? signPz *999.9 : momentum.Rapidity());464 465 entry = static_cast<Photon 468 eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta()); 469 rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity()); 470 471 entry = static_cast<Photon*>(branch->NewEntry()); 466 472 467 473 entry->Eta = eta; … … 469 475 entry->PT = pt; 470 476 entry->E = momentum.E(); 471 entry->T = position.T() * 1.0E-3 /c_light;477 entry->T = position.T()*1.0E-3/c_light; 472 478 473 479 // Isolation variables 474 480 475 481 entry->IsolationVar = candidate->IsolationVar; 476 entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;477 entry->SumPtCharged = candidate->SumPtCharged ;478 entry->SumPtNeutral = candidate->SumPtNeutral ;479 entry->SumPtChargedPU = candidate->SumPtChargedPU ;480 entry->SumPt = candidate->SumPt ;481 482 entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad /candidate->Eem : 999.9;482 entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ; 483 entry->SumPtCharged = candidate->SumPtCharged ; 484 entry->SumPtNeutral = candidate->SumPtNeutral ; 485 entry->SumPtChargedPU = candidate->SumPtChargedPU ; 486 entry->SumPt = candidate->SumPt ; 487 488 entry->EhadOverEem = candidate->Eem > 0.0 ? candidate->Ehad/candidate->Eem : 999.9; 483 489 484 490 // 1: prompt -- 2: non prompt -- 3: fake … … 503 509 // loop over all electrons 504 510 iterator.Reset(); 505 while((candidate = static_cast<Candidate 511 while((candidate = static_cast<Candidate*>(iterator.Next()))) 506 512 { 507 513 const TLorentzVector &momentum = candidate->Momentum; … … 511 517 cosTheta = TMath::Abs(momentum.CosTheta()); 512 518 signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0; 513 eta = (cosTheta == 1.0 ? signPz *999.9 : momentum.Eta());514 rapidity = (cosTheta == 1.0 ? signPz *999.9 : momentum.Rapidity());515 516 entry = static_cast<Electron 519 eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta()); 520 rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity()); 521 522 entry = static_cast<Electron*>(branch->NewEntry()); 517 523 518 524 entry->Eta = eta; … … 520 526 entry->PT = pt; 521 527 522 entry->T = position.T() * 1.0E-3 / c_light; 523 524 // displacement 525 entry->D0 = candidate->D0; 526 entry->ErrorD0 = candidate->ErrorD0; 527 entry->DZ = candidate->DZ; 528 entry->ErrorDZ = candidate->ErrorDZ; 528 entry->T = position.T()*1.0E-3/c_light; 529 529 530 530 // Isolation variables 531 531 532 entry->IsolationVar = candidate->IsolationVar; 532 entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr; 533 entry->SumPtCharged = candidate->SumPtCharged; 534 entry->SumPtNeutral = candidate->SumPtNeutral; 535 entry->SumPtChargedPU = candidate->SumPtChargedPU; 536 entry->SumPt = candidate->SumPt; 533 entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ; 534 entry->SumPtCharged = candidate->SumPtCharged ; 535 entry->SumPtNeutral = candidate->SumPtNeutral ; 536 entry->SumPtChargedPU = candidate->SumPtChargedPU ; 537 entry->SumPt = candidate->SumPt ; 538 537 539 538 540 entry->Charge = candidate->Charge; … … 559 561 // loop over all muons 560 562 iterator.Reset(); 561 while((candidate = static_cast<Candidate 563 while((candidate = static_cast<Candidate*>(iterator.Next()))) 562 564 { 563 565 const TLorentzVector &momentum = candidate->Momentum; … … 567 569 cosTheta = TMath::Abs(momentum.CosTheta()); 568 570 signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0; 569 eta = (cosTheta == 1.0 ? signPz *999.9 : momentum.Eta());570 rapidity = (cosTheta == 1.0 ? signPz *999.9 : momentum.Rapidity());571 572 entry = static_cast<Muon 571 eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta()); 572 rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity()); 573 574 entry = static_cast<Muon*>(branch->NewEntry()); 573 575 574 576 entry->SetBit(kIsReferenced); … … 579 581 entry->PT = pt; 580 582 581 entry->T = position.T() * 1.0E-3 / c_light; 582 583 // displacement 584 entry->D0 = candidate->D0; 585 entry->ErrorD0 = candidate->ErrorD0; 586 entry->DZ = candidate->DZ; 587 entry->ErrorDZ = candidate->ErrorDZ; 583 entry->T = position.T()*1.0E-3/c_light; 588 584 589 585 // Isolation variables 590 586 591 587 entry->IsolationVar = candidate->IsolationVar; 592 entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ;593 entry->SumPtCharged = candidate->SumPtCharged ;594 entry->SumPtNeutral = candidate->SumPtNeutral ;595 entry->SumPtChargedPU = candidate->SumPtChargedPU ;596 entry->SumPt = candidate->SumPt ;588 entry->IsolationVarRhoCorr = candidate->IsolationVarRhoCorr ; 589 entry->SumPtCharged = candidate->SumPtCharged ; 590 entry->SumPtNeutral = candidate->SumPtNeutral ; 591 entry->SumPtChargedPU = candidate->SumPtChargedPU ; 592 entry->SumPt = candidate->SumPt ; 597 593 598 594 entry->Charge = candidate->Charge; … … 618 614 // loop over all jets 619 615 iterator.Reset(); 620 while((candidate = static_cast<Candidate 616 while((candidate = static_cast<Candidate*>(iterator.Next()))) 621 617 { 622 618 TIter itConstituents(candidate->GetCandidates()); … … 628 624 cosTheta = TMath::Abs(momentum.CosTheta()); 629 625 signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0; 630 eta = (cosTheta == 1.0 ? signPz *999.9 : momentum.Eta());631 rapidity = (cosTheta == 1.0 ? signPz *999.9 : momentum.Rapidity());632 633 entry = static_cast<Jet 626 eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta()); 627 rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity()); 628 629 entry = static_cast<Jet*>(branch->NewEntry()); 634 630 635 631 entry->Eta = eta; … … 637 633 entry->PT = pt; 638 634 639 entry->T = position.T() * 1.0E-3 /c_light;635 entry->T = position.T()*1.0E-3/c_light; 640 636 641 637 entry->Mass = momentum.M(); … … 656 652 657 653 entry->TauTag = candidate->TauTag; 658 entry->TauWeight = candidate->TauWeight;659 654 660 655 entry->Charge = candidate->Charge; … … 664 659 ecalEnergy = 0.0; 665 660 hcalEnergy = 0.0; 666 while((constituent = static_cast<Candidate 661 while((constituent = static_cast<Candidate*>(itConstituents.Next()))) 667 662 { 668 663 entry->Constituents.Add(constituent); … … 671 666 } 672 667 673 entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy /ecalEnergy : 999.9;668 entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9; 674 669 675 670 //--- Pile-Up Jet ID variables ---- … … 688 683 entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped; 689 684 690 entry->SoftDroppedJet = candidate->SoftDroppedJet;691 entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1 ;685 entry->SoftDroppedJet = candidate->SoftDroppedJet ; 686 entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1 ; 692 687 entry->SoftDroppedSubJet2 = candidate->SoftDroppedSubJet2; 688 693 689 694 690 for(i = 0; i < 5; i++) 695 691 { 696 entry->FracPt[i] = candidate ->FracPt[i];697 entry->Tau[i] = candidate ->Tau[i];698 entry->TrimmedP4[i] = candidate ->TrimmedP4[i];699 entry->PrunedP4[i] = candidate ->PrunedP4[i];700 entry->SoftDroppedP4[i] = candidate ->SoftDroppedP4[i];692 entry->FracPt[i] = candidate -> FracPt[i]; 693 entry->Tau[i] = candidate -> Tau[i]; 694 entry->TrimmedP4[i] = candidate -> TrimmedP4[i]; 695 entry->PrunedP4[i] = candidate -> PrunedP4[i]; 696 entry->SoftDroppedP4[i] = candidate -> SoftDroppedP4[i]; 701 697 } 702 698 … … 705 701 entry->ExclYmerge34 = candidate->ExclYmerge34; 706 702 entry->ExclYmerge45 = candidate->ExclYmerge45; 707 entry->ExclYmerge56 = candidate->ExclYmerge56; 703 entry->ExclYmerge56 = candidate->ExclYmerge56; 704 708 705 709 706 FillParticles(candidate, &entry->Particles); … … 719 716 720 717 // get the first entry 721 if((candidate = static_cast<Candidate 722 { 723 const TLorentzVector &momentum = candidate->Momentum; 724 725 entry = static_cast<MissingET 718 if((candidate = static_cast<Candidate*>(array->At(0)))) 719 { 720 const TLorentzVector &momentum = candidate->Momentum; 721 722 entry = static_cast<MissingET*>(branch->NewEntry()); 726 723 727 724 entry->Eta = (-momentum).Eta(); … … 739 736 740 737 // get the first entry 741 if((candidate = static_cast<Candidate 742 { 743 const TLorentzVector &momentum = candidate->Momentum; 744 745 entry = static_cast<ScalarHT 738 if((candidate = static_cast<Candidate*>(array->At(0)))) 739 { 740 const TLorentzVector &momentum = candidate->Momentum; 741 742 entry = static_cast<ScalarHT*>(branch->NewEntry()); 746 743 747 744 entry->HT = momentum.Pt(); … … 759 756 // loop over all rho 760 757 iterator.Reset(); 761 while((candidate = static_cast<Candidate 762 { 763 const TLorentzVector &momentum = candidate->Momentum; 764 765 entry = static_cast<Rho 758 while((candidate = static_cast<Candidate*>(iterator.Next()))) 759 { 760 const TLorentzVector &momentum = candidate->Momentum; 761 762 entry = static_cast<Rho*>(branch->NewEntry()); 766 763 767 764 entry->Rho = momentum.E(); … … 779 776 780 777 // get the first entry 781 if((candidate = static_cast<Candidate 782 { 783 const TLorentzVector &momentum = candidate->Momentum; 784 785 entry = static_cast<Weight 778 if((candidate = static_cast<Candidate*>(array->At(0)))) 779 { 780 const TLorentzVector &momentum = candidate->Momentum; 781 782 entry = static_cast<Weight*>(branch->NewEntry()); 786 783 787 784 entry->Weight = momentum.E(); … … 799 796 // loop over all roman pot hits 800 797 iterator.Reset(); 801 while((candidate = static_cast<Candidate 798 while((candidate = static_cast<Candidate*>(iterator.Next()))) 802 799 { 803 800 const TLorentzVector &position = candidate->Position; 804 801 const TLorentzVector &momentum = candidate->Momentum; 805 802 806 entry = static_cast<HectorHit 803 entry = static_cast<HectorHit*>(branch->NewEntry()); 807 804 808 805 entry->E = momentum.E();
Note:
See TracChangeset
for help on using the changeset viewer.