Fork me on GitHub

Changeset a5af1df in git for modules/TreeWriter.cc


Ignore:
Timestamp:
Dec 9, 2021, 7:38:54 AM (3 years ago)
Author:
christinaw97 <christina.wang@…>
Children:
d612dec
Parents:
a5ff49f
Message:

added CscCluster modules and classes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/TreeWriter.cc

    ra5ff49f ra5af1df  
    7575  fClassMap[Electron::Class()] = &TreeWriter::ProcessElectrons;
    7676  fClassMap[Muon::Class()] = &TreeWriter::ProcessMuons;
     77  fClassMap[CscCluster::Class()] = &TreeWriter::ProcessCscCluster;
    7778  fClassMap[Jet::Class()] = &TreeWriter::ProcessJets;
    7879  fClassMap[MissingET::Class()] = &TreeWriter::ProcessMissingET;
     
    182183    const TLorentzVector &momentum = candidate->Momentum;
    183184    const TLorentzVector &position = candidate->Position;
     185    const TLorentzVector &DecayPosition = candidate->DecayPosition;
    184186
    185187    entry = static_cast<GenParticle *>(branch->NewEntry());
     
    215217    entry->D0 = candidate->D0;
    216218    entry->DZ = candidate->DZ;
    217     entry->P = candidate->P;
     219    entry->P = momentum.P();
    218220    entry->PT = candidate->PT;
    219221    entry->CtgTheta = candidate->CtgTheta;
     
    230232    entry->Z = position.Z();
    231233    entry->T = position.T() * 1.0E-3 / c_light;
     234
     235    entry->decayX = DecayPosition.X();
     236    entry->decayY = DecayPosition.Y();
     237    entry->decayZ = DecayPosition.Z();
     238    entry->decayT = DecayPosition.T()* 1.0E-3 / c_light;
     239    float beta = entry->P/momentum.E();
     240    float gamma = 1./sqrt(1-beta*beta);
     241    entry->ctau = sqrt(pow(entry->decayX-entry->X,2)+pow(entry->decayY-entry->Y,2)+pow(entry->decayZ-entry->Z,2))/(beta*gamma);// in millimeter
    232242  }
    233243}
     
    730740  }
    731741}
     742//------------------------------------------------------------------------------
     743
     744void TreeWriter::ProcessCscCluster(ExRootTreeBranch *branch, TObjArray *array)
     745{
     746  TIter iterator(array);
     747  Candidate *candidate = 0;
     748  CscCluster *entry = 0;
     749  Double_t pt, signPz, cosTheta, eta, rapidity;
     750
     751  const Double_t c_light = 2.99792458E8; // in unit of m/s
     752
     753  array->Sort();
     754
     755
     756  // loop over all clusters
     757  iterator.Reset();
     758  while((candidate = static_cast<Candidate *>(iterator.Next())))
     759  {
     760    const TLorentzVector &momentum = candidate->Momentum;
     761    const TLorentzVector &position = candidate->DecayPosition;
     762
     763    pt = momentum.Pt();
     764    cosTheta = TMath::Abs(momentum.CosTheta());
     765    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
     766    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
     767
     768    entry = static_cast<CscCluster *>(branch->NewEntry());
     769
     770    entry->SetBit(kIsReferenced);
     771    entry->SetUniqueID(candidate->GetUniqueID());
     772
     773    entry->Eta = eta;
     774    entry->Phi = momentum.Phi();
     775
     776
     777    // entry->Eta = position.Eta();
     778    // entry->Phi = position.Phi();
     779
     780    entry->PT = momentum.Pt(); // pt of LLP
     781    entry->Px = momentum.Px();// px of LLP
     782    entry->Py = momentum.Py();// py of LLP
     783    entry->Pz = momentum.Pz();// pz of LLP
     784    entry->E = momentum.E(); // E of LLP
     785    entry->pid = candidate->PID; // LLP pid
     786    entry->Eem = candidate->Eem; // LLP pid
     787    entry->Ehad = candidate->Ehad; // LLP pid
     788    Double_t beta = momentum.P()/momentum.E();
     789    Double_t gamma = 1.0/sqrt(1-beta*beta);
     790    Double_t decayDistance = sqrt(pow(position.X(),2)+pow(position.Y(),2)+pow(position.Z(),2)); // mm
     791    entry->beta = beta; // LLP pid
     792    entry->ctau = decayDistance/(beta * gamma);; // LLP pid
     793
     794    // entry->T = (position.T()-sqrt(pow(position.X(),2)+pow(position.Y(),2)+pow(position.Z(),2)))* 1.0E-3 / c_light; // LLP decay time-photon travel time
     795
     796    entry->T = decayDistance*(1./beta-1)* 1.0E-3/c_light*1e9; // ns
     797    entry->X = position.X(); // LLP decay x
     798    entry->Y = position.Y(); //  LLP decay y
     799    entry->Z = position.Z(); //  LLP decay z
     800    // entry->Size = 100;
     801  }
     802}
    732803
    733804//------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.