1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
bool user::Execute(SampleFormat& sample, const EventFormat& event)
{
if (event.rec()!=0)
{
Float_t a1, a2, a3, a4, a5, a6;
TLorentzVector tlvelec, tlvmu, tlvleptons, tlvleptonmax, tlvelecp, tlvelecn, tlvmup, tlvmun, tlvZ, tlvjetbtag, tlvmup1, tlvmup2, tlvmup3, tlvmun1, tlvmun2, tlvmun3, tlvelec1, tlvelec2, tlvelec3; //With TLorentzVector.h we can work with vectors of 4 dimensons, to know more about TlorentzVecor.h go here https://root.cern.ch/root/html/TLorentzVector.html
Float_t min = 81;
Float_t max = 102;
Float_t mz = 91.1876;
for (unsigned int i=0;i<event.rec()->electrons().size();i++)
{
const RecLeptonFormat& elec = event.rec()->electrons()[i]; //this array gives the 1, 2 or three electrons presented in the event (event.rec()).
tlvelec = elec.momentum() ; //function inside TLorentzVector.h
HistptELEC->Fill(tlvelec.Pt()); // same ^
if ( elec.charge() > 0 ) {
tlvelecp = tlvelec;
}
cout << "elec positive" << endl;
if ( elec.charge() < 0 ) {
tlvelecn = tlvelec;
cout << "elec negative" << endl;
}
}
for (unsigned int i=0;i<event.rec()->muons().size();i++)
{
const RecLeptonFormat& mu = event.rec()->muons()[i];
tlvmu = mu.momentum();
if ( mu.charge() > 0 ) { //tlvmup is the 4-vector of the muon with charge +1
tlvmup = mu.momentum();
cout << "mu positive" << endl;
}
if ( mu.charge() < 0 ) { //tlvmup is the 4-vector of the muon with charge -1
tlvmun = mu.momentum();
cout << "mu negative" << endl;
}
tlvelec = tlvelecp + tlvelecn; //sum of vectors
tlvmu = tlvmup + tlvmun;
if ( (tlvelec.Pt() > tlvmu.Pt()) )
{
tlvleptonmax = tlvelec ;
HistptLEPTONS->Fill(tlvleptonmax.Pt());
}
if ( (tlvmu.Pt() > tlvelec.Pt()) ) // Pt() is another function
{
tlvleptonmax = tlvmu ;
HistptLEPTONS->Fill(tlvleptonmax.Pt());
}
}
if ( (tlvleptons.M() > min) && (tlvleptons.M() < max) ) { //M is a function, so tlvleptons.M() is the value of mass of the 4-vector.
tlvZ = tlvleptons;
HistptZ-> Fill(tlvZ.Pt());
HistmZ-> Fill(tlvZ.M());
cout << "display pT(Z)" << tlvZ.Pt() << endl;
cout << "massa = " << tlvZ.M() << endl;
}
}
return true;
}
|