Fork me on GitHub

Changes in / [e39abb4:0e7d64a] in git


Ignore:
Files:
7 added
217 edited

Legend:

Unmodified
Added
Removed
  • .circleci/config.yml

    re39abb4 r0e7d64a  
    88        command: |
    99          make distclean
    10           make -j `nproc` HAS_PYTHIA8=true
     10          make -j 8 HAS_PYTHIA8=true
    1111    - run:
    1212        name: Build Delphes using cmake
     
    1616          cd build
    1717          cmake ..
    18           make -j `nproc`
     18          make -j 8
    1919
    2020jobs:
     
    2727    docker:
    2828      - image: delphes/ubuntu:18.04
    29   fedora-28:
     29  fedora-30:
    3030    <<: *shared
    3131    docker:
    32       - image: delphes/fedora:28
     32      - image: delphes/fedora:30
    3333
    3434workflows:
     
    3838      - ubuntu-1404
    3939      - ubuntu-1804
    40       - fedora-28
     40      - fedora-30
  • .clang-format

    re39abb4 r0e7d64a  
    11BasedOnStyle: LLVM
    22Language: Cpp
     3Standard: Cpp03
    34IndentWidth: 2
    45ConstructorInitializerIndentWidth: 2
  • CHANGELOG

    re39abb4 r0e7d64a  
     13.4.2:
     2- added DenseTrackFilter for modelling tracking inefficiencies in boosted, dense environments
     3- added detector cards for CLIC and HL-LHC detectors
     4- added muons to Tower collection used for jets reconstruction and MET calculation in the ATLAS card (#1118)
     5- added Weight branch to HepMC
     6- added Jet constituent output to FastJetFinder (allows more complex schemes of MET calculation) (#1349)
     7- added Valencia jet algorithm from FastJet Contrib library and exclusive jet clustering for e+e- collisions (thanks to Ulrike Schnoor)
     8- added possibility to read cross section from LHE files produced with Wizard event generator
     9- added NeutralOutputArray in ParticlePropagator
     10- added various information in StatusPidFilter (B and tau decay products, photons, SUSY particles, W daughters)
     11- added DelphesProIO reader for ProIO data format (thanks to Sergei Chekanov)
     12- improved TrackSmearing and updated TrackCountingBTagging (thanks to Kevin Pedro)
     13- adapted Efficiency and DelphesFormula to long-lived particles
     14- adapted Python analysis code to recent ROOT versions (thanks to Kerim Suruliz)
     15- updated class version of LHEFEvent, HepMCEvent, Photon, Electron, Muon, Jet and Candidate (#1363)
     16- updated FastJet library to 3.3.2 and FastJet Contrib library to 1.041
     17- updated copyright and licensing information
     18- removed dependency on the RPC and XDR libraries from STDHEP reader (#1310)
     19- fixed Delphes class destructor (TList::Clear error) (#1320)
     20
    1213.4.1:
    222- added RadiusMax and HalfLengthMax to ParticlePropagator to keep decay products of the long-lived particles (#1084)
     
    424- improved CMake configuration
    525- fixed weights in LHEFReader
    6 - fixed bug in Charged Hadron Subtraction (CHS) 
     26- fixed bug in Charged Hadron Subtraction (CHS)
    727- promoted z vertex resolution to TFormula
    828- fixed bugs in DelphesDisplay
  • Makefile

    re39abb4 r0e7d64a  
    105105        classes/DelphesHepMCReader.h \
    106106        classes/DelphesPileUpWriter.h \
    107         external/ExRootAnalysis/ExRootTreeWriter.h \
     107        external/ExRootAnalysis/ExRootProgressBar.h \
    108108        external/ExRootAnalysis/ExRootTreeBranch.h \
    109         external/ExRootAnalysis/ExRootProgressBar.h
     109        external/ExRootAnalysis/ExRootTreeWriter.h
    110110lhco2root$(ExeSuf): \
    111111        tmp/converters/lhco2root.$(ObjSuf)
     
    113113tmp/converters/lhco2root.$(ObjSuf): \
    114114        converters/lhco2root.cpp \
     115        classes/DelphesClasses.h \
     116        classes/DelphesFactory.h \
     117        classes/DelphesStream.h \
    115118        modules/Delphes.h \
    116         classes/DelphesStream.h \
    117         classes/DelphesClasses.h \
    118         classes/DelphesFactory.h \
    119         external/ExRootAnalysis/ExRootTreeWriter.h \
     119        external/ExRootAnalysis/ExRootProgressBar.h \
    120120        external/ExRootAnalysis/ExRootTreeBranch.h \
    121         external/ExRootAnalysis/ExRootProgressBar.h
     121        external/ExRootAnalysis/ExRootTreeWriter.h
    122122pileup2root$(ExeSuf): \
    123123        tmp/converters/pileup2root.$(ObjSuf)
     
    125125tmp/converters/pileup2root.$(ObjSuf): \
    126126        converters/pileup2root.cpp \
     127        classes/DelphesClasses.h \
     128        classes/DelphesFactory.h \
     129        classes/DelphesPileUpReader.h \
    127130        classes/DelphesStream.h \
    128         classes/DelphesClasses.h \
    129         classes/DelphesFactory.h \
    130         classes/DelphesPileUpReader.h \
    131         external/ExRootAnalysis/ExRootTreeWriter.h \
     131        external/ExRootAnalysis/ExRootProgressBar.h \
    132132        external/ExRootAnalysis/ExRootTreeBranch.h \
    133         external/ExRootAnalysis/ExRootProgressBar.h
     133        external/ExRootAnalysis/ExRootTreeWriter.h
    134134root2lhco$(ExeSuf): \
    135135        tmp/converters/root2lhco.$(ObjSuf)
     
    138138        converters/root2lhco.cpp \
    139139        classes/DelphesClasses.h \
    140         external/ExRootAnalysis/ExRootTreeReader.h \
    141         external/ExRootAnalysis/ExRootProgressBar.h
     140        external/ExRootAnalysis/ExRootProgressBar.h \
     141        external/ExRootAnalysis/ExRootTreeReader.h
    142142root2pileup$(ExeSuf): \
    143143        tmp/converters/root2pileup.$(ObjSuf)
     
    147147        classes/DelphesClasses.h \
    148148        classes/DelphesPileUpWriter.h \
    149         external/ExRootAnalysis/ExRootTreeReader.h \
    150         external/ExRootAnalysis/ExRootProgressBar.h
     149        external/ExRootAnalysis/ExRootProgressBar.h \
     150        external/ExRootAnalysis/ExRootTreeReader.h
    151151stdhep2pileup$(ExeSuf): \
    152152        tmp/converters/stdhep2pileup.$(ObjSuf)
     
    156156        classes/DelphesClasses.h \
    157157        classes/DelphesFactory.h \
     158        classes/DelphesPileUpWriter.h \
    158159        classes/DelphesSTDHEPReader.h \
    159         classes/DelphesPileUpWriter.h \
    160         external/ExRootAnalysis/ExRootTreeWriter.h \
     160        external/ExRootAnalysis/ExRootProgressBar.h \
    161161        external/ExRootAnalysis/ExRootTreeBranch.h \
    162         external/ExRootAnalysis/ExRootProgressBar.h
     162        external/ExRootAnalysis/ExRootTreeWriter.h
    163163CaloGrid$(ExeSuf): \
    164164        tmp/examples/CaloGrid.$(ObjSuf)
     
    166166tmp/examples/CaloGrid.$(ObjSuf): \
    167167        examples/CaloGrid.cpp \
    168         display/Delphes3DGeometry.h \
    169         classes/DelphesClasses.h \
    170         external/ExRootAnalysis/ExRootConfReader.h
     168        external/ExRootAnalysis/ExRootConfReader.h \
     169        classes/DelphesClasses.h \
     170        display/Delphes3DGeometry.h
    171171Example1$(ExeSuf): \
    172172        tmp/examples/Example1.$(ObjSuf)
     
    175175        examples/Example1.cpp \
    176176        classes/DelphesClasses.h \
     177        external/ExRootAnalysis/ExRootResult.h \
     178        external/ExRootAnalysis/ExRootTreeBranch.h \
    177179        external/ExRootAnalysis/ExRootTreeReader.h \
    178180        external/ExRootAnalysis/ExRootTreeWriter.h \
    179         external/ExRootAnalysis/ExRootTreeBranch.h \
    180         external/ExRootAnalysis/ExRootResult.h \
    181181        external/ExRootAnalysis/ExRootUtilities.h
    182182DelphesValidation$(ExeSuf): \
     
    186186        validation/DelphesValidation.cpp \
    187187        classes/DelphesClasses.h \
     188        external/ExRootAnalysis/ExRootResult.h \
     189        external/ExRootAnalysis/ExRootTreeBranch.h \
    188190        external/ExRootAnalysis/ExRootTreeReader.h \
    189191        external/ExRootAnalysis/ExRootTreeWriter.h \
    190         external/ExRootAnalysis/ExRootTreeBranch.h \
    191         external/ExRootAnalysis/ExRootResult.h \
    192192        external/ExRootAnalysis/ExRootUtilities.h
    193193EXECUTABLE +=  \
     
    218218tmp/readers/DelphesHepMC.$(ObjSuf): \
    219219        readers/DelphesHepMC.cpp \
     220        classes/DelphesClasses.h \
     221        classes/DelphesFactory.h \
     222        classes/DelphesHepMCReader.h \
    220223        modules/Delphes.h \
    221         classes/DelphesClasses.h \
    222         classes/DelphesFactory.h \
    223         classes/DelphesHepMCReader.h \
    224         external/ExRootAnalysis/ExRootTreeWriter.h \
     224        external/ExRootAnalysis/ExRootProgressBar.h \
    225225        external/ExRootAnalysis/ExRootTreeBranch.h \
    226         external/ExRootAnalysis/ExRootProgressBar.h
     226        external/ExRootAnalysis/ExRootTreeWriter.h
    227227DelphesLHEF$(ExeSuf): \
    228228        tmp/readers/DelphesLHEF.$(ObjSuf)
     
    230230tmp/readers/DelphesLHEF.$(ObjSuf): \
    231231        readers/DelphesLHEF.cpp \
     232        classes/DelphesClasses.h \
     233        classes/DelphesFactory.h \
     234        classes/DelphesLHEFReader.h \
    232235        modules/Delphes.h \
    233         classes/DelphesClasses.h \
    234         classes/DelphesFactory.h \
    235         classes/DelphesLHEFReader.h \
    236         external/ExRootAnalysis/ExRootTreeWriter.h \
     236        external/ExRootAnalysis/ExRootProgressBar.h \
    237237        external/ExRootAnalysis/ExRootTreeBranch.h \
    238         external/ExRootAnalysis/ExRootProgressBar.h
     238        external/ExRootAnalysis/ExRootTreeWriter.h
    239239DelphesROOT$(ExeSuf): \
    240240        tmp/readers/DelphesROOT.$(ObjSuf)
     
    242242tmp/readers/DelphesROOT.$(ObjSuf): \
    243243        readers/DelphesROOT.cpp \
     244        classes/DelphesClasses.h \
     245        classes/DelphesFactory.h \
     246        classes/DelphesStream.h \
    244247        modules/Delphes.h \
    245         classes/DelphesStream.h \
    246         classes/DelphesClasses.h \
    247         classes/DelphesFactory.h \
    248         external/ExRootAnalysis/ExRootTreeWriter.h \
     248        external/ExRootAnalysis/ExRootProgressBar.h \
     249        external/ExRootAnalysis/ExRootTreeBranch.h \
    249250        external/ExRootAnalysis/ExRootTreeReader.h \
    250         external/ExRootAnalysis/ExRootTreeBranch.h \
    251         external/ExRootAnalysis/ExRootProgressBar.h
     251        external/ExRootAnalysis/ExRootTreeWriter.h
    252252DelphesSTDHEP$(ExeSuf): \
    253253        tmp/readers/DelphesSTDHEP.$(ObjSuf)
     
    255255tmp/readers/DelphesSTDHEP.$(ObjSuf): \
    256256        readers/DelphesSTDHEP.cpp \
     257        classes/DelphesClasses.h \
     258        classes/DelphesFactory.h \
     259        classes/DelphesSTDHEPReader.h \
    257260        modules/Delphes.h \
    258         classes/DelphesClasses.h \
    259         classes/DelphesFactory.h \
    260         classes/DelphesSTDHEPReader.h \
    261         external/ExRootAnalysis/ExRootTreeWriter.h \
     261        external/ExRootAnalysis/ExRootProgressBar.h \
    262262        external/ExRootAnalysis/ExRootTreeBranch.h \
    263         external/ExRootAnalysis/ExRootProgressBar.h
     263        external/ExRootAnalysis/ExRootTreeWriter.h
    264264EXECUTABLE +=  \
    265265        DelphesHepMC$(ExeSuf) \
     
    280280tmp/readers/DelphesCMSFWLite.$(ObjSuf): \
    281281        readers/DelphesCMSFWLite.cpp \
     282        classes/DelphesClasses.h \
     283        classes/DelphesFactory.h \
     284        classes/DelphesStream.h \
    282285        modules/Delphes.h \
    283         classes/DelphesStream.h \
    284         classes/DelphesClasses.h \
    285         classes/DelphesFactory.h \
    286         external/ExRootAnalysis/ExRootTreeWriter.h \
     286        external/ExRootAnalysis/ExRootProgressBar.h \
    287287        external/ExRootAnalysis/ExRootTreeBranch.h \
    288         external/ExRootAnalysis/ExRootProgressBar.h
     288        external/ExRootAnalysis/ExRootTreeWriter.h
    289289EXECUTABLE +=  \
    290290        DelphesCMSFWLite$(ExeSuf)
     
    301301tmp/readers/DelphesProMC.$(ObjSuf): \
    302302        readers/DelphesProMC.cpp \
     303        classes/DelphesClasses.h \
     304        classes/DelphesFactory.h \
     305        classes/DelphesStream.h \
    303306        modules/Delphes.h \
    304         classes/DelphesStream.h \
    305         classes/DelphesClasses.h \
    306         classes/DelphesFactory.h \
    307         external/ExRootAnalysis/ExRootTreeWriter.h \
     307        external/ExRootAnalysis/ExRootProgressBar.h \
    308308        external/ExRootAnalysis/ExRootTreeBranch.h \
    309         external/ExRootAnalysis/ExRootProgressBar.h
     309        external/ExRootAnalysis/ExRootTreeWriter.h
    310310EXECUTABLE +=  \
    311311        DelphesProMC$(ExeSuf)
     
    322322tmp/readers/DelphesProIO.$(ObjSuf): \
    323323        readers/DelphesProIO.cpp \
     324        classes/DelphesClasses.h \
     325        classes/DelphesFactory.h \
     326        classes/DelphesStream.h \
    324327        modules/Delphes.h \
    325         classes/DelphesStream.h \
    326         classes/DelphesClasses.h \
    327         classes/DelphesFactory.h \
    328         external/ExRootAnalysis/ExRootTreeWriter.h \
     328        external/ExRootAnalysis/ExRootProgressBar.h \
    329329        external/ExRootAnalysis/ExRootTreeBranch.h \
    330         external/ExRootAnalysis/ExRootProgressBar.h
     330        external/ExRootAnalysis/ExRootTreeWriter.h
    331331EXECUTABLE +=  \
    332332        DelphesProIO$(ExeSuf)
     
    343343tmp/readers/DelphesPythia8.$(ObjSuf): \
    344344        readers/DelphesPythia8.cpp \
     345        classes/DelphesClasses.h \
     346        classes/DelphesFactory.h \
     347        classes/DelphesLHEFReader.h \
    345348        modules/Delphes.h \
    346         classes/DelphesClasses.h \
    347         classes/DelphesFactory.h \
    348         classes/DelphesLHEFReader.h \
    349         external/ExRootAnalysis/ExRootTreeWriter.h \
     349        external/ExRootAnalysis/ExRootProgressBar.h \
    350350        external/ExRootAnalysis/ExRootTreeBranch.h \
    351         external/ExRootAnalysis/ExRootProgressBar.h
     351        external/ExRootAnalysis/ExRootTreeWriter.h
    352352EXECUTABLE +=  \
    353353        DelphesPythia8$(ExeSuf)
     
    527527        classes/DelphesModule.h \
    528528        classes/DelphesFactory.h \
     529        external/ExRootAnalysis/ExRootResult.h \
     530        external/ExRootAnalysis/ExRootTreeBranch.h \
    529531        external/ExRootAnalysis/ExRootTreeReader.h \
    530         external/ExRootAnalysis/ExRootTreeBranch.h \
    531         external/ExRootAnalysis/ExRootTreeWriter.h \
    532         external/ExRootAnalysis/ExRootResult.h
     532        external/ExRootAnalysis/ExRootTreeWriter.h
    533533tmp/classes/DelphesPileUpReader.$(ObjSuf): \
    534534        classes/DelphesPileUpReader.$(SrcSuf) \
     
    650650        classes/DelphesFactory.h \
    651651        classes/DelphesFormula.h \
    652         external/ExRootAnalysis/ExRootResult.h \
    653         external/ExRootAnalysis/ExRootFilter.h \
    654         external/ExRootAnalysis/ExRootClassifier.h
     652        external/ExRootAnalysis/ExRootClassifier.h \
     653        external/ExRootAnalysis/ExRootFilter.h \
     654        external/ExRootAnalysis/ExRootResult.h
    655655tmp/modules/BTagging.$(ObjSuf): \
    656656        modules/BTagging.$(SrcSuf) \
     
    665665        classes/DelphesFactory.h \
    666666        classes/DelphesFormula.h \
    667         external/ExRootAnalysis/ExRootResult.h \
    668         external/ExRootAnalysis/ExRootFilter.h \
    669         external/ExRootAnalysis/ExRootClassifier.h
     667        external/ExRootAnalysis/ExRootClassifier.h \
     668        external/ExRootAnalysis/ExRootFilter.h \
     669        external/ExRootAnalysis/ExRootResult.h
    670670tmp/modules/Calorimeter.$(ObjSuf): \
    671671        modules/Calorimeter.$(SrcSuf) \
     
    674674        classes/DelphesFactory.h \
    675675        classes/DelphesFormula.h \
    676         external/ExRootAnalysis/ExRootResult.h \
    677         external/ExRootAnalysis/ExRootFilter.h \
    678         external/ExRootAnalysis/ExRootClassifier.h
     676        external/ExRootAnalysis/ExRootClassifier.h \
     677        external/ExRootAnalysis/ExRootFilter.h \
     678        external/ExRootAnalysis/ExRootResult.h
    679679tmp/modules/Cloner.$(ObjSuf): \
    680680        modules/Cloner.$(SrcSuf) \
     
    683683        classes/DelphesFactory.h \
    684684        classes/DelphesFormula.h \
    685         external/ExRootAnalysis/ExRootResult.h \
    686         external/ExRootAnalysis/ExRootFilter.h \
    687         external/ExRootAnalysis/ExRootClassifier.h
     685        external/ExRootAnalysis/ExRootClassifier.h \
     686        external/ExRootAnalysis/ExRootFilter.h \
     687        external/ExRootAnalysis/ExRootResult.h
    688688tmp/modules/ConstituentFilter.$(ObjSuf): \
    689689        modules/ConstituentFilter.$(SrcSuf) \
     
    692692        classes/DelphesFactory.h \
    693693        classes/DelphesFormula.h \
    694         external/ExRootAnalysis/ExRootResult.h \
    695         external/ExRootAnalysis/ExRootFilter.h \
    696         external/ExRootAnalysis/ExRootClassifier.h
     694        external/ExRootAnalysis/ExRootClassifier.h \
     695        external/ExRootAnalysis/ExRootFilter.h \
     696        external/ExRootAnalysis/ExRootResult.h
    697697tmp/modules/Delphes.$(ObjSuf): \
    698698        modules/Delphes.$(SrcSuf) \
     
    701701        classes/DelphesFactory.h \
    702702        classes/DelphesFormula.h \
     703        external/ExRootAnalysis/ExRootClassifier.h \
     704        external/ExRootAnalysis/ExRootConfReader.h \
     705        external/ExRootAnalysis/ExRootFilter.h \
    703706        external/ExRootAnalysis/ExRootResult.h \
    704         external/ExRootAnalysis/ExRootFilter.h \
    705         external/ExRootAnalysis/ExRootClassifier.h \
    706         external/ExRootAnalysis/ExRootConfReader.h \
    707707        external/ExRootAnalysis/ExRootTreeWriter.h
    708708tmp/modules/DenseTrackFilter.$(ObjSuf): \
     
    712712        classes/DelphesFactory.h \
    713713        classes/DelphesFormula.h \
    714         external/ExRootAnalysis/ExRootResult.h \
    715         external/ExRootAnalysis/ExRootFilter.h \
    716         external/ExRootAnalysis/ExRootClassifier.h
     714        external/ExRootAnalysis/ExRootClassifier.h \
     715        external/ExRootAnalysis/ExRootFilter.h \
     716        external/ExRootAnalysis/ExRootResult.h
    717717tmp/modules/DualReadoutCalorimeter.$(ObjSuf): \
    718718        modules/DualReadoutCalorimeter.$(SrcSuf) \
     
    730730        classes/DelphesFactory.h \
    731731        classes/DelphesFormula.h \
    732         external/ExRootAnalysis/ExRootResult.h \
    733         external/ExRootAnalysis/ExRootFilter.h \
    734         external/ExRootAnalysis/ExRootClassifier.h
     732        external/ExRootAnalysis/ExRootClassifier.h \
     733        external/ExRootAnalysis/ExRootFilter.h \
     734        external/ExRootAnalysis/ExRootResult.h
    735735tmp/modules/EnergyScale.$(ObjSuf): \
    736736        modules/EnergyScale.$(SrcSuf) \
     
    739739        classes/DelphesFactory.h \
    740740        classes/DelphesFormula.h \
    741         external/ExRootAnalysis/ExRootResult.h \
    742         external/ExRootAnalysis/ExRootFilter.h \
    743         external/ExRootAnalysis/ExRootClassifier.h
     741        external/ExRootAnalysis/ExRootClassifier.h \
     742        external/ExRootAnalysis/ExRootFilter.h \
     743        external/ExRootAnalysis/ExRootResult.h
    744744tmp/modules/EnergySmearing.$(ObjSuf): \
    745745        modules/EnergySmearing.$(SrcSuf) \
     
    748748        classes/DelphesFactory.h \
    749749        classes/DelphesFormula.h \
    750         external/ExRootAnalysis/ExRootResult.h \
    751         external/ExRootAnalysis/ExRootFilter.h \
    752         external/ExRootAnalysis/ExRootClassifier.h
     750        external/ExRootAnalysis/ExRootClassifier.h \
     751        external/ExRootAnalysis/ExRootFilter.h \
     752        external/ExRootAnalysis/ExRootResult.h
    753753tmp/modules/ExampleModule.$(ObjSuf): \
    754754        modules/ExampleModule.$(SrcSuf) \
     
    757757        classes/DelphesFactory.h \
    758758        classes/DelphesFormula.h \
    759         external/ExRootAnalysis/ExRootResult.h \
    760         external/ExRootAnalysis/ExRootFilter.h \
    761         external/ExRootAnalysis/ExRootClassifier.h
     759        external/ExRootAnalysis/ExRootClassifier.h \
     760        external/ExRootAnalysis/ExRootFilter.h \
     761        external/ExRootAnalysis/ExRootResult.h
    762762tmp/modules/Hector.$(ObjSuf): \
    763763        modules/Hector.$(SrcSuf) \
     
    766766        classes/DelphesFactory.h \
    767767        classes/DelphesFormula.h \
     768        external/ExRootAnalysis/ExRootClassifier.h \
     769        external/ExRootAnalysis/ExRootFilter.h \
    768770        external/ExRootAnalysis/ExRootResult.h \
    769         external/ExRootAnalysis/ExRootFilter.h \
    770         external/ExRootAnalysis/ExRootClassifier.h \
    771771        external/Hector/H_BeamLine.h \
    772         external/Hector/H_RecRPObject.h \
    773         external/Hector/H_BeamParticle.h
     772        external/Hector/H_BeamParticle.h \
     773        external/Hector/H_RecRPObject.h
    774774tmp/modules/IdentificationMap.$(ObjSuf): \
    775775        modules/IdentificationMap.$(SrcSuf) \
     
    778778        classes/DelphesFactory.h \
    779779        classes/DelphesFormula.h \
    780         external/ExRootAnalysis/ExRootResult.h \
    781         external/ExRootAnalysis/ExRootFilter.h \
    782         external/ExRootAnalysis/ExRootClassifier.h
     780        external/ExRootAnalysis/ExRootClassifier.h \
     781        external/ExRootAnalysis/ExRootFilter.h \
     782        external/ExRootAnalysis/ExRootResult.h
    783783tmp/modules/ImpactParameterSmearing.$(ObjSuf): \
    784784        modules/ImpactParameterSmearing.$(SrcSuf) \
     
    787787        classes/DelphesFactory.h \
    788788        classes/DelphesFormula.h \
    789         external/ExRootAnalysis/ExRootResult.h \
    790         external/ExRootAnalysis/ExRootFilter.h \
    791         external/ExRootAnalysis/ExRootClassifier.h
     789        external/ExRootAnalysis/ExRootClassifier.h \
     790        external/ExRootAnalysis/ExRootFilter.h \
     791        external/ExRootAnalysis/ExRootResult.h
    792792tmp/modules/Isolation.$(ObjSuf): \
    793793        modules/Isolation.$(SrcSuf) \
     
    796796        classes/DelphesFactory.h \
    797797        classes/DelphesFormula.h \
    798         external/ExRootAnalysis/ExRootResult.h \
    799         external/ExRootAnalysis/ExRootFilter.h \
    800         external/ExRootAnalysis/ExRootClassifier.h
     798        external/ExRootAnalysis/ExRootClassifier.h \
     799        external/ExRootAnalysis/ExRootFilter.h \
     800        external/ExRootAnalysis/ExRootResult.h
    801801tmp/modules/JetFakeParticle.$(ObjSuf): \
    802802        modules/JetFakeParticle.$(SrcSuf) \
     
    805805        classes/DelphesFactory.h \
    806806        classes/DelphesFormula.h \
    807         external/ExRootAnalysis/ExRootResult.h \
    808         external/ExRootAnalysis/ExRootFilter.h \
    809         external/ExRootAnalysis/ExRootClassifier.h
     807        external/ExRootAnalysis/ExRootClassifier.h \
     808        external/ExRootAnalysis/ExRootFilter.h \
     809        external/ExRootAnalysis/ExRootResult.h
    810810tmp/modules/JetFlavorAssociation.$(ObjSuf): \
    811811        modules/JetFlavorAssociation.$(SrcSuf) \
     
    814814        classes/DelphesFactory.h \
    815815        classes/DelphesFormula.h \
    816         external/ExRootAnalysis/ExRootResult.h \
    817         external/ExRootAnalysis/ExRootFilter.h \
    818         external/ExRootAnalysis/ExRootClassifier.h
     816        external/ExRootAnalysis/ExRootClassifier.h \
     817        external/ExRootAnalysis/ExRootFilter.h \
     818        external/ExRootAnalysis/ExRootResult.h
    819819tmp/modules/JetPileUpSubtractor.$(ObjSuf): \
    820820        modules/JetPileUpSubtractor.$(SrcSuf) \
     
    823823        classes/DelphesFactory.h \
    824824        classes/DelphesFormula.h \
    825         external/ExRootAnalysis/ExRootResult.h \
    826         external/ExRootAnalysis/ExRootFilter.h \
    827         external/ExRootAnalysis/ExRootClassifier.h
     825        external/ExRootAnalysis/ExRootClassifier.h \
     826        external/ExRootAnalysis/ExRootFilter.h \
     827        external/ExRootAnalysis/ExRootResult.h
    828828tmp/modules/LeptonDressing.$(ObjSuf): \
    829829        modules/LeptonDressing.$(SrcSuf) \
     
    832832        classes/DelphesFactory.h \
    833833        classes/DelphesFormula.h \
    834         external/ExRootAnalysis/ExRootResult.h \
    835         external/ExRootAnalysis/ExRootFilter.h \
    836         external/ExRootAnalysis/ExRootClassifier.h
     834        external/ExRootAnalysis/ExRootClassifier.h \
     835        external/ExRootAnalysis/ExRootFilter.h \
     836        external/ExRootAnalysis/ExRootResult.h
    837837tmp/modules/Merger.$(ObjSuf): \
    838838        modules/Merger.$(SrcSuf) \
     
    841841        classes/DelphesFactory.h \
    842842        classes/DelphesFormula.h \
    843         external/ExRootAnalysis/ExRootResult.h \
    844         external/ExRootAnalysis/ExRootFilter.h \
    845         external/ExRootAnalysis/ExRootClassifier.h
     843        external/ExRootAnalysis/ExRootClassifier.h \
     844        external/ExRootAnalysis/ExRootFilter.h \
     845        external/ExRootAnalysis/ExRootResult.h
    846846tmp/modules/MomentumSmearing.$(ObjSuf): \
    847847        modules/MomentumSmearing.$(SrcSuf) \
     
    850850        classes/DelphesFactory.h \
    851851        classes/DelphesFormula.h \
    852         external/ExRootAnalysis/ExRootResult.h \
    853         external/ExRootAnalysis/ExRootFilter.h \
    854         external/ExRootAnalysis/ExRootClassifier.h
     852        external/ExRootAnalysis/ExRootClassifier.h \
     853        external/ExRootAnalysis/ExRootFilter.h \
     854        external/ExRootAnalysis/ExRootResult.h
    855855tmp/modules/OldCalorimeter.$(ObjSuf): \
    856856        modules/OldCalorimeter.$(SrcSuf) \
     
    859859        classes/DelphesFactory.h \
    860860        classes/DelphesFormula.h \
    861         external/ExRootAnalysis/ExRootResult.h \
    862         external/ExRootAnalysis/ExRootFilter.h \
    863         external/ExRootAnalysis/ExRootClassifier.h
     861        external/ExRootAnalysis/ExRootClassifier.h \
     862        external/ExRootAnalysis/ExRootFilter.h \
     863        external/ExRootAnalysis/ExRootResult.h
    864864tmp/modules/ParticlePropagator.$(ObjSuf): \
    865865        modules/ParticlePropagator.$(SrcSuf) \
     
    868868        classes/DelphesFactory.h \
    869869        classes/DelphesFormula.h \
    870         external/ExRootAnalysis/ExRootResult.h \
    871         external/ExRootAnalysis/ExRootFilter.h \
    872         external/ExRootAnalysis/ExRootClassifier.h
     870        external/ExRootAnalysis/ExRootClassifier.h \
     871        external/ExRootAnalysis/ExRootFilter.h \
     872        external/ExRootAnalysis/ExRootResult.h
    873873tmp/modules/PdgCodeFilter.$(ObjSuf): \
    874874        modules/PdgCodeFilter.$(SrcSuf) \
     
    877877        classes/DelphesFactory.h \
    878878        classes/DelphesFormula.h \
    879         external/ExRootAnalysis/ExRootResult.h \
    880         external/ExRootAnalysis/ExRootFilter.h \
    881         external/ExRootAnalysis/ExRootClassifier.h
     879        external/ExRootAnalysis/ExRootClassifier.h \
     880        external/ExRootAnalysis/ExRootFilter.h \
     881        external/ExRootAnalysis/ExRootResult.h
    882882tmp/modules/PhotonConversions.$(ObjSuf): \
    883883        modules/PhotonConversions.$(SrcSuf) \
    884884        modules/PhotonConversions.h \
    885885        classes/DelphesClasses.h \
    886         classes/DelphesFactory.h \
    887886        classes/DelphesCylindricalFormula.h \
    888         external/ExRootAnalysis/ExRootResult.h \
    889         external/ExRootAnalysis/ExRootFilter.h \
    890         external/ExRootAnalysis/ExRootClassifier.h
     887        classes/DelphesFactory.h \
     888        external/ExRootAnalysis/ExRootClassifier.h \
     889        external/ExRootAnalysis/ExRootFilter.h \
     890        external/ExRootAnalysis/ExRootResult.h
    891891tmp/modules/PhotonID.$(ObjSuf): \
    892892        modules/PhotonID.$(SrcSuf) \
     
    895895        classes/DelphesFactory.h \
    896896        classes/DelphesFormula.h \
    897         external/ExRootAnalysis/ExRootResult.h \
    898         external/ExRootAnalysis/ExRootFilter.h \
    899         external/ExRootAnalysis/ExRootClassifier.h
     897        external/ExRootAnalysis/ExRootClassifier.h \
     898        external/ExRootAnalysis/ExRootFilter.h \
     899        external/ExRootAnalysis/ExRootResult.h
    900900tmp/modules/PileUpJetID.$(ObjSuf): \
    901901        modules/PileUpJetID.$(SrcSuf) \
     
    904904        classes/DelphesFactory.h \
    905905        classes/DelphesFormula.h \
    906         external/ExRootAnalysis/ExRootResult.h \
    907         external/ExRootAnalysis/ExRootFilter.h \
    908         external/ExRootAnalysis/ExRootClassifier.h
     906        external/ExRootAnalysis/ExRootClassifier.h \
     907        external/ExRootAnalysis/ExRootFilter.h \
     908        external/ExRootAnalysis/ExRootResult.h
    909909tmp/modules/PileUpMerger.$(ObjSuf): \
    910910        modules/PileUpMerger.$(SrcSuf) \
     
    912912        classes/DelphesClasses.h \
    913913        classes/DelphesFactory.h \
     914        classes/DelphesPileUpReader.h \
    914915        classes/DelphesTF2.h \
    915         classes/DelphesPileUpReader.h \
    916         external/ExRootAnalysis/ExRootResult.h \
    917         external/ExRootAnalysis/ExRootFilter.h \
    918         external/ExRootAnalysis/ExRootClassifier.h
     916        external/ExRootAnalysis/ExRootClassifier.h \
     917        external/ExRootAnalysis/ExRootFilter.h \
     918        external/ExRootAnalysis/ExRootResult.h
    919919tmp/modules/PileUpMergerPythia8.$(ObjSuf): \
    920920        modules/PileUpMergerPythia8.$(SrcSuf) \
     
    922922        classes/DelphesClasses.h \
    923923        classes/DelphesFactory.h \
     924        classes/DelphesPileUpReader.h \
    924925        classes/DelphesTF2.h \
    925         classes/DelphesPileUpReader.h \
    926         external/ExRootAnalysis/ExRootResult.h \
    927         external/ExRootAnalysis/ExRootFilter.h \
    928         external/ExRootAnalysis/ExRootClassifier.h
     926        external/ExRootAnalysis/ExRootClassifier.h \
     927        external/ExRootAnalysis/ExRootFilter.h \
     928        external/ExRootAnalysis/ExRootResult.h
    929929tmp/modules/RecoPuFilter.$(ObjSuf): \
    930930        modules/RecoPuFilter.$(SrcSuf) \
     
    933933        classes/DelphesFactory.h \
    934934        classes/DelphesFormula.h \
    935         external/ExRootAnalysis/ExRootResult.h \
    936         external/ExRootAnalysis/ExRootFilter.h \
    937         external/ExRootAnalysis/ExRootClassifier.h
     935        external/ExRootAnalysis/ExRootClassifier.h \
     936        external/ExRootAnalysis/ExRootFilter.h \
     937        external/ExRootAnalysis/ExRootResult.h
    938938tmp/modules/SimpleCalorimeter.$(ObjSuf): \
    939939        modules/SimpleCalorimeter.$(SrcSuf) \
     
    942942        classes/DelphesFactory.h \
    943943        classes/DelphesFormula.h \
    944         external/ExRootAnalysis/ExRootResult.h \
    945         external/ExRootAnalysis/ExRootFilter.h \
    946         external/ExRootAnalysis/ExRootClassifier.h
     944        external/ExRootAnalysis/ExRootClassifier.h \
     945        external/ExRootAnalysis/ExRootFilter.h \
     946        external/ExRootAnalysis/ExRootResult.h
    947947tmp/modules/StatusPidFilter.$(ObjSuf): \
    948948        modules/StatusPidFilter.$(SrcSuf) \
     
    951951        classes/DelphesFactory.h \
    952952        classes/DelphesFormula.h \
    953         external/ExRootAnalysis/ExRootResult.h \
    954         external/ExRootAnalysis/ExRootFilter.h \
    955         external/ExRootAnalysis/ExRootClassifier.h
     953        external/ExRootAnalysis/ExRootClassifier.h \
     954        external/ExRootAnalysis/ExRootFilter.h \
     955        external/ExRootAnalysis/ExRootResult.h
    956956tmp/modules/TaggingParticlesSkimmer.$(ObjSuf): \
    957957        modules/TaggingParticlesSkimmer.$(SrcSuf) \
     
    961961        classes/DelphesFactory.h \
    962962        classes/DelphesFormula.h \
    963         external/ExRootAnalysis/ExRootResult.h \
    964         external/ExRootAnalysis/ExRootFilter.h \
    965         external/ExRootAnalysis/ExRootClassifier.h
     963        external/ExRootAnalysis/ExRootClassifier.h \
     964        external/ExRootAnalysis/ExRootFilter.h \
     965        external/ExRootAnalysis/ExRootResult.h
    966966tmp/modules/TauTagging.$(ObjSuf): \
    967967        modules/TauTagging.$(SrcSuf) \
     
    976976        classes/DelphesFactory.h \
    977977        classes/DelphesFormula.h \
    978         external/ExRootAnalysis/ExRootResult.h \
    979         external/ExRootAnalysis/ExRootFilter.h \
    980         external/ExRootAnalysis/ExRootClassifier.h
     978        external/ExRootAnalysis/ExRootClassifier.h \
     979        external/ExRootAnalysis/ExRootFilter.h \
     980        external/ExRootAnalysis/ExRootResult.h
    981981tmp/modules/TrackCountingBTagging.$(ObjSuf): \
    982982        modules/TrackCountingBTagging.$(SrcSuf) \
     
    991991        classes/DelphesFactory.h \
    992992        classes/DelphesFormula.h \
    993         external/ExRootAnalysis/ExRootResult.h \
    994         external/ExRootAnalysis/ExRootFilter.h \
    995         external/ExRootAnalysis/ExRootClassifier.h
     993        external/ExRootAnalysis/ExRootClassifier.h \
     994        external/ExRootAnalysis/ExRootFilter.h \
     995        external/ExRootAnalysis/ExRootResult.h
    996996tmp/modules/TrackPileUpSubtractor.$(ObjSuf): \
    997997        modules/TrackPileUpSubtractor.$(SrcSuf) \
     
    10001000        classes/DelphesFactory.h \
    10011001        classes/DelphesFormula.h \
    1002         external/ExRootAnalysis/ExRootResult.h \
    1003         external/ExRootAnalysis/ExRootFilter.h \
    1004         external/ExRootAnalysis/ExRootClassifier.h
     1002        external/ExRootAnalysis/ExRootClassifier.h \
     1003        external/ExRootAnalysis/ExRootFilter.h \
     1004        external/ExRootAnalysis/ExRootResult.h
    10051005tmp/modules/TrackSmearing.$(ObjSuf): \
    10061006        modules/TrackSmearing.$(SrcSuf) \
     
    10091009        classes/DelphesFactory.h \
    10101010        classes/DelphesFormula.h \
    1011         external/ExRootAnalysis/ExRootResult.h \
    1012         external/ExRootAnalysis/ExRootFilter.h \
    1013         external/ExRootAnalysis/ExRootClassifier.h
     1011        external/ExRootAnalysis/ExRootClassifier.h \
     1012        external/ExRootAnalysis/ExRootFilter.h \
     1013        external/ExRootAnalysis/ExRootResult.h
    10141014tmp/modules/TreeWriter.$(ObjSuf): \
    10151015        modules/TreeWriter.$(SrcSuf) \
     
    10181018        classes/DelphesFactory.h \
    10191019        classes/DelphesFormula.h \
     1020        external/ExRootAnalysis/ExRootClassifier.h \
     1021        external/ExRootAnalysis/ExRootFilter.h \
    10201022        external/ExRootAnalysis/ExRootResult.h \
    1021         external/ExRootAnalysis/ExRootFilter.h \
    1022         external/ExRootAnalysis/ExRootClassifier.h \
    10231023        external/ExRootAnalysis/ExRootTreeBranch.h
    10241024tmp/modules/UniqueObjectFinder.$(ObjSuf): \
     
    10281028        classes/DelphesFactory.h \
    10291029        classes/DelphesFormula.h \
    1030         external/ExRootAnalysis/ExRootResult.h \
    1031         external/ExRootAnalysis/ExRootFilter.h \
    1032         external/ExRootAnalysis/ExRootClassifier.h
     1030        external/ExRootAnalysis/ExRootClassifier.h \
     1031        external/ExRootAnalysis/ExRootFilter.h \
     1032        external/ExRootAnalysis/ExRootResult.h
    10331033tmp/modules/VertexFinder.$(ObjSuf): \
    10341034        modules/VertexFinder.$(SrcSuf) \
     
    10381038        classes/DelphesFormula.h \
    10391039        classes/DelphesPileUpReader.h \
    1040         external/ExRootAnalysis/ExRootResult.h \
    1041         external/ExRootAnalysis/ExRootFilter.h \
    1042         external/ExRootAnalysis/ExRootClassifier.h
     1040        external/ExRootAnalysis/ExRootClassifier.h \
     1041        external/ExRootAnalysis/ExRootFilter.h \
     1042        external/ExRootAnalysis/ExRootResult.h
    10431043tmp/modules/VertexFinderDA4D.$(ObjSuf): \
    10441044        modules/VertexFinderDA4D.$(SrcSuf) \
     
    10481048        classes/DelphesFormula.h \
    10491049        classes/DelphesPileUpReader.h \
    1050         external/ExRootAnalysis/ExRootResult.h \
    1051         external/ExRootAnalysis/ExRootFilter.h \
    1052         external/ExRootAnalysis/ExRootClassifier.h
     1050        external/ExRootAnalysis/ExRootClassifier.h \
     1051        external/ExRootAnalysis/ExRootFilter.h \
     1052        external/ExRootAnalysis/ExRootResult.h
    10531053tmp/modules/VertexSorter.$(ObjSuf): \
    10541054        modules/VertexSorter.$(SrcSuf) \
     
    10581058        classes/DelphesFormula.h \
    10591059        classes/DelphesPileUpReader.h \
    1060         external/ExRootAnalysis/ExRootResult.h \
    1061         external/ExRootAnalysis/ExRootFilter.h \
    1062         external/ExRootAnalysis/ExRootClassifier.h
     1060        external/ExRootAnalysis/ExRootClassifier.h \
     1061        external/ExRootAnalysis/ExRootFilter.h \
     1062        external/ExRootAnalysis/ExRootResult.h
    10631063tmp/modules/Weighter.$(ObjSuf): \
    10641064        modules/Weighter.$(SrcSuf) \
     
    10671067        classes/DelphesFactory.h \
    10681068        classes/DelphesFormula.h \
    1069         external/ExRootAnalysis/ExRootResult.h \
    1070         external/ExRootAnalysis/ExRootFilter.h \
    1071         external/ExRootAnalysis/ExRootClassifier.h
     1069        external/ExRootAnalysis/ExRootClassifier.h \
     1070        external/ExRootAnalysis/ExRootFilter.h \
     1071        external/ExRootAnalysis/ExRootResult.h
    10721072DELPHES_OBJ +=  \
    10731073        tmp/classes/DelphesClasses.$(ObjSuf) \
     
    15011501        classes/DelphesFactory.h \
    15021502        classes/DelphesFormula.h \
     1503        external/ExRootAnalysis/ExRootClassifier.h \
     1504        external/ExRootAnalysis/ExRootFilter.h \
    15031505        external/ExRootAnalysis/ExRootResult.h \
    1504         external/ExRootAnalysis/ExRootFilter.h \
    1505         external/ExRootAnalysis/ExRootClassifier.h \
     1506        external/fastjet/ClusterSequence.hh \
     1507        external/fastjet/ClusterSequenceArea.hh \
     1508        external/fastjet/JetDefinition.hh \
    15061509        external/fastjet/PseudoJet.hh \
    1507         external/fastjet/JetDefinition.hh \
    1508         external/fastjet/ClusterSequence.hh \
    15091510        external/fastjet/Selector.hh \
    1510         external/fastjet/ClusterSequenceArea.hh \
    15111511        external/fastjet/tools/JetMedianBackgroundEstimator.hh \
     1512        external/fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh \
     1513        external/fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh \
    15121514        external/fastjet/plugins/SISCone/fastjet/SISConePlugin.hh \
    1513         external/fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh \
    1514         external/fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh \
    1515         external/fastjet/contribs/Nsubjettiness/Nsubjettiness.hh \
     1515        external/fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh \
    15161516        external/fastjet/contribs/Nsubjettiness/Njettiness.hh \
    15171517        external/fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh \
    1518         external/fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh \
     1518        external/fastjet/contribs/Nsubjettiness/Nsubjettiness.hh \
    15191519        external/fastjet/contribs/ValenciaPlugin/ValenciaPlugin.hh \
     1520        external/fastjet/contribs/RecursiveTools/SoftDrop.hh \
    15201521        external/fastjet/tools/Filter.hh \
    1521         external/fastjet/tools/Pruner.hh \
    1522         external/fastjet/contribs/RecursiveTools/SoftDrop.hh
     1522        external/fastjet/tools/Pruner.hh
    15231523tmp/modules/FastJetGridMedianEstimator.$(ObjSuf): \
    15241524        modules/FastJetGridMedianEstimator.$(SrcSuf) \
     
    15271527        classes/DelphesFactory.h \
    15281528        classes/DelphesFormula.h \
     1529        external/ExRootAnalysis/ExRootClassifier.h \
     1530        external/ExRootAnalysis/ExRootFilter.h \
    15291531        external/ExRootAnalysis/ExRootResult.h \
    1530         external/ExRootAnalysis/ExRootFilter.h \
    1531         external/ExRootAnalysis/ExRootClassifier.h \
     1532        external/fastjet/ClusterSequence.hh \
     1533        external/fastjet/ClusterSequenceArea.hh \
     1534        external/fastjet/JetDefinition.hh \
    15321535        external/fastjet/PseudoJet.hh \
    1533         external/fastjet/JetDefinition.hh \
    1534         external/fastjet/ClusterSequence.hh \
     1536        external/fastjet/RectangularGrid.hh \
    15351537        external/fastjet/Selector.hh \
    1536         external/fastjet/RectangularGrid.hh \
    1537         external/fastjet/ClusterSequenceArea.hh \
    15381538        external/fastjet/tools/JetMedianBackgroundEstimator.hh \
    15391539        external/fastjet/tools/GridMedianBackgroundEstimator.hh \
     1540        external/fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh \
     1541        external/fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh \
    15401542        external/fastjet/plugins/SISCone/fastjet/SISConePlugin.hh \
    1541         external/fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh \
    1542         external/fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh \
    1543         external/fastjet/contribs/Nsubjettiness/Nsubjettiness.hh \
     1543        external/fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh \
    15441544        external/fastjet/contribs/Nsubjettiness/Njettiness.hh \
    15451545        external/fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh \
    1546         external/fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh
     1546        external/fastjet/contribs/Nsubjettiness/Nsubjettiness.hh
    15471547tmp/modules/RunPUPPI.$(ObjSuf): \
    15481548        modules/RunPUPPI.$(SrcSuf) \
    15491549        modules/RunPUPPI.h \
    1550         external/PUPPI/RecoObj2.hh \
    15511550        external/PUPPI/AlgoObj.hh \
    15521551        external/PUPPI/PuppiContainer.hh \
     1552        external/PUPPI/RecoObj2.hh \
    15531553        external/fastjet/PseudoJet.hh \
    15541554        classes/DelphesClasses.h \
     
    16821682tmp/display/DelphesEventDisplay.$(ObjSuf): \
    16831683        display/DelphesEventDisplay.$(SrcSuf) \
     1684        display/Delphes3DGeometry.h \
     1685        display/DelphesBranchElement.h \
    16841686        display/DelphesCaloData.h \
    1685         display/DelphesBranchElement.h \
    1686         display/Delphes3DGeometry.h \
     1687        display/DelphesDisplay.h \
    16871688        display/DelphesEventDisplay.h \
    1688         display/DelphesDisplay.h \
    1689         display/Delphes3DGeometry.h \
    16901689        display/DelphesHtmlSummary.h \
    16911690        display/DelphesPlotSummary.h \
     
    20552054
    20562055modules/TauTagging.h: \
    2057         classes/DelphesModule.h \
     2056        external/ExRootAnalysis/ExRootClassifier.h \
     2057        external/ExRootAnalysis/ExRootFilter.h \
    20582058        external/ExRootAnalysis/ExRootResult.h \
    2059         external/ExRootAnalysis/ExRootFilter.h \
    2060         external/ExRootAnalysis/ExRootClassifier.h
     2059        classes/DelphesModule.h
    20612060        @touch $@
    20622061
     
    21062105
    21072106modules/JetFlavorAssociation.h: \
    2108         classes/DelphesModule.h \
    2109         classes/DelphesClasses.h
     2107        classes/DelphesClasses.h \
     2108        classes/DelphesModule.h
    21102109        @touch $@
    21112110
  • README

    re39abb4 r0e7d64a  
    44Commands to get the code:
    55
    6    wget http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.4.1.tar.gz
     6   wget http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.4.2.tar.gz
    77
    8    tar -zxf Delphes-3.4.1.tar.gz
     8   tar -zxf Delphes-3.4.2.tar.gz
    99
    1010Commands to compile the code:
    1111
    12    cd Delphes-3.4.1
     12   cd Delphes-3.4.2
    1313
    1414   make
  • README.md

    re39abb4 r0e7d64a  
    1414
    1515```
    16    wget http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.4.1.tar.gz
     16   wget http://cp3.irmp.ucl.ac.be/downloads/Delphes-3.4.2.tar.gz
    1717
    18    tar -zxf Delphes-3.4.1.tar.gz
     18   tar -zxf Delphes-3.4.2.tar.gz
    1919```
    2020
     
    2222
    2323```
    24    cd Delphes-3.4.1
     24   cd Delphes-3.4.2
    2525
    2626   make
  • VERSION

    re39abb4 r0e7d64a  
    1 3.4.1
     13.4.2
  • cards/FCC/FCChh.tcl

    re39abb4 r0e7d64a  
    12391239
    12401240  (pt <= 10.0)                                                       * (0.00) +
    1241   (abs(eta) < 2.5) * (pt > 10.0 && pt < 5000.0)                      * (0.6)                      + \
    1242   (abs(eta) < 2.5) * (pt > 5000.0 && pt < 34000.0)                   * (0.6) *(8./9. - pt/30000.) + \
     1241  (abs(eta) < 2.5) * (pt > 10.0 && pt < 5000.0)                      * (0.8)                      + \
     1242  (abs(eta) < 2.5) * (pt > 5000.0 && pt < 34000.0)                   * (0.8) *(8./9. - pt/30000.) + \
    12431243  (abs(eta) < 2.5)                   * (pt > 34000.0)                * (0.000) + \
    1244   (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 10.0 && pt < 5000.0)    * (0.45) + \
    1245   (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 5000.0 && pt < 34000.0) * (0.45)*(8./9. - pt/30000.) + \
     1244  (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 10.0 && pt < 5000.0)    * (0.65) + \
     1245  (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 5000.0 && pt < 34000.0) * (0.65)*(8./9. - pt/30000.) + \
    12461246  (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 34000.0)                * (0.00) + \
    12471247  (abs(eta) > 4.0)                                                   * (0.00)}
  • cards/delphes_card_CLICdet_Stage1.tcl

    re39abb4 r0e7d64a  
    11#######################################
    22# CLICdet model
    3 # based on CLICdp-Note-2017-001
     3# based on arXiv:1812.07337 and
     4# CLICdp-Note-2017-001
     5#
    46# Ulrike Schnoor ulrike.schnoor@cern.ch
    57#
     
    1113# according to final state
    1214#
     15# c-tagging capabilities of CLICdet are
     16# not yet implemented here. Please
     17# contact us if you want to use it.
     18#######################################
     19
    1320#######################################
    1421# Order of execution of various modules
     
    707714    set OutputArray photons
    708715
    709     set DeltaRMax 0.5
     716    set DeltaRMax 0.1
    710717
    711718    set PTMin 0.5
    712719
    713     set PTRatioMax 0.12
     720    set PTRatioMax 0.2
    714721}
    715722
     
    805812    set OutputArray electrons
    806813
    807     set DeltaRMax 0.5
     814    set DeltaRMax 0.1
    808815
    809816    set PTMin 0.5
    810817
    811     set PTRatioMax 0.12
     818    set PTRatioMax 0.2
    812819}
    813820
     
    844851    set OutputArray muons
    845852
    846     set DeltaRMax 0.5
     853    set DeltaRMax 0.1
    847854
    848855    set PTMin 0.5
    849856
    850     set PTRatioMax 0.25
     857    set PTRatioMax 0.2
    851858}
    852859
  • cards/delphes_card_CLICdet_Stage2.tcl

    re39abb4 r0e7d64a  
    11#######################################
    22# CLICdet model
    3 # based on CLICdp-Note-2017-001
     3# based on arXiv:1812.07337 and
     4# CLICdp-Note-2017-001
     5#
    46# Ulrike Schnoor ulrike.schnoor@cern.ch
    57#
     
    1113# according to final state
    1214#
     15# c-tagging capabilities of CLICdet are
     16# not yet implemented here. Please
     17# contact us if you want to use it.
     18#######################################
     19
    1320#######################################
    1421# Order of execution of various modules
     
    124131
    125132    JetFlavorAssociation_R05N2
    126         JetFlavorAssociation_R05N3
    127         JetFlavorAssociation_R05N4
    128         JetFlavorAssociation_R05N5
    129         JetFlavorAssociation_R05N6
    130        
    131         JetFlavorAssociation_R07N2
    132         JetFlavorAssociation_R07N3
    133         JetFlavorAssociation_R07N4
    134         JetFlavorAssociation_R07N5
    135         JetFlavorAssociation_R07N6
    136 
    137         JetFlavorAssociation_R10N2
    138         JetFlavorAssociation_R10N3
    139         JetFlavorAssociation_R10N4
    140         JetFlavorAssociation_R10N5
    141         JetFlavorAssociation_R10N6
    142 
    143         JetFlavorAssociation_R12N2
    144         JetFlavorAssociation_R12N3
    145         JetFlavorAssociation_R12N4
    146         JetFlavorAssociation_R12N5
    147         JetFlavorAssociation_R12N6
    148 
    149         JetFlavorAssociation_R15N2
    150         JetFlavorAssociation_R15N3
    151         JetFlavorAssociation_R15N4
    152         JetFlavorAssociation_R15N5
    153         JetFlavorAssociation_R15N6
    154 
    155         JetFlavorAssociation_R05_inclusive
    156         JetFlavorAssociation_R07_inclusive
    157         JetFlavorAssociation_R10_inclusive
    158         JetFlavorAssociation_R12_inclusive
    159         JetFlavorAssociation_R15_inclusive
    160 
    161    
    162         BTaggingWP50_R05N2
    163         BTaggingWP70_R05N2
    164         BTaggingWP90_R05N2
    165         BTaggingWP50_R05N3
    166         BTaggingWP70_R05N3
    167         BTaggingWP90_R05N3
    168         BTaggingWP50_R05N4
    169         BTaggingWP70_R05N4
    170         BTaggingWP90_R05N4
    171         BTaggingWP50_R05N5
    172         BTaggingWP70_R05N5
    173         BTaggingWP90_R05N5
    174         BTaggingWP50_R05N6
    175         BTaggingWP70_R05N6
    176         BTaggingWP90_R05N6
    177         BTaggingWP50_R07N2
    178         BTaggingWP70_R07N2
    179         BTaggingWP90_R07N2
    180         BTaggingWP50_R07N3
    181         BTaggingWP70_R07N3
    182         BTaggingWP90_R07N3
    183         BTaggingWP50_R07N4
    184         BTaggingWP70_R07N4
    185         BTaggingWP90_R07N4
    186         BTaggingWP50_R07N5
    187         BTaggingWP70_R07N5
    188         BTaggingWP90_R07N5
    189         BTaggingWP50_R07N6
    190         BTaggingWP70_R07N6
    191         BTaggingWP90_R07N6
    192         BTaggingWP50_R10N2
    193         BTaggingWP70_R10N2
    194         BTaggingWP90_R10N2
    195         BTaggingWP50_R10N3
    196         BTaggingWP70_R10N3
    197         BTaggingWP90_R10N3
    198         BTaggingWP50_R10N4
    199         BTaggingWP70_R10N4
    200         BTaggingWP90_R10N4
    201         BTaggingWP50_R10N5
    202         BTaggingWP70_R10N5
    203         BTaggingWP90_R10N5
    204         BTaggingWP50_R10N6
    205         BTaggingWP70_R10N6
    206         BTaggingWP90_R10N6
    207         BTaggingWP50_R12N2
    208         BTaggingWP70_R12N2
    209         BTaggingWP90_R12N2
    210         BTaggingWP50_R12N3
    211         BTaggingWP70_R12N3
    212         BTaggingWP90_R12N3
    213         BTaggingWP50_R12N4
    214         BTaggingWP70_R12N4
    215         BTaggingWP90_R12N4
    216         BTaggingWP50_R12N5
    217         BTaggingWP70_R12N5
    218         BTaggingWP90_R12N5
    219         BTaggingWP50_R12N6
    220         BTaggingWP70_R12N6
    221         BTaggingWP90_R12N6
    222         BTaggingWP50_R15N2
    223         BTaggingWP70_R15N2
    224         BTaggingWP90_R15N2
    225         BTaggingWP50_R15N3
    226         BTaggingWP70_R15N3
    227         BTaggingWP90_R15N3
    228         BTaggingWP50_R15N4
    229         BTaggingWP70_R15N4
    230         BTaggingWP90_R15N4
    231         BTaggingWP50_R15N5
    232         BTaggingWP70_R15N5
    233         BTaggingWP90_R15N5
    234         BTaggingWP50_R15N6
    235         BTaggingWP70_R15N6
    236         BTaggingWP90_R15N6
     133    JetFlavorAssociation_R05N3
     134    JetFlavorAssociation_R05N4
     135    JetFlavorAssociation_R05N5
     136    JetFlavorAssociation_R05N6
     137   
     138    JetFlavorAssociation_R07N2
     139    JetFlavorAssociation_R07N3
     140    JetFlavorAssociation_R07N4
     141    JetFlavorAssociation_R07N5
     142    JetFlavorAssociation_R07N6
     143   
     144    JetFlavorAssociation_R10N2
     145    JetFlavorAssociation_R10N3
     146    JetFlavorAssociation_R10N4
     147    JetFlavorAssociation_R10N5
     148    JetFlavorAssociation_R10N6
     149   
     150    JetFlavorAssociation_R12N2
     151    JetFlavorAssociation_R12N3
     152    JetFlavorAssociation_R12N4
     153    JetFlavorAssociation_R12N5
     154    JetFlavorAssociation_R12N6
     155   
     156    JetFlavorAssociation_R15N2
     157    JetFlavorAssociation_R15N3
     158    JetFlavorAssociation_R15N4
     159    JetFlavorAssociation_R15N5
     160    JetFlavorAssociation_R15N6
     161   
     162    JetFlavorAssociation_R05_inclusive
     163    JetFlavorAssociation_R07_inclusive
     164    JetFlavorAssociation_R10_inclusive
     165    JetFlavorAssociation_R12_inclusive
     166    JetFlavorAssociation_R15_inclusive
     167
     168
     169    JetFlavorAssociation_JER_R05N2
     170    JetFlavorAssociation_JER_R05N3
     171    JetFlavorAssociation_JER_R05N4
     172    JetFlavorAssociation_JER_R05N5
     173    JetFlavorAssociation_JER_R05N6
     174   
     175    JetFlavorAssociation_JER_R07N2
     176    JetFlavorAssociation_JER_R07N3
     177    JetFlavorAssociation_JER_R07N4
     178    JetFlavorAssociation_JER_R07N5
     179    JetFlavorAssociation_JER_R07N6
     180   
     181    JetFlavorAssociation_JER_R10N2
     182    JetFlavorAssociation_JER_R10N3
     183    JetFlavorAssociation_JER_R10N4
     184    JetFlavorAssociation_JER_R10N5
     185    JetFlavorAssociation_JER_R10N6
     186   
     187    JetFlavorAssociation_JER_R12N2
     188    JetFlavorAssociation_JER_R12N3
     189    JetFlavorAssociation_JER_R12N4
     190    JetFlavorAssociation_JER_R12N5
     191    JetFlavorAssociation_JER_R12N6
     192   
     193    JetFlavorAssociation_JER_R15N2
     194    JetFlavorAssociation_JER_R15N3
     195    JetFlavorAssociation_JER_R15N4
     196    JetFlavorAssociation_JER_R15N5
     197    JetFlavorAssociation_JER_R15N6
     198   
     199    JetFlavorAssociation_JER_R05_inclusive
     200    JetFlavorAssociation_JER_R07_inclusive
     201    JetFlavorAssociation_JER_R10_inclusive
     202    JetFlavorAssociation_JER_R12_inclusive
     203    JetFlavorAssociation_JER_R15_inclusive
     204   
     205   
     206    BTaggingWP50_R05N2
     207    BTaggingWP70_R05N2
     208    BTaggingWP90_R05N2
     209    BTaggingWP50_R05N3
     210    BTaggingWP70_R05N3
     211    BTaggingWP90_R05N3
     212    BTaggingWP50_R05N4
     213    BTaggingWP70_R05N4
     214    BTaggingWP90_R05N4
     215    BTaggingWP50_R05N5
     216    BTaggingWP70_R05N5
     217    BTaggingWP90_R05N5
     218    BTaggingWP50_R05N6
     219    BTaggingWP70_R05N6
     220    BTaggingWP90_R05N6
     221    BTaggingWP50_R07N2
     222    BTaggingWP70_R07N2
     223    BTaggingWP90_R07N2
     224    BTaggingWP50_R07N3
     225    BTaggingWP70_R07N3
     226    BTaggingWP90_R07N3
     227    BTaggingWP50_R07N4
     228    BTaggingWP70_R07N4
     229    BTaggingWP90_R07N4
     230    BTaggingWP50_R07N5
     231    BTaggingWP70_R07N5
     232    BTaggingWP90_R07N5
     233    BTaggingWP50_R07N6
     234    BTaggingWP70_R07N6
     235    BTaggingWP90_R07N6
     236    BTaggingWP50_R10N2
     237    BTaggingWP70_R10N2
     238    BTaggingWP90_R10N2
     239    BTaggingWP50_R10N3
     240    BTaggingWP70_R10N3
     241    BTaggingWP90_R10N3
     242    BTaggingWP50_R10N4
     243    BTaggingWP70_R10N4
     244    BTaggingWP90_R10N4
     245    BTaggingWP50_R10N5
     246    BTaggingWP70_R10N5
     247    BTaggingWP90_R10N5
     248    BTaggingWP50_R10N6
     249    BTaggingWP70_R10N6
     250    BTaggingWP90_R10N6
     251    BTaggingWP50_R12N2
     252    BTaggingWP70_R12N2
     253    BTaggingWP90_R12N2
     254    BTaggingWP50_R12N3
     255    BTaggingWP70_R12N3
     256    BTaggingWP90_R12N3
     257    BTaggingWP50_R12N4
     258    BTaggingWP70_R12N4
     259    BTaggingWP90_R12N4
     260    BTaggingWP50_R12N5
     261    BTaggingWP70_R12N5
     262    BTaggingWP90_R12N5
     263    BTaggingWP50_R12N6
     264    BTaggingWP70_R12N6
     265    BTaggingWP90_R12N6
     266    BTaggingWP50_R15N2
     267    BTaggingWP70_R15N2
     268    BTaggingWP90_R15N2
     269    BTaggingWP50_R15N3
     270    BTaggingWP70_R15N3
     271    BTaggingWP90_R15N3
     272    BTaggingWP50_R15N4
     273    BTaggingWP70_R15N4
     274    BTaggingWP90_R15N4
     275    BTaggingWP50_R15N5
     276    BTaggingWP70_R15N5
     277    BTaggingWP90_R15N5
     278    BTaggingWP50_R15N6
     279    BTaggingWP70_R15N6
     280    BTaggingWP90_R15N6
    237281    BTaggingWP50_R05_inclusive
    238282    BTaggingWP70_R05_inclusive
     
    251295    BTaggingWP90_R15_inclusive
    252296
     297
     298
     299    BTagging_JER_WP50_R05N2
     300    BTagging_JER_WP70_R05N2
     301    BTagging_JER_WP90_R05N2
     302    BTagging_JER_WP50_R05N3
     303    BTagging_JER_WP70_R05N3
     304    BTagging_JER_WP90_R05N3
     305    BTagging_JER_WP50_R05N4
     306    BTagging_JER_WP70_R05N4
     307    BTagging_JER_WP90_R05N4
     308    BTagging_JER_WP50_R05N5
     309    BTagging_JER_WP70_R05N5
     310    BTagging_JER_WP90_R05N5
     311    BTagging_JER_WP50_R05N6
     312    BTagging_JER_WP70_R05N6
     313    BTagging_JER_WP90_R05N6
     314    BTagging_JER_WP50_R07N2
     315    BTagging_JER_WP70_R07N2
     316    BTagging_JER_WP90_R07N2
     317    BTagging_JER_WP50_R07N3
     318    BTagging_JER_WP70_R07N3
     319    BTagging_JER_WP90_R07N3
     320    BTagging_JER_WP50_R07N4
     321    BTagging_JER_WP70_R07N4
     322    BTagging_JER_WP90_R07N4
     323    BTagging_JER_WP50_R07N5
     324    BTagging_JER_WP70_R07N5
     325    BTagging_JER_WP90_R07N5
     326    BTagging_JER_WP50_R07N6
     327    BTagging_JER_WP70_R07N6
     328    BTagging_JER_WP90_R07N6
     329    BTagging_JER_WP50_R10N2
     330    BTagging_JER_WP70_R10N2
     331    BTagging_JER_WP90_R10N2
     332    BTagging_JER_WP50_R10N3
     333    BTagging_JER_WP70_R10N3
     334    BTagging_JER_WP90_R10N3
     335    BTagging_JER_WP50_R10N4
     336    BTagging_JER_WP70_R10N4
     337    BTagging_JER_WP90_R10N4
     338    BTagging_JER_WP50_R10N5
     339    BTagging_JER_WP70_R10N5
     340    BTagging_JER_WP90_R10N5
     341    BTagging_JER_WP50_R10N6
     342    BTagging_JER_WP70_R10N6
     343    BTagging_JER_WP90_R10N6
     344    BTagging_JER_WP50_R12N2
     345    BTagging_JER_WP70_R12N2
     346    BTagging_JER_WP90_R12N2
     347    BTagging_JER_WP50_R12N3
     348    BTagging_JER_WP70_R12N3
     349    BTagging_JER_WP90_R12N3
     350    BTagging_JER_WP50_R12N4
     351    BTagging_JER_WP70_R12N4
     352    BTagging_JER_WP90_R12N4
     353    BTagging_JER_WP50_R12N5
     354    BTagging_JER_WP70_R12N5
     355    BTagging_JER_WP90_R12N5
     356    BTagging_JER_WP50_R12N6
     357    BTagging_JER_WP70_R12N6
     358    BTagging_JER_WP90_R12N6
     359    BTagging_JER_WP50_R15N2
     360    BTagging_JER_WP70_R15N2
     361    BTagging_JER_WP90_R15N2
     362    BTagging_JER_WP50_R15N3
     363    BTagging_JER_WP70_R15N3
     364    BTagging_JER_WP90_R15N3
     365    BTagging_JER_WP50_R15N4
     366    BTagging_JER_WP70_R15N4
     367    BTagging_JER_WP90_R15N4
     368    BTagging_JER_WP50_R15N5
     369    BTagging_JER_WP70_R15N5
     370    BTagging_JER_WP90_R15N5
     371    BTagging_JER_WP50_R15N6
     372    BTagging_JER_WP70_R15N6
     373    BTagging_JER_WP90_R15N6
     374    BTagging_JER_WP50_R05_inclusive
     375    BTagging_JER_WP70_R05_inclusive
     376    BTagging_JER_WP90_R05_inclusive
     377    BTagging_JER_WP50_R07_inclusive
     378    BTagging_JER_WP70_R07_inclusive
     379    BTagging_JER_WP90_R07_inclusive
     380    BTagging_JER_WP50_R10_inclusive
     381    BTagging_JER_WP70_R10_inclusive
     382    BTagging_JER_WP90_R10_inclusive
     383    BTagging_JER_WP50_R12_inclusive
     384    BTagging_JER_WP70_R12_inclusive
     385    BTagging_JER_WP90_R12_inclusive
     386    BTagging_JER_WP50_R15_inclusive
     387    BTagging_JER_WP70_R15_inclusive
     388    BTagging_JER_WP90_R15_inclusive
     389   
    253390   
    254391    TauTagging_R05N2
     
    277414    TauTagging_R15N5
    278415    TauTagging_R15N6
    279 
    280416    TauTagging_R05_inclusive
    281417    TauTagging_R07_inclusive
     
    283419    TauTagging_R12_inclusive
    284420    TauTagging_R15_inclusive
     421
     422    TauTagging_JER_R05N2
     423    TauTagging_JER_R05N3
     424    TauTagging_JER_R05N4
     425    TauTagging_JER_R05N5
     426    TauTagging_JER_R05N6
     427    TauTagging_JER_R07N2
     428    TauTagging_JER_R07N3
     429    TauTagging_JER_R07N4
     430    TauTagging_JER_R07N5
     431    TauTagging_JER_R07N6
     432    TauTagging_JER_R10N2
     433    TauTagging_JER_R10N3
     434    TauTagging_JER_R10N4
     435    TauTagging_JER_R10N5
     436    TauTagging_JER_R10N6
     437    TauTagging_JER_R12N2
     438    TauTagging_JER_R12N3
     439    TauTagging_JER_R12N4
     440    TauTagging_JER_R12N5
     441    TauTagging_JER_R12N6
     442    TauTagging_JER_R15N2
     443    TauTagging_JER_R15N3
     444    TauTagging_JER_R15N4
     445    TauTagging_JER_R15N5
     446    TauTagging_JER_R15N6
     447    TauTagging_JER_R05_inclusive
     448    TauTagging_JER_R07_inclusive
     449    TauTagging_JER_R10_inclusive
     450    TauTagging_JER_R12_inclusive
     451    TauTagging_JER_R15_inclusive
    285452
    286453
     
    739906    set OutputArray photons
    740907
    741     set DeltaRMax 0.5
     908    set DeltaRMax 0.1
    742909
    743910    set PTMin 0.5
    744911
    745     set PTRatioMax 0.12
     912    set PTRatioMax 0.2
    746913}
    747914
     
    8371004    set OutputArray electrons
    8381005
    839     set DeltaRMax 0.5
     1006    set DeltaRMax 0.1
    8401007
    8411008    set PTMin 0.5
    8421009
    843     set PTRatioMax 0.12
     1010    set PTRatioMax 0.2
    8441011}
    8451012
     
    8751042    set OutputArray muons
    8761043
    877     set DeltaRMax 0.5
     1044    set DeltaRMax 0.1
    8781045
    8791046    set PTMin 0.5
    8801047
    881     set PTRatioMax 0.25
     1048    set PTRatioMax 0.2
    8821049}
    8831050
     
    10001167
    10011168source  CLIC/CLICdet_JetFlavorAssociation.tcl
     1169source  CLIC/CLICdet_JetFlavorAssociation_JER.tcl
    10021170
    10031171###########
     
    10071175
    10081176source  CLIC/CLICdet_BTagging.tcl
     1177source  CLIC/CLICdet_BTagging_JER.tcl
    10091178
    10101179
     
    10151184
    10161185source CLIC/CLICdet_TauTagging.tcl
     1186source CLIC/CLICdet_TauTagging_JER.tcl
    10171187
    10181188
  • cards/delphes_card_CLICdet_Stage3.tcl

    re39abb4 r0e7d64a  
    11#######################################
    22# CLICdet model
    3 # based on CLICdp-Note-2017-001
     3# based on arXiv:1812.07337 and
     4# CLICdp-Note-2017-001
     5#
    46# Ulrike Schnoor ulrike.schnoor@cern.ch
    5 #
    67#
    78# For the high energy stage of
     
    1112# use exclusive clustering with njets
    1213# according to final state
    13 #
     14#
     15# c-tagging capabilities of CLICdet are
     16# not yet implemented here. Please
     17# contact us if you want to use it.
     18#######################################
     19
    1420#######################################
    1521# Order of execution of various modules
     
    125131
    126132    JetFlavorAssociation_R05N2
    127         JetFlavorAssociation_R05N3
    128         JetFlavorAssociation_R05N4
    129         JetFlavorAssociation_R05N5
    130         JetFlavorAssociation_R05N6
    131        
    132         JetFlavorAssociation_R07N2
    133         JetFlavorAssociation_R07N3
    134         JetFlavorAssociation_R07N4
    135         JetFlavorAssociation_R07N5
    136         JetFlavorAssociation_R07N6
    137 
    138         JetFlavorAssociation_R10N2
    139         JetFlavorAssociation_R10N3
    140         JetFlavorAssociation_R10N4
    141         JetFlavorAssociation_R10N5
    142         JetFlavorAssociation_R10N6
    143 
    144         JetFlavorAssociation_R12N2
    145         JetFlavorAssociation_R12N3
    146         JetFlavorAssociation_R12N4
    147         JetFlavorAssociation_R12N5
    148         JetFlavorAssociation_R12N6
    149 
    150         JetFlavorAssociation_R15N2
    151         JetFlavorAssociation_R15N3
    152         JetFlavorAssociation_R15N4
    153         JetFlavorAssociation_R15N5
    154         JetFlavorAssociation_R15N6
    155 
    156         JetFlavorAssociation_R05_inclusive
    157         JetFlavorAssociation_R07_inclusive
    158         JetFlavorAssociation_R10_inclusive
    159         JetFlavorAssociation_R12_inclusive
    160         JetFlavorAssociation_R15_inclusive
    161 
    162    
    163         BTaggingWP50_R05N2
    164         BTaggingWP70_R05N2
    165         BTaggingWP90_R05N2
    166         BTaggingWP50_R05N3
    167         BTaggingWP70_R05N3
    168         BTaggingWP90_R05N3
    169         BTaggingWP50_R05N4
    170         BTaggingWP70_R05N4
    171         BTaggingWP90_R05N4
    172         BTaggingWP50_R05N5
    173         BTaggingWP70_R05N5
    174         BTaggingWP90_R05N5
    175         BTaggingWP50_R05N6
    176         BTaggingWP70_R05N6
    177         BTaggingWP90_R05N6
    178         BTaggingWP50_R07N2
    179         BTaggingWP70_R07N2
    180         BTaggingWP90_R07N2
    181         BTaggingWP50_R07N3
    182         BTaggingWP70_R07N3
    183         BTaggingWP90_R07N3
    184         BTaggingWP50_R07N4
    185         BTaggingWP70_R07N4
    186         BTaggingWP90_R07N4
    187         BTaggingWP50_R07N5
    188         BTaggingWP70_R07N5
    189         BTaggingWP90_R07N5
    190         BTaggingWP50_R07N6
    191         BTaggingWP70_R07N6
    192         BTaggingWP90_R07N6
    193         BTaggingWP50_R10N2
    194         BTaggingWP70_R10N2
    195         BTaggingWP90_R10N2
    196         BTaggingWP50_R10N3
    197         BTaggingWP70_R10N3
    198         BTaggingWP90_R10N3
    199         BTaggingWP50_R10N4
    200         BTaggingWP70_R10N4
    201         BTaggingWP90_R10N4
    202         BTaggingWP50_R10N5
    203         BTaggingWP70_R10N5
    204         BTaggingWP90_R10N5
    205         BTaggingWP50_R10N6
    206         BTaggingWP70_R10N6
    207         BTaggingWP90_R10N6
    208         BTaggingWP50_R12N2
    209         BTaggingWP70_R12N2
    210         BTaggingWP90_R12N2
    211         BTaggingWP50_R12N3
    212         BTaggingWP70_R12N3
    213         BTaggingWP90_R12N3
    214         BTaggingWP50_R12N4
    215         BTaggingWP70_R12N4
    216         BTaggingWP90_R12N4
    217         BTaggingWP50_R12N5
    218         BTaggingWP70_R12N5
    219         BTaggingWP90_R12N5
    220         BTaggingWP50_R12N6
    221         BTaggingWP70_R12N6
    222         BTaggingWP90_R12N6
    223         BTaggingWP50_R15N2
    224         BTaggingWP70_R15N2
    225         BTaggingWP90_R15N2
    226         BTaggingWP50_R15N3
    227         BTaggingWP70_R15N3
    228         BTaggingWP90_R15N3
    229         BTaggingWP50_R15N4
    230         BTaggingWP70_R15N4
    231         BTaggingWP90_R15N4
    232         BTaggingWP50_R15N5
    233         BTaggingWP70_R15N5
    234         BTaggingWP90_R15N5
    235         BTaggingWP50_R15N6
    236         BTaggingWP70_R15N6
    237         BTaggingWP90_R15N6
     133    JetFlavorAssociation_R05N3
     134    JetFlavorAssociation_R05N4
     135    JetFlavorAssociation_R05N5
     136    JetFlavorAssociation_R05N6
     137   
     138    JetFlavorAssociation_R07N2
     139    JetFlavorAssociation_R07N3
     140    JetFlavorAssociation_R07N4
     141    JetFlavorAssociation_R07N5
     142    JetFlavorAssociation_R07N6
     143
     144    JetFlavorAssociation_R10N2
     145    JetFlavorAssociation_R10N3
     146    JetFlavorAssociation_R10N4
     147    JetFlavorAssociation_R10N5
     148    JetFlavorAssociation_R10N6
     149
     150    JetFlavorAssociation_R12N2
     151    JetFlavorAssociation_R12N3
     152    JetFlavorAssociation_R12N4
     153    JetFlavorAssociation_R12N5
     154    JetFlavorAssociation_R12N6
     155
     156    JetFlavorAssociation_R15N2
     157    JetFlavorAssociation_R15N3
     158    JetFlavorAssociation_R15N4
     159    JetFlavorAssociation_R15N5
     160    JetFlavorAssociation_R15N6
     161
     162    JetFlavorAssociation_R05_inclusive
     163    JetFlavorAssociation_R07_inclusive
     164    JetFlavorAssociation_R10_inclusive
     165    JetFlavorAssociation_R12_inclusive
     166    JetFlavorAssociation_R15_inclusive
     167
     168    JetFlavorAssociation_JER_R05N2
     169    JetFlavorAssociation_JER_R05N3
     170    JetFlavorAssociation_JER_R05N4
     171    JetFlavorAssociation_JER_R05N5
     172    JetFlavorAssociation_JER_R05N6
     173   
     174    JetFlavorAssociation_JER_R07N2
     175    JetFlavorAssociation_JER_R07N3
     176    JetFlavorAssociation_JER_R07N4
     177    JetFlavorAssociation_JER_R07N5
     178    JetFlavorAssociation_JER_R07N6
     179   
     180    JetFlavorAssociation_JER_R10N2
     181    JetFlavorAssociation_JER_R10N3
     182    JetFlavorAssociation_JER_R10N4
     183    JetFlavorAssociation_JER_R10N5
     184    JetFlavorAssociation_JER_R10N6
     185   
     186    JetFlavorAssociation_JER_R12N2
     187    JetFlavorAssociation_JER_R12N3
     188    JetFlavorAssociation_JER_R12N4
     189    JetFlavorAssociation_JER_R12N5
     190    JetFlavorAssociation_JER_R12N6
     191   
     192    JetFlavorAssociation_JER_R15N2
     193    JetFlavorAssociation_JER_R15N3
     194    JetFlavorAssociation_JER_R15N4
     195    JetFlavorAssociation_JER_R15N5
     196    JetFlavorAssociation_JER_R15N6
     197   
     198    JetFlavorAssociation_JER_R05_inclusive
     199    JetFlavorAssociation_JER_R07_inclusive
     200    JetFlavorAssociation_JER_R10_inclusive
     201    JetFlavorAssociation_JER_R12_inclusive
     202    JetFlavorAssociation_JER_R15_inclusive
     203   
     204    BTaggingWP50_R05N2
     205    BTaggingWP70_R05N2
     206    BTaggingWP90_R05N2
     207    BTaggingWP50_R05N3
     208    BTaggingWP70_R05N3
     209    BTaggingWP90_R05N3
     210    BTaggingWP50_R05N4
     211    BTaggingWP70_R05N4
     212    BTaggingWP90_R05N4
     213    BTaggingWP50_R05N5
     214    BTaggingWP70_R05N5
     215    BTaggingWP90_R05N5
     216    BTaggingWP50_R05N6
     217    BTaggingWP70_R05N6
     218    BTaggingWP90_R05N6
     219    BTaggingWP50_R07N2
     220    BTaggingWP70_R07N2
     221    BTaggingWP90_R07N2
     222    BTaggingWP50_R07N3
     223    BTaggingWP70_R07N3
     224    BTaggingWP90_R07N3
     225    BTaggingWP50_R07N4
     226    BTaggingWP70_R07N4
     227    BTaggingWP90_R07N4
     228    BTaggingWP50_R07N5
     229    BTaggingWP70_R07N5
     230    BTaggingWP90_R07N5
     231    BTaggingWP50_R07N6
     232    BTaggingWP70_R07N6
     233    BTaggingWP90_R07N6
     234    BTaggingWP50_R10N2
     235    BTaggingWP70_R10N2
     236    BTaggingWP90_R10N2
     237    BTaggingWP50_R10N3
     238    BTaggingWP70_R10N3
     239    BTaggingWP90_R10N3
     240    BTaggingWP50_R10N4
     241    BTaggingWP70_R10N4
     242    BTaggingWP90_R10N4
     243    BTaggingWP50_R10N5
     244    BTaggingWP70_R10N5
     245    BTaggingWP90_R10N5
     246    BTaggingWP50_R10N6
     247    BTaggingWP70_R10N6
     248    BTaggingWP90_R10N6
     249    BTaggingWP50_R12N2
     250    BTaggingWP70_R12N2
     251    BTaggingWP90_R12N2
     252    BTaggingWP50_R12N3
     253    BTaggingWP70_R12N3
     254    BTaggingWP90_R12N3
     255    BTaggingWP50_R12N4
     256    BTaggingWP70_R12N4
     257    BTaggingWP90_R12N4
     258    BTaggingWP50_R12N5
     259    BTaggingWP70_R12N5
     260    BTaggingWP90_R12N5
     261    BTaggingWP50_R12N6
     262    BTaggingWP70_R12N6
     263    BTaggingWP90_R12N6
     264    BTaggingWP50_R15N2
     265    BTaggingWP70_R15N2
     266    BTaggingWP90_R15N2
     267    BTaggingWP50_R15N3
     268    BTaggingWP70_R15N3
     269    BTaggingWP90_R15N3
     270    BTaggingWP50_R15N4
     271    BTaggingWP70_R15N4
     272    BTaggingWP90_R15N4
     273    BTaggingWP50_R15N5
     274    BTaggingWP70_R15N5
     275    BTaggingWP90_R15N5
     276    BTaggingWP50_R15N6
     277    BTaggingWP70_R15N6
     278    BTaggingWP90_R15N6
    238279    BTaggingWP50_R05_inclusive
    239280    BTaggingWP70_R05_inclusive
     
    252293    BTaggingWP90_R15_inclusive
    253294
    254    
     295    BTagging_JER_WP50_R05N2
     296    BTagging_JER_WP70_R05N2
     297    BTagging_JER_WP90_R05N2
     298    BTagging_JER_WP50_R05N3
     299    BTagging_JER_WP70_R05N3
     300    BTagging_JER_WP90_R05N3
     301    BTagging_JER_WP50_R05N4
     302    BTagging_JER_WP70_R05N4
     303    BTagging_JER_WP90_R05N4
     304    BTagging_JER_WP50_R05N5
     305    BTagging_JER_WP70_R05N5
     306    BTagging_JER_WP90_R05N5
     307    BTagging_JER_WP50_R05N6
     308    BTagging_JER_WP70_R05N6
     309    BTagging_JER_WP90_R05N6
     310    BTagging_JER_WP50_R07N2
     311    BTagging_JER_WP70_R07N2
     312    BTagging_JER_WP90_R07N2
     313    BTagging_JER_WP50_R07N3
     314    BTagging_JER_WP70_R07N3
     315    BTagging_JER_WP90_R07N3
     316    BTagging_JER_WP50_R07N4
     317    BTagging_JER_WP70_R07N4
     318    BTagging_JER_WP90_R07N4
     319    BTagging_JER_WP50_R07N5
     320    BTagging_JER_WP70_R07N5
     321    BTagging_JER_WP90_R07N5
     322    BTagging_JER_WP50_R07N6
     323    BTagging_JER_WP70_R07N6
     324    BTagging_JER_WP90_R07N6
     325    BTagging_JER_WP50_R10N2
     326    BTagging_JER_WP70_R10N2
     327    BTagging_JER_WP90_R10N2
     328    BTagging_JER_WP50_R10N3
     329    BTagging_JER_WP70_R10N3
     330    BTagging_JER_WP90_R10N3
     331    BTagging_JER_WP50_R10N4
     332    BTagging_JER_WP70_R10N4
     333    BTagging_JER_WP90_R10N4
     334    BTagging_JER_WP50_R10N5
     335    BTagging_JER_WP70_R10N5
     336    BTagging_JER_WP90_R10N5
     337    BTagging_JER_WP50_R10N6
     338    BTagging_JER_WP70_R10N6
     339    BTagging_JER_WP90_R10N6
     340    BTagging_JER_WP50_R12N2
     341    BTagging_JER_WP70_R12N2
     342    BTagging_JER_WP90_R12N2
     343    BTagging_JER_WP50_R12N3
     344    BTagging_JER_WP70_R12N3
     345    BTagging_JER_WP90_R12N3
     346    BTagging_JER_WP50_R12N4
     347    BTagging_JER_WP70_R12N4
     348    BTagging_JER_WP90_R12N4
     349    BTagging_JER_WP50_R12N5
     350    BTagging_JER_WP70_R12N5
     351    BTagging_JER_WP90_R12N5
     352    BTagging_JER_WP50_R12N6
     353    BTagging_JER_WP70_R12N6
     354    BTagging_JER_WP90_R12N6
     355    BTagging_JER_WP50_R15N2
     356    BTagging_JER_WP70_R15N2
     357    BTagging_JER_WP90_R15N2
     358    BTagging_JER_WP50_R15N3
     359    BTagging_JER_WP70_R15N3
     360    BTagging_JER_WP90_R15N3
     361    BTagging_JER_WP50_R15N4
     362    BTagging_JER_WP70_R15N4
     363    BTagging_JER_WP90_R15N4
     364    BTagging_JER_WP50_R15N5
     365    BTagging_JER_WP70_R15N5
     366    BTagging_JER_WP90_R15N5
     367    BTagging_JER_WP50_R15N6
     368    BTagging_JER_WP70_R15N6
     369    BTagging_JER_WP90_R15N6
     370    BTagging_JER_WP50_R05_inclusive
     371    BTagging_JER_WP70_R05_inclusive
     372    BTagging_JER_WP90_R05_inclusive
     373    BTagging_JER_WP50_R07_inclusive
     374    BTagging_JER_WP70_R07_inclusive
     375    BTagging_JER_WP90_R07_inclusive
     376    BTagging_JER_WP50_R10_inclusive
     377    BTagging_JER_WP70_R10_inclusive
     378    BTagging_JER_WP90_R10_inclusive
     379    BTagging_JER_WP50_R12_inclusive
     380    BTagging_JER_WP70_R12_inclusive
     381    BTagging_JER_WP90_R12_inclusive
     382    BTagging_JER_WP50_R15_inclusive
     383    BTagging_JER_WP70_R15_inclusive
     384    BTagging_JER_WP90_R15_inclusive
     385     
    255386    TauTagging_R05N2
    256387    TauTagging_R05N3
     
    278409    TauTagging_R15N5
    279410    TauTagging_R15N6
    280 
    281411    TauTagging_R05_inclusive
    282412    TauTagging_R07_inclusive
     
    285415    TauTagging_R15_inclusive
    286416
     417    TauTagging_JER_R05N2
     418    TauTagging_JER_R05N3
     419    TauTagging_JER_R05N4
     420    TauTagging_JER_R05N5
     421    TauTagging_JER_R05N6
     422    TauTagging_JER_R07N2
     423    TauTagging_JER_R07N3
     424    TauTagging_JER_R07N4
     425    TauTagging_JER_R07N5
     426    TauTagging_JER_R07N6
     427    TauTagging_JER_R10N2
     428    TauTagging_JER_R10N3
     429    TauTagging_JER_R10N4
     430    TauTagging_JER_R10N5
     431    TauTagging_JER_R10N6
     432    TauTagging_JER_R12N2
     433    TauTagging_JER_R12N3
     434    TauTagging_JER_R12N4
     435    TauTagging_JER_R12N5
     436    TauTagging_JER_R12N6
     437    TauTagging_JER_R15N2
     438    TauTagging_JER_R15N3
     439    TauTagging_JER_R15N4
     440    TauTagging_JER_R15N5
     441    TauTagging_JER_R15N6
     442    TauTagging_JER_R05_inclusive
     443    TauTagging_JER_R07_inclusive
     444    TauTagging_JER_R10_inclusive
     445    TauTagging_JER_R12_inclusive
     446    TauTagging_JER_R15_inclusive
    287447
    288448
     
    730890}
    731891
     892
    732893##################
    733894# Photon isolation
     
    740901    set OutputArray photons
    741902
    742     set DeltaRMax 0.5
     903    set DeltaRMax 0.1
    743904
    744905    set PTMin 0.5
    745906
    746     set PTRatioMax 0.12
    747 }
     907    set PTRatioMax 0.2
     908}
     909
    748910
    749911#####################
     
    8381000    set OutputArray electrons
    8391001
    840     set DeltaRMax 0.5
     1002    set DeltaRMax 0.1
    8411003
    8421004    set PTMin 0.5
    8431005
    844     set PTRatioMax 0.12
     1006    set PTRatioMax 0.2
    8451007}
    8461008
     
    8761038    set OutputArray muons
    8771039
    878     set DeltaRMax 0.5
     1040    set DeltaRMax 0.1
    8791041
    8801042    set PTMin 0.5
    8811043
    882     set PTRatioMax 0.25
     1044    set PTRatioMax 0.2
    8831045}
    8841046
     
    10031165
    10041166source  CLIC/CLICdet_JetFlavorAssociation.tcl
     1167source  CLIC/CLICdet_JetFlavorAssociation_JER.tcl
    10051168
    10061169###########
     
    10101173
    10111174source  CLIC/CLICdet_BTagging.tcl
     1175source  CLIC/CLICdet_BTagging_JER.tcl
    10121176
    10131177
     
    10181182
    10191183source CLIC/CLICdet_TauTagging.tcl
     1184source CLIC/CLICdet_TauTagging_JER.tcl
    10201185
    10211186
  • classes/DelphesClasses.cc

    re39abb4 r0e7d64a  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918
    2019/**
     
    122121  Charge(0), Mass(0.0),
    123122  IsPU(0), IsRecoPU(0), IsConstituent(0), IsFromConversion(0),
    124   ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0),
    125123  Flavor(0), FlavorAlgo(0), FlavorPhys(0),
    126124  BTag(0), BTagAlgo(0), BTagPhys(0),
     
    129127  Momentum(0.0, 0.0, 0.0, 0.0),
    130128  Position(0.0, 0.0, 0.0, 0.0),
     129  InitialPosition(0.0, 0.0, 0.0, 0.0),
    131130  PositionError(0.0, 0.0, 0.0, 0.0),
    132   InitialPosition(0.0, 0.0, 0.0, 0.0),
    133131  Area(0.0, 0.0, 0.0, 0.0),
    134132  L(0),
    135   D0(0), ErrorD0(0), 
    136   DZ(0), ErrorDZ(0), 
    137   P(0),  ErrorP(0),
    138   PT(0), ErrorPT(0), 
    139   CtgTheta(0), ErrorCtgTheta(0), 
    140   Phi(0), ErrorPhi(0), 
    141   Xd(0), Yd(0), Zd(0), 
     133  D0(0), ErrorD0(0),
     134  DZ(0), ErrorDZ(0),
     135  P(0), ErrorP(0),
     136  PT(0), ErrorPT(0),
     137  CtgTheta(0), ErrorCtgTheta(0),
     138  Phi(0), ErrorPhi(0),
     139  Xd(0), Yd(0), Zd(0),
    142140  TrackResolution(0),
    143141  NCharged(0),
     
    154152  SumPtChargedPU(-999),
    155153  SumPt(-999),
     154  ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0),
    156155  NSubJetsTrimmed(0),
    157156  NSubJetsPruned(0),
     
    236235  return kFALSE;
    237236}
    238 
    239237
    240238//------------------------------------------------------------------------------
     
    304302  object.PT = PT;
    305303  object.ErrorPT = ErrorPT;
    306   object.CtgTheta = CtgTheta ;
     304  object.CtgTheta = CtgTheta;
    307305  object.ErrorCtgTheta = ErrorCtgTheta;
    308306  object.Phi = Phi;
    309   object.ErrorPhi = ErrorPhi; 
     307  object.ErrorPhi = ErrorPhi;
    310308  object.Xd = Xd;
    311309  object.Yd = Yd;
     
    327325  object.ClusterIndex = ClusterIndex;
    328326  object.ClusterNDF = ClusterNDF;
    329   object.ClusterSigma = ClusterSigma; 
     327  object.ClusterSigma = ClusterSigma;
    330328  object.SumPT2 = SumPT2;
    331  
     329
    332330  object.FracPt[0] = FracPt[0];
    333331  object.FracPt[1] = FracPt[1];
     
    361359  object.NSubJetsSoftDropped = NSubJetsSoftDropped;
    362360
    363   object.SoftDroppedJet =SoftDroppedJet;
     361  object.SoftDroppedJet = SoftDroppedJet;
    364362  object.SoftDroppedSubJet1 = SoftDroppedSubJet1;
    365363  object.SoftDroppedSubJet2 = SoftDroppedSubJet2;
     
    384382//------------------------------------------------------------------------------
    385383
    386 void Candidate::Clear(Option_t* option)
     384void Candidate::Clear(Option_t *option)
    387385{
    388386  int i;
     
    391389  PID = 0;
    392390  Status = 0;
    393   M1 = -1; M2 = -1; D1 = -1; D2 = -1;
     391  M1 = -1;
     392  M2 = -1;
     393  D1 = -1;
     394  D2 = -1;
    394395  Charge = 0;
    395396  Mass = 0.0;
     
    420421  L = 0.0;
    421422  ErrorT = 0.0;
    422   D0 = 0.0; 
     423  D0 = 0.0;
    423424  ErrorD0 = 0.0;
    424425  DZ = 0.0;
    425426  ErrorDZ = 0.0;
    426   P =0.0;
    427   ErrorP =0.0;
     427  P = 0.0;
     428  ErrorP = 0.0;
    428429  PT = 0.0;
    429430  ErrorPT = 0.0;
     
    455456  ClusterIndex = -1;
    456457  ClusterNDF = -99;
    457   ClusterSigma = 0.0; 
     458  ClusterSigma = 0.0;
    458459  SumPT2 = 0.0;
    459460  BTVSumPT2 = 0.0;
    460461  GenDeltaZ = 0.0;
    461   GenSumPT2 = 0.0; 
    462  
     462  GenSumPT2 = 0.0;
     463
    463464  FracPt[0] = 0.0;
    464465  FracPt[1] = 0.0;
     
    476477  SoftDroppedSubJet2.SetXYZT(0.0, 0.0, 0.0, 0.0);
    477478
    478 
    479479  for(i = 0; i < 5; ++i)
    480480  {
  • classes/DelphesClasses.h

    re39abb4 r0e7d64a  
    3232// Dependencies (#includes)
    3333
     34#include "TLorentzVector.h"
     35#include "TObject.h"
    3436#include "TRef.h"
    35 #include "TObject.h"
    3637#include "TRefArray.h"
    37 #include "TLorentzVector.h"
    3838
    3939#include "classes/SortableObject.h"
     
    4646{
    4747public:
    48 
    4948  Long64_t Number; // event number
    5049
     
    6059{
    6160public:
    62 
    6361  Int_t Trigger; // trigger word
    6462
     
    7169{
    7270public:
    73 
    7471  Int_t ProcessID; // subprocess code for the event | hepup.IDPRUP
    7572
     
    8077  Float_t AlphaQCD; // value of the QCD coupling used in the event | hepup.AQCDUP
    8178
    82   ClassDef(LHEFEvent, 2)
     79  ClassDef(LHEFEvent, 3)
    8380};
    8481
     
    9996{
    10097public:
    101 
    10298  Int_t ProcessID; // unique signal process id | signal_process_id()
    10399  Int_t MPI; // number of multi parton interactions | mpi ()
     
    122118  Float_t PDF2; // PDF (id2, x2, Q) | pdf_info()->pdf2()
    123119
    124 
    125 
    126   ClassDef(HepMCEvent, 2)
     120  ClassDef(HepMCEvent, 3)
    127121};
    128122
     
    181175{
    182176public:
    183 
    184177  Float_t T; // vertex position (t component)
    185178  Float_t X; // vertex position (x component)
     
    260253{
    261254public:
    262 
    263255  Float_t PT; // photon transverse momentum
    264256  Float_t Eta; // photon pseudorapidity
     
    287279  TLorentzVector P4() const;
    288280
    289   ClassDef(Photon, 3)
     281  ClassDef(Photon, 4)
    290282};
    291283
     
    295287{
    296288public:
    297 
    298289  Float_t PT; // electron transverse momentum
    299290  Float_t Eta; // electron pseudorapidity
     
    315306  Float_t SumPt; // isolation variable
    316307
    317   static CompBase *fgCompare; //!
    318   const CompBase *GetCompare() const { return fgCompare; }
    319 
    320   TLorentzVector P4() const;
    321 
    322   ClassDef(Electron, 3)
     308  Float_t D0; // track transverse impact parameter
     309  Float_t DZ; // track longitudinal impact parameter
     310  Float_t ErrorD0; // track transverse impact parameter error
     311  Float_t ErrorDZ; // track longitudinal impact parameter error
     312
     313  static CompBase *fgCompare; //!
     314  const CompBase *GetCompare() const { return fgCompare; }
     315
     316  TLorentzVector P4() const;
     317
     318  ClassDef(Electron, 4)
    323319};
    324320
     
    328324{
    329325public:
    330 
    331326  Float_t PT; // muon transverse momentum
    332327  Float_t Eta; // muon pseudorapidity
     
    346341  Float_t SumPt; // isolation variable
    347342
    348   static CompBase *fgCompare; //!
    349   const CompBase *GetCompare() const { return fgCompare; }
    350 
    351   TLorentzVector P4() const;
    352 
    353   ClassDef(Muon, 3)
     343  Float_t D0; // track transverse impact parameter
     344  Float_t DZ; // track longitudinal impact parameter
     345  Float_t ErrorD0; // track transverse impact parameter error
     346  Float_t ErrorDZ; // track longitudinal impact parameter error
     347
     348  static CompBase *fgCompare; //!
     349  const CompBase *GetCompare() const { return fgCompare; }
     350
     351  TLorentzVector P4() const;
     352
     353  ClassDef(Muon, 4)
    354354};
    355355
     
    359359{
    360360public:
    361 
    362361  Float_t PT; // jet transverse momentum
    363362  Float_t Eta; // jet pseudorapidity
     
    368367  Float_t Mass; // jet invariant mass
    369368
    370   Float_t DeltaEta;  // jet radius in pseudorapidity
    371   Float_t DeltaPhi;  // jet radius in azimuthal angle
     369  Float_t DeltaEta; // jet radius in pseudorapidity
     370  Float_t DeltaPhi; // jet radius in azimuthal angle
    372371
    373372  UInt_t Flavor; // jet flavor
     
    404403  TLorentzVector SoftDroppedP4[5]; // first entry (i = 0) is the total SoftDropped Jet 4-momenta and from i = 1 to 4 are the pruned subjets 4-momenta
    405404
    406 
    407405  Int_t NSubJetsTrimmed; // number of subjets trimmed
    408406  Int_t NSubJetsPruned; // number of subjets pruned
     
    413411  Double_t ExclYmerge45;
    414412  Double_t ExclYmerge56;
    415  
     413
    416414  TRefArray Constituents; // references to constituents
    417415  TRefArray Particles; // references to generated particles
     
    423421  TLorentzVector Area;
    424422
    425   ClassDef(Jet, 3)
     423  ClassDef(Jet, 4)
    426424};
    427425
     
    616614
    617615  Int_t NTimeHits;
    618   std::vector< std::pair< Float_t, Float_t > > ECalEnergyTimePairs;
     616  std::vector<std::pair<Float_t, Float_t> > ECalEnergyTimePairs;
    619617
    620618  // Isolation variables
     
    660658  Double_t ExclYmerge45;
    661659  Double_t ExclYmerge56;
    662      
     660
    663661  static CompBase *fgCompare; //!
    664662  const CompBase *GetCompare() const { return fgCompare; }
     
    671669  virtual void Copy(TObject &object) const;
    672670  virtual TObject *Clone(const char *newname = "") const;
    673   virtual void Clear(Option_t* option = "");
     671  virtual void Clear(Option_t *option = "");
    674672
    675673private:
     
    679677  void SetFactory(DelphesFactory *factory) { fFactory = factory; }
    680678
    681   ClassDef(Candidate, 5)
     679  ClassDef(Candidate, 6)
    682680};
    683681
    684682#endif // DelphesClasses_h
    685 
    686 
  • classes/DelphesCylindricalFormula.cc

    re39abb4 r0e7d64a  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918
    2019#include "classes/DelphesCylindricalFormula.h"
     
    5453  for(it = expression; *it; ++it)
    5554  {
    56     if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
     55    if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
    5756    buffer.Append(*it);
    5857  }
  • classes/DelphesCylindricalFormula.h

    re39abb4 r0e7d64a  
    2525{
    2626public:
    27 
    2827  DelphesCylindricalFormula();
    2928
     
    3837
    3938#endif /* DelphesCylindricalFormula_h */
    40 
  • classes/DelphesFactory.cc

    re39abb4 r0e7d64a  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918
    2019/** \class DelphesFactory
     
    5150  if(fObjArrays) delete fObjArrays;
    5251
    53   map< const TClass*, ExRootTreeBranch* >::iterator itBranches;
     52  map<const TClass *, ExRootTreeBranch *>::iterator itBranches;
    5453  for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
    5554  {
    56     delete (itBranches->second);
     55    delete(itBranches->second);
    5756  }
    5857}
     
    6059//------------------------------------------------------------------------------
    6160
    62 void DelphesFactory::Clear(Option_t* option)
     61void DelphesFactory::Clear(Option_t *option)
    6362{
    6463  set<TObject *>::iterator itPool;
     
    7069  TProcessID::SetObjectCount(0);
    7170
    72   map< const TClass*, ExRootTreeBranch* >::iterator itBranches;
     71  map<const TClass *, ExRootTreeBranch *>::iterator itBranches;
    7372  for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
    7473  {
     
    120119
    121120//------------------------------------------------------------------------------
    122 
  • classes/DelphesFactory.h

    re39abb4 r0e7d64a  
    4242{
    4343public:
    44  
    4544  DelphesFactory(const char *name = "ObjectFactory");
    4645  ~DelphesFactory();
    4746
    48   virtual void Clear(Option_t* option = "");
    49  
     47  virtual void Clear(Option_t *option = "");
     48
    5049  TObjArray *NewPermanentArray();
    5150
     
    5655  TObject *New(TClass *cl);
    5756
    58   template<typename T>
     57  template <typename T>
    5958  T *New() { return static_cast<T *>(New(T::Class())); }
    6059
    6160private:
    62 
    6361  ExRootTreeBranch *fObjArrays; //!
    6462
    6563#if !defined(__CINT__) && !defined(__CLING__)
    66   std::map< const TClass*, ExRootTreeBranch* > fBranches; //!
     64  std::map<const TClass *, ExRootTreeBranch *> fBranches; //!
    6765#endif
    6866
    69   std::set< TObject* > fPool; //!
    70  
     67  std::set<TObject *> fPool; //!
     68
    7169  ClassDef(DelphesFactory, 1)
    7270};
    7371
    7472#endif /* DelphesFactory */
    75 
  • classes/DelphesFormula.cc

    re39abb4 r0e7d64a  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918
    2019#include "classes/DelphesFormula.h"
     
    5453  for(it = expression; *it; ++it)
    5554  {
    56     if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
     55    if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
    5756    buffer.Append(*it);
    5857  }
     
    6160  buffer.ReplaceAll("phi", "z");
    6261  buffer.ReplaceAll("energy", "t");
     62  buffer.ReplaceAll("d0", "[0]");
     63  buffer.ReplaceAll("dz", "[1]");
     64  buffer.ReplaceAll("ctgTheta", "[2]");
    6365
     66#if ROOT_VERSION_CODE < ROOT_VERSION(6, 3, 0)
     67  TFormula::SetMaxima(100000, 1000, 1000000);
     68#endif
    6469
    65 
    66   #if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
    67     TFormula::SetMaxima(100000,1000,1000000);
    68   #endif
    69  
    7070  if(TFormula::Compile(buffer) != 0)
    7171  {
     
    7777//------------------------------------------------------------------------------
    7878
    79 Double_t DelphesFormula::Eval(Double_t pt, Double_t eta, Double_t phi, Double_t energy)
     79Double_t DelphesFormula::Eval(Double_t pt, Double_t eta, Double_t phi,
     80  Double_t energy, Double_t d0, Double_t dz,
     81  Double_t ctgTheta)
    8082{
    81    Double_t x[4] = {pt, eta, phi, energy};
    82    return EvalPar(x);
     83  Double_t x[4] = {pt, eta, phi, energy};
     84  Double_t params[3] = {d0, dz, ctgTheta};
     85  return EvalPar(x, params);
    8386}
    8487
  • classes/DelphesFormula.h

    re39abb4 r0e7d64a  
    2525{
    2626public:
    27 
    2827  DelphesFormula();
    2928
     
    3433  Int_t Compile(const char *expression);
    3534
    36   Double_t Eval(Double_t pt, Double_t eta = 0, Double_t phi = 0, Double_t energy = 0);
     35  Double_t Eval(Double_t pt, Double_t eta = 0, Double_t phi = 0,
     36    Double_t energy = 0, Double_t d0 = 0, Double_t dz = 0,
     37    Double_t ctgTheta = 0);
    3738};
    3839
    3940#endif /* DelphesFormula_h */
    40 
  • classes/DelphesHepMCReader.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesHepMCReader
    2120 *
     
    2827#include "classes/DelphesHepMCReader.h"
    2928
    30 #include <stdexcept>
    3129#include <iostream>
    3230#include <sstream>
     31#include <stdexcept>
    3332
    3433#include <map>
     
    3736#include <stdio.h>
    3837
     38#include "TDatabasePDG.h"
     39#include "TLorentzVector.h"
    3940#include "TObjArray.h"
     41#include "TParticlePDG.h"
    4042#include "TStopwatch.h"
    41 #include "TDatabasePDG.h"
    42 #include "TParticlePDG.h"
    43 #include "TLorentzVector.h"
    4443
    4544#include "classes/DelphesClasses.h"
     
    111110  TObjArray *partonOutputArray)
    112111{
    113   map< int, pair< int, int > >::iterator itMotherMap;
    114   map< int, pair< int, int > >::iterator itDaughterMap;
     112  map<int, pair<int, int> >::iterator itMotherMap;
     113  map<int, pair<int, int> >::iterator itDaughterMap;
    115114  char key, momentumUnit[4], positionUnit[3];
    116115  int i, rc, state;
     
    141140    if(!rc)
    142141    {
    143       cerr << "** ERROR: " << "invalid event format" << endl;
     142      cerr << "** ERROR: "
     143           << "invalid event format" << endl;
    144144      return kFALSE;
    145145    }
     
    155155    if(!rc)
    156156    {
    157       cerr << "** ERROR: " << "invalid event format" << endl;
     157      cerr << "** ERROR: "
     158           << "invalid event format" << endl;
    158159      return kFALSE;
    159160    }
     
    167168    if(!rc)
    168169    {
    169       cerr << "** ERROR: " << "invalid event format" << endl;
     170      cerr << "** ERROR: "
     171           << "invalid event format" << endl;
    170172      return kFALSE;
    171173    }
     
    177179    if(rc != 2)
    178180    {
    179       cerr << "** ERROR: " << "invalid units format" << endl;
     181      cerr << "** ERROR: "
     182           << "invalid units format" << endl;
    180183      return kFALSE;
    181184    }
     
    189192      fMomentumCoefficient = 0.001;
    190193    }
    191    
     194
    192195    if(strncmp(positionUnit, "MM", 3) == 0)
    193196    {
     
    199202    }
    200203  }
    201  
     204
    202205  else if(key == 'C')
    203206  {
     
    205208      && bufferStream.ReadDbl(fCrossSectionError);
    206209  }
    207  
     210
    208211  else if(key == 'F')
    209212  {
     
    218221    if(!rc)
    219222    {
    220       cerr << "** ERROR: " << "invalid PDF format" << endl;
     223      cerr << "** ERROR: "
     224           << "invalid PDF format" << endl;
    221225      return kFALSE;
    222226    }
     
    235239    if(!rc)
    236240    {
    237       cerr << "** ERROR: " << "invalid vertex format" << endl;
     241      cerr << "** ERROR: "
     242           << "invalid vertex format" << endl;
    238243      return kFALSE;
    239244    }
     
    256261    if(!rc)
    257262    {
    258       cerr << "** ERROR: " << "invalid particle format" << endl;
     263      cerr << "** ERROR: "
     264           << "invalid particle format" << endl;
    259265      return kFALSE;
    260266    }
     
    345351{
    346352  Weight *element;
    347   vector< double >::const_iterator itWeight;
     353  vector<double>::const_iterator itWeight;
    348354
    349355  for(itWeight = fWeight.begin(); itWeight != fWeight.end(); ++itWeight)
     
    374380
    375381  pdgParticle = fPDG->GetParticle(fPID);
    376   candidate->Charge = pdgParticle ? int(pdgParticle->Charge()/3.0) : -999;
     382  candidate->Charge = pdgParticle ? int(pdgParticle->Charge() / 3.0) : -999;
    377383  candidate->Mass = fMass;
    378384
     
    427433{
    428434  Candidate *candidate;
    429   map< int, pair< int, int > >::iterator itMotherMap;
    430   map< int, pair< int, int > >::iterator itDaughterMap;
     435  map<int, pair<int, int> >::iterator itMotherMap;
     436  map<int, pair<int, int> >::iterator itDaughterMap;
    431437  int i;
    432438
  • classes/DelphesHepMCReader.h

    re39abb4 r0e7d64a  
    4242{
    4343public:
    44 
    4544  DelphesHepMCReader();
    4645  ~DelphesHepMCReader();
     
    6261
    6362private:
    64 
    6563  void AnalyzeParticle(DelphesFactory *factory,
    6664    TObjArray *allParticleOutputArray,
     
    8280
    8381  int fStateSize;
    84   std::vector< int > fState;
     82  std::vector<int> fState;
    8583
    8684  int fWeightSize;
    87   std::vector< double > fWeight;
     85  std::vector<double> fWeight;
    8886
    8987  double fCrossSection, fCrossSectionError;
     
    10098  int fParticleCounter;
    10199
    102   std::map< int, std::pair < int, int > > fMotherMap;
    103   std::map< int, std::pair < int, int > > fDaughterMap;
     100  std::map<int, std::pair<int, int> > fMotherMap;
     101  std::map<int, std::pair<int, int> > fDaughterMap;
    104102};
    105103
    106104#endif // DelphesHepMCReader_h
    107 
    108 
  • classes/DelphesLHEFReader.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesLHEFReader
    2120 *
     
    2827#include "classes/DelphesLHEFReader.h"
    2928
    30 #include <stdexcept>
    3129#include <iostream>
    3230#include <sstream>
     31#include <stdexcept>
    3332
    3433#include <stdio.h>
    3534
     35#include "TDatabasePDG.h"
     36#include "TLorentzVector.h"
    3637#include "TObjArray.h"
     38#include "TParticlePDG.h"
    3739#include "TStopwatch.h"
    38 #include "TDatabasePDG.h"
    39 #include "TParticlePDG.h"
    40 #include "TLorentzVector.h"
    4140
    4241#include "classes/DelphesClasses.h"
     
    5453DelphesLHEFReader::DelphesLHEFReader() :
    5554  fInputFile(0), fBuffer(0), fPDG(0),
    56   fEventReady(kFALSE), fEventCounter(-1), fParticleCounter(-1),   fCrossSection(1)
     55  fEventReady(kFALSE), fEventCounter(-1), fParticleCounter(-1), fCrossSection(1)
    5756
    5857{
     
    124123    if(!rc)
    125124    {
    126       cerr << "** ERROR: " << "invalid event format" << endl;
     125      cerr << "** ERROR: "
     126           << "invalid event format" << endl;
    127127      return kFALSE;
    128128    }
     
    148148    if(!rc)
    149149    {
    150       cerr << "** ERROR: " << "invalid particle format" << endl;
     150      cerr << "** ERROR: "
     151           << "invalid particle format" << endl;
    151152      return kFALSE;
    152153    }
     
    162163    if(!pch)
    163164    {
    164       cerr << "** ERROR: " << "invalid weight format" << endl;
     165      cerr << "** ERROR: "
     166           << "invalid weight format" << endl;
    165167      return kFALSE;
    166168    }
     
    172174    if(!pch)
    173175    {
    174       cerr << "** ERROR: " << "invalid weight format" << endl;
     176      cerr << "** ERROR: "
     177           << "invalid weight format" << endl;
    175178      return kFALSE;
    176179    }
     
    181184    if(!rc)
    182185    {
    183       cerr << "** ERROR: " << "invalid weight format" << endl;
     186      cerr << "** ERROR: "
     187           << "invalid weight format" << endl;
    184188      return kFALSE;
    185189    }
     
    192196    if(!pch)
    193197    {
    194       cerr << "** ERROR: " << "invalid cross section format" << endl;
     198      cerr << "** ERROR: "
     199           << "invalid cross section format" << endl;
    195200      return kFALSE;
    196201    }
     
    199204    if(!pch)
    200205    {
    201       cerr << "** ERROR: " << "invalid cross section format" << endl;
     206      cerr << "** ERROR: "
     207           << "invalid cross section format" << endl;
    202208      return kFALSE;
    203209    }
     
    208214    if(!rc)
    209215    {
    210       cerr << "** ERROR: " << "invalid cross section format" << endl;
     216      cerr << "** ERROR: "
     217           << "invalid cross section format" << endl;
    211218      return kFALSE;
    212219    }
     
    249256{
    250257  LHEFWeight *element;
    251   vector< pair< int, double > >::const_iterator itWeightList;
     258  vector<pair<int, double> >::const_iterator itWeightList;
    252259
    253260  for(itWeightList = fWeightList.begin(); itWeightList != fWeightList.end(); ++itWeightList)
     
    279286
    280287  pdgParticle = fPDG->GetParticle(fPID);
    281   candidate->Charge = pdgParticle ? int(pdgParticle->Charge()/3.0) : -999;
     288  candidate->Charge = pdgParticle ? int(pdgParticle->Charge() / 3.0) : -999;
    282289  candidate->Mass = fMass;
    283290
  • classes/DelphesLHEFReader.h

    re39abb4 r0e7d64a  
    3030#include <stdio.h>
    3131
     32#include <utility>
    3233#include <vector>
    33 #include <utility>
    3434
    3535class TObjArray;
     
    4242{
    4343public:
    44 
    4544  DelphesLHEFReader();
    4645  ~DelphesLHEFReader();
     
    6261
    6362private:
    64 
    6563  void AnalyzeParticle(DelphesFactory *factory,
    6664    TObjArray *allParticleOutputArray,
     
    8381  int fPID, fStatus, fM1, fM2, fC1, fC2;
    8482  double fPx, fPy, fPz, fE, fMass;
    85  
    86   std::vector< std::pair< int, double > > fWeightList;
     83
     84  std::vector<std::pair<int, double> > fWeightList;
    8785};
    8886
    8987#endif // DelphesLHEFReader_h
    90 
    91 
  • classes/DelphesModule.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesModule
    2120 *
     
    3029#include "classes/DelphesFactory.h"
    3130
     31#include "ExRootAnalysis/ExRootResult.h"
     32#include "ExRootAnalysis/ExRootTreeBranch.h"
    3233#include "ExRootAnalysis/ExRootTreeReader.h"
    33 #include "ExRootAnalysis/ExRootTreeBranch.h"
    3434#include "ExRootAnalysis/ExRootTreeWriter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3635
    37 #include "TROOT.h"
    3836#include "TClass.h"
    3937#include "TFolder.h"
    4038#include "TObjArray.h"
     39#include "TROOT.h"
    4140
    4241#include <iostream>
     42#include <sstream>
    4343#include <stdexcept>
    44 #include <sstream>
    4544
    4645using namespace std;
     
    157156  return fFactory;
    158157}
    159 
    160 
  • classes/DelphesModule.h

    re39abb4 r0e7d64a  
    4141class DelphesFactory;
    4242
    43 class DelphesModule: public ExRootTask 
     43class DelphesModule: public ExRootTask
    4444{
    4545public:
    46 
    4746  DelphesModule();
    4847  ~DelphesModule();
     
    6160
    6261protected:
    63 
    6462  ExRootTreeWriter *fTreeWriter;
    6563  DelphesFactory *fFactory;
    6664
    6765private:
    68 
    6966  ExRootResult *fPlots;
    7067
     
    7572
    7673#endif /* DelphesModule_h */
    77 
  • classes/DelphesPileUpReader.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesPileUpReader
    2120 *
     
    2827#include "classes/DelphesPileUpReader.h"
    2928
    30 #include <stdexcept>
    3129#include <iostream>
    3230#include <sstream>
     31#include <stdexcept>
    3332
     33#include <stdint.h>
    3434#include <stdio.h>
    35 #include <stdint.h>
    3635
    3736#include "classes/DelphesXDRReader.h"
     
    5251  stringstream message;
    5352
    54   fIndex = new uint8_t[kIndexSize*8];
    55   fBuffer = new uint8_t[kBufferSize*kRecordSize*4];
     53  fIndex = new uint8_t[kIndexSize * 8];
     54  fBuffer = new uint8_t[kBufferSize * kRecordSize * 4];
    5655  fInputReader = new DelphesXDRReader;
    5756  fIndexReader = new DelphesXDRReader;
     
    8281
    8382  // read index of events
    84   fseeko(fPileUpFile, -8 - 8*fEntries, SEEK_END);
    85   fInputReader->ReadRaw(fIndex, fEntries*8);
     83  fseeko(fPileUpFile, -8 - 8 * fEntries, SEEK_END);
     84  fInputReader->ReadRaw(fIndex, fEntries * 8);
    8685}
    8786
     
    130129
    131130  // read event position
    132   fIndexReader->SetOffset(8*entry);
     131  fIndexReader->SetOffset(8 * entry);
    133132  fIndexReader->ReadValue(&offset, 8);
    134133
     
    142141  }
    143142
    144   fInputReader->ReadRaw(fBuffer, fEntrySize*kRecordSize*4);
     143  fInputReader->ReadRaw(fBuffer, fEntrySize * kRecordSize * 4);
    145144  fBufferReader->SetOffset(0);
    146145  fCounter = 0;
  • classes/DelphesPileUpReader.h

    re39abb4 r0e7d64a  
    2828 */
    2929
     30#include <stdint.h>
    3031#include <stdio.h>
    31 #include <stdint.h>
    3232
    3333class DelphesXDRReader;
     
    3636{
    3737public:
    38 
    3938  DelphesPileUpReader(const char *fileName);
    4039
     
    5049
    5150private:
    52 
    5351  int64_t fEntries;
    5452
  • classes/DelphesPileUpWriter.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesPileUpWriter
    2120 *
     
    2827#include "classes/DelphesPileUpWriter.h"
    2928
    30 #include <stdexcept>
    3129#include <iostream>
    3230#include <sstream>
     31#include <stdexcept>
    3332
     33#include <stdint.h>
    3434#include <stdio.h>
    35 #include <stdint.h>
    3635
    3736#include "classes/DelphesXDRWriter.h"
     
    5251  stringstream message;
    5352
    54   fIndex = new uint8_t[kIndexSize*8];
    55   fBuffer = new uint8_t[kBufferSize*kRecordSize*4];
     53  fIndex = new uint8_t[kIndexSize * 8];
     54  fBuffer = new uint8_t[kBufferSize * kRecordSize * 4];
    5655  fOutputWriter = new DelphesXDRWriter;
    5756  fIndexWriter = new DelphesXDRWriter;
     
    118117
    119118  fOutputWriter->WriteValue(&fEntrySize, 4);
    120   fOutputWriter->WriteRaw(fBuffer, fEntrySize*kRecordSize*4);
     119  fOutputWriter->WriteRaw(fBuffer, fEntrySize * kRecordSize * 4);
    121120
    122121  fIndexWriter->WriteValue(&fOffset, 8);
    123   fOffset += fEntrySize*kRecordSize*4 + 4;
     122  fOffset += fEntrySize * kRecordSize * 4 + 4;
    124123
    125124  fBufferWriter->SetOffset(0);
     
    133132void DelphesPileUpWriter::WriteIndex()
    134133{
    135   fOutputWriter->WriteRaw(fIndex, fEntries*8);
     134  fOutputWriter->WriteRaw(fIndex, fEntries * 8);
    136135  fOutputWriter->WriteValue(&fEntries, 8);
    137136}
  • classes/DelphesPileUpWriter.h

    re39abb4 r0e7d64a  
    2828 */
    2929
     30#include <stdint.h>
    3031#include <stdio.h>
    31 #include <stdint.h>
    3232
    3333class DelphesXDRWriter;
     
    3636{
    3737public:
    38 
    3938  DelphesPileUpWriter(const char *fileName);
    4039
     
    5049
    5150private:
    52 
    5351  int64_t fEntries;
    5452  int32_t fEntrySize;
  • classes/DelphesSTDHEPReader.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesSTDHEPReader
    2120 *
     
    2827#include "classes/DelphesSTDHEPReader.h"
    2928
    30 #include <stdexcept>
    3129#include <iostream>
    3230#include <sstream>
    33 
    34 #include <stdio.h>
     31#include <stdexcept>
     32
    3533#include <errno.h>
    3634#include <stdint.h>
     35#include <stdio.h>
    3736#include <string.h>
    3837
     38#include "TDatabasePDG.h"
     39#include "TLorentzVector.h"
    3940#include "TObjArray.h"
     41#include "TParticlePDG.h"
    4042#include "TStopwatch.h"
    41 #include "TDatabasePDG.h"
    42 #include "TParticlePDG.h"
    43 #include "TLorentzVector.h"
    4443
    4544#include "classes/DelphesClasses.h"
     
    5150using namespace std;
    5251
    53 static const int kBufferSize  = 1000000;
     52static const int kBufferSize = 1000000;
    5453
    5554//---------------------------------------------------------------------------
     
    5857  fInputFile(0), fBuffer(0), fPDG(0), fBlockType(-1)
    5958{
    60   fBuffer = new uint8_t[kBufferSize*96 + 24];
     59  fBuffer = new uint8_t[kBufferSize * 96 + 24];
    6160
    6261  fPDG = TDatabasePDG::Instance();
     
    117116    ReadEventHeader();
    118117  }
    119   else if(fBlockType == MCFIO_STDHEPBEG ||
    120           fBlockType == MCFIO_STDHEPEND)
     118  else if(fBlockType == MCFIO_STDHEPBEG || fBlockType == MCFIO_STDHEPEND)
    121119  {
    122120    ReadSTDCM1();
     
    170168  uint32_t size;
    171169  fReader[0].ReadValue(&size, 4);
    172   SkipBytes(size*elsize);
     170  SkipBytes(size * elsize);
    173171}
    174172
     
    178176{
    179177  uint32_t i;
    180   enum STDHEPVersion {UNKNOWN, V1, V2, V21} version;
     178  enum STDHEPVersion
     179  {
     180    UNKNOWN,
     181    V1,
     182    V2,
     183    V21
     184  } version;
    181185
    182186  // version
    183187  fReader[0].ReadString(fBuffer, 100);
    184   if(fBuffer[0] == '\0' || fBuffer[1] == '\0') version = UNKNOWN;
    185   else if(fBuffer[0] == '1') version = V1;
    186   else if(strncmp((char *)fBuffer, "2.01", 4) == 0) version = V21;
    187   else if(fBuffer[0] == '2') version = V2;
    188   else version = UNKNOWN;
     188  if(fBuffer[0] == '\0' || fBuffer[1] == '\0')
     189    version = UNKNOWN;
     190  else if(fBuffer[0] == '1')
     191    version = V1;
     192  else if(strncmp((char *)fBuffer, "2.01", 4) == 0)
     193    version = V21;
     194  else if(fBuffer[0] == '2')
     195    version = V2;
     196  else
     197    version = UNKNOWN;
    189198
    190199  if(version == UNKNOWN)
     
    363372  // 4 + 4 + 4 + 4 + 4 + 4 = 96*n + 24
    364373
    365   fReader[0].ReadRaw(fBuffer, 96*fEventSize + 24);
     374  fReader[0].ReadRaw(fBuffer, 96 * fEventSize + 24);
    366375
    367376  fReader[1].SetBuffer(fBuffer);
    368   fReader[2].SetBuffer(fBuffer + 4*1 + 4*1*fEventSize);
    369   fReader[3].SetBuffer(fBuffer + 4*2 + 4*2*fEventSize);
    370   fReader[4].SetBuffer(fBuffer + 4*3 + 4*4*fEventSize);
    371   fReader[5].SetBuffer(fBuffer + 4*4 + 4*6*fEventSize);
    372   fReader[6].SetBuffer(fBuffer + 4*5 + 4*16*fEventSize);
     377  fReader[2].SetBuffer(fBuffer + 4 * 1 + 4 * 1 * fEventSize);
     378  fReader[3].SetBuffer(fBuffer + 4 * 2 + 4 * 2 * fEventSize);
     379  fReader[4].SetBuffer(fBuffer + 4 * 3 + 4 * 4 * fEventSize);
     380  fReader[5].SetBuffer(fBuffer + 4 * 4 + 4 * 6 * fEventSize);
     381  fReader[6].SetBuffer(fBuffer + 4 * 5 + 4 * 16 * fEventSize);
    373382
    374383  fReader[1].ReadValue(&idhepSize, 4);
     
    391400  fAlphaQCD = 0.0;
    392401  fScaleSize = 0;
    393   memset(fScale, 0, 10*sizeof(double));
     402  memset(fScale, 0, 10 * sizeof(double));
    394403}
    395404
     
    494503
    495504    pdgParticle = fPDG->GetParticle(pid);
    496     candidate->Charge = pdgParticle ? int(pdgParticle->Charge()/3.0) : -999;
     505    candidate->Charge = pdgParticle ? int(pdgParticle->Charge() / 3.0) : -999;
    497506    candidate->Mass = mass;
    498507
  • classes/DelphesSTDHEPReader.h

    re39abb4 r0e7d64a  
    2828 */
    2929
     30#include <stdint.h>
    3031#include <stdio.h>
    31 #include <stdint.h>
    3232
    3333#include "classes/DelphesXDRReader.h"
     
    7272
    7373private:
    74 
    7574  void AnalyzeParticles(DelphesFactory *factory,
    7675    TObjArray *allParticleOutputArray,
  • classes/DelphesStream.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesStream
    2120 *
     
    2827#include "classes/DelphesStream.h"
    2928
     29#include <errno.h>
     30#include <limits.h>
     31#include <math.h>
     32#include <stdio.h>
    3033#include <stdlib.h>
    31 #include <limits.h>
    3234#include <string.h>
    33 #include <stdio.h>
    34 #include <errno.h>
    35 #include <math.h>
    3635
    3736#include <iostream>
     
    6564    if(fFirstHugePos && value == HUGE_VAL)
    6665    {
    67       fFirstHugePos = false; 
     66      fFirstHugePos = false;
    6867      cout << "** WARNING: too large positive value, return " << value << endl;
    6968    }
    7069    else if(fFirstHugeNeg && value == -HUGE_VAL)
    7170    {
    72       fFirstHugeNeg = false; 
     71      fFirstHugeNeg = false;
    7372      cout << "** WARNING: too large negative value, return " << value << endl;
    7473    }
    7574    else if(fFirstZero)
    7675    {
    77       fFirstZero = false; 
     76      fFirstZero = false;
    7877      value = 0.0;
    7978      cout << "** WARNING: too small value, return " << value << endl;
     
    9493    if(fFirstLongMin && value == LONG_MIN)
    9594    {
    96       fFirstLongMin = false; 
     95      fFirstLongMin = false;
    9796      cout << "** WARNING: too large positive value, return " << value << endl;
    9897    }
    9998    else if(fFirstLongMax && value == LONG_MAX)
    10099    {
    101       fFirstLongMax = false; 
     100      fFirstLongMax = false;
    102101      cout << "** WARNING: too large negative value, return " << value << endl;
    103102    }
  • classes/DelphesStream.h

    re39abb4 r0e7d64a  
    3131{
    3232public:
    33 
    3433  DelphesStream(char *buffer);
    3534
     
    3837
    3938private:
     39  char *fBuffer;
    4040
    41   char *fBuffer;
    42  
    4341  static bool fFirstLongMin;
    4442  static bool fFirstLongMax;
     
    4947
    5048#endif // DelphesStream_h
    51 
    52 
  • classes/DelphesTF2.cc

    re39abb4 r0e7d64a  
    3232{
    3333
    34 #if ROOT_VERSION_CODE >= ROOT_VERSION(6,04,00)
     34#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 3, 0)
    3535  fFormula = new TFormula();
    3636#endif
    37 
    38 
    3937}
    4038
     
    6058  for(it = expression; *it; ++it)
    6159  {
    62     if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
     60    if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
    6361    buffer.Append(*it);
    6462  }
    6563  buffer.ReplaceAll("z", "x");
    6664  buffer.ReplaceAll("t", "y");
    67 #if ROOT_VERSION_CODE < ROOT_VERSION(6,04,00)
     65#if ROOT_VERSION_CODE < ROOT_VERSION(6, 3, 0)
    6866  if(TF2::Compile(buffer) != 0)
    6967#else
  • classes/DelphesTF2.h

    re39abb4 r0e7d64a  
    2525{
    2626public:
    27 
    2827  DelphesTF2();
    2928
  • classes/DelphesXDRReader.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesXDRReader
    2120 *
     
    2827#include "classes/DelphesXDRReader.h"
    2928
     29#include <stdint.h>
    3030#include <stdio.h>
    31 #include <stdint.h>
    3231#include <string.h>
    3332
     
    109108
    110109  if(size > maxSize) size = maxSize;
    111    
     110
    112111  if(fBuffer)
    113112  {
  • classes/DelphesXDRReader.h

    re39abb4 r0e7d64a  
    2828 */
    2929
     30#include <stdint.h>
    3031#include <stdio.h>
    31 #include <stdint.h>
    3232
    3333class DelphesXDRReader
    3434{
    3535public:
    36 
    3736  DelphesXDRReader();
    3837
     
    4645
    4746private:
    48 
    4947  FILE *fFile;
    5048  uint8_t *fBuffer;
  • classes/DelphesXDRWriter.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DelphesXDRWriter
    2120 *
     
    2827#include "classes/DelphesXDRWriter.h"
    2928
     29#include <stdint.h>
    3030#include <stdio.h>
    31 #include <stdint.h>
    3231#include <string.h>
    3332
  • classes/DelphesXDRWriter.h

    re39abb4 r0e7d64a  
    2828 */
    2929
     30#include <stdint.h>
    3031#include <stdio.h>
    31 #include <stdint.h>
    3232
    3333class DelphesXDRWriter
    3434{
    3535public:
    36 
    3736  DelphesXDRWriter();
    3837
     
    4544
    4645private:
    47 
    4846  FILE *fFile;
    4947  uint8_t *fBuffer;
  • classes/SortableObject.h

    re39abb4 r0e7d64a  
    2626 */
    2727
     28#include "TObject.h"
    2829#include "TRef.h"
    29 #include "TObject.h"
    3030#include "TRefArray.h"
    3131
     
    3737{
    3838public:
    39   virtual ~CompBase() { }
     39  virtual ~CompBase() {}
    4040  virtual Bool_t IsSortable(const TObject *) const { return kTRUE; }
    4141  virtual Int_t Compare(const TObject *obj1, const TObject *obj2) const = 0;
     
    4747{
    4848public:
    49 
    5049  Bool_t IsSortable() const { return GetCompare() ? GetCompare()->IsSortable(this) : kFALSE; }
    5150  Int_t Compare(const TObject *obj) const { return GetCompare()->Compare(this, obj); }
     
    6463{
    6564  CompE() {}
     65
    6666public:
    6767  static CompE *Instance()
     
    7373  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    7474  {
    75     const T *t1 = static_cast<const T*>(obj1);
    76     const T *t2 = static_cast<const T*>(obj2);
     75    const T *t1 = static_cast<const T *>(obj1);
     76    const T *t2 = static_cast<const T *>(obj2);
    7777    if(t1->E > t2->E)
    7878      return -1;
     
    9090{
    9191  CompPT() {}
     92
    9293public:
    9394  static CompPT *Instance()
     
    99100  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    100101  {
    101     const T *t1 = static_cast<const T*>(obj1);
    102     const T *t2 = static_cast<const T*>(obj2);
     102    const T *t1 = static_cast<const T *>(obj1);
     103    const T *t2 = static_cast<const T *>(obj2);
    103104    if(t1->PT > t2->PT)
    104105      return -1;
     
    116117{
    117118  CompMomentumPt() {}
     119
    118120public:
    119121  static CompMomentumPt *Instance()
     
    125127  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    126128  {
    127     const T *t1 = static_cast<const T*>(obj1);
    128     const T *t2 = static_cast<const T*>(obj2);
     129    const T *t1 = static_cast<const T *>(obj1);
     130    const T *t2 = static_cast<const T *>(obj2);
    129131    if(t1->Momentum.Pt() > t2->Momentum.Pt())
    130132      return -1;
     
    142144{
    143145  CompET() {}
     146
    144147public:
    145148  static CompET *Instance()
     
    151154  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    152155  {
    153     const T *t1 = static_cast<const T*>(obj1);
    154     const T *t2 = static_cast<const T*>(obj2);
     156    const T *t1 = static_cast<const T *>(obj1);
     157    const T *t2 = static_cast<const T *>(obj2);
    155158    if(t1->ET > t2->ET)
    156159      return -1;
     
    168171{
    169172  CompSumPT2() {}
     173
    170174public:
    171175  static CompSumPT2 *Instance()
     
    177181  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    178182  {
    179     const T *t1 = static_cast<const T*>(obj1);
    180     const T *t2 = static_cast<const T*>(obj2);
     183    const T *t1 = static_cast<const T *>(obj1);
     184    const T *t2 = static_cast<const T *>(obj2);
    181185    if(t1->SumPT2 > t2->SumPT2)
    182186      return -1;
     
    193197class CompDeltaR: public CompBase
    194198{
    195   CompDeltaR(const T2 *obj = 0) : fObj(obj) {}
     199  CompDeltaR(const T2 *obj = 0) :
     200    fObj(obj) {}
    196201
    197202  Double_t DeltaPhi(Double_t phi1, Double_t phi2)
    198203  {
    199204    Double_t phi = TMath::Abs(phi1 - phi2);
    200     return (phi <= TMath::Pi()) ? phi : (2.0*TMath::Pi()) - phi;
    201   }
    202 
    203   Double_t Sqr(Double_t x) { return x*x; }
     205    return (phi <= TMath::Pi()) ? phi : (2.0 * TMath::Pi()) - phi;
     206  }
     207
     208  Double_t Sqr(Double_t x) { return x * x; }
    204209
    205210  Double_t SumSqr(Double_t a, Double_t b)
     
    207212    Double_t aAbs = TMath::Abs(a);
    208213    Double_t bAbs = TMath::Abs(b);
    209     if(aAbs > bAbs) return aAbs * TMath::Sqrt(1.0 + Sqr(bAbs / aAbs));
    210     else return (bAbs == 0) ? 0.0 : bAbs * TMath::Sqrt(1.0 + Sqr(aAbs / bAbs));
     214    if(aAbs > bAbs)
     215      return aAbs * TMath::Sqrt(1.0 + Sqr(bAbs / aAbs));
     216    else
     217      return (bAbs == 0) ? 0.0 : bAbs * TMath::Sqrt(1.0 + Sqr(aAbs / bAbs));
    211218  };
    212219
     
    214221
    215222public:
    216     static CompDeltaR *Instance(const T2 *obj = 0)
    217   {
    218       static CompDeltaR single(obj);
    219       return &single;
     223  static CompDeltaR *Instance(const T2 *obj = 0)
     224  {
     225    static CompDeltaR single(obj);
     226    return &single;
    220227  }
    221228
     
    225232  {
    226233    Double_t eta[3], phi[3], deltaR[2];
    227     const T1 *t1 = static_cast<const T1*>(obj1);
    228     const T1 *t2 = static_cast<const T1*>(obj2);
     234    const T1 *t1 = static_cast<const T1 *>(obj1);
     235    const T1 *t2 = static_cast<const T1 *>(obj2);
    229236
    230237    eta[0] = fObj->Eta;
     
    250257
    251258#endif // SortableObject_h
    252 
    253 
  • converters/hepmc2pileup.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 #include <stdexcept>
    2019#include <iostream>
    2120#include <sstream>
     21#include <stdexcept>
    2222
    2323#include <signal.h>
    2424
     25#include "TApplication.h"
    2526#include "TROOT.h"
    26 #include "TApplication.h"
    2727
     28#include "TDatabasePDG.h"
    2829#include "TFile.h"
     30#include "TLorentzVector.h"
    2931#include "TObjArray.h"
     32#include "TParticlePDG.h"
    3033#include "TStopwatch.h"
    31 #include "TDatabasePDG.h"
    32 #include "TParticlePDG.h"
    33 #include "TLorentzVector.h"
    3434
    3535#include "classes/DelphesClasses.h"
     
    3838#include "classes/DelphesPileUpWriter.h"
    3939
     40#include "ExRootAnalysis/ExRootProgressBar.h"
     41#include "ExRootAnalysis/ExRootTreeBranch.h"
    4042#include "ExRootAnalysis/ExRootTreeWriter.h"
    41 #include "ExRootAnalysis/ExRootTreeBranch.h"
    42 #include "ExRootAnalysis/ExRootProgressBar.h"
    4343
    4444using namespace std;
     
    7171  if(argc < 2)
    7272  {
    73     cout << " Usage: " << appName << " output_file" << " [input_file(s)]" << endl;
     73    cout << " Usage: " << appName << " output_file"
     74         << " [input_file(s)]" << endl;
    7475    cout << " output_file - output binary pile-up file," << endl;
    7576    cout << " input_file(s) - input file(s) in HepMC format," << endl;
     
    142143      reader->Clear();
    143144      while(reader->ReadBlock(factory, allParticleOutputArray,
    144         stableParticleOutputArray, partonOutputArray) && !interrupted)
     145              stableParticleOutputArray, partonOutputArray)
     146        && !interrupted)
    145147      {
    146148        if(reader->EventReady())
     
    149151
    150152          itParticle->Reset();
    151           while((candidate = static_cast<Candidate*>(itParticle->Next())))
     153          while((candidate = static_cast<Candidate *>(itParticle->Next())))
    152154          {
    153155            const TLorentzVector &position = candidate->Position;
     
    173175
    174176      ++i;
    175     }
    176     while(i < argc);
     177    } while(i < argc);
    177178
    178179    writer->WriteIndex();
  • converters/lhco2root.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 #include <stdexcept>
    2019#include <iostream>
    2120#include <sstream>
    22 
    23 #include <stdlib.h>
     21#include <stdexcept>
     22
    2423#include <signal.h>
    2524#include <stdio.h>
    26 
     25#include <stdlib.h>
     26
     27#include "TApplication.h"
    2728#include "TROOT.h"
    28 #include "TApplication.h"
    29 
     29
     30#include "TDatabasePDG.h"
    3031#include "TFile.h"
     32#include "TLorentzVector.h"
    3133#include "TObjArray.h"
     34#include "TParticlePDG.h"
    3235#include "TStopwatch.h"
    33 #include "TDatabasePDG.h"
    34 #include "TParticlePDG.h"
    35 #include "TLorentzVector.h"
    36 
    37 #include "modules/Delphes.h"
    38 #include "classes/DelphesStream.h"
     36
    3937#include "classes/DelphesClasses.h"
    4038#include "classes/DelphesFactory.h"
    41 
     39#include "classes/DelphesStream.h"
     40#include "modules/Delphes.h"
     41
     42#include "ExRootAnalysis/ExRootProgressBar.h"
     43#include "ExRootAnalysis/ExRootTreeBranch.h"
    4244#include "ExRootAnalysis/ExRootTreeWriter.h"
    43 #include "ExRootAnalysis/ExRootTreeBranch.h"
    44 #include "ExRootAnalysis/ExRootProgressBar.h"
    4545
    4646using namespace std;
    4747
    48 static const int kBufferSize  = 1024;
     48static const int kBufferSize = 1024;
    4949
    5050/*
     
    7474
    7575private:
    76 
    7776  void AddMissingEvents();
    7877
     
    8685  void AnalyseMissingET(ExRootTreeBranch *branch);
    8786
    88   enum {kIntParamSize = 2, kDblParamSize = 7};
     87  enum
     88  {
     89    kIntParamSize = 2,
     90    kDblParamSize = 7
     91  };
    8992  Int_t fIntParam[kIntParamSize];
    9093  Double_t fDblParam[kDblParamSize];
     
    106109  ExRootTreeBranch *fBranchJet;
    107110  ExRootTreeBranch *fBranchMissingET;
    108 
    109111};
    110112
     
    169171    if(!rc)
    170172    {
    171       cerr << "** ERROR: " << "invalid event format" << endl;
     173      cerr << "** ERROR: "
     174           << "invalid event format" << endl;
    172175      return kFALSE;
    173176    }
     
    195198    if(!rc)
    196199    {
    197       cerr << "** ERROR: " << "invalid object format" << endl;
     200      cerr << "** ERROR: "
     201           << "invalid object format" << endl;
    198202      return kFALSE;
    199203    }
     
    201205    switch(fIntParam[1])
    202206    {
    203       case 0: AnalysePhoton(fBranchPhoton); break;
    204       case 1: AnalyseElectron(fBranchElectron); break;
    205       case 2: AnalyseMuon(fBranchMuon); break;
    206       case 3: AnalyseTau(fBranchJet); break;
    207       case 4: AnalyseJet(fBranchJet); break;
    208       case 6: AnalyseMissingET(fBranchMissingET); break;
     207    case 0: AnalysePhoton(fBranchPhoton); break;
     208    case 1: AnalyseElectron(fBranchElectron); break;
     209    case 2: AnalyseMuon(fBranchMuon); break;
     210    case 3: AnalyseTau(fBranchJet); break;
     211    case 4: AnalyseJet(fBranchJet); break;
     212    case 6: AnalyseMissingET(fBranchMissingET); break;
    209213    }
    210214  }
     
    228232  LHCOEvent *element;
    229233
    230   element = static_cast<LHCOEvent*>(branch->NewEntry());
     234  element = static_cast<LHCOEvent *>(branch->NewEntry());
    231235
    232236  element->Number = fEventNumber;
     
    240244  Photon *element;
    241245
    242   element = static_cast<Photon*>(branch->NewEntry());
     246  element = static_cast<Photon *>(branch->NewEntry());
    243247
    244248  element->Eta = fDblParam[0];
     
    254258  Electron *element;
    255259
    256   element = static_cast<Electron*>(branch->NewEntry());
     260  element = static_cast<Electron *>(branch->NewEntry());
    257261
    258262  element->Eta = fDblParam[0];
     
    261265
    262266  element->Charge = fDblParam[4] < 0.0 ? -1 : 1;
    263 /*
     267  /*
    264268  element->Ntrk = TMath::Abs(fDblParam[4]);
    265269*/
     
    273277  Muon *element;
    274278
    275   element = static_cast<Muon*>(branch->NewEntry());
     279  element = static_cast<Muon *>(branch->NewEntry());
    276280
    277281  element->Eta = fDblParam[0];
     
    280284
    281285  element->Charge = fDblParam[4] < 0.0 ? -1 : 1;
    282 /*
     286  /*
    283287  element->Ntrk = TMath::Abs(fDblParam[4]);
    284288
     
    296300  Jet *element;
    297301
    298   element = static_cast<Jet*>(branch->NewEntry());
     302  element = static_cast<Jet *>(branch->NewEntry());
    299303
    300304  element->Eta = fDblParam[0];
     
    308312
    309313  element->Charge = fDblParam[4] < 0 ? -1 : 1;
    310 /*
     314  /*
    311315  element->Ntrk = TMath::Abs(fDblParam[4]);
    312316*/
     
    320324  Jet *element;
    321325
    322   element = static_cast<Jet*>(branch->NewEntry());
     326  element = static_cast<Jet *>(branch->NewEntry());
    323327
    324328  element->Eta = fDblParam[0];
     
    327331
    328332  element->Mass = fDblParam[3];
    329 /*
     333  /*
    330334  element->Ntrk = TMath::Abs(Int_t(fDblParam[4]));
    331335*/
     
    336340
    337341  element->EhadOverEem = fDblParam[6];
    338 /*
     342  /*
    339343  element->Index = fIntParam[0];
    340344*/
     
    347351  MissingET *element;
    348352
    349   element = static_cast<MissingET*>(branch->NewEntry());
     353  element = static_cast<MissingET *>(branch->NewEntry());
    350354
    351355  element->Phi = fDblParam[1];
     
    376380  if(argc < 2)
    377381  {
    378     cout << " Usage: " << appName << " output_file" << " [input_file(s)]" << endl;
     382    cout << " Usage: " << appName << " output_file"
     383         << " [input_file(s)]" << endl;
    379384    cout << " output_file - output file in ROOT format," << endl;
    380385    cout << " input_file(s) - input file(s) in LHCO format," << endl;
     
    456461
    457462      ++i;
    458     }
    459     while(i < argc);
     463    } while(i < argc);
    460464
    461465    cout << "** Exiting..." << endl;
     
    474478  }
    475479}
    476 
    477 
  • converters/pileup2root.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    20 #include <stdexcept>
    2119#include <iostream>
    2220#include <sstream>
    23 
    24 #include <stdlib.h>
     21#include <stdexcept>
     22
    2523#include <signal.h>
    2624#include <stdio.h>
    27 
     25#include <stdlib.h>
     26
     27#include "TApplication.h"
    2828#include "TROOT.h"
    29 #include "TApplication.h"
    30 
     29
     30#include "TDatabasePDG.h"
    3131#include "TFile.h"
     32#include "TLorentzVector.h"
    3233#include "TObjArray.h"
     34#include "TParticlePDG.h"
    3335#include "TStopwatch.h"
    34 #include "TDatabasePDG.h"
    35 #include "TParticlePDG.h"
    36 #include "TLorentzVector.h"
    37 
    38 #include "classes/DelphesStream.h"
     36
    3937#include "classes/DelphesClasses.h"
    4038#include "classes/DelphesFactory.h"
    4139#include "classes/DelphesPileUpReader.h"
    42 
     40#include "classes/DelphesStream.h"
     41
     42#include "ExRootAnalysis/ExRootProgressBar.h"
     43#include "ExRootAnalysis/ExRootTreeBranch.h"
    4344#include "ExRootAnalysis/ExRootTreeWriter.h"
    44 #include "ExRootAnalysis/ExRootTreeBranch.h"
    45 #include "ExRootAnalysis/ExRootProgressBar.h"
    4645
    4746using namespace std;
     
    6261  while(reader->ReadParticle(pid, x, y, z, t, px, py, pz, e))
    6362  {
    64     particle = static_cast<GenParticle*>(branch->NewEntry());
     63    particle = static_cast<GenParticle *>(branch->NewEntry());
    6564
    6665    particle->PID = pid;
     
    8483
    8584    pdgParticle = pdg->GetParticle(pid);
    86     particle->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     85    particle->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    8786
    8887    particle->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
     
    9291    cosTheta = TMath::Abs(momentum.CosTheta());
    9392    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    94     eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
    95     rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
     93    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
     94    rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
    9695
    9796    particle->Eta = eta;
     
    126125  if(argc != 3)
    127126  {
    128     cout << " Usage: " << appName << " output_file" << " input_file" << endl;
     127    cout << " Usage: " << appName << " output_file"
     128         << " input_file" << endl;
    129129    cout << " output_file - output file in ROOT format," << endl;
    130130    cout << " input_file - input binary pile-up file." << endl;
     
    199199  }
    200200}
    201 
    202 
  • converters/root2lhco.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
     19#include <fstream>
     20#include <iostream>
     21#include <sstream>
    1922#include <stdexcept>
    20 #include <iostream>
    21 #include <fstream>
    22 #include <sstream>
    2323#include <string>
    2424
    25 #include <stdlib.h>
    2625#include <signal.h>
    2726#include <stdio.h>
    28 
     27#include <stdlib.h>
     28
     29#include "TApplication.h"
    2930#include "TROOT.h"
    30 #include "TApplication.h"
    31 
     31
     32#include "TClonesArray.h"
    3233#include "TFile.h"
    33 #include "TClonesArray.h"
    3434
    3535#include "classes/DelphesClasses.h"
    3636
     37#include "ExRootAnalysis/ExRootProgressBar.h"
    3738#include "ExRootAnalysis/ExRootTreeReader.h"
    38 #include "ExRootAnalysis/ExRootProgressBar.h"
    3939
    4040using namespace std;
     
    6262
    6363private:
    64 
    6564  void Reset();
    6665  void Write();
     
    7675  void AnalyseMissingET();
    7776
    78   enum {kIntParamSize = 2, kDblParamSize = 9};
     77  enum
     78  {
     79    kIntParamSize = 2,
     80    kDblParamSize = 9
     81  };
    7982  Int_t fIntParam[kIntParamSize];
    8083  Double_t fDblParam[kDblParamSize];
     
    132135  fBranchMissingET = fTreeReader->UseBranch("MissingET");
    133136
    134   if(!fBranchEvent || !fBranchTrack || !fBranchTower || !fBranchPhoton ||
    135      !fBranchElectron || !fBranchMuon || !fBranchJet || !fBranchMissingET)
     137  if(!fBranchEvent || !fBranchTrack || !fBranchTower || !fBranchPhoton || !fBranchElectron || !fBranchMuon || !fBranchJet || !fBranchMissingET)
    136138  {
    137139    throw runtime_error("ROOT file doesn't contain all required branches");
     
    202204  Event *element;
    203205
    204   element = static_cast<Event*>(fBranchEvent->At(0));
     206  element = static_cast<Event *>(fBranchEvent->At(0));
    205207
    206208  fprintf(fOutputFile, "%4d %13lld %8d\n", 0, element->Number, 0);
     
    216218
    217219  fItPhoton->Reset();
    218   while((element = static_cast<Photon*>(fItPhoton->Next())))
     220  while((element = static_cast<Photon *>(fItPhoton->Next())))
    219221  {
    220222    Reset();
     
    239241
    240242  fItElectron->Reset();
    241   while((element = static_cast<Electron*>(fItElectron->Next())))
     243  while((element = static_cast<Electron *>(fItElectron->Next())))
    242244  {
    243245    Reset();
     
    270272  muonCounter = 0;
    271273  fItMuon->Reset();
    272   while((element = static_cast<Muon*>(fItMuon->Next())))
     274  while((element = static_cast<Muon *>(fItMuon->Next())))
    273275  {
    274276    Reset();
     
    276278    sumPT = 0.0;
    277279    fItTrack->Reset();
    278     while((track = static_cast<Track*>(fItTrack->Next())))
     280    while((track = static_cast<Track *>(fItTrack->Next())))
    279281    {
    280282      if(element->P4().DeltaR(track->P4()) < 0.5) sumPT += track->PT;
     
    283285    sumET = 0.0;
    284286    fItTower->Reset();
    285     while((tower = static_cast<Tower*>(fItTower->Next())))
     287    while((tower = static_cast<Tower *>(fItTower->Next())))
    286288    {
    287289      if(element->P4().DeltaR(tower->P4()) < 0.5) sumET += tower->ET;
     
    293295    minDR = 1.0E9;
    294296    fItJet->Reset();
    295     while((jet = static_cast<Jet*>(fItJet->Next())))
     297    while((jet = static_cast<Jet *>(fItJet->Next())))
    296298    {
    297299      if(jet->TauTag != 0)
     
    325327    }
    326328
    327     ratET = sumET/element->PT;
     329    ratET = sumET / element->PT;
    328330    fDblParam[6] = Float_t(TMath::Nint(sumPT)) + (ratET < 1.0 ? ratET : 0.99);
    329331
     
    342344
    343345  fItJet->Reset();
    344   while((element = static_cast<Jet*>(fItJet->Next())))
     346  while((element = static_cast<Jet *>(fItJet->Next())))
    345347  {
    346348    if(element->TauTag == 0) continue;
     
    350352    counter = 1;
    351353
    352    /*
     354    /*
    353355    fItTrack->Reset();
    354356    while((track = static_cast<Track*>(fItTrack->Next())))
     
    380382
    381383  fItJet->Reset();
    382   while((element = static_cast<Jet*>(fItJet->Next())))
     384  while((element = static_cast<Jet *>(fItJet->Next())))
    383385  {
    384386    if(element->TauTag != 0) continue;
     
    388390    counter = 0;
    389391    fItTrack->Reset();
    390     while((track = static_cast<Track*>(fItTrack->Next())))
     392    while((track = static_cast<Track *>(fItTrack->Next())))
    391393    {
    392394      if(element->P4().DeltaR(track->P4()) < 0.5) ++counter;
     
    413415  MissingET *element;
    414416
    415   element = static_cast<MissingET*>(fBranchMissingET->At(0));
     417  element = static_cast<MissingET *>(fBranchMissingET->At(0));
    416418
    417419  Reset();
     
    471473  if(argc < 2 || argc > 4)
    472474  {
    473     cerr << " Usage: " << appName << " input_file" << " [output_file] [--jet-branch=Jet]" << endl;
     475    cerr << " Usage: " << appName << " input_file"
     476         << " [output_file] [--jet-branch=Jet]" << endl;
    474477    cerr << " input_file - input file in ROOT format," << endl;
    475478    cerr << " output_file - output file in LHCO format," << endl;
  • converters/root2pileup.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 #include <stdexcept>
    2019#include <iostream>
    2120#include <sstream>
     21#include <stdexcept>
    2222#include <string>
    2323
    2424#include <signal.h>
    2525
     26#include "TApplication.h"
    2627#include "TROOT.h"
    27 #include "TApplication.h"
    2828
     29#include "TClonesArray.h"
    2930#include "TFile.h"
    30 #include "TClonesArray.h"
    3131
    3232#include "classes/DelphesClasses.h"
    3333#include "classes/DelphesPileUpWriter.h"
    3434
     35#include "ExRootAnalysis/ExRootProgressBar.h"
    3536#include "ExRootAnalysis/ExRootTreeReader.h"
    36 #include "ExRootAnalysis/ExRootProgressBar.h"
    3737
    3838using namespace std;
     
    6464  if(argc < 3)
    6565  {
    66     cout << " Usage: " << appName << " output_file" << " input_file(s)" << endl;
     66    cout << " Usage: " << appName << " output_file"
     67         << " input_file(s)" << endl;
    6768    cout << " output_file - output binary pile-up file," << endl;
    6869    cout << " input_file(s) - input file(s) in ROOT format." << endl;
     
    108109
    109110        itParticle->Reset();
    110         while((particle = static_cast<GenParticle*>(itParticle->Next())))
     111        while((particle = static_cast<GenParticle *>(itParticle->Next())))
    111112        {
    112113          writer->WriteParticle(particle->PID,
     
    114115            particle->Px, particle->Py, particle->Pz, particle->E);
    115116        }
    116        
     117
    117118        writer->WriteEntry();
    118119
  • converters/stdhep2pileup.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 #include <stdexcept>
    2019#include <iostream>
    2120#include <sstream>
     21#include <stdexcept>
    2222
    2323#include <signal.h>
    2424
     25#include "TApplication.h"
    2526#include "TROOT.h"
    26 #include "TApplication.h"
    2727
     28#include "TDatabasePDG.h"
    2829#include "TFile.h"
     30#include "TLorentzVector.h"
    2931#include "TObjArray.h"
     32#include "TParticlePDG.h"
    3033#include "TStopwatch.h"
    31 #include "TDatabasePDG.h"
    32 #include "TParticlePDG.h"
    33 #include "TLorentzVector.h"
    3434
    3535#include "classes/DelphesClasses.h"
    3636#include "classes/DelphesFactory.h"
     37#include "classes/DelphesPileUpWriter.h"
    3738#include "classes/DelphesSTDHEPReader.h"
    38 #include "classes/DelphesPileUpWriter.h"
    3939
     40#include "ExRootAnalysis/ExRootProgressBar.h"
     41#include "ExRootAnalysis/ExRootTreeBranch.h"
    4042#include "ExRootAnalysis/ExRootTreeWriter.h"
    41 #include "ExRootAnalysis/ExRootTreeBranch.h"
    42 #include "ExRootAnalysis/ExRootProgressBar.h"
    4343
    4444using namespace std;
     
    7171  if(argc < 2)
    7272  {
    73     cout << " Usage: " << appName << " output_file" << " [input_file(s)]" << endl;
     73    cout << " Usage: " << appName << " output_file"
     74         << " [input_file(s)]" << endl;
    7475    cout << " output_file - output binary pile-up file," << endl;
    7576    cout << " input_file(s) - input file(s) in STDHEP format," << endl;
     
    142143      reader->Clear();
    143144      while(reader->ReadBlock(factory, allParticleOutputArray,
    144         stableParticleOutputArray, partonOutputArray) && !interrupted)
     145              stableParticleOutputArray, partonOutputArray)
     146        && !interrupted)
    145147      {
    146148        if(reader->EventReady())
     
    149151
    150152          itParticle->Reset();
    151           while((candidate = static_cast<Candidate*>(itParticle->Next())))
     153          while((candidate = static_cast<Candidate *>(itParticle->Next())))
    152154          {
    153155            const TLorentzVector &position = candidate->Position;
     
    173175
    174176      ++i;
    175     }
    176     while(i < argc);
     177    } while(i < argc);
    177178
    178179    writer->WriteIndex();
  • display/Delphes3DGeometry.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
     19#include <algorithm>
     20#include <cassert>
     21#include <map>
    1922#include <set>
    20 #include <map>
     23#include <sstream>
    2124#include <utility>
    2225#include <vector>
    23 #include <algorithm>
    24 #include <sstream>
    25 #include <cassert>
    2626
    2727#include "TAxis.h"
     28#include "TF2.h"
     29#include "TFormula.h"
     30#include "TGeoArb8.h"
     31#include "TGeoCompositeShape.h"
     32#include "TGeoCone.h"
    2833#include "TGeoManager.h"
    29 #include "TGeoVolume.h"
     34#include "TGeoMatrix.h"
    3035#include "TGeoMedium.h"
    3136#include "TGeoNode.h"
    32 #include "TGeoCompositeShape.h"
    33 #include "TGeoMatrix.h"
    3437#include "TGeoTube.h"
    35 #include "TGeoCone.h"
    36 #include "TGeoArb8.h"
    37 #include "TF2.h"
    38 #include "TFormula.h"
     38#include "TGeoVolume.h"
    3939#include "TH1F.h"
    4040#include "TMath.h"
     
    4848using namespace std;
    4949
    50 Delphes3DGeometry::Delphes3DGeometry(TGeoManager *geom, bool transp) {
    51 
    52    //--- the geometry manager
    53    geom_ = geom==NULL? gGeoManager : geom;
    54    //gGeoManager->DefaultColors();
    55 
    56    //--- define some materials
    57    TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0);
    58    TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // placeholder
    59    if(transp) {
    60      matVacuum->SetTransparency(85);
    61      matAl->SetTransparency(85);
    62    }
    63 
    64    //--- define some media
    65    TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum);
    66    TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl);
    67    vacuum_ = Vacuum;
    68    tkmed_ = Vacuum; // placeholder
    69    calomed_ = Al;   // placeholder
    70    mudetmed_ = Al;  // placeholder
    71 
    72    // custom parameters
    73    contingency_ = 10.;
    74    calo_barrel_thickness_ = 50.;
    75    calo_endcap_thickness_ = 75.;
    76    muonSystem_thickn_ = 10.;
    77 
    78    // read these parameters from the Delphes Card (with default values)
    79    etaAxis_   = NULL;
    80    phiAxis_   = NULL;
    81    tk_radius_ = 120.;
    82    tk_length_ = 150.;
    83    tk_etamax_ = 3.0;
    84    tk_Bz_     = 1.;
    85    muonSystem_radius_ = 200.;
     50Delphes3DGeometry::Delphes3DGeometry(TGeoManager *geom, bool transp)
     51{
     52
     53  //--- the geometry manager
     54  geom_ = geom == NULL ? gGeoManager : geom;
     55  //gGeoManager->DefaultColors();
     56
     57  //--- define some materials
     58  TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0);
     59  TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98, 13, 2.7); // placeholder
     60  if(transp)
     61  {
     62    matVacuum->SetTransparency(85);
     63    matAl->SetTransparency(85);
     64  }
     65
     66  //--- define some media
     67  TGeoMedium *Vacuum = new TGeoMedium("Vacuum", 1, matVacuum);
     68  TGeoMedium *Al = new TGeoMedium("Root Material", 2, matAl);
     69  vacuum_ = Vacuum;
     70  tkmed_ = Vacuum; // placeholder
     71  calomed_ = Al; // placeholder
     72  mudetmed_ = Al; // placeholder
     73
     74  // custom parameters
     75  contingency_ = 10.;
     76  calo_barrel_thickness_ = 50.;
     77  calo_endcap_thickness_ = 75.;
     78  muonSystem_thickn_ = 10.;
     79
     80  // read these parameters from the Delphes Card (with default values)
     81  etaAxis_ = NULL;
     82  phiAxis_ = NULL;
     83  tk_radius_ = 120.;
     84  tk_length_ = 150.;
     85  tk_etamax_ = 3.0;
     86  tk_Bz_ = 1.;
     87  muonSystem_radius_ = 200.;
    8688}
    8789
    8890void Delphes3DGeometry::readFile(const char *configFile,
    89                                  const char* ParticlePropagator, const char* TrackingEfficiency,
    90                                  const char* MuonEfficiency, const char* Calorimeters) {
    91 
    92    ExRootConfReader *confReader = new ExRootConfReader;
    93    confReader->ReadFile(configFile);
    94 
    95    tk_radius_ = confReader->GetDouble(Form("%s::Radius",ParticlePropagator), 1.0)*100.;         // tk_radius
    96    tk_length_ = confReader->GetDouble(Form("%s::HalfLength",ParticlePropagator), 3.0)*100.;     // tk_length
    97    tk_Bz_     = confReader->GetDouble("ParticlePropagator::Bz", 0.0);                           // tk_Bz
    98    
    99    TString buffer;
    100    const char *it;
    101  
    102    
    103    {
    104    TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",TrackingEfficiency),"abs(eta)<3.0");
    105    tkEffFormula.ReplaceAll("pt","x");
    106    tkEffFormula.ReplaceAll("eta","y");
    107    tkEffFormula.ReplaceAll("phi","0.");
    108  
    109    buffer.Clear();
    110    for(it = tkEffFormula.Data(); *it; ++it)
    111    {
    112      if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
    113      buffer.Append(*it);
    114    }
    115 
    116    TF2* tkEffFunction = new TF2("tkEff",buffer,0,1000,-10,10);
    117    TH1F etaHisto("eta","eta",100,5.,-5.);
    118    Double_t pt,eta;
    119    for(int i=0;i<1000;++i) {
    120      tkEffFunction->GetRandom2(pt,eta);
    121      etaHisto.Fill(eta);
    122    }
    123    Int_t bin = -1;
    124    bin = etaHisto.FindFirstBinAbove(0.5);
    125    Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
    126    bin = etaHisto.FindLastBinAbove(0.5);
    127    Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
    128    tk_etamax_ = TMath::Max(fabs(etamin),fabs(etamax));                                          // tk_etamax
    129    delete tkEffFunction;
    130    }
    131 
    132    {
    133    muondets_.push_back("muons");
    134    TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula",MuonEfficiency),"abs(eta)<2.0");
    135    muonEffFormula.ReplaceAll("pt","x");
    136    muonEffFormula.ReplaceAll("eta","y");
    137    muonEffFormula.ReplaceAll("phi","0.");
    138    
    139    buffer.Clear();
    140    for(it = muonEffFormula.Data(); *it; ++it)
    141    {
    142      if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
    143      buffer.Append(*it);
    144    }
    145 
    146    TF2* muEffFunction = new TF2("muEff",buffer,0,1000,-10,10);
    147    TH1F etaHisto("eta2","eta2",100,5.,-5.);
    148    Double_t pt,eta;
    149    for(int i=0;i<1000;++i) {
    150      muEffFunction->GetRandom2(pt,eta);
    151      etaHisto.Fill(eta);
    152    }
    153    Int_t bin = -1;
    154    bin = etaHisto.FindFirstBinAbove(0.5);
    155    Double_t etamin = (bin>-1) ? etaHisto.GetBinLowEdge(bin) : -10.;
    156    bin = etaHisto.FindLastBinAbove(0.5);
    157    Double_t etamax = (bin>-1) ? etaHisto.GetBinLowEdge(bin+1) : -10.;
    158    muonSystem_etamax_["muons"] = TMath::Max(fabs(etamin),fabs(etamax));                 // muonSystem_etamax
    159    delete muEffFunction;
    160    }
    161 
    162    std::string s(Calorimeters);
    163    std::replace( s.begin(), s.end(), ',', ' ' );
    164    std::istringstream stream( s );
    165    std::string word;
    166    while (stream >> word) calorimeters_.push_back(word);
    167 
    168    caloBinning_.clear();                                                                // calo binning
    169    for(std::vector<std::string>::const_iterator calo=calorimeters_.begin();calo!=calorimeters_.end(); ++calo) {
    170      set< pair<Double_t, Int_t> > caloBinning;
    171      ExRootConfParam paramEtaBins, paramPhiBins;
    172      ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",calo->c_str()));
    173      Int_t size = param.GetSize();
    174      for(int i = 0; i < size/2; ++i) {
    175        paramEtaBins = param[i*2];
    176        paramPhiBins = param[i*2+1];
    177        assert(paramEtaBins.GetSize()==1);
    178        caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(),paramPhiBins.GetSize()-1));
    179      }
    180      caloBinning_[*calo] = caloBinning;
    181    }
    182 
    183    set< pair<Double_t, Int_t> > caloBinning = caloBinning_[*calorimeters_.begin()];
    184    Double_t *etaBins = new Double_t[caloBinning.size()]; // note that this is the eta binning of the first calo
    185    unsigned int ii = 0;
    186    for(set< pair<Double_t, Int_t> >::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet) {
    187      etaBins[ii++] = itEtaSet->first;
    188    }
    189    etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins);
    190    phiAxis_ = new TAxis(72, -TMath::Pi(), TMath::Pi()); // note that this is fixed while #phibins could vary, also with eta, which doesn't seem possible in ROOT
    191 
    192    muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_+calo_barrel_thickness_)*calorimeters_.size() + muonSystem_thickn_;
    193    muonSystem_length_ = tk_length_ + contingency_ + (contingency_+calo_endcap_thickness_)*calorimeters_.size() + muonSystem_thickn_;
    194 
    195    delete confReader;
    196 
    197 }
    198 
    199 TGeoVolume* Delphes3DGeometry::getDetector(bool withTowers) {
    200    // compute the envelope
    201    Double_t system_radius = tk_radius_+calo_barrel_thickness_+3*contingency_;
    202    Double_t system_length = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size()+contingency_;
    203    // the detector volume
    204    TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, system_radius, system_radius, system_length);
    205    // build the detector
    206    std::pair<Double_t, Double_t> limits = addTracker(top);
    207    Double_t radius = limits.first;
    208    Double_t length = limits.second;
    209    for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo) {
    210      limits = addCalorimeter(top,calo->c_str(),radius,length,caloBinning_[*calo]);
    211      if (withTowers) {
    212        addCaloTowers(top,calo->c_str(),radius,length,caloBinning_[*calo]);
    213      }
    214      radius = limits.first;
    215      length = limits.second;
    216    }
    217    for(std::vector<std::string>::const_iterator muon = muondets_.begin(); muon != muondets_.end(); ++muon) {
    218      limits = addMuonDets(top, muon->c_str(), radius, length);
    219      radius = limits.first;
    220      length = limits.second;
    221    }
    222    // return the result
    223    return top;
    224 }
    225 
    226 std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top) {
    227    // tracker: a cylinder with two cones substracted
    228    new TGeoCone("forwardTkAcceptance",(tk_length_/2.+0.05),0.,tk_radius_,(tk_length_)*2.*exp(-tk_etamax_)/(1-exp(-2.*tk_etamax_)),tk_radius_);
    229    TGeoTranslation *tr1  = new TGeoTranslation("tkacc1",0., 0., tk_length_/2.);
    230    tr1->RegisterYourself();
    231    TGeoRotation *negz    = new TGeoRotation("tknegz",0,180,0);
    232    negz->RegisterYourself();
    233    TGeoCombiTrans  *tr2  = new TGeoCombiTrans("tkacc2",0.,0.,-tk_length_/2.,negz);
    234    tr2->RegisterYourself();
    235    TGeoCompositeShape* tracker_cs = new TGeoCompositeShape("tracker_cs","forwardTkAcceptance:tkacc1+forwardTkAcceptance:tkacc2");
    236    TGeoVolume *tracker = new TGeoVolume("tracker",tracker_cs,tkmed_);   
    237    tracker->SetLineColor(kYellow);
    238    top->AddNode(tracker,1);
    239    return std::make_pair(tk_radius_,tk_length_);
    240 }
    241 
    242 std::pair<Double_t, Double_t> Delphes3DGeometry::addCalorimeter(TGeoVolume *top, const char* name,
    243                                                                 Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) {
    244    // parameters derived from the inputs
    245    Double_t calo_endcap_etamax        = TMath::Max(fabs(caloBinning.begin()->first),fabs(caloBinning.rbegin()->first));
    246    Double_t calo_barrel_innerRadius   = innerBarrelRadius+contingency_;
    247    Double_t calo_barrel_length        = innerBarrelLength + calo_barrel_thickness_;
    248    Double_t calo_endcap_etamin        = -log(innerBarrelRadius/(2*innerBarrelLength));
    249    Double_t calo_endcap_innerRadius1  = innerBarrelLength*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax));
    250    Double_t calo_endcap_innerRadius2  = (innerBarrelLength+calo_endcap_thickness_)*2.*exp(-calo_endcap_etamax)/(1-exp(-2.*calo_endcap_etamax));
    251    Double_t calo_endcap_outerRadius1  = innerBarrelRadius;
    252    Double_t calo_endcap_outerRadius2  = innerBarrelRadius+calo_barrel_thickness_;
    253    Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_);
    254    Double_t calo_endcap_diskThickness = TMath::Max(0.,calo_endcap_thickness_-calo_endcap_coneThickness);
    255 
    256    // calorimeters: tube truncated in eta + cones
    257    new TGeoTube(Form("%s_barrel_cylinder",name),calo_barrel_innerRadius,calo_barrel_innerRadius+calo_barrel_thickness_,calo_barrel_length);
    258    new TGeoCone(Form("%s_endcap_cone",name),calo_endcap_coneThickness/2.,calo_endcap_innerRadius1,calo_endcap_outerRadius1,calo_endcap_innerRadius2,calo_endcap_outerRadius2);
    259    new TGeoTube(Form("%s_endcap_disk",name),calo_endcap_innerRadius2,tk_radius_+calo_barrel_thickness_,calo_endcap_diskThickness/2.);
    260    TGeoTranslation *tr1 = new TGeoTranslation(Form("%s_tr1",name),0., 0., (calo_endcap_coneThickness+calo_endcap_diskThickness)/2.);
    261    tr1->RegisterYourself();
    262    TGeoCompositeShape *calo_endcap_cs = new TGeoCompositeShape(Form("%s_endcap_cs",name),Form("%s_endcap_cone+%s_endcap_disk:%s_tr1",name,name,name));
    263    TGeoTranslation *trc1 = new TGeoTranslation(Form("%s_endcap1_position",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.);
    264    trc1->RegisterYourself();
    265    TGeoRotation *negz = new TGeoRotation(Form("%s_negz",name),0,180,0);
    266    TGeoCombiTrans  *trc2 = new TGeoCombiTrans(Form("%s_endcap2_position",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.),negz);
    267    trc2->RegisterYourself();
    268    TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont",name),0.,0., innerBarrelLength+calo_endcap_coneThickness/2.+contingency_);
    269    trc1c->RegisterYourself();
    270    TGeoCombiTrans  *trc2c = new TGeoCombiTrans(Form("%s_endcap2_position_cont",name),0.,0.,-(innerBarrelLength+calo_endcap_coneThickness/2.)-contingency_,negz);
    271    trc2c->RegisterYourself();
    272    TGeoVolume *calo_endcap = new TGeoVolume(Form("%s_endcap",name),calo_endcap_cs,calomed_);
    273    TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape(Form("%s_barrel_cs",name),
    274                                                                Form("%s_barrel_cylinder-%s_endcap_cs:%s_endcap1_position-%s_endcap_cs:%s_endcap2_position",name,name,name,name,name));
    275    TGeoVolume *calo_barrel = new TGeoVolume(Form("%s_barrel",name),calo_barrel_cs,calomed_);
    276    calo_endcap->SetLineColor(kViolet);
    277    calo_endcap->SetFillColor(kViolet);
    278    calo_barrel->SetLineColor(kRed);
    279    top->AddNode(calo_endcap,1,trc1c);
    280    top->AddNode(calo_endcap,2,trc2c);
    281    top->AddNode(calo_barrel,1);
    282    return std::make_pair(calo_barrel_innerRadius+calo_barrel_thickness_,innerBarrelLength+calo_endcap_thickness_+contingency_);
    283 }
    284 
    285 std::pair<Double_t, Double_t> Delphes3DGeometry::addMuonDets(TGeoVolume *top, const char* name, Double_t innerBarrelRadius, Double_t innerBarrelLength) {
    286    // muon system: tube + disks
    287    Double_t muonSystem_radius = innerBarrelRadius + contingency_;
    288    Double_t muonSystem_length = innerBarrelLength + contingency_;
    289    Double_t muonSystem_rmin   = muonSystem_length*2.*exp(-muonSystem_etamax_[name])/(1-exp(-2.*muonSystem_etamax_[name]));
    290    TGeoVolume *muon_barrel = geom_->MakeTube(Form("%s_barrel",name),mudetmed_,muonSystem_radius,muonSystem_radius+muonSystem_thickn_,muonSystem_length);
    291    muon_barrel->SetLineColor(kBlue);
    292    top->AddNode(muon_barrel,1);
    293    TGeoVolume *muon_endcap = geom_->MakeTube(Form("%s_endcap",name),mudetmed_,muonSystem_rmin,muonSystem_radius+muonSystem_thickn_,muonSystem_thickn_/2.);
    294    muon_endcap->SetLineColor(kBlue);
    295    TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position",name),0.,0.,muonSystem_length);
    296    trm1->RegisterYourself();
    297    TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position",name),0.,0.,-muonSystem_length);
    298    trm1->RegisterYourself();
    299    top->AddNode(muon_endcap,1,trm1);
    300    top->AddNode(muon_endcap,2,trm2);
    301    return std::make_pair(muonSystem_radius,muonSystem_length);
    302 }
    303 
    304 void Delphes3DGeometry::addCaloTowers(TGeoVolume *top, const char* name,
    305                                                        Double_t innerBarrelRadius, Double_t innerBarrelLength, set< pair<Double_t, Int_t> >& caloBinning) {
    306 
    307    TGeoVolume* calo_endcap = top->GetNode(Form("%s_endcap_1",name))->GetVolume();
    308    TGeoVolume* calo_barrel = top->GetNode(Form("%s_barrel_1",name))->GetVolume();
    309    Double_t calo_endcap_etamin = -log(innerBarrelRadius/(2*innerBarrelLength));
    310    Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1-exp(-2.*calo_endcap_etamin)) / (2.*exp(-calo_endcap_etamin)), calo_endcap_thickness_);
    311 
    312    // calo towers in the barrel
    313    Double_t vertices[16] = {0.,0.,0.,0.,0.,0.,0.,0.}; // summit of the pyramid
    314    Double_t R  = tk_radius_ + contingency_+(contingency_+calo_barrel_thickness_)*calorimeters_.size(); // radius of the muons system = height of the pyramid
    315    Int_t nEtaBins = caloBinning.size();
    316    // this rotation is to make the tower point "up"
    317    TGeoRotation* initTowerRot = new TGeoRotation(Form("%s_initTowerRot",name),0.,90.,0.);
    318    TGeoCombiTrans* initTower  = new TGeoCombiTrans(Form("%s_initTower",name),0.,-R/2.,0.,initTowerRot);
    319    initTower->RegisterYourself();
    320    // eta bins... we build one pyramid per eta slice and then translate it nphi times.
    321    // phi bins represented by rotations around z
    322    Double_t *y = new Double_t[nEtaBins];
    323    Double_t *dx = new Double_t[nEtaBins];
    324    Int_t *nphi = new Int_t[nEtaBins];
    325    Int_t etaslice = 0;
    326    std::map<std::pair<int,int>, TGeoRotation*> phirotations;
    327    for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) {
    328      if(abs(bin->first)>calo_endcap_etamin) continue; // only in the barrel
    329      nphi[etaslice] = bin->second;
    330      y[etaslice] = 0.5*R*(1-exp(-2*bin->first))/exp(-bin->first);
    331      Double_t phiRotationAngle = 360./nphi[etaslice];
    332      dx[etaslice] = R*tan(TMath::Pi()*phiRotationAngle/360.);
    333      for(int phislice=0;phislice<nphi[etaslice];++phislice) {
    334        phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.);
    335        phirotations[make_pair(etaslice,phislice)]->RegisterYourself();
    336      }
    337      ++etaslice;
    338    }
    339    nEtaBins = etaslice;
    340    for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices
    341      vertices[8]  = -dx[i]; vertices[9]  = y[i];
    342      vertices[10] = -dx[i]; vertices[11] = y[i+1];
    343      vertices[12] =  dx[i]; vertices[13] = y[i+1];
    344      vertices[14] =  dx[i]; vertices[15] = y[i];
    345      new TGeoArb8(Form("%s_tower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0
    346      // intersection between the tower and the calo_barrel
    347      TGeoCompositeShape *finaltower_cs = new TGeoCompositeShape(Form("%s_ftower%d_cs",name,i),Form("%s_tower%d:%s_initTower*%s_barrel_cs",name,i,name,name));
    348      TGeoVolume *finaltower = new TGeoVolume(Form("%s_ftower%d",name,i),finaltower_cs,calomed_);
    349      finaltower->SetLineColor(kRed);
    350      for(int j=0;j<nphi[i];++j) { // loop on the phi slices
    351        calo_barrel->AddNode(finaltower,j,phirotations[make_pair(i,j)]);
    352      }
    353    }
    354    delete[] y;
    355    delete[] dx;
    356    delete[] nphi;
    357    //the towers in the forward region
    358    R  = tk_length_+contingency_+(contingency_+calo_endcap_thickness_)*calorimeters_.size(); // Z of the muons system = height of the pyramid
    359    nEtaBins = caloBinning.size();
    360    // translation to bring the origin of the tower to (0,0,0) (well, not really as the endcap is not yet in place)
    361    TGeoTranslation* towerdz = new TGeoTranslation(Form("%s_towerdz",name),0.,0.,R/2.-(innerBarrelLength+calo_endcap_coneThickness/2.));
    362    towerdz->RegisterYourself();
    363    // eta bins... we build one pyramid per eta slice and then translate it nphi times.
    364    Double_t *r = new Double_t[nEtaBins];
    365    nphi = new Int_t[nEtaBins];
    366    etaslice = 0;
    367    phirotations.clear();
    368    for(set< pair<Double_t, Int_t> >::const_iterator bin=caloBinning.begin(); bin!=caloBinning.end();++bin) {
    369      if(bin->first<calo_endcap_etamin) continue; // only in the + endcap
    370      r[etaslice] = R*2*exp(-bin->first)/(1-exp(-2*bin->first));
    371      nphi[etaslice] = bin->second;
    372      Double_t phiRotationAngle = 360./nphi[etaslice];
    373      for(int phislice=0;phislice<nphi[etaslice];++phislice) {
    374        phirotations[make_pair(etaslice,phislice)] = new TGeoRotation(Form("%s_forward_phi%d_%d",name,etaslice,phislice),phiRotationAngle*phislice,0.,0.);
    375        phirotations[make_pair(etaslice,phislice)]->RegisterYourself();
    376      }
    377      ++etaslice;
    378    }
    379    nEtaBins = etaslice;
    380    for(int i=0;i<nEtaBins-1;++i) { // loop on the eta slices
    381      vertices[8]  = -r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[9]  = r[i+1]*cos(TMath::Pi()/nphi[i]);
    382      vertices[10] = -r[i]*sin(TMath::Pi()/nphi[i]);   vertices[11] = r[i]*cos(TMath::Pi()/nphi[i]);
    383      vertices[12] =  r[i]*sin(TMath::Pi()/nphi[i]);   vertices[13] = r[i]*cos(TMath::Pi()/nphi[i]);
    384      vertices[14] =  r[i+1]*sin(TMath::Pi()/nphi[i]); vertices[15] = r[i+1]*cos(TMath::Pi()/nphi[i]);
    385      new TGeoArb8(Form("%sfwdtower%d",name,i),R/2., vertices); // tower in the proper eta slice, at phi=0
    386      // intersection between the tower and the calo_endcap
    387      TGeoCompositeShape *finalfwdtower_cs = new TGeoCompositeShape(Form("%sffwdtower%d_cs",name,i),Form("%sfwdtower%d:%s_towerdz*%s_endcap_cs",name,i,name,name));
    388      TGeoVolume *finalfwdtower = new TGeoVolume(Form("%sffwdtower%d",name,i),finalfwdtower_cs,calomed_);
    389      finalfwdtower->SetLineColor(kViolet);
    390      for(int j=0;j<nphi[i];++j) { // loop on the phi slices
    391        calo_endcap->AddNode(finalfwdtower,j,phirotations[make_pair(i,j)]);
    392      }
    393    }
    394    delete[] r;
    395    delete[] nphi;
    396 }
    397 
     91  const char *ParticlePropagator, const char *TrackingEfficiency,
     92  const char *MuonEfficiency, const char *Calorimeters)
     93{
     94
     95  ExRootConfReader *confReader = new ExRootConfReader;
     96  confReader->ReadFile(configFile);
     97
     98  tk_radius_ = confReader->GetDouble(Form("%s::Radius", ParticlePropagator), 1.0) * 100.; // tk_radius
     99  tk_length_ = confReader->GetDouble(Form("%s::HalfLength", ParticlePropagator), 3.0) * 100.; // tk_length
     100  tk_Bz_ = confReader->GetDouble("ParticlePropagator::Bz", 0.0); // tk_Bz
     101
     102  TString buffer;
     103  const char *it;
     104
     105  {
     106    TString tkEffFormula = confReader->GetString(Form("%s::EfficiencyFormula", TrackingEfficiency), "abs(eta)<3.0");
     107    tkEffFormula.ReplaceAll("pt", "x");
     108    tkEffFormula.ReplaceAll("eta", "y");
     109    tkEffFormula.ReplaceAll("phi", "0.");
     110
     111    buffer.Clear();
     112    for(it = tkEffFormula.Data(); *it; ++it)
     113    {
     114      if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
     115      buffer.Append(*it);
     116    }
     117
     118    TF2 *tkEffFunction = new TF2("tkEff", buffer, 0, 1000, -10, 10);
     119    TH1F etaHisto("eta", "eta", 100, 5., -5.);
     120    Double_t pt, eta;
     121    for(int i = 0; i < 1000; ++i)
     122    {
     123      tkEffFunction->GetRandom2(pt, eta);
     124      etaHisto.Fill(eta);
     125    }
     126    Int_t bin = -1;
     127    bin = etaHisto.FindFirstBinAbove(0.5);
     128    Double_t etamin = (bin > -1) ? etaHisto.GetBinLowEdge(bin) : -10.;
     129    bin = etaHisto.FindLastBinAbove(0.5);
     130    Double_t etamax = (bin > -1) ? etaHisto.GetBinLowEdge(bin + 1) : -10.;
     131    tk_etamax_ = TMath::Max(fabs(etamin), fabs(etamax)); // tk_etamax
     132    delete tkEffFunction;
     133  }
     134
     135  {
     136    muondets_.push_back("muons");
     137    TString muonEffFormula = confReader->GetString(Form("%s::EfficiencyFormula", MuonEfficiency), "abs(eta)<2.0");
     138    muonEffFormula.ReplaceAll("pt", "x");
     139    muonEffFormula.ReplaceAll("eta", "y");
     140    muonEffFormula.ReplaceAll("phi", "0.");
     141
     142    buffer.Clear();
     143    for(it = muonEffFormula.Data(); *it; ++it)
     144    {
     145      if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
     146      buffer.Append(*it);
     147    }
     148
     149    TF2 *muEffFunction = new TF2("muEff", buffer, 0, 1000, -10, 10);
     150    TH1F etaHisto("eta2", "eta2", 100, 5., -5.);
     151    Double_t pt, eta;
     152    for(int i = 0; i < 1000; ++i)
     153    {
     154      muEffFunction->GetRandom2(pt, eta);
     155      etaHisto.Fill(eta);
     156    }
     157    Int_t bin = -1;
     158    bin = etaHisto.FindFirstBinAbove(0.5);
     159    Double_t etamin = (bin > -1) ? etaHisto.GetBinLowEdge(bin) : -10.;
     160    bin = etaHisto.FindLastBinAbove(0.5);
     161    Double_t etamax = (bin > -1) ? etaHisto.GetBinLowEdge(bin + 1) : -10.;
     162    muonSystem_etamax_["muons"] = TMath::Max(fabs(etamin), fabs(etamax)); // muonSystem_etamax
     163    delete muEffFunction;
     164  }
     165
     166  std::string s(Calorimeters);
     167  std::replace(s.begin(), s.end(), ',', ' ');
     168  std::istringstream stream(s);
     169  std::string word;
     170  while(stream >> word) calorimeters_.push_back(word);
     171
     172  caloBinning_.clear(); // calo binning
     173  for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo)
     174  {
     175    set<pair<Double_t, Int_t> > caloBinning;
     176    ExRootConfParam paramEtaBins, paramPhiBins;
     177    ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins", calo->c_str()));
     178    Int_t size = param.GetSize();
     179    for(int i = 0; i < size / 2; ++i)
     180    {
     181      paramEtaBins = param[i * 2];
     182      paramPhiBins = param[i * 2 + 1];
     183      assert(paramEtaBins.GetSize() == 1);
     184      caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(), paramPhiBins.GetSize() - 1));
     185    }
     186    caloBinning_[*calo] = caloBinning;
     187  }
     188
     189  set<pair<Double_t, Int_t> > caloBinning = caloBinning_[*calorimeters_.begin()];
     190  Double_t *etaBins = new Double_t[caloBinning.size()]; // note that this is the eta binning of the first calo
     191  unsigned int ii = 0;
     192  for(set<pair<Double_t, Int_t> >::const_iterator itEtaSet = caloBinning.begin(); itEtaSet != caloBinning.end(); ++itEtaSet)
     193  {
     194    etaBins[ii++] = itEtaSet->first;
     195  }
     196  etaAxis_ = new TAxis(caloBinning.size() - 1, etaBins);
     197  phiAxis_ = new TAxis(72, -TMath::Pi(), TMath::Pi()); // note that this is fixed while #phibins could vary, also with eta, which doesn't seem possible in ROOT
     198
     199  muonSystem_radius_ = tk_radius_ + contingency_ + (contingency_ + calo_barrel_thickness_) * calorimeters_.size() + muonSystem_thickn_;
     200  muonSystem_length_ = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size() + muonSystem_thickn_;
     201
     202  delete confReader;
     203}
     204
     205TGeoVolume *Delphes3DGeometry::getDetector(bool withTowers)
     206{
     207  // compute the envelope
     208  Double_t system_radius = tk_radius_ + calo_barrel_thickness_ + 3 * contingency_;
     209  Double_t system_length = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size() + contingency_;
     210  // the detector volume
     211  TGeoVolume *top = geom_->MakeBox("Delphes3DGeometry", vacuum_, system_radius, system_radius, system_length);
     212  // build the detector
     213  std::pair<Double_t, Double_t> limits = addTracker(top);
     214  Double_t radius = limits.first;
     215  Double_t length = limits.second;
     216  for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo)
     217  {
     218    limits = addCalorimeter(top, calo->c_str(), radius, length, caloBinning_[*calo]);
     219    if(withTowers)
     220    {
     221      addCaloTowers(top, calo->c_str(), radius, length, caloBinning_[*calo]);
     222    }
     223    radius = limits.first;
     224    length = limits.second;
     225  }
     226  for(std::vector<std::string>::const_iterator muon = muondets_.begin(); muon != muondets_.end(); ++muon)
     227  {
     228    limits = addMuonDets(top, muon->c_str(), radius, length);
     229    radius = limits.first;
     230    length = limits.second;
     231  }
     232  // return the result
     233  return top;
     234}
     235
     236std::pair<Double_t, Double_t> Delphes3DGeometry::addTracker(TGeoVolume *top)
     237{
     238  // tracker: a cylinder with two cones substracted
     239  new TGeoCone("forwardTkAcceptance", (tk_length_ / 2. + 0.05), 0., tk_radius_, (tk_length_)*2. * exp(-tk_etamax_) / (1 - exp(-2. * tk_etamax_)), tk_radius_);
     240  TGeoTranslation *tr1 = new TGeoTranslation("tkacc1", 0., 0., tk_length_ / 2.);
     241  tr1->RegisterYourself();
     242  TGeoRotation *negz = new TGeoRotation("tknegz", 0, 180, 0);
     243  negz->RegisterYourself();
     244  TGeoCombiTrans *tr2 = new TGeoCombiTrans("tkacc2", 0., 0., -tk_length_ / 2., negz);
     245  tr2->RegisterYourself();
     246  TGeoCompositeShape *tracker_cs = new TGeoCompositeShape("tracker_cs", "forwardTkAcceptance:tkacc1+forwardTkAcceptance:tkacc2");
     247  TGeoVolume *tracker = new TGeoVolume("tracker", tracker_cs, tkmed_);
     248  tracker->SetLineColor(kYellow);
     249  top->AddNode(tracker, 1);
     250  return std::make_pair(tk_radius_, tk_length_);
     251}
     252
     253std::pair<Double_t, Double_t> Delphes3DGeometry::addCalorimeter(TGeoVolume *top, const char *name,
     254  Double_t innerBarrelRadius, Double_t innerBarrelLength, set<pair<Double_t, Int_t> > &caloBinning)
     255{
     256  // parameters derived from the inputs
     257  Double_t calo_endcap_etamax = TMath::Max(fabs(caloBinning.begin()->first), fabs(caloBinning.rbegin()->first));
     258  Double_t calo_barrel_innerRadius = innerBarrelRadius + contingency_;
     259  Double_t calo_barrel_length = innerBarrelLength + calo_barrel_thickness_;
     260  Double_t calo_endcap_etamin = -log(innerBarrelRadius / (2 * innerBarrelLength));
     261  Double_t calo_endcap_innerRadius1 = innerBarrelLength * 2. * exp(-calo_endcap_etamax) / (1 - exp(-2. * calo_endcap_etamax));
     262  Double_t calo_endcap_innerRadius2 = (innerBarrelLength + calo_endcap_thickness_) * 2. * exp(-calo_endcap_etamax) / (1 - exp(-2. * calo_endcap_etamax));
     263  Double_t calo_endcap_outerRadius1 = innerBarrelRadius;
     264  Double_t calo_endcap_outerRadius2 = innerBarrelRadius + calo_barrel_thickness_;
     265  Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1 - exp(-2. * calo_endcap_etamin)) / (2. * exp(-calo_endcap_etamin)), calo_endcap_thickness_);
     266  Double_t calo_endcap_diskThickness = TMath::Max(0., calo_endcap_thickness_ - calo_endcap_coneThickness);
     267
     268  // calorimeters: tube truncated in eta + cones
     269  new TGeoTube(Form("%s_barrel_cylinder", name), calo_barrel_innerRadius, calo_barrel_innerRadius + calo_barrel_thickness_, calo_barrel_length);
     270  new TGeoCone(Form("%s_endcap_cone", name), calo_endcap_coneThickness / 2., calo_endcap_innerRadius1, calo_endcap_outerRadius1, calo_endcap_innerRadius2, calo_endcap_outerRadius2);
     271  new TGeoTube(Form("%s_endcap_disk", name), calo_endcap_innerRadius2, tk_radius_ + calo_barrel_thickness_, calo_endcap_diskThickness / 2.);
     272  TGeoTranslation *tr1 = new TGeoTranslation(Form("%s_tr1", name), 0., 0., (calo_endcap_coneThickness + calo_endcap_diskThickness) / 2.);
     273  tr1->RegisterYourself();
     274  TGeoCompositeShape *calo_endcap_cs = new TGeoCompositeShape(Form("%s_endcap_cs", name), Form("%s_endcap_cone+%s_endcap_disk:%s_tr1", name, name, name));
     275  TGeoTranslation *trc1 = new TGeoTranslation(Form("%s_endcap1_position", name), 0., 0., innerBarrelLength + calo_endcap_coneThickness / 2.);
     276  trc1->RegisterYourself();
     277  TGeoRotation *negz = new TGeoRotation(Form("%s_negz", name), 0, 180, 0);
     278  TGeoCombiTrans *trc2 = new TGeoCombiTrans(Form("%s_endcap2_position", name), 0., 0., -(innerBarrelLength + calo_endcap_coneThickness / 2.), negz);
     279  trc2->RegisterYourself();
     280  TGeoTranslation *trc1c = new TGeoTranslation(Form("%s_endcap1_position_cont", name), 0., 0., innerBarrelLength + calo_endcap_coneThickness / 2. + contingency_);
     281  trc1c->RegisterYourself();
     282  TGeoCombiTrans *trc2c = new TGeoCombiTrans(Form("%s_endcap2_position_cont", name), 0., 0., -(innerBarrelLength + calo_endcap_coneThickness / 2.) - contingency_, negz);
     283  trc2c->RegisterYourself();
     284  TGeoVolume *calo_endcap = new TGeoVolume(Form("%s_endcap", name), calo_endcap_cs, calomed_);
     285  TGeoCompositeShape *calo_barrel_cs = new TGeoCompositeShape(Form("%s_barrel_cs", name),
     286    Form("%s_barrel_cylinder-%s_endcap_cs:%s_endcap1_position-%s_endcap_cs:%s_endcap2_position", name, name, name, name, name));
     287  TGeoVolume *calo_barrel = new TGeoVolume(Form("%s_barrel", name), calo_barrel_cs, calomed_);
     288  calo_endcap->SetLineColor(kViolet);
     289  calo_endcap->SetFillColor(kViolet);
     290  calo_barrel->SetLineColor(kRed);
     291  top->AddNode(calo_endcap, 1, trc1c);
     292  top->AddNode(calo_endcap, 2, trc2c);
     293  top->AddNode(calo_barrel, 1);
     294  return std::make_pair(calo_barrel_innerRadius + calo_barrel_thickness_, innerBarrelLength + calo_endcap_thickness_ + contingency_);
     295}
     296
     297std::pair<Double_t, Double_t> Delphes3DGeometry::addMuonDets(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength)
     298{
     299  // muon system: tube + disks
     300  Double_t muonSystem_radius = innerBarrelRadius + contingency_;
     301  Double_t muonSystem_length = innerBarrelLength + contingency_;
     302  Double_t muonSystem_rmin = muonSystem_length * 2. * exp(-muonSystem_etamax_[name]) / (1 - exp(-2. * muonSystem_etamax_[name]));
     303  TGeoVolume *muon_barrel = geom_->MakeTube(Form("%s_barrel", name), mudetmed_, muonSystem_radius, muonSystem_radius + muonSystem_thickn_, muonSystem_length);
     304  muon_barrel->SetLineColor(kBlue);
     305  top->AddNode(muon_barrel, 1);
     306  TGeoVolume *muon_endcap = geom_->MakeTube(Form("%s_endcap", name), mudetmed_, muonSystem_rmin, muonSystem_radius + muonSystem_thickn_, muonSystem_thickn_ / 2.);
     307  muon_endcap->SetLineColor(kBlue);
     308  TGeoTranslation *trm1 = new TGeoTranslation(Form("%sEndcap1_position", name), 0., 0., muonSystem_length);
     309  trm1->RegisterYourself();
     310  TGeoTranslation *trm2 = new TGeoTranslation(Form("%sEndcap2_position", name), 0., 0., -muonSystem_length);
     311  trm1->RegisterYourself();
     312  top->AddNode(muon_endcap, 1, trm1);
     313  top->AddNode(muon_endcap, 2, trm2);
     314  return std::make_pair(muonSystem_radius, muonSystem_length);
     315}
     316
     317void Delphes3DGeometry::addCaloTowers(TGeoVolume *top, const char *name,
     318  Double_t innerBarrelRadius, Double_t innerBarrelLength, set<pair<Double_t, Int_t> > &caloBinning)
     319{
     320
     321  TGeoVolume *calo_endcap = top->GetNode(Form("%s_endcap_1", name))->GetVolume();
     322  TGeoVolume *calo_barrel = top->GetNode(Form("%s_barrel_1", name))->GetVolume();
     323  Double_t calo_endcap_etamin = -log(innerBarrelRadius / (2 * innerBarrelLength));
     324  Double_t calo_endcap_coneThickness = TMath::Min(calo_barrel_thickness_ * (1 - exp(-2. * calo_endcap_etamin)) / (2. * exp(-calo_endcap_etamin)), calo_endcap_thickness_);
     325
     326  // calo towers in the barrel
     327  Double_t vertices[16] = {0., 0., 0., 0., 0., 0., 0., 0.}; // summit of the pyramid
     328  Double_t R = tk_radius_ + contingency_ + (contingency_ + calo_barrel_thickness_) * calorimeters_.size(); // radius of the muons system = height of the pyramid
     329  Int_t nEtaBins = caloBinning.size();
     330  // this rotation is to make the tower point "up"
     331  TGeoRotation *initTowerRot = new TGeoRotation(Form("%s_initTowerRot", name), 0., 90., 0.);
     332  TGeoCombiTrans *initTower = new TGeoCombiTrans(Form("%s_initTower", name), 0., -R / 2., 0., initTowerRot);
     333  initTower->RegisterYourself();
     334  // eta bins... we build one pyramid per eta slice and then translate it nphi times.
     335  // phi bins represented by rotations around z
     336  Double_t *y = new Double_t[nEtaBins];
     337  Double_t *dx = new Double_t[nEtaBins];
     338  Int_t *nphi = new Int_t[nEtaBins];
     339  Int_t etaslice = 0;
     340  std::map<std::pair<int, int>, TGeoRotation *> phirotations;
     341  for(set<pair<Double_t, Int_t> >::const_iterator bin = caloBinning.begin(); bin != caloBinning.end(); ++bin)
     342  {
     343    if(abs(bin->first) > calo_endcap_etamin) continue; // only in the barrel
     344    nphi[etaslice] = bin->second;
     345    y[etaslice] = 0.5 * R * (1 - exp(-2 * bin->first)) / exp(-bin->first);
     346    Double_t phiRotationAngle = 360. / nphi[etaslice];
     347    dx[etaslice] = R * tan(TMath::Pi() * phiRotationAngle / 360.);
     348    for(int phislice = 0; phislice < nphi[etaslice]; ++phislice)
     349    {
     350      phirotations[make_pair(etaslice, phislice)] = new TGeoRotation(Form("%s_phi%d_%d", name, etaslice, phislice), phiRotationAngle * phislice, 0., 0.);
     351      phirotations[make_pair(etaslice, phislice)]->RegisterYourself();
     352    }
     353    ++etaslice;
     354  }
     355  nEtaBins = etaslice;
     356  for(int i = 0; i < nEtaBins - 1; ++i)
     357  { // loop on the eta slices
     358    vertices[8] = -dx[i];
     359    vertices[9] = y[i];
     360    vertices[10] = -dx[i];
     361    vertices[11] = y[i + 1];
     362    vertices[12] = dx[i];
     363    vertices[13] = y[i + 1];
     364    vertices[14] = dx[i];
     365    vertices[15] = y[i];
     366    new TGeoArb8(Form("%s_tower%d", name, i), R / 2., vertices); // tower in the proper eta slice, at phi=0
     367    // intersection between the tower and the calo_barrel
     368    TGeoCompositeShape *finaltower_cs = new TGeoCompositeShape(Form("%s_ftower%d_cs", name, i), Form("%s_tower%d:%s_initTower*%s_barrel_cs", name, i, name, name));
     369    TGeoVolume *finaltower = new TGeoVolume(Form("%s_ftower%d", name, i), finaltower_cs, calomed_);
     370    finaltower->SetLineColor(kRed);
     371    for(int j = 0; j < nphi[i]; ++j)
     372    { // loop on the phi slices
     373      calo_barrel->AddNode(finaltower, j, phirotations[make_pair(i, j)]);
     374    }
     375  }
     376  delete[] y;
     377  delete[] dx;
     378  delete[] nphi;
     379  //the towers in the forward region
     380  R = tk_length_ + contingency_ + (contingency_ + calo_endcap_thickness_) * calorimeters_.size(); // Z of the muons system = height of the pyramid
     381  nEtaBins = caloBinning.size();
     382  // translation to bring the origin of the tower to (0,0,0) (well, not really as the endcap is not yet in place)
     383  TGeoTranslation *towerdz = new TGeoTranslation(Form("%s_towerdz", name), 0., 0., R / 2. - (innerBarrelLength + calo_endcap_coneThickness / 2.));
     384  towerdz->RegisterYourself();
     385  // eta bins... we build one pyramid per eta slice and then translate it nphi times.
     386  Double_t *r = new Double_t[nEtaBins];
     387  nphi = new Int_t[nEtaBins];
     388  etaslice = 0;
     389  phirotations.clear();
     390  for(set<pair<Double_t, Int_t> >::const_iterator bin = caloBinning.begin(); bin != caloBinning.end(); ++bin)
     391  {
     392    if(bin->first < calo_endcap_etamin) continue; // only in the + endcap
     393    r[etaslice] = R * 2 * exp(-bin->first) / (1 - exp(-2 * bin->first));
     394    nphi[etaslice] = bin->second;
     395    Double_t phiRotationAngle = 360. / nphi[etaslice];
     396    for(int phislice = 0; phislice < nphi[etaslice]; ++phislice)
     397    {
     398      phirotations[make_pair(etaslice, phislice)] = new TGeoRotation(Form("%s_forward_phi%d_%d", name, etaslice, phislice), phiRotationAngle * phislice, 0., 0.);
     399      phirotations[make_pair(etaslice, phislice)]->RegisterYourself();
     400    }
     401    ++etaslice;
     402  }
     403  nEtaBins = etaslice;
     404  for(int i = 0; i < nEtaBins - 1; ++i)
     405  { // loop on the eta slices
     406    vertices[8] = -r[i + 1] * sin(TMath::Pi() / nphi[i]);
     407    vertices[9] = r[i + 1] * cos(TMath::Pi() / nphi[i]);
     408    vertices[10] = -r[i] * sin(TMath::Pi() / nphi[i]);
     409    vertices[11] = r[i] * cos(TMath::Pi() / nphi[i]);
     410    vertices[12] = r[i] * sin(TMath::Pi() / nphi[i]);
     411    vertices[13] = r[i] * cos(TMath::Pi() / nphi[i]);
     412    vertices[14] = r[i + 1] * sin(TMath::Pi() / nphi[i]);
     413    vertices[15] = r[i + 1] * cos(TMath::Pi() / nphi[i]);
     414    new TGeoArb8(Form("%sfwdtower%d", name, i), R / 2., vertices); // tower in the proper eta slice, at phi=0
     415    // intersection between the tower and the calo_endcap
     416    TGeoCompositeShape *finalfwdtower_cs = new TGeoCompositeShape(Form("%sffwdtower%d_cs", name, i), Form("%sfwdtower%d:%s_towerdz*%s_endcap_cs", name, i, name, name));
     417    TGeoVolume *finalfwdtower = new TGeoVolume(Form("%sffwdtower%d", name, i), finalfwdtower_cs, calomed_);
     418    finalfwdtower->SetLineColor(kViolet);
     419    for(int j = 0; j < nphi[i]; ++j)
     420    { // loop on the phi slices
     421      calo_endcap->AddNode(finalfwdtower, j, phirotations[make_pair(i, j)]);
     422    }
     423  }
     424  delete[] r;
     425  delete[] nphi;
     426}
  • display/Delphes3DGeometry.h

    re39abb4 r0e7d64a  
    2020#define Delphes3DGeometry_h
    2121
     22#include <map>
    2223#include <set>
    23 #include <map>
    2424#include <vector>
    2525
     
    3333// TODO: asymmetric detector
    3434
    35 class Delphes3DGeometry {
    36    public:
    37      Delphes3DGeometry(TGeoManager *geom = NULL, bool transp = false);
    38      ~Delphes3DGeometry() {}
     35class Delphes3DGeometry
     36{
     37public:
     38  Delphes3DGeometry(TGeoManager *geom = NULL, bool transp = false);
     39  ~Delphes3DGeometry() {}
    3940
    40      void readFile(const char *filename, const char *ParticlePropagator="ParticlePropagator",
    41                                          const char *TrackingEfficiency="ChargedHadronTrackingEfficiency",
    42                                          const char *MuonEfficiency="MuonEfficiency",
    43                                          const char *Calorimeters="Calorimeter");
     41  void readFile(const char *filename, const char *ParticlePropagator = "ParticlePropagator",
     42    const char *TrackingEfficiency = "ChargedHadronTrackingEfficiency",
     43    const char *MuonEfficiency = "MuonEfficiency",
     44    const char *Calorimeters = "Calorimeter");
    4445
    45      void setContingency(Double_t contingency) { contingency_ = contingency; }
    46      void setCaloBarrelThickness(Double_t thickness) { calo_barrel_thickness_ = thickness; }
    47      void setCaloEndcapThickness(Double_t thickness) { calo_endcap_thickness_ = thickness; }
    48      void setMuonSystemThickness(Double_t thickness) { muonSystem_thickn_ = thickness; }
     46  void setContingency(Double_t contingency) { contingency_ = contingency; }
     47  void setCaloBarrelThickness(Double_t thickness) { calo_barrel_thickness_ = thickness; }
     48  void setCaloEndcapThickness(Double_t thickness) { calo_endcap_thickness_ = thickness; }
     49  void setMuonSystemThickness(Double_t thickness) { muonSystem_thickn_ = thickness; }
    4950
    50      TGeoVolume *getDetector(bool withTowers = true);
     51  TGeoVolume *getDetector(bool withTowers = true);
    5152
    52      Double_t getTrackerRadius() const { return tk_radius_; }
    53      Double_t getDetectorRadius() const { return muonSystem_radius_; }
    54      Double_t getTrackerHalfLength() const { return tk_length_; }
    55      Double_t getDetectorHalfLength() const { return muonSystem_length_; }
    56      Double_t getBField() const { return tk_Bz_; }
    57      std::pair<TAxis*, TAxis*> getCaloAxes() { return std::make_pair(etaAxis_,phiAxis_); }
     53  Double_t getTrackerRadius() const { return tk_radius_; }
     54  Double_t getDetectorRadius() const { return muonSystem_radius_; }
     55  Double_t getTrackerHalfLength() const { return tk_length_; }
     56  Double_t getDetectorHalfLength() const { return muonSystem_length_; }
     57  Double_t getBField() const { return tk_Bz_; }
     58  std::pair<TAxis *, TAxis *> getCaloAxes() { return std::make_pair(etaAxis_, phiAxis_); }
    5859
    59    private:
    60      std::pair<Double_t, Double_t> addTracker(TGeoVolume *top);
    61      std::pair<Double_t, Double_t> addCalorimeter(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set< std::pair<Double_t, Int_t> >& caloBinning);
    62      std::pair<Double_t, Double_t> addMuonDets(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength);
    63      void addCaloTowers(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set< std::pair<Double_t, Int_t> >& caloBinning);
     60private:
     61  std::pair<Double_t, Double_t> addTracker(TGeoVolume *top);
     62  std::pair<Double_t, Double_t> addCalorimeter(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set<std::pair<Double_t, Int_t> > &caloBinning);
     63  std::pair<Double_t, Double_t> addMuonDets(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength);
     64  void addCaloTowers(TGeoVolume *top, const char *name, Double_t innerBarrelRadius, Double_t innerBarrelLength, std::set<std::pair<Double_t, Int_t> > &caloBinning);
    6465
    65    private:
     66private:
     67  TGeoManager *geom_;
    6668
    67      TGeoManager *geom_;
     69  TGeoMedium *vacuum_;
     70  TGeoMedium *tkmed_;
     71  TGeoMedium *calomed_;
     72  TGeoMedium *mudetmed_;
    6873
    69      TGeoMedium *vacuum_;
    70      TGeoMedium *tkmed_;
    71      TGeoMedium *calomed_;
    72      TGeoMedium *mudetmed_;
     74  TAxis *etaAxis_;
     75  TAxis *phiAxis_;
    7376
    74      TAxis *etaAxis_;
    75      TAxis *phiAxis_;
     77  Double_t contingency_;
     78  Double_t calo_barrel_thickness_;
     79  Double_t calo_endcap_thickness_;
     80  Double_t muonSystem_thickn_;
     81  Double_t muonSystem_radius_;
     82  Double_t muonSystem_length_;
     83  Double_t tk_radius_;
     84  Double_t tk_length_;
     85  Double_t tk_etamax_;
     86  Double_t tk_Bz_;
    7687
    77      Double_t contingency_;
    78      Double_t calo_barrel_thickness_;
    79      Double_t calo_endcap_thickness_;
    80      Double_t muonSystem_thickn_;
    81      Double_t muonSystem_radius_;
    82      Double_t muonSystem_length_;
    83      Double_t tk_radius_;
    84      Double_t tk_length_;
    85      Double_t tk_etamax_;
    86      Double_t tk_Bz_;
     88  std::vector<std::string> calorimeters_;
     89  std::vector<std::string> muondets_;
    8790
    88      std::vector<std::string> calorimeters_;
    89      std::vector<std::string> muondets_;
    90 
    91      std::map<std::string, Double_t> muonSystem_etamax_;
    92      std::map<std::string, std::set< std::pair<Double_t, Int_t> > > caloBinning_;
    93 
     91  std::map<std::string, Double_t> muonSystem_etamax_;
     92  std::map<std::string, std::set<std::pair<Double_t, Int_t> > > caloBinning_;
    9493};
    9594
  • display/DelphesBranchElement.cc

    re39abb4 r0e7d64a  
    1818
    1919#include "display/DelphesBranchElement.h"
    20 #include "classes/DelphesClasses.h"
     20#include "TEveArrow.h"
    2121#include "TEveJetCone.h"
    2222#include "TEveTrack.h"
    2323#include "TEveTrackPropagator.h"
    24 #include "TEveArrow.h"
    2524#include "TEveVector.h"
     25#include "classes/DelphesClasses.h"
    2626#include <iostream>
    2727
    2828// special case for calo towers
    29 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
    30     data_ = new DelphesCaloData(2);
    31     data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
    32     data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
    33     data_->IncDenyDestroy();
    34 }
    35 template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
    36 template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch() {
    37   if(TString(GetType())=="Tower") {
     29template <>
     30DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
     31  DelphesBranchBase(name, branch, color, maxPt)
     32{
     33  data_ = new DelphesCaloData(2);
     34  data_->RefSliceInfo(0).Setup("ECAL", 0.1, kRed);
     35  data_->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
     36  data_->IncDenyDestroy();
     37}
     38template <>
     39void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
     40template <>
     41void DelphesBranchElement<DelphesCaloData>::ReadBranch()
     42{
     43  if(TString(GetType()) == "Tower")
     44  {
    3845    // Loop over all towers
    3946    TIter itTower(branch_);
    4047    Tower *tower;
    41     while((tower = (Tower *) itTower.Next())) {
     48    while((tower = (Tower *)itTower.Next()))
     49    {
    4250      data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
    4351      data_->FillSlice(0, tower->Eem);
     
    4755  }
    4856}
    49 template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() {
     57template <>
     58std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors()
     59{
    5060  std::vector<TLorentzVector> output;
    51   if(TString(GetType())=="Tower") {
     61  if(TString(GetType()) == "Tower")
     62  {
    5263    TIter itTower(branch_);
    5364    Tower *tower;
    54     while((tower = (Tower *) itTower.Next())) {
     65    while((tower = (Tower *)itTower.Next()))
     66    {
    5567      TLorentzVector v;
    56       v.SetPtEtaPhiM(tower->Eem+tower->Ehad,(tower->Edges[0]+tower->Edges[1])/2.,(tower->Edges[2]+tower->Edges[3])/2.,0.);
     68      v.SetPtEtaPhiM(tower->Eem + tower->Ehad, (tower->Edges[0] + tower->Edges[1]) / 2., (tower->Edges[2] + tower->Edges[3]) / 2., 0.);
    5769      output.push_back(v);
    5870    }
     
    6274
    6375// special case for element lists
    64 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
    65     data_ = new TEveElementList(name);
    66     data_->SetMainColor(color_);
    67 }
    68 template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
    69 template<> void DelphesBranchElement<TEveElementList>::ReadBranch() {
    70   if(TString(GetType())=="Jet") {
     76template <>
     77DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
     78  DelphesBranchBase(name, branch, color, maxPt)
     79{
     80  data_ = new TEveElementList(name);
     81  data_->SetMainColor(color_);
     82}
     83template <>
     84void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
     85template <>
     86void DelphesBranchElement<TEveElementList>::ReadBranch()
     87{
     88  if(TString(GetType()) == "Jet")
     89  {
    7190    TIter itJet(branch_);
    7291    Jet *jet;
     
    7493    // Loop over all jets
    7594    Int_t counter = 0;
    76     while((jet = (Jet *) itJet.Next())) {
     95    while((jet = (Jet *)itJet.Next()))
     96    {
    7797      eveJetCone = new TEveJetCone();
    78       eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
     98      eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f", counter, jet->PT, jet->Eta, jet->Phi, jet->Mass));
    7999      eveJetCone->SetName(Form("jet [%d]", counter++));
    80100      eveJetCone->SetMainTransparency(60);
     
    86106      data_->AddElement(eveJetCone);
    87107    }
    88   } else if(TString(GetType())=="MissingET") {
     108  }
     109  else if(TString(GetType()) == "MissingET")
     110  {
    89111    // MissingET as invisible track (like a photon)
    90112    MissingET *MET;
     
    94116    trkProp->SetMaxR(tkRadius_);
    95117    trkProp->SetMaxZ(tkHalfLength_);
    96     if(branch_->GetEntriesFast() > 0) {
    97       MET = (MissingET*) branch_->At(0);
     118    if(branch_->GetEntriesFast() > 0)
     119    {
     120      MET = (MissingET *)branch_->At(0);
    98121      TParticle pb(13, 1, 0, 0, 0, 0,
    99                    (tkRadius_ * MET->MET/maxPt_)*cos(MET->Phi),
    100                    (tkRadius_ * MET->MET/maxPt_)*sin(MET->Phi),
    101                    0., MET->MET, 0.0, 0.0, 0.0, 0.0);
     122        (tkRadius_ * MET->MET / maxPt_) * cos(MET->Phi),
     123        (tkRadius_ * MET->MET / maxPt_) * sin(MET->Phi),
     124        0., MET->MET, 0.0, 0.0, 0.0, 0.0);
    102125      eveMet = new TEveTrack(&pb, 0, trkProp);
    103126      eveMet->SetName("Missing Et");
     
    115138  }
    116139}
    117 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() {
     140template <>
     141std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors()
     142{
    118143  std::vector<TLorentzVector> output;
    119   if(TString(GetType())=="Jet") {
     144  if(TString(GetType()) == "Jet")
     145  {
    120146    TIter itJet(branch_);
    121147    Jet *jet;
    122148    // Loop over all jets
    123     while((jet = (Jet *) itJet.Next())) {
     149    while((jet = (Jet *)itJet.Next()))
     150    {
    124151      TLorentzVector v;
    125152      v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass);
    126153      output.push_back(v);
    127154    }
    128   } else if(TString(GetType())=="MissingET") {
     155  }
     156  else if(TString(GetType()) == "MissingET")
     157  {
    129158    TIter itMet(branch_);
    130159    MissingET *MET;
    131160    // Missing Et
    132     while((MET = (MissingET*) itMet.Next())) {
     161    while((MET = (MissingET *)itMet.Next()))
     162    {
    133163      TLorentzVector v;
    134       v.SetPtEtaPhiM(MET->MET,MET->Eta,MET->Phi,0.);
     164      v.SetPtEtaPhiM(MET->MET, MET->Eta, MET->Phi, 0.);
    135165      output.push_back(v);
    136166    }
     
    140170
    141171// special case for track lists
    142 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
     172template <>
     173DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
     174  DelphesBranchBase(name, branch, color, maxPt)
     175{
    143176  data_ = new TEveTrackList(name);
    144177  data_->SetMainColor(color_);
     
    147180  data_->SetMarkerSize(0.5);
    148181}
    149 template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
    150   tkRadius_ = r;
     182template <>
     183void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz)
     184{
     185  tkRadius_ = r;
    151186  tkHalfLength_ = l;
    152187  tk_Bz_ = Bz;
     
    156191  trkProp->SetMaxZ(tkHalfLength_);
    157192}
    158 template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
    159 template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
     193template <>
     194void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
     195template <>
     196void DelphesBranchElement<TEveTrackList>::ReadBranch()
     197{
    160198  TString type = GetType();
    161199  TIter itTrack(branch_);
     
    167205  trkProp->SetMaxZ(tkHalfLength_);
    168206  GenParticle *particle;
    169   if(type=="Track") { // CASE 1: TRACKS
     207  if(type == "Track")
     208  { // CASE 1: TRACKS
    170209    Track *track;
    171     while((track = (Track *) itTrack.Next())) {
     210    while((track = (Track *)itTrack.Next()))
     211    {
    172212      TParticle pb(track->PID, 1, 0, 0, 0, 0,
    173                    track->P4().Px(), track->P4().Py(),
    174                    track->P4().Pz(), track->P4().E(),
    175                    track->X/10.0, track->Y/10.0, track->Z/10.0, track->T/10.0);
    176       eveTrack = new TEveTrack(&pb, counter, trkProp);
    177       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    178       eveTrack->SetStdTitle();
    179       eveTrack->SetAttLineAttMarker(data_);
    180       data_->AddElement(eveTrack);
    181       eveTrack->SetLineColor(GetColor());
    182       eveTrack->MakeTrack();
    183     }
    184   } else if(type=="Electron") { // CASE 2: ELECTRONS
     213        track->P4().Px(), track->P4().Py(),
     214        track->P4().Pz(), track->P4().E(),
     215        track->X / 10.0, track->Y / 10.0, track->Z / 10.0, track->T / 10.0);
     216      eveTrack = new TEveTrack(&pb, counter, trkProp);
     217      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     218      eveTrack->SetStdTitle();
     219      eveTrack->SetAttLineAttMarker(data_);
     220      data_->AddElement(eveTrack);
     221      eveTrack->SetLineColor(GetColor());
     222      eveTrack->MakeTrack();
     223    }
     224  }
     225  else if(type == "Electron")
     226  { // CASE 2: ELECTRONS
    185227    Electron *electron;
    186     while((electron = (Electron *) itTrack.Next())) {
    187       particle = (GenParticle*) electron->Particle.GetObject();
    188       TParticle pb(electron->Charge<0?11:-11, 1, 0, 0, 0, 0,
    189                    electron->P4().Px(), electron->P4().Py(),
    190                    electron->P4().Pz(), electron->P4().E(),
    191                    particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
    192       eveTrack = new TEveTrack(&pb, counter, trkProp);
    193       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    194       eveTrack->SetStdTitle();
    195       eveTrack->SetAttLineAttMarker(data_);
    196       data_->AddElement(eveTrack);
    197       eveTrack->SetLineColor(GetColor());
    198       eveTrack->MakeTrack();
    199     }
    200   } else if(type=="Muon") { // CASE 3: MUONS
     228    while((electron = (Electron *)itTrack.Next()))
     229    {
     230      particle = (GenParticle *)electron->Particle.GetObject();
     231      TParticle pb(electron->Charge < 0 ? 11 : -11, 1, 0, 0, 0, 0,
     232        electron->P4().Px(), electron->P4().Py(),
     233        electron->P4().Pz(), electron->P4().E(),
     234        particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
     235      eveTrack = new TEveTrack(&pb, counter, trkProp);
     236      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     237      eveTrack->SetStdTitle();
     238      eveTrack->SetAttLineAttMarker(data_);
     239      data_->AddElement(eveTrack);
     240      eveTrack->SetLineColor(GetColor());
     241      eveTrack->MakeTrack();
     242    }
     243  }
     244  else if(type == "Muon")
     245  { // CASE 3: MUONS
    201246    Muon *muon;
    202     while((muon = (Muon *) itTrack.Next())) {
    203       particle = (GenParticle*) muon->Particle.GetObject();
    204       TParticle pb(muon->Charge<0?13:-13, 1, 0, 0, 0, 0,
    205                    muon->P4().Px(), muon->P4().Py(),
    206                    muon->P4().Pz(), muon->P4().E(),
    207                    particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
    208       eveTrack = new TEveTrack(&pb, counter, trkProp);
    209       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    210       eveTrack->SetStdTitle();
    211       eveTrack->SetAttLineAttMarker(data_);
    212       data_->AddElement(eveTrack);
    213       eveTrack->SetLineColor(GetColor());
    214       eveTrack->MakeTrack();
    215     }
    216   } else if(type=="Photon") { // CASE 4: PHOTONS
     247    while((muon = (Muon *)itTrack.Next()))
     248    {
     249      particle = (GenParticle *)muon->Particle.GetObject();
     250      TParticle pb(muon->Charge < 0 ? 13 : -13, 1, 0, 0, 0, 0,
     251        muon->P4().Px(), muon->P4().Py(),
     252        muon->P4().Pz(), muon->P4().E(),
     253        particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
     254      eveTrack = new TEveTrack(&pb, counter, trkProp);
     255      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     256      eveTrack->SetStdTitle();
     257      eveTrack->SetAttLineAttMarker(data_);
     258      data_->AddElement(eveTrack);
     259      eveTrack->SetLineColor(GetColor());
     260      eveTrack->MakeTrack();
     261    }
     262  }
     263  else if(type == "Photon")
     264  { // CASE 4: PHOTONS
    217265    Photon *photon;
    218     while((photon = (Photon *) itTrack.Next())) {
     266    while((photon = (Photon *)itTrack.Next()))
     267    {
    219268      TParticle pb(22, 1, 0, 0, 0, 0,
    220                    photon->P4().Px(), photon->P4().Py(),
    221                    photon->P4().Pz(), photon->P4().E(),
    222                    0.0, 0.0, 0.0, 0.0);
     269        photon->P4().Px(), photon->P4().Py(),
     270        photon->P4().Pz(), photon->P4().E(),
     271        0.0, 0.0, 0.0, 0.0);
    223272      eveTrack = new TEveTrack(&pb, counter, trkProp);
    224273      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     
    230279      eveTrack->MakeTrack();
    231280    }
    232   } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
     281  }
     282  else if(type == "GenParticle")
     283  { // CASE 5: GENPARTICLES
    233284    GenParticle *particle;
    234     while((particle = (GenParticle *) itTrack.Next())) {
     285    while((particle = (GenParticle *)itTrack.Next()))
     286    {
    235287      if(particle->Status != 1) continue;
    236288      TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
    237                    particle->P4().Px(), particle->P4().Py(),
    238                    particle->P4().Pz(), particle->P4().E(),
    239                    particle->X/10.0, particle->Y/10.0, particle->Z/10.0, particle->T/10.0);
    240       eveTrack = new TEveTrack(&pb, counter, trkProp);
    241       eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
    242       eveTrack->SetStdTitle();
    243       eveTrack->SetAttLineAttMarker(data_);
    244       data_->AddElement(eveTrack);
    245       eveTrack->SetLineColor(GetColor());
    246       if(particle->Charge==0) eveTrack->SetLineStyle(7);
    247       eveTrack->MakeTrack();
    248     }
    249   }
    250 }
    251 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() {
     289        particle->P4().Px(), particle->P4().Py(),
     290        particle->P4().Pz(), particle->P4().E(),
     291        particle->X / 10.0, particle->Y / 10.0, particle->Z / 10.0, particle->T / 10.0);
     292      eveTrack = new TEveTrack(&pb, counter, trkProp);
     293      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     294      eveTrack->SetStdTitle();
     295      eveTrack->SetAttLineAttMarker(data_);
     296      data_->AddElement(eveTrack);
     297      eveTrack->SetLineColor(GetColor());
     298      if(particle->Charge == 0) eveTrack->SetLineStyle(7);
     299      eveTrack->MakeTrack();
     300    }
     301  }
     302}
     303template <>
     304std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors()
     305{
    252306  std::vector<TLorentzVector> output;
    253307  TString type = GetType();
    254308  TIter itTrack(branch_);
    255   if(type=="Track") { // CASE 1: TRACKS
     309  if(type == "Track")
     310  { // CASE 1: TRACKS
    256311    Track *track;
    257     while((track = (Track *) itTrack.Next())) {
     312    while((track = (Track *)itTrack.Next()))
     313    {
    258314      output.push_back(track->P4());
    259315    }
    260   } else if(type=="Electron") { // CASE 2: ELECTRONS
     316  }
     317  else if(type == "Electron")
     318  { // CASE 2: ELECTRONS
    261319    Electron *electron;
    262     while((electron = (Electron *) itTrack.Next())) {
     320    while((electron = (Electron *)itTrack.Next()))
     321    {
    263322      output.push_back(electron->P4());
    264323    }
    265   } else if(type=="Muon") { // CASE 3: MUONS
     324  }
     325  else if(type == "Muon")
     326  { // CASE 3: MUONS
    266327    Muon *muon;
    267     while((muon = (Muon *) itTrack.Next())) {
     328    while((muon = (Muon *)itTrack.Next()))
     329    {
    268330      output.push_back(muon->P4());
    269331    }
    270   } else if(type=="Photon") { // CASE 4: PHOTONS
     332  }
     333  else if(type == "Photon")
     334  { // CASE 4: PHOTONS
    271335    Photon *photon;
    272     while((photon = (Photon *) itTrack.Next())) {
     336    while((photon = (Photon *)itTrack.Next()))
     337    {
    273338      output.push_back(photon->P4());
    274339    }
    275   } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
     340  }
     341  else if(type == "GenParticle")
     342  { // CASE 5: GENPARTICLES
    276343    GenParticle *particle;
    277     while((particle = (GenParticle *) itTrack.Next())) {
     344    while((particle = (GenParticle *)itTrack.Next()))
     345    {
    278346      if(particle->Status != 1) continue;
    279         output.push_back(particle->P4());
     347      output.push_back(particle->P4());
    280348    }
    281349  }
  • display/DelphesBranchElement.h

    re39abb4 r0e7d64a  
    2020#define DelphesBranchElement_h
    2121
     22#include "TClass.h"
     23#include "TClonesArray.h"
    2224#include "TColor.h"
     25#include "TEveElement.h"
     26#include "TEveTrack.h"
    2327#include "TString.h"
    24 #include "TClonesArray.h"
    25 #include "TClass.h"
     28#include "display/DelphesCaloData.h"
    2629#include <exception>
    2730#include <iostream>
    28 #include "display/DelphesCaloData.h"
    29 #include "TEveElement.h"
    30 #include "TEveTrack.h"
    3131
    3232// virtual class to represent objects from a Delphes-tree branch
    3333class DelphesBranchBase
    3434{
    35   public:
    36     DelphesBranchBase(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack, Float_t maxPt=50.):name_(name),maxPt_(maxPt),branch_(branch),color_(color) {}
    37     virtual ~DelphesBranchBase() {}
    38     const char* GetName() const { return (const char*)name_; }
    39     const char* GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; }
    40     virtual const char* GetClassName() = 0;
    41     enum EColor GetColor() const { return color_; }
    42     virtual void Reset() = 0;
    43     virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
    44     virtual void ReadBranch() = 0;
    45     virtual std::vector<TLorentzVector> GetVectors() = 0;
     35public:
     36  DelphesBranchBase(const char *name = "", TClonesArray *branch = NULL, const enum EColor color = kBlack, Float_t maxPt = 50.) :
     37    name_(name), maxPt_(maxPt), branch_(branch), color_(color) {}
     38  virtual ~DelphesBranchBase() {}
     39  const char *GetName() const { return (const char *)name_; }
     40  const char *GetType() const { return branch_ ? branch_->GetClass()->GetName() : "None"; }
     41  virtual const char *GetClassName() = 0;
     42  enum EColor GetColor() const { return color_; }
     43  virtual void Reset() = 0;
     44  virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz = 0.)
     45  {
     46    tkRadius_ = r;
     47    tkHalfLength_ = l;
     48    tk_Bz_ = Bz;
     49  }
     50  virtual void ReadBranch() = 0;
     51  virtual std::vector<TLorentzVector> GetVectors() = 0;
    4652
    47   protected:
    48     TString name_;
    49     Float_t maxPt_;
    50     TClonesArray* branch_;
    51     const enum EColor color_;
    52     Float_t tkRadius_,tkHalfLength_, tk_Bz_;
     53protected:
     54  TString name_;
     55  Float_t maxPt_;
     56  TClonesArray *branch_;
     57  const enum EColor color_;
     58  Float_t tkRadius_, tkHalfLength_, tk_Bz_;
    5359};
    5460
    5561// concrete implementations. EveContainer can be a TrackList, ElementList or CaloData.
    56 template<typename EveContainer> class DelphesBranchElement: public DelphesBranchBase
     62template <typename EveContainer>
     63class DelphesBranchElement: public DelphesBranchBase
    5764{
    58   public:
    59     // constructor
    60     DelphesBranchElement(const char* name="", TClonesArray* branch=NULL, const enum EColor color=kBlack, Float_t maxPt=50.):DelphesBranchBase(name, branch, color, maxPt) {
    61       throw std::exception();
    62     }
     65public:
     66  // constructor
     67  DelphesBranchElement(const char *name = "", TClonesArray *branch = NULL, const enum EColor color = kBlack, Float_t maxPt = 50.) :
     68    DelphesBranchBase(name, branch, color, maxPt)
     69  {
     70    throw std::exception();
     71  }
    6372
    64     // destructor
    65     virtual ~DelphesBranchElement() { delete data_; }
     73  // destructor
     74  virtual ~DelphesBranchElement() { delete data_; }
    6675
    67     // get the container (ElementList, TrackList, or CaloData)
    68     EveContainer* GetContainer() { return data_; }
     76  // get the container (ElementList, TrackList, or CaloData)
     77  EveContainer *GetContainer() { return data_; }
    6978
    70     // tracking volume
    71     virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
     79  // tracking volume
     80  virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz = 0.)
     81  {
     82    tkRadius_ = r;
     83    tkHalfLength_ = l;
     84    tk_Bz_ = Bz;
     85  }
    7286
    73     // resets the collection (before moving to the next event)
    74     virtual void Reset() {};
     87  // resets the collection (before moving to the next event)
     88  virtual void Reset(){};
    7589
    76     // template class name
    77     virtual const char* GetClassName() { return data_->ClassName(); }
     90  // template class name
     91  virtual const char *GetClassName() { return data_->ClassName(); }
    7892
    79     // read the branch and fill elements for display
    80     virtual void ReadBranch() {}
     93  // read the branch and fill elements for display
     94  virtual void ReadBranch() {}
    8195
    82     // return the vector for all elements
    83     virtual std::vector<TLorentzVector> GetVectors() { std::vector<TLorentzVector> v; return v; }
     96  // return the vector for all elements
     97  virtual std::vector<TLorentzVector> GetVectors()
     98  {
     99    std::vector<TLorentzVector> v;
     100    return v;
     101  }
    84102
    85   private:
    86     EveContainer* data_;
     103private:
     104  EveContainer *data_;
    87105};
    88106
     
    90108
    91109// special case for calo towers
    92 template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
    93 template<> void DelphesBranchElement<DelphesCaloData>::Reset();
    94 template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch();
    95 template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors();
     110template <>
     111DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
     112template <>
     113void DelphesBranchElement<DelphesCaloData>::Reset();
     114template <>
     115void DelphesBranchElement<DelphesCaloData>::ReadBranch();
     116template <>
     117std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors();
    96118
    97119// special case for element lists
    98 template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
    99 template<> void DelphesBranchElement<TEveElementList>::Reset();
    100 template<> void DelphesBranchElement<TEveElementList>::ReadBranch();
    101 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors();
     120template <>
     121DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
     122template <>
     123void DelphesBranchElement<TEveElementList>::Reset();
     124template <>
     125void DelphesBranchElement<TEveElementList>::ReadBranch();
     126template <>
     127std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors();
    102128
    103129// special case for track lists
    104 template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
    105 template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
    106 template<> void DelphesBranchElement<TEveTrackList>::Reset();
    107 template<> void DelphesBranchElement<TEveTrackList>::ReadBranch();
    108 template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors();
     130template <>
     131DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
     132template <>
     133void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
     134template <>
     135void DelphesBranchElement<TEveTrackList>::Reset();
     136template <>
     137void DelphesBranchElement<TEveTrackList>::ReadBranch();
     138template <>
     139std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors();
    109140
    110141#endif // CINT, CLING
  • display/DelphesCaloData.cc

    re39abb4 r0e7d64a  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
    18 
    1918
    2019#include "display/DelphesCaloData.h"
     
    3736void DelphesCaloData::ClearTowers()
    3837{
    39    fGeomVec.clear();
     38  fGeomVec.clear();
    4039}
    4140
  • display/DelphesCaloData.h

    re39abb4 r0e7d64a  
    2222#include "TEveCaloData.h"
    2323
    24 class DelphesCaloData: public TEveCaloDataVec 
     24class DelphesCaloData: public TEveCaloDataVec
    2525{
    2626public:
    27  
    2827  DelphesCaloData(Int_t nslices);
    2928
     
    3635
    3736#endif /* DelphesCaloData_h */
    38 
  • display/DelphesDisplay.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
     19#include "TEveBrowser.h"
    2020#include "TEveManager.h"
     21#include "TEveProjectionAxes.h"
     22#include "TEveProjectionManager.h"
     23#include "TEveScene.h"
    2124#include "TEveViewer.h"
     25#include "TEveWindow.h"
    2226#include "TGLViewer.h"
    2327#include "TGLWidget.h"
    24 #include "TEveScene.h"
    25 #include "TEveProjectionManager.h"
    26 #include "TEveProjectionAxes.h"
    27 #include "TEveBrowser.h"
    28 #include "TEveWindow.h"
    2928#include "TGTab.h"
    3029
    3130#include "TEveCalo2DGL.h"
    32 #include "TEveCalo3DGL.h" 
     31#include "TEveCalo3DGL.h"
    3332#include "TEveCaloLegoGL.h"
    3433#include "TEveCaloLegoOverlay.h"
     
    4847  fRhoZMgr = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
    4948
    50         fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry");
    51         fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry");
     49  fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry");
     50  fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry");
    5251
    53         fRPhiCaloScene = gEve->SpawnNewScene("RPhi Calorimeter");
    54         fRhoZCaloScene = gEve->SpawnNewScene("RhoZ Calorimeter");
    55         fLegoCaloScene = gEve->SpawnNewScene("Lego Calorimeter");
     52  fRPhiCaloScene = gEve->SpawnNewScene("RPhi Calorimeter");
     53  fRhoZCaloScene = gEve->SpawnNewScene("RhoZ Calorimeter");
     54  fLegoCaloScene = gEve->SpawnNewScene("Lego Calorimeter");
    5655
    57         fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data");
    58         fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data");
    59  
     56  fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data");
     57  fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data");
     58
    6059  axes = new TEveProjectionAxes(fRPhiMgr);
    6160  fRPhiGeomScene->AddElement(axes);
     
    8584  f3DimView->AddScene(gEve->GetGlobalScene());
    8685  f3DimView->AddScene(gEve->GetEventScene());
    87  
     86
    8887  pack1->NewSlot()->MakeCurrent();
    8988  fLegoView = gEve->SpawnNewViewer("Lego View", "");
    9089  fLegoView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
    9190  fLegoView->AddScene(fLegoCaloScene);
    92  
     91
    9392  pack0->NewSlot()->MakeCurrent();
    9493  fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
     
    9796  fRPhiView->AddScene(fRPhiCaloScene);
    9897  fRPhiView->AddScene(fRPhiEventScene);
    99        
     98
    10099  pack0->NewSlot()->MakeCurrent();
    101100  fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
     
    114113//------------------------------------------------------------------------------
    115114
    116 void DelphesDisplay::ImportGeomRPhi(TEveElement* el)
    117 { 
     115void DelphesDisplay::ImportGeomRPhi(TEveElement *el)
     116{
    118117  fRPhiMgr->ImportElements(el, fRPhiGeomScene);
    119118}
    120119
    121 void DelphesDisplay::ImportGeomRhoZ(TEveElement* el)
    122 { 
     120void DelphesDisplay::ImportGeomRhoZ(TEveElement *el)
     121{
    123122  fRhoZMgr->ImportElements(el, fRhoZGeomScene);
    124123}
     
    137136{
    138137  TEveCaloLegoOverlay *overlay = new TEveCaloLegoOverlay();
    139  
     138
    140139  overlay->SetCaloLego(calo);
    141140  fLegoView->GetGLViewer()->AddOverlayElement(overlay);
     
    144143}
    145144
    146 void DelphesDisplay::ImportEventRPhi(TEveElement* el)
    147 { 
     145void DelphesDisplay::ImportEventRPhi(TEveElement *el)
     146{
    148147  fRPhiMgr->ImportElements(el, fRPhiEventScene);
    149148}
    150149
    151 void DelphesDisplay::ImportEventRhoZ(TEveElement* el)
    152 { 
     150void DelphesDisplay::ImportEventRhoZ(TEveElement *el)
     151{
    153152  fRhoZMgr->ImportElements(el, fRhoZEventScene);
    154153}
     
    166165}
    167166//------------------------------------------------------------------------------
    168 
  • display/DelphesDisplay.h

    re39abb4 r0e7d64a  
    3030{
    3131public:
    32  
    3332  DelphesDisplay();
    3433
    3534  virtual ~DelphesDisplay();
    3635
    37   void ImportGeomRPhi(TEveElement* el);
    38   void ImportGeomRhoZ(TEveElement* el);
     36  void ImportGeomRPhi(TEveElement *el);
     37  void ImportGeomRhoZ(TEveElement *el);
    3938
    4039  void ImportCaloRPhi(TEveCalo3D *calo);
     
    4241  void ImportCaloLego(TEveCaloLego *calo);
    4342
    44   void ImportEventRPhi(TEveElement* el);
    45   void ImportEventRhoZ(TEveElement* el);
     43  void ImportEventRPhi(TEveElement *el);
     44  void ImportEventRhoZ(TEveElement *el);
    4645
    4746  void DestroyEventRPhi();
     
    4948
    5049private:
    51 
    5250  TEveProjectionManager *fRPhiMgr;
    5351  TEveProjectionManager *fRhoZMgr;
     
    7068
    7169#endif /* DelphesDisplay_h */
    72 
  • display/DelphesEventDisplay.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
     19#include <algorithm>
    1920#include <cassert>
    2021#include <iostream>
    2122#include <utility>
    22 #include <algorithm>
    23 
     23
     24#include "TAxis.h"
     25#include "TCanvas.h"
     26#include "TChain.h"
     27#include "TClonesArray.h"
     28#include "TEveArrow.h"
     29#include "TEveBrowser.h"
     30#include "TEveCalo.h"
     31#include "TEveElement.h"
     32#include "TEveEventManager.h"
     33#include "TEveGeoNode.h"
     34#include "TEveJetCone.h"
     35#include "TEveManager.h"
     36#include "TEveTrack.h"
     37#include "TEveTrackPropagator.h"
     38#include "TEveTrans.h"
     39#include "TEveViewer.h"
     40#include "TGButton.h"
     41#include "TGHtml.h"
     42#include "TGNumberEntry.h"
     43#include "TGProgressBar.h"
     44#include "TGStatusBar.h"
     45#include "TGTextEntry.h"
    2446#include "TGeoManager.h"
    2547#include "TGeoVolume.h"
    26 #include "TEveElement.h"
    27 #include "TEveJetCone.h"
    28 #include "TEveTrack.h"
    29 #include "TEveTrackPropagator.h"
    30 #include "TEveCalo.h"
    31 #include "TEveManager.h"
    32 #include "TEveGeoNode.h"
    33 #include "TEveTrans.h"
    34 #include "TEveViewer.h"
    35 #include "TEveBrowser.h"
    36 #include "TEveArrow.h"
     48#include "TH1F.h"
    3749#include "TMath.h"
     50#include "TRootBrowser.h"
     51#include "TRootEmbeddedCanvas.h"
    3852#include "TSystem.h"
    39 #include "TRootBrowser.h"
    40 #include "TGButton.h"
    41 #include "TGTextEntry.h"
    42 #include "TGProgressBar.h"
    43 #include "TGNumberEntry.h"
    44 #include "TRootEmbeddedCanvas.h"
    45 #include "TClonesArray.h"
    46 #include "TEveEventManager.h"
    47 #include "TCanvas.h"
    48 #include "TH1F.h"
    49 #include "TAxis.h"
    50 #include "TChain.h"
    51 #include "TGHtml.h"
    52 #include "TGStatusBar.h"
    53 
     53
     54#include "display/Delphes3DGeometry.h"
     55#include "display/DelphesBranchElement.h"
    5456#include "display/DelphesCaloData.h"
    55 #include "display/DelphesBranchElement.h"
    56 #include "display/Delphes3DGeometry.h"
     57#include "display/DelphesDisplay.h"
    5758#include "display/DelphesEventDisplay.h"
    58 #include "display/DelphesDisplay.h"
    59 #include "display/Delphes3DGeometry.h"
    6059#include "display/DelphesHtmlSummary.h"
    6160#include "display/DelphesPlotSummary.h"
     
    6766DelphesEventDisplay::DelphesEventDisplay()
    6867{
    69    event_id_ = 0;
    70    tkRadius_ = 1.29;
    71    totRadius_ = 2.0;
    72    tkHalfLength_ = 3.0;
    73    muHalfLength_ = 6.0;
    74    bz_ = 3.8;
    75    chain_ = new TChain("Delphes");
    76    treeReader_ = 0;
    77    delphesDisplay_ = 0;
    78    etaAxis_ = 0;
    79    phiAxis_ = 0;
     68  event_id_ = 0;
     69  tkRadius_ = 1.29;
     70  totRadius_ = 2.0;
     71  tkHalfLength_ = 3.0;
     72  muHalfLength_ = 6.0;
     73  bz_ = 3.8;
     74  chain_ = new TChain("Delphes");
     75  treeReader_ = 0;
     76  delphesDisplay_ = 0;
     77  etaAxis_ = 0;
     78  phiAxis_ = 0;
    8079}
    8180
    8281DelphesEventDisplay::~DelphesEventDisplay()
    8382{
    84    delete chain_;
     83  delete chain_;
    8584}
    8685
    8786void DelphesEventDisplay::EventChanged(Int_t e)
    8887{
    89   if( e!= event_id_ ) {
     88  if(e != event_id_)
     89  {
    9090    event_id_ = e;
    91     Emit("EventChanged(Int_t)",e);
     91    Emit("EventChanged(Int_t)", e);
    9292    load_event();
    9393  }
    9494}
    9595
    96 
    97 DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D)
    98 {
    99    event_id_ = 0;
    100    tkRadius_ = 1.29;
    101    totRadius_ = 2.0;
    102    tkHalfLength_ = 3.0;
    103    bz_ = 3.8;
    104    chain_ = new TChain("Delphes");
    105    treeReader_ = 0;
    106    delphesDisplay_ = 0;
    107 
    108    // initialize the application
    109    TEveManager::Create(kTRUE, "IV");
    110    fStatusBar_ = gEve->GetBrowser()->GetStatusBar();
    111    TGeoManager *geom = gGeoManager;
    112 
    113    // build the detector
    114    tkRadius_ = det3D.getTrackerRadius();
    115    totRadius_ = det3D.getDetectorRadius();
    116    tkHalfLength_ = det3D.getTrackerHalfLength();
    117    muHalfLength_ = det3D.getDetectorHalfLength();
    118    bz_ = det3D.getBField();
    119    etaAxis_ = det3D.getCaloAxes().first;
    120    phiAxis_ = det3D.getCaloAxes().second;
    121    TGeoVolume *top = det3D.getDetector(false);
    122    geom->SetTopVolume(top);
    123    TEveElementList *geometry = new TEveElementList("Geometry");
    124    TObjArray *nodes = top->GetNodes();
    125    TIter itNodes(nodes);
    126    TGeoNode *nodeobj;
    127    TEveGeoTopNode *node;
    128    while((nodeobj = (TGeoNode*)itNodes.Next())) {
    129      node = new TEveGeoTopNode(gGeoManager,nodeobj);
    130      node->UseNodeTrans();
    131      geometry->AddElement(node);
    132    }
    133 
    134    // Create chain of root trees
    135    chain_->Add(inputFile);
    136 
    137    // Create object of class ExRootTreeReader
    138    fStatusBar_->SetText("Opening Delphes data file", 1);
    139    gSystem->ProcessEvents();
    140    treeReader_ = new ExRootTreeReader(chain_);
    141 
    142    // prepare data collections
    143    readConfig(configFile, elements_);
    144    for(std::vector<DelphesBranchBase *>::iterator element = elements_.begin(); element<elements_.end(); ++element) {
    145      DelphesBranchElement<TEveTrackList> *item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList>*>(*element);
    146      DelphesBranchElement<TEveElementList> *item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList>*>(*element);
    147      if(item_v1) gEve->AddElement(item_v1->GetContainer());
    148      if(item_v2) gEve->AddElement(item_v2->GetContainer());
    149    }
    150 
    151    // viewers and scenes
    152    delphesDisplay_ = new DelphesDisplay;
    153    gEve->AddGlobalElement(geometry);
    154    delphesDisplay_->ImportGeomRPhi(geometry);
    155    delphesDisplay_->ImportGeomRhoZ(geometry);
    156    // find the first calo data and use that to initialize the calo display
    157    for(std::vector<DelphesBranchBase *>::iterator data=elements_.begin();data<elements_.end();++data) {
    158      if(TString((*data)->GetType())=="Tower") { // we could also use GetClassName()=="DelphesCaloData"
    159        DelphesCaloData *container = dynamic_cast<DelphesBranchElement<DelphesCaloData>*>((*data))->GetContainer();
    160        assert(container);
    161        TEveCalo3D *calo3d = new TEveCalo3D(container);
    162        calo3d->SetBarrelRadius(tkRadius_);
    163        calo3d->SetEndCapPos(tkHalfLength_);
    164        gEve->AddGlobalElement(calo3d);
    165        delphesDisplay_->ImportCaloRPhi(calo3d);
    166        delphesDisplay_->ImportCaloRhoZ(calo3d);
    167        TEveCaloLego *lego = new TEveCaloLego(container);
    168        lego->InitMainTrans();
    169  //    lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
    170        lego->RefMainTrans().SetScale(100, 100, TMath::Pi());
    171        lego->SetAutoRebin(kFALSE);
    172        lego->Set2DMode(TEveCaloLego::kValSizeOutline);
    173        delphesDisplay_->ImportCaloLego(lego);
    174        break;
    175      }
    176    }
    177 
    178    // the GUI: control panel, summary tab
    179    make_gui();
    180 
    181    //ready...
    182    fStatusBar_->SetText("Ready.", 1);
    183    gSystem->ProcessEvents();
    184    load_event();
    185    gEve->Redraw3D(kTRUE);   
    186 
     96DelphesEventDisplay::DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry &det3D)
     97{
     98  event_id_ = 0;
     99  tkRadius_ = 1.29;
     100  totRadius_ = 2.0;
     101  tkHalfLength_ = 3.0;
     102  bz_ = 3.8;
     103  chain_ = new TChain("Delphes");
     104  treeReader_ = 0;
     105  delphesDisplay_ = 0;
     106
     107  // initialize the application
     108  TEveManager::Create(kTRUE, "IV");
     109  fStatusBar_ = gEve->GetBrowser()->GetStatusBar();
     110  TGeoManager *geom = gGeoManager;
     111
     112  // build the detector
     113  tkRadius_ = det3D.getTrackerRadius();
     114  totRadius_ = det3D.getDetectorRadius();
     115  tkHalfLength_ = det3D.getTrackerHalfLength();
     116  muHalfLength_ = det3D.getDetectorHalfLength();
     117  bz_ = det3D.getBField();
     118  etaAxis_ = det3D.getCaloAxes().first;
     119  phiAxis_ = det3D.getCaloAxes().second;
     120  TGeoVolume *top = det3D.getDetector(false);
     121  geom->SetTopVolume(top);
     122  TEveElementList *geometry = new TEveElementList("Geometry");
     123  TObjArray *nodes = top->GetNodes();
     124  TIter itNodes(nodes);
     125  TGeoNode *nodeobj;
     126  TEveGeoTopNode *node;
     127  while((nodeobj = (TGeoNode *)itNodes.Next()))
     128  {
     129    node = new TEveGeoTopNode(gGeoManager, nodeobj);
     130    node->UseNodeTrans();
     131    geometry->AddElement(node);
     132  }
     133
     134  // Create chain of root trees
     135  chain_->Add(inputFile);
     136
     137  // Create object of class ExRootTreeReader
     138  fStatusBar_->SetText("Opening Delphes data file", 1);
     139  gSystem->ProcessEvents();
     140  treeReader_ = new ExRootTreeReader(chain_);
     141
     142  // prepare data collections
     143  readConfig(configFile, elements_);
     144  for(std::vector<DelphesBranchBase *>::iterator element = elements_.begin(); element < elements_.end(); ++element)
     145  {
     146    DelphesBranchElement<TEveTrackList> *item_v1 = dynamic_cast<DelphesBranchElement<TEveTrackList> *>(*element);
     147    DelphesBranchElement<TEveElementList> *item_v2 = dynamic_cast<DelphesBranchElement<TEveElementList> *>(*element);
     148    if(item_v1) gEve->AddElement(item_v1->GetContainer());
     149    if(item_v2) gEve->AddElement(item_v2->GetContainer());
     150  }
     151
     152  // viewers and scenes
     153  delphesDisplay_ = new DelphesDisplay;
     154  gEve->AddGlobalElement(geometry);
     155  delphesDisplay_->ImportGeomRPhi(geometry);
     156  delphesDisplay_->ImportGeomRhoZ(geometry);
     157  // find the first calo data and use that to initialize the calo display
     158  for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data)
     159  {
     160    if(TString((*data)->GetType()) == "Tower")
     161    { // we could also use GetClassName()=="DelphesCaloData"
     162      DelphesCaloData *container = dynamic_cast<DelphesBranchElement<DelphesCaloData> *>((*data))->GetContainer();
     163      assert(container);
     164      TEveCalo3D *calo3d = new TEveCalo3D(container);
     165      calo3d->SetBarrelRadius(tkRadius_);
     166      calo3d->SetEndCapPos(tkHalfLength_);
     167      gEve->AddGlobalElement(calo3d);
     168      delphesDisplay_->ImportCaloRPhi(calo3d);
     169      delphesDisplay_->ImportCaloRhoZ(calo3d);
     170      TEveCaloLego *lego = new TEveCaloLego(container);
     171      lego->InitMainTrans();
     172      //    lego->RefMainTrans().SetScale(TMath::TwoPi(), TMath::TwoPi(), TMath::Pi());
     173      lego->RefMainTrans().SetScale(100, 100, TMath::Pi());
     174      lego->SetAutoRebin(kFALSE);
     175      lego->Set2DMode(TEveCaloLego::kValSizeOutline);
     176      delphesDisplay_->ImportCaloLego(lego);
     177      break;
     178    }
     179  }
     180
     181  // the GUI: control panel, summary tab
     182  make_gui();
     183
     184  //ready...
     185  fStatusBar_->SetText("Ready.", 1);
     186  gSystem->ProcessEvents();
     187  load_event();
     188  gEve->Redraw3D(kTRUE);
    187189}
    188190
    189191// function that parses the config to extract the branches of interest and prepare containers
    190 void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase*>& elements) {
    191    ExRootConfReader *confReader = new ExRootConfReader;
    192    confReader->ReadFile(configFile);
    193    ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch");
    194    Int_t nBranches = branches.GetSize()/3;
    195    DelphesBranchElement<TEveTrackList> *tlist;
    196    DelphesBranchElement<DelphesCaloData> *clist;
    197    DelphesBranchElement<TEveElementList> *elist;
    198    // first loop with all but tracks
    199    for(Int_t b = 0; b<nBranches; ++b) {
    200      TString input = branches[b*3].GetString();
    201      TString name = branches[b*3+1].GetString();
    202      TString className = branches[b*3+2].GetString();
    203      if(className=="Tower") {
    204        if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
    205        clist = new DelphesBranchElement<DelphesCaloData>(name,treeReader_->UseBranch(name),kBlack);
    206        clist->GetContainer()->SetEtaBins(etaAxis_);
    207        clist->GetContainer()->SetPhiBins(phiAxis_);
    208        elements.push_back(clist);
    209      } else if(className=="Jet") {
    210        if(input.Contains("GenJetFinder")) {
    211          elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kCyan);
    212          elist->GetContainer()->SetRnrSelf(false);
    213          elist->GetContainer()->SetRnrChildren(false);
    214          elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    215          elements.push_back(elist);
    216        } else {
    217          elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kYellow);
    218          elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    219          elements.push_back(elist);
    220        }
    221      } else if(className=="Electron") {
    222        tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kRed);
    223        tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    224        elements.push_back(tlist);
    225      } else if(className=="Photon") {
    226        tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kYellow);
    227        tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    228        elements.push_back(tlist);
    229      } else if(className=="Muon") {
    230        tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kGreen);
    231        tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_);
    232        elements.push_back(tlist);
    233      } else if(className=="MissingET") {
    234        elist = new DelphesBranchElement<TEveElementList>(name,treeReader_->UseBranch(name),kViolet);
    235        elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    236        elements.push_back(elist);
    237      } else if(className=="GenParticle") {
    238        tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kCyan);
    239        tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    240        tlist->GetContainer()->SetRnrSelf(false);
    241        tlist->GetContainer()->SetRnrChildren(false);
    242        elements.push_back(tlist);
    243      } else {
    244        continue;
    245      }
    246    }
    247    // second loop for tracks
    248    for(Int_t b = 0; b<nBranches; ++b) {
    249      TString input = branches[b*3].GetString();
    250      TString name = branches[b*3+1].GetString();
    251      TString className = branches[b*3+2].GetString();
    252      if(className=="Track") {
    253        if(input.Contains("eflow",TString::kIgnoreCase) || name.Contains("eflow",TString::kIgnoreCase)) continue; //no eflow
    254        tlist = new DelphesBranchElement<TEveTrackList>(name,treeReader_->UseBranch(name),kBlue);
    255        tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
    256        elements.push_back(tlist);
    257      }
    258    }
     192void DelphesEventDisplay::readConfig(const char *configFile, std::vector<DelphesBranchBase *> &elements)
     193{
     194  ExRootConfReader *confReader = new ExRootConfReader;
     195  confReader->ReadFile(configFile);
     196  ExRootConfParam branches = confReader->GetParam("TreeWriter::Branch");
     197  Int_t nBranches = branches.GetSize() / 3;
     198  DelphesBranchElement<TEveTrackList> *tlist;
     199  DelphesBranchElement<DelphesCaloData> *clist;
     200  DelphesBranchElement<TEveElementList> *elist;
     201  // first loop with all but tracks
     202  for(Int_t b = 0; b < nBranches; ++b)
     203  {
     204    TString input = branches[b * 3].GetString();
     205    TString name = branches[b * 3 + 1].GetString();
     206    TString className = branches[b * 3 + 2].GetString();
     207    if(className == "Tower")
     208    {
     209      if(input.Contains("eflow", TString::kIgnoreCase) || name.Contains("eflow", TString::kIgnoreCase)) continue; //no eflow
     210      clist = new DelphesBranchElement<DelphesCaloData>(name, treeReader_->UseBranch(name), kBlack);
     211      clist->GetContainer()->SetEtaBins(etaAxis_);
     212      clist->GetContainer()->SetPhiBins(phiAxis_);
     213      elements.push_back(clist);
     214    }
     215    else if(className == "Jet")
     216    {
     217      if(input.Contains("GenJetFinder"))
     218      {
     219        elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kCyan);
     220        elist->GetContainer()->SetRnrSelf(false);
     221        elist->GetContainer()->SetRnrChildren(false);
     222        elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     223        elements.push_back(elist);
     224      }
     225      else
     226      {
     227        elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kYellow);
     228        elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     229        elements.push_back(elist);
     230      }
     231    }
     232    else if(className == "Electron")
     233    {
     234      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kRed);
     235      tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     236      elements.push_back(tlist);
     237    }
     238    else if(className == "Photon")
     239    {
     240      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kYellow);
     241      tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     242      elements.push_back(tlist);
     243    }
     244    else if(className == "Muon")
     245    {
     246      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kGreen);
     247      tlist->SetTrackingVolume(totRadius_, muHalfLength_, bz_);
     248      elements.push_back(tlist);
     249    }
     250    else if(className == "MissingET")
     251    {
     252      elist = new DelphesBranchElement<TEveElementList>(name, treeReader_->UseBranch(name), kViolet);
     253      elist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     254      elements.push_back(elist);
     255    }
     256    else if(className == "GenParticle")
     257    {
     258      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kCyan);
     259      tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     260      tlist->GetContainer()->SetRnrSelf(false);
     261      tlist->GetContainer()->SetRnrChildren(false);
     262      elements.push_back(tlist);
     263    }
     264    else
     265    {
     266      continue;
     267    }
     268  }
     269  // second loop for tracks
     270  for(Int_t b = 0; b < nBranches; ++b)
     271  {
     272    TString input = branches[b * 3].GetString();
     273    TString name = branches[b * 3 + 1].GetString();
     274    TString className = branches[b * 3 + 2].GetString();
     275    if(className == "Track")
     276    {
     277      if(input.Contains("eflow", TString::kIgnoreCase) || name.Contains("eflow", TString::kIgnoreCase)) continue; //no eflow
     278      tlist = new DelphesBranchElement<TEveTrackList>(name, treeReader_->UseBranch(name), kBlue);
     279      tlist->SetTrackingVolume(tkRadius_, tkHalfLength_, bz_);
     280      elements.push_back(tlist);
     281    }
     282  }
    259283}
    260284
    261285void DelphesEventDisplay::load_event()
    262286{
    263    // Load event specified in global event_id_.
    264    // The contents of previous event are removed.
    265 
    266    // safety
    267    if(event_id_ >= treeReader_->GetEntries() || event_id_<0 ) return;
    268 
    269    // message
    270    fStatusBar_->SetText(Form("Loading event %d.", event_id_), 1);
    271    gSystem->ProcessEvents();
    272 
    273    // clear the previous event
    274    gEve->GetViewers()->DeleteAnnotations();
    275    for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
    276      (*data)->Reset();
    277    }
    278 
    279    // Load selected branches with data from specified event
    280    treeReader_->ReadEntry(event_id_);
    281    for(std::vector<DelphesBranchBase*>::iterator data=elements_.begin();data<elements_.end();++data) {
    282      (*data)->ReadBranch();
    283    }
    284 
    285    // update display
    286    TEveElement *top = (TEveElement*)gEve->GetCurrentEvent();
    287    delphesDisplay_->DestroyEventRPhi();
    288    delphesDisplay_->ImportEventRPhi(top);
    289    delphesDisplay_->DestroyEventRhoZ();
    290    delphesDisplay_->ImportEventRhoZ(top);
    291    update_html_summary();
    292    plotSummary_->FillEvent();
    293    plotSummary_->Draw();
    294 
    295    gEve->Redraw3D(kFALSE, kTRUE);
    296    fStatusBar_->SetText(Form("Loaded event %d.", event_id_), 1);
    297    gSystem->ProcessEvents();
     287  // Load event specified in global event_id_.
     288  // The contents of previous event are removed.
     289
     290  // safety
     291  if(event_id_ >= treeReader_->GetEntries() || event_id_ < 0) return;
     292
     293  // message
     294  fStatusBar_->SetText(Form("Loading event %d.", event_id_), 1);
     295  gSystem->ProcessEvents();
     296
     297  // clear the previous event
     298  gEve->GetViewers()->DeleteAnnotations();
     299  for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data)
     300  {
     301    (*data)->Reset();
     302  }
     303
     304  // Load selected branches with data from specified event
     305  treeReader_->ReadEntry(event_id_);
     306  for(std::vector<DelphesBranchBase *>::iterator data = elements_.begin(); data < elements_.end(); ++data)
     307  {
     308    (*data)->ReadBranch();
     309  }
     310
     311  // update display
     312  TEveElement *top = (TEveElement *)gEve->GetCurrentEvent();
     313  delphesDisplay_->DestroyEventRPhi();
     314  delphesDisplay_->ImportEventRPhi(top);
     315  delphesDisplay_->DestroyEventRhoZ();
     316  delphesDisplay_->ImportEventRhoZ(top);
     317  update_html_summary();
     318  plotSummary_->FillEvent();
     319  plotSummary_->Draw();
     320
     321  gEve->Redraw3D(kFALSE, kTRUE);
     322  fStatusBar_->SetText(Form("Loaded event %d.", event_id_), 1);
     323  gSystem->ProcessEvents();
    298324}
    299325
    300326void DelphesEventDisplay::update_html_summary()
    301327{
    302    // Update summary of current event.
    303 
    304    TEveElement::List_i i;
    305    TEveElement::List_i j;
    306    Int_t k;
    307    TEveElement *el;
    308    DelphesHtmlObjTable *table;
    309    TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
    310    if (mgr) {
    311       htmlSummary_->Clear("D");
    312       for (i=mgr->BeginChildren(); i!=mgr->EndChildren(); ++i) {
    313          el = ((TEveElement*)(*i));
    314          if (el->IsA() == TEvePointSet::Class()) {
    315             TEvePointSet *ps = (TEvePointSet *)el;
    316             TString ename  = ps->GetElementName();
    317             TString etitle = ps->GetElementTitle();
    318             if (ename.First('\'') != kNPOS)
    319                ename.Remove(ename.First('\''));
    320             etitle.Remove(0, 2);
    321             Int_t nel = atoi(etitle.Data());
    322             table = htmlSummary_->AddTable(ename, 0, nel);
    323          }
    324          else if (el->IsA() == TEveTrackList::Class()) {
    325             TEveTrackList *tracks = (TEveTrackList *)el;
    326             TString ename  = tracks->GetElementName();
    327             if (ename.First('\'') != kNPOS)
    328                ename.Remove(ename.First('\''));
    329             table = htmlSummary_->AddTable(ename.Data(), 5,
    330                      tracks->NumChildren(), kTRUE, "first");
    331             table->SetLabel(0, "Momentum");
    332             table->SetLabel(1, "P_t");
    333             table->SetLabel(2, "Phi");
    334             table->SetLabel(3, "Theta");
    335             table->SetLabel(4, "Eta");
    336             k=0;
    337             for (j=tracks->BeginChildren(); j!=tracks->EndChildren(); ++j) {
    338                Float_t p     = ((TEveTrack*)(*j))->GetMomentum().Mag();
    339                table->SetValue(0, k, p);
    340                Float_t pt    = ((TEveTrack*)(*j))->GetMomentum().Perp();
    341                table->SetValue(1, k, pt);
    342                Float_t phi   = ((TEveTrack*)(*j))->GetMomentum().Phi();
    343                table->SetValue(2, k, phi);
    344                Float_t theta = ((TEveTrack*)(*j))->GetMomentum().Theta();
    345                table->SetValue(3, k, theta);
    346                Float_t eta   = theta>0.0005 && theta<3.1413 ? ((TEveTrack*)(*j))->GetMomentum().Eta() : 1e10;
    347                table->SetValue(4, k, eta);
    348                ++k;
    349             }
    350          }
     328  // Update summary of current event.
     329
     330  TEveElement::List_i i;
     331  TEveElement::List_i j;
     332  Int_t k;
     333  TEveElement *el;
     334  DelphesHtmlObjTable *table;
     335  TEveEventManager *mgr = gEve ? gEve->GetCurrentEvent() : 0;
     336  if(mgr)
     337  {
     338    htmlSummary_->Clear("D");
     339    for(i = mgr->BeginChildren(); i != mgr->EndChildren(); ++i)
     340    {
     341      el = ((TEveElement *)(*i));
     342      if(el->IsA() == TEvePointSet::Class())
     343      {
     344        TEvePointSet *ps = (TEvePointSet *)el;
     345        TString ename = ps->GetElementName();
     346        TString etitle = ps->GetElementTitle();
     347        if(ename.First('\'') != kNPOS)
     348          ename.Remove(ename.First('\''));
     349        etitle.Remove(0, 2);
     350        Int_t nel = atoi(etitle.Data());
     351        table = htmlSummary_->AddTable(ename, 0, nel);
    351352      }
    352       htmlSummary_->Build();
    353       gHtml_->Clear();
    354       gHtml_->ParseText((char*)htmlSummary_->Html().Data());
    355       gHtml_->Layout();
    356    }
    357  
     353      else if(el->IsA() == TEveTrackList::Class())
     354      {
     355        TEveTrackList *tracks = (TEveTrackList *)el;
     356        TString ename = tracks->GetElementName();
     357        if(ename.First('\'') != kNPOS)
     358          ename.Remove(ename.First('\''));
     359        table = htmlSummary_->AddTable(ename.Data(), 5,
     360          tracks->NumChildren(), kTRUE, "first");
     361        table->SetLabel(0, "Momentum");
     362        table->SetLabel(1, "P_t");
     363        table->SetLabel(2, "Phi");
     364        table->SetLabel(3, "Theta");
     365        table->SetLabel(4, "Eta");
     366        k = 0;
     367        for(j = tracks->BeginChildren(); j != tracks->EndChildren(); ++j)
     368        {
     369          Float_t p = ((TEveTrack *)(*j))->GetMomentum().Mag();
     370          table->SetValue(0, k, p);
     371          Float_t pt = ((TEveTrack *)(*j))->GetMomentum().Perp();
     372          table->SetValue(1, k, pt);
     373          Float_t phi = ((TEveTrack *)(*j))->GetMomentum().Phi();
     374          table->SetValue(2, k, phi);
     375          Float_t theta = ((TEveTrack *)(*j))->GetMomentum().Theta();
     376          table->SetValue(3, k, theta);
     377          Float_t eta = theta > 0.0005 && theta < 3.1413 ? ((TEveTrack *)(*j))->GetMomentum().Eta() : 1e10;
     378          table->SetValue(4, k, eta);
     379          ++k;
     380        }
     381      }
     382    }
     383    htmlSummary_->Build();
     384    gHtml_->Clear();
     385    gHtml_->ParseText((char *)htmlSummary_->Html().Data());
     386    gHtml_->Layout();
     387  }
    358388}
    359389
     
    364394void DelphesEventDisplay::make_gui()
    365395{
    366    // Create minimal GUI for event navigation.
    367 
    368    // add a tab on the left
    369    TEveBrowser *browser = gEve->GetBrowser();
    370    browser->SetWindowName("Delphes Event Display");
    371    browser->StartEmbedding(TRootBrowser::kLeft);
    372 
    373    // set the main title
    374    TGMainFrame *frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
    375    frmMain->SetWindowName("Delphes Event Display");
    376    frmMain->SetCleanup(kDeepCleanup);
    377 
    378    // build the navigation menu
    379    TString icondir;
    380    if(gSystem->Getenv("ROOTSYS"))
    381      icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS"));
    382    if(!gSystem->OpenDirectory(icondir))
    383      icondir = Form("%s/icons/", (const char*)gSystem->GetFromPipe("root-config --etcdir") );
    384    TGGroupFrame *vf = new TGGroupFrame(frmMain,"Event navigation",kVerticalFrame | kFitWidth );
    385    {
    386      TGHorizontalFrame *hf = new TGHorizontalFrame(frmMain);
    387      {
    388         TGPictureButton *b = 0;
    389 
    390         b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoBack.gif"));
    391         hf->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsCenterY , 10, 2, 10, 10));
    392         b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()");
    393 
    394         TGNumberEntry *numberEntry = new TGNumberEntry(hf,0,9,-1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, treeReader_->GetEntries());
    395         hf->AddFrame(numberEntry, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY , 2, 0, 10, 10));
    396         this->Connect("EventChanged(Int_t)","TGNumberEntry",numberEntry,"SetIntNumber(Long_t)");
    397         numberEntry->GetNumberEntry()->Connect("TextChanged(char*)", "DelphesEventDisplay", this, "PreSetEv(char*)");
    398         numberEntry->GetNumberEntry()->Connect("ReturnPressed()", "DelphesEventDisplay", this, "GoTo()");
    399        
    400         b = new TGPictureButton(hf, gClient->GetPicture(icondir+"GoForward.gif"));
    401         hf->AddFrame(b, new TGLayoutHints(kLHintsRight | kLHintsCenterY , 2, 10, 10, 10));
    402         b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()");
    403  
    404      }
    405      vf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX , 2, 2, 2, 2));
    406 
    407      TGHProgressBar *progress = new TGHProgressBar(frmMain, TGProgressBar::kFancy, 100);
    408      progress->SetMax( treeReader_->GetEntries());
    409      progress->ShowPosition(kTRUE, kFALSE, "Event %.0f");
    410      progress->SetBarColor("green");
    411      vf->AddFrame(progress, new TGLayoutHints(kLHintsExpandX, 10, 10, 5, 5));
    412      this->Connect("EventChanged(Int_t)","TGHProgressBar",progress,"SetPosition(Float_t)");
    413    }
    414    frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX , 5, 5, 5, 5));
    415    vf = new TGGroupFrame(frmMain,"Batch operations",kVerticalFrame | kFitWidth );
    416    {
    417         TGTextButton *b = new TGTextButton(vf, "Initialize Summary Plots");
    418         vf->AddFrame(b, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX, 10, 10, 10, 10));
    419         b->Connect("Clicked()", "DelphesEventDisplay", this, "InitSummaryPlots()");
    420    }
    421    frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX , 5, 5, 5, 5));
    422 
    423    frmMain->MapSubwindows();
    424    frmMain->Resize();
    425    frmMain->MapWindow();
    426    browser->StopEmbedding();
    427    browser->SetTabTitle("Event Control", 0);
    428 
    429    // the summary tab
    430    htmlSummary_ = new DelphesHtmlSummary("Delphes Event Display Summary Table");
    431    TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
    432    gHtml_ = new TGHtml(0, 100, 100);
    433    TEveWindowFrame *wf = slot->MakeFrame(gHtml_);
    434    gHtml_->MapSubwindows();
    435    wf->SetElementName("Summary tables");
    436 
    437    // plot tab
    438    slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
    439    TEveWindowTab *tab = slot->MakeTab();
    440    tab->SetElementName("Summary plots");
    441    tab->SetShowTitleBar(kFALSE);
    442    plotSummary_ = new DelphesPlotSummary(tab);
    443    plotSummary_->Init(elements_);
    444    plotSummary_->Connect("Progress(Int_t)", "DelphesEventDisplay", this, "DisplayProgress(Int_t)");
    445 
    446 }
    447 
    448 void DelphesEventDisplay::Fwd() { 
    449   if (event_id_ < treeReader_->GetEntries() - 2) {
    450      EventChanged(event_id_+1);
    451   } else {
    452      printf("Already at last event.\n");
    453   }
    454 }
    455 
    456 void DelphesEventDisplay::Bck() {
    457   if (event_id_ > 0) {
    458      EventChanged(event_id_-1);
    459   } else {
    460      printf("Already at first event.\n");
    461   }
    462 }
    463 
    464 void DelphesEventDisplay::PreSetEv(char *ev) {
     396  // Create minimal GUI for event navigation.
     397
     398  // add a tab on the left
     399  TEveBrowser *browser = gEve->GetBrowser();
     400  browser->SetWindowName("Delphes Event Display");
     401  browser->StartEmbedding(TRootBrowser::kLeft);
     402
     403  // set the main title
     404  TGMainFrame *frmMain = new TGMainFrame(gClient->GetRoot(), 1000, 600);
     405  frmMain->SetWindowName("Delphes Event Display");
     406  frmMain->SetCleanup(kDeepCleanup);
     407
     408  // build the navigation menu
     409  TString icondir;
     410  if(gSystem->Getenv("ROOTSYS"))
     411    icondir = Form("%s/icons/", gSystem->Getenv("ROOTSYS"));
     412  if(!gSystem->OpenDirectory(icondir))
     413    icondir = Form("%s/icons/", (const char *)gSystem->GetFromPipe("root-config --etcdir"));
     414  TGGroupFrame *vf = new TGGroupFrame(frmMain, "Event navigation", kVerticalFrame | kFitWidth);
     415  {
     416    TGHorizontalFrame *hf = new TGHorizontalFrame(frmMain);
     417    {
     418      TGPictureButton *b = 0;
     419
     420      b = new TGPictureButton(hf, gClient->GetPicture(icondir + "GoBack.gif"));
     421      hf->AddFrame(b, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 10, 10));
     422      b->Connect("Clicked()", "DelphesEventDisplay", this, "Bck()");
     423
     424      TGNumberEntry *numberEntry = new TGNumberEntry(hf, 0, 9, -1, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, treeReader_->GetEntries());
     425      hf->AddFrame(numberEntry, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 0, 10, 10));
     426      this->Connect("EventChanged(Int_t)", "TGNumberEntry", numberEntry, "SetIntNumber(Long_t)");
     427      numberEntry->GetNumberEntry()->Connect("TextChanged(char*)", "DelphesEventDisplay", this, "PreSetEv(char*)");
     428      numberEntry->GetNumberEntry()->Connect("ReturnPressed()", "DelphesEventDisplay", this, "GoTo()");
     429
     430      b = new TGPictureButton(hf, gClient->GetPicture(icondir + "GoForward.gif"));
     431      hf->AddFrame(b, new TGLayoutHints(kLHintsRight | kLHintsCenterY, 2, 10, 10, 10));
     432      b->Connect("Clicked()", "DelphesEventDisplay", this, "Fwd()");
     433    }
     434    vf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
     435
     436    TGHProgressBar *progress = new TGHProgressBar(frmMain, TGProgressBar::kFancy, 100);
     437    progress->SetMax(treeReader_->GetEntries());
     438    progress->ShowPosition(kTRUE, kFALSE, "Event %.0f");
     439    progress->SetBarColor("green");
     440    vf->AddFrame(progress, new TGLayoutHints(kLHintsExpandX, 10, 10, 5, 5));
     441    this->Connect("EventChanged(Int_t)", "TGHProgressBar", progress, "SetPosition(Float_t)");
     442  }
     443  frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
     444  vf = new TGGroupFrame(frmMain, "Batch operations", kVerticalFrame | kFitWidth);
     445  {
     446    TGTextButton *b = new TGTextButton(vf, "Initialize Summary Plots");
     447    vf->AddFrame(b, new TGLayoutHints(kLHintsCenterX | kLHintsCenterY | kLHintsExpandX, 10, 10, 10, 10));
     448    b->Connect("Clicked()", "DelphesEventDisplay", this, "InitSummaryPlots()");
     449  }
     450  frmMain->AddFrame(vf, new TGLayoutHints(kLHintsExpandX, 5, 5, 5, 5));
     451
     452  frmMain->MapSubwindows();
     453  frmMain->Resize();
     454  frmMain->MapWindow();
     455  browser->StopEmbedding();
     456  browser->SetTabTitle("Event Control", 0);
     457
     458  // the summary tab
     459  htmlSummary_ = new DelphesHtmlSummary("Delphes Event Display Summary Table");
     460  TEveWindowSlot *slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
     461  gHtml_ = new TGHtml(0, 100, 100);
     462  TEveWindowFrame *wf = slot->MakeFrame(gHtml_);
     463  gHtml_->MapSubwindows();
     464  wf->SetElementName("Summary tables");
     465
     466  // plot tab
     467  slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
     468  TEveWindowTab *tab = slot->MakeTab();
     469  tab->SetElementName("Summary plots");
     470  tab->SetShowTitleBar(kFALSE);
     471  plotSummary_ = new DelphesPlotSummary(tab);
     472  plotSummary_->Init(elements_);
     473  plotSummary_->Connect("Progress(Int_t)", "DelphesEventDisplay", this, "DisplayProgress(Int_t)");
     474}
     475
     476void DelphesEventDisplay::Fwd()
     477{
     478  if(event_id_ < treeReader_->GetEntries() - 2)
     479  {
     480    EventChanged(event_id_ + 1);
     481  }
     482  else
     483  {
     484    printf("Already at last event.\n");
     485  }
     486}
     487
     488void DelphesEventDisplay::Bck()
     489{
     490  if(event_id_ > 0)
     491  {
     492    EventChanged(event_id_ - 1);
     493  }
     494  else
     495  {
     496    printf("Already at first event.\n");
     497  }
     498}
     499
     500void DelphesEventDisplay::PreSetEv(char *ev)
     501{
    465502  event_id_tmp_ = Int_t(atoi(ev));
    466503}
    467504
    468 void DelphesEventDisplay::GoTo() {
    469   if (event_id_tmp_>=0 && event_id_tmp_ < treeReader_->GetEntries()-1) {
     505void DelphesEventDisplay::GoTo()
     506{
     507  if(event_id_tmp_ >= 0 && event_id_tmp_ < treeReader_->GetEntries() - 1)
     508  {
    470509    EventChanged(event_id_tmp_);
    471   } else {
     510  }
     511  else
     512  {
    472513    printf("Error: no such event.\n");
    473514  }
    474515}
    475516
    476 void DelphesEventDisplay::InitSummaryPlots() {
     517void DelphesEventDisplay::InitSummaryPlots()
     518{
    477519  plotSummary_->FillSample(treeReader_, event_id_);
    478520  plotSummary_->FillEvent();
     
    480522}
    481523
    482 void DelphesEventDisplay::DisplayProgress(Int_t p) {
    483   fStatusBar_->SetText(Form("Processing... %d %%",p), 1);
     524void DelphesEventDisplay::DisplayProgress(Int_t p)
     525{
     526  fStatusBar_->SetText(Form("Processing... %d %%", p), 1);
    484527  gSystem->ProcessEvents();
    485528}
  • display/DelphesEventDisplay.h

    re39abb4 r0e7d64a  
    2222#include <vector>
    2323
     24#include "RQ_OBJECT.h"
    2425#include "Rtypes.h"
    25 #include "RQ_OBJECT.h"
    2626
    2727class TAxis;
     
    4545class DelphesEventDisplay
    4646{
    47     RQ_OBJECT("DelphesEventDisplay")
    48   public:
    49     DelphesEventDisplay();
    50     DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry& det3D);
    51     ~DelphesEventDisplay();
    52     void EventChanged(Int_t); // *SIGNAL*
     47  RQ_OBJECT("DelphesEventDisplay")
     48public:
     49  DelphesEventDisplay();
     50  DelphesEventDisplay(const char *configFile, const char *inputFile, Delphes3DGeometry &det3D);
     51  ~DelphesEventDisplay();
     52  void EventChanged(Int_t); // *SIGNAL*
    5353
    54   private:
    55     void update_html_summary();
    56     void make_gui();
    57     void load_event();
    58     void readConfig(const char *configFile, std::vector<DelphesBranchBase *>& elements);
     54private:
     55  void update_html_summary();
     56  void make_gui();
     57  void load_event();
     58  void readConfig(const char *configFile, std::vector<DelphesBranchBase *> &elements);
    5959
    60     // Configuration and global variables.
    61     Int_t event_id_;
    62     Int_t event_id_tmp_;
    63     ExRootTreeReader *treeReader_;
    64     Double_t tkRadius_, totRadius_, tkHalfLength_, muHalfLength_, bz_;
    65     TAxis *etaAxis_, *phiAxis_;
    66     TChain *chain_;
    67     std::vector<DelphesBranchBase *> elements_;
    68     DelphesDisplay *delphesDisplay_;
    69     DelphesHtmlSummary *htmlSummary_;
    70     TGHtml *gHtml_;
    71     DelphesPlotSummary *plotSummary_;
    72     TGStatusBar *fStatusBar_;
    73    
    74     // gui controls
    75   public:
    76      void Fwd();
     60  // Configuration and global variables.
     61  Int_t event_id_;
     62  Int_t event_id_tmp_;
     63  ExRootTreeReader *treeReader_;
     64  Double_t tkRadius_, totRadius_, tkHalfLength_, muHalfLength_, bz_;
     65  TAxis *etaAxis_, *phiAxis_;
     66  TChain *chain_;
     67  std::vector<DelphesBranchBase *> elements_;
     68  DelphesDisplay *delphesDisplay_;
     69  DelphesHtmlSummary *htmlSummary_;
     70  TGHtml *gHtml_;
     71  DelphesPlotSummary *plotSummary_;
     72  TGStatusBar *fStatusBar_;
    7773
    78      void Bck();
     74  // gui controls
     75public:
     76  void Fwd();
    7977
    80     void PreSetEv(char *ev);
     78  void Bck();
    8179
    82     void GoTo();
     80  void PreSetEv(char *ev);
    8381
    84     void InitSummaryPlots();
     82  void GoTo();
    8583
    86     void DisplayProgress(Int_t p);
     84  void InitSummaryPlots();
     85
     86  void DisplayProgress(Int_t p);
    8787};
    8888
  • display/DelphesHtmlSummary.cc

    re39abb4 r0e7d64a  
    1818
    1919#include "display/DelphesHtmlSummary.h"
    20 #include "TGHtml.h"
    2120#include "TEveElement.h"
     21#include "TEveEventManager.h"
    2222#include "TEveManager.h"
    23 #include "TEveEventManager.h"
    2423#include "TEvePointSet.h"
    2524#include "TEveTrack.h"
     25#include "TGHtml.h"
    2626
    2727//==============================================================================
    2828
    2929DelphesHtmlSummary *fgDelphesHtmlSummary = 0;
    30 TGHtml      *fgHtml        = 0;
     30TGHtml *fgHtml = 0;
    3131
    3232//==============================================================================
    3333
    3434//______________________________________________________________________________
    35 DelphesHtmlObjTable::DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) : 
    36    fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
    37 {
    38    // Constructor.
    39 
    40    fValues = new TArrayF[fNFields];
    41    for (int i=0;i<fNFields;i++)
    42       fValues[i].Set(nvals);
    43    fLabels = new TString[fNFields];
     35DelphesHtmlObjTable::DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp) :
     36  fName(name), fNValues(nvals), fNFields(nfields), fExpand(exp)
     37{
     38  // Constructor.
     39
     40  fValues = new TArrayF[fNFields];
     41  for(int i = 0; i < fNFields; i++)
     42    fValues[i].Set(nvals);
     43  fLabels = new TString[fNFields];
    4444}
    4545
     
    4747DelphesHtmlObjTable::~DelphesHtmlObjTable()
    4848{
    49    // Destructor.
    50 
    51    delete [] fValues;
    52    delete [] fLabels;
     49  // Destructor.
     50
     51  delete[] fValues;
     52  delete[] fLabels;
    5353}
    5454
     
    5656void DelphesHtmlObjTable::Build()
    5757{
    58    // Build HTML code.
    59 
    60    fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
    61 
    62    BuildTitle();
    63    if (fExpand && (fNFields > 0) && (fNValues > 0)) {
    64       BuildLabels();
    65       BuildTable();
    66    }
    67 
    68    fHtml += "</table>";
     58  // Build HTML code.
     59
     60  fHtml = "<table width=100% border=1 cellspacing=0 cellpadding=0 bgcolor=f0f0f0> ",
     61
     62  BuildTitle();
     63  if(fExpand && (fNFields > 0) && (fNValues > 0))
     64  {
     65    BuildLabels();
     66    BuildTable();
     67  }
     68
     69  fHtml += "</table>";
    6970}
    7071
     
    7273void DelphesHtmlObjTable::BuildTitle()
    7374{
    74    // Build table title.
    75    
    76    fHtml += "<tr><td colspan=";
    77    fHtml += Form("%d>", fNFields+1);
    78    fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
    79    fHtml += "<tr><td align=left>";
    80    fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
    81    fHtml += fName;
    82    fHtml += "</i></b></font></td>";
    83    fHtml += "<td>";
    84    fHtml += "<td align=right> ";
    85    fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
    86    fHtml += Form("Size = %d", fNValues);
    87    fHtml += "</i></b></font></td></tr>";
    88    fHtml += "</table>";
    89    fHtml += "</td></tr>";
     75  // Build table title.
     76
     77  fHtml += "<tr><td colspan=";
     78  fHtml += Form("%d>", fNFields + 1);
     79  fHtml += "<table width=100% border=0 cellspacing=2 cellpadding=0 bgcolor=6e6ea0>";
     80  fHtml += "<tr><td align=left>";
     81  fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
     82  fHtml += fName;
     83  fHtml += "</i></b></font></td>";
     84  fHtml += "<td>";
     85  fHtml += "<td align=right> ";
     86  fHtml += "<font face=Verdana size=3 color=ffffff><b><i>";
     87  fHtml += Form("Size = %d", fNValues);
     88  fHtml += "</i></b></font></td></tr>";
     89  fHtml += "</table>";
     90  fHtml += "</td></tr>";
    9091}
    9192
     
    9394void DelphesHtmlObjTable::BuildLabels()
    9495{
    95    // Build table labels.
    96 
    97    Int_t i;
    98    fHtml += "<tr bgcolor=c0c0ff>";
    99    fHtml += "<th> </th>"; // for the check boxes
    100    for (i=0;i<fNFields;i++) {
    101       fHtml += "<th> ";
    102       fHtml += fLabels[i];
    103       fHtml += " </th>"; // for the check boxes
    104    }
    105    fHtml += "</tr>";
     96  // Build table labels.
     97
     98  Int_t i;
     99  fHtml += "<tr bgcolor=c0c0ff>";
     100  fHtml += "<th> </th>"; // for the check boxes
     101  for(i = 0; i < fNFields; i++)
     102  {
     103    fHtml += "<th> ";
     104    fHtml += fLabels[i];
     105    fHtml += " </th>"; // for the check boxes
     106  }
     107  fHtml += "</tr>";
    106108}
    107109
     
    109111void DelphesHtmlObjTable::BuildTable()
    110112{
    111    // Build part of table with values.
    112 
    113    for (int i = 0; i < fNValues; i++) {
    114       if (i%2)
    115          fHtml += "<tr bgcolor=e0e0ff>";
    116       else
    117          fHtml += "<tr bgcolor=ffffff>";
    118      
    119       TString name = fName;
    120       name.ReplaceAll(" ", "_");
    121       // checkboxes
    122       fHtml += "<td bgcolor=d0d0ff align=\"center\">";
    123       fHtml += "<input type=\"checkbox\" name=\"";
    124       fHtml += name;
    125       fHtml += Form("[%d]\">",i);
     113  // Build part of table with values.
     114
     115  for(int i = 0; i < fNValues; i++)
     116  {
     117    if(i % 2)
     118      fHtml += "<tr bgcolor=e0e0ff>";
     119    else
     120      fHtml += "<tr bgcolor=ffffff>";
     121
     122    TString name = fName;
     123    name.ReplaceAll(" ", "_");
     124    // checkboxes
     125    fHtml += "<td bgcolor=d0d0ff align=\"center\">";
     126    fHtml += "<input type=\"checkbox\" name=\"";
     127    fHtml += name;
     128    fHtml += Form("[%d]\">", i);
     129    fHtml += "</td>";
     130
     131    for(int j = 0; j < fNFields; j++)
     132    {
     133      fHtml += "<td width=";
     134      fHtml += Form("%d%%", 100 / fNFields);
     135      fHtml += " align=\"center\"";
     136      fHtml += ">";
     137      fHtml += Form("%1.4f", fValues[j][i]);
    126138      fHtml += "</td>";
    127 
    128       for (int j = 0; j < fNFields; j++) {
    129          fHtml += "<td width=";
    130          fHtml += Form("%d%%", 100/fNFields);
    131          fHtml += " align=\"center\"";
    132          fHtml += ">";
    133          fHtml += Form("%1.4f", fValues[j][i]);
    134          fHtml += "</td>";
    135       }
    136       fHtml += "</tr> ";
    137    }
    138 }
    139 
    140 //______________________________________________________________________________
    141 DelphesHtmlSummary::DelphesHtmlSummary(const char *title) : fNTables(0), fTitle(title)
    142 {
    143    // Constructor.
    144 
    145    fObjTables = new TOrdCollection();
     139    }
     140    fHtml += "</tr> ";
     141  }
     142}
     143
     144//______________________________________________________________________________
     145DelphesHtmlSummary::DelphesHtmlSummary(const char *title) :
     146  fNTables(0), fTitle(title)
     147{
     148  // Constructor.
     149
     150  fObjTables = new TOrdCollection();
    146151}
    147152
     
    149154DelphesHtmlSummary::~DelphesHtmlSummary()
    150155{
    151    // Destructor.
    152 
    153    Reset();
     156  // Destructor.
     157
     158  Reset();
    154159}
    155160
    156161//______________________________________________________________________________
    157162DelphesHtmlObjTable *DelphesHtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals,
    158                                     Bool_t exp, Option_t *option)
    159 {
    160    // Add a new table in our list of tables.
    161 
    162    TString opt = option;
    163    opt.ToLower();
    164    DelphesHtmlObjTable *table = new DelphesHtmlObjTable(name, nfields, nvals, exp);
    165    fNTables++;
    166    if (opt.Contains("first"))
    167       fObjTables->AddFirst(table);
    168    else
    169       fObjTables->Add(table);
    170    return table;
     163  Bool_t exp, Option_t *option)
     164{
     165  // Add a new table in our list of tables.
     166
     167  TString opt = option;
     168  opt.ToLower();
     169  DelphesHtmlObjTable *table = new DelphesHtmlObjTable(name, nfields, nvals, exp);
     170  fNTables++;
     171  if(opt.Contains("first"))
     172    fObjTables->AddFirst(table);
     173  else
     174    fObjTables->Add(table);
     175  return table;
    171176}
    172177
     
    174179void DelphesHtmlSummary::Clear(Option_t *option)
    175180{
    176    // Clear the table list.
    177 
    178    if (option && option[0] == 'D')
    179       fObjTables->Delete(option);
    180    else
    181       fObjTables->Clear(option);
    182    fNTables = 0;
     181  // Clear the table list.
     182
     183  if(option && option[0] == 'D')
     184    fObjTables->Delete(option);
     185  else
     186    fObjTables->Clear(option);
     187  fNTables = 0;
    183188}
    184189
     
    186191void DelphesHtmlSummary::Reset(Option_t *)
    187192{
    188    // Reset (delete) the table list;
    189 
    190    delete fObjTables; fObjTables = 0;
    191    fNTables = 0;
     193  // Reset (delete) the table list;
     194
     195  delete fObjTables;
     196  fObjTables = 0;
     197  fNTables = 0;
    192198}
    193199
     
    195201void DelphesHtmlSummary::Build()
    196202{
    197    // Build the summary.
    198 
    199    MakeHeader();
    200    for (int i=0;i<fNTables;i++) {
    201       GetTable(i)->Build();
    202       fHtml += GetTable(i)->Html();
    203    }
    204    MakeFooter();
     203  // Build the summary.
     204
     205  MakeHeader();
     206  for(int i = 0; i < fNTables; i++)
     207  {
     208    GetTable(i)->Build();
     209    fHtml += GetTable(i)->Html();
     210  }
     211  MakeFooter();
    205212}
    206213
     
    208215void DelphesHtmlSummary::MakeHeader()
    209216{
    210    // Make HTML header.
    211 
    212    fHeader = "<html><head><title>";
    213    fHeader += fTitle;
    214    fHeader += "</title></head><body>";
    215    fHeader += "<center><h2><font color=#2222ee><i>";
    216    fHeader += fTitle;
    217    fHeader += "</i></font></h2></center>";
    218    fHtml    = fHeader;
     217  // Make HTML header.
     218
     219  fHeader = "<html><head><title>";
     220  fHeader += fTitle;
     221  fHeader += "</title></head><body>";
     222  fHeader += "<center><h2><font color=#2222ee><i>";
     223  fHeader += fTitle;
     224  fHeader += "</i></font></h2></center>";
     225  fHtml = fHeader;
    219226}
    220227
     
    222229void DelphesHtmlSummary::MakeFooter()
    223230{
    224    // Make HTML footer.
    225 
    226    fFooter  = "<br><p><br><center><strong><font size=2 color=#2222ee>";
    227    fFooter += "Example of using Html widget to display tabular data";
    228    fFooter += "<br>";
    229    fFooter += "(c) 2007-2010 Bertrand Bellenot";
    230    fFooter += "</font></strong></center></body></html>"; 
    231    fHtml   += fFooter;
    232 }
    233 
     231  // Make HTML footer.
     232
     233  fFooter = "<br><p><br><center><strong><font size=2 color=#2222ee>";
     234  fFooter += "Example of using Html widget to display tabular data";
     235  fFooter += "<br>";
     236  fFooter += "(c) 2007-2010 Bertrand Bellenot";
     237  fFooter += "</font></strong></center></body></html>";
     238  fHtml += fFooter;
     239}
  • display/DelphesHtmlSummary.h

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 // Delphes HTML table for the event display. 
     19// Delphes HTML table for the event display.
    2020// Based on the ROOT example "alice_esd_html_summary.C"
    2121
    2222#ifndef DelphesHtmlSummary_h
    23 #define DelphesHtmlSummary_h 
     23#define DelphesHtmlSummary_h
    2424
    2525#include "TArrayF.h"
    2626#include "TOrdCollection.h"
    2727
     28class DelphesHtmlObjTable: public TObject
     29{
     30public: // make them public for shorter code
     31  TString fName;
     32  Int_t fNValues; // number of values
     33  Int_t fNFields; // number of fields
     34  TArrayF *fValues;
     35  TString *fLabels;
     36  Bool_t fExpand;
    2837
    29 class DelphesHtmlObjTable : public TObject
    30 {
    31 public:                     // make them public for shorter code
     38  TString fHtml; // HTML output code
    3239
    33    TString   fName;
    34    Int_t     fNValues;      // number of values
    35    Int_t     fNFields;      // number of fields
    36    TArrayF  *fValues;
    37    TString  *fLabels;
    38    Bool_t    fExpand;
    39 
    40    TString   fHtml;         // HTML output code
    41 
    42    void Build();
    43    void BuildTitle();
    44    void BuildLabels();
    45    void BuildTable();
     40  void Build();
     41  void BuildTitle();
     42  void BuildLabels();
     43  void BuildTable();
    4644
    4745public:
    48    DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp=kTRUE);
    49    virtual ~DelphesHtmlObjTable();
     46  DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp = kTRUE);
     47  virtual ~DelphesHtmlObjTable();
    5048
    51    void    SetLabel(Int_t col, const char *label) { fLabels[col] = label; }
    52    void    SetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); }
    53    TString Html() const { return fHtml; }
     49  void SetLabel(Int_t col, const char *label) { fLabels[col] = label; }
     50  void SetValue(Int_t col, Int_t row, Float_t val) { fValues[col].SetAt(val, row); }
     51  TString Html() const { return fHtml; }
    5452
    55    ClassDef(DelphesHtmlObjTable, 0);
     53  ClassDef(DelphesHtmlObjTable, 0);
    5654};
    5755
     
    6058class DelphesHtmlSummary
    6159{
    62 public:                           // make them public for shorter code
    63    Int_t          fNTables;
    64    TOrdCollection *fObjTables;    // ->array of object tables
    65    TString         fHtml;        // output HTML string
    66    TString         fTitle;        // page title
    67    TString         fHeader;      // HTML header
    68    TString         fFooter;      // HTML footer
     60public: // make them public for shorter code
     61  Int_t fNTables;
     62  TOrdCollection *fObjTables; // ->array of object tables
     63  TString fHtml; // output HTML string
     64  TString fTitle; // page title
     65  TString fHeader; // HTML header
     66  TString fFooter; // HTML footer
    6967
    70    void    MakeHeader();
    71    void    MakeFooter();
     68  void MakeHeader();
     69  void MakeFooter();
    7270
    7371public:
    74    DelphesHtmlSummary(const char *title);
    75    virtual ~DelphesHtmlSummary();
     72  DelphesHtmlSummary(const char *title);
     73  virtual ~DelphesHtmlSummary();
    7674
    77    DelphesHtmlObjTable  *AddTable(const char *name, Int_t nfields, Int_t nvals,
    78                            Bool_t exp=kTRUE, Option_t *opt="");
    79    DelphesHtmlObjTable *GetTable(Int_t at) const { return (DelphesHtmlObjTable *)fObjTables->At(at); }
    80    void          Build();
    81    void           Clear(Option_t *option="");
    82    void           Reset(Option_t *option="");
    83    TString        Html() const { return fHtml; }
     75  DelphesHtmlObjTable *AddTable(const char *name, Int_t nfields, Int_t nvals,
     76    Bool_t exp = kTRUE, Option_t *opt = "");
     77  DelphesHtmlObjTable *GetTable(Int_t at) const { return (DelphesHtmlObjTable *)fObjTables->At(at); }
     78  void Build();
     79  void Clear(Option_t *option = "");
     80  void Reset(Option_t *option = "");
     81  TString Html() const { return fHtml; }
    8482
    85    ClassDef(DelphesHtmlSummary, 0);
     83  ClassDef(DelphesHtmlSummary, 0);
    8684};
    8785
  • display/DelphesPlotSummary.cc

    re39abb4 r0e7d64a  
    2121#include <algorithm>
    2222
    23 bool vecsorter (TLorentzVector i,TLorentzVector j) { return (i.Pt()>j.Pt()); }
    24 
    25 DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab* tab):tab_(tab) {}
     23bool vecsorter(TLorentzVector i, TLorentzVector j) { return (i.Pt() > j.Pt()); }
     24
     25DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab *tab) :
     26  tab_(tab) {}
    2627
    2728DelphesPlotSummary::~DelphesPlotSummary() {}
     
    2930void DelphesPlotSummary::Progress(Int_t p)
    3031{
    31   Emit("Progress(Int_t)",p);
    32 }
    33 
    34 void DelphesPlotSummary::Init(std::vector<DelphesBranchBase*>& elements) {
     32  Emit("Progress(Int_t)", p);
     33}
     34
     35void DelphesPlotSummary::Init(std::vector<DelphesBranchBase *> &elements)
     36{
    3537  elements_ = &elements;
    3638  // loop on the elements, and create tabs
    37   for(std::vector<DelphesBranchBase*>::iterator data=elements.begin();data<elements.end();++data) {
     39  for(std::vector<DelphesBranchBase *>::iterator data = elements.begin(); data < elements.end(); ++data)
     40  {
    3841    // the canvas
    39     TEveWindowSlot* slot = tab_->NewSlot();
    40     TRootEmbeddedCanvas* trec = new TRootEmbeddedCanvas();
    41     TCanvas* canvas = trec->GetCanvas();
    42     TEveWindowFrame * wf = slot->MakeFrame(trec);
     42    TEveWindowSlot *slot = tab_->NewSlot();
     43    TRootEmbeddedCanvas *trec = new TRootEmbeddedCanvas();
     44    TCanvas *canvas = trec->GetCanvas();
     45    TEveWindowFrame *wf = slot->MakeFrame(trec);
    4346    wf->SetElementName((*data)->GetName());
    44     canvas->Divide(3,3);
     47    canvas->Divide(3, 3);
    4548    canvases_[(*data)->GetName()] = canvas;
    4649    // the histograms
    47     TH1F* h;
    48     std::vector<TH1F*> histograms;
     50    TH1F *h;
     51    std::vector<TH1F *> histograms;
    4952    histograms.reserve(9);
    50     h = new TH1F(Form("%sPt",(*data)->GetName()),Form("%s Pt",(*data)->GetName()),100,0,-1);
    51     histograms.push_back(h);
    52     h = new TH1F(Form("%sEta",(*data)->GetName()),Form("%s Eta",(*data)->GetName()),100,0,-1);
    53     histograms.push_back(h);
    54     h = new TH1F(Form("%sPhi",(*data)->GetName()),Form("%s Phi",(*data)->GetName()),100,0,-1);
    55     histograms.push_back(h);
    56     h = new TH1F(Form("l%sPt",(*data)->GetName()),Form("leading %s Pt",(*data)->GetName()),100,0,-1);
    57     histograms.push_back(h);
    58     h = new TH1F(Form("l%sEta",(*data)->GetName()),Form("leading %s Eta",(*data)->GetName()),100,0,-1);
    59     histograms.push_back(h);
    60     h = new TH1F(Form("l%sPhi",(*data)->GetName()),Form("leading %s Phi",(*data)->GetName()),100,0,-1);
    61     histograms.push_back(h);
    62     h = new TH1F(Form("sl%sPt",(*data)->GetName()),Form("subleading %s Pt",(*data)->GetName()),100,0,-1);
    63     histograms.push_back(h);
    64     h = new TH1F(Form("sl%sEta",(*data)->GetName()),Form("subleading %s Eta",(*data)->GetName()),100,0,-1);
    65     histograms.push_back(h);
    66     h = new TH1F(Form("sl%sPhi",(*data)->GetName()),Form("subleading %s Phi",(*data)->GetName()),100,0,-1);
     53    h = new TH1F(Form("%sPt", (*data)->GetName()), Form("%s Pt", (*data)->GetName()), 100, 0, -1);
     54    histograms.push_back(h);
     55    h = new TH1F(Form("%sEta", (*data)->GetName()), Form("%s Eta", (*data)->GetName()), 100, 0, -1);
     56    histograms.push_back(h);
     57    h = new TH1F(Form("%sPhi", (*data)->GetName()), Form("%s Phi", (*data)->GetName()), 100, 0, -1);
     58    histograms.push_back(h);
     59    h = new TH1F(Form("l%sPt", (*data)->GetName()), Form("leading %s Pt", (*data)->GetName()), 100, 0, -1);
     60    histograms.push_back(h);
     61    h = new TH1F(Form("l%sEta", (*data)->GetName()), Form("leading %s Eta", (*data)->GetName()), 100, 0, -1);
     62    histograms.push_back(h);
     63    h = new TH1F(Form("l%sPhi", (*data)->GetName()), Form("leading %s Phi", (*data)->GetName()), 100, 0, -1);
     64    histograms.push_back(h);
     65    h = new TH1F(Form("sl%sPt", (*data)->GetName()), Form("subleading %s Pt", (*data)->GetName()), 100, 0, -1);
     66    histograms.push_back(h);
     67    h = new TH1F(Form("sl%sEta", (*data)->GetName()), Form("subleading %s Eta", (*data)->GetName()), 100, 0, -1);
     68    histograms.push_back(h);
     69    h = new TH1F(Form("sl%sPhi", (*data)->GetName()), Form("subleading %s Phi", (*data)->GetName()), 100, 0, -1);
    6770    histograms.push_back(h);
    6871    histograms_[(*data)->GetName()] = histograms;
    6972    // the event histograms
    70     TH1F* h1 = (TH1F*)histograms[0]->Clone(); h1->Reset(); h1->SetLineColor(kBlue);
    71     TH1F* h2 = (TH1F*)histograms[1]->Clone(); h2->Reset(); h2->SetLineColor(kBlue);
    72     TH1F* h3 = (TH1F*)histograms[2]->Clone(); h3->Reset(); h3->SetLineColor(kBlue);
    73     std::vector<TH1F*> hv;
     73    TH1F *h1 = (TH1F *)histograms[0]->Clone();
     74    h1->Reset();
     75    h1->SetLineColor(kBlue);
     76    TH1F *h2 = (TH1F *)histograms[1]->Clone();
     77    h2->Reset();
     78    h2->SetLineColor(kBlue);
     79    TH1F *h3 = (TH1F *)histograms[2]->Clone();
     80    h3->Reset();
     81    h3->SetLineColor(kBlue);
     82    std::vector<TH1F *> hv;
    7483    hv.push_back(h1);
    7584    hv.push_back(h2);
     
    7887    // the event markers
    7988    TMarker *m;
    80     std::vector<TMarker*> mv;
    81     m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    82     mv.push_back(m);
    83     m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    84     mv.push_back(m);
    85     m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    86     mv.push_back(m);
    87     m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    88     mv.push_back(m);
    89     m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    90     mv.push_back(m);
    91     m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
     89    std::vector<TMarker *> mv;
     90    m = new TMarker(0, 0, 29);
     91    m->SetMarkerColor(kBlue);
     92    m->SetMarkerSize(3);
     93    mv.push_back(m);
     94    m = new TMarker(0, 0, 29);
     95    m->SetMarkerColor(kBlue);
     96    m->SetMarkerSize(3);
     97    mv.push_back(m);
     98    m = new TMarker(0, 0, 29);
     99    m->SetMarkerColor(kBlue);
     100    m->SetMarkerSize(3);
     101    mv.push_back(m);
     102    m = new TMarker(0, 0, 29);
     103    m->SetMarkerColor(kBlue);
     104    m->SetMarkerSize(3);
     105    mv.push_back(m);
     106    m = new TMarker(0, 0, 29);
     107    m->SetMarkerColor(kBlue);
     108    m->SetMarkerSize(3);
     109    mv.push_back(m);
     110    m = new TMarker(0, 0, 29);
     111    m->SetMarkerColor(kBlue);
     112    m->SetMarkerSize(3);
    92113    mv.push_back(m);
    93114    eventMarkers_[(*data)->GetName()] = mv;
     
    95116}
    96117
    97 void DelphesPlotSummary::FillSample(ExRootTreeReader* treeReader, Int_t event_id) {
     118void DelphesPlotSummary::FillSample(ExRootTreeReader *treeReader, Int_t event_id)
     119{
    98120  Int_t entries = treeReader->GetEntries();
    99   for(Int_t i=0;i<entries;++i) {
     121  for(Int_t i = 0; i < entries; ++i)
     122  {
    100123    treeReader->ReadEntry(i);
    101     for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) {
     124    for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element)
     125    {
    102126      std::vector<TLorentzVector> vectors = (*element)->GetVectors();
    103       std::sort(vectors.begin(), vectors.end(), vecsorter);
    104       std::vector<TH1F*> histograms = histograms_[(*element)->GetName()];
    105       for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) {
     127      std::sort(vectors.begin(), vectors.end(), vecsorter);
     128      std::vector<TH1F *> histograms = histograms_[(*element)->GetName()];
     129      for(std::vector<TLorentzVector>::iterator it = vectors.begin(); it < vectors.end(); ++it)
     130      {
    106131        histograms[0]->Fill(it->Pt());
    107132        histograms[1]->Fill(it->Eta());
    108133        histograms[2]->Fill(it->Phi());
    109         if(it==vectors.begin()) {
     134        if(it == vectors.begin())
     135        {
    110136          histograms[3]->Fill(it->Pt());
    111137          histograms[4]->Fill(it->Eta());
    112138          histograms[5]->Fill(it->Phi());
    113139        }
    114         if(it==vectors.begin()+1) {
     140        if(it == vectors.begin() + 1)
     141        {
    115142          histograms[6]->Fill(it->Pt());
    116143          histograms[7]->Fill(it->Eta());
     
    119146      }
    120147    }
    121     Progress(int(100*i/entries));
     148    Progress(int(100 * i / entries));
    122149  }
    123150  treeReader->ReadEntry(event_id);
     
    125152}
    126153
    127 void DelphesPlotSummary::Draw() {
    128   for(std::map< TString, TCanvas* >::iterator it=canvases_.begin(); it!=canvases_.end(); ++it) {
    129     TCanvas* c = it->second;
    130     std::vector<TH1F*> histograms = histograms_[it->first];
    131     std::vector<TH1F*> eventProfiles = eventProfiles_[it->first];
    132     std::vector<TMarker*> eventMarkers = eventMarkers_[it->first];
    133     for(Int_t i=0;i<9;++i) {
    134       c->cd(i+1);
    135       if(histograms[i]->GetEntries()==0) continue;
     154void DelphesPlotSummary::Draw()
     155{
     156  for(std::map<TString, TCanvas *>::iterator it = canvases_.begin(); it != canvases_.end(); ++it)
     157  {
     158    TCanvas *c = it->second;
     159    std::vector<TH1F *> histograms = histograms_[it->first];
     160    std::vector<TH1F *> eventProfiles = eventProfiles_[it->first];
     161    std::vector<TMarker *> eventMarkers = eventMarkers_[it->first];
     162    for(Int_t i = 0; i < 9; ++i)
     163    {
     164      c->cd(i + 1);
     165      if(histograms[i]->GetEntries() == 0) continue;
    136166      histograms[i]->Draw();
    137       if(i<3) {
     167      if(i < 3)
     168      {
    138169        eventProfiles[i]->Draw("same");
    139       } else {
    140         eventMarkers[i-3]->Draw("same");
     170      }
     171      else
     172      {
     173        eventMarkers[i - 3]->Draw("same");
    141174      }
    142175    }
    143176    c->Update();
    144   }
    145 }
    146 
    147 void DelphesPlotSummary::FillEvent() {
     177  }
     178}
     179
     180void DelphesPlotSummary::FillEvent()
     181{
    148182  // clear event histograms and markers
    149   for(std::map< TString, std::vector<TH1F*> >::iterator hv = eventProfiles_.begin(); hv!=eventProfiles_.end();++hv) {
    150     for(std::vector<TH1F*>::iterator h = hv->second.begin(); h<hv->second.end();++h) {
     183  for(std::map<TString, std::vector<TH1F *> >::iterator hv = eventProfiles_.begin(); hv != eventProfiles_.end(); ++hv)
     184  {
     185    for(std::vector<TH1F *>::iterator h = hv->second.begin(); h < hv->second.end(); ++h)
     186    {
    151187      (*h)->Reset();
    152188    }
    153189  }
    154   for(std::map< TString, std::vector<TMarker*> >::iterator mv = eventMarkers_.begin(); mv!=eventMarkers_.end();++mv) {
    155     for(std::vector<TMarker*>::iterator m = mv->second.begin(); m<mv->second.end();++m) {
     190  for(std::map<TString, std::vector<TMarker *> >::iterator mv = eventMarkers_.begin(); mv != eventMarkers_.end(); ++mv)
     191  {
     192    for(std::vector<TMarker *>::iterator m = mv->second.begin(); m < mv->second.end(); ++m)
     193    {
    156194      (*m)->SetMarkerSize(0);
    157195    }
    158196  }
    159197  // loop over the elements and fill markers with event data
    160   for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) {
     198  for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element)
     199  {
    161200    std::vector<TLorentzVector> vectors = (*element)->GetVectors();
    162     std::sort(vectors.begin(), vectors.end(), vecsorter);
    163     std::vector<TH1F*> hv = eventProfiles_[(*element)->GetName()];
    164     TH1F* h1 = hv[0]; h1->Reset();
    165     TH1F* h2 = hv[1]; h1->Reset();
    166     TH1F* h3 = hv[2]; h1->Reset();
    167     std::vector<TMarker*> mv = eventMarkers_[(*element)->GetName()];
    168     for(std::vector<TLorentzVector>::iterator it=vectors.begin(); it<vectors.end();++it) {
     201    std::sort(vectors.begin(), vectors.end(), vecsorter);
     202    std::vector<TH1F *> hv = eventProfiles_[(*element)->GetName()];
     203    TH1F *h1 = hv[0];
     204    h1->Reset();
     205    TH1F *h2 = hv[1];
     206    h1->Reset();
     207    TH1F *h3 = hv[2];
     208    h1->Reset();
     209    std::vector<TMarker *> mv = eventMarkers_[(*element)->GetName()];
     210    for(std::vector<TLorentzVector>::iterator it = vectors.begin(); it < vectors.end(); ++it)
     211    {
    169212      h1->Fill(it->Pt());
    170213      h2->Fill(it->Eta());
    171214      h3->Fill(it->Phi());
    172       if(it==vectors.begin()) {
    173         mv[0]->SetX(it->Pt()); mv[0]->SetMarkerSize(3);
    174         mv[1]->SetX(it->Eta()); mv[1]->SetMarkerSize(3);
    175         mv[2]->SetX(it->Phi()); mv[2]->SetMarkerSize(3);
    176       }
    177       if(it==vectors.begin()+1) {
    178         mv[3]->SetX(it->Pt()); mv[3]->SetMarkerSize(3);
    179         mv[4]->SetX(it->Eta()); mv[4]->SetMarkerSize(3);
    180         mv[5]->SetX(it->Phi()); mv[5]->SetMarkerSize(3);
    181       }
    182     }
    183   }
    184 }
     215      if(it == vectors.begin())
     216      {
     217        mv[0]->SetX(it->Pt());
     218        mv[0]->SetMarkerSize(3);
     219        mv[1]->SetX(it->Eta());
     220        mv[1]->SetMarkerSize(3);
     221        mv[2]->SetX(it->Phi());
     222        mv[2]->SetMarkerSize(3);
     223      }
     224      if(it == vectors.begin() + 1)
     225      {
     226        mv[3]->SetX(it->Pt());
     227        mv[3]->SetMarkerSize(3);
     228        mv[4]->SetX(it->Eta());
     229        mv[4]->SetMarkerSize(3);
     230        mv[5]->SetX(it->Phi());
     231        mv[5]->SetMarkerSize(3);
     232      }
     233    }
     234  }
     235}
  • display/DelphesPlotSummary.h

    re39abb4 r0e7d64a  
    2020#define DelphesPlotSummary_h
    2121
    22 #include <vector>
    23 #include <map>
    24 #include "TString.h"
    25 #include "TH1F.h"
     22#include "DelphesBranchElement.h"
    2623#include "TCanvas.h"
    2724#include "TEveWindow.h"
    28 #include "DelphesBranchElement.h"
     25#include "TH1F.h"
     26#include "TString.h"
    2927#include "external/ExRootAnalysis/ExRootTreeReader.h"
    3028#include <RQ_OBJECT.h>
    31 
     29#include <map>
     30#include <vector>
    3231
    3332class DelphesPlotSummary
    3433{
    35     RQ_OBJECT("DelphesPlotSummary")
    36   public:
    37     DelphesPlotSummary(TEveWindowTab* tab);
    38     virtual ~DelphesPlotSummary();
    39     void Init(std::vector<DelphesBranchBase*>& elements);
    40     void FillSample(ExRootTreeReader* treeReader, Int_t event_id);
    41     void FillEvent();
    42     void Draw();
    43     void Progress(Int_t); // *SIGNAL*
     34  RQ_OBJECT("DelphesPlotSummary")
     35public:
     36  DelphesPlotSummary(TEveWindowTab *tab);
     37  virtual ~DelphesPlotSummary();
     38  void Init(std::vector<DelphesBranchBase *> &elements);
     39  void FillSample(ExRootTreeReader *treeReader, Int_t event_id);
     40  void FillEvent();
     41  void Draw();
     42  void Progress(Int_t); // *SIGNAL*
    4443
    45   private:
    46     TEveWindowTab* tab_;
    47     std::map< TString, TCanvas* >           canvases_;
    48     std::map< TString, std::vector<TH1F*> > histograms_;
    49     std::vector<DelphesBranchBase*>* elements_;
    50     std::map< TString, std::vector<TMarker*> > eventMarkers_;
    51     std::map< TString, std::vector<TH1F*> > eventProfiles_;
    52 
     44private:
     45  TEveWindowTab *tab_;
     46  std::map<TString, TCanvas *> canvases_;
     47  std::map<TString, std::vector<TH1F *> > histograms_;
     48  std::vector<DelphesBranchBase *> *elements_;
     49  std::map<TString, std::vector<TMarker *> > eventMarkers_;
     50  std::map<TString, std::vector<TH1F *> > eventProfiles_;
    5351};
    5452
    5553#endif // DelphesPlotSummary_h
    56 
  • doc/update_fastjet.sh

    re39abb4 r0e7d64a  
    1 version=3.3.1
     1version=3.3.2
    22
    33wget http://fastjet.fr/repo/fastjet-${version}.tar.gz
     
    99
    1010cd fastjet-${version}
    11 ./configure --enable-allcxxplugins
     11./configure --enable-allcxxplugins --disable-auto-ptr
    1212cd -
    1313
  • examples/CMakeLists.txt

    re39abb4 r0e7d64a  
    11include_directories(
    22  ${CMAKE_SOURCE_DIR}
    3   ${DelphesExternals_INCLUDE_DIR} 
     3  ${DelphesExternals_INCLUDE_DIR}
    44)
    55
     
    1717# take all other relevant files and put them into examples/
    1818install(FILES ${macros} DESTINATION examples)
     19install(DIRECTORY ExternalFastJet DESTINATION examples)
     20if(PYTHIA8_FOUND)
     21  install(DIRECTORY Pythia8 DESTINATION examples)
     22endif()
  • examples/CaloGrid.cpp

    re39abb4 r0e7d64a  
    11//calorimeter grid
     2#include <algorithm>
     3#include <cassert>
     4#include <iostream>
     5#include <map>
    26#include <set>
    3 #include <map>
     7#include <sstream>
    48#include <utility>
    59#include <vector>
    6 #include <algorithm>
    7 #include <sstream>
    8 #include <iostream>
    9 #include <cassert>
    1010
     11#include "ExRootAnalysis/ExRootConfReader.h"
     12#include "classes/DelphesClasses.h"
    1113#include "display/Delphes3DGeometry.h"
    12 #include "classes/DelphesClasses.h"
    13 #include "ExRootAnalysis/ExRootConfReader.h"
    1414
    1515#include "TCanvas.h"
    16 #include "TStyle.h"
    17 #include "TString.h"
    18 #include "TText.h"
    1916#include "TH2F.h"
    2017#include "TLine.h"
     18#include "TString.h"
     19#include "TStyle.h"
     20#include "TText.h"
    2121
    2222using namespace std;
     
    2828{
    2929
    30  if(argc !=3)
    31  {
    32   cout << " Usage: ./CaloGrid [detector card] [calo name]"<<endl;
    33   cout<< "Example: ./CaloGrid cards/delphes_card_CMS.tcl ECal" <<endl;
    34   return 0;
    35  }
     30  if(argc != 3)
     31  {
     32    cout << " Usage: ./CaloGrid [detector card] [calo name]" << endl;
     33    cout << "Example: ./CaloGrid cards/delphes_card_CMS.tcl ECal" << endl;
     34    return 0;
     35  }
    3636
    3737  TString card(argv[1]);
     
    3939  ExRootConfReader *confReader = new ExRootConfReader;
    4040  confReader->ReadFile(card);
    41  
     41
    4242  std::vector<std::string> calorimeters_;
    43   std::map<std::string, std::set< std::pair<Double_t, Int_t> > > caloBinning_;
    44    
     43  std::map<std::string, std::set<std::pair<Double_t, Int_t> > > caloBinning_;
     44
    4545  std::string s(argv[2]);
    46   std::replace( s.begin(), s.end(), ',', ' ' );
    47   std::istringstream stream( s );
     46  std::replace(s.begin(), s.end(), ',', ' ');
     47  std::istringstream stream(s);
    4848  std::string word;
    49   while (stream >> word) calorimeters_.push_back(word);
     49  while(stream >> word) calorimeters_.push_back(word);
    5050
    51   caloBinning_.clear();                                                         // calo binning
     51  caloBinning_.clear(); // calo binning
    5252
    53   TCanvas c("","",1600,838);
    54    
    55   gPad->SetLeftMargin(0.16) ;
    56   gPad->SetTopMargin(0.16) ;
    57   gPad->SetBottomMargin(0.20) ;
     53  TCanvas c("", "", 1600, 838);
     54
     55  gPad->SetLeftMargin(0.16);
     56  gPad->SetTopMargin(0.16);
     57  gPad->SetBottomMargin(0.20);
    5858  gStyle->SetOptStat(0000000);
    59  
     59
    6060  gStyle->SetTextFont(132);
    61    
     61
    6262  TH2F h2("h2", "", 1, -6, 6, 1, 0, 6.28);
    6363
     
    7171  h2.GetYaxis()->SetLabelFont(132);
    7272
    73   h2.GetXaxis()->SetTitleOffset(1.4) ;
    74   h2.GetYaxis()->SetTitleOffset(1.1) ;
    75   h2.GetXaxis()->SetLabelOffset(0.02) ;
    76   h2.GetYaxis()->SetLabelOffset(0.02) ;
    77   h2.GetXaxis()->SetTitleSize(0.06) ;
    78   h2.GetYaxis()->SetTitleSize(0.06) ;
    79   h2.GetXaxis()->SetLabelSize(0.06) ;
    80   h2.GetYaxis()->SetLabelSize(0.06) ;
    81  
    82   h2.GetXaxis()->SetTickLength(0.0) ;
    83   h2.GetYaxis()->SetTickLength(0.0) ;
     73  h2.GetXaxis()->SetTitleOffset(1.4);
     74  h2.GetYaxis()->SetTitleOffset(1.1);
     75  h2.GetXaxis()->SetLabelOffset(0.02);
     76  h2.GetYaxis()->SetLabelOffset(0.02);
     77  h2.GetXaxis()->SetTitleSize(0.06);
     78  h2.GetYaxis()->SetTitleSize(0.06);
     79  h2.GetXaxis()->SetLabelSize(0.06);
     80  h2.GetYaxis()->SetLabelSize(0.06);
    8481
    85  
    86   h2.Draw(); 
    87  
    88    // fake loop just keeping it for convenience right now
    89   for(std::vector<std::string>::const_iterator calo=calorimeters_.begin();calo!=calorimeters_.end(); ++calo) {
    90  
     82  h2.GetXaxis()->SetTickLength(0.0);
     83  h2.GetYaxis()->SetTickLength(0.0);
     84
     85  h2.Draw();
     86
     87  // fake loop just keeping it for convenience right now
     88  for(std::vector<std::string>::const_iterator calo = calorimeters_.begin(); calo != calorimeters_.end(); ++calo)
     89  {
     90
    9191    //first entry is eta bin, second is number of phi bins
    92     set< pair<Double_t, Int_t> > caloBinning;
     92    set<pair<Double_t, Int_t> > caloBinning;
    9393    ExRootConfParam paramEtaBins, paramPhiBins;
    94     ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins",calo->c_str()));
     94    ExRootConfParam param = confReader->GetParam(Form("%s::EtaPhiBins", calo->c_str()));
    9595    Int_t size = param.GetSize();
    96    
    97     for(int i = 0; i < size/2; ++i) {
    98       paramEtaBins = param[i*2];
    99       paramPhiBins = param[i*2+1];
    100       assert(paramEtaBins.GetSize()==1);
    101      
    102       caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(),paramPhiBins.GetSize()-1));
     96
     97    for(int i = 0; i < size / 2; ++i)
     98    {
     99      paramEtaBins = param[i * 2];
     100      paramPhiBins = param[i * 2 + 1];
     101      assert(paramEtaBins.GetSize() == 1);
     102
     103      caloBinning.insert(std::make_pair(paramEtaBins[0].GetDouble(), paramPhiBins.GetSize() - 1));
    103104    }
    104105    caloBinning_[*calo] = caloBinning;
    105  
    106   TLine *liney;
    107   TLine *linex;
    108  
    109   //loop over calo binning
    110   std::set<std::pair<Double_t, Int_t> >::iterator it;
    111  
    112   Int_t n = -1;
    113   for (it = caloBinning.begin(); it != caloBinning.end(); ++it)
    114   {
    115     n++;
    116    
    117     if(debug)cout<<"-----------------------"<<endl;
    118     if(debug)cout<<it->first<<","<<it->second<<endl;
    119     liney = new TLine(it->first,0,it->first,6.28);
    120     liney->SetLineColor(kRed+3);
    121     liney->Draw();
    122    
    123     set<std::pair<Double_t, Int_t> >::iterator it2 = it;
    124     it2--;
    125            
    126     for(int j = 0; j <= it->second; j++)
     106
     107    TLine *liney;
     108    TLine *linex;
     109
     110    //loop over calo binning
     111    std::set<std::pair<Double_t, Int_t> >::iterator it;
     112
     113    Int_t n = -1;
     114    for(it = caloBinning.begin(); it != caloBinning.end(); ++it)
    127115    {
    128      
    129       Double_t yval0 = 0 + 6.28 * j / it->second;
    130      
    131       if(debug) cout<<it2->first<<","<<yval0<<","<<it->first<<","<<yval0<<endl;
    132      
    133       linex = new TLine(it->first,yval0,it2->first,yval0);
    134       linex->SetLineColor(kRed+3);
    135       linex->Draw();
    136          
    137     }
    138    
    139  
    140   }
    141  
    142  
     116      n++;
     117
     118      if(debug) cout << "-----------------------" << endl;
     119      if(debug) cout << it->first << "," << it->second << endl;
     120      liney = new TLine(it->first, 0, it->first, 6.28);
     121      liney->SetLineColor(kRed + 3);
     122      liney->Draw();
     123
     124      set<std::pair<Double_t, Int_t> >::iterator it2 = it;
     125      it2--;
     126
     127      for(int j = 0; j <= it->second; j++)
     128      {
     129
     130        Double_t yval0 = 0 + 6.28 * j / it->second;
     131
     132        if(debug) cout << it2->first << "," << yval0 << "," << it->first << "," << yval0 << endl;
     133
     134        linex = new TLine(it->first, yval0, it2->first, yval0);
     135        linex->SetLineColor(kRed + 3);
     136        linex->Draw();
     137      }
     138    }
    143139  }
    144140
    145141  TString text = TString(s);
    146   TText *th1 = new TText(5.00,6.45,text);
    147   th1->SetTextAlign(31); 
    148   th1->SetTextFont(132); 
     142  TText *th1 = new TText(5.00, 6.45, text);
     143  th1->SetTextAlign(31);
     144  th1->SetTextFont(132);
    149145  th1->SetTextSize(0.075);
    150146  th1->Draw();
    151147
    152 
    153148  TString output = TString(s);
    154   c.Print(output+".png","png");
    155   c.Print(output+".pdf","pdf");
    156  
     149  c.Print(output + ".png", "png");
     150  c.Print(output + ".pdf", "pdf");
    157151}
  • examples/Example1.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019#include <iostream>
    2120#include <utility>
    2221#include <vector>
    2322
     23#include "TApplication.h"
    2424#include "TROOT.h"
    2525#include "TSystem.h"
    26 #include "TApplication.h"
    2726
    2827#include "TString.h"
    2928
     29#include "TClonesArray.h"
    3030#include "TH2.h"
    3131#include "THStack.h"
    3232#include "TLegend.h"
     33#include "TLorentzVector.h"
    3334#include "TPaveText.h"
    34 #include "TClonesArray.h"
    35 #include "TLorentzVector.h"
    3635
    3736#include "classes/DelphesClasses.h"
    3837
     38#include "ExRootAnalysis/ExRootResult.h"
     39#include "ExRootAnalysis/ExRootTreeBranch.h"
    3940#include "ExRootAnalysis/ExRootTreeReader.h"
    4041#include "ExRootAnalysis/ExRootTreeWriter.h"
    41 #include "ExRootAnalysis/ExRootTreeBranch.h"
    42 #include "ExRootAnalysis/ExRootResult.h"
    4342#include "ExRootAnalysis/ExRootUtilities.h"
    4443
     
    7271  TString inputFile(argv[1]);
    7372
    74 //------------------------------------------------------------------------------
     73  //------------------------------------------------------------------------------
    7574
    76 // Here you call your macro's main function
     75  // Here you call your macro's main function
    7776
    7877  Example1(inputFile);
    7978
    80 //------------------------------------------------------------------------------
    81 
     79  //------------------------------------------------------------------------------
    8280}
    83 
    84 
  • external/ExRootAnalysis/ExRootClassifier.h

    re39abb4 r0e7d64a  
    1111  virtual ~ExRootClassifier() {}
    1212  virtual Int_t GetCategory(TObject *object) = 0;
    13 
    1413};
    1514
    1615#endif /* ExRootClassifier */
    17 
  • external/ExRootAnalysis/ExRootConfReader.cc

    re39abb4 r0e7d64a  
    1414#include "TSystem.h"
    1515
     16#include <fstream>
     17#include <iomanip>
    1618#include <iostream>
    17 #include <iomanip>
    18 #include <fstream>
     19#include <sstream>
     20#include <stdexcept>
    1921#include <string>
    20 #include <stdexcept>
    21 #include <sstream>
    2222
    2323using namespace std;
     
    186186int ModuleObjCmdProc(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
    187187{
    188   ExRootConfReader *reader = static_cast<ExRootConfReader*>(clientData);
     188  ExRootConfReader *reader = static_cast<ExRootConfReader *>(clientData);
    189189
    190190  if(objc < 3)
     
    203203    Tcl_ListObjAppendElement(interp, object, Tcl_NewStringObj("namespace", -1));
    204204    Tcl_ListObjAppendElement(interp, object, Tcl_NewStringObj("eval", -1));
    205     Tcl_ListObjAppendList(interp, object, Tcl_NewListObj(objc-2, objv+2));
     205    Tcl_ListObjAppendList(interp, object, Tcl_NewListObj(objc - 2, objv + 2));
    206206
    207207    return Tcl_GlobalEvalObj(interp, object);
     
    215215int SourceObjCmdProc(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
    216216{
    217   ExRootConfReader *reader = static_cast<ExRootConfReader*>(clientData);
     217  ExRootConfReader *reader = static_cast<ExRootConfReader *>(clientData);
    218218  stringstream fileName;
    219219
     
    245245  if(fObject && TCL_OK != Tcl_GetIntFromObj(fTclInterp, fObject, &result))
    246246  {
    247     message << "parameter '"<< fName << "' is not an integer." << endl;
     247    message << "parameter '" << fName << "' is not an integer." << endl;
    248248    message << fName << " = " << Tcl_GetStringFromObj(fObject, 0);
    249249    throw runtime_error(message.str());
     
    260260  if(fObject && TCL_OK != Tcl_GetLongFromObj(fTclInterp, fObject, &result))
    261261  {
    262     message << "parameter '"<< fName << "' is not an long integer." << endl;
     262    message << "parameter '" << fName << "' is not an long integer." << endl;
    263263    message << fName << " = " << Tcl_GetStringFromObj(fObject, 0);
    264264    throw runtime_error(message.str());
     
    275275  if(fObject && TCL_OK != Tcl_GetDoubleFromObj(fTclInterp, fObject, &result))
    276276  {
    277     message << "parameter '"<< fName << "' is not a number." << endl;
     277    message << "parameter '" << fName << "' is not a number." << endl;
    278278    message << fName << " = " << Tcl_GetStringFromObj(fObject, 0);
    279279    throw runtime_error(message.str());
     
    290290  if(fObject && TCL_OK != Tcl_GetBooleanFromObj(fTclInterp, fObject, &result))
    291291  {
    292     message << "parameter '"<< fName << "' is not a boolean." << endl;
     292    message << "parameter '" << fName << "' is not a boolean." << endl;
    293293    message << fName << " = " << Tcl_GetStringFromObj(fObject, 0);
    294294    throw runtime_error(message.str());
     
    314314  if(fObject && TCL_OK != Tcl_ListObjLength(fTclInterp, fObject, &length))
    315315  {
    316     message << "parameter '"<< fName << "' is not a list." << endl;
     316    message << "parameter '" << fName << "' is not a list." << endl;
    317317    message << fName << " = " << Tcl_GetStringFromObj(fObject, 0);
    318318    throw runtime_error(message.str());
     
    329329  if(fObject && TCL_OK != Tcl_ListObjIndex(fTclInterp, fObject, index, &object))
    330330  {
    331     message << "parameter '"<< fName << "' is not a list." << endl;
     331    message << "parameter '" << fName << "' is not a list." << endl;
    332332    message << fName << " = " << Tcl_GetStringFromObj(fObject, 0);
    333333    throw runtime_error(message.str());
  • external/ExRootAnalysis/ExRootConfReader.h

    re39abb4 r0e7d64a  
    2121{
    2222public:
    23 
    2423  ExRootConfParam(const char *name = 0, Tcl_Obj *object = 0, Tcl_Interp *interp = 0);
    2524
     
    3433
    3534private:
    36 
    3735  const char *fName; //!
    3836  Tcl_Obj *fObject; //!
     
    4240//------------------------------------------------------------------------------
    4341
    44 class ExRootConfReader : public TNamed
     42class ExRootConfReader: public TNamed
    4543{
    4644public:
     
    6664
    6765private:
    68 
    6966  const char *fTopDir; //!
    7067
     
    7774
    7875#endif
    79 
  • external/ExRootAnalysis/ExRootFilter.cc

    re39abb4 r0e7d64a  
    1111#include "ExRootAnalysis/ExRootClassifier.h"
    1212
     13#include "TObjArray.h"
    1314#include "TSeqCollection.h"
    14 #include "TObjArray.h"
    1515
    1616#include <iostream>
     17#include <sstream>
    1718#include <stdexcept>
    18 #include <sstream>
    1919
    2020using namespace std;
    2121
    22 typedef map<Int_t, TObjArray*> TCategoryMap;
    23 typedef map<ExRootClassifier*, pair<Bool_t, TCategoryMap> > TClassifierMap;
     22typedef map<Int_t, TObjArray *> TCategoryMap;
     23typedef map<ExRootClassifier *, pair<Bool_t, TCategoryMap> > TClassifierMap;
    2424
    2525ExRootFilter::ExRootFilter(const TSeqCollection *collection) :
     
    4040        itSubMap != itMap->second.second.end(); ++itSubMap)
    4141    {
    42       delete (itSubMap->second);
     42      delete(itSubMap->second);
    4343    }
    4444  }
     
    132132
    133133//------------------------------------------------------------------------------
    134 
  • external/ExRootAnalysis/ExRootFilter.h

    re39abb4 r0e7d64a  
    1414{
    1515public:
    16 
    1716  ExRootFilter(const TSeqCollection *collection);
    1817  ~ExRootFilter();
     
    2322
    2423private:
    25 
    2624  const TSeqCollection *fCollection; //!
    2725  TIterator *fIter; //!
    2826
    29   std::map<ExRootClassifier*, std::pair<Bool_t, std::map<Int_t, TObjArray*> > > fMap; //!
    30 
     27  std::map<ExRootClassifier *, std::pair<Bool_t, std::map<Int_t, TObjArray *> > > fMap; //!
    3128};
    3229
    3330#endif /* ExRootFilter */
    34 
  • external/ExRootAnalysis/ExRootProgressBar.cc

    re39abb4 r0e7d64a  
    1414#include <iostream>
    1515
     16#include <stdio.h>
    1617#include <string.h>
    17 #include <stdio.h>
    1818
    1919using namespace std;
     
    4646  if(fEntries > 0)
    4747  {
    48     Int_t hashes = Int_t(Double_t(entry)/fEntries*fWidth);
     48    Int_t hashes = Int_t(Double_t(entry) / fEntries * fWidth);
    4949    if(hashes > fWidth) hashes = fWidth;
    5050    if(hashes != fHashes)
     
    5353      memset(fBar + hashes, '-', fWidth - hashes);
    5454      fHashes = hashes;
    55       fprintf(stderr, "** [%s] (%.2f%%)\r", fBar, Float_t(entry)/fEntries*100.0);
     55      fprintf(stderr, "** [%s] (%.2f%%)\r", fBar, Float_t(entry) / fEntries * 100.0);
    5656    }
    5757  }
     
    7777
    7878//------------------------------------------------------------------------------
    79 
  • external/ExRootAnalysis/ExRootProgressBar.h

    re39abb4 r0e7d64a  
    77{
    88public:
    9 
    109  ExRootProgressBar(Long64_t entries, Int_t width = 64);
    1110  ~ExRootProgressBar();
     
    1514
    1615private:
    17 
    1816  Long64_t fEntries, fEventCounter;
    1917  Int_t fWidth;
     
    2321
    2422  char *fBar; //!
    25 
    2623};
    2724
    2825#endif /* ExRootProgressBar */
    29 
  • external/ExRootAnalysis/ExRootResult.cc

    re39abb4 r0e7d64a  
    1212#include "ExRootAnalysis/ExRootUtilities.h"
    1313
    14 #include "TROOT.h"
     14#include "TCanvas.h"
     15#include "TClass.h"
    1516#include "TFile.h"
    16 #include "TClass.h"
    17 #include "TStyle.h"
    18 #include "TCanvas.h"
    19 #include "TLegend.h"
    20 #include "TPaveText.h"
    21 #include "TPaveStats.h"
    22 #include "TList.h"
     17#include "TFolder.h"
    2318#include "TH2.h"
    2419#include "THStack.h"
     20#include "TLegend.h"
     21#include "TList.h"
     22#include "TObjArray.h"
     23#include "TPaveStats.h"
     24#include "TPaveText.h"
    2525#include "TProfile.h"
    26 #include "TObjArray.h"
    27 #include "TFolder.h"
     26#include "TROOT.h"
     27#include "TStyle.h"
    2828
    2929#include <iostream>
     
    3737//------------------------------------------------------------------------------
    3838
    39 ExRootResult::ExRootResult() : fCanvas(0), fFolder(0)
     39ExRootResult::ExRootResult() :
     40  fCanvas(0), fFolder(0)
    4041{
    4142}
     
    4546ExRootResult::~ExRootResult()
    4647{
    47   set<TObject*>::iterator itPool;
     48  set<TObject *>::iterator itPool;
    4849  for(itPool = fPool.begin(); itPool != fPool.end(); ++itPool)
    4950  {
     
    6869  TFile *file = new TFile(fileName, "RECREATE");
    6970  file->cd();
    70   std::map<TObject*, PlotSettings>::iterator itPlotMap;
     71  std::map<TObject *, PlotSettings>::iterator itPlotMap;
    7172  for(itPlotMap = fPlotMap.begin(); itPlotMap != fPlotMap.end(); ++itPlotMap)
    7273  {
     
    123124  // gStyle->SetOptFit(101);
    124125
    125   fCanvas = static_cast<TCanvas*>(gROOT->FindObject("c1"));
     126  fCanvas = static_cast<TCanvas *>(gROOT->FindObject("c1"));
    126127  if(fCanvas)
    127128  {
     
    154155  if(!plot) return;
    155156
    156   std::map<TObject*, PlotSettings>::iterator itPlotMap = fPlotMap.find(plot);
     157  std::map<TObject *, PlotSettings>::iterator itPlotMap = fPlotMap.find(plot);
    157158  if(itPlotMap != fPlotMap.end())
    158159  {
     
    178179  if(plot->IsA()->InheritsFrom(TH1::Class()))
    179180  {
    180     histogram = static_cast<TH1*>(plot);
    181   }
    182 
    183   map<TObject*, PlotSettings>::iterator itPlotMap = fPlotMap.find(plot);
     181    histogram = static_cast<TH1 *>(plot);
     182  }
     183
     184  map<TObject *, PlotSettings>::iterator itPlotMap = fPlotMap.find(plot);
    184185  if(itPlotMap != fPlotMap.end())
    185186  {
     
    224225  TCanvas *canvas = GetCanvas();
    225226
    226   map<TObject*, PlotSettings>::iterator itPlotMap;
     227  map<TObject *, PlotSettings>::iterator itPlotMap;
    227228
    228229  for(itPlotMap = fPlotMap.begin(); itPlotMap != fPlotMap.end(); ++itPlotMap)
     
    236237    if(object->IsA()->InheritsFrom(TH1::Class()))
    237238    {
    238       histogram = static_cast<TH1*>(object);
     239      histogram = static_cast<TH1 *>(object);
    239240    }
    240241    else if(object->IsA()->InheritsFrom(THStack::Class()))
    241242    {
    242       stack = static_cast<THStack*>(object);
    243       histogram = static_cast<TH1*>(stack->GetHists()->First());
     243      stack = static_cast<THStack *>(object);
     244      histogram = static_cast<TH1 *>(stack->GetHists()->First());
    244245    }
    245246
     
    271272    if(histogram)
    272273    {
    273       stats = static_cast<TPaveStats*>(histogram->FindObject("stats"));
     274      stats = static_cast<TPaveStats *>(histogram->FindObject("stats"));
    274275      if(stats)
    275276      {
     
    300301
    301302TH1 *ExRootResult::AddHist1D(const char *name, const char *title,
    302                              const char *xlabel, const char *ylabel,
    303                              Int_t nxbins, Axis_t xmin, Axis_t xmax,
    304                              Int_t logx, Int_t logy)
     303  const char *xlabel, const char *ylabel,
     304  Int_t nxbins, Axis_t xmin, Axis_t xmax,
     305  Int_t logx, Int_t logy)
    305306{
    306307  TH1F *hist = new TH1F(name, title, nxbins, xmin, xmax);
     
    324325
    325326TH1 *ExRootResult::AddHist1D(const char *name, const char *title,
    326                              const char *xlabel, const char *ylabel,
    327                              Int_t nxbins, const Float_t *bins,
    328                              Int_t logx, Int_t logy)
     327  const char *xlabel, const char *ylabel,
     328  Int_t nxbins, const Float_t *bins,
     329  Int_t logx, Int_t logy)
    329330{
    330331  TH1F *hist = new TH1F(name, title, nxbins, bins);
     
    348349
    349350TProfile *ExRootResult::AddProfile(const char *name, const char *title,
    350                                    const char *xlabel, const char *ylabel,
    351                                    Int_t nxbins, Axis_t xmin, Axis_t xmax,
    352                                    Int_t logx, Int_t logy)
     351  const char *xlabel, const char *ylabel,
     352  Int_t nxbins, Axis_t xmin, Axis_t xmax,
     353  Int_t logx, Int_t logy)
    353354{
    354355  TProfile *profile = new TProfile(name, title, nxbins, xmin, xmax);
     
    372373
    373374TH2 *ExRootResult::AddHist2D(const char *name, const char *title,
    374                              const char *xlabel, const char *ylabel,
    375                              Int_t nxbins, Axis_t xmin, Axis_t xmax,
    376                              Int_t nybins, Axis_t ymin, Axis_t ymax,
    377                              Int_t logx, Int_t logy)
     375  const char *xlabel, const char *ylabel,
     376  Int_t nxbins, Axis_t xmin, Axis_t xmax,
     377  Int_t nybins, Axis_t ymin, Axis_t ymax,
     378  Int_t logx, Int_t logy)
    378379{
    379380  TH2F *hist = new TH2F(name, title, nxbins, xmin, xmax, nybins, ymin, ymax);
  • external/ExRootAnalysis/ExRootResult.h

    re39abb4 r0e7d64a  
    22#define ExRootResult_h
    33
     4#include "Gtypes.h"
    45#include "Rtypes.h"
    5 #include "Gtypes.h"
    66#include "TMath.h"
    77
     8#include <map>
    89#include <set>
    9 #include <map>
    1010
    1111class TH1;
     
    2323
    2424public:
    25 
    2625  ExRootResult();
    2726  ~ExRootResult();
     
    3231
    3332  TH1 *AddHist1D(const char *name, const char *title,
    34                  const char *xlabel, const char *ylabel,
    35                  Int_t nxbins, Axis_t xmin, Axis_t xmax,
    36                  Int_t logx = 0, Int_t logy = 0);
     33    const char *xlabel, const char *ylabel,
     34    Int_t nxbins, Axis_t xmin, Axis_t xmax,
     35    Int_t logx = 0, Int_t logy = 0);
    3736
    3837  TH1 *AddHist1D(const char *name, const char *title,
    39                  const char *xlabel, const char *ylabel,
    40                  Int_t nxbins, const Float_t *bins,
    41                  Int_t logx = 0, Int_t logy = 0);
     38    const char *xlabel, const char *ylabel,
     39    Int_t nxbins, const Float_t *bins,
     40    Int_t logx = 0, Int_t logy = 0);
    4241
    4342  TProfile *AddProfile(const char *name, const char *title,
    44                        const char *xlabel, const char *ylabel,
    45                        Int_t nxbins, Axis_t xmin, Axis_t xmax,
    46                        Int_t logx = 0, Int_t logy = 0);
     43    const char *xlabel, const char *ylabel,
     44    Int_t nxbins, Axis_t xmin, Axis_t xmax,
     45    Int_t logx = 0, Int_t logy = 0);
    4746
    4847  TH2 *AddHist2D(const char *name, const char *title,
    49                  const char *xlabel, const char *ylabel,
    50                  Int_t nxbins, Axis_t xmin, Axis_t xmax,
    51                  Int_t nybins, Axis_t ymin, Axis_t ymax,
    52                  Int_t logx = 0, Int_t logy = 0);
     48    const char *xlabel, const char *ylabel,
     49    Int_t nxbins, Axis_t xmin, Axis_t xmax,
     50    Int_t nybins, Axis_t ymin, Axis_t ymax,
     51    Int_t logx = 0, Int_t logy = 0);
    5352
    5453  THStack *AddHistStack(const char *name, const char *title);
     
    6261  TCanvas *GetCanvas();
    6362
    64   void PrintPlot(TObject *plot, const char *sufix = "",  const char *format = "eps");
     63  void PrintPlot(TObject *plot, const char *sufix = "", const char *format = "eps");
    6564
    6665  void SetFolder(TFolder *folder) { fFolder = folder; }
    6766
    6867private:
    69 
    7068  struct PlotSettings
    7169  {
     
    7977  TCanvas *fCanvas; //!
    8078
    81   std::set<TObject*> fPool; //!
     79  std::set<TObject *> fPool; //!
    8280
    83   std::map<TObject*, PlotSettings> fPlotMap; //!
     81  std::map<TObject *, PlotSettings> fPlotMap; //!
    8482
    8583  TFolder *fFolder; //!
    86 
    8784};
    8885
    8986#endif /* ExRootResult_h */
    90 
  • external/ExRootAnalysis/ExRootTask.cc

    re39abb4 r0e7d64a  
    1111#include "ExRootAnalysis/ExRootConfReader.h"
    1212
    13 #include "TROOT.h"
    1413#include "TClass.h"
    1514#include "TFolder.h"
     15#include "TROOT.h"
    1616#include "TString.h"
    1717
     18#include <iomanip>
    1819#include <iostream>
    19 #include <iomanip>
     20#include <sstream>
    2021#include <stdexcept>
    21 #include <sstream>
    2222
    2323static const char *const kINIT = "0";
     
    144144
    145145  if(!cl) return 0;
    146  
     146
    147147  if(!cl->InheritsFrom(ExRootTask::Class()))
    148148  {
     
    310310  return object;
    311311}
    312 
  • external/ExRootAnalysis/ExRootTask.h

    re39abb4 r0e7d64a  
    1717class TFolder;
    1818
    19 class ExRootTask : public TTask
     19class ExRootTask: public TTask
    2020{
    2121public:
    22 
    2322  ExRootTask();
    2423  virtual ~ExRootTask();
     
    4140  ExRootTask *NewTask(const char *className, const char *taskName);
    4241
    43   void Exec(Option_t* option);
     42  void Exec(Option_t *option);
    4443
    4544  int GetInt(const char *name, int defaultValue, int index = -1);
     
    5554
    5655protected:
    57 
    5856  TFolder *GetFolder() const { return fFolder; }
    5957  ExRootConfReader *GetConfReader() const { return fConfReader; }
     
    6361
    6462private:
    65 
    6663  TFolder *fFolder; //!
    6764  ExRootConfReader *fConfReader; //!
     
    7168
    7269#endif /* ExRootTask */
    73 
  • external/ExRootAnalysis/ExRootTreeBranch.cc

    re39abb4 r0e7d64a  
    1111#include "ExRootAnalysis/ExRootTreeBranch.h"
    1212
     13#include "TClonesArray.h"
    1314#include "TFile.h"
     15#include "TString.h"
    1416#include "TTree.h"
    15 #include "TString.h"
    16 #include "TClonesArray.h"
    1717
    1818#include <iostream>
     19#include <sstream>
    1920#include <stdexcept>
    20 #include <sstream>
    2121
    2222using namespace std;
     
    2828{
    2929  stringstream message;
    30 //  cl->IgnoreTObjectStreamer();
    31 //  cl->BypassStreamer();
     30  //  cl->IgnoreTObjectStreamer();
     31  //  cl->BypassStreamer();
    3232  fData = new TClonesArray(cl, fCapacity);
    3333
     
    6565  if(fSize >= fCapacity)
    6666  {
    67     if(fCapacity < 10) fCapacity = 10;
    68     else if(fCapacity < 30) fCapacity = 30;
    69     else if(fCapacity < 100) fCapacity = 100;
    70     else if(fCapacity < 250) fCapacity = 250;
    71     else fCapacity *= 2;
     67    if(fCapacity < 10)
     68      fCapacity = 10;
     69    else if(fCapacity < 30)
     70      fCapacity = 30;
     71    else if(fCapacity < 100)
     72      fCapacity = 100;
     73    else if(fCapacity < 250)
     74      fCapacity = 250;
     75    else
     76      fCapacity *= 2;
    7277
    7378    fData->ExpandCreateFast(fCapacity);
     
    7681    fData->ExpandCreateFast(fSize);
    7782  }
    78  
     83
    7984  return fData->AddrAt(fSize++);
    8085}
     
    8994
    9095//------------------------------------------------------------------------------
    91 
  • external/ExRootAnalysis/ExRootTreeBranch.h

    re39abb4 r0e7d64a  
    1919{
    2020public:
    21 
    2221  ExRootTreeBranch(const char *name, TClass *cl, TTree *tree = 0);
    2322  ~ExRootTreeBranch();
     
    2726
    2827private:
    29 
    3028  Int_t fSize, fCapacity; //!
    3129  TClonesArray *fData; //!
     
    3331
    3432#endif /* ExRootTreeBranch */
    35 
  • external/ExRootAnalysis/ExRootTreeReader.cc

    re39abb4 r0e7d64a  
    1010#include "ExRootAnalysis/ExRootTreeReader.h"
    1111
     12#include "TBranchElement.h"
     13#include "TCanvas.h"
     14#include "TClonesArray.h"
    1215#include "TH2.h"
    1316#include "TStyle.h"
    14 #include "TCanvas.h"
    15 #include "TClonesArray.h"
    16 #include "TBranchElement.h"
    1717
    1818#include <iostream>
     
    5151  if(fChain->IsA() == TChain::Class())
    5252  {
    53     TChain *chain = static_cast<TChain*>(fChain);
     53    TChain *chain = static_cast<TChain *>(fChain);
    5454    if(chain->GetTreeNumber() != fCurrentTree)
    5555    {
     
    9494      if(branch->IsA() == TBranchElement::Class())
    9595      {
    96         TBranchElement *element = static_cast<TBranchElement*>(branch);
     96        TBranchElement *element = static_cast<TBranchElement *>(branch);
    9797        const char *className = element->GetClonesName();
    9898        Int_t size = element->GetMaximum();
     
    145145
    146146//------------------------------------------------------------------------------
    147 
  • external/ExRootAnalysis/ExRootTreeReader.h

    re39abb4 r0e7d64a  
    1010 */
    1111
    12 #include "TROOT.h"
    13 #include "TNamed.h"
    1412#include "TChain.h"
    1513#include "TFile.h"
     14#include "TNamed.h"
     15#include "TROOT.h"
    1616
    1717#include <map>
    1818
    19 class ExRootTreeReader : public TNamed
     19class ExRootTreeReader: public TNamed
    2020{
    21 public :
    22 
     21public:
    2322  ExRootTreeReader(TTree *tree = 0);
    2423  ~ExRootTreeReader();
     
    3231
    3332private:
    34 
    3533  Bool_t Notify();
    3634
     
    3836  Int_t fCurrentTree; //! current Tree number in a TChain
    3937
    40   typedef std::map<TString, std::pair<TBranch*, TClonesArray*> > TBranchMap;
     38  typedef std::map<TString, std::pair<TBranch *, TClonesArray *> > TBranchMap;
    4139
    4240  TBranchMap fBranchMap; //!
  • external/ExRootAnalysis/ExRootTreeWriter.cc

    re39abb4 r0e7d64a  
    1111#include "ExRootAnalysis/ExRootTreeBranch.h"
    1212
     13#include "TClonesArray.h"
     14#include "TFile.h"
    1315#include "TROOT.h"
    14 #include "TFile.h"
    1516#include "TTree.h"
    16 #include "TClonesArray.h"
    1717
    1818#include <iostream>
     19#include <sstream>
    1920#include <stdexcept>
    20 #include <sstream>
    2121
    2222using namespace std;
     
    3131ExRootTreeWriter::~ExRootTreeWriter()
    3232{
    33   set<ExRootTreeBranch*>::iterator itBranches;
     33  set<ExRootTreeBranch *>::iterator itBranches;
    3434  for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
    3535  {
    36     delete (*itBranches);
     36    delete(*itBranches);
    3737  }
    3838
     
    6969void ExRootTreeWriter::Clear()
    7070{
    71   set<ExRootTreeBranch*>::iterator itBranches;
     71  set<ExRootTreeBranch *>::iterator itBranches;
    7272  for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
    7373  {
     
    9595
    9696  tree->SetDirectory(fFile);
    97   tree->SetAutoSave(10000000);  // autosave when 10 MB written
     97  tree->SetAutoSave(10000000); // autosave when 10 MB written
    9898
    9999  return tree;
  • external/ExRootAnalysis/ExRootTreeWriter.h

    re39abb4 r0e7d64a  
    1919class ExRootTreeBranch;
    2020
    21 class ExRootTreeWriter : public TNamed
     21class ExRootTreeWriter: public TNamed
    2222{
    2323public:
    24 
    2524  ExRootTreeWriter(TFile *file = 0, const char *treeName = "Analysis");
    2625  ~ExRootTreeWriter();
     
    3635
    3736private:
    38 
    3937  TTree *NewTree();
    4038
     
    4442  TString fTreeName; //!
    4543
    46   std::set<ExRootTreeBranch*> fBranches; //!
     44  std::set<ExRootTreeBranch *> fBranches; //!
    4745
    4846  ClassDef(ExRootTreeWriter, 1)
     
    5048
    5149#endif /* ExRootTreeWriter */
    52 
  • external/ExRootAnalysis/ExRootUtilities.cc

    re39abb4 r0e7d64a  
    1010#include "ExRootAnalysis/ExRootUtilities.h"
    1111
     12#include "TChain.h"
     13#include "TH1.h"
    1214#include "TROOT.h"
    13 #include "TH1.h"
    14 #include "TChain.h"
    1515
     16#include <fstream>
    1617#include <iostream>
    17 #include <fstream>
    1818
    1919using namespace std;
     
    7474
    7575//------------------------------------------------------------------------------
    76 
  • external/Hector/H_Beam.h

    re39abb4 r0e7d64a  
    107107        //@{
    108108                inline const float getEmittanceX() const {
    109                     if(!x_disp*tx_disp) cout<<"Warning : Degenerate Beam : x-emittance = 0"<<endl;     
     109                    if(x_disp * tx_disp == 0) cout<<"Warning : Degenerate Beam : x-emittance = 0"<<endl;       
    110110                        return x_disp * tan(tx_disp/URAD)/URAD;
    111111                }
    112112        inline const float getEmittanceY() const {
    113                         if(!y_disp*ty_disp) cout<<"Warning : Degenerate Beam : y-emittance = 0"<<endl;
     113                    if(y_disp * ty_disp == 0) cout<<"Warning : Degenerate Beam : y-emittance = 0"<<endl;
    114114                        return y_disp * tan(ty_disp/URAD)/URAD;
    115115                }
  • external/fastjet/VERSION

    re39abb4 r0e7d64a  
    1 3.3.1
     13.3.2
  • external/fastjet/config_auto.h

    re39abb4 r0e7d64a  
    6565
    6666/* compile the deprecated parts of the interface using auto-ptr */
    67 #ifndef FASTJET_HAVE_AUTO_PTR_INTERFACE
    68 #define FASTJET_HAVE_AUTO_PTR_INTERFACE  /**/
    69 #endif
     67/* #undef HAVE_AUTO_PTR_INTERFACE */
    7068
    7169/* compiler supports c++14 deprecated keyword */
     
    169167/* Define to the full name and version of this package. */
    170168#ifndef FASTJET_PACKAGE_STRING
    171 #define FASTJET_PACKAGE_STRING  "FastJet 3.3.1"
     169#define FASTJET_PACKAGE_STRING  "FastJet 3.3.2"
    172170#endif
    173171
     
    184182/* Define to the version of this package. */
    185183#ifndef FASTJET_PACKAGE_VERSION
    186 #define FASTJET_PACKAGE_VERSION  "3.3.1"
     184#define FASTJET_PACKAGE_VERSION  "3.3.2"
    187185#endif
    188186
     
    194192/* Version number of package */
    195193#ifndef FASTJET_VERSION
    196 #define FASTJET_VERSION  "3.3.1"
     194#define FASTJET_VERSION  "3.3.2"
    197195#endif
    198196
     
    209207/* Version of the package under the form XYYZZ (instead of X.Y.Z) */
    210208#ifndef FASTJET_VERSION_NUMBER
    211 #define FASTJET_VERSION_NUMBER  30301
     209#define FASTJET_VERSION_NUMBER  30302
    212210#endif
    213211
    214212/* Patch version of this package */
    215213#ifndef FASTJET_VERSION_PATCHLEVEL
    216 #define FASTJET_VERSION_PATCHLEVEL  1
     214#define FASTJET_VERSION_PATCHLEVEL  2
    217215#endif
    218216
  • external/fastjet/config_raw.h

    re39abb4 r0e7d64a  
    3939
    4040/* compile the deprecated parts of the interface using auto-ptr */
    41 #define HAVE_AUTO_PTR_INTERFACE /**/
     41/* #undef HAVE_AUTO_PTR_INTERFACE */
    4242
    4343/* compiler supports c++14 deprecated keyword */
     
    106106
    107107/* Define to the full name and version of this package. */
    108 #define PACKAGE_STRING "FastJet 3.3.1"
     108#define PACKAGE_STRING "FastJet 3.3.2"
    109109
    110110/* Define to the one symbol short name of this package. */
     
    115115
    116116/* Define to the version of this package. */
    117 #define PACKAGE_VERSION "3.3.1"
     117#define PACKAGE_VERSION "3.3.2"
    118118
    119119/* Define to 1 if you have the ANSI C header files. */
     
    121121
    122122/* Version number of package */
    123 #define VERSION "3.3.1"
     123#define VERSION "3.3.2"
    124124
    125125/* Major version of this package */
     
    130130
    131131/* Version of the package under the form XYYZZ (instead of X.Y.Z) */
    132 #define VERSION_NUMBER 30301
     132#define VERSION_NUMBER 30302
    133133
    134134/* Patch version of this package */
    135 #define VERSION_PATCHLEVEL 1
     135#define VERSION_PATCHLEVEL 2
    136136
    137137/* Pre-release version of this package */
  • external/fastjet/config_win.h

    re39abb4 r0e7d64a  
    1 #define FASTJET_PACKAGE_STRING  "FastJet 3.3.1"
    2 #define FASTJET_PACKAGE_VERSION  "3.3.1"
    3 #define FASTJET_VERSION  "3.3.1"
     1#define FASTJET_PACKAGE_STRING  "FastJet 3.3.2"
     2#define FASTJET_PACKAGE_VERSION  "3.3.2"
     3#define FASTJET_VERSION  "3.3.2"
    44#define FASTJET_VERSION_MAJOR       3
    55#define FASTJET_VERSION_MINOR       3
    6 #define FASTJET_VERSION_PATCHLEVEL  1
    7 #define FASTJET_VERSION_NUMBER      30301
     6#define FASTJET_VERSION_PATCHLEVEL  2
     7#define FASTJET_VERSION_NUMBER      30302
    88
    99/* The ATLASCone plugin is disabled by default*/
  • external/fastjet/contribs/ValenciaPlugin/AUTHORS

    re39abb4 r0e7d64a  
    1 The ValenciaJetAlgorithm FastJet contrib was written and is maintained and developed by: Ignacio Garcia Garcia, Marcel Vos, IFIC (UVEG/CSIC) Valencia, Spain
     1The ValenciaPlugin FastJet contrib was written and is maintained and developed by: Ignacio Garcia Garcia, Marcel Vos, IFIC (UVEG/CSIC) Valencia, Spain
    22
    3 Acknowledging suggestions by Gavin P. Salam (CERN) and J. Thaler (MIT)
     3The first incarnation of the Valencia algorithm (with two parameters R and beta) was proposed "A robust jet reconstruction algorithm for high-energy lepton colliders", PLB 750 (2015) 95-99, arXiv:1404.4294
     4The authors acknowledge suggestions by Gavin P. Salam (CERN) and his help in assessing the IR safety of the algorithm
    45
    5 A preprint motivating the algorithm and describing its performance is available on: "A new jet algorithm for lepton colliders", arXiv:1404.4294 (submitted to PLB)
     6The VLC algorithm (with three parameters R, beta and gamma) is described in "Jet reconstruction at high-energy electron-positron colliders", EPJC 78 (2018) no. 2, 144. The addition of the gamma parameter was suggested by J. Thaler (MIT). The performance of the algorithm is evaluated in detail in this paper, in collaboration with Ph. Roloff, R. Simoniello (CERN) and M. Boronat, J. Fuster (IFIC)
    67
    78Please contact: marcel.vos@ific.uv.es for questions, queries and comments
  • external/fastjet/contribs/ValenciaPlugin/ChangeLog

    re39abb4 r0e7d64a  
     122-12-2018: Gavin Salam <gavin.salam@cern.ch>
     2        * VERSION:
     3        * NEWS:
     4        updated version to 2.0.2
     5
     62018-12-18: Marcel Vos <marcel.vos@ific.uv.es>a
     7        * ValenciaPlugin.cc:
     8        Incorporates a modification suggested by
     9        Filip Zarnecki (Warsaw) to make sure the behaviour for negative
     10        beta is correct (added to trunk in june 2017 but left out of
     11        2.0.1)
     12
     132018-12-04: Marcel Vos <marcel.vos@ific.uv.es>
     14        * VERSION
     15        * NEWS
     16        updated version to 2.0.1
     17
     18        * ValenciaPlugin.cc:
     19        Bug fix: a bug was discovered in the plugin by Matthias Weber (CERN)
     20        the calculation of the distance diB assumed massless constituents.
     21        The impact on the results - jet energy and mass - is typically small,
     22        but can be non-negligible
     23
    12424-02-2015  Marcel Vos <marcel.vos@ific.uv.es>
    225
  • external/fastjet/contribs/ValenciaPlugin/NEWS

    re39abb4 r0e7d64a  
     122 December 2018: bug-fix release 2.0.2, for negative beta
     204 December 2018: bug-fix release 2.0.1, for massive constituents
    1324 February 2015: version 2.0.0
    2421 February 2015: released 2.0-devel
  • external/fastjet/contribs/ValenciaPlugin/VERSION

    re39abb4 r0e7d64a  
    1 2.0.0
     12.0.2
  • external/fastjet/contribs/ValenciaPlugin/ValenciaPlugin.cc

    re39abb4 r0e7d64a  
    1 // $Id: ValenciaPlugin.cc 776 2015-02-24 17:53:27Z vos $
     1// $Id: ValenciaPlugin.cc 1209 2018-12-05 16:18:01Z vos $
    22//
    33// Copyright (c) 2014, Marcel Vos and Ignacio Garcia
     
    6666    // E-to-the-2*beta times sin(polar angle)-to-the-2*gamma
    6767    if (E==0. || jet.perp()==0.) diB=0.;
    68     diB = pow(E,2*beta) * pow(jet.perp()/E,2*info->gamma()); 
     68    // modified diB in release 2.0.1   
     69    diB = pow(E,2*beta) * pow(jet.perp()/sqrt(jet.perp2()+jet.pz()*jet.pz()),2*info->gamma());
    6970  }
    7071
     
    7879                   - nz*jet->nz;
    7980
    80     if (jet->E < E)
     81    if (pow(jet->E,2*beta) < pow(E,2*beta))
    8182      dij *= 2 * pow(jet->E,2*beta);
    8283    else
  • external/fastjet/contribs/ValenciaPlugin/ValenciaPlugin.hh

    re39abb4 r0e7d64a  
    1 // $Id: ValenciaPlugin.hh 776 2015-02-24 17:53:27Z vos $
     1// $Id: ValenciaPlugin.hh 771 2015-02-21 16:40:07Z vos $
    22//
    33// Copyright (c) 2014, Marcel Vos and Ignacio Garcia
  • external/fastjet/plugins/SISCone/config.h

    re39abb4 r0e7d64a  
    8383/* Define to the full name and version of this package. */
    8484#ifndef SISCONE_PACKAGE_STRING
    85 #define SISCONE_PACKAGE_STRING  "SISCone 3.0.3"
     85#define SISCONE_PACKAGE_STRING  "SISCone 3.0.4"
    8686#endif
    8787
     
    9898/* Define to the version of this package. */
    9999#ifndef SISCONE_PACKAGE_VERSION
    100 #define SISCONE_PACKAGE_VERSION  "3.0.3"
     100#define SISCONE_PACKAGE_VERSION  "3.0.4"
    101101#endif
    102102
     
    111111/* Version number of package */
    112112#ifndef SISCONE_VERSION
    113 #define SISCONE_VERSION  "3.0.3"
     113#define SISCONE_VERSION  "3.0.4"
    114114#endif
    115115 
  • external/fastjet/plugins/SISCone/config_raw.h

    re39abb4 r0e7d64a  
    4848
    4949/* Define to the full name and version of this package. */
    50 #define PACKAGE_STRING "SISCone 3.0.3"
     50#define PACKAGE_STRING "SISCone 3.0.4"
    5151
    5252/* Define to the one symbol short name of this package. */
     
    5757
    5858/* Define to the version of this package. */
    59 #define PACKAGE_VERSION "3.0.3"
     59#define PACKAGE_VERSION "3.0.4"
    6060
    6161/* Define to 1 if you have the ANSI C header files. */
     
    6666
    6767/* Version number of package */
    68 #define VERSION "3.0.3"
     68#define VERSION "3.0.4"
  • external/fastjet/plugins/SISCone/split_merge.h

    re39abb4 r0e7d64a  
    446446  // jet information
    447447  /// list of jet candidates
    448 #ifdef SISCONE_USES_UNIQUE_PTR_AS_AUTO_PTR
     448#if __cplusplus < 201103L
     449  std::auto_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates;
     450#else
    449451  std::unique_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates;
    450 #else
    451   std::auto_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates;
    452452#endif
    453453 
  • external/tcl/tcl.h

    re39abb4 r0e7d64a  
    488488EXTERN int              Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr));
    489489
    490 #ifdef TCL_MEM_DEBUG
    491 #   define Tcl_IncrRefCount(objPtr) \
    492         Tcl_DbIncrRefCount(objPtr, __FILE__, __LINE__)
    493 #   define Tcl_DecrRefCount(objPtr) \
    494         Tcl_DbDecrRefCount(objPtr, __FILE__, __LINE__)
    495 #   define Tcl_IsShared(objPtr) \
    496         Tcl_DbIsShared(objPtr, __FILE__, __LINE__)
    497 #else
    498490#   define Tcl_IncrRefCount(objPtr) \
    499491        ++(objPtr)->refCount
     
    502494#   define Tcl_IsShared(objPtr) \
    503495        ((objPtr)->refCount > 1)
    504 #endif
    505496
    506497/*
    507498 * Macros and definitions that help to debug the use of Tcl objects.
    508  * When TCL_MEM_DEBUG is defined, the Tcl_New* declarations are
    509  * overridden to call debugging versions of the object creation procedures.
    510499 */
    511500
     
    519508EXTERN Tcl_Obj *        Tcl_NewStringObj _ANSI_ARGS_((char *bytes,
    520509                            int length));
    521 
    522 #ifdef TCL_MEM_DEBUG
    523 #  define Tcl_NewBooleanObj(val) \
    524      Tcl_DbNewBooleanObj(val, __FILE__, __LINE__)
    525 #  define Tcl_NewDoubleObj(val) \
    526      Tcl_DbNewDoubleObj(val, __FILE__, __LINE__)
    527 #  define Tcl_NewIntObj(val) \
    528      Tcl_DbNewLongObj(val, __FILE__, __LINE__)
    529 #  define Tcl_NewListObj(objc, objv) \
    530      Tcl_DbNewListObj(objc, objv, __FILE__, __LINE__)
    531 #  define Tcl_NewLongObj(val) \
    532      Tcl_DbNewLongObj(val, __FILE__, __LINE__)
    533 #  define Tcl_NewObj() \
    534      Tcl_DbNewObj(__FILE__, __LINE__)
    535 #  define Tcl_NewStringObj(bytes, len) \
    536      Tcl_DbNewStringObj(bytes, len, __FILE__, __LINE__)
    537 #endif /* TCL_MEM_DEBUG */
    538510
    539511/*
     
    726698                            unsigned int size));
    727699
    728 #ifdef TCL_MEM_DEBUG
    729 
    730 #  define Tcl_Alloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
    731 #  define Tcl_Free(x)  Tcl_DbCkfree(x, __FILE__, __LINE__)
    732 #  define Tcl_Realloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
    733 #  define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)
    734 #  define ckfree(x)  Tcl_DbCkfree(x, __FILE__, __LINE__)
    735 #  define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)
    736 
    737 EXTERN int              Tcl_DumpActiveMemory _ANSI_ARGS_((char *fileName));
    738 EXTERN void             Tcl_ValidateAllMemory _ANSI_ARGS_((char *file,
    739                             int line));
    740 
    741 #else
    742 
    743700/*
    744701 * If USE_TCLALLOC is true, then we need to call Tcl_Alloc instead of
     
    760717#  define Tcl_DumpActiveMemory(x)
    761718#  define Tcl_ValidateAllMemory(x,y)
    762 
    763 #endif /* TCL_MEM_DEBUG */
    764719
    765720/*
  • external/tcl/tclBasic.c

    re39abb4 r0e7d64a  
    32873287            TclInitByteCodeObj(objPtr, &compEnv);
    32883288            codePtr = (ByteCode *) objPtr->internalRep.otherValuePtr;
    3289             if (tclTraceCompile == 2) {
    3290                 TclPrintByteCodeObj(interp, objPtr);
    3291             }
    32923289            TclFreeCompileEnv(&compEnv);
    32933290        } else {
  • external/tcl/tclCkalloc.c

    re39abb4 r0e7d64a  
    2222#define TRUE    1
    2323
    24 #ifdef TCL_MEM_DEBUG
    25 
    26 /*
    27  * One of the following structures is allocated each time the
    28  * "memory tag" command is invoked, to hold the current tag.
    29  */
    30 
    31 typedef struct MemTag {
    32     int refCount;               /* Number of mem_headers referencing
    33                                  * this tag. */
    34     char string[4];             /* Actual size of string will be as
    35                                  * large as needed for actual tag.  This
    36                                  * must be the last field in the structure. */
    37 } MemTag;
    38 
    39 #define TAG_SIZE(bytesInString) ((unsigned) sizeof(MemTag) + bytesInString - 3)
    40 
    41 static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers
    42                                  * (set by "memory tag" command). */
    43 
    44 /*
    45  * One of the following structures is allocated just before each
    46  * dynamically allocated chunk of memory, both to record information
    47  * about the chunk and to help detect chunk under-runs.
    48  */
    49 
    50 #define LOW_GUARD_SIZE (8 + (32 - (sizeof(long) + sizeof(int)))%8)
    51 struct mem_header {
    52     struct mem_header *flink;
    53     struct mem_header *blink;
    54     MemTag *tagPtr;             /* Tag from "memory tag" command;  may be
    55                                  * NULL. */
    56     char *file;
    57     long length;
    58     int line;
    59     unsigned char low_guard[LOW_GUARD_SIZE];
    60                                 /* Aligns body on 8-byte boundary, plus
    61                                  * provides at least 8 additional guard bytes
    62                                  * to detect underruns. */
    63     char body[1];               /* First byte of client's space.  Actual
    64                                  * size of this field will be larger than
    65                                  * one. */
    66 };
    67 
    68 static struct mem_header *allocHead = NULL;  /* List of allocated structures */
    69 
    70 #define GUARD_VALUE  0141
    71 
    72 /*
    73  * The following macro determines the amount of guard space *above* each
    74  * chunk of memory.
    75  */
    76 
    77 #define HIGH_GUARD_SIZE 8
    78 
    79 /*
    80  * The following macro computes the offset of the "body" field within
    81  * mem_header.  It is used to get back to the header pointer from the
    82  * body pointer that's used by clients.
    83  */
    84 
    85 #define BODY_OFFSET \
    86         ((unsigned long) (&((struct mem_header *) 0)->body))
    87 
    88 static int total_mallocs = 0;
    89 static int total_frees = 0;
    90 static int current_bytes_malloced = 0;
    91 static int maximum_bytes_malloced = 0;
    92 static int current_malloc_packets = 0;
    93 static int maximum_malloc_packets = 0;
    94 static int break_on_malloc = 0;
    95 static int trace_on_at_malloc = 0;
    96 static int  alloc_tracing = FALSE;
    97 static int  init_malloced_bodies = TRUE;
    98 #ifdef MEM_VALIDATE
    99     static int  validate_memory = TRUE;
    100 #else
    101     static int  validate_memory = FALSE;
    102 #endif
    103 
    104 /*
    105  * Prototypes for procedures defined in this file:
    106  */
    107 
    108 static int              MemoryCmd _ANSI_ARGS_((ClientData clientData,
    109                             Tcl_Interp *interp, int argc, char **argv));
    110 static void             ValidateMemory _ANSI_ARGS_((
    111                             struct mem_header *memHeaderP, char *file,
    112                             int line, int nukeGuards));
    113 
    114 
    115 /*
    116  *----------------------------------------------------------------------
    117  *
    118  * TclDumpMemoryInfo --
    119  *     Display the global memory management statistics.
    120  *
    121  *----------------------------------------------------------------------
    122  */
    123 void
    124 TclDumpMemoryInfo(outFile)
    125     FILE *outFile;
    126 {
    127         fprintf(outFile,"total mallocs             %10d\n",
    128                 total_mallocs);
    129         fprintf(outFile,"total frees               %10d\n",
    130                 total_frees);
    131         fprintf(outFile,"current packets allocated %10d\n",
    132                 current_malloc_packets);
    133         fprintf(outFile,"current bytes allocated   %10d\n",
    134                 current_bytes_malloced);
    135         fprintf(outFile,"maximum packets allocated %10d\n",
    136                 maximum_malloc_packets);
    137         fprintf(outFile,"maximum bytes allocated   %10d\n",
    138                 maximum_bytes_malloced);
    139 }
    140 
    141 
    142 /*
    143  *----------------------------------------------------------------------
    144  *
    145  * ValidateMemory --
    146  *     Procedure to validate allocted memory guard zones.
    147  *
    148  *----------------------------------------------------------------------
    149  */
    150 static void
    151 ValidateMemory(memHeaderP, file, line, nukeGuards)
    152     struct mem_header *memHeaderP;
    153     char              *file;
    154     int                line;
    155     int                nukeGuards;
    156 {
    157     unsigned char *hiPtr;
    158     int   idx;
    159     int   guard_failed = FALSE;
    160     int byte;
    161    
    162     for (idx = 0; idx < LOW_GUARD_SIZE; idx++) {
    163         byte = *(memHeaderP->low_guard + idx);
    164         if (byte != GUARD_VALUE) {
    165             guard_failed = TRUE;
    166             fflush(stdout);
    167             byte &= 0xff;
    168             fprintf(stderr, "low guard byte %d is 0x%x  \t%c\n", idx, byte,
    169                     (isprint(UCHAR(byte)) ? byte : ' '));
    170         }
    171     }
    172     if (guard_failed) {
    173         TclDumpMemoryInfo (stderr);
    174         fprintf(stderr, "low guard failed at %lx, %s %d\n",
    175                  (long unsigned int) memHeaderP->body, file, line);
    176         fflush(stderr);  /* In case name pointer is bad. */
    177         fprintf(stderr, "%ld bytes allocated at (%s %d)\n", memHeaderP->length,
    178                 memHeaderP->file, memHeaderP->line);
    179         panic ("Memory validation failure");
    180     }
    181 
    182     hiPtr = (unsigned char *)memHeaderP->body + memHeaderP->length;
    183     for (idx = 0; idx < HIGH_GUARD_SIZE; idx++) {
    184         byte = *(hiPtr + idx);
    185         if (byte != GUARD_VALUE) {
    186             guard_failed = TRUE;
    187             fflush (stdout);
    188             byte &= 0xff;
    189             fprintf(stderr, "hi guard byte %d is 0x%x  \t%c\n", idx, byte,
    190                     (isprint(UCHAR(byte)) ? byte : ' '));
    191         }
    192     }
    193 
    194     if (guard_failed) {
    195         TclDumpMemoryInfo (stderr);
    196         fprintf(stderr, "high guard failed at %lx, %s %d\n",
    197                  (long unsigned int) memHeaderP->body, file, line);
    198         fflush(stderr);  /* In case name pointer is bad. */
    199         fprintf(stderr, "%ld bytes allocated at (%s %d)\n",
    200                 memHeaderP->length, memHeaderP->file,
    201                 memHeaderP->line);
    202         panic("Memory validation failure");
    203     }
    204 
    205     if (nukeGuards) {
    206         memset ((char *) memHeaderP->low_guard, 0, LOW_GUARD_SIZE);
    207         memset ((char *) hiPtr, 0, HIGH_GUARD_SIZE);
    208     }
    209 
    210 }
    211 
    212 
    213 /*
    214  *----------------------------------------------------------------------
    215  *
    216  * Tcl_ValidateAllMemory --
    217  *     Validates guard regions for all allocated memory.
    218  *
    219  *----------------------------------------------------------------------
    220  */
    221 void
    222 Tcl_ValidateAllMemory (file, line)
    223     char  *file;
    224     int    line;
    225 {
    226     struct mem_header *memScanP;
    227 
    228     for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink)
    229         ValidateMemory(memScanP, file, line, FALSE);
    230 
    231 }
    232 
    233 
    234 /*
    235  *----------------------------------------------------------------------
    236  *
    237  * Tcl_DumpActiveMemory --
    238  *     Displays all allocated memory to stderr.
    239  *
    240  * Results:
    241  *     Return TCL_ERROR if an error accessing the file occures, `errno'
    242  *     will have the file error number left in it.
    243  *----------------------------------------------------------------------
    244  */
    245 int
    246 Tcl_DumpActiveMemory (fileName)
    247     char *fileName;
    248 {
    249     FILE              *fileP;
    250     struct mem_header *memScanP;
    251     char              *address;
    252 
    253     fileP = fopen(fileName, "w");
    254     if (fileP == NULL)
    255         return TCL_ERROR;
    256 
    257     for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink) {
    258         address = &memScanP->body [0];
    259         fprintf(fileP, "%8lx - %8lx  %7ld @ %s %d %s",
    260                 (long unsigned int) address,
    261                  (long unsigned int) address + memScanP->length - 1,
    262                  memScanP->length, memScanP->file, memScanP->line,
    263                  (memScanP->tagPtr == NULL) ? "" : memScanP->tagPtr->string);
    264         (void) fputc('\n', fileP);
    265     }
    266     fclose (fileP);
    267     return TCL_OK;
    268 }
    269 
    270 
    271 /*
    272  *----------------------------------------------------------------------
    273  *
    274  * Tcl_DbCkalloc - debugging ckalloc
    275  *
    276  *        Allocate the requested amount of space plus some extra for
    277  *        guard bands at both ends of the request, plus a size, panicing
    278  *        if there isn't enough space, then write in the guard bands
    279  *        and return the address of the space in the middle that the
    280  *        user asked for.
    281  *
    282  *        The second and third arguments are file and line, these contain
    283  *        the filename and line number corresponding to the caller.
    284  *        These are sent by the ckalloc macro; it uses the preprocessor
    285  *        autodefines __FILE__ and __LINE__.
    286  *
    287  *----------------------------------------------------------------------
    288  */
    289 char *
    290 Tcl_DbCkalloc(size, file, line)
    291     unsigned int size;
    292     char        *file;
    293     int          line;
    294 {
    295     struct mem_header *result;
    296 
    297     if (validate_memory)
    298         Tcl_ValidateAllMemory (file, line);
    299 
    300     result = (struct mem_header *) TclpAlloc((unsigned)size +
    301                               sizeof(struct mem_header) + HIGH_GUARD_SIZE);
    302     if (result == NULL) {
    303         fflush(stdout);
    304         TclDumpMemoryInfo(stderr);
    305         panic("unable to alloc %d bytes, %s line %d", size, file,
    306               line);
    307     }
    308 
    309     /*
    310      * Fill in guard zones and size.  Also initialize the contents of
    311      * the block with bogus bytes to detect uses of initialized data.
    312      * Link into allocated list.
    313      */
    314     if (init_malloced_bodies) {
    315         memset ((VOID *) result, GUARD_VALUE,
    316                 size + sizeof(struct mem_header) + HIGH_GUARD_SIZE);
    317     } else {
    318         memset ((char *) result->low_guard, GUARD_VALUE, LOW_GUARD_SIZE);
    319         memset (result->body + size, GUARD_VALUE, HIGH_GUARD_SIZE);
    320     }
    321     result->length = size;
    322     result->tagPtr = curTagPtr;
    323     if (curTagPtr != NULL) {
    324         curTagPtr->refCount++;
    325     }
    326     result->file = file;
    327     result->line = line;
    328     result->flink = allocHead;
    329     result->blink = NULL;
    330     if (allocHead != NULL)
    331         allocHead->blink = result;
    332     allocHead = result;
    333 
    334     total_mallocs++;
    335     if (trace_on_at_malloc && (total_mallocs >= trace_on_at_malloc)) {
    336         (void) fflush(stdout);
    337         fprintf(stderr, "reached malloc trace enable point (%d)\n",
    338                 total_mallocs);
    339         fflush(stderr);
    340         alloc_tracing = TRUE;
    341         trace_on_at_malloc = 0;
    342     }
    343 
    344     if (alloc_tracing)
    345         fprintf(stderr,"ckalloc %lx %d %s %d\n",
    346                 (long unsigned int) result->body, size, file, line);
    347 
    348     if (break_on_malloc && (total_mallocs >= break_on_malloc)) {
    349         break_on_malloc = 0;
    350         (void) fflush(stdout);
    351         fprintf(stderr,"reached malloc break limit (%d)\n",
    352                 total_mallocs);
    353         fprintf(stderr, "program will now enter C debugger\n");
    354         (void) fflush(stderr);
    355         abort();
    356     }
    357 
    358     current_malloc_packets++;
    359     if (current_malloc_packets > maximum_malloc_packets)
    360         maximum_malloc_packets = current_malloc_packets;
    361     current_bytes_malloced += size;
    362     if (current_bytes_malloced > maximum_bytes_malloced)
    363         maximum_bytes_malloced = current_bytes_malloced;
    364 
    365     return result->body;
    366 }
    367 
    368 
    369 /*
    370  *----------------------------------------------------------------------
    371  *
    372  * Tcl_DbCkfree - debugging ckfree
    373  *
    374  *        Verify that the low and high guards are intact, and if so
    375  *        then free the buffer else panic.
    376  *
    377  *        The guards are erased after being checked to catch duplicate
    378  *        frees.
    379  *
    380  *        The second and third arguments are file and line, these contain
    381  *        the filename and line number corresponding to the caller.
    382  *        These are sent by the ckfree macro; it uses the preprocessor
    383  *        autodefines __FILE__ and __LINE__.
    384  *
    385  *----------------------------------------------------------------------
    386  */
    387 
    388 int
    389 Tcl_DbCkfree(ptr, file, line)
    390     char *  ptr;
    391     char     *file;
    392     int       line;
    393 {
    394     /*
    395      * The following cast is *very* tricky.  Must convert the pointer
    396      * to an integer before doing arithmetic on it, because otherwise
    397      * the arithmetic will be done differently (and incorrectly) on
    398      * word-addressed machines such as Crays (will subtract only bytes,
    399      * even though BODY_OFFSET is in words on these machines).
    400      */
    401 
    402     struct mem_header *memp = (struct mem_header *)
    403             (((unsigned long) ptr) - BODY_OFFSET);
    404 
    405     if (alloc_tracing)
    406         fprintf(stderr, "ckfree %lx %ld %s %d\n",
    407                 (long unsigned int) memp->body, memp->length, file, line);
    408 
    409     if (validate_memory)
    410         Tcl_ValidateAllMemory(file, line);
    411 
    412     ValidateMemory(memp, file, line, TRUE);
    413     if (init_malloced_bodies) {
    414         memset((VOID *) ptr, GUARD_VALUE, (size_t) memp->length);
    415     }
    416 
    417     total_frees++;
    418     current_malloc_packets--;
    419     current_bytes_malloced -= memp->length;
    420 
    421     if (memp->tagPtr != NULL) {
    422         memp->tagPtr->refCount--;
    423         if ((memp->tagPtr->refCount == 0) && (curTagPtr != memp->tagPtr)) {
    424             TclpFree((char *) memp->tagPtr);
    425         }
    426     }
    427 
    428     /*
    429      * Delink from allocated list
    430      */
    431     if (memp->flink != NULL)
    432         memp->flink->blink = memp->blink;
    433     if (memp->blink != NULL)
    434         memp->blink->flink = memp->flink;
    435     if (allocHead == memp)
    436         allocHead = memp->flink;
    437     TclpFree((char *) memp);
    438     return 0;
    439 }
    440 
    441 
    442 /*
    443  *--------------------------------------------------------------------
    444  *
    445  * Tcl_DbCkrealloc - debugging ckrealloc
    446  *
    447  *      Reallocate a chunk of memory by allocating a new one of the
    448  *      right size, copying the old data to the new location, and then
    449  *      freeing the old memory space, using all the memory checking
    450  *      features of this package.
    451  *
    452  *--------------------------------------------------------------------
    453  */
    454 char *
    455 Tcl_DbCkrealloc(ptr, size, file, line)
    456     char *ptr;
    457     unsigned int size;
    458     char *file;
    459     int line;
    460 {
    461     char *new;
    462     unsigned int copySize;
    463 
    464     /*
    465      * See comment from Tcl_DbCkfree before you change the following
    466      * line.
    467      */
    468 
    469     struct mem_header *memp = (struct mem_header *)
    470             (((unsigned long) ptr) - BODY_OFFSET);
    471 
    472     copySize = size;
    473     if (copySize > (unsigned int) memp->length) {
    474         copySize = memp->length;
    475     }
    476     new = Tcl_DbCkalloc(size, file, line);
    477     memcpy((VOID *) new, (VOID *) ptr, (size_t) copySize);
    478     Tcl_DbCkfree(ptr, file, line);
    479     return(new);
    480 }
    481 
    482 
    483 
    484 /*
    485  *----------------------------------------------------------------------
    486  *
    487  * Tcl_Alloc, et al. --
    488  *
    489  *      These functions are defined in terms of the debugging versions
    490  *      when TCL_MEM_DEBUG is set.
    491  *
    492  * Results:
    493  *      Same as the debug versions.
    494  *
    495  * Side effects:
    496  *      Same as the debug versions.
    497  *
    498  *----------------------------------------------------------------------
    499  */
    500 
    501 #undef Tcl_Alloc
    502 #undef Tcl_Free
    503 #undef Tcl_Realloc
    504 
    505 char *
    506 Tcl_Alloc(size)
    507     unsigned int size;
    508 {
    509     return Tcl_DbCkalloc(size, "unknown", 0);
    510 }
    511 
    512 void
    513 Tcl_Free(ptr)
    514     char *ptr;
    515 {
    516     Tcl_DbCkfree(ptr, "unknown", 0);
    517 }
    518 
    519 char *
    520 Tcl_Realloc(ptr, size)
    521     char *ptr;
    522     unsigned int size;
    523 {
    524     return Tcl_DbCkrealloc(ptr, size, "unknown", 0);
    525 }
    526 
    527 
    528 /*
    529  *----------------------------------------------------------------------
    530  *
    531  * MemoryCmd --
    532  *     Implements the TCL memory command:
    533  *       memory info
    534  *       memory display
    535  *       break_on_malloc count
    536  *       trace_on_at_malloc count
    537  *       trace on|off
    538  *       validate on|off
    539  *
    540  * Results:
    541  *     Standard TCL results.
    542  *
    543  *----------------------------------------------------------------------
    544  */
    545         /* ARGSUSED */
    546 static int
    547 MemoryCmd (clientData, interp, argc, argv)
    548     ClientData  clientData;
    549     Tcl_Interp *interp;
    550     int         argc;
    551     char      **argv;
    552 {
    553     char *fileName;
    554     Tcl_DString buffer;
    555     int result;
    556 
    557     if (argc < 2) {
    558         Tcl_AppendResult(interp, "wrong # args: should be \"",
    559                 argv[0], " option [args..]\"", (char *) NULL);
    560         return TCL_ERROR;
    561     }
    562 
    563     if (strcmp(argv[1],"active") == 0) {
    564         if (argc != 3) {
    565             Tcl_AppendResult(interp, "wrong # args: should be \"",
    566                     argv[0], " active file\"", (char *) NULL);
    567             return TCL_ERROR;
    568         }
    569         fileName = Tcl_TranslateFileName(interp, argv[2], &buffer);
    570         if (fileName == NULL) {
    571             return TCL_ERROR;
    572         }
    573         result = Tcl_DumpActiveMemory (fileName);
    574         Tcl_DStringFree(&buffer);
    575         if (result != TCL_OK) {
    576             Tcl_AppendResult(interp, "error accessing ", argv[2],
    577                     (char *) NULL);
    578             return TCL_ERROR;
    579         }
    580         return TCL_OK;
    581     }
    582     if (strcmp(argv[1],"break_on_malloc") == 0) {
    583         if (argc != 3) {
    584             goto argError;
    585         }
    586         if (Tcl_GetInt(interp, argv[2], &break_on_malloc) != TCL_OK) {
    587             return TCL_ERROR;
    588         }
    589         return TCL_OK;
    590     }
    591     if (strcmp(argv[1],"info") == 0) {
    592         TclDumpMemoryInfo(stdout);
    593         return TCL_OK;
    594     }
    595     if (strcmp(argv[1],"init") == 0) {
    596         if (argc != 3) {
    597             goto bad_suboption;
    598         }
    599         init_malloced_bodies = (strcmp(argv[2],"on") == 0);
    600         return TCL_OK;
    601     }
    602     if (strcmp(argv[1],"tag") == 0) {
    603         if (argc != 3) {
    604             Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    605                     " tag string\"", (char *) NULL);
    606             return TCL_ERROR;
    607         }
    608         if ((curTagPtr != NULL) && (curTagPtr->refCount == 0)) {
    609             TclpFree((char *) curTagPtr);
    610         }
    611         curTagPtr = (MemTag *) TclpAlloc(TAG_SIZE(strlen(argv[2])));
    612         curTagPtr->refCount = 0;
    613         strcpy(curTagPtr->string, argv[2]);
    614         return TCL_OK;
    615     }
    616     if (strcmp(argv[1],"trace") == 0) {
    617         if (argc != 3) {
    618             goto bad_suboption;
    619         }
    620         alloc_tracing = (strcmp(argv[2],"on") == 0);
    621         return TCL_OK;
    622     }
    623 
    624     if (strcmp(argv[1],"trace_on_at_malloc") == 0) {
    625         if (argc != 3) {
    626             goto argError;
    627         }
    628         if (Tcl_GetInt(interp, argv[2], &trace_on_at_malloc) != TCL_OK) {
    629             return TCL_ERROR;
    630         }
    631         return TCL_OK;
    632     }
    633     if (strcmp(argv[1],"validate") == 0) {
    634         if (argc != 3) {
    635             goto bad_suboption;
    636         }
    637         validate_memory = (strcmp(argv[2],"on") == 0);
    638         return TCL_OK;
    639     }
    640 
    641     Tcl_AppendResult(interp, "bad option \"", argv[1],
    642             "\": should be active, break_on_malloc, info, init, ",
    643             "tag, trace, trace_on_at_malloc, or validate", (char *) NULL);
    644     return TCL_ERROR;
    645 
    646 argError:
    647     Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    648             " ", argv[1], " count\"", (char *) NULL);
    649     return TCL_ERROR;
    650 
    651 bad_suboption:
    652     Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
    653             " ", argv[1], " on|off\"", (char *) NULL);
    654     return TCL_ERROR;
    655 }
    656 
    657 
    658 /*
    659  *----------------------------------------------------------------------
    660  *
    661  * Tcl_InitMemory --
    662  *     Initialize the memory command.
    663  *
    664  *----------------------------------------------------------------------
    665  */
    666 void
    667 Tcl_InitMemory(interp)
    668     Tcl_Interp *interp;
    669 {
    670     Tcl_CreateCommand (interp, "memory", MemoryCmd, (ClientData) NULL,
    671             (Tcl_CmdDeleteProc *) NULL);
    672 }
    673 
    674 #else
    675 
    676 
    677 
    67824/*
    67925 *----------------------------------------------------------------------
    68026 *
    68127 * Tcl_Alloc --
    682  *     Interface to TclpAlloc when TCL_MEM_DEBUG is disabled.  It does check
    683  *    that memory was actually allocated.
     28 *      Interface to TclpAlloc.
     29 *      It does check that memory was actually allocated.
    68430 *
    68531 *----------------------------------------------------------------------
     
    72268 *
    72369 * Tcl_Realloc --
    724  *     Interface to TclpRealloc when TCL_MEM_DEBUG is disabled.  It does
    725  *    check that memory was actually allocated.
     70 *      Interface to TclpRealloc.
     71 *      It does check that memory was actually allocated.
    72672 *
    72773 *----------------------------------------------------------------------
     
    765111 *
    766112 * Tcl_Free --
    767  *     Interface to TclpFree when TCL_MEM_DEBUG is disabled.  Done here
    768  *     rather in the macro to keep some modules from being compiled with
    769  *     TCL_MEM_DEBUG enabled and some with it disabled.
     113 *      Interface to TclpFree.
    770114 *
    771115 *----------------------------------------------------------------------
     
    778122        TclpFree(ptr);
    779123}
    780 
    781 int
    782 Tcl_DbCkfree(ptr, file, line)
    783     char *  ptr;
    784     char     *file;
    785     int       line;
    786 {
    787     TclpFree(ptr);
    788     return 0;
    789 }
    790 
    791 
    792 /*
    793  *----------------------------------------------------------------------
    794  *
    795  * Tcl_InitMemory --
    796  *     Dummy initialization for memory command, which is only available
    797  *     if TCL_MEM_DEBUG is on.
    798  *
    799  *----------------------------------------------------------------------
    800  */
    801         /* ARGSUSED */
    802 void
    803 Tcl_InitMemory(interp)
    804     Tcl_Interp *interp;
    805 {
    806 }
    807 
    808 #undef Tcl_DumpActiveMemory
    809 #undef Tcl_ValidateAllMemory
    810 
    811 extern int              Tcl_DumpActiveMemory _ANSI_ARGS_((char *fileName));
    812 extern void             Tcl_ValidateAllMemory _ANSI_ARGS_((char *file,
    813                             int line));
    814 
    815 int
    816 Tcl_DumpActiveMemory(fileName)
    817     char *fileName;
    818 {
    819     return TCL_OK;
    820 }
    821 
    822 void
    823 Tcl_ValidateAllMemory(file, line)
    824     char  *file;
    825     int    line;
    826 {
    827 }
    828 
    829 #endif
  • external/tcl/tclCompExpr.c

    re39abb4 r0e7d64a  
    3131#define ERANGE 34
    3232#endif
    33 
    34 /*
    35  * Boolean variable that controls whether expression compilation tracing
    36  * is enabled.
    37  */
    38 
    39 #ifdef TCL_COMPILE_DEBUG
    40 static int traceCompileExpr = 0;
    41 #endif /* TCL_COMPILE_DEBUG */
    4233
    4334/*
     
    132123#define NOT             (COLON + 1)
    133124#define BIT_NOT         (NOT + 1)
    134 
    135 /*
    136  * Mapping from tokens to strings; used for debugging messages. These
    137  * entries must match the order and number of the token definitions above.
    138  */
    139 
    140 #ifdef TCL_COMPILE_DEBUG
    141 static char *tokenStrings[] = {
    142     "LITERAL", "FUNCNAME",
    143     "[", "]", "(", ")", "$", "\"", ",", "END", "UNKNOWN",
    144     "*", "/", "%", "+", "-",
    145     "<<", ">>", "<", ">", "<=", ">=", "==", "!=",
    146     "&", "^", "|", "&&", "||", "?", ":",
    147     "!", "~"
    148 };
    149 #endif /* TCL_COMPILE_DEBUG */
    150125
    151126/*
     
    198173                            ExprInfo *infoPtr, CompileEnv *envPtr));
    199174
    200 /*
    201  * Macro used to debug the execution of the recursive descent parser used
    202  * to compile expressions.
    203  */
    204 
    205 #ifdef TCL_COMPILE_DEBUG
    206 #define HERE(production, level) \
    207     if (traceCompileExpr) { \
    208         fprintf(stderr, "%*s%s: token=%s, next=\"%.20s\"\n", \
    209                 (level), " ", (production), tokenStrings[infoPtr->token], \
    210                 infoPtr->next); \
    211     }
    212 #else
    213 #define HERE(production, level)
    214 #endif /* TCL_COMPILE_DEBUG */
    215175
    216176
     
    277237                                 * to execute the expression. */
    278238    int result;
    279 
    280 #ifdef TCL_COMPILE_DEBUG
    281     if (traceCompileExpr) {
    282         fprintf(stderr, "expr: string=\"%.30s\"\n", string);
    283     }
    284 #endif /* TCL_COMPILE_DEBUG */
    285239
    286240    /*
     
    409363    int elseCodeOffset, currCodeOffset, jumpDist, result;
    410364   
    411     HERE("condExpr", 1);
    412365    result = CompileLorExpr(interp, infoPtr, flags, envPtr);
    413366    if (result != TCL_OK) {
     
    571524    Tcl_Obj *objPtr;
    572525   
    573     HERE("lorExpr", 2);
    574526    result = CompileLandExpr(interp, infoPtr, flags, envPtr);
    575527    if ((result != TCL_OK) || (infoPtr->token != OR)) {
     
    739691    Tcl_Obj *objPtr;
    740692
    741     HERE("landExpr", 3);
    742693    result = CompileBitOrExpr(interp, infoPtr, flags, envPtr);
    743694    if ((result != TCL_OK) || (infoPtr->token != AND)) {
     
    899850    int result;
    900851
    901     HERE("bitOrExpr", 4);
    902852    result = CompileBitXorExpr(interp, infoPtr, flags, envPtr);
    903853    if (result != TCL_OK) {
     
    970920    int result;
    971921
    972     HERE("bitXorExpr", 5);
    973922    result = CompileBitAndExpr(interp, infoPtr, flags, envPtr);
    974923    if (result != TCL_OK) {
     
    1041990    int result;
    1042991
    1043     HERE("bitAndExpr", 6);
    1044992    result = CompileEqualityExpr(interp, infoPtr, flags, envPtr);
    1045993    if (result != TCL_OK) {
     
    11121060    int op, result;
    11131061
    1114     HERE("equalityExpr", 7);
    11151062    result = CompileRelationalExpr(interp, infoPtr, flags, envPtr);
    11161063    if (result != TCL_OK) {
     
    11901137    int op, result;
    11911138
    1192     HERE("relationalExpr", 8);
    11931139    result = CompileShiftExpr(interp, infoPtr, flags, envPtr);
    11941140    if (result != TCL_OK) {
     
    12771223    int op, result;
    12781224
    1279     HERE("shiftExpr", 9);
    12801225    result = CompileAddExpr(interp, infoPtr, flags, envPtr);
    12811226    if (result != TCL_OK) {
     
    13551300    int op, result;
    13561301
    1357     HERE("addExpr", 10);
    13581302    result = CompileMultiplyExpr(interp, infoPtr, flags, envPtr);
    13591303    if (result != TCL_OK) {
     
    14331377    int op, result;
    14341378
    1435     HERE("multiplyExpr", 11);
    14361379    result = CompileUnaryExpr(interp, infoPtr, flags, envPtr);
    14371380    if (result != TCL_OK) {
     
    15131456    int op, result;
    15141457
    1515     HERE("unaryExpr", 12);
    15161458    op = infoPtr->token;
    15171459    if ((op == PLUS) || (op == MINUS) || (op == BIT_NOT) || (op == NOT)) {
     
    16081550     */
    16091551
    1610     HERE("primaryExpr", 13);
    16111552    theToken = infoPtr->token;
    16121553
  • external/tcl/tclCompile.c

    re39abb4 r0e7d64a  
    1717#include "tclInt.h"
    1818#include "tclCompile.h"
    19 
    20 /*
    21  * Variable that controls whether compilation tracing is enabled and, if so,
    22  * what level of tracing is desired:
    23  *    0: no compilation tracing
    24  *    1: summarize compilation of top level cmds and proc bodies
    25  *    2: display all instructions of each ByteCode compiled
    26  * This variable is linked to the Tcl variable "tcl_traceCompile".
    27  */
    28 
    29 int tclTraceCompile = 0;
    30 static int traceInitialized = 0;
    31 
    32 /*
    33  * Count of the number of compilations and various other compilation-
    34  * related statistics.
    35  */
    36 
    37 #ifdef TCL_COMPILE_STATS
    38 long tclNumCompilations = 0;
    39 double tclTotalSourceBytes = 0.0;
    40 double tclTotalCodeBytes = 0.0;
    41 
    42 double tclTotalInstBytes = 0.0;
    43 double tclTotalObjBytes = 0.0;
    44 double tclTotalExceptBytes = 0.0;
    45 double tclTotalAuxBytes = 0.0;
    46 double tclTotalCmdMapBytes = 0.0;
    47 
    48 double tclCurrentSourceBytes = 0.0;
    49 double tclCurrentCodeBytes = 0.0;
    50 
    51 int tclSourceCount[32];
    52 int tclByteCodeCount[32];
    53 #endif /* TCL_COMPILE_STATS */
    5419
    5520/*
     
    443408 *----------------------------------------------------------------------
    444409 *
    445  * TclPrintByteCodeObj --
    446  *
    447  *      This procedure prints ("disassembles") the instructions of a
    448  *      bytecode object to stdout.
    449  *
    450  * Results:
    451  *      None.
    452  *
    453  * Side effects:
    454  *      None.
    455  *
    456  *----------------------------------------------------------------------
    457  */
    458 
    459 void
    460 TclPrintByteCodeObj(interp, objPtr)
    461     Tcl_Interp *interp;         /* Used only for Tcl_GetStringFromObj. */
    462     Tcl_Obj *objPtr;            /* The bytecode object to disassemble. */
    463 {
    464     ByteCode* codePtr = (ByteCode *) objPtr->internalRep.otherValuePtr;
    465     unsigned char *codeStart, *codeLimit, *pc;
    466     unsigned char *codeDeltaNext, *codeLengthNext;
    467     unsigned char *srcDeltaNext, *srcLengthNext;
    468     int codeOffset, codeLen, srcOffset, srcLen;
    469     int numCmds, numObjs, delta, objBytes, i;
    470 
    471     if (codePtr->refCount <= 0) {
    472         return;                 /* already freed */
    473     }
    474 
    475     codeStart = codePtr->codeStart;
    476     codeLimit = (codeStart + codePtr->numCodeBytes);
    477     numCmds = codePtr->numCommands;
    478     numObjs = codePtr->numObjects;
    479 
    480     objBytes = (numObjs * sizeof(Tcl_Obj));
    481     for (i = 0;  i < numObjs;  i++) {
    482         Tcl_Obj *litObjPtr = codePtr->objArrayPtr[i];
    483         if (litObjPtr->bytes != NULL) {
    484             objBytes += litObjPtr->length;
    485         }
    486     }
    487 
    488     /*
    489      * Print header lines describing the ByteCode.
    490      */
    491 
    492     fprintf(stdout, "\nByteCode 0x%x, ref ct %u, epoch %u, interp 0x%x(epoch %u)\n",
    493             (unsigned int) codePtr, codePtr->refCount,
    494             codePtr->compileEpoch, (unsigned int) codePtr->iPtr,
    495             codePtr->iPtr->compileEpoch);
    496     fprintf(stdout, "  Source ");
    497     TclPrintSource(stdout, codePtr->source,
    498             TclMin(codePtr->numSrcChars, 70));
    499     fprintf(stdout, "\n  Cmds %d, chars %d, inst %d, objs %u, aux %d, stk depth %u, code/src %.2f\n",
    500             numCmds, codePtr->numSrcChars, codePtr->numCodeBytes, numObjs,
    501             codePtr->numAuxDataItems, codePtr->maxStackDepth,
    502             (codePtr->numSrcChars?
    503                     ((float)codePtr->totalSize)/((float)codePtr->numSrcChars) : 0.0));
    504     fprintf(stdout, "  Code %zu = %u(header)+%d(inst)+%d(objs)+%u(exc)+%u(aux)+%d(cmd map)\n",
    505             codePtr->totalSize, sizeof(ByteCode), codePtr->numCodeBytes,
    506             objBytes, (codePtr->numExcRanges * sizeof(ExceptionRange)),
    507             (codePtr->numAuxDataItems * sizeof(AuxData)),
    508             codePtr->numCmdLocBytes);
    509 
    510     /*
    511      * If the ByteCode is the compiled body of a Tcl procedure, print
    512      * information about that procedure. Note that we don't know the
    513      * procedure's name since ByteCode's can be shared among procedures.
    514      */
    515    
    516     if (codePtr->procPtr != NULL) {
    517         Proc *procPtr = codePtr->procPtr;
    518         int numCompiledLocals = procPtr->numCompiledLocals;
    519         fprintf(stdout,
    520                 "  Proc 0x%x, ref ct %d, args %d, compiled locals %d\n",
    521                 (unsigned int) procPtr, procPtr->refCount, procPtr->numArgs,
    522                 numCompiledLocals);
    523         if (numCompiledLocals > 0) {
    524             CompiledLocal *localPtr = procPtr->firstLocalPtr;
    525             for (i = 0;  i < numCompiledLocals;  i++) {
    526                 fprintf(stdout, "      %d: slot %d%s%s%s%s%s%s",
    527                         i, localPtr->frameIndex,
    528                         ((localPtr->flags & VAR_SCALAR)?  ", scalar"  : ""),
    529                         ((localPtr->flags & VAR_ARRAY)?  ", array"  : ""),
    530                         ((localPtr->flags & VAR_LINK)?  ", link"  : ""),
    531                         ((localPtr->flags & VAR_ARGUMENT)?  ", arg"  : ""),
    532                         ((localPtr->flags & VAR_TEMPORARY)? ", temp" : ""),
    533                         ((localPtr->flags & VAR_RESOLVED)? ", resolved" : ""));
    534                 if (TclIsVarTemporary(localPtr)) {
    535                     fprintf(stdout,     "\n");
    536                 } else {
    537                     fprintf(stdout,     ", name=\"%s\"\n", localPtr->name);
    538                 }
    539                 localPtr = localPtr->nextPtr;
    540             }
    541         }
    542     }
    543 
    544     /*
    545      * Print the ExceptionRange array.
    546      */
    547 
    548     if (codePtr->numExcRanges > 0) {
    549         fprintf(stdout, "  Exception ranges %d, depth %d:\n",
    550                 codePtr->numExcRanges, codePtr->maxExcRangeDepth);
    551         for (i = 0;  i < codePtr->numExcRanges;  i++) {
    552             ExceptionRange *rangePtr = &(codePtr->excRangeArrayPtr[i]);
    553             fprintf(stdout, "      %d: level %d, %s, pc %d-%d, ",
    554                     i, rangePtr->nestingLevel,
    555                     ((rangePtr->type == LOOP_EXCEPTION_RANGE)? "loop":"catch"),
    556                     rangePtr->codeOffset,
    557                     (rangePtr->codeOffset + rangePtr->numCodeBytes - 1));
    558             switch (rangePtr->type) {
    559             case LOOP_EXCEPTION_RANGE:
    560                 fprintf(stdout, "continue %d, break %d\n",
    561                         rangePtr->continueOffset, rangePtr->breakOffset);
    562                 break;
    563             case CATCH_EXCEPTION_RANGE:
    564                 fprintf(stdout, "catch %d\n", rangePtr->catchOffset);
    565                 break;
    566             default:
    567                 panic("TclPrintSource: unrecognized ExceptionRange type %d\n",
    568                         rangePtr->type);
    569             }
    570         }
    571     }
    572    
    573     /*
    574      * If there were no commands (e.g., an expression or an empty string
    575      * was compiled), just print all instructions and return.
    576      */
    577 
    578     if (numCmds == 0) {
    579         pc = codeStart;
    580         while (pc < codeLimit) {
    581             fprintf(stdout, "    ");
    582             pc += TclPrintInstruction(codePtr, pc);
    583         }
    584         return;
    585     }
    586    
    587     /*
    588      * Print table showing the code offset, source offset, and source
    589      * length for each command. These are encoded as a sequence of bytes.
    590      */
    591 
    592     fprintf(stdout, "  Commands %d:", numCmds);
    593     codeDeltaNext = codePtr->codeDeltaStart;
    594     codeLengthNext = codePtr->codeLengthStart;
    595     srcDeltaNext  = codePtr->srcDeltaStart;
    596     srcLengthNext = codePtr->srcLengthStart;
    597     codeOffset = srcOffset = 0;
    598     for (i = 0;  i < numCmds;  i++) {
    599         if ((unsigned int) (*codeDeltaNext) == (unsigned int) 0xFF) {
    600             codeDeltaNext++;
    601             delta = TclGetInt4AtPtr(codeDeltaNext);
    602             codeDeltaNext += 4;
    603         } else {
    604             delta = TclGetInt1AtPtr(codeDeltaNext);
    605             codeDeltaNext++;
    606         }
    607         codeOffset += delta;
    608 
    609         if ((unsigned int) (*codeLengthNext) == (unsigned int) 0xFF) {
    610             codeLengthNext++;
    611             codeLen = TclGetInt4AtPtr(codeLengthNext);
    612             codeLengthNext += 4;
    613         } else {
    614             codeLen = TclGetInt1AtPtr(codeLengthNext);
    615             codeLengthNext++;
    616         }
    617        
    618         if ((unsigned int) (*srcDeltaNext) == (unsigned int) 0xFF) {
    619             srcDeltaNext++;
    620             delta = TclGetInt4AtPtr(srcDeltaNext);
    621             srcDeltaNext += 4;
    622         } else {
    623             delta = TclGetInt1AtPtr(srcDeltaNext);
    624             srcDeltaNext++;
    625         }
    626         srcOffset += delta;
    627 
    628         if ((unsigned int) (*srcLengthNext) == (unsigned int) 0xFF) {
    629             srcLengthNext++;
    630             srcLen = TclGetInt4AtPtr(srcLengthNext);
    631             srcLengthNext += 4;
    632         } else {
    633             srcLen = TclGetInt1AtPtr(srcLengthNext);
    634             srcLengthNext++;
    635         }
    636        
    637         fprintf(stdout, "%s%4d: pc %d-%d, source %d-%d",
    638                 ((i % 2)? "     " : "\n   "),
    639                 (i+1), codeOffset, (codeOffset + codeLen - 1),
    640                 srcOffset, (srcOffset + srcLen - 1));
    641     }
    642     if ((numCmds > 0) && ((numCmds % 2) != 0)) {
    643         fprintf(stdout, "\n");
    644     }
    645    
    646     /*
    647      * Print each instruction. If the instruction corresponds to the start
    648      * of a command, print the command's source. Note that we don't need
    649      * the code length here.
    650      */
    651 
    652     codeDeltaNext = codePtr->codeDeltaStart;
    653     srcDeltaNext  = codePtr->srcDeltaStart;
    654     srcLengthNext = codePtr->srcLengthStart;
    655     codeOffset = srcOffset = 0;
    656     pc = codeStart;
    657     for (i = 0;  i < numCmds;  i++) {
    658         if ((unsigned int) (*codeDeltaNext) == (unsigned int) 0xFF) {
    659             codeDeltaNext++;
    660             delta = TclGetInt4AtPtr(codeDeltaNext);
    661             codeDeltaNext += 4;
    662         } else {
    663             delta = TclGetInt1AtPtr(codeDeltaNext);
    664             codeDeltaNext++;
    665         }
    666         codeOffset += delta;
    667 
    668         if ((unsigned int) (*srcDeltaNext) == (unsigned int) 0xFF) {
    669             srcDeltaNext++;
    670             delta = TclGetInt4AtPtr(srcDeltaNext);
    671             srcDeltaNext += 4;
    672         } else {
    673             delta = TclGetInt1AtPtr(srcDeltaNext);
    674             srcDeltaNext++;
    675         }
    676         srcOffset += delta;
    677 
    678         if ((unsigned int) (*srcLengthNext) == (unsigned int) 0xFF) {
    679             srcLengthNext++;
    680             srcLen = TclGetInt4AtPtr(srcLengthNext);
    681             srcLengthNext += 4;
    682         } else {
    683             srcLen = TclGetInt1AtPtr(srcLengthNext);
    684             srcLengthNext++;
    685         }
    686 
    687         /*
    688          * Print instructions before command i.
    689          */
    690        
    691         while ((pc-codeStart) < codeOffset) {
    692             fprintf(stdout, "    ");
    693             pc += TclPrintInstruction(codePtr, pc);
    694         }
    695 
    696         fprintf(stdout, "  Command %d: ", (i+1));
    697         TclPrintSource(stdout, (codePtr->source + srcOffset),
    698                 TclMin(srcLen, 70));
    699         fprintf(stdout, "\n");
    700     }
    701     if (pc < codeLimit) {
    702         /*
    703          * Print instructions after the last command.
    704          */
    705 
    706         while (pc < codeLimit) {
    707             fprintf(stdout, "    ");
    708             pc += TclPrintInstruction(codePtr, pc);
    709         }
    710     }
    711 }
    712 
    713 
    714 /*
    715  *----------------------------------------------------------------------
    716  *
    717  * TclPrintInstruction --
    718  *
    719  *      This procedure prints ("disassembles") one instruction from a
    720  *      bytecode object to stdout.
    721  *
    722  * Results:
    723  *      Returns the length in bytes of the current instruiction.
    724  *
    725  * Side effects:
    726  *      None.
    727  *
    728  *----------------------------------------------------------------------
    729  */
    730 
    731 int
    732 TclPrintInstruction(codePtr, pc)
    733     ByteCode* codePtr;          /* Bytecode containing the instruction. */
    734     unsigned char *pc;          /* Points to first byte of instruction. */
    735 {
    736     Proc *procPtr = codePtr->procPtr;
    737     unsigned char opCode = *pc;
    738     register InstructionDesc *instDesc = &instructionTable[opCode];
    739     unsigned char *codeStart = codePtr->codeStart;
    740     unsigned int pcOffset = (pc - codeStart);
    741     int opnd, elemLen, i, j;
    742     Tcl_Obj *elemPtr;
    743     char *string;
    744    
    745     fprintf(stdout, "(%u) %s ", pcOffset, instDesc->name);
    746     for (i = 0;  i < instDesc->numOperands;  i++) {
    747         switch (instDesc->opTypes[i]) {
    748         case OPERAND_INT1:
    749             opnd = TclGetInt1AtPtr(pc+1+i);
    750             if ((i == 0) && ((opCode == INST_JUMP1)
    751                              || (opCode == INST_JUMP_TRUE1)
    752                              || (opCode == INST_JUMP_FALSE1))) {
    753                 fprintf(stdout, "%d     # pc %u", opnd, (pcOffset + opnd));
    754             } else {
    755                 fprintf(stdout, "%d", opnd);
    756             }
    757             break;
    758         case OPERAND_INT4:
    759             opnd = TclGetInt4AtPtr(pc+1+i);
    760             if ((i == 0) && ((opCode == INST_JUMP4)
    761                              || (opCode == INST_JUMP_TRUE4)
    762                              || (opCode == INST_JUMP_FALSE4))) {
    763                 fprintf(stdout, "%d     # pc %u", opnd, (pcOffset + opnd));
    764             } else {
    765                 fprintf(stdout, "%d", opnd);
    766             }
    767             break;
    768         case OPERAND_UINT1:
    769             opnd = TclGetUInt1AtPtr(pc+1+i);
    770             if ((i == 0) && (opCode == INST_PUSH1)) {
    771                 elemPtr = codePtr->objArrayPtr[opnd];
    772                 string = Tcl_GetStringFromObj(elemPtr, &elemLen);
    773                 fprintf(stdout, "%u     # ", (unsigned int) opnd);
    774                 TclPrintSource(stdout, string, TclMin(elemLen, 40));
    775             } else if ((i == 0) && ((opCode == INST_LOAD_SCALAR1)
    776                                     || (opCode == INST_LOAD_ARRAY1)
    777                                     || (opCode == INST_STORE_SCALAR1)
    778                                     || (opCode == INST_STORE_ARRAY1))) {
    779                 int localCt = procPtr->numCompiledLocals;
    780                 CompiledLocal *localPtr = procPtr->firstLocalPtr;
    781                 if (opnd >= localCt) {
    782                     panic("TclPrintInstruction: bad local var index %u (%u locals)\n",
    783                              (unsigned int) opnd, localCt);
    784                     return instDesc->numBytes;
    785                 }
    786                 for (j = 0;  j < opnd;  j++) {
    787                     localPtr = localPtr->nextPtr;
    788                 }
    789                 if (TclIsVarTemporary(localPtr)) {
    790                     fprintf(stdout, "%u # temp var %u",
    791                             (unsigned int) opnd, (unsigned int) opnd);
    792                 } else {
    793                     fprintf(stdout, "%u # var ", (unsigned int) opnd);
    794                     TclPrintSource(stdout, localPtr->name, 40);
    795                 }
    796             } else {
    797                 fprintf(stdout, "%u ", (unsigned int) opnd);
    798             }
    799             break;
    800         case OPERAND_UINT4:
    801             opnd = TclGetUInt4AtPtr(pc+1+i);
    802             if (opCode == INST_PUSH4) {
    803                 elemPtr = codePtr->objArrayPtr[opnd];
    804                 string = Tcl_GetStringFromObj(elemPtr, &elemLen);
    805                 fprintf(stdout, "%u     # ", opnd);
    806                 TclPrintSource(stdout, string, TclMin(elemLen, 40));
    807             } else if ((i == 0) && ((opCode == INST_LOAD_SCALAR4)
    808                                     || (opCode == INST_LOAD_ARRAY4)
    809                                     || (opCode == INST_STORE_SCALAR4)
    810                                     || (opCode == INST_STORE_ARRAY4))) {
    811                 int localCt = procPtr->numCompiledLocals;
    812                 CompiledLocal *localPtr = procPtr->firstLocalPtr;
    813                 if (opnd >= localCt) {
    814                     panic("TclPrintInstruction: bad local var index %u (%u locals)\n",
    815                              (unsigned int) opnd, localCt);
    816                     return instDesc->numBytes;
    817                 }
    818                 for (j = 0;  j < opnd;  j++) {
    819                     localPtr = localPtr->nextPtr;
    820                 }
    821                 if (TclIsVarTemporary(localPtr)) {
    822                     fprintf(stdout, "%u # temp var %u",
    823                             (unsigned int) opnd, (unsigned int) opnd);
    824                 } else {
    825                     fprintf(stdout, "%u # var ", (unsigned int) opnd);
    826                     TclPrintSource(stdout, localPtr->name, 40);
    827                 }
    828             } else {
    829                 fprintf(stdout, "%u ", (unsigned int) opnd);
    830             }
    831             break;
    832         case OPERAND_NONE:
    833         default:
    834             break;
    835         }
    836     }
    837     fprintf(stdout, "\n");
    838     return instDesc->numBytes;
    839 }
    840 
    841 
    842 /*
    843  *----------------------------------------------------------------------
    844  *
    845410 * TclPrintSource --
    846411 *
     
    972537    register int i;
    973538
    974 #ifdef TCL_COMPILE_STATS   
    975     tclCurrentSourceBytes -= (double) codePtr->numSrcChars;
    976     tclCurrentCodeBytes -= (double) codePtr->totalSize;
    977 #endif /* TCL_COMPILE_STATS */
    978 
    979539    /*
    980540     * A single heap object holds the ByteCode structure and its code,
     
    1067627    int length, result;
    1068628
    1069     if (!traceInitialized) {
    1070         if (Tcl_LinkVar(interp, "tcl_traceCompile",
    1071                     (char *) &tclTraceCompile,  TCL_LINK_INT) != TCL_OK) {
    1072             panic("SetByteCodeFromAny: unable to create link for tcl_traceCompile variable");
    1073         }
    1074         traceInitialized = 1;
    1075     }
    1076    
    1077629    string = Tcl_GetStringFromObj(objPtr, &length);
    1078630    TclInitCompileEnv(interp, &compEnv, string);
     
    1113665    TclFreeCompileEnv(&compEnv);
    1114666
    1115     if (result == TCL_OK) {
    1116         if (tclTraceCompile == 2) {
    1117             TclPrintByteCodeObj(interp, objPtr);
    1118         }
    1119     }
    1120667    return result;
    1121668}
     
    1311858    int numObjects, i;
    1312859    Namespace *namespacePtr;
    1313 #ifdef TCL_COMPILE_STATS
    1314     int srcLenLog2, sizeLog2;
    1315 #endif /*TCL_COMPILE_STATS*/
    1316860
    1317861    codeBytes = (envPtr->codeNext - envPtr->codeStart);
     
    1342886    }
    1343887    totalSize = (size + objBytes);
    1344 
    1345 #ifdef TCL_COMPILE_STATS
    1346     tclNumCompilations++;
    1347     tclTotalSourceBytes += (double) srcLen;
    1348     tclTotalCodeBytes += (double) totalSize;
    1349    
    1350     tclTotalInstBytes += (double) codeBytes;
    1351     tclTotalObjBytes += (double) objBytes;
    1352     tclTotalExceptBytes += exceptArrayBytes;
    1353     tclTotalAuxBytes += (double) auxDataArrayBytes;
    1354     tclTotalCmdMapBytes += (double) cmdLocBytes;
    1355 
    1356     tclCurrentSourceBytes += (double) srcLen;
    1357     tclCurrentCodeBytes += (double) totalSize;
    1358 
    1359     srcLenLog2 = TclLog2(srcLen);
    1360     sizeLog2 = TclLog2((int) totalSize);
    1361     if ((srcLenLog2 > 31) || (sizeLog2 > 31)) {
    1362         panic("TclInitByteCodeObj: bad source or code sizes\n");
    1363     }
    1364     tclSourceCount[srcLenLog2]++;
    1365     tclByteCodeCount[sizeLog2]++;
    1366 #endif /* TCL_COMPILE_STATS */   
    1367888
    1368889    if (envPtr->iPtr->varFramePtr != NULL) {
     
    18201341                cmdCodeOffset);
    18211342           
    1822         if ((!(flags & TCL_BRACKET_TERM))
    1823                 && (tclTraceCompile >= 1) && (envPtr->procPtr == NULL)) {
    1824             /*
    1825              * Display a line summarizing the top level command we are about
    1826              * to compile.
    1827              */
    1828            
    1829             char *p = cmdSrcStart;
    1830             int numChars, complete;
    1831            
    1832             while ((CHAR_TYPE(p, lastChar) != TCL_COMMAND_END)
    1833                    || ((*p == ']') && !(flags & TCL_BRACKET_TERM))) {
    1834                 p++;
    1835             }
    1836             numChars = (p - cmdSrcStart);
    1837             complete = 1;
    1838             if (numChars > 60) {
    1839                 numChars = 60;
    1840                 complete = 0;
    1841             } else if ((numChars >= 2) && (*p == '\n') && (*(p-1) == '{')) {
    1842                 complete = 0;
    1843             }
    1844             fprintf(stdout, "Compiling: %.*s%s\n",
    1845                     numChars, cmdSrcStart, (complete? "" : " ..."));
    1846         }
    1847        
    18481343        while ((type != TCL_COMMAND_END)
    18491344                || ((c == ']') && !(flags & TCL_BRACKET_TERM))) {
  • external/tcl/tclCompile.h

    re39abb4 r0e7d64a  
    3636
    3737extern Tcl_ObjType      tclCmdNameType;
    38 
    39 /*
    40  * Variable that controls whether compilation tracing is enabled and, if so,
    41  * what level of tracing is desired:
    42  *    0: no compilation tracing
    43  *    1: summarize compilation of top level cmds and proc bodies
    44  *    2: display all instructions of each ByteCode compiled
    45  * This variable is linked to the Tcl variable "tcl_traceCompile".
    46  */
    47 
    48 extern int              tclTraceCompile;
    49 
    50 /*
    51  * Variable that controls whether execution tracing is enabled and, if so,
    52  * what level of tracing is desired:
    53  *    0: no execution tracing
    54  *    1: trace invocations of Tcl procs only
    55  *    2: trace invocations of all (not compiled away) commands
    56  *    3: display each instruction executed
    57  * This variable is linked to the Tcl variable "tcl_traceExec".
    58  */
    59 
    60 extern int              tclTraceExec;
    61 
    62 /*
    63  * The number of bytecode compilations and various other compilation-related
    64  * statistics. The tclByteCodeCount and tclSourceCount arrays are used to
    65  * hold the count of ByteCodes and sources whose sizes fall into various
    66  * binary decades; e.g., tclByteCodeCount[5] is a count of the ByteCodes
    67  * with size larger than 2**4 and less than or equal to 2**5.
    68  */
    69 
    70 #ifdef TCL_COMPILE_STATS
    71 extern long             tclNumCompilations;
    72 extern double           tclTotalSourceBytes;
    73 extern double           tclTotalCodeBytes;
    74 
    75 extern double           tclTotalInstBytes;
    76 extern double           tclTotalObjBytes;
    77 extern double           tclTotalExceptBytes;
    78 extern double           tclTotalAuxBytes;
    79 extern double           tclTotalCmdMapBytes;
    80 
    81 extern double           tclCurrentSourceBytes;
    82 extern double           tclCurrentCodeBytes;
    83 
    84 extern int              tclSourceCount[32];
    85 extern int              tclByteCodeCount[32];
    86 #endif /* TCL_COMPILE_STATS */
    8738
    8839/*
     
    816767EXTERN void             TclInitJumpFixupArray _ANSI_ARGS_((
    817768                            JumpFixupArray *fixupArrayPtr));
    818 #ifdef TCL_COMPILE_STATS
    819 EXTERN int              TclLog2 _ANSI_ARGS_((int value));
    820 #endif /*TCL_COMPILE_STATS*/
    821769EXTERN int              TclObjIndexForString _ANSI_ARGS_((char *start,
    822770                            int length, int allocStrRep, int inHeap,
    823771                            CompileEnv *envPtr));
    824 EXTERN int              TclPrintInstruction _ANSI_ARGS_((ByteCode* codePtr,
    825                             unsigned char *pc));
    826772EXTERN void             TclPrintSource _ANSI_ARGS_((FILE *outFile,
    827773                            char *string, int maxChars));
  • external/tcl/tclExecute.c

    re39abb4 r0e7d64a  
    5151
    5252/*
    53  * Variable that controls whether execution tracing is enabled and, if so,
    54  * what level of tracing is desired:
    55  *    0: no execution tracing
    56  *    1: trace invocations of Tcl procs only
    57  *    2: trace invocations of all (not compiled away) commands
    58  *    3: display each instruction executed
    59  * This variable is linked to the Tcl variable "tcl_traceExec".
    60  */
    61 
    62 int tclTraceExec = 0;
    63 
    64 /*
    6553 * The following global variable is use to signal matherr that Tcl
    6654 * is responsible for the arithmetic, so errors can be handled in a
     
    10290};
    10391   
    104 /*
    105  * Mapping from Tcl result codes to strings; used for error and debugging
    106  * messages.
    107  */
    108 
    109 #ifdef TCL_COMPILE_DEBUG
    110 static char *resultStrings[] = {
    111     "TCL_OK", "TCL_ERROR", "TCL_RETURN", "TCL_BREAK", "TCL_CONTINUE"
    112 };
    113 #endif /* TCL_COMPILE_DEBUG */
    114 
    115 /*
    116  * The following are statistics-related variables that record information
    117  * about the bytecode compiler and interpreter's operation. This includes
    118  * an array that records for each instruction how often it is executed.
    119  */
    120 
    121 #ifdef TCL_COMPILE_STATS
    122 static long numExecutions = 0;
    123 static int instructionCount[256];
    124 #endif /* TCL_COMPILE_STATS */
    125 
    12692/*
    12793 * Macros for testing floating-point values for certain special cases. Test
     
    187153#define POP_OBJECT() \
    188154    (stackPtr[stackTop--].o)
    189 
    190 /*
    191  * Macros used to trace instruction execution. The macros TRACE,
    192  * TRACE_WITH_OBJ, and O2S are only used inside TclExecuteByteCode.
    193  * O2S is only used in TRACE* calls to get a string from an object.
    194  *
    195  * NOTE THAT CLIENTS OF O2S ARE LIKELY TO FAIL IF THE OBJECT'S
    196  * STRING REP CONTAINS NULLS.
    197  */
    198 
    199 #ifdef TCL_COMPILE_DEBUG
    200        
    201 #define O2S(objPtr) \
    202     Tcl_GetStringFromObj((objPtr), &length)
    203        
    204 #ifdef TCL_COMPILE_STATS
    205 #define TRACE(a) \
    206     if (traceInstructions) { \
    207         fprintf(stdout, "%d: %d,%ld (%u) ", iPtr->numLevels, \
    208                stackTop, (tclObjsAlloced - tclObjsFreed), \
    209                (unsigned int)(pc - codePtr->codeStart)); \
    210         printf a; \
    211         fflush(stdout); \
    212     }
    213 #define TRACE_WITH_OBJ(a, objPtr) \
    214     if (traceInstructions) { \
    215         fprintf(stdout, "%d: %d,%ld (%u) ", iPtr->numLevels, \
    216                stackTop, (tclObjsAlloced - tclObjsFreed), \
    217                (unsigned int)(pc - codePtr->codeStart)); \
    218         printf a; \
    219         bytes = Tcl_GetStringFromObj((objPtr), &length); \
    220         TclPrintSource(stdout, bytes, TclMin(length, 30)); \
    221         fprintf(stdout, "\n"); \
    222         fflush(stdout); \
    223     }
    224 #else  /* not TCL_COMPILE_STATS */
    225 #define TRACE(a) \
    226     if (traceInstructions) { \
    227         fprintf(stdout, "%d: %d (%u) ", iPtr->numLevels, stackTop, \
    228                (unsigned int)(pc - codePtr->codeStart)); \
    229         printf a; \
    230         fflush(stdout); \
    231     }
    232 #define TRACE_WITH_OBJ(a, objPtr) \
    233     if (traceInstructions) { \
    234         fprintf(stdout, "%d: %d (%u) ", iPtr->numLevels, stackTop, \
    235                (unsigned int)(pc - codePtr->codeStart)); \
    236         printf a; \
    237         bytes = Tcl_GetStringFromObj((objPtr), &length); \
    238         TclPrintSource(stdout, bytes, TclMin(length, 30)); \
    239         fprintf(stdout, "\n"); \
    240         fflush(stdout); \
    241     }
    242 #endif /* TCL_COMPILE_STATS */
    243 
    244 #else  /* not TCL_COMPILE_DEBUG */
    245        
    246 #define TRACE(a)
    247 #define TRACE_WITH_OBJ(a, objPtr)
    248 #define O2S(objPtr)
    249        
    250 #endif /* TCL_COMPILE_DEBUG */
    251155
    252156/*
     
    274178static int              ExprUnaryFunc _ANSI_ARGS_((Tcl_Interp *interp,
    275179                            ExecEnv *eePtr, ClientData clientData));
    276 #ifdef TCL_COMPILE_STATS
    277 static int              EvalStatsCmd _ANSI_ARGS_((ClientData clientData,
    278                             Tcl_Interp *interp, int argc, char **argv));
    279 #endif /* TCL_COMPILE_STATS */
    280180static void             FreeCmdNameInternalRep _ANSI_ARGS_((
    281181                            Tcl_Obj *objPtr));
     
    293193static int              SetCmdNameFromAny _ANSI_ARGS_((Tcl_Interp *interp,
    294194                            Tcl_Obj *objPtr));
    295 #ifdef TCL_COMPILE_DEBUG
    296 static char *           StringForResultCode _ANSI_ARGS_((int result));
    297 #endif /* TCL_COMPILE_DEBUG */
    298195static void             UpdateStringOfCmdName _ANSI_ARGS_((Tcl_Obj *objPtr));
    299 #ifdef TCL_COMPILE_DEBUG
    300 static void             ValidatePcAndStackTop _ANSI_ARGS_((
    301                             ByteCode *codePtr, unsigned char *pc,
    302                             int stackTop, int stackLowerBound,
    303                             int stackUpperBound));
    304 #endif /* TCL_COMPILE_DEBUG */
    305196
    306197/*
     
    368259 *
    369260 * Side effects:
    370  *      This procedure initializes the array of instruction names. If
    371  *      compiling with the TCL_COMPILE_STATS flag, it initializes the
    372  *      array that counts the executions of each instruction and it
    373  *      creates the "evalstats" command. It also registers the command name
    374  *      Tcl_ObjType. It also establishes the link between the Tcl
    375  *      "tcl_traceExec" and C "tclTraceExec" variables.
     261 *      This procedure initializes the array of instruction names.
    376262 *
    377263 *----------------------------------------------------------------------
     
    391277    for (i = 0;  instructionTable[i].name != NULL;  i++) {
    392278        opName[i] = instructionTable[i].name;
    393     }
    394 
    395 #ifdef TCL_COMPILE_STATS   
    396     (VOID *) memset(instructionCount, 0, sizeof(instructionCount));
    397     (VOID *) memset(tclByteCodeCount, 0, sizeof(tclByteCodeCount));
    398     (VOID *) memset(tclSourceCount, 0, sizeof(tclSourceCount));
    399 
    400     Tcl_CreateCommand(interp, "evalstats", EvalStatsCmd,
    401                       (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
    402 #endif /* TCL_COMPILE_STATS */
    403    
    404     if (Tcl_LinkVar(interp, "tcl_traceExec", (char *) &tclTraceExec,
    405                     TCL_LINK_INT) != TCL_OK) {
    406         panic("InitByteCodeExecution: can't create link for tcl_traceExec variable");
    407279    }
    408280}
     
    598470                                 * process break, continue, and errors. */
    599471    int result = TCL_OK;        /* Return code returned after execution. */
    600     int traceInstructions = (tclTraceExec == 3);
    601472    Tcl_Obj *valuePtr, *value2Ptr, *namePtr, *objPtr;
    602473    char *bytes;
    603474    int length;
    604475    long i;
    605     Tcl_DString command;        /* Used for debugging. If tclTraceExec >= 2
    606                                  * holds a string representing the last
    607                                  * command invoked. */
    608476
    609477    /*
     
    620488
    621489    /*
    622      * THIS PROC FAILS IF AN OBJECT'S STRING REP HAS A NULL BYTE.
    623      */
    624 
    625     if (tclTraceExec >= 2) {
    626         PrintByteCodeInfo(codePtr);
    627 #ifdef TCL_COMPILE_STATS
    628         fprintf(stdout, "  Starting stack top=%d, system objects=%ld\n",
    629                 eePtr->stackTop, (tclObjsAlloced - tclObjsFreed));
    630 #else
    631         fprintf(stdout, "  Starting stack top=%d\n", eePtr->stackTop);
    632 #endif /* TCL_COMPILE_STATS */
    633         fflush(stdout);
    634     }
    635 
    636 #ifdef TCL_COMPILE_STATS
    637     numExecutions++;
    638 #endif /* TCL_COMPILE_STATS */
    639 
    640     /*
    641490     * Make sure the catch stack is large enough to hold the maximum number
    642491     * of catch commands that could ever be executing at the same time. This
     
    659508
    660509    /*
    661      * Initialize the buffer that holds a string containing the name and
    662      * arguments for the last invoked command.
    663      */
    664 
    665     Tcl_DStringInit(&command);
    666 
    667     /*
    668510     * Loop executing instructions until a "done" instruction, a TCL_RETURN,
    669511     * or some error.
     
    671513
    672514    for (;;) {
    673 #ifdef TCL_COMPILE_DEBUG
    674         ValidatePcAndStackTop(codePtr, pc, stackTop, initStackTop,
    675                 eePtr->stackEnd);
    676 #else /* not TCL_COMPILE_DEBUG */
    677         if (traceInstructions) {
    678 #ifdef TCL_COMPILE_STATS
    679             fprintf(stdout, "%d: %d,%ld ", iPtr->numLevels, stackTop,
    680                     (tclObjsAlloced - tclObjsFreed));
    681 #else /* TCL_COMPILE_STATS */
    682             fprintf(stdout, "%d: %d ", iPtr->numLevels, stackTop);
    683 #endif /* TCL_COMPILE_STATS */
    684             TclPrintInstruction(codePtr, pc);
    685             fflush(stdout);
    686         }
    687 #endif /* TCL_COMPILE_DEBUG */
    688        
    689515        opCode = *pc;
    690 #ifdef TCL_COMPILE_STATS   
    691         instructionCount[opCode]++;
    692 #endif /* TCL_COMPILE_STATS */
    693516
    694517        switch (opCode) {
     
    710533                panic("TclExecuteByteCode execution failure: end stack top != start stack top");
    711534            }
    712             TRACE_WITH_OBJ(("done => return code=%d, result is ", result),
    713                     iPtr->objResultPtr);
    714535            goto done;
    715536           
     
    717538            valuePtr = objArrayPtr[TclGetUInt1AtPtr(pc+1)];
    718539            PUSH_OBJECT(valuePtr);
    719             TRACE_WITH_OBJ(("push1 %u => ", TclGetUInt1AtPtr(pc+1)),
    720                     valuePtr);
    721540            ADJUST_PC(2);
    722541           
     
    724543            valuePtr = objArrayPtr[TclGetUInt4AtPtr(pc+1)];
    725544            PUSH_OBJECT(valuePtr);
    726             TRACE_WITH_OBJ(("push4 %u => ", TclGetUInt4AtPtr(pc+1)),
    727                     valuePtr);
    728545            ADJUST_PC(5);
    729546           
    730547        case INST_POP:
    731548            valuePtr = POP_OBJECT();
    732             TRACE_WITH_OBJ(("pop => discarding "), valuePtr);
    733549            TclDecrRefCount(valuePtr); /* finished with pop'ed object. */
    734550            ADJUST_PC(1);
     
    737553            valuePtr = stackPtr[stackTop].o;
    738554            PUSH_OBJECT(Tcl_DuplicateObj(valuePtr));
    739             TRACE_WITH_OBJ(("dup => "), valuePtr);
    740555            ADJUST_PC(1);
    741556
     
    790605               
    791606                PUSH_OBJECT(concatObjPtr);
    792                 TRACE_WITH_OBJ(("concat %u => ", opnd), concatObjPtr);
    793607                ADJUST_PC(2);
    794608            }
     
    815629                                    * Init. to avoid compiler warning. */
    816630                Tcl_Command cmd;
    817 #ifdef TCL_COMPILE_DEBUG
    818                 int isUnknownCmd = 0;
    819                 char cmdNameBuf[30];
    820 #endif /* TCL_COMPILE_DEBUG */
    821631               
    822632                /*
     
    867677                                "invalid command name \"", cmdName, "\"",
    868678                                (char *) NULL);
    869                         TRACE(("%s %u => unknown proc not found: ",
    870                                opName[opCode], objc));
    871679                        result = TCL_ERROR;
    872680                        goto checkForCatch;
    873681                    }
    874682                    cmdPtr = (Command *) cmd;
    875 #ifdef TCL_COMPILE_DEBUG
    876                     isUnknownCmd = 1;
    877 #endif /*TCL_COMPILE_DEBUG*/                   
    878683                    stackTop++; /* need room for new inserted objv[0] */
    879684                    for (i = objc;  i >= 0;  i--) {
     
    918723                Tcl_ResetResult(interp);
    919724
    920                 if (tclTraceExec >= 2) {
    921                     char buffer[50];
    922 
    923                     sprintf(buffer, "%d: (%u) invoking ", iPtr->numLevels,
    924                             (unsigned int)(pc - codePtr->codeStart));
    925                     Tcl_DStringAppend(&command, buffer, -1);
    926                    
    927 #ifdef TCL_COMPILE_DEBUG
    928                     if (traceInstructions) { /* tclTraceExec == 3 */
    929                         strncpy(cmdNameBuf, cmdName, 20);
    930                         TRACE(("%s %u => call ", opName[opCode],
    931                                (isUnknownCmd? objc-1 : objc)));
    932                     } else {
    933                         fprintf(stdout, "%s", buffer);
    934                     }
    935 #else /* TCL_COMPILE_DEBUG */
    936                     fprintf(stdout, "%s", buffer);
    937 #endif /*TCL_COMPILE_DEBUG*/
    938 
    939                     for (i = 0;  i < objc;  i++) {
    940                         bytes = TclGetStringFromObj(objv[i], &length);
    941                         TclPrintSource(stdout, bytes, TclMin(length, 15));
    942                         fprintf(stdout, " ");
    943 
    944                         sprintf(buffer, "\"%.*s\" ", TclMin(length, 15), bytes);
    945                         Tcl_DStringAppend(&command, buffer, -1);
    946                     }
    947                     fprintf(stdout, "\n");
    948                     fflush(stdout);
    949 
    950                     Tcl_DStringFree(&command);
    951                 }
    952 
    953725                iPtr->cmdCount++;
    954726                DECACHE_STACK_INFO();
     
    996768                     */
    997769                    PUSH_OBJECT(Tcl_GetObjResult(interp));
    998                     TRACE_WITH_OBJ(("%s %u => ...after \"%.20s\", result=",
    999                             opName[opCode], objc, cmdNameBuf),
    1000                             Tcl_GetObjResult(interp));
    1001770                    ADJUST_PC(pcAdjustment);
    1002771                   
     
    1015784                            /*catchOnly*/ 0, codePtr);
    1016785                    if (rangePtr == NULL) {
    1017                         TRACE(("%s %u => ... after \"%.20s\", no encl. loop or catch, returning %s\n",
    1018                                 opName[opCode], objc, cmdNameBuf,
    1019                                 StringForResultCode(result)));
    1020786                        goto abnormalReturn; /* no catch exists to check */
    1021787                    }
     
    1025791                            newPcOffset = rangePtr->breakOffset;
    1026792                        } else if (rangePtr->continueOffset == -1) {
    1027                             TRACE(("%s %u => ... after \"%.20s\", %s, loop w/o continue, checking for catch\n",
    1028                                    opName[opCode], objc, cmdNameBuf,
    1029                                    StringForResultCode(result)));
    1030793                            goto checkForCatch;
    1031794                        } else {
    1032795                            newPcOffset = rangePtr->continueOffset;
    1033796                        }
    1034                         TRACE(("%s %u => ... after \"%.20s\", %s, range at %d, new pc %d\n",
    1035                                opName[opCode], objc, cmdNameBuf,
    1036                                StringForResultCode(result),
    1037                                rangePtr->codeOffset, newPcOffset));
    1038797                        break;
    1039798                    case CATCH_EXCEPTION_RANGE:
    1040                         TRACE(("%s %u => ... after \"%.20s\", %s...\n",
    1041                                opName[opCode], objc, cmdNameBuf,
    1042                                StringForResultCode(result)));
    1043799                        goto processCatch; /* it will use rangePtr */
    1044800                    default:
     
    1054810                     * enclosing catch exception range, if any.
    1055811                     */
    1056                     TRACE_WITH_OBJ(("%s %u => ... after \"%.20s\", TCL_ERROR ",
    1057                             opName[opCode], objc, cmdNameBuf),
    1058                             Tcl_GetObjResult(interp));
    1059812                    goto checkForCatch;
    1060813
     
    1065818                     * for an enclosing catch exception range, if any.
    1066819                     */
    1067                     TRACE(("%s %u => ... after \"%.20s\", TCL_RETURN\n",
    1068                             opName[opCode], objc, cmdNameBuf));
    1069820                    goto checkForCatch;
    1070821
    1071822                default:
    1072                     TRACE_WITH_OBJ(("%s %u => ... after \"%.20s\", OTHER RETURN CODE %d ",
    1073                             opName[opCode], objc, cmdNameBuf, result),
    1074                             Tcl_GetObjResult(interp));
    1075823                    goto checkForCatch;
    1076824                } /* end of switch on result from invoke instruction */
     
    1088836               
    1089837                PUSH_OBJECT(Tcl_GetObjResult(interp));
    1090                 TRACE_WITH_OBJ(("evalStk \"%.30s\" => ", O2S(objPtr)),
    1091                         Tcl_GetObjResult(interp));
    1092838                TclDecrRefCount(objPtr);
    1093839                ADJUST_PC(1);
     
    1109855                        codePtr);
    1110856                if (rangePtr == NULL) {
    1111                     TRACE(("evalStk \"%.30s\" => no encl. loop or catch, returning %s\n",
    1112                             O2S(objPtr), StringForResultCode(result)));
    1113857                    Tcl_DecrRefCount(objPtr);
    1114858                    goto abnormalReturn;    /* no catch exists to check */
     
    1119863                        newPcOffset = rangePtr->breakOffset;
    1120864                    } else if (rangePtr->continueOffset == -1) {
    1121                         TRACE(("evalStk \"%.30s\" => %s, loop w/o continue, checking for catch\n",
    1122                                O2S(objPtr), StringForResultCode(result)));
    1123865                        Tcl_DecrRefCount(objPtr);
    1124866                        goto checkForCatch;
     
    1127869                    }
    1128870                    result = TCL_OK;
    1129                     TRACE_WITH_OBJ(("evalStk \"%.30s\" => %s, range at %d, new pc %d ",
    1130                             O2S(objPtr), StringForResultCode(result),
    1131                             rangePtr->codeOffset, newPcOffset), valuePtr);
    1132871                    break;
    1133872                case CATCH_EXCEPTION_RANGE:
    1134                     TRACE_WITH_OBJ(("evalStk \"%.30s\" => %s ",
    1135                             O2S(objPtr), StringForResultCode(result)),
    1136                             valuePtr);
    1137873                    Tcl_DecrRefCount(objPtr);
    1138874                    goto processCatch;  /* it will use rangePtr */
     
    1144880                continue;       /* restart outer instruction loop at pc */
    1145881            } else { /* eval returned TCL_ERROR, TCL_RETURN, unknown code */
    1146                 TRACE_WITH_OBJ(("evalStk \"%.30s\" => ERROR: ", O2S(objPtr)),
    1147                         Tcl_GetObjResult(interp));
    1148882                Tcl_DecrRefCount(objPtr);
    1149883                goto checkForCatch;
     
    1157891            CACHE_STACK_INFO();
    1158892            if (result != TCL_OK) {
    1159                 TRACE_WITH_OBJ(("exprStk \"%.30s\" => ERROR: ",
    1160                         O2S(objPtr)), Tcl_GetObjResult(interp));
    1161893                Tcl_DecrRefCount(objPtr);
    1162894                goto checkForCatch;
    1163895            }
    1164896            stackPtr[++stackTop].o = valuePtr; /* already has right refct */
    1165             TRACE_WITH_OBJ(("exprStk \"%.30s\" => ", O2S(objPtr)), valuePtr);
    1166897            TclDecrRefCount(objPtr);
    1167898            ADJUST_PC(1);
     
    1182913            CACHE_STACK_INFO();
    1183914            if (valuePtr == NULL) {
    1184                 TRACE_WITH_OBJ(("%s %u => ERROR: ", opName[opCode], opnd),
    1185                         Tcl_GetObjResult(interp));
    1186915                result = TCL_ERROR;
    1187916                goto checkForCatch;
    1188917            }
    1189918            PUSH_OBJECT(valuePtr);
    1190             TRACE_WITH_OBJ(("%s %u => ", opName[opCode], opnd), valuePtr);
    1191919            ADJUST_PC(pcAdjustment);
    1192920
     
    1198926            CACHE_STACK_INFO();
    1199927            if (valuePtr == NULL) {
    1200                 TRACE_WITH_OBJ(("loadScalarStk \"%.30s\" => ERROR: ",
    1201                         O2S(namePtr)), Tcl_GetObjResult(interp));
    1202928                Tcl_DecrRefCount(namePtr);
    1203929                result = TCL_ERROR;
     
    1205931            }
    1206932            PUSH_OBJECT(valuePtr);
    1207             TRACE_WITH_OBJ(("loadScalarStk \"%.30s\" => ",
    1208                     O2S(namePtr)), valuePtr);
    1209933            TclDecrRefCount(namePtr);
    1210934            ADJUST_PC(1);
     
    1228952                CACHE_STACK_INFO();
    1229953                if (valuePtr == NULL) {
    1230                     TRACE_WITH_OBJ(("%s %u \"%.30s\" => ERROR: ",
    1231                             opName[opCode], opnd, O2S(elemPtr)),
    1232                             Tcl_GetObjResult(interp));
    1233954                    Tcl_DecrRefCount(elemPtr);
    1234955                    result = TCL_ERROR;
     
    1236957                }
    1237958                PUSH_OBJECT(valuePtr);
    1238                 TRACE_WITH_OBJ(("%s %u \"%.30s\" => ",
    1239                         opName[opCode], opnd, O2S(elemPtr)), valuePtr);
    1240959                TclDecrRefCount(elemPtr);
    1241960            }
     
    1252971                CACHE_STACK_INFO();
    1253972                if (valuePtr == NULL) {
    1254                     TRACE_WITH_OBJ(("loadArrayStk \"%.30s(%.30s)\" => ERROR: ",
    1255                             O2S(namePtr), O2S(elemPtr)),
    1256                             Tcl_GetObjResult(interp));
    1257973                    Tcl_DecrRefCount(namePtr);
    1258974                    Tcl_DecrRefCount(elemPtr);
     
    1261977                }
    1262978                PUSH_OBJECT(valuePtr);
    1263                 TRACE_WITH_OBJ(("loadArrayStk \"%.30s(%.30s)\" => ",
    1264                         O2S(namePtr), O2S(elemPtr)), valuePtr);
    1265979                TclDecrRefCount(namePtr);
    1266980                TclDecrRefCount(elemPtr);
     
    1275989            CACHE_STACK_INFO();
    1276990            if (valuePtr == NULL) {
    1277                 TRACE_WITH_OBJ(("loadStk \"%.30s\" => ERROR: ",
    1278                         O2S(namePtr)), Tcl_GetObjResult(interp));
    1279991                Tcl_DecrRefCount(namePtr);
    1280992                result = TCL_ERROR;
     
    1282994            }
    1283995            PUSH_OBJECT(valuePtr);
    1284             TRACE_WITH_OBJ(("loadStk \"%.30s\" => ", O2S(namePtr)),
    1285                     valuePtr);
    1286996            TclDecrRefCount(namePtr);
    1287997            ADJUST_PC(1);
     
    13031013            CACHE_STACK_INFO();
    13041014            if (value2Ptr == NULL) {
    1305                 TRACE_WITH_OBJ(("%s %u <- \"%.30s\" => ERROR: ",
    1306                         opName[opCode], opnd, O2S(valuePtr)),
    1307                         Tcl_GetObjResult(interp));
    13081015                Tcl_DecrRefCount(valuePtr);
    13091016                result = TCL_ERROR;
     
    13111018            }
    13121019            PUSH_OBJECT(value2Ptr);
    1313             TRACE_WITH_OBJ(("%s %u <- \"%.30s\" => ",
    1314                     opName[opCode], opnd, O2S(valuePtr)), value2Ptr);
    13151020            TclDecrRefCount(valuePtr);
    13161021            ADJUST_PC(pcAdjustment);
     
    13241029            CACHE_STACK_INFO();
    13251030            if (value2Ptr == NULL) {
    1326                 TRACE_WITH_OBJ(
    1327                         ("storeScalarStk \"%.30s\" <- \"%.30s\" => ERROR: ",
    1328                         O2S(namePtr), O2S(valuePtr)),
    1329                         Tcl_GetObjResult(interp));
    13301031                Tcl_DecrRefCount(namePtr);
    13311032                Tcl_DecrRefCount(valuePtr);
     
    13341035            }
    13351036            PUSH_OBJECT(value2Ptr);
    1336             TRACE_WITH_OBJ(
    1337                     ("storeScalarStk \"%.30s\" <- \"%.30s\" => ",
    1338                     O2S(namePtr),
    1339                     O2S(valuePtr)),
    1340                     value2Ptr);
    13411037            TclDecrRefCount(namePtr);
    13421038            TclDecrRefCount(valuePtr);
     
    13631059                CACHE_STACK_INFO();
    13641060                if (value2Ptr == NULL) {
    1365                     TRACE_WITH_OBJ(
    1366                             ("%s %u \"%.30s\" <- \"%.30s\" => ERROR: ",
    1367                             opName[opCode], opnd, O2S(elemPtr),
    1368                             O2S(valuePtr)), Tcl_GetObjResult(interp));
    13691061                    Tcl_DecrRefCount(elemPtr);
    13701062                    Tcl_DecrRefCount(valuePtr);
     
    13731065                }
    13741066                PUSH_OBJECT(value2Ptr);
    1375                 TRACE_WITH_OBJ(("%s %u \"%.30s\" <- \"%.30s\" => ",
    1376                         opName[opCode], opnd, O2S(elemPtr), O2S(valuePtr)),
    1377                         value2Ptr);
    13781067                TclDecrRefCount(elemPtr);
    13791068                TclDecrRefCount(valuePtr);
     
    13931082                CACHE_STACK_INFO();
    13941083                if (value2Ptr == NULL) {
    1395                     TRACE_WITH_OBJ(("storeArrayStk \"%.30s(%.30s)\" <- \"%.30s\" => ERROR: ",
    1396                             O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),
    1397                             Tcl_GetObjResult(interp));
    13981084                    Tcl_DecrRefCount(namePtr);
    13991085                    Tcl_DecrRefCount(elemPtr);
     
    14031089                }
    14041090                PUSH_OBJECT(value2Ptr);
    1405                 TRACE_WITH_OBJ(("storeArrayStk \"%.30s(%.30s)\" <- \"%.30s\" => ",
    1406                         O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),
    1407                         value2Ptr);
    14081091                TclDecrRefCount(namePtr);
    14091092                TclDecrRefCount(elemPtr);
     
    14201103            CACHE_STACK_INFO();
    14211104            if (value2Ptr == NULL) {
    1422                 TRACE_WITH_OBJ(("storeStk \"%.30s\" <- \"%.30s\" => ERROR: ",
    1423                         O2S(namePtr), O2S(valuePtr)),
    1424                         Tcl_GetObjResult(interp));
    14251105                Tcl_DecrRefCount(namePtr);
    14261106                Tcl_DecrRefCount(valuePtr);
     
    14291109            }
    14301110            PUSH_OBJECT(value2Ptr);
    1431             TRACE_WITH_OBJ(("storeStk \"%.30s\" <- \"%.30s\" => ",
    1432                     O2S(namePtr), O2S(valuePtr)), value2Ptr);
    14331111            TclDecrRefCount(namePtr);
    14341112            TclDecrRefCount(valuePtr);
     
    14411119                result = tclIntType.setFromAnyProc(interp, valuePtr);
    14421120                if (result != TCL_OK) {
    1443                     TRACE_WITH_OBJ(("incrScalar1 %u (by %s) => ERROR converting increment amount to int: ",
    1444                             opnd, O2S(valuePtr)), Tcl_GetObjResult(interp));
    14451121                    Tcl_DecrRefCount(valuePtr);
    14461122                    goto checkForCatch;
     
    14521128            CACHE_STACK_INFO();
    14531129            if (value2Ptr == NULL) {
    1454                 TRACE_WITH_OBJ(("incrScalar1 %u (by %ld) => ERROR: ",
    1455                         opnd, i), Tcl_GetObjResult(interp));
    14561130                Tcl_DecrRefCount(valuePtr);
    14571131                result = TCL_ERROR;
     
    14591133            }
    14601134            PUSH_OBJECT(value2Ptr);
    1461             TRACE_WITH_OBJ(("incrScalar1 %u (by %ld) => ", opnd, i),
    1462                     value2Ptr);
    14631135            TclDecrRefCount(valuePtr);
    14641136            ADJUST_PC(2);
     
    14711143                result = tclIntType.setFromAnyProc(interp, valuePtr);
    14721144                if (result != TCL_OK) {
    1473                     TRACE_WITH_OBJ(("%s \"%.30s\" (by %s) => ERROR converting increment amount to int: ",
    1474                             opName[opCode], O2S(namePtr), O2S(valuePtr)),
    1475                             Tcl_GetObjResult(interp));
    14761145                    Tcl_DecrRefCount(namePtr);
    14771146                    Tcl_DecrRefCount(valuePtr);
     
    14851154            CACHE_STACK_INFO();
    14861155            if (value2Ptr == NULL) {
    1487                 TRACE_WITH_OBJ(("%s \"%.30s\" (by %ld) => ERROR: ",
    1488                         opName[opCode], O2S(namePtr), i),
    1489                         Tcl_GetObjResult(interp));
    14901156                Tcl_DecrRefCount(namePtr);
    14911157                Tcl_DecrRefCount(valuePtr);
     
    14941160            }
    14951161            PUSH_OBJECT(value2Ptr);
    1496             TRACE_WITH_OBJ(("%s \"%.30s\" (by %ld) => ",
    1497                     opName[opCode], O2S(namePtr), i), value2Ptr);
    14981162            Tcl_DecrRefCount(namePtr);
    14991163            Tcl_DecrRefCount(valuePtr);
     
    15101174                    result = tclIntType.setFromAnyProc(interp, valuePtr);
    15111175                    if (result != TCL_OK) {
    1512                         TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %s) => ERROR converting increment amount to int: ",
    1513                                 opnd, O2S(elemPtr), O2S(valuePtr)),
    1514                                 Tcl_GetObjResult(interp));
    15151176                        Tcl_DecrRefCount(elemPtr);
    15161177                        Tcl_DecrRefCount(valuePtr);
     
    15241185                CACHE_STACK_INFO();
    15251186                if (value2Ptr == NULL) {
    1526                     TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %ld) => ERROR: ",
    1527                             opnd, O2S(elemPtr), i),
    1528                             Tcl_GetObjResult(interp));
    15291187                    Tcl_DecrRefCount(elemPtr);
    15301188                    Tcl_DecrRefCount(valuePtr);
     
    15331191                }
    15341192                PUSH_OBJECT(value2Ptr);
    1535                 TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %ld) => ",
    1536                         opnd, O2S(elemPtr), i), value2Ptr);
    15371193                Tcl_DecrRefCount(elemPtr);
    15381194                Tcl_DecrRefCount(valuePtr);
     
    15501206                    result = tclIntType.setFromAnyProc(interp, valuePtr);
    15511207                    if (result != TCL_OK) {
    1552                         TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %s) => ERROR converting increment amount to int: ",
    1553                                 O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),
    1554                                 Tcl_GetObjResult(interp));
    15551208                        Tcl_DecrRefCount(namePtr);
    15561209                        Tcl_DecrRefCount(elemPtr);
     
    15651218                CACHE_STACK_INFO();
    15661219                if (value2Ptr == NULL) {
    1567                     TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %ld) => ERROR: ",
    1568                             O2S(namePtr), O2S(elemPtr), i),
    1569                             Tcl_GetObjResult(interp));
    15701220                    Tcl_DecrRefCount(namePtr);
    15711221                    Tcl_DecrRefCount(elemPtr);
     
    15751225                }
    15761226                PUSH_OBJECT(value2Ptr);
    1577                 TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %ld) => ",
    1578                         O2S(namePtr), O2S(elemPtr), i), value2Ptr);
    15791227                Tcl_DecrRefCount(namePtr);
    15801228                Tcl_DecrRefCount(elemPtr);
     
    15901238            CACHE_STACK_INFO();
    15911239            if (value2Ptr == NULL) {
    1592                 TRACE_WITH_OBJ(("incrScalar1Imm %u %ld => ERROR: ",
    1593                         opnd, i), Tcl_GetObjResult(interp));
    15941240                result = TCL_ERROR;
    15951241                goto checkForCatch;
    15961242            }
    15971243            PUSH_OBJECT(value2Ptr);
    1598             TRACE_WITH_OBJ(("incrScalar1Imm %u %ld => ", opnd, i),
    1599                     value2Ptr);
    16001244            ADJUST_PC(3);
    16011245
     
    16091253            CACHE_STACK_INFO();
    16101254            if (value2Ptr == NULL) {
    1611                 TRACE_WITH_OBJ(("%s \"%.30s\" %ld => ERROR: ",
    1612                         opName[opCode], O2S(namePtr), i),
    1613                         Tcl_GetObjResult(interp));
    16141255                result = TCL_ERROR;
    16151256                Tcl_DecrRefCount(namePtr);
     
    16171258            }
    16181259            PUSH_OBJECT(value2Ptr);
    1619             TRACE_WITH_OBJ(("%s \"%.30s\" %ld => ",
    1620                     opName[opCode], O2S(namePtr), i), value2Ptr);
    16211260            TclDecrRefCount(namePtr);
    16221261            ADJUST_PC(2);
     
    16341273                CACHE_STACK_INFO();
    16351274                if (value2Ptr == NULL) {
    1636                     TRACE_WITH_OBJ(("incrArray1Imm %u \"%.30s\" (by %ld) => ERROR: ",
    1637                             opnd, O2S(elemPtr), i),
    1638                             Tcl_GetObjResult(interp));
    16391275                    Tcl_DecrRefCount(elemPtr);
    16401276                    result = TCL_ERROR;
     
    16421278                }
    16431279                PUSH_OBJECT(value2Ptr);
    1644                 TRACE_WITH_OBJ(("incrArray1Imm %u \"%.30s\" (by %ld) => ",
    1645                         opnd, O2S(elemPtr), i), value2Ptr);
    16461280                Tcl_DecrRefCount(elemPtr);
    16471281            }
     
    16601294                CACHE_STACK_INFO();
    16611295                if (value2Ptr == NULL) {
    1662                     TRACE_WITH_OBJ(("incrArrayStkImm \"%.30s(%.30s)\" (by %ld) => ERROR: ",
    1663                             O2S(namePtr), O2S(elemPtr), i),
    1664                             Tcl_GetObjResult(interp));
    16651296                    Tcl_DecrRefCount(namePtr);
    16661297                    Tcl_DecrRefCount(elemPtr);
     
    16691300                }
    16701301                PUSH_OBJECT(value2Ptr);
    1671                 TRACE_WITH_OBJ(("incrArrayStkImm \"%.30s(%.30s)\" (by %ld) => ",
    1672                         O2S(namePtr), O2S(elemPtr), i), value2Ptr);
    16731302                Tcl_DecrRefCount(namePtr);
    16741303                Tcl_DecrRefCount(elemPtr);
     
    16781307        case INST_JUMP1:
    16791308            opnd = TclGetInt1AtPtr(pc+1);
    1680             TRACE(("jump1 %d => new pc %u\n", opnd,
    1681                    (unsigned int)(pc + opnd - codePtr->codeStart)));
    16821309            ADJUST_PC(opnd);
    16831310
    16841311        case INST_JUMP4:
    16851312            opnd = TclGetInt4AtPtr(pc+1);
    1686             TRACE(("jump4 %d => new pc %u\n", opnd,
    1687                    (unsigned int)(pc + opnd - codePtr->codeStart)));
    16881313            ADJUST_PC(opnd);
    16891314
     
    17091334                    result = Tcl_GetBooleanFromObj(interp, valuePtr, &b);
    17101335                    if (result != TCL_OK) {
    1711                         TRACE_WITH_OBJ(("%s %d => ERROR: ", opName[opCode],
    1712                                 opnd), Tcl_GetObjResult(interp));
    17131336                        Tcl_DecrRefCount(valuePtr);
    17141337                        goto checkForCatch;
     
    17161339                }
    17171340                if (b) {
    1718                     TRACE(("%s %d => %.20s true, new pc %u\n",
    1719                             opName[opCode], opnd, O2S(valuePtr),
    1720                             (unsigned int)(pc+opnd - codePtr->codeStart)));
    17211341                    TclDecrRefCount(valuePtr);
    17221342                    ADJUST_PC(opnd);
    17231343                } else {
    1724                     TRACE(("%s %d => %.20s false\n", opName[opCode], opnd,
    1725                             O2S(valuePtr)));
    17261344                    TclDecrRefCount(valuePtr);
    17271345                    ADJUST_PC(pcAdjustment);
     
    17501368                    result = Tcl_GetBooleanFromObj(interp, valuePtr, &b);
    17511369                    if (result != TCL_OK) {
    1752                         TRACE_WITH_OBJ(("%s %d => ERROR: ", opName[opCode],
    1753                                 opnd), Tcl_GetObjResult(interp));
    17541370                        Tcl_DecrRefCount(valuePtr);
    17551371                        goto checkForCatch;
     
    17571373                }
    17581374                if (b) {
    1759                     TRACE(("%s %d => %.20s true\n", opName[opCode], opnd,
    1760                             O2S(valuePtr)));
    17611375                    TclDecrRefCount(valuePtr);
    17621376                    ADJUST_PC(pcAdjustment);
    17631377                } else {
    1764                     TRACE(("%s %d => %.20s false, new pc %u\n",
    1765                             opName[opCode], opnd, O2S(valuePtr),
    1766                            (unsigned int)(pc + opnd - codePtr->codeStart)));
    17671378                    TclDecrRefCount(valuePtr);
    17681379                    ADJUST_PC(opnd);
     
    18041415                    }
    18051416                    if (result != TCL_OK) {
    1806                         TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",
    1807                                 opName[opCode], O2S(valuePtr),
    1808                                 (t1Ptr? t1Ptr->name : "null")));
    18091417                        IllegalExprOperandType(interp, opCode, valuePtr);
    18101418                        Tcl_DecrRefCount(valuePtr);
     
    18301438                    }
    18311439                    if (result != TCL_OK) {
    1832                         TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",
    1833                                 opName[opCode], O2S(value2Ptr),
    1834                                 (t2Ptr? t2Ptr->name : "null")));
    18351440                        IllegalExprOperandType(interp, opCode, value2Ptr);
    18361441                        Tcl_DecrRefCount(valuePtr);
     
    18511456                if (Tcl_IsShared(valuePtr)) {
    18521457                    PUSH_OBJECT(Tcl_NewLongObj(iResult));
    1853                     TRACE(("%s %.20s %.20s => %d\n", opName[opCode],
    1854                            O2S(valuePtr), O2S(value2Ptr), iResult));
    18551458                    TclDecrRefCount(valuePtr);
    18561459                } else {        /* reuse the valuePtr object */
    1857                     TRACE(("%s %.20s %.20s => %d\n",
    1858                            opName[opCode], /* NB: stack top is off by 1 */
    1859                            O2S(valuePtr), O2S(value2Ptr), iResult));
    18601460                    Tcl_SetLongObj(valuePtr, iResult);
    18611461                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     
    20131613                if (Tcl_IsShared(valuePtr)) {
    20141614                    PUSH_OBJECT(Tcl_NewLongObj(iResult));
    2015                     TRACE(("%s %.20s %.20s => %ld\n", opName[opCode],
    2016                         O2S(valuePtr), O2S(value2Ptr), iResult));
    20171615                    TclDecrRefCount(valuePtr);
    20181616                } else {        /* reuse the valuePtr object */
    2019                     TRACE(("%s %.20s %.20s => %ld\n",
    2020                         opName[opCode], /* NB: stack top is off by 1 */
    2021                         O2S(valuePtr), O2S(value2Ptr), iResult));
    20221617                    Tcl_SetLongObj(valuePtr, iResult);
    20231618                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     
    20491644                            valuePtr, &i);
    20501645                    if (result != TCL_OK) {
    2051                         TRACE(("%s %.20s %.20s => ILLEGAL 1st TYPE %s\n",
    2052                               opName[opCode], O2S(valuePtr), O2S(value2Ptr),
    2053                               (valuePtr->typePtr?
    2054                                    valuePtr->typePtr->name : "null")));
    20551646                        IllegalExprOperandType(interp, opCode, valuePtr);
    20561647                        Tcl_DecrRefCount(valuePtr);
     
    20651656                            value2Ptr, &i2);
    20661657                    if (result != TCL_OK) {
    2067                         TRACE(("%s %.20s %.20s => ILLEGAL 2nd TYPE %s\n",
    2068                               opName[opCode], O2S(valuePtr), O2S(value2Ptr),
    2069                               (value2Ptr->typePtr?
    2070                                    value2Ptr->typePtr->name : "null")));
    20711658                        IllegalExprOperandType(interp, opCode, value2Ptr);
    20721659                        Tcl_DecrRefCount(valuePtr);
     
    20851672                     */
    20861673                    if (i2 == 0) {
    2087                         TRACE(("mod %ld %ld => DIVIDE BY ZERO\n", i, i2));
    20881674                        Tcl_DecrRefCount(valuePtr);
    20891675                        Tcl_DecrRefCount(value2Ptr);
     
    21371723                if (Tcl_IsShared(valuePtr)) {
    21381724                    PUSH_OBJECT(Tcl_NewLongObj(iResult));
    2139                     TRACE(("%s %ld %ld => %ld\n", opName[opCode], i, i2,
    2140                            iResult));
    21411725                    TclDecrRefCount(valuePtr);
    21421726                } else {        /* reuse the valuePtr object */
    2143                     TRACE(("%s %ld %ld => %ld\n", opName[opCode], i, i2,
    2144                         iResult)); /* NB: stack top is off by 1 */
    21451727                    Tcl_SetLongObj(valuePtr, iResult);
    21461728                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     
    21861768                    }
    21871769                    if (result != TCL_OK) {
    2188                         TRACE(("%s %.20s %.20s => ILLEGAL 1st TYPE %s\n",
    2189                                opName[opCode], s, O2S(value2Ptr),
    2190                                (valuePtr->typePtr?
    2191                                     valuePtr->typePtr->name : "null")));
    21921770                        IllegalExprOperandType(interp, opCode, valuePtr);
    21931771                        Tcl_DecrRefCount(valuePtr);
     
    22121790                    }
    22131791                    if (result != TCL_OK) {
    2214                         TRACE(("%s %.20s %.20s => ILLEGAL 2nd TYPE %s\n",
    2215                                opName[opCode], O2S(valuePtr), s,
    2216                                (value2Ptr->typePtr?
    2217                                     value2Ptr->typePtr->name : "null")));
    22181792                        IllegalExprOperandType(interp, opCode, value2Ptr);
    22191793                        Tcl_DecrRefCount(valuePtr);
     
    22461820                    case INST_DIV:
    22471821                        if (d2 == 0.0) {
    2248                             TRACE(("div %.6g %.6g => DIVIDE BY ZERO\n",
    2249                                    d1, d2));
    22501822                            Tcl_DecrRefCount(valuePtr);
    22511823                            Tcl_DecrRefCount(value2Ptr);
     
    22611833                   
    22621834                    if (IS_NAN(dResult) || IS_INF(dResult)) {
    2263                         TRACE(("%s %.20s %.20s => IEEE FLOATING PT ERROR\n",
    2264                                opName[opCode], O2S(valuePtr), O2S(value2Ptr)));
    22651835                        TclExprFloatError(interp, dResult);
    22661836                        result = TCL_ERROR;
     
    22911861                         */
    22921862                        if (i2 == 0) {
    2293                             TRACE(("div %ld %ld => DIVIDE BY ZERO\n",
    2294                                     i, i2));
    22951863                            Tcl_DecrRefCount(valuePtr);
    22961864                            Tcl_DecrRefCount(value2Ptr);
     
    23181886                    if (doDouble) {
    23191887                        PUSH_OBJECT(Tcl_NewDoubleObj(dResult));
    2320                         TRACE(("%s %.6g %.6g => %.6g\n", opName[opCode],
    2321                                d1, d2, dResult));
    23221888                    } else {
    23231889                        PUSH_OBJECT(Tcl_NewLongObj(iResult));
    2324                         TRACE(("%s %ld %ld => %ld\n", opName[opCode],
    2325                                i, i2, iResult));
    23261890                    }
    23271891                    TclDecrRefCount(valuePtr);
    23281892                } else {            /* reuse the valuePtr object */
    23291893                    if (doDouble) { /* NB: stack top is off by 1 */
    2330                         TRACE(("%s %.6g %.6g => %.6g\n", opName[opCode],
    2331                                d1, d2, dResult));
    23321894                        Tcl_SetDoubleObj(valuePtr, dResult);
    23331895                    } else {
    2334                         TRACE(("%s %ld %ld => %ld\n", opName[opCode],
    2335                                i, i2, iResult));
    23361896                        Tcl_SetLongObj(valuePtr, iResult);
    23371897                    }
     
    23631923                    }
    23641924                    if (result != TCL_OK) {
    2365                         TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",
    2366                                 opName[opCode], s,
    2367                                 (tPtr? tPtr->name : "null")));
    23681925                        IllegalExprOperandType(interp, opCode, valuePtr);
    23691926                        goto checkForCatch;
    23701927                    }
    23711928                }
    2372                 TRACE_WITH_OBJ(("uplus %s => ", O2S(valuePtr)), valuePtr);
    23731929            }
    23741930            ADJUST_PC(1);
     
    23991955                    }
    24001956                    if (result != TCL_OK) {
    2401                         TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s\n",
    2402                                 opName[opCode], s,
    2403                                (tPtr? tPtr->name : "null")));
    24041957                        IllegalExprOperandType(interp, opCode, valuePtr);
    24051958                        Tcl_DecrRefCount(valuePtr);
     
    24171970                        objPtr = Tcl_NewLongObj(
    24181971                                (opCode == INST_UMINUS)? -i : !i);
    2419                         TRACE_WITH_OBJ(("%s %ld => ", opName[opCode], i),
    2420                                 objPtr); /* NB: stack top is off by 1 */
    24211972                    } else {
    24221973                        d = valuePtr->internalRep.doubleValue;
     
    24301981                            objPtr = Tcl_NewLongObj((d==0.0)? 1 : 0);
    24311982                        }
    2432                         TRACE_WITH_OBJ(("%s %.6g => ", opName[opCode], d),
    2433                                 objPtr); /* NB: stack top is off by 1 */
    24341983                    }
    24351984                    PUSH_OBJECT(objPtr);
     
    24431992                        Tcl_SetLongObj(valuePtr,
    24441993                                (opCode == INST_UMINUS)? -i : !i);
    2445                         TRACE_WITH_OBJ(("%s %ld => ", opName[opCode], i),
    2446                                 valuePtr); /* NB: stack top is off by 1 */
    24471994                    } else {
    24481995                        d = valuePtr->internalRep.doubleValue;
     
    24562003                            Tcl_SetLongObj(valuePtr, (d==0.0)? 1 : 0);
    24572004                        }
    2458                         TRACE_WITH_OBJ(("%s %.6g => ", opName[opCode], d),
    2459                                 valuePtr); /* NB: stack top is off by 1 */
    24602005                    }
    24612006                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     
    24812026                            valuePtr, &i);
    24822027                    if (result != TCL_OK) {   /* try to convert to double */
    2483                         TRACE(("bitnot \"%.20s\" => ILLEGAL TYPE %s\n",
    2484                                O2S(valuePtr), (tPtr? tPtr->name : "null")));
    24852028                        IllegalExprOperandType(interp, opCode, valuePtr);
    24862029                        Tcl_DecrRefCount(valuePtr);
     
    24922035                if (Tcl_IsShared(valuePtr)) {
    24932036                    PUSH_OBJECT(Tcl_NewLongObj(~i));
    2494                     TRACE(("bitnot 0x%lx => (%lu)\n", i, ~i));
    24952037                    TclDecrRefCount(valuePtr);
    24962038                } else {
     
    25002042                    Tcl_SetLongObj(valuePtr, ~i);
    25012043                    ++stackTop; /* valuePtr now on stk top has right r.c. */
    2502                     TRACE(("bitnot 0x%lx => (%lu)\n", i, ~i));
    25032044                }
    25042045            }
     
    25152056
    25162057                if ((opnd < 0) || (opnd > LAST_BUILTIN_FUNC)) {
    2517                     TRACE(("UNRECOGNIZED BUILTIN FUNC CODE %d\n", opnd));
    25182058                    panic("TclExecuteByteCode: unrecognized builtin function code %d", opnd);
    25192059                }
     
    25282068                    goto checkForCatch;
    25292069                }
    2530                 TRACE_WITH_OBJ(("callBuiltinFunc1 %d => ", opnd),
    2531                         stackPtr[stackTop].o);
    25322070            }
    25332071            ADJUST_PC(2);
     
    25552093                    goto checkForCatch;
    25562094                }
    2557                 TRACE_WITH_OBJ(("callFunc1 %d => ", objc),
    2558                         stackPtr[stackTop].o);
    25592095                ADJUST_PC(2);
    25602096            }
     
    26272163                        d = valuePtr->internalRep.doubleValue;
    26282164                        if (IS_NAN(d) || IS_INF(d)) {
    2629                             TRACE(("tryCvtToNumeric \"%.20s\" => IEEE FLOATING PT ERROR\n",
    2630                                    O2S(valuePtr)));
    26312165                            TclExprFloatError(interp, d);
    26322166                            result = TCL_ERROR;
     
    26362170                    shared = shared;            /* lint, shared not used. */
    26372171                    converted = converted;      /* lint, converted not used. */
    2638                     TRACE(("tryCvtToNumeric \"%.20s\" => numeric, %s, %s\n",
    2639                            O2S(valuePtr),
    2640                            (converted? "converted" : "not converted"),
    2641                            (shared? "shared" : "not shared")));
    2642                 } else {
    2643                     TRACE(("tryCvtToNumeric \"%.20s\" => not numeric\n",
    2644                            O2S(valuePtr)));
    26452172                }
    26462173            }
     
    26602187                    codePtr);
    26612188            if (rangePtr == NULL) {
    2662                 TRACE(("break => no encl. loop or catch, returning TCL_BREAK\n"));
    26632189                result = TCL_BREAK;
    26642190                goto abnormalReturn; /* no catch exists to check */
     
    26672193            case LOOP_EXCEPTION_RANGE:
    26682194                result = TCL_OK;
    2669                 TRACE(("break => range at %d, new pc %d\n",
    2670                        rangePtr->codeOffset, rangePtr->breakOffset));
    26712195                break;
    26722196            case CATCH_EXCEPTION_RANGE:
    26732197                result = TCL_BREAK;
    2674                 TRACE(("break => ...\n"));
    26752198                goto processCatch; /* it will use rangePtr */
    26762199            default:
     
    26932216                    codePtr);
    26942217            if (rangePtr == NULL) {
    2695                 TRACE(("continue => no encl. loop or catch, returning TCL_CONTINUE\n"));
    26962218                result = TCL_CONTINUE;
    26972219                goto abnormalReturn;
     
    27002222            case LOOP_EXCEPTION_RANGE:
    27012223                if (rangePtr->continueOffset == -1) {
    2702                     TRACE(("continue => loop w/o continue, checking for catch\n"));
    27032224                    goto checkForCatch;
    27042225                } else {
    27052226                    result = TCL_OK;
    2706                     TRACE(("continue => range at %d, new pc %d\n",
    2707                            rangePtr->codeOffset, rangePtr->continueOffset));
    27082227                }
    27092228                break;
    27102229            case CATCH_EXCEPTION_RANGE:
    27112230                result = TCL_CONTINUE;
    2712                 TRACE(("continue => ...\n"));
    27132231                goto processCatch; /* it will use rangePtr */
    27142232            default:
     
    27442262                TclSetVarScalar(iterVarPtr);
    27452263                TclClearVarUndefined(iterVarPtr);
    2746                 TRACE(("foreach_start4 %u => loop iter count temp %d\n",
    2747                         opnd, iterTmpIndex));
    27482264            }
    27492265            ADJUST_PC(5);
     
    27942310                    result = Tcl_ListObjLength(interp, listPtr, &listLen);
    27952311                    if (result != TCL_OK) {
    2796                         TRACE_WITH_OBJ(("foreach_step4 %u => ERROR converting list %ld, \"%s\": ",
    2797                                 opnd, i, O2S(listPtr)),
    2798                                 Tcl_GetObjResult(interp));
    27992312                        goto checkForCatch;
    28002313                    }
     
    28402353                            CACHE_STACK_INFO();
    28412354                            if (value2Ptr == NULL) {
    2842                                 TRACE_WITH_OBJ(("foreach_step4 %u => ERROR init. index temp %d: ",
    2843                                        opnd, varIndex),
    2844                                        Tcl_GetObjResult(interp));
    28452355                                if (setEmptyStr) {
    28462356                                    Tcl_DecrRefCount(elemPtr); /* unneeded */
     
    28622372
    28632373                PUSH_OBJECT(Tcl_NewLongObj(continueLoop));
    2864                 TRACE(("foreach_step4 %u => %d lists, iter %d, %s loop\n",
    2865                         opnd, numLists, iterNum,
    2866                         (continueLoop? "continue" : "exit")));
    28672374            }
    28682375            ADJUST_PC(5);
     
    28752382             */
    28762383            catchStackPtr[++catchTop] = stackTop;
    2877             TRACE(("beginCatch4 %u => catchTop=%d, stackTop=%d\n",
    2878                     TclGetUInt4AtPtr(pc+1), catchTop, stackTop));
    28792384            ADJUST_PC(5);
    28802385
     
    28822387            catchTop--;
    28832388            result = TCL_OK;
    2884             TRACE(("endCatch => catchTop=%d\n", catchTop));
    28852389            ADJUST_PC(1);
    28862390
    28872391        case INST_PUSH_RESULT:
    28882392            PUSH_OBJECT(Tcl_GetObjResult(interp));
    2889             TRACE_WITH_OBJ(("pushResult => "), Tcl_GetObjResult(interp));
    28902393            ADJUST_PC(1);
    28912394
    28922395        case INST_PUSH_RETURN_CODE:
    28932396            PUSH_OBJECT(Tcl_NewLongObj(result));
    2894             TRACE(("pushReturnCode => %u\n", result));
    28952397            ADJUST_PC(1);
    28962398
    28972399        default:
    2898             TRACE(("UNRECOGNIZED INSTRUCTION %u\n", opCode));
    28992400            panic("TclExecuteByteCode: unrecognized opCode %u", opCode);
    29002401        } /* end of switch on opCode */
     
    29262427        rangePtr = TclGetExceptionRangeForPc(pc, /*catchOnly*/ 1, codePtr);
    29272428        if (rangePtr == NULL) {
    2928             TRACE(("   ... no enclosing catch, returning %s\n",
    2929                     StringForResultCode(result)));
    29302429            goto abnormalReturn;
    29312430        }
     
    29452444            TclDecrRefCount(valuePtr);
    29462445        }
    2947         TRACE(("  ... found catch at %d, catchTop=%d, unwound to %d, new pc %u\n",
    2948                 rangePtr->codeOffset, catchTop, catchStackPtr[catchTop],
    2949                 (unsigned int)(rangePtr->catchOffset)));
    29502446        pc = (codePtr->codeStart + rangePtr->catchOffset);
    29512447        continue;               /* restart the execution loop at pc */
     
    29752471#undef STATIC_CATCH_STACK_SIZE
    29762472}
    2977 
    2978 
    2979 /*
    2980  *----------------------------------------------------------------------
    2981  *
    2982  * PrintByteCodeInfo --
    2983  *
    2984  *      This procedure prints a summary about a bytecode object to stdout.
    2985  *      It is called by TclExecuteByteCode when starting to execute the
    2986  *      bytecode object if tclTraceExec has the value 2 or more.
    2987  *
    2988  * Results:
    2989  *      None.
    2990  *
    2991  * Side effects:
    2992  *      None.
    2993  *
    2994  *----------------------------------------------------------------------
    2995  */
    2996 
    2997 static void
    2998 PrintByteCodeInfo(codePtr)
    2999     register ByteCode *codePtr; /* The bytecode whose summary is printed
    3000                                  * to stdout. */
    3001 {
    3002     Proc *procPtr = codePtr->procPtr;
    3003     int numCmds = codePtr->numCommands;
    3004     int numObjs = codePtr->numObjects;
    3005     int objBytes, i;
    3006 
    3007     objBytes = (numObjs * sizeof(Tcl_Obj));
    3008     for (i = 0;  i < numObjs;  i++) {
    3009         Tcl_Obj *litObjPtr = codePtr->objArrayPtr[i];
    3010         if (litObjPtr->bytes != NULL) {
    3011             objBytes += litObjPtr->length;
    3012         }
    3013     }
    3014    
    3015     fprintf(stdout, "\nExecuting ByteCode 0x%x, ref ct %u, epoch %u, interp 0x%x(epoch %u)\n",
    3016             (unsigned int) codePtr, codePtr->refCount,
    3017             codePtr->compileEpoch, (unsigned int) codePtr->iPtr,
    3018             codePtr->iPtr->compileEpoch);
    3019    
    3020     fprintf(stdout, "  Source: ");
    3021     TclPrintSource(stdout, codePtr->source, 70);
    3022 
    3023     fprintf(stdout, "\n  Cmds %d, chars %d, inst %u, objs %u, aux %d, stk depth %u, code/src %.2fn",
    3024             numCmds, codePtr->numSrcChars, codePtr->numCodeBytes, numObjs,
    3025             codePtr->numAuxDataItems, codePtr->maxStackDepth,
    3026             (codePtr->numSrcChars?
    3027                     ((float)codePtr->totalSize)/((float)codePtr->numSrcChars) : 0.0));
    3028 
    3029     fprintf(stdout, "  Code %zu = %u(header)+%d(inst)+%d(objs)+%u(exc)+%u(aux)+%d(cmd map)\n",
    3030             codePtr->totalSize, sizeof(ByteCode), codePtr->numCodeBytes,
    3031             objBytes, (codePtr->numExcRanges * sizeof(ExceptionRange)),
    3032             (codePtr->numAuxDataItems * sizeof(AuxData)),
    3033             codePtr->numCmdLocBytes);
    3034 
    3035     if (procPtr != NULL) {
    3036         fprintf(stdout,
    3037                 "  Proc 0x%x, ref ct %d, args %d, compiled locals %d\n",
    3038                 (unsigned int) procPtr, procPtr->refCount,
    3039                 procPtr->numArgs, procPtr->numCompiledLocals);
    3040     }
    3041 }
    3042 
    3043 
    3044 /*
    3045  *----------------------------------------------------------------------
    3046  *
    3047  * ValidatePcAndStackTop --
    3048  *
    3049  *      This procedure is called by TclExecuteByteCode when debugging to
    3050  *      verify that the program counter and stack top are valid during
    3051  *      execution.
    3052  *
    3053  * Results:
    3054  *      None.
    3055  *
    3056  * Side effects:
    3057  *      Prints a message to stderr and panics if either the pc or stack
    3058  *      top are invalid.
    3059  *
    3060  *----------------------------------------------------------------------
    3061  */
    3062 
    3063 #ifdef TCL_COMPILE_DEBUG
    3064 static void
    3065 ValidatePcAndStackTop(codePtr, pc, stackTop, stackLowerBound, stackUpperBound)
    3066     register ByteCode *codePtr; /* The bytecode whose summary is printed
    3067                                  * to stdout. */
    3068     unsigned char *pc;          /* Points to first byte of a bytecode
    3069                                  * instruction. The program counter. */
    3070     int stackTop;               /* Current stack top. Must be between
    3071                                  * stackLowerBound and stackUpperBound
    3072                                  * (inclusive). */
    3073     int stackLowerBound;        /* Smallest legal value for stackTop. */
    3074     int stackUpperBound;        /* Greatest legal value for stackTop. */
    3075 {
    3076     unsigned int relativePc = (unsigned int) (pc - codePtr->codeStart);
    3077     unsigned int codeStart = (unsigned int) codePtr->codeStart;
    3078     unsigned int codeEnd = (unsigned int)
    3079             (codePtr->codeStart + codePtr->numCodeBytes);
    3080     unsigned char opCode = *pc;
    3081 
    3082     if (((unsigned int) pc < codeStart) || ((unsigned int) pc > codeEnd)) {
    3083         fprintf(stderr, "\nBad instruction pc 0x%x in TclExecuteByteCode\n",
    3084                 (unsigned int) pc);
    3085         panic("TclExecuteByteCode execution failure: bad pc");
    3086     }
    3087     if ((unsigned int) opCode > LAST_INST_OPCODE) {
    3088         fprintf(stderr, "\nBad opcode %d at pc %u in TclExecuteByteCode\n",
    3089                 (unsigned int) opCode, relativePc);
    3090         panic("TclExecuteByteCode execution failure: bad opcode");
    3091     }
    3092     if ((stackTop < stackLowerBound) || (stackTop > stackUpperBound)) {
    3093         int numChars;
    3094         char *cmd = GetSrcInfoForPc(pc, codePtr, &numChars);
    3095         char *ellipsis = "";
    3096        
    3097         fprintf(stderr, "\nBad stack top %d at pc %u in TclExecuteByteCode",
    3098                 stackTop, relativePc);
    3099         if (cmd != NULL) {
    3100             if (numChars > 100) {
    3101                 numChars = 100;
    3102                 ellipsis = "...";
    3103             }
    3104             fprintf(stderr, "\n executing %.*s%s\n", numChars, cmd,
    3105                     ellipsis);
    3106         } else {
    3107             fprintf(stderr, "\n");
    3108         }
    3109         panic("TclExecuteByteCode execution failure: bad stack top");
    3110     }
    3111 }
    3112 #endif /* TCL_COMPILE_DEBUG */
    31132473
    31142474
     
    42713631
    42723632
    4273 #ifdef TCL_COMPILE_STATS
    4274 /*
    4275  *----------------------------------------------------------------------
    4276  *
    4277  * TclLog2 --
    4278  *
    4279  *      Procedure used while collecting compilation statistics to determine
    4280  *      the log base 2 of an integer.
    4281  *
    4282  * Results:
    4283  *      Returns the log base 2 of the operand. If the argument is less
    4284  *      than or equal to zero, a zero is returned.
    4285  *
    4286  * Side effects:
    4287  *      None.
    4288  *
    4289  *----------------------------------------------------------------------
    4290  */
    4291 
    4292 int
    4293 TclLog2(value)
    4294     register int value;         /* The integer for which to compute the
    4295                                  * log base 2. */
    4296 {
    4297     register int n = value;
    4298     register int result = 0;
    4299 
    4300     while (n > 1) {
    4301         n = n >> 1;
    4302         result++;
    4303     }
    4304     return result;
    4305 }
    4306 
    4307 
    4308 /*
    4309  *----------------------------------------------------------------------
    4310  *
    4311  * EvalStatsCmd --
    4312  *
    4313  *      Implements the "evalstats" command that prints instruction execution
    4314  *      counts to stdout.
    4315  *
    4316  * Results:
    4317  *      Standard Tcl results.
    4318  *
    4319  * Side effects:
    4320  *      None.
    4321  *
    4322  *----------------------------------------------------------------------
    4323  */
    4324 
    4325 static int
    4326 EvalStatsCmd(unused, interp, argc, argv)
    4327     ClientData unused;          /* Unused. */
    4328     Tcl_Interp *interp;         /* The current interpreter. */
    4329     int argc;                   /* The number of arguments. */
    4330     char **argv;                /* The argument strings. */
    4331 {
    4332     register double total = 0.0;
    4333     register int i;
    4334     int maxSizeDecade = 0;
    4335     double totalHeaderBytes = (tclNumCompilations * sizeof(ByteCode));
    4336 
    4337     for (i = 0;  i < 256;  i++) {
    4338         if (instructionCount[i] != 0) {
    4339             total += instructionCount[i];
    4340         }
    4341     }
    4342 
    4343     for (i = 31;  i >= 0;  i--) {
    4344         if ((tclSourceCount[i] > 0) && (tclByteCodeCount[i] > 0)) {
    4345             maxSizeDecade = i;
    4346             break;
    4347         }
    4348     }
    4349 
    4350     fprintf(stdout, "\nNumber of compilations           %ld\n",
    4351             tclNumCompilations);
    4352     fprintf(stdout, "Number of executions               %ld\n",
    4353             numExecutions);
    4354     fprintf(stdout, "Average executions/compilation     %.0f\n",
    4355             ((float) numExecutions/tclNumCompilations));
    4356    
    4357     fprintf(stdout, "\nInstructions executed            %.0f\n",
    4358             total);
    4359     fprintf(stdout, "Average instructions/compile       %.0f\n",
    4360             total/tclNumCompilations);
    4361     fprintf(stdout, "Average instructions/execution     %.0f\n",
    4362             total/numExecutions);
    4363    
    4364     fprintf(stdout, "\nTotal source bytes               %.6g\n",
    4365             tclTotalSourceBytes);
    4366     fprintf(stdout, "Total code bytes           %.6g\n",
    4367             tclTotalCodeBytes);
    4368     fprintf(stdout, "Average code/compilation   %.0f\n",
    4369             tclTotalCodeBytes/tclNumCompilations);
    4370     fprintf(stdout, "Average code/source                %.2f\n",
    4371             tclTotalCodeBytes/tclTotalSourceBytes);
    4372     fprintf(stdout, "Current source bytes               %.6g\n",
    4373             tclCurrentSourceBytes);
    4374     fprintf(stdout, "Current code bytes         %.6g\n",
    4375             tclCurrentCodeBytes);
    4376     fprintf(stdout, "Current code/source                %.2f\n",
    4377             tclCurrentCodeBytes/tclCurrentSourceBytes);
    4378    
    4379     fprintf(stdout, "\nTotal objects allocated          %ld\n",
    4380             tclObjsAlloced);
    4381     fprintf(stdout, "Total objects freed                %ld\n",
    4382             tclObjsFreed);
    4383     fprintf(stdout, "Current objects:           %ld\n",
    4384             (tclObjsAlloced - tclObjsFreed));
    4385 
    4386     fprintf(stdout, "\nBreakdown of code byte requirements:\n");
    4387     fprintf(stdout, "                   Total bytes      Pct of    Avg per\n");
    4388     fprintf(stdout, "                                  all code    compile\n");
    4389     fprintf(stdout, "Total code        %12.6g        100%%   %8.2f\n",
    4390             tclTotalCodeBytes, tclTotalCodeBytes/tclNumCompilations);
    4391     fprintf(stdout, "Header            %12.6g   %8.2f%%   %8.2f\n",
    4392             totalHeaderBytes,
    4393             ((totalHeaderBytes * 100.0) / tclTotalCodeBytes),
    4394             totalHeaderBytes/tclNumCompilations);
    4395     fprintf(stdout, "Instructions      %12.6g   %8.2f%%   %8.2f\n",
    4396             tclTotalInstBytes,
    4397             ((tclTotalInstBytes * 100.0) / tclTotalCodeBytes),
    4398             tclTotalInstBytes/tclNumCompilations);
    4399     fprintf(stdout, "Objects           %12.6g   %8.2f%%   %8.2f\n",
    4400             tclTotalObjBytes,
    4401             ((tclTotalObjBytes * 100.0) / tclTotalCodeBytes),
    4402             tclTotalObjBytes/tclNumCompilations);
    4403     fprintf(stdout, "Exception table   %12.6g   %8.2f%%   %8.2f\n",
    4404             tclTotalExceptBytes,
    4405             ((tclTotalExceptBytes * 100.0) / tclTotalCodeBytes),
    4406             tclTotalExceptBytes/tclNumCompilations);
    4407     fprintf(stdout, "Auxiliary data    %12.6g   %8.2f%%   %8.2f\n",
    4408             tclTotalAuxBytes,
    4409             ((tclTotalAuxBytes * 100.0) / tclTotalCodeBytes),
    4410             tclTotalAuxBytes/tclNumCompilations);
    4411     fprintf(stdout, "Command map       %12.6g   %8.2f%%   %8.2f\n",
    4412             tclTotalCmdMapBytes,
    4413             ((tclTotalCmdMapBytes * 100.0) / tclTotalCodeBytes),
    4414             tclTotalCmdMapBytes/tclNumCompilations);
    4415    
    4416     fprintf(stdout, "\nSource and ByteCode size distributions:\n");
    4417     fprintf(stdout, "    binary decade          source    code\n");
    4418     for (i = 0;  i <= maxSizeDecade;  i++) {
    4419         int decadeLow, decadeHigh;
    4420 
    4421         if (i == 0) {
    4422             decadeLow = 0;
    4423         } else {
    4424             decadeLow = 1 << i;
    4425         }
    4426         decadeHigh = (1 << (i+1)) - 1;
    4427         fprintf(stdout, "       %6d -%6d                %6d     %6d\n",
    4428                 decadeLow, decadeHigh,
    4429                 tclSourceCount[i], tclByteCodeCount[i]);
    4430     }
    4431 
    4432     fprintf(stdout, "\nInstruction counts:\n");
    4433     for (i = 0;  i < 256;  i++) {
    4434         if (instructionCount[i]) {
    4435             fprintf(stdout, "%20s %8d %6.2f%%\n",
    4436                     opName[i], instructionCount[i],
    4437                     (instructionCount[i] * 100.0)/total);
    4438         }
    4439     }
    4440 
    4441 #ifdef TCL_MEM_DEBUG
    4442     fprintf(stdout, "\nHeap Statistics:\n");
    4443     TclDumpMemoryInfo(stdout);
    4444 #endif /* TCL_MEM_DEBUG */
    4445 
    4446     return TCL_OK;
    4447 }
    4448 #endif /* TCL_COMPILE_STATS */
    4449 
    4450 
    44513633/*
    44523634 *----------------------------------------------------------------------
     
    47583940    panic("UpdateStringOfCmdName should never be invoked");
    47593941}
    4760 
    4761 
    4762 #ifdef TCL_COMPILE_DEBUG
    4763 /*
    4764  *----------------------------------------------------------------------
    4765  *
    4766  * StringForResultCode --
    4767  *
    4768  *      Procedure that returns a human-readable string representing a
    4769  *      Tcl result code such as TCL_ERROR.
    4770  *
    4771  * Results:
    4772  *      If the result code is one of the standard Tcl return codes, the
    4773  *      result is a string representing that code such as "TCL_ERROR".
    4774  *      Otherwise, the result string is that code formatted as a
    4775  *      sequence of decimal digit characters. Note that the resulting
    4776  *      string must not be modified by the caller.
    4777  *
    4778  * Side effects:
    4779  *      None.
    4780  *
    4781  *----------------------------------------------------------------------
    4782  */
    4783 
    4784 static char *
    4785 StringForResultCode(result)
    4786     int result;                 /* The Tcl result code for which to
    4787                                  * generate a string. */
    4788 {
    4789     static char buf[20];
    4790    
    4791     if ((result >= TCL_OK) && (result <= TCL_CONTINUE)) {
    4792         return resultStrings[result];
    4793     }
    4794     TclFormatInt(buf, result);
    4795     return buf;
    4796 }
    4797 #endif /* TCL_COMPILE_DEBUG */
  • external/tcl/tclInt.h

    re39abb4 r0e7d64a  
    13261326
    13271327extern Tcl_Obj *        tclFreeObjList;
    1328 
    1329 #ifdef TCL_COMPILE_STATS
    1330 extern long             tclObjsAlloced;
    1331 extern long             tclObjsFreed;
    1332 #endif /* TCL_COMPILE_STATS */
    13331328
    13341329/*
     
    14451440                            int objc, Tcl_Obj *CONST objv[], int flags));
    14461441EXTERN char *           TclpAlloc _ANSI_ARGS_((unsigned int size));
    1447 
     1442EXTERN void             TclpFree(char *cp);
    14481443EXTERN char *           TclpRealloc _ANSI_ARGS_((char *ptr,
    14491444                            unsigned int size));
     
    14721467EXTERN int              TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp,
    14731468                            Tcl_Interp *cmdInterp, Tcl_Command cmd));
    1474 EXTERN void             TclPrintByteCodeObj _ANSI_ARGS_((Tcl_Interp *interp,
    1475                             Tcl_Obj *objPtr));
    14761469EXTERN void             TclProcCleanupProc _ANSI_ARGS_((Proc *procPtr));
    14771470EXTERN int              TclProcCompileProc _ANSI_ARGS_((Tcl_Interp *interp,
     
    16881681 */
    16891682
    1690 #ifdef TCL_COMPILE_STATS
    1691 #  define TclIncrObjsAllocated() \
    1692     tclObjsAlloced++
    1693 #  define TclIncrObjsFreed() \
    1694     tclObjsFreed++
    1695 #else
    1696 #  define TclIncrObjsAllocated()
    1697 #  define TclIncrObjsFreed()
    1698 #endif /* TCL_COMPILE_STATS */
    1699 
    1700 #ifdef TCL_MEM_DEBUG
    1701 #  define TclNewObj(objPtr) \
    1702     (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), __FILE__, __LINE__); \
    1703     (objPtr)->refCount = 0; \
    1704     (objPtr)->bytes    = tclEmptyStringRep; \
    1705     (objPtr)->length   = 0; \
    1706     (objPtr)->typePtr  = NULL; \
    1707     TclIncrObjsAllocated()
    1708 #  define TclDbNewObj(objPtr, file, line) \
    1709     (objPtr) = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), (file), (line)); \
    1710     (objPtr)->refCount = 0; \
    1711     (objPtr)->bytes    = tclEmptyStringRep; \
    1712     (objPtr)->length   = 0; \
    1713     (objPtr)->typePtr  = NULL; \
    1714     TclIncrObjsAllocated()
    1715 #  define TclDecrRefCount(objPtr) \
    1716     if (--(objPtr)->refCount <= 0) { \
    1717         if ((objPtr)->refCount < -1) \
    1718             panic("Reference count for %lx was negative: %s line %d", \
    1719                   (objPtr), __FILE__, __LINE__); \
    1720         if (((objPtr)->bytes != NULL) \
    1721                 && ((objPtr)->bytes != tclEmptyStringRep)) { \
    1722             ckfree((char *) (objPtr)->bytes); \
    1723         } \
    1724         if (((objPtr)->typePtr != NULL) \
    1725                 && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \
    1726             (objPtr)->typePtr->freeIntRepProc(objPtr); \
    1727         } \
    1728         ckfree((char *) (objPtr)); \
    1729         TclIncrObjsFreed(); \
    1730     }
    1731 #else /* not TCL_MEM_DEBUG */
    17321683#  define TclNewObj(objPtr) \
    17331684    if (tclFreeObjList == NULL) { \
     
    17401691    (objPtr)->bytes    = tclEmptyStringRep; \
    17411692    (objPtr)->length   = 0; \
    1742     (objPtr)->typePtr  = NULL; \
    1743     TclIncrObjsAllocated()
     1693    (objPtr)->typePtr  = NULL;
    17441694#  define TclDecrRefCount(objPtr) \
    17451695    if (--(objPtr)->refCount <= 0) { \
     
    17541704        (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
    17551705        tclFreeObjList = (objPtr); \
    1756         TclIncrObjsFreed(); \
    17571706    }
    1758 #endif /* TCL_MEM_DEBUG */
    17591707
    17601708/*
  • external/tcl/tclListObj.c

    re39abb4 r0e7d64a  
    4646 * Tcl_NewListObj --
    4747 *
    48  *      This procedure is normally called when not debugging: i.e., when
    49  *      TCL_MEM_DEBUG is not defined. It creates a new list object from an
    50  *      (objc,objv) array: that is, each of the objc elements of the array
    51  *      referenced by objv is inserted as an element into a new Tcl object.
    52  *
    53  *      When TCL_MEM_DEBUG is defined, this procedure just returns the
    54  *      result of calling the debugging version Tcl_DbNewListObj.
     48 *      This procedure creates a new list object from an (objc,objv) array:
     49 *      that is, each of the objc elements of the array referenced by objv
     50 *      is inserted as an element into a new Tcl object.
    5551 *
    5652 * Results:
     
    6662 *----------------------------------------------------------------------
    6763 */
    68 
    69 #ifdef TCL_MEM_DEBUG
    70 #undef Tcl_NewListObj
    71 
    72 Tcl_Obj *
    73 Tcl_NewListObj(objc, objv)
    74     int objc;                   /* Count of objects referenced by objv. */
    75     Tcl_Obj *CONST objv[];      /* An array of pointers to Tcl objects. */
    76 {
    77     return Tcl_DbNewListObj(objc, objv, "unknown", 0);
    78 }
    79 
    80 #else /* if not TCL_MEM_DEBUG */
    8164
    8265Tcl_Obj *
     
    11295    return listPtr;
    11396}
    114 #endif /* if TCL_MEM_DEBUG */
    115 
    116 
    117 /*
    118  *----------------------------------------------------------------------
    119  *
    120  * Tcl_DbNewListObj --
    121  *
    122  *      This procedure is normally called when debugging: i.e., when
    123  *      TCL_MEM_DEBUG is defined. It creates new list objects. It is the
    124  *      same as the Tcl_NewListObj procedure above except that it calls
    125  *      Tcl_DbCkalloc directly with the file name and line number from its
    126  *      caller. This simplifies debugging since then the checkmem command
    127  *      will report the correct file name and line number when reporting
    128  *      objects that haven't been freed.
    129  *
    130  *      When TCL_MEM_DEBUG is not defined, this procedure just returns the
    131  *      result of calling Tcl_NewListObj.
    132  *
    133  * Results:
    134  *      A new list object is returned that is initialized from the object
    135  *      pointers in objv. If objc is less than or equal to zero, an empty
    136  *      object is returned. The new object's string representation
    137  *      is left NULL. The new list object has ref count 0.
    138  *
    139  * Side effects:
    140  *      The ref counts of the elements in objv are incremented since the
    141  *      resulting list now refers to them.
    142  *
    143  *----------------------------------------------------------------------
    144  */
    145 
    146 #ifdef TCL_MEM_DEBUG
    147 
    148 Tcl_Obj *
    149 Tcl_DbNewListObj(objc, objv, file, line)
    150     int objc;                   /* Count of objects referenced by objv. */
    151     Tcl_Obj *CONST objv[];      /* An array of pointers to Tcl objects. */
    152     char *file;                 /* The name of the source file calling this
    153                                  * procedure; used for debugging. */
    154     int line;                   /* Line number in the source file; used
    155                                  * for debugging. */
    156 {
    157     register Tcl_Obj *listPtr;
    158     register Tcl_Obj **elemPtrs;
    159     register List *listRepPtr;
    160     int i;
    161    
    162     TclDbNewObj(listPtr, file, line);
    163    
    164     if (objc > 0) {
    165         Tcl_InvalidateStringRep(listPtr);
    166        
    167         elemPtrs = (Tcl_Obj **)
    168             ckalloc((unsigned) (objc * sizeof(Tcl_Obj *)));
    169         for (i = 0;  i < objc;  i++) {
    170             elemPtrs[i] = objv[i];
    171             Tcl_IncrRefCount(elemPtrs[i]);
    172         }
    173        
    174         listRepPtr = (List *) ckalloc(sizeof(List));
    175         listRepPtr->maxElemCount = objc;
    176         listRepPtr->elemCount    = objc;
    177         listRepPtr->elements     = elemPtrs;
    178        
    179         listPtr->internalRep.otherValuePtr = (VOID *) listRepPtr;
    180         listPtr->typePtr = &tclListType;
    181     }
    182     return listPtr;
    183 }
    184 
    185 #else /* if not TCL_MEM_DEBUG */
    186 
    187 Tcl_Obj *
    188 Tcl_DbNewListObj(objc, objv, file, line)
    189     int objc;                   /* Count of objects referenced by objv. */
    190     Tcl_Obj *CONST objv[];      /* An array of pointers to Tcl objects. */
    191     char *file;                 /* The name of the source file calling this
    192                                  * procedure; used for debugging. */
    193     int line;                   /* Line number in the source file; used
    194                                  * for debugging. */
    195 {
    196     return Tcl_NewListObj(objc, objv);
    197 }
    198 #endif /* TCL_MEM_DEBUG */
    19997
    20098
  • external/tcl/tclObj.c

    re39abb4 r0e7d64a  
    3636
    3737char *tclEmptyStringRep = NULL;
    38 
    39 /*
    40  * Count of the number of Tcl objects every allocated (by Tcl_NewObj) and
    41  * freed (by TclFreeObj).
    42  */
    43 
    44 #ifdef TCL_COMPILE_STATS
    45 long tclObjsAlloced = 0;
    46 long tclObjsFreed = 0;
    47 #endif /* TCL_COMPILE_STATS */
    4838
    4939/*
     
    417407 * Tcl_NewObj --
    418408 *
    419  *      This procedure is normally called when not debugging: i.e., when
    420  *      TCL_MEM_DEBUG is not defined. It creates new Tcl objects that denote
    421  *      the empty string. These objects have a NULL object type and NULL
    422  *      string representation byte pointer. Type managers call this routine
    423  *      to allocate new objects that they further initialize.
    424  *
    425  *      When TCL_MEM_DEBUG is defined, this procedure just returns the
    426  *      result of calling the debugging version Tcl_DbNewObj.
     409 *      This procedure creates new Tcl objects that denote the empty string.
     410 *      These objects have a NULL object type and NULL string representation
     411 *      byte pointer. Type managers call this routine to allocate new objects
     412 *      that they further initialize.
    427413 *
    428414 * Results:
     
    431417 *      is set to 0.
    432418 *
    433  * Side effects:
    434  *      If compiling with TCL_COMPILE_STATS, this procedure increments
    435  *      the global count of allocated objects (tclObjsAlloced).
    436  *
    437  *----------------------------------------------------------------------
    438  */
    439 
    440 #ifdef TCL_MEM_DEBUG
    441 #undef Tcl_NewObj
    442 
    443 Tcl_Obj *
    444 Tcl_NewObj()
    445 {
    446     return Tcl_DbNewObj("unknown", 0);
    447 }
    448 
    449 #else /* if not TCL_MEM_DEBUG */
     419 *----------------------------------------------------------------------
     420 */
    450421
    451422Tcl_Obj *
     
    468439    objPtr->length   = 0;
    469440    objPtr->typePtr  = NULL;
    470 #ifdef TCL_COMPILE_STATS
    471     tclObjsAlloced++;
    472 #endif /* TCL_COMPILE_STATS */
    473441    return objPtr;
    474442}
    475 #endif /* TCL_MEM_DEBUG */
    476 
    477 
    478 /*
    479  *----------------------------------------------------------------------
    480  *
    481  * Tcl_DbNewObj --
    482  *
    483  *      This procedure is normally called when debugging: i.e., when
    484  *      TCL_MEM_DEBUG is defined. It creates new Tcl objects that denote the
    485  *      empty string. It is the same as the Tcl_NewObj procedure above
    486  *      except that it calls Tcl_DbCkalloc directly with the file name and
    487  *      line number from its caller. This simplifies debugging since then
    488  *      the checkmem command will report the correct file name and line
    489  *      number when reporting objects that haven't been freed.
    490  *
    491  *      When TCL_MEM_DEBUG is not defined, this procedure just returns the
    492  *      result of calling Tcl_NewObj.
    493  *
    494  * Results:
    495  *      The result is a newly allocated that represents the empty string.
    496  *      The new object's typePtr is set NULL and its ref count is set to 0.
    497  *
    498  * Side effects:
    499  *      If compiling with TCL_COMPILE_STATS, this procedure increments
    500  *      the global count of allocated objects (tclObjsAlloced).
    501  *
    502  *----------------------------------------------------------------------
    503  */
    504 
    505 #ifdef TCL_MEM_DEBUG
    506 
    507 Tcl_Obj *
    508 Tcl_DbNewObj(file, line)
    509     register char *file;        /* The name of the source file calling this
    510                                  * procedure; used for debugging. */
    511     register int line;          /* Line number in the source file; used
    512                                  * for debugging. */
    513 {
    514     register Tcl_Obj *objPtr;
    515 
    516     /*
    517      * If debugging Tcl's memory usage, allocate the object using ckalloc.
    518      * Otherwise, allocate it using the list of free Tcl_Objs we maintain.
    519      */
    520 
    521     objPtr = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), file, line);
    522     objPtr->refCount = 0;
    523     objPtr->bytes    = tclEmptyStringRep;
    524     objPtr->length   = 0;
    525     objPtr->typePtr  = NULL;
    526 #ifdef TCL_COMPILE_STATS
    527     tclObjsAlloced++;
    528 #endif /* TCL_COMPILE_STATS */
    529     return objPtr;
    530 }
    531 
    532 #else /* if not TCL_MEM_DEBUG */
    533 
    534 Tcl_Obj *
    535 Tcl_DbNewObj(file, line)
    536     char *file;                 /* The name of the source file calling this
    537                                  * procedure; used for debugging. */
    538     int line;                   /* Line number in the source file; used
    539                                  * for debugging. */
    540 {
    541     return Tcl_NewObj();
    542 }
    543 #endif /* TCL_MEM_DEBUG */
    544443
    545444
     
    609508 *      after deallocating the string representation and calling the
    610509 *      type-specific Tcl_FreeInternalRepProc to deallocate the object's
    611  *      internal representation. If compiling with TCL_COMPILE_STATS,
    612  *      this procedure increments the global count of freed objects
    613  *      (tclObjsFreed).
     510 *      internal representation.
    614511 *
    615512 *----------------------------------------------------------------------
     
    622519    register Tcl_ObjType *typePtr = objPtr->typePtr;
    623520   
    624 #ifdef TCL_MEM_DEBUG
    625     if ((objPtr)->refCount < -1) {
    626         panic("Reference count for %lx was negative", objPtr);
    627     }
    628 #endif /* TCL_MEM_DEBUG */
    629 
    630521    Tcl_InvalidateStringRep(objPtr);
    631522    if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) {
     
    634525
    635526    /*
    636      * If debugging Tcl's memory usage, deallocate the object using ckfree.
    637      * Otherwise, deallocate it by adding it onto the list of free
     527     * Deallocate the object by adding it onto the list of free
    638528     * Tcl_Objs we maintain.
    639529     */
    640530   
    641 #ifdef TCL_MEM_DEBUG
    642     ckfree((char *) objPtr);
    643 #else
    644531    objPtr->internalRep.otherValuePtr = (VOID *) tclFreeObjList;
    645532    tclFreeObjList = objPtr;
    646 #endif /* TCL_MEM_DEBUG */
    647 
    648 #ifdef TCL_COMPILE_STATS   
    649     tclObjsFreed++;
    650 #endif /* TCL_COMPILE_STATS */   
    651533}
    652534
     
    794676 * Tcl_NewBooleanObj --
    795677 *
    796  *      This procedure is normally called when not debugging: i.e., when
    797  *      TCL_MEM_DEBUG is not defined. It creates a new boolean object and
    798  *      initializes it from the argument boolean value. A nonzero
    799  *      "boolValue" is coerced to 1.
    800  *
    801  *      When TCL_MEM_DEBUG is defined, this procedure just returns the
    802  *      result of calling the debugging version Tcl_DbNewBooleanObj.
     678 *      This procedure creates a new boolean object and initializes it from
     679 *      the argument boolean value. A nonzero "boolValue" is coerced to 1.
    803680 *
    804681 * Results:
     
    811688 *----------------------------------------------------------------------
    812689 */
    813 
    814 #ifdef TCL_MEM_DEBUG
    815 #undef Tcl_NewBooleanObj
    816690
    817691Tcl_Obj *
     
    819693    register int boolValue;     /* Boolean used to initialize new object. */
    820694{
    821     return Tcl_DbNewBooleanObj(boolValue, "unknown", 0);
    822 }
    823 
    824 #else /* if not TCL_MEM_DEBUG */
    825 
    826 Tcl_Obj *
    827 Tcl_NewBooleanObj(boolValue)
    828     register int boolValue;     /* Boolean used to initialize new object. */
    829 {
    830695    register Tcl_Obj *objPtr;
    831696
     
    837702    return objPtr;
    838703}
    839 #endif /* TCL_MEM_DEBUG */
    840 
    841 
    842 /*
    843  *----------------------------------------------------------------------
    844  *
    845  * Tcl_DbNewBooleanObj --
    846  *
    847  *      This procedure is normally called when debugging: i.e., when
    848  *      TCL_MEM_DEBUG is defined. It creates new boolean objects. It is the
    849  *      same as the Tcl_NewBooleanObj procedure above except that it calls
    850  *      Tcl_DbCkalloc directly with the file name and line number from its
    851  *      caller. This simplifies debugging since then the checkmem command
    852  *      will report the correct file name and line number when reporting
    853  *      objects that haven't been freed.
    854  *
    855  *      When TCL_MEM_DEBUG is not defined, this procedure just returns the
    856  *      result of calling Tcl_NewBooleanObj.
    857  *
    858  * Results:
    859  *      The newly created object is returned. This object will have an
    860  *      invalid string representation. The returned object has ref count 0.
    861  *
    862  * Side effects:
    863  *      None.
    864  *
    865  *----------------------------------------------------------------------
    866  */
    867 
    868 #ifdef TCL_MEM_DEBUG
    869 
    870 Tcl_Obj *
    871 Tcl_DbNewBooleanObj(boolValue, file, line)
    872     register int boolValue;     /* Boolean used to initialize new object. */
    873     char *file;                 /* The name of the source file calling this
    874                                  * procedure; used for debugging. */
    875     int line;                   /* Line number in the source file; used
    876                                  * for debugging. */
    877 {
    878     register Tcl_Obj *objPtr;
    879 
    880     TclDbNewObj(objPtr, file, line);
    881     objPtr->bytes = NULL;
    882    
    883     objPtr->internalRep.longValue = (boolValue? 1 : 0);
    884     objPtr->typePtr = &tclBooleanType;
    885     return objPtr;
    886 }
    887 
    888 #else /* if not TCL_MEM_DEBUG */
    889 
    890 Tcl_Obj *
    891 Tcl_DbNewBooleanObj(boolValue, file, line)
    892     register int boolValue;     /* Boolean used to initialize new object. */
    893     char *file;                 /* The name of the source file calling this
    894                                  * procedure; used for debugging. */
    895     int line;                   /* Line number in the source file; used
    896                                  * for debugging. */
    897 {
    898     return Tcl_NewBooleanObj(boolValue);
    899 }
    900 #endif /* TCL_MEM_DEBUG */
    901704
    902705
     
    1178981 * Tcl_NewDoubleObj --
    1179982 *
    1180  *      This procedure is normally called when not debugging: i.e., when
    1181  *      TCL_MEM_DEBUG is not defined. It creates a new double object and
    1182  *      initializes it from the argument double value.
    1183  *
    1184  *      When TCL_MEM_DEBUG is defined, this procedure just returns the
    1185  *      result of calling the debugging version Tcl_DbNewDoubleObj.
     983 *      This procedure creates a new double object and initializes it from
     984 *      the argument double value.
    1186985 *
    1187986 * Results:
     
    1194993 *----------------------------------------------------------------------
    1195994 */
    1196 
    1197 #ifdef TCL_MEM_DEBUG
    1198 #undef Tcl_NewDoubleObj
    1199995
    1200996Tcl_Obj *
     
    1202998    register double dblValue;   /* Double used to initialize the object. */
    1203999{
    1204     return Tcl_DbNewDoubleObj(dblValue, "unknown", 0);
    1205 }
    1206 
    1207 #else /* if not TCL_MEM_DEBUG */
    1208 
    1209 Tcl_Obj *
    1210 Tcl_NewDoubleObj(dblValue)
    1211     register double dblValue;   /* Double used to initialize the object. */
    1212 {
    12131000    register Tcl_Obj *objPtr;
    12141001
     
    12201007    return objPtr;
    12211008}
    1222 #endif /* if TCL_MEM_DEBUG */
    1223 
    1224 
    1225 /*
    1226  *----------------------------------------------------------------------
    1227  *
    1228  * Tcl_DbNewDoubleObj --
    1229  *
    1230  *      This procedure is normally called when debugging: i.e., when
    1231  *      TCL_MEM_DEBUG is defined. It creates new double objects. It is the
    1232  *      same as the Tcl_NewDoubleObj procedure above except that it calls
    1233  *      Tcl_DbCkalloc directly with the file name and line number from its
    1234  *      caller. This simplifies debugging since then the checkmem command
    1235  *      will report the correct file name and line number when reporting
    1236  *      objects that haven't been freed.
    1237  *
    1238  *      When TCL_MEM_DEBUG is not defined, this procedure just returns the
    1239  *      result of calling Tcl_NewDoubleObj.
    1240  *
    1241  * Results:
    1242  *      The newly created object is returned. This object will have an
    1243  *      invalid string representation. The returned object has ref count 0.
    1244  *
    1245  * Side effects:
    1246  *      None.
    1247  *
    1248  *----------------------------------------------------------------------
    1249  */
    1250 
    1251 #ifdef TCL_MEM_DEBUG
    1252 
    1253 Tcl_Obj *
    1254 Tcl_DbNewDoubleObj(dblValue, file, line)
    1255     register double dblValue;   /* Double used to initialize the object. */
    1256     char *file;                 /* The name of the source file calling this
    1257                                  * procedure; used for debugging. */
    1258     int line;                   /* Line number in the source file; used
    1259                                  * for debugging. */
    1260 {
    1261     register Tcl_Obj *objPtr;
    1262 
    1263     TclDbNewObj(objPtr, file, line);
    1264     objPtr->bytes = NULL;
    1265    
    1266     objPtr->internalRep.doubleValue = dblValue;
    1267     objPtr->typePtr = &tclDoubleType;
    1268     return objPtr;
    1269 }
    1270 
    1271 #else /* if not TCL_MEM_DEBUG */
    1272 
    1273 Tcl_Obj *
    1274 Tcl_DbNewDoubleObj(dblValue, file, line)
    1275     register double dblValue;   /* Double used to initialize the object. */
    1276     char *file;                 /* The name of the source file calling this
    1277                                  * procedure; used for debugging. */
    1278     int line;                   /* Line number in the source file; used
    1279                                  * for debugging. */
    1280 {
    1281     return Tcl_NewDoubleObj(dblValue);
    1282 }
    1283 #endif /* TCL_MEM_DEBUG */
    12841009
    12851010
     
    15311256 * Tcl_NewIntObj --
    15321257 *
    1533  *      If a client is compiled with TCL_MEM_DEBUG defined, calls to
    1534  *      Tcl_NewIntObj to create a new integer object end up calling the
    1535  *      debugging procedure Tcl_DbNewLongObj instead.
    1536  *
    1537  *      Otherwise, if the client is compiled without TCL_MEM_DEBUG defined,
    1538  *      calls to Tcl_NewIntObj result in a call to one of the two
     1258 *      Calls to Tcl_NewIntObj result in a call to one of the two
    15391259 *      Tcl_NewIntObj implementations below. We provide two implementations
    15401260 *      so that the Tcl core can be compiled to do memory debugging of the
     
    15561276 */
    15571277
    1558 #ifdef TCL_MEM_DEBUG
    1559 #undef Tcl_NewIntObj
    1560 
    15611278Tcl_Obj *
    15621279Tcl_NewIntObj(intValue)
    15631280    register int intValue;      /* Int used to initialize the new object. */
    15641281{
    1565     return Tcl_DbNewLongObj((long)intValue, "unknown", 0);
    1566 }
    1567 
    1568 #else /* if not TCL_MEM_DEBUG */
    1569 
    1570 Tcl_Obj *
    1571 Tcl_NewIntObj(intValue)
    1572     register int intValue;      /* Int used to initialize the new object. */
    1573 {
    15741282    register Tcl_Obj *objPtr;
    15751283
     
    15811289    return objPtr;
    15821290}
    1583 #endif /* if TCL_MEM_DEBUG */
    15841291
    15851292
     
    18561563 * Tcl_NewLongObj --
    18571564 *
    1858  *      If a client is compiled with TCL_MEM_DEBUG defined, calls to
    1859  *      Tcl_NewLongObj to create a new long integer object end up calling
    1860  *      the debugging procedure Tcl_DbNewLongObj instead.
    1861  *
    1862  *      Otherwise, if the client is compiled without TCL_MEM_DEBUG defined,
    1863  *      calls to Tcl_NewLongObj result in a call to one of the two
     1565 *      Calls to Tcl_NewLongObj result in a call to one of the two
    18641566 *      Tcl_NewLongObj implementations below. We provide two implementations
    18651567 *      so that the Tcl core can be compiled to do memory debugging of the
     
    18811583 */
    18821584
    1883 #ifdef TCL_MEM_DEBUG
    1884 #undef Tcl_NewLongObj
    1885 
    18861585Tcl_Obj *
    18871586Tcl_NewLongObj(longValue)
     
    18891588                                 * new object. */
    18901589{
    1891     return Tcl_DbNewLongObj(longValue, "unknown", 0);
    1892 }
    1893 
    1894 #else /* if not TCL_MEM_DEBUG */
    1895 
    1896 Tcl_Obj *
    1897 Tcl_NewLongObj(longValue)
    1898     register long longValue;    /* Long integer used to initialize the
    1899                                  * new object. */
    1900 {
    19011590    register Tcl_Obj *objPtr;
    19021591
     
    19081597    return objPtr;
    19091598}
    1910 #endif /* if TCL_MEM_DEBUG */
    19111599
    19121600
     
    19161604 * Tcl_DbNewLongObj --
    19171605 *
    1918  *      If a client is compiled with TCL_MEM_DEBUG defined, calls to
    1919  *      Tcl_NewIntObj and Tcl_NewLongObj to create new integer or
    1920  *      long integer objects end up calling the debugging procedure
    1921  *      Tcl_DbNewLongObj instead. We provide two implementations of
    1922  *      Tcl_DbNewLongObj so that whether the Tcl core is compiled to do
    1923  *      memory debugging of the core is independent of whether a client
    1924  *      requests debugging for itself.
    1925  *
    1926  *      When the core is compiled with TCL_MEM_DEBUG defined,
    1927  *      Tcl_DbNewLongObj calls Tcl_DbCkalloc directly with the file name and
    1928  *      line number from its caller. This simplifies debugging since then
    1929  *      the checkmem command will report the caller's file name and line
    1930  *      number when reporting objects that haven't been freed.
    1931  *
    1932  *      Otherwise, when the core is compiled without TCL_MEM_DEBUG defined,
    1933  *      this procedure just returns the result of calling Tcl_NewLongObj.
     1606 *      This procedure just returns the result of calling Tcl_NewLongObj.
    19341607 *
    19351608 * Results:
     
    19431616 *----------------------------------------------------------------------
    19441617 */
    1945 
    1946 #ifdef TCL_MEM_DEBUG
    19471618
    19481619Tcl_Obj *
     
    19551626                                 * for debugging. */
    19561627{
    1957     register Tcl_Obj *objPtr;
    1958 
    1959     TclDbNewObj(objPtr, file, line);
    1960     objPtr->bytes = NULL;
    1961    
    1962     objPtr->internalRep.longValue = longValue;
    1963     objPtr->typePtr = &tclIntType;
    1964     return objPtr;
    1965 }
    1966 
    1967 #else /* if not TCL_MEM_DEBUG */
    1968 
    1969 Tcl_Obj *
    1970 Tcl_DbNewLongObj(longValue, file, line)
    1971     register long longValue;    /* Long integer used to initialize the
    1972                                  * new object. */
    1973     char *file;                 /* The name of the source file calling this
    1974                                  * procedure; used for debugging. */
    1975     int line;                   /* Line number in the source file; used
    1976                                  * for debugging. */
    1977 {
    19781628    return Tcl_NewLongObj(longValue);
    19791629}
    1980 #endif /* TCL_MEM_DEBUG */
    19811630
    19821631
     
    20601709    return result;
    20611710}
    2062 
    2063 
    2064 /*
    2065  *----------------------------------------------------------------------
    2066  *
    2067  * Tcl_DbIncrRefCount --
    2068  *
    2069  *      This procedure is normally called when debugging: i.e., when
    2070  *      TCL_MEM_DEBUG is defined. This checks to see whether or not
    2071  *      the memory has been freed before incrementing the ref count.
    2072  *
    2073  *      When TCL_MEM_DEBUG is not defined, this procedure just increments
    2074  *      the reference count of the object.
    2075  *
    2076  * Results:
    2077  *      None.
    2078  *
    2079  * Side effects:
    2080  *      The object's ref count is incremented.
    2081  *
    2082  *----------------------------------------------------------------------
    2083  */
    2084 
    2085 void
    2086 Tcl_DbIncrRefCount(objPtr, file, line)
    2087     register Tcl_Obj *objPtr;   /* The object we are adding a reference to. */
    2088     char *file;                 /* The name of the source file calling this
    2089                                  * procedure; used for debugging. */
    2090     int line;                   /* Line number in the source file; used
    2091                                  * for debugging. */
    2092 {
    2093 #ifdef TCL_MEM_DEBUG
    2094     if (objPtr->refCount == 0x61616161) {
    2095         fprintf(stderr, "file = %s, line = %d\n", file, line);
    2096         fflush(stderr);
    2097         panic("Trying to increment refCount of previously disposed object.");
    2098     }
    2099 #endif
    2100     ++(objPtr)->refCount;
    2101 }
    2102 
    2103 
    2104 /*
    2105  *----------------------------------------------------------------------
    2106  *
    2107  * Tcl_DbDecrRefCount --
    2108  *
    2109  *      This procedure is normally called when debugging: i.e., when
    2110  *      TCL_MEM_DEBUG is defined. This checks to see whether or not
    2111  *      the memory has been freed before incrementing the ref count.
    2112  *
    2113  *      When TCL_MEM_DEBUG is not defined, this procedure just increments
    2114  *      the reference count of the object.
    2115  *
    2116  * Results:
    2117  *      None.
    2118  *
    2119  * Side effects:
    2120  *      The object's ref count is incremented.
    2121  *
    2122  *----------------------------------------------------------------------
    2123  */
    2124 
    2125 void
    2126 Tcl_DbDecrRefCount(objPtr, file, line)
    2127     register Tcl_Obj *objPtr;   /* The object we are adding a reference to. */
    2128     char *file;                 /* The name of the source file calling this
    2129                                  * procedure; used for debugging. */
    2130     int line;                   /* Line number in the source file; used
    2131                                  * for debugging. */
    2132 {
    2133 #ifdef TCL_MEM_DEBUG
    2134     if (objPtr->refCount == 0x61616161) {
    2135         fprintf(stderr, "file = %s, line = %d\n", file, line);
    2136         fflush(stderr);
    2137         panic("Trying to decrement refCount of previously disposed object.");
    2138     }
    2139 #endif
    2140     if (--(objPtr)->refCount <= 0) {
    2141         TclFreeObj(objPtr);
    2142     }
    2143 }
    2144 
    2145 
    2146 /*
    2147  *----------------------------------------------------------------------
    2148  *
    2149  * Tcl_DbIsShared --
    2150  *
    2151  *      This procedure is normally called when debugging: i.e., when
    2152  *      TCL_MEM_DEBUG is defined. This checks to see whether or not
    2153  *      the memory has been freed before incrementing the ref count.
    2154  *
    2155  *      When TCL_MEM_DEBUG is not defined, this procedure just decrements
    2156  *      the reference count of the object and throws it away if the count
    2157  *      is 0 or less.
    2158  *
    2159  * Results:
    2160  *      None.
    2161  *
    2162  * Side effects:
    2163  *      The object's ref count is incremented.
    2164  *
    2165  *----------------------------------------------------------------------
    2166  */
    2167 
    2168 int
    2169 Tcl_DbIsShared(objPtr, file, line)
    2170     register Tcl_Obj *objPtr;   /* The object we are adding a reference to. */
    2171     char *file;                 /* The name of the source file calling this
    2172                                  * procedure; used for debugging. */
    2173     int line;                   /* Line number in the source file; used
    2174                                  * for debugging. */
    2175 {
    2176 #ifdef TCL_MEM_DEBUG
    2177     if (objPtr->refCount == 0x61616161) {
    2178         fprintf(stderr, "file = %s, line = %d\n", file, line);
    2179         fflush(stderr);
    2180         panic("Trying to check whether previously disposed object is shared.");
    2181     }
    2182 #endif
    2183     return ((objPtr)->refCount > 1);
    2184 }
  • external/tcl/tclProc.c

    re39abb4 r0e7d64a  
    985985     */
    986986
    987     if (tclTraceExec >= 1) {
    988         fprintf(stdout, "Calling proc ");
    989         for (i = 0;  i < objc;  i++) {
    990             bytes = Tcl_GetStringFromObj(objv[i], &length);
    991             TclPrintSource(stdout, bytes, TclMin(length, 15));
    992             fprintf(stdout, " ");
    993         }
    994         fprintf(stdout, "\n");
    995         fflush(stdout);
    996     }
    997 
    998987    iPtr->returnCode = TCL_OK;
    999988    procPtr->refCount++;
     
    11191108        int numChars;
    11201109        char *ellipsis;
    1121        
    1122         if (tclTraceCompile >= 1) {
    1123             /*
    1124              * Display a line summarizing the top level command we
    1125              * are about to compile.
    1126              */
    1127  
    1128             numChars = strlen(procName);
    1129             ellipsis = "";
    1130             if (numChars > 50) {
    1131                 numChars = 50;
    1132                 ellipsis = "...";
    1133             }
    1134             fprintf(stdout, "Compiling %s \"%.*s%s\"\n",
    1135                     description, numChars, procName, ellipsis);
    1136         }
    11371110       
    11381111        /*
  • external/tcl/tclStringObj.c

    re39abb4 r0e7d64a  
    5050 * Tcl_NewStringObj --
    5151 *
    52  *      This procedure is normally called when not debugging: i.e., when
    53  *      TCL_MEM_DEBUG is not defined. It creates a new string object and
    54  *      initializes it from the byte pointer and length arguments.
    55  *
    56  *      When TCL_MEM_DEBUG is defined, this procedure just returns the
    57  *      result of calling the debugging version Tcl_DbNewStringObj.
     52 *      This procedure creates a new string object and initializes it from
     53 *      the byte pointer and length arguments.
    5854 *
    5955 * Results:
     
    7066 *----------------------------------------------------------------------
    7167 */
    72 
    73 #ifdef TCL_MEM_DEBUG
    74 #undef Tcl_NewStringObj
    7568
    7669Tcl_Obj *
     
    8376                                 * NULL byte. */
    8477{
    85     return Tcl_DbNewStringObj(bytes, length, "unknown", 0);
    86 }
    87 
    88 #else /* if not TCL_MEM_DEBUG */
    89 
    90 Tcl_Obj *
    91 Tcl_NewStringObj(bytes, length)
    92     register char *bytes;       /* Points to the first of the length bytes
    93                                  * used to initialize the new object. */
    94     register int length;        /* The number of bytes to copy from "bytes"
    95                                  * when initializing the new object. If
    96                                  * negative, use bytes up to the first
    97                                  * NULL byte. */
    98 {
    9978    register Tcl_Obj *objPtr;
    10079
     
    10685    return objPtr;
    10786}
    108 #endif /* TCL_MEM_DEBUG */
    109 
    110 
    111 /*
    112  *----------------------------------------------------------------------
    113  *
    114  * Tcl_DbNewStringObj --
    115  *
    116  *      This procedure is normally called when debugging: i.e., when
    117  *      TCL_MEM_DEBUG is defined. It creates new string objects. It is the
    118  *      same as the Tcl_NewStringObj procedure above except that it calls
    119  *      Tcl_DbCkalloc directly with the file name and line number from its
    120  *      caller. This simplifies debugging since then the checkmem command
    121  *      will report the correct file name and line number when reporting
    122  *      objects that haven't been freed.
    123  *
    124  *      When TCL_MEM_DEBUG is not defined, this procedure just returns the
    125  *      result of calling Tcl_NewStringObj.
    126  *
    127  * Results:
    128  *      A newly created string object is returned that has ref count zero.
    129  *
    130  * Side effects:
    131  *      The new object's internal string representation will be set to a
    132  *      copy of the length bytes starting at "bytes". If "length" is
    133  *      negative, use bytes up to the first NULL byte; i.e., assume "bytes"
    134  *      points to a C-style NULL-terminated string. The object's type is set
    135  *      to NULL. An extra NULL is added to the end of the new object's byte
    136  *      array.
    137  *
    138  *----------------------------------------------------------------------
    139  */
    140 
    141 #ifdef TCL_MEM_DEBUG
    142 
    143 Tcl_Obj *
    144 Tcl_DbNewStringObj(bytes, length, file, line)
    145     register char *bytes;       /* Points to the first of the length bytes
    146                                  * used to initialize the new object. */
    147     register int length;        /* The number of bytes to copy from "bytes"
    148                                  * when initializing the new object. If
    149                                  * negative, use bytes up to the first
    150                                  * NULL byte. */
    151     char *file;                 /* The name of the source file calling this
    152                                  * procedure; used for debugging. */
    153     int line;                   /* Line number in the source file; used
    154                                  * for debugging. */
    155 {
    156     register Tcl_Obj *objPtr;
    157 
    158     if (length < 0) {
    159         length = (bytes? strlen(bytes) : 0);
    160     }
    161     TclDbNewObj(objPtr, file, line);
    162     TclInitStringRep(objPtr, bytes, length);
    163     return objPtr;
    164 }
    165 
    166 #else /* if not TCL_MEM_DEBUG */
    167 
    168 Tcl_Obj *
    169 Tcl_DbNewStringObj(bytes, length, file, line)
    170     register char *bytes;       /* Points to the first of the length bytes
    171                                  * used to initialize the new object. */
    172     register int length;        /* The number of bytes to copy from "bytes"
    173                                  * when initializing the new object. If
    174                                  * negative, use bytes up to the first
    175                                  * NULL byte. */
    176     char *file;                 /* The name of the source file calling this
    177                                  * procedure; used for debugging. */
    178     int line;                   /* Line number in the source file; used
    179                                  * for debugging. */
    180 {
    181     return Tcl_NewStringObj(bytes, length);
    182 }
    183 #endif /* TCL_MEM_DEBUG */
    18487
    18588
  • external/tcl/tclVar.c

    re39abb4 r0e7d64a  
    711711    char *msg;
    712712
    713 #ifdef TCL_COMPILE_DEBUG
    714     Proc *procPtr = varFramePtr->procPtr;
    715     int localCt = procPtr->numCompiledLocals;
    716 
    717     if (compiledLocals == NULL) {
    718         fprintf(stderr, "\nTclGetIndexedScalar: can't get local %i in frame 0x%x, no compiled locals\n",
    719                 localIndex, (unsigned int) varFramePtr);
    720         panic("TclGetIndexedScalar: no compiled locals in frame 0x%x",
    721                 (unsigned int) varFramePtr);
    722     }
    723     if ((localIndex < 0) || (localIndex >= localCt)) {
    724         fprintf(stderr, "\nTclGetIndexedScalar: can't get local %i in frame 0x%x with %i locals\n",
    725                 localIndex, (unsigned int) varFramePtr, localCt);
    726         panic("TclGetIndexedScalar: bad local index %i in frame 0x%x",
    727                 localIndex, (unsigned int) varFramePtr);
    728     }
    729 #endif /* TCL_COMPILE_DEBUG */
    730    
    731713    varPtr = &(compiledLocals[localIndex]);
    732714    varName = varPtr->name;
     
    832814    int new;
    833815
    834 #ifdef TCL_COMPILE_DEBUG
    835     Proc *procPtr = varFramePtr->procPtr;
    836     int localCt = procPtr->numCompiledLocals;
    837 
    838     if (compiledLocals == NULL) {
    839         fprintf(stderr, "\nTclGetElementOfIndexedArray: can't get element of local %i in frame 0x%x, no compiled locals\n",
    840                 localIndex, (unsigned int) varFramePtr);
    841         panic("TclGetIndexedScalar: no compiled locals in frame 0x%x",
    842                 (unsigned int) varFramePtr);
    843     }
    844     if ((localIndex < 0) || (localIndex >= localCt)) {
    845         fprintf(stderr, "\nTclGetIndexedScalar: can't get element of local %i in frame 0x%x with %i locals\n",
    846                 localIndex, (unsigned int) varFramePtr, localCt);
    847         panic("TclGetElementOfIndexedArray: bad local index %i in frame 0x%x",
    848                 localIndex, (unsigned int) varFramePtr);
    849     }
    850 #endif /* TCL_COMPILE_DEBUG */
    851 
    852816    /*
    853817     * THIS FAILS IF THE ELEMENT NAME OBJECT'S STRING REP HAS A NULL BYTE.
     
    14491413    Tcl_Obj *resultPtr = NULL;
    14501414
    1451 #ifdef TCL_COMPILE_DEBUG
    1452     Proc *procPtr = varFramePtr->procPtr;
    1453     int localCt = procPtr->numCompiledLocals;
    1454 
    1455     if (compiledLocals == NULL) {
    1456         fprintf(stderr, "\nTclSetIndexedScalar: can't set local %i in frame 0x%x, no compiled locals\n",
    1457                 localIndex, (unsigned int) varFramePtr);
    1458         panic("TclSetIndexedScalar: no compiled locals in frame 0x%x",
    1459                 (unsigned int) varFramePtr);
    1460     }
    1461     if ((localIndex < 0) || (localIndex >= localCt)) {
    1462         fprintf(stderr, "\nTclSetIndexedScalar: can't set local %i in frame 0x%x with %i locals\n",
    1463                 localIndex, (unsigned int) varFramePtr, localCt);
    1464         panic("TclSetIndexedScalar: bad local index %i in frame 0x%x",
    1465                 localIndex, (unsigned int) varFramePtr);
    1466     }
    1467 #endif /* TCL_COMPILE_DEBUG */
    1468    
    14691415    varPtr = &(compiledLocals[localIndex]);
    14701416    varName = varPtr->name;
     
    16351581    int new;
    16361582   
    1637 #ifdef TCL_COMPILE_DEBUG
    1638     Proc *procPtr = varFramePtr->procPtr;
    1639     int localCt = procPtr->numCompiledLocals;
    1640 
    1641     if (compiledLocals == NULL) {
    1642         fprintf(stderr, "\nTclSetElementOfIndexedArray: can't set element of local %i in frame 0x%x, no compiled locals\n",
    1643                 localIndex, (unsigned int) varFramePtr);
    1644         panic("TclSetIndexedScalar: no compiled locals in frame 0x%x",
    1645                 (unsigned int) varFramePtr);
    1646     }
    1647     if ((localIndex < 0) || (localIndex >= localCt)) {
    1648         fprintf(stderr, "\nTclSetIndexedScalar: can't set elememt of local %i in frame 0x%x with %i locals\n",
    1649                 localIndex, (unsigned int) varFramePtr, localCt);
    1650         panic("TclSetElementOfIndexedArray: bad local index %i in frame 0x%x",
    1651                 localIndex, (unsigned int) varFramePtr);
    1652     }
    1653 #endif /* TCL_COMPILE_DEBUG */
    1654 
    16551583    /*
    16561584     * THIS FAILS IF THE ELEMENT NAME OBJECT'S STRING REP HAS A NULL BYTE.
  • modules/AngularSmearing.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class AngularSmearing
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    46 #include <algorithm>
    47 #include <stdexcept>
     45#include <algorithm>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    7776  fFormulaPhi->Compile(GetString("PhiResolutionFormula", "0.0"));
    7877
    79 
    8078  // import input array
    8179
     
    103101
    104102  fItInputArray->Reset();
    105   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     103  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    106104  {
    107105    const TLorentzVector &candidatePosition = candidate->Position;
     
    116114    eta = gRandom->Gaus(eta, fFormulaEta->Eval(pt, eta, phi, e));
    117115    phi = gRandom->Gaus(phi, fFormulaPhi->Eval(pt, eta, phi, e));
    118    
     116
    119117    if(pt <= 0.0) continue;
    120118
    121119    mother = candidate;
    122     candidate = static_cast<Candidate*>(candidate->Clone());
     120    candidate = static_cast<Candidate *>(candidate->Clone());
    123121    eta = candidateMomentum.Eta();
    124122    phi = candidateMomentum.Phi();
    125     candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
     123    candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt * TMath::CosH(eta));
    126124    candidate->AddCandidate(mother);
    127        
     125
    128126    fOutputArray->Add(candidate);
    129127  }
  • modules/AngularSmearing.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  AngularSmearing();
    4140  ~AngularSmearing();
     
    4645
    4746private:
    48 
    4947  DelphesFormula *fFormulaEta; //!
    5048  DelphesFormula *fFormulaPhi; //!
     
    5351
    5452  const TObjArray *fInputArray; //!
    55  
     53
    5654  TObjArray *fOutputArray; //!
    5755
  • modules/BTagging.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class BTagging
    2120 *
     
    3433#include "classes/DelphesFormula.h"
    3534
     35#include "TDatabasePDG.h"
     36#include "TFormula.h"
     37#include "TLorentzVector.h"
    3638#include "TMath.h"
     39#include "TObjArray.h"
     40#include "TRandom3.h"
    3741#include "TString.h"
    38 #include "TFormula.h"
    39 #include "TRandom3.h"
    40 #include "TObjArray.h"
    41 #include "TDatabasePDG.h"
    42 #include "TLorentzVector.h"
    4342
    4443#include <algorithm>
    45 #include <stdexcept>
    4644#include <iostream>
    4745#include <sstream>
     46#include <stdexcept>
    4847
    4948using namespace std;
     
    6665void BTagging::Init()
    6766{
    68   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     67  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    6968  ExRootConfParam param;
    7069  DelphesFormula *formula;
     
    7877
    7978  fEfficiencyMap.clear();
    80   for(i = 0; i < size/2; ++i)
     79  for(i = 0; i < size / 2; ++i)
    8180  {
    8281    formula = new DelphesFormula;
    83     formula->Compile(param[i*2 + 1].GetString());
     82    formula->Compile(param[i * 2 + 1].GetString());
    8483
    85     fEfficiencyMap[param[i*2].GetInt()] = formula;
     84    fEfficiencyMap[param[i * 2].GetInt()] = formula;
    8685  }
    8786
     
    106105void BTagging::Finish()
    107106{
    108   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     107  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    109108  DelphesFormula *formula;
    110109
     
    124123  Candidate *jet;
    125124  Double_t pt, eta, phi, e;
    126   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     125  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    127126  DelphesFormula *formula;
    128127
    129128  // loop over all input jets
    130129  fItJetInputArray->Reset();
    131   while((jet = static_cast<Candidate*>(fItJetInputArray->Next())))
     130  while((jet = static_cast<Candidate *>(fItJetInputArray->Next())))
    132131  {
    133132    const TLorentzVector &jetMomentum = jet->Momentum;
  • modules/BTagging.h

    re39abb4 r0e7d64a  
    4040{
    4141public:
    42 
    4342  BTagging();
    4443  ~BTagging();
     
    4948
    5049private:
    51 
    5250  Int_t fBitNumber;
    5351
    5452#if !defined(__CINT__) && !defined(__CLING__)
    55   std::map< Int_t, DelphesFormula * > fEfficiencyMap; //!
     53  std::map<Int_t, DelphesFormula *> fEfficiencyMap; //!
    5654#endif
    5755
    5856  TIterator *fItJetInputArray; //!
    59  
     57
    6058  const TObjArray *fJetInputArray; //!
    6159
  • modules/BeamSpotFilter.cc

    re39abb4 r0e7d64a  
    77 */
    88
    9 
    109#include "modules/BeamSpotFilter.h"
    1110
     
    1413#include "classes/DelphesFormula.h"
    1514
     15#include "ExRootAnalysis/ExRootClassifier.h"
     16#include "ExRootAnalysis/ExRootFilter.h"
    1617#include "ExRootAnalysis/ExRootResult.h"
    17 #include "ExRootAnalysis/ExRootFilter.h"
    18 #include "ExRootAnalysis/ExRootClassifier.h"
    1918
     19#include "TDatabasePDG.h"
     20#include "TFormula.h"
     21#include "TLorentzVector.h"
    2022#include "TMath.h"
     23#include "TObjArray.h"
     24#include "TRandom3.h"
    2125#include "TString.h"
    22 #include "TFormula.h"
    23 #include "TRandom3.h"
    24 #include "TObjArray.h"
    25 #include "TDatabasePDG.h"
    26 #include "TLorentzVector.h"
    2726
    2827#include <algorithm>
    29 #include <stdexcept>
    3028#include <iostream>
    3129#include <sstream>
     30#include <stdexcept>
    3231
    3332using namespace std;
     
    5049void BeamSpotFilter::Init()
    5150{
    52  
     51
    5352  // import input array
    5453  fInputArray = ImportArray(GetString("InputArray", "Delphes/allParticles"));
     
    7372  Candidate *candidate;
    7473  Bool_t passed = false;
    75  
     74
    7675  fItInputArray->Reset();
    77   while((candidate = static_cast<Candidate*>(fItInputArray->Next())) && !passed)
     76  while((candidate = static_cast<Candidate *>(fItInputArray->Next())) && !passed)
    7877  {
    7978    if(candidate->IsPU == 0) passed = true;
    8079    fOutputArray->Add(candidate);
    8180  }
    82  
    8381}
    84 
    85  
  • modules/BeamSpotFilter.h

    re39abb4 r0e7d64a  
    2020{
    2121public:
    22 
    2322  BeamSpotFilter();
    2423  ~BeamSpotFilter();
     
    2928
    3029private:
    31 
    3230  Float_t fPassedOne;
    3331
  • modules/CMakeLists.txt

    re39abb4 r0e7d64a  
    2828if (NOT ${ROOT_VERSION} VERSION_LESS "6.0.0")
    2929  install(FILES
    30       ${PROJECT_BINARY_DIR}/modules/libModulesDict_rdict.pcm
    31       ${PROJECT_BINARY_DIR}/modules/libFastJetDict_rdict.pcm
     30    ${PROJECT_BINARY_DIR}/modules/libModulesDict_rdict.pcm
     31    ${PROJECT_BINARY_DIR}/modules/libFastJetDict_rdict.pcm
     32    DESTINATION lib)
     33  if(PYTHIA8_FOUND)
     34    install(FILES
     35      ${PROJECT_BINARY_DIR}/modules/libPythia8Dict_rdict.pcm
    3236      DESTINATION lib)
     37  endif()
    3338endif()
  • modules/Calorimeter.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class Calorimeter
    2120 *
     
    3332#include "classes/DelphesFormula.h"
    3433
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3536#include "ExRootAnalysis/ExRootResult.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    37 #include "ExRootAnalysis/ExRootClassifier.h"
    38 
     37
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
    3941#include "TMath.h"
     42#include "TObjArray.h"
     43#include "TRandom3.h"
    4044#include "TString.h"
    41 #include "TFormula.h"
    42 #include "TRandom3.h"
    43 #include "TObjArray.h"
    44 #include "TDatabasePDG.h"
    45 #include "TLorentzVector.h"
    4645
    4746#include <algorithm>
    48 #include <stdexcept>
    4947#include <iostream>
    5048#include <sstream>
     49#include <stdexcept>
    5150
    5251using namespace std;
     
    5857  fItParticleInputArray(0), fItTrackInputArray(0)
    5958{
    60  
     59
    6160  fECalResolutionFormula = new DelphesFormula;
    6261  fHCalResolutionFormula = new DelphesFormula;
     
    6766  fHCalTowerTrackArray = new TObjArray;
    6867  fItHCalTowerTrackArray = fHCalTowerTrackArray->MakeIterator();
    69  
    7068}
    7169
     
    7472Calorimeter::~Calorimeter()
    7573{
    76  
     74
    7775  if(fECalResolutionFormula) delete fECalResolutionFormula;
    7876  if(fHCalResolutionFormula) delete fHCalResolutionFormula;
     
    8381  if(fHCalTowerTrackArray) delete fHCalTowerTrackArray;
    8482  if(fItHCalTowerTrackArray) delete fItHCalTowerTrackArray;
    85  
    8683}
    8784
     
    9491  Double_t ecalFraction, hcalFraction;
    9592  TBinMap::iterator itEtaBin;
    96   set< Double_t >::iterator itPhiBin;
    97   vector< Double_t > *phiBins;
     93  set<Double_t>::iterator itPhiBin;
     94  vector<Double_t> *phiBins;
    9895
    9996  // read eta and phi bins
     
    103100  fEtaBins.clear();
    104101  fPhiBins.clear();
    105   for(i = 0; i < size/2; ++i)
    106   {
    107     paramEtaBins = param[i*2];
     102  for(i = 0; i < size / 2; ++i)
     103  {
     104    paramEtaBins = param[i * 2];
    108105    sizeEtaBins = paramEtaBins.GetSize();
    109     paramPhiBins = param[i*2 + 1];
     106    paramPhiBins = param[i * 2 + 1];
    110107    sizePhiBins = paramPhiBins.GetSize();
    111108
     
    124121  {
    125122    fEtaBins.push_back(itEtaBin->first);
    126     phiBins = new vector< double >(itEtaBin->second.size());
     123    phiBins = new vector<double>(itEtaBin->second.size());
    127124    fPhiBins.push_back(phiBins);
    128125    phiBins->clear();
     
    141138  fFractionMap[0] = make_pair(0.0, 1.0);
    142139
    143   for(i = 0; i < size/2; ++i)
    144   {
    145     paramFractions = param[i*2 + 1];
     140  for(i = 0; i < size / 2; ++i)
     141  {
     142    paramFractions = param[i * 2 + 1];
    146143
    147144    ecalFraction = paramFractions[0].GetDouble();
    148145    hcalFraction = paramFractions[1].GetDouble();
    149146
    150     fFractionMap[param[i*2].GetInt()] = make_pair(ecalFraction, hcalFraction);
     147    fFractionMap[param[i * 2].GetInt()] = make_pair(ecalFraction, hcalFraction);
    151148  }
    152149
    153150  // read min E value for timing measurement in ECAL
    154   fTimingEnergyMin = GetDouble("TimingEnergyMin",4.);
     151  fTimingEnergyMin = GetDouble("TimingEnergyMin", 4.);
    155152  // For timing
    156153  // So far this flag needs to be false
     
    192189void Calorimeter::Finish()
    193190{
    194   vector< vector< Double_t >* >::iterator itPhiBin;
     191  vector<vector<Double_t> *>::iterator itPhiBin;
    195192  if(fItParticleInputArray) delete fItParticleInputArray;
    196193  if(fItTrackInputArray) delete fItTrackInputArray;
     
    218215  TFractionMap::iterator itFractionMap;
    219216
    220   vector< Double_t >::iterator itEtaBin;
    221   vector< Double_t >::iterator itPhiBin;
    222   vector< Double_t > *phiBins;
    223 
    224   vector< Long64_t >::iterator itTowerHits;
     217  vector<Double_t>::iterator itEtaBin;
     218  vector<Double_t>::iterator itPhiBin;
     219  vector<Double_t> *phiBins;
     220
     221  vector<Long64_t>::iterator itTowerHits;
    225222
    226223  DelphesFactory *factory = GetFactory();
     
    234231  fItParticleInputArray->Reset();
    235232  number = -1;
    236   while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
     233  while((particle = static_cast<Candidate *>(fItParticleInputArray->Next())))
    237234  {
    238235    const TLorentzVector &particlePosition = particle->Position;
     
    280277  fItTrackInputArray->Reset();
    281278  number = -1;
    282   while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
     279  while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
    283280  {
    284281    const TLorentzVector &trackPosition = track->Position;
     
    331328    towerHit = (*itTowerHits);
    332329    flags = (towerHit >> 24) & 0x00000000000000FFLL;
    333     number = (towerHit) & 0x0000000000FFFFFFLL;
     330    number = (towerHit)&0x0000000000FFFFFFLL;
    334331    hitEtaPhi = towerHit >> 32;
    335332
     
    352349
    353350      // calculate eta and phi of the tower's center
    354       fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
    355       fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
     351      fTowerEta = 0.5 * (fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
     352      fTowerPhi = 0.5 * ((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
    356353
    357354      fTowerEdges[0] = fEtaBins[etaBin - 1];
     
    365362      fECalTrackEnergy = 0.0;
    366363      fHCalTrackEnergy = 0.0;
    367      
     364
    368365      fECalTrackSigma = 0.0;
    369366      fHCalTrackSigma = 0.0;
    370      
     367
    371368      fTowerTrackHits = 0;
    372369      fTowerPhotonHits = 0;
     
    374371      fECalTowerTrackArray->Clear();
    375372      fHCalTowerTrackArray->Clear();
    376    
    377373    }
    378374
     
    382378      ++fTowerTrackHits;
    383379
    384       track = static_cast<Candidate*>(fTrackInputArray->At(number));
     380      track = static_cast<Candidate *>(fTrackInputArray->At(number));
    385381      momentum = track->Momentum;
    386382      position = track->Position;
     
    400396      {
    401397        fECalTrackEnergy += ecalEnergy;
    402         ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());       
    403         if(ecalSigma/momentum.E() < track->TrackResolution) energyGuess = ecalEnergy;       
    404         else energyGuess = momentum.E();
    405 
    406         fECalTrackSigma += (track->TrackResolution)*energyGuess*(track->TrackResolution)*energyGuess;
     398        ecalSigma = fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
     399        if(ecalSigma / momentum.E() < track->TrackResolution)
     400          energyGuess = ecalEnergy;
     401        else
     402          energyGuess = momentum.E();
     403
     404        fECalTrackSigma += (track->TrackResolution) * energyGuess * (track->TrackResolution) * energyGuess;
    407405        fECalTowerTrackArray->Add(track);
    408406      }
    409      
     407
    410408      else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] > 1.0E-9)
    411409      {
    412410        fHCalTrackEnergy += hcalEnergy;
    413411        hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
    414         if(hcalSigma/momentum.E() < track->TrackResolution) energyGuess = hcalEnergy;
    415         else energyGuess = momentum.E();
    416 
    417         fHCalTrackSigma += (track->TrackResolution)*energyGuess*(track->TrackResolution)*energyGuess;
     412        if(hcalSigma / momentum.E() < track->TrackResolution)
     413          energyGuess = hcalEnergy;
     414        else
     415          energyGuess = momentum.E();
     416
     417        fHCalTrackSigma += (track->TrackResolution) * energyGuess * (track->TrackResolution) * energyGuess;
    418418        fHCalTowerTrackArray->Add(track);
    419419      }
    420      
     420
    421421      else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] < 1.0E-9)
    422422      {
     
    430430    if(flags & 2) ++fTowerPhotonHits;
    431431
    432     particle = static_cast<Candidate*>(fParticleInputArray->At(number));
     432    particle = static_cast<Candidate *>(fParticleInputArray->At(number));
    433433    momentum = particle->Momentum;
    434434    position = particle->Position;
     
    443443    if(ecalEnergy > fTimingEnergyMin && fTower)
    444444    {
    445       if (abs(particle->PID) != 11 || !fElectronsFromTrack)
     445      if(abs(particle->PID) != 11 || !fElectronsFromTrack)
    446446      {
    447447        fTower->ECalEnergyTimePairs.push_back(make_pair<Float_t, Float_t>(ecalEnergy, particle->Position.T()));
     
    464464  Double_t ecalEnergy, hcalEnergy;
    465465  Double_t ecalNeutralEnergy, hcalNeutralEnergy;
    466  
     466
    467467  Double_t ecalSigma, hcalSigma;
    468468  Double_t ecalNeutralSigma, hcalNeutralSigma;
    469469
    470470  Double_t weightTrack, weightCalo, bestEnergyEstimate, rescaleFactor;
    471  
     471
    472472  TLorentzVector momentum;
    473473  TFractionMap::iterator itFractionMap;
     
    486486  hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, hcalEnergy);
    487487
    488   if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin*ecalSigma) ecalEnergy = 0.0;
    489   if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin*hcalSigma) hcalEnergy = 0.0;
     488  if(ecalEnergy < fECalEnergyMin || ecalEnergy < fECalEnergySignificanceMin * ecalSigma) ecalEnergy = 0.0;
     489  if(hcalEnergy < fHCalEnergyMin || hcalEnergy < fHCalEnergySignificanceMin * hcalSigma) hcalEnergy = 0.0;
    490490
    491491  energy = ecalEnergy + hcalEnergy;
     
    519519  if(sumWeight > 0.0)
    520520  {
    521     fTower->Position.SetPtEtaPhiE(1.0, eta, phi, sumWeightedTime/sumWeight);
     521    fTower->Position.SetPtEtaPhiE(1.0, eta, phi, sumWeightedTime / sumWeight);
    522522  }
    523523  else
     
    525525    fTower->Position.SetPtEtaPhiE(1.0, eta, phi, 999999.9);
    526526  }
    527 
    528527
    529528  fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
     
    545544    fTowerOutputArray->Add(fTower);
    546545  }
    547  
     546
    548547  // fill energy flow candidates
    549548  fECalTrackSigma = TMath::Sqrt(fECalTrackSigma);
     
    551550
    552551  //compute neutral excesses
    553   ecalNeutralEnergy = max( (ecalEnergy - fECalTrackEnergy) , 0.0);
    554   hcalNeutralEnergy = max( (hcalEnergy - fHCalTrackEnergy) , 0.0);
    555  
    556   ecalNeutralSigma = ecalNeutralEnergy / TMath::Sqrt(fECalTrackSigma*fECalTrackSigma + ecalSigma*ecalSigma);
    557   hcalNeutralSigma = hcalNeutralEnergy / TMath::Sqrt(fHCalTrackSigma*fHCalTrackSigma + hcalSigma*hcalSigma);
    558  
    559    // if ecal neutral excess is significant, simply create neutral EflowPhoton tower and clone each track into eflowtrack
     552  ecalNeutralEnergy = max((ecalEnergy - fECalTrackEnergy), 0.0);
     553  hcalNeutralEnergy = max((hcalEnergy - fHCalTrackEnergy), 0.0);
     554
     555  ecalNeutralSigma = ecalNeutralEnergy / TMath::Sqrt(fECalTrackSigma * fECalTrackSigma + ecalSigma * ecalSigma);
     556  hcalNeutralSigma = hcalNeutralEnergy / TMath::Sqrt(fHCalTrackSigma * fHCalTrackSigma + hcalSigma * hcalSigma);
     557
     558  // if ecal neutral excess is significant, simply create neutral EflowPhoton tower and clone each track into eflowtrack
    560559  if(ecalNeutralEnergy > fECalEnergyMin && ecalNeutralSigma > fECalEnergySignificanceMin)
    561560  {
    562561    // create new photon tower
    563     tower = static_cast<Candidate*>(fTower->Clone());
    564     pt =  ecalNeutralEnergy / TMath::CosH(eta);
    565    
     562    tower = static_cast<Candidate *>(fTower->Clone());
     563    pt = ecalNeutralEnergy / TMath::CosH(eta);
     564
    566565    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalNeutralEnergy);
    567566    tower->Eem = ecalNeutralEnergy;
    568567    tower->Ehad = 0.0;
    569568    tower->PID = 22;
    570    
     569
    571570    fEFlowPhotonOutputArray->Add(tower);
    572    
     571
    573572    //clone tracks
    574573    fItECalTowerTrackArray->Reset();
    575     while((track = static_cast<Candidate*>(fItECalTowerTrackArray->Next())))
     574    while((track = static_cast<Candidate *>(fItECalTowerTrackArray->Next())))
    576575    {
    577576      mother = track;
    578       track = static_cast<Candidate*>(track->Clone());
     577      track = static_cast<Candidate *>(track->Clone());
    579578      track->AddCandidate(mother);
    580579
    581580      fEFlowTrackOutputArray->Add(track);
    582581    }
    583  
    584   }
    585  
     582  }
     583
    586584  // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking
    587585  else if(fECalTrackEnergy > 0.0)
    588586  {
    589     weightTrack = (fECalTrackSigma > 0.0) ? 1 / (fECalTrackSigma*fECalTrackSigma) : 0.0;
    590     weightCalo  = (ecalSigma > 0.0) ? 1 / (ecalSigma*ecalSigma) : 0.0;
    591  
    592     bestEnergyEstimate = (weightTrack*fECalTrackEnergy + weightCalo*ecalEnergy) / (weightTrack + weightCalo);
    593     rescaleFactor = bestEnergyEstimate/fECalTrackEnergy;
     587    weightTrack = (fECalTrackSigma > 0.0) ? 1 / (fECalTrackSigma * fECalTrackSigma) : 0.0;
     588    weightCalo = (ecalSigma > 0.0) ? 1 / (ecalSigma * ecalSigma) : 0.0;
     589
     590    bestEnergyEstimate = (weightTrack * fECalTrackEnergy + weightCalo * ecalEnergy) / (weightTrack + weightCalo);
     591    rescaleFactor = bestEnergyEstimate / fECalTrackEnergy;
    594592
    595593    //rescale tracks
    596594    fItECalTowerTrackArray->Reset();
    597     while((track = static_cast<Candidate*>(fItECalTowerTrackArray->Next())))
    598     { 
     595    while((track = static_cast<Candidate *>(fItECalTowerTrackArray->Next())))
     596    {
    599597      mother = track;
    600       track = static_cast<Candidate*>(track->Clone());
     598      track = static_cast<Candidate *>(track->Clone());
    601599      track->AddCandidate(mother);
    602600
     
    606604    }
    607605  }
    608 
    609606
    610607  // if hcal neutral excess is significant, simply create neutral EflowNeutralHadron tower and clone each track into eflowtrack
     
    612609  {
    613610    // create new photon tower
    614     tower = static_cast<Candidate*>(fTower->Clone());
    615     pt =  hcalNeutralEnergy / TMath::CosH(eta);
    616    
     611    tower = static_cast<Candidate *>(fTower->Clone());
     612    pt = hcalNeutralEnergy / TMath::CosH(eta);
     613
    617614    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalNeutralEnergy);
    618615    tower->Ehad = hcalNeutralEnergy;
    619616    tower->Eem = 0.0;
    620    
     617
    621618    fEFlowNeutralHadronOutputArray->Add(tower);
    622    
     619
    623620    //clone tracks
    624621    fItHCalTowerTrackArray->Reset();
    625     while((track = static_cast<Candidate*>(fItHCalTowerTrackArray->Next())))
     622    while((track = static_cast<Candidate *>(fItHCalTowerTrackArray->Next())))
    626623    {
    627624      mother = track;
    628       track = static_cast<Candidate*>(track->Clone());
     625      track = static_cast<Candidate *>(track->Clone());
    629626      track->AddCandidate(mother);
    630627
    631628      fEFlowTrackOutputArray->Add(track);
    632629    }
    633  
    634   }
    635  
     630  }
     631
    636632  // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking
    637633  else if(fHCalTrackEnergy > 0.0)
    638634  {
    639     weightTrack = (fHCalTrackSigma > 0.0) ? 1 / (fHCalTrackSigma*fHCalTrackSigma) : 0.0;
    640     weightCalo  = (hcalSigma > 0.0) ? 1 / (hcalSigma*hcalSigma) : 0.0;
    641  
    642     bestEnergyEstimate = (weightTrack*fHCalTrackEnergy + weightCalo*hcalEnergy) / (weightTrack + weightCalo);
     635    weightTrack = (fHCalTrackSigma > 0.0) ? 1 / (fHCalTrackSigma * fHCalTrackSigma) : 0.0;
     636    weightCalo = (hcalSigma > 0.0) ? 1 / (hcalSigma * hcalSigma) : 0.0;
     637
     638    bestEnergyEstimate = (weightTrack * fHCalTrackEnergy + weightCalo * hcalEnergy) / (weightTrack + weightCalo);
    643639    rescaleFactor = bestEnergyEstimate / fHCalTrackEnergy;
    644640
    645641    //rescale tracks
    646642    fItHCalTowerTrackArray->Reset();
    647     while((track = static_cast<Candidate*>(fItHCalTowerTrackArray->Next())))
    648     { 
     643    while((track = static_cast<Candidate *>(fItHCalTowerTrackArray->Next())))
     644    {
    649645      mother = track;
    650       track = static_cast<Candidate*>(track->Clone());
     646      track = static_cast<Candidate *>(track->Clone());
    651647      track->AddCandidate(mother);
    652648
     
    656652    }
    657653  }
    658  
    659  
    660654}
    661655
     
    668662  if(mean > 0.0)
    669663  {
    670     b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
    671     a = TMath::Log(mean) - 0.5*b*b;
    672 
    673     return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
     664    b = TMath::Sqrt(TMath::Log((1.0 + (sigma * sigma) / (mean * mean))));
     665    a = TMath::Log(mean) - 0.5 * b * b;
     666
     667    return TMath::Exp(a + b * gRandom->Gaus(0.0, 1.0));
    674668  }
    675669  else
  • modules/Calorimeter.h

    re39abb4 r0e7d64a  
    4242{
    4343public:
    44 
    4544  Calorimeter();
    4645  ~Calorimeter();
     
    5150
    5251private:
    53 
    54   typedef std::map< Long64_t, std::pair< Double_t, Double_t > > TFractionMap; //!
    55   typedef std::map< Double_t, std::set< Double_t > > TBinMap; //!
     52  typedef std::map<Long64_t, std::pair<Double_t, Double_t> > TFractionMap; //!
     53  typedef std::map<Double_t, std::set<Double_t> > TBinMap; //!
    5654
    5755  Candidate *fTower;
     
    7977  TBinMap fBinMap; //!
    8078
    81   std::vector < Double_t > fEtaBins;
    82   std::vector < std::vector < Double_t >* > fPhiBins;
     79  std::vector<Double_t> fEtaBins;
     80  std::vector<std::vector<Double_t> *> fPhiBins;
    8381
    84   std::vector < Long64_t > fTowerHits;
     82  std::vector<Long64_t> fTowerHits;
    8583
    86   std::vector < Double_t > fECalTowerFractions;
    87   std::vector < Double_t > fHCalTowerFractions;
     84  std::vector<Double_t> fECalTowerFractions;
     85  std::vector<Double_t> fHCalTowerFractions;
    8886
    89   std::vector < Double_t > fECalTrackFractions;
    90   std::vector < Double_t > fHCalTrackFractions;
     87  std::vector<Double_t> fECalTrackFractions;
     88  std::vector<Double_t> fHCalTrackFractions;
    9189
    9290  DelphesFormula *fECalResolutionFormula; //!
  • modules/Cloner.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class Clone
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
    3837#include <algorithm>
    39 #include <stdexcept>
    4038#include <iostream>
    4139#include <sstream>
     40#include <stdexcept>
    4241
    4342using namespace std;
     
    4847  fItInputArray(0)
    4948{
    50 
    5149}
    5250
     
    5553Cloner::~Cloner()
    5654{
    57 
    5855}
    5956
     
    7067
    7168  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
    72 
    7369}
    7470
     
    8581{
    8682  Candidate *candidate;
    87  
    88  // loop over all input candidates
     83
     84  // loop over all input candidates
    8985  fItInputArray->Reset();
    90   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     86  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    9187  {
    92     candidate = static_cast<Candidate*>(candidate->Clone());
     88    candidate = static_cast<Candidate *>(candidate->Clone());
    9389    fOutputArray->Add(candidate);
    9490  }
  • modules/Cloner.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  Cloner();
    4140  ~Cloner();
     
    4645
    4746private:
    48 
    4947  TIterator *fItInputArray; //!
    5048
  • modules/ConstituentFilter.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class ConstituentFilter
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    8887  param = GetParam("ConstituentInputArray");
    8988  size = param.GetSize();
    90   for(i = 0; i < size/2; ++i)
     89  for(i = 0; i < size / 2; ++i)
    9190  {
    92     array = ImportArray(param[i*2].GetString());
     91    array = ImportArray(param[i * 2].GetString());
    9392    iterator = array->MakeIterator();
    9493
    95     fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
     94    fInputMap[iterator] = ExportArray(param[i * 2 + 1].GetString());
    9695  }
    9796}
     
    101100void ConstituentFilter::Finish()
    102101{
    103   map< TIterator *, TObjArray * >::iterator itInputMap;
    104   vector< TIterator * >::iterator itInputList;
     102  map<TIterator *, TObjArray *>::iterator itInputMap;
     103  vector<TIterator *>::iterator itInputList;
    105104  TIterator *iterator;
    106105
     
    123122{
    124123  Candidate *jet, *constituent;
    125   map< TIterator *, TObjArray * >::iterator itInputMap;
    126   vector< TIterator * >::iterator itInputList;
     124  map<TIterator *, TObjArray *>::iterator itInputMap;
     125  vector<TIterator *>::iterator itInputList;
    127126  TIterator *iterator;
    128127  TObjArray *array;
     
    135134    // loop over all jets
    136135    iterator->Reset();
    137     while((jet = static_cast<Candidate*>(iterator->Next())))
     136    while((jet = static_cast<Candidate *>(iterator->Next())))
    138137    {
    139138      TIter itConstituents(jet->GetCandidates());
     
    142141
    143142      // loop over all constituents
    144       while((constituent = static_cast<Candidate*>(itConstituents.Next())))
     143      while((constituent = static_cast<Candidate *>(itConstituents.Next())))
    145144      {
    146145        // set the IsConstituent flag
     
    158157    // loop over all constituents
    159158    iterator->Reset();
    160     while((constituent = static_cast<Candidate*>(iterator->Next())))
     159    while((constituent = static_cast<Candidate *>(iterator->Next())))
    161160    {
    162161      // check the IsConstituent flag
  • modules/ConstituentFilter.h

    re39abb4 r0e7d64a  
    3030#include "classes/DelphesModule.h"
    3131
     32#include <map>
    3233#include <vector>
    33 #include <map>
    3434
    3535class TIterator;
     
    3939{
    4040public:
    41 
    4241  ConstituentFilter();
    4342  ~ConstituentFilter();
     
    4847
    4948private:
    50 
    5149  Double_t fJetPTMin;
    5250
    53   std::vector< TIterator * > fInputList; //!
     51  std::vector<TIterator *> fInputList; //!
    5452
    55   std::map< TIterator *, TObjArray * > fInputMap; //!
     53  std::map<TIterator *, TObjArray *> fInputMap; //!
    5654
    5755  TObjArray *fOutputArray; //!
  • modules/Delphes.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class Delphes
    2120 *
     
    3332#include "classes/DelphesFormula.h"
    3433
    35 #include "ExRootAnalysis/ExRootResult.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    3734#include "ExRootAnalysis/ExRootClassifier.h"
    3835#include "ExRootAnalysis/ExRootConfReader.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
     37#include "ExRootAnalysis/ExRootResult.h"
    3938#include "ExRootAnalysis/ExRootTreeWriter.h"
    4039
     40#include "TDatabasePDG.h"
     41#include "TFolder.h"
     42#include "TFormula.h"
     43#include "TLorentzVector.h"
     44#include "TMath.h"
     45#include "TObjArray.h"
    4146#include "TROOT.h"
    42 #include "TMath.h"
    43 #include "TFolder.h"
     47#include "TRandom3.h"
    4448#include "TString.h"
    45 #include "TFormula.h"
    46 #include "TRandom3.h"
    47 #include "TObjArray.h"
    48 #include "TDatabasePDG.h"
    49 #include "TLorentzVector.h"
    5049
    51 #include <algorithm>
    52 #include <stdexcept>
     50#include <algorithm>
    5351#include <iostream>
    5452#include <sstream>
     53#include <stdexcept>
    5554
     55#include <stdio.h>
    5656#include <string.h>
    57 #include <stdio.h>
    5857
    5958using namespace std;
  • modules/Delphes.h

    re39abb4 r0e7d64a  
    4141{
    4242public:
    43 
    4443  Delphes(const char *name = "Delphes");
    4544  ~Delphes();
    4645
    4746  void SetTreeWriter(ExRootTreeWriter *treeWriter);
    48  
     47
    4948  DelphesFactory *GetFactory() const { return fFactory; }
    5049
     
    5655
    5756private:
    58 
    5957  DelphesFactory *fFactory;
    6058
     
    6361
    6462#endif /* Delphes_h */
    65 
  • modules/DenseTrackFilter.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class DenseTrackFilter
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    37 
     36
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    7170  Long_t i, j, k, size, sizeEtaBins, sizePhiBins;
    7271  TBinMap::iterator itEtaBin;
    73   set< Double_t >::iterator itPhiBin;
    74   vector< Double_t > *phiBins;
     72  set<Double_t>::iterator itPhiBin;
     73  vector<Double_t> *phiBins;
    7574
    7675  // read eta and phi bins
     
    8079  fEtaBins.clear();
    8180  fPhiBins.clear();
    82   for(i = 0; i < size/2; ++i)
    83   {
    84     paramEtaBins = param[i*2];
     81  for(i = 0; i < size / 2; ++i)
     82  {
     83    paramEtaBins = param[i * 2];
    8584    sizeEtaBins = paramEtaBins.GetSize();
    86     paramPhiBins = param[i*2 + 1];
     85    paramPhiBins = param[i * 2 + 1];
    8786    sizePhiBins = paramPhiBins.GetSize();
    8887
     
    101100  {
    102101    fEtaBins.push_back(itEtaBin->first);
    103     phiBins = new vector< double >(itEtaBin->second.size());
     102    phiBins = new vector<double>(itEtaBin->second.size());
    104103    fPhiBins.push_back(phiBins);
    105104    phiBins->clear();
     
    126125void DenseTrackFilter::Finish()
    127126{
    128   vector< vector< Double_t >* >::iterator itPhiBin;
     127  vector<vector<Double_t> *>::iterator itPhiBin;
    129128  if(fItTrackInputArray) delete fItTrackInputArray;
    130129  for(itPhiBin = fPhiBins.begin(); itPhiBin != fPhiBins.end(); ++itPhiBin)
     
    145144  Double_t ptmax;
    146145
    147   vector< Double_t >::iterator itEtaBin;
    148   vector< Double_t >::iterator itPhiBin;
    149   vector< Double_t > *phiBins;
    150 
    151   vector< Long64_t >::iterator itTowerHits;
     146  vector<Double_t>::iterator itEtaBin;
     147  vector<Double_t>::iterator itPhiBin;
     148  vector<Double_t> *phiBins;
     149
     150  vector<Long64_t>::iterator itTowerHits;
    152151
    153152  fTowerHits.clear();
     
    156155  fItTrackInputArray->Reset();
    157156  number = -1;
    158   while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
     157  while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
    159158  {
    160159    const TLorentzVector &trackPosition = track->Position;
     
    196195    towerHit = (*itTowerHits);
    197196    flags = (towerHit >> 24) & 0x00000000000000FFLL;
    198     number = (towerHit) & 0x0000000000FFFFFFLL;
     197    number = (towerHit)&0x0000000000FFFFFFLL;
    199198    hitEtaPhi = towerHit >> 32;
    200199
     
    216215    {
    217216      ++fTowerTrackHits;
    218       track = static_cast<Candidate*>(fTrackInputArray->At(number));
     217      track = static_cast<Candidate *>(fTrackInputArray->At(number));
    219218      momentum = track->Momentum;
    220219
     
    226225      continue;
    227226    }
    228 
    229227  }
    230228
    231229  // here fill last tower
    232230  FillTrack();
    233 
    234231}
    235232
     
    245242  // saving track with highest pT that hit the tower
    246243  if(fTowerTrackHits < 1) return;
    247    
     244
    248245  numberOfCandidates = fBestTrack->GetCandidates()->GetEntriesFast();
    249246  if(numberOfCandidates < 1) return;
    250247
    251   track = static_cast<Candidate*>(fBestTrack->GetCandidates()->At(numberOfCandidates - 1));
    252   candidate = static_cast<Candidate*>(track->Clone());
     248  track = static_cast<Candidate *>(fBestTrack->GetCandidates()->At(numberOfCandidates - 1));
     249  candidate = static_cast<Candidate *>(track->Clone());
    253250  pt = candidate->Momentum.Pt();
    254251  eta = candidate->Momentum.Eta();
     
    256253  eta = gRandom->Gaus(eta, fEtaPhiRes);
    257254  phi = gRandom->Gaus(phi, fEtaPhiRes);
    258   candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
     255  candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt * TMath::CosH(eta));
    259256  candidate->AddCandidate(track);
    260257
     
    262259  switch(TMath::Abs(candidate->PID))
    263260  {
    264     case 11:
    265       fElectronOutputArray->Add(candidate);
    266       break;
    267     case 13:
    268       fMuonOutputArray->Add(candidate);
    269       break;
    270     default:
    271       fChargedHadronOutputArray->Add(candidate);
    272   }
    273 }
     261  case 11:
     262    fElectronOutputArray->Add(candidate);
     263    break;
     264  case 13:
     265    fMuonOutputArray->Add(candidate);
     266    break;
     267  default:
     268    fChargedHadronOutputArray->Add(candidate);
     269  }
     270}
  • modules/DenseTrackFilter.h

    re39abb4 r0e7d64a  
    4141{
    4242public:
    43 
    4443  DenseTrackFilter();
    4544  ~DenseTrackFilter();
     
    5049
    5150private:
    52 
    53   typedef std::map< Double_t, std::set< Double_t > > TBinMap; //!
     51  typedef std::map<Double_t, std::set<Double_t> > TBinMap; //!
    5452
    5553  Candidate *fBestTrack;
     
    6159  TBinMap fBinMap; //!
    6260
    63   std::vector < Double_t > fEtaBins;
    64   std::vector < std::vector < Double_t >* > fPhiBins;
     61  std::vector<Double_t> fEtaBins;
     62  std::vector<std::vector<Double_t> *> fPhiBins;
    6563
    66   std::vector < Long64_t > fTowerHits;
     64  std::vector<Long64_t> fTowerHits;
    6765
    6866  TIterator *fItTrackInputArray; //!
  • modules/Efficiency.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class Efficiency
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    46 #include <algorithm>
    47 #include <stdexcept>
     45#include <algorithm>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    9493
    9594void Efficiency::Process()
    96 { 
     95{
    9796  Candidate *candidate;
    98   Double_t pt, eta, phi, e;
     97  Double_t pt, eta, phi, e, d0, dz, ctgTheta;
    9998
    10099  fItInputArray->Reset();
    101   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     100  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    102101  {
    103102    const TLorentzVector &candidatePosition = candidate->Position;
     
    107106    pt = candidateMomentum.Pt();
    108107    e = candidateMomentum.E();
     108    d0 = candidate->D0;
     109    dz = candidate->DZ;
     110    ctgTheta = candidate->CtgTheta;
    109111
    110112    // apply an efficency formula
    111     if(gRandom->Uniform() > fFormula->Eval(pt, eta, phi, e)) continue;
    112    
     113    if(gRandom->Uniform() > fFormula->Eval(pt, eta, phi, e, d0, dz, ctgTheta)) continue;
     114
    113115    fOutputArray->Add(candidate);
    114116  }
  • modules/Efficiency.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  Efficiency();
    4140  ~Efficiency();
     
    4645
    4746private:
    48 
    4947  DelphesFormula *fFormula; //!
    5048
  • modules/EnergyScale.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class EnergyScale
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    46 #include <algorithm>
    47 #include <stdexcept>
     45#include <algorithm>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    9897  TLorentzVector momentum;
    9998  Double_t scale;
    100  
     99
    101100  fItInputArray->Reset();
    102   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     101  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    103102  {
    104103    momentum = candidate->Momentum;
     
    108107    if(scale > 0.0) momentum *= scale;
    109108
    110     candidate = static_cast<Candidate*>(candidate->Clone());
     109    candidate = static_cast<Candidate *>(candidate->Clone());
    111110    candidate->Momentum = momentum;
    112111
  • modules/EnergyScale.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  EnergyScale();
    4140  ~EnergyScale();
     
    4645
    4746private:
    48 
    4947  DelphesFormula *fFormula; //!
    5048
     
    5250
    5351  const TObjArray *fInputArray; //!
    54  
     52
    5553  TObjArray *fOutputArray; //!
    5654
  • modules/EnergySmearing.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class EnergySmearing
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    46 #include <algorithm>
    47 #include <stdexcept>
     45#include <algorithm>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    8786
    8887void EnergySmearing::Finish()
    89 { 
     88{
    9089  if(fItInputArray) delete fItInputArray;
    9190}
     
    9998
    10099  fItInputArray->Reset();
    101   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     100  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    102101  {
    103102    const TLorentzVector &candidatePosition = candidate->Position;
    104103    const TLorentzVector &candidateMomentum = candidate->Momentum;
    105    
     104
    106105    pt = candidatePosition.Pt();
    107106    eta = candidatePosition.Eta();
    108107    phi = candidatePosition.Phi();
    109108    energy = candidateMomentum.E();
    110  
     109
    111110    // apply smearing formula
    112111    energy = gRandom->Gaus(energy, fFormula->Eval(pt, eta, phi, energy));
    113      
     112
    114113    if(energy <= 0.0) continue;
    115  
     114
    116115    mother = candidate;
    117     candidate = static_cast<Candidate*>(candidate->Clone());
     116    candidate = static_cast<Candidate *>(candidate->Clone());
    118117    eta = candidateMomentum.Eta();
    119118    phi = candidateMomentum.Phi();
    120     candidate->Momentum.SetPtEtaPhiE(energy/TMath::CosH(eta), eta, phi, energy);
    121     candidate->TrackResolution = fFormula->Eval(pt, eta, phi, energy)/candidateMomentum.E();
     119    candidate->Momentum.SetPtEtaPhiE(energy / TMath::CosH(eta), eta, phi, energy);
     120    candidate->TrackResolution = fFormula->Eval(pt, eta, phi, energy) / candidateMomentum.E();
    122121    candidate->AddCandidate(mother);
    123  
     122
    124123    fOutputArray->Add(candidate);
    125124  }
  • modules/EnergySmearing.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  EnergySmearing();
    4140  ~EnergySmearing();
     
    4645
    4746private:
    48 
    4947  DelphesFormula *fFormula; //!
    5048
     
    5250
    5351  const TObjArray *fInputArray; //!
    54  
     52
    5553  TObjArray *fOutputArray; //!
    5654
  • modules/ExampleModule.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class ExampleModule
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    46 #include <algorithm>
    47 #include <stdexcept>
     45#include <algorithm>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    8786    fArrayParam.push_back(param[i].GetDouble());
    8887  }
    89  
     88
    9089  // import input array(s)
    9190
     
    9695
    9796  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
    98 
    9997}
    10098
     
    115113  // loop over all input candidates
    116114  fItInputArray->Reset();
    117   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     115  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    118116  {
    119117    candidatePosition = candidate->Position;
  • modules/ExampleModule.h

    re39abb4 r0e7d64a  
    3838{
    3939public:
    40 
    4140  ExampleModule();
    4241  ~ExampleModule();
     
    4746
    4847private:
    49 
    5048  Int_t fIntParam;
    5149  Double_t fDoubleParam;
    52  
    53   std::deque <Double_t> fArrayParam;
    54  
     50
     51  std::deque<Double_t> fArrayParam;
     52
    5553  DelphesFormula *fFormula; //!
    5654
  • modules/FastJetFinder.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class FastJetFinder
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    37 
     36
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049#include <vector>
    5150
     51#include "fastjet/ClusterSequence.hh"
     52#include "fastjet/ClusterSequenceArea.hh"
     53#include "fastjet/JetDefinition.hh"
    5254#include "fastjet/PseudoJet.hh"
    53 #include "fastjet/JetDefinition.hh"
    54 #include "fastjet/ClusterSequence.hh"
    5555#include "fastjet/Selector.hh"
    56 #include "fastjet/ClusterSequenceArea.hh"
    5756#include "fastjet/tools/JetMedianBackgroundEstimator.hh"
    5857
     58#include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh"
     59#include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
    5960#include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh"
    60 #include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
    61 #include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh"
    62 
    63 #include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
     61
     62#include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
    6463#include "fastjet/contribs/Nsubjettiness/Njettiness.hh"
    6564#include "fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh"
    66 #include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
     65#include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
    6766
    6867#include "fastjet/contribs/ValenciaPlugin/ValenciaPlugin.hh"
    6968
     69#include "fastjet/contribs/RecursiveTools/SoftDrop.hh"
    7070#include "fastjet/tools/Filter.hh"
    7171#include "fastjet/tools/Pruner.hh"
    72 #include "fastjet/contribs/RecursiveTools/SoftDrop.hh"
    7372
    7473using namespace std;
    7574using namespace fastjet;
    7675using namespace fastjet::contrib;
    77 
    7876
    7977//------------------------------------------------------------------------------
     
    8381  fDefinition(0), fAreaDefinition(0), fItInputArray(0)
    8482{
    85 
    8683}
    8784
     
    9087FastJetFinder::~FastJetFinder()
    9188{
    92 
    9389}
    9490
     
    120116  fJetPTMin = GetDouble("JetPTMin", 10.0);
    121117
    122  
    123118  //-- N(sub)jettiness parameters --
    124119
     
    127122  fAxisMode = GetInt("AxisMode", 1);
    128123  fRcutOff = GetDouble("RcutOff", 0.8); // used only if Njettiness is used as jet clustering algo (case 8)
    129   fN = GetInt("N", 2);                  // used only if Njettiness is used as jet clustering algo (case 8)
     124  fN = GetInt("N", 2); // used only if Njettiness is used as jet clustering algo (case 8)
    130125
    131126  //-- Exclusive clustering for e+e- collisions --
    132  
    133   fNJets = GetInt("NJets",2);
     127
     128  fNJets = GetInt("NJets", 2);
    134129  fExclusiveClustering = GetBool("ExclusiveClustering", false);
    135130
    136131  //-- Valencia Linear Collider algorithm
     132
    137133  fGamma = GetDouble("Gamma", 1.0);
    138134  //fBeta parameter see above
    139  
     135
    140136  fMeasureDef = new NormalizedMeasure(fBeta, fParameterR);
    141    
     137
    142138  switch(fAxisMode)
    143139  {
    144     default:
    145       case 1:
    146         fAxesDef = new WTA_KT_Axes();
    147         break;
    148       case 2:
    149         fAxesDef = new OnePass_WTA_KT_Axes();
    150         break;
    151       case 3:
    152         fAxesDef = new KT_Axes();
    153         break;
    154       case 4:
    155         fAxesDef = new OnePass_KT_Axes();
    156    }
     140  default:
     141  case 1:
     142    fAxesDef = new WTA_KT_Axes();
     143    break;
     144  case 2:
     145    fAxesDef = new OnePass_WTA_KT_Axes();
     146    break;
     147  case 3:
     148    fAxesDef = new KT_Axes();
     149    break;
     150  case 4:
     151    fAxesDef = new OnePass_KT_Axes();
     152  }
    157153
    158154  //-- Trimming parameters --
    159  
     155
    160156  fComputeTrimming = GetBool("ComputeTrimming", false);
    161157  fRTrim = GetDouble("RTrim", 0.2);
    162158  fPtFracTrim = GetDouble("PtFracTrim", 0.05);
    163  
    164159
    165160  //-- Pruning parameters --
    166  
     161
    167162  fComputePruning = GetBool("ComputePruning", false);
    168163  fZcutPrun = GetDouble("ZcutPrun", 0.1);
    169164  fRcutPrun = GetDouble("RcutPrun", 0.5);
    170165  fRPrun = GetDouble("RPrun", 0.8);
    171  
     166
    172167  //-- SoftDrop parameters --
    173  
    174   fComputeSoftDrop     = GetBool("ComputeSoftDrop", false);
    175   fBetaSoftDrop        = GetDouble("BetaSoftDrop", 0.0);
     168
     169  fComputeSoftDrop = GetBool("ComputeSoftDrop", false);
     170  fBetaSoftDrop = GetDouble("BetaSoftDrop", 0.0);
    176171  fSymmetryCutSoftDrop = GetDouble("SymmetryCutSoftDrop", 0.1);
    177   fR0SoftDrop= GetDouble("R0SoftDrop=", 0.8);
    178  
     172  fR0SoftDrop = GetDouble("R0SoftDrop=", 0.8);
    179173
    180174  // ---  Jet Area Parameters ---
     175
    181176  fAreaAlgorithm = GetInt("AreaAlgorithm", 0);
    182177  fComputeRho = GetBool("ComputeRho", false);
     
    195190  switch(fAreaAlgorithm)
    196191  {
    197     case 1:
    198       fAreaDefinition = new AreaDefinition(active_area_explicit_ghosts, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));
    199       break;
    200     case 2:
    201       fAreaDefinition = new AreaDefinition(one_ghost_passive_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));
    202       break;
    203     case 3:
    204       fAreaDefinition = new AreaDefinition(passive_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));
    205       break;
    206     case 4:
    207       fAreaDefinition = new AreaDefinition(VoronoiAreaSpec(fEffectiveRfact));
    208       break;
    209     case 5:
    210       fAreaDefinition = new AreaDefinition(active_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));
    211       break;
    212     default:
    213     case 0:
    214       fAreaDefinition = 0;
    215       break;
     192  default:
     193  case 0:
     194    fAreaDefinition = 0;
     195    break;
     196  case 1:
     197    fAreaDefinition = new AreaDefinition(active_area_explicit_ghosts, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));
     198    break;
     199  case 2:
     200    fAreaDefinition = new AreaDefinition(one_ghost_passive_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));
     201    break;
     202  case 3:
     203    fAreaDefinition = new AreaDefinition(passive_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));
     204    break;
     205  case 4:
     206    fAreaDefinition = new AreaDefinition(VoronoiAreaSpec(fEffectiveRfact));
     207    break;
     208  case 5:
     209    fAreaDefinition = new AreaDefinition(active_area, GhostedAreaSpec(fGhostEtaMax, fRepeat, fGhostArea, fGridScatter, fPtScatter, fMeanGhostPt));
     210    break;
    216211  }
    217212
    218213  switch(fJetAlgorithm)
    219214  {
    220     case 1:
    221       plugin = new CDFJetCluPlugin(fSeedThreshold, fConeRadius, fAdjacencyCut, fMaxIterations, fIratch, fOverlapThreshold);
    222       fDefinition = new JetDefinition(plugin);
    223       break;
    224     case 2:
    225       plugin = new CDFMidPointPlugin(fSeedThreshold, fConeRadius, fConeAreaFraction, fMaxPairSize, fMaxIterations, fOverlapThreshold);
    226       fDefinition = new JetDefinition(plugin);
    227       break;
    228     case 3:
    229       plugin = new SISConePlugin(fConeRadius, fOverlapThreshold, fMaxIterations, fJetPTMin);
    230       fDefinition = new JetDefinition(plugin);
    231       break;
    232     case 4:
    233       fDefinition = new JetDefinition(kt_algorithm, fParameterR);
    234       break;
    235     case 5:
    236       fDefinition = new JetDefinition(cambridge_algorithm, fParameterR);
    237       break;
    238     default:
    239     case 6:
    240       fDefinition = new JetDefinition(antikt_algorithm, fParameterR);
    241       break;
    242     case 7:
    243       recomb = new WinnerTakeAllRecombiner();
    244       fDefinition = new JetDefinition(antikt_algorithm, fParameterR, recomb, Best);
    245       break;
    246     case 8:
    247       fNjettinessPlugin = new NjettinessPlugin(fN, Njettiness::wta_kt_axes, Njettiness::unnormalized_cutoff_measure, fBeta, fRcutOff);
    248       fDefinition = new JetDefinition(fNjettinessPlugin);
    249       break;
     215  case 1:
     216    plugin = new CDFJetCluPlugin(fSeedThreshold, fConeRadius, fAdjacencyCut, fMaxIterations, fIratch, fOverlapThreshold);
     217    fDefinition = new JetDefinition(plugin);
     218    break;
     219  case 2:
     220    plugin = new CDFMidPointPlugin(fSeedThreshold, fConeRadius, fConeAreaFraction, fMaxPairSize, fMaxIterations, fOverlapThreshold);
     221    fDefinition = new JetDefinition(plugin);
     222    break;
     223  case 3:
     224    plugin = new SISConePlugin(fConeRadius, fOverlapThreshold, fMaxIterations, fJetPTMin);
     225    fDefinition = new JetDefinition(plugin);
     226    break;
     227  case 4:
     228    fDefinition = new JetDefinition(kt_algorithm, fParameterR);
     229    break;
     230  case 5:
     231    fDefinition = new JetDefinition(cambridge_algorithm, fParameterR);
     232    break;
     233  default:
     234  case 6:
     235    fDefinition = new JetDefinition(antikt_algorithm, fParameterR);
     236    break;
     237  case 7:
     238    recomb = new WinnerTakeAllRecombiner();
     239    fDefinition = new JetDefinition(antikt_algorithm, fParameterR, recomb, Best);
     240    break;
     241  case 8:
     242    fNjettinessPlugin = new NjettinessPlugin(fN, Njettiness::wta_kt_axes, Njettiness::unnormalized_cutoff_measure, fBeta, fRcutOff);
     243    fDefinition = new JetDefinition(fNjettinessPlugin);
     244    break;
    250245  case 9:
    251       fValenciaPlugin = new ValenciaPlugin(fParameterR, fBeta, fGamma);
    252       fDefinition = new JetDefinition(fValenciaPlugin);
    253       break;
    254 
    255   }
    256 
    257    
     246    fValenciaPlugin = new ValenciaPlugin(fParameterR, fBeta, fGamma);
     247    fDefinition = new JetDefinition(fValenciaPlugin);
     248    break;
     249  }
    258250
    259251  fPlugin = plugin;
     
    270262
    271263    fEstimators.clear();
    272     for(i = 0; i < size/2; ++i)
    273     {
    274       etaMin = param[i*2].GetDouble();
    275       etaMax = param[i*2 + 1].GetDouble();
     264    for(i = 0; i < size / 2; ++i)
     265    {
     266      etaMin = param[i * 2].GetDouble();
     267      etaMax = param[i * 2 + 1].GetDouble();
    276268      estimatorStruct.estimator = new JetMedianBackgroundEstimator(SelectorRapRange(etaMin, etaMax), *fDefinition, *fAreaDefinition);
    277269      estimatorStruct.etaMin = etaMin;
     
    290282  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
    291283  fRhoOutputArray = ExportArray(GetString("RhoOutputArray", "rho"));
     284  fConstituentsOutputArray = ExportArray(GetString("ConstituentsOutputArray", "constituents"));
    292285}
    293286
     
    296289void FastJetFinder::Finish()
    297290{
    298   vector< TEstimatorStruct >::iterator itEstimators;
     291  vector<TEstimatorStruct>::iterator itEstimators;
    299292
    300293  for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
     
    306299  if(fDefinition) delete fDefinition;
    307300  if(fAreaDefinition) delete fAreaDefinition;
    308   if(fPlugin) delete static_cast<JetDefinition::Plugin*>(fPlugin);
    309   if(fRecomb) delete static_cast<JetDefinition::Recombiner*>(fRecomb);
    310   if(fNjettinessPlugin) delete static_cast<JetDefinition::Plugin*>(fNjettinessPlugin);
     301  if(fPlugin) delete static_cast<JetDefinition::Plugin *>(fPlugin);
     302  if(fRecomb) delete static_cast<JetDefinition::Recombiner *>(fRecomb);
     303  if(fNjettinessPlugin) delete static_cast<JetDefinition::Plugin *>(fNjettinessPlugin);
    311304  if(fAxesDef) delete fAxesDef;
    312305  if(fMeasureDef) delete fMeasureDef;
    313   if(fValenciaPlugin) delete static_cast<JetDefinition::Plugin*>(fValenciaPlugin);
    314 
     306  if(fValenciaPlugin) delete static_cast<JetDefinition::Plugin *>(fValenciaPlugin);
    315307}
    316308
     
    325317  Double_t time, timeWeight;
    326318  Int_t number, ncharged, nneutrals;
    327   Int_t charge; 
     319  Int_t charge;
    328320  Double_t rho = 0.0;
    329321  PseudoJet jet, area;
    330322  ClusterSequence *sequence;
    331   vector< PseudoJet > inputList, outputList, subjets;
    332   vector< PseudoJet >::iterator itInputList, itOutputList;
    333   vector< TEstimatorStruct >::iterator itEstimators;
     323  vector<PseudoJet> inputList, outputList, subjets;
     324  vector<PseudoJet>::iterator itInputList, itOutputList;
     325  vector<TEstimatorStruct>::iterator itEstimators;
    334326  Double_t excl_ymerge23 = 0.0;
    335327  Double_t excl_ymerge34 = 0.0;
    336328  Double_t excl_ymerge45 = 0.0;
    337329  Double_t excl_ymerge56 = 0.0;
    338  
     330
    339331  DelphesFactory *factory = GetFactory();
    340332
     
    344336  fItInputArray->Reset();
    345337  number = 0;
    346   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     338  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    347339  {
    348340    momentum = candidate->Momentum;
     
    381373  outputList.clear();
    382374
    383  
    384375  if(fExclusiveClustering)
    385     {
    386    try{
    387      outputList = sorted_by_pt(sequence->exclusive_jets( fNJets ));
    388    }
    389    catch(fastjet::Error)
    390      {
    391        outputList.clear();
    392      }
    393 
    394       excl_ymerge23 = sequence->exclusive_ymerge( 2 );
    395       excl_ymerge34 = sequence->exclusive_ymerge( 3 );
    396       excl_ymerge45 = sequence->exclusive_ymerge( 4 );
    397       excl_ymerge56 = sequence->exclusive_ymerge( 5 );
    398     }
     376  {
     377    try
     378    {
     379      outputList = sorted_by_pt(sequence->exclusive_jets(fNJets));
     380    }
     381    catch(fastjet::Error)
     382    {
     383      outputList.clear();
     384    }
     385
     386    excl_ymerge23 = sequence->exclusive_ymerge(2);
     387    excl_ymerge34 = sequence->exclusive_ymerge(3);
     388    excl_ymerge45 = sequence->exclusive_ymerge(4);
     389    excl_ymerge56 = sequence->exclusive_ymerge(5);
     390  }
    399391  else
    400     {
    401       outputList = sorted_by_pt(sequence->inclusive_jets(fJetPTMin));
    402     }
     392  {
     393    outputList = sorted_by_pt(sequence->inclusive_jets(fJetPTMin));
     394  }
    403395
    404396  // loop over all jets and export them
    405397  detaMax = 0.0;
    406398  dphiMax = 0.0;
    407  
     399
    408400  for(itOutputList = outputList.begin(); itOutputList != outputList.end(); ++itOutputList)
    409401  {
     
    416408    if(fAreaDefinition) area = itOutputList->area_4vector();
    417409
    418 
    419    
    420410    candidate = factory->NewCandidate();
    421411
     
    434424    {
    435425      if(itInputList->user_index() < 0) continue;
    436       constituent = static_cast<Candidate*>(fInputArray->At(itInputList->user_index()));
     426      constituent = static_cast<Candidate *>(fInputArray->At(itInputList->user_index()));
    437427
    438428      deta = TMath::Abs(momentum.Eta() - constituent->Momentum.Eta());
     
    441431      if(dphi > dphiMax) dphiMax = dphi;
    442432
    443       if(constituent->Charge == 0) nneutrals++;
    444       else ncharged++;
    445 
    446       time += TMath::Sqrt(constituent->Momentum.E())*(constituent->Position.T());
     433      if(constituent->Charge == 0)
     434        nneutrals++;
     435      else
     436        ncharged++;
     437
     438      time += TMath::Sqrt(constituent->Momentum.E()) * (constituent->Position.T());
    447439      timeWeight += TMath::Sqrt(constituent->Momentum.E());
    448440
    449441      charge += constituent->Charge;
    450442
     443      fConstituentsOutputArray->Add(constituent);
    451444      candidate->AddCandidate(constituent);
    452445    }
    453446
    454447    candidate->Momentum = momentum;
    455     candidate->Position.SetT(time/timeWeight);
     448    candidate->Position.SetT(time / timeWeight);
    456449    candidate->Area.SetPxPyPzE(area.px(), area.py(), area.pz(), area.E());
    457450
    458451    candidate->DeltaEta = detaMax;
    459452    candidate->DeltaPhi = dphiMax;
    460     candidate->Charge = charge; 
     453    candidate->Charge = charge;
    461454    candidate->NNeutrals = nneutrals;
    462455    candidate->NCharged = ncharged;
    463 
    464456
    465457    //for exclusive clustering, access y_n,n+1 as exclusive_ymerge (fNJets);
     
    468460    candidate->ExclYmerge45 = excl_ymerge45;
    469461    candidate->ExclYmerge56 = excl_ymerge56;
    470    
     462
    471463    //------------------------------------
    472464    // Trimming
     
    476468    {
    477469
    478       fastjet::Filter    trimmer(fastjet::JetDefinition(fastjet::kt_algorithm,fRTrim),fastjet::SelectorPtFractionMin(fPtFracTrim));
     470      fastjet::Filter trimmer(fastjet::JetDefinition(fastjet::kt_algorithm, fRTrim), fastjet::SelectorPtFractionMin(fPtFracTrim));
    479471      fastjet::PseudoJet trimmed_jet = trimmer(*itOutputList);
    480      
     472
    481473      trimmed_jet = join(trimmed_jet.constituents());
    482      
     474
    483475      candidate->TrimmedP4[0].SetPtEtaPhiM(trimmed_jet.pt(), trimmed_jet.eta(), trimmed_jet.phi(), trimmed_jet.m());
    484        
    485       // four hardest subjets 
     476
     477      // four hardest subjets
    486478      subjets.clear();
    487479      subjets = trimmed_jet.pieces();
    488480      subjets = sorted_by_pt(subjets);
    489      
     481
    490482      candidate->NSubJetsTrimmed = subjets.size();
    491483
    492       for (size_t i = 0; i < subjets.size() and i < 4; i++)
     484      for(size_t i = 0; i < subjets.size() and i < 4; i++)
    493485      {
    494             if(subjets.at(i).pt() < 0) continue ;
    495             candidate->TrimmedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
     486        if(subjets.at(i).pt() < 0) continue;
     487        candidate->TrimmedP4[i + 1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
    496488      }
    497489    }
    498    
    499    
     490
    500491    //------------------------------------
    501492    // Pruning
    502493    //------------------------------------
    503    
    504    
     494
    505495    if(fComputePruning)
    506496    {
    507497
    508       fastjet::Pruner    pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm,fRPrun),fZcutPrun,fRcutPrun);
     498      fastjet::Pruner pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm, fRPrun), fZcutPrun, fRcutPrun);
    509499      fastjet::PseudoJet pruned_jet = pruner(*itOutputList);
    510500
    511501      candidate->PrunedP4[0].SetPtEtaPhiM(pruned_jet.pt(), pruned_jet.eta(), pruned_jet.phi(), pruned_jet.m());
    512          
    513       // four hardest subjet 
     502
     503      // four hardest subjet
    514504      subjets.clear();
    515505      subjets = pruned_jet.pieces();
    516506      subjets = sorted_by_pt(subjets);
    517      
     507
    518508      candidate->NSubJetsPruned = subjets.size();
    519509
    520       for (size_t i = 0; i < subjets.size() and i < 4; i++)
     510      for(size_t i = 0; i < subjets.size() and i < 4; i++)
    521511      {
    522             if(subjets.at(i).pt() < 0) continue ;
    523             candidate->PrunedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
     512        if(subjets.at(i).pt() < 0) continue;
     513        candidate->PrunedP4[i + 1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
    524514      }
    525 
    526     }
    527      
     515    }
     516
    528517    //------------------------------------
    529518    // SoftDrop
    530519    //------------------------------------
    531    
     520
    532521    if(fComputeSoftDrop)
    533522    {
    534    
    535       contrib::SoftDrop softDrop(fBetaSoftDrop,fSymmetryCutSoftDrop,fR0SoftDrop);
     523
     524      contrib::SoftDrop softDrop(fBetaSoftDrop, fSymmetryCutSoftDrop, fR0SoftDrop);
    536525      fastjet::PseudoJet softdrop_jet = softDrop(*itOutputList);
    537      
     526
    538527      candidate->SoftDroppedP4[0].SetPtEtaPhiM(softdrop_jet.pt(), softdrop_jet.eta(), softdrop_jet.phi(), softdrop_jet.m());
    539        
    540       // four hardest subjet 
    541      
     528
     529      // four hardest subjet
     530
    542531      subjets.clear();
    543       subjets    = softdrop_jet.pieces();
    544       subjets    = sorted_by_pt(subjets);
     532      subjets = softdrop_jet.pieces();
     533      subjets = sorted_by_pt(subjets);
    545534      candidate->NSubJetsSoftDropped = softdrop_jet.pieces().size();
    546535
    547536      candidate->SoftDroppedJet = candidate->SoftDroppedP4[0];
    548537
    549       for (size_t i = 0; i < subjets.size() and i < 4; i++)
     538      for(size_t i = 0; i < subjets.size() and i < 4; i++)
    550539      {
    551             if(subjets.at(i).pt() < 0) continue ;
    552             candidate->SoftDroppedP4[i+1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
    553             if(i==0) candidate->SoftDroppedSubJet1 = candidate->SoftDroppedP4[i+1];
    554             if(i==1) candidate->SoftDroppedSubJet2 = candidate->SoftDroppedP4[i+1];
     540        if(subjets.at(i).pt() < 0) continue;
     541        candidate->SoftDroppedP4[i + 1].SetPtEtaPhiM(subjets.at(i).pt(), subjets.at(i).eta(), subjets.at(i).phi(), subjets.at(i).m());
     542        if(i == 0) candidate->SoftDroppedSubJet1 = candidate->SoftDroppedP4[i + 1];
     543        if(i == 1) candidate->SoftDroppedSubJet2 = candidate->SoftDroppedP4[i + 1];
    555544      }
    556545    }
    557  
     546
    558547    // --- compute N-subjettiness with N = 1,2,3,4,5 ----
    559548
    560549    if(fComputeNsubjettiness)
    561550    {
    562      
     551
    563552      Nsubjettiness nSub1(1, *fAxesDef, *fMeasureDef);
    564553      Nsubjettiness nSub2(2, *fAxesDef, *fMeasureDef);
     
    566555      Nsubjettiness nSub4(4, *fAxesDef, *fMeasureDef);
    567556      Nsubjettiness nSub5(5, *fAxesDef, *fMeasureDef);
    568      
     557
    569558      candidate->Tau[0] = nSub1(*itOutputList);
    570559      candidate->Tau[1] = nSub2(*itOutputList);
     
    572561      candidate->Tau[3] = nSub4(*itOutputList);
    573562      candidate->Tau[4] = nSub5(*itOutputList);
    574          
    575563    }
    576564
  • modules/FastJetFinder.h

    re39abb4 r0e7d64a  
    3535class TIterator;
    3636
    37 namespace fastjet {
    38   class JetDefinition;
    39   class AreaDefinition;
    40   class JetMedianBackgroundEstimator;
    41   namespace contrib {
    42     class NjettinessPlugin;
    43     class ValenciaPlugin;
    44     class AxesDefinition;
    45     class MeasureDefinition;   
    46   }
    47 }
     37namespace fastjet
     38{
     39class JetDefinition;
     40class AreaDefinition;
     41class JetMedianBackgroundEstimator;
     42namespace contrib
     43{
     44class NjettinessPlugin;
     45class ValenciaPlugin;
     46class AxesDefinition;
     47class MeasureDefinition;
     48} // namespace contrib
     49} // namespace fastjet
    4850
    4951class FastJetFinder: public DelphesModule
    5052{
    5153public:
    52 
    5354  FastJetFinder();
    5455  ~FastJetFinder();
     
    5960
    6061private:
    61 
    6262  void *fPlugin; //!
    6363  void *fRecomb; //!
    6464
    65   fastjet::contrib::AxesDefinition *fAxesDef; 
    66   fastjet::contrib::MeasureDefinition *fMeasureDef;   
     65  fastjet::contrib::AxesDefinition *fAxesDef;
     66  fastjet::contrib::MeasureDefinition *fMeasureDef;
    6767
    6868  fastjet::contrib::NjettinessPlugin *fNjettinessPlugin; //!
     
    9090  //-- Valencia Linear Collider algorithm
    9191  Double_t fGamma;
    92  
     92
    9393  //-- N (sub)jettiness parameters --
    9494
     
    9797  Int_t fAxisMode;
    9898  Double_t fRcutOff;
    99   Int_t fN ;
     99  Int_t fN;
    100100
    101101  //-- Trimming parameters --
    102  
     102
    103103  Bool_t fComputeTrimming;
    104104  Double_t fRTrim;
    105105  Double_t fPtFracTrim;
    106  
     106
    107107  //-- Pruning parameters --
    108108
     
    123123  fastjet::AreaDefinition *fAreaDefinition;
    124124  Int_t fAreaAlgorithm;
    125   Bool_t  fComputeRho;
     125  Bool_t fComputeRho;
    126126
    127127  // -- ghost based areas --
     
    143143  };
    144144
    145   std::vector< TEstimatorStruct > fEstimators; //!
     145  std::vector<TEstimatorStruct> fEstimators; //!
    146146#endif
    147147
     
    152152  TObjArray *fOutputArray; //!
    153153  TObjArray *fRhoOutputArray; //!
     154  TObjArray *fConstituentsOutputArray; //!
    154155
    155156  ClassDef(FastJetFinder, 1)
  • modules/FastJetGridMedianEstimator.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class FastJetGridMedianEstimator
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
     49#include <utility>
    5050#include <vector>
    51 #include <utility>
    5251
     52#include "fastjet/ClusterSequence.hh"
     53#include "fastjet/ClusterSequenceArea.hh"
     54#include "fastjet/JetDefinition.hh"
    5355#include "fastjet/PseudoJet.hh"
    54 #include "fastjet/JetDefinition.hh"
    55 #include "fastjet/ClusterSequence.hh"
     56#include "fastjet/RectangularGrid.hh"
    5657#include "fastjet/Selector.hh"
    57 #include "fastjet/RectangularGrid.hh"
    58 #include "fastjet/ClusterSequenceArea.hh"
    5958#include "fastjet/tools/JetMedianBackgroundEstimator.hh"
    6059
    6160#include "fastjet/tools/GridMedianBackgroundEstimator.hh"
    6261
     62#include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh"
     63#include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
    6364#include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh"
    64 #include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
    65 #include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh"
    6665
    67 #include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
     66#include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
    6867#include "fastjet/contribs/Nsubjettiness/Njettiness.hh"
    6968#include "fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh"
    70 #include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
     69#include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
    7170
    7271using namespace std;
    7372using namespace fastjet;
    7473using namespace fastjet::contrib;
    75 
    7674
    7775//------------------------------------------------------------------------------
     
    8078  fItInputArray(0)
    8179{
    82 
    8380}
    8481
     
    8784FastJetGridMedianEstimator::~FastJetGridMedianEstimator()
    8885{
    89 
    9086}
    9187
     
    104100
    105101  fEstimators.clear();
    106   for(i = 0; i < size/4; ++i)
     102  for(i = 0; i < size / 4; ++i)
    107103  {
    108     rapMin = param[i*4].GetDouble();
    109     rapMax = param[i*4 + 1].GetDouble();
    110     drap = param[i*4 + 2].GetDouble();
    111     dphi = param[i*4 + 3].GetDouble();
     104    rapMin = param[i * 4].GetDouble();
     105    rapMax = param[i * 4 + 1].GetDouble();
     106    drap = param[i * 4 + 2].GetDouble();
     107    dphi = param[i * 4 + 3].GetDouble();
    112108    fEstimators.push_back(new GridMedianBackgroundEstimator(rapMin, rapMax, drap, dphi));
    113109  }
     
    125121void FastJetGridMedianEstimator::Finish()
    126122{
    127   vector< GridMedianBackgroundEstimator * >::iterator itEstimators;
     123  vector<GridMedianBackgroundEstimator *>::iterator itEstimators;
    128124
    129125  for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
     
    144140  Double_t rho = 0;
    145141  PseudoJet jet;
    146   vector< PseudoJet > inputList, outputList;
     142  vector<PseudoJet> inputList, outputList;
    147143
    148   vector< GridMedianBackgroundEstimator * >::iterator itEstimators;;
     144  vector<GridMedianBackgroundEstimator *>::iterator itEstimators;
     145  ;
    149146
    150147  DelphesFactory *factory = GetFactory();
     
    155152  fItInputArray->Reset();
    156153  number = 0;
    157   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     154  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    158155  {
    159156    momentum = candidate->Momentum;
  • modules/FastJetGridMedianEstimator.h

    re39abb4 r0e7d64a  
    2020#define FastJetGridMedianEstimator_h
    2121
    22 
    2322/** \class FastJetGridMedianEstimator
    2423 *
     
    3534class TIterator;
    3635
    37 namespace fastjet {
    38   class GridMedianBackgroundEstimator;
     36namespace fastjet
     37{
     38class GridMedianBackgroundEstimator;
    3939}
    4040
     
    4242{
    4343public:
    44 
    4544  FastJetGridMedianEstimator();
    4645  ~FastJetGridMedianEstimator();
     
    5150
    5251private:
    53 
    54   std::vector< fastjet::GridMedianBackgroundEstimator * > fEstimators; //!
     52  std::vector<fastjet::GridMedianBackgroundEstimator *> fEstimators; //!
    5553
    5654  TIterator *fItInputArray; //!
  • modules/Hector.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class Hector
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150#include "Hector/H_BeamLine.h"
     51#include "Hector/H_BeamParticle.h"
    5252#include "Hector/H_RecRPObject.h"
    53 #include "Hector/H_BeamParticle.h"
    5453
    5554using namespace std;
     
    120119
    121120  fItInputArray->Reset();
    122   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     121  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    123122  {
    124123    const TLorentzVector &candidatePosition = candidate->Position;
     
    132131    z = 1.0E-3 * candidatePosition.Z();
    133132
    134 //    tx = 1.0E6 * TMath::ATan(candidateMomentum.Px()/pz);
    135 //    ty = 1.0E6 * TMath::ATan(candidateMomentum.Py()/pz);
     133    //    tx = 1.0E6 * TMath::ATan(candidateMomentum.Px()/pz);
     134    //    ty = 1.0E6 * TMath::ATan(candidateMomentum.Py()/pz);
    136135
    137136    tx = 0.0;
    138137    ty = 0.0;
    139138
    140     theta = TMath::Hypot(TMath::ATan(candidateMomentum.Px()/pz), TMath::ATan(candidateMomentum.Py()/pz));
    141     distance = (fDistance - 1.0E-3 * candidatePosition.Z())/TMath::Cos(theta);
    142     time = gRandom->Gaus((distance + 1.0E-3 * candidatePosition.T())/c_light, fSigmaT);
     139    theta = TMath::Hypot(TMath::ATan(candidateMomentum.Px() / pz), TMath::ATan(candidateMomentum.Py() / pz));
     140    distance = (fDistance - 1.0E-3 * candidatePosition.Z()) / TMath::Cos(theta);
     141    time = gRandom->Gaus((distance + 1.0E-3 * candidatePosition.T()) / c_light, fSigmaT);
    143142
    144143    H_BeamParticle particle(candidate->Mass, candidate->Charge);
    145 //    particle.set4Momentum(candidateMomentum);
    146     particle.set4Momentum(candidateMomentum.Px(), candidateMomentum.Py(), 
    147                           candidateMomentum.Pz(), candidateMomentum.E());
     144    //    particle.set4Momentum(candidateMomentum);
     145    particle.set4Momentum(candidateMomentum.Px(), candidateMomentum.Py(),
     146      candidateMomentum.Pz(), candidateMomentum.E());
    148147    particle.setPosition(x, y, tx, ty, z);
    149148
     
    158157
    159158    mother = candidate;
    160     candidate = static_cast<Candidate*>(candidate->Clone());
     159    candidate = static_cast<Candidate *>(candidate->Clone());
    161160    candidate->Position.SetXYZT(particle.getX(), particle.getY(), particle.getS(), time);
    162161    candidate->Momentum.SetPxPyPzE(particle.getTX(), particle.getTY(), 0.0, particle.getE());
  • modules/Hector.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  Hector();
    4140  ~Hector();
     
    4645
    4746private:
    48 
    4947  Int_t fDirection;
    5048
  • modules/IdentificationMap.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class IdentificationMap
    2120 *
     
    3332#include "classes/DelphesFormula.h"
    3433
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3536#include "ExRootAnalysis/ExRootResult.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    37 #include "ExRootAnalysis/ExRootClassifier.h"
    3837
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
    3941#include "TMath.h"
     42#include "TObjArray.h"
     43#include "TRandom3.h"
    4044#include "TString.h"
    41 #include "TFormula.h"
    42 #include "TRandom3.h"
    43 #include "TObjArray.h"
    44 #include "TDatabasePDG.h"
    45 #include "TLorentzVector.h"
    4645
    4746#include <algorithm>
    48 #include <stdexcept>
    4947#include <iostream>
    5048#include <sstream>
     49#include <stdexcept>
    5150
    5251using namespace std;
     
    7978
    8079  fEfficiencyMap.clear();
    81   for(i = 0; i < size/3; ++i)
     80  for(i = 0; i < size / 3; ++i)
    8281  {
    8382    formula = new DelphesFormula;
    84     formula->Compile(param[i*3 + 2].GetString());
    85     pdg = param[i*3].GetInt();
    86     fEfficiencyMap.insert(make_pair(pdg, make_pair(param[i*3 + 1].GetInt(), formula)));
     83    formula->Compile(param[i * 3 + 2].GetString());
     84    pdg = param[i * 3].GetInt();
     85    fEfficiencyMap.insert(make_pair(pdg, make_pair(param[i * 3 + 1].GetInt(), formula)));
    8786  }
    8887
     
    129128  Double_t pt, eta, phi, e;
    130129  TMisIDMap::iterator itEfficiencyMap;
    131   pair <TMisIDMap::iterator, TMisIDMap::iterator> range;
     130  pair<TMisIDMap::iterator, TMisIDMap::iterator> range;
    132131  DelphesFormula *formula;
    133132  Int_t pdgCodeIn, pdgCodeOut, charge;
     
    136135
    137136  fItInputArray->Reset();
    138   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     137  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    139138  {
    140139    const TLorentzVector &candidatePosition = candidate->Position;
     
    144143    pt = candidateMomentum.Pt();
    145144    e = candidateMomentum.E();
    146    
     145
    147146    pdgCodeIn = candidate->PID;
    148147    charge = candidate->Charge;
     
    171170      {
    172171        // change PID of particle
    173         if(pdgCodeOut != 0) candidate->PID = charge*pdgCodeOut;
     172        if(pdgCodeOut != 0) candidate->PID = charge * pdgCodeOut;
    174173        fOutputArray->Add(candidate);
    175174        break;
  • modules/IdentificationMap.h

    re39abb4 r0e7d64a  
    2020#define IdentificationMap_h
    2121
    22 
    2322/** \class IdentificationMap
    2423 *
     
    3938{
    4039public:
    41 
    4240  IdentificationMap();
    4341  ~IdentificationMap();
     
    4846
    4947private:
    50 
    51   typedef std::multimap< Int_t, std::pair< Int_t, DelphesFormula * > > TMisIDMap; //!
     48  typedef std::multimap<Int_t, std::pair<Int_t, DelphesFormula *> > TMisIDMap; //!
    5249
    5350  TMisIDMap fEfficiencyMap; //!
  • modules/ImpactParameterSmearing.cc

    re39abb4 r0e7d64a  
    2525 */
    2626
    27 
    2827#include "modules/ImpactParameterSmearing.h"
    2928
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    10099
    101100  fItInputArray->Reset();
    102   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     101  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    103102  {
    104103
    105104    // take momentum before smearing (otherwise apply double smearing on d0)
    106     particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
     105    particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
    107106
    108107    const TLorentzVector &candidateMomentum = particle->Momentum;
     
    112111    phi = candidateMomentum.Phi();
    113112    e = candidateMomentum.E();
    114    
     113
    115114    px = candidateMomentum.Px();
    116115    py = candidateMomentum.Py();
    117116
    118117    // calculate coordinates of closest approach to track circle in transverse plane xd, yd, zd
    119     xd =  candidate->Xd;
    120     yd =  candidate->Yd;
    121     zd =  candidate->Zd;
     118    xd = candidate->Xd;
     119    yd = candidate->Yd;
     120    zd = candidate->Zd;
    122121
    123122    // calculate smeared values
     
    131130
    132131    // calculate impact parameter (after-smearing)
    133     d0 = (xd*py - yd*px)/pt;
     132    d0 = (xd * py - yd * px) / pt;
    134133
    135134    dd0 = gRandom->Gaus(0.0, fFormula->Eval(pt, eta, phi, e));
     
    138137    mother = candidate;
    139138
    140     candidate = static_cast<Candidate*>(candidate->Clone());
     139    candidate = static_cast<Candidate *>(candidate->Clone());
    141140    candidate->Xd = xd;
    142141    candidate->Yd = yd;
  • modules/ImpactParameterSmearing.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  ImpactParameterSmearing();
    4140  ~ImpactParameterSmearing();
     
    4645
    4746private:
    48 
    4947  DelphesFormula *fFormula; //!
    5048
     
    5250
    5351  const TObjArray *fInputArray; //!
    54  
     52
    5553  TObjArray *fOutputArray; //!
    5654
  • modules/Isolation.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class Isolation
    2120 *
     
    3534#include "classes/DelphesFormula.h"
    3635
     36#include "ExRootAnalysis/ExRootClassifier.h"
     37#include "ExRootAnalysis/ExRootFilter.h"
    3738#include "ExRootAnalysis/ExRootResult.h"
    38 #include "ExRootAnalysis/ExRootFilter.h"
    39 #include "ExRootAnalysis/ExRootClassifier.h"
    40 
     39
     40#include "TDatabasePDG.h"
     41#include "TFormula.h"
     42#include "TLorentzVector.h"
    4143#include "TMath.h"
     44#include "TObjArray.h"
     45#include "TRandom3.h"
    4246#include "TString.h"
    43 #include "TFormula.h"
    44 #include "TRandom3.h"
    45 #include "TObjArray.h"
    46 #include "TDatabasePDG.h"
    47 #include "TLorentzVector.h"
    4847
    4948#include <algorithm>
    50 #include <stdexcept>
    5149#include <iostream>
    5250#include <sstream>
     51#include <stdexcept>
    5352
    5453using namespace std;
     
    5958{
    6059public:
    61 
    6260  IsolationClassifier() {}
    6361
     
    7169Int_t IsolationClassifier::GetCategory(TObject *object)
    7270{
    73   Candidate *track = static_cast<Candidate*>(object);
     71  Candidate *track = static_cast<Candidate *>(object);
    7472  const TLorentzVector &momentum = track->Momentum;
    7573
     
    171169  // loop over all input jets
    172170  fItCandidateInputArray->Reset();
    173   while((candidate = static_cast<Candidate*>(fItCandidateInputArray->Next())))
     171  while((candidate = static_cast<Candidate *>(fItCandidateInputArray->Next())))
    174172  {
    175173    const TLorentzVector &candidateMomentum = candidate->Momentum;
     
    181179    {
    182180      fItRhoInputArray->Reset();
    183       while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
     181      while((object = static_cast<Candidate *>(fItRhoInputArray->Next())))
    184182      {
    185183        if(eta >= object->Edges[0] && eta < object->Edges[1])
     
    198196
    199197    itIsolationArray.Reset();
    200     while((isolation = static_cast<Candidate*>(itIsolationArray.Next())))
     198    while((isolation = static_cast<Candidate *>(itIsolationArray.Next())))
    201199    {
    202200      const TLorentzVector &isolationMomentum = isolation->Momentum;
     
    204202      if(fUseMiniCone)
    205203      {
    206          pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax &&
    207          candidateMomentum.DeltaR(isolationMomentum) > fDeltaRMin;
     204        pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax && candidateMomentum.DeltaR(isolationMomentum) > fDeltaRMin;
    208205      }
    209206      else
    210207      {
    211          pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax &&
    212          candidate->GetUniqueID() != isolation->GetUniqueID();
     208        pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax && candidate->GetUniqueID() != isolation->GetUniqueID();
    213209      }
    214210
     
    233229        }
    234230      }
    235 
    236231    }
    237232
    238    // find rho
     233    // find rho
    239234    rho = 0.0;
    240235    if(fRhoInputArray)
    241236    {
    242237      fItRhoInputArray->Reset();
    243       while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
     238      while((object = static_cast<Candidate *>(fItRhoInputArray->Next())))
    244239      {
    245240        if(eta >= object->Edges[0] && eta < object->Edges[1])
     
    250245    }
    251246
    252 
    253 
    254247    // correct sum for pile-up contamination
    255     sumDBeta = sumChargedNoPU + TMath::Max(sumNeutral - 0.5*sumChargedPU, 0.0);
    256     sumRhoCorr = sumChargedNoPU + TMath::Max(sumNeutral - TMath::Max(rho, 0.0)*fDeltaRMax*fDeltaRMax*TMath::Pi(), 0.0);
    257     ratioDBeta = sumDBeta/candidateMomentum.Pt();
    258     ratioRhoCorr = sumRhoCorr/candidateMomentum.Pt();
     248    sumDBeta = sumChargedNoPU + TMath::Max(sumNeutral - 0.5 * sumChargedPU, 0.0);
     249    sumRhoCorr = sumChargedNoPU + TMath::Max(sumNeutral - TMath::Max(rho, 0.0) * fDeltaRMax * fDeltaRMax * TMath::Pi(), 0.0);
     250    ratioDBeta = sumDBeta / candidateMomentum.Pt();
     251    ratioRhoCorr = sumRhoCorr / candidateMomentum.Pt();
    259252
    260253    candidate->IsolationVar = ratioDBeta;
  • modules/Isolation.h

    re39abb4 r0e7d64a  
    4141{
    4242public:
    43 
    4443  Isolation();
    4544  ~Isolation();
     
    5049
    5150private:
    52 
    5351  Double_t fDeltaRMax;
    5452
  • modules/JetFakeParticle.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class JetFakeParticle
    2120 *
     
    3332#include "classes/DelphesFormula.h"
    3433
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3536#include "ExRootAnalysis/ExRootResult.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    37 #include "ExRootAnalysis/ExRootClassifier.h"
    38 
     37
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
    3941#include "TMath.h"
     42#include "TObjArray.h"
     43#include "TRandom3.h"
    4044#include "TString.h"
    41 #include "TFormula.h"
    42 #include "TRandom3.h"
    43 #include "TObjArray.h"
    44 #include "TDatabasePDG.h"
    45 #include "TLorentzVector.h"
    4645
    4746#include <algorithm>
    48 #include <stdexcept>
    4947#include <iostream>
    5048#include <sstream>
    51 
     49#include <stdexcept>
    5250
    5351using namespace std;
     
    8179  fEfficiencyMap.clear();
    8280
    83   for(i = 0; i < size/2; ++i)
     81  for(i = 0; i < size / 2; ++i)
    8482  {
    8583    formula = new DelphesFormula;
    86     formula->Compile(param[i*2 + 1].GetString());
    87     pdgCode = param[i*2].GetInt();
     84    formula->Compile(param[i * 2 + 1].GetString());
     85    pdgCode = param[i * 2].GetInt();
    8886
    8987    if(TMath::Abs(pdgCode) != 11 && TMath::Abs(pdgCode) != 13 && TMath::Abs(pdgCode) != 22)
     
    9290    }
    9391
    94     fEfficiencyMap[param[i*2].GetInt()] = formula;
     92    fEfficiencyMap[param[i * 2].GetInt()] = formula;
    9593  }
    9694
     
    116114  fPhotonOutputArray = ExportArray(GetString("PhotonOutputArray", "fakePhotons"));
    117115  fJetOutputArray = ExportArray(GetString("JetOutputArray", "jets"));
    118 
    119116}
    120117
     
    147144
    148145  fItInputArray->Reset();
    149   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     146  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    150147  {
    151148    const TLorentzVector &candidatePosition = candidate->Position;
     
    170167      if(total <= r && r < total + p)
    171168      {
    172         fake = static_cast<Candidate*>(candidate->Clone());
     169        fake = static_cast<Candidate *>(candidate->Clone());
    173170
    174171        // convert jet
     
    178175          if(candidate->Charge != 0)
    179176          {
    180             fake->Charge = candidate->Charge/TMath::Abs(candidate->Charge);
     177            fake->Charge = candidate->Charge / TMath::Abs(candidate->Charge);
    181178          }
    182179          else
     
    184181            rs = gRandom->Uniform();
    185182            fake->Charge = (rs < 0.5) ? -1 : 1;
    186            
    187183          }
    188184        }
  • modules/JetFakeParticle.h

    re39abb4 r0e7d64a  
    2020#define JetFakeParticle_h
    2121
    22 
    2322/** \class JetFakeParticle
    2423 *
     
    3938{
    4039public:
    41 
    4240  JetFakeParticle();
    4341  ~JetFakeParticle();
     
    4846
    4947private:
    50 
    51   #if !defined(__CINT__) && !defined(__CLING__)
    52   typedef std::map< Int_t, DelphesFormula * > TFakeMap; //!
     48#if !defined(__CINT__) && !defined(__CLING__)
     49  typedef std::map<Int_t, DelphesFormula *> TFakeMap; //!
    5350  TFakeMap fEfficiencyMap;
    54   #endif
     51#endif
    5552
    5653  TIterator *fItInputArray; //!
  • modules/JetFlavorAssociation.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class JetFlavorAssociation
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    37 
     36
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    5352//------------------------------------------------------------------------------
    5453
    55 class PartonClassifier: public ExRootClassifier
     54class PartonClassifier : public ExRootClassifier
    5655{
    5756public:
    58 
    5957  PartonClassifier() {}
    6058  Int_t GetCategory(TObject *object);
     
    6765Int_t PartonClassifier::GetCategory(TObject *object)
    6866{
    69  // select parton in the parton list
     67  // select parton in the parton list
    7068
    7169  Candidate *parton = static_cast<Candidate *>(object);
     
    8785//------------------------------------------------------------------------------
    8886
    89 class ParticleLHEFClassifier: public ExRootClassifier
     87class ParticleLHEFClassifier : public ExRootClassifier
    9088{
    9189public:
    92 
    9390  ParticleLHEFClassifier() {}
    9491  Int_t GetCategory(TObject *object);
     
    190187//------------------------------------------------------------------------------
    191188
    192 void JetFlavorAssociation::Process(){
     189void JetFlavorAssociation::Process()
     190{
    193191
    194192  Candidate *jet;
     
    201199  if(partonArray == 0) return;
    202200
    203   if(fParticleLHEFInputArray) 
     201  if(fParticleLHEFInputArray)
    204202  {
    205203    fParticleLHEFFilter->Reset();
     
    227225  Candidate *tempParton = 0, *tempPartonHighestPt = 0;
    228226  int pdgCode, pdgCodeMax = -1;
    229  
     227
    230228  TIter itPartonArray(partonArray);
    231229  TIter itPartonLHEFArray(partonLHEFArray);
     
    241239      if(pdgCodeMax < pdgCode) pdgCodeMax = pdgCode;
    242240    }
    243  
     241
    244242    if(!fParticleLHEFInputArray) continue;
    245  
     243
    246244    itPartonLHEFArray.Reset();
    247245    while((partonLHEF = static_cast<Candidate *>(itPartonLHEFArray.Next())))
    248246    {
    249       if(parton->Momentum.DeltaR(partonLHEF->Momentum) < 0.001 &&
    250          parton->PID == partonLHEF->PID &&
    251          partonLHEF->Charge == parton->Charge)
    252       {     
    253          break;
     247      if(parton->Momentum.DeltaR(partonLHEF->Momentum) < 0.001 && parton->PID == partonLHEF->PID && partonLHEF->Charge == parton->Charge)
     248      {
     249        break;
    254250      }
    255251
     
    330326    while((partonLHEF = static_cast<Candidate *>(itPartonLHEFArray.Next())))
    331327    {
    332       if(parton->Momentum.DeltaR(partonLHEF->Momentum) < 0.01 &&
    333          parton->PID == partonLHEF->PID &&
    334          partonLHEF->Charge == parton->Charge)
     328      if(parton->Momentum.DeltaR(partonLHEF->Momentum) < 0.01 && parton->PID == partonLHEF->PID && partonLHEF->Charge == parton->Charge)
    335329      {
    336330        isGoodCandidate = false;
  • modules/JetFlavorAssociation.h

    re39abb4 r0e7d64a  
    2828 */
    2929
     30#include "classes/DelphesClasses.h"
    3031#include "classes/DelphesModule.h"
    31 #include "classes/DelphesClasses.h"
    3232#include <map>
    3333
     
    4242{
    4343public:
    44 
    4544  JetFlavorAssociation();
    4645  ~JetFlavorAssociation();
     
    5453
    5554private:
    56 
    5755  Double_t fDeltaR;
    5856
  • modules/JetPileUpSubtractor.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class JetPileUpSubtractor
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    5655  fItJetInputArray(0), fItRhoInputArray(0)
    5756{
    58 
    5957}
    6058
     
    6361JetPileUpSubtractor::~JetPileUpSubtractor()
    6462{
    65 
    6663}
    6764
     
    8380
    8481  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
    85 
    8682}
    8783
     
    105101  // loop over all input candidates
    106102  fItJetInputArray->Reset();
    107   while((candidate = static_cast<Candidate*>(fItJetInputArray->Next())))
     103  while((candidate = static_cast<Candidate *>(fItJetInputArray->Next())))
    108104  {
    109105    momentum = candidate->Momentum;
     
    116112    {
    117113      fItRhoInputArray->Reset();
    118       while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
     114      while((object = static_cast<Candidate *>(fItRhoInputArray->Next())))
    119115      {
    120116        if(eta >= object->Edges[0] && eta < object->Edges[1])
     
    132128    if(momentum.Pt() <= fJetPTMin) continue;
    133129
    134     candidate = static_cast<Candidate*>(candidate->Clone());
     130    candidate = static_cast<Candidate *>(candidate->Clone());
    135131    candidate->Momentum = momentum;
    136132
  • modules/JetPileUpSubtractor.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  JetPileUpSubtractor();
    4140  ~JetPileUpSubtractor();
     
    4645
    4746private:
    48 
    4947  Double_t fJetPTMin;
    5048
  • modules/LeptonDressing.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class LeptonDressing
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    46 #include <algorithm>
    47 #include <stdexcept>
     45#include <algorithm>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    5453
    5554LeptonDressing::LeptonDressing() :
    56  fItDressingInputArray(0), fItCandidateInputArray(0)
     55  fItDressingInputArray(0), fItCandidateInputArray(0)
    5756{
    5857}
     
    7473  fDressingInputArray = ImportArray(GetString("DressingInputArray", "Calorimeter/photons"));
    7574  fItDressingInputArray = fDressingInputArray->MakeIterator();
    76  
     75
    7776  fCandidateInputArray = ImportArray(GetString("CandidateInputArray", "UniqueObjectFinder/electrons"));
    7877  fItCandidateInputArray = fCandidateInputArray->MakeIterator();
    79  
     78
    8079  // create output array
    8180
     
    9796  Candidate *candidate, *dressing, *mother;
    9897  TLorentzVector momentum;
    99  
     98
    10099  // loop over all input candidate
    101100  fItCandidateInputArray->Reset();
    102   while((candidate = static_cast<Candidate*>(fItCandidateInputArray->Next())))
     101  while((candidate = static_cast<Candidate *>(fItCandidateInputArray->Next())))
    103102  {
    104103    const TLorentzVector &candidateMomentum = candidate->Momentum;
     
    107106    fItDressingInputArray->Reset();
    108107    momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
    109     while((dressing = static_cast<Candidate*>(fItDressingInputArray->Next())))
     108    while((dressing = static_cast<Candidate *>(fItDressingInputArray->Next())))
    110109    {
    111110      const TLorentzVector &dressingMomentum = dressing->Momentum;
    112       if (dressingMomentum.Pt() > 0.1)
     111      if(dressingMomentum.Pt() > 0.1)
    113112      {
    114113        if(candidateMomentum.DeltaR(dressingMomentum) <= fDeltaR)
     
    120119
    121120    mother = candidate;
    122     candidate = static_cast<Candidate*>(candidate->Clone());
     121    candidate = static_cast<Candidate *>(candidate->Clone());
    123122
    124123    candidate->Momentum += momentum;
    125124    candidate->AddCandidate(mother);
    126    
     125
    127126    fOutputArray->Add(candidate);
    128127  }
  • modules/LeptonDressing.h

    re39abb4 r0e7d64a  
    3434{
    3535public:
    36 
    3736  LeptonDressing();
    3837  ~LeptonDressing();
    39  
     38
    4039  void Init();
    4140  void Process();
     
    4342
    4443private:
     44  Double_t fDeltaR;
    4545
    46   Double_t fDeltaR;
    47  
    4846  TIterator *fItDressingInputArray; //!
    49  
     47
    5048  TIterator *fItCandidateInputArray; //!
    5149
    5250  const TObjArray *fDressingInputArray; //!
    53  
     51
    5452  const TObjArray *fCandidateInputArray; //!
    5553
  • modules/Merger.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class Merger
    2120 *
     
    3332#include "classes/DelphesFormula.h"
    3433
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3536#include "ExRootAnalysis/ExRootResult.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    37 #include "ExRootAnalysis/ExRootClassifier.h"
    3837
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
    3941#include "TMath.h"
     42#include "TObjArray.h"
     43#include "TRandom3.h"
    4044#include "TString.h"
    41 #include "TFormula.h"
    42 #include "TRandom3.h"
    43 #include "TObjArray.h"
    44 #include "TDatabasePDG.h"
    45 #include "TLorentzVector.h"
    4645
    47 #include <algorithm>
    48 #include <stdexcept>
     46#include <algorithm>
    4947#include <iostream>
    5048#include <sstream>
     49#include <stdexcept>
    5150
    5251using namespace std;
     
    8988
    9089  fMomentumOutputArray = ExportArray(GetString("MomentumOutputArray", "momentum"));
    91  
     90
    9291  fEnergyOutputArray = ExportArray(GetString("EnergyOutputArray", "energy"));
    9392}
     
    9796void Merger::Finish()
    9897{
    99   vector< TIterator * >::iterator itInputList;
     98  vector<TIterator *>::iterator itInputList;
    10099  TIterator *iterator;
    101100
     
    113112  Candidate *candidate;
    114113  TLorentzVector momentum;
    115   Double_t sumPT, sumE; 
    116   vector< TIterator * >::iterator itInputList;
     114  Double_t sumPT, sumE;
     115  vector<TIterator *>::iterator itInputList;
    117116  TIterator *iterator;
    118117
    119118  DelphesFactory *factory = GetFactory();
    120  
     119
    121120  momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
    122121  sumPT = 0;
     
    130129    // loop over all candidates
    131130    iterator->Reset();
    132     while((candidate = static_cast<Candidate*>(iterator->Next())))
     131    while((candidate = static_cast<Candidate *>(iterator->Next())))
    133132    {
    134133      const TLorentzVector &candidateMomentum = candidate->Momentum;
     
    143142
    144143  candidate = factory->NewCandidate();
    145  
     144
    146145  candidate->Position.SetXYZT(0.0, 0.0, 0.0, 0.0);
    147146  candidate->Momentum = momentum;
    148  
     147
    149148  fMomentumOutputArray->Add(candidate);
    150149
    151150  candidate = factory->NewCandidate();
    152  
     151
    153152  candidate->Position.SetXYZT(0.0, 0.0, 0.0, 0.0);
    154153  candidate->Momentum.SetPtEtaPhiE(sumPT, 0.0, 0.0, sumE);
    155  
     154
    156155  fEnergyOutputArray->Add(candidate);
    157156}
  • modules/Merger.h

    re39abb4 r0e7d64a  
    3939{
    4040public:
    41 
    4241  Merger();
    4342  ~Merger();
     
    4847
    4948private:
    50 
    51   std::vector< TIterator * > fInputList; //!
     49  std::vector<TIterator *> fInputList; //!
    5250
    5351  TObjArray *fOutputArray; //!
  • modules/MomentumSmearing.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class MomentumSmearing
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    46 #include <algorithm>
    47 #include <stdexcept>
     45#include <algorithm>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    9998
    10099  fItInputArray->Reset();
    101   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     100  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    102101  {
    103102    const TLorentzVector &candidatePosition = candidate->Position;
     
    108107    e = candidateMomentum.E();
    109108    res = fFormula->Eval(pt, eta, phi, e);
    110  
     109
    111110    // apply smearing formula
    112111    //pt = gRandom->Gaus(pt, fFormula->Eval(pt, eta, phi, e) * pt);
    113    
    114     res = ( res > 1.0 ) ? 1.0 : res;
    115112
    116     pt = LogNormal(pt, res * pt );
    117    
     113    res = (res > 1.0) ? 1.0 : res;
     114
     115    pt = LogNormal(pt, res * pt);
     116
    118117    //if(pt <= 0.0) continue;
    119118
    120119    mother = candidate;
    121     candidate = static_cast<Candidate*>(candidate->Clone());
     120    candidate = static_cast<Candidate *>(candidate->Clone());
    122121    eta = candidateMomentum.Eta();
    123122    phi = candidateMomentum.Phi();
    124     candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
     123    candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt * TMath::CosH(eta));
    125124    //candidate->TrackResolution = fFormula->Eval(pt, eta, phi, e);
    126125    candidate->TrackResolution = res;
    127126    candidate->AddCandidate(mother);
    128        
     127
    129128    fOutputArray->Add(candidate);
    130129  }
     
    138137  if(mean > 0.0)
    139138  {
    140     b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
    141     a = TMath::Log(mean) - 0.5*b*b;
     139    b = TMath::Sqrt(TMath::Log((1.0 + (sigma * sigma) / (mean * mean))));
     140    a = TMath::Log(mean) - 0.5 * b * b;
    142141
    143     return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
     142    return TMath::Exp(a + b * gRandom->Gaus(0.0, 1.0));
    144143  }
    145144  else
     
    149148}
    150149
    151 
    152150//------------------------------------------------------------------------------
  • modules/MomentumSmearing.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  MomentumSmearing();
    4140  ~MomentumSmearing();
     
    4645
    4746private:
    48 
    4947  Double_t LogNormal(Double_t mean, Double_t sigma);
    5048
     
    5452
    5553  const TObjArray *fInputArray; //!
    56  
     54
    5755  TObjArray *fOutputArray; //!
    5856
  • modules/OldCalorimeter.cc

    re39abb4 r0e7d64a  
    1919#include "classes/DelphesFormula.h"
    2020
     21#include "ExRootAnalysis/ExRootClassifier.h"
     22#include "ExRootAnalysis/ExRootFilter.h"
    2123#include "ExRootAnalysis/ExRootResult.h"
    22 #include "ExRootAnalysis/ExRootFilter.h"
    23 #include "ExRootAnalysis/ExRootClassifier.h"
    24 
     24
     25#include "TDatabasePDG.h"
     26#include "TFormula.h"
     27#include "TLorentzVector.h"
    2528#include "TMath.h"
     29#include "TObjArray.h"
     30#include "TRandom3.h"
    2631#include "TString.h"
    27 #include "TFormula.h"
    28 #include "TRandom3.h"
    29 #include "TObjArray.h"
    30 #include "TDatabasePDG.h"
    31 #include "TLorentzVector.h"
    3232
    3333#include <algorithm>
    34 #include <stdexcept>
    3534#include <iostream>
    3635#include <sstream>
     36#include <stdexcept>
    3737
    3838using namespace std;
     
    8282  if(fItTowerECalTrackArray) delete fItTowerECalTrackArray;
    8383  if(fTowerHCalTrackArray) delete fTowerHCalTrackArray;
    84   if(fItTowerHCalTrackArray) delete fItTowerHCalTrackArray;}
     84  if(fItTowerHCalTrackArray) delete fItTowerHCalTrackArray;
     85}
    8586
    8687//------------------------------------------------------------------------------
     
    9293  Double_t ecalFraction, hcalFraction;
    9394  TBinMap::iterator itEtaBin;
    94   set< Double_t >::iterator itPhiBin;
    95   vector< Double_t > *phiBins;
     95  set<Double_t>::iterator itPhiBin;
     96  vector<Double_t> *phiBins;
    9697
    9798  // read eta and phi bins
     
    101102  fEtaBins.clear();
    102103  fPhiBins.clear();
    103   for(i = 0; i < size/2; ++i)
    104   {
    105     paramEtaBins = param[i*2];
     104  for(i = 0; i < size / 2; ++i)
     105  {
     106    paramEtaBins = param[i * 2];
    106107    sizeEtaBins = paramEtaBins.GetSize();
    107     paramPhiBins = param[i*2 + 1];
     108    paramPhiBins = param[i * 2 + 1];
    108109    sizePhiBins = paramPhiBins.GetSize();
    109110
     
    122123  {
    123124    fEtaBins.push_back(itEtaBin->first);
    124     phiBins = new vector< double >(itEtaBin->second.size());
     125    phiBins = new vector<double>(itEtaBin->second.size());
    125126    fPhiBins.push_back(phiBins);
    126127    phiBins->clear();
     
    139140  fFractionMap[0] = make_pair(0.0, 1.0);
    140141
    141   for(i = 0; i < size/2; ++i)
    142   {
    143     paramFractions = param[i*2 + 1];
     142  for(i = 0; i < size / 2; ++i)
     143  {
     144    paramFractions = param[i * 2 + 1];
    144145    sizeFractions = paramFractions.GetSize();
    145146
     
    147148    hcalFraction = paramFractions[1].GetDouble();
    148149
    149     fFractionMap[param[i*2].GetInt()] = make_pair(ecalFraction, hcalFraction);
    150   }
    151 /*
     150    fFractionMap[param[i * 2].GetInt()] = make_pair(ecalFraction, hcalFraction);
     151  }
     152  /*
    152153  TFractionMap::iterator itFractionMap;
    153154  for(itFractionMap = fFractionMap.begin(); itFractionMap != fFractionMap.end(); ++itFractionMap)
     
    179180void OldCalorimeter::Finish()
    180181{
    181   vector< vector< Double_t>* >::iterator itPhiBin;
     182  vector<vector<Double_t> *>::iterator itPhiBin;
    182183  if(fItParticleInputArray) delete fItParticleInputArray;
    183184  if(fItTrackInputArray) delete fItTrackInputArray;
     
    203204  TFractionMap::iterator itFractionMap;
    204205
    205   vector< Double_t >::iterator itEtaBin;
    206   vector< Double_t >::iterator itPhiBin;
    207   vector< Double_t > *phiBins;
    208 
    209   vector< Long64_t >::iterator itTowerHits;
     206  vector<Double_t>::iterator itEtaBin;
     207  vector<Double_t>::iterator itPhiBin;
     208  vector<Double_t> *phiBins;
     209
     210  vector<Long64_t>::iterator itTowerHits;
    210211
    211212  DelphesFactory *factory = GetFactory();
     
    217218  fItParticleInputArray->Reset();
    218219  number = -1;
    219   while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
     220  while((particle = static_cast<Candidate *>(fItParticleInputArray->Next())))
    220221  {
    221222    const TLorentzVector &particlePosition = particle->Position;
     
    265266  fItTrackInputArray->Reset();
    266267  number = -1;
    267   while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
     268  while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
    268269  {
    269270    const TLorentzVector &trackPosition = track->Position;
     
    315316    towerHit = (*itTowerHits);
    316317    flags = (towerHit >> 24) & 0x00000000000000FFLL;
    317     number = (towerHit) & 0x0000000000FFFFFFLL;
     318    number = (towerHit)&0x0000000000FFFFFFLL;
    318319    hitEtaPhi = towerHit >> 32;
    319320
     
    336337
    337338      // calculate eta and phi of the tower's center
    338       fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
    339       fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
     339      fTowerEta = 0.5 * (fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
     340      fTowerPhi = 0.5 * ((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
    340341
    341342      fTowerEdges[0] = fEtaBins[etaBin - 1];
     
    368369    if(flags & 1)
    369370    {
    370       track = static_cast<Candidate*>(fTrackInputArray->At(number));
     371      track = static_cast<Candidate *>(fTrackInputArray->At(number));
    371372
    372373      ++fTowerTrackAllHits;
     
    408409    if(flags & 8) ++fTowerPhotonHits;
    409410
    410     particle = static_cast<Candidate*>(fParticleInputArray->At(number));
     411    particle = static_cast<Candidate *>(fParticleInputArray->At(number));
    411412    momentum = particle->Momentum;
    412413
     
    436437  if(!fTower) return;
    437438
    438 //  ecalEnergy = gRandom->Gaus(fTowerECalEnergy, fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy));
    439 //  if(ecalEnergy < 0.0) ecalEnergy = 0.0;
     439  //  ecalEnergy = gRandom->Gaus(fTowerECalEnergy, fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy));
     440  //  if(ecalEnergy < 0.0) ecalEnergy = 0.0;
    440441
    441442  ecalEnergy = LogNormal(fTowerECalEnergy, fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy));
    442443
    443 //  hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
    444 //  if(hcalEnergy < 0.0) hcalEnergy = 0.0;
     444  //  hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
     445  //  if(hcalEnergy < 0.0) hcalEnergy = 0.0;
    445446
    446447  hcalEnergy = LogNormal(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
     
    448449  energy = ecalEnergy + hcalEnergy;
    449450
    450 //  eta = fTowerEta;
    451 //  phi = fTowerPhi;
     451  //  eta = fTowerEta;
     452  //  phi = fTowerPhi;
    452453
    453454  eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
     
    481482  {
    482483    fItTowerTrackArray->Reset();
    483     while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
     484    while((track = static_cast<Candidate *>(fItTowerTrackArray->Next())))
    484485    {
    485486      fEFlowTrackOutputArray->Add(track);
    486487    }
    487488  }
    488   else if(fTowerTrackAllHits > 0 &&
    489           fTowerECalHits + fTowerHCalHits == fTowerAllHits)
    490   {
    491     if(fTowerECalHits == fTowerECalTrackHits &&
    492        fTowerHCalHits == fTowerHCalTrackHits)
     489  else if(fTowerTrackAllHits > 0 && fTowerECalHits + fTowerHCalHits == fTowerAllHits)
     490  {
     491    if(fTowerECalHits == fTowerECalTrackHits && fTowerHCalHits == fTowerHCalTrackHits)
    493492    {
    494493      itTowerTrackArray = fItTowerTrackArray;
     
    506505
    507506        fItTowerHCalArray->Reset();
    508         while((particle = static_cast<Candidate*>(fItTowerHCalArray->Next())))
     507        while((particle = static_cast<Candidate *>(fItTowerHCalArray->Next())))
    509508        {
    510509          tower->AddCandidate(particle);
     
    538537
    539538        fItTowerECalArray->Reset();
    540         while((particle = static_cast<Candidate*>(fItTowerECalArray->Next())))
     539        while((particle = static_cast<Candidate *>(fItTowerECalArray->Next())))
    541540        {
    542541          tower->AddCandidate(particle);
     
    567566    {
    568567      itTowerTrackArray->Reset();
    569       while((track = static_cast<Candidate*>(itTowerTrackArray->Next())))
     568      while((track = static_cast<Candidate *>(itTowerTrackArray->Next())))
    570569      {
    571570        fEFlowTrackOutputArray->Add(track);
     
    587586  if(mean > 0.0)
    588587  {
    589     b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
    590     a = TMath::Log(mean) - 0.5*b*b;
    591 
    592     return TMath::Exp(a + b*gRandom->Gaus(0, 1));
     588    b = TMath::Sqrt(TMath::Log((1.0 + (sigma * sigma) / (mean * mean))));
     589    a = TMath::Log(mean) - 0.5 * b * b;
     590
     591    return TMath::Exp(a + b * gRandom->Gaus(0, 1));
    593592  }
    594593  else
  • modules/OldCalorimeter.h

    re39abb4 r0e7d64a  
    2828{
    2929public:
    30 
    3130  OldCalorimeter();
    3231  ~OldCalorimeter();
     
    3736
    3837private:
    39 
    40   typedef std::map< Long64_t, std::pair< Double_t, Double_t > > TFractionMap; //!
    41   typedef std::map< Double_t, std::set< Double_t > > TBinMap; //!
     38  typedef std::map<Long64_t, std::pair<Double_t, Double_t> > TFractionMap; //!
     39  typedef std::map<Double_t, std::set<Double_t> > TBinMap; //!
    4240
    4341  Candidate *fTower;
     
    5149  TBinMap fBinMap; //!
    5250
    53   std::vector < Double_t > fEtaBins;
    54   std::vector < std::vector < Double_t >* > fPhiBins;
     51  std::vector<Double_t> fEtaBins;
     52  std::vector<std::vector<Double_t> *> fPhiBins;
    5553
    56   std::vector < Long64_t > fTowerHits;
     54  std::vector<Long64_t> fTowerHits;
    5755
    58   std::vector < Double_t > fECalFractions;
    59   std::vector < Double_t > fHCalFractions;
     56  std::vector<Double_t> fECalFractions;
     57  std::vector<Double_t> fHCalFractions;
    6058
    6159  DelphesFormula *fECalResolutionFormula; //!
  • modules/ParticlePropagator.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class ParticlePropagator
    2120 *
     
    3534#include "classes/DelphesFormula.h"
    3635
     36#include "ExRootAnalysis/ExRootClassifier.h"
     37#include "ExRootAnalysis/ExRootFilter.h"
    3738#include "ExRootAnalysis/ExRootResult.h"
    38 #include "ExRootAnalysis/ExRootFilter.h"
    39 #include "ExRootAnalysis/ExRootClassifier.h"
    40 
     39
     40#include "TDatabasePDG.h"
     41#include "TFormula.h"
     42#include "TLorentzVector.h"
    4143#include "TMath.h"
     44#include "TObjArray.h"
     45#include "TRandom3.h"
    4246#include "TString.h"
    43 #include "TFormula.h"
    44 #include "TRandom3.h"
    45 #include "TObjArray.h"
    46 #include "TDatabasePDG.h"
    47 #include "TLorentzVector.h"
    4847
    4948#include <algorithm>
    50 #include <stdexcept>
    5149#include <iostream>
    5250#include <sstream>
     51#include <stdexcept>
    5352
    5453using namespace std;
     
    6766}
    6867
    69 
    7068//------------------------------------------------------------------------------
    7169
     
    7371{
    7472  fRadius = GetDouble("Radius", 1.0);
    75   fRadius2 = fRadius*fRadius;
     73  fRadius2 = fRadius * fRadius;
    7674  fHalfLength = GetDouble("HalfLength", 3.0);
    7775  fBz = GetDouble("Bz", 0.0);
     
    140138  const Double_t c_light = 2.99792458E8;
    141139
    142   if (!fBeamSpotInputArray || fBeamSpotInputArray->GetSize () == 0)
     140  if(!fBeamSpotInputArray || fBeamSpotInputArray->GetSize() == 0)
    143141    beamSpotPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
    144142  else
    145143  {
    146     Candidate &beamSpotCandidate = *((Candidate *) fBeamSpotInputArray->At(0));
     144    Candidate &beamSpotCandidate = *((Candidate *)fBeamSpotInputArray->At(0));
    147145    beamSpotPosition = beamSpotCandidate.Position;
    148146  }
    149147
    150148  fItInputArray->Reset();
    151   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     149  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    152150  {
    153151    if(candidate->GetCandidates()->GetEntriesFast() == 0)
     
    157155    else
    158156    {
    159       particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
     157      particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
    160158    }
    161159
    162160    particlePosition = particle->Position;
    163161    particleMomentum = particle->Momentum;
    164     x = particlePosition.X()*1.0E-3;
    165     y = particlePosition.Y()*1.0E-3;
    166     z = particlePosition.Z()*1.0E-3;
    167 
    168     bsx = beamSpotPosition.X()*1.0E-3;
    169     bsy = beamSpotPosition.Y()*1.0E-3;
    170     bsz = beamSpotPosition.Z()*1.0E-3;
     162    x = particlePosition.X() * 1.0E-3;
     163    y = particlePosition.Y() * 1.0E-3;
     164    z = particlePosition.Z() * 1.0E-3;
     165
     166    bsx = beamSpotPosition.X() * 1.0E-3;
     167    bsy = beamSpotPosition.Y() * 1.0E-3;
     168    bsz = beamSpotPosition.Z() * 1.0E-3;
    171169
    172170    q = particle->Charge;
     
    193191    {
    194192      mother = candidate;
    195       candidate = static_cast<Candidate*>(candidate->Clone());
     193      candidate = static_cast<Candidate *>(candidate->Clone());
    196194
    197195      candidate->InitialPosition = particlePosition;
     
    207205    {
    208206      // solve pt2*t^2 + 2*(px*x + py*y)*t - (fRadius2 - x*x - y*y) = 0
    209       tmp = px*y - py*x;
    210       discr2 = pt2*fRadius2 - tmp*tmp;
     207      tmp = px * y - py * x;
     208      discr2 = pt2 * fRadius2 - tmp * tmp;
    211209
    212210      if(discr2 < 0.0)
     
    216214      }
    217215
    218       tmp = px*x + py*y;
     216      tmp = px * x + py * y;
    219217      discr = TMath::Sqrt(discr2);
    220       t1 = (-tmp + discr)/pt2;
    221       t2 = (-tmp - discr)/pt2;
     218      t1 = (-tmp + discr) / pt2;
     219      t2 = (-tmp - discr) / pt2;
    222220      t = (t1 < 0.0) ? t2 : t1;
    223221
    224       z_t = z + pz*t;
     222      z_t = z + pz * t;
    225223      if(TMath::Abs(z_t) > fHalfLength)
    226224      {
     
    230228      }
    231229
    232       x_t = x + px*t;
    233       y_t = y + py*t;
    234       z_t = z + pz*t;
    235 
    236       l = TMath::Sqrt( (x_t - x)*(x_t - x) + (y_t - y)*(y_t - y) + (z_t - z)*(z_t - z));
     230      x_t = x + px * t;
     231      y_t = y + py * t;
     232      z_t = z + pz * t;
     233
     234      l = TMath::Sqrt((x_t - x) * (x_t - x) + (y_t - y) * (y_t - y) + (z_t - z) * (z_t - z));
    237235
    238236      mother = candidate;
    239       candidate = static_cast<Candidate*>(candidate->Clone());
     237      candidate = static_cast<Candidate *>(candidate->Clone());
    240238
    241239      candidate->InitialPosition = particlePosition;
    242       candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*e*1.0E3);
    243       candidate->L = l*1.0E3;
     240      candidate->Position.SetXYZT(x_t * 1.0E3, y_t * 1.0E3, z_t * 1.0E3, particlePosition.T() + t * e * 1.0E3);
     241      candidate->L = l * 1.0E3;
    244242
    245243      candidate->Momentum = particleMomentum;
     
    251249        switch(TMath::Abs(candidate->PID))
    252250        {
    253           case 11:
    254             fElectronOutputArray->Add(candidate);
    255             break;
    256           case 13:
    257             fMuonOutputArray->Add(candidate);
    258             break;
    259           default:
    260             fChargedHadronOutputArray->Add(candidate);
     251        case 11:
     252          fElectronOutputArray->Add(candidate);
     253          break;
     254        case 13:
     255          fMuonOutputArray->Add(candidate);
     256          break;
     257        default:
     258          fChargedHadronOutputArray->Add(candidate);
    261259        }
    262260      }
    263261      else
    264262      {
    265          fNeutralOutputArray->Add(candidate);
     263        fNeutralOutputArray->Add(candidate);
    266264      }
    267265    }
     
    275273      //     helix radius r = p_{T0} / (omega gamma m)
    276274
    277       gammam = e*1.0E9 / (c_light*c_light);      // gammam in [eV/c^2]
    278       omega = q * fBz / (gammam);                // omega is here in [89875518/s]
    279       r = pt / (q * fBz) * 1.0E9/c_light;        // in [m]
     275      gammam = e * 1.0E9 / (c_light * c_light); // gammam in [eV/c^2]
     276      omega = q * fBz / (gammam); // omega is here in [89875518/s]
     277      r = pt / (q * fBz) * 1.0E9 / c_light; // in [m]
    280278
    281279      phi_0 = TMath::ATan2(py, px); // [rad] in [-pi, pi]
    282280
    283281      // 2. helix axis coordinates
    284       x_c = x + r*TMath::Sin(phi_0);
    285       y_c = y - r*TMath::Cos(phi_0);
     282      x_c = x + r * TMath::Sin(phi_0);
     283      y_c = y - r * TMath::Cos(phi_0);
    286284      r_c = TMath::Hypot(x_c, y_c);
    287285      phi_c = TMath::ATan2(y_c, x_c);
     
    290288
    291289      rcu = TMath::Abs(r);
    292       rc2 = r_c*r_c;
     290      rc2 = r_c * r_c;
    293291
    294292      // calculate coordinates of closest approach to track circle in transverse plane xd, yd, zd
    295       xd = x_c*x_c*x_c - x_c*rcu*r_c + x_c*y_c*y_c;
     293      xd = x_c * x_c * x_c - x_c * rcu * r_c + x_c * y_c * y_c;
    296294      xd = (rc2 > 0.0) ? xd / rc2 : -999;
    297       yd = y_c*(-rcu*r_c + rc2);
     295      yd = y_c * (-rcu * r_c + rc2);
    298296      yd = (rc2 > 0.0) ? yd / rc2 : -999;
    299       zd = z + (TMath::Sqrt(xd*xd + yd*yd) - TMath::Sqrt(x*x + y*y))*pz/pt;
     297      zd = z + (TMath::Sqrt(xd * xd + yd * yd) - TMath::Sqrt(x * x + y * y)) * pz / pt;
    300298
    301299      // use perigee momentum rather than original particle
     
    311309      // calculate additional track parameters (correct for beamspot position)
    312310
    313       d0        = ((x - bsx) * py - (y - bsy) * px) / pt;
    314       dz        = z - ((x - bsx) * px + (y - bsy) * py) / pt * (pz / pt);
    315       p         = particleMomentum.P();
    316       ctgTheta  = 1.0 / TMath::Tan (particleMomentum.Theta());
    317 
     311      d0 = ((x - bsx) * py - (y - bsy) * px) / pt;
     312      dz = z - ((x - bsx) * px + (y - bsy) * py) / pt * (pz / pt);
     313      p = particleMomentum.P();
     314      ctgTheta = 1.0 / TMath::Tan(particleMomentum.Theta());
    318315
    319316      // 3. time evaluation t = TMath::Min(t_r, t_z)
     
    322319      t_r = 0.0; // in [ns]
    323320      int sign_pz = (pz > 0.0) ? 1 : -1;
    324       if(pz == 0.0) t_z = 1.0E99;
    325       else t_z = gammam / (pz*1.0E9/c_light) * (-z + fHalfLength*sign_pz);
    326 
    327       if(r_c + TMath::Abs(r)  < fRadius)
     321      if(pz == 0.0)
     322        t_z = 1.0E99;
     323      else
     324        t_z = gammam / (pz * 1.0E9 / c_light) * (-z + fHalfLength * sign_pz);
     325
     326      if(r_c + TMath::Abs(r) < fRadius)
    328327      {
    329328        // helix does not cross the cylinder sides
     
    332331      else
    333332      {
    334         asinrho = TMath::ASin((fRadius*fRadius - r_c*r_c - r*r) / (2*TMath::Abs(r)*r_c));
     333        asinrho = TMath::ASin((fRadius * fRadius - r_c * r_c - r * r) / (2 * TMath::Abs(r) * r_c));
    335334        delta = phi_0 - phi;
    336         if(delta <-TMath::Pi()) delta += 2*TMath::Pi();
    337         if(delta > TMath::Pi()) delta -= 2*TMath::Pi();
     335        if(delta < -TMath::Pi()) delta += 2 * TMath::Pi();
     336        if(delta > TMath::Pi()) delta -= 2 * TMath::Pi();
    338337        t1 = (delta + asinrho) / omega;
    339338        t2 = (delta + TMath::Pi() - asinrho) / omega;
     
    359358      x_t = x_c + r * TMath::Sin(omega * t - phi_0);
    360359      y_t = y_c + r * TMath::Cos(omega * t - phi_0);
    361       z_t = z + pz*1.0E9 / c_light / gammam * t;
     360      z_t = z + pz * 1.0E9 / c_light / gammam * t;
    362361      r_t = TMath::Hypot(x_t, y_t);
    363362
    364 
    365363      // compute path length for an helix
    366364
    367       alpha = pz*1.0E9 / c_light / gammam;
    368       l = t * TMath::Sqrt(alpha*alpha + r*r*omega*omega);
     365      alpha = pz * 1.0E9 / c_light / gammam;
     366      l = t * TMath::Sqrt(alpha * alpha + r * r * omega * omega);
    369367
    370368      if(r_t > 0.0)
     
    374372        if(particle == candidate)
    375373        {
    376           particle->D0 = d0*1.0E3;
    377           particle->DZ = dz*1.0E3;
     374          particle->D0 = d0 * 1.0E3;
     375          particle->DZ = dz * 1.0E3;
    378376          particle->P = p;
    379377          particle->PT = pt;
     
    383381
    384382        mother = candidate;
    385         candidate = static_cast<Candidate*>(candidate->Clone());
     383        candidate = static_cast<Candidate *>(candidate->Clone());
    386384
    387385        candidate->InitialPosition = particlePosition;
    388         candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*c_light*1.0E3);
     386        candidate->Position.SetXYZT(x_t * 1.0E3, y_t * 1.0E3, z_t * 1.0E3, particlePosition.T() + t * c_light * 1.0E3);
    389387
    390388        candidate->Momentum = particleMomentum;
    391389
    392         candidate->L = l*1.0E3;
    393 
    394         candidate->Xd = xd*1.0E3;
    395         candidate->Yd = yd*1.0E3;
    396         candidate->Zd = zd*1.0E3;
     390        candidate->L = l * 1.0E3;
     391
     392        candidate->Xd = xd * 1.0E3;
     393        candidate->Yd = yd * 1.0E3;
     394        candidate->Zd = zd * 1.0E3;
    397395
    398396        candidate->AddCandidate(mother);
     
    401399        switch(TMath::Abs(candidate->PID))
    402400        {
    403           case 11:
    404             fElectronOutputArray->Add(candidate);
    405             break;
    406           case 13:
    407             fMuonOutputArray->Add(candidate);
    408             break;
    409           default:
    410             fChargedHadronOutputArray->Add(candidate);
     401        case 11:
     402          fElectronOutputArray->Add(candidate);
     403          break;
     404        case 13:
     405          fMuonOutputArray->Add(candidate);
     406          break;
     407        default:
     408          fChargedHadronOutputArray->Add(candidate);
    411409        }
    412410      }
     
    416414
    417415//------------------------------------------------------------------------------
    418 
  • modules/ParticlePropagator.h

    re39abb4 r0e7d64a  
    4040{
    4141public:
    42 
    4342  ParticlePropagator();
    4443  ~ParticlePropagator();
     
    4948
    5049private:
    51 
    5250  Double_t fRadius, fRadius2, fRadiusMax, fHalfLength, fHalfLengthMax;
    5351  Double_t fBz;
  • modules/PdgCodeFilter.cc

    re39abb4 r0e7d64a  
    3131#include "classes/DelphesFormula.h"
    3232
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3335#include "ExRootAnalysis/ExRootResult.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootClassifier.h"
    3636
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3740#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3843#include "TString.h"
    39 #include "TFormula.h"
    40 #include "TRandom3.h"
    41 #include "TObjArray.h"
    42 #include "TDatabasePDG.h"
    43 #include "TLorentzVector.h"
    4444
    4545#include <algorithm>
    46 #include <stdexcept>
    4746#include <iostream>
    4847#include <sstream>
     48#include <stdexcept>
    4949
    5050using namespace std;
     
    7575
    7676  fInvert = GetBool("Invert", false);
     77
     78  // no pileup
     79  fRequireNotPileup = GetBool("RequireNotPileup", false);
    7780
    7881  fRequireStatus = GetBool("RequireStatus", false);
     
    118121
    119122  fItInputArray->Reset();
    120   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     123  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    121124  {
    122125    pdgCode = candidate->PID;
     
    127130    if(fRequireStatus && (candidate->Status != fStatus)) continue;
    128131    if(fRequireCharge && (candidate->Charge != fCharge)) continue;
     132    if(fRequireNotPileup && (candidate->IsPU > 0)) continue;
    129133
    130134    pass = kTRUE;
     
    135139  }
    136140}
    137 
  • modules/PdgCodeFilter.h

    re39abb4 r0e7d64a  
    3939{
    4040public:
    41 
    4241  PdgCodeFilter();
    4342  ~PdgCodeFilter();
     
    4847
    4948private:
    50 
    5149  Double_t fPTMin; //!
    5250  Bool_t fInvert; //!
     
    5553  Bool_t fRequireCharge; //!
    5654  Int_t fCharge; //!
    57 
     55  Bool_t fRequireNotPileup; //!
    5856
    5957  std::vector<Int_t> fPdgCodes;
  • modules/PhotonConversions.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class PhotonConversions
    2120 *
     
    3029
    3130#include "classes/DelphesClasses.h"
     31#include "classes/DelphesCylindricalFormula.h"
    3232#include "classes/DelphesFactory.h"
    33 #include "classes/DelphesCylindricalFormula.h"
    34 
     33
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3536#include "ExRootAnalysis/ExRootResult.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    37 #include "ExRootAnalysis/ExRootClassifier.h"
    38 
     37
     38#include "TDatabasePDG.h"
     39#include "TF1.h"
     40#include "TFormula.h"
     41#include "TLorentzVector.h"
    3942#include "TMath.h"
    40 #include "TF1.h"
     43#include "TObjArray.h"
     44#include "TRandom3.h"
    4145#include "TString.h"
    42 #include "TFormula.h"
    43 #include "TRandom3.h"
    44 #include "TObjArray.h"
    45 #include "TDatabasePDG.h"
    46 #include "TLorentzVector.h"
    4746#include "TVector3.h"
    4847
    4948#include <algorithm>
    50 #include <stdexcept>
    5149#include <iostream>
    5250#include <sstream>
     51#include <stdexcept>
    5352
    5453using namespace std;
     
    5958  fItInputArray(0), fConversionMap(0), fDecayXsec(0)
    6059{
    61   fDecayXsec = new TF1("decayXsec","1.0 - 4.0/3.0 * x * (1.0 - x)", 0.0, 1.0);
     60  fDecayXsec = new TF1("decayXsec", "1.0 - 4.0/3.0 * x * (1.0 - x)", 0.0, 1.0);
    6261  fConversionMap = new DelphesCylindricalFormula;
    6362}
     
    7473{
    7574  fRadius = GetDouble("Radius", 1.0);
    76   fRadius2 = fRadius*fRadius;
     75  fRadius2 = fRadius * fRadius;
    7776
    7877  fHalfLength = GetDouble("HalfLength", 3.0);
     
    122121
    123122  fItInputArray->Reset();
    124   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     123  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    125124  {
    126125
     
    133132      candidatePosition = candidate->Position;
    134133      candidateMomentum = candidate->Momentum;
    135       x = candidatePosition.X()*1.0E-3;
    136       y = candidatePosition.Y()*1.0E-3;
    137       z = candidatePosition.Z()*1.0E-3;
     134      x = candidatePosition.X() * 1.0E-3;
     135      y = candidatePosition.Y() * 1.0E-3;
     136      z = candidatePosition.Z() * 1.0E-3;
    138137
    139138      // check that particle position is inside the cylinder
     
    152151
    153152      // solve pt2*t^2 + 2*(px*x + py*y)*t - (fRadius2 - x*x - y*y) = 0
    154       tmp = px*y - py*x;
    155       discr2 = pt2*fRadius2 - tmp*tmp;
     153      tmp = px * y - py * x;
     154      discr2 = pt2 * fRadius2 - tmp * tmp;
    156155
    157156      if(discr2 < 0.0)
     
    161160      }
    162161
    163       tmp = px*x + py*y;
     162      tmp = px * x + py * y;
    164163      discr = TMath::Sqrt(discr2);
    165       t1 = (-tmp + discr)/pt2;
    166       t2 = (-tmp - discr)/pt2;
     164      t1 = (-tmp + discr) / pt2;
     165      t2 = (-tmp - discr) / pt2;
    167166      t = (t1 < 0.0) ? t2 : t1;
    168167
    169       z_t = z + pz*t;
     168      z_t = z + pz * t;
    170169      if(TMath::Abs(z_t) > fHalfLength)
    171170      {
     
    176175
    177176      // final position
    178       x_t = x + px*t;
    179       y_t = y + py*t;
    180       z_t = z + pz*t;
    181 
    182       r_t = TMath::Sqrt(x_t*x_t + y_t*y_t + z_t*z_t);
    183 
     177      x_t = x + px * t;
     178      y_t = y + py * t;
     179      z_t = z + pz * t;
     180
     181      r_t = TMath::Sqrt(x_t * x_t + y_t * y_t + z_t * z_t);
    184182
    185183      // here starts conversion code
    186       nsteps = Int_t(r_t/fStep);
     184      nsteps = Int_t(r_t / fStep);
    187185
    188186      x_i = x;
     
    190188      z_i = z;
    191189
    192       dt = t/nsteps;
     190      dt = t / nsteps;
    193191
    194192      converted = false;
     
    196194      for(i = 0; i < nsteps; ++i)
    197195      {
    198         x_i += px*dt;
    199         y_i += py*dt;
    200         z_i += pz*dt;
    201         pos_i.SetXYZ(x_i,y_i,z_i);
     196        x_i += px * dt;
     197        y_i += py * dt;
     198        z_i += pz * dt;
     199        pos_i.SetXYZ(x_i, y_i, z_i);
    202200
    203201        // convert photon position into cylindrical coordinates, cylindrical r,phi,z !!
    204202
    205         r_i = TMath::Sqrt(x_i*x_i + y_i*y_i);
     203        r_i = TMath::Sqrt(x_i * x_i + y_i * y_i);
    206204        phi_i = pos_i.Phi();
    207205
     
    210208
    211209        // convert into conversion probability
    212         p_conv = 1 - TMath::Exp(-7.0/9.0*fStep*rate);
     210        p_conv = 1 - TMath::Exp(-7.0 / 9.0 * fStep * rate);
    213211
    214212        // case conversion occurs
     
    221219          x2 = 1 - x1;
    222220
    223           ep = static_cast<Candidate*>(candidate->Clone());
    224           em = static_cast<Candidate*>(candidate->Clone());
    225 
    226           ep->Position.SetXYZT(x_i*1.0E3, y_i*1.0E3, z_i*1.0E3, candidatePosition.T() + nsteps*dt*e*1.0E3);
    227           em->Position.SetXYZT(x_i*1.0E3, y_i*1.0E3, z_i*1.0E3, candidatePosition.T() + nsteps*dt*e*1.0E3);
    228 
    229           ep->Momentum.SetPtEtaPhiE(x1*pt, eta, phi, x1*e);
    230           em->Momentum.SetPtEtaPhiE(x2*pt, eta, phi, x2*e);
     221          ep = static_cast<Candidate *>(candidate->Clone());
     222          em = static_cast<Candidate *>(candidate->Clone());
     223
     224          ep->Position.SetXYZT(x_i * 1.0E3, y_i * 1.0E3, z_i * 1.0E3, candidatePosition.T() + nsteps * dt * e * 1.0E3);
     225          em->Position.SetXYZT(x_i * 1.0E3, y_i * 1.0E3, z_i * 1.0E3, candidatePosition.T() + nsteps * dt * e * 1.0E3);
     226
     227          ep->Momentum.SetPtEtaPhiE(x1 * pt, eta, phi, x1 * e);
     228          em->Momentum.SetPtEtaPhiE(x2 * pt, eta, phi, x2 * e);
    231229
    232230          ep->PID = -11;
     
    251249
    252250//------------------------------------------------------------------------------
    253 
  • modules/PhotonConversions.h

    re39abb4 r0e7d64a  
    3838{
    3939public:
    40 
    4140  PhotonConversions();
    4241  ~PhotonConversions();
     
    4746
    4847private:
    49 
    5048  Double_t fRadius, fRadius2, fHalfLength;
    5149  Double_t fEtaMin, fEtaMax;
  • modules/PhotonID.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class PhotonID
    2120 *
     
    3433#include "classes/DelphesFormula.h"
    3534
     35#include "ExRootAnalysis/ExRootClassifier.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
    3637#include "ExRootAnalysis/ExRootResult.h"
    37 #include "ExRootAnalysis/ExRootFilter.h"
    38 #include "ExRootAnalysis/ExRootClassifier.h"
    39 
     38
     39#include "TDatabasePDG.h"
     40#include "TFormula.h"
     41#include "TLorentzVector.h"
    4042#include "TMath.h"
     43#include "TObjArray.h"
     44#include "TRandom3.h"
    4145#include "TString.h"
    42 #include "TFormula.h"
    43 #include "TRandom3.h"
    44 #include "TObjArray.h"
    45 #include "TDatabasePDG.h"
    46 #include "TLorentzVector.h"
    47 
    48 #include <algorithm>
    49 #include <stdexcept>
     46
     47#include <algorithm>
    5048#include <iostream>
    5149#include <sstream>
     50#include <stdexcept>
    5251
    5352using namespace std;
     
    5655
    5756PhotonID::PhotonID() :
    58   fPromptFormula(0), fNonPromptFormula(0), fFakeFormula(0), fItInputPhotonArray(0),  fItInputGenArray(0)
    59 {
    60  fPromptFormula = new DelphesFormula;
    61  fNonPromptFormula = new DelphesFormula;
    62  fFakeFormula = new DelphesFormula;
     57  fPromptFormula(0), fNonPromptFormula(0), fFakeFormula(0), fItInputPhotonArray(0), fItInputGenArray(0)
     58{
     59  fPromptFormula = new DelphesFormula;
     60  fNonPromptFormula = new DelphesFormula;
     61  fFakeFormula = new DelphesFormula;
    6362}
    6463
     
    8180  fNonPromptFormula->Compile(GetString("NonPromptFormula", "1.0"));
    8281  fFakeFormula->Compile(GetString("FakeFormula", "1.0"));
    83  
     82
    8483  // import input arrays
    8584  fInputPhotonArray = ImportArray(GetString("InputPhotonArray", "PhotonIsolation/photons"));
     
    111110
    112111void PhotonID::Process()
    113 { 
     112{
    114113  Candidate *candidate, *mother;
    115114  Double_t pt, eta, phi, e;
    116115  Double_t relIso;
    117116  Bool_t isolated;
    118  
     117
    119118  //cout<< "----  new event ---------"<<endl;
    120119
    121120  fItInputPhotonArray->Reset();
    122   while((candidate = static_cast<Candidate*>(fItInputPhotonArray->Next())))
     121  while((candidate = static_cast<Candidate *>(fItInputPhotonArray->Next())))
    123122  {
    124123
    125124    mother = candidate;
    126     candidate = static_cast<Candidate*>(candidate->Clone());
     125    candidate = static_cast<Candidate *>(candidate->Clone());
    127126    candidate->AddCandidate(mother);
    128127
     
    134133    e = candidateMomentum.E();
    135134
    136     if (pt < fPTMin) continue;
     135    if(pt < fPTMin) continue;
    137136
    138137    //cout<< "              ---- photon -----: "<<pt<<","<<eta<<","<<phi<<endl;
    139    
     138
    140139    // find out if photon matches does not match photon in gen collection and apply fae efficiency
    141     if (isFake(candidate) )
     140    if(isFake(candidate))
    142141    {
    143142      //cout<<"                    Fake!"<<endl;
     
    157156
    158157      // if isolated apply prompt formula
    159       if (isolated)
     158      if(isolated)
    160159      {
    161160        //cout<<"                       isolated!:   "<<relIso<<endl;
     
    164163        candidate->Status = 1;
    165164        fOutputArray->Add(candidate);
    166        
    167165      }
    168      
     166
    169167      // if non-isolated apply non-prompt formula
    170168      else
     
    182180//------------------------------------------------------------------------------
    183181
    184 Bool_t PhotonID::isFake(const Candidate *obj){
     182Bool_t PhotonID::isFake(const Candidate *obj)
     183{
    185184
    186185  const TLorentzVector &mom_rec = obj->Momentum;
    187  
     186
    188187  Bool_t matches = false;
    189188  fItInputGenArray->Reset();
    190189  Candidate *gen;
    191  
    192   while((gen = static_cast<Candidate*>(fItInputGenArray->Next())))
     190
     191  while((gen = static_cast<Candidate *>(fItInputGenArray->Next())))
    193192  {
    194193    const TLorentzVector &mom_gen = gen->Momentum;
    195194    Int_t status = gen->Status;
    196195    Int_t pdgCode = TMath::Abs(gen->PID);
    197     Float_t dPtOverPt = TMath::Abs((mom_gen.Pt() - mom_rec.Pt())/mom_rec.Pt());
     196    Float_t dPtOverPt = TMath::Abs((mom_gen.Pt() - mom_rec.Pt()) / mom_rec.Pt());
    198197    Float_t deltaR = mom_gen.DeltaR(mom_rec);
    199198
    200     if (status != 1) continue;
    201     if (pdgCode != 22) continue;
    202     if (dPtOverPt > 0.5) continue;
    203     if (deltaR > 0.1) continue;
     199    if(status != 1) continue;
     200    if(pdgCode != 22) continue;
     201    if(dPtOverPt > 0.5) continue;
     202    if(deltaR > 0.1) continue;
    204203
    205204    matches = true;
    206205    break;
    207 
    208206  }
    209207
  • modules/PhotonID.h

    re39abb4 r0e7d64a  
    4040{
    4141public:
    42 
    4342  PhotonID();
    4443  ~PhotonID();
     
    4948
    5049private:
    51 
    5250  DelphesFormula *fPromptFormula;
    5351  DelphesFormula *fNonPromptFormula;
    5452  DelphesFormula *fFakeFormula;
    55  
     53
    5654  // import input arrays
    5755  const TObjArray *fInputPhotonArray;
  • modules/PileUpJetID.cc

    re39abb4 r0e7d64a  
    1414#include "classes/DelphesFormula.h"
    1515
     16#include "ExRootAnalysis/ExRootClassifier.h"
     17#include "ExRootAnalysis/ExRootFilter.h"
    1618#include "ExRootAnalysis/ExRootResult.h"
    17 #include "ExRootAnalysis/ExRootFilter.h"
    18 #include "ExRootAnalysis/ExRootClassifier.h"
    19 
     19
     20#include "TFormula.h"
    2021#include "TMath.h"
     22#include "TObjArray.h"
     23#include "TRandom3.h"
    2124#include "TString.h"
    22 #include "TFormula.h"
    23 #include "TRandom3.h"
    24 #include "TObjArray.h"
    2525//#include "TDatabasePDG.h"
    2626#include "TLorentzVector.h"
    2727
    2828#include <algorithm>
    29 #include <stdexcept>
    3029#include <iostream>
    3130#include <sstream>
     31#include <stdexcept>
    3232
    3333using namespace std;
     
    3636
    3737PileUpJetID::PileUpJetID() :
    38   fItJetInputArray(0),fTrackInputArray(0),fNeutralInputArray(0)
    39 {
    40 
     38  fItJetInputArray(0), fTrackInputArray(0), fNeutralInputArray(0)
     39{
    4140}
    4241
     
    4544PileUpJetID::~PileUpJetID()
    4645{
    47 
    4846}
    4947
     
    5755  fUseConstituents = GetInt("UseConstituents", 0);
    5856
    59   fMeanSqDeltaRMaxBarrel = GetDouble("MeanSqDeltaRMaxBarrel",0.1);
    60   fBetaMinBarrel = GetDouble("BetaMinBarrel",0.1);
    61   fMeanSqDeltaRMaxEndcap = GetDouble("MeanSqDeltaRMaxEndcap",0.1);
    62   fBetaMinEndcap = GetDouble("BetaMinEndcap",0.1);
    63   fMeanSqDeltaRMaxForward = GetDouble("MeanSqDeltaRMaxForward",0.1);
     57  fMeanSqDeltaRMaxBarrel = GetDouble("MeanSqDeltaRMaxBarrel", 0.1);
     58  fBetaMinBarrel = GetDouble("BetaMinBarrel", 0.1);
     59  fMeanSqDeltaRMaxEndcap = GetDouble("MeanSqDeltaRMaxEndcap", 0.1);
     60  fBetaMinEndcap = GetDouble("BetaMinEndcap", 0.1);
     61  fMeanSqDeltaRMaxForward = GetDouble("MeanSqDeltaRMaxForward", 0.1);
    6462  fJetPTMinForNeutrals = GetDouble("JetPTMinForNeutrals", 20.0);
    6563  fNeutralPTMin = GetDouble("NeutralPTMin", 2.0);
     
    8280  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
    8381
    84   fNeutralsInPassingJets = ExportArray(GetString("NeutralsInPassingJets","eflowtowers"));
    85 
     82  fNeutralsInPassingJets = ExportArray(GetString("NeutralsInPassingJets", "eflowtowers"));
    8683}
    8784
     
    9592  if(fItTrackInputArray) delete fItTrackInputArray;
    9693  if(fItNeutralInputArray) delete fItNeutralInputArray;
    97 
    9894}
    9995
     
    109105  // loop over all input candidates
    110106  fItJetInputArray->Reset();
    111   while((candidate = static_cast<Candidate*>(fItJetInputArray->Next())))
     107  while((candidate = static_cast<Candidate *>(fItJetInputArray->Next())))
    112108  {
    113109    momentum = candidate->Momentum;
     
    133129    float pt_ann[5];
    134130
    135     for (int i = 0 ; i < 5 ; i++) {
     131    for(int i = 0; i < 5; i++)
     132    {
    136133      pt_ann[i] = 0.;
    137134    }
    138135
    139     if (fUseConstituents) {
     136    if(fUseConstituents)
     137    {
    140138      TIter itConstituents(candidate->GetCandidates());
    141       while((constituent = static_cast<Candidate*>(itConstituents.Next()))) {
     139      while((constituent = static_cast<Candidate *>(itConstituents.Next())))
     140      {
    142141        float pt = constituent->Momentum.Pt();
    143142        float dr = candidate->Momentum.DeltaR(constituent->Momentum);
    144         //      cout << " There exists a constituent with dr=" << dr << endl;
    145         sumpt += pt;
    146         sumdrsqptsq += dr*dr*pt*pt;
    147         sumptsq += pt*pt;
    148         if (constituent->Charge == 0) {
    149           nn++;
    150         } else {
    151           if (constituent->IsRecoPU) {
    152             sumptchpu += pt;
    153           } else {
    154             sumptchpv += pt;
    155           }
    156           sumptch += pt;
    157           nc++;
    158         }
    159         for (int i = 0 ; i < 5 ; i++) {
    160           if (dr > 0.1*i && dr < 0.1*(i+1)) {
    161             pt_ann[i] += pt;
    162           }
    163         }
    164         float tow_sumT = 0;
    165         float tow_sumW = 0;
    166         for (int i = 0 ; i < constituent->ECalEnergyTimePairs.size() ; i++) {
    167           float w = TMath::Sqrt(constituent->ECalEnergyTimePairs[i].first);
    168           if (fAverageEachTower) {
    169             tow_sumT += w*constituent->ECalEnergyTimePairs[i].second;
     143        //      cout << " There exists a constituent with dr=" << dr << endl;
     144        sumpt += pt;
     145        sumdrsqptsq += dr * dr * pt * pt;
     146        sumptsq += pt * pt;
     147        if(constituent->Charge == 0)
     148        {
     149          nn++;
     150        }
     151        else
     152        {
     153          if(constituent->IsRecoPU)
     154          {
     155            sumptchpu += pt;
     156          }
     157          else
     158          {
     159            sumptchpv += pt;
     160          }
     161          sumptch += pt;
     162          nc++;
     163        }
     164        for(int i = 0; i < 5; i++)
     165        {
     166          if(dr > 0.1 * i && dr < 0.1 * (i + 1))
     167          {
     168            pt_ann[i] += pt;
     169          }
     170        }
     171        float tow_sumT = 0;
     172        float tow_sumW = 0;
     173        for(int i = 0; i < constituent->ECalEnergyTimePairs.size(); i++)
     174        {
     175          float w = TMath::Sqrt(constituent->ECalEnergyTimePairs[i].first);
     176          if(fAverageEachTower)
     177          {
     178            tow_sumT += w * constituent->ECalEnergyTimePairs[i].second;
    170179            tow_sumW += w;
    171           } else {
    172             sumT0 += w*constituent->ECalEnergyTimePairs[i].second;
    173             sumT1 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.001);
    174             sumT10 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.010);
    175             sumT20 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.020);
    176             sumT30 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.030);
    177             sumT40 += w*gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second,0.040);
    178             sumWeightsForT += w;
    179             candidate->NTimeHits++;
    180           }
    181         }
    182         if (fAverageEachTower && tow_sumW > 0.) {
    183           sumT0 += tow_sumT;
    184           sumT1 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.001);
    185           sumT10 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0010);
    186           sumT20 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0020);
    187           sumT30 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0030);
    188           sumT40 += tow_sumW*gRandom->Gaus(tow_sumT/tow_sumW,0.0040);
    189           sumWeightsForT += tow_sumW;
    190           candidate->NTimeHits++;
    191         }
    192       }
    193     } else {
     180          }
     181          else
     182          {
     183            sumT0 += w * constituent->ECalEnergyTimePairs[i].second;
     184            sumT1 += w * gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second, 0.001);
     185            sumT10 += w * gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second, 0.010);
     186            sumT20 += w * gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second, 0.020);
     187            sumT30 += w * gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second, 0.030);
     188            sumT40 += w * gRandom->Gaus(constituent->ECalEnergyTimePairs[i].second, 0.040);
     189            sumWeightsForT += w;
     190            candidate->NTimeHits++;
     191          }
     192        }
     193        if(fAverageEachTower && tow_sumW > 0.)
     194        {
     195          sumT0 += tow_sumT;
     196          sumT1 += tow_sumW * gRandom->Gaus(tow_sumT / tow_sumW, 0.001);
     197          sumT10 += tow_sumW * gRandom->Gaus(tow_sumT / tow_sumW, 0.0010);
     198          sumT20 += tow_sumW * gRandom->Gaus(tow_sumT / tow_sumW, 0.0020);
     199          sumT30 += tow_sumW * gRandom->Gaus(tow_sumT / tow_sumW, 0.0030);
     200          sumT40 += tow_sumW * gRandom->Gaus(tow_sumT / tow_sumW, 0.0040);
     201          sumWeightsForT += tow_sumW;
     202          candidate->NTimeHits++;
     203        }
     204      }
     205    }
     206    else
     207    {
    194208      // Not using constituents, using dr
    195209      fItTrackInputArray->Reset();
    196       while ((trk = static_cast<Candidate*>(fItTrackInputArray->Next()))) {
    197         if (trk->Momentum.DeltaR(candidate->Momentum) < fParameterR) {
    198           float pt = trk->Momentum.Pt();
    199           sumpt += pt;
    200           sumptch += pt;
    201           if (trk->IsRecoPU) {
    202             sumptchpu += pt;
    203           } else {
    204             sumptchpv += pt;
    205           }
    206           float dr = candidate->Momentum.DeltaR(trk->Momentum);
    207           sumdrsqptsq += dr*dr*pt*pt;
    208           sumptsq += pt*pt;
    209           nc++;
    210           for (int i = 0 ; i < 5 ; i++) {
    211             if (dr > 0.1*i && dr < 0.1*(i+1)) {
    212               pt_ann[i] += pt;
    213             }
    214           }
    215         }
     210      while((trk = static_cast<Candidate *>(fItTrackInputArray->Next())))
     211      {
     212        if(trk->Momentum.DeltaR(candidate->Momentum) < fParameterR)
     213        {
     214          float pt = trk->Momentum.Pt();
     215          sumpt += pt;
     216          sumptch += pt;
     217          if(trk->IsRecoPU)
     218          {
     219            sumptchpu += pt;
     220          }
     221          else
     222          {
     223            sumptchpv += pt;
     224          }
     225          float dr = candidate->Momentum.DeltaR(trk->Momentum);
     226          sumdrsqptsq += dr * dr * pt * pt;
     227          sumptsq += pt * pt;
     228          nc++;
     229          for(int i = 0; i < 5; i++)
     230          {
     231            if(dr > 0.1 * i && dr < 0.1 * (i + 1))
     232            {
     233              pt_ann[i] += pt;
     234            }
     235          }
     236        }
    216237      }
    217238      fItNeutralInputArray->Reset();
    218       while ((constituent = static_cast<Candidate*>(fItNeutralInputArray->Next()))) {
    219         if (constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR) {
    220           float pt = constituent->Momentum.Pt();
    221           sumpt += pt;
    222           float dr = candidate->Momentum.DeltaR(constituent->Momentum);
    223           sumdrsqptsq += dr*dr*pt*pt;
    224           sumptsq += pt*pt;
    225           nn++;
    226           for (int i = 0 ; i < 5 ; i++) {
    227             if (dr > 0.1*i && dr < 0.1*(i+1)) {
    228             pt_ann[i] += pt;
    229             }
    230           }
    231         }
    232       }
    233     }
    234 
    235     if (sumptch > 0.) {
    236       candidate->Beta = sumptchpv/sumptch;
    237       candidate->BetaStar = sumptchpu/sumptch;
    238     } else {
     239      while((constituent = static_cast<Candidate *>(fItNeutralInputArray->Next())))
     240      {
     241        if(constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR)
     242        {
     243          float pt = constituent->Momentum.Pt();
     244          sumpt += pt;
     245          float dr = candidate->Momentum.DeltaR(constituent->Momentum);
     246          sumdrsqptsq += dr * dr * pt * pt;
     247          sumptsq += pt * pt;
     248          nn++;
     249          for(int i = 0; i < 5; i++)
     250          {
     251            if(dr > 0.1 * i && dr < 0.1 * (i + 1))
     252            {
     253              pt_ann[i] += pt;
     254            }
     255          }
     256        }
     257      }
     258    }
     259
     260    if(sumptch > 0.)
     261    {
     262      candidate->Beta = sumptchpv / sumptch;
     263      candidate->BetaStar = sumptchpu / sumptch;
     264    }
     265    else
     266    {
    239267      candidate->Beta = -999.;
    240268      candidate->BetaStar = -999.;
    241269    }
    242     if (sumptsq > 0.) {
    243       candidate->MeanSqDeltaR = sumdrsqptsq/sumptsq;
    244     } else {
     270    if(sumptsq > 0.)
     271    {
     272      candidate->MeanSqDeltaR = sumdrsqptsq / sumptsq;
     273    }
     274    else
     275    {
    245276      candidate->MeanSqDeltaR = -999.;
    246277    }
    247278    candidate->NCharged = nc;
    248279    candidate->NNeutrals = nn;
    249     if (sumpt > 0.) {
     280    if(sumpt > 0.)
     281    {
    250282      candidate->PTD = TMath::Sqrt(sumptsq) / sumpt;
    251       for (int i = 0 ; i < 5 ; i++) {
    252         candidate->FracPt[i] = pt_ann[i]/sumpt;
    253       }
    254     } else {
     283      for(int i = 0; i < 5; i++)
     284      {
     285        candidate->FracPt[i] = pt_ann[i] / sumpt;
     286      }
     287    }
     288    else
     289    {
    255290      candidate->PTD = -999.;
    256       for (int i = 0 ; i < 5 ; i++) {
     291      for(int i = 0; i < 5; i++)
     292      {
    257293        candidate->FracPt[i] = -999.;
    258294      }
     
    271307
    272308    bool passId = false;
    273     if (candidate->Momentum.Pt() > fJetPTMinForNeutrals && candidate->MeanSqDeltaR > -0.1) {
    274       if (fabs(candidate->Momentum.Eta())<1.5) {
    275         passId = ((candidate->Beta > fBetaMinBarrel) && (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxBarrel));
    276       } else if (fabs(candidate->Momentum.Eta())<4.0) {
    277         passId = ((candidate->Beta > fBetaMinEndcap) && (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxEndcap));
    278       } else {
    279         passId = (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxForward);
    280       }
    281     }
    282 
    283     //    cout << " Pt Eta MeanSqDeltaR Beta PassId " << candidate->Momentum.Pt()
     309    if(candidate->Momentum.Pt() > fJetPTMinForNeutrals && candidate->MeanSqDeltaR > -0.1)
     310    {
     311      if(fabs(candidate->Momentum.Eta()) < 1.5)
     312      {
     313        passId = ((candidate->Beta > fBetaMinBarrel) && (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxBarrel));
     314      }
     315      else if(fabs(candidate->Momentum.Eta()) < 4.0)
     316      {
     317        passId = ((candidate->Beta > fBetaMinEndcap) && (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxEndcap));
     318      }
     319      else
     320      {
     321        passId = (candidate->MeanSqDeltaR < fMeanSqDeltaRMaxForward);
     322      }
     323    }
     324
     325    //    cout << " Pt Eta MeanSqDeltaR Beta PassId " << candidate->Momentum.Pt()
    284326    //   << " " << candidate->Momentum.Eta() << " " << candidate->MeanSqDeltaR << " " << candidate->Beta << " " << passId << endl;
    285327
    286     if (passId) {
    287       if (fUseConstituents) {
    288         TIter itConstituents(candidate->GetCandidates());
    289         while((constituent = static_cast<Candidate*>(itConstituents.Next()))) {
    290           if (constituent->Charge == 0 && constituent->Momentum.Pt() > fNeutralPTMin) {
    291             fNeutralsInPassingJets->Add(constituent);
    292             //      cout << "    Constitutent added Pt Eta Charge " << constituent->Momentum.Pt() << " " << constituent->Momentum.Eta() << " " << constituent->Charge << endl;
    293           }
    294         }
    295       } else { // use DeltaR
    296         fItNeutralInputArray->Reset();
    297         while ((constituent = static_cast<Candidate*>(fItNeutralInputArray->Next()))) {
    298           if (constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR && constituent->Momentum.Pt() > fNeutralPTMin) {
    299             fNeutralsInPassingJets->Add(constituent);
    300             //            cout << "    Constitutent added Pt Eta Charge " << constituent->Momentum.Pt() << " " << constituent->Momentum.Eta() << " " << constituent->Charge << endl;
    301           }
    302         }
    303       }
    304     }
    305 
    306 
     328    if(passId)
     329    {
     330      if(fUseConstituents)
     331      {
     332        TIter itConstituents(candidate->GetCandidates());
     333        while((constituent = static_cast<Candidate *>(itConstituents.Next())))
     334        {
     335          if(constituent->Charge == 0 && constituent->Momentum.Pt() > fNeutralPTMin)
     336          {
     337            fNeutralsInPassingJets->Add(constituent);
     338            //      cout << "    Constitutent added Pt Eta Charge " << constituent->Momentum.Pt() << " " << constituent->Momentum.Eta() << " " << constituent->Charge << endl;
     339          }
     340        }
     341      }
     342      else
     343      { // use DeltaR
     344        fItNeutralInputArray->Reset();
     345        while((constituent = static_cast<Candidate *>(fItNeutralInputArray->Next())))
     346        {
     347          if(constituent->Momentum.DeltaR(candidate->Momentum) < fParameterR && constituent->Momentum.Pt() > fNeutralPTMin)
     348          {
     349            fNeutralsInPassingJets->Add(constituent);
     350            //            cout << "    Constitutent added Pt Eta Charge " << constituent->Momentum.Pt() << " " << constituent->Momentum.Eta() << " " << constituent->Charge << endl;
     351          }
     352        }
     353      }
     354    }
    307355  }
    308356}
  • modules/PileUpJetID.h

    re39abb4 r0e7d64a  
    1010 */
    1111
    12 
    1312#include "classes/DelphesModule.h"
    1413
     
    2120{
    2221public:
    23 
    2422  PileUpJetID();
    2523  ~PileUpJetID();
     
    3028
    3129private:
    32 
    3330  Double_t fJetPTMin;
    3431  Double_t fParameterR;
     
    8885  // If set to false, uses everything within dR < fParameterR even if in other jets &c.
    8986  // Results should be very similar for PF
    90   Int_t fUseConstituents; 
     87  Int_t fUseConstituents;
    9188
    9289  Bool_t fAverageEachTower;
     
    9794
    9895  const TObjArray *fTrackInputArray; // SCZ
    99   const TObjArray *fNeutralInputArray; 
     96  const TObjArray *fNeutralInputArray;
    10097
    10198  TIterator *fItTrackInputArray; // SCZ
     
    105102  TObjArray *fNeutralsInPassingJets; // SCZ
    106103
    107 
    108104  ClassDef(PileUpJetID, 2)
    109105};
  • modules/PileUpMerger.cc

    re39abb4 r0e7d64a  
    2929#include "classes/DelphesClasses.h"
    3030#include "classes/DelphesFactory.h"
     31#include "classes/DelphesPileUpReader.h"
    3132#include "classes/DelphesTF2.h"
    32 #include "classes/DelphesPileUpReader.h"
    33 
     33
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3436#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    37 
     37
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
    3841#include "TMath.h"
     42#include "TObjArray.h"
     43#include "TRandom3.h"
    3944#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4545
    4646#include <algorithm>
    47 #include <stdexcept>
    4847#include <iostream>
    4948#include <sstream>
     49#include <stdexcept>
    5050
    5151using namespace std;
     
    5959}
    6060
    61 
    6261//------------------------------------------------------------------------------
    6362
     
    7574  fPileUpDistribution = GetInt("PileUpDistribution", 0);
    7675
    77   fMeanPileUp  = GetDouble("MeanPileUp", 10);
     76  fMeanPileUp = GetDouble("MeanPileUp", 10);
    7877
    7978  fZVertexSpread = GetDouble("ZVertexSpread", 0.15);
     
    135134  dt0 = -1.0e6;
    136135
    137   dt *= c_light*1.0E3; // necessary in order to make t in mm/c
     136  dt *= c_light * 1.0E3; // necessary in order to make t in mm/c
    138137  dz *= 1.0E3; // necessary in order to make z in mm
    139138
     
    150149  vertex = factory->NewCandidate();
    151150
    152   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     151  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    153152  {
    154153    vx += candidate->Position.X();
     
    159158
    160159    // take postion and time from first stable particle
    161     if (dz0 < -999999.0)
     160    if(dz0 < -999999.0)
    162161      dz0 = z;
    163     if (dt0 < -999999.0)
     162    if(dt0 < -999999.0)
    164163      dt0 = t;
    165164
     
    172171    fParticleOutputArray->Add(candidate);
    173172
    174     if(TMath::Abs(candidate->Charge) >  1.0E-9)
     173    if(TMath::Abs(candidate->Charge) > 1.0E-9)
    175174    {
    176175      nch++;
    177       sumpt2 += pt*pt;
     176      sumpt2 += pt * pt;
    178177      vertex->AddCandidate(candidate);
    179178    }
     
    198197  switch(fPileUpDistribution)
    199198  {
    200     case 0:
    201       numberOfEvents = gRandom->Poisson(fMeanPileUp);
    202       break;
    203     case 1:
    204       numberOfEvents = gRandom->Integer(2*fMeanPileUp + 1);
    205       break;
    206     case 2:
    207       numberOfEvents = fMeanPileUp;
    208       break;
    209     default:
    210       numberOfEvents = gRandom->Poisson(fMeanPileUp);
    211       break;
     199  case 0:
     200    numberOfEvents = gRandom->Poisson(fMeanPileUp);
     201    break;
     202  case 1:
     203    numberOfEvents = gRandom->Integer(2 * fMeanPileUp + 1);
     204    break;
     205  case 2:
     206    numberOfEvents = fMeanPileUp;
     207    break;
     208  default:
     209    numberOfEvents = gRandom->Poisson(fMeanPileUp);
     210    break;
    212211  }
    213212
    214213  allEntries = fReader->GetEntries();
    215 
    216214
    217215  for(event = 0; event < numberOfEvents; ++event)
     
    219217    do
    220218    {
    221       entry = TMath::Nint(gRandom->Rndm()*allEntries);
    222     }
    223     while(entry >= allEntries);
     219      entry = TMath::Nint(gRandom->Rndm() * allEntries);
     220    } while(entry >= allEntries);
    224221
    225222    fReader->ReadEntry(entry);
    226223
    227    // --- Pile-up vertex smearing
     224    // --- Pile-up vertex smearing
    228225
    229226    fFunction->GetRandom2(dz, dt);
    230227
    231     dt *= c_light*1.0E3; // necessary in order to make t in mm/c
     228    dt *= c_light * 1.0E3; // necessary in order to make t in mm/c
    232229    dz *= 1.0E3; // necessary in order to make z in mm
    233230
     
    252249
    253250      pdgParticle = pdg->GetParticle(pid);
    254       candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     251      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    255252      candidate->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
    256253
     
    271268
    272269      ++numberOfParticles;
    273       if(TMath::Abs(candidate->Charge) >  1.0E-9)
     270      if(TMath::Abs(candidate->Charge) > 1.0E-9)
    274271      {
    275272        nch++;
    276         sumpt2 += pt*pt;
     273        sumpt2 += pt * pt;
    277274        vertex->AddCandidate(candidate);
    278275      }
     
    299296
    300297    fVertexOutputArray->Add(vertex);
    301 
    302298  }
    303299}
  • modules/PileUpMerger.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  PileUpMerger();
    4140  ~PileUpMerger();
     
    4645
    4746private:
    48 
    4947  Int_t fPileUpDistribution;
    5048  Double_t fMeanPileUp;
  • modules/PileUpMergerPythia8.cc

    re39abb4 r0e7d64a  
    2929#include "classes/DelphesClasses.h"
    3030#include "classes/DelphesFactory.h"
     31#include "classes/DelphesPileUpReader.h"
    3132#include "classes/DelphesTF2.h"
    32 #include "classes/DelphesPileUpReader.h"
    33 
     33
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3436#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3737
    3838#include "Pythia.h"
    3939
     40#include "TDatabasePDG.h"
     41#include "TFormula.h"
     42#include "TLorentzVector.h"
    4043#include "TMath.h"
     44#include "TObjArray.h"
     45#include "TRandom3.h"
    4146#include "TString.h"
    42 #include "TFormula.h"
    43 #include "TRandom3.h"
    44 #include "TObjArray.h"
    45 #include "TDatabasePDG.h"
    46 #include "TLorentzVector.h"
    4747
    4848#include <algorithm>
    49 #include <stdexcept>
    5049#include <iostream>
    5150#include <sstream>
     51#include <stdexcept>
    5252
    5353using namespace std;
     
    7676  fPileUpDistribution = GetInt("PileUpDistribution", 0);
    7777
    78   fMeanPileUp  = GetDouble("MeanPileUp", 10);
     78  fMeanPileUp = GetDouble("MeanPileUp", 10);
    7979
    8080  fZVertexSpread = GetDouble("ZVertexSpread", 0.15);
     
    133133  fFunction->GetRandom2(dz, dt);
    134134
    135   dt *= c_light*1.0E3; // necessary in order to make t in mm/c
     135  dt *= c_light * 1.0E3; // necessary in order to make t in mm/c
    136136  dz *= 1.0E3; // necessary in order to make z in mm
    137137  vx = 0.0;
    138138  vy = 0.0;
    139139  numberOfParticles = fInputArray->GetEntriesFast();
    140   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     140  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    141141  {
    142142    vx += candidate->Position.X();
     
    165165  switch(fPileUpDistribution)
    166166  {
    167     case 0:
    168       numberOfEvents = gRandom->Poisson(fMeanPileUp);
    169       break;
    170     case 1:
    171       numberOfEvents = gRandom->Integer(2*fMeanPileUp + 1);
    172       break;
    173     default:
    174       numberOfEvents = gRandom->Poisson(fMeanPileUp);
    175       break;
     167  case 0:
     168    numberOfEvents = gRandom->Poisson(fMeanPileUp);
     169    break;
     170  case 1:
     171    numberOfEvents = gRandom->Integer(2 * fMeanPileUp + 1);
     172    break;
     173  default:
     174    numberOfEvents = gRandom->Poisson(fMeanPileUp);
     175    break;
    176176  }
    177177
    178178  for(event = 0; event < numberOfEvents; ++event)
    179179  {
    180     while(!fPythia->next());
    181 
    182    // --- Pile-up vertex smearing
     180    while(!fPythia->next())
     181      ;
     182
     183    // --- Pile-up vertex smearing
    183184
    184185    fFunction->GetRandom2(dz, dt);
    185186
    186     dt *= c_light*1.0E3; // necessary in order to make t in mm/c
     187    dt *= c_light * 1.0E3; // necessary in order to make t in mm/c
    187188    dz *= 1.0E3; // necessary in order to make z in mm
    188189
     
    201202
    202203      pid = particle.id();
    203       px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.e();
    204       x = particle.xProd(); y = particle.yProd(); z = particle.zProd(); t = particle.tProd();
     204      px = particle.px();
     205      py = particle.py();
     206      pz = particle.pz();
     207      e = particle.e();
     208      x = particle.xProd();
     209      y = particle.yProd();
     210      z = particle.zProd();
     211      t = particle.tProd();
    205212
    206213      candidate = factory->NewCandidate();
     
    211218
    212219      pdgParticle = pdg->GetParticle(pid);
    213       candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     220      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    214221      candidate->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
    215222
  • modules/PileUpMergerPythia8.h

    re39abb4 r0e7d64a  
    3535namespace Pythia8
    3636{
    37  class Pythia;
     37class Pythia;
    3838};
    3939
     
    4141{
    4242public:
    43 
    4443  PileUpMergerPythia8();
    4544  ~PileUpMergerPythia8();
     
    5049
    5150private:
    52 
    5351  Int_t fPileUpDistribution;
    5452  Double_t fMeanPileUp;
  • modules/RecoPuFilter.cc

    re39abb4 r0e7d64a  
    3232#include "classes/DelphesFormula.h"
    3333
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3436#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3737
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
    3841#include "TMath.h"
     42#include "TObjArray.h"
     43#include "TRandom3.h"
    3944#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4545
    4646#include <algorithm>
    47 #include <stdexcept>
    4847#include <iostream>
    4948#include <sstream>
     49#include <stdexcept>
    5050
    5151using namespace std;
     
    9797
    9898  fItInputArray->Reset();
    99   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     99  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    100100  {
    101101    if(candidate->IsRecoPU) continue;
     
    103103  }
    104104}
    105 
  • modules/RecoPuFilter.h

    re39abb4 r0e7d64a  
    4040{
    4141public:
    42 
    4342  RecoPuFilter();
    4443  ~RecoPuFilter();
     
    4948
    5049private:
    51 
    5250  TIterator *fItInputArray; //!
    5351
  • modules/RunPUPPI.cc

    re39abb4 r0e7d64a  
    11#include "modules/RunPUPPI.h"
    22
    3 #include "PUPPI/RecoObj2.hh"
    43#include "PUPPI/AlgoObj.hh"
    54#include "PUPPI/PuppiContainer.hh"
     5#include "PUPPI/RecoObj2.hh"
    66
    77#include "fastjet/PseudoJet.hh"
     
    1111#include "classes/DelphesFormula.h"
    1212
    13 #include <algorithm>
    14 #include <stdexcept>
     13#include <algorithm>
    1514#include <iostream>
    1615#include <sstream>
     16#include <stdexcept>
    1717#include <vector>
    1818
     
    2222//------------------------------------------------------------------------------
    2323RunPUPPI::RunPUPPI() :
    24   fItTrackInputArray(0), 
     24  fItTrackInputArray(0),
    2525  fItNeutralInputArray(0)
    26 {}
    27 
    28 //------------------------------------------------------------------------------
    29 RunPUPPI::~RunPUPPI(){}
    30 
    31 //------------------------------------------------------------------------------
    32 
    33 void RunPUPPI::Init(){
     26{
     27}
     28
     29//------------------------------------------------------------------------------
     30RunPUPPI::~RunPUPPI() {}
     31
     32//------------------------------------------------------------------------------
     33
     34void RunPUPPI::Init()
     35{
    3436  // input collection
    35   fTrackInputArray     = ImportArray(GetString("TrackInputArray", "Calorimeter/towers"));
    36   fItTrackInputArray   = fTrackInputArray->MakeIterator();
    37   fNeutralInputArray   = ImportArray(GetString("NeutralInputArray", "Calorimeter/towers"));
     37  fTrackInputArray = ImportArray(GetString("TrackInputArray", "Calorimeter/towers"));
     38  fItTrackInputArray = fTrackInputArray->MakeIterator();
     39  fNeutralInputArray = ImportArray(GetString("NeutralInputArray", "Calorimeter/towers"));
    3840  fItNeutralInputArray = fNeutralInputArray->MakeIterator();
    39   fPVInputArray        = ImportArray(GetString("PVInputArray", "PV"));
    40   fPVItInputArray      = fPVInputArray->MakeIterator();
    41   // puppi parameters                                 
    42   fApplyNoLep     = GetBool("UseNoLep", true);   
     41  fPVInputArray = ImportArray(GetString("PVInputArray", "PV"));
     42  fPVItInputArray = fPVInputArray->MakeIterator();
     43  // puppi parameters
     44  fApplyNoLep = GetBool("UseNoLep", true);
    4345  fMinPuppiWeight = GetDouble("MinPuppiWeight", 0.01);
    44   fUseExp         = GetBool("UseExp", false);
     46  fUseExp = GetBool("UseExp", false);
    4547  // read eta min ranges
    4648  ExRootConfParam param = GetParam("EtaMinBin");
     
    5557  fPtMinBin.clear();
    5658  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fPtMinBin.push_back(param[iMap].GetDouble());
    57   // read cone size                                                                                                                                                           
     59  // read cone size
    5860  param = GetParam("ConeSizeBin");
    5961  fConeSizeBin.clear();
    6062  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fConeSizeBin.push_back(param[iMap].GetDouble());
    61   // read RMS min pt                                                                                                                                             
     63  // read RMS min pt
    6264  param = GetParam("RMSPtMinBin");
    6365  fRMSPtMinBin.clear();
     
    7577  fNeutralPtSlope.clear();
    7678  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fNeutralPtSlope.push_back(param[iMap].GetDouble());
    77   // read apply chs                                                                                                                                                           
     79  // read apply chs
    7880  //param = GetParam("ApplyCHS");
    7981  //fApplyCHS.clear();
     
    8789  fApplyLowPUCorr.clear();
    8890  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fApplyLowPUCorr.push_back(param[iMap].GetBool());
    89   // read metric id                                                                                                                                                         
     91  // read metric id
    9092  param = GetParam("MetricId");
    9193  fMetricId.clear();
     
    9698  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fCombId.push_back(param[iMap].GetInt());
    9799  // create output array
    98   fOutputArray        = ExportArray(GetString("OutputArray", "puppiParticles"));
    99   fOutputTrackArray   = ExportArray(GetString("OutputArrayTracks", "puppiTracks"));
     100  fOutputArray = ExportArray(GetString("OutputArray", "puppiParticles"));
     101  fOutputTrackArray = ExportArray(GetString("OutputArrayTracks", "puppiTracks"));
    100102  fOutputNeutralArray = ExportArray(GetString("OutputArrayNeutrals", "puppiNeutrals"));
    101103  // Create algorithm list for puppi
    102104  std::vector<AlgoObj> puppiAlgo;
    103   if(puppiAlgo.empty()){
     105  if(puppiAlgo.empty())
     106  {
    104107    if(!(fEtaMinBin.size() == fEtaMaxBin.size() and fEtaMinBin.size() == fPtMinBin.size() and fEtaMinBin.size() == fConeSizeBin.size() and fEtaMinBin.size() == fRMSPtMinBin.size()
    105          and fEtaMinBin.size() == fRMSScaleFactorBin.size() and fEtaMinBin.size() == fNeutralMinEBin.size() and  fEtaMinBin.size() == fNeutralPtSlope.size()
    106          and fEtaMinBin.size() == fUseCharged.size()
    107          and fEtaMinBin.size() == fApplyLowPUCorr.size() and fEtaMinBin.size() == fMetricId.size())) {
    108       std::cerr<<" Error in PUPPI configuration, algo info should have the same size --> exit from the code"<<std::endl;
     108         and fEtaMinBin.size() == fRMSScaleFactorBin.size() and fEtaMinBin.size() == fNeutralMinEBin.size() and fEtaMinBin.size() == fNeutralPtSlope.size()
     109         and fEtaMinBin.size() == fUseCharged.size()
     110         and fEtaMinBin.size() == fApplyLowPUCorr.size() and fEtaMinBin.size() == fMetricId.size()))
     111    {
     112      std::cerr << " Error in PUPPI configuration, algo info should have the same size --> exit from the code" << std::endl;
    109113      std::exit(EXIT_FAILURE);
    110114    }
    111115  }
    112   for( size_t iAlgo =  0 ; iAlgo < fEtaMinBin.size() ; iAlgo++){
    113     AlgoObj algoTmp ;
    114     algoTmp.etaMin            = fEtaMinBin.at(iAlgo);
    115     algoTmp.etaMax            = fEtaMaxBin.at(iAlgo);
    116     algoTmp.ptMin             = fPtMinBin.at(iAlgo);
    117     algoTmp.minNeutralPt      = fNeutralMinEBin.at(iAlgo);
     116  for(size_t iAlgo = 0; iAlgo < fEtaMinBin.size(); iAlgo++)
     117  {
     118    AlgoObj algoTmp;
     119    algoTmp.etaMin = fEtaMinBin.at(iAlgo);
     120    algoTmp.etaMax = fEtaMaxBin.at(iAlgo);
     121    algoTmp.ptMin = fPtMinBin.at(iAlgo);
     122    algoTmp.minNeutralPt = fNeutralMinEBin.at(iAlgo);
    118123    algoTmp.minNeutralPtSlope = fNeutralPtSlope.at(iAlgo);
    119124    //Eta Extrapolation stuff is missing
    120125    //Loop through file requiring algos for same bins to be adjacent
    121     while(iAlgo < fEtaMinBin.size() and algoTmp.etaMin == fEtaMinBin.at(iAlgo) and algoTmp.etaMax == fEtaMaxBin.at(iAlgo)) {
     126    while(iAlgo < fEtaMinBin.size() and algoTmp.etaMin == fEtaMinBin.at(iAlgo) and algoTmp.etaMax == fEtaMaxBin.at(iAlgo))
     127    {
    122128      AlgoSubObj algoSubTmp;
    123       algoSubTmp.metricId          = fMetricId.at(iAlgo);
    124       algoSubTmp.useCharged        = fUseCharged.at(iAlgo);
    125       algoSubTmp.applyLowPUCorr    = fApplyLowPUCorr.at(iAlgo);
    126       algoSubTmp.combId            = fCombId.at(iAlgo);
    127       algoSubTmp.coneSize          = fConeSizeBin.at(iAlgo);
    128       algoSubTmp.rmsPtMin          = fRMSPtMinBin.at(iAlgo);
    129       algoSubTmp.rmsScaleFactor    = fRMSScaleFactorBin.at(iAlgo);
     129      algoSubTmp.metricId = fMetricId.at(iAlgo);
     130      algoSubTmp.useCharged = fUseCharged.at(iAlgo);
     131      algoSubTmp.applyLowPUCorr = fApplyLowPUCorr.at(iAlgo);
     132      algoSubTmp.combId = fCombId.at(iAlgo);
     133      algoSubTmp.coneSize = fConeSizeBin.at(iAlgo);
     134      algoSubTmp.rmsPtMin = fRMSPtMinBin.at(iAlgo);
     135      algoSubTmp.rmsScaleFactor = fRMSScaleFactorBin.at(iAlgo);
    130136      algoTmp.subAlgos.push_back(algoSubTmp);
    131137      iAlgo++;
    132138    }
    133139    iAlgo--;
    134     //if(std::find(puppiAlgo.begin(),puppiAlgo.end(),algoTmp) != puppiAlgo.end()) continue;   
    135     puppiAlgo.push_back(algoTmp);     
    136   }
    137   fPuppi  = new PuppiContainer(true,fUseExp,fMinPuppiWeight,puppiAlgo);
    138 }
    139 
    140 //------------------------------------------------------------------------------
    141 
    142 void RunPUPPI::Finish(){
    143   if(fItTrackInputArray)   delete fItTrackInputArray;
     140    //if(std::find(puppiAlgo.begin(),puppiAlgo.end(),algoTmp) != puppiAlgo.end()) continue;
     141    puppiAlgo.push_back(algoTmp);
     142  }
     143  fPuppi = new PuppiContainer(true, fUseExp, fMinPuppiWeight, puppiAlgo);
     144}
     145
     146//------------------------------------------------------------------------------
     147
     148void RunPUPPI::Finish()
     149{
     150  if(fItTrackInputArray) delete fItTrackInputArray;
    144151  if(fItNeutralInputArray) delete fItNeutralInputArray;
    145152  if(fPuppi) delete fPuppi;
     
    148155//------------------------------------------------------------------------------
    149156
    150 void RunPUPPI::Process(){
     157void RunPUPPI::Process()
     158{
    151159
    152160  Candidate *candidate, *particle;
     
    156164
    157165  // loop over input objects
    158   fItTrackInputArray   ->Reset();
    159   fItNeutralInputArray ->Reset();
    160   fPVItInputArray      ->Reset();
     166  fItTrackInputArray->Reset();
     167  fItNeutralInputArray->Reset();
     168  fPVItInputArray->Reset();
    161169
    162170  std::vector<Candidate *> InputParticles;
    163171  InputParticles.clear();
    164172
    165   // take the leading vertex 
     173  // take the leading vertex
    166174  float PVZ = 0.;
    167   Candidate *pv = static_cast<Candidate*>(fPVItInputArray->Next());
    168   if (pv) PVZ = pv->Position.Z();
     175  Candidate *pv = static_cast<Candidate *>(fPVItInputArray->Next());
     176  if(pv) PVZ = pv->Position.Z();
    169177  // Fill input particles for puppi
    170178  std::vector<RecoObj> puppiInputVector;
    171179  puppiInputVector.clear();
    172   int lNBad  = 0;
     180  int lNBad = 0;
    173181  // Loop on charge track candidate
    174   while((candidate = static_cast<Candidate*>(fItTrackInputArray->Next()))){   
    175       momentum = candidate->Momentum;
    176       RecoObj curRecoObj;
    177       curRecoObj.pt  = momentum.Pt();
    178       curRecoObj.eta = momentum.Eta();
    179       curRecoObj.phi = momentum.Phi();
    180       curRecoObj.m   = momentum.M(); 
    181       particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));//if(fApplyNoLep && TMath::Abs(candidate->PID) == 11) continue; //Dumb cut to minimize the nolepton on electron
    182       //if(fApplyNoLep && TMath::Abs(candidate->PID) == 13) continue;
    183       if (candidate->IsRecoPU and candidate->Charge !=0) { // if it comes fromPU vertexes after the resolution smearing and the dZ matching within resolution
    184         lNBad++;
    185         curRecoObj.id    = 2;
    186         curRecoObj.vtxId = 0.7*(fPVInputArray->GetEntries()); //Hack apply reco vtx efficiency of 70% for calibration
    187         if(TMath::Abs(candidate->PID) == 11)      curRecoObj.pfType = 2;
    188         else if(TMath::Abs(candidate->PID) == 13) curRecoObj.pfType = 3;
    189         else if(TMath::Abs(candidate->PID) == 22) curRecoObj.pfType = 4;
    190         else curRecoObj.pfType = 1;
    191         curRecoObj.dZ = particle->Position.Z()-PVZ;
    192       }
    193       else if(!candidate->IsRecoPU && candidate->Charge !=0) {
    194         curRecoObj.id    = 1;  // charge from LV
    195         curRecoObj.vtxId = 1; // from PV
    196         if(TMath::Abs(candidate->PID) == 11)      curRecoObj.pfType = 2;
    197         else if(TMath::Abs(candidate->PID) == 13) curRecoObj.pfType = 3;
    198         else if(TMath::Abs(candidate->PID) == 22) curRecoObj.pfType = 4;
    199         else curRecoObj.pfType = 1;
    200         curRecoObj.dZ = particle->Position.Z()-PVZ;
    201       }
    202       else {
    203         std::cerr<<" RunPUPPI: problem with a charged track --> it has charge 0 "<<std::endl;
    204         continue;
    205       }
    206 
    207       puppiInputVector.push_back(curRecoObj);
    208       InputParticles.push_back(candidate);
    209   }
    210 
    211   // Loop on neutral calo cells
    212   while((candidate = static_cast<Candidate*>(fItNeutralInputArray->Next()))){
    213       momentum = candidate->Momentum;
    214       RecoObj curRecoObj;
    215       curRecoObj.pt  = momentum.Pt();
    216       curRecoObj.eta = momentum.Eta();
    217       curRecoObj.phi = momentum.Phi();
    218       curRecoObj.m   = momentum.M();
    219       curRecoObj.charge = 0;
    220       particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
    221       if(candidate->Charge == 0){
    222         curRecoObj.id    = 0; // neutrals have id==0
    223         curRecoObj.vtxId = 0; // neutrals have vtxId==0
    224         if(TMath::Abs(candidate->PID) == 11)      curRecoObj.pfType = 2;
    225         else if(TMath::Abs(candidate->PID) == 13) curRecoObj.pfType = 3;
    226         else if(TMath::Abs(candidate->PID) == 22) curRecoObj.pfType = 4;
    227         else curRecoObj.pfType = 5;
    228         curRecoObj.dZ = particle->Position.Z()-PVZ;
    229       }
    230       else{
    231         std::cerr<<" RunPUPPI: problem with a neutrals cells --> it has charge !=0 "<<std::endl;
    232         continue;
    233       }
    234       puppiInputVector.push_back(curRecoObj);
    235       InputParticles.push_back(candidate);
     182  while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
     183  {
     184    momentum = candidate->Momentum;
     185    RecoObj curRecoObj;
     186    curRecoObj.pt = momentum.Pt();
     187    curRecoObj.eta = momentum.Eta();
     188    curRecoObj.phi = momentum.Phi();
     189    curRecoObj.m = momentum.M();
     190    particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0)); //if(fApplyNoLep && TMath::Abs(candidate->PID) == 11) continue; //Dumb cut to minimize the nolepton on electron
     191    //if(fApplyNoLep && TMath::Abs(candidate->PID) == 13) continue;
     192    if(candidate->IsRecoPU and candidate->Charge != 0)
     193    { // if it comes fromPU vertexes after the resolution smearing and the dZ matching within resolution
     194      lNBad++;
     195      curRecoObj.id = 2;
     196      curRecoObj.vtxId = 0.7 * (fPVInputArray->GetEntries()); //Hack apply reco vtx efficiency of 70% for calibration
     197      if(TMath::Abs(candidate->PID) == 11)
     198        curRecoObj.pfType = 2;
     199      else if(TMath::Abs(candidate->PID) == 13)
     200        curRecoObj.pfType = 3;
     201      else if(TMath::Abs(candidate->PID) == 22)
     202        curRecoObj.pfType = 4;
     203      else
     204        curRecoObj.pfType = 1;
     205      curRecoObj.dZ = particle->Position.Z() - PVZ;
     206    }
     207    else if(!candidate->IsRecoPU && candidate->Charge != 0)
     208    {
     209      curRecoObj.id = 1; // charge from LV
     210      curRecoObj.vtxId = 1; // from PV
     211      if(TMath::Abs(candidate->PID) == 11)
     212        curRecoObj.pfType = 2;
     213      else if(TMath::Abs(candidate->PID) == 13)
     214        curRecoObj.pfType = 3;
     215      else if(TMath::Abs(candidate->PID) == 22)
     216        curRecoObj.pfType = 4;
     217      else
     218        curRecoObj.pfType = 1;
     219      curRecoObj.dZ = particle->Position.Z() - PVZ;
     220    }
     221    else
     222    {
     223      std::cerr << " RunPUPPI: problem with a charged track --> it has charge 0 " << std::endl;
     224      continue;
     225    }
     226
     227    puppiInputVector.push_back(curRecoObj);
     228    InputParticles.push_back(candidate);
     229  }
     230
     231  // Loop on neutral calo cells
     232  while((candidate = static_cast<Candidate *>(fItNeutralInputArray->Next())))
     233  {
     234    momentum = candidate->Momentum;
     235    RecoObj curRecoObj;
     236    curRecoObj.pt = momentum.Pt();
     237    curRecoObj.eta = momentum.Eta();
     238    curRecoObj.phi = momentum.Phi();
     239    curRecoObj.m = momentum.M();
     240    curRecoObj.charge = 0;
     241    particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     242    if(candidate->Charge == 0)
     243    {
     244      curRecoObj.id = 0; // neutrals have id==0
     245      curRecoObj.vtxId = 0; // neutrals have vtxId==0
     246      if(TMath::Abs(candidate->PID) == 11)
     247        curRecoObj.pfType = 2;
     248      else if(TMath::Abs(candidate->PID) == 13)
     249        curRecoObj.pfType = 3;
     250      else if(TMath::Abs(candidate->PID) == 22)
     251        curRecoObj.pfType = 4;
     252      else
     253        curRecoObj.pfType = 5;
     254      curRecoObj.dZ = particle->Position.Z() - PVZ;
     255    }
     256    else
     257    {
     258      std::cerr << " RunPUPPI: problem with a neutrals cells --> it has charge !=0 " << std::endl;
     259      continue;
     260    }
     261    puppiInputVector.push_back(curRecoObj);
     262    InputParticles.push_back(candidate);
    236263  }
    237264  // Create PUPPI container
     
    241268
    242269  // Loop on final particles
    243   for (std::vector<PseudoJet>::iterator it = puppiParticles.begin() ; it != puppiParticles.end() ; it++) {
    244     if(it->user_index() <= int(InputParticles.size())){     
     270  for(std::vector<PseudoJet>::iterator it = puppiParticles.begin(); it != puppiParticles.end(); it++)
     271  {
     272    if(it->user_index() <= int(InputParticles.size()))
     273    {
    245274      candidate = static_cast<Candidate *>(InputParticles.at(it->user_index())->Clone());
    246       candidate->Momentum.SetPxPyPzE(it->px(),it->py(),it->pz(),it->e());
     275      candidate->Momentum.SetPxPyPzE(it->px(), it->py(), it->pz(), it->e());
    247276      fOutputArray->Add(candidate);
    248       if( puppiInputVector.at(it->user_index()).id == 1 or puppiInputVector.at(it->user_index()).id == 2) fOutputTrackArray->Add(candidate);
    249       else if (puppiInputVector.at(it->user_index()).id == 0) fOutputNeutralArray->Add(candidate);
    250     }
    251     else{
    252       std::cerr<<" particle not found in the input Array --> skip "<<std::endl;
     277      if(puppiInputVector.at(it->user_index()).id == 1 or puppiInputVector.at(it->user_index()).id == 2)
     278        fOutputTrackArray->Add(candidate);
     279      else if(puppiInputVector.at(it->user_index()).id == 0)
     280        fOutputNeutralArray->Add(candidate);
     281    }
     282    else
     283    {
     284      std::cerr << " particle not found in the input Array --> skip " << std::endl;
    253285      continue;
    254     }     
    255   }
    256 
    257 }
     286    }
     287  }
     288}
  • modules/RunPUPPI.h

    re39abb4 r0e7d64a  
    99class PuppiContainer;
    1010
    11 class RunPUPPI: public DelphesModule {
     11class RunPUPPI: public DelphesModule
     12{
    1213
    13  public:
    14 
     14public:
    1515  RunPUPPI();
    1616  ~RunPUPPI();
     
    1919  void Process();
    2020  void Finish();
    21  
    22  private:
    2321
     22private:
    2423  TIterator *fItTrackInputArray;
    2524  TIterator *fItNeutralInputArray; //!
    26   TIterator *fPVItInputArray; //!                                                                                                                                                     
    27  
     25  TIterator *fPVItInputArray; //!
     26
    2827  const TObjArray *fTrackInputArray;
    2928  const TObjArray *fNeutralInputArray; //!
    30   const TObjArray *fPVInputArray; //!                                                                                                                                                     
    31   PuppiContainer* fPuppi;
     29  const TObjArray *fPVInputArray; //!
     30  PuppiContainer *fPuppi;
    3231  // puppi parameters
    3332  bool fApplyNoLep;
    3433  double fMinPuppiWeight;
    3534  bool fUseExp;
    36  
    37   std::vector<float> fEtaMinBin ;
    38   std::vector<float> fEtaMaxBin ;
    39   std::vector<float> fPtMinBin ;
    40   std::vector<float> fConeSizeBin ;
    41   std::vector<float> fRMSPtMinBin ;
    42   std::vector<float> fRMSScaleFactorBin ;
     35
     36  std::vector<float> fEtaMinBin;
     37  std::vector<float> fEtaMaxBin;
     38  std::vector<float> fPtMinBin;
     39  std::vector<float> fConeSizeBin;
     40  std::vector<float> fRMSPtMinBin;
     41  std::vector<float> fRMSScaleFactorBin;
    4342  std::vector<float> fNeutralMinEBin;
    4443  std::vector<float> fNeutralPtSlope;
    45   std::vector<bool>  fApplyCHS;
    46   std::vector<bool>  fUseCharged;
    47   std::vector<bool>  fApplyLowPUCorr;
    48   std::vector<int>   fMetricId;
    49   std::vector<int>   fCombId;
     44  std::vector<bool> fApplyCHS;
     45  std::vector<bool> fUseCharged;
     46  std::vector<bool> fApplyLowPUCorr;
     47  std::vector<int> fMetricId;
     48  std::vector<int> fCombId;
    5049
    5150  TObjArray *fOutputArray;
  • modules/SimpleCalorimeter.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class SimpleCalorimeter
    2120 *
     
    3332#include "classes/DelphesFormula.h"
    3433
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3536#include "ExRootAnalysis/ExRootResult.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    37 #include "ExRootAnalysis/ExRootClassifier.h"
    38 
     37
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
    3941#include "TMath.h"
     42#include "TObjArray.h"
     43#include "TRandom3.h"
    4044#include "TString.h"
    41 #include "TFormula.h"
    42 #include "TRandom3.h"
    43 #include "TObjArray.h"
    44 #include "TDatabasePDG.h"
    45 #include "TLorentzVector.h"
    4645
    4746#include <algorithm>
    48 #include <stdexcept>
    4947#include <iostream>
    5048#include <sstream>
     49#include <stdexcept>
    5150
    5251using namespace std;
     
    5857  fItParticleInputArray(0), fItTrackInputArray(0)
    5958{
    60  
     59
    6160  fResolutionFormula = new DelphesFormula;
    6261  fTowerTrackArray = new TObjArray;
    6362  fItTowerTrackArray = fTowerTrackArray->MakeIterator();
    64  
    6563}
    6664
     
    6967SimpleCalorimeter::~SimpleCalorimeter()
    7068{
    71  
     69
    7270  if(fResolutionFormula) delete fResolutionFormula;
    7371  if(fTowerTrackArray) delete fTowerTrackArray;
    7472  if(fItTowerTrackArray) delete fItTowerTrackArray;
    75  
    7673}
    7774
     
    8481  Double_t fraction;
    8582  TBinMap::iterator itEtaBin;
    86   set< Double_t >::iterator itPhiBin;
    87   vector< Double_t > *phiBins;
     83  set<Double_t>::iterator itPhiBin;
     84  vector<Double_t> *phiBins;
    8885
    8986  // read eta and phi bins
     
    9390  fEtaBins.clear();
    9491  fPhiBins.clear();
    95   for(i = 0; i < size/2; ++i)
    96   {
    97     paramEtaBins = param[i*2];
     92  for(i = 0; i < size / 2; ++i)
     93  {
     94    paramEtaBins = param[i * 2];
    9895    sizeEtaBins = paramEtaBins.GetSize();
    99     paramPhiBins = param[i*2 + 1];
     96    paramPhiBins = param[i * 2 + 1];
    10097    sizePhiBins = paramPhiBins.GetSize();
    10198
     
    114111  {
    115112    fEtaBins.push_back(itEtaBin->first);
    116     phiBins = new vector< double >(itEtaBin->second.size());
     113    phiBins = new vector<double>(itEtaBin->second.size());
    117114    fPhiBins.push_back(phiBins);
    118115    phiBins->clear();
     
    131128  fFractionMap[0] = 1.0;
    132129
    133   for(i = 0; i < size/2; ++i)
    134   {
    135     paramFractions = param[i*2 + 1];
     130  for(i = 0; i < size / 2; ++i)
     131  {
     132    paramFractions = param[i * 2 + 1];
    136133    fraction = paramFractions[0].GetDouble();
    137     fFractionMap[param[i*2].GetInt()] = fraction;
     134    fFractionMap[param[i * 2].GetInt()] = fraction;
    138135  }
    139136
     
    170167void SimpleCalorimeter::Finish()
    171168{
    172   vector< vector< Double_t >* >::iterator itPhiBin;
     169  vector<vector<Double_t> *>::iterator itPhiBin;
    173170  if(fItParticleInputArray) delete fItParticleInputArray;
    174171  if(fItTrackInputArray) delete fItTrackInputArray;
     
    197194  TFractionMap::iterator itFractionMap;
    198195
    199   vector< Double_t >::iterator itEtaBin;
    200   vector< Double_t >::iterator itPhiBin;
    201   vector< Double_t > *phiBins;
    202 
    203   vector< Long64_t >::iterator itTowerHits;
     196  vector<Double_t>::iterator itEtaBin;
     197  vector<Double_t>::iterator itPhiBin;
     198  vector<Double_t> *phiBins;
     199
     200  vector<Long64_t>::iterator itTowerHits;
    204201
    205202  DelphesFactory *factory = GetFactory();
     
    211208  fItParticleInputArray->Reset();
    212209  number = -1;
    213   while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
     210  while((particle = static_cast<Candidate *>(fItParticleInputArray->Next())))
    214211  {
    215212    const TLorentzVector &particlePosition = particle->Position;
     
    254251  fItTrackInputArray->Reset();
    255252  number = -1;
    256   while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
     253  while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
    257254  {
    258255    const TLorentzVector &trackPosition = track->Position;
     
    303300    towerHit = (*itTowerHits);
    304301    flags = (towerHit >> 24) & 0x00000000000000FFLL;
    305     number = (towerHit) & 0x0000000000FFFFFFLL;
     302    number = (towerHit)&0x0000000000FFFFFFLL;
    306303    hitEtaPhi = towerHit >> 32;
    307304
     
    324321
    325322      // calculate eta and phi of the tower's center
    326       fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
    327       fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
     323      fTowerEta = 0.5 * (fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
     324      fTowerPhi = 0.5 * ((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
    328325
    329326      fTowerEdges[0] = fEtaBins[etaBin - 1];
     
    346343
    347344      fTowerTrackArray->Clear();
    348      }
     345    }
    349346
    350347    // check for track hits
     
    353350      ++fTowerTrackHits;
    354351
    355       track = static_cast<Candidate*>(fTrackInputArray->At(number));
     352      track = static_cast<Candidate *>(fTrackInputArray->At(number));
    356353      momentum = track->Momentum;
    357354      position = track->Position;
     
    359356      energy = momentum.E() * fTrackFractions[number];
    360357
    361       fTrackTime += TMath::Sqrt(energy)*position.T();
     358      fTrackTime += TMath::Sqrt(energy) * position.T();
    362359      fTrackTimeWeight += TMath::Sqrt(energy);
    363360
    364361      if(fTrackFractions[number] > 1.0E-9)
    365362      {
    366              
    367        // compute total charged energy   
    368        fTrackEnergy += energy;
    369        sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
    370        if(sigma/momentum.E() < track->TrackResolution) energyGuess = energy;
    371        else energyGuess = momentum.E();
    372 
    373        fTrackSigma += ((track->TrackResolution)*energyGuess)*((track->TrackResolution)*energyGuess);
    374        fTowerTrackArray->Add(track);
     363
     364        // compute total charged energy
     365        fTrackEnergy += energy;
     366        sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
     367        if(sigma / momentum.E() < track->TrackResolution)
     368          energyGuess = energy;
     369        else
     370          energyGuess = momentum.E();
     371
     372        fTrackSigma += ((track->TrackResolution) * energyGuess) * ((track->TrackResolution) * energyGuess);
     373        fTowerTrackArray->Add(track);
    375374      }
    376        
     375
    377376      else
    378377      {
     
    386385    if(flags & 2) ++fTowerPhotonHits;
    387386
    388     particle = static_cast<Candidate*>(fParticleInputArray->At(number));
     387    particle = static_cast<Candidate *>(fParticleInputArray->At(number));
    389388    momentum = particle->Momentum;
    390389    position = particle->Position;
     
    395394    fTowerEnergy += energy;
    396395
    397     fTowerTime += energy*position.T();
     396    fTowerTime += energy * position.T();
    398397    fTowerTimeWeight += energy;
    399398
     
    410409{
    411410  Candidate *tower, *track, *mother;
    412   Double_t energy,neutralEnergy, pt, eta, phi;
     411  Double_t energy, neutralEnergy, pt, eta, phi;
    413412  Double_t sigma, neutralSigma;
    414413  Double_t time;
    415    
     414
    416415  Double_t weightTrack, weightCalo, bestEnergyEstimate, rescaleFactor;
    417416
     
    425424  energy = LogNormal(fTowerEnergy, sigma);
    426425
    427   time = (fTowerTimeWeight < 1.0E-09 ) ? 0.0 : fTowerTime/fTowerTimeWeight;
     426  time = (fTowerTimeWeight < 1.0E-09) ? 0.0 : fTowerTime / fTowerTimeWeight;
    428427
    429428  sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, energy);
    430429
    431   if(energy < fEnergyMin || energy < fEnergySignificanceMin*sigma) energy = 0.0;
    432 
     430  if(energy < fEnergyMin || energy < fEnergySignificanceMin * sigma) energy = 0.0;
    433431
    434432  if(fSmearTowerCenter)
     
    459457  if(energy > 0.0) fTowerOutputArray->Add(fTower);
    460458
    461  
    462459  // e-flow candidates
    463460
    464461  //compute neutral excess
    465  
     462
    466463  fTrackSigma = TMath::Sqrt(fTrackSigma);
    467   neutralEnergy = max( (energy - fTrackEnergy) , 0.0);
    468  
     464  neutralEnergy = max((energy - fTrackEnergy), 0.0);
     465
    469466  //compute sigma_trk total
    470   neutralSigma = neutralEnergy / TMath::Sqrt(fTrackSigma*fTrackSigma+ sigma*sigma);
    471    
     467  neutralSigma = neutralEnergy / TMath::Sqrt(fTrackSigma * fTrackSigma + sigma * sigma);
     468
    472469  // if neutral excess is significant, simply create neutral Eflow tower and clone each track into eflowtrack
    473470  if(neutralEnergy > fEnergyMin && neutralSigma > fEnergySignificanceMin)
    474471  {
    475472    // create new photon tower
    476     tower = static_cast<Candidate*>(fTower->Clone());
     473    tower = static_cast<Candidate *>(fTower->Clone());
    477474    pt = neutralEnergy / TMath::CosH(eta);
    478475
     
    480477    tower->Ehad = (fIsEcal) ? 0 : neutralEnergy;
    481478    tower->PID = (fIsEcal) ? 22 : 0;
    482  
     479
    483480    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, neutralEnergy);
    484481    fEFlowTowerOutputArray->Add(tower);
    485    
     482
    486483    fItTowerTrackArray->Reset();
    487     while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
     484    while((track = static_cast<Candidate *>(fItTowerTrackArray->Next())))
    488485    {
    489486      mother = track;
    490       track = static_cast<Candidate*>(track->Clone());
     487      track = static_cast<Candidate *>(track->Clone());
    491488      track->AddCandidate(mother);
    492489
     
    494491    }
    495492  }
    496    
     493
    497494  // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking
    498   else if (fTrackEnergy > 0.0)
    499   {
    500     weightTrack = (fTrackSigma > 0.0) ? 1 / (fTrackSigma*fTrackSigma) : 0.0;
    501     weightCalo  = (sigma > 0.0) ? 1 / (sigma*sigma) : 0.0;
    502  
    503     bestEnergyEstimate = (weightTrack*fTrackEnergy + weightCalo*energy) / (weightTrack + weightCalo);
    504     rescaleFactor = bestEnergyEstimate/fTrackEnergy;
    505    
     495  else if(fTrackEnergy > 0.0)
     496  {
     497    weightTrack = (fTrackSigma > 0.0) ? 1 / (fTrackSigma * fTrackSigma) : 0.0;
     498    weightCalo = (sigma > 0.0) ? 1 / (sigma * sigma) : 0.0;
     499
     500    bestEnergyEstimate = (weightTrack * fTrackEnergy + weightCalo * energy) / (weightTrack + weightCalo);
     501    rescaleFactor = bestEnergyEstimate / fTrackEnergy;
     502
    506503    fItTowerTrackArray->Reset();
    507     while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
     504    while((track = static_cast<Candidate *>(fItTowerTrackArray->Next())))
    508505    {
    509506      mother = track;
    510       track = static_cast<Candidate*>(track->Clone());
     507      track = static_cast<Candidate *>(track->Clone());
    511508      track->AddCandidate(mother);
    512509
     
    516513    }
    517514  }
    518    
    519  }
     515}
    520516
    521517//------------------------------------------------------------------------------
     
    527523  if(mean > 0.0)
    528524  {
    529     b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
    530     a = TMath::Log(mean) - 0.5*b*b;
    531 
    532     return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
     525    b = TMath::Sqrt(TMath::Log((1.0 + (sigma * sigma) / (mean * mean))));
     526    a = TMath::Log(mean) - 0.5 * b * b;
     527
     528    return TMath::Exp(a + b * gRandom->Gaus(0.0, 1.0));
    533529  }
    534530  else
  • modules/SimpleCalorimeter.h

    re39abb4 r0e7d64a  
    4343{
    4444public:
    45 
    4645  SimpleCalorimeter();
    4746  ~SimpleCalorimeter();
     
    5251
    5352private:
    54 
    55   typedef std::map< Long64_t, Double_t > TFractionMap; //!
    56   typedef std::map< Double_t, std::set< Double_t > > TBinMap; //!
     53  typedef std::map<Long64_t, Double_t> TFractionMap; //!
     54  typedef std::map<Double_t, std::set<Double_t> > TBinMap; //!
    5755
    5856  Candidate *fTower;
     
    8280  TBinMap fBinMap; //!
    8381
    84   std::vector < Double_t > fEtaBins;
    85   std::vector < std::vector < Double_t >* > fPhiBins;
     82  std::vector<Double_t> fEtaBins;
     83  std::vector<std::vector<Double_t> *> fPhiBins;
    8684
    87   std::vector < Long64_t > fTowerHits;
     85  std::vector<Long64_t> fTowerHits;
    8886
    89   std::vector < Double_t > fTowerFractions;
     87  std::vector<Double_t> fTowerFractions;
    9088
    91   std::vector < Double_t > fTrackFractions;
     89  std::vector<Double_t> fTrackFractions;
    9290
    9391  DelphesFormula *fResolutionFormula; //!
  • modules/StatusPidFilter.cc

    re39abb4 r0e7d64a  
    3232#include "classes/DelphesFormula.h"
    3333
     34#include "ExRootAnalysis/ExRootClassifier.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3436#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    37 
     37
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
    3841#include "TMath.h"
     42#include "TObjArray.h"
     43#include "TRandom3.h"
    3944#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4545
    4646#include <algorithm>
    47 #include <stdexcept>
    4847#include <iostream>
    4948#include <sstream>
     49#include <stdexcept>
    5050
    5151using namespace std;
    5252
    53 namespace {
    54   // integer power (faster than TMath::Pow() + cast to integer)
    55   int ipow(int base, int exp)
    56   {
    57       int result = 1;
    58       while (exp)
    59       {
    60           if (exp & 1)
    61               result *= base;
    62           exp >>= 1;
    63           base *= base;
    64       }
    65 
    66       return result;
    67   }
    68 
    69   // standalone function to extract the i-th digit from a number (counting from 0 = rightmost, etc..)
    70   int digit(int val, int i)
    71   {
    72       int y    = ipow(10,i);
    73       int z    = val/y;
    74       int val2 = val / (y * 10);
    75       return (z - val2*10);
    76   }
    77 
    78   //  return the first two digits if this is a "fundamental" particle
    79   //  ID = 100 is a special case (internal generator ID's are 81-100)
    80   //  also, 101 and 102 are now used (by HepPID) for geantinos
    81   int fundamentalID(int pdgCode)
    82   {
    83       pdgCode = abs(pdgCode);
    84       if( ( digit(pdgCode, 9) == 1 ) && ( digit(pdgCode, 8) == 0 ) ) { return 0; }
    85       if( digit(pdgCode, 2) == 0 && digit(pdgCode, 3) == 0) {
    86           return pdgCode%10000;
    87       } else if( pdgCode <= 102 ) {
    88           return pdgCode;
    89       } else {
    90           return 0;
    91       }
    92   }
    93 
    94   bool hasBottom(int pdgCode)
    95   {
    96       if ( (pdgCode/10000000) > 0)
    97         return false;
    98       if (pdgCode <= 100)
    99         return false;
    100       if (fundamentalID(pdgCode) <= 100 && fundamentalID(pdgCode) > 0)
    101         return false;
    102       if( digit(pdgCode, 3) == 5 || digit(pdgCode, 2) == 5 || digit(pdgCode, 1) == 5 )
    103         return true;     
    104       return false;
    105   }
    106 
    107   bool isTauDaughter(int pdgCode, int M1, const TObjArray *fInputArray){
    108     //not needed, just to speed up the code - can be further refined but gives only negligible improvement:
    109     if ( pdgCode==15 || pdgCode<11 || (pdgCode > 22 && pdgCode < 100) || pdgCode>1000 )
    110       return false;
    111 
    112     if ( M1 < 0 )
    113       return false;
    114 
    115     Candidate *mother;
    116     mother = static_cast<Candidate*>(fInputArray->At( M1 ));
    117     if ( TMath::Abs(mother->PID) == 15 )
    118       return true;
    119 
    120     return false;
    121   }
    122 
    123   bool isWDaughter(int M1, const TObjArray *fInputArray)
    124   {
    125      if ( M1 < 0 ) return false;
    126 
    127      Candidate *mother;
    128      mother = static_cast<Candidate*>(fInputArray->At( M1 ));
    129      if ( TMath::Abs(mother->PID) == 24 ) return true;
    130 
    131      return false;
    132   }
    133 
    134 }
    135 
     53namespace
     54{
     55// integer power (faster than TMath::Pow() + cast to integer)
     56int ipow(int base, int exp)
     57{
     58  int result = 1;
     59  while(exp)
     60  {
     61    if(exp & 1)
     62      result *= base;
     63    exp >>= 1;
     64    base *= base;
     65  }
     66
     67  return result;
     68}
     69
     70// standalone function to extract the i-th digit from a number (counting from 0 = rightmost, etc..)
     71int digit(int val, int i)
     72{
     73  int y = ipow(10, i);
     74  int z = val / y;
     75  int val2 = val / (y * 10);
     76  return (z - val2 * 10);
     77}
     78
     79//  return the first two digits if this is a "fundamental" particle
     80//  ID = 100 is a special case (internal generator ID's are 81-100)
     81//  also, 101 and 102 are now used (by HepPID) for geantinos
     82int fundamentalID(int pdgCode)
     83{
     84  pdgCode = abs(pdgCode);
     85  if((digit(pdgCode, 9) == 1) && (digit(pdgCode, 8) == 0))
     86  {
     87    return 0;
     88  }
     89  if(digit(pdgCode, 2) == 0 && digit(pdgCode, 3) == 0)
     90  {
     91    return pdgCode % 10000;
     92  }
     93  else if(pdgCode <= 102)
     94  {
     95    return pdgCode;
     96  }
     97  else
     98  {
     99    return 0;
     100  }
     101}
     102
     103bool hasBottom(int pdgCode)
     104{
     105  if((pdgCode / 10000000) > 0)
     106    return false;
     107  if(pdgCode <= 100)
     108    return false;
     109  if(fundamentalID(pdgCode) <= 100 && fundamentalID(pdgCode) > 0)
     110    return false;
     111  if(digit(pdgCode, 3) == 5 || digit(pdgCode, 2) == 5 || digit(pdgCode, 1) == 5)
     112    return true;
     113  return false;
     114}
     115
     116bool isTauDaughter(int pdgCode, int M1, const TObjArray *fInputArray)
     117{
     118  //not needed, just to speed up the code - can be further refined but gives only negligible improvement:
     119  if(pdgCode == 15 || pdgCode < 11 || (pdgCode > 22 && pdgCode < 100) || pdgCode > 1000)
     120    return false;
     121
     122  if(M1 < 0)
     123    return false;
     124
     125  Candidate *mother;
     126  mother = static_cast<Candidate *>(fInputArray->At(M1));
     127  if(TMath::Abs(mother->PID) == 15)
     128    return true;
     129
     130  return false;
     131}
     132
     133bool isWDaughter(int M1, const TObjArray *fInputArray)
     134{
     135  if(M1 < 0) return false;
     136
     137  Candidate *mother;
     138  mother = static_cast<Candidate *>(fInputArray->At(M1));
     139  if(TMath::Abs(mother->PID) == 24) return true;
     140
     141  return false;
     142}
     143
     144} // namespace
    136145
    137146//------------------------------------------------------------------------------
     
    153162{
    154163  // PT threshold
    155 
    156164  fPTMin = GetDouble("PTMin", 0.5);
     165
     166  // keep or remove pileup particles
     167  fRequireNotPileup = GetBool("RequireNotPileup", false);
    157168
    158169  // import input array
     
    181192
    182193  fItInputArray->Reset();
    183   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     194  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    184195  {
    185196    status = candidate->Status;
     
    193204    // hard scattering particles (first condition for Py6, second for Py8)
    194205    if(status == 3) pass = kTRUE;
    195     if(status > 20 && status < 30 ) pass = kTRUE;
     206    if(status > 20 && status < 30) pass = kTRUE;
    196207
    197208    // electrons, muons, taus and neutrinos
     
    199210
    200211    // heavy quarks
    201     if(pdgCode == 4 ||pdgCode == 5 || pdgCode == 6) pass = kTRUE;
     212    if(pdgCode == 4 || pdgCode == 5 || pdgCode == 6) pass = kTRUE;
    202213
    203214    // Gauge bosons and other fundamental bosons
    204215    if(pdgCode > 22 && pdgCode < 43) pass = kTRUE;
    205216
    206     //Stable photons 
    207     if(pdgCode == 22 && status==1) pass = kTRUE;
     217    //Stable photons
     218    if(pdgCode == 22 && status == 1) pass = kTRUE;
    208219
    209220    // logic ported from HepPDF: http://lcgapp.cern.ch/project/simu/HepPDT/HepPDT.2.05.02/html/ParticleID_8cc-source.html#l00081
    210221    bool is_b_hadron = hasBottom(pdgCode);
    211     bool is_b_quark  = (pdgCode == 5);
     222    bool is_b_quark = (pdgCode == 5);
    212223
    213224    bool is_tau_daughter = isTauDaughter(pdgCode, candidate->M1, fInputArray);
    214225
    215     if (is_b_hadron)
     226    if(is_b_hadron)
    216227      pass = kTRUE;
    217228
    218     if (is_tau_daughter)
     229    if(is_tau_daughter)
    219230      pass = kTRUE;
    220231
    221232    bool is_W_daughter = isWDaughter(candidate->M1, fInputArray);
    222     if (is_W_daughter)
     233    if(is_W_daughter)
    223234      pass = kTRUE;
    224235
    225236    // fPTMin not applied to b_hadrons / b_quarks to allow for b-enriched sample stitching
    226237    // fPTMin not applied to tau decay products to allow visible-tau four momentum determination
    227     if(!pass || (candidate->Momentum.Pt() < fPTMin && !(is_b_hadron || is_b_quark || is_tau_daughter || is_W_daughter)) ) continue;
     238    if(!pass || (candidate->Momentum.Pt() < fPTMin && !(is_b_hadron || is_b_quark || is_tau_daughter || is_W_daughter))) continue;
     239
     240    // not pileup particles
     241    if(fRequireNotPileup && (candidate->IsPU > 0)) continue;
    228242
    229243    fOutputArray->Add(candidate);
    230244  }
    231245}
    232 
  • modules/StatusPidFilter.h

    re39abb4 r0e7d64a  
    3939{
    4040public:
    41 
    4241  StatusPidFilter();
    4342  ~StatusPidFilter();
     
    4847
    4948private:
     49  Double_t fPTMin; //!
    5050
    51   Double_t fPTMin; //!
     51  Bool_t fRequireNotPileup; //!
    5252
    5353  TIterator *fItInputArray; //!
  • modules/TaggingParticlesSkimmer.cc

    re39abb4 r0e7d64a  
    3535#include "classes/DelphesFormula.h"
    3636
     37#include "ExRootAnalysis/ExRootClassifier.h"
     38#include "ExRootAnalysis/ExRootFilter.h"
    3739#include "ExRootAnalysis/ExRootResult.h"
    38 #include "ExRootAnalysis/ExRootFilter.h"
    39 #include "ExRootAnalysis/ExRootClassifier.h"
    4040
     41#include "TDatabasePDG.h"
     42#include "TFormula.h"
     43#include "TLorentzVector.h"
    4144#include "TMath.h"
     45#include "TObjArray.h"
     46#include "TRandom3.h"
    4247#include "TString.h"
    43 #include "TFormula.h"
    44 #include "TRandom3.h"
    45 #include "TObjArray.h"
    46 #include "TDatabasePDG.h"
    47 #include "TLorentzVector.h"
    4848
    4949#include <algorithm>
    50 #include <stdexcept>
    5150#include <iostream>
    5251#include <sstream>
     52#include <stdexcept>
    5353
    5454using namespace std;
    55 
    5655
    5756//------------------------------------------------------------------------------
    5857
    5958TaggingParticlesSkimmer::TaggingParticlesSkimmer() :
    60   fItPartonInputArray(0), fFilter(0), fClassifier(0)
     59  fClassifier(0), fFilter(0), fItPartonInputArray(0),
     60  fPartonInputArray(0), fParticleInputArray(0), fOutputArray(0)
    6161{
    6262}
     
    7272void TaggingParticlesSkimmer::Init()
    7373{
    74  
     74
    7575  fPTMin = GetDouble("PTMin", 15.0);
    7676  fEtaMax = GetDouble("EtaMax", 2.5);
    77    
     77
    7878  // import input array
    7979  fPartonInputArray = ImportArray(GetString("PartonInputArray", "Delphes/partons"));
    8080  fItPartonInputArray = fPartonInputArray->MakeIterator();
    81  
     81
    8282  fParticleInputArray = ImportArray(GetString("ParticleInputArray", "Delphes/allParticles"));
    8383
    84  
    8584  fClassifier = new TauTaggingPartonClassifier(fParticleInputArray);
    8685  fClassifier->fPTMin = GetDouble("PTMin", 15.0);
    8786  fClassifier->fEtaMax = GetDouble("EtaMax", 2.5);
    8887
    89  
    9088  fFilter = new ExRootFilter(fPartonInputArray);
    9189
     
    9795
    9896void TaggingParticlesSkimmer::Finish()
    99 { 
     97{
    10098  if(fItPartonInputArray) delete fItPartonInputArray;
    10199  if(fFilter) delete fFilter;
     
    127125    if(tau->D1 < 0) continue;
    128126
    129     if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
    130        tau->D2 >= fParticleInputArray->GetEntriesFast())
     127    if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
    131128    {
    132129      throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    134131
    135132    tauMomentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
    136    
     133
    137134    for(i = tau->D1; i <= tau->D2; ++i)
    138135    {
     
    141138      tauMomentum += daughter->Momentum;
    142139    }
    143  
    144    candidate = static_cast<Candidate*>(tau->Clone());
    145    candidate->Momentum = tauMomentum;
    146140
    147    
    148    fOutputArray->Add(candidate);
     141    candidate = static_cast<Candidate *>(tau->Clone());
     142    candidate->Momentum = tauMomentum;
    149143
     144    fOutputArray->Add(candidate);
    150145  }
    151146
    152147  // then add all other partons (except tau's to avoid double counting)
    153  
     148
    154149  fItPartonInputArray->Reset();
    155   while((candidate = static_cast<Candidate*>(fItPartonInputArray->Next())))
     150  while((candidate = static_cast<Candidate *>(fItPartonInputArray->Next())))
    156151  {
    157152    pdgCode = TMath::Abs(candidate->PID);
    158153    if(pdgCode == 15) continue;
    159    
     154
    160155    pt = candidate->Momentum.Pt();
    161156    if(pt < fPTMin) continue;
    162    
     157
    163158    eta = TMath::Abs(candidate->Momentum.Eta());
    164159    if(eta > fEtaMax) continue;
    165        
     160
    166161    fOutputArray->Add(candidate);
    167162  }
    168 
    169 
    170163}
    171 
  • modules/TaggingParticlesSkimmer.h

    re39abb4 r0e7d64a  
    4242{
    4343public:
    44 
    4544  TaggingParticlesSkimmer();
    4645  ~TaggingParticlesSkimmer();
     
    5150
    5251private:
    53 
    5452  Double_t fPTMin; //!
    5553  Double_t fEtaMax; //!
    56  
     54
    5755  TauTaggingPartonClassifier *fClassifier; //!
    58  
     56
    5957  ExRootFilter *fFilter;
    6058
    6159  TIterator *fItPartonInputArray; //!
    62  
     60
    6361  const TObjArray *fPartonInputArray; //!
    6462  const TObjArray *fParticleInputArray; //!
  • modules/TauTagging.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class TauTagging
    2120 *
     
    3433#include "classes/DelphesFormula.h"
    3534
     35#include "TDatabasePDG.h"
     36#include "TFormula.h"
     37#include "TLorentzVector.h"
    3638#include "TMath.h"
     39#include "TObjArray.h"
     40#include "TRandom3.h"
    3741#include "TString.h"
    38 #include "TFormula.h"
    39 #include "TRandom3.h"
    40 #include "TObjArray.h"
    41 #include "TDatabasePDG.h"
    42 #include "TLorentzVector.h"
    4342
    4443#include <algorithm>
    45 #include <stdexcept>
    4644#include <iostream>
    4745#include <sstream>
     46#include <stdexcept>
    4847
    4948using namespace std;
    50 
    5149
    5250//------------------------------------------------------------------------------
     
    6361  Candidate *daughter1 = 0;
    6462  Candidate *daughter2 = 0;
    65  
     63
    6664  const TLorentzVector &momentum = tau->Momentum;
    6765  Int_t pdgCode, i, j;
     
    7674  if(tau->D2 < tau->D1) return -1;
    7775
    78   if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
    79      tau->D2 >= fParticleInputArray->GetEntriesFast())
     76  if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
    8077  {
    8178    throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    8683    daughter1 = static_cast<Candidate *>(fParticleInputArray->At(i));
    8784    pdgCode = TMath::Abs(daughter1->PID);
    88     if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15) return -1;
     85    if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15)
     86      return -1;
    8987    else if(pdgCode == 24)
    9088    {
    91      if(daughter1->D1 < 0) return -1;
    92      for(j = daughter1->D1; j <= daughter1->D2; ++j)
    93      {
    94        daughter2 = static_cast<Candidate*>(fParticleInputArray->At(j));
    95        pdgCode = TMath::Abs(daughter2->PID);
    96        if(pdgCode == 11 || pdgCode == 13) return -1;
    97      }
    98        
     89      if(daughter1->D1 < 0) return -1;
     90      for(j = daughter1->D1; j <= daughter1->D2; ++j)
     91      {
     92        daughter2 = static_cast<Candidate *>(fParticleInputArray->At(j));
     93        pdgCode = TMath::Abs(daughter2->PID);
     94        if(pdgCode == 11 || pdgCode == 13) return -1;
     95      }
    9996    }
    10097  }
     
    121118void TauTagging::Init()
    122119{
    123   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     120  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    124121  ExRootConfParam param;
    125122  DelphesFormula *formula;
     
    135132
    136133  fEfficiencyMap.clear();
    137   for(i = 0; i < size/2; ++i)
     134  for(i = 0; i < size / 2; ++i)
    138135  {
    139136    formula = new DelphesFormula;
    140     formula->Compile(param[i*2 + 1].GetString());
    141 
    142     fEfficiencyMap[param[i*2].GetInt()] = formula;
     137    formula->Compile(param[i * 2 + 1].GetString());
     138
     139    fEfficiencyMap[param[i * 2].GetInt()] = formula;
    143140  }
    144141
     
    174171void TauTagging::Finish()
    175172{
    176   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     173  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    177174  DelphesFormula *formula;
    178175
     
    197194  Double_t pt, eta, phi, e, eff;
    198195  TObjArray *tauArray;
    199   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     196  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    200197  DelphesFormula *formula;
    201198  Int_t pdgCode, charge, i;
     
    218215
    219216    // loop over all input taus
    220     if(tauArray){
     217    if(tauArray)
     218    {
    221219      TIter itTauArray(tauArray);
    222220      while((tau = static_cast<Candidate *>(itTauArray.Next())))
     
    224222        if(tau->D1 < 0) continue;
    225223
    226         if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
    227            tau->D2 >= fParticleInputArray->GetEntriesFast())
     224        if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
    228225        {
    229226          throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    257254    eff = formula->Eval(pt, eta, phi, e);
    258255    jet->TauTag |= (gRandom->Uniform() <= eff) << fBitNumber;
    259     jet->TauWeight = eff;     
     256    jet->TauWeight = eff;
    260257
    261258    // set tau charge
  • modules/TauTagging.h

    re39abb4 r0e7d64a  
    3030 */
    3131
     32#include "ExRootAnalysis/ExRootClassifier.h"
     33#include "ExRootAnalysis/ExRootFilter.h"
     34#include "ExRootAnalysis/ExRootResult.h"
    3235#include "classes/DelphesModule.h"
    33 #include "ExRootAnalysis/ExRootResult.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootClassifier.h"
    3636
    3737#include <map>
     
    4646{
    4747public:
    48 
    4948  TauTagging();
    5049  ~TauTagging();
     
    5554
    5655private:
    57  
    5856  Int_t fBitNumber;
    59  
     57
    6058  Double_t fDeltaR;
    6159
    6260#if !defined(__CINT__) && !defined(__CLING__)
    63   std::map< Int_t, DelphesFormula * > fEfficiencyMap; //!
     61  std::map<Int_t, DelphesFormula *> fEfficiencyMap; //!
    6462#endif
    65  
     63
    6664  TauTaggingPartonClassifier *fClassifier; //!
    67  
     65
    6866  ExRootFilter *fFilter;
    6967
    7068  TIterator *fItPartonInputArray; //!
    71  
     69
    7270  TIterator *fItJetInputArray; //!
    7371
     
    7573
    7674  const TObjArray *fPartonInputArray; //!
    77  
     75
    7876  const TObjArray *fJetInputArray; //!
    7977
     
    8179};
    8280
    83 
    8481//------------------------------------------------------------------------------
    8582
    86 class TauTaggingPartonClassifier : public ExRootClassifier
     83class TauTaggingPartonClassifier: public ExRootClassifier
    8784{
    8885public:
    89 
    9086  TauTaggingPartonClassifier(const TObjArray *array);
    9187
     
    9793};
    9894
    99 
    10095#endif
  • modules/TimeSmearing.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class TimeSmearing
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    5453
    5554TimeSmearing::TimeSmearing() :
    56 fItInputArray(0)
     55  fItInputArray(0)
    5756{
    5857}
     
    9796
    9897  fItInputArray->Reset();
    99   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     98  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    10099  {
    101100    const TLorentzVector &candidateInitialPosition = candidate->InitialPosition;
    102101    const TLorentzVector &candidateFinalPosition = candidate->Position;
    103102
    104     ti = candidateInitialPosition.T()*1.0E-3/c_light;
    105     tf = candidateFinalPosition.T()*1.0E-3/c_light;
     103    ti = candidateInitialPosition.T() * 1.0E-3 / c_light;
     104    tf = candidateFinalPosition.T() * 1.0E-3 / c_light;
    106105
    107106    // apply smearing formula
     
    109108    ti = ti + tf_smeared - tf;
    110109    tf = tf_smeared;
    111    
     110
    112111    mother = candidate;
    113     candidate = static_cast<Candidate*>(candidate->Clone());
    114     candidate->InitialPosition.SetT(ti*1.0E3*c_light);
    115     candidate->Position.SetT(tf*1.0E3*c_light);
     112    candidate = static_cast<Candidate *>(candidate->Clone());
     113    candidate->InitialPosition.SetT(ti * 1.0E3 * c_light);
     114    candidate->Position.SetT(tf * 1.0E3 * c_light);
    116115
    117     candidate->ErrorT = fTimeResolution*1.0E3*c_light;
     116    candidate->ErrorT = fTimeResolution * 1.0E3 * c_light;
    118117
    119118    candidate->AddCandidate(mother);
  • modules/TimeSmearing.h

    re39abb4 r0e7d64a  
    3636{
    3737public:
    38 
    3938  TimeSmearing();
    4039  ~TimeSmearing();
     
    4544
    4645private:
    47 
    4846  Double_t fTimeResolution;
    4947
  • modules/TrackCountingBTagging.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class TrackCountingBTagging
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "TFormula.h"
     34#include "TLorentzVector.h"
    3435#include "TMath.h"
     36#include "TObjArray.h"
     37#include "TRandom3.h"
    3538#include "TString.h"
    36 #include "TFormula.h"
    37 #include "TRandom3.h"
    38 #include "TObjArray.h"
    39 #include "TLorentzVector.h"
    4039
    4140#include <algorithm>
    42 #include <stdexcept>
    4341#include <iostream>
    4442#include <sstream>
     43#include <stdexcept>
    4544
    4645using namespace std;
     
    107106  // loop over all input jets
    108107  fItJetInputArray->Reset();
    109   while((jet = static_cast<Candidate*>(fItJetInputArray->Next())))
     108  while((jet = static_cast<Candidate *>(fItJetInputArray->Next())))
    110109  {
    111110    const TLorentzVector &jetMomentum = jet->Momentum;
     
    118117    count = 0;
    119118    // stop once we have enough tracks
    120     while((track = static_cast<Candidate*>(fItTrackInputArray->Next())) and count < fNtracks)
     119    while((track = static_cast<Candidate *>(fItTrackInputArray->Next())) and count < fNtracks)
    121120    {
    122121      const TLorentzVector &trkMomentum = track->Momentum;
    123122      tpt = trkMomentum.Pt();
    124123      if(tpt < fPtMin) continue;
    125      
     124
    126125      d0 = TMath::Abs(track->D0);
    127126      if(d0 > fIPmax) continue;
     
    137136      ddz = TMath::Abs(track->ErrorDZ);
    138137
    139       if(fUse3D){
    140         sign = (jpx*xd + jpy*yd + jpz*zd > 0.0) ? 1 : -1;
     138      if(fUse3D)
     139      {
     140        sign = (jpx * xd + jpy * yd + jpz * zd > 0.0) ? 1 : -1;
    141141        //add transverse and longitudinal significances in quadrature
    142         sip = sign * TMath::Sqrt( TMath::Power(d0 / dd0, 2) + TMath::Power(dz / ddz, 2) );
     142        sip = sign * TMath::Sqrt(TMath::Power(d0 / dd0, 2) + TMath::Power(dz / ddz, 2));
    143143      }
    144       else {
    145         sign = (jpx*xd + jpy*yd > 0.0) ? 1 : -1;
     144      else
     145      {
     146        sign = (jpx * xd + jpy * yd > 0.0) ? 1 : -1;
    146147        sip = sign * d0 / TMath::Abs(dd0);
    147148      }
  • modules/TrackCountingBTagging.h

    re39abb4 r0e7d64a  
    3737{
    3838public:
    39 
    4039  TrackCountingBTagging();
    4140  ~TrackCountingBTagging();
     
    4645
    4746private:
    48 
    4947  Int_t fBitNumber;
    5048
     
    5351  Double_t fIPmax;
    5452  Double_t fSigMin;
    55   Int_t    fNtracks;
    56   Bool_t   fUse3D;
     53  Int_t fNtracks;
     54  Bool_t fUse3D;
    5755
    5856  TIterator *fItTrackInputArray; //!
  • modules/TrackCountingTauTagging.cc

    re39abb4 r0e7d64a  
    2020#include "classes/DelphesFormula.h"
    2121
     22#include "ExRootAnalysis/ExRootClassifier.h"
     23#include "ExRootAnalysis/ExRootFilter.h"
    2224#include "ExRootAnalysis/ExRootResult.h"
    23 #include "ExRootAnalysis/ExRootFilter.h"
    24 #include "ExRootAnalysis/ExRootClassifier.h"
    25 
     25
     26#include "TDatabasePDG.h"
     27#include "TFormula.h"
     28#include "TLorentzVector.h"
    2629#include "TMath.h"
     30#include "TObjArray.h"
     31#include "TRandom3.h"
    2732#include "TString.h"
    28 #include "TFormula.h"
    29 #include "TRandom3.h"
    30 #include "TObjArray.h"
    31 #include "TDatabasePDG.h"
    32 #include "TLorentzVector.h"
    3333
    3434#include <algorithm>
    35 #include <stdexcept>
    3635#include <iostream>
    3736#include <sstream>
     37#include <stdexcept>
    3838
    3939using namespace std;
     
    4444{
    4545public:
    46 
    4746  TrackCountingTauTaggingPartonClassifier(const TObjArray *array);
    4847
     
    6766  Candidate *daughter1 = 0;
    6867  Candidate *daughter2 = 0;
    69  
     68
    7069  const TLorentzVector &momentum = tau->Momentum;
    7170  Int_t pdgCode, i, j;
     
    8079  if(tau->D2 < tau->D1) return -1;
    8180
    82   if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
    83      tau->D2 >= fParticleInputArray->GetEntriesFast())
     81  if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
    8482  {
    8583    throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    9088    daughter1 = static_cast<Candidate *>(fParticleInputArray->At(i));
    9189    pdgCode = TMath::Abs(daughter1->PID);
    92     if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15) return -1;
     90    if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15)
     91      return -1;
    9392    else if(pdgCode == 24)
    9493    {
    95      if(daughter1->D1 < 0) return -1;
    96      for(j = daughter1->D1; j <= daughter1->D2; ++j)
    97      {
    98        daughter2 = static_cast<Candidate*>(fParticleInputArray->At(j));
    99        pdgCode = TMath::Abs(daughter2->PID);
    100        if(pdgCode == 11 || pdgCode == 13) return -1;
    101      }
    102        
     94      if(daughter1->D1 < 0) return -1;
     95      for(j = daughter1->D1; j <= daughter1->D2; ++j)
     96      {
     97        daughter2 = static_cast<Candidate *>(fParticleInputArray->At(j));
     98        pdgCode = TMath::Abs(daughter2->PID);
     99        if(pdgCode == 11 || pdgCode == 13) return -1;
     100      }
    103101    }
    104102  }
     
    125123void TrackCountingTauTagging::Init()
    126124{
    127   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     125  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    128126  ExRootConfParam param;
    129127  DelphesFormula *formula;
     
    135133  fDeltaRTrack = GetDouble("DeltaRTrack", 0.2);
    136134  fTrackPTMin = GetDouble("TrackPTMin", 1.0);
    137  
     135
    138136  // read efficiency formulas
    139137  param = GetParam("EfficiencyFormula");
     
    141139
    142140  fEfficiencyMap.clear();
    143   for(i = 0; i < size/2; ++i)
     141  for(i = 0; i < size / 2; ++i)
    144142  {
    145143    formula = new DelphesFormula;
    146     formula->Compile(param[i*2 + 1].GetString());
    147 
    148     fEfficiencyMap[param[i*2].GetInt()] = formula;
     144    formula->Compile(param[i * 2 + 1].GetString());
     145
     146    fEfficiencyMap[param[i * 2].GetInt()] = formula;
    149147  }
    150148
     
    172170  fTrackInputArray = ImportArray(GetString("TrackInputArray", "TrackMerger/tracks"));
    173171  fItTrackInputArray = fTrackInputArray->MakeIterator();
    174  
     172
    175173  fFilter = new ExRootFilter(fPartonInputArray);
    176174
     
    183181void TrackCountingTauTagging::Finish()
    184182{
    185   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     183  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    186184  DelphesFormula *formula;
    187185
     
    207205  Double_t pt, eta, phi, e;
    208206  TObjArray *tauArray;
    209   map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
     207  map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
    210208  DelphesFormula *formula;
    211209  Int_t pdgCode, charge, i, identifier;
     
    232230    e = jetMomentum.E();
    233231
    234 
    235 // loop over all input tracks
     232    // loop over all input tracks
    236233    fItTrackInputArray->Reset();
    237234    while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
    238235    {
    239         if((track->Momentum).Pt() < fTrackPTMin) continue;
    240         if(jetMomentum.DeltaR(track->Momentum) <= fDeltaRTrack) {
    241             identifier -= 1;
    242             charge += track->Charge;
    243         }
    244     }
    245    
     236      if((track->Momentum).Pt() < fTrackPTMin) continue;
     237      if(jetMomentum.DeltaR(track->Momentum) <= fDeltaRTrack)
     238      {
     239        identifier -= 1;
     240        charge += track->Charge;
     241      }
     242    }
     243
    246244    // loop over all input taus
    247245    itTauArray.Reset();
     
    251249      if(tau->D1 < 0) continue;
    252250
    253       if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
    254          tau->D2 >= fParticleInputArray->GetEntriesFast())
     251      if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
    255252      {
    256253        throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    263260        daughter = static_cast<Candidate *>(fParticleInputArray->At(i));
    264261        if(TMath::Abs(daughter->PID) == 16) continue;
    265         tauMomentum += daughter->Momentum; 
     262        tauMomentum += daughter->Momentum;
    266263      }
    267264
    268265      if(jetMomentum.DeltaR(tauMomentum) <= fDeltaR)
    269       {       
     266      {
    270267        matchedTau = true;
    271268        pdgCode = 15;
     
    273270    }
    274271    if(matchedTau)
    275         identifier *= -1;
     272      identifier *= -1;
    276273    // find an efficency formula
    277274    // If the identifier is larger than 2, set it to 2 (multiprong requires at least 2 tracks)
    278     if (identifier > 2)
    279         identifier = 2;
    280     else if (identifier < -2)
    281         identifier = -2;
    282 
    283    
     275    if(identifier > 2)
     276      identifier = 2;
     277    else if(identifier < -2)
     278      identifier = -2;
     279
    284280    itEfficiencyMap = fEfficiencyMap.find(identifier);
    285281    if(itEfficiencyMap == fEfficiencyMap.end())
     
    293289    // apply an efficency formula
    294290    jet->TauTag |= (gRandom->Uniform() <= formula->Eval(pt, eta, phi, e)) << fBitNumber;
    295    
    296    
     291
    297292    // set tau charge
    298293    jet->Charge = charge;
  • modules/TrackCountingTauTagging.h

    re39abb4 r0e7d64a  
    2929{
    3030public:
    31 
    3231  TrackCountingTauTagging();
    3332  ~TrackCountingTauTagging();
     
    3837
    3938private:
    40 
    4139  Int_t fBitNumber;
    4240
     
    4543  Double_t fTrackPTMin;
    4644
    47   std::map< Int_t, DelphesFormula * > fEfficiencyMap; //!
    48  
     45  std::map<Int_t, DelphesFormula *> fEfficiencyMap; //!
     46
    4947  TrackCountingTauTaggingPartonClassifier *fClassifier; //!
    50  
     48
    5149  ExRootFilter *fFilter;
    5250
    5351  TIterator *fItPartonInputArray; //!
    54  
     52
    5553  TIterator *fItTrackInputArray; //!
    56  
     54
    5755  TIterator *fItJetInputArray; //!
    5856
     
    6260
    6361  const TObjArray *fPartonInputArray; //!
    64  
     62
    6563  const TObjArray *fJetInputArray; //!
    6664
  • modules/TrackPileUpSubtractor.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class TrackPileUpSubtractor
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    5453
    5554TrackPileUpSubtractor::TrackPileUpSubtractor() :
    56 fFormula(0)
     55  fFormula(0)
    5756{
    5857  fFormula = new DelphesFormula;
     
    8887
    8988  size = param.GetSize();
    90   for(i = 0; i < size/2; ++i)
     89  for(i = 0; i < size / 2; ++i)
    9190  {
    92     array = ImportArray(param[i*2].GetString());
     91    array = ImportArray(param[i * 2].GetString());
    9392    iterator = array->MakeIterator();
    9493
    95     fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
     94    fInputMap[iterator] = ExportArray(param[i * 2 + 1].GetString());
    9695  }
    9796}
     
    101100void TrackPileUpSubtractor::Finish()
    102101{
    103   map< TIterator *, TObjArray * >::iterator itInputMap;
     102  map<TIterator *, TObjArray *>::iterator itInputMap;
    104103  TIterator *iterator;
    105104
     
    119118{
    120119  Candidate *candidate, *particle;
    121   map< TIterator *, TObjArray * >::iterator itInputMap;
     120  map<TIterator *, TObjArray *>::iterator itInputMap;
    122121  TIterator *iterator;
    123122  TObjArray *array;
    124   Double_t z, zvtx=0;
     123  Double_t z, zvtx = 0;
    125124  Double_t pt, eta, phi, e;
    126 
    127125
    128126  // find z position of primary vertex
    129127
    130128  fItVertexInputArray->Reset();
    131   while((candidate = static_cast<Candidate*>(fItVertexInputArray->Next())))
     129  while((candidate = static_cast<Candidate *>(fItVertexInputArray->Next())))
    132130  {
    133131    if(!candidate->IsPU)
     
    146144    // loop over all candidates
    147145    iterator->Reset();
    148     while((candidate = static_cast<Candidate*>(iterator->Next())))
     146    while((candidate = static_cast<Candidate *>(iterator->Next())))
    149147    {
    150       particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
     148      particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
    151149      const TLorentzVector &candidateMomentum = particle->Momentum;
    152150
     
    155153      phi = candidateMomentum.Phi();
    156154      e = candidateMomentum.E();
    157      
     155
    158156      z = particle->Position.Z();
    159157
     
    161159      // assume perfect pile-up subtraction for tracks outside fZVertexResolution
    162160
    163       if(candidate->Charge !=0 && candidate->IsPU && TMath::Abs(z-zvtx) > fFormula->Eval(pt, eta, phi, e)* 1.0e3)
     161      if(candidate->Charge != 0 && candidate->IsPU && TMath::Abs(z - zvtx) > fFormula->Eval(pt, eta, phi, e) * 1.0e3)
    164162      {
    165163        candidate->IsRecoPU = 1;
  • modules/TrackPileUpSubtractor.h

    re39abb4 r0e7d64a  
    3939{
    4040public:
    41 
    4241  TrackPileUpSubtractor();
    4342  ~TrackPileUpSubtractor();
     
    4847
    4948private:
    50 
    5149  DelphesFormula *fFormula; //!
    5250
    5351  Double_t fPTMin;
    5452
    55   std::map< TIterator *, TObjArray * > fInputMap; //!
     53  std::map<TIterator *, TObjArray *> fInputMap; //!
    5654
    5755  ClassDef(TrackPileUpSubtractor, 1)
    5856
    59   TIterator *fItVertexInputArray; //!
     57    TIterator *fItVertexInputArray; //!
    6058
    6159  const TObjArray *fVertexInputArray; //!
    62 
    6360};
    6461
  • modules/TrackSmearing.cc

    re39abb4 r0e7d64a  
    1313#include "classes/DelphesFormula.h"
    1414
     15#include "ExRootAnalysis/ExRootClassifier.h"
     16#include "ExRootAnalysis/ExRootFilter.h"
    1517#include "ExRootAnalysis/ExRootResult.h"
    16 #include "ExRootAnalysis/ExRootFilter.h"
    17 #include "ExRootAnalysis/ExRootClassifier.h"
    18 
     18
     19#include "TDatabasePDG.h"
     20#include "TFile.h"
     21#include "TFormula.h"
     22#include "TLorentzVector.h"
    1923#include "TMath.h"
     24#include "TObjArray.h"
     25#include "TProfile2D.h"
     26#include "TRandom3.h"
    2027#include "TString.h"
    21 #include "TFormula.h"
    22 #include "TRandom3.h"
    23 #include "TObjArray.h"
    24 #include "TDatabasePDG.h"
    25 #include "TLorentzVector.h"
    26 #include "TFile.h"
    27 #include "TProfile2D.h"
    28 
    29 #include <algorithm>
    30 #include <stdexcept>
     28
     29#include <algorithm>
    3130#include <iostream>
    3231#include <sstream>
     32#include <stdexcept>
    3333
    3434using namespace std;
     
    6666
    6767  // !!! IF WE WANT TO KEEP ROOT INPUT !!!
    68   if (string (GetString("D0ResolutionFormula", "0.0")) != "0.0")
    69     {
    70       fD0Formula->Compile(GetString("D0ResolutionFormula", "0.0"));
    71       fUseD0Formula = true;
    72     }
    73   else
    74     {
    75       fD0ResolutionFile = GetString("D0ResolutionFile", "errors.root");
    76       fD0ResolutionHist = GetString("D0ResolutionHist", "d0");
    77       fUseD0Formula = false;
    78     }
    79   if (string (GetString("DZResolutionFormula", "0.0")) != "0.0")
    80     {
    81       fDZFormula->Compile(GetString("DZResolutionFormula", "0.0"));
    82       fUseDZFormula = true;
    83     }
    84   else
    85     {
    86       fDZResolutionFile = GetString("DZResolutionFile", "errors.root");
    87       fDZResolutionHist = GetString("DZResolutionHist", "dz");
    88       fUseDZFormula = false;
    89     }
    90   if (string (GetString("PResolutionFormula", "0.0")) != "0.0")
    91     {
    92       fPFormula->Compile(GetString("PResolutionFormula", "0.0"));
    93       fUsePFormula = true;
    94     }
    95   else
    96     {
    97       fPResolutionFile = GetString("PResolutionFile", "errors.root");
    98       fPResolutionHist = GetString("PResolutionHist", "p");
    99       fUsePFormula = false;
    100     }
    101   if (string (GetString("CtgThetaResolutionFormula", "0.0")) != "0.0")
    102     {
    103       fCtgThetaFormula->Compile(GetString("CtgThetaResolutionFormula", "0.0"));
    104       fUseCtgThetaFormula = true;
    105     }
    106   else
    107     {
    108       fCtgThetaResolutionFile = GetString("CtgThetaResolutionFile", "errors.root");
    109       fCtgThetaResolutionHist = GetString("CtgThetaResolutionHist", "ctgTheta");
    110       fUseCtgThetaFormula = false;
    111     }
    112   if (string (GetString("PhiResolutionFormula", "0.0")) != "0.0")
    113     {
    114       fPhiFormula->Compile(GetString("PhiResolutionFormula", "0.0"));
    115       fUsePhiFormula = true;
    116     }
    117   else
    118     {
    119       fPhiResolutionFile = GetString("PhiResolutionFile", "errors.root");
    120       fPhiResolutionHist = GetString("PhiResolutionHist", "phi");
    121       fUsePhiFormula = false;
    122     }
     68  if(string(GetString("D0ResolutionFormula", "0.0")) != "0.0")
     69  {
     70    fD0Formula->Compile(GetString("D0ResolutionFormula", "0.0"));
     71    fUseD0Formula = true;
     72  }
     73  else
     74  {
     75    fD0ResolutionFile = GetString("D0ResolutionFile", "errors.root");
     76    fD0ResolutionHist = GetString("D0ResolutionHist", "d0");
     77    fUseD0Formula = false;
     78  }
     79  if(string(GetString("DZResolutionFormula", "0.0")) != "0.0")
     80  {
     81    fDZFormula->Compile(GetString("DZResolutionFormula", "0.0"));
     82    fUseDZFormula = true;
     83  }
     84  else
     85  {
     86    fDZResolutionFile = GetString("DZResolutionFile", "errors.root");
     87    fDZResolutionHist = GetString("DZResolutionHist", "dz");
     88    fUseDZFormula = false;
     89  }
     90  if(string(GetString("PResolutionFormula", "0.0")) != "0.0")
     91  {
     92    fPFormula->Compile(GetString("PResolutionFormula", "0.0"));
     93    fUsePFormula = true;
     94  }
     95  else
     96  {
     97    fPResolutionFile = GetString("PResolutionFile", "errors.root");
     98    fPResolutionHist = GetString("PResolutionHist", "p");
     99    fUsePFormula = false;
     100  }
     101  if(string(GetString("CtgThetaResolutionFormula", "0.0")) != "0.0")
     102  {
     103    fCtgThetaFormula->Compile(GetString("CtgThetaResolutionFormula", "0.0"));
     104    fUseCtgThetaFormula = true;
     105  }
     106  else
     107  {
     108    fCtgThetaResolutionFile = GetString("CtgThetaResolutionFile", "errors.root");
     109    fCtgThetaResolutionHist = GetString("CtgThetaResolutionHist", "ctgTheta");
     110    fUseCtgThetaFormula = false;
     111  }
     112  if(string(GetString("PhiResolutionFormula", "0.0")) != "0.0")
     113  {
     114    fPhiFormula->Compile(GetString("PhiResolutionFormula", "0.0"));
     115    fUsePhiFormula = true;
     116  }
     117  else
     118  {
     119    fPhiResolutionFile = GetString("PhiResolutionFile", "errors.root");
     120    fPhiResolutionHist = GetString("PhiResolutionHist", "phi");
     121    fUsePhiFormula = false;
     122  }
    123123
    124124  fApplyToPileUp = GetBool("ApplyToPileUp", true);
     
    128128  fInputArray = ImportArray(GetString("InputArray", "ParticlePropagator/stableParticles"));
    129129  fItInputArray = fInputArray->MakeIterator();
    130  
     130
    131131  // import beamspot
    132132  try
     
    137137  {
    138138    fBeamSpotInputArray = 0;
    139   } 
    140  
     139  }
     140
    141141  // create output array
    142142
     
    170170             *phiErrorHist = NULL;
    171171
    172   if (!fBeamSpotInputArray || fBeamSpotInputArray->GetSize () == 0)
     172  if(!fBeamSpotInputArray || fBeamSpotInputArray->GetSize() == 0)
    173173    beamSpotPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
    174174  else
    175175  {
    176     Candidate &beamSpotCandidate = *((Candidate *) fBeamSpotInputArray->At (0));
     176    Candidate &beamSpotCandidate = *((Candidate *)fBeamSpotInputArray->At(0));
    177177    beamSpotPosition = beamSpotCandidate.Position;
    178178  }
    179179
    180   if (!fUseD0Formula)
    181   {
    182      TFile *fin = TFile::Open (fD0ResolutionFile.c_str ());
    183      d0ErrorHist = (TProfile2D *) fin->Get (fD0ResolutionHist.c_str ());
    184      d0ErrorHist->SetDirectory (0);
    185      fin->Close ();
    186   }
    187   if (!fUseDZFormula)
    188   {
    189      TFile *fin = TFile::Open (fDZResolutionFile.c_str ());
    190      dzErrorHist = (TProfile2D *) fin->Get (fDZResolutionHist.c_str ());
    191      dzErrorHist->SetDirectory (0);
    192      fin->Close ();
    193   }
    194   if (!fUsePFormula)
    195   {
    196      TFile *fin = TFile::Open (fPResolutionFile.c_str ());
    197      pErrorHist = (TProfile2D *) fin->Get (fPResolutionHist.c_str ());
    198      pErrorHist->SetDirectory (0);
    199      fin->Close ();
    200   }
    201   if (!fUseCtgThetaFormula)
    202   {
    203      TFile *fin = TFile::Open (fCtgThetaResolutionFile.c_str ());
    204      ctgThetaErrorHist = (TProfile2D *) fin->Get (fCtgThetaResolutionHist.c_str ());
    205      ctgThetaErrorHist->SetDirectory (0);
    206      fin->Close ();
    207   }
    208   if (!fUsePhiFormula)
    209   {
    210      TFile *fin = TFile::Open (fPhiResolutionFile.c_str ());
    211      phiErrorHist = (TProfile2D *) fin->Get (fPhiResolutionHist.c_str ());
    212      phiErrorHist->SetDirectory (0);
    213      fin->Close ();
     180  if(!fUseD0Formula)
     181  {
     182    TFile *fin = TFile::Open(fD0ResolutionFile.c_str());
     183    d0ErrorHist = (TProfile2D *)fin->Get(fD0ResolutionHist.c_str());
     184    d0ErrorHist->SetDirectory(0);
     185    fin->Close();
     186  }
     187  if(!fUseDZFormula)
     188  {
     189    TFile *fin = TFile::Open(fDZResolutionFile.c_str());
     190    dzErrorHist = (TProfile2D *)fin->Get(fDZResolutionHist.c_str());
     191    dzErrorHist->SetDirectory(0);
     192    fin->Close();
     193  }
     194  if(!fUsePFormula)
     195  {
     196    TFile *fin = TFile::Open(fPResolutionFile.c_str());
     197    pErrorHist = (TProfile2D *)fin->Get(fPResolutionHist.c_str());
     198    pErrorHist->SetDirectory(0);
     199    fin->Close();
     200  }
     201  if(!fUseCtgThetaFormula)
     202  {
     203    TFile *fin = TFile::Open(fCtgThetaResolutionFile.c_str());
     204    ctgThetaErrorHist = (TProfile2D *)fin->Get(fCtgThetaResolutionHist.c_str());
     205    ctgThetaErrorHist->SetDirectory(0);
     206    fin->Close();
     207  }
     208  if(!fUsePhiFormula)
     209  {
     210    TFile *fin = TFile::Open(fPhiResolutionFile.c_str());
     211    phiErrorHist = (TProfile2D *)fin->Get(fPhiResolutionHist.c_str());
     212    phiErrorHist->SetDirectory(0);
     213    fin->Close();
    214214  }
    215215
    216216  fItInputArray->Reset();
    217   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    218   {
    219    
     217  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     218  {
     219
    220220    const TLorentzVector &momentum = candidate->Momentum;
    221221    const TLorentzVector &position = candidate->InitialPosition;
    222    
     222
    223223    pt = momentum.Pt();
    224224    eta = momentum.Eta();
     
    226226    d0 = trueD0 = candidate->D0;
    227227    dz = trueDZ = candidate->DZ;
    228      
     228
    229229    p = trueP = candidate->P;
    230230    ctgTheta = trueCtgTheta = candidate->CtgTheta;
    231231    phi = truePhi = candidate->Phi;
    232232
    233     if (fUseD0Formula)
     233    if(fUseD0Formula)
    234234      d0Error = fD0Formula->Eval(pt, eta);
    235235    else
    236236    {
    237        Int_t xbin, ybin;
    238 
    239        xbin = pt < d0ErrorHist->GetXaxis ()->GetXmax () ? d0ErrorHist->GetXaxis ()->FindBin (pt)
    240             : d0ErrorHist->GetXaxis ()->GetBinCenter (d0ErrorHist->GetXaxis ()->GetNbins ());
    241        ybin = d0ErrorHist->GetYaxis ()->FindBin (TMath::Abs (eta));
    242        d0Error = d0ErrorHist->GetBinContent (xbin, ybin);
    243        if (!d0Error)
    244           d0Error = -1.0;
    245     }
    246     if (d0Error < 0.0)
     237      Int_t xbin, ybin;
     238
     239      xbin = pt < d0ErrorHist->GetXaxis()->GetXmax() ? d0ErrorHist->GetXaxis()->FindBin(pt) : d0ErrorHist->GetXaxis()->GetBinCenter(d0ErrorHist->GetXaxis()->GetNbins());
     240      ybin = d0ErrorHist->GetYaxis()->FindBin(TMath::Abs(eta));
     241      d0Error = d0ErrorHist->GetBinContent(xbin, ybin);
     242      if(!d0Error)
     243        d0Error = -1.0;
     244    }
     245    if(d0Error < 0.0)
    247246      continue;
    248247
    249     if (fUseDZFormula)
     248    if(fUseDZFormula)
    250249      dzError = fDZFormula->Eval(pt, eta);
    251250    else
    252251    {
    253        Int_t xbin, ybin;
    254 
    255        xbin = pt < dzErrorHist->GetXaxis ()->GetXmax () ? dzErrorHist->GetXaxis ()->FindBin (pt)
    256             : dzErrorHist->GetXaxis ()->GetBinCenter (dzErrorHist->GetXaxis ()->GetNbins ());
    257        ybin = dzErrorHist->GetYaxis ()->FindBin (TMath::Abs (eta));
    258        dzError = dzErrorHist->GetBinContent (xbin, ybin);
    259        if (!dzError)
    260           dzError = -1.0;
    261     }
    262     if (dzError < 0.0)
     252      Int_t xbin, ybin;
     253
     254      xbin = pt < dzErrorHist->GetXaxis()->GetXmax() ? dzErrorHist->GetXaxis()->FindBin(pt) : dzErrorHist->GetXaxis()->GetBinCenter(dzErrorHist->GetXaxis()->GetNbins());
     255      ybin = dzErrorHist->GetYaxis()->FindBin(TMath::Abs(eta));
     256      dzError = dzErrorHist->GetBinContent(xbin, ybin);
     257      if(!dzError)
     258        dzError = -1.0;
     259    }
     260    if(dzError < 0.0)
    263261      continue;
    264262
    265     if (fUsePFormula)
     263    if(fUsePFormula)
    266264      pError = fPFormula->Eval(pt, eta) * p;
    267265    else
    268266    {
    269        Int_t xbin, ybin;
    270 
    271        xbin = pt < pErrorHist->GetXaxis ()->GetXmax () ? pErrorHist->GetXaxis ()->FindBin (pt)
    272             : pErrorHist->GetXaxis ()->GetBinCenter (pErrorHist->GetXaxis ()->GetNbins ());
    273        ybin = pErrorHist->GetYaxis ()->FindBin (TMath::Abs (eta));
    274        pError = pErrorHist->GetBinContent (xbin, ybin) * p;
    275        if (!pError)
    276           pError = -1.0;
    277     }
    278     if (pError < 0.0)
     267      Int_t xbin, ybin;
     268
     269      xbin = pt < pErrorHist->GetXaxis()->GetXmax() ? pErrorHist->GetXaxis()->FindBin(pt) : pErrorHist->GetXaxis()->GetBinCenter(pErrorHist->GetXaxis()->GetNbins());
     270      ybin = pErrorHist->GetYaxis()->FindBin(TMath::Abs(eta));
     271      pError = pErrorHist->GetBinContent(xbin, ybin) * p;
     272      if(!pError)
     273        pError = -1.0;
     274    }
     275    if(pError < 0.0)
    279276      continue;
    280277
    281     if (fUseCtgThetaFormula)
     278    if(fUseCtgThetaFormula)
    282279      ctgThetaError = fCtgThetaFormula->Eval(pt, eta);
    283280    else
    284281    {
    285        Int_t xbin, ybin;
    286 
    287        xbin = pt < ctgThetaErrorHist->GetXaxis ()->GetXmax () ? ctgThetaErrorHist->GetXaxis ()->FindBin (pt)
    288             : ctgThetaErrorHist->GetXaxis ()->GetBinCenter (ctgThetaErrorHist->GetXaxis ()->GetNbins ());
    289        ybin = ctgThetaErrorHist->GetYaxis ()->FindBin (TMath::Abs (eta));
    290        ctgThetaError = ctgThetaErrorHist->GetBinContent (xbin, ybin);
    291        if (!ctgThetaError)
    292          ctgThetaError = -1.0;
    293     }
    294     if (ctgThetaError < 0.0)
     282      Int_t xbin, ybin;
     283
     284      xbin = pt < ctgThetaErrorHist->GetXaxis()->GetXmax() ? ctgThetaErrorHist->GetXaxis()->FindBin(pt) : ctgThetaErrorHist->GetXaxis()->GetBinCenter(ctgThetaErrorHist->GetXaxis()->GetNbins());
     285      ybin = ctgThetaErrorHist->GetYaxis()->FindBin(TMath::Abs(eta));
     286      ctgThetaError = ctgThetaErrorHist->GetBinContent(xbin, ybin);
     287      if(!ctgThetaError)
     288        ctgThetaError = -1.0;
     289    }
     290    if(ctgThetaError < 0.0)
    295291      continue;
    296292
    297     if (fUsePhiFormula)
     293    if(fUsePhiFormula)
    298294      phiError = fPhiFormula->Eval(pt, eta);
    299295    else
    300296    {
    301        Int_t xbin, ybin;
    302 
    303        xbin = pt < phiErrorHist->GetXaxis ()->GetXmax () ? phiErrorHist->GetXaxis ()->FindBin (pt)
    304             : phiErrorHist->GetXaxis ()->GetBinCenter (phiErrorHist->GetXaxis ()->GetNbins ());
    305        ybin = phiErrorHist->GetYaxis ()->FindBin (TMath::Abs (eta));
    306        phiError = phiErrorHist->GetBinContent (xbin, ybin);
    307        if (!phiError)
    308           phiError = -1.0;
    309     }
    310     if (phiError < 0.0)
     297      Int_t xbin, ybin;
     298
     299      xbin = pt < phiErrorHist->GetXaxis()->GetXmax() ? phiErrorHist->GetXaxis()->FindBin(pt) : phiErrorHist->GetXaxis()->GetBinCenter(phiErrorHist->GetXaxis()->GetNbins());
     300      ybin = phiErrorHist->GetYaxis()->FindBin(TMath::Abs(eta));
     301      phiError = phiErrorHist->GetBinContent(xbin, ybin);
     302      if(!phiError)
     303        phiError = -1.0;
     304    }
     305    if(phiError < 0.0)
    311306      continue;
    312307
    313     if (fApplyToPileUp || !candidate->IsPU)
    314     {
    315        d0 = gRandom->Gaus(d0, d0Error);
    316        dz = gRandom->Gaus(dz, dzError);
    317        p = gRandom->Gaus(p, pError);
    318        ctgTheta = gRandom->Gaus(ctgTheta, ctgThetaError);
    319        phi = gRandom->Gaus(phi, phiError);
     308    if(fApplyToPileUp || !candidate->IsPU)
     309    {
     310      d0 = gRandom->Gaus(d0, d0Error);
     311      dz = gRandom->Gaus(dz, dzError);
     312      p = gRandom->Gaus(p, pError);
     313      ctgTheta = gRandom->Gaus(ctgTheta, ctgThetaError);
     314      phi = gRandom->Gaus(phi, phiError);
    320315    }
    321316
    322317    if(p < 0.0) continue;
    323     while (phi > TMath::Pi ()) phi -= TMath::TwoPi ();
    324     while (phi <= -TMath::Pi ()) phi += TMath::TwoPi ();
     318    while(phi > TMath::Pi()) phi -= TMath::TwoPi();
     319    while(phi <= -TMath::Pi()) phi += TMath::TwoPi();
    325320
    326321    mother = candidate;
    327     candidate = static_cast<Candidate*>(candidate->Clone());
     322    candidate = static_cast<Candidate *>(candidate->Clone());
    328323    candidate->D0 = d0;
    329324    candidate->DZ = dz;
     
    332327    candidate->Phi = phi;
    333328
    334     theta = TMath::ACos(ctgTheta / TMath::Sqrt (1.0 + ctgTheta * ctgTheta));
    335     candidate->Momentum.SetPx (p * TMath::Cos (phi) * TMath::Sin (theta));
    336     candidate->Momentum.SetPy (p * TMath::Sin (phi) * TMath::Sin (theta));
    337     candidate->Momentum.SetPz (p * TMath::Cos (theta));
    338     candidate->Momentum.SetE (candidate->Momentum.Pt () * TMath::CosH (eta));
    339     candidate->PT = candidate->Momentum.Pt ();
    340 
    341     x = position.X ();
    342     y = position.Y ();
    343     z = position.Z ();
    344     t = position.T ();
    345     px = candidate->Momentum.Px ();
    346     py = candidate->Momentum.Py ();
    347     pz = candidate->Momentum.Pz ();
    348     pt = candidate->Momentum.Pt ();
    349    
     329    theta = TMath::ACos(ctgTheta / TMath::Sqrt(1.0 + ctgTheta * ctgTheta));
     330    candidate->Momentum.SetPx(p * TMath::Cos(phi) * TMath::Sin(theta));
     331    candidate->Momentum.SetPy(p * TMath::Sin(phi) * TMath::Sin(theta));
     332    candidate->Momentum.SetPz(p * TMath::Cos(theta));
     333    candidate->Momentum.SetE(candidate->Momentum.Pt() * TMath::CosH(eta));
     334    candidate->PT = candidate->Momentum.Pt();
     335
     336    x = position.X();
     337    y = position.Y();
     338    z = position.Z();
     339    t = position.T();
     340    px = candidate->Momentum.Px();
     341    py = candidate->Momentum.Py();
     342    pz = candidate->Momentum.Pz();
     343    pt = candidate->Momentum.Pt();
     344
    350345    // -- solve for delta: d0' = ( (x+delta)*py' - (y+delta)*px' )/pt'
    351    
    352     candidate->InitialPosition.SetX (x + ((px * y - py * x + d0 * pt) / (py - px)));
    353     candidate->InitialPosition.SetY (y + ((px * y - py * x + d0 * pt) / (py - px)));
    354     x = candidate->InitialPosition.X ();
    355     y = candidate->InitialPosition.Y ();
    356     candidate->InitialPosition.SetZ (z + ((pz * (px * (x - beamSpotPosition.X ()) + py * (y - beamSpotPosition.Y ())) + pt * pt * (dz - z)) / (pt * pt)));
    357     z = candidate->InitialPosition.Z ();
     346
     347    candidate->InitialPosition.SetX(x + ((px * y - py * x + d0 * pt) / (py - px)));
     348    candidate->InitialPosition.SetY(y + ((px * y - py * x + d0 * pt) / (py - px)));
     349    x = candidate->InitialPosition.X();
     350    y = candidate->InitialPosition.Y();
     351    candidate->InitialPosition.SetZ(z + ((pz * (px * (x - beamSpotPosition.X()) + py * (y - beamSpotPosition.Y())) + pt * pt * (dz - z)) / (pt * pt)));
     352    z = candidate->InitialPosition.Z();
    358353
    359354    candidate->InitialPosition.SetT(t);
     
    366361    q = candidate->Charge;
    367362
    368     r = pt / (q * fBz) * 1.0E9/c_light;        // in [m]
     363    r = pt / (q * fBz) * 1.0E9 / c_light; // in [m]
    369364    phi_0 = TMath::ATan2(py, px); // [rad] in [-pi, pi]
    370365
    371366    // 2. helix axis coordinates
    372     x_c = x + r*TMath::Sin(phi_0);
    373     y_c = y - r*TMath::Cos(phi_0);
     367    x_c = x + r * TMath::Sin(phi_0);
     368    y_c = y - r * TMath::Cos(phi_0);
    374369    r_c = TMath::Hypot(x_c, y_c);
    375370
    376371    rcu = TMath::Abs(r);
    377     rc2 = r_c*r_c;
     372    rc2 = r_c * r_c;
    378373
    379374    // calculate coordinates of closest approach to track circle in transverse plane xd, yd, zd
    380     xd = x_c*x_c*x_c - x_c*rcu*r_c + x_c*y_c*y_c;
     375    xd = x_c * x_c * x_c - x_c * rcu * r_c + x_c * y_c * y_c;
    381376    xd = (rc2 > 0.0) ? xd / rc2 : -999;
    382     yd = y_c*(-rcu*r_c + rc2);
     377    yd = y_c * (-rcu * r_c + rc2);
    383378    yd = (rc2 > 0.0) ? yd / rc2 : -999;
    384     zd = z + (TMath::Sqrt(xd*xd + yd*yd) - TMath::Sqrt(x*x + y*y))*pz/pt;
    385 
    386     candidate->Xd = xd*1.0E3;
    387     candidate->Yd = yd*1.0E3;
    388     candidate->Zd = zd*1.0E3;
    389 
    390     if (fApplyToPileUp || !candidate->IsPU)
    391     {
    392        candidate->ErrorD0 = d0Error;
    393        candidate->ErrorDZ = dzError;
    394        candidate->ErrorP = pError;
    395        candidate->ErrorCtgTheta = ctgThetaError;
    396        candidate->ErrorPhi = phiError;
    397        candidate->ErrorPT = ptError (p, ctgTheta, pError, ctgThetaError);
    398        candidate->TrackResolution = pError/p;
    399     }
    400    
     379    zd = z + (TMath::Sqrt(xd * xd + yd * yd) - TMath::Sqrt(x * x + y * y)) * pz / pt;
     380
     381    candidate->Xd = xd * 1.0E3;
     382    candidate->Yd = yd * 1.0E3;
     383    candidate->Zd = zd * 1.0E3;
     384
     385    if(fApplyToPileUp || !candidate->IsPU)
     386    {
     387      candidate->ErrorD0 = d0Error;
     388      candidate->ErrorDZ = dzError;
     389      candidate->ErrorP = pError;
     390      candidate->ErrorCtgTheta = ctgThetaError;
     391      candidate->ErrorPhi = phiError;
     392      candidate->ErrorPT = ptError(p, ctgTheta, pError, ctgThetaError);
     393      candidate->TrackResolution = pError / p;
     394    }
     395
    401396    candidate->AddCandidate(mother);
    402397    fOutputArray->Add(candidate);
     
    406401}
    407402
    408 Double_t TrackSmearing::ptError (const Double_t p, const Double_t ctgTheta, const Double_t dP, const Double_t dCtgTheta)
     403Double_t TrackSmearing::ptError(const Double_t p, const Double_t ctgTheta, const Double_t dP, const Double_t dCtgTheta)
    409404{
    410405  Double_t a, b;
    411406  a = (p * p * ctgTheta * ctgTheta * dCtgTheta * dCtgTheta) / ((ctgTheta * ctgTheta + 1) * (ctgTheta * ctgTheta + 1) * (ctgTheta * ctgTheta + 1));
    412407  b = (dP * dP) / (ctgTheta * ctgTheta + 1);
    413   return sqrt (a + b);
    414 }
    415 
    416 //------------------------------------------------------------------------------
     408  return sqrt(a + b);
     409}
     410
     411//------------------------------------------------------------------------------
  • modules/TrackSmearing.h

    re39abb4 r0e7d64a  
    2121{
    2222public:
    23 
    2423  TrackSmearing();
    2524  ~TrackSmearing();
     
    3029
    3130private:
    32 
    33   Double_t ptError (const Double_t, const Double_t, const Double_t, const Double_t);
     31  Double_t ptError(const Double_t, const Double_t, const Double_t, const Double_t);
    3432
    3533  Double_t fBz;
     
    6664  const TObjArray *fInputArray; //!
    6765  const TObjArray *fBeamSpotInputArray; //!
    68  
     66
    6967  TObjArray *fOutputArray; //!
    7068
  • modules/TreeWriter.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class TreeWriter
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736#include "ExRootAnalysis/ExRootTreeBranch.h"
    3837
     38#include "TDatabasePDG.h"
     39#include "TFormula.h"
     40#include "TLorentzVector.h"
     41#include "TMath.h"
     42#include "TObjArray.h"
    3943#include "TROOT.h"
    40 #include "TMath.h"
     44#include "TRandom3.h"
    4145#include "TString.h"
    42 #include "TFormula.h"
    43 #include "TRandom3.h"
    44 #include "TObjArray.h"
    45 #include "TDatabasePDG.h"
    46 #include "TLorentzVector.h"
    4746
    4847#include <algorithm>
    49 #include <stdexcept>
    5048#include <iostream>
    5149#include <sstream>
     50#include <stdexcept>
    5251
    5352using namespace std;
     
    8483
    8584  TBranchMap::iterator itBranchMap;
    86   map< TClass *, TProcessMethod >::iterator itClassMap;
     85  map<TClass *, TProcessMethod>::iterator itClassMap;
    8786
    8887  // read branch configuration and
     
    9796
    9897  size = param.GetSize();
    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();
     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();
    104103
    105104    branchClass = gROOT->GetClass(branchClassName);
     
    123122    fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array)));
    124123  }
    125 
    126124}
    127125
     
    139137  it1.Reset();
    140138  array->Clear();
    141   while((candidate = static_cast<Candidate*>(it1.Next())))
     139  while((candidate = static_cast<Candidate *>(it1.Next())))
    142140  {
    143141    TIter it2(candidate->GetCandidates());
     
    151149
    152150    // track
    153     candidate = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
     151    candidate = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
    154152    if(candidate->GetCandidates()->GetEntriesFast() == 0)
    155153    {
     
    160158    // tower
    161159    it2.Reset();
    162     while((candidate = static_cast<Candidate*>(it2.Next())))
     160    while((candidate = static_cast<Candidate *>(it2.Next())))
    163161    {
    164162      array->Add(candidate->GetCandidates()->At(0));
     
    180178  // loop over all particles
    181179  iterator.Reset();
    182   while((candidate = static_cast<Candidate*>(iterator.Next())))
     180  while((candidate = static_cast<Candidate *>(iterator.Next())))
    183181  {
    184182    const TLorentzVector &momentum = candidate->Momentum;
    185183    const TLorentzVector &position = candidate->Position;
    186184
    187     entry = static_cast<GenParticle*>(branch->NewEntry());
     185    entry = static_cast<GenParticle *>(branch->NewEntry());
    188186
    189187    entry->SetBit(kIsReferenced);
     
    193191    cosTheta = TMath::Abs(momentum.CosTheta());
    194192    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    195     eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
    196     rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
     193    eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
     194    rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
    197195
    198196    entry->PID = candidate->PID;
     
    215213    entry->Pz = momentum.Pz();
    216214
    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;
     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;
    223221
    224222    entry->Eta = eta;
     
    231229    entry->Y = position.Y();
    232230    entry->Z = position.Z();
    233     entry->T = position.T()*1.0E-3/c_light;
     231    entry->T = position.T() * 1.0E-3 / c_light;
    234232  }
    235233}
     
    255253  // loop over all vertices
    256254  iterator.Reset();
    257   while((candidate = static_cast<Candidate*>(iterator.Next())))
     255  while((candidate = static_cast<Candidate *>(iterator.Next())))
    258256  {
    259257
     
    269267    y = candidate->Position.Y();
    270268    z = candidate->Position.Z();
    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());
     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 *>(branch->NewEntry());
    279277
    280278    entry->Index = index;
     
    296294    entry->ErrorT = tError;
    297295
    298 
    299296    TIter itConstituents(candidate->GetCandidates());
    300297    itConstituents.Reset();
    301298    entry->Constituents.Clear();
    302     while((constituent = static_cast<Candidate*>(itConstituents.Next())))
     299    while((constituent = static_cast<Candidate *>(itConstituents.Next())))
    303300    {
    304301      entry->Constituents.Add(constituent);
    305302    }
    306 
    307   }
    308 }
    309 
     303  }
     304}
    310305
    311306//------------------------------------------------------------------------------
     
    322317  // loop over all tracks
    323318  iterator.Reset();
    324   while((candidate = static_cast<Candidate*>(iterator.Next())))
     319  while((candidate = static_cast<Candidate *>(iterator.Next())))
    325320  {
    326321    const TLorentzVector &position = candidate->Position;
     
    328323    cosTheta = TMath::Abs(position.CosTheta());
    329324    signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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 *>(branch->NewEntry());
    334329
    335330    entry->SetBit(kIsReferenced);
     
    346341    entry->YOuter = position.Y();
    347342    entry->ZOuter = position.Z();
    348     entry->TOuter = position.T()*1.0E-3/c_light;
     343    entry->TOuter = position.T() * 1.0E-3 / c_light;
    349344
    350345    entry->L = candidate->L;
    351346
    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;
     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;
    359354    entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
    360     entry->ErrorPhi      = candidate->ErrorPhi;
     355    entry->ErrorPhi = candidate->ErrorPhi;
    361356
    362357    entry->Xd = candidate->Xd;
     
    369364    p = momentum.P();
    370365    phi = momentum.Phi();
    371     ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1/TMath::Tan(momentum.Theta()) : 1e10;
     366    ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1 / TMath::Tan(momentum.Theta()) : 1e10;
    372367
    373368    cosTheta = TMath::Abs(momentum.CosTheta());
    374369    signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    375     eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta());
    376     rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity());
     370    eta = (cosTheta == 1.0 ? signz * 999.9 : momentum.Eta());
     371    rapidity = (cosTheta == 1.0 ? signz * 999.9 : momentum.Rapidity());
    377372
    378373    entry->P = p;
    379     entry->PT  = pt;
     374    entry->PT = pt;
    380375    entry->Eta = eta;
    381376    entry->Phi = phi;
    382377    entry->CtgTheta = ctgTheta;
    383378
    384     particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
     379    particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
    385380    const TLorentzVector &initialPosition = particle->Position;
    386381
     
    388383    entry->Y = initialPosition.Y();
    389384    entry->Z = initialPosition.Z();
    390     entry->T = initialPosition.T()*1.0E-3/c_light;
     385    entry->T = initialPosition.T() * 1.0E-3 / c_light;
    391386
    392387    entry->Particle = particle;
    393388
    394389    entry->VertexIndex = candidate->ClusterIndex;
    395 
    396390  }
    397391}
     
    409403  // loop over all towers
    410404  iterator.Reset();
    411   while((candidate = static_cast<Candidate*>(iterator.Next())))
     405  while((candidate = static_cast<Candidate *>(iterator.Next())))
    412406  {
    413407    const TLorentzVector &momentum = candidate->Momentum;
     
    417411    cosTheta = TMath::Abs(momentum.CosTheta());
    418412    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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 *>(branch->NewEntry());
    423417
    424418    entry->SetBit(kIsReferenced);
     
    436430    entry->Edges[3] = candidate->Edges[3];
    437431
    438     entry->T = position.T()*1.0E-3/c_light;
     432    entry->T = position.T() * 1.0E-3 / c_light;
    439433    entry->NTimeHits = candidate->NTimeHits;
    440434
     
    457451  // loop over all photons
    458452  iterator.Reset();
    459   while((candidate = static_cast<Candidate*>(iterator.Next())))
     453  while((candidate = static_cast<Candidate *>(iterator.Next())))
    460454  {
    461455    TIter it1(candidate->GetCandidates());
     
    466460    cosTheta = TMath::Abs(momentum.CosTheta());
    467461    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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 *>(branch->NewEntry());
    472466
    473467    entry->Eta = eta;
     
    475469    entry->PT = pt;
    476470    entry->E = momentum.E();
    477     entry->T = position.T()*1.0E-3/c_light;
     471    entry->T = position.T() * 1.0E-3 / c_light;
    478472
    479473    // Isolation variables
    480474
    481475    entry->IsolationVar = candidate->IsolationVar;
    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;
     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;
    489483
    490484    // 1: prompt -- 2: non prompt -- 3: fake
     
    509503  // loop over all electrons
    510504  iterator.Reset();
    511   while((candidate = static_cast<Candidate*>(iterator.Next())))
     505  while((candidate = static_cast<Candidate *>(iterator.Next())))
    512506  {
    513507    const TLorentzVector &momentum = candidate->Momentum;
     
    517511    cosTheta = TMath::Abs(momentum.CosTheta());
    518512    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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 *>(branch->NewEntry());
    523517
    524518    entry->Eta = eta;
     
    526520    entry->PT = pt;
    527521
    528     entry->T = position.T()*1.0E-3/c_light;
     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;
    529529
    530530    // Isolation variables
    531 
    532531    entry->IsolationVar = candidate->IsolationVar;
    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 
     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;
    539537
    540538    entry->Charge = candidate->Charge;
     
    561559  // loop over all muons
    562560  iterator.Reset();
    563   while((candidate = static_cast<Candidate*>(iterator.Next())))
     561  while((candidate = static_cast<Candidate *>(iterator.Next())))
    564562  {
    565563    const TLorentzVector &momentum = candidate->Momentum;
     
    569567    cosTheta = TMath::Abs(momentum.CosTheta());
    570568    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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 *>(branch->NewEntry());
    575573
    576574    entry->SetBit(kIsReferenced);
     
    581579    entry->PT = pt;
    582580
    583     entry->T = position.T()*1.0E-3/c_light;
     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;
    584588
    585589    // Isolation variables
    586590
    587591    entry->IsolationVar = candidate->IsolationVar;
    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 ;
     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;
    593597
    594598    entry->Charge = candidate->Charge;
     
    614618  // loop over all jets
    615619  iterator.Reset();
    616   while((candidate = static_cast<Candidate*>(iterator.Next())))
     620  while((candidate = static_cast<Candidate *>(iterator.Next())))
    617621  {
    618622    TIter itConstituents(candidate->GetCandidates());
     
    624628    cosTheta = TMath::Abs(momentum.CosTheta());
    625629    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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 *>(branch->NewEntry());
    630634
    631635    entry->Eta = eta;
     
    633637    entry->PT = pt;
    634638
    635     entry->T = position.T()*1.0E-3/c_light;
     639    entry->T = position.T() * 1.0E-3 / c_light;
    636640
    637641    entry->Mass = momentum.M();
     
    660664    ecalEnergy = 0.0;
    661665    hcalEnergy = 0.0;
    662     while((constituent = static_cast<Candidate*>(itConstituents.Next())))
     666    while((constituent = static_cast<Candidate *>(itConstituents.Next())))
    663667    {
    664668      entry->Constituents.Add(constituent);
     
    667671    }
    668672
    669     entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
     673    entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy / ecalEnergy : 999.9;
    670674
    671675    //---   Pile-Up Jet ID variables ----
     
    684688    entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
    685689
    686     entry->SoftDroppedJet     = candidate->SoftDroppedJet ;
    687     entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1 ;
     690    entry->SoftDroppedJet = candidate->SoftDroppedJet;
     691    entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1;
    688692    entry->SoftDroppedSubJet2 = candidate->SoftDroppedSubJet2;
    689 
    690693
    691694    for(i = 0; i < 5; i++)
    692695    {
    693       entry->FracPt[i] = candidate -> FracPt[i];
    694       entry->Tau[i] = candidate -> Tau[i];
    695       entry->TrimmedP4[i] = candidate -> TrimmedP4[i];
    696       entry->PrunedP4[i] = candidate -> PrunedP4[i];
    697       entry->SoftDroppedP4[i] = candidate -> SoftDroppedP4[i];
     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];
    698701    }
    699702
     
    702705    entry->ExclYmerge34 = candidate->ExclYmerge34;
    703706    entry->ExclYmerge45 = candidate->ExclYmerge45;
    704     entry->ExclYmerge56 = candidate->ExclYmerge56;   
    705 
     707    entry->ExclYmerge56 = candidate->ExclYmerge56;
    706708
    707709    FillParticles(candidate, &entry->Particles);
     
    717719
    718720  // get the first entry
    719   if((candidate = static_cast<Candidate*>(array->At(0))))
    720   {
    721     const TLorentzVector &momentum = candidate->Momentum;
    722 
    723     entry = static_cast<MissingET*>(branch->NewEntry());
     721  if((candidate = static_cast<Candidate *>(array->At(0))))
     722  {
     723    const TLorentzVector &momentum = candidate->Momentum;
     724
     725    entry = static_cast<MissingET *>(branch->NewEntry());
    724726
    725727    entry->Eta = (-momentum).Eta();
     
    737739
    738740  // get the first entry
    739   if((candidate = static_cast<Candidate*>(array->At(0))))
    740   {
    741     const TLorentzVector &momentum = candidate->Momentum;
    742 
    743     entry = static_cast<ScalarHT*>(branch->NewEntry());
     741  if((candidate = static_cast<Candidate *>(array->At(0))))
     742  {
     743    const TLorentzVector &momentum = candidate->Momentum;
     744
     745    entry = static_cast<ScalarHT *>(branch->NewEntry());
    744746
    745747    entry->HT = momentum.Pt();
     
    757759  // loop over all rho
    758760  iterator.Reset();
    759   while((candidate = static_cast<Candidate*>(iterator.Next())))
    760   {
    761     const TLorentzVector &momentum = candidate->Momentum;
    762 
    763     entry = static_cast<Rho*>(branch->NewEntry());
     761  while((candidate = static_cast<Candidate *>(iterator.Next())))
     762  {
     763    const TLorentzVector &momentum = candidate->Momentum;
     764
     765    entry = static_cast<Rho *>(branch->NewEntry());
    764766
    765767    entry->Rho = momentum.E();
     
    777779
    778780  // get the first entry
    779   if((candidate = static_cast<Candidate*>(array->At(0))))
    780   {
    781     const TLorentzVector &momentum = candidate->Momentum;
    782 
    783     entry = static_cast<Weight*>(branch->NewEntry());
     781  if((candidate = static_cast<Candidate *>(array->At(0))))
     782  {
     783    const TLorentzVector &momentum = candidate->Momentum;
     784
     785    entry = static_cast<Weight *>(branch->NewEntry());
    784786
    785787    entry->Weight = momentum.E();
     
    797799  // loop over all roman pot hits
    798800  iterator.Reset();
    799   while((candidate = static_cast<Candidate*>(iterator.Next())))
     801  while((candidate = static_cast<Candidate *>(iterator.Next())))
    800802  {
    801803    const TLorentzVector &position = candidate->Position;
    802804    const TLorentzVector &momentum = candidate->Momentum;
    803805
    804     entry = static_cast<HectorHit*>(branch->NewEntry());
     806    entry = static_cast<HectorHit *>(branch->NewEntry());
    805807
    806808    entry->E = momentum.E();
  • modules/TreeWriter.h

    re39abb4 r0e7d64a  
    4242{
    4343public:
    44 
    4544  TreeWriter();
    4645  ~TreeWriter();
     
    5150
    5251private:
    53 
    5452  void FillParticles(Candidate *candidate, TRefArray *array);
    5553
     
    7270  typedef void (TreeWriter::*TProcessMethod)(ExRootTreeBranch *, TObjArray *); //!
    7371
    74   typedef std::map< ExRootTreeBranch *, std::pair< TProcessMethod, TObjArray * > > TBranchMap; //!
     72  typedef std::map<ExRootTreeBranch *, std::pair<TProcessMethod, TObjArray *> > TBranchMap; //!
    7573
    7674  TBranchMap fBranchMap; //!
    7775
    78   std::map< TClass *, TProcessMethod > fClassMap; //!
     76  std::map<TClass *, TProcessMethod> fClassMap; //!
    7977#endif
    8078
  • modules/UniqueObjectFinder.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class UniqueObjectFinder
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    46 #include <algorithm>
    47 #include <stdexcept>
     45#include <algorithm>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    6766void UniqueObjectFinder::Init()
    6867{
     68  // use GetUniqueID algorithm to find unique objects (faster than the default Overlaps method)
     69  fUseUniqueID = GetBool("UseUniqueID", false);
     70
    6971  // import arrays with output from other modules
    7072
     
    7779
    7880  size = param.GetSize();
    79   for(i = 0; i < size/2; ++i)
     81  for(i = 0; i < size / 2; ++i)
    8082  {
    81     array = ImportArray(param[i*2].GetString());
     83    array = ImportArray(param[i * 2].GetString());
    8284    iterator = array->MakeIterator();
    8385
    84     fInputMap.push_back(make_pair(iterator, ExportArray(param[i*2 + 1].GetString())));
     86    fInputMap.push_back(make_pair(iterator, ExportArray(param[i * 2 + 1].GetString())));
    8587  }
    8688}
     
    9092void UniqueObjectFinder::Finish()
    9193{
    92   vector< pair< TIterator *, TObjArray * > >::iterator itInputMap;
     94  vector<pair<TIterator *, TObjArray *> >::iterator itInputMap;
    9395  TIterator *iterator;
    9496
     
    106108{
    107109  Candidate *candidate;
    108   vector< pair< TIterator *, TObjArray * > >::iterator itInputMap;
     110  vector<pair<TIterator *, TObjArray *> >::iterator itInputMap;
    109111  TIterator *iterator;
    110112  TObjArray *array;
     
    118120    // loop over all candidates
    119121    iterator->Reset();
    120     while((candidate = static_cast<Candidate*>(iterator->Next())))
     122    while((candidate = static_cast<Candidate *>(iterator->Next())))
    121123    {
    122124      if(Unique(candidate, itInputMap))
     
    130132//------------------------------------------------------------------------------
    131133
    132 Bool_t UniqueObjectFinder::Unique(Candidate *candidate, vector< pair< TIterator *, TObjArray * > >::iterator itInputMap)
     134Bool_t UniqueObjectFinder::Unique(Candidate *candidate, vector<pair<TIterator *, TObjArray *> >::iterator itInputMap)
    133135{
    134136  Candidate *previousCandidate;
    135   vector< pair< TIterator *, TObjArray * > >::iterator previousItInputMap;
     137  vector<pair<TIterator *, TObjArray *> >::iterator previousItInputMap;
    136138  TObjArray *array;
    137139
     
    144146    // loop over all candidates
    145147    iterator.Reset();
    146     while((previousCandidate = static_cast<Candidate*>(iterator.Next())))
     148    while((previousCandidate = static_cast<Candidate *>(iterator.Next())))
    147149    {
    148       if(candidate->Overlaps(previousCandidate))
     150      if(fUseUniqueID)
    149151      {
    150         return kFALSE;
     152        if(candidate->GetUniqueID() == previousCandidate->GetUniqueID())
     153        {
     154          return kFALSE;
     155        }
     156      }
     157      else
     158      {
     159        if(candidate->Overlaps(previousCandidate))
     160        {
     161          return kFALSE;
     162        }
    151163      }
    152164    }
  • modules/UniqueObjectFinder.h

    re39abb4 r0e7d64a  
    3030#include "classes/DelphesModule.h"
    3131
     32#include <utility>
    3233#include <vector>
    33 #include <utility>
    3434
    3535class TIterator;
     
    4040{
    4141public:
    42 
    4342  UniqueObjectFinder();
    4443  ~UniqueObjectFinder();
     
    4948
    5049private:
     50  Bool_t fUseUniqueID;
    5151
    52   Bool_t Unique(Candidate *candidate, std::vector< std::pair< TIterator *, TObjArray * > >::iterator itInputMap);
     52  Bool_t Unique(Candidate *candidate, std::vector<std::pair<TIterator *, TObjArray *> >::iterator itInputMap);
    5353
    54   std::vector< std::pair< TIterator *, TObjArray * > > fInputMap; //!
     54  std::vector<std::pair<TIterator *, TObjArray *> > fInputMap; //!
    5555
    5656  ClassDef(UniqueObjectFinder, 1)
  • modules/VertexFinder.cc

    re39abb4 r0e7d64a  
    77 */
    88
    9 
    109#include "modules/VertexFinder.h"
    1110#include "classes/DelphesClasses.h"
     
    1413#include "classes/DelphesPileUpReader.h"
    1514
     15#include "ExRootAnalysis/ExRootClassifier.h"
     16#include "ExRootAnalysis/ExRootFilter.h"
    1617#include "ExRootAnalysis/ExRootResult.h"
    17 #include "ExRootAnalysis/ExRootFilter.h"
    18 #include "ExRootAnalysis/ExRootClassifier.h"
    19 
     18
     19#include "TDatabasePDG.h"
     20#include "TFormula.h"
     21#include "TLorentzVector.h"
    2022#include "TMath.h"
     23#include "TMatrixT.h"
     24#include "TObjArray.h"
     25#include "TRandom3.h"
    2126#include "TString.h"
    22 #include "TFormula.h"
    23 #include "TRandom3.h"
    24 #include "TObjArray.h"
    25 #include "TDatabasePDG.h"
    26 #include "TLorentzVector.h"
    27 #include "TMatrixT.h"
    2827#include "TVector3.h"
    2928
     29#include <algorithm>
     30#include <iostream>
     31#include <map>
     32#include <stdexcept>
     33#include <string>
    3034#include <utility>
    31 #include <algorithm>
    32 #include <stdexcept>
    33 #include <iostream>
    3435#include <vector>
    35 #include <map>
    36 #include <string>
    3736
    3837using namespace std;
    3938
    40 static const Double_t mm  = 1.;
    41 static const Double_t m = 1000.*mm;
    42 static const Double_t ns  = 1.;
    43 static const Double_t s = 1.e+9 *ns;
    44 static const Double_t c_light   = 2.99792458e+8 * m/s;
     39static const Double_t mm = 1.;
     40static const Double_t m = 1000. * mm;
     41static const Double_t ns = 1.;
     42static const Double_t s = 1.e+9 * ns;
     43static const Double_t c_light = 2.99792458e+8 * m / s;
    4544
    4645//------------------------------------------------------------------------------
     
    8483//------------------------------------------------------------------------------
    8584
    86 static Bool_t secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     85static Bool_t secondAscending(pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    8786{
    8887  return (pair0.second < pair1.second);
    8988}
    9089
    91 static Bool_t secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     90static Bool_t secondDescending(pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    9291{
    9392  return (pair0.second > pair1.second);
     
    101100
    102101  // Clear the track and cluster maps before starting
    103   trackIDToDouble.clear ();
    104   trackIDToInt.clear ();
    105   trackIDToBool.clear ();
    106   clusterIDToDouble.clear ();
    107   clusterIDToInt.clear ();
    108   clusterIDToBool.clear ();
    109   trackPT.clear ();
    110   clusterSumPT2.clear ();
     102  trackIDToDouble.clear();
     103  trackIDToInt.clear();
     104  trackIDToBool.clear();
     105  clusterIDToDouble.clear();
     106  clusterIDToInt.clear();
     107  clusterIDToBool.clear();
     108  trackPT.clear();
     109  clusterSumPT2.clear();
    111110
    112111  // Create the initial cluster seeds
    113   createSeeds ();
     112  createSeeds();
    114113
    115114  // In order of descending seed pt, grow each cluster. If a cluster ends up with
    116115  // fewer than MinNDF tracks, release the tracks for other clusters to claim.
    117   sort (clusterSumPT2.begin (), clusterSumPT2.end (), secondDescending);
    118   for (vector<pair<UInt_t, Double_t> >::const_iterator cluster = clusterSumPT2.begin (); cluster != clusterSumPT2.end (); cluster++)
    119     {
    120       // Skip the cluster if it no longer has any tracks
    121       if (!clusterIDToInt.at (cluster->first).at ("ndf"))
    122         continue;
    123        
    124       // Grow the cluster if GrowSeeds is true
    125       if (fGrowSeeds)
    126         growCluster (cluster->first);
    127 
    128       // If the cluster still has fewer than MinNDF tracks, release the tracks;
    129       // otherwise, mark the seed track as claimed
    130      
    131       if ((Int_t) clusterIDToInt.at (cluster->first).at ("ndf") < fMinNDF)
    132         {
    133           for (map<UInt_t, map<string, Int_t> >::iterator track = trackIDToInt.begin (); track != trackIDToInt.end (); track++)
    134             {
    135               if (track->second.at ("clusterIndex") != (Int_t) cluster->first)
    136                 continue;
    137               track->second["clusterIndex"] = -1;
    138               trackIDToBool[track->first]["claimed"] = false;
    139             }
    140         }
    141       else
    142         trackIDToBool[clusterIDToInt.at (cluster->first).at ("seed")]["claimed"] = true;
    143     }
     116  sort(clusterSumPT2.begin(), clusterSumPT2.end(), secondDescending);
     117  for(vector<pair<UInt_t, Double_t> >::const_iterator cluster = clusterSumPT2.begin(); cluster != clusterSumPT2.end(); cluster++)
     118  {
     119    // Skip the cluster if it no longer has any tracks
     120    if(!clusterIDToInt.at(cluster->first).at("ndf"))
     121      continue;
     122
     123    // Grow the cluster if GrowSeeds is true
     124    if(fGrowSeeds)
     125      growCluster(cluster->first);
     126
     127    // If the cluster still has fewer than MinNDF tracks, release the tracks;
     128    // otherwise, mark the seed track as claimed
     129
     130    if((Int_t)clusterIDToInt.at(cluster->first).at("ndf") < fMinNDF)
     131    {
     132      for(map<UInt_t, map<string, Int_t> >::iterator track = trackIDToInt.begin(); track != trackIDToInt.end(); track++)
     133      {
     134        if(track->second.at("clusterIndex") != (Int_t)cluster->first)
     135          continue;
     136        track->second["clusterIndex"] = -1;
     137        trackIDToBool[track->first]["claimed"] = false;
     138      }
     139    }
     140    else
     141      trackIDToBool[clusterIDToInt.at(cluster->first).at("seed")]["claimed"] = true;
     142  }
    144143
    145144  // Add tracks to the output array after updating their ClusterIndex.
    146   fItInputArray->Reset ();
    147   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    148     {
    149       if (candidate->Momentum.Pt () < fMinPT || fabs (candidate->Momentum.Eta ()) > fMaxEta)
    150         continue;
    151       candidate->ClusterIndex = trackIDToInt.at (candidate->GetUniqueID ()).at ("clusterIndex");
    152       fOutputArray->Add(candidate);
    153     }
     145  fItInputArray->Reset();
     146  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     147  {
     148    if(candidate->Momentum.Pt() < fMinPT || fabs(candidate->Momentum.Eta()) > fMaxEta)
     149      continue;
     150    candidate->ClusterIndex = trackIDToInt.at(candidate->GetUniqueID()).at("clusterIndex");
     151    fOutputArray->Add(candidate);
     152  }
    154153
    155154  // Add clusters with at least MinNDF tracks to the output array in order of
    156155  // descending sum(pt**2).
    157   clusterSumPT2.clear ();
    158   for (map<UInt_t, map<string, Int_t> >::const_iterator cluster = clusterIDToInt.begin (); cluster != clusterIDToInt.end (); cluster++)
    159   {
    160    
    161     if (cluster->second.at ("ndf") < fMinNDF)
    162       continue;
    163     clusterSumPT2.push_back (make_pair (cluster->first, clusterIDToDouble.at (cluster->first).at ("sumPT2")));
    164   }
    165   sort (clusterSumPT2.begin (), clusterSumPT2.end (), secondDescending);
    166  
    167   for (vector<pair<UInt_t, Double_t> >::const_iterator cluster = clusterSumPT2.begin (); cluster != clusterSumPT2.end (); cluster++)
     156  clusterSumPT2.clear();
     157  for(map<UInt_t, map<string, Int_t> >::const_iterator cluster = clusterIDToInt.begin(); cluster != clusterIDToInt.end(); cluster++)
     158  {
     159
     160    if(cluster->second.at("ndf") < fMinNDF)
     161      continue;
     162    clusterSumPT2.push_back(make_pair(cluster->first, clusterIDToDouble.at(cluster->first).at("sumPT2")));
     163  }
     164  sort(clusterSumPT2.begin(), clusterSumPT2.end(), secondDescending);
     165
     166  for(vector<pair<UInt_t, Double_t> >::const_iterator cluster = clusterSumPT2.begin(); cluster != clusterSumPT2.end(); cluster++)
    168167  {
    169168    DelphesFactory *factory = GetFactory();
     
    171170
    172171    candidate->ClusterIndex = cluster->first;
    173     candidate->ClusterNDF = clusterIDToInt.at (cluster->first).at ("ndf");
     172    candidate->ClusterNDF = clusterIDToInt.at(cluster->first).at("ndf");
    174173    candidate->ClusterSigma = fSigma;
    175174    candidate->SumPT2 = cluster->second;
    176     candidate->Position.SetXYZT(0.0, 0.0, clusterIDToDouble.at (cluster->first).at ("z"), 0.0);
    177     candidate->PositionError.SetXYZT(0.0, 0.0, clusterIDToDouble.at (cluster->first).at ("ez"), 0.0);
     175    candidate->Position.SetXYZT(0.0, 0.0, clusterIDToDouble.at(cluster->first).at("z"), 0.0);
     176    candidate->PositionError.SetXYZT(0.0, 0.0, clusterIDToDouble.at(cluster->first).at("ez"), 0.0);
    178177
    179178    fVertexOutputArray->Add(candidate);
     
    183182//------------------------------------------------------------------------------
    184183
    185 void VertexFinder::createSeeds ()
     184void VertexFinder::createSeeds()
    186185{
    187186  Candidate *candidate;
     
    190189  // Loop over all tracks, initializing some variables.
    191190  fItInputArray->Reset();
    192   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    193     {
    194       if (candidate->Momentum.Pt () < fMinPT || fabs (candidate->Momentum.Eta ()) > fMaxEta)
    195         continue;
    196 
    197       trackIDToDouble[candidate->GetUniqueID ()]["pt"] = candidate->Momentum.Pt ();
    198       trackIDToDouble[candidate->GetUniqueID ()]["ept"] = candidate->ErrorPT ? candidate->ErrorPT : 1.0e-15;;
    199       trackIDToDouble[candidate->GetUniqueID ()]["eta"] = candidate->Momentum.Eta ();
    200 
    201       trackIDToDouble[candidate->GetUniqueID ()]["z"] = candidate->DZ;
    202       trackIDToDouble[candidate->GetUniqueID ()]["ez"] = candidate->ErrorDZ ? candidate->ErrorDZ : 1.0e-15;
    203 
    204       trackIDToInt[candidate->GetUniqueID ()]["clusterIndex"] = -1;
    205       trackIDToInt[candidate->GetUniqueID ()]["interactionIndex"] = candidate->IsPU;
    206 
    207       trackIDToBool[candidate->GetUniqueID ()]["claimed"] = false;
    208 
    209       trackPT.push_back (make_pair (candidate->GetUniqueID (), candidate->Momentum.Pt ()));
    210     }
     191  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     192  {
     193    if(candidate->Momentum.Pt() < fMinPT || fabs(candidate->Momentum.Eta()) > fMaxEta)
     194      continue;
     195
     196    trackIDToDouble[candidate->GetUniqueID()]["pt"] = candidate->Momentum.Pt();
     197    trackIDToDouble[candidate->GetUniqueID()]["ept"] = candidate->ErrorPT ? candidate->ErrorPT : 1.0e-15;
     198    ;
     199    trackIDToDouble[candidate->GetUniqueID()]["eta"] = candidate->Momentum.Eta();
     200
     201    trackIDToDouble[candidate->GetUniqueID()]["z"] = candidate->DZ;
     202    trackIDToDouble[candidate->GetUniqueID()]["ez"] = candidate->ErrorDZ ? candidate->ErrorDZ : 1.0e-15;
     203
     204    trackIDToInt[candidate->GetUniqueID()]["clusterIndex"] = -1;
     205    trackIDToInt[candidate->GetUniqueID()]["interactionIndex"] = candidate->IsPU;
     206
     207    trackIDToBool[candidate->GetUniqueID()]["claimed"] = false;
     208
     209    trackPT.push_back(make_pair(candidate->GetUniqueID(), candidate->Momentum.Pt()));
     210  }
    211211
    212212  // Sort tracks by pt and leave only the SeedMinPT highest pt ones in the
    213213  // trackPT vector.
    214   sort (trackPT.begin (), trackPT.end (), secondDescending);
    215   for (vector<pair<UInt_t, Double_t> >::const_iterator track = trackPT.begin (); track != trackPT.end (); track++, maxSeeds++)
    216     {
    217       if (track->second < fSeedMinPT)
    218         break;
    219     }
     214  sort(trackPT.begin(), trackPT.end(), secondDescending);
     215  for(vector<pair<UInt_t, Double_t> >::const_iterator track = trackPT.begin(); track != trackPT.end(); track++, maxSeeds++)
     216  {
     217    if(track->second < fSeedMinPT)
     218      break;
     219  }
    220220  // If there are no tracks with pt above MinSeedPT, create just one seed from
    221221  // the highest pt track.
    222   if (!maxSeeds)
     222  if(!maxSeeds)
    223223    maxSeeds++;
    224   if (trackPT.size () > maxSeeds)
    225     {
    226       trackPT.erase (trackPT.begin () + maxSeeds, trackPT.end ());
    227     }
     224  if(trackPT.size() > maxSeeds)
     225  {
     226    trackPT.erase(trackPT.begin() + maxSeeds, trackPT.end());
     227  }
    228228
    229229  // Create the seeds from the SeedMinPT highest pt tracks.
    230   for (vector<pair<UInt_t, Double_t> >::const_iterator track = trackPT.begin (); track != trackPT.end (); track++, clusterIndex++)
    231     {
    232       addTrackToCluster (track->first, clusterIndex);
    233       clusterSumPT2.push_back (make_pair (clusterIndex, track->second * track->second));
    234     }
    235 }
    236 
    237 //------------------------------------------------------------------------------
    238 
    239 void VertexFinder::growCluster (const UInt_t clusterIndex)
     230  for(vector<pair<UInt_t, Double_t> >::const_iterator track = trackPT.begin(); track != trackPT.end(); track++, clusterIndex++)
     231  {
     232    addTrackToCluster(track->first, clusterIndex);
     233    clusterSumPT2.push_back(make_pair(clusterIndex, track->second * track->second));
     234  }
     235}
     236
     237//------------------------------------------------------------------------------
     238
     239void VertexFinder::growCluster(const UInt_t clusterIndex)
    240240{
    241241  Bool_t done = false;
     
    244244  Double_t nearestDistance;
    245245  vector<UInt_t> nearTracks;
    246   nearTracks.clear ();
     246  nearTracks.clear();
    247247
    248248  // Grow the cluster until there are no more tracks within Sigma standard
    249249  // deviations of the cluster.
    250   while (!done)
    251     {
    252       done = true;
    253       nearestID = 0;
    254       nearestDistance = -1.0;
    255 
    256       // These two loops are for finding the nearest track to the cluster. The
    257       // first time, the ID of each track within 10*Sigma of the cluster is
    258       // saved in the nearTracks vector; subsequently, to save time, only the
    259       // tracks in this vector are checked.
    260       if (!nearTracks.size ())
     250  while(!done)
     251  {
     252    done = true;
     253    nearestID = 0;
     254    nearestDistance = -1.0;
     255
     256    // These two loops are for finding the nearest track to the cluster. The
     257    // first time, the ID of each track within 10*Sigma of the cluster is
     258    // saved in the nearTracks vector; subsequently, to save time, only the
     259    // tracks in this vector are checked.
     260    if(!nearTracks.size())
     261    {
     262
     263      for(map<UInt_t, map<string, Double_t> >::const_iterator track = trackIDToDouble.begin(); track != trackIDToDouble.end(); track++)
     264      {
     265        if(trackIDToBool.at(track->first).at("claimed") || trackIDToInt.at(track->first).at("clusterIndex") == (Int_t)clusterIndex)
     266          continue;
     267
     268        Double_t distance = fabs(clusterIDToDouble.at(clusterIndex).at("z") - track->second.at("z")) / hypot(clusterIDToDouble.at(clusterIndex).at("ez"), track->second.at("ez"));
     269        if(nearestDistance < 0.0 || distance < nearestDistance)
    261270        {
    262        
    263             for (map<UInt_t, map<string, Double_t> >::const_iterator track = trackIDToDouble.begin (); track != trackIDToDouble.end (); track++)
    264             {
    265               if (trackIDToBool.at (track->first).at ("claimed") || trackIDToInt.at (track->first).at ("clusterIndex") == (Int_t) clusterIndex)
    266                 continue;
    267                
    268               Double_t distance = fabs (clusterIDToDouble.at (clusterIndex).at ("z") - track->second.at ("z")) / hypot (clusterIDToDouble.at (clusterIndex).at ("ez"), track->second.at ("ez"));
    269               if (nearestDistance < 0.0 || distance < nearestDistance)
    270                 {
    271                   nearestID = track->first;
    272                   nearestDistance = distance;
    273                 }
    274               if (distance < 10.0 * fSigma)
    275                 nearTracks.push_back (track->first);
    276             }
     271          nearestID = track->first;
     272          nearestDistance = distance;
    277273        }
    278      
    279       else
     274        if(distance < 10.0 * fSigma)
     275          nearTracks.push_back(track->first);
     276      }
     277    }
     278
     279    else
     280    {
     281      for(vector<UInt_t>::const_iterator track = nearTracks.begin(); track != nearTracks.end(); track++)
     282      {
     283        if(trackIDToBool.at(*track).at("claimed") || trackIDToInt.at(*track).at("clusterIndex") == (Int_t)clusterIndex)
     284          continue;
     285        Double_t distance = fabs(clusterIDToDouble.at(clusterIndex).at("z") - trackIDToDouble.at(*track).at("z")) / hypot(clusterIDToDouble.at(clusterIndex).at("ez"), trackIDToDouble.at(*track).at("ez"));
     286        if(nearestDistance < 0.0 || distance < nearestDistance)
    280287        {
    281           for (vector<UInt_t>::const_iterator track = nearTracks.begin (); track != nearTracks.end (); track++)
    282             {
    283               if (trackIDToBool.at (*track).at ("claimed") || trackIDToInt.at (*track).at ("clusterIndex") == (Int_t) clusterIndex)
    284                 continue;
    285               Double_t distance = fabs (clusterIDToDouble.at (clusterIndex).at ("z") - trackIDToDouble.at (*track).at ("z")) / hypot (clusterIDToDouble.at (clusterIndex).at ("ez"), trackIDToDouble.at (*track).at ("ez"));
    286               if (nearestDistance < 0.0 || distance < nearestDistance)
    287                 {
    288                   nearestID = *track;
    289                   nearestDistance = distance;
    290                 }
    291             }
     288          nearestID = *track;
     289          nearestDistance = distance;
    292290        }
    293      
    294       // If no tracks within Sigma of the cluster were found, stop growing.
    295       done = nearestDistance > fSigma || nearestDistance < 0.0;
    296       if (done)
    297         {
    298           continue;
    299         }
    300 
    301       // Add the nearest track within Sigma to the cluster. If it already
    302       // belonged to another cluster, remove it from that cluster first.
    303       if (nearestDistance < fSigma)
    304         {
    305           oldClusterIndex = trackIDToInt.at (nearestID).at ("clusterIndex");
    306           if (oldClusterIndex >= 0)
    307             removeTrackFromCluster (nearestID, oldClusterIndex);
    308 
    309           trackIDToBool[nearestID]["claimed"] = true;
    310           addTrackToCluster (nearestID, clusterIndex);
    311         }
    312     }
    313 }
    314 
    315 //------------------------------------------------------------------------------
    316 
    317 Double_t VertexFinder::weight (const UInt_t trackID)
    318 {
    319   return ((trackIDToDouble.at (trackID).at ("pt") / (trackIDToDouble.at (trackID).at ("ept") * trackIDToDouble.at (trackID).at ("ez"))) * (trackIDToDouble.at (trackID).at ("pt") / (trackIDToDouble.at (trackID).at ("ept") * trackIDToDouble.at (trackID).at ("ez"))));
    320 }
    321 
    322 //------------------------------------------------------------------------------
    323 
    324 void VertexFinder::removeTrackFromCluster (const UInt_t trackID, const UInt_t clusterID)
    325 {
    326   Double_t wz = weight (trackID);
     291      }
     292    }
     293
     294    // If no tracks within Sigma of the cluster were found, stop growing.
     295    done = nearestDistance > fSigma || nearestDistance < 0.0;
     296    if(done)
     297    {
     298      continue;
     299    }
     300
     301    // Add the nearest track within Sigma to the cluster. If it already
     302    // belonged to another cluster, remove it from that cluster first.
     303    if(nearestDistance < fSigma)
     304    {
     305      oldClusterIndex = trackIDToInt.at(nearestID).at("clusterIndex");
     306      if(oldClusterIndex >= 0)
     307        removeTrackFromCluster(nearestID, oldClusterIndex);
     308
     309      trackIDToBool[nearestID]["claimed"] = true;
     310      addTrackToCluster(nearestID, clusterIndex);
     311    }
     312  }
     313}
     314
     315//------------------------------------------------------------------------------
     316
     317Double_t VertexFinder::weight(const UInt_t trackID)
     318{
     319  return ((trackIDToDouble.at(trackID).at("pt") / (trackIDToDouble.at(trackID).at("ept") * trackIDToDouble.at(trackID).at("ez"))) * (trackIDToDouble.at(trackID).at("pt") / (trackIDToDouble.at(trackID).at("ept") * trackIDToDouble.at(trackID).at("ez"))));
     320}
     321
     322//------------------------------------------------------------------------------
     323
     324void VertexFinder::removeTrackFromCluster(const UInt_t trackID, const UInt_t clusterID)
     325{
     326  Double_t wz = weight(trackID);
    327327
    328328  trackIDToInt[trackID]["clusterIndex"] = -1;
    329329  clusterIDToInt[clusterID]["ndf"]--;
    330330
    331   clusterIDToDouble[clusterID]["sumZ"] -= wz * trackIDToDouble.at (trackID).at ("z");
    332   clusterIDToDouble[clusterID]["errorSumZ"] -= wz * trackIDToDouble.at (trackID).at ("ez") * trackIDToDouble.at (trackID).at ("ez");
     331  clusterIDToDouble[clusterID]["sumZ"] -= wz * trackIDToDouble.at(trackID).at("z");
     332  clusterIDToDouble[clusterID]["errorSumZ"] -= wz * trackIDToDouble.at(trackID).at("ez") * trackIDToDouble.at(trackID).at("ez");
    333333  clusterIDToDouble[clusterID]["sumOfWeightsZ"] -= wz;
    334   clusterIDToDouble[clusterID]["z"] = clusterIDToDouble.at (clusterID).at ("sumZ") / clusterIDToDouble.at (clusterID).at ("sumOfWeightsZ");
    335   clusterIDToDouble[clusterID]["ez"] = sqrt ((1.0 / clusterIDToInt.at (clusterID).at ("ndf")) * (clusterIDToDouble.at (clusterID).at ("errorSumZ") / clusterIDToDouble.at (clusterID).at ("sumOfWeightsZ")));
    336   clusterIDToDouble[clusterID]["sumPT2"] -= trackIDToDouble.at (trackID).at ("pt") * trackIDToDouble.at (trackID).at ("pt");
    337 }
    338 
    339 //------------------------------------------------------------------------------
    340 
    341 void VertexFinder::addTrackToCluster (const UInt_t trackID, const UInt_t clusterID)
    342 {
    343   Double_t wz = weight (trackID);
    344 
    345   if (!clusterIDToInt.count (clusterID))
    346     {
    347       clusterIDToInt[clusterID]["ndf"] = 0;
    348       clusterIDToInt[clusterID]["seed"] = trackID;
    349       clusterIDToDouble[clusterID]["sumZ"] = 0.0;
    350       clusterIDToDouble[clusterID]["errorSumZ"] = 0.0;
    351       clusterIDToDouble[clusterID]["sumOfWeightsZ"] = 0.0;
    352       clusterIDToDouble[clusterID]["sumPT2"] = 0.0;
    353     }
     334  clusterIDToDouble[clusterID]["z"] = clusterIDToDouble.at(clusterID).at("sumZ") / clusterIDToDouble.at(clusterID).at("sumOfWeightsZ");
     335  clusterIDToDouble[clusterID]["ez"] = sqrt((1.0 / clusterIDToInt.at(clusterID).at("ndf")) * (clusterIDToDouble.at(clusterID).at("errorSumZ") / clusterIDToDouble.at(clusterID).at("sumOfWeightsZ")));
     336  clusterIDToDouble[clusterID]["sumPT2"] -= trackIDToDouble.at(trackID).at("pt") * trackIDToDouble.at(trackID).at("pt");
     337}
     338
     339//------------------------------------------------------------------------------
     340
     341void VertexFinder::addTrackToCluster(const UInt_t trackID, const UInt_t clusterID)
     342{
     343  Double_t wz = weight(trackID);
     344
     345  if(!clusterIDToInt.count(clusterID))
     346  {
     347    clusterIDToInt[clusterID]["ndf"] = 0;
     348    clusterIDToInt[clusterID]["seed"] = trackID;
     349    clusterIDToDouble[clusterID]["sumZ"] = 0.0;
     350    clusterIDToDouble[clusterID]["errorSumZ"] = 0.0;
     351    clusterIDToDouble[clusterID]["sumOfWeightsZ"] = 0.0;
     352    clusterIDToDouble[clusterID]["sumPT2"] = 0.0;
     353  }
    354354
    355355  trackIDToInt[trackID]["clusterIndex"] = clusterID;
    356356  clusterIDToInt[clusterID]["ndf"]++;
    357357
    358   clusterIDToDouble[clusterID]["sumZ"] += wz * trackIDToDouble.at (trackID).at ("z");
    359   clusterIDToDouble[clusterID]["errorSumZ"] += wz * trackIDToDouble.at (trackID).at ("ez") * trackIDToDouble.at (trackID).at ("ez");
     358  clusterIDToDouble[clusterID]["sumZ"] += wz * trackIDToDouble.at(trackID).at("z");
     359  clusterIDToDouble[clusterID]["errorSumZ"] += wz * trackIDToDouble.at(trackID).at("ez") * trackIDToDouble.at(trackID).at("ez");
    360360  clusterIDToDouble[clusterID]["sumOfWeightsZ"] += wz;
    361   clusterIDToDouble[clusterID]["z"] = clusterIDToDouble.at (clusterID).at ("sumZ") / clusterIDToDouble.at (clusterID).at ("sumOfWeightsZ");
    362   clusterIDToDouble[clusterID]["ez"] = sqrt ((1.0 / clusterIDToInt.at (clusterID).at ("ndf")) * (clusterIDToDouble.at (clusterID).at ("errorSumZ") / clusterIDToDouble.at (clusterID).at ("sumOfWeightsZ")));
    363   clusterIDToDouble[clusterID]["sumPT2"] += trackIDToDouble.at (trackID).at ("pt") * trackIDToDouble.at (trackID).at ("pt");
    364 }
    365 
    366 //------------------------------------------------------------------------------
     361  clusterIDToDouble[clusterID]["z"] = clusterIDToDouble.at(clusterID).at("sumZ") / clusterIDToDouble.at(clusterID).at("sumOfWeightsZ");
     362  clusterIDToDouble[clusterID]["ez"] = sqrt((1.0 / clusterIDToInt.at(clusterID).at("ndf")) * (clusterIDToDouble.at(clusterID).at("errorSumZ") / clusterIDToDouble.at(clusterID).at("sumOfWeightsZ")));
     363  clusterIDToDouble[clusterID]["sumPT2"] += trackIDToDouble.at(trackID).at("pt") * trackIDToDouble.at(trackID).at("pt");
     364}
     365
     366//------------------------------------------------------------------------------
  • modules/VertexFinder.h

    re39abb4 r0e7d64a  
    1010 */
    1111
    12 
    1312#include "classes/DelphesModule.h"
    1413
     14#include <map>
    1515#include <string>
    1616#include <vector>
    17 #include <map>
    1817
    1918class TObjArray;
     
    2322{
    2423public:
    25 
    2624  VertexFinder();
    2725  ~VertexFinder();
     
    3230
    3331private:
    34 
    35   void createSeeds ();
    36   void growCluster (const UInt_t);
    37   Double_t weight (const UInt_t);
    38   void addTrackToCluster (const UInt_t, const UInt_t);
    39   void removeTrackFromCluster (const UInt_t, const UInt_t);
     32  void createSeeds();
     33  void growCluster(const UInt_t);
     34  Double_t weight(const UInt_t);
     35  void addTrackToCluster(const UInt_t, const UInt_t);
     36  void removeTrackFromCluster(const UInt_t, const UInt_t);
    4037
    4138  Double_t fSigma;
  • modules/VertexFinderDA4D.cc

    re39abb4 r0e7d64a  
    77 */
    88
    9 
    109#include "modules/VertexFinderDA4D.h"
    1110#include "classes/DelphesClasses.h"
     
    1413#include "classes/DelphesPileUpReader.h"
    1514
     15#include "ExRootAnalysis/ExRootClassifier.h"
     16#include "ExRootAnalysis/ExRootFilter.h"
    1617#include "ExRootAnalysis/ExRootResult.h"
    17 #include "ExRootAnalysis/ExRootFilter.h"
    18 #include "ExRootAnalysis/ExRootClassifier.h"
    19 
     18
     19#include "TDatabasePDG.h"
     20#include "TFormula.h"
     21#include "TLorentzVector.h"
    2022#include "TMath.h"
     23#include "TMatrixT.h"
     24#include "TObjArray.h"
     25#include "TRandom3.h"
    2126#include "TString.h"
    22 #include "TFormula.h"
    23 #include "TRandom3.h"
    24 #include "TObjArray.h"
    25 #include "TDatabasePDG.h"
    26 #include "TLorentzVector.h"
    27 #include "TMatrixT.h"
    2827#include "TVector3.h"
    2928
     29#include <algorithm>
     30#include <iostream>
     31#include <stdexcept>
    3032#include <utility>
    31 #include <algorithm>
    32 #include <stdexcept>
    33 #include <iostream>
    3433#include <vector>
    3534
    3635using namespace std;
    3736
    38 static const Double_t mm  = 1.;
    39 static const Double_t m = 1000.*mm;
    40 static const Double_t ns  = 1.;
    41 static const Double_t s = 1.e+9 *ns;
    42 static const Double_t c_light   = 2.99792458e+8 * m/s;
     37static const Double_t mm = 1.;
     38static const Double_t m = 1000. * mm;
     39static const Double_t ns = 1.;
     40static const Double_t s = 1.e+9 * ns;
     41static const Double_t c_light = 2.99792458e+8 * m / s;
    4342
    4443struct track_t
    4544{
    46   double z;      // z-coordinate at point of closest approach to the beamline
    47   double t;      // t-coordinate at point of closest approach to the beamline
    48   double dz2;    // square of the error of z(pca)
    49   double dtz;    // covariance of z-t
    50   double dt2;    // square of the error of t(pca)
     45  double z; // z-coordinate at point of closest approach to the beamline
     46  double t; // t-coordinate at point of closest approach to the beamline
     47  double dz2; // square of the error of z(pca)
     48  double dtz; // covariance of z-t
     49  double dt2; // square of the error of t(pca)
    5150  Candidate *tt; // a pointer to the Candidate Track
    52   double Z;      // Z[i]   for DA clustering
    53   double pi;     // track weight
     51  double Z; // Z[i]   for DA clustering
     52  double pi; // track weight
    5453  double pt;
    5554  double eta;
     
    6160  double z;
    6261  double t;
    63   double pk;     // vertex weight for "constrained" clustering
     62  double pk; // vertex weight for "constrained" clustering
    6463  // --- temporary numbers, used during update
    6564  double ei;
     
    7675static double update1(double beta, std::vector<track_t> &tks, std::vector<vertex_t> &y);
    7776static double update2(double beta, std::vector<track_t> &tks, std::vector<vertex_t> &y, double &rho0, const double dzCutOff);
    78 static void dump(const double beta, const std::vector<vertex_t> & y, const std::vector<track_t> & tks);
     77static void dump(const double beta, const std::vector<vertex_t> &y, const std::vector<track_t> &tks);
    7978static bool merge(std::vector<vertex_t> &);
    8079static bool merge(std::vector<vertex_t> &, double &);
    81 static bool purge(std::vector<vertex_t> &, std::vector<track_t> & , double &, const double, const double);
     80static bool purge(std::vector<vertex_t> &, std::vector<track_t> &, double &, const double, const double);
    8281static void splitAll(std::vector<vertex_t> &y);
    8382static double beta0(const double betamax, std::vector<track_t> &tks, std::vector<vertex_t> &y, const double coolingFactor);
    8483static double Eik(const track_t &t, const vertex_t &k);
    8584
    86 static bool recTrackLessZ1(const track_t & tk1, const track_t & tk2)
     85static bool recTrackLessZ1(const track_t &tk1, const track_t &tk2)
    8786{
    8887  return tk1.z < tk2.z;
     
    115114  fVertexSpaceSize = GetDouble("VertexSpaceSize", 0.5); //in mm
    116115  fVertexTimeSize = GetDouble("VertexTimeSize", 10E-12); //in s
    117   fUseTc         = GetBool("UseTc", 1);
    118   fBetaMax       = GetDouble("BetaMax ", 0.1);
    119   fBetaStop      = GetDouble("BetaStop", 1.0);
     116  fUseTc = GetBool("UseTc", 1);
     117  fBetaMax = GetDouble("BetaMax ", 0.1);
     118  fBetaStop = GetDouble("BetaStop", 1.0);
    120119  fCoolingFactor = GetDouble("CoolingFactor", 0.8);
    121120  fMaxIterations = GetInt("MaxIterations", 100);
    122   fDzCutOff      = GetDouble("DzCutOff", 40); // Adaptive Fitter uses 30 mm but that appears to be a bit tight here sometimes
    123   fD0CutOff      = GetDouble("D0CutOff", 30);
    124   fDtCutOff      = GetDouble("DtCutOff", 100E-12); // dummy
     121  fDzCutOff = GetDouble("DzCutOff", 40); // Adaptive Fitter uses 30 mm but that appears to be a bit tight here sometimes
     122  fD0CutOff = GetDouble("D0CutOff", 30);
     123  fDtCutOff = GetDouble("DtCutOff", 100E-12); // dummy
    125124
    126125  // convert stuff in cm, ns
    127126  fVertexSpaceSize /= 10.0;
    128127  fVertexTimeSize *= 1E9;
    129   fDzCutOff       /= 10.0;  // Adaptive Fitter uses 3.0 but that appears to be a bit tight here sometimes
    130   fD0CutOff       /= 10.0;
     128  fDzCutOff /= 10.0; // Adaptive Fitter uses 3.0 but that appears to be a bit tight here sometimes
     129  fD0CutOff /= 10.0;
    131130
    132131  fInputArray = ImportArray(GetString("InputArray", "TrackSmearing/tracks"));
     
    157156
    158157  TLorentzVector pos, mom;
    159   if (fVerbose)
    160   {
    161      cout<<" start processing vertices ..."<<endl;
    162      cout<<" Found "<<fInputArray->GetEntriesFast()<<" input tracks"<<endl;
    163      //loop over input tracks
    164      fItInputArray->Reset();
    165      while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    166      {
    167         pos = candidate->InitialPosition;
    168         mom = candidate->Momentum;
    169 
    170         cout<<"pt: "<<mom.Pt()<<", eta: "<<mom.Eta()<<", phi: "<<mom.Phi()<<", z: "<<candidate->DZ/10<<endl;
    171      }
     158  if(fVerbose)
     159  {
     160    cout << " start processing vertices ..." << endl;
     161    cout << " Found " << fInputArray->GetEntriesFast() << " input tracks" << endl;
     162    //loop over input tracks
     163    fItInputArray->Reset();
     164    while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     165    {
     166      pos = candidate->InitialPosition;
     167      mom = candidate->Momentum;
     168
     169      cout << "pt: " << mom.Pt() << ", eta: " << mom.Eta() << ", phi: " << mom.Phi() << ", z: " << candidate->DZ / 10 << endl;
     170    }
    172171  }
    173172
     
    175174  clusterize(*fInputArray, *ClusterArray);
    176175
    177   if (fVerbose){std::cout <<  " clustering returned  "<< ClusterArray->GetEntriesFast() << " clusters  from " << fInputArray->GetEntriesFast() << " selected tracks" <<std::endl;}
     176  if(fVerbose)
     177  {
     178    std::cout << " clustering returned  " << ClusterArray->GetEntriesFast() << " clusters  from " << fInputArray->GetEntriesFast() << " selected tracks" << std::endl;
     179  }
    178180
    179181  //loop over vertex candidates
    180182  ItClusterArray = ClusterArray->MakeIterator();
    181183  ItClusterArray->Reset();
    182   while((candidate = static_cast<Candidate*>(ItClusterArray->Next())))
    183   {
    184 
    185      double meantime = 0.;
    186      double expv_x2 = 0.;
    187      double normw = 0.;
    188      double errtime = 0;
    189 
    190      double meanpos = 0.;
    191      double meanerr2 = 0.;
    192      double normpos = 0.;
    193      double errpos = 0.;
    194 
    195      double sumpt2 = 0.;
    196 
    197      int itr = 0;
    198 
    199      if(fVerbose)cout<<"this vertex has: "<<candidate->GetCandidates()->GetEntriesFast()<<" tracks"<<endl;
    200 
    201      // loop over tracks belonging to this vertex
    202      TIter it1(candidate->GetCandidates());
    203      it1.Reset();
    204 
    205      while((track = static_cast<Candidate*>(it1.Next())))
    206      {
    207 
    208         itr++;
    209         // TBC: the time is in ns for now TBC
    210         double t = track->InitialPosition.T()/c_light;
    211         double dt = track->ErrorT/c_light;
    212         const double time = t;
    213         const double inverr = 1.0/dt;
    214         meantime += time*inverr;
    215         expv_x2  += time*time*inverr;
    216         normw    += inverr;
    217 
    218         // compute error position TBC
    219         const double pt = track->Momentum.Pt();
    220         const double z = track->DZ/10.0;
    221         const double err_pt = track->ErrorPT;
    222         const double err_z = track->ErrorDZ;
    223 
    224         const double wi = (pt/(err_pt*err_z))*(pt/(err_pt*err_z));
    225         meanpos += z*wi;
    226 
    227         meanerr2 += err_z*err_z*wi;
    228         normpos += wi;
    229         sumpt2 += pt*pt;
    230 
    231         // while we are here store cluster index in tracks
    232         track->ClusterIndex = ivtx;
    233      }
    234 
    235      meantime = meantime/normw;
    236      expv_x2 = expv_x2/normw;
    237      errtime = TMath::Sqrt((expv_x2 - meantime*meantime)/itr);
    238      meanpos = meanpos/normpos;
    239      meanerr2 = meanerr2/normpos;
    240      errpos = TMath::Sqrt(meanerr2/itr);
    241 
    242      candidate->Position.SetXYZT(0.0, 0.0, meanpos*10.0 , meantime*c_light);
    243      candidate->PositionError.SetXYZT(0.0, 0.0, errpos*10.0 , errtime*c_light);
    244      candidate->SumPT2 = sumpt2;
    245      candidate->ClusterNDF = itr;
    246      candidate->ClusterIndex = ivtx;
    247 
    248      fVertexOutputArray->Add(candidate);
    249 
    250      ivtx++;
    251 
    252      if (fVerbose){
    253      std::cout << "x,y,z";
    254        std::cout << ",t";
    255        std::cout << "=" << candidate->Position.X()/10.0 <<" " << candidate->Position.Y()/10.0 << " " <<  candidate->Position.Z()/10.0;
    256        std::cout << " " << candidate->Position.T()/c_light;
    257 
    258        std::cout << std::endl;
    259        std::cout << "sumpt2 " << candidate->SumPT2<<endl;
    260      
    261        std::cout << "ex,ey,ez";
    262        std::cout << ",et";
    263        std::cout << "=" << candidate->PositionError.X()/10.0 <<" " << candidate->PositionError.Y()/10.0 << " " <<  candidate->PositionError.Z()/10.0;
    264        std::cout << " " << candidate->PositionError.T()/c_light;
    265        std::cout << std::endl;
    266 
    267       }
    268    }// end of cluster loop
    269 
    270 
    271     if(fVerbose){
    272       std::cout << "PrimaryVertexProducerAlgorithm::vertices candidates =" << ClusterArray->GetEntriesFast() << std::endl;
    273     }
    274 
    275     //TBC maybe this can be done later
    276     // sort vertices by pt**2  vertex (aka signal vertex tagging)
    277     /*if(pvs.size()>1){
     184  while((candidate = static_cast<Candidate *>(ItClusterArray->Next())))
     185  {
     186
     187    double meantime = 0.;
     188    double expv_x2 = 0.;
     189    double normw = 0.;
     190    double errtime = 0;
     191
     192    double meanpos = 0.;
     193    double meanerr2 = 0.;
     194    double normpos = 0.;
     195    double errpos = 0.;
     196
     197    double sumpt2 = 0.;
     198
     199    int itr = 0;
     200
     201    if(fVerbose) cout << "this vertex has: " << candidate->GetCandidates()->GetEntriesFast() << " tracks" << endl;
     202
     203    // loop over tracks belonging to this vertex
     204    TIter it1(candidate->GetCandidates());
     205    it1.Reset();
     206
     207    while((track = static_cast<Candidate *>(it1.Next())))
     208    {
     209
     210      itr++;
     211      // TBC: the time is in ns for now TBC
     212      double t = track->InitialPosition.T() / c_light;
     213      double dt = track->ErrorT / c_light;
     214      const double time = t;
     215      const double inverr = 1.0 / dt;
     216      meantime += time * inverr;
     217      expv_x2 += time * time * inverr;
     218      normw += inverr;
     219
     220      // compute error position TBC
     221      const double pt = track->Momentum.Pt();
     222      const double z = track->DZ / 10.0;
     223      const double err_pt = track->ErrorPT;
     224      const double err_z = track->ErrorDZ;
     225
     226      const double wi = (pt / (err_pt * err_z)) * (pt / (err_pt * err_z));
     227      meanpos += z * wi;
     228
     229      meanerr2 += err_z * err_z * wi;
     230      normpos += wi;
     231      sumpt2 += pt * pt;
     232
     233      // while we are here store cluster index in tracks
     234      track->ClusterIndex = ivtx;
     235    }
     236
     237    meantime = meantime / normw;
     238    expv_x2 = expv_x2 / normw;
     239    errtime = TMath::Sqrt((expv_x2 - meantime * meantime) / itr);
     240    meanpos = meanpos / normpos;
     241    meanerr2 = meanerr2 / normpos;
     242    errpos = TMath::Sqrt(meanerr2 / itr);
     243
     244    candidate->Position.SetXYZT(0.0, 0.0, meanpos * 10.0, meantime * c_light);
     245    candidate->PositionError.SetXYZT(0.0, 0.0, errpos * 10.0, errtime * c_light);
     246    candidate->SumPT2 = sumpt2;
     247    candidate->ClusterNDF = itr;
     248    candidate->ClusterIndex = ivtx;
     249
     250    fVertexOutputArray->Add(candidate);
     251
     252    ivtx++;
     253
     254    if(fVerbose)
     255    {
     256      std::cout << "x,y,z";
     257      std::cout << ",t";
     258      std::cout << "=" << candidate->Position.X() / 10.0 << " " << candidate->Position.Y() / 10.0 << " " << candidate->Position.Z() / 10.0;
     259      std::cout << " " << candidate->Position.T() / c_light;
     260
     261      std::cout << std::endl;
     262      std::cout << "sumpt2 " << candidate->SumPT2 << endl;
     263
     264      std::cout << "ex,ey,ez";
     265      std::cout << ",et";
     266      std::cout << "=" << candidate->PositionError.X() / 10.0 << " " << candidate->PositionError.Y() / 10.0 << " " << candidate->PositionError.Z() / 10.0;
     267      std::cout << " " << candidate->PositionError.T() / c_light;
     268      std::cout << std::endl;
     269    }
     270  } // end of cluster loop
     271
     272  if(fVerbose)
     273  {
     274    std::cout << "PrimaryVertexProducerAlgorithm::vertices candidates =" << ClusterArray->GetEntriesFast() << std::endl;
     275  }
     276
     277  //TBC maybe this can be done later
     278  // sort vertices by pt**2  vertex (aka signal vertex tagging)
     279  /*if(pvs.size()>1){
    278280      sort(pvs.begin(), pvs.end(), VertexHigherPtSquared());
    279281    }
     
    281283
    282284  delete ClusterArray;
    283 
    284285}
    285286
     
    288289void VertexFinderDA4D::clusterize(const TObjArray &tracks, TObjArray &clusters)
    289290{
    290   if(fVerbose) {
     291  if(fVerbose)
     292  {
    291293    cout << "###################################################" << endl;
    292     cout << "# VertexFinderDA4D::clusterize   nt="<<tracks.GetEntriesFast() << endl;
     294    cout << "# VertexFinderDA4D::clusterize   nt=" << tracks.GetEntriesFast() << endl;
    293295    cout << "###################################################" << endl;
    294296  }
    295297
    296   vector< Candidate* > pv = vertices();
    297 
    298   if(fVerbose){ cout << "# VertexFinderDA4D::clusterize   pv.size="<<pv.size() << endl;  }
    299   if (pv.size()==0){ return;  }
     298  vector<Candidate *> pv = vertices();
     299
     300  if(fVerbose)
     301  {
     302    cout << "# VertexFinderDA4D::clusterize   pv.size=" << pv.size() << endl;
     303  }
     304  if(pv.size() == 0)
     305  {
     306    return;
     307  }
    300308
    301309  // convert into vector of candidates
    302310  //TObjArray *ClusterArray = pv.begin()->GetCandidates();
    303311  //Candidate *aCluster = static_cast<Candidate*>(&(pv.at(0)));
    304    Candidate *aCluster = pv.at(0);
     312  Candidate *aCluster = pv.at(0);
    305313
    306314  // fill into clusters and merge
    307315
    308 
    309   if( fVerbose ) {
    310       std::cout << '\t' << 0;
    311       std::cout << ' ' << (*pv.begin())->Position.Z()/10.0 << ' ' << (*pv.begin())->Position.T()/c_light << std::endl;
    312     }
    313 
    314   for(vector<Candidate*>::iterator k=pv.begin()+1; k!=pv.end(); k++){
    315     if( fVerbose ) {
    316       std::cout << '\t' << std::distance(pv.begin(),k);
     316  if(fVerbose)
     317  {
     318    std::cout << '\t' << 0;
     319    std::cout << ' ' << (*pv.begin())->Position.Z() / 10.0 << ' ' << (*pv.begin())->Position.T() / c_light << std::endl;
     320  }
     321
     322  for(vector<Candidate *>::iterator k = pv.begin() + 1; k != pv.end(); k++)
     323  {
     324    if(fVerbose)
     325    {
     326      std::cout << '\t' << std::distance(pv.begin(), k);
    317327      std::cout << ' ' << (*k)->Position.Z() << ' ' << (*k)->Position.T() << std::endl;
    318328    }
    319329
    320 
    321330    // TBC - check units here
    322     if ( std::abs((*k)->Position.Z() - (*(k-1))->Position.Z())/10.0 > (2*fVertexSpaceSize) ||
    323          std::abs((*k)->Position.T() - (*(k-1))->Position.Z())/c_light > 2*0.010 ) {
     331    if(std::abs((*k)->Position.Z() - (*(k - 1))->Position.Z()) / 10.0 > (2 * fVertexSpaceSize) || std::abs((*k)->Position.T() - (*(k - 1))->Position.Z()) / c_light > 2 * 0.010)
     332    {
    324333      // close a cluster
    325334      clusters.Add(aCluster);
     
    327336    }
    328337    //for(unsigned int i=0; i<k->GetCandidates().GetEntriesFast(); i++){
    329       aCluster = *k;
     338    aCluster = *k;
    330339    //}
    331 
    332340  }
    333341  clusters.Add(aCluster);
    334342
    335   if(fVerbose) { std::cout << "# VertexFinderDA4D::clusterize clusters.size="<<clusters.GetEntriesFast() << std::endl; }
    336 
    337 }
    338 
    339 //------------------------------------------------------------------------------
    340 
    341 vector< Candidate* > VertexFinderDA4D::vertices()
     343  if(fVerbose)
     344  {
     345    std::cout << "# VertexFinderDA4D::clusterize clusters.size=" << clusters.GetEntriesFast() << std::endl;
     346  }
     347}
     348
     349//------------------------------------------------------------------------------
     350
     351vector<Candidate *> VertexFinderDA4D::vertices()
    342352{
    343353  Candidate *candidate;
    344354  UInt_t clusterIndex = 0;
    345   vector< Candidate* > clusters;
     355  vector<Candidate *> clusters;
    346356
    347357  vector<track_t> tks;
     
    351361  // loop over input tracks
    352362  fItInputArray->Reset();
    353   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     363  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    354364  {
    355365    //TBC everything in cm
    356     z = candidate->DZ/10;
     366    z = candidate->DZ / 10;
    357367    tr.z = z;
    358     dz = candidate->ErrorDZ/10;
    359     tr.dz2 = dz*dz          // track error
    360     //TBC: beamspot size induced error, take 0 for now.
    361     // + (std::pow(beamspot.BeamWidthX()*cos(phi),2.)+std::pow(beamspot.BeamWidthY()*sin(phi),2.))/std::pow(tantheta,2.) // beam-width induced
    362     + fVertexSpaceSize*fVertexSpaceSize; // intrinsic vertex size, safer for outliers and short lived decays
     368    dz = candidate->ErrorDZ / 10;
     369    tr.dz2 = dz * dz // track error
     370      //TBC: beamspot size induced error, take 0 for now.
     371      // + (std::pow(beamspot.BeamWidthX()*cos(phi),2.)+std::pow(beamspot.BeamWidthY()*sin(phi),2.))/std::pow(tantheta,2.) // beam-width induced
     372      + fVertexSpaceSize * fVertexSpaceSize; // intrinsic vertex size, safer for outliers and short lived decays
    363373
    364374    // TBC: the time is in ns for now TBC
    365375    //t = candidate->Position.T()/c_light;
    366     t = candidate->InitialPosition.T()/c_light;
    367     l = candidate->L/c_light;
     376    t = candidate->InitialPosition.T() / c_light;
     377    l = candidate->L / c_light;
    368378    double pt = candidate->Momentum.Pt();
    369379    double eta = candidate->Momentum.Eta();
     
    375385    tr.t = t; //
    376386    tr.dtz = 0.;
    377     dt = candidate->ErrorT/c_light;
    378     tr.dt2 = dt*dt + fVertexTimeSize*fVertexTimeSize;   // the ~injected~ timing error plus a small minimum vertex size in time
    379     if(fD0CutOff>0)
    380     {
    381 
    382       d0 = TMath::Abs(candidate->D0)/10.0;
    383       d0error = candidate->ErrorD0/10.0;
    384 
    385       tr.pi=1./(1.+exp((d0*d0)/(d0error*d0error) - fD0CutOff*fD0CutOff));  // reduce weight for high ip tracks
    386 
     387    dt = candidate->ErrorT / c_light;
     388    tr.dt2 = dt * dt + fVertexTimeSize * fVertexTimeSize; // the ~injected~ timing error plus a small minimum vertex size in time
     389    if(fD0CutOff > 0)
     390    {
     391
     392      d0 = TMath::Abs(candidate->D0) / 10.0;
     393      d0error = candidate->ErrorD0 / 10.0;
     394
     395      tr.pi = 1. / (1. + exp((d0 * d0) / (d0error * d0error) - fD0CutOff * fD0CutOff)); // reduce weight for high ip tracks
    387396    }
    388397    else
    389398    {
    390       tr.pi=1.;
    391     }
    392     tr.tt=&(*candidate);
    393     tr.Z=1.;
     399      tr.pi = 1.;
     400    }
     401    tr.tt = &(*candidate);
     402    tr.Z = 1.;
    394403
    395404    // TBC now putting track selection here (> fPTMin)
     
    404413  if(fVerbose)
    405414  {
    406     std::cout<<" start processing vertices ..."<<std::endl;
    407     std::cout<<" Found "<<tks.size()<<" input tracks"<<std::endl;
     415    std::cout << " start processing vertices ..." << std::endl;
     416    std::cout << " Found " << tks.size() << " input tracks" << std::endl;
    408417    //loop over input tracks
    409418
    410 
    411    for(std::vector<track_t>::const_iterator it=tks.begin(); it!=tks.end(); it++){
    412      double z = it->z;
    413      double pt=it->pt;
    414      double eta=it->eta;
    415      double phi=it->phi;
    416      double t = it->t;
    417 
    418      std::cout<<"pt: "<<pt<<", eta: "<<eta<<", phi: "<<phi<<", z: "<<z<<", t: "<<t<<std::endl;
    419    }
    420   }
    421 
    422   unsigned int nt=tks.size();
    423   double rho0=0.0; // start with no outlier rejection
    424 
    425   if (tks.empty()) return clusters;
     419    for(std::vector<track_t>::const_iterator it = tks.begin(); it != tks.end(); it++)
     420    {
     421      double z = it->z;
     422      double pt = it->pt;
     423      double eta = it->eta;
     424      double phi = it->phi;
     425      double t = it->t;
     426
     427      std::cout << "pt: " << pt << ", eta: " << eta << ", phi: " << phi << ", z: " << z << ", t: " << t << std::endl;
     428    }
     429  }
     430
     431  unsigned int nt = tks.size();
     432  double rho0 = 0.0; // start with no outlier rejection
     433
     434  if(tks.empty()) return clusters;
    426435
    427436  vector<vertex_t> y; // the vertex prototypes
     
    429438  // initialize:single vertex at infinite temperature
    430439  vertex_t vstart;
    431   vstart.z=0.;
    432   vstart.t=0.;
    433   vstart.pk=1.;
     440  vstart.z = 0.;
     441  vstart.t = 0.;
     442  vstart.pk = 1.;
    434443  y.push_back(vstart);
    435   int niter=0;      // number of iterations
     444  int niter = 0; // number of iterations
    436445
    437446  // estimate first critical temperature
    438   double beta=beta0(fBetaMax, tks, y, fCoolingFactor);
    439   niter=0; while((update1(beta, tks,y)>1.e-6)  && (niter++ < fMaxIterations)){ }
     447  double beta = beta0(fBetaMax, tks, y, fCoolingFactor);
     448  niter = 0;
     449  while((update1(beta, tks, y) > 1.e-6) && (niter++ < fMaxIterations))
     450  {
     451  }
    440452
    441453  // annealing loop, stop when T<Tmin  (i.e. beta>1/Tmin)
    442   while(beta<fBetaMax){
    443 
    444     if(fUseTc){
    445       update1(beta, tks,y);
    446       while(merge(y,beta)){update1(beta, tks,y);}
    447       split(beta, tks,y);
    448       beta=beta/fCoolingFactor;
    449     }else{
    450       beta=beta/fCoolingFactor;
     454  while(beta < fBetaMax)
     455  {
     456
     457    if(fUseTc)
     458    {
     459      update1(beta, tks, y);
     460      while(merge(y, beta))
     461      {
     462        update1(beta, tks, y);
     463      }
     464      split(beta, tks, y);
     465      beta = beta / fCoolingFactor;
     466    }
     467    else
     468    {
     469      beta = beta / fCoolingFactor;
    451470      splitAll(y);
    452471    }
    453472
    454    // make sure we are not too far from equilibrium before cooling further
    455    niter=0; while((update1(beta, tks,y)>1.e-6)  && (niter++ < fMaxIterations)){ }
    456 
    457   }
    458 
    459   if(fUseTc){
     473    // make sure we are not too far from equilibrium before cooling further
     474    niter = 0;
     475    while((update1(beta, tks, y) > 1.e-6) && (niter++ < fMaxIterations))
     476    {
     477    }
     478  }
     479
     480  if(fUseTc)
     481  {
    460482    // last round of splitting, make sure no critical clusters are left
    461     update1(beta, tks,y);
    462     while(merge(y,beta)){update1(beta, tks,y);}
    463     unsigned int ntry=0;
    464     while( split(beta, tks,y) && (ntry++<10) ){
    465       niter=0;
    466       while((update1(beta, tks,y)>1.e-6)  && (niter++ < fMaxIterations)){}
    467       merge(y,beta);
    468       update1(beta, tks,y);
    469     }
    470   }else{
     483    update1(beta, tks, y);
     484    while(merge(y, beta))
     485    {
     486      update1(beta, tks, y);
     487    }
     488    unsigned int ntry = 0;
     489    while(split(beta, tks, y) && (ntry++ < 10))
     490    {
     491      niter = 0;
     492      while((update1(beta, tks, y) > 1.e-6) && (niter++ < fMaxIterations))
     493      {
     494      }
     495      merge(y, beta);
     496      update1(beta, tks, y);
     497    }
     498  }
     499  else
     500  {
    471501    // merge collapsed clusters
    472     while(merge(y,beta)){update1(beta, tks,y);}
    473     if(fVerbose ){ cout << "dump after 1st merging " << endl;  dump(beta,y,tks);}
     502    while(merge(y, beta))
     503    {
     504      update1(beta, tks, y);
     505    }
     506    if(fVerbose)
     507    {
     508      cout << "dump after 1st merging " << endl;
     509      dump(beta, y, tks);
     510    }
    474511  }
    475512
    476513  // switch on outlier rejection
    477   rho0=1./nt; for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){ k->pk =1.; }  // democratic
    478   niter=0; while((update2(beta, tks,y,rho0, fDzCutOff) > 1.e-8)  && (niter++ < fMaxIterations)){  }
    479   if(fVerbose  ){ cout << "rho0=" << rho0 <<   " niter=" << niter <<  endl; dump(beta,y,tks);}
    480 
     514  rho0 = 1. / nt;
     515  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     516  {
     517    k->pk = 1.;
     518  } // democratic
     519  niter = 0;
     520  while((update2(beta, tks, y, rho0, fDzCutOff) > 1.e-8) && (niter++ < fMaxIterations))
     521  {
     522  }
     523  if(fVerbose)
     524  {
     525    cout << "rho0=" << rho0 << " niter=" << niter << endl;
     526    dump(beta, y, tks);
     527  }
    481528
    482529  // merge again  (some cluster split by outliers collapse here)
    483   while(merge(y)){}
    484   if(fVerbose  ){ cout << "dump after 2nd merging " << endl;  dump(beta,y,tks);}
    485 
     530  while(merge(y))
     531  {
     532  }
     533  if(fVerbose)
     534  {
     535    cout << "dump after 2nd merging " << endl;
     536    dump(beta, y, tks);
     537  }
    486538
    487539  // continue from freeze-out to Tstop (=1) without splitting, eliminate insignificant vertices
    488   while(beta<=fBetaStop){
    489     while(purge(y,tks,rho0, beta, fDzCutOff)){
    490       niter=0; while((update2(beta, tks, y, rho0, fDzCutOff) > 1.e-6)  && (niter++ < fMaxIterations)){  }
    491     }
    492     beta/=fCoolingFactor;
    493     niter=0; while((update2(beta, tks, y, rho0, fDzCutOff) > 1.e-6)  && (niter++ < fMaxIterations)){  }
    494   }
    495 
    496 
    497 //   // new, one last round of cleaning at T=Tstop
    498 //   while(purge(y,tks,rho0, beta)){
    499 //     niter=0; while((update2(beta, tks,y,rho0, fDzCutOff) > 1.e-6)  && (niter++ < fMaxIterations)){  }
    500 //   }
    501 
    502 
    503   if(fVerbose){
    504    cout << "Final result, rho0=" << rho0 << endl;
    505    dump(beta,y,tks);
    506   }
    507 
     540  while(beta <= fBetaStop)
     541  {
     542    while(purge(y, tks, rho0, beta, fDzCutOff))
     543    {
     544      niter = 0;
     545      while((update2(beta, tks, y, rho0, fDzCutOff) > 1.e-6) && (niter++ < fMaxIterations))
     546      {
     547      }
     548    }
     549    beta /= fCoolingFactor;
     550    niter = 0;
     551    while((update2(beta, tks, y, rho0, fDzCutOff) > 1.e-6) && (niter++ < fMaxIterations))
     552    {
     553    }
     554  }
     555
     556  //   // new, one last round of cleaning at T=Tstop
     557  //   while(purge(y,tks,rho0, beta)){
     558  //     niter=0; while((update2(beta, tks,y,rho0, fDzCutOff) > 1.e-6)  && (niter++ < fMaxIterations)){  }
     559  //   }
     560
     561  if(fVerbose)
     562  {
     563    cout << "Final result, rho0=" << rho0 << endl;
     564    dump(beta, y, tks);
     565  }
    508566
    509567  // select significant tracks and use a TransientVertex as a container
     
    511569
    512570  // ensure correct normalization of probabilities, should make double assginment reasonably impossible
    513   for(unsigned int i=0; i<nt; i++){
    514     tks[i].Z=rho0*exp(-beta*( fDzCutOff*fDzCutOff));
    515     for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    516       tks[i].Z += k->pk * exp(-beta*Eik(tks[i],*k));
    517     }
    518   }
    519 
    520   for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
     571  for(unsigned int i = 0; i < nt; i++)
     572  {
     573    tks[i].Z = rho0 * exp(-beta * (fDzCutOff * fDzCutOff));
     574    for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     575    {
     576      tks[i].Z += k->pk * exp(-beta * Eik(tks[i], *k));
     577    }
     578  }
     579
     580  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     581  {
    521582
    522583    DelphesFactory *factory = GetFactory();
     
    532593    double expv_x2 = 0.;
    533594    double normw = 0.;
    534     for(unsigned int i=0; i<nt; i++){
    535       const double invdt = 1.0/std::sqrt(tks[i].dt2);
    536       if(tks[i].Z>0){
    537   double p = k->pk * exp(-beta*Eik(tks[i],*k)) / tks[i].Z;
    538   if( (tks[i].pi>0) && ( p > 0.5 ) ){
     595    for(unsigned int i = 0; i < nt; i++)
     596    {
     597      const double invdt = 1.0 / std::sqrt(tks[i].dt2);
     598      if(tks[i].Z > 0)
     599      {
     600        double p = k->pk * exp(-beta * Eik(tks[i], *k)) / tks[i].Z;
     601        if((tks[i].pi > 0) && (p > 0.5))
     602        {
    539603          //std::cout << "pushing back " << i << ' ' << tks[i].tt << std::endl;
    540604          //vertexTracks.push_back(*(tks[i].tt)); tks[i].Z=0;
    541605
    542           candidate->AddCandidate(tks[i].tt); tks[i].Z=0;
    543 
    544           mean     += tks[i].t*invdt*p;
    545           expv_x2  += tks[i].t*tks[i].t*invdt*p;
    546           normw    += invdt*p;
     606          candidate->AddCandidate(tks[i].tt);
     607          tks[i].Z = 0;
     608
     609          mean += tks[i].t * invdt * p;
     610          expv_x2 += tks[i].t * tks[i].t * invdt * p;
     611          normw += invdt * p;
    547612        } // setting Z=0 excludes double assignment
    548613      }
    549614    }
    550615
    551     mean = mean/normw;
    552     expv_x2 = expv_x2/normw;
    553     const double time_var = expv_x2 - mean*mean;
     616    mean = mean / normw;
     617    expv_x2 = expv_x2 / normw;
     618    const double time_var = expv_x2 - mean * mean;
    554619    const double crappy_error_guess = std::sqrt(time_var);
    555620    /*GlobalError dummyErrorWithTime(0,
     
    559624    //TransientVertex v(pos, time, dummyErrorWithTime, vertexTracks, 5);
    560625
    561 
    562     candidate->ClusterIndex = clusterIndex++;;
    563     candidate->Position.SetXYZT(0.0, 0.0, z*10.0 , time*c_light);
     626    candidate->ClusterIndex = clusterIndex++;
     627    ;
     628    candidate->Position.SetXYZT(0.0, 0.0, z * 10.0, time * c_light);
    564629
    565630    // TBC - fill error later ...
    566     candidate->PositionError.SetXYZT(0.0, 0.0, 0.0 , crappy_error_guess*c_light);
     631    candidate->PositionError.SetXYZT(0.0, 0.0, 0.0, crappy_error_guess * c_light);
    567632
    568633    clusterIndex++;
     
    570635  }
    571636
    572 
    573637  return clusters;
    574 
    575 }
    576 
    577 //------------------------------------------------------------------------------
    578 
    579 static double Eik(const track_t & t, const vertex_t &k)
    580 {
    581   return std::pow(t.z-k.z,2.)/t.dz2 + std::pow(t.t - k.t,2.)/t.dt2;
     638}
     639
     640//------------------------------------------------------------------------------
     641
     642static double Eik(const track_t &t, const vertex_t &k)
     643{
     644  return std::pow(t.z - k.z, 2.) / t.dz2 + std::pow(t.t - k.t, 2.) / t.dt2;
    582645}
    583646
     
    588651  // copy and sort for nicer printout
    589652  vector<track_t> tks;
    590   for(vector<track_t>::const_iterator t=tks0.begin(); t!=tks0.end(); t++){tks.push_back(*t); }
     653  for(vector<track_t>::const_iterator t = tks0.begin(); t != tks0.end(); t++)
     654  {
     655    tks.push_back(*t);
     656  }
    591657  std::stable_sort(tks.begin(), tks.end(), recTrackLessZ1);
    592658
     
    595661  cout << "                                                               z= ";
    596662  cout.precision(4);
    597   for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
     663  for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
     664  {
    598665    //cout  <<  setw(8) << fixed << k->z;
    599666  }
    600   cout << endl << "                                                               t= ";
    601   for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
     667  cout << endl
     668       << "                                                               t= ";
     669  for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
     670  {
    602671    //cout  <<  setw(8) << fixed << k->t;
    603672  }
    604673  //cout << endl << "T=" << setw(15) << 1./beta <<"                                             Tc= ";
    605   for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
     674  for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
     675  {
    606676    //cout  <<  setw(8) << fixed << k->Tc ;
    607677  }
    608678
    609   cout << endl << "                                                              pk=";
    610   double sumpk=0;
    611   for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
     679  cout << endl
     680       << "                                                              pk=";
     681  double sumpk = 0;
     682  for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
     683  {
    612684    //cout <<  setw(8) <<  setprecision(3) <<  fixed << k->pk;
    613     sumpk+=k->pk;
    614   }
    615   cout  << endl;
    616 
    617   double E=0, F=0;
     685    sumpk += k->pk;
     686  }
     687  cout << endl;
     688
     689  double E = 0, F = 0;
    618690  cout << endl;
    619691  cout << "----       z +/- dz        t +/- dt        ip +/-dip       pt    phi  eta    weights  ----" << endl;
    620692  cout.precision(4);
    621   for(unsigned int i=0; i<tks.size(); i++){
    622     if (tks[i].Z>0){  F-=log(tks[i].Z)/beta;}
    623     double tz= tks[i].z;
    624     double tt= tks[i].t;
     693  for(unsigned int i = 0; i < tks.size(); i++)
     694  {
     695    if(tks[i].Z > 0)
     696    {
     697      F -= log(tks[i].Z) / beta;
     698    }
     699    double tz = tks[i].z;
     700    double tt = tks[i].t;
    625701    //cout <<  setw (3)<< i << ")" <<  setw (8) << fixed << setprecision(4)<<  tz << " +/-" <<  setw (6)<< sqrt(tks[i].dz2)
    626702    //     << setw(8) << fixed << setprecision(4) << tt << " +/-" << setw(6) << std::sqrt(tks[i].dt2)  ;
    627703
    628     double sump=0.;
    629     for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
    630     if((tks[i].pi>0)&&(tks[i].Z>0)){
    631     //double p=pik(beta,tks[i],*k);
    632     double p=k->pk * std::exp(-beta*Eik(tks[i],*k)) / tks[i].Z;
    633     if( p > 0.0001){
    634       //cout <<  setw (8) <<  setprecision(3) << p;
    635     }else{
    636       cout << "    .   ";
    637     }
    638     E+=p*Eik(tks[i],*k);
    639     sump+=p;
    640   }else{
    641       cout << "        ";
    642   }
    643       }
    644       cout << endl;
    645     }
    646     cout << endl << "T=" << 1/beta  << " E=" << E << " n="<< y.size() << "  F= " << F <<  endl <<  "----------" << endl;
     704    double sump = 0.;
     705    for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
     706    {
     707      if((tks[i].pi > 0) && (tks[i].Z > 0))
     708      {
     709        //double p=pik(beta,tks[i],*k);
     710        double p = k->pk * std::exp(-beta * Eik(tks[i], *k)) / tks[i].Z;
     711        if(p > 0.0001)
     712        {
     713          //cout <<  setw (8) <<  setprecision(3) << p;
     714        }
     715        else
     716        {
     717          cout << "    .   ";
     718        }
     719        E += p * Eik(tks[i], *k);
     720        sump += p;
     721      }
     722      else
     723      {
     724        cout << "        ";
     725      }
     726    }
     727    cout << endl;
     728  }
     729  cout << endl
     730       << "T=" << 1 / beta << " E=" << E << " n=" << y.size() << "  F= " << F << endl
     731       << "----------" << endl;
    647732}
    648733
     
    655740  // returns the squared sum of changes of vertex positions
    656741
    657   unsigned int nt=tks.size();
     742  unsigned int nt = tks.size();
    658743
    659744  //initialize sums
    660   double sumpi=0;
    661   for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); ++k){
    662     k->sw=0.; k->swz=0.; k->swt = 0.; k->se=0.;
    663     k->swE=0.;  k->Tc=0.;
    664   }
    665 
     745  double sumpi = 0;
     746  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); ++k)
     747  {
     748    k->sw = 0.;
     749    k->swz = 0.;
     750    k->swt = 0.;
     751    k->se = 0.;
     752    k->swE = 0.;
     753    k->Tc = 0.;
     754  }
    666755
    667756  // loop over tracks
    668   for(unsigned int i=0; i<nt; i++){
     757  for(unsigned int i = 0; i < nt; i++)
     758  {
    669759
    670760    // update pik and Zi
    671761    double Zi = 0.;
    672     for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); ++k){
    673       k->ei = std::exp(-beta*Eik(tks[i],*k));// cache exponential for one track at a time
    674       Zi   += k->pk * k->ei;
    675     }
    676     tks[i].Z=Zi;
     762    for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); ++k)
     763    {
     764      k->ei = std::exp(-beta * Eik(tks[i], *k)); // cache exponential for one track at a time
     765      Zi += k->pk * k->ei;
     766    }
     767    tks[i].Z = Zi;
    677768
    678769    // normalization for pk
    679     if (tks[i].Z>0){
     770    if(tks[i].Z > 0)
     771    {
    680772      sumpi += tks[i].pi;
    681773      // accumulate weighted z and weights for vertex update
    682       for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); ++k){
    683   k->se  += tks[i].pi* k->ei / Zi;
    684   const double w = k->pk * tks[i].pi* k->ei / ( Zi * ( tks[i].dz2 * tks[i].dt2 ) );
    685   k->sw  += w;
    686   k->swz += w * tks[i].z;
     774      for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); ++k)
     775      {
     776        k->se += tks[i].pi * k->ei / Zi;
     777        const double w = k->pk * tks[i].pi * k->ei / (Zi * (tks[i].dz2 * tks[i].dt2));
     778        k->sw += w;
     779        k->swz += w * tks[i].z;
    687780        k->swt += w * tks[i].t;
    688   k->swE += w * Eik(tks[i],*k);
    689       }
    690     }else{
     781        k->swE += w * Eik(tks[i], *k);
     782      }
     783    }
     784    else
     785    {
    691786      sumpi += tks[i].pi;
    692787    }
    693788
    694 
    695789  } // end of track loop
    696790
    697 
    698791  // now update z and pk
    699   double delta=0;
    700   for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    701     if ( k->sw > 0){
    702       const double znew = k->swz/k->sw;
    703       const double tnew = k->swt/k->sw;
    704       delta += std::pow(k->z-znew,2.) + std::pow(k->t-tnew,2.);
    705       k->z  = znew;
    706       k->t  = tnew;
    707       k->Tc = 2.*k->swE/k->sw;
    708     }else{
     792  double delta = 0;
     793  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     794  {
     795    if(k->sw > 0)
     796    {
     797      const double znew = k->swz / k->sw;
     798      const double tnew = k->swt / k->sw;
     799      delta += std::pow(k->z - znew, 2.) + std::pow(k->t - tnew, 2.);
     800      k->z = znew;
     801      k->t = tnew;
     802      k->Tc = 2. * k->swE / k->sw;
     803    }
     804    else
     805    {
    709806      // cout << " a cluster melted away ?  pk=" << k->pk <<  " sumw=" << k->sw <<  endl
    710       k->Tc=-1;
     807      k->Tc = -1;
    711808    }
    712809
     
    725822  // returns the squared sum of changes of vertex positions
    726823
    727   unsigned int nt=tks.size();
     824  unsigned int nt = tks.size();
    728825
    729826  //initialize sums
    730   for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    731     k->sw = 0.;   k->swz = 0.; k->swt = 0.; k->se = 0.;
    732     k->swE = 0.;  k->Tc=0.;
    733   }
    734 
     827  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     828  {
     829    k->sw = 0.;
     830    k->swz = 0.;
     831    k->swt = 0.;
     832    k->se = 0.;
     833    k->swE = 0.;
     834    k->Tc = 0.;
     835  }
    735836
    736837  // loop over tracks
    737   for(unsigned int i=0; i<nt; i++){
     838  for(unsigned int i = 0; i < nt; i++)
     839  {
    738840
    739841    // update pik and Zi and Ti
    740     double Zi = rho0*std::exp(-beta*(dzCutOff*dzCutOff));// cut-off (eventually add finite size in time)
     842    double Zi = rho0 * std::exp(-beta * (dzCutOff * dzCutOff)); // cut-off (eventually add finite size in time)
    741843    //double Ti = 0.; // dt0*std::exp(-beta*fDtCutOff);
    742     for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    743       k->ei = std::exp(-beta*Eik(tks[i],*k));// cache exponential for one track at a time
    744       Zi   += k->pk * k->ei;
    745     }
    746     tks[i].Z=Zi;
     844    for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     845    {
     846      k->ei = std::exp(-beta * Eik(tks[i], *k)); // cache exponential for one track at a time
     847      Zi += k->pk * k->ei;
     848    }
     849    tks[i].Z = Zi;
    747850
    748851    // normalization
    749     if (tks[i].Z>0){
    750        // accumulate weighted z and weights for vertex update
    751       for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    752   k->se += tks[i].pi* k->ei / Zi;
    753   double w = k->pk * tks[i].pi * k->ei /( Zi * ( tks[i].dz2 * tks[i].dt2 ) );
    754   k->sw  += w;
    755   k->swz += w * tks[i].z;
     852    if(tks[i].Z > 0)
     853    {
     854      // accumulate weighted z and weights for vertex update
     855      for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     856      {
     857        k->se += tks[i].pi * k->ei / Zi;
     858        double w = k->pk * tks[i].pi * k->ei / (Zi * (tks[i].dz2 * tks[i].dt2));
     859        k->sw += w;
     860        k->swz += w * tks[i].z;
    756861        k->swt += w * tks[i].t;
    757   k->swE += w * Eik(tks[i],*k);
     862        k->swE += w * Eik(tks[i], *k);
    758863      }
    759864    }
     
    762867
    763868  // now update z
    764   double delta=0;
    765   for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    766     if ( k->sw > 0){
    767       const double znew=k->swz/k->sw;
    768       const double tnew=k->swt/k->sw;
    769       delta += std::pow(k->z-znew,2.) + std::pow(k->t-tnew,2.);
    770       k->z   = znew;
    771       k->t   = tnew;
    772       k->Tc  = 2*k->swE/k->sw;
    773     }else{
     869  double delta = 0;
     870  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     871  {
     872    if(k->sw > 0)
     873    {
     874      const double znew = k->swz / k->sw;
     875      const double tnew = k->swt / k->sw;
     876      delta += std::pow(k->z - znew, 2.) + std::pow(k->t - tnew, 2.);
     877      k->z = znew;
     878      k->t = tnew;
     879      k->Tc = 2 * k->swE / k->sw;
     880    }
     881    else
     882    {
    774883      // cout << " a cluster melted away ?  pk=" << k->pk <<  " sumw=" << k->sw <<  endl;
    775884      k->Tc = 0;
    776885    }
    777 
    778886  }
    779887
     
    788896  // merge clusters that collapsed or never separated, return true if vertices were merged, false otherwise
    789897
    790   if(y.size()<2)  return false;
    791 
    792   for(vector<vertex_t>::iterator k=y.begin(); (k+1)!=y.end(); k++){
    793     if( std::abs( (k+1)->z - k->z ) < 1.e-3 &&
    794         std::abs( (k+1)->t - k->t ) < 1.e-3    ){  // with fabs if only called after freeze-out (splitAll() at highter T)
    795       double rho = k->pk + (k+1)->pk;
    796       if(rho>0){
    797         k->z = ( k->pk * k->z + (k+1)->z * (k+1)->pk)/rho;
    798         k->t = ( k->pk * k->t + (k+1)->t * (k+1)->pk)/rho;
    799       }else{
    800         k->z = 0.5*(k->z + (k+1)->z);
    801         k->t = 0.5*(k->t + (k+1)->t);
     898  if(y.size() < 2) return false;
     899
     900  for(vector<vertex_t>::iterator k = y.begin(); (k + 1) != y.end(); k++)
     901  {
     902    if(std::abs((k + 1)->z - k->z) < 1.e-3 && std::abs((k + 1)->t - k->t) < 1.e-3)
     903    { // with fabs if only called after freeze-out (splitAll() at highter T)
     904      double rho = k->pk + (k + 1)->pk;
     905      if(rho > 0)
     906      {
     907        k->z = (k->pk * k->z + (k + 1)->z * (k + 1)->pk) / rho;
     908        k->t = (k->pk * k->t + (k + 1)->t * (k + 1)->pk) / rho;
     909      }
     910      else
     911      {
     912        k->z = 0.5 * (k->z + (k + 1)->z);
     913        k->t = 0.5 * (k->t + (k + 1)->t);
    802914      }
    803915      k->pk = rho;
    804916
    805       y.erase(k+1);
     917      y.erase(k + 1);
    806918      return true;
    807919    }
     
    818930  // only merge if the estimated critical temperature of the merged vertex is below the current temperature
    819931  // return true if vertices were merged, false otherwise
    820   if(y.size()<2)  return false;
    821 
    822   for(vector<vertex_t>::iterator k=y.begin(); (k+1)!=y.end(); k++){
    823     if ( std::abs((k+1)->z - k->z) < 2.e-3 &&
    824          std::abs((k+1)->t - k->t) < 2.e-3    ) {
    825       double rho=k->pk + (k+1)->pk;
    826       double swE=k->swE+(k+1)->swE - k->pk * (k+1)->pk / rho * ( std::pow((k+1)->z - k->z,2.) +
    827                                                                  std::pow((k+1)->t - k->t,2.)   );
    828       double Tc=2*swE/(k->sw+(k+1)->sw);
    829 
    830       if(Tc*beta<1){
    831   if(rho>0){
    832     k->z = ( k->pk * k->z + (k+1)->z * (k+1)->pk)/rho;
    833           k->t = ( k->pk * k->t + (k+1)->t * (k+1)->pk)/rho;
    834   }else{
    835     k->z = 0.5*(k->z + (k+1)->z);
    836           k->t = 0.5*(k->t + (k+1)->t);
    837   }
    838   k->pk  = rho;
    839   k->sw += (k+1)->sw;
    840   k->swE = swE;
    841   k->Tc  = Tc;
    842   y.erase(k+1);
    843   return true;
     932  if(y.size() < 2) return false;
     933
     934  for(vector<vertex_t>::iterator k = y.begin(); (k + 1) != y.end(); k++)
     935  {
     936    if(std::abs((k + 1)->z - k->z) < 2.e-3 && std::abs((k + 1)->t - k->t) < 2.e-3)
     937    {
     938      double rho = k->pk + (k + 1)->pk;
     939      double swE = k->swE + (k + 1)->swE - k->pk * (k + 1)->pk / rho * (std::pow((k + 1)->z - k->z, 2.) + std::pow((k + 1)->t - k->t, 2.));
     940      double Tc = 2 * swE / (k->sw + (k + 1)->sw);
     941
     942      if(Tc * beta < 1)
     943      {
     944        if(rho > 0)
     945        {
     946          k->z = (k->pk * k->z + (k + 1)->z * (k + 1)->pk) / rho;
     947          k->t = (k->pk * k->t + (k + 1)->t * (k + 1)->pk) / rho;
     948        }
     949        else
     950        {
     951          k->z = 0.5 * (k->z + (k + 1)->z);
     952          k->t = 0.5 * (k->t + (k + 1)->t);
     953        }
     954        k->pk = rho;
     955        k->sw += (k + 1)->sw;
     956        k->swE = swE;
     957        k->Tc = Tc;
     958        y.erase(k + 1);
     959        return true;
    844960      }
    845961    }
     
    851967//------------------------------------------------------------------------------
    852968
    853 static bool purge(vector<vertex_t> &y, vector<track_t> &tks, double & rho0, const double beta, const double dzCutOff)
     969static bool purge(vector<vertex_t> &y, vector<track_t> &tks, double &rho0, const double beta, const double dzCutOff)
    854970{
    855971  // eliminate clusters with only one significant/unique track
    856   if(y.size()<2)  return false;
    857 
    858   unsigned int nt=tks.size();
    859   double sumpmin=nt;
    860   vector<vertex_t>::iterator k0=y.end();
    861   for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    862     int nUnique=0;
    863     double sump=0;
    864     double pmax=k->pk/(k->pk+rho0*exp(-beta*dzCutOff*dzCutOff));
    865     for(unsigned int i=0; i<nt; i++){
    866       if(tks[i].Z > 0){
    867   double p = k->pk * std::exp(-beta*Eik(tks[i],*k)) / tks[i].Z ;
    868   sump+=p;
    869   if( (p > 0.9*pmax) && (tks[i].pi>0) ){ nUnique++; }
    870       }
    871     }
    872 
    873     if((nUnique<2)&&(sump<sumpmin)){
    874       sumpmin=sump;
    875       k0=k;
    876     }
    877   }
    878 
    879   if(k0!=y.end()){
     972  if(y.size() < 2) return false;
     973
     974  unsigned int nt = tks.size();
     975  double sumpmin = nt;
     976  vector<vertex_t>::iterator k0 = y.end();
     977  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     978  {
     979    int nUnique = 0;
     980    double sump = 0;
     981    double pmax = k->pk / (k->pk + rho0 * exp(-beta * dzCutOff * dzCutOff));
     982    for(unsigned int i = 0; i < nt; i++)
     983    {
     984      if(tks[i].Z > 0)
     985      {
     986        double p = k->pk * std::exp(-beta * Eik(tks[i], *k)) / tks[i].Z;
     987        sump += p;
     988        if((p > 0.9 * pmax) && (tks[i].pi > 0))
     989        {
     990          nUnique++;
     991        }
     992      }
     993    }
     994
     995    if((nUnique < 2) && (sump < sumpmin))
     996    {
     997      sumpmin = sump;
     998      k0 = k;
     999    }
     1000  }
     1001
     1002  if(k0 != y.end())
     1003  {
    8801004    //cout << "eliminating prototype at " << k0->z << "," << k0->t << " with sump=" << sumpmin << endl;
    8811005    //rho0+=k0->pk;
    8821006    y.erase(k0);
    8831007    return true;
    884   }else{
     1008  }
     1009  else
     1010  {
    8851011    return false;
    8861012  }
     
    8921018{
    8931019
    894   double T0=0; // max Tc for beta=0
     1020  double T0 = 0; // max Tc for beta=0
    8951021  // estimate critical temperature from beta=0 (T=inf)
    896   unsigned int nt=tks.size();
    897 
    898   for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
     1022  unsigned int nt = tks.size();
     1023
     1024  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     1025  {
    8991026
    9001027    // vertex fit at T=inf
    901     double sumwz=0.;
    902     double sumwt=0.;
    903     double sumw=0.;
    904     for(unsigned int i=0; i<nt; i++){
    905       double w = tks[i].pi/(tks[i].dz2 * tks[i].dt2);
    906       sumwz += w*tks[i].z;
    907       sumwt += w*tks[i].t;
    908       sumw  += w;
    909     }
    910     k->z = sumwz/sumw;
    911     k->t = sumwt/sumw;
     1028    double sumwz = 0.;
     1029    double sumwt = 0.;
     1030    double sumw = 0.;
     1031    for(unsigned int i = 0; i < nt; i++)
     1032    {
     1033      double w = tks[i].pi / (tks[i].dz2 * tks[i].dt2);
     1034      sumwz += w * tks[i].z;
     1035      sumwt += w * tks[i].t;
     1036      sumw += w;
     1037    }
     1038    k->z = sumwz / sumw;
     1039    k->t = sumwt / sumw;
    9121040
    9131041    // estimate Tcrit, eventually do this in the same loop
    914     double a=0, b=0;
    915     for(unsigned int i=0; i<nt; i++){
    916       double dx = tks[i].z-(k->z);
    917       double dt = tks[i].t-(k->t);
    918       double w  = tks[i].pi/(tks[i].dz2 * tks[i].dt2);
    919       a += w*(std::pow(dx,2.)/tks[i].dz2 + std::pow(dt,2.)/tks[i].dt2);
     1042    double a = 0, b = 0;
     1043    for(unsigned int i = 0; i < nt; i++)
     1044    {
     1045      double dx = tks[i].z - (k->z);
     1046      double dt = tks[i].t - (k->t);
     1047      double w = tks[i].pi / (tks[i].dz2 * tks[i].dt2);
     1048      a += w * (std::pow(dx, 2.) / tks[i].dz2 + std::pow(dt, 2.) / tks[i].dt2);
    9201049      b += w;
    9211050    }
    922     double Tc= 2.*a/b;  // the critical temperature of this vertex
    923     if(Tc>T0) T0=Tc;
    924   }// vertex loop (normally there should be only one vertex at beta=0)
    925 
    926   if (T0>1./betamax){
    927     return betamax/pow(coolingFactor, int(std::log(T0*betamax)/std::log(coolingFactor))-1 );
    928   }else{
     1051    double Tc = 2. * a / b; // the critical temperature of this vertex
     1052    if(Tc > T0) T0 = Tc;
     1053  } // vertex loop (normally there should be only one vertex at beta=0)
     1054
     1055  if(T0 > 1. / betamax)
     1056  {
     1057    return betamax / pow(coolingFactor, int(std::log(T0 * betamax) / std::log(coolingFactor)) - 1);
     1058  }
     1059  else
     1060  {
    9291061    // ensure at least one annealing step
    930     return betamax/coolingFactor;
     1062    return betamax / coolingFactor;
    9311063  }
    9321064}
     
    9461078
    9471079  std::vector<std::pair<double, unsigned int> > critical;
    948   for(unsigned int ik=0; ik<y.size(); ik++){
    949     if (beta*y[ik].Tc > 1.){
    950       critical.push_back( make_pair(y[ik].Tc, ik));
    951     }
    952   }
    953   std::stable_sort(critical.begin(), critical.end(), std::greater<std::pair<double, unsigned int> >() );
    954 
    955   for(unsigned int ic=0; ic<critical.size(); ic++){
    956     unsigned int ik=critical[ic].second;
     1080  for(unsigned int ik = 0; ik < y.size(); ik++)
     1081  {
     1082    if(beta * y[ik].Tc > 1.)
     1083    {
     1084      critical.push_back(make_pair(y[ik].Tc, ik));
     1085    }
     1086  }
     1087  std::stable_sort(critical.begin(), critical.end(), std::greater<std::pair<double, unsigned int> >());
     1088
     1089  for(unsigned int ic = 0; ic < critical.size(); ic++)
     1090  {
     1091    unsigned int ik = critical[ic].second;
    9571092    // estimate subcluster positions and weight
    958     double p1=0, z1=0, t1=0, w1=0;
    959     double p2=0, z2=0, t2=0, w2=0;
     1093    double p1 = 0, z1 = 0, t1 = 0, w1 = 0;
     1094    double p2 = 0, z2 = 0, t2 = 0, w2 = 0;
    9601095    //double sumpi=0;
    961     for(unsigned int i=0; i<tks.size(); i++){
    962       if(tks[i].Z>0){
    963   //sumpi+=tks[i].pi;
    964   double p=y[ik].pk * exp(-beta*Eik(tks[i],y[ik])) / tks[i].Z*tks[i].pi;
    965   double w=p/(tks[i].dz2 * tks[i].dt2);
    966   if(tks[i].z < y[ik].z){
    967     p1+=p; z1+=w*tks[i].z; t1+=w*tks[i].t; w1+=w;
    968   }else{
    969     p2+=p; z2+=w*tks[i].z; t2+=w*tks[i].t; w2+=w;
    970   }
    971       }
    972     }
    973     if(w1>0){  z1=z1/w1; t1=t1/w1;} else{ z1=y[ik].z-epsilon; t1=y[ik].t-epsilon; }
    974     if(w2>0){  z2=z2/w2; t2=t2/w2;} else{ z2=y[ik].z+epsilon; t2=y[ik].t+epsilon;}
     1096    for(unsigned int i = 0; i < tks.size(); i++)
     1097    {
     1098      if(tks[i].Z > 0)
     1099      {
     1100        //sumpi+=tks[i].pi;
     1101        double p = y[ik].pk * exp(-beta * Eik(tks[i], y[ik])) / tks[i].Z * tks[i].pi;
     1102        double w = p / (tks[i].dz2 * tks[i].dt2);
     1103        if(tks[i].z < y[ik].z)
     1104        {
     1105          p1 += p;
     1106          z1 += w * tks[i].z;
     1107          t1 += w * tks[i].t;
     1108          w1 += w;
     1109        }
     1110        else
     1111        {
     1112          p2 += p;
     1113          z2 += w * tks[i].z;
     1114          t2 += w * tks[i].t;
     1115          w2 += w;
     1116        }
     1117      }
     1118    }
     1119    if(w1 > 0)
     1120    {
     1121      z1 = z1 / w1;
     1122      t1 = t1 / w1;
     1123    }
     1124    else
     1125    {
     1126      z1 = y[ik].z - epsilon;
     1127      t1 = y[ik].t - epsilon;
     1128    }
     1129    if(w2 > 0)
     1130    {
     1131      z2 = z2 / w2;
     1132      t2 = t2 / w2;
     1133    }
     1134    else
     1135    {
     1136      z2 = y[ik].z + epsilon;
     1137      t2 = y[ik].t + epsilon;
     1138    }
    9751139
    9761140    // reduce split size if there is not enough room
    977     if( ( ik   > 0       ) && ( y[ik-1].z>=z1 ) ){ z1=0.5*(y[ik].z+y[ik-1].z); t1=0.5*(y[ik].t+y[ik-1].t); }
    978     if( ( ik+1 < y.size()) && ( y[ik+1].z<=z2 ) ){ z2=0.5*(y[ik].z+y[ik+1].z); t2=0.5*(y[ik].t+y[ik+1].t); }
     1141    if((ik > 0) && (y[ik - 1].z >= z1))
     1142    {
     1143      z1 = 0.5 * (y[ik].z + y[ik - 1].z);
     1144      t1 = 0.5 * (y[ik].t + y[ik - 1].t);
     1145    }
     1146    if((ik + 1 < y.size()) && (y[ik + 1].z <= z2))
     1147    {
     1148      z2 = 0.5 * (y[ik].z + y[ik + 1].z);
     1149      t2 = 0.5 * (y[ik].t + y[ik + 1].t);
     1150    }
    9791151
    9801152    // split if the new subclusters are significantly separated
    981     if( (z2-z1)>epsilon || std::abs(t2-t1) > epsilon){
    982       split=true;
     1153    if((z2 - z1) > epsilon || std::abs(t2 - t1) > epsilon)
     1154    {
     1155      split = true;
    9831156      vertex_t vnew;
    984       vnew.pk = p1*y[ik].pk/(p1+p2);
    985       y[ik].pk= p2*y[ik].pk/(p1+p2);
    986       vnew.z  = z1;
    987       vnew.t  = t1;
     1157      vnew.pk = p1 * y[ik].pk / (p1 + p2);
     1158      y[ik].pk = p2 * y[ik].pk / (p1 + p2);
     1159      vnew.z = z1;
     1160      vnew.t = t1;
    9881161      y[ik].z = z2;
    9891162      y[ik].t = t2;
    990       y.insert(y.begin()+ik, vnew);
    991 
    992      // adjust remaining pointers
    993       for(unsigned int jc=ic; jc<critical.size(); jc++){
    994         if (critical[jc].second>ik) {critical[jc].second++;}
     1163      y.insert(y.begin() + ik, vnew);
     1164
     1165      // adjust remaining pointers
     1166      for(unsigned int jc = ic; jc < critical.size(); jc++)
     1167      {
     1168        if(critical[jc].second > ik)
     1169        {
     1170          critical[jc].second++;
     1171        }
    9951172      }
    9961173    }
     
    10061183{
    10071184
    1008 
    1009   const double epsilon=1e-3;      // split all single vertices by 10 um
    1010   const double zsep=2*epsilon;    // split vertices that are isolated by at least zsep (vertices that haven't collapsed)
    1011   const double tsep=2*epsilon;    // check t as well
     1185  const double epsilon = 1e-3; // split all single vertices by 10 um
     1186  const double zsep = 2 * epsilon; // split vertices that are isolated by at least zsep (vertices that haven't collapsed)
     1187  const double tsep = 2 * epsilon; // check t as well
    10121188
    10131189  vector<vertex_t> y1;
    10141190
    1015   for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    1016     if ( ( (k==y.begin())|| (k-1)->z < k->z - zsep) && (((k+1)==y.end()  )|| (k+1)->z > k->z + zsep)) {
     1191  for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
     1192  {
     1193    if(((k == y.begin()) || (k - 1)->z < k->z - zsep) && (((k + 1) == y.end()) || (k + 1)->z > k->z + zsep))
     1194    {
    10171195      // isolated prototype, split
    10181196      vertex_t vnew;
    1019       vnew.z  = k->z - epsilon;
    1020       vnew.t  = k->t - epsilon;
    1021       (*k).z  = k->z + epsilon;
    1022       (*k).t  = k->t + epsilon;
    1023       vnew.pk= 0.5* (*k).pk;
    1024       (*k).pk= 0.5* (*k).pk;
     1197      vnew.z = k->z - epsilon;
     1198      vnew.t = k->t - epsilon;
     1199      (*k).z = k->z + epsilon;
     1200      (*k).t = k->t + epsilon;
     1201      vnew.pk = 0.5 * (*k).pk;
     1202      (*k).pk = 0.5 * (*k).pk;
    10251203      y1.push_back(vnew);
    10261204      y1.push_back(*k);
    1027 
    1028     }else if( y1.empty() || (y1.back().z < k->z -zsep) || (y1.back().t < k->t - tsep) ){
     1205    }
     1206    else if(y1.empty() || (y1.back().z < k->z - zsep) || (y1.back().t < k->t - tsep))
     1207    {
    10291208      y1.push_back(*k);
    1030     }else{
     1209    }
     1210    else
     1211    {
    10311212      y1.back().z -= epsilon;
    10321213      y1.back().t -= epsilon;
     
    10351216      y1.push_back(*k);
    10361217    }
    1037   }// vertex loop
    1038 
    1039   y=y1;
    1040 }
    1041 
    1042 
    1043 
     1218  } // vertex loop
     1219
     1220  y = y1;
     1221}
  • modules/VertexFinderDA4D.h

    re39abb4 r0e7d64a  
    99 *
    1010 */
    11 
    1211
    1312#include "classes/DelphesModule.h"
     
    2221{
    2322public:
    24 
    2523  VertexFinderDA4D();
    2624  ~VertexFinderDA4D();
     
    3129
    3230  void clusterize(const TObjArray &tracks, TObjArray &clusters);
    33   std::vector< Candidate* > vertices();
     31  std::vector<Candidate *> vertices();
    3432
    3533private:
    36 
    3734  Bool_t fVerbose;
    3835  Double_t fMinPT;
  • modules/VertexSorter.cc

    re39abb4 r0e7d64a  
    1616#include "classes/DelphesPileUpReader.h"
    1717
     18#include "ExRootAnalysis/ExRootClassifier.h"
     19#include "ExRootAnalysis/ExRootFilter.h"
    1820#include "ExRootAnalysis/ExRootResult.h"
    19 #include "ExRootAnalysis/ExRootFilter.h"
    20 #include "ExRootAnalysis/ExRootClassifier.h"
    21 
     21
     22#include "TDatabasePDG.h"
     23#include "TFormula.h"
     24#include "TLorentzVector.h"
    2225#include "TMath.h"
     26#include "TMatrixT.h"
     27#include "TObjArray.h"
     28#include "TRandom3.h"
    2329#include "TString.h"
    24 #include "TFormula.h"
    25 #include "TRandom3.h"
    26 #include "TObjArray.h"
    27 #include "TDatabasePDG.h"
    28 #include "TLorentzVector.h"
    29 #include "TMatrixT.h"
    3030#include "TVector3.h"
    3131
     32#include <algorithm>
     33#include <iostream>
     34#include <map>
     35#include <stdexcept>
     36#include <string>
    3237#include <utility>
    33 #include <algorithm>
    34 #include <stdexcept>
    35 #include <iostream>
    3638#include <vector>
    37 #include <map>
    38 #include <string>
    3939
    4040using namespace std;
    4141
    42 static const Double_t mm  = 1.;
    43 static const Double_t m = 1000.*mm;
    44 static const Double_t ns  = 1.;
    45 static const Double_t s = 1.e+9 *ns;
    46 static const Double_t c_light   = 2.99792458e+8 * m/s;
     42static const Double_t mm = 1.;
     43static const Double_t m = 1000. * mm;
     44static const Double_t ns = 1.;
     45static const Double_t s = 1.e+9 * ns;
     46static const Double_t c_light = 2.99792458e+8 * m / s;
    4747
    4848//------------------------------------------------------------------------------
     
    6868  fItTrackInputArray = fTrackInputArray->MakeIterator();
    6969
    70   if (string (GetString("JetInputArray", "")) != "")
    71     {
    72       fJetInputArray = ImportArray(GetString("JetInputArray", ""));
    73       fItJetInputArray = fJetInputArray->MakeIterator();
    74     }
     70  if(string(GetString("JetInputArray", "")) != "")
     71  {
     72    fJetInputArray = ImportArray(GetString("JetInputArray", ""));
     73    fItJetInputArray = fJetInputArray->MakeIterator();
     74  }
    7575
    7676  // import beamspot
     
    8282  {
    8383    fBeamSpotInputArray = 0;
    84   } 
    85  
     84  }
     85
    8686  fOutputArray = ExportArray(GetString("OutputArray", "clusters"));
    8787
     
    9999//------------------------------------------------------------------------------
    100100
    101 static Bool_t secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     101static Bool_t secondDescending(pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    102102{
    103103  return (pair0.second > pair1.second);
    104104}
    105105
    106 static Bool_t secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     106static Bool_t secondAscending(pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    107107{
    108108  return (pair0.second < pair1.second);
     
    121121  vector<pair<Int_t, Double_t> >::const_iterator itSortedClusterIDs;
    122122
    123   for (Int_t iCluster = 0; iCluster < fInputArray->GetEntries (); iCluster++)
    124     {
    125       const Candidate &cluster = *((Candidate *) fInputArray->At (iCluster));
    126       clusterIDToIndex[cluster.ClusterIndex] = iCluster;
    127       clusterIDToSumPT2[cluster.ClusterIndex] = 0.0;
    128     }
     123  for(Int_t iCluster = 0; iCluster < fInputArray->GetEntries(); iCluster++)
     124  {
     125    const Candidate &cluster = *((Candidate *)fInputArray->At(iCluster));
     126    clusterIDToIndex[cluster.ClusterIndex] = iCluster;
     127    clusterIDToSumPT2[cluster.ClusterIndex] = 0.0;
     128  }
    129129
    130130  if(fMethod == "BTV")
    131     {
    132       if (!fJetInputArray)
    133         {
    134           cout << "BTV PV sorting selected, but no jet collection given!" << endl;
    135           throw 0;
    136         }
    137 
    138       fItTrackInputArray->Reset();
    139       while((candidate = static_cast<Candidate*>(fItTrackInputArray->Next())))
    140         {
    141           if (candidate->Momentum.Pt () < 1.0)
    142             continue;
    143           if (candidate->ClusterIndex < 0)
    144             continue;
    145           TLorentzVector p (candidate->Momentum.Px (), candidate->Momentum.Py (), candidate->Momentum.Pz (), candidate->Momentum.E ());
    146           Bool_t isInJet = false;
    147 
    148           fItJetInputArray->Reset();
    149           while((jetCandidate = static_cast<Candidate*>(fItJetInputArray->Next())))
    150             {
    151               if (jetCandidate->Momentum.Pt () < 30.0)
    152                 continue;
    153               TLorentzVector q (jetCandidate->Momentum.Px (), jetCandidate->Momentum.Py (), jetCandidate->Momentum.Pz (), jetCandidate->Momentum.E ());
    154 
    155               if (p.DeltaR (q) > 0.4)
    156                 continue;
    157               isInJet = true;
    158               break;
    159             }
    160           if (!isInJet)
    161             continue;
    162 
    163           clusterIDToSumPT2.at (candidate->ClusterIndex) += candidate->Momentum.Pt () * candidate->Momentum.Pt ();
    164         }
    165 
    166       for (itClusterIDToSumPT2 = clusterIDToSumPT2.begin(); itClusterIDToSumPT2 != clusterIDToSumPT2.end(); ++itClusterIDToSumPT2)
    167         sortedClusterIDs.push_back (make_pair (itClusterIDToSumPT2->first, itClusterIDToSumPT2->second));
    168       sort (sortedClusterIDs.begin (), sortedClusterIDs.end (), secondDescending);
    169     }
    170   else if (fMethod == "GenClosest")
    171     {
    172       if (!fBeamSpotInputArray)
    173         {
    174           cout << "GenClosest PV sorting selected, but no beamspot collection given!" << endl;
    175           throw 0;
    176         }
    177       if (!fBeamSpotInputArray->GetSize ())
    178         {
    179           cout << "Beamspot collection is empty!" << endl;
    180           throw 0;
    181         }
    182 
    183       beamSpotCandidate = (Candidate *) fBeamSpotInputArray->At (0);
    184       for (Int_t iCluster = 0; iCluster < fInputArray->GetEntries (); iCluster++)
    185         {
    186           const Candidate &cluster = *((Candidate *) fInputArray->At (iCluster));
    187           sortedClusterIDs.push_back (make_pair (cluster.ClusterIndex, fabs (cluster.Position.Z () - beamSpotCandidate->Position.Z ())));
    188         }
    189       sort (sortedClusterIDs.begin (), sortedClusterIDs.end (), secondAscending);
    190     }
    191   else if (fMethod == "GenBest")
    192     {
    193       fItTrackInputArray->Reset();
    194       while((candidate = static_cast<Candidate*>(fItTrackInputArray->Next())))
    195         {
    196           if (candidate->IsPU)
    197             continue;
    198           for (itClusterIDToIndex = clusterIDToIndex.begin(); itClusterIDToIndex != clusterIDToIndex.end(); ++itClusterIDToIndex)
    199             {
    200               if (candidate->ClusterIndex != itClusterIDToIndex->first)
    201                 continue;
    202               clusterIDToSumPT2.at (itClusterIDToIndex->first) += candidate->Momentum.Pt () * candidate->Momentum.Pt ();
    203             }
    204         }
    205 
    206       for (itClusterIDToSumPT2 = clusterIDToSumPT2.begin(); itClusterIDToSumPT2 != clusterIDToSumPT2.end(); ++itClusterIDToSumPT2)
    207         sortedClusterIDs.push_back (make_pair (itClusterIDToSumPT2->first, itClusterIDToSumPT2->second));
    208       sort (sortedClusterIDs.begin (), sortedClusterIDs.end (), secondDescending);
    209     }
     131  {
     132    if(!fJetInputArray)
     133    {
     134      cout << "BTV PV sorting selected, but no jet collection given!" << endl;
     135      throw 0;
     136    }
     137
     138    fItTrackInputArray->Reset();
     139    while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
     140    {
     141      if(candidate->Momentum.Pt() < 1.0)
     142        continue;
     143      if(candidate->ClusterIndex < 0)
     144        continue;
     145      TLorentzVector p(candidate->Momentum.Px(), candidate->Momentum.Py(), candidate->Momentum.Pz(), candidate->Momentum.E());
     146      Bool_t isInJet = false;
     147
     148      fItJetInputArray->Reset();
     149      while((jetCandidate = static_cast<Candidate *>(fItJetInputArray->Next())))
     150      {
     151        if(jetCandidate->Momentum.Pt() < 30.0)
     152          continue;
     153        TLorentzVector q(jetCandidate->Momentum.Px(), jetCandidate->Momentum.Py(), jetCandidate->Momentum.Pz(), jetCandidate->Momentum.E());
     154
     155        if(p.DeltaR(q) > 0.4)
     156          continue;
     157        isInJet = true;
     158        break;
     159      }
     160      if(!isInJet)
     161        continue;
     162
     163      clusterIDToSumPT2.at(candidate->ClusterIndex) += candidate->Momentum.Pt() * candidate->Momentum.Pt();
     164    }
     165
     166    for(itClusterIDToSumPT2 = clusterIDToSumPT2.begin(); itClusterIDToSumPT2 != clusterIDToSumPT2.end(); ++itClusterIDToSumPT2)
     167      sortedClusterIDs.push_back(make_pair(itClusterIDToSumPT2->first, itClusterIDToSumPT2->second));
     168    sort(sortedClusterIDs.begin(), sortedClusterIDs.end(), secondDescending);
     169  }
     170  else if(fMethod == "GenClosest")
     171  {
     172    if(!fBeamSpotInputArray)
     173    {
     174      cout << "GenClosest PV sorting selected, but no beamspot collection given!" << endl;
     175      throw 0;
     176    }
     177    if(!fBeamSpotInputArray->GetSize())
     178    {
     179      cout << "Beamspot collection is empty!" << endl;
     180      throw 0;
     181    }
     182
     183    beamSpotCandidate = (Candidate *)fBeamSpotInputArray->At(0);
     184    for(Int_t iCluster = 0; iCluster < fInputArray->GetEntries(); iCluster++)
     185    {
     186      const Candidate &cluster = *((Candidate *)fInputArray->At(iCluster));
     187      sortedClusterIDs.push_back(make_pair(cluster.ClusterIndex, fabs(cluster.Position.Z() - beamSpotCandidate->Position.Z())));
     188    }
     189    sort(sortedClusterIDs.begin(), sortedClusterIDs.end(), secondAscending);
     190  }
     191  else if(fMethod == "GenBest")
     192  {
     193    fItTrackInputArray->Reset();
     194    while((candidate = static_cast<Candidate *>(fItTrackInputArray->Next())))
     195    {
     196      if(candidate->IsPU)
     197        continue;
     198      for(itClusterIDToIndex = clusterIDToIndex.begin(); itClusterIDToIndex != clusterIDToIndex.end(); ++itClusterIDToIndex)
     199      {
     200        if(candidate->ClusterIndex != itClusterIDToIndex->first)
     201          continue;
     202        clusterIDToSumPT2.at(itClusterIDToIndex->first) += candidate->Momentum.Pt() * candidate->Momentum.Pt();
     203      }
     204    }
     205
     206    for(itClusterIDToSumPT2 = clusterIDToSumPT2.begin(); itClusterIDToSumPT2 != clusterIDToSumPT2.end(); ++itClusterIDToSumPT2)
     207      sortedClusterIDs.push_back(make_pair(itClusterIDToSumPT2->first, itClusterIDToSumPT2->second));
     208    sort(sortedClusterIDs.begin(), sortedClusterIDs.end(), secondDescending);
     209  }
    210210  else
    211     {
    212       cout << "\"" << fMethod << "\" is not a valid sorting method!" << endl;
    213       cout << "Valid methods are:" << endl;
    214       cout << "  BTV" << endl;
    215       cout << "  GenClosest" << endl;
    216       cout << "  GenBest" << endl;
    217       throw 0;
    218     }
    219   for (itSortedClusterIDs = sortedClusterIDs.begin(); itSortedClusterIDs != sortedClusterIDs.end(); ++itSortedClusterIDs)
    220     {
    221       Candidate *cluster = (Candidate *) fInputArray->At (clusterIDToIndex.at (itSortedClusterIDs->first));
    222       if (fMethod == "BTV")
    223         cluster->BTVSumPT2 = itSortedClusterIDs->second;
    224       else if (fMethod == "GenClosest")
    225         cluster->GenDeltaZ = itSortedClusterIDs->second;
    226       else if (fMethod == "GenBest")
    227         cluster->GenSumPT2 = itSortedClusterIDs->second;
    228       fOutputArray->Add (cluster);
    229     }
    230 }
    231 
    232 //------------------------------------------------------------------------------
     211  {
     212    cout << "\"" << fMethod << "\" is not a valid sorting method!" << endl;
     213    cout << "Valid methods are:" << endl;
     214    cout << "  BTV" << endl;
     215    cout << "  GenClosest" << endl;
     216    cout << "  GenBest" << endl;
     217    throw 0;
     218  }
     219  for(itSortedClusterIDs = sortedClusterIDs.begin(); itSortedClusterIDs != sortedClusterIDs.end(); ++itSortedClusterIDs)
     220  {
     221    Candidate *cluster = (Candidate *)fInputArray->At(clusterIDToIndex.at(itSortedClusterIDs->first));
     222    if(fMethod == "BTV")
     223      cluster->BTVSumPT2 = itSortedClusterIDs->second;
     224    else if(fMethod == "GenClosest")
     225      cluster->GenDeltaZ = itSortedClusterIDs->second;
     226    else if(fMethod == "GenBest")
     227      cluster->GenSumPT2 = itSortedClusterIDs->second;
     228    fOutputArray->Add(cluster);
     229  }
     230}
     231
     232//------------------------------------------------------------------------------
  • modules/VertexSorter.h

    re39abb4 r0e7d64a  
    2323{
    2424public:
    25 
    2625  VertexSorter();
    2726  ~VertexSorter();
     
    3231
    3332private:
    34 
    3533  TObjArray *fInputArray;
    3634
  • modules/Weighter.cc

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019/** \class Weighter
    2120 *
     
    3231#include "classes/DelphesFormula.h"
    3332
     33#include "ExRootAnalysis/ExRootClassifier.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3435#include "ExRootAnalysis/ExRootResult.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootClassifier.h"
    3736
     37#include "TDatabasePDG.h"
     38#include "TFormula.h"
     39#include "TLorentzVector.h"
    3840#include "TMath.h"
     41#include "TObjArray.h"
     42#include "TRandom3.h"
    3943#include "TString.h"
    40 #include "TFormula.h"
    41 #include "TRandom3.h"
    42 #include "TObjArray.h"
    43 #include "TDatabasePDG.h"
    44 #include "TLorentzVector.h"
    4544
    4645#include <algorithm>
    47 #include <stdexcept>
    4846#include <iostream>
    4947#include <sstream>
     48#include <stdexcept>
    5049
    5150using namespace std;
     
    5352//------------------------------------------------------------------------------
    5453
    55 bool Weighter::TIndexStruct::operator< (const Weighter::TIndexStruct &value) const
     54bool Weighter::TIndexStruct::operator<(const Weighter::TIndexStruct &value) const
    5655{
    5756  Int_t i;
     
    9089  fWeightSet.clear();
    9190
    92 
    9391  // set default weight value
    9492  fWeightMap.clear();
    95   memset(index.codes, 0, 4*sizeof(Int_t));
     93  memset(index.codes, 0, 4 * sizeof(Int_t));
    9694  fWeightMap[index] = 1.0;
    9795
     
    9997  param = GetParam("Weight");
    10098  size = param.GetSize();
    101   for(i = 0; i < size/2; ++i)
     99  for(i = 0; i < size / 2; ++i)
    102100  {
    103     paramCodes = param[i*2];
     101    paramCodes = param[i * 2];
    104102    sizeCodes = paramCodes.GetSize();
    105     weight = param[i*2 + 1].GetDouble();
     103    weight = param[i * 2 + 1].GetDouble();
    106104
    107105    if(sizeCodes < 1 || sizeCodes > 4)
     
    110108    }
    111109
    112     memset(index.codes, 0, 4*sizeof(Int_t));
     110    memset(index.codes, 0, 4 * sizeof(Int_t));
    113111
    114112    for(j = 0; j < sizeCodes; ++j)
     
    157155  fCodeSet.clear();
    158156  fItInputArray->Reset();
    159   while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
     157  while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
    160158  {
    161159    if(candidate->Status != 3) continue;
     
    167165
    168166  // find default weight value
    169   memset(index.codes, 0, 4*sizeof(Int_t));
     167  memset(index.codes, 0, 4 * sizeof(Int_t));
    170168  itWeightMap = fWeightMap.find(index);
    171169  weight = itWeightMap->second;
  • modules/Weighter.h

    re39abb4 r0e7d64a  
    3030#include "classes/DelphesModule.h"
    3131
     32#include <map>
    3233#include <set>
    33 #include <map>
    3434
    3535class TObjArray;
     
    3838{
    3939public:
    40 
    4140  Weighter();
    4241  ~Weighter();
     
    4746
    4847private:
    49 
    5048#if !defined(__CINT__) && !defined(__CLING__)
    5149  struct TIndexStruct
    5250  {
    5351    Int_t codes[4];
    54     bool operator< (const TIndexStruct &value) const;
     52    bool operator<(const TIndexStruct &value) const;
    5553  };
    5654
  • readers/DelphesCMSFWLite.cpp

    re39abb4 r0e7d64a  
    1818
    1919#include <algorithm>
     20#include <iostream>
     21#include <memory>
     22#include <sstream>
    2023#include <stdexcept>
    21 #include <iostream>
    22 #include <sstream>
    23 #include <memory>
    2424
    2525#include <map>
    2626#include <vector>
    2727
    28 #include <stdlib.h>
    2928#include <signal.h>
    3029#include <stdio.h>
    31 
     30#include <stdlib.h>
     31
     32#include "TApplication.h"
    3233#include "TROOT.h"
    33 #include "TApplication.h"
    34 
     34
     35#include "TDatabasePDG.h"
    3536#include "TFile.h"
     37#include "TLorentzVector.h"
    3638#include "TObjArray.h"
     39#include "TParticlePDG.h"
    3740#include "TStopwatch.h"
    38 #include "TDatabasePDG.h"
    39 #include "TParticlePDG.h"
    40 #include "TLorentzVector.h"
    41 
    42 #include "modules/Delphes.h"
    43 #include "classes/DelphesStream.h"
     41
    4442#include "classes/DelphesClasses.h"
    4543#include "classes/DelphesFactory.h"
    46 
     44#include "classes/DelphesStream.h"
     45#include "modules/Delphes.h"
     46
     47#include "ExRootAnalysis/ExRootProgressBar.h"
     48#include "ExRootAnalysis/ExRootTreeBranch.h"
    4749#include "ExRootAnalysis/ExRootTreeWriter.h"
    48 #include "ExRootAnalysis/ExRootTreeBranch.h"
    49 #include "ExRootAnalysis/ExRootProgressBar.h"
    50 
    51 #include "FWCore/FWLite/interface/FWLiteEnabler.h"
     50
    5251#include "DataFormats/FWLite/interface/Event.h"
    5352#include "DataFormats/FWLite/interface/Handle.h"
    5453#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
    5554#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
     55#include "FWCore/FWLite/interface/FWLiteEnabler.h"
     56#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
    5657#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
    57 #include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
    5858#include "SimDataFormats/GeneratorProducts/interface/LHEEventProduct.h"
    5959#include "SimDataFormats/GeneratorProducts/interface/WeightsInfo.h"
     
    6969{
    7070
    71   fwlite::Handle< GenEventInfoProduct > handleGenEventInfo;
    72   fwlite::Handle< LHEEventProduct > handleLHEEvent;
    73   fwlite::Handle< vector< reco::GenParticle > > handleParticle;
    74   fwlite::Handle< vector< pat::PackedGenParticle > > handlePackedParticle;
    75 
    76   vector< reco::GenParticle >::const_iterator itParticle;
    77   vector< pat::PackedGenParticle >::const_iterator itPackedParticle;
    78 
    79   vector< const reco::Candidate * > vectorCandidate;
    80   vector< const reco::Candidate * >::iterator itCandidate;
     71  fwlite::Handle<GenEventInfoProduct> handleGenEventInfo;
     72  fwlite::Handle<LHEEventProduct> handleLHEEvent;
     73  fwlite::Handle<vector<reco::GenParticle> > handleParticle;
     74  fwlite::Handle<vector<pat::PackedGenParticle> > handlePackedParticle;
     75
     76  vector<reco::GenParticle>::const_iterator itParticle;
     77  vector<pat::PackedGenParticle>::const_iterator itPackedParticle;
     78
     79  vector<const reco::Candidate *> vectorCandidate;
     80  vector<const reco::Candidate *>::iterator itCandidate;
    8181
    8282  handleGenEventInfo.getByLabel(event, "generator");
     
    9999    handleParticle.getByLabel(event, "genParticles");
    100100  }
    101   else if(!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event,"prunedGenParticles")).empty()))
     101  else if(!((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && !((handleParticle.getBranchNameFor(event, "prunedGenParticles")).empty()))
    102102  {
    103103    handleParticle.getByLabel(event, "prunedGenParticles");
     
    106106  else
    107107  {
    108     std::cout<<"Wrong GenParticle Label! Please, check the input file."<<std::endl;
     108    std::cout << "Wrong GenParticle Label! Please, check the input file." << std::endl;
    109109    exit(-1);
    110110  }
    111111
    112112  Bool_t foundLHE = !((handleLHEEvent.getBranchNameFor(event, "source")).empty()) || !((handleLHEEvent.getBranchNameFor(event, "externalLHEProducer")).empty());
    113   Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty()) ;
     113  Bool_t isMiniAOD = !((handlePackedParticle.getBranchNameFor(event, "packedGenParticles")).empty()) && ((handleParticle.getBranchNameFor(event, "genParticles")).empty());
    114114
    115115  HepMCEvent *element;
     
    148148  if(foundLHE)
    149149  {
    150     const vector< gen::WeightsInfo > &vectorWeightsInfo = handleLHEEvent->weights();
    151     vector< gen::WeightsInfo >::const_iterator itWeightsInfo;
     150    const vector<gen::WeightsInfo> &vectorWeightsInfo = handleLHEEvent->weights();
     151    vector<gen::WeightsInfo>::const_iterator itWeightsInfo;
    152152
    153153    for(itWeightsInfo = vectorWeightsInfo.begin(); itWeightsInfo != vectorWeightsInfo.end(); ++itWeightsInfo)
     
    173173    status = particle.status();
    174174    if(isMiniAOD && particle.status() == 1) continue;
    175     px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    176     x = particle.vx(); y = particle.vy(); z = particle.vz();
     175    px = particle.px();
     176    py = particle.py();
     177    pz = particle.pz();
     178    e = particle.energy();
     179    mass = particle.mass();
     180    x = particle.vx();
     181    y = particle.vy();
     182    z = particle.vz();
    177183
    178184    candidate = factory->NewCandidate();
     
    196202
    197203    pdgParticle = pdg->GetParticle(pid);
    198     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     204    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    199205    candidate->Mass = mass;
    200206
    201207    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
    202208
    203     candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
     209    candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0);
    204210
    205211    allParticleOutputArray->Add(candidate);
     
    232238    pid = particle.pdgId();
    233239    status = particle.status();
    234     px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.energy(); mass = particle.mass();
    235     x = particle.vx(); y = particle.vy(); z = particle.vz();
     240    px = particle.px();
     241    py = particle.py();
     242    pz = particle.pz();
     243    e = particle.energy();
     244    mass = particle.mass();
     245    x = particle.vx();
     246    y = particle.vy();
     247    z = particle.vz();
    236248
    237249    candidate = factory->NewCandidate();
     
    255267
    256268    pdgParticle = pdg->GetParticle(pid);
    257     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     269    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    258270    candidate->Mass = mass;
    259271
    260272    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
    261273
    262     candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
     274    candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0);
    263275
    264276    allParticleOutputArray->Add(candidate);
     
    303315  if(argc < 4)
    304316  {
    305     cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
     317    cout << " Usage: " << appName << " config_file"
     318         << " output_file"
     319         << " input_file(s)" << endl;
    306320    cout << " config_file - configuration file in Tcl format," << endl;
    307321    cout << " output_file - output file in ROOT format," << endl;
  • readers/DelphesHepMC.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 #include <stdexcept>
    2019#include <iostream>
    2120#include <sstream>
     21#include <stdexcept>
    2222
    2323#include <signal.h>
    2424
     25#include "TApplication.h"
    2526#include "TROOT.h"
    26 #include "TApplication.h"
    27 
     27
     28#include "TDatabasePDG.h"
    2829#include "TFile.h"
     30#include "TLorentzVector.h"
    2931#include "TObjArray.h"
     32#include "TParticlePDG.h"
    3033#include "TStopwatch.h"
    31 #include "TDatabasePDG.h"
    32 #include "TParticlePDG.h"
    33 #include "TLorentzVector.h"
    34 
    35 #include "modules/Delphes.h"
     34
    3635#include "classes/DelphesClasses.h"
    3736#include "classes/DelphesFactory.h"
    3837#include "classes/DelphesHepMCReader.h"
    39 
     38#include "modules/Delphes.h"
     39
     40#include "ExRootAnalysis/ExRootProgressBar.h"
     41#include "ExRootAnalysis/ExRootTreeBranch.h"
    4042#include "ExRootAnalysis/ExRootTreeWriter.h"
    41 #include "ExRootAnalysis/ExRootTreeBranch.h"
    42 #include "ExRootAnalysis/ExRootProgressBar.h"
    4343
    4444using namespace std;
     
    7474  if(argc < 3)
    7575  {
    76     cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl;
     76    cout << " Usage: " << appName << " config_file"
     77         << " output_file"
     78         << " [input_file(s)]" << endl;
    7779    cout << " config_file - configuration file in Tcl format," << endl;
    7880    cout << " output_file - output file in ROOT format," << endl;
     
    178180      reader->Clear();
    179181      readStopWatch.Start();
    180       while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) &&
    181         reader->ReadBlock(factory, allParticleOutputArray,
    182         stableParticleOutputArray, partonOutputArray) && !interrupted)
     182      while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted)
    183183      {
    184184        if(reader->EventReady())
     
    217217
    218218      ++i;
    219     }
    220     while(i < argc);
     219    } while(i < argc);
    221220
    222221    modularDelphes->FinishTask();
  • readers/DelphesLHEF.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 #include <stdexcept>
    2019#include <iostream>
    2120#include <sstream>
     21#include <stdexcept>
    2222
    2323#include <signal.h>
    2424
     25#include "TApplication.h"
    2526#include "TROOT.h"
    26 #include "TApplication.h"
    27 
     27
     28#include "TDatabasePDG.h"
    2829#include "TFile.h"
     30#include "TLorentzVector.h"
    2931#include "TObjArray.h"
     32#include "TParticlePDG.h"
    3033#include "TStopwatch.h"
    31 #include "TDatabasePDG.h"
    32 #include "TParticlePDG.h"
    33 #include "TLorentzVector.h"
    34 
    35 #include "modules/Delphes.h"
     34
    3635#include "classes/DelphesClasses.h"
    3736#include "classes/DelphesFactory.h"
    3837#include "classes/DelphesLHEFReader.h"
    39 
     38#include "modules/Delphes.h"
     39
     40#include "ExRootAnalysis/ExRootProgressBar.h"
     41#include "ExRootAnalysis/ExRootTreeBranch.h"
    4042#include "ExRootAnalysis/ExRootTreeWriter.h"
    41 #include "ExRootAnalysis/ExRootTreeBranch.h"
    42 #include "ExRootAnalysis/ExRootProgressBar.h"
    4343
    4444using namespace std;
     
    7474  if(argc < 3)
    7575  {
    76     cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl;
     76    cout << " Usage: " << appName << " config_file"
     77         << " output_file"
     78         << " [input_file(s)]" << endl;
    7779    cout << " config_file - configuration file in Tcl format," << endl;
    7880    cout << " output_file - output file in ROOT format," << endl;
     
    178180      reader->Clear();
    179181      readStopWatch.Start();
    180       while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) &&
    181         reader->ReadBlock(factory, allParticleOutputArray,
    182         stableParticleOutputArray, partonOutputArray) && !interrupted)
     182      while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted)
    183183      {
    184184        if(reader->EventReady())
     
    218218
    219219      ++i;
    220     }
    221     while(i < argc);
     220    } while(i < argc);
    222221
    223222    modularDelphes->FinishTask();
  • readers/DelphesProIO.cpp

    re39abb4 r0e7d64a  
    1818 */
    1919
     20#include <iostream>
     21#include <memory>
     22#include <sstream>
    2023#include <stdexcept>
    21 #include <iostream>
    22 #include <sstream>
    23 #include <memory>
    2424
    2525#include <map>
    2626
    27 #include <stdlib.h>
    2827#include <signal.h>
    2928#include <stdio.h>
    30 
     29#include <stdlib.h>
     30
     31#include "TApplication.h"
    3132#include "TROOT.h"
    32 #include "TApplication.h"
    33 
     33
     34#include "TDatabasePDG.h"
    3435#include "TFile.h"
     36#include "TLorentzVector.h"
    3537#include "TObjArray.h"
     38#include "TParticlePDG.h"
    3639#include "TStopwatch.h"
    37 #include "TDatabasePDG.h"
    38 #include "TParticlePDG.h"
    39 #include "TLorentzVector.h"
    40 
    41 #include "modules/Delphes.h"
    42 #include "classes/DelphesStream.h"
     40
    4341#include "classes/DelphesClasses.h"
    4442#include "classes/DelphesFactory.h"
    45 
     43#include "classes/DelphesStream.h"
     44#include "modules/Delphes.h"
     45
     46#include "ExRootAnalysis/ExRootProgressBar.h"
     47#include "ExRootAnalysis/ExRootTreeBranch.h"
    4648#include "ExRootAnalysis/ExRootTreeWriter.h"
    47 #include "ExRootAnalysis/ExRootTreeBranch.h"
    48 #include "ExRootAnalysis/ExRootProgressBar.h"
    49 
    50 #include <proio/reader.h>
     49
    5150#include <proio/event.h>
    5251#include <proio/model/mc.pb.h>
    53 namespace model=proio::model::mc;
    54 
     52#include <proio/reader.h>
     53namespace model = proio::model::mc;
    5554
    5655using namespace std;
     
    5958// This method dynamically checks the message type (varint or not) depending on
    6059// non-zero value of units momentumUnit and positionUnit.
    61 void ConvertInput(proio::Event *event, double momentumUnit, double positionUnit, 
     60void ConvertInput(proio::Event *event, double momentumUnit, double positionUnit,
    6261  ExRootTreeBranch *branch, DelphesFactory *factory,
    6362  TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray,
     
    8079  element = static_cast<HepMCEvent *>(branch->NewEntry());
    8180
    82  int nID=0;
    83  double weight=0;
    84  int process_id=0;
    85  auto mcentries = event->TaggedEntries("MCParameters");
    86  for (uint64_t mcentryID : mcentries) {
    87    auto mcpar = dynamic_cast<proio::model::mc::MCParameters *>(event->GetEntry(mcentryID));
    88    nID=mcpar->number();
    89    weight=mcpar->weight();
    90    process_id=mcpar->processid();
    91    break; // consider only most generic from 1st entry
    92  };
     81  int nID = 0;
     82  double weight = 0;
     83  int process_id = 0;
     84  auto mcentries = event->TaggedEntries("MCParameters");
     85  for(uint64_t mcentryID : mcentries)
     86  {
     87    auto mcpar = dynamic_cast<proio::model::mc::MCParameters *>(event->GetEntry(mcentryID));
     88    nID = mcpar->number();
     89    weight = mcpar->weight();
     90    process_id = mcpar->processid();
     91    break; // consider only most generic from 1st entry
     92  };
    9393
    9494  element->Number = nID;
    95   element->ProcessID =process_id;
     95  element->ProcessID = process_id;
    9696  element->Weight = weight;
    9797
    98 /*
     98  /*
    9999  // Pythia8 specific
    100100  element->MPI = mutableEvent->mpi();
     
    114114  element->ProcTime = procStopWatch->RealTime();
    115115
    116 
    117 
    118  if ( momentumUnit >0 && positionUnit>0) {
    119 
    120 
    121   auto entries = event->TaggedEntries("VarintPackedParticles");
    122 
    123   for (uint64_t entryID : entries) {
    124 
    125     auto mutableParticles = dynamic_cast<model::VarintPackedParticles *>(event->GetEntry(entryID));
    126 
    127     for(int i = 0; i < mutableParticles->pdg_size(); ++i)
    128    {
    129     pid = mutableParticles->pdg(i);
    130     status = mutableParticles->status(i);
    131     px = mutableParticles->px(i)/momentumUnit;
    132     py = mutableParticles->py(i)/momentumUnit;
    133     pz = mutableParticles->pz(i)/momentumUnit;
    134     mass = mutableParticles->mass(i)/momentumUnit;
    135     x = mutableParticles->x(i)/positionUnit;
    136     y = mutableParticles->y(i)/positionUnit;
    137     z = mutableParticles->z(i)/positionUnit;
    138     t = mutableParticles->t(i)/positionUnit;
    139    
    140     candidate = factory->NewCandidate();
    141     candidate->PID = pid;
    142     pdgCode = TMath::Abs(candidate->PID);
    143     candidate->Status = status;
    144     candidate->M1 = mutableParticles->parent1(i);
    145     candidate->M2 = mutableParticles->parent2(i);
    146     candidate->D1 = mutableParticles->child1(i);
    147     candidate->D2 = mutableParticles->child2(i);
    148     pdgParticle = pdg->GetParticle(pid);
    149     candidate->Charge = mutableParticles->charge(i)/3.0;
    150     //candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    151     candidate->Mass = mass;
    152     candidate->Momentum.SetXYZM(px, py, pz, mass);
    153     candidate->Position.SetXYZT(x, y, z, t);
    154     allParticleOutputArray->Add(candidate);
    155     if(!pdgParticle) continue;
    156 
    157     if(status == 1)
     116  if(momentumUnit > 0 && positionUnit > 0)
     117  {
     118
     119    auto entries = event->TaggedEntries("VarintPackedParticles");
     120
     121    for(uint64_t entryID : entries)
    158122    {
    159       stableParticleOutputArray->Add(candidate);
    160     }
    161     else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
    162     {
    163       partonOutputArray->Add(candidate);
     123
     124      auto mutableParticles = dynamic_cast<model::VarintPackedParticles *>(event->GetEntry(entryID));
     125
     126      for(int i = 0; i < mutableParticles->pdg_size(); ++i)
     127      {
     128        pid = mutableParticles->pdg(i);
     129        status = mutableParticles->status(i);
     130        px = mutableParticles->px(i) / momentumUnit;
     131        py = mutableParticles->py(i) / momentumUnit;
     132        pz = mutableParticles->pz(i) / momentumUnit;
     133        mass = mutableParticles->mass(i) / momentumUnit;
     134        x = mutableParticles->x(i) / positionUnit;
     135        y = mutableParticles->y(i) / positionUnit;
     136        z = mutableParticles->z(i) / positionUnit;
     137        t = mutableParticles->t(i) / positionUnit;
     138
     139        candidate = factory->NewCandidate();
     140        candidate->PID = pid;
     141        pdgCode = TMath::Abs(candidate->PID);
     142        candidate->Status = status;
     143        candidate->M1 = mutableParticles->parent1(i);
     144        candidate->M2 = mutableParticles->parent2(i);
     145        candidate->D1 = mutableParticles->child1(i);
     146        candidate->D2 = mutableParticles->child2(i);
     147        pdgParticle = pdg->GetParticle(pid);
     148        candidate->Charge = mutableParticles->charge(i) / 3.0;
     149        //candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     150        candidate->Mass = mass;
     151        candidate->Momentum.SetXYZM(px, py, pz, mass);
     152        candidate->Position.SetXYZT(x, y, z, t);
     153        allParticleOutputArray->Add(candidate);
     154        if(!pdgParticle) continue;
     155
     156        if(status == 1)
     157        {
     158          stableParticleOutputArray->Add(candidate);
     159        }
     160        else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
     161        {
     162          partonOutputArray->Add(candidate);
     163        }
     164      }
    164165    }
    165166  }
    166 
    167   }
    168 
    169  } else {
    170 
    171 
    172  auto entries = event->TaggedEntries("Particle");
    173 
    174  for (uint64_t entryID : entries) {
    175     auto part = dynamic_cast<model::Particle *>(event->GetEntry(entryID));
    176     pid = part->pdg();
    177     status = part->status();
    178     model::XYZF pvector=part->p();
    179     px=pvector.x();
    180     py=pvector.y();
    181     pz=pvector.z();
    182     mass = part->mass();
    183     auto v =part->vertex();
    184     x=v.x();
    185     y=v.y();
    186     z=v.z();
    187     t=v.t();
    188 
    189     candidate = factory->NewCandidate();
    190     candidate->PID = pid;
    191     pdgCode = TMath::Abs(candidate->PID);
    192     candidate->Status = status;
    193 
    194     int M1=0;
    195     int M2=0;
    196     for (int k1=0; k1<part->parent_size(); k1++){
    197        if (k1==0) {
    198                    auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(0)));
    199                    M1=mother->barcode();
    200        }
    201        if (k1==1) {
    202                    auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(1)));
    203                    M2=mother->barcode();
    204        }
     167  else
     168  {
     169
     170    auto entries = event->TaggedEntries("Particle");
     171
     172    for(uint64_t entryID : entries)
     173    {
     174      auto part = dynamic_cast<model::Particle *>(event->GetEntry(entryID));
     175      pid = part->pdg();
     176      status = part->status();
     177      model::XYZF pvector = part->p();
     178      px = pvector.x();
     179      py = pvector.y();
     180      pz = pvector.z();
     181      mass = part->mass();
     182      auto v = part->vertex();
     183      x = v.x();
     184      y = v.y();
     185      z = v.z();
     186      t = v.t();
     187
     188      candidate = factory->NewCandidate();
     189      candidate->PID = pid;
     190      pdgCode = TMath::Abs(candidate->PID);
     191      candidate->Status = status;
     192
     193      int M1 = 0;
     194      int M2 = 0;
     195      for(int k1 = 0; k1 < part->parent_size(); k1++)
     196      {
     197        if(k1 == 0)
     198        {
     199          auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(0)));
     200          M1 = mother->barcode();
     201        }
     202        if(k1 == 1)
     203        {
     204          auto mother = dynamic_cast<model::Particle *>(event->GetEntry(part->parent(1)));
     205          M2 = mother->barcode();
     206        }
     207      }
     208
     209      int D1 = 0;
     210      int D2 = 0;
     211      for(int k1 = 0; k1 < part->child_size(); k1++)
     212      {
     213        if(k1 == 0)
     214        {
     215          auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(0)));
     216          D1 = child->barcode();
     217        }
     218
     219        if(k1 == 1)
     220        {
     221          auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(1)));
     222          D2 = child->barcode();
     223        };
     224      }
     225
     226      candidate->M1 = M1;
     227      candidate->M2 = M2;
     228      candidate->D1 = D1;
     229      candidate->D2 = D2;
     230
     231      pdgParticle = pdg->GetParticle(pid);
     232      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
     233      candidate->Mass = mass;
     234
     235      candidate->Momentum.SetXYZM(px, py, pz, mass);
     236
     237      candidate->Position.SetXYZT(x, y, z, t);
     238
     239      allParticleOutputArray->Add(candidate);
     240
     241      if(!pdgParticle) continue;
     242
     243      if(status == 1)
     244      {
     245        stableParticleOutputArray->Add(candidate);
     246      }
     247      else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
     248      {
     249        partonOutputArray->Add(candidate);
     250      }
    205251    }
    206252
    207 
    208     int D1=0;
    209     int D2=0;
    210     for (int k1=0; k1<part->child_size(); k1++){
    211        if (k1==0) {
    212                    auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(0)));
    213                    D1=child->barcode();
    214        }
    215 
    216       if (k1==1) {
    217                    auto child = dynamic_cast<model::Particle *>(event->GetEntry(part->child(1)));
    218                    D2=child->barcode();
    219          };
    220       }
    221 
    222 
    223     candidate->M1 = M1;
    224     candidate->M2 = M2;
    225     candidate->D1 = D1;
    226     candidate->D2 = D2;
    227 
    228     pdgParticle = pdg->GetParticle(pid);
    229     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    230     candidate->Mass = mass;
    231 
    232     candidate->Momentum.SetXYZM(px, py, pz, mass);
    233 
    234     candidate->Position.SetXYZT(x, y, z, t);
    235 
    236     allParticleOutputArray->Add(candidate);
    237 
    238     if(!pdgParticle) continue;
    239 
    240     if(status == 1)
    241     {
    242       stableParticleOutputArray->Add(candidate);
    243     }
    244     else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
    245     {
    246       partonOutputArray->Add(candidate);
    247     }
    248 
    249   }
    250 
    251 
    252   } // end particle type
    253 
     253  } // end particle type
    254254}
    255255
     
    283283  if(argc < 4)
    284284  {
    285     cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
     285    cout << " Usage: " << appName << " config_file"
     286         << " output_file"
     287         << " input_file(s)" << endl;
    286288    cout << " config_file - configuration file in Tcl format," << endl;
    287289    cout << " output_file - output file in ROOT format," << endl;
     
    330332      cout << "** INFO: Reading " << argv[i] << endl;
    331333
    332       inputFile=new proio::Reader( argv[i] );
     334      inputFile = new proio::Reader(argv[i]);
    333335
    334336      if(inputFile == NULL)
     
    338340      }
    339341
    340 
    341 /*
     342      /*
    342343// this is slow method, but general
    343344      inputFile->SeekToStart();
     
    350351*/
    351352
    352 
    353     auto event = new proio::Event();
    354 
    355 
    356    double varint_energy=0;
    357    double varint_length=0;
    358 
    359 
    360     auto max_n_events = std::numeric_limits<uint64_t>::max();
    361     auto nn = inputFile->Skip(max_n_events);
    362     cout << "** INFO: " << nn-1 << " events found in ProIO file" << endl;
    363     inputFile->SeekToStart();
    364     numberOfEvents = nn-1; // last event has only metadata (no particle record)
    365  
    366     if(numberOfEvents <= 0) continue;
    367 
    368     ExRootProgressBar progressBar(numberOfEvents - 1);
    369 
     353      auto event = new proio::Event();
     354
     355      double varint_energy = 0;
     356      double varint_length = 0;
     357
     358      auto max_n_events = std::numeric_limits<uint64_t>::max();
     359      auto nn = inputFile->Skip(max_n_events);
     360      cout << "** INFO: " << nn - 1 << " events found in ProIO file" << endl;
     361      inputFile->SeekToStart();
     362      numberOfEvents = nn - 1; // last event has only metadata (no particle record)
     363
     364      if(numberOfEvents <= 0) continue;
     365
     366      ExRootProgressBar progressBar(numberOfEvents - 1);
    370367
    371368      // Loop over all objects
     
    376373      for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter)
    377374      {
    378         inputFile->Next(event); 
     375        inputFile->Next(event);
    379376        if(event == 0) continue;
    380377
    381        // get metadata
    382        if (eventCounter == 0) {
    383        auto metadata = event->Metadata();
    384        std::cout << "** INFO: ProIO file metadata:" << std::endl;
    385        for (auto element : metadata) {
    386         string key=(string)element.first;
    387         string value=(string)(*element.second);
    388         std::cout << "** INFO:   " << key << " = " << value << std::endl;
    389         if (key=="info:varint_energy") varint_energy=std::stod(value);
    390         if (key=="info:varint_length") varint_length=std::stod(value);
    391         }
    392        }
    393 
     378        // get metadata
     379        if(eventCounter == 0)
     380        {
     381          auto metadata = event->Metadata();
     382          std::cout << "** INFO: ProIO file metadata:" << std::endl;
     383          for(auto element : metadata)
     384          {
     385            string key = (string)element.first;
     386            string value = (string)(*element.second);
     387            std::cout << "** INFO:   " << key << " = " << value << std::endl;
     388            if(key == "info:varint_energy") varint_energy = std::stod(value);
     389            if(key == "info:varint_length") varint_length = std::stod(value);
     390          }
     391        }
    394392
    395393        readStopWatch.Stop();
     
    397395        procStopWatch.Start();
    398396
    399         ConvertInput(event, varint_energy, varint_length, 
     397        ConvertInput(event, varint_energy, varint_length,
    400398          branchEvent, factory,
    401399          allParticleOutputArray, stableParticleOutputArray,
    402400          partonOutputArray, &readStopWatch, &procStopWatch);
    403  
     401
    404402        modularDelphes->ProcessTask();
    405403        procStopWatch.Stop();
     
    414412      }
    415413
    416 
    417414      progressBar.Update(eventCounter, eventCounter, kTRUE);
    418415      progressBar.Finish();
     
    420417      delete inputFile;
    421418    }
    422 
    423419
    424420    modularDelphes->FinishTask();
  • readers/DelphesProMC.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
     19#include <iostream>
     20#include <memory>
     21#include <sstream>
    1922#include <stdexcept>
    20 #include <iostream>
    21 #include <sstream>
    22 #include <memory>
    2323
    2424#include <map>
    2525
    26 #include <stdlib.h>
    2726#include <signal.h>
    2827#include <stdio.h>
    29 
     28#include <stdlib.h>
     29
     30#include "TApplication.h"
    3031#include "TROOT.h"
    31 #include "TApplication.h"
    32 
     32
     33#include "TDatabasePDG.h"
    3334#include "TFile.h"
     35#include "TLorentzVector.h"
    3436#include "TObjArray.h"
     37#include "TParticlePDG.h"
    3538#include "TStopwatch.h"
    36 #include "TDatabasePDG.h"
    37 #include "TParticlePDG.h"
    38 #include "TLorentzVector.h"
    39 
    40 #include "modules/Delphes.h"
    41 #include "classes/DelphesStream.h"
     39
    4240#include "classes/DelphesClasses.h"
    4341#include "classes/DelphesFactory.h"
    44 
     42#include "classes/DelphesStream.h"
     43#include "modules/Delphes.h"
     44
     45#include "ExRootAnalysis/ExRootProgressBar.h"
     46#include "ExRootAnalysis/ExRootTreeBranch.h"
    4547#include "ExRootAnalysis/ExRootTreeWriter.h"
    46 #include "ExRootAnalysis/ExRootTreeBranch.h"
    47 #include "ExRootAnalysis/ExRootProgressBar.h"
    4848
    4949#include "ProMC.pb.h"
     
    109109    status = mutableParticles->status(i);
    110110
    111     px = mutableParticles->px(i)/momentumUnit;
    112     py = mutableParticles->py(i)/momentumUnit;
    113     pz = mutableParticles->pz(i)/momentumUnit;
    114     mass = mutableParticles->mass(i)/momentumUnit;
    115     x = mutableParticles->x(i)/positionUnit;
    116     y = mutableParticles->y(i)/positionUnit;
    117     z = mutableParticles->z(i)/positionUnit;
    118     t = mutableParticles->t(i)/positionUnit;
     111    px = mutableParticles->px(i) / momentumUnit;
     112    py = mutableParticles->py(i) / momentumUnit;
     113    pz = mutableParticles->pz(i) / momentumUnit;
     114    mass = mutableParticles->mass(i) / momentumUnit;
     115    x = mutableParticles->x(i) / positionUnit;
     116    y = mutableParticles->y(i) / positionUnit;
     117    z = mutableParticles->z(i) / positionUnit;
     118    t = mutableParticles->t(i) / positionUnit;
    119119
    120120    candidate = factory->NewCandidate();
     
    125125    candidate->Status = status;
    126126
     127    candidate->IsPU = 0;
     128    if(mutableParticles->barcode(i) > 0) candidate->IsPU = 1; // pileup particle
     129
    127130    candidate->M1 = mutableParticles->mother1(i);
    128131    candidate->M2 = mutableParticles->mother2(i);
     
    132135
    133136    pdgParticle = pdg->GetParticle(pid);
    134     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     137    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    135138    candidate->Mass = mass;
    136139
     
    184187  if(argc < 4)
    185188  {
    186     cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
     189    cout << " Usage: " << appName << " config_file"
     190         << " output_file"
     191         << " input_file(s)" << endl;
    187192    cout << " config_file - configuration file in Tcl format," << endl;
    188193    cout << " output_file - output file in ROOT format," << endl;
     
    231236      cout << "** Reading " << argv[i] << endl;
    232237
     238      // use 64 bit
     239      //inputFile = new ProMCBook(argv[i], "r", true);
     240
     241      //use 32 bit zip (faster but limitted to 64k events)
    233242      inputFile = new ProMCBook(argv[i], "r");
    234243
     
    237246      momentumUnit = static_cast<double>(header.momentumunit());
    238247      positionUnit = static_cast<double>(header.lengthunit());
    239 
    240 
    241248
    242249      if(inputFile == NULL)
  • readers/DelphesPythia8.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 #include <stdexcept>
    2019#include <iostream>
    2120#include <sstream>
     21#include <stdexcept>
    2222#include <string>
    2323
     
    2727#include "Pythia8Plugins/CombineMatchingInput.h"
    2828
     29#include "TApplication.h"
    2930#include "TROOT.h"
    30 #include "TApplication.h"
    31 
     31
     32#include "TDatabasePDG.h"
    3233#include "TFile.h"
     34#include "TLorentzVector.h"
    3335#include "TObjArray.h"
     36#include "TParticlePDG.h"
    3437#include "TStopwatch.h"
    35 #include "TDatabasePDG.h"
    36 #include "TParticlePDG.h"
    37 #include "TLorentzVector.h"
    38 
    39 #include "modules/Delphes.h"
     38
    4039#include "classes/DelphesClasses.h"
    4140#include "classes/DelphesFactory.h"
    4241#include "classes/DelphesLHEFReader.h"
    43 
     42#include "modules/Delphes.h"
     43
     44#include "ExRootAnalysis/ExRootProgressBar.h"
     45#include "ExRootAnalysis/ExRootTreeBranch.h"
    4446#include "ExRootAnalysis/ExRootTreeWriter.h"
    45 #include "ExRootAnalysis/ExRootTreeBranch.h"
    46 #include "ExRootAnalysis/ExRootProgressBar.h"
    4747
    4848using namespace std;
     
    9898    pid = particle.id();
    9999    status = particle.statusHepMC();
    100     px = particle.px(); py = particle.py(); pz = particle.pz(); e = particle.e(); mass = particle.m();
    101     x = particle.xProd(); y = particle.yProd(); z = particle.zProd(); t = particle.tProd();
     100    px = particle.px();
     101    py = particle.py();
     102    pz = particle.pz();
     103    e = particle.e();
     104    mass = particle.m();
     105    x = particle.xProd();
     106    y = particle.yProd();
     107    z = particle.zProd();
     108    t = particle.tProd();
    102109
    103110    candidate = factory->NewCandidate();
     
    115122
    116123    pdgParticle = pdg->GetParticle(pid);
    117     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
     124    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
    118125    candidate->Mass = mass;
    119126
     
    166173
    167174  // pMin = 0.1 GeV for single particles
    168   pp = pow(10, - 1.0 + (log10(pMax) + 1.0) * rndm.flat());
     175  pp = pow(10, -1.0 + (log10(pMax) + 1.0) * rndm.flat());
    169176  eta = (2.0 * rndm.flat() - 1.0) * etaMax;
    170177  phi = 2.0 * M_PI * rndm.flat();
    171178  mm = pdt.mSel(id);
    172   ee = Pythia8::sqrtpos(pp*pp + mm*mm);
     179  ee = Pythia8::sqrtpos(pp * pp + mm * mm);
    173180  pt = pp / cosh(eta);
    174181
     
    193200  phi = 2.0 * M_PI * rndm.flat();
    194201  mm = pdt.mSel(id);
    195   ee = Pythia8::sqrtpos(pp*pp + mm*mm);
     202  ee = Pythia8::sqrtpos(pp * pp + mm * mm);
    196203  pt = pp / cosh(eta);
    197204
    198   if( (id == 4 || id == 5) && pt < 10.0) return;
     205  if((id == 4 || id == 5) && pt < 10.0) return;
    199206
    200207  if(id == 21)
     
    238245  // for matching
    239246  Pythia8::CombineMatchingInput *combined = 0;
    240   Pythia8::UserHooks* matching = 0;
     247  Pythia8::UserHooks *matching = 0;
    241248
    242249  if(argc != 4)
    243250  {
    244     cout << " Usage: " << appName << " config_file" << " pythia_card" << " output_file" << endl;
     251    cout << " Usage: " << appName << " config_file"
     252         << " pythia_card"
     253         << " output_file" << endl;
    245254    cout << " config_file - configuration file in Tcl format," << endl;
    246255    cout << " pythia_card - Pythia8 configuration file," << endl;
     
    293302    }
    294303    pythia->setUserHooksPtr(matching);
    295 
    296304
    297305    if(pythia == NULL)
     
    348356    for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter)
    349357    {
    350       while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF,
    351         stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady());
     358      while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF, stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady())
     359        ;
    352360
    353361      if(spareFlag1)
  • readers/DelphesROOT.cpp

    re39abb4 r0e7d64a  
    1818
    1919#include <algorithm>
     20#include <iostream>
     21#include <memory>
     22#include <sstream>
    2023#include <stdexcept>
    21 #include <iostream>
    22 #include <sstream>
    23 #include <memory>
    2424
    2525#include <map>
    2626#include <vector>
    2727
    28 #include <stdlib.h>
    2928#include <signal.h>
    3029#include <stdio.h>
    31 
     30#include <stdlib.h>
     31
     32#include "TApplication.h"
    3233#include "TROOT.h"
    33 #include "TApplication.h"
    34 
     34
     35#include "TClonesArray.h"
     36#include "TDatabasePDG.h"
    3537#include "TFile.h"
    36 #include "TClonesArray.h"
     38#include "TLorentzVector.h"
    3739#include "TObjArray.h"
     40#include "TParticlePDG.h"
    3841#include "TStopwatch.h"
    39 #include "TDatabasePDG.h"
    40 #include "TParticlePDG.h"
    41 #include "TLorentzVector.h"
    42 
    43 #include "modules/Delphes.h"
    44 #include "classes/DelphesStream.h"
     42
    4543#include "classes/DelphesClasses.h"
    4644#include "classes/DelphesFactory.h"
    47 
     45#include "classes/DelphesStream.h"
     46#include "modules/Delphes.h"
     47
     48#include "ExRootAnalysis/ExRootProgressBar.h"
     49#include "ExRootAnalysis/ExRootTreeBranch.h"
     50#include "ExRootAnalysis/ExRootTreeReader.h"
    4851#include "ExRootAnalysis/ExRootTreeWriter.h"
    49 #include "ExRootAnalysis/ExRootTreeReader.h"
    50 #include "ExRootAnalysis/ExRootTreeBranch.h"
    51 #include "ExRootAnalysis/ExRootProgressBar.h"
    52 
    53 
    5452
    5553using namespace std;
    5654
    5755//---------------------------------------------------------------------------
    58 
    5956
    6057//---------------------------------------------------------------------------
     
    9491  if(argc < 4)
    9592  {
    96     cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
     93    cout << " Usage: " << appName << " config_file"
     94         << " output_file"
     95         << " input_file(s)" << endl;
    9796    cout << " config_file - configuration file in Tcl format," << endl;
    9897    cout << " output_file - output file in ROOT format," << endl;
     
    122121
    123122    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
    124    
     123
    125124    confReader = new ExRootConfReader;
    126125    confReader->ReadFile(argv[1]);
     
    129128    modularDelphes->SetConfReader(confReader);
    130129    modularDelphes->SetTreeWriter(treeWriter);
    131    
     130
    132131    TChain *chain = new TChain("Delphes");
    133    
     132
    134133    factory = modularDelphes->GetFactory();
    135134    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
     
    145144      chain->Add(argv[i]);
    146145      ExRootTreeReader *treeReader = new ExRootTreeReader(chain);
    147      
     146
    148147      inputFile = TFile::Open(argv[i]);
    149148
     
    153152        throw runtime_error(message.str());
    154153      }
    155      
     154
    156155      numberOfEvents = treeReader->GetEntries();
    157       TClonesArray *branchParticle   = treeReader->UseBranch("Particle");
     156      TClonesArray *branchParticle = treeReader->UseBranch("Particle");
    158157      TClonesArray *branchHepMCEvent = treeReader->UseBranch("Event");
    159      
     158
    160159      if(numberOfEvents <= 0) continue;
    161160
     
    169168      for(Int_t entry = 0; entry < numberOfEvents && !interrupted; ++entry)
    170169      {
    171    
     170
    172171        treeReader->ReadEntry(entry);
    173172
    174         // -- TBC need also to include event weights -- 
    175        
    176         eve = (HepMCEvent*) branchHepMCEvent->At(0);
     173        // -- TBC need also to include event weights --
     174
     175        eve = (HepMCEvent *)branchHepMCEvent->At(0);
    177176        element = static_cast<HepMCEvent *>(branchEvent->NewEntry());
    178        
     177
    179178        element->Number = eventCounter;
    180179
     
    197196        element->ProcTime = eve->ProcTime;
    198197
    199         for(Int_t j=0; j < branchParticle->GetEntriesFast(); j++)
    200         {     
    201          
    202           gen = (GenParticle*) branchParticle->At(j);     
     198        for(Int_t j = 0; j < branchParticle->GetEntriesFast(); j++)
     199        {
     200
     201          gen = (GenParticle *)branchParticle->At(j);
    203202          candidate = factory->NewCandidate();
    204203
    205204          candidate->Momentum = gen->P4();
    206           candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T*1.0E3*c_light);
    207          
     205          candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T * 1.0E3 * c_light);
     206
    208207          candidate->PID = gen->PID;
    209208          candidate->Status = gen->Status;
    210      
     209
    211210          candidate->M1 = gen->M1;
    212211          candidate->M2 = gen->M2;
     
    216215
    217216          candidate->Charge = gen->Charge;
    218           candidate->Mass   = gen->Mass;
    219    
     217          candidate->Mass = gen->Mass;
     218
    220219          allParticleOutputArray->Add(candidate);
    221  
     220
    222221          pdgCode = TMath::Abs(gen->PID);
    223222
     
    231230          }
    232231        }
    233        
     232
    234233        modularDelphes->ProcessTask();
    235234
     
    242241        ++eventCounter;
    243242      }
    244  
     243
    245244      progressBar.Update(eventCounter, eventCounter, kTRUE);
    246245      progressBar.Finish();
    247246
    248247      inputFile->Close();
    249    
     248
    250249      delete treeReader;
    251      
    252250    }
    253251
     
    262260    delete outputFile;
    263261    delete chain;
    264    
     262
    265263    return 0;
    266264  }
  • readers/DelphesSTDHEP.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 #include <stdexcept>
    2019#include <iostream>
    2120#include <sstream>
     21#include <stdexcept>
    2222
    2323#include <signal.h>
    2424
     25#include "TApplication.h"
    2526#include "TROOT.h"
    26 #include "TApplication.h"
    27 
     27
     28#include "TDatabasePDG.h"
    2829#include "TFile.h"
     30#include "TLorentzVector.h"
    2931#include "TObjArray.h"
     32#include "TParticlePDG.h"
    3033#include "TStopwatch.h"
    31 #include "TDatabasePDG.h"
    32 #include "TParticlePDG.h"
    33 #include "TLorentzVector.h"
    34 
    35 #include "modules/Delphes.h"
     34
    3635#include "classes/DelphesClasses.h"
    3736#include "classes/DelphesFactory.h"
    3837#include "classes/DelphesSTDHEPReader.h"
    39 
     38#include "modules/Delphes.h"
     39
     40#include "ExRootAnalysis/ExRootProgressBar.h"
     41#include "ExRootAnalysis/ExRootTreeBranch.h"
    4042#include "ExRootAnalysis/ExRootTreeWriter.h"
    41 #include "ExRootAnalysis/ExRootTreeBranch.h"
    42 #include "ExRootAnalysis/ExRootProgressBar.h"
    4343
    4444using namespace std;
     
    7474  if(argc < 3)
    7575  {
    76     cout << " Usage: " << appName << " config_file" << " output_file" << " [input_file(s)]" << endl;
     76    cout << " Usage: " << appName << " config_file"
     77         << " output_file"
     78         << " [input_file(s)]" << endl;
    7779    cout << " config_file - configuration file in Tcl format," << endl;
    7880    cout << " output_file - output file in ROOT format," << endl;
     
    177179      reader->Clear();
    178180      readStopWatch.Start();
    179       while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) &&
    180         reader->ReadBlock(factory, allParticleOutputArray,
    181         stableParticleOutputArray, partonOutputArray) && !interrupted)
     181      while((maxEvents <= 0 || eventCounter - skipEvents < maxEvents) && reader->ReadBlock(factory, allParticleOutputArray, stableParticleOutputArray, partonOutputArray) && !interrupted)
    182182      {
    183183        if(reader->EventReady())
     
    215215
    216216      ++i;
    217     }
    218     while(i < argc);
     217    } while(i < argc);
    219218
    220219    modularDelphes->FinishTask();
  • validation/DelphesValidation.cpp

    re39abb4 r0e7d64a  
    1717 */
    1818
    19 
    2019#include <iostream>
     20#include <typeinfo>
    2121#include <utility>
    2222#include <vector>
    23 #include <typeinfo>
    24 
     23
     24#include "TApplication.h"
    2525#include "TROOT.h"
    2626#include "TSystem.h"
    27 #include "TApplication.h"
    2827
    2928#include "TString.h"
    3029
     30#include "TCanvas.h"
     31#include "TClonesArray.h"
     32#include "TGraph.h"
     33#include "TGraphErrors.h"
    3134#include "TH1.h"
    3235#include "TH2.h"
    33 #include "TMath.h"
    34 #include "TStyle.h"
    35 #include "TGraph.h"
    36 #include "TCanvas.h"
    3736#include "THStack.h"
    3837#include "TLegend.h"
     38#include "TLorentzVector.h"
     39#include "TMath.h"
     40#include "TMultiGraph.h"
    3941#include "TPaveText.h"
    40 #include "TClonesArray.h"
    41 #include "TLorentzVector.h"
    42 #include "TGraphErrors.h"
    43 #include "TMultiGraph.h"
     42#include "TStyle.h"
    4443
    4544#include "classes/DelphesClasses.h"
    4645
     46#include "ExRootAnalysis/ExRootResult.h"
     47#include "ExRootAnalysis/ExRootTreeBranch.h"
    4748#include "ExRootAnalysis/ExRootTreeReader.h"
    4849#include "ExRootAnalysis/ExRootTreeWriter.h"
    49 #include "ExRootAnalysis/ExRootTreeBranch.h"
    50 #include "ExRootAnalysis/ExRootResult.h"
    5150#include "ExRootAnalysis/ExRootUtilities.h"
    5251
     
    8281unsigned int k;
    8382
    84 
    8583struct resolPlot
    8684{
    87   TH1* resolHist;
     85  TH1 *resolHist;
    8886  double ptmin;
    8987  double ptmax;
     
    9997  void set(double ptdown, double ptup, TString object, double xmin = 0, double xmax = 2);
    10098  void set(double etadown, double etaup, double ptdown, double ptup, TString object, double xmin = 0, double xmax = 2);
    101   void print(){std::cout << ptmin << std::endl;}
     99  void print() { std::cout << ptmin << std::endl; }
    102100};
    103 
    104101
    105102resolPlot::resolPlot()
     
    109106resolPlot::resolPlot(double ptdown, double ptup, TString object)
    110107{
    111   this->set(ptdown,ptup,object);
     108  this->set(ptdown, ptup, object);
    112109}
    113110
     
    123120  obj = object;
    124121
    125   resolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax), obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax), 1000, xmin, xmax);
     122  resolHist = new TH1D(obj + "_delta_pt_" + Form("%4.2f", ptmin) + "_" + Form("%4.2f", ptmax), obj + "_delta_pt_" + Form("%4.2f", ptmin) + "_" + Form("%4.2f", ptmax), 1000, xmin, xmax);
    126123}
    127124
     
    134131  obj = object;
    135132
    136   resolHist = new TH1D(obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_"+Form("%4.2f",etamin)+"_"+Form("%4.2f",etamax), obj+"_delta_pt_"+Form("%4.2f",ptmin)+"_"+Form("%4.2f",ptmax)+"_"+Form("%4.2f",etamin)+"_"+Form("%4.2f",etamax), 1000, xmin, xmax);
     133  resolHist = new TH1D(obj + "_delta_pt_" + Form("%4.2f", ptmin) + "_" + Form("%4.2f", ptmax) + "_" + Form("%4.2f", etamin) + "_" + Form("%4.2f", etamax), obj + "_delta_pt_" + Form("%4.2f", ptmin) + "_" + Form("%4.2f", ptmax) + "_" + Form("%4.2f", etamin) + "_" + Form("%4.2f", etamax), 1000, xmin, xmax);
    137134}
    138 
    139 
    140135
    141136void HistogramsCollection(std::vector<resolPlot> *histos, double ptmin, double ptmax, TString obj, double xmin = 0, double xmax = 2)
     
    146141  resolPlot ptemp;
    147142
    148   for (int i = 0; i < Nbins; i++)
     143  for(int i = 0; i < Nbins; i++)
    149144  {
    150145    width = (ptmax - ptmin) / Nbins;
    151     ptdown = TMath::Power(10,ptmin + i * width );
    152     ptup = TMath::Power(10,ptmin + (i+1) * width );
     146    ptdown = TMath::Power(10, ptmin + i * width);
     147    ptup = TMath::Power(10, ptmin + (i + 1) * width);
    153148    ptemp.set(ptdown, ptup, obj, xmin, xmax);
    154149    histos->push_back(ptemp);
    155150  }
    156151}
    157 
    158152
    159153void HistogramsCollectionVsEta(std::vector<resolPlot> *histos, double etamin, double etamax, double ptmin, double ptmax, TString obj, double xmin = 0, double xmax = 2)
     
    164158  double etaup;
    165159
    166   for (int i = 0; i < Nbins; i++)
     160  for(int i = 0; i < Nbins; i++)
    167161  {
    168162    width = (etamax - etamin) / Nbins;
    169163    etadown = etamin + i * width;
    170     etaup = etamin + (i+1) * width;
     164    etaup = etamin + (i + 1) * width;
    171165
    172166    ptemp.set(etadown, etaup, ptmin, ptmax, obj, xmin, xmax);
     
    175169}
    176170
    177 
    178171//------------------------------------------------------------------------------
    179172
     
    183176//------------------------------------------------------------------------------
    184177
    185 void BinLogX(TH1*h)
     178void BinLogX(TH1 *h)
    186179{
    187180  TAxis *axis = h->GetXaxis();
     
    193186  Axis_t *new_bins = new Axis_t[bins + 1];
    194187
    195   for (int i = 0; i <= bins; i++)
     188  for(int i = 0; i <= bins; i++)
    196189  {
    197190    new_bins[i] = TMath::Power(10, from + i * width);
     
    201194}
    202195
    203 
    204196//------------------------------------------------------------------------------
    205197
    206 template<typename T>
    207 TH1D* GetEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     198template <typename T>
     199TH1D *GetEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    208200{
    209201
    210   cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     202  cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    211203
    212204  Long64_t allEntries = treeReader->GetEntries();
     
    223215  Int_t i, j;
    224216
    225   TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    226   TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     217  TH1D *histGenPt = new TH1D(name + " gen spectra Pt", name + " gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     218  TH1D *histRecoPt = new TH1D(name + " reco spectra Pt", name + " reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    227219
    228220  histGenPt->SetDirectory(0);
     
    242234    {
    243235
    244       particle = (GenParticle*) branchParticle->At(i);
     236      particle = (GenParticle *)branchParticle->At(i);
    245237      genMomentum = particle->P4();
    246238
    247239      deltaR = 999;
    248240
    249       pt  = genMomentum.Pt();
     241      pt = genMomentum.Pt();
    250242      eta = TMath::Abs(genMomentum.Eta());
    251243
    252 
    253       if(eta > etamax || eta < etamin ) continue;
    254 
    255       if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
     244      if(eta > etamax || eta < etamin) continue;
     245
     246      if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
    256247      //if (TMath::Abs(particle->PID) == pdgID && (particle->Status>20 && particle->Status <30) && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    257248      {
     
    259250        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    260251        {
    261           recoObj = (T*)branchReco->At(j);
     252          recoObj = (T *)branchReco->At(j);
    262253          recoMomentum = recoObj->P4();
    263         //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    264 
    265 
     254          //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    266255
    267256          // take the closest parton candidate
     
    269258          {
    270259            Jet *jet = (Jet *)recoObj;
    271             if( !(jet->BTag & (1 << 0)) ) continue;
     260            if(!(jet->BTag & (1 << 0))) continue;
    272261
    273262            //if(jet->BTag != ) continue;
    274263          }
    275264
    276             if(TMath::Abs(pdgID) == 4)
     265          if(TMath::Abs(pdgID) == 4)
    277266          {
    278267            Jet *jet = (Jet *)recoObj;
    279             if( !(jet->BTag & (1 << 0)) ) continue;
     268            if(!(jet->BTag & (1 << 0))) continue;
    280269          }
    281270
    282             if(TMath::Abs(pdgID) == 1)
     271          if(TMath::Abs(pdgID) == 1)
    283272          {
    284273            Jet *jet = (Jet *)recoObj;
    285             if( !(jet->BTag & (1 << 0)) ) continue;
     274            if(!(jet->BTag & (1 << 0))) continue;
    286275          }
    287276
     
    291280            if(jet->TauTag != 1) continue;
    292281          }
    293 
    294282
    295283          if(genMomentum.DeltaR(recoMomentum) < deltaR)
     
    300288        }
    301289        histGenPt->Fill(pt);
    302         if(deltaR < 0.3 && bestRecoMomentum.Pt()> 0.20*pt ) { histRecoPt->Fill(pt);}
    303 
     290        if(deltaR < 0.3 && bestRecoMomentum.Pt() > 0.20 * pt)
     291        {
     292          histRecoPt->Fill(pt);
     293        }
    304294      }
    305295    }
     
    315305}
    316306
    317 
    318 template<typename T>
    319 TH1D* GetEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     307template <typename T>
     308TH1D *GetEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    320309{
    321310
    322   cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     311  cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    323312
    324313  Long64_t allEntries = treeReader->GetEntries();
     
    335324  Int_t i, j;
    336325
    337   TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra", Nbins, etamin, etamax);
    338   TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra", Nbins, etamin, etamax);
     326  TH1D *histGenEta = new TH1D(name + " gen spectra Eta", name + " gen spectra", Nbins, etamin, etamax);
     327  TH1D *histRecoEta = new TH1D(name + " reco spectra Eta", name + " reco spectra", Nbins, etamin, etamax);
    339328
    340329  histGenEta->SetDirectory(0);
     
    351340    {
    352341
    353       particle = (GenParticle*) branchParticle->At(i);
     342      particle = (GenParticle *)branchParticle->At(i);
    354343      genMomentum = particle->P4();
    355344
    356345      deltaR = 999;
    357346
    358       pt  = genMomentum.Pt();
     347      pt = genMomentum.Pt();
    359348      eta = genMomentum.Eta();
    360349
    361       if(pt > ptmax || pt < ptmin ) continue;
    362 
    363       if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
     350      if(pt > ptmax || pt < ptmin) continue;
     351
     352      if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
    364353      //if (TMath::Abs(particle->PID) == pdgID && (particle->Status>20 && particle->Status <30) && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    365354      {
     
    367356        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    368357        {
    369           recoObj = (T*)branchReco->At(j);
     358          recoObj = (T *)branchReco->At(j);
    370359          recoMomentum = recoObj->P4();
    371360          // this is simply to avoid warnings from initial state particle
    372361          // having infite rapidity ...
    373         //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
     362          //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    374363
    375364          // take the closest parton candidate
     
    377366          {
    378367            Jet *jet = (Jet *)recoObj;
    379             if( !(jet->BTag & (1 << 0)) ) continue;
    380 
     368            if(!(jet->BTag & (1 << 0))) continue;
    381369          }
    382370
     
    384372          {
    385373            Jet *jet = (Jet *)recoObj;
    386             if( !(jet->BTag & (1 << 0)) ) continue;
     374            if(!(jet->BTag & (1 << 0))) continue;
    387375          }
    388376
    389            if(TMath::Abs(pdgID) == 1)
     377          if(TMath::Abs(pdgID) == 1)
    390378          {
    391379            Jet *jet = (Jet *)recoObj;
    392             if( !(jet->BTag & (1 << 0)) ) continue;
     380            if(!(jet->BTag & (1 << 0))) continue;
    393381          }
    394382
     
    406394
    407395        histGenEta->Fill(eta);
    408         if(deltaR < 0.3) { histRecoEta->Fill(eta); }
    409 
     396        if(deltaR < 0.3)
     397        {
     398          histRecoEta->Fill(eta);
     399        }
    410400      }
    411401    }
     
    421411}
    422412
    423 
    424413//------------------------------------------------------------------------------
    425414
    426 template<typename T>
    427 TH1D* GetJetEffPt(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     415template <typename T>
     416TH1D *GetJetEffPt(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    428417{
    429418
    430   cout << "** Computing Efficiency of reconstructing "<< branchJet->GetName() << " with PID " << pdgID << endl;
     419  cout << "** Computing Efficiency of reconstructing " << branchJet->GetName() << " with PID " << pdgID << endl;
    431420
    432421  Long64_t allEntries = treeReader->GetEntries();
     
    441430  Int_t j;
    442431
    443   TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    444   TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     432  TH1D *histGenPt = new TH1D(name + " gen spectra Pt", name + " gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     433  TH1D *histRecoPt = new TH1D(name + " reco spectra Pt", name + " reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    445434
    446435  histGenPt->SetDirectory(0);
     
    459448    for(j = 0; j < branchJet->GetEntriesFast(); ++j)
    460449    {
    461       recoObj = (T*)branchJet->At(j);
     450      recoObj = (T *)branchJet->At(j);
    462451      recoMomentum = recoObj->P4();
    463       pt =   recoMomentum.Pt();     
     452      pt = recoMomentum.Pt();
    464453      eta = TMath::Abs(recoMomentum.Eta());
    465454      Jet *jet = (Jet *)recoObj;
    466          
    467       if(eta > etamax || eta < etamin ) continue;
     455
     456      if(eta > etamax || eta < etamin) continue;
    468457      if(pt < ptmin || pt > ptmax) continue;
    469      
     458
    470459      Int_t flavor = jet->Flavor;
    471460      if(flavor == 21) flavor = 0;
    472    
     461
    473462      if(TMath::Abs(pdgID) == 1)
    474463      {
    475        
     464
    476465        if(flavor < 4)
    477466        {
    478467          histGenPt->Fill(pt);
    479           if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
     468          if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
    480469        }
    481470      }
     
    485474        {
    486475          histGenPt->Fill(pt);
    487           if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
     476          if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
    488477        }
    489478      }
     
    493482        {
    494483          histGenPt->Fill(pt);
    495           if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
     484          if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
    496485        }
    497486      }
    498    }
    499 
     487    }
    500488  }
    501489
     
    511499// ------------------------------------------------------------------------------------------------------------------------------------------------------
    512500
    513 template<typename T>
    514 TH1D* GetJetEffEta(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     501template <typename T>
     502TH1D *GetJetEffEta(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    515503{
    516504
    517   cout << "** Computing Efficiency of reconstructing "<< branchJet->GetName() << " with PID " << pdgID << endl;
     505  cout << "** Computing Efficiency of reconstructing " << branchJet->GetName() << " with PID " << pdgID << endl;
    518506
    519507  Long64_t allEntries = treeReader->GetEntries();
     
    528516  Int_t j;
    529517
    530   TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra", Nbins, etamin, etamax);
    531   TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra", Nbins, etamin, etamax);
     518  TH1D *histGenEta = new TH1D(name + " gen spectra Eta", name + " gen spectra", Nbins, etamin, etamax);
     519  TH1D *histRecoEta = new TH1D(name + " reco spectra Eta", name + " reco spectra", Nbins, etamin, etamax);
    532520
    533521  histGenEta->SetDirectory(0);
     
    542530    for(j = 0; j < branchJet->GetEntriesFast(); ++j)
    543531    {
    544       recoObj = (T*)branchJet->At(j);
     532      recoObj = (T *)branchJet->At(j);
    545533      recoMomentum = recoObj->P4();
    546       pt =   recoMomentum.Pt();     
     534      pt = recoMomentum.Pt();
    547535      eta = recoMomentum.Eta();
    548536      Jet *jet = (Jet *)recoObj;
    549          
    550       if(eta > etamax || eta < etamin ) continue;
     537
     538      if(eta > etamax || eta < etamin) continue;
    551539      if(pt < ptmin || pt > ptmax) continue;
    552      
     540
    553541      Int_t flavor = jet->Flavor;
    554542      if(flavor == 21) flavor = 0;
    555          
     543
    556544      if(TMath::Abs(pdgID) == 1)
    557545      {
    558         if(flavor  == 1 || flavor == 21)
     546        if(flavor == 1 || flavor == 21)
    559547        {
    560548          histGenEta->Fill(eta);
    561           if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
     549          if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
    562550        }
    563551      }
     
    567555        {
    568556          histGenEta->Fill(eta);
    569           if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
     557          if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
    570558        }
    571559      }
     
    575563        {
    576564          histGenEta->Fill(eta);
    577           if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
     565          if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
    578566        }
    579567      }
    580    }
    581 
    582   }
    583 
     568    }
     569  }
    584570
    585571  histRecoEta->Sumw2();
     
    592578}
    593579
    594 
    595580// -----------------------------------------------------------------------------------------------------------------------------------------------------
    596581
    597 template<typename T>
    598 TH1D* GetTauEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     582template <typename T>
     583TH1D *GetTauEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    599584{
    600585
    601   cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     586  cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    602587
    603588  Long64_t allEntries = treeReader->GetEntries();
     
    614599  Int_t i, j;
    615600
    616   TH1D *histGenPt = new TH1D(name+" gen spectra Pt",name+" gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    617   TH1D *histRecoPt = new TH1D(name+" reco spectra Pt",name+" reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     601  TH1D *histGenPt = new TH1D(name + " gen spectra Pt", name + " gen spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
     602  TH1D *histRecoPt = new TH1D(name + " reco spectra Pt", name + " reco spectra cen", Nbins, TMath::Log10(ptmin), TMath::Log10(ptmax));
    618603
    619604  histGenPt->SetDirectory(0);
     
    633618    {
    634619
    635       particle = (GenParticle*) branchParticle->At(i);
     620      particle = (GenParticle *)branchParticle->At(i);
    636621      genMomentum = particle->P4();
    637622
    638623      deltaR = 999;
    639624
    640       pt  = genMomentum.Pt();
     625      pt = genMomentum.Pt();
    641626      eta = TMath::Abs(genMomentum.Eta());
    642627
    643       if(eta > etamax || eta < etamin ) continue;
    644 
    645       if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
     628      if(eta > etamax || eta < etamin) continue;
     629
     630      if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
    646631      {
    647632        // Loop over all reco object in event
    648633        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    649634        {
    650           recoObj = (T*)branchReco->At(j);
     635          recoObj = (T *)branchReco->At(j);
    651636          recoMomentum = recoObj->P4();
    652637          // this is simply to avoid warnings from initial state particle
     
    657642          {
    658643            Jet *jet = (Jet *)recoObj;
    659             if( jet->TauTag != 1 ) continue;
     644            if(jet->TauTag != 1) continue;
    660645          }
    661646
     
    674659
    675660        histGenPt->Fill(pt);
    676         if(deltaR < 0.3) { histRecoPt->Fill(pt); }
    677 
     661        if(deltaR < 0.3)
     662        {
     663          histRecoPt->Fill(pt);
     664        }
    678665      }
    679666    }
     
    683670  histGenPt->Sumw2();
    684671
    685 
    686672  histRecoPt->Divide(histGenPt);
    687673  histRecoPt->Scale(100.);
    688   if(TMath::Abs(pdgID) == 15) histRecoPt->Scale(1/0.648);
     674  if(TMath::Abs(pdgID) == 15) histRecoPt->Scale(1 / 0.648);
    689675
    690676  return histRecoPt;
    691677}
    692678
    693 template<typename T>
    694 TH1D* GetTauEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     679template <typename T>
     680TH1D *GetTauEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    695681{
    696682
    697   cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     683  cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    698684
    699685  Long64_t allEntries = treeReader->GetEntries();
     
    710696  Int_t i, j;
    711697
    712   TH1D *histGenEta = new TH1D(name+" gen spectra Eta",name+" gen spectra", Nbins, etamin, etamax);
    713   TH1D *histRecoEta = new TH1D(name+" reco spectra Eta",name+" reco spectra", Nbins, etamin, etamax);
     698  TH1D *histGenEta = new TH1D(name + " gen spectra Eta", name + " gen spectra", Nbins, etamin, etamax);
     699  TH1D *histRecoEta = new TH1D(name + " reco spectra Eta", name + " reco spectra", Nbins, etamin, etamax);
    714700
    715701  histGenEta->SetDirectory(0);
     
    726712    {
    727713
    728       particle = (GenParticle*) branchParticle->At(i);
     714      particle = (GenParticle *)branchParticle->At(i);
    729715      genMomentum = particle->P4();
    730716
    731717      deltaR = 999;
    732718
    733       pt  = genMomentum.Pt();
     719      pt = genMomentum.Pt();
    734720      eta = genMomentum.Eta();
    735721
    736       if(pt > ptmax || pt < ptmin ) continue;
    737 
    738       if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
     722      if(pt > ptmax || pt < ptmin) continue;
     723
     724      if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
    739725      {
    740726        // Loop over all reco object in event
    741727        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    742728        {
    743           recoObj = (T*)branchReco->At(j);
     729          recoObj = (T *)branchReco->At(j);
    744730          recoMomentum = recoObj->P4();
    745731          // this is simply to avoid warnings from initial state particle
    746732          // having infite rapidity ...
    747         //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    748 
    749          if(TMath::Abs(pdgID) == 1)
     733          //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
     734
     735          if(TMath::Abs(pdgID) == 1)
    750736          {
    751737            Jet *jet = (Jet *)recoObj;
    752             if( jet->TauTag != 1 ) continue;
     738            if(jet->TauTag != 1) continue;
    753739          }
    754740
     
    767753
    768754        histGenEta->Fill(eta);
    769         if(deltaR < 0.3) { histRecoEta->Fill(eta); }
    770 
     755        if(deltaR < 0.3)
     756        {
     757          histRecoEta->Fill(eta);
     758        }
    771759      }
    772760    }
     
    778766  histRecoEta->Divide(histGenEta);
    779767  histRecoEta->Scale(100.);
    780   if(TMath::Abs(pdgID) == 15) histRecoEta->Scale(1/0.648);
     768  if(TMath::Abs(pdgID) == 15) histRecoEta->Scale(1 / 0.648);
    781769
    782770  return histRecoEta;
    783771}
    784772
    785 
    786 template<typename T>
     773template <typename T>
    787774void GetPtres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t etaMin, Double_t etaMax, ExRootTreeReader *treeReader)
    788775{
     
    792779
    793780  GenParticle *particle;
    794   T* recoObj;
     781  T *recoObj;
    795782
    796783  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    811798    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    812799    {
    813       recoObj = (T*) branchReco->At(i);
     800      recoObj = (T *)branchReco->At(i);
    814801      recoMomentum = recoObj->P4();
    815802
    816803      deltaR = 999;
    817804
    818      // Loop over all hard partons in event
    819      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    820      {
    821         particle = (GenParticle*) branchParticle->At(j);
    822         if (particle->PID == pdgID && particle->Status == 1)
     805      // Loop over all hard partons in event
     806      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
     807      {
     808        particle = (GenParticle *)branchParticle->At(j);
     809        if(particle->PID == pdgID && particle->Status == 1)
    823810        {
    824811          genMomentum = particle->P4();
     
    831818          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    832819          {
    833              deltaR = genMomentum.DeltaR(recoMomentum);
    834              bestGenMomentum = genMomentum;
     820            deltaR = genMomentum.DeltaR(recoMomentum);
     821            bestGenMomentum = genMomentum;
    835822          }
    836823        }
     
    839826      if(deltaR < 0.3)
    840827      {
    841         pt  = bestGenMomentum.Pt();
     828        pt = bestGenMomentum.Pt();
    842829        eta = TMath::Abs(bestGenMomentum.Eta());
    843830
    844         for (bin = 0; bin < Nbins; bin++)
     831        for(bin = 0; bin < Nbins; bin++)
    845832        {
    846833          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta > etaMin && eta < etaMax)
    847834          {
    848             histos->at(bin).resolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());
     835            histos->at(bin).resolHist->Fill(recoMomentum.Pt() / bestGenMomentum.Pt());
    849836          }
    850837        }
     
    854841}
    855842
    856 
    857 template<typename T>
     843template <typename T>
    858844void GetEres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t etaMin, Double_t etaMax, ExRootTreeReader *treeReader)
    859845{
     
    863849
    864850  GenParticle *particle;
    865   T* recoObj;
     851  T *recoObj;
    866852
    867853  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    879865    treeReader->ReadEntry(entry);
    880866
    881      // Loop over all reconstructed jets in event
     867    // Loop over all reconstructed jets in event
    882868    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    883869    {
    884       recoObj = (T*) branchReco->At(i);
     870      recoObj = (T *)branchReco->At(i);
    885871      recoMomentum = recoObj->P4();
    886872
    887873      deltaR = 999;
    888874
    889      // Loop over all hard partons in event
    890      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    891      {
    892         particle = (GenParticle*) branchParticle->At(j);
    893         if (particle->PID == pdgID && particle->Status == 1)
     875      // Loop over all hard partons in event
     876      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
     877      {
     878        particle = (GenParticle *)branchParticle->At(j);
     879        if(particle->PID == pdgID && particle->Status == 1)
    894880        {
    895881          genMomentum = particle->P4();
     
    902888          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    903889          {
    904              deltaR = genMomentum.DeltaR(recoMomentum);
    905              bestGenMomentum = genMomentum;
     890            deltaR = genMomentum.DeltaR(recoMomentum);
     891            bestGenMomentum = genMomentum;
    906892          }
    907893        }
     
    910896      if(deltaR < 0.3)
    911897      {
    912         e  = bestGenMomentum.E();
     898        e = bestGenMomentum.E();
    913899        eta = TMath::Abs(bestGenMomentum.Eta());
    914900
    915         for (bin = 0; bin < Nbins; bin++)
     901        for(bin = 0; bin < Nbins; bin++)
    916902        {
    917903          if(e > histos->at(bin).ptmin && e < histos->at(bin).ptmax && eta > etaMin && eta < etaMax)
    918904          {
    919             histos->at(bin).resolHist->Fill(recoMomentum.E()/bestGenMomentum.E());
     905            histos->at(bin).resolHist->Fill(recoMomentum.E() / bestGenMomentum.E());
    920906          }
    921907        }
     
    925911}
    926912
    927 
    928 template<typename T>
     913template <typename T>
    929914void GetPtresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t ptMin, Double_t ptMax, ExRootTreeReader *treeReader)
    930915{
     
    934919
    935920  GenParticle *particle;
    936   T* recoObj;
     921  T *recoObj;
    937922
    938923  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    953938    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    954939    {
    955       recoObj = (T*) branchReco->At(i);
     940      recoObj = (T *)branchReco->At(i);
    956941      recoMomentum = recoObj->P4();
    957942
    958943      deltaR = 999;
    959944
    960      // Loop over all hard partons in event
    961      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    962      {
    963         particle = (GenParticle*) branchParticle->At(j);
    964         if (particle->PID == pdgID && particle->Status == 1)
     945      // Loop over all hard partons in event
     946      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
     947      {
     948        particle = (GenParticle *)branchParticle->At(j);
     949        if(particle->PID == pdgID && particle->Status == 1)
    965950        {
    966951          genMomentum = particle->P4();
     
    973958          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    974959          {
    975              deltaR = genMomentum.DeltaR(recoMomentum);
    976              bestGenMomentum = genMomentum;
     960            deltaR = genMomentum.DeltaR(recoMomentum);
     961            bestGenMomentum = genMomentum;
    977962          }
    978963        }
     
    981966      if(deltaR < 0.3)
    982967      {
    983         pt  = bestGenMomentum.Pt();
     968        pt = bestGenMomentum.Pt();
    984969        eta = bestGenMomentum.Eta();
    985970
    986         for (bin = 0; bin < Nbins; bin++)
     971        for(bin = 0; bin < Nbins; bin++)
    987972        {
    988973          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && pt > ptMin && pt < ptMax)
    989974          {
    990              histos->at(bin).resolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());
     975            histos->at(bin).resolHist->Fill(recoMomentum.Pt() / bestGenMomentum.Pt());
    991976          }
    992977        }
     
    996981}
    997982
    998 template<typename T>
     983template <typename T>
    999984void GetEresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t eMin, Double_t eMax, ExRootTreeReader *treeReader)
    1000985{
     
    1004989
    1005990  GenParticle *particle;
    1006   T* recoObj;
     991  T *recoObj;
    1007992
    1008993  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    10231008    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    10241009    {
    1025       recoObj = (T*) branchReco->At(i);
     1010      recoObj = (T *)branchReco->At(i);
    10261011      recoMomentum = recoObj->P4();
    10271012
    10281013      deltaR = 999;
    10291014
    1030      // Loop over all hard partons in event
    1031      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
    1032      {
    1033         particle = (GenParticle*) branchParticle->At(j);
    1034         if (particle->PID == pdgID && particle->Status == 1)
     1015      // Loop over all hard partons in event
     1016      for(j = 0; j < branchParticle->GetEntriesFast(); ++j)
     1017      {
     1018        particle = (GenParticle *)branchParticle->At(j);
     1019        if(particle->PID == pdgID && particle->Status == 1)
    10351020        {
    10361021          genMomentum = particle->P4();
     
    10431028          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    10441029          {
    1045              deltaR = genMomentum.DeltaR(recoMomentum);
    1046              bestGenMomentum = genMomentum;
     1030            deltaR = genMomentum.DeltaR(recoMomentum);
     1031            bestGenMomentum = genMomentum;
    10471032          }
    10481033        }
     
    10511036      if(deltaR < 0.3)
    10521037      {
    1053         e  = bestGenMomentum.E();
     1038        e = bestGenMomentum.E();
    10541039        eta = bestGenMomentum.Eta();
    10551040
    1056 
    1057 
    1058         for (bin = 0; bin < Nbins; bin++)
     1041        for(bin = 0; bin < Nbins; bin++)
    10591042        {
    10601043          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && e > eMin && e < eMax)
    10611044          {
    1062              histos->at(bin).resolHist->Fill(recoMomentum.E()/bestGenMomentum.E());
     1045            histos->at(bin).resolHist->Fill(recoMomentum.E() / bestGenMomentum.E());
    10631046          }
    10641047        }
     
    10681051}
    10691052
    1070 
    1071 
    10721053void GetJetsEres(std::vector<resolPlot> *histos, TClonesArray *branchJet, TClonesArray *branchGenJet, ExRootTreeReader *treeReader, Double_t etaMin, Double_t etaMax)
    10731054{
     
    10931074    treeReader->ReadEntry(entry);
    10941075
    1095     if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
     1076    if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
    10961077
    10971078    // Loop over all reconstructed jets in event
    1098     for(i = 0; i < TMath::Min(2,branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
     1079    for(i = 0; i < TMath::Min(2, branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
    10991080    {
    11001081
    1101       jet = (Jet*) branchJet->At(i);
     1082      jet = (Jet *)branchJet->At(i);
    11021083      jetMomentum = jet->P4();
    11031084
    11041085      deltaR = 999;
    11051086
    1106      // Loop over all hard partons in event
    1107      for(j = 0; j < TMath::Min(2,branchGenJet->GetEntriesFast()); ++j)
    1108      {
    1109         genjet = (Jet*) branchGenJet->At(j);
     1087      // Loop over all hard partons in event
     1088      for(j = 0; j < TMath::Min(2, branchGenJet->GetEntriesFast()); ++j)
     1089      {
     1090        genjet = (Jet *)branchGenJet->At(j);
    11101091
    11111092        genJetMomentum = genjet->P4();
     
    11181099        if(genJetMomentum.DeltaR(jetMomentum) < deltaR)
    11191100        {
    1120            deltaR = genJetMomentum.DeltaR(jetMomentum);
    1121            bestGenJetMomentum = genJetMomentum;
     1101          deltaR = genJetMomentum.DeltaR(jetMomentum);
     1102          bestGenJetMomentum = genJetMomentum;
    11221103        }
    11231104      }
     
    11251106      if(deltaR < 0.3)
    11261107      {
    1127         pt  = genJetMomentum.E();
     1108        pt = genJetMomentum.E();
    11281109        eta = genJetMomentum.Eta();
    11291110
    1130         for (bin = 0; bin < Nbins; bin++)
     1111        for(bin = 0; bin < Nbins; bin++)
    11311112        {
    11321113          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < etaMax && eta > etaMin)
    11331114          {
    1134              histos->at(bin).resolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
     1115            histos->at(bin).resolHist->Fill(jetMomentum.E() / bestGenJetMomentum.E());
    11351116          }
    11361117        }
     
    11631144    treeReader->ReadEntry(entry);
    11641145
    1165     if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
     1146    if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
    11661147
    11671148    // Loop over all reconstructed jets in event
    1168     for(i = 0; i < TMath::Min(2,branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
     1149    for(i = 0; i < TMath::Min(2, branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
    11691150    {
    11701151
    1171       jet = (Jet*) branchJet->At(i);
     1152      jet = (Jet *)branchJet->At(i);
    11721153      jetMomentum = jet->P4();
    11731154
    11741155      deltaR = 999;
    11751156
    1176      // Loop over all hard partons in event
    1177      for(j = 0; j < TMath::Min(2,branchGenJet->GetEntriesFast()); ++j)
    1178      {
    1179         genjet = (Jet*) branchGenJet->At(j);
     1157      // Loop over all hard partons in event
     1158      for(j = 0; j < TMath::Min(2, branchGenJet->GetEntriesFast()); ++j)
     1159      {
     1160        genjet = (Jet *)branchGenJet->At(j);
    11801161
    11811162        genJetMomentum = genjet->P4();
     
    11881169        if(genJetMomentum.DeltaR(jetMomentum) < deltaR)
    11891170        {
    1190            deltaR = genJetMomentum.DeltaR(jetMomentum);
    1191            bestGenJetMomentum = genJetMomentum;
     1171          deltaR = genJetMomentum.DeltaR(jetMomentum);
     1172          bestGenJetMomentum = genJetMomentum;
    11921173        }
    11931174      }
     
    11961177      {
    11971178
    1198         pt  = genJetMomentum.E();
     1179        pt = genJetMomentum.E();
    11991180        eta = genJetMomentum.Eta();
    12001181
    1201         for (bin = 0; bin < Nbins; bin++)
     1182        for(bin = 0; bin < Nbins; bin++)
    12021183        {
    12031184          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && pt < eMax && pt > eMin)
    12041185          {
    1205              histos->at(bin).resolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
     1186            histos->at(bin).resolHist->Fill(jetMomentum.E() / bestGenJetMomentum.E());
    12061187          }
    12071188        }
     
    12111192}
    12121193
    1213 
    1214 
    1215 std::pair<Double_t, Double_t> GausFit(TH1* hist)
     1194std::pair<Double_t, Double_t> GausFit(TH1 *hist)
    12161195{
    1217   TF1 *f1 = new TF1("f1", "gaus", hist->GetMean()-2*hist->GetRMS(), hist->GetMean()+2*hist->GetRMS());
    1218   hist->Fit("f1","RQ");
    1219 
    1220   TF1 *f2 = new TF1("f2", "gaus", f1->GetParameter(1) - 2*f1->GetParameter(2), f1->GetParameter(1) + 2*f1->GetParameter(2));
    1221   hist->Fit("f2","RQ");
     1196  TF1 *f1 = new TF1("f1", "gaus", hist->GetMean() - 2 * hist->GetRMS(), hist->GetMean() + 2 * hist->GetRMS());
     1197  hist->Fit("f1", "RQ");
     1198
     1199  TF1 *f2 = new TF1("f2", "gaus", f1->GetParameter(1) - 2 * f1->GetParameter(2), f1->GetParameter(1) + 2 * f1->GetParameter(2));
     1200  hist->Fit("f2", "RQ");
    12221201
    12231202  Double_t sig = f2->GetParameter(2);
     
    12261205  delete f1;
    12271206  delete f2;
    1228   return make_pair (sig, sigErr);
     1207  return make_pair(sig, sigErr);
    12291208}
    1230 
    12311209
    12321210TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool rms = false)
     
    12341212  Int_t bin;
    12351213  Int_t count = 0;
    1236   TGraphErrors gr = TGraphErrors(Nbins/2);
     1214  TGraphErrors gr = TGraphErrors(Nbins / 2);
    12371215  double val, error;
    1238   for (bin = 0; bin < Nbins; bin++)
    1239   {
    1240      std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
    1241      if (rms == true)
    1242      {
    1243        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, 100*histos->at(bin).resolHist->GetRMS());
    1244        //gr.SetPointError(count,0, 100*sigvalues.second); // to correct
    1245        error = 100*histos->at(bin).resolHist->GetRMSError();
    1246        val = 100*histos->at(bin).resolHist->GetRMS();
    1247        if(error > 0.2*val) error = 0.2*val;
    1248        gr.SetPointError(count,0, error); // to correct
    1249      }
    1250      else
    1251      {
    1252 
    1253        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, 100*sigvalues.first);
    1254        error = 100*sigvalues.second;
    1255        val = 100*sigvalues.first;
    1256        if(error > 0.2*val) error = 0.2*val;
    1257        gr.SetPointError(count,0, error); // to correct
    1258        //gr.SetPointError(count,0, 100*sigvalues.second);
    1259      }
    1260      count++;
     1216  for(bin = 0; bin < Nbins; bin++)
     1217  {
     1218    std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
     1219    if(rms == true)
     1220    {
     1221      gr.SetPoint(count, (histos->at(bin).ptmin + histos->at(bin).ptmax) / 2.0, 100 * histos->at(bin).resolHist->GetRMS());
     1222      //gr.SetPointError(count,0, 100*sigvalues.second); // to correct
     1223      error = 100 * histos->at(bin).resolHist->GetRMSError();
     1224      val = 100 * histos->at(bin).resolHist->GetRMS();
     1225      if(error > 0.2 * val) error = 0.2 * val;
     1226      gr.SetPointError(count, 0, error); // to correct
     1227    }
     1228    else
     1229    {
     1230
     1231      gr.SetPoint(count, (histos->at(bin).ptmin + histos->at(bin).ptmax) / 2.0, 100 * sigvalues.first);
     1232      error = 100 * sigvalues.second;
     1233      val = 100 * sigvalues.first;
     1234      if(error > 0.2 * val) error = 0.2 * val;
     1235      gr.SetPointError(count, 0, error); // to correct
     1236      //gr.SetPointError(count,0, 100*sigvalues.second);
     1237    }
     1238    count++;
    12611239  }
    12621240
     
    12681246  Int_t bin;
    12691247  Int_t count = 0;
    1270   TGraphErrors gr = TGraphErrors(Nbins/2);
     1248  TGraphErrors gr = TGraphErrors(Nbins / 2);
    12711249  double val, error;
    1272   for (bin = 0; bin < Nbins; bin++)
    1273   {
    1274      std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
    1275      if (rms == true)
    1276      {
    1277        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, histos->at(bin).resolHist->GetRMS());
    1278        error = histos->at(bin).resolHist->GetRMSError();
    1279        val = histos->at(bin).resolHist->GetRMS();
    1280        if(error > 0.2*val) error = 0.2*val;
    1281        gr.SetPointError(count,0, error); // to correct
    1282      }
    1283      else
    1284      {
    1285 
    1286        gr.SetPoint(count,(histos->at(bin).ptmin+histos->at(bin).ptmax)/2.0, sigvalues.first);
    1287        val = sigvalues.first;
    1288        error = sigvalues.second;
    1289        if(error > 0.2*val) error = 0.2*val;
    1290        gr.SetPointError(count,0, error);
    1291        //gr.SetPointError(count,0, 100*sigvalues.second);
    1292      }
    1293      count++;
     1250  for(bin = 0; bin < Nbins; bin++)
     1251  {
     1252    std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
     1253    if(rms == true)
     1254    {
     1255      gr.SetPoint(count, (histos->at(bin).ptmin + histos->at(bin).ptmax) / 2.0, histos->at(bin).resolHist->GetRMS());
     1256      error = histos->at(bin).resolHist->GetRMSError();
     1257      val = histos->at(bin).resolHist->GetRMS();
     1258      if(error > 0.2 * val) error = 0.2 * val;
     1259      gr.SetPointError(count, 0, error); // to correct
     1260    }
     1261    else
     1262    {
     1263
     1264      gr.SetPoint(count, (histos->at(bin).ptmin + histos->at(bin).ptmax) / 2.0, sigvalues.first);
     1265      val = sigvalues.first;
     1266      error = sigvalues.second;
     1267      if(error > 0.2 * val) error = 0.2 * val;
     1268      gr.SetPointError(count, 0, error);
     1269      //gr.SetPointError(count,0, 100*sigvalues.second);
     1270    }
     1271    count++;
    12941272  }
    12951273
    12961274  return gr;
    12971275}
    1298 
    1299 
    13001276
    13011277TGraphErrors EresGraphVsEta(std::vector<resolPlot> *histos, bool rms = false)
     
    13031279  Int_t bin;
    13041280  Int_t count = 0;
    1305   TGraphErrors gr = TGraphErrors(Nbins/2);
     1281  TGraphErrors gr = TGraphErrors(Nbins / 2);
    13061282  double val, error;
    1307   for (bin = 0; bin < Nbins; bin++)
    1308   {
    1309 
    1310      std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
    1311      if (rms == true)
    1312      {
    1313        gr.SetPoint(count,(histos->at(bin).etamin+histos->at(bin).etamax)/2.0, histos->at(bin).resolHist->GetRMS());
    1314        error = 100*histos->at(bin).resolHist->GetRMSError();
    1315        val = 100*histos->at(bin).resolHist->GetRMS();
    1316        if(error > 0.2*val) error = 0.2*val;
    1317        gr.SetPointError(count,0, error); // to correct
    1318      }
    1319      else
    1320      {
    1321        gr.SetPoint(count,(histos->at(bin).etamin+histos->at(bin).etamax)/2.0, 100*sigvalues.first);
    1322        val = 100*sigvalues.first;
    1323        error = 100*sigvalues.second;
    1324        if(error > 0.2*val) error = 0.2*val;
    1325        gr.SetPointError(count,0, error);
    1326        //gr.SetPointError(count,0, 100*sigvalues.second);
    1327      }
    1328      count++;
     1283  for(bin = 0; bin < Nbins; bin++)
     1284  {
     1285
     1286    std::pair<Double_t, Double_t> sigvalues = GausFit(histos->at(bin).resolHist);
     1287    if(rms == true)
     1288    {
     1289      gr.SetPoint(count, (histos->at(bin).etamin + histos->at(bin).etamax) / 2.0, histos->at(bin).resolHist->GetRMS());
     1290      error = 100 * histos->at(bin).resolHist->GetRMSError();
     1291      val = 100 * histos->at(bin).resolHist->GetRMS();
     1292      if(error > 0.2 * val) error = 0.2 * val;
     1293      gr.SetPointError(count, 0, error); // to correct
     1294    }
     1295    else
     1296    {
     1297      gr.SetPoint(count, (histos->at(bin).etamin + histos->at(bin).etamax) / 2.0, 100 * sigvalues.first);
     1298      val = 100 * sigvalues.first;
     1299      error = 100 * sigvalues.second;
     1300      if(error > 0.2 * val) error = 0.2 * val;
     1301      gr.SetPointError(count, 0, error);
     1302      //gr.SetPointError(count,0, 100*sigvalues.second);
     1303    }
     1304    count++;
    13291305  }
    13301306
     
    13561332    treeReader->ReadEntry(entry);
    13571333
    1358     if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
    1359 
    1360     if (branchJet->GetEntriesFast() > 1)
     1334    if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
     1335
     1336    if(branchJet->GetEntriesFast() > 1)
    13611337    {
    13621338
    1363       jet = (Jet*) branchJet->At(0);
     1339      jet = (Jet *)branchJet->At(0);
    13641340      p1 = jet->P4();
    1365       jet = (Jet*) branchJet->At(1);
     1341      jet = (Jet *)branchJet->At(1);
    13661342      p2 = jet->P4();
    13671343
    1368       met = (MissingET*) branchMet->At(0);
    1369       scalarHT = (ScalarHT*) branchScalarHT->At(0);
     1344      met = (MissingET *)branchMet->At(0);
     1345      scalarHT = (ScalarHT *)branchScalarHT->At(0);
    13701346      ht = scalarHT->HT;
    13711347
    1372       if(p1.Pt() < 0.75*ht/2) continue;
    1373       if(p2.Pt() < 0.75*ht/2) continue;
    1374 
    1375       for (bin = 0; bin < Nbins; bin++)
     1348      if(p1.Pt() < 0.75 * ht / 2) continue;
     1349      if(p2.Pt() < 0.75 * ht / 2) continue;
     1350
     1351      for(bin = 0; bin < Nbins; bin++)
    13761352      {
    1377         if(ht > histos->at(bin).ptmin && ht < histos->at(bin).ptmax )
     1353        if(ht > histos->at(bin).ptmin && ht < histos->at(bin).ptmax)
    13781354        {
    13791355          histos->at(bin).resolHist->Fill(met->P4().Px());
     
    13841360}
    13851361
    1386 
    1387 
    13881362//------------------------------------------------------------------------------
    1389 
    13901363
    13911364void addResoGraph(TMultiGraph *mg, TGraphErrors *gr, TLegend *leg, int style, Color_t color, TString text)
     
    14001373  std::cout << "Adding " << gr->GetName() << std::endl;
    14011374  mg->Add(gr);
    1402   leg->AddEntry(gr,text,"p");
    1403 
     1375  leg->AddEntry(gr, text, "p");
    14041376}
    1405 
    14061377
    14071378void DrawAxis(TMultiGraph *mg, TLegend *leg, double xmin, double xmax, double ymin, double ymax, TString tx, TString ty, bool logx = 0, bool logy = 0)
     
    14091380  mg->SetMinimum(ymin);
    14101381  mg->SetMaximum(ymax);
    1411   mg->GetXaxis()->SetLimits(xmin,xmax);
     1382  mg->GetXaxis()->SetLimits(xmin, xmax);
    14121383
    14131384  mg->GetXaxis()->SetTitle(tx);
     
    14401411  if(logy) gPad->SetLogy();
    14411412
    1442 
    14431413  //gPad->SetGridx();
    14441414  //gPad->SetGridy();
     
    14471417  gPad->Modified();
    14481418  gPad->Update();
    1449 
    14501419}
    1451 
    14521420
    14531421void DelphesValidation(
     
    15451513  colors.push_back(kBlue);
    15461514  colors.push_back(kRed);
    1547   colors.push_back(kGreen+1);
    1548   colors.push_back(kMagenta+1);
     1515  colors.push_back(kGreen + 1);
     1516  colors.push_back(kMagenta + 1);
    15491517  colors.push_back(kOrange);
    15501518
     
    15661534  Int_t lastSlash = figPath.Last('/');
    15671535  Int_t sizePath = figPath.Length();
    1568   figPath.Remove(lastSlash+1,sizePath);
     1536  figPath.Remove(lastSlash + 1, sizePath);
    15691537
    15701538  TString header = pdfOutput;
     
    15731541  lastSlash = header.Last('/');
    15741542  sizePath = header.Length();
    1575   header.Remove(0,lastSlash+1);
     1543  header.Remove(0, lastSlash + 1);
    15761544
    15771545  TString vrs(version);
    15781546
    1579   TPaveText *pave = new TPaveText(0.0, 0.89, 0.94, 0.94,"NDC");
     1547  TPaveText *pave = new TPaveText(0.0, 0.89, 0.94, 0.94, "NDC");
    15801548  pave->SetTextAlign(30);
    15811549  pave->SetTextFont(132);
     
    15841552  pave->SetFillColor(0);
    15851553  pave->SetFillStyle(0);
    1586   pave->AddText("Delphes "+vrs+" - "+header);
     1554  pave->AddText("Delphes " + vrs + " - " + header);
    15871555
    15881556  TString s_etaMin, s_etaMax, s_eta, s_pt, s_e;
     
    16101578  etaVals.push_back(6.0);
    16111579
    1612   const int n_etabins = etaVals.size()-1;
     1580  const int n_etabins = etaVals.size() - 1;
    16131581  const int n_ptbins = ptVals.size();
    16141582
     
    16191587  // --------- Pion Tracks  --------- //
    16201588
    1621   TMultiGraph *mg_trkpi_res_pt  = new TMultiGraph("","");
    1622   TMultiGraph *mg_trkpi_eff_pt  = new TMultiGraph("","");
    1623   TMultiGraph *mg_trkpi_res_eta = new TMultiGraph("","");
    1624   TMultiGraph *mg_trkpi_eff_eta = new TMultiGraph("","");
    1625 
    1626   TLegend *leg_trkpi_res_pt = new TLegend(0.55,0.22,0.90,0.48);
    1627   TLegend *leg_trkpi_eff_pt = (TLegend*)leg_trkpi_res_pt->Clone();
    1628   TLegend *leg_trkpi_res_eta = (TLegend*)leg_trkpi_res_pt->Clone();
    1629   TLegend *leg_trkpi_eff_eta = (TLegend*)leg_trkpi_res_eta->Clone();
    1630 
    1631   TGraphErrors *gr_trkpi_res_pt  = new TGraphErrors[n_etabins];
    1632   TGraphErrors *gr_trkpi_eff_pt  = new TGraphErrors[n_etabins];
     1589  TMultiGraph *mg_trkpi_res_pt = new TMultiGraph("", "");
     1590  TMultiGraph *mg_trkpi_eff_pt = new TMultiGraph("", "");
     1591  TMultiGraph *mg_trkpi_res_eta = new TMultiGraph("", "");
     1592  TMultiGraph *mg_trkpi_eff_eta = new TMultiGraph("", "");
     1593
     1594  TLegend *leg_trkpi_res_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     1595  TLegend *leg_trkpi_eff_pt = (TLegend *)leg_trkpi_res_pt->Clone();
     1596  TLegend *leg_trkpi_res_eta = (TLegend *)leg_trkpi_res_pt->Clone();
     1597  TLegend *leg_trkpi_eff_eta = (TLegend *)leg_trkpi_res_eta->Clone();
     1598
     1599  TGraphErrors *gr_trkpi_res_pt = new TGraphErrors[n_etabins];
     1600  TGraphErrors *gr_trkpi_eff_pt = new TGraphErrors[n_etabins];
    16331601  TGraphErrors *gr_trkpi_res_eta = new TGraphErrors[n_ptbins];
    16341602  TGraphErrors *gr_trkpi_eff_eta = new TGraphErrors[n_ptbins];
    1635   TH1D* h_trkpi_eff_pt, *h_trkpi_eff_eta;
    1636 
    1637   std::vector<resolPlot> *plots_trkpi_res_pt   = new std::vector<resolPlot>[n_etabins];
    1638   std::vector<resolPlot> *plots_trkpi_res_eta  = new std::vector<resolPlot>[n_ptbins];
     1603  TH1D *h_trkpi_eff_pt, *h_trkpi_eff_eta;
     1604
     1605  std::vector<resolPlot> *plots_trkpi_res_pt = new std::vector<resolPlot>[n_etabins];
     1606  std::vector<resolPlot> *plots_trkpi_res_eta = new std::vector<resolPlot>[n_ptbins];
    16391607
    16401608  // loop over eta bins
    1641   for (k = 0; k < etaVals.size()-1; k++)
    1642   {
    1643      HistogramsCollection(&plots_trkpi_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
    1644      GetPtres<Track>(&plots_trkpi_res_pt[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
    1645      gr_trkpi_res_pt[k] = EresGraph(&plots_trkpi_res_pt[k]);
    1646 
    1647      h_trkpi_eff_pt = GetEffPt<Track>(branchTrackPion, branchParticlePion, "Pion", 211, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
    1648      gr_trkpi_eff_pt[k] = TGraphErrors(h_trkpi_eff_pt);
    1649 
    1650      s_etaMin = Form("%.1f",etaVals.at(k));
    1651      s_etaMax = Form("%.1f",etaVals.at(k+1));
    1652 
    1653      s_eta = "#pi^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    1654 
    1655      gr_trkpi_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    1656      gr_trkpi_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
    1657 
    1658      addResoGraph(mg_trkpi_res_pt, &gr_trkpi_res_pt[k], leg_trkpi_res_pt, markerStyles.at(k), colors.at(k), s_eta);
    1659      addResoGraph(mg_trkpi_eff_pt, &gr_trkpi_eff_pt[k], leg_trkpi_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     1609  for(k = 0; k < etaVals.size() - 1; k++)
     1610  {
     1611    HistogramsCollection(&plots_trkpi_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
     1612    GetPtres<Track>(&plots_trkpi_res_pt[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k + 1), treeReaderPion);
     1613    gr_trkpi_res_pt[k] = EresGraph(&plots_trkpi_res_pt[k]);
     1614
     1615    h_trkpi_eff_pt = GetEffPt<Track>(branchTrackPion, branchParticlePion, "Pion", 211, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderPion);
     1616    gr_trkpi_eff_pt[k] = TGraphErrors(h_trkpi_eff_pt);
     1617
     1618    s_etaMin = Form("%.1f", etaVals.at(k));
     1619    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1620
     1621    s_eta = "#pi^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     1622
     1623    gr_trkpi_res_pt[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     1624    gr_trkpi_eff_pt[k].SetName("trkEff_" + s_etaMin + "_" + s_etaMax);
     1625
     1626    addResoGraph(mg_trkpi_res_pt, &gr_trkpi_res_pt[k], leg_trkpi_res_pt, markerStyles.at(k), colors.at(k), s_eta);
     1627    addResoGraph(mg_trkpi_eff_pt, &gr_trkpi_eff_pt[k], leg_trkpi_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    16601628  }
    16611629
    16621630  // loop over pt
    1663   for (k = 0; k < ptVals.size(); k++)
    1664   {
    1665      HistogramsCollectionVsEta(&plots_trkpi_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkpi", 0.0, 2.0);
    1666      GetPtresVsEta<Track>(&plots_trkpi_res_eta[k], branchTrackPion, branchParticlePion, 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPion);
    1667      gr_trkpi_res_eta[k] = EresGraphVsEta(&plots_trkpi_res_eta[k]);
    1668 
    1669      h_trkpi_eff_eta = GetEffEta<Track>(branchTrackPion, branchParticlePion, "Pion", 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderPion);
    1670      gr_trkpi_eff_eta[k] = TGraphErrors(h_trkpi_eff_eta);
    1671 
    1672      s_pt = Form("#pi^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    1673      if(ptVals.at(k) >= 1000.) s_pt = Form("#pi^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    1674 
    1675      addResoGraph(mg_trkpi_res_eta, &gr_trkpi_res_eta[k], leg_trkpi_res_eta, markerStyles.at(k), colors.at(k), s_pt );
    1676      addResoGraph(mg_trkpi_eff_eta, &gr_trkpi_eff_eta[k], leg_trkpi_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    1677 
    1678   }
    1679 
    1680   TCanvas *c_trkpi_res_pt = new TCanvas("","", 800, 600);
     1631  for(k = 0; k < ptVals.size(); k++)
     1632  {
     1633    HistogramsCollectionVsEta(&plots_trkpi_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkpi", 0.0, 2.0);
     1634    GetPtresVsEta<Track>(&plots_trkpi_res_eta[k], branchTrackPion, branchParticlePion, 211, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderPion);
     1635    gr_trkpi_res_eta[k] = EresGraphVsEta(&plots_trkpi_res_eta[k]);
     1636
     1637    h_trkpi_eff_eta = GetEffEta<Track>(branchTrackPion, branchParticlePion, "Pion", 211, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderPion);
     1638    gr_trkpi_eff_eta[k] = TGraphErrors(h_trkpi_eff_eta);
     1639
     1640    s_pt = Form("#pi^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     1641    if(ptVals.at(k) >= 1000.) s_pt = Form("#pi^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     1642
     1643    addResoGraph(mg_trkpi_res_eta, &gr_trkpi_res_eta[k], leg_trkpi_res_eta, markerStyles.at(k), colors.at(k), s_pt);
     1644    addResoGraph(mg_trkpi_eff_eta, &gr_trkpi_eff_eta[k], leg_trkpi_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     1645  }
     1646
     1647  TCanvas *c_trkpi_res_pt = new TCanvas("", "", 800, 600);
    16811648
    16821649  mg_trkpi_res_pt->Draw("APE");
     
    16851652  pave->Draw();
    16861653
    1687   c_trkpi_res_pt->Print(pdfOutput+"(","pdf");
    1688   c_trkpi_res_pt->Print(figPath+"img_trkpi_res_pt.pdf","pdf");
    1689   c_trkpi_res_pt->Print(figPath+"img_trkpi_res_pt.png","png");
    1690 
    1691   TCanvas *c_trkpi_res_eta = new TCanvas("","", 800, 600);
     1654  c_trkpi_res_pt->Print(pdfOutput + "(", "pdf");
     1655  c_trkpi_res_pt->Print(figPath + "img_trkpi_res_pt.pdf", "pdf");
     1656  c_trkpi_res_pt->Print(figPath + "img_trkpi_res_pt.png", "png");
     1657
     1658  TCanvas *c_trkpi_res_eta = new TCanvas("", "", 800, 600);
    16921659
    16931660  mg_trkpi_res_eta->Draw("APE");
     
    16961663  pave->Draw();
    16971664
    1698   c_trkpi_res_eta->Print(pdfOutput,"pdf");
    1699   c_trkpi_res_eta->Print(figPath+"img_trkpi_res_eta.pdf","pdf");
    1700   c_trkpi_res_eta->Print(figPath+"img_trkpi_res_eta.png","png");
    1701 
    1702   TCanvas *c_trkpi_eff_pt = new TCanvas("","", 800, 600);
     1665  c_trkpi_res_eta->Print(pdfOutput, "pdf");
     1666  c_trkpi_res_eta->Print(figPath + "img_trkpi_res_eta.pdf", "pdf");
     1667  c_trkpi_res_eta->Print(figPath + "img_trkpi_res_eta.png", "png");
     1668
     1669  TCanvas *c_trkpi_eff_pt = new TCanvas("", "", 800, 600);
    17031670
    17041671  mg_trkpi_eff_pt->Draw("APE");
     
    17071674  pave->Draw();
    17081675
    1709   c_trkpi_eff_pt->Print(pdfOutput,"pdf");
    1710   c_trkpi_eff_pt->Print(figPath+"img_trkpi_eff_pt.pdf","pdf");
    1711   c_trkpi_eff_pt->Print(figPath+"img_trkpi_eff_pt.png","png");
    1712 
    1713   TCanvas *c_trkpi_eff_eta = new TCanvas("","", 800, 600);
     1676  c_trkpi_eff_pt->Print(pdfOutput, "pdf");
     1677  c_trkpi_eff_pt->Print(figPath + "img_trkpi_eff_pt.pdf", "pdf");
     1678  c_trkpi_eff_pt->Print(figPath + "img_trkpi_eff_pt.png", "png");
     1679
     1680  TCanvas *c_trkpi_eff_eta = new TCanvas("", "", 800, 600);
    17141681
    17151682  mg_trkpi_eff_eta->Draw("APE");
     
    17181685  pave->Draw();
    17191686
    1720 
    1721   c_trkpi_eff_eta->Print(pdfOutput,"pdf");
    1722   c_trkpi_eff_eta->Print(figPath+"img_trkpi_eff_eta.pdf","pdf");
    1723   c_trkpi_eff_eta->Print(figPath+"img_trkpi_eff_eta.png","png");
     1687  c_trkpi_eff_eta->Print(pdfOutput, "pdf");
     1688  c_trkpi_eff_eta->Print(figPath + "img_trkpi_eff_eta.pdf", "pdf");
     1689  c_trkpi_eff_eta->Print(figPath + "img_trkpi_eff_eta.png", "png");
    17241690
    17251691  // --------- Electron Tracks  --------- //
    17261692
    1727   TMultiGraph *mg_trkele_res_pt  = new TMultiGraph("","");
    1728   TMultiGraph *mg_trkele_eff_pt  = new TMultiGraph("","");
    1729   TMultiGraph *mg_trkele_res_eta = new TMultiGraph("","");
    1730   TMultiGraph *mg_trkele_eff_eta = new TMultiGraph("","");
    1731 
    1732   TLegend *leg_trkele_res_pt = new TLegend(0.55,0.22,0.90,0.48);
    1733   TLegend *leg_trkele_eff_pt = (TLegend*)leg_trkele_res_pt->Clone();
    1734   TLegend *leg_trkele_res_eta = (TLegend*)leg_trkele_res_pt->Clone();
    1735   TLegend *leg_trkele_eff_eta = (TLegend*)leg_trkele_res_eta->Clone();
    1736 
    1737   TGraphErrors *gr_trkele_res_pt  = new TGraphErrors[n_etabins];
    1738   TGraphErrors *gr_trkele_eff_pt  = new TGraphErrors[n_etabins];
     1693  TMultiGraph *mg_trkele_res_pt = new TMultiGraph("", "");
     1694  TMultiGraph *mg_trkele_eff_pt = new TMultiGraph("", "");
     1695  TMultiGraph *mg_trkele_res_eta = new TMultiGraph("", "");
     1696  TMultiGraph *mg_trkele_eff_eta = new TMultiGraph("", "");
     1697
     1698  TLegend *leg_trkele_res_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     1699  TLegend *leg_trkele_eff_pt = (TLegend *)leg_trkele_res_pt->Clone();
     1700  TLegend *leg_trkele_res_eta = (TLegend *)leg_trkele_res_pt->Clone();
     1701  TLegend *leg_trkele_eff_eta = (TLegend *)leg_trkele_res_eta->Clone();
     1702
     1703  TGraphErrors *gr_trkele_res_pt = new TGraphErrors[n_etabins];
     1704  TGraphErrors *gr_trkele_eff_pt = new TGraphErrors[n_etabins];
    17391705  TGraphErrors *gr_trkele_res_eta = new TGraphErrors[n_ptbins];
    17401706  TGraphErrors *gr_trkele_eff_eta = new TGraphErrors[n_ptbins];
    17411707
    1742   TH1D* h_trkele_eff_pt, *h_trkele_eff_eta;
    1743 
    1744   std::vector<resolPlot> *plots_trkele_res_pt   = new std::vector<resolPlot>[n_etabins];
    1745   std::vector<resolPlot> *plots_trkele_res_eta  = new std::vector<resolPlot>[n_ptbins];
     1708  TH1D *h_trkele_eff_pt, *h_trkele_eff_eta;
     1709
     1710  std::vector<resolPlot> *plots_trkele_res_pt = new std::vector<resolPlot>[n_etabins];
     1711  std::vector<resolPlot> *plots_trkele_res_eta = new std::vector<resolPlot>[n_ptbins];
    17461712
    17471713  // loop over eta bins
    1748   for (k = 0; k < etaVals.size()-1; k++)
    1749   {
    1750      HistogramsCollection(&plots_trkele_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
    1751      GetPtres<Track>(&plots_trkele_res_pt[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    1752      gr_trkele_res_pt[k] = EresGraph(&plots_trkele_res_pt[k]);
    1753 
    1754      h_trkele_eff_pt = GetEffPt<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    1755      gr_trkele_eff_pt[k] = TGraphErrors(h_trkele_eff_pt);
    1756 
    1757      s_etaMin = Form("%.1f",etaVals.at(k));
    1758      s_etaMax = Form("%.1f",etaVals.at(k+1));
    1759 
    1760      s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    1761 
    1762      gr_trkele_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    1763      gr_trkele_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
    1764 
    1765      addResoGraph(mg_trkele_res_pt, &gr_trkele_res_pt[k], leg_trkele_res_pt, markerStyles.at(k), colors.at(k), s_eta);
    1766      addResoGraph(mg_trkele_eff_pt, &gr_trkele_eff_pt[k], leg_trkele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     1714  for(k = 0; k < etaVals.size() - 1; k++)
     1715  {
     1716    HistogramsCollection(&plots_trkele_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
     1717    GetPtres<Track>(&plots_trkele_res_pt[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     1718    gr_trkele_res_pt[k] = EresGraph(&plots_trkele_res_pt[k]);
     1719
     1720    h_trkele_eff_pt = GetEffPt<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     1721    gr_trkele_eff_pt[k] = TGraphErrors(h_trkele_eff_pt);
     1722
     1723    s_etaMin = Form("%.1f", etaVals.at(k));
     1724    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1725
     1726    s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     1727
     1728    gr_trkele_res_pt[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     1729    gr_trkele_eff_pt[k].SetName("trkEff_" + s_etaMin + "_" + s_etaMax);
     1730
     1731    addResoGraph(mg_trkele_res_pt, &gr_trkele_res_pt[k], leg_trkele_res_pt, markerStyles.at(k), colors.at(k), s_eta);
     1732    addResoGraph(mg_trkele_eff_pt, &gr_trkele_eff_pt[k], leg_trkele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    17671733  }
    17681734
    17691735  // loop over pt
    1770   for (k = 0; k < ptVals.size(); k++)
    1771   {
    1772      HistogramsCollectionVsEta(&plots_trkele_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkele", 0.0, 2.0);
    1773      GetPtresVsEta<Track>(&plots_trkele_res_eta[k], branchTrackElectron, branchParticleElectron, 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderElectron);
    1774      gr_trkele_res_eta[k] = EresGraphVsEta(&plots_trkele_res_eta[k]);
    1775 
    1776      h_trkele_eff_eta = GetEffEta<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderElectron);
    1777      gr_trkele_eff_eta[k] = TGraphErrors(h_trkele_eff_eta);
    1778 
    1779      s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    1780      if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    1781 
    1782      addResoGraph(mg_trkele_res_eta, &gr_trkele_res_eta[k], leg_trkele_res_eta, markerStyles.at(k), colors.at(k), s_pt );
    1783      addResoGraph(mg_trkele_eff_eta, &gr_trkele_eff_eta[k], leg_trkele_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    1784 
    1785   }
    1786 
    1787   TCanvas *c_trkele_res_pt = new TCanvas("","", 800, 600);
     1736  for(k = 0; k < ptVals.size(); k++)
     1737  {
     1738    HistogramsCollectionVsEta(&plots_trkele_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkele", 0.0, 2.0);
     1739    GetPtresVsEta<Track>(&plots_trkele_res_eta[k], branchTrackElectron, branchParticleElectron, 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderElectron);
     1740    gr_trkele_res_eta[k] = EresGraphVsEta(&plots_trkele_res_eta[k]);
     1741
     1742    h_trkele_eff_eta = GetEffEta<Track>(branchTrackElectron, branchParticleElectron, "Electron", 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderElectron);
     1743    gr_trkele_eff_eta[k] = TGraphErrors(h_trkele_eff_eta);
     1744
     1745    s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     1746    if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     1747
     1748    addResoGraph(mg_trkele_res_eta, &gr_trkele_res_eta[k], leg_trkele_res_eta, markerStyles.at(k), colors.at(k), s_pt);
     1749    addResoGraph(mg_trkele_eff_eta, &gr_trkele_eff_eta[k], leg_trkele_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     1750  }
     1751
     1752  TCanvas *c_trkele_res_pt = new TCanvas("", "", 800, 600);
    17881753
    17891754  mg_trkele_res_pt->Draw("APE");
     
    17921757  pave->Draw();
    17931758
    1794   c_trkele_res_pt->Print(pdfOutput,"pdf");
    1795   c_trkele_res_pt->Print(figPath+"img_trkele_res_pt.pdf","pdf");
    1796   c_trkele_res_pt->Print(figPath+"img_trkele_res_pt.png","png");
    1797 
    1798   TCanvas *c_trkele_res_eta = new TCanvas("","", 800, 600);
     1759  c_trkele_res_pt->Print(pdfOutput, "pdf");
     1760  c_trkele_res_pt->Print(figPath + "img_trkele_res_pt.pdf", "pdf");
     1761  c_trkele_res_pt->Print(figPath + "img_trkele_res_pt.png", "png");
     1762
     1763  TCanvas *c_trkele_res_eta = new TCanvas("", "", 800, 600);
    17991764
    18001765  mg_trkele_res_eta->Draw("APE");
     
    18031768  pave->Draw();
    18041769
    1805   c_trkele_res_eta->Print(pdfOutput,"pdf");
    1806   c_trkele_res_eta->Print(figPath+"img_trkele_res_eta.pdf","pdf");
    1807   c_trkele_res_eta->Print(figPath+"img_trkele_res_eta.png","png");
    1808 
    1809   TCanvas *c_trkele_eff_pt = new TCanvas("","", 800, 600);
     1770  c_trkele_res_eta->Print(pdfOutput, "pdf");
     1771  c_trkele_res_eta->Print(figPath + "img_trkele_res_eta.pdf", "pdf");
     1772  c_trkele_res_eta->Print(figPath + "img_trkele_res_eta.png", "png");
     1773
     1774  TCanvas *c_trkele_eff_pt = new TCanvas("", "", 800, 600);
    18101775
    18111776  mg_trkele_eff_pt->Draw("APE");
     
    18141779  pave->Draw();
    18151780
    1816   c_trkele_eff_pt->Print(pdfOutput,"pdf");
    1817   c_trkele_eff_pt->Print(figPath+"img_trkele_eff_pt.pdf","pdf");
    1818   c_trkele_eff_pt->Print(figPath+"img_trkele_eff_pt.png","png");
    1819 
    1820   TCanvas *c_trkele_eff_eta = new TCanvas("","", 800, 600);
     1781  c_trkele_eff_pt->Print(pdfOutput, "pdf");
     1782  c_trkele_eff_pt->Print(figPath + "img_trkele_eff_pt.pdf", "pdf");
     1783  c_trkele_eff_pt->Print(figPath + "img_trkele_eff_pt.png", "png");
     1784
     1785  TCanvas *c_trkele_eff_eta = new TCanvas("", "", 800, 600);
    18211786
    18221787  mg_trkele_eff_eta->Draw("APE");
     
    18251790  pave->Draw();
    18261791
    1827   c_trkele_eff_eta->Print(pdfOutput,"pdf");
    1828   c_trkele_eff_eta->Print(figPath+"img_trkele_eff_eta.pdf","pdf");
    1829   c_trkele_eff_eta->Print(figPath+"img_trkele_eff_eta.png","png");
    1830 
     1792  c_trkele_eff_eta->Print(pdfOutput, "pdf");
     1793  c_trkele_eff_eta->Print(figPath + "img_trkele_eff_eta.pdf", "pdf");
     1794  c_trkele_eff_eta->Print(figPath + "img_trkele_eff_eta.png", "png");
    18311795
    18321796  // --------- Muon Tracks  --------- //
    18331797
    1834   TMultiGraph *mg_trkmu_res_pt  = new TMultiGraph("","");
    1835   TMultiGraph *mg_trkmu_eff_pt  = new TMultiGraph("","");
    1836   TMultiGraph *mg_trkmu_res_eta = new TMultiGraph("","");
    1837   TMultiGraph *mg_trkmu_eff_eta = new TMultiGraph("","");
    1838 
    1839   TLegend *leg_trkmu_res_pt = new TLegend(0.55,0.22,0.90,0.48);
    1840   TLegend *leg_trkmu_eff_pt = (TLegend*)leg_trkmu_res_pt->Clone();
    1841 
    1842   TLegend *leg_trkmu_res_eta = (TLegend*)leg_trkmu_res_pt->Clone();
    1843   TLegend *leg_trkmu_eff_eta = (TLegend*)leg_trkmu_res_eta->Clone();
    1844 
    1845 
    1846   TGraphErrors *gr_trkmu_res_pt  = new TGraphErrors[n_etabins];
    1847   TGraphErrors *gr_trkmu_eff_pt  = new TGraphErrors[n_etabins];
     1798  TMultiGraph *mg_trkmu_res_pt = new TMultiGraph("", "");
     1799  TMultiGraph *mg_trkmu_eff_pt = new TMultiGraph("", "");
     1800  TMultiGraph *mg_trkmu_res_eta = new TMultiGraph("", "");
     1801  TMultiGraph *mg_trkmu_eff_eta = new TMultiGraph("", "");
     1802
     1803  TLegend *leg_trkmu_res_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     1804  TLegend *leg_trkmu_eff_pt = (TLegend *)leg_trkmu_res_pt->Clone();
     1805
     1806  TLegend *leg_trkmu_res_eta = (TLegend *)leg_trkmu_res_pt->Clone();
     1807  TLegend *leg_trkmu_eff_eta = (TLegend *)leg_trkmu_res_eta->Clone();
     1808
     1809  TGraphErrors *gr_trkmu_res_pt = new TGraphErrors[n_etabins];
     1810  TGraphErrors *gr_trkmu_eff_pt = new TGraphErrors[n_etabins];
    18481811  TGraphErrors *gr_trkmu_res_eta = new TGraphErrors[n_ptbins];
    18491812  TGraphErrors *gr_trkmu_eff_eta = new TGraphErrors[n_ptbins];
    18501813
    1851   TH1D* h_trkmu_eff_pt, *h_trkmu_eff_eta;
    1852 
    1853   std::vector<resolPlot> *plots_trkmu_res_pt   = new std::vector<resolPlot>[n_etabins];
    1854   std::vector<resolPlot> *plots_trkmu_res_eta  = new std::vector<resolPlot>[n_ptbins];
     1814  TH1D *h_trkmu_eff_pt, *h_trkmu_eff_eta;
     1815
     1816  std::vector<resolPlot> *plots_trkmu_res_pt = new std::vector<resolPlot>[n_etabins];
     1817  std::vector<resolPlot> *plots_trkmu_res_eta = new std::vector<resolPlot>[n_ptbins];
    18551818
    18561819  // loop over eta bins
    1857   for (k = 0; k < etaVals.size()-1; k++)
    1858   {
    1859      HistogramsCollection(&plots_trkmu_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkmu");
    1860      GetPtres<Track>(&plots_trkmu_res_pt[k], branchTrackMuon, branchParticleMuon, 13, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
    1861      gr_trkmu_res_pt[k] = EresGraph(&plots_trkmu_res_pt[k]);
    1862 
    1863      h_trkmu_eff_pt = GetEffPt<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
    1864      gr_trkmu_eff_pt[k] = TGraphErrors(h_trkmu_eff_pt);
    1865 
    1866      s_etaMin = Form("%.1f",etaVals.at(k));
    1867      s_etaMax = Form("%.1f",etaVals.at(k+1));
    1868 
    1869      s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    1870 
    1871      gr_trkmu_res_pt[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    1872      gr_trkmu_eff_pt[k].SetName("trkEff_"+s_etaMin+"_"+s_etaMax);
    1873 
    1874      addResoGraph(mg_trkmu_res_pt, &gr_trkmu_res_pt[k], leg_trkmu_res_pt, markerStyles.at(k), colors.at(k), s_eta);
    1875      addResoGraph(mg_trkmu_eff_pt, &gr_trkmu_eff_pt[k], leg_trkmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     1820  for(k = 0; k < etaVals.size() - 1; k++)
     1821  {
     1822    HistogramsCollection(&plots_trkmu_res_pt[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkmu");
     1823    GetPtres<Track>(&plots_trkmu_res_pt[k], branchTrackMuon, branchParticleMuon, 13, etaVals.at(k), etaVals.at(k + 1), treeReaderMuon);
     1824    gr_trkmu_res_pt[k] = EresGraph(&plots_trkmu_res_pt[k]);
     1825
     1826    h_trkmu_eff_pt = GetEffPt<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderMuon);
     1827    gr_trkmu_eff_pt[k] = TGraphErrors(h_trkmu_eff_pt);
     1828
     1829    s_etaMin = Form("%.1f", etaVals.at(k));
     1830    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1831
     1832    s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     1833
     1834    gr_trkmu_res_pt[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     1835    gr_trkmu_eff_pt[k].SetName("trkEff_" + s_etaMin + "_" + s_etaMax);
     1836
     1837    addResoGraph(mg_trkmu_res_pt, &gr_trkmu_res_pt[k], leg_trkmu_res_pt, markerStyles.at(k), colors.at(k), s_eta);
     1838    addResoGraph(mg_trkmu_eff_pt, &gr_trkmu_eff_pt[k], leg_trkmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    18761839  }
    18771840
    18781841  // loop over pt
    1879   for (k = 0; k < ptVals.size(); k++)
    1880   {
    1881      HistogramsCollectionVsEta(&plots_trkmu_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkmu", 0.0, 2.0);
    1882      GetPtresVsEta<Track>(&plots_trkmu_res_eta[k], branchTrackMuon, branchParticleMuon, 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderMuon);
    1883      gr_trkmu_res_eta[k] = EresGraphVsEta(&plots_trkmu_res_eta[k]);
    1884 
    1885      h_trkmu_eff_eta = GetEffEta<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderMuon);
    1886      gr_trkmu_eff_eta[k] = TGraphErrors(h_trkmu_eff_eta);
    1887 
    1888      s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    1889      if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    1890 
    1891      addResoGraph(mg_trkmu_res_eta, &gr_trkmu_res_eta[k], leg_trkmu_res_eta, markerStyles.at(k), colors.at(k), s_pt );
    1892      addResoGraph(mg_trkmu_eff_eta, &gr_trkmu_eff_eta[k], leg_trkmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    1893 
    1894   }
    1895 
    1896   TCanvas *c_trkmu_res_pt = new TCanvas("","", 800, 600);
     1842  for(k = 0; k < ptVals.size(); k++)
     1843  {
     1844    HistogramsCollectionVsEta(&plots_trkmu_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkmu", 0.0, 2.0);
     1845    GetPtresVsEta<Track>(&plots_trkmu_res_eta[k], branchTrackMuon, branchParticleMuon, 13, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderMuon);
     1846    gr_trkmu_res_eta[k] = EresGraphVsEta(&plots_trkmu_res_eta[k]);
     1847
     1848    h_trkmu_eff_eta = GetEffEta<Track>(branchTrackMuon, branchParticleMuon, "Muon", 13, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderMuon);
     1849    gr_trkmu_eff_eta[k] = TGraphErrors(h_trkmu_eff_eta);
     1850
     1851    s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     1852    if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     1853
     1854    addResoGraph(mg_trkmu_res_eta, &gr_trkmu_res_eta[k], leg_trkmu_res_eta, markerStyles.at(k), colors.at(k), s_pt);
     1855    addResoGraph(mg_trkmu_eff_eta, &gr_trkmu_eff_eta[k], leg_trkmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     1856  }
     1857
     1858  TCanvas *c_trkmu_res_pt = new TCanvas("", "", 800, 600);
    18971859
    18981860  mg_trkmu_res_pt->Draw("APE");
     
    19011863  pave->Draw();
    19021864
    1903   c_trkmu_res_pt->Print(pdfOutput,"pdf");
    1904   c_trkmu_res_pt->Print(figPath+"img_trkmu_res_pt.pdf","pdf");
    1905   c_trkmu_res_pt->Print(figPath+"img_trkmu_res_pt.png","png");
    1906 
    1907   TCanvas *c_trkmu_res_eta = new TCanvas("","", 800, 600);
     1865  c_trkmu_res_pt->Print(pdfOutput, "pdf");
     1866  c_trkmu_res_pt->Print(figPath + "img_trkmu_res_pt.pdf", "pdf");
     1867  c_trkmu_res_pt->Print(figPath + "img_trkmu_res_pt.png", "png");
     1868
     1869  TCanvas *c_trkmu_res_eta = new TCanvas("", "", 800, 600);
    19081870
    19091871  mg_trkmu_res_eta->Draw("APE");
     
    19121874  pave->Draw();
    19131875
    1914   c_trkmu_res_eta->Print(pdfOutput,"pdf");
    1915   c_trkmu_res_eta->Print(figPath+"img_trkmu_res_eta.pdf","pdf");
    1916   c_trkmu_res_eta->Print(figPath+"img_trkmu_res_eta.png","png");
    1917 
    1918   TCanvas *c_trkmu_eff_pt = new TCanvas("","", 800, 600);
     1876  c_trkmu_res_eta->Print(pdfOutput, "pdf");
     1877  c_trkmu_res_eta->Print(figPath + "img_trkmu_res_eta.pdf", "pdf");
     1878  c_trkmu_res_eta->Print(figPath + "img_trkmu_res_eta.png", "png");
     1879
     1880  TCanvas *c_trkmu_eff_pt = new TCanvas("", "", 800, 600);
    19191881
    19201882  mg_trkmu_eff_pt->Draw("APE");
     
    19231885  pave->Draw();
    19241886
    1925   c_trkmu_eff_pt->Print(pdfOutput,"pdf");
    1926   c_trkmu_eff_pt->Print(figPath+"img_trkmu_eff_pt.pdf","pdf");
    1927   c_trkmu_eff_pt->Print(figPath+"img_trkmu_eff_pt.png","png");
    1928 
    1929   TCanvas *c_trkmu_eff_eta = new TCanvas("","", 800, 600);
     1887  c_trkmu_eff_pt->Print(pdfOutput, "pdf");
     1888  c_trkmu_eff_pt->Print(figPath + "img_trkmu_eff_pt.pdf", "pdf");
     1889  c_trkmu_eff_pt->Print(figPath + "img_trkmu_eff_pt.png", "png");
     1890
     1891  TCanvas *c_trkmu_eff_eta = new TCanvas("", "", 800, 600);
    19301892
    19311893  mg_trkmu_eff_eta->Draw("APE");
     
    19341896  pave->Draw();
    19351897
    1936   c_trkmu_eff_eta->Print(pdfOutput,"pdf");
    1937   c_trkmu_eff_eta->Print(figPath+"img_trkmu_eff_eta.pdf","pdf");
    1938   c_trkmu_eff_eta->Print(figPath+"img_trkmu_eff_eta.png","png");
    1939 
     1898  c_trkmu_eff_eta->Print(pdfOutput, "pdf");
     1899  c_trkmu_eff_eta->Print(figPath + "img_trkmu_eff_eta.pdf", "pdf");
     1900  c_trkmu_eff_eta->Print(figPath + "img_trkmu_eff_eta.png", "png");
    19401901
    19411902  //////////////////////
     
    19431904  //////////////////////
    19441905
    1945 
    1946   TMultiGraph *mg_ecal_res_e  = new TMultiGraph("","");
    1947   TMultiGraph *mg_ecal_res_eta = new TMultiGraph("","");
    1948 
    1949   TLegend *leg_ecal_res_e = new TLegend(0.55,0.64,0.90,0.90);
    1950   TLegend *leg_ecal_res_eta = new TLegend(0.60,0.59,0.95,0.90);
    1951 
    1952   TGraphErrors *gr_ecal_res_e    = new TGraphErrors[n_etabins];
    1953   TGraphErrors *gr_ecal_res_eta  = new TGraphErrors[n_ptbins];
    1954 
    1955   std::vector<resolPlot> *plots_ecal_res_e   = new std::vector<resolPlot>[n_etabins];
     1906  TMultiGraph *mg_ecal_res_e = new TMultiGraph("", "");
     1907  TMultiGraph *mg_ecal_res_eta = new TMultiGraph("", "");
     1908
     1909  TLegend *leg_ecal_res_e = new TLegend(0.55, 0.64, 0.90, 0.90);
     1910  TLegend *leg_ecal_res_eta = new TLegend(0.60, 0.59, 0.95, 0.90);
     1911
     1912  TGraphErrors *gr_ecal_res_e = new TGraphErrors[n_etabins];
     1913  TGraphErrors *gr_ecal_res_eta = new TGraphErrors[n_ptbins];
     1914
     1915  std::vector<resolPlot> *plots_ecal_res_e = new std::vector<resolPlot>[n_etabins];
    19561916  std::vector<resolPlot> *plots_ecal_res_eta = new std::vector<resolPlot>[n_ptbins];
    19571917
    19581918  // loop over eta bins
    1959   for (k = 0; k < etaVals.size()-1; k++)
    1960   {
    1961      HistogramsCollection(&plots_ecal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "ecal");
    1962      GetEres<Tower>(&plots_ecal_res_e[k], branchTowerPhoton, branchParticlePhoton, 22, etaVals.at(k), etaVals.at(k+1), treeReaderPhoton);
    1963      gr_ecal_res_e[k] = EresGraph(&plots_ecal_res_e[k]);
    1964 
    1965      s_etaMin = Form("%.1f",etaVals.at(k));
    1966      s_etaMax = Form("%.1f",etaVals.at(k+1));
    1967 
    1968      s_eta = "#gamma , " + s_etaMin + " < | #eta | < "+s_etaMax;
    1969 
    1970      gr_ecal_res_e[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    1971 
    1972      addResoGraph(mg_ecal_res_e, &gr_ecal_res_e[k], leg_ecal_res_e, markerStyles.at(k), colors.at(k), s_eta);
     1919  for(k = 0; k < etaVals.size() - 1; k++)
     1920  {
     1921    HistogramsCollection(&plots_ecal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "ecal");
     1922    GetEres<Tower>(&plots_ecal_res_e[k], branchTowerPhoton, branchParticlePhoton, 22, etaVals.at(k), etaVals.at(k + 1), treeReaderPhoton);
     1923    gr_ecal_res_e[k] = EresGraph(&plots_ecal_res_e[k]);
     1924
     1925    s_etaMin = Form("%.1f", etaVals.at(k));
     1926    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1927
     1928    s_eta = "#gamma , " + s_etaMin + " < | #eta | < " + s_etaMax;
     1929
     1930    gr_ecal_res_e[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     1931
     1932    addResoGraph(mg_ecal_res_e, &gr_ecal_res_e[k], leg_ecal_res_e, markerStyles.at(k), colors.at(k), s_eta);
    19731933  }
    19741934
    19751935  // loop over pt
    1976   for (k = 0; k < ptVals.size(); k++)
    1977   {
    1978      HistogramsCollectionVsEta(&plots_ecal_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "ecal", 0.0, 2.0);
    1979      GetEresVsEta<Tower>(&plots_ecal_res_eta[k], branchTowerPhoton, branchParticlePhoton, 22, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPhoton);
    1980      gr_ecal_res_eta[k] = EresGraphVsEta(&plots_ecal_res_eta[k]);
    1981 
    1982      s_e = Form("#gamma , E = %.0f GeV",ptVals.at(k));
    1983      if(ptVals.at(k) >= 1000.) s_e = Form("#gamma , E = %.0f TeV",ptVals.at(k)/1000.);
    1984 
    1985      addResoGraph(mg_ecal_res_eta, &gr_ecal_res_eta[k], leg_ecal_res_eta, markerStyles.at(k), colors.at(k), s_e );
    1986   }
    1987 
    1988   TCanvas *c_ecal_res_e = new TCanvas("","", 800, 600);
     1936  for(k = 0; k < ptVals.size(); k++)
     1937  {
     1938    HistogramsCollectionVsEta(&plots_ecal_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "ecal", 0.0, 2.0);
     1939    GetEresVsEta<Tower>(&plots_ecal_res_eta[k], branchTowerPhoton, branchParticlePhoton, 22, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderPhoton);
     1940    gr_ecal_res_eta[k] = EresGraphVsEta(&plots_ecal_res_eta[k]);
     1941
     1942    s_e = Form("#gamma , E = %.0f GeV", ptVals.at(k));
     1943    if(ptVals.at(k) >= 1000.) s_e = Form("#gamma , E = %.0f TeV", ptVals.at(k) / 1000.);
     1944
     1945    addResoGraph(mg_ecal_res_eta, &gr_ecal_res_eta[k], leg_ecal_res_eta, markerStyles.at(k), colors.at(k), s_e);
     1946  }
     1947
     1948  TCanvas *c_ecal_res_e = new TCanvas("", "", 800, 600);
    19891949
    19901950  mg_ecal_res_e->Draw("APE");
    1991  // DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.5, 100, "E [GeV]", "(ECAL resolution in E)/E (%)", true, true);
     1951  // DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.5, 100, "E [GeV]", "(ECAL resolution in E)/E (%)", true, true);
    19921952  DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.0, 20, "E [GeV]", "(ECAL resolution in E)/E (%)", true, false);
    19931953  leg_ecal_res_e->Draw();
    19941954  pave->Draw();
    19951955
    1996   c_ecal_res_e->Print(pdfOutput,"pdf");
    1997   c_ecal_res_e->Print(figPath+"img_ecal_res_e.pdf","pdf");
    1998   c_ecal_res_e->Print(figPath+"img_ecal_res_e.png","png");
    1999 
    2000   TCanvas *c_ecal_res_eta = new TCanvas("","", 800, 600);
     1956  c_ecal_res_e->Print(pdfOutput, "pdf");
     1957  c_ecal_res_e->Print(figPath + "img_ecal_res_e.pdf", "pdf");
     1958  c_ecal_res_e->Print(figPath + "img_ecal_res_e.png", "png");
     1959
     1960  TCanvas *c_ecal_res_eta = new TCanvas("", "", 800, 600);
    20011961
    20021962  mg_ecal_res_eta->Draw("APE");
     
    20061966  pave->Draw();
    20071967
    2008   c_ecal_res_eta->Print(pdfOutput,"pdf");
    2009   c_ecal_res_eta->Print(figPath+"img_ecal_res_eta.pdf","pdf");
    2010   c_ecal_res_eta->Print(figPath+"img_ecal_res_eta.png","png");
     1968  c_ecal_res_eta->Print(pdfOutput, "pdf");
     1969  c_ecal_res_eta->Print(figPath + "img_ecal_res_eta.pdf", "pdf");
     1970  c_ecal_res_eta->Print(figPath + "img_ecal_res_eta.png", "png");
    20111971
    20121972  //////////////////////
     
    20141974  //////////////////////
    20151975
    2016 
    2017   TMultiGraph *mg_hcal_res_e  = new TMultiGraph("","");
    2018   TMultiGraph *mg_hcal_res_eta = new TMultiGraph("","");
    2019 
    2020   TLegend *leg_hcal_res_e = new TLegend(0.55,0.64,0.90,0.90);
    2021   TLegend *leg_hcal_res_eta = new TLegend(0.60,0.59,0.95,0.90);
    2022 
    2023   TGraphErrors *gr_hcal_res_e   = new TGraphErrors[n_etabins];
     1976  TMultiGraph *mg_hcal_res_e = new TMultiGraph("", "");
     1977  TMultiGraph *mg_hcal_res_eta = new TMultiGraph("", "");
     1978
     1979  TLegend *leg_hcal_res_e = new TLegend(0.55, 0.64, 0.90, 0.90);
     1980  TLegend *leg_hcal_res_eta = new TLegend(0.60, 0.59, 0.95, 0.90);
     1981
     1982  TGraphErrors *gr_hcal_res_e = new TGraphErrors[n_etabins];
    20241983  TGraphErrors *gr_hcal_res_eta = new TGraphErrors[n_ptbins];
    20251984
    2026   std::vector<resolPlot> *plots_hcal_res_e   = new std::vector<resolPlot>[n_etabins];
     1985  std::vector<resolPlot> *plots_hcal_res_e = new std::vector<resolPlot>[n_etabins];
    20271986  std::vector<resolPlot> *plots_hcal_res_eta = new std::vector<resolPlot>[n_ptbins];
    20281987
    20291988  // loop over eta bins
    2030   for (k = 0; k < etaVals.size()-1; k++)
    2031   {
    2032      HistogramsCollection(&plots_hcal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "hcal");
    2033      GetEres<Tower>(&plots_hcal_res_e[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, etaVals.at(k), etaVals.at(k+1), treeReaderNeutralHadron);
    2034 
    2035      gr_hcal_res_e[k] = EresGraph(&plots_hcal_res_e[k]);
    2036 
    2037      s_etaMin = Form("%.1f",etaVals.at(k));
    2038      s_etaMax = Form("%.1f",etaVals.at(k+1));
    2039 
    2040      s_eta = "n , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2041 
    2042      gr_hcal_res_e[k].SetName("trkRes_"+s_etaMin+"_"+s_etaMax);
    2043 
    2044      addResoGraph(mg_hcal_res_e, &gr_hcal_res_e[k], leg_hcal_res_e, markerStyles.at(k), colors.at(k), s_eta);
     1989  for(k = 0; k < etaVals.size() - 1; k++)
     1990  {
     1991    HistogramsCollection(&plots_hcal_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "hcal");
     1992    GetEres<Tower>(&plots_hcal_res_e[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, etaVals.at(k), etaVals.at(k + 1), treeReaderNeutralHadron);
     1993
     1994    gr_hcal_res_e[k] = EresGraph(&plots_hcal_res_e[k]);
     1995
     1996    s_etaMin = Form("%.1f", etaVals.at(k));
     1997    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     1998
     1999    s_eta = "n , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2000
     2001    gr_hcal_res_e[k].SetName("trkRes_" + s_etaMin + "_" + s_etaMax);
     2002
     2003    addResoGraph(mg_hcal_res_e, &gr_hcal_res_e[k], leg_hcal_res_e, markerStyles.at(k), colors.at(k), s_eta);
    20452004  }
    20462005
    20472006  // loop over pt
    2048   for (k = 0; k < ptVals.size(); k++)
    2049   {
    2050      HistogramsCollectionVsEta(&plots_hcal_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "hcal", 0.0, 2.0);
    2051      GetEresVsEta<Tower>(&plots_hcal_res_eta[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderNeutralHadron);
    2052      gr_hcal_res_eta[k] = EresGraphVsEta(&plots_hcal_res_eta[k]);
    2053 
    2054      s_e = Form("n , E = %.0f GeV",ptVals.at(k));
    2055      if(ptVals.at(k) >= 1000.) s_e = Form("n , E = %.0f TeV",ptVals.at(k)/1000.);
    2056 
    2057      addResoGraph(mg_hcal_res_eta, &gr_hcal_res_eta[k], leg_hcal_res_eta, markerStyles.at(k), colors.at(k), s_e );
    2058   }
    2059 
    2060 
    2061   TCanvas *c_hcal_res_e = new TCanvas("","", 800, 600);
     2007  for(k = 0; k < ptVals.size(); k++)
     2008  {
     2009    HistogramsCollectionVsEta(&plots_hcal_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "hcal", 0.0, 2.0);
     2010    GetEresVsEta<Tower>(&plots_hcal_res_eta[k], branchTowerNeutralHadron, branchParticleNeutralHadron, 2112, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderNeutralHadron);
     2011    gr_hcal_res_eta[k] = EresGraphVsEta(&plots_hcal_res_eta[k]);
     2012
     2013    s_e = Form("n , E = %.0f GeV", ptVals.at(k));
     2014    if(ptVals.at(k) >= 1000.) s_e = Form("n , E = %.0f TeV", ptVals.at(k) / 1000.);
     2015
     2016    addResoGraph(mg_hcal_res_eta, &gr_hcal_res_eta[k], leg_hcal_res_eta, markerStyles.at(k), colors.at(k), s_e);
     2017  }
     2018
     2019  TCanvas *c_hcal_res_e = new TCanvas("", "", 800, 600);
    20622020
    20632021  mg_hcal_res_e->Draw("APE");
     
    20672025  pave->Draw();
    20682026
    2069   c_hcal_res_e->Print(pdfOutput,"pdf");
    2070   c_hcal_res_e->Print(figPath+"img_hcal_res_e.pdf","pdf");
    2071   c_hcal_res_e->Print(figPath+"img_hcal_res_e.png","png");
    2072 
    2073   TCanvas *c_hcal_res_eta = new TCanvas("","", 800, 600);
     2027  c_hcal_res_e->Print(pdfOutput, "pdf");
     2028  c_hcal_res_e->Print(figPath + "img_hcal_res_e.pdf", "pdf");
     2029  c_hcal_res_e->Print(figPath + "img_hcal_res_e.png", "png");
     2030
     2031  TCanvas *c_hcal_res_eta = new TCanvas("", "", 800, 600);
    20742032
    20752033  mg_hcal_res_eta->Draw("APE");
     
    20792037  pave->Draw();
    20802038
    2081   c_hcal_res_eta->Print(pdfOutput,"pdf");
    2082   c_hcal_res_eta->Print(figPath+"img_hcal_res_eta.pdf","pdf");
    2083   c_hcal_res_eta->Print(figPath+"img_hcal_res_eta.png","png");
     2039  c_hcal_res_eta->Print(pdfOutput, "pdf");
     2040  c_hcal_res_eta->Print(figPath + "img_hcal_res_eta.pdf", "pdf");
     2041  c_hcal_res_eta->Print(figPath + "img_hcal_res_eta.png", "png");
    20842042
    20852043  ////////////////////
     
    20982056  TGraphErrors *gr_trkele_res_eeta = new TGraphErrors[n_ptbins];
    20992057
    2100   std::vector<resolPlot> *plots_pfele_res_e     = new std::vector<resolPlot>[n_etabins];
    2101   std::vector<resolPlot> *plots_pfele_res_eta   = new std::vector<resolPlot>[n_ptbins];
    2102   std::vector<resolPlot> *plots_trkele_res_e    = new std::vector<resolPlot>[n_etabins];
     2058  std::vector<resolPlot> *plots_pfele_res_e = new std::vector<resolPlot>[n_etabins];
     2059  std::vector<resolPlot> *plots_pfele_res_eta = new std::vector<resolPlot>[n_ptbins];
     2060  std::vector<resolPlot> *plots_trkele_res_e = new std::vector<resolPlot>[n_etabins];
    21032061  std::vector<resolPlot> *plots_trkele_res_eeta = new std::vector<resolPlot>[n_ptbins];
    21042062
     
    21062064  TCanvas *c_pfele_res_eta[n_ptbins];
    21072065
    2108 
    21092066  // loop over eta bins
    2110   for (k = 0; k < etaVals.size()-1; k++)
    2111   {
    2112      mg_pfele_res_e[k] = new TMultiGraph("","");
    2113      leg_pfele_res_e[k] = new TLegend(0.40,0.60,0.75,0.90);
    2114 
    2115      HistogramsCollection(&plots_pfele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfele");
    2116      GetEres<Electron>(&plots_pfele_res_e[k], branchElectronPF, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    2117      gr_pfele_res_e[k] = EresGraph(&plots_pfele_res_e[k]);
    2118 
    2119      HistogramsCollection(&plots_trkele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
    2120      GetEres<Track>(&plots_trkele_res_e[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    2121      gr_trkele_res_e[k] = EresGraph(&plots_trkele_res_e[k]);
    2122 
    2123      s_etaMin = Form("%.1f",etaVals.at(k));
    2124      s_etaMax = Form("%.1f",etaVals.at(k+1));
    2125      s_eta    = "e^{ #pm}, "+ s_etaMin + " < | #eta | < " + s_etaMax;
    2126 
    2127      leg_pfele_res_e[k]->SetTextFont(132);
    2128      leg_pfele_res_e[k]->SetHeader(s_eta);
    2129 
    2130      addResoGraph(mg_pfele_res_e[k], &gr_ecal_res_e[k], leg_pfele_res_e[k], markerStyles.at(0), colors.at(0), "ECAL");
    2131      addResoGraph(mg_pfele_res_e[k], &gr_trkele_res_e[k], leg_pfele_res_e[k], markerStyles.at(1), colors.at(1), "Track");
    2132      addResoGraph(mg_pfele_res_e[k], &gr_pfele_res_e[k], leg_pfele_res_e[k], markerStyles.at(2), colors.at(2), "Particle-flow");
    2133 
    2134      c_pfele_res_e[k] = new TCanvas("","", 800, 600);
    2135 
    2136      mg_pfele_res_e[k]->Draw("APE");
    2137      //DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
    2138      DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.0, 20, "E [GeV]", "(resolution in E)/E (%)", true, false);
    2139      leg_pfele_res_e[k]->Draw();
    2140      pave->Draw();
    2141 
    2142      TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
    2143 
    2144      c_pfele_res_e[k]->Print(pdfOutput,"pdf");
    2145      c_pfele_res_e[k]->Print(figPath+"img_pfele_res_"+s_etarange+"e.pdf","pdf");
    2146      c_pfele_res_e[k]->Print(figPath+"img_pfele_res_"+s_etarange+"e.png","png");
    2147 
    2148   }
    2149 
    2150 
    2151     // loop over eta bins
    2152   for (k = 0; k < ptVals.size(); k++)
    2153   {
    2154 
    2155      mg_pfele_res_eta[k] = new TMultiGraph("","");
    2156      leg_pfele_res_eta[k] = new TLegend(0.40,0.60,0.75,0.90);
    2157 
    2158      HistogramsCollectionVsEta(&plots_pfele_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfele", 0.0, 2.0);
    2159      GetEresVsEta<Electron>(&plots_pfele_res_eta[k], branchElectronPF, branchParticleElectron, 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderElectron);
    2160      gr_pfele_res_eta[k] = EresGraphVsEta(&plots_pfele_res_eta[k]);
    2161 
    2162      HistogramsCollectionVsEta(&plots_trkele_res_eeta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkele", 0.0, 2.0);
    2163      GetEresVsEta<Track>(&plots_trkele_res_eeta[k], branchTrackElectron, branchParticleElectron, 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderElectron);
    2164      gr_trkele_res_eeta[k] = EresGraphVsEta(&plots_trkele_res_eeta[k]);
    2165 
    2166      s_e = Form("e^{ #pm}, E = %.0f GeV",ptVals.at(k));
    2167      if(ptVals.at(k) >= 1000.) s_e = Form("e^{ #pm}, E = %.0f TeV",ptVals.at(k)/1000.);
    2168 
    2169 
    2170      leg_pfele_res_eta[k]->SetTextFont(132);
    2171      leg_pfele_res_eta[k]->SetHeader(s_e);
    2172 
    2173      addResoGraph(mg_pfele_res_eta[k], &gr_ecal_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(0), colors.at(0), "ECAL");
    2174      addResoGraph(mg_pfele_res_eta[k], &gr_trkele_res_eeta[k], leg_pfele_res_eta[k], markerStyles.at(1), colors.at(1), "Track");
    2175      addResoGraph(mg_pfele_res_eta[k], &gr_pfele_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(2), colors.at(2), "Particle-flow");
    2176 
    2177      c_pfele_res_eta[k] = new TCanvas("","", 800, 600);
    2178 
    2179      mg_pfele_res_eta[k]->Draw("APE");
    2180      //DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
    2181      DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
    2182      leg_pfele_res_eta[k]->Draw();
    2183      pave->Draw();
    2184 
    2185      TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
    2186 
    2187      c_pfele_res_eta[k]->Print(pdfOutput,"pdf");
    2188      c_pfele_res_eta[k]->Print(figPath+"img_pfele_res_"+s_ptrange+"eta.pdf","pdf");
    2189      c_pfele_res_eta[k]->Print(figPath+"img_pfele_res_"+s_ptrange+"eta.png","png");
    2190 
     2067  for(k = 0; k < etaVals.size() - 1; k++)
     2068  {
     2069    mg_pfele_res_e[k] = new TMultiGraph("", "");
     2070    leg_pfele_res_e[k] = new TLegend(0.40, 0.60, 0.75, 0.90);
     2071
     2072    HistogramsCollection(&plots_pfele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfele");
     2073    GetEres<Electron>(&plots_pfele_res_e[k], branchElectronPF, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     2074    gr_pfele_res_e[k] = EresGraph(&plots_pfele_res_e[k]);
     2075
     2076    HistogramsCollection(&plots_trkele_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkele");
     2077    GetEres<Track>(&plots_trkele_res_e[k], branchTrackElectron, branchParticleElectron, 11, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     2078    gr_trkele_res_e[k] = EresGraph(&plots_trkele_res_e[k]);
     2079
     2080    s_etaMin = Form("%.1f", etaVals.at(k));
     2081    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2082    s_eta = "e^{ #pm}, " + s_etaMin + " < | #eta | < " + s_etaMax;
     2083
     2084    leg_pfele_res_e[k]->SetTextFont(132);
     2085    leg_pfele_res_e[k]->SetHeader(s_eta);
     2086
     2087    addResoGraph(mg_pfele_res_e[k], &gr_ecal_res_e[k], leg_pfele_res_e[k], markerStyles.at(0), colors.at(0), "ECAL");
     2088    addResoGraph(mg_pfele_res_e[k], &gr_trkele_res_e[k], leg_pfele_res_e[k], markerStyles.at(1), colors.at(1), "Track");
     2089    addResoGraph(mg_pfele_res_e[k], &gr_pfele_res_e[k], leg_pfele_res_e[k], markerStyles.at(2), colors.at(2), "Particle-flow");
     2090
     2091    c_pfele_res_e[k] = new TCanvas("", "", 800, 600);
     2092
     2093    mg_pfele_res_e[k]->Draw("APE");
     2094    //DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
     2095    DrawAxis(mg_pfele_res_e[k], leg_pfele_res_e[k], ptMin, ptMax, 0.0, 20, "E [GeV]", "(resolution in E)/E (%)", true, false);
     2096    leg_pfele_res_e[k]->Draw();
     2097    pave->Draw();
     2098
     2099    TString s_etarange = "eta_" + s_etaMin + "_" + s_etaMax + "_";
     2100
     2101    c_pfele_res_e[k]->Print(pdfOutput, "pdf");
     2102    c_pfele_res_e[k]->Print(figPath + "img_pfele_res_" + s_etarange + "e.pdf", "pdf");
     2103    c_pfele_res_e[k]->Print(figPath + "img_pfele_res_" + s_etarange + "e.png", "png");
     2104  }
     2105
     2106  // loop over eta bins
     2107  for(k = 0; k < ptVals.size(); k++)
     2108  {
     2109
     2110    mg_pfele_res_eta[k] = new TMultiGraph("", "");
     2111    leg_pfele_res_eta[k] = new TLegend(0.40, 0.60, 0.75, 0.90);
     2112
     2113    HistogramsCollectionVsEta(&plots_pfele_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "pfele", 0.0, 2.0);
     2114    GetEresVsEta<Electron>(&plots_pfele_res_eta[k], branchElectronPF, branchParticleElectron, 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderElectron);
     2115    gr_pfele_res_eta[k] = EresGraphVsEta(&plots_pfele_res_eta[k]);
     2116
     2117    HistogramsCollectionVsEta(&plots_trkele_res_eeta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkele", 0.0, 2.0);
     2118    GetEresVsEta<Track>(&plots_trkele_res_eeta[k], branchTrackElectron, branchParticleElectron, 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderElectron);
     2119    gr_trkele_res_eeta[k] = EresGraphVsEta(&plots_trkele_res_eeta[k]);
     2120
     2121    s_e = Form("e^{ #pm}, E = %.0f GeV", ptVals.at(k));
     2122    if(ptVals.at(k) >= 1000.) s_e = Form("e^{ #pm}, E = %.0f TeV", ptVals.at(k) / 1000.);
     2123
     2124    leg_pfele_res_eta[k]->SetTextFont(132);
     2125    leg_pfele_res_eta[k]->SetHeader(s_e);
     2126
     2127    addResoGraph(mg_pfele_res_eta[k], &gr_ecal_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(0), colors.at(0), "ECAL");
     2128    addResoGraph(mg_pfele_res_eta[k], &gr_trkele_res_eeta[k], leg_pfele_res_eta[k], markerStyles.at(1), colors.at(1), "Track");
     2129    addResoGraph(mg_pfele_res_eta[k], &gr_pfele_res_eta[k], leg_pfele_res_eta[k], markerStyles.at(2), colors.at(2), "Particle-flow");
     2130
     2131    c_pfele_res_eta[k] = new TCanvas("", "", 800, 600);
     2132
     2133    mg_pfele_res_eta[k]->Draw("APE");
     2134    //DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
     2135    DrawAxis(mg_pfele_res_eta[k], leg_pfele_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
     2136    leg_pfele_res_eta[k]->Draw();
     2137    pave->Draw();
     2138
     2139    TString s_ptrange = Form("pt_%.0f_", ptVals.at(k));
     2140
     2141    c_pfele_res_eta[k]->Print(pdfOutput, "pdf");
     2142    c_pfele_res_eta[k]->Print(figPath + "img_pfele_res_" + s_ptrange + "eta.pdf", "pdf");
     2143    c_pfele_res_eta[k]->Print(figPath + "img_pfele_res_" + s_ptrange + "eta.png", "png");
    21912144  }
    21922145
     
    22012154  TLegend *leg_pfpi_res_eta[n_ptbins];
    22022155
    2203   TGraphErrors *gr_pfpi_res_e     = new TGraphErrors[n_etabins];
    2204   TGraphErrors *gr_pfpi_res_eta   = new TGraphErrors[n_ptbins];
    2205 
    2206   TGraphErrors *gr_trkpi_res_e    = new TGraphErrors[n_etabins];
     2156  TGraphErrors *gr_pfpi_res_e = new TGraphErrors[n_etabins];
     2157  TGraphErrors *gr_pfpi_res_eta = new TGraphErrors[n_ptbins];
     2158
     2159  TGraphErrors *gr_trkpi_res_e = new TGraphErrors[n_etabins];
    22072160  TGraphErrors *gr_trkpi_res_eeta = new TGraphErrors[n_ptbins];
    22082161
    2209   std::vector<resolPlot> *plots_pfpi_res_e     = new std::vector<resolPlot>[n_etabins];
    2210   std::vector<resolPlot> *plots_pfpi_res_eta   = new std::vector<resolPlot>[n_ptbins];
    2211   std::vector<resolPlot> *plots_trkpi_res_e    = new std::vector<resolPlot>[n_etabins];
     2162  std::vector<resolPlot> *plots_pfpi_res_e = new std::vector<resolPlot>[n_etabins];
     2163  std::vector<resolPlot> *plots_pfpi_res_eta = new std::vector<resolPlot>[n_ptbins];
     2164  std::vector<resolPlot> *plots_trkpi_res_e = new std::vector<resolPlot>[n_etabins];
    22122165  std::vector<resolPlot> *plots_trkpi_res_eeta = new std::vector<resolPlot>[n_ptbins];
    22132166
     
    22152168  TCanvas *c_pfpi_res_eta[n_ptbins];
    22162169
    2217 
    22182170  // loop over eta bins
    2219   for (k = 0; k < etaVals.size()-1; k++)
    2220   {
    2221      mg_pfpi_res_e[k] = new TMultiGraph("","");
    2222      leg_pfpi_res_e[k] = new TLegend(0.40,0.60,0.75,0.90);
    2223 
    2224      HistogramsCollection(&plots_pfpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfpi");
    2225      GetEres<Track>(&plots_pfpi_res_e[k], branchPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
    2226      gr_pfpi_res_e[k] = EresGraph(&plots_pfpi_res_e[k]);
    2227 
    2228      HistogramsCollection(&plots_trkpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
    2229      GetEres<Track>(&plots_trkpi_res_e[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k+1), treeReaderPion);
    2230      gr_trkpi_res_e[k] = EresGraph(&plots_trkpi_res_e[k]);
    2231 
    2232 
    2233      s_etaMin = Form("%.1f",etaVals.at(k));
    2234      s_etaMax = Form("%.1f",etaVals.at(k+1));
    2235      s_eta    = "#pi^{ #pm}, "+ s_etaMin + " < | #eta | < " + s_etaMax;
    2236 
    2237      leg_pfpi_res_e[k]->SetTextFont(132);
    2238      leg_pfpi_res_e[k]->SetHeader(s_eta);
    2239 
    2240      addResoGraph(mg_pfpi_res_e[k], &gr_hcal_res_e[k], leg_pfpi_res_e[k], markerStyles.at(0), colors.at(0), "HCAL");
    2241      addResoGraph(mg_pfpi_res_e[k], &gr_trkpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(1), colors.at(1), "Track");
    2242      addResoGraph(mg_pfpi_res_e[k], &gr_pfpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(2), colors.at(2), "Particle-flow");
    2243 
    2244      c_pfpi_res_e[k] = new TCanvas("","", 800, 600);
    2245 
    2246      mg_pfpi_res_e[k]->Draw("APE");
    2247      //DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
    2248      DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 50, "E [GeV]", "(resolution in E)/E (%)", true, false);
    2249      leg_pfpi_res_e[k]->Draw();
    2250      pave->Draw();
    2251 
    2252      TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
    2253 
    2254      c_pfpi_res_e[k]->Print(pdfOutput,"pdf");
    2255      c_pfpi_res_e[k]->Print(figPath+"img_pfpi_res_"+s_etarange+"e.pdf","pdf");
    2256      c_pfpi_res_e[k]->Print(figPath+"img_pfpi_res_"+s_etarange+"e.png","png");
    2257 
    2258   }
    2259 
    2260 
    2261     // loop over eta bins
    2262   for (k = 0; k < ptVals.size(); k++)
    2263   {
    2264 
    2265      mg_pfpi_res_eta[k] = new TMultiGraph("","");
    2266      leg_pfpi_res_eta[k] = new TLegend(0.40,0.60,0.75,0.90);
    2267 
    2268      HistogramsCollectionVsEta(&plots_pfpi_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfpi", 0.0, 2.0);
    2269      GetEresVsEta<Track>(&plots_pfpi_res_eta[k], branchPion, branchParticlePion, 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPion);
    2270      gr_pfpi_res_eta[k] = EresGraphVsEta(&plots_pfpi_res_eta[k]);
    2271 
    2272      HistogramsCollectionVsEta(&plots_trkpi_res_eeta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "trkpi", 0.0, 2.0);
    2273      GetEresVsEta<Track>(&plots_trkpi_res_eeta[k], branchPion, branchParticlePion, 211, 0.5*ptVals.at(k), 2.0*ptVals.at(k), treeReaderPion);
    2274      gr_trkpi_res_eeta[k] = EresGraphVsEta(&plots_trkpi_res_eeta[k]);
    2275 
    2276 
    2277      s_e = Form("#pi^{ #pm}, E = %.0f GeV",ptVals.at(k));
    2278      if(ptVals.at(k) >= 1000.) s_e = Form("#pi^{ #pm}, E = %.0f TeV",ptVals.at(k)/1000.);
    2279 
    2280      leg_pfpi_res_eta[k]->SetTextFont(132);
    2281      leg_pfpi_res_eta[k]->SetHeader(s_e);
    2282 
    2283      addResoGraph(mg_pfpi_res_eta[k], &gr_hcal_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(0), colors.at(0), "HCAL");
    2284      addResoGraph(mg_pfpi_res_eta[k], &gr_trkpi_res_eeta[k], leg_pfpi_res_eta[k], markerStyles.at(1), colors.at(1), "Track");
    2285      addResoGraph(mg_pfpi_res_eta[k], &gr_pfpi_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(2), colors.at(2), "Particle-flow");
    2286 
    2287      c_pfpi_res_eta[k] = new TCanvas("","", 800, 600);
    2288 
    2289      mg_pfpi_res_eta[k]->Draw("APE");
    2290      //DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
    2291      DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
    2292      leg_pfpi_res_eta[k]->Draw();
    2293      pave->Draw();
    2294 
    2295      TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
    2296 
    2297      c_pfpi_res_eta[k]->Print(pdfOutput,"pdf");
    2298      c_pfpi_res_eta[k]->Print(figPath+"img_pfpi_res_"+s_ptrange+"eta.pdf","pdf");
    2299      c_pfpi_res_eta[k]->Print(figPath+"img_pfpi_res_"+s_ptrange+"eta.png","png");
    2300 
    2301   }
    2302 
     2171  for(k = 0; k < etaVals.size() - 1; k++)
     2172  {
     2173    mg_pfpi_res_e[k] = new TMultiGraph("", "");
     2174    leg_pfpi_res_e[k] = new TLegend(0.40, 0.60, 0.75, 0.90);
     2175
     2176    HistogramsCollection(&plots_pfpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfpi");
     2177    GetEres<Track>(&plots_pfpi_res_e[k], branchPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k + 1), treeReaderPion);
     2178    gr_pfpi_res_e[k] = EresGraph(&plots_pfpi_res_e[k]);
     2179
     2180    HistogramsCollection(&plots_trkpi_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "trkpi");
     2181    GetEres<Track>(&plots_trkpi_res_e[k], branchTrackPion, branchParticlePion, 211, etaVals.at(k), etaVals.at(k + 1), treeReaderPion);
     2182    gr_trkpi_res_e[k] = EresGraph(&plots_trkpi_res_e[k]);
     2183
     2184    s_etaMin = Form("%.1f", etaVals.at(k));
     2185    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2186    s_eta = "#pi^{ #pm}, " + s_etaMin + " < | #eta | < " + s_etaMax;
     2187
     2188    leg_pfpi_res_e[k]->SetTextFont(132);
     2189    leg_pfpi_res_e[k]->SetHeader(s_eta);
     2190
     2191    addResoGraph(mg_pfpi_res_e[k], &gr_hcal_res_e[k], leg_pfpi_res_e[k], markerStyles.at(0), colors.at(0), "HCAL");
     2192    addResoGraph(mg_pfpi_res_e[k], &gr_trkpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(1), colors.at(1), "Track");
     2193    addResoGraph(mg_pfpi_res_e[k], &gr_pfpi_res_e[k], leg_pfpi_res_e[k], markerStyles.at(2), colors.at(2), "Particle-flow");
     2194
     2195    c_pfpi_res_e[k] = new TCanvas("", "", 800, 600);
     2196
     2197    mg_pfpi_res_e[k]->Draw("APE");
     2198    //DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
     2199    DrawAxis(mg_pfpi_res_e[k], leg_pfpi_res_e[k], ptMin, ptMax, 0.1, 50, "E [GeV]", "(resolution in E)/E (%)", true, false);
     2200    leg_pfpi_res_e[k]->Draw();
     2201    pave->Draw();
     2202
     2203    TString s_etarange = "eta_" + s_etaMin + "_" + s_etaMax + "_";
     2204
     2205    c_pfpi_res_e[k]->Print(pdfOutput, "pdf");
     2206    c_pfpi_res_e[k]->Print(figPath + "img_pfpi_res_" + s_etarange + "e.pdf", "pdf");
     2207    c_pfpi_res_e[k]->Print(figPath + "img_pfpi_res_" + s_etarange + "e.png", "png");
     2208  }
     2209
     2210  // loop over eta bins
     2211  for(k = 0; k < ptVals.size(); k++)
     2212  {
     2213
     2214    mg_pfpi_res_eta[k] = new TMultiGraph("", "");
     2215    leg_pfpi_res_eta[k] = new TLegend(0.40, 0.60, 0.75, 0.90);
     2216
     2217    HistogramsCollectionVsEta(&plots_pfpi_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "pfpi", 0.0, 2.0);
     2218    GetEresVsEta<Track>(&plots_pfpi_res_eta[k], branchPion, branchParticlePion, 211, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderPion);
     2219    gr_pfpi_res_eta[k] = EresGraphVsEta(&plots_pfpi_res_eta[k]);
     2220
     2221    HistogramsCollectionVsEta(&plots_trkpi_res_eeta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "trkpi", 0.0, 2.0);
     2222    GetEresVsEta<Track>(&plots_trkpi_res_eeta[k], branchPion, branchParticlePion, 211, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), treeReaderPion);
     2223    gr_trkpi_res_eeta[k] = EresGraphVsEta(&plots_trkpi_res_eeta[k]);
     2224
     2225    s_e = Form("#pi^{ #pm}, E = %.0f GeV", ptVals.at(k));
     2226    if(ptVals.at(k) >= 1000.) s_e = Form("#pi^{ #pm}, E = %.0f TeV", ptVals.at(k) / 1000.);
     2227
     2228    leg_pfpi_res_eta[k]->SetTextFont(132);
     2229    leg_pfpi_res_eta[k]->SetHeader(s_e);
     2230
     2231    addResoGraph(mg_pfpi_res_eta[k], &gr_hcal_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(0), colors.at(0), "HCAL");
     2232    addResoGraph(mg_pfpi_res_eta[k], &gr_trkpi_res_eeta[k], leg_pfpi_res_eta[k], markerStyles.at(1), colors.at(1), "Track");
     2233    addResoGraph(mg_pfpi_res_eta[k], &gr_pfpi_res_eta[k], leg_pfpi_res_eta[k], markerStyles.at(2), colors.at(2), "Particle-flow");
     2234
     2235    c_pfpi_res_eta[k] = new TCanvas("", "", 800, 600);
     2236
     2237    mg_pfpi_res_eta[k]->Draw("APE");
     2238    //DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
     2239    DrawAxis(mg_pfpi_res_eta[k], leg_pfpi_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
     2240    leg_pfpi_res_eta[k]->Draw();
     2241    pave->Draw();
     2242
     2243    TString s_ptrange = Form("pt_%.0f_", ptVals.at(k));
     2244
     2245    c_pfpi_res_eta[k]->Print(pdfOutput, "pdf");
     2246    c_pfpi_res_eta[k]->Print(figPath + "img_pfpi_res_" + s_ptrange + "eta.pdf", "pdf");
     2247    c_pfpi_res_eta[k]->Print(figPath + "img_pfpi_res_" + s_ptrange + "eta.png", "png");
     2248  }
    23032249
    23042250  /////////////////
     
    23122258  TLegend *leg_pfjet_res_eta[n_ptbins];
    23132259
    2314   TGraphErrors *gr_pfjet_res_e   = new TGraphErrors[n_etabins];
     2260  TGraphErrors *gr_pfjet_res_e = new TGraphErrors[n_etabins];
    23152261  TGraphErrors *gr_pfjet_res_eta = new TGraphErrors[n_ptbins];
    23162262
    2317   TGraphErrors *gr_cajet_res_e   = new TGraphErrors[n_etabins];
     2263  TGraphErrors *gr_cajet_res_e = new TGraphErrors[n_etabins];
    23182264  TGraphErrors *gr_cajet_res_eta = new TGraphErrors[n_ptbins];
    23192265
    2320   std::vector<resolPlot> *plots_pfjet_res_e   = new std::vector<resolPlot>[n_etabins];
     2266  std::vector<resolPlot> *plots_pfjet_res_e = new std::vector<resolPlot>[n_etabins];
    23212267  std::vector<resolPlot> *plots_pfjet_res_eta = new std::vector<resolPlot>[n_ptbins];
    2322   std::vector<resolPlot> *plots_cajet_res_e   = new std::vector<resolPlot>[n_etabins];
     2268  std::vector<resolPlot> *plots_cajet_res_e = new std::vector<resolPlot>[n_etabins];
    23232269  std::vector<resolPlot> *plots_cajet_res_eta = new std::vector<resolPlot>[n_ptbins];
    23242270
     
    23262272  TCanvas *c_pfjet_res_eta[n_ptbins];
    23272273
    2328 
    23292274  // loop over eta bins
    2330   for (k = 0; k < etaVals.size()-1; k++)
    2331   {
    2332 
    2333      mg_pfjet_res_e[k] = new TMultiGraph("","");
    2334      leg_pfjet_res_e[k] = new TLegend(0.40,0.70,0.90,0.90);
    2335 
    2336      HistogramsCollection(&plots_pfjet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfjet");
    2337      HistogramsCollection(&plots_cajet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "cajet");
    2338 
    2339      GetJetsEres(&plots_pfjet_res_e[k], branchPFJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k+1));
    2340      GetJetsEres(&plots_cajet_res_e[k], branchCaloJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k+1));
    2341 
    2342      gr_pfjet_res_e[k] = EresGraph(&plots_pfjet_res_e[k]);
    2343      gr_cajet_res_e[k] = EresGraph(&plots_cajet_res_e[k]);
    2344 
    2345      s_etaMin = Form("%.1f",etaVals.at(k));
    2346      s_etaMax = Form("%.1f",etaVals.at(k+1));
    2347      s_eta    = "anti-k_{T},  R = 0.4,  "+ s_etaMin + " < | #eta | < " + s_etaMax;
    2348 
    2349      leg_pfjet_res_e[k]->SetTextFont(132);
    2350      leg_pfjet_res_e[k]->SetHeader(s_eta);
    2351 
    2352      addResoGraph(mg_pfjet_res_e[k], &gr_cajet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(0), colors.at(0), "Calorimeter Jets");
    2353      addResoGraph(mg_pfjet_res_e[k], &gr_pfjet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(1), colors.at(1), "Particle-flow Jets");
    2354 
    2355      c_pfjet_res_e[k] = new TCanvas("","", 800, 600);
    2356 
    2357      mg_pfjet_res_e[k]->Draw("APE");
    2358      //DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.5, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
    2359      DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.0, 30, "E [GeV]", "(resolution in E)/E (%)", true, false);
    2360      leg_pfjet_res_e[k]->Draw();
    2361      pave->Draw();
    2362 
    2363      TString s_etarange = "eta_"+s_etaMin+"_"+s_etaMax+"_";
    2364 
    2365      c_pfjet_res_e[k]->Print(pdfOutput,"pdf");
    2366      c_pfjet_res_e[k]->Print(figPath+"img_pfjet_res_"+s_etarange+"e.pdf","pdf");
    2367      c_pfjet_res_e[k]->Print(figPath+"img_pfjet_res_"+s_etarange+"e.png","png");
    2368 
    2369   }
    2370 
    2371 
    2372     // loop over eta bins
    2373   for (k = 0; k < ptVals.size(); k++)
    2374   {
    2375 
    2376      mg_pfjet_res_eta[k] = new TMultiGraph("","");
    2377      leg_pfjet_res_eta[k] = new TLegend(0.30,0.70,0.85,0.90);
    2378 
    2379      HistogramsCollectionVsEta(&plots_pfjet_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "pfjet", 0.0, 2.0);
    2380      HistogramsCollectionVsEta(&plots_cajet_res_eta[k], etaMin, etaMax, 0.5*ptVals.at(k), 2.0*ptVals.at(k), "cajet", 0.0, 2.0);
    2381 
    2382      GetJetsEresVsEta(&plots_pfjet_res_eta[k], branchPFJet, branchGenJet, treeReaderJet, 0.5*ptVals.at(k), 2.0*ptVals.at(k));
    2383      GetJetsEresVsEta(&plots_cajet_res_eta[k], branchCaloJet, branchGenJet, treeReaderJet, 0.5*ptVals.at(k), 2.0*ptVals.at(k));
    2384 
    2385      gr_pfjet_res_eta[k] = EresGraphVsEta(&plots_pfjet_res_eta[k]);
    2386      gr_cajet_res_eta[k] = EresGraphVsEta(&plots_cajet_res_eta[k]);
    2387 
    2388      s_e = Form("anti-k_{T},  R = 0.4,  jets, E = %.0f GeV",ptVals.at(k));
    2389      if(ptVals.at(k) >= 1000.) s_e = Form("anti-k_{T},  R = 0.4,  E = %.0f TeV",ptVals.at(k)/1000.);
    2390 
    2391      leg_pfjet_res_eta[k]->SetTextFont(132);
    2392      leg_pfjet_res_eta[k]->SetHeader(s_e);
    2393 
    2394      addResoGraph(mg_pfjet_res_eta[k], &gr_cajet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(0), colors.at(0), "Calorimeter Jets");
    2395      addResoGraph(mg_pfjet_res_eta[k], &gr_pfjet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(1), colors.at(1), "Particle-flow Jets");
    2396 
    2397      c_pfjet_res_eta[k] = new TCanvas("","", 800, 600);
    2398 
    2399      mg_pfjet_res_eta[k]->Draw("APE");
    2400      //DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
    2401      DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
    2402      leg_pfjet_res_eta[k]->Draw();
    2403      pave->Draw();
    2404 
    2405      TString s_ptrange = Form("pt_%.0f_",ptVals.at(k));
    2406 
    2407      c_pfjet_res_eta[k]->Print(pdfOutput,"pdf");
    2408      c_pfjet_res_eta[k]->Print(figPath+"img_pfjet_res_"+s_ptrange+"eta.pdf","pdf");
    2409      c_pfjet_res_eta[k]->Print(figPath+"img_pfjet_res_"+s_ptrange+"eta.png","png");
    2410 
    2411   }
    2412 
    2413 
    2414     /////////////////////
    2415     // PF Missing ET  ///
    2416     /////////////////////
    2417 
    2418     TMultiGraph *mg_met_res_ht = new TMultiGraph("","");
    2419     TLegend *leg_met_res_ht    = new TLegend(0.60,0.22,0.90,0.42);
    2420 
    2421     std::vector<resolPlot> plots_pfmet, plots_camet;
    2422 
    2423     HistogramsCollection(&plots_pfmet, TMath::Log10(ptMin), TMath::Log10(ptMax), "pfMET", -500, 500);
    2424     HistogramsCollection(&plots_camet, TMath::Log10(ptMin), TMath::Log10(ptMax), "caMET", -500, 500);
    2425 
    2426     GetMetres(&plots_pfmet, branchGenScalarHT, branchMet, branchPFJet, treeReaderJet);
    2427     GetMetres(&plots_camet, branchGenScalarHT, branchCaloMet, branchCaloJet, treeReaderJet);
    2428 
    2429     TGraphErrors gr_pfmet_res_ht = MetResGraph(&plots_pfmet, true);
    2430     TGraphErrors gr_camet_res_ht = MetResGraph(&plots_camet, true);
    2431 
    2432     addResoGraph(mg_met_res_ht, &gr_camet_res_ht, leg_met_res_ht, markerStyles.at(0), colors.at(0), "Calorimeter E_{T}^{miss}");
    2433     addResoGraph(mg_met_res_ht, &gr_pfmet_res_ht, leg_met_res_ht, markerStyles.at(1), colors.at(1), "Particle-flow E_{T}^{miss}");
    2434 
    2435     TCanvas *c_met_res_ht = new TCanvas("","", 800, 600);
    2436 
    2437     mg_met_res_ht->Draw("APE");
    2438     DrawAxis(mg_met_res_ht, leg_met_res_ht, 1000, 100000, 0.1, 1000, " #sum p_{T} [GeV]", "resolution in E_{x,y}^{miss} [GeV]", true, true);
    2439 
    2440     leg_met_res_ht->Draw();
     2275  for(k = 0; k < etaVals.size() - 1; k++)
     2276  {
     2277
     2278    mg_pfjet_res_e[k] = new TMultiGraph("", "");
     2279    leg_pfjet_res_e[k] = new TLegend(0.40, 0.70, 0.90, 0.90);
     2280
     2281    HistogramsCollection(&plots_pfjet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "pfjet");
     2282    HistogramsCollection(&plots_cajet_res_e[k], TMath::Log10(ptMin), TMath::Log10(ptMax), "cajet");
     2283
     2284    GetJetsEres(&plots_pfjet_res_e[k], branchPFJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k + 1));
     2285    GetJetsEres(&plots_cajet_res_e[k], branchCaloJet, branchGenJet, treeReaderJet, etaVals.at(k), etaVals.at(k + 1));
     2286
     2287    gr_pfjet_res_e[k] = EresGraph(&plots_pfjet_res_e[k]);
     2288    gr_cajet_res_e[k] = EresGraph(&plots_cajet_res_e[k]);
     2289
     2290    s_etaMin = Form("%.1f", etaVals.at(k));
     2291    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2292    s_eta = "anti-k_{T},  R = 0.4,  " + s_etaMin + " < | #eta | < " + s_etaMax;
     2293
     2294    leg_pfjet_res_e[k]->SetTextFont(132);
     2295    leg_pfjet_res_e[k]->SetHeader(s_eta);
     2296
     2297    addResoGraph(mg_pfjet_res_e[k], &gr_cajet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(0), colors.at(0), "Calorimeter Jets");
     2298    addResoGraph(mg_pfjet_res_e[k], &gr_pfjet_res_e[k], leg_pfjet_res_e[k], markerStyles.at(1), colors.at(1), "Particle-flow Jets");
     2299
     2300    c_pfjet_res_e[k] = new TCanvas("", "", 800, 600);
     2301
     2302    mg_pfjet_res_e[k]->Draw("APE");
     2303    //DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.5, 100, "E [GeV]", "(resolution in E)/E (%)", true, true);
     2304    DrawAxis(mg_pfjet_res_e[k], leg_pfjet_res_e[k], 10, ptMax, 0.0, 30, "E [GeV]", "(resolution in E)/E (%)", true, false);
     2305    leg_pfjet_res_e[k]->Draw();
    24412306    pave->Draw();
    2442     c_met_res_ht->Print(pdfOutput,"pdf");
    2443     c_met_res_ht->Print(figPath+"img_met_res_ht.pdf","pdf");
    2444     c_met_res_ht->Print(figPath+"img_met_res_ht.png","png");
    2445 
    2446 
    2447     /////////////////////////////////////////
    2448     // Electron Reconstruction Efficiency ///
    2449     /////////////////////////////////////////
    2450 
    2451     TMultiGraph *mg_recele_eff_pt  = new TMultiGraph("","");
    2452     TMultiGraph *mg_recele_eff_eta = new TMultiGraph("","");
    2453 
    2454     TLegend *leg_recele_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
    2455     TLegend *leg_recele_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
    2456 
    2457     TGraphErrors *gr_recele_eff_pt  = new TGraphErrors[n_etabins];
    2458     TGraphErrors *gr_recele_eff_eta = new TGraphErrors[n_ptbins];
    2459     TH1D* h_recele_eff_pt, *h_recele_eff_eta;
    2460 
    2461     // loop over eta bins
    2462     for (k = 0; k < etaVals.size()-1; k++)
     2307
     2308    TString s_etarange = "eta_" + s_etaMin + "_" + s_etaMax + "_";
     2309
     2310    c_pfjet_res_e[k]->Print(pdfOutput, "pdf");
     2311    c_pfjet_res_e[k]->Print(figPath + "img_pfjet_res_" + s_etarange + "e.pdf", "pdf");
     2312    c_pfjet_res_e[k]->Print(figPath + "img_pfjet_res_" + s_etarange + "e.png", "png");
     2313  }
     2314
     2315  // loop over eta bins
     2316  for(k = 0; k < ptVals.size(); k++)
     2317  {
     2318
     2319    mg_pfjet_res_eta[k] = new TMultiGraph("", "");
     2320    leg_pfjet_res_eta[k] = new TLegend(0.30, 0.70, 0.85, 0.90);
     2321
     2322    HistogramsCollectionVsEta(&plots_pfjet_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "pfjet", 0.0, 2.0);
     2323    HistogramsCollectionVsEta(&plots_cajet_res_eta[k], etaMin, etaMax, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), "cajet", 0.0, 2.0);
     2324
     2325    GetJetsEresVsEta(&plots_pfjet_res_eta[k], branchPFJet, branchGenJet, treeReaderJet, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k));
     2326    GetJetsEresVsEta(&plots_cajet_res_eta[k], branchCaloJet, branchGenJet, treeReaderJet, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k));
     2327
     2328    gr_pfjet_res_eta[k] = EresGraphVsEta(&plots_pfjet_res_eta[k]);
     2329    gr_cajet_res_eta[k] = EresGraphVsEta(&plots_cajet_res_eta[k]);
     2330
     2331    s_e = Form("anti-k_{T},  R = 0.4,  jets, E = %.0f GeV", ptVals.at(k));
     2332    if(ptVals.at(k) >= 1000.) s_e = Form("anti-k_{T},  R = 0.4,  E = %.0f TeV", ptVals.at(k) / 1000.);
     2333
     2334    leg_pfjet_res_eta[k]->SetTextFont(132);
     2335    leg_pfjet_res_eta[k]->SetHeader(s_e);
     2336
     2337    addResoGraph(mg_pfjet_res_eta[k], &gr_cajet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(0), colors.at(0), "Calorimeter Jets");
     2338    addResoGraph(mg_pfjet_res_eta[k], &gr_pfjet_res_eta[k], leg_pfjet_res_eta[k], markerStyles.at(1), colors.at(1), "Particle-flow Jets");
     2339
     2340    c_pfjet_res_eta[k] = new TCanvas("", "", 800, 600);
     2341
     2342    mg_pfjet_res_eta[k]->Draw("APE");
     2343    //DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.1, 1000, "#eta", "(resolution in E)/E (%)", false, true);
     2344    DrawAxis(mg_pfjet_res_eta[k], leg_pfjet_res_eta[k], etaMin, etaMax, 0.0, 50, "#eta", "(resolution in E)/E (%)", false, false);
     2345    leg_pfjet_res_eta[k]->Draw();
     2346    pave->Draw();
     2347
     2348    TString s_ptrange = Form("pt_%.0f_", ptVals.at(k));
     2349
     2350    c_pfjet_res_eta[k]->Print(pdfOutput, "pdf");
     2351    c_pfjet_res_eta[k]->Print(figPath + "img_pfjet_res_" + s_ptrange + "eta.pdf", "pdf");
     2352    c_pfjet_res_eta[k]->Print(figPath + "img_pfjet_res_" + s_ptrange + "eta.png", "png");
     2353  }
     2354
     2355  /////////////////////
     2356  // PF Missing ET  ///
     2357  /////////////////////
     2358
     2359  TMultiGraph *mg_met_res_ht = new TMultiGraph("", "");
     2360  TLegend *leg_met_res_ht = new TLegend(0.60, 0.22, 0.90, 0.42);
     2361
     2362  std::vector<resolPlot> plots_pfmet, plots_camet;
     2363
     2364  HistogramsCollection(&plots_pfmet, TMath::Log10(ptMin), TMath::Log10(ptMax), "pfMET", -500, 500);
     2365  HistogramsCollection(&plots_camet, TMath::Log10(ptMin), TMath::Log10(ptMax), "caMET", -500, 500);
     2366
     2367  GetMetres(&plots_pfmet, branchGenScalarHT, branchMet, branchPFJet, treeReaderJet);
     2368  GetMetres(&plots_camet, branchGenScalarHT, branchCaloMet, branchCaloJet, treeReaderJet);
     2369
     2370  TGraphErrors gr_pfmet_res_ht = MetResGraph(&plots_pfmet, true);
     2371  TGraphErrors gr_camet_res_ht = MetResGraph(&plots_camet, true);
     2372
     2373  addResoGraph(mg_met_res_ht, &gr_camet_res_ht, leg_met_res_ht, markerStyles.at(0), colors.at(0), "Calorimeter E_{T}^{miss}");
     2374  addResoGraph(mg_met_res_ht, &gr_pfmet_res_ht, leg_met_res_ht, markerStyles.at(1), colors.at(1), "Particle-flow E_{T}^{miss}");
     2375
     2376  TCanvas *c_met_res_ht = new TCanvas("", "", 800, 600);
     2377
     2378  mg_met_res_ht->Draw("APE");
     2379  DrawAxis(mg_met_res_ht, leg_met_res_ht, 1000, 100000, 0.1, 1000, " #sum p_{T} [GeV]", "resolution in E_{x,y}^{miss} [GeV]", true, true);
     2380
     2381  leg_met_res_ht->Draw();
     2382  pave->Draw();
     2383  c_met_res_ht->Print(pdfOutput, "pdf");
     2384  c_met_res_ht->Print(figPath + "img_met_res_ht.pdf", "pdf");
     2385  c_met_res_ht->Print(figPath + "img_met_res_ht.png", "png");
     2386
     2387  /////////////////////////////////////////
     2388  // Electron Reconstruction Efficiency ///
     2389  /////////////////////////////////////////
     2390
     2391  TMultiGraph *mg_recele_eff_pt = new TMultiGraph("", "");
     2392  TMultiGraph *mg_recele_eff_eta = new TMultiGraph("", "");
     2393
     2394  TLegend *leg_recele_eff_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     2395  TLegend *leg_recele_eff_eta = new TLegend(0.55, 0.22, 0.90, 0.48);
     2396
     2397  TGraphErrors *gr_recele_eff_pt = new TGraphErrors[n_etabins];
     2398  TGraphErrors *gr_recele_eff_eta = new TGraphErrors[n_ptbins];
     2399  TH1D *h_recele_eff_pt, *h_recele_eff_eta;
     2400
     2401  // loop over eta bins
     2402  for(k = 0; k < etaVals.size() - 1; k++)
     2403  {
     2404
     2405    h_recele_eff_pt = GetEffPt<Electron>(branchElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderElectron);
     2406    gr_recele_eff_pt[k] = TGraphErrors(h_recele_eff_pt);
     2407
     2408    s_etaMin = Form("%.1f", etaVals.at(k));
     2409    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2410
     2411    s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2412
     2413    gr_recele_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2414
     2415    addResoGraph(mg_recele_eff_pt, &gr_recele_eff_pt[k], leg_recele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2416  }
     2417
     2418  // loop over pt
     2419  for(k = 0; k < ptVals.size(); k++)
     2420  {
     2421    h_recele_eff_eta = GetEffEta<Electron>(branchElectron, branchParticleElectron, "Electron", 11, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderElectron);
     2422    gr_recele_eff_eta[k] = TGraphErrors(h_recele_eff_eta);
     2423
     2424    s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     2425    if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2426
     2427    addResoGraph(mg_recele_eff_eta, &gr_recele_eff_eta[k], leg_recele_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2428  }
     2429
     2430  TCanvas *c_recele_eff_pt = new TCanvas("", "", 800, 600);
     2431
     2432  mg_recele_eff_pt->Draw("APE");
     2433  DrawAxis(mg_recele_eff_pt, leg_recele_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
     2434  leg_recele_eff_pt->Draw();
     2435  pave->Draw();
     2436
     2437  c_recele_eff_pt->Print(pdfOutput, "pdf");
     2438  c_recele_eff_pt->Print(figPath + "img_recele_eff_pt.pdf", "pdf");
     2439  c_recele_eff_pt->Print(figPath + "img_recele_eff_pt.png", "png");
     2440
     2441  TCanvas *c_recele_eff_eta = new TCanvas("", "", 800, 600);
     2442
     2443  mg_recele_eff_eta->Draw("APE");
     2444  DrawAxis(mg_recele_eff_eta, leg_recele_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
     2445  leg_recele_eff_eta->Draw();
     2446  pave->Draw();
     2447
     2448  c_recele_eff_eta->Print(pdfOutput, "pdf");
     2449  c_recele_eff_eta->Print(figPath + "img_recele_eff_eta.pdf", "pdf");
     2450  c_recele_eff_eta->Print(figPath + "img_recele_eff_eta.png", "png");
     2451
     2452  /////////////////////////////////////////
     2453  // Muon Reconstruction Efficiency ///
     2454  /////////////////////////////////////////
     2455
     2456  TMultiGraph *mg_recmu_eff_pt = new TMultiGraph("", "");
     2457  TMultiGraph *mg_recmu_eff_eta = new TMultiGraph("", "");
     2458
     2459  TLegend *leg_recmu_eff_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     2460  TLegend *leg_recmu_eff_eta = new TLegend(0.55, 0.22, 0.90, 0.48);
     2461
     2462  TGraphErrors *gr_recmu_eff_pt = new TGraphErrors[n_etabins];
     2463  TGraphErrors *gr_recmu_eff_eta = new TGraphErrors[n_ptbins];
     2464  TH1D *h_recmu_eff_pt, *h_recmu_eff_eta;
     2465
     2466  // loop over eta bins
     2467  for(k = 0; k < etaVals.size() - 1; k++)
     2468  {
     2469
     2470    h_recmu_eff_pt = GetEffPt<Muon>(branchMuon, branchParticleMuon, "muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderMuon);
     2471    gr_recmu_eff_pt[k] = TGraphErrors(h_recmu_eff_pt);
     2472
     2473    s_etaMin = Form("%.1f", etaVals.at(k));
     2474    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2475
     2476    s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2477
     2478    gr_recmu_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2479
     2480    addResoGraph(mg_recmu_eff_pt, &gr_recmu_eff_pt[k], leg_recmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2481  }
     2482
     2483  // loop over pt
     2484  for(k = 0; k < ptVals.size(); k++)
     2485  {
     2486    h_recmu_eff_eta = GetEffEta<Muon>(branchMuon, branchParticleMuon, "muon", 13, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderMuon);
     2487    gr_recmu_eff_eta[k] = TGraphErrors(h_recmu_eff_eta);
     2488
     2489    s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV", ptVals.at(k));
     2490    if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2491
     2492    addResoGraph(mg_recmu_eff_eta, &gr_recmu_eff_eta[k], leg_recmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2493  }
     2494
     2495  TCanvas *c_recmu_eff_pt = new TCanvas("", "", 800, 600);
     2496
     2497  mg_recmu_eff_pt->Draw("APE");
     2498  DrawAxis(mg_recmu_eff_pt, leg_recmu_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
     2499  leg_recmu_eff_pt->Draw();
     2500  pave->Draw();
     2501
     2502  c_recmu_eff_pt->Print(pdfOutput, "pdf");
     2503  c_recmu_eff_pt->Print(figPath + "img_recmu_eff_pt.pdf", "pdf");
     2504  c_recmu_eff_pt->Print(figPath + "img_recmu_eff_pt.png", "png");
     2505
     2506  TCanvas *c_recmu_eff_eta = new TCanvas("", "", 800, 600);
     2507
     2508  mg_recmu_eff_eta->Draw("APE");
     2509  DrawAxis(mg_recmu_eff_eta, leg_recmu_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
     2510  leg_recmu_eff_eta->Draw();
     2511  pave->Draw();
     2512
     2513  c_recmu_eff_eta->Print(pdfOutput, "pdf");
     2514  c_recmu_eff_eta->Print(figPath + "img_recmu_eff_eta.pdf", "pdf");
     2515  c_recmu_eff_eta->Print(figPath + "img_recmu_eff_eta.png", "png");
     2516
     2517  /////////////////////////////////////////
     2518  // Photon Reconstruction Efficiency   ///
     2519  /////////////////////////////////////////
     2520
     2521  TMultiGraph *mg_recpho_eff_pt = new TMultiGraph("", "");
     2522  TMultiGraph *mg_recpho_eff_eta = new TMultiGraph("", "");
     2523
     2524  TLegend *leg_recpho_eff_pt = new TLegend(0.55, 0.22, 0.90, 0.48);
     2525  TLegend *leg_recpho_eff_eta = new TLegend(0.55, 0.22, 0.90, 0.48);
     2526
     2527  TGraphErrors *gr_recpho_eff_pt = new TGraphErrors[n_etabins];
     2528  TGraphErrors *gr_recpho_eff_eta = new TGraphErrors[n_ptbins];
     2529  TH1D *h_recpho_eff_pt, *h_recpho_eff_eta;
     2530
     2531  // loop over eta bins
     2532  for(k = 0; k < etaVals.size() - 1; k++)
     2533  {
     2534
     2535    h_recpho_eff_pt = GetEffPt<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderPhoton);
     2536    gr_recpho_eff_pt[k] = TGraphErrors(h_recpho_eff_pt);
     2537
     2538    s_etaMin = Form("%.1f", etaVals.at(k));
     2539    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2540
     2541    s_eta = "#gamma , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2542
     2543    gr_recpho_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2544
     2545    addResoGraph(mg_recpho_eff_pt, &gr_recpho_eff_pt[k], leg_recpho_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2546  }
     2547
     2548  // loop over pt
     2549  for(k = 0; k < ptVals.size(); k++)
     2550  {
     2551    h_recpho_eff_eta = GetEffEta<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderPhoton);
     2552    gr_recpho_eff_eta[k] = TGraphErrors(h_recpho_eff_eta);
     2553
     2554    s_pt = Form("#gamma , p_{T} = %.0f GeV", ptVals.at(k));
     2555    if(ptVals.at(k) >= 1000.) s_pt = Form("#gamma , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2556
     2557    addResoGraph(mg_recpho_eff_eta, &gr_recpho_eff_eta[k], leg_recpho_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2558  }
     2559
     2560  TCanvas *c_recpho_eff_pt = new TCanvas("", "", 800, 600);
     2561
     2562  mg_recpho_eff_pt->Draw("APE");
     2563  DrawAxis(mg_recpho_eff_pt, leg_recpho_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
     2564  leg_recpho_eff_pt->Draw();
     2565  pave->Draw();
     2566
     2567  c_recpho_eff_pt->Print(pdfOutput, "pdf");
     2568  c_recpho_eff_pt->Print(figPath + "img_recpho_eff_pt.pdf", "pdf");
     2569  c_recpho_eff_pt->Print(figPath + "img_recpho_eff_pt.png", "png");
     2570
     2571  TCanvas *c_recpho_eff_eta = new TCanvas("", "", 800, 600);
     2572
     2573  mg_recpho_eff_eta->Draw("APE");
     2574  DrawAxis(mg_recpho_eff_eta, leg_recpho_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
     2575  leg_recpho_eff_eta->Draw();
     2576  pave->Draw();
     2577
     2578  c_recpho_eff_eta->Print(pdfOutput, "pdf");
     2579  c_recpho_eff_eta->Print(figPath + "img_recpho_eff_eta.pdf", "pdf");
     2580  c_recpho_eff_eta->Print(figPath + "img_recpho_eff_eta.png", "png");
     2581
     2582  /////////////////////////////////////////
     2583  // B-jets  Efficiency/ mistag rates   ///
     2584  /////////////////////////////////////////
     2585
     2586  TMultiGraph *mg_recbjet_eff_pt = new TMultiGraph("", "");
     2587  TMultiGraph *mg_recbjet_eff_eta = new TMultiGraph("", "");
     2588
     2589  TLegend *leg_recbjet_eff_pt = new TLegend(0.50, 0.22, 0.90, 0.48);
     2590  TLegend *leg_recbjet_eff_eta = new TLegend(0.50, 0.22, 0.90, 0.48);
     2591
     2592  TGraphErrors *gr_recbjet_eff_pt = new TGraphErrors[n_etabins];
     2593  TGraphErrors *gr_recbjet_eff_eta = new TGraphErrors[n_ptbins];
     2594  TH1D *h_recbjet_eff_pt, *h_recbjet_eff_eta;
     2595
     2596  // loop over eta bins
     2597  for(k = 0; k < etaVals.size() - 1; k++)
     2598  {
     2599
     2600    h_recbjet_eff_pt = GetJetEffPt<Jet>(branchPFBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderBJet);
     2601    //h_recbjet_eff_pt = GetEffPt<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderBJet);
     2602    gr_recbjet_eff_pt[k] = TGraphErrors(h_recbjet_eff_pt);
     2603
     2604    s_etaMin = Form("%.1f", etaVals.at(k));
     2605    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2606
     2607    s_eta = "b-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2608
     2609    gr_recbjet_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2610
     2611    addResoGraph(mg_recbjet_eff_pt, &gr_recbjet_eff_pt[k], leg_recbjet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2612  }
     2613
     2614  // loop over pt
     2615  for(k = 0; k < ptVals.size(); k++)
     2616  {
     2617    h_recbjet_eff_eta = GetJetEffEta<Jet>(branchPFBJet, "BJet", 5, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderBJet);
     2618    //h_recbjet_eff_eta = GetEffEta<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderBJet);
     2619    gr_recbjet_eff_eta[k] = TGraphErrors(h_recbjet_eff_eta);
     2620
     2621    s_pt = Form("b-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2622    if(ptVals.at(k) >= 1000.) s_pt = Form("b-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2623
     2624    addResoGraph(mg_recbjet_eff_eta, &gr_recbjet_eff_eta[k], leg_recbjet_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2625  }
     2626
     2627  TCanvas *c_recbjet_eff_pt = new TCanvas("", "", 800, 600);
     2628
     2629  mg_recbjet_eff_pt->Draw("APE");
     2630  DrawAxis(mg_recbjet_eff_pt, leg_recbjet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "b - tag efficiency (%)", true, false);
     2631  leg_recbjet_eff_pt->Draw();
     2632  pave->Draw();
     2633
     2634  c_recbjet_eff_pt->Print(pdfOutput, "pdf");
     2635  c_recbjet_eff_pt->Print(figPath + "img_recbjet_eff_pt.pdf", "pdf");
     2636  c_recbjet_eff_pt->Print(figPath + "img_recbjet_eff_pt.png", "png");
     2637
     2638  TCanvas *c_recbjet_eff_eta = new TCanvas("", "", 800, 600);
     2639
     2640  mg_recbjet_eff_eta->Draw("APE");
     2641  DrawAxis(mg_recbjet_eff_eta, leg_recbjet_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "b - tag efficiency (%)", false, false);
     2642  leg_recbjet_eff_eta->Draw();
     2643  pave->Draw();
     2644
     2645  c_recbjet_eff_eta->Print(pdfOutput, "pdf");
     2646  c_recbjet_eff_eta->Print(figPath + "img_recbjet_eff_eta.pdf", "pdf");
     2647  c_recbjet_eff_eta->Print(figPath + "img_recbjet_eff_eta.png", "png");
     2648
     2649  // ------ c - mistag  ------
     2650
     2651  TMultiGraph *mg_recbjet_cmis_pt = new TMultiGraph("", "");
     2652  TMultiGraph *mg_recbjet_cmis_eta = new TMultiGraph("", "");
     2653
     2654  TLegend *leg_recbjet_cmis_pt = new TLegend(0.50, 0.64, 0.90, 0.90);
     2655  TLegend *leg_recbjet_cmis_eta = new TLegend(0.50, 0.64, 0.90, 0.90);
     2656
     2657  TGraphErrors *gr_recbjet_cmis_pt = new TGraphErrors[n_etabins];
     2658  TGraphErrors *gr_recbjet_cmis_eta = new TGraphErrors[n_ptbins];
     2659  TH1D *h_recbjet_cmis_pt, *h_recbjet_cmis_eta;
     2660
     2661  // loop over eta bins
     2662  for(k = 0; k < etaVals.size() - 1; k++)
     2663  {
     2664
     2665    h_recbjet_cmis_pt = GetJetEffPt<Jet>(branchPFCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderCJet);
     2666    //h_recbjet_cmis_pt = GetEffPt<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderCJet);
     2667    gr_recbjet_cmis_pt[k] = TGraphErrors(h_recbjet_cmis_pt);
     2668
     2669    s_etaMin = Form("%.1f", etaVals.at(k));
     2670    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2671
     2672    s_eta = "c-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2673
     2674    gr_recbjet_cmis_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2675
     2676    addResoGraph(mg_recbjet_cmis_pt, &gr_recbjet_cmis_pt[k], leg_recbjet_cmis_pt, markerStyles.at(k), colors.at(k), s_eta);
     2677  }
     2678
     2679  // loop over pt
     2680  for(k = 0; k < ptVals.size(); k++)
     2681  {
     2682    h_recbjet_cmis_eta = GetJetEffEta<Jet>(branchPFCJet, "CJet", 4, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderCJet);
     2683    //h_recbjet_cmis_eta = GetEffEta<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderCJet);
     2684    gr_recbjet_cmis_eta[k] = TGraphErrors(h_recbjet_cmis_eta);
     2685
     2686    s_pt = Form("c-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2687    if(ptVals.at(k) >= 1000.) s_pt = Form("c-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2688
     2689    addResoGraph(mg_recbjet_cmis_eta, &gr_recbjet_cmis_eta[k], leg_recbjet_cmis_eta, markerStyles.at(k), colors.at(k), s_pt);
     2690  }
     2691
     2692  TCanvas *c_recbjet_cmis_pt = new TCanvas("", "", 800, 600);
     2693
     2694  mg_recbjet_cmis_pt->Draw("APE");
     2695  DrawAxis(mg_recbjet_cmis_pt, leg_recbjet_cmis_pt, ptMin, ptMax, 0.0, 20, "p_{T} [GeV]", "c - mistag rate (%)", true, false);
     2696  leg_recbjet_cmis_pt->Draw();
     2697  pave->Draw();
     2698
     2699  c_recbjet_cmis_pt->Print(pdfOutput, "pdf");
     2700  c_recbjet_cmis_pt->Print(figPath + "img_recbjet_cmis_pt.pdf", "pdf");
     2701  c_recbjet_cmis_pt->Print(figPath + "img_recbjet_cmis_pt.png", "png");
     2702
     2703  TCanvas *c_recbjet_cmis_eta = new TCanvas("", "", 800, 600);
     2704
     2705  mg_recbjet_cmis_eta->Draw("APE");
     2706  DrawAxis(mg_recbjet_cmis_eta, leg_recbjet_cmis_eta, etaMin, etaMax, 0.0, 20, " #eta ", "c - mistag rate (%)", false, false);
     2707  leg_recbjet_cmis_eta->Draw();
     2708  pave->Draw();
     2709
     2710  c_recbjet_cmis_eta->Print(pdfOutput, "pdf");
     2711  c_recbjet_cmis_eta->Print(figPath + "img_recbjet_cmis_eta.pdf", "pdf");
     2712  c_recbjet_cmis_eta->Print(figPath + "img_recbjet_cmis_eta.png", "png");
     2713
     2714  // ------ light - mistag  ------
     2715
     2716  TMultiGraph *mg_recbjet_lmis_pt = new TMultiGraph("", "");
     2717  TMultiGraph *mg_recbjet_lmis_eta = new TMultiGraph("", "");
     2718
     2719  TLegend *leg_recbjet_lmis_pt = new TLegend(0.50, 0.64, 0.90, 0.90);
     2720  TLegend *leg_recbjet_lmis_eta = new TLegend(0.50, 0.64, 0.90, 0.90);
     2721
     2722  TGraphErrors *gr_recbjet_lmis_pt = new TGraphErrors[n_etabins];
     2723  TGraphErrors *gr_recbjet_lmis_eta = new TGraphErrors[n_ptbins];
     2724  TH1D *h_recbjet_lmis_pt, *h_recbjet_lmis_eta;
     2725
     2726  // loop over eta bins
     2727  for(k = 0; k < etaVals.size() - 1; k++)
     2728  {
     2729
     2730    h_recbjet_lmis_pt = GetJetEffPt<Jet>(branchJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderJet);
     2731    //h_recbjet_lmis_pt = GetEffPt<Jet>(branchJet, branchParticleJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
     2732    gr_recbjet_lmis_pt[k] = TGraphErrors(h_recbjet_lmis_pt);
     2733
     2734    s_etaMin = Form("%.1f", etaVals.at(k));
     2735    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2736
     2737    s_eta = "uds-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2738
     2739    gr_recbjet_lmis_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2740
     2741    addResoGraph(mg_recbjet_lmis_pt, &gr_recbjet_lmis_pt[k], leg_recbjet_lmis_pt, markerStyles.at(k), colors.at(k), s_eta);
     2742  }
     2743
     2744  // loop over pt
     2745  for(k = 0; k < ptVals.size(); k++)
     2746  {
     2747    h_recbjet_lmis_eta = GetJetEffEta<Jet>(branchJet, "Jet", 1, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderJet);
     2748    //h_recbjet_lmis_eta = GetEffEta<Jet>(branchJet, branchParticleJet, "Jet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
     2749    gr_recbjet_lmis_eta[k] = TGraphErrors(h_recbjet_lmis_eta);
     2750
     2751    s_pt = Form("uds-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2752    if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2753
     2754    addResoGraph(mg_recbjet_lmis_eta, &gr_recbjet_lmis_eta[k], leg_recbjet_lmis_eta, markerStyles.at(k), colors.at(k), s_pt);
     2755  }
     2756
     2757  TCanvas *c_recbjet_lmis_pt = new TCanvas("", "", 800, 600);
     2758
     2759  mg_recbjet_lmis_pt->Draw("APE");
     2760
     2761  DrawAxis(mg_recbjet_lmis_pt, leg_recbjet_lmis_pt, ptMin, ptMax, 0.0, 1.0, "p_{T} [GeV]", "light - mistag rate (%)", true, false);
     2762
     2763  leg_recbjet_lmis_pt->Draw();
     2764  pave->Draw();
     2765
     2766  c_recbjet_lmis_pt->Print(pdfOutput, "pdf");
     2767  c_recbjet_lmis_pt->Print(figPath + "img_recbjet_lmis_pt.pdf", "pdf");
     2768  c_recbjet_lmis_pt->Print(figPath + "img_recbjet_lmis_pt.png", "png");
     2769
     2770  TCanvas *c_recbjet_lmis_eta = new TCanvas("", "", 800, 600);
     2771
     2772  mg_recbjet_lmis_eta->Draw("APE");
     2773  DrawAxis(mg_recbjet_lmis_eta, leg_recbjet_lmis_eta, etaMin, etaMax, 0.0, 1.0, " #eta ", "light - mistag rate (%)", false, false);
     2774  leg_recbjet_lmis_eta->Draw();
     2775  pave->Draw();
     2776
     2777  c_recbjet_lmis_eta->Print(pdfOutput, "pdf");
     2778  c_recbjet_lmis_eta->Print(figPath + "img_recbjet_lmis_eta.pdf", "pdf");
     2779  c_recbjet_lmis_eta->Print(figPath + "img_recbjet_lmis_eta.png", "png");
     2780
     2781  ///////////////////////////////////////////
     2782  // tau-jets  Efficiency/ mistag rates   ///
     2783  ///////////////////////////////////////////
     2784
     2785  TMultiGraph *mg_rectaujet_eff_pt = new TMultiGraph("", "");
     2786  TMultiGraph *mg_rectaujet_eff_eta = new TMultiGraph("", "");
     2787
     2788  TLegend *leg_rectaujet_eff_pt = new TLegend(0.50, 0.22, 0.90, 0.48);
     2789  TLegend *leg_rectaujet_eff_eta = new TLegend(0.50, 0.22, 0.90, 0.48);
     2790
     2791  TGraphErrors *gr_rectaujet_eff_pt = new TGraphErrors[n_etabins];
     2792  TGraphErrors *gr_rectaujet_eff_eta = new TGraphErrors[n_ptbins];
     2793  TH1D *h_rectaujet_eff_pt, *h_rectaujet_eff_eta;
     2794
     2795  // loop over eta bins
     2796  for(k = 0; k < etaVals.size() - 1; k++)
     2797  {
     2798
     2799    h_rectaujet_eff_pt = GetTauEffPt<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderTauJet);
     2800    gr_rectaujet_eff_pt[k] = TGraphErrors(h_rectaujet_eff_pt);
     2801
     2802    s_etaMin = Form("%.1f", etaVals.at(k));
     2803    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2804
     2805    s_eta = "#tau-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2806
     2807    gr_rectaujet_eff_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2808
     2809    addResoGraph(mg_rectaujet_eff_pt, &gr_rectaujet_eff_pt[k], leg_rectaujet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2810  }
     2811
     2812  // loop over pt
     2813  for(k = 0; k < ptVals.size(); k++)
     2814  {
     2815    h_rectaujet_eff_eta = GetTauEffEta<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderTauJet);
     2816    gr_rectaujet_eff_eta[k] = TGraphErrors(h_rectaujet_eff_eta);
     2817
     2818    s_pt = Form("#tau-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2819    if(ptVals.at(k) >= 1000.) s_pt = Form("#tau-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2820
     2821    addResoGraph(mg_rectaujet_eff_eta, &gr_rectaujet_eff_eta[k], leg_rectaujet_eff_eta, markerStyles.at(k), colors.at(k), s_pt);
     2822  }
     2823
     2824  TCanvas *c_rectaujet_eff_pt = new TCanvas("", "", 800, 600);
     2825
     2826  mg_rectaujet_eff_pt->Draw("APE");
     2827  DrawAxis(mg_rectaujet_eff_pt, leg_rectaujet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "#tau - tag efficiency (%)", true, false);
     2828  leg_rectaujet_eff_pt->Draw();
     2829  pave->Draw();
     2830
     2831  c_rectaujet_eff_pt->Print(pdfOutput, "pdf");
     2832  c_rectaujet_eff_pt->Print(figPath + "img_rectaujet_eff_pt.pdf", "pdf");
     2833  c_rectaujet_eff_pt->Print(figPath + "img_rectaujet_eff_pt.png", "png");
     2834
     2835  TCanvas *c_rectaujet_eff_eta = new TCanvas("", "", 800, 600);
     2836
     2837  mg_rectaujet_eff_eta->Draw("APE");
     2838  DrawAxis(mg_rectaujet_eff_eta, leg_rectaujet_eff_eta, etaMin, etaMax, 0.0, 100., " #eta ", "#tau - tag efficiency (%)", false, false);
     2839  leg_rectaujet_eff_eta->Draw();
     2840  pave->Draw();
     2841
     2842  c_rectaujet_eff_eta->Print(pdfOutput, "pdf");
     2843  c_rectaujet_eff_eta->Print(figPath + "img_rectaujet_eff_eta.pdf", "pdf");
     2844  c_rectaujet_eff_eta->Print(figPath + "img_rectaujet_eff_eta.png", "png");
     2845
     2846  //--------------- tau mistag rate ----------
     2847
     2848  TMultiGraph *mg_rectaujet_mis_pt = new TMultiGraph("", "");
     2849  TMultiGraph *mg_rectaujet_mis_eta = new TMultiGraph("", "");
     2850
     2851  TLegend *leg_rectaujet_mis_pt = new TLegend(0.50, 0.64, 0.90, 0.90);
     2852  TLegend *leg_rectaujet_mis_eta = new TLegend(0.50, 0.64, 0.90, 0.90);
     2853
     2854  TGraphErrors *gr_rectaujet_mis_pt = new TGraphErrors[n_etabins];
     2855  TGraphErrors *gr_rectaujet_mis_eta = new TGraphErrors[n_ptbins];
     2856  TH1D *h_rectaujet_mis_pt, *h_rectaujet_mis_eta;
     2857
     2858  // loop over eta bins
     2859  for(k = 0; k < etaVals.size() - 1; k++)
     2860  {
     2861
     2862    h_rectaujet_mis_pt = GetTauEffPt<Jet>(branchJet, branchParticleJet, "TauJet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k + 1), treeReaderJet);
     2863    gr_rectaujet_mis_pt[k] = TGraphErrors(h_rectaujet_mis_pt);
     2864
     2865    s_etaMin = Form("%.1f", etaVals.at(k));
     2866    s_etaMax = Form("%.1f", etaVals.at(k + 1));
     2867
     2868    s_eta = "uds-jet , " + s_etaMin + " < | #eta | < " + s_etaMax;
     2869
     2870    gr_rectaujet_mis_pt[k].SetName("recEff_" + s_etaMin + "_" + s_etaMax);
     2871
     2872    addResoGraph(mg_rectaujet_mis_pt, &gr_rectaujet_mis_pt[k], leg_rectaujet_mis_pt, markerStyles.at(k), colors.at(k), s_eta);
     2873  }
     2874
     2875  // loop over pt
     2876  for(k = 0; k < ptVals.size(); k++)
     2877  {
     2878    h_rectaujet_mis_eta = GetTauEffEta<Jet>(branchJet, branchParticleJet, "TauJet", 1, 0.5 * ptVals.at(k), 2.0 * ptVals.at(k), etaMin, etaMax, treeReaderJet);
     2879    gr_rectaujet_mis_eta[k] = TGraphErrors(h_rectaujet_mis_eta);
     2880
     2881    s_pt = Form("uds-jet , p_{T} = %.0f GeV", ptVals.at(k));
     2882    if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV", ptVals.at(k) / 1000.);
     2883
     2884    addResoGraph(mg_rectaujet_mis_eta, &gr_rectaujet_mis_eta[k], leg_rectaujet_mis_eta, markerStyles.at(k), colors.at(k), s_pt);
     2885  }
     2886
     2887  TCanvas *c_rectaujet_mis_pt = new TCanvas("", "", 800, 600);
     2888
     2889  mg_rectaujet_mis_pt->Draw("APE");
     2890  DrawAxis(mg_rectaujet_mis_pt, leg_rectaujet_mis_pt, ptMin, ptMax, 0.0, 5., "p_{T} [GeV]", "#tau - mistag(%)", true, false);
     2891  leg_rectaujet_mis_pt->Draw();
     2892  pave->Draw();
     2893
     2894  c_rectaujet_mis_pt->Print(pdfOutput, "pdf");
     2895  c_rectaujet_mis_pt->Print(figPath + "img_rectaujet_mis_pt.pdf", "pdf");
     2896  c_rectaujet_mis_pt->Print(figPath + "img_rectaujet_mis_pt.png", "png");
     2897
     2898  TCanvas *c_rectaujet_mis_eta = new TCanvas("", "", 800, 600);
     2899
     2900  mg_rectaujet_mis_eta->Draw("APE");
     2901  DrawAxis(mg_rectaujet_mis_eta, leg_rectaujet_mis_eta, etaMin, etaMax, 0.0, 5., " #eta ", "#tau - mistag (%)", false, false);
     2902  leg_rectaujet_mis_eta->Draw();
     2903  pave->Draw();
     2904
     2905  c_rectaujet_mis_eta->Print(pdfOutput + ")", "pdf");
     2906  c_rectaujet_mis_eta->Print(figPath + "img_rectaujet_mis_eta.pdf", "pdf");
     2907  c_rectaujet_mis_eta->Print(figPath + "img_rectaujet_mis_eta.png", "png");
     2908
     2909  //   ----   store resolution histograms in the output (for leave efficiencies out) ---
     2910
     2911  TFile *fout = new TFile(outputFile, "recreate");
     2912
     2913  for(int bin = 0; bin < Nbins; bin++)
     2914  {
     2915
     2916    for(k = 0; k < etaVals.size() - 1; k++)
    24632917    {
    2464 
    2465        h_recele_eff_pt = GetEffPt<Electron>(branchElectron, branchParticleElectron, "Electron", 11, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderElectron);
    2466        gr_recele_eff_pt[k] = TGraphErrors(h_recele_eff_pt);
    2467 
    2468        s_etaMin = Form("%.1f",etaVals.at(k));
    2469        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2470 
    2471        s_eta = "e^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2472 
    2473        gr_recele_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2474 
    2475        addResoGraph(mg_recele_eff_pt, &gr_recele_eff_pt[k], leg_recele_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
     2918      plots_trkpi_res_pt[k].at(bin).resolHist->Write();
     2919      plots_trkele_res_pt[k].at(bin).resolHist->Write();
     2920      plots_trkmu_res_pt[k].at(bin).resolHist->Write();
     2921      plots_ecal_res_e[k].at(bin).resolHist->Write();
     2922      plots_hcal_res_e[k].at(bin).resolHist->Write();
     2923      plots_pfele_res_e[k].at(bin).resolHist->Write();
     2924      plots_pfpi_res_e[k].at(bin).resolHist->Write();
     2925      plots_pfjet_res_e[k].at(bin).resolHist->Write();
     2926      plots_cajet_res_e[k].at(bin).resolHist->Write();
    24762927    }
    24772928
    2478     // loop over pt
    2479     for (k = 0; k < ptVals.size(); k++)
     2929    for(k = 0; k < ptVals.size(); k++)
    24802930    {
    2481        h_recele_eff_eta = GetEffEta<Electron>(branchElectron, branchParticleElectron, "Electron", 11, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderElectron);
    2482        gr_recele_eff_eta[k] = TGraphErrors(h_recele_eff_eta);
    2483 
    2484        s_pt = Form("e^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    2485        if(ptVals.at(k) >= 1000.) s_pt = Form("e^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2486 
    2487        addResoGraph(mg_recele_eff_eta, &gr_recele_eff_eta[k], leg_recele_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2488     }
    2489 
    2490     TCanvas *c_recele_eff_pt = new TCanvas("","", 800, 600);
    2491 
    2492     mg_recele_eff_pt->Draw("APE");
    2493     DrawAxis(mg_recele_eff_pt, leg_recele_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
    2494     leg_recele_eff_pt->Draw();
    2495     pave->Draw();
    2496 
    2497     c_recele_eff_pt->Print(pdfOutput,"pdf");
    2498     c_recele_eff_pt->Print(figPath+"img_recele_eff_pt.pdf","pdf");
    2499     c_recele_eff_pt->Print(figPath+"img_recele_eff_pt.png","png");
    2500 
    2501     TCanvas *c_recele_eff_eta = new TCanvas("","", 800, 600);
    2502 
    2503     mg_recele_eff_eta->Draw("APE");
    2504     DrawAxis(mg_recele_eff_eta, leg_recele_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
    2505     leg_recele_eff_eta->Draw();
    2506     pave->Draw();
    2507 
    2508     c_recele_eff_eta->Print(pdfOutput,"pdf");
    2509     c_recele_eff_eta->Print(figPath+"img_recele_eff_eta.pdf","pdf");
    2510     c_recele_eff_eta->Print(figPath+"img_recele_eff_eta.png","png");
    2511 
    2512 
    2513     /////////////////////////////////////////
    2514     // Muon Reconstruction Efficiency ///
    2515     /////////////////////////////////////////
    2516 
    2517     TMultiGraph *mg_recmu_eff_pt  = new TMultiGraph("","");
    2518     TMultiGraph *mg_recmu_eff_eta = new TMultiGraph("","");
    2519 
    2520     TLegend *leg_recmu_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
    2521     TLegend *leg_recmu_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
    2522 
    2523     TGraphErrors *gr_recmu_eff_pt  = new TGraphErrors[n_etabins];
    2524     TGraphErrors *gr_recmu_eff_eta = new TGraphErrors[n_ptbins];
    2525     TH1D* h_recmu_eff_pt, *h_recmu_eff_eta;
    2526 
    2527     // loop over eta bins
    2528     for (k = 0; k < etaVals.size()-1; k++)
    2529     {
    2530 
    2531        h_recmu_eff_pt = GetEffPt<Muon>(branchMuon, branchParticleMuon, "muon", 13, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderMuon);
    2532        gr_recmu_eff_pt[k] = TGraphErrors(h_recmu_eff_pt);
    2533 
    2534        s_etaMin = Form("%.1f",etaVals.at(k));
    2535        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2536 
    2537        s_eta = "#mu^{ #pm} , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2538 
    2539        gr_recmu_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2540 
    2541        addResoGraph(mg_recmu_eff_pt, &gr_recmu_eff_pt[k], leg_recmu_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    2542     }
    2543 
    2544     // loop over pt
    2545     for (k = 0; k < ptVals.size(); k++)
    2546     {
    2547        h_recmu_eff_eta = GetEffEta<Muon>(branchMuon, branchParticleMuon, "muon", 13, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderMuon);
    2548        gr_recmu_eff_eta[k] = TGraphErrors(h_recmu_eff_eta);
    2549 
    2550        s_pt = Form("#mu^{ #pm} , p_{T} = %.0f GeV",ptVals.at(k));
    2551        if(ptVals.at(k) >= 1000.) s_pt = Form("#mu^{ #pm} , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2552 
    2553        addResoGraph(mg_recmu_eff_eta, &gr_recmu_eff_eta[k], leg_recmu_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2554     }
    2555 
    2556     TCanvas *c_recmu_eff_pt = new TCanvas("","", 800, 600);
    2557 
    2558     mg_recmu_eff_pt->Draw("APE");
    2559     DrawAxis(mg_recmu_eff_pt, leg_recmu_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
    2560     leg_recmu_eff_pt->Draw();
    2561     pave->Draw();
    2562 
    2563     c_recmu_eff_pt->Print(pdfOutput,"pdf");
    2564     c_recmu_eff_pt->Print(figPath+"img_recmu_eff_pt.pdf","pdf");
    2565     c_recmu_eff_pt->Print(figPath+"img_recmu_eff_pt.png","png");
    2566 
    2567     TCanvas *c_recmu_eff_eta = new TCanvas("","", 800, 600);
    2568 
    2569     mg_recmu_eff_eta->Draw("APE");
    2570     DrawAxis(mg_recmu_eff_eta, leg_recmu_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
    2571     leg_recmu_eff_eta->Draw();
    2572     pave->Draw();
    2573 
    2574     c_recmu_eff_eta->Print(pdfOutput,"pdf");
    2575     c_recmu_eff_eta->Print(figPath+"img_recmu_eff_eta.pdf","pdf");
    2576     c_recmu_eff_eta->Print(figPath+"img_recmu_eff_eta.png","png");
    2577 
    2578 
    2579     /////////////////////////////////////////
    2580     // Photon Reconstruction Efficiency   ///
    2581     /////////////////////////////////////////
    2582 
    2583     TMultiGraph *mg_recpho_eff_pt  = new TMultiGraph("","");
    2584     TMultiGraph *mg_recpho_eff_eta = new TMultiGraph("","");
    2585 
    2586     TLegend *leg_recpho_eff_pt  = new TLegend(0.55,0.22,0.90,0.48);
    2587     TLegend *leg_recpho_eff_eta = new TLegend(0.55,0.22,0.90,0.48);
    2588 
    2589     TGraphErrors *gr_recpho_eff_pt  = new TGraphErrors[n_etabins];
    2590     TGraphErrors *gr_recpho_eff_eta = new TGraphErrors[n_ptbins];
    2591     TH1D* h_recpho_eff_pt, *h_recpho_eff_eta;
    2592 
    2593     // loop over eta bins
    2594     for (k = 0; k < etaVals.size()-1; k++)
    2595     {
    2596 
    2597        h_recpho_eff_pt = GetEffPt<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderPhoton);
    2598        gr_recpho_eff_pt[k] = TGraphErrors(h_recpho_eff_pt);
    2599 
    2600        s_etaMin = Form("%.1f",etaVals.at(k));
    2601        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2602 
    2603        s_eta = "#gamma , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2604 
    2605        gr_recpho_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2606 
    2607        addResoGraph(mg_recpho_eff_pt, &gr_recpho_eff_pt[k], leg_recpho_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    2608     }
    2609 
    2610     // loop over pt
    2611     for (k = 0; k < ptVals.size(); k++)
    2612     {
    2613        h_recpho_eff_eta = GetEffEta<Photon>(branchPhoton, branchParticlePhoton, "Photon", 22, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderPhoton);
    2614        gr_recpho_eff_eta[k] = TGraphErrors(h_recpho_eff_eta);
    2615 
    2616        s_pt = Form("#gamma , p_{T} = %.0f GeV",ptVals.at(k));
    2617        if(ptVals.at(k) >= 1000.) s_pt = Form("#gamma , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2618 
    2619        addResoGraph(mg_recpho_eff_eta, &gr_recpho_eff_eta[k], leg_recpho_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2620     }
    2621 
    2622     TCanvas *c_recpho_eff_pt = new TCanvas("","", 800, 600);
    2623 
    2624     mg_recpho_eff_pt->Draw("APE");
    2625     DrawAxis(mg_recpho_eff_pt, leg_recpho_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "reconstruction efficiency (%)", true, false);
    2626     leg_recpho_eff_pt->Draw();
    2627     pave->Draw();
    2628 
    2629     c_recpho_eff_pt->Print(pdfOutput,"pdf");
    2630     c_recpho_eff_pt->Print(figPath+"img_recpho_eff_pt.pdf","pdf");
    2631     c_recpho_eff_pt->Print(figPath+"img_recpho_eff_pt.png","png");
    2632 
    2633     TCanvas *c_recpho_eff_eta = new TCanvas("","", 800, 600);
    2634 
    2635     mg_recpho_eff_eta->Draw("APE");
    2636     DrawAxis(mg_recpho_eff_eta, leg_recpho_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "reconstruction efficiency (%)", false, false);
    2637     leg_recpho_eff_eta->Draw();
    2638     pave->Draw();
    2639 
    2640     c_recpho_eff_eta->Print(pdfOutput,"pdf");
    2641     c_recpho_eff_eta->Print(figPath+"img_recpho_eff_eta.pdf","pdf");
    2642     c_recpho_eff_eta->Print(figPath+"img_recpho_eff_eta.png","png");
    2643    
    2644     /////////////////////////////////////////
    2645     // B-jets  Efficiency/ mistag rates   ///
    2646     /////////////////////////////////////////
    2647 
    2648     TMultiGraph *mg_recbjet_eff_pt  = new TMultiGraph("","");
    2649     TMultiGraph *mg_recbjet_eff_eta = new TMultiGraph("","");
    2650 
    2651     TLegend *leg_recbjet_eff_pt  = new TLegend(0.50,0.22,0.90,0.48);
    2652     TLegend *leg_recbjet_eff_eta = new TLegend(0.50,0.22,0.90,0.48);
    2653 
    2654     TGraphErrors *gr_recbjet_eff_pt  = new TGraphErrors[n_etabins];
    2655     TGraphErrors *gr_recbjet_eff_eta = new TGraphErrors[n_ptbins];
    2656     TH1D* h_recbjet_eff_pt, *h_recbjet_eff_eta;
    2657 
    2658     // loop over eta bins
    2659     for (k = 0; k < etaVals.size()-1; k++)
    2660     {
    2661 
    2662        h_recbjet_eff_pt = GetJetEffPt<Jet>(branchPFBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderBJet);
    2663        //h_recbjet_eff_pt = GetEffPt<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderBJet);
    2664        gr_recbjet_eff_pt[k] = TGraphErrors(h_recbjet_eff_pt);
    2665 
    2666        s_etaMin = Form("%.1f",etaVals.at(k));
    2667        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2668 
    2669        s_eta = "b-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2670 
    2671        gr_recbjet_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2672 
    2673        addResoGraph(mg_recbjet_eff_pt, &gr_recbjet_eff_pt[k], leg_recbjet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    2674     }
    2675 
    2676     // loop over pt
    2677     for (k = 0; k < ptVals.size(); k++)
    2678     {
    2679        h_recbjet_eff_eta = GetJetEffEta<Jet>(branchPFBJet, "BJet", 5, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderBJet);
    2680        //h_recbjet_eff_eta = GetEffEta<Jet>(branchPFBJet, branchParticleBJet, "BJet", 5, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderBJet);
    2681        gr_recbjet_eff_eta[k] = TGraphErrors(h_recbjet_eff_eta);
    2682 
    2683        s_pt = Form("b-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2684        if(ptVals.at(k) >= 1000.) s_pt = Form("b-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2685 
    2686        addResoGraph(mg_recbjet_eff_eta, &gr_recbjet_eff_eta[k], leg_recbjet_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2687     }
    2688 
    2689     TCanvas *c_recbjet_eff_pt = new TCanvas("","", 800, 600);
    2690 
    2691     mg_recbjet_eff_pt->Draw("APE");
    2692     DrawAxis(mg_recbjet_eff_pt, leg_recbjet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "b - tag efficiency (%)", true, false);
    2693     leg_recbjet_eff_pt->Draw();
    2694     pave->Draw();
    2695 
    2696     c_recbjet_eff_pt->Print(pdfOutput,"pdf");
    2697     c_recbjet_eff_pt->Print(figPath+"img_recbjet_eff_pt.pdf","pdf");
    2698     c_recbjet_eff_pt->Print(figPath+"img_recbjet_eff_pt.png","png");
    2699 
    2700     TCanvas *c_recbjet_eff_eta = new TCanvas("","", 800, 600);
    2701 
    2702     mg_recbjet_eff_eta->Draw("APE");
    2703     DrawAxis(mg_recbjet_eff_eta, leg_recbjet_eff_eta, etaMin, etaMax, 0.0, 100, " #eta ", "b - tag efficiency (%)", false, false);
    2704     leg_recbjet_eff_eta->Draw();
    2705     pave->Draw();
    2706 
    2707     c_recbjet_eff_eta->Print(pdfOutput,"pdf");
    2708     c_recbjet_eff_eta->Print(figPath+"img_recbjet_eff_eta.pdf","pdf");
    2709     c_recbjet_eff_eta->Print(figPath+"img_recbjet_eff_eta.png","png");
    2710 
    2711     // ------ c - mistag  ------
    2712 
    2713     TMultiGraph *mg_recbjet_cmis_pt  = new TMultiGraph("","");
    2714     TMultiGraph *mg_recbjet_cmis_eta = new TMultiGraph("","");
    2715 
    2716     TLegend *leg_recbjet_cmis_pt  = new TLegend(0.50,0.64,0.90,0.90);
    2717     TLegend *leg_recbjet_cmis_eta = new TLegend(0.50,0.64,0.90,0.90);
    2718 
    2719     TGraphErrors *gr_recbjet_cmis_pt  = new TGraphErrors[n_etabins];
    2720     TGraphErrors *gr_recbjet_cmis_eta = new TGraphErrors[n_ptbins];
    2721     TH1D* h_recbjet_cmis_pt, *h_recbjet_cmis_eta;
    2722 
    2723     // loop over eta bins
    2724     for (k = 0; k < etaVals.size()-1; k++)
    2725     {
    2726 
    2727        h_recbjet_cmis_pt = GetJetEffPt<Jet>(branchPFCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderCJet);
    2728        //h_recbjet_cmis_pt = GetEffPt<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderCJet);
    2729        gr_recbjet_cmis_pt[k] = TGraphErrors(h_recbjet_cmis_pt);
    2730 
    2731        s_etaMin = Form("%.1f",etaVals.at(k));
    2732        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2733 
    2734        s_eta = "c-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2735 
    2736        gr_recbjet_cmis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2737 
    2738        addResoGraph(mg_recbjet_cmis_pt, &gr_recbjet_cmis_pt[k], leg_recbjet_cmis_pt, markerStyles.at(k), colors.at(k), s_eta);
    2739     }
    2740 
    2741     // loop over pt
    2742     for (k = 0; k < ptVals.size(); k++)
    2743     {
    2744        h_recbjet_cmis_eta = GetJetEffEta<Jet>(branchPFCJet, "CJet", 4, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderCJet);
    2745        //h_recbjet_cmis_eta = GetEffEta<Jet>(branchPFCJet, branchParticleCJet, "CJet", 4, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderCJet);
    2746        gr_recbjet_cmis_eta[k] = TGraphErrors(h_recbjet_cmis_eta);
    2747 
    2748        s_pt = Form("c-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2749        if(ptVals.at(k) >= 1000.) s_pt = Form("c-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2750 
    2751        addResoGraph(mg_recbjet_cmis_eta, &gr_recbjet_cmis_eta[k], leg_recbjet_cmis_eta, markerStyles.at(k), colors.at(k), s_pt );
    2752     }
    2753 
    2754     TCanvas *c_recbjet_cmis_pt = new TCanvas("","", 800, 600);
    2755 
    2756     mg_recbjet_cmis_pt->Draw("APE");
    2757     DrawAxis(mg_recbjet_cmis_pt, leg_recbjet_cmis_pt, ptMin, ptMax, 0.0, 20, "p_{T} [GeV]", "c - mistag rate (%)", true, false);
    2758     leg_recbjet_cmis_pt->Draw();
    2759     pave->Draw();
    2760 
    2761     c_recbjet_cmis_pt->Print(pdfOutput,"pdf");
    2762     c_recbjet_cmis_pt->Print(figPath+"img_recbjet_cmis_pt.pdf","pdf");
    2763     c_recbjet_cmis_pt->Print(figPath+"img_recbjet_cmis_pt.png","png");
    2764 
    2765     TCanvas *c_recbjet_cmis_eta = new TCanvas("","", 800, 600);
    2766 
    2767     mg_recbjet_cmis_eta->Draw("APE");
    2768     DrawAxis(mg_recbjet_cmis_eta, leg_recbjet_cmis_eta, etaMin, etaMax, 0.0, 20, " #eta ", "c - mistag rate (%)", false, false);
    2769     leg_recbjet_cmis_eta->Draw();
    2770     pave->Draw();
    2771 
    2772     c_recbjet_cmis_eta->Print(pdfOutput,"pdf");
    2773     c_recbjet_cmis_eta->Print(figPath+"img_recbjet_cmis_eta.pdf","pdf");
    2774     c_recbjet_cmis_eta->Print(figPath+"img_recbjet_cmis_eta.png","png");
    2775 
    2776     // ------ light - mistag  ------
    2777 
    2778     TMultiGraph *mg_recbjet_lmis_pt  = new TMultiGraph("","");
    2779     TMultiGraph *mg_recbjet_lmis_eta = new TMultiGraph("","");
    2780 
    2781     TLegend *leg_recbjet_lmis_pt  = new TLegend(0.50,0.64,0.90,0.90);
    2782     TLegend *leg_recbjet_lmis_eta = new TLegend(0.50,0.64,0.90,0.90);
    2783 
    2784     TGraphErrors *gr_recbjet_lmis_pt  = new TGraphErrors[n_etabins];
    2785     TGraphErrors *gr_recbjet_lmis_eta = new TGraphErrors[n_ptbins];
    2786     TH1D* h_recbjet_lmis_pt, *h_recbjet_lmis_eta;
    2787 
    2788     // loop over eta bins
    2789     for (k = 0; k < etaVals.size()-1; k++)
    2790     {
    2791 
    2792        h_recbjet_lmis_pt = GetJetEffPt<Jet>(branchJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
    2793        //h_recbjet_lmis_pt = GetEffPt<Jet>(branchJet, branchParticleJet, "Jet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
    2794        gr_recbjet_lmis_pt[k] = TGraphErrors(h_recbjet_lmis_pt);
    2795 
    2796        s_etaMin = Form("%.1f",etaVals.at(k));
    2797        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2798 
    2799        s_eta = "uds-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2800 
    2801        gr_recbjet_lmis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2802 
    2803        addResoGraph(mg_recbjet_lmis_pt, &gr_recbjet_lmis_pt[k], leg_recbjet_lmis_pt, markerStyles.at(k), colors.at(k), s_eta);
    2804     }
    2805 
    2806     // loop over pt
    2807     for (k = 0; k < ptVals.size(); k++)
    2808     {
    2809        h_recbjet_lmis_eta = GetJetEffEta<Jet>(branchJet, "Jet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
    2810        //h_recbjet_lmis_eta = GetEffEta<Jet>(branchJet, branchParticleJet, "Jet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
    2811        gr_recbjet_lmis_eta[k] = TGraphErrors(h_recbjet_lmis_eta);
    2812 
    2813        s_pt = Form("uds-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2814        if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2815 
    2816        addResoGraph(mg_recbjet_lmis_eta, &gr_recbjet_lmis_eta[k], leg_recbjet_lmis_eta, markerStyles.at(k), colors.at(k), s_pt );
    2817     }
    2818 
    2819     TCanvas *c_recbjet_lmis_pt = new TCanvas("","", 800, 600);
    2820 
    2821     mg_recbjet_lmis_pt->Draw("APE");
    2822    
    2823     DrawAxis(mg_recbjet_lmis_pt, leg_recbjet_lmis_pt, ptMin, ptMax, 0.0, 1.0, "p_{T} [GeV]", "light - mistag rate (%)", true, false);
    2824    
    2825     leg_recbjet_lmis_pt->Draw();
    2826     pave->Draw();
    2827 
    2828     c_recbjet_lmis_pt->Print(pdfOutput,"pdf");
    2829     c_recbjet_lmis_pt->Print(figPath+"img_recbjet_lmis_pt.pdf","pdf");
    2830     c_recbjet_lmis_pt->Print(figPath+"img_recbjet_lmis_pt.png","png");
    2831 
    2832     TCanvas *c_recbjet_lmis_eta = new TCanvas("","", 800, 600);
    2833 
    2834     mg_recbjet_lmis_eta->Draw("APE");
    2835     DrawAxis(mg_recbjet_lmis_eta, leg_recbjet_lmis_eta, etaMin, etaMax, 0.0, 1.0, " #eta ", "light - mistag rate (%)", false, false);
    2836     leg_recbjet_lmis_eta->Draw();
    2837     pave->Draw();
    2838 
    2839     c_recbjet_lmis_eta->Print(pdfOutput,"pdf");
    2840     c_recbjet_lmis_eta->Print(figPath+"img_recbjet_lmis_eta.pdf","pdf");
    2841     c_recbjet_lmis_eta->Print(figPath+"img_recbjet_lmis_eta.png","png");
    2842 
    2843 
    2844     ///////////////////////////////////////////
    2845     // tau-jets  Efficiency/ mistag rates   ///
    2846     ///////////////////////////////////////////
    2847 
    2848     TMultiGraph *mg_rectaujet_eff_pt  = new TMultiGraph("","");
    2849     TMultiGraph *mg_rectaujet_eff_eta = new TMultiGraph("","");
    2850 
    2851     TLegend *leg_rectaujet_eff_pt  = new TLegend(0.50,0.22,0.90,0.48);
    2852     TLegend *leg_rectaujet_eff_eta = new TLegend(0.50,0.22,0.90,0.48);
    2853 
    2854     TGraphErrors *gr_rectaujet_eff_pt  = new TGraphErrors[n_etabins];
    2855     TGraphErrors *gr_rectaujet_eff_eta = new TGraphErrors[n_ptbins];
    2856     TH1D* h_rectaujet_eff_pt, *h_rectaujet_eff_eta;
    2857 
    2858     // loop over eta bins
    2859     for (k = 0; k < etaVals.size()-1; k++)
    2860     {
    2861 
    2862        h_rectaujet_eff_pt = GetTauEffPt<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderTauJet);
    2863        gr_rectaujet_eff_pt[k] = TGraphErrors(h_rectaujet_eff_pt);
    2864 
    2865        s_etaMin = Form("%.1f",etaVals.at(k));
    2866        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2867 
    2868        s_eta = "#tau-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2869 
    2870        gr_rectaujet_eff_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2871 
    2872        addResoGraph(mg_rectaujet_eff_pt, &gr_rectaujet_eff_pt[k], leg_rectaujet_eff_pt, markerStyles.at(k), colors.at(k), s_eta);
    2873     }
    2874 
    2875     // loop over pt
    2876     for (k = 0; k < ptVals.size(); k++)
    2877     {
    2878        h_rectaujet_eff_eta = GetTauEffEta<Jet>(branchPFTauJet, branchParticleTauJet, "TauJet", 15, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderTauJet);
    2879        gr_rectaujet_eff_eta[k] = TGraphErrors(h_rectaujet_eff_eta);
    2880 
    2881        s_pt = Form("#tau-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2882        if(ptVals.at(k) >= 1000.) s_pt = Form("#tau-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2883 
    2884        addResoGraph(mg_rectaujet_eff_eta, &gr_rectaujet_eff_eta[k], leg_rectaujet_eff_eta, markerStyles.at(k), colors.at(k), s_pt );
    2885     }
    2886 
    2887 
    2888     TCanvas *c_rectaujet_eff_pt = new TCanvas("","", 800, 600);
    2889 
    2890     mg_rectaujet_eff_pt->Draw("APE");
    2891     DrawAxis(mg_rectaujet_eff_pt, leg_rectaujet_eff_pt, ptMin, ptMax, 0.0, 100, "p_{T} [GeV]", "#tau - tag efficiency (%)", true, false);
    2892     leg_rectaujet_eff_pt->Draw();
    2893     pave->Draw();
    2894 
    2895     c_rectaujet_eff_pt->Print(pdfOutput,"pdf");
    2896     c_rectaujet_eff_pt->Print(figPath+"img_rectaujet_eff_pt.pdf","pdf");
    2897     c_rectaujet_eff_pt->Print(figPath+"img_rectaujet_eff_pt.png","png");
    2898 
    2899     TCanvas *c_rectaujet_eff_eta = new TCanvas("","", 800, 600);
    2900 
    2901     mg_rectaujet_eff_eta->Draw("APE");
    2902     DrawAxis(mg_rectaujet_eff_eta, leg_rectaujet_eff_eta, etaMin, etaMax, 0.0, 100., " #eta ", "#tau - tag efficiency (%)", false, false);
    2903     leg_rectaujet_eff_eta->Draw();
    2904     pave->Draw();
    2905 
    2906     c_rectaujet_eff_eta->Print(pdfOutput,"pdf");
    2907     c_rectaujet_eff_eta->Print(figPath+"img_rectaujet_eff_eta.pdf","pdf");
    2908     c_rectaujet_eff_eta->Print(figPath+"img_rectaujet_eff_eta.png","png");
    2909 
    2910 
    2911     //--------------- tau mistag rate ----------
    2912 
    2913     TMultiGraph *mg_rectaujet_mis_pt  = new TMultiGraph("","");
    2914     TMultiGraph *mg_rectaujet_mis_eta = new TMultiGraph("","");
    2915 
    2916     TLegend *leg_rectaujet_mis_pt  = new TLegend(0.50,0.64,0.90,0.90);
    2917     TLegend *leg_rectaujet_mis_eta = new TLegend(0.50,0.64,0.90,0.90);
    2918 
    2919     TGraphErrors *gr_rectaujet_mis_pt  = new TGraphErrors[n_etabins];
    2920     TGraphErrors *gr_rectaujet_mis_eta = new TGraphErrors[n_ptbins];
    2921     TH1D* h_rectaujet_mis_pt, *h_rectaujet_mis_eta;
    2922 
    2923     // loop over eta bins
    2924     for (k = 0; k < etaVals.size()-1; k++)
    2925     {
    2926 
    2927        h_rectaujet_mis_pt = GetTauEffPt<Jet>(branchJet, branchParticleJet, "TauJet", 1, ptMin, ptMax, etaVals.at(k), etaVals.at(k+1), treeReaderJet);
    2928        gr_rectaujet_mis_pt[k] = TGraphErrors(h_rectaujet_mis_pt);
    2929 
    2930        s_etaMin = Form("%.1f",etaVals.at(k));
    2931        s_etaMax = Form("%.1f",etaVals.at(k+1));
    2932 
    2933        s_eta = "uds-jet , " + s_etaMin + " < | #eta | < "+s_etaMax;
    2934 
    2935        gr_rectaujet_mis_pt[k].SetName("recEff_"+s_etaMin+"_"+s_etaMax);
    2936 
    2937        addResoGraph(mg_rectaujet_mis_pt, &gr_rectaujet_mis_pt[k], leg_rectaujet_mis_pt, markerStyles.at(k), colors.at(k), s_eta);
    2938     }
    2939 
    2940     // loop over pt
    2941     for (k = 0; k < ptVals.size(); k++)
    2942     {
    2943        h_rectaujet_mis_eta = GetTauEffEta<Jet>(branchJet, branchParticleJet, "TauJet", 1, 0.5*ptVals.at(k), 2.0*ptVals.at(k) ,etaMin, etaMax , treeReaderJet);
    2944        gr_rectaujet_mis_eta[k] = TGraphErrors(h_rectaujet_mis_eta);
    2945 
    2946        s_pt = Form("uds-jet , p_{T} = %.0f GeV",ptVals.at(k));
    2947        if(ptVals.at(k) >= 1000.) s_pt = Form("uds-jet , p_{T} = %.0f TeV",ptVals.at(k)/1000.);
    2948 
    2949        addResoGraph(mg_rectaujet_mis_eta, &gr_rectaujet_mis_eta[k], leg_rectaujet_mis_eta, markerStyles.at(k), colors.at(k), s_pt );
    2950     }
    2951 
    2952     TCanvas *c_rectaujet_mis_pt = new TCanvas("","", 800, 600);
    2953 
    2954     mg_rectaujet_mis_pt->Draw("APE");
    2955     DrawAxis(mg_rectaujet_mis_pt, leg_rectaujet_mis_pt, ptMin, ptMax, 0.0, 5., "p_{T} [GeV]", "#tau - mistag(%)", true, false);
    2956     leg_rectaujet_mis_pt->Draw();
    2957     pave->Draw();
    2958 
    2959     c_rectaujet_mis_pt->Print(pdfOutput,"pdf");
    2960     c_rectaujet_mis_pt->Print(figPath+"img_rectaujet_mis_pt.pdf","pdf");
    2961     c_rectaujet_mis_pt->Print(figPath+"img_rectaujet_mis_pt.png","png");
    2962 
    2963     TCanvas *c_rectaujet_mis_eta = new TCanvas("","", 800, 600);
    2964 
    2965     mg_rectaujet_mis_eta->Draw("APE");
    2966     DrawAxis(mg_rectaujet_mis_eta, leg_rectaujet_mis_eta, etaMin, etaMax, 0.0, 5., " #eta ", "#tau - mistag (%)", false, false);
    2967     leg_rectaujet_mis_eta->Draw();
    2968     pave->Draw();
    2969 
    2970     c_rectaujet_mis_eta->Print(pdfOutput+")","pdf");
    2971     c_rectaujet_mis_eta->Print(figPath+"img_rectaujet_mis_eta.pdf","pdf");
    2972     c_rectaujet_mis_eta->Print(figPath+"img_rectaujet_mis_eta.png","png");
    2973 
    2974 
    2975 //   ----   store resolution histograms in the output (for leave efficiencies out) ---
    2976 
    2977 
    2978   TFile *fout = new TFile(outputFile,"recreate");
    2979 
    2980   for (int bin = 0; bin < Nbins; bin++)
    2981   {
    2982 
    2983     for (k = 0; k < etaVals.size()-1; k++)
    2984     {
    2985        plots_trkpi_res_pt[k].at(bin).resolHist->Write();
    2986        plots_trkele_res_pt[k].at(bin).resolHist->Write();
    2987        plots_trkmu_res_pt[k].at(bin).resolHist->Write();
    2988        plots_ecal_res_e[k].at(bin).resolHist->Write();
    2989        plots_hcal_res_e[k].at(bin).resolHist->Write();
    2990        plots_pfele_res_e[k].at(bin).resolHist->Write();
    2991        plots_pfpi_res_e[k].at(bin).resolHist->Write();
    2992        plots_pfjet_res_e[k].at(bin).resolHist->Write();
    2993        plots_cajet_res_e[k].at(bin).resolHist->Write();
    2994 
    2995     }
    2996 
    2997     for (k = 0; k < ptVals.size(); k++)
    2998     {
    2999        plots_trkpi_res_eta[k].at(bin).resolHist->Write();
    3000        plots_trkele_res_eta[k].at(bin).resolHist->Write();
    3001        plots_trkmu_res_eta[k].at(bin).resolHist->Write();
    3002        plots_ecal_res_eta[k].at(bin).resolHist->Write();
    3003        plots_hcal_res_eta[k].at(bin).resolHist->Write();
    3004        plots_pfele_res_eta[k].at(bin).resolHist->Write();
    3005        plots_pfpi_res_eta[k].at(bin).resolHist->Write();
    3006        plots_pfjet_res_eta[k].at(bin).resolHist->Write();
    3007        plots_cajet_res_eta[k].at(bin).resolHist->Write();
    3008 
     2931      plots_trkpi_res_eta[k].at(bin).resolHist->Write();
     2932      plots_trkele_res_eta[k].at(bin).resolHist->Write();
     2933      plots_trkmu_res_eta[k].at(bin).resolHist->Write();
     2934      plots_ecal_res_eta[k].at(bin).resolHist->Write();
     2935      plots_hcal_res_eta[k].at(bin).resolHist->Write();
     2936      plots_pfele_res_eta[k].at(bin).resolHist->Write();
     2937      plots_pfpi_res_eta[k].at(bin).resolHist->Write();
     2938      plots_pfjet_res_eta[k].at(bin).resolHist->Write();
     2939      plots_cajet_res_eta[k].at(bin).resolHist->Write();
    30092940    }
    30102941
    30112942    plots_pfmet.at(bin).resolHist->Write();
    30122943    plots_camet.at(bin).resolHist->Write();
    3013 
    30142944  }
    30152945
    30162946  fout->Write();
    3017 
    30182947
    30192948  cout << "** Exiting..." << endl;
     
    30652994  DelphesValidation(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11]);
    30662995}
    3067 
    3068 
    3069 
Note: See TracChangeset for help on using the changeset viewer.