12 |
|
#include "MitAna/DataTree/interface/PFJetCol.h" |
13 |
|
#include "MitAna/DataTree/interface/GenJetCol.h" |
14 |
|
#include "TDataMember.h" |
15 |
+ |
#include "TFile.h" |
16 |
|
#include <TNtuple.h> |
17 |
|
#include <TRandom3.h> |
18 |
|
#include <TSystem.h> |
20 |
|
using namespace mithep; |
21 |
|
|
22 |
|
ClassImp(mithep::PhotonTreeWriter) |
23 |
< |
ClassImp(mithep::PhotonTreeWriterPhoton) |
23 |
> |
templateClassImp(mithep::PhotonTreeWriterPhoton) |
24 |
|
ClassImp(mithep::PhotonTreeWriterDiphotonEvent) |
25 |
|
|
26 |
|
//-------------------------------------------------------------------------------------------------- |
29 |
|
BaseMod (name,title), |
30 |
|
// define all the Branches to load |
31 |
|
fPhotonBranchName (Names::gkPhotonBrn), |
32 |
+ |
fPFPhotonName ("PFPhotons"), |
33 |
|
fElectronName (Names::gkElectronBrn), |
34 |
|
fGoodElectronName (Names::gkElectronBrn), |
35 |
|
fConversionName (Names::gkMvfConversionBrn), |
56 |
|
// ---------------------------------------- |
57 |
|
// collections.... |
58 |
|
fPhotons (0), |
59 |
+ |
fPFPhotons (0), |
60 |
|
fElectrons (0), |
61 |
|
fConversions (0), |
62 |
|
fTracks (0), |
78 |
|
fApplyElectronVeto (kTRUE), |
79 |
|
fWriteDiphotonTree (kTRUE), |
80 |
|
fWriteSingleTree (kTRUE), |
81 |
+ |
fEnablePFPhotons (kTRUE), |
82 |
|
fExcludeSinglePrompt (kFALSE), |
83 |
|
fExcludeDoublePrompt (kFALSE), |
84 |
|
fEnableJets (kFALSE), |
85 |
|
fApplyLeptonTag (kFALSE), |
86 |
|
fApplyBTag (kFALSE), |
87 |
|
fApplyPFMetCorrections (kFALSE), |
88 |
+ |
fFillClusterArrays (kFALSE), |
89 |
|
fPhFixDataFile (gSystem->Getenv("CMSSW_BASE") + |
90 |
|
TString("/src/MitPhysics/data/PhotonFixSTART42V13.dat")), |
91 |
|
fTupleName ("hPhotonTree") |
119 |
|
egcol = fPhotons; |
120 |
|
if (egcol->GetEntries()<1) |
121 |
|
return; |
122 |
+ |
|
123 |
+ |
if (fEnablePFPhotons) LoadEventObject(fPFPhotonName, fPFPhotons); |
124 |
|
LoadEventObject(fElectronName, fElectrons); |
125 |
|
LoadEventObject(fConversionName, fConversions); |
126 |
|
LoadEventObject(fTrackBranchName, fTracks); |
147 |
|
rho = (Double_t) fPileUpDen->At(0)->RhoRandomLowEta(); |
148 |
|
|
149 |
|
const BaseVertex *bsp = dynamic_cast<const BaseVertex*>(fBeamspot->At(0)); |
150 |
< |
|
150 |
> |
|
151 |
|
if( !fIsData ) { |
152 |
|
LoadBranch(fMCParticleName); |
153 |
|
LoadBranch(fPileUpName); |
174 |
|
Double_t _spfMet = fPFMet->At(0)->SumEt(); |
175 |
|
fDiphotonEvent->leptonTag = -1; // disabled |
176 |
|
|
177 |
< |
fDiphotonEvent->rho = rho; |
177 |
> |
fDiphotonEvent->rho = fPileUpDen->At(0)->RhoKt6PFJets(); |
178 |
> |
fDiphotonEvent->rho25 = fPileUpDen->At(0)->RhoRandomLowEta(); |
179 |
> |
fDiphotonEvent->rhoold = fPileUpDen->At(0)->Rho(); |
180 |
|
fDiphotonEvent->genHiggspt = _pth; |
181 |
|
fDiphotonEvent->genHiggsZ = _decayZ; |
182 |
|
fDiphotonEvent->genmass = _genmass; |
305 |
|
const DecayParticle *conv2 = PhotonTools::MatchedConversion(sc2,fConversions,bsp, |
306 |
|
nhitsbeforevtxmax); |
307 |
|
|
308 |
< |
const SuperCluster *pfsc1 = PhotonTools::MatchedSC(sc1,fSuperClusters); |
309 |
< |
const SuperCluster *pfsc2 = PhotonTools::MatchedSC(sc2,fSuperClusters); |
308 |
> |
const SuperCluster *pfsc1 = PhotonTools::MatchedPFSC(sc1,fPFPhotons, fElectrons); |
309 |
> |
const SuperCluster *pfsc2 = PhotonTools::MatchedPFSC(sc2,fPFPhotons, fElectrons); |
310 |
|
|
311 |
|
const MCParticle *phgen1 = 0; |
312 |
|
const MCParticle *phgen2 = 0; |
507 |
|
fDiphotonEvent->dphidijetgg = MathUtils::DeltaPhi( (jet1->Mom()+jet2->Mom()).Phi(), _phigg ); |
508 |
|
} |
509 |
|
|
510 |
+ |
PFJetOArr pfjets; |
511 |
+ |
for (UInt_t ijet=0; ijet<fPFJets->GetEntries(); ++ijet) { |
512 |
+ |
const PFJet *pfjet = dynamic_cast<const PFJet*>(fPFJets->At(ijet)); |
513 |
+ |
if (pfjet && MathUtils::DeltaR(*pfjet,*phHard)>0.3 && MathUtils::DeltaR(*pfjet,*phSoft)>0.3) pfjets.Add(pfjet); |
514 |
+ |
} |
515 |
+ |
|
516 |
+ |
PFCandidateOArr pfcands; |
517 |
+ |
for (UInt_t icand=0; icand<fPFCands->GetEntries(); ++icand) { |
518 |
+ |
const PFCandidate *pfcand = fPFCands->At(icand); |
519 |
+ |
if (MathUtils::DeltaR(*pfcand,*phHard)>0.1 && MathUtils::DeltaR(*pfcand,*phSoft)>0.1) pfcands.Add(pfcand); |
520 |
+ |
} |
521 |
+ |
|
522 |
+ |
const Vertex *firstvtx = fPV->At(0); |
523 |
+ |
const Vertex *selvtx = fPV->At(0); |
524 |
+ |
|
525 |
+ |
if (!fLoopOnGoodElectrons && phHard->HasPV()) { |
526 |
+ |
selvtx = phHard->PV(); |
527 |
+ |
} |
528 |
+ |
|
529 |
+ |
|
530 |
+ |
{ |
531 |
+ |
Met mmet = fMVAMet.GetMet( false, |
532 |
+ |
0.,0.,0., |
533 |
+ |
fPFMet->At(0), |
534 |
+ |
&pfcands,selvtx,fPV, fPileUpDen->At(0)->Rho(), |
535 |
+ |
&pfjets, |
536 |
+ |
int(fPV->GetEntries()), |
537 |
+ |
kFALSE); |
538 |
+ |
|
539 |
+ |
TMatrixD *metcov = fMVAMet.GetMetCovariance(); |
540 |
+ |
|
541 |
+ |
ThreeVector fullmet(mmet.Px() - phHard->Px() - phSoft->Px(), |
542 |
+ |
mmet.Py() - phHard->Py() - phSoft->Py(), |
543 |
+ |
0.); |
544 |
+ |
|
545 |
+ |
ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > mcov; |
546 |
+ |
mcov(0,0) = (*metcov)(0,0); |
547 |
+ |
mcov(0,1) = (*metcov)(0,1); |
548 |
+ |
mcov(1,0) = (*metcov)(1,0); |
549 |
+ |
mcov(1,1) = (*metcov)(1,1); |
550 |
+ |
ROOT::Math::SVector<double,2> vmet; |
551 |
+ |
vmet(0) = fullmet.X(); |
552 |
+ |
vmet(1) = fullmet.Y(); |
553 |
+ |
mcov.Invert(); |
554 |
+ |
Double_t metsig = sqrt(ROOT::Math::Similarity(mcov,vmet)); |
555 |
+ |
|
556 |
+ |
fDiphotonEvent->mvametsel = fullmet.Rho(); |
557 |
+ |
fDiphotonEvent->mvametselphi = fullmet.Phi(); |
558 |
+ |
fDiphotonEvent->mvametselx = fullmet.X(); |
559 |
+ |
fDiphotonEvent->mvametsely = fullmet.Y(); |
560 |
+ |
fDiphotonEvent->mvametselsig = metsig; |
561 |
+ |
} |
562 |
+ |
|
563 |
+ |
{ |
564 |
+ |
Met mmet = fMVAMet.GetMet( false, |
565 |
+ |
0.,0.,0., |
566 |
+ |
fPFMet->At(0), |
567 |
+ |
&pfcands,firstvtx,fPV, fPileUpDen->At(0)->Rho(), |
568 |
+ |
&pfjets, |
569 |
+ |
int(fPV->GetEntries()), |
570 |
+ |
kFALSE); |
571 |
+ |
|
572 |
+ |
TMatrixD *metcov = fMVAMet.GetMetCovariance(); |
573 |
+ |
|
574 |
+ |
ThreeVector fullmet(mmet.Px() - phHard->Px() - phSoft->Px(), |
575 |
+ |
mmet.Py() - phHard->Py() - phSoft->Py(), |
576 |
+ |
0.); |
577 |
+ |
|
578 |
+ |
ROOT::Math::SMatrix<double,2,2,ROOT::Math::MatRepSym<double,2> > mcov; |
579 |
+ |
mcov(0,0) = (*metcov)(0,0); |
580 |
+ |
mcov(0,1) = (*metcov)(0,1); |
581 |
+ |
mcov(1,0) = (*metcov)(1,0); |
582 |
+ |
mcov(1,1) = (*metcov)(1,1); |
583 |
+ |
ROOT::Math::SVector<double,2> vmet; |
584 |
+ |
vmet(0) = fullmet.X(); |
585 |
+ |
vmet(1) = fullmet.Y(); |
586 |
+ |
mcov.Invert(); |
587 |
+ |
Double_t metsig = sqrt(ROOT::Math::Similarity(mcov,vmet)); |
588 |
+ |
|
589 |
+ |
fDiphotonEvent->mvametfirst = fullmet.Rho(); |
590 |
+ |
fDiphotonEvent->mvametfirstphi = fullmet.Phi(); |
591 |
+ |
fDiphotonEvent->mvametfirstx = fullmet.X(); |
592 |
+ |
fDiphotonEvent->mvametfirsty = fullmet.Y(); |
593 |
+ |
fDiphotonEvent->mvametfirstsig = metsig; |
594 |
+ |
} |
595 |
+ |
|
596 |
|
} |
597 |
|
|
598 |
|
fDiphotonEvent->corrpfmet = -99.; |
654 |
|
fDiphotonEvent->costhetaele = _costhetaele; |
655 |
|
fDiphotonEvent->evtcat = _evtcat; |
656 |
|
|
657 |
< |
fDiphotonEvent->photons[0].SetVars(phHard,conv1,ele1,pfsc1,phgen1,fPhfixph,fPhfixele,fTracks,fPV,rho,fElectrons,fApplyElectronVeto); |
658 |
< |
fDiphotonEvent->photons[1].SetVars(phSoft,conv2,ele2,pfsc2,phgen2,fPhfixph,fPhfixele,fTracks,fPV,rho,fElectrons,fApplyElectronVeto); |
657 |
> |
fDiphotonEvent->photons[0].SetVars(phHard,conv1,ele1,pfsc1,phgen1,fPhfixph,fPhfixele,fTracks,fPV,rho,fFillClusterArrays,fElectrons,fApplyElectronVeto); |
658 |
> |
fDiphotonEvent->photons[1].SetVars(phSoft,conv2,ele2,pfsc2,phgen2,fPhfixph,fPhfixele,fTracks,fPV,rho,fFillClusterArrays,fElectrons,fApplyElectronVeto); |
659 |
|
|
660 |
|
Float_t ph1ecor = fDiphotonEvent->photons[0].Ecor(); |
661 |
|
Float_t ph1ecorerr = fDiphotonEvent->photons[0].Ecorerr(); |
816 |
|
|
817 |
|
const DecayParticle *conv = PhotonTools::MatchedConversion(sc,fConversions,bsp, |
818 |
|
nhitsbeforevtxmax); |
819 |
< |
const SuperCluster *pfsc = PhotonTools::MatchedSC(sc,fSuperClusters); |
820 |
< |
|
819 |
> |
const SuperCluster *pfsc = PhotonTools::MatchedPFSC(sc,fPFPhotons, fElectrons); |
820 |
> |
|
821 |
|
if (!fLoopOnGoodElectrons && ph->HasPV()) { |
822 |
|
fDiphotonEvent->vtxZ = ph->PV()->Z(); |
823 |
|
} |
846 |
|
(1.0-fDiphotonEvent->cosphimetele)); |
847 |
|
} |
848 |
|
|
849 |
< |
fSinglePhoton->SetVars(ph,conv,ele,pfsc,phgen,fPhfixph,fPhfixele,fTracks,fPV,rho, |
849 |
> |
fSinglePhoton->SetVars(ph,conv,ele,pfsc,phgen,fPhfixph,fPhfixele,fTracks,fPV,rho,fFillClusterArrays, |
850 |
|
fElectrons,fApplyElectronVeto); |
851 |
|
hCiCTupleSingle->Fill(); |
852 |
|
} |
869 |
|
} |
870 |
|
|
871 |
|
ReqEventObject(fPhotonBranchName,fPhotons, fPhotonsFromBranch); |
872 |
+ |
if (fEnablePFPhotons) ReqEventObject(fPFPhotonName,fPFPhotons, true); |
873 |
|
ReqEventObject(fTrackBranchName, fTracks, true); |
874 |
|
ReqEventObject(fElectronName, fElectrons, true); |
875 |
|
ReqEventObject(fGoodElectronName,fGoodElectrons,fGoodElectronsFromBranch); |
902 |
|
fPhfixph.initialise("4_2",std::string(fPhFixDataFile)); |
903 |
|
fPhfixele.initialise("4_2e",std::string(fPhFixDataFile)); |
904 |
|
|
905 |
+ |
// fMVAMet.Initialize(TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_lowpt.weights.xml"))), |
906 |
+ |
// TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_highpt.weights.xml"))), |
907 |
+ |
// TString(getenv("CMSSW_BASE")+string("/src/MitPhysics/Utils/python/JetIdParams_cfi.py")), |
908 |
+ |
// TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmet_42.root"))), |
909 |
+ |
// TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetphi_42.root"))), |
910 |
+ |
// TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu1_42.root"))), |
911 |
+ |
// TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu2_42.root"))) |
912 |
+ |
// ); |
913 |
+ |
|
914 |
+ |
fMVAMet.Initialize(TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_lowpt.weights.xml"))), |
915 |
+ |
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/mva_JetID_highpt.weights.xml"))), |
916 |
+ |
TString(getenv("CMSSW_BASE")+string("/src/MitPhysics/Utils/python/JetIdParams_cfi.py")), |
917 |
+ |
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmet_52.root"))), |
918 |
+ |
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetphi_52.root"))), |
919 |
+ |
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu1cov_52.root"))), |
920 |
+ |
TString((getenv("CMSSW_BASE")+string("/src/MitPhysics/data/gbrmetu2cov_52.root"))) |
921 |
+ |
); |
922 |
+ |
|
923 |
|
fDiphotonEvent = new PhotonTreeWriterDiphotonEvent; |
924 |
< |
fSinglePhoton = new PhotonTreeWriterPhoton; |
924 |
> |
fSinglePhoton = new PhotonTreeWriterPhoton<16>; |
925 |
|
|
926 |
< |
if (fWriteDiphotonTree) |
926 |
> |
TFile *ftmp = TFile::Open(TString::Format("%s_tmp.root",GetName()),"RECREATE"); |
927 |
> |
|
928 |
> |
if (fWriteDiphotonTree) { |
929 |
|
hCiCTuple = new TTree(fTupleName.Data(),fTupleName.Data()); |
930 |
+ |
hCiCTuple->SetAutoSave(300e9); |
931 |
+ |
} |
932 |
|
TString singlename = fTupleName + TString("Single"); |
933 |
< |
if (fWriteSingleTree) |
933 |
> |
if (fWriteSingleTree) { |
934 |
|
hCiCTupleSingle = new TTree(singlename,singlename); |
935 |
< |
|
935 |
> |
hCiCTupleSingle->SetAutoSave(300e9); |
936 |
> |
} |
937 |
> |
|
938 |
|
//make flattish tree from classes so we don't have to rely on dictionaries for reading later |
939 |
|
TClass *eclass = TClass::GetClass("mithep::PhotonTreeWriterDiphotonEvent"); |
940 |
< |
TClass *pclass = TClass::GetClass("mithep::PhotonTreeWriterPhoton"); |
940 |
> |
TClass *pclass = TClass::GetClass("mithep::PhotonTreeWriterPhoton<16>"); |
941 |
|
TList *elist = eclass->GetListOfDataMembers(); |
942 |
|
TList *plist = pclass->GetListOfDataMembers(); |
943 |
|
|
944 |
|
for (int i=0; i<elist->GetEntries(); ++i) { |
945 |
|
const TDataMember *tdm = static_cast<const TDataMember*>(elist->At(i)); |
946 |
< |
if (!(tdm->IsBasic() && tdm->IsPersistent())) |
827 |
< |
continue; |
946 |
> |
if (!(tdm->IsBasic() && tdm->IsPersistent())) continue; |
947 |
|
TString typestring; |
948 |
< |
if (TString(tdm->GetTypeName())=="Char_t") typestring = "B"; |
949 |
< |
else if (TString(tdm->GetTypeName())=="UChar_t") typestring = "b"; |
950 |
< |
else if (TString(tdm->GetTypeName())=="Short_t") typestring = "S"; |
951 |
< |
else if (TString(tdm->GetTypeName())=="UShort_t") typestring = "s"; |
952 |
< |
else if (TString(tdm->GetTypeName())=="Int_t") typestring = "I"; |
953 |
< |
else if (TString(tdm->GetTypeName())=="UInt_t") typestring = "i"; |
954 |
< |
else if (TString(tdm->GetTypeName())=="Float_t") typestring = "F"; |
955 |
< |
else if (TString(tdm->GetTypeName())=="Double_t") typestring = "D"; |
956 |
< |
else if (TString(tdm->GetTypeName())=="Long64_t") typestring = "L"; |
957 |
< |
else if (TString(tdm->GetTypeName())=="ULong64_t") typestring = "l"; |
958 |
< |
else if (TString(tdm->GetTypeName())=="Bool_t") typestring = "O"; |
959 |
< |
else |
841 |
< |
continue; |
948 |
> |
if (TString(tdm->GetTypeName()).BeginsWith("Char_t")) typestring = "B"; |
949 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("UChar_t")) typestring = "b"; |
950 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Short_t")) typestring = "S"; |
951 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("UShort_t")) typestring = "s"; |
952 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Int_t")) typestring = "I"; |
953 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("UInt_t")) typestring = "i"; |
954 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Float_t")) typestring = "F"; |
955 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Double_t")) typestring = "D"; |
956 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Long64_t")) typestring = "L"; |
957 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("ULong64_t")) typestring = "l"; |
958 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Bool_t")) typestring = "O"; |
959 |
> |
else continue; |
960 |
|
//printf("%s %s: %i\n",tdm->GetTypeName(),tdm->GetName(),int(tdm->GetOffset())); |
961 |
|
Char_t *addr = (Char_t*)fDiphotonEvent; |
962 |
|
assert(sizeof(Char_t)==1); |
963 |
< |
|
964 |
< |
if (fWriteDiphotonTree) |
847 |
< |
hCiCTuple->Branch(tdm->GetName(),addr + tdm->GetOffset(), |
848 |
< |
TString::Format("%s/%s",tdm->GetName(),typestring.Data())); |
849 |
< |
if (fWriteSingleTree) |
850 |
< |
hCiCTupleSingle->Branch(tdm->GetName(),addr + tdm->GetOffset(), |
851 |
< |
TString::Format("%s/%s",tdm->GetName(),typestring.Data())); |
963 |
> |
if (fWriteDiphotonTree) hCiCTuple->Branch(tdm->GetName(),addr + tdm->GetOffset(),TString::Format("%s/%s",tdm->GetName(),typestring.Data())); |
964 |
> |
if (fWriteSingleTree) hCiCTupleSingle->Branch(tdm->GetName(),addr + tdm->GetOffset(),TString::Format("%s/%s",tdm->GetName(),typestring.Data())); |
965 |
|
} |
966 |
|
|
967 |
|
for (int iph=0; iph<2; ++iph) { |
968 |
|
for (int i=0; i<plist->GetEntries(); ++i) { |
969 |
|
const TDataMember *tdm = static_cast<const TDataMember*>(plist->At(i)); |
970 |
< |
if (!(tdm->IsBasic() && tdm->IsPersistent())) |
858 |
< |
continue; |
970 |
> |
if (!(tdm->IsBasic() && tdm->IsPersistent())) continue; |
971 |
|
TString typestring; |
972 |
< |
if (TString(tdm->GetTypeName())=="Char_t") |
973 |
< |
typestring = "B"; |
974 |
< |
else if (TString(tdm->GetTypeName())=="UChar_t") |
975 |
< |
typestring = "b"; |
976 |
< |
else if (TString(tdm->GetTypeName())=="Short_t") |
977 |
< |
typestring = "S"; |
978 |
< |
else if (TString(tdm->GetTypeName())=="UShort_t") |
979 |
< |
typestring = "s"; |
980 |
< |
else if (TString(tdm->GetTypeName())=="Int_t") |
981 |
< |
typestring = "I"; |
982 |
< |
else if (TString(tdm->GetTypeName())=="UInt_t") |
983 |
< |
typestring = "i"; |
872 |
< |
else if (TString(tdm->GetTypeName())=="Float_t") |
873 |
< |
typestring = "F"; |
874 |
< |
else if (TString(tdm->GetTypeName())=="Double_t") |
875 |
< |
typestring = "D"; |
876 |
< |
else if (TString(tdm->GetTypeName())=="Long64_t") |
877 |
< |
typestring = "L"; |
878 |
< |
else if (TString(tdm->GetTypeName())=="ULong64_t") |
879 |
< |
typestring = "l"; |
880 |
< |
else if (TString(tdm->GetTypeName())=="Bool_t") |
881 |
< |
typestring = "O"; |
882 |
< |
else |
883 |
< |
continue; |
972 |
> |
if (TString(tdm->GetTypeName()).BeginsWith("Char_t")) typestring = "B"; |
973 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("UChar_t")) typestring = "b"; |
974 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Short_t")) typestring = "S"; |
975 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("UShort_t")) typestring = "s"; |
976 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Int_t")) typestring = "I"; |
977 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("UInt_t")) typestring = "i"; |
978 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Float_t")) typestring = "F"; |
979 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Double_t")) typestring = "D"; |
980 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Long64_t")) typestring = "L"; |
981 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("ULong64_t")) typestring = "l"; |
982 |
> |
else if (TString(tdm->GetTypeName()).BeginsWith("Bool_t")) typestring = "O"; |
983 |
> |
else continue; |
984 |
|
//printf("%s\n",tdm->GetTypeName()); |
985 |
|
TString varname = TString::Format("ph%d.%s",iph+1,tdm->GetName()); |
986 |
+ |
if (tdm->GetArrayDim()==1) { |
987 |
+ |
varname = TString::Format("%s[%i]",varname.Data(),tdm->GetMaxIndex(0)); |
988 |
+ |
} |
989 |
+ |
|
990 |
+ |
//printf("typename = %s, arraydim = %i, arraysize = %i,varname = %s\n", tdm->GetTypeName(), tdm->GetArrayDim(), tdm->GetMaxIndex(0), varname.Data()); |
991 |
|
|
992 |
|
Char_t *addr = (Char_t*)&fDiphotonEvent->photons[iph]; |
993 |
|
assert(sizeof(Char_t)==1); |
994 |
< |
|
890 |
< |
if (fWriteDiphotonTree) |
891 |
< |
hCiCTuple->Branch(varname,addr+tdm->GetOffset(), |
892 |
< |
TString::Format("%s/%s",varname.Data(),typestring.Data())); |
994 |
> |
if (fWriteDiphotonTree) hCiCTuple->Branch(varname,addr+tdm->GetOffset(),TString::Format("%s/%s",varname.Data(),typestring.Data())); |
995 |
|
|
996 |
|
if (iph==0) { |
997 |
|
TString singlename = TString::Format("ph.%s",tdm->GetName()); |
998 |
+ |
if (tdm->GetArrayDim()==1) { |
999 |
+ |
singlename = TString::Format("%s[%i]",singlename.Data(),tdm->GetMaxIndex(0)); |
1000 |
+ |
} |
1001 |
|
Char_t *addrsingle = (Char_t*)fSinglePhoton; |
1002 |
< |
if (fWriteSingleTree) |
898 |
< |
hCiCTupleSingle->Branch(singlename,addrsingle+tdm->GetOffset(), |
899 |
< |
TString::Format("%s/%s",singlename.Data(),typestring.Data())); |
1002 |
> |
if (fWriteSingleTree) hCiCTupleSingle->Branch(singlename,addrsingle+tdm->GetOffset(),TString::Format("%s/%s",singlename.Data(),typestring.Data())); |
1003 |
|
} |
1004 |
|
} |
1005 |
|
} |
1049 |
|
return ( ph1IsHR9 && ph2IsHR9 ? 2. : 3.); |
1050 |
|
} |
1051 |
|
|
1052 |
< |
void PhotonTreeWriterPhoton::SetVars(const Photon *p, const DecayParticle *c, const Electron *ele, |
1052 |
> |
template <int NClus> |
1053 |
> |
void PhotonTreeWriterPhoton<NClus>::SetVars(const Photon *p, const DecayParticle *c, const Electron *ele, |
1054 |
|
const SuperCluster *pfsc, const MCParticle *m, |
1055 |
|
PhotonFix &phfixph, PhotonFix &phfixele, |
1056 |
|
const TrackCol* trackCol,const VertexCol* vtxCol,Double_t rho, |
1057 |
+ |
Bool_t fillclusterarrays, |
1058 |
|
const ElectronCol* els, Bool_t applyElectronVeto) { |
1059 |
|
|
1060 |
|
const SuperCluster *s = 0; |
1103 |
|
e3x3 = p->E33(); |
1104 |
|
e5x5 = p->E55(); |
1105 |
|
hovere = p->HadOverEm(); |
1106 |
+ |
hoveretower = p->HadOverEmTow(); |
1107 |
|
sigietaieta = p->CoviEtaiEta(); |
1108 |
|
phcat = PhotonTools::CiCBaseLineCat(p); |
1109 |
|
eerr = p->EnergyErr(); |
1166 |
|
sce = s->Energy(); |
1167 |
|
scrawe = s->RawEnergy(); |
1168 |
|
scpse = s->PreshowerEnergy(); |
1169 |
+ |
scpssigmaxx = s->PsEffWidthSigmaXX(); |
1170 |
+ |
scpssigmayy = s->PsEffWidthSigmaYY(); |
1171 |
|
sceta = s->Eta(); |
1172 |
|
scphi = s->Phi(); |
1173 |
|
scnclusters = s->ClusterSize(); |
1396 |
|
nhitsbclast2 = 0; |
1397 |
|
} |
1398 |
|
|
1399 |
+ |
for (UInt_t iclus=0; iclus<NClus; ++iclus) { |
1400 |
+ |
if (fillclusterarrays && iclus < s->ClusterSize() ) { |
1401 |
+ |
const BasicCluster *ib =s->Cluster(iclus); |
1402 |
+ |
|
1403 |
+ |
ebcs[iclus] = ib->Energy(); |
1404 |
+ |
etabcs[iclus] = ib->Eta(); |
1405 |
+ |
phibcs[iclus] = ib->Phi(); |
1406 |
+ |
ietabcs[iclus] = ib->IEta(); |
1407 |
+ |
iphibcs[iclus] = ib->IPhi(); |
1408 |
+ |
ixbcs[iclus] = ib->IX(); |
1409 |
+ |
iybcs[iclus] = ib->IY(); |
1410 |
+ |
etacrybcs[iclus] = ib->EtaCry(); |
1411 |
+ |
phicrybcs[iclus] = ib->PhiCry(); |
1412 |
+ |
xcrybcs[iclus] = ib->XCry(); |
1413 |
+ |
ycrybcs[iclus] = ib->YCry(); |
1414 |
+ |
sigietaietabcs[iclus] = TMath::Sqrt(ib->CoviEtaiEta()); |
1415 |
+ |
sigiphiphibcs[iclus] = TMath::Sqrt(ib->CoviPhiiPhi()); |
1416 |
+ |
covietaiphibcs[iclus] = ib->CoviEtaiPhi(); |
1417 |
+ |
sigetaetabcs[iclus] = TMath::Sqrt(ib->CovEtaEta()); |
1418 |
+ |
sigphiphibcs[iclus] = TMath::Sqrt(ib->CovPhiPhi()); |
1419 |
+ |
covetaphibcs[iclus] = ib->CovEtaPhi(); |
1420 |
+ |
e3x3bcs[iclus] = ib->E3x3(); |
1421 |
+ |
e5x5bcs[iclus] = ib->E5x5(); |
1422 |
+ |
emaxbcs[iclus] = ib->EMax(); |
1423 |
+ |
e2ndbcs[iclus] = ib->E2nd(); |
1424 |
+ |
etopbcs[iclus] = ib->ETop(); |
1425 |
+ |
ebottombcs[iclus] = ib->EBottom(); |
1426 |
+ |
eleftbcs[iclus] = ib->ELeft(); |
1427 |
+ |
erightbcs[iclus] = ib->ERight(); |
1428 |
+ |
e1x3bcs[iclus] = ib->E1x3(); |
1429 |
+ |
e3x1bcs[iclus] = ib->E3x1(); |
1430 |
+ |
e1x5bcs[iclus] = ib->E1x5(); |
1431 |
+ |
e2x2bcs[iclus] = ib->E2x2(); |
1432 |
+ |
e4x4bcs[iclus] = ib->E4x4(); |
1433 |
+ |
e2x5maxbcs[iclus] = ib->E2x5Max(); |
1434 |
+ |
e2x5topbcs[iclus] = ib->E2x5Top(); |
1435 |
+ |
e2x5bottombcs[iclus] = ib->E2x5Bottom(); |
1436 |
+ |
e2x5leftbcs[iclus] = ib->E2x5Left(); |
1437 |
+ |
e2x5rightbcs[iclus] = ib->E2x5Right(); |
1438 |
+ |
nhitsbcs[iclus]= ib->NHits(); |
1439 |
+ |
} |
1440 |
+ |
else { |
1441 |
+ |
ebcs[iclus] = -999; |
1442 |
+ |
etabcs[iclus] = -999; |
1443 |
+ |
phibcs[iclus] = -999; |
1444 |
+ |
ietabcs[iclus] = -999; |
1445 |
+ |
iphibcs[iclus] = -999; |
1446 |
+ |
ixbcs[iclus] = -999; |
1447 |
+ |
iybcs[iclus] = -999; |
1448 |
+ |
etacrybcs[iclus] = -999; |
1449 |
+ |
phicrybcs[iclus] = -999; |
1450 |
+ |
xcrybcs[iclus] = -999; |
1451 |
+ |
ycrybcs[iclus] = -999; |
1452 |
+ |
sigietaietabcs[iclus] = -999; |
1453 |
+ |
sigiphiphibcs[iclus] = -999; |
1454 |
+ |
covietaiphibcs[iclus] = -999; |
1455 |
+ |
sigetaetabcs[iclus] = -999; |
1456 |
+ |
sigphiphibcs[iclus] = -999; |
1457 |
+ |
covetaphibcs[iclus] = -999; |
1458 |
+ |
e3x3bcs[iclus] = -999; |
1459 |
+ |
e5x5bcs[iclus] = -999; |
1460 |
+ |
emaxbcs[iclus] = -999; |
1461 |
+ |
e2ndbcs[iclus] = -999; |
1462 |
+ |
etopbcs[iclus] = -999; |
1463 |
+ |
ebottombcs[iclus] = -999; |
1464 |
+ |
eleftbcs[iclus] = -999; |
1465 |
+ |
erightbcs[iclus] = -999; |
1466 |
+ |
e1x3bcs[iclus] = -999; |
1467 |
+ |
e3x1bcs[iclus] = -999; |
1468 |
+ |
e1x5bcs[iclus] = -999; |
1469 |
+ |
e2x2bcs[iclus] = -999; |
1470 |
+ |
e4x4bcs[iclus] = -999; |
1471 |
+ |
e2x5maxbcs[iclus] = -999; |
1472 |
+ |
e2x5topbcs[iclus] = -999; |
1473 |
+ |
e2x5bottombcs[iclus] = -999; |
1474 |
+ |
e2x5leftbcs[iclus] = -999; |
1475 |
+ |
e2x5rightbcs[iclus] = -999; |
1476 |
+ |
nhitsbcs[iclus] = -999; |
1477 |
+ |
} |
1478 |
+ |
} |
1479 |
+ |
|
1480 |
+ |
for (UInt_t iclus=0; iclus<NClus; ++iclus) { |
1481 |
+ |
if (fillclusterarrays && pfsc && iclus < pfsc->ClusterSize() ) { |
1482 |
+ |
const BasicCluster *ib =pfsc->Cluster(iclus); |
1483 |
+ |
|
1484 |
+ |
epfbcs[iclus] = ib->Energy(); |
1485 |
+ |
etapfbcs[iclus] = ib->Eta(); |
1486 |
+ |
phipfbcs[iclus] = ib->Phi(); |
1487 |
+ |
ietapfbcs[iclus] = ib->IEta(); |
1488 |
+ |
iphipfbcs[iclus] = ib->IPhi(); |
1489 |
+ |
ixpfbcs[iclus] = ib->IX(); |
1490 |
+ |
iypfbcs[iclus] = ib->IY(); |
1491 |
+ |
etacrypfbcs[iclus] = ib->EtaCry(); |
1492 |
+ |
phicrypfbcs[iclus] = ib->PhiCry(); |
1493 |
+ |
xcrypfbcs[iclus] = ib->XCry(); |
1494 |
+ |
ycrypfbcs[iclus] = ib->YCry(); |
1495 |
+ |
sigietaietapfbcs[iclus] = TMath::Sqrt(ib->CoviEtaiEta()); |
1496 |
+ |
sigiphiphipfbcs[iclus] = TMath::Sqrt(ib->CoviPhiiPhi()); |
1497 |
+ |
covietaiphipfbcs[iclus] = ib->CoviEtaiPhi(); |
1498 |
+ |
sigetaetapfbcs[iclus] = TMath::Sqrt(ib->CovEtaEta()); |
1499 |
+ |
sigphiphipfbcs[iclus] = TMath::Sqrt(ib->CovPhiPhi()); |
1500 |
+ |
covetaphipfbcs[iclus] = ib->CovEtaPhi(); |
1501 |
+ |
e3x3pfbcs[iclus] = ib->E3x3(); |
1502 |
+ |
e5x5pfbcs[iclus] = ib->E5x5(); |
1503 |
+ |
emaxpfbcs[iclus] = ib->EMax(); |
1504 |
+ |
e2ndpfbcs[iclus] = ib->E2nd(); |
1505 |
+ |
etoppfbcs[iclus] = ib->ETop(); |
1506 |
+ |
ebottompfbcs[iclus] = ib->EBottom(); |
1507 |
+ |
eleftpfbcs[iclus] = ib->ELeft(); |
1508 |
+ |
erightpfbcs[iclus] = ib->ERight(); |
1509 |
+ |
e1x3pfbcs[iclus] = ib->E1x3(); |
1510 |
+ |
e3x1pfbcs[iclus] = ib->E3x1(); |
1511 |
+ |
e1x5pfbcs[iclus] = ib->E1x5(); |
1512 |
+ |
e2x2pfbcs[iclus] = ib->E2x2(); |
1513 |
+ |
e4x4pfbcs[iclus] = ib->E4x4(); |
1514 |
+ |
e2x5maxpfbcs[iclus] = ib->E2x5Max(); |
1515 |
+ |
e2x5toppfbcs[iclus] = ib->E2x5Top(); |
1516 |
+ |
e2x5bottompfbcs[iclus] = ib->E2x5Bottom(); |
1517 |
+ |
e2x5leftpfbcs[iclus] = ib->E2x5Left(); |
1518 |
+ |
e2x5rightpfbcs[iclus] = ib->E2x5Right(); |
1519 |
+ |
nhitspfbcs[iclus]= ib->NHits(); |
1520 |
+ |
} |
1521 |
+ |
else { |
1522 |
+ |
epfbcs[iclus] = -999; |
1523 |
+ |
etapfbcs[iclus] = -999; |
1524 |
+ |
phipfbcs[iclus] = -999; |
1525 |
+ |
ietapfbcs[iclus] = -999; |
1526 |
+ |
iphipfbcs[iclus] = -999; |
1527 |
+ |
ixpfbcs[iclus] = -999; |
1528 |
+ |
iypfbcs[iclus] = -999; |
1529 |
+ |
etacrypfbcs[iclus] = -999; |
1530 |
+ |
phicrypfbcs[iclus] = -999; |
1531 |
+ |
xcrypfbcs[iclus] = -999; |
1532 |
+ |
ycrypfbcs[iclus] = -999; |
1533 |
+ |
sigietaietapfbcs[iclus] = -999; |
1534 |
+ |
sigiphiphipfbcs[iclus] = -999; |
1535 |
+ |
covietaiphipfbcs[iclus] = -999; |
1536 |
+ |
sigetaetapfbcs[iclus] = -999; |
1537 |
+ |
sigphiphipfbcs[iclus] = -999; |
1538 |
+ |
covetaphipfbcs[iclus] = -999; |
1539 |
+ |
e3x3pfbcs[iclus] = -999; |
1540 |
+ |
e5x5pfbcs[iclus] = -999; |
1541 |
+ |
emaxpfbcs[iclus] = -999; |
1542 |
+ |
e2ndpfbcs[iclus] = -999; |
1543 |
+ |
etoppfbcs[iclus] = -999; |
1544 |
+ |
ebottompfbcs[iclus] = -999; |
1545 |
+ |
eleftpfbcs[iclus] = -999; |
1546 |
+ |
erightpfbcs[iclus] = -999; |
1547 |
+ |
e1x3pfbcs[iclus] = -999; |
1548 |
+ |
e3x1pfbcs[iclus] = -999; |
1549 |
+ |
e1x5pfbcs[iclus] = -999; |
1550 |
+ |
e2x2pfbcs[iclus] = -999; |
1551 |
+ |
e4x4pfbcs[iclus] = -999; |
1552 |
+ |
e2x5maxpfbcs[iclus] = -999; |
1553 |
+ |
e2x5toppfbcs[iclus] = -999; |
1554 |
+ |
e2x5bottompfbcs[iclus] = -999; |
1555 |
+ |
e2x5leftpfbcs[iclus] = -999; |
1556 |
+ |
e2x5rightpfbcs[iclus] = -999; |
1557 |
+ |
nhitspfbcs[iclus] = -999; |
1558 |
+ |
} |
1559 |
+ |
} |
1560 |
+ |
|
1561 |
+ |
for (UInt_t iclus=0; iclus<100; ++iclus) { |
1562 |
+ |
if (fillclusterarrays && pfsc && iclus < pfsc->NPsClusts() ) { |
1563 |
+ |
const PsCluster *ib = pfsc->PsClust(iclus); |
1564 |
+ |
|
1565 |
+ |
epsc[iclus] = ib->Energy(); |
1566 |
+ |
etapsc[iclus] = ib->Eta(); |
1567 |
+ |
phipsc[iclus] = ib->Phi(); |
1568 |
+ |
planepsc[iclus] = ib->PsPlane(); |
1569 |
+ |
} |
1570 |
+ |
else { |
1571 |
+ |
epsc[iclus] = -999; |
1572 |
+ |
etapsc[iclus] = -999; |
1573 |
+ |
phipsc[iclus] = -999; |
1574 |
+ |
planepsc[iclus] = 0; |
1575 |
+ |
} |
1576 |
+ |
} |
1577 |
+ |
|
1578 |
|
//initialize photon energy corrections if needed |
1579 |
|
/*if (!PhotonFix::initialised()) { |
1580 |
|
PhotonFix::initialise("4_2",std::string((gSystem->Getenv("CMSSW_BASE") + TString("/src/MitPhysics/data/PhotonFix.dat")).Data())); |
1724 |
|
pfscrawe = pfsc->RawEnergy(); |
1725 |
|
pfsceta = pfsc->Eta(); |
1726 |
|
pfscphi = pfsc->Phi(); |
1727 |
+ |
pfscnclusters = pfsc->NClusters(); |
1728 |
+ |
pfscnhits = pfsc->NHits(); |
1729 |
+ |
pfscetawidth = pfsc->EtaWidth(); |
1730 |
+ |
pfscphiwidth = pfsc->PhiWidth(); |
1731 |
+ |
pfscnpsclusters = pfsc->NPsClusts(); |
1732 |
|
} |
1733 |
|
else { |
1734 |
|
haspfsc = kFALSE; |
1736 |
|
pfscrawe = -99.; |
1737 |
|
pfsceta = -99.; |
1738 |
|
pfscphi = -99.; |
1739 |
+ |
pfscnclusters = 0; |
1740 |
+ |
pfscnhits = 0; |
1741 |
+ |
pfscetawidth = -99.; |
1742 |
+ |
pfscphiwidth = -99.; |
1743 |
+ |
pfscnpsclusters = 0; |
1744 |
|
} |
1745 |
|
|
1746 |
|
genz = -99.; |