| 1 |
|
|---|
| 2 | #include "modules/MadGraphShowerLeptonSelector.h"
|
|---|
| 3 |
|
|---|
| 4 | #include "modules/MadGraphParticleClassifier.h"
|
|---|
| 5 |
|
|---|
| 6 | #include "ExRootAnalysis/ExRootClasses.h"
|
|---|
| 7 | #include "ExRootAnalysis/ExRootFilter.h"
|
|---|
| 8 |
|
|---|
| 9 | #include "ExRootAnalysis/ExRootFactory.h"
|
|---|
| 10 | #include "ExRootAnalysis/ExRootCandidate.h"
|
|---|
| 11 |
|
|---|
| 12 | #include "TMath.h"
|
|---|
| 13 | #include "TString.h"
|
|---|
| 14 | #include "TLorentzVector.h"
|
|---|
| 15 | #include "TClonesArray.h"
|
|---|
| 16 |
|
|---|
| 17 | #include <iostream>
|
|---|
| 18 | #include <set>
|
|---|
| 19 |
|
|---|
| 20 | using namespace std;
|
|---|
| 21 |
|
|---|
| 22 | //------------------------------------------------------------------------------
|
|---|
| 23 |
|
|---|
| 24 | MadGraphShowerLeptonSelector::MadGraphShowerLeptonSelector() :
|
|---|
| 25 | fFilter(0), fClassifier(0)
|
|---|
| 26 | {
|
|---|
| 27 | }
|
|---|
| 28 |
|
|---|
| 29 | //------------------------------------------------------------------------------
|
|---|
| 30 |
|
|---|
| 31 | MadGraphShowerLeptonSelector::~MadGraphShowerLeptonSelector()
|
|---|
| 32 | {
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 | //------------------------------------------------------------------------------
|
|---|
| 36 |
|
|---|
| 37 | void MadGraphShowerLeptonSelector::Init()
|
|---|
| 38 | {
|
|---|
| 39 | TString className;
|
|---|
| 40 | ExRootConfParam param, classParticles;
|
|---|
| 41 |
|
|---|
| 42 | Int_t i, j, status, pid, sizeParam, sizeParticles;
|
|---|
| 43 |
|
|---|
| 44 | // import ROOT tree branch
|
|---|
| 45 |
|
|---|
| 46 | fBranchParticle = UseBranch("GenParticle");
|
|---|
| 47 |
|
|---|
| 48 | // create classifier and filter
|
|---|
| 49 |
|
|---|
| 50 | fClassifier = new MadGraphParticleClassifier();
|
|---|
| 51 | fFilter = new ExRootFilter(fBranchParticle);
|
|---|
| 52 |
|
|---|
| 53 | // read particle status from configuration file and setup classifier
|
|---|
| 54 |
|
|---|
| 55 | param = GetParam("ParticleStatus");
|
|---|
| 56 | sizeParam = param.GetSize();
|
|---|
| 57 |
|
|---|
| 58 | for(i = 0; i < sizeParam; ++i)
|
|---|
| 59 | {
|
|---|
| 60 | status = param[i].GetInt();
|
|---|
| 61 | fClassifier->InsertParticleStatus(status);
|
|---|
| 62 | }
|
|---|
| 63 |
|
|---|
| 64 | // read particle classes from configuration file and setup classifier
|
|---|
| 65 |
|
|---|
| 66 | param = GetParam("ClassParticles");
|
|---|
| 67 | sizeParam = param.GetSize();
|
|---|
| 68 |
|
|---|
| 69 | for(i = 0; i < sizeParam/2; ++i)
|
|---|
| 70 | {
|
|---|
| 71 | className = param[i*2].GetString();
|
|---|
| 72 | classParticles = param[i*2 + 1];
|
|---|
| 73 | sizeParticles = classParticles.GetSize();
|
|---|
| 74 |
|
|---|
| 75 | for(j = 0; j < sizeParticles; ++j)
|
|---|
| 76 | {
|
|---|
| 77 | pid = classParticles[j].GetInt();
|
|---|
| 78 | fClassifier->InsertClassPID(className, pid);
|
|---|
| 79 | }
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | fClassifier->SetExtendable(kFALSE);
|
|---|
| 83 |
|
|---|
| 84 | // create output arrays
|
|---|
| 85 |
|
|---|
| 86 | fOutputArray = ExportArray("candidates");
|
|---|
| 87 |
|
|---|
| 88 | }
|
|---|
| 89 |
|
|---|
| 90 | //------------------------------------------------------------------------------
|
|---|
| 91 |
|
|---|
| 92 | void MadGraphShowerLeptonSelector::Finish()
|
|---|
| 93 | {
|
|---|
| 94 | if(fFilter) delete fFilter;
|
|---|
| 95 | if(fClassifier) delete fClassifier;
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | //------------------------------------------------------------------------------
|
|---|
| 99 |
|
|---|
| 100 | void MadGraphShowerLeptonSelector::Process()
|
|---|
| 101 | {
|
|---|
| 102 | TObjArray *array = 0;
|
|---|
| 103 | ExRootGenParticle *parent = 0, *particle = 0;
|
|---|
| 104 | ExRootCandidate *candidate = 0;
|
|---|
| 105 | ExRootFactory *factory = GetFactory();
|
|---|
| 106 |
|
|---|
| 107 | Int_t category, entry;
|
|---|
| 108 | TString name;
|
|---|
| 109 | TLorentzVector momentum;
|
|---|
| 110 |
|
|---|
| 111 | fFilter->Reset();
|
|---|
| 112 |
|
|---|
| 113 | // make filter classify particles and fill all subarrays
|
|---|
| 114 | // at this point classifier creates additional/missing classes
|
|---|
| 115 | fFilter->GetSubArray(fClassifier, 0);
|
|---|
| 116 |
|
|---|
| 117 | // loop over all classes and export class names and classified particles
|
|---|
| 118 | for(category = 0; category < fClassifier->GetMaxCategories(); ++category)
|
|---|
| 119 | {
|
|---|
| 120 | array = fFilter->GetSubArray(fClassifier, category);
|
|---|
| 121 | name = fClassifier->GetCategoryClassName(category);
|
|---|
| 122 |
|
|---|
| 123 | if(array == 0) continue;
|
|---|
| 124 |
|
|---|
| 125 | // sort particles by PT
|
|---|
| 126 | ExRootGenParticle::fgCompare = ExRootComparePT<ExRootGenParticle>::Instance();
|
|---|
| 127 | array->Sort();
|
|---|
| 128 |
|
|---|
| 129 | entry = 1;
|
|---|
| 130 |
|
|---|
| 131 | TIter itArray(array);
|
|---|
| 132 |
|
|---|
| 133 | while(particle = static_cast<ExRootGenParticle*>(itArray.Next()))
|
|---|
| 134 | {
|
|---|
| 135 | if(particle->M1 < 0) continue;
|
|---|
| 136 |
|
|---|
| 137 | parent = static_cast<ExRootGenParticle*>(fBranchParticle->At(particle->M1));
|
|---|
| 138 |
|
|---|
| 139 | if(parent == 0 || parent->Status != 3) continue;
|
|---|
| 140 |
|
|---|
| 141 | momentum.SetPxPyPzE(particle->Px, particle->Py, particle->Pz, particle->E);
|
|---|
| 142 |
|
|---|
| 143 | candidate = factory->NewCandidate();
|
|---|
| 144 |
|
|---|
| 145 | candidate->SetP4(momentum);
|
|---|
| 146 | candidate->SetName(Form("%s_{%d}", name.Data(), entry ));
|
|---|
| 147 |
|
|---|
| 148 | fOutputArray->Add(candidate);
|
|---|
| 149 |
|
|---|
| 150 | ++entry;
|
|---|
| 151 | }
|
|---|
| 152 | }
|
|---|
| 153 | }
|
|---|
| 154 | //------------------------------------------------------------------------------
|
|---|
| 155 |
|
|---|