Fork me on GitHub

Changes in / [0e7d64a:e39abb4] in git


Ignore:
Files:
7 deleted
217 edited

Legend:

Unmodified
Added
Removed
  • .circleci/config.yml

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

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

    r0e7d64a re39abb4  
    1 3.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 
    2113.4.1:
    222- added RadiusMax and HalfLengthMax to ParticlePropagator to keep decay products of the long-lived particles (#1084)
     
    244- improved CMake configuration
    255- fixed weights in LHEFReader
    26 - fixed bug in Charged Hadron Subtraction (CHS)
     6- fixed bug in Charged Hadron Subtraction (CHS) 
    277- promoted z vertex resolution to TFormula
    288- fixed bugs in DelphesDisplay
  • Makefile

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

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

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

    r0e7d64a re39abb4  
    1 3.4.2
     13.4.1
  • cards/FCC/FCChh.tcl

    r0e7d64a re39abb4  
    12391239
    12401240  (pt <= 10.0)                                                       * (0.00) +
    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.) + \
     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.) + \
    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.65) + \
    1245   (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 5000.0 && pt < 34000.0) * (0.65)*(8./9. - pt/30000.) + \
     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.) + \
    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

    r0e7d64a re39abb4  
    11#######################################
    22# CLICdet model
    3 # based on arXiv:1812.07337 and
    4 # CLICdp-Note-2017-001
    5 #
     3# based on CLICdp-Note-2017-001
    64# Ulrike Schnoor ulrike.schnoor@cern.ch
    75#
     
    1311# according to final state
    1412#
    15 # c-tagging capabilities of CLICdet are
    16 # not yet implemented here. Please
    17 # contact us if you want to use it.
    18 #######################################
    19 
    2013#######################################
    2114# Order of execution of various modules
     
    714707    set OutputArray photons
    715708
    716     set DeltaRMax 0.1
     709    set DeltaRMax 0.5
    717710
    718711    set PTMin 0.5
    719712
    720     set PTRatioMax 0.2
     713    set PTRatioMax 0.12
    721714}
    722715
     
    812805    set OutputArray electrons
    813806
    814     set DeltaRMax 0.1
     807    set DeltaRMax 0.5
    815808
    816809    set PTMin 0.5
    817810
    818     set PTRatioMax 0.2
     811    set PTRatioMax 0.12
    819812}
    820813
     
    851844    set OutputArray muons
    852845
    853     set DeltaRMax 0.1
     846    set DeltaRMax 0.5
    854847
    855848    set PTMin 0.5
    856849
    857     set PTRatioMax 0.2
     850    set PTRatioMax 0.25
    858851}
    859852
  • cards/delphes_card_CLICdet_Stage2.tcl

    r0e7d64a re39abb4  
    11#######################################
    22# CLICdet model
    3 # based on arXiv:1812.07337 and
    4 # CLICdp-Note-2017-001
    5 #
     3# based on CLICdp-Note-2017-001
    64# Ulrike Schnoor ulrike.schnoor@cern.ch
    75#
     
    1311# according to final state
    1412#
    15 # c-tagging capabilities of CLICdet are
    16 # not yet implemented here. Please
    17 # contact us if you want to use it.
    18 #######################################
    19 
    2013#######################################
    2114# Order of execution of various modules
     
    131124
    132125    JetFlavorAssociation_R05N2
    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
     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
    281237    BTaggingWP50_R05_inclusive
    282238    BTaggingWP70_R05_inclusive
     
    295251    BTaggingWP90_R15_inclusive
    296252
    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    
    390253   
    391254    TauTagging_R05N2
     
    414277    TauTagging_R15N5
    415278    TauTagging_R15N6
     279
    416280    TauTagging_R05_inclusive
    417281    TauTagging_R07_inclusive
     
    419283    TauTagging_R12_inclusive
    420284    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
    452285
    453286
     
    906739    set OutputArray photons
    907740
    908     set DeltaRMax 0.1
     741    set DeltaRMax 0.5
    909742
    910743    set PTMin 0.5
    911744
    912     set PTRatioMax 0.2
     745    set PTRatioMax 0.12
    913746}
    914747
     
    1004837    set OutputArray electrons
    1005838
    1006     set DeltaRMax 0.1
     839    set DeltaRMax 0.5
    1007840
    1008841    set PTMin 0.5
    1009842
    1010     set PTRatioMax 0.2
     843    set PTRatioMax 0.12
    1011844}
    1012845
     
    1042875    set OutputArray muons
    1043876
    1044     set DeltaRMax 0.1
     877    set DeltaRMax 0.5
    1045878
    1046879    set PTMin 0.5
    1047880
    1048     set PTRatioMax 0.2
     881    set PTRatioMax 0.25
    1049882}
    1050883
     
    11671000
    11681001source  CLIC/CLICdet_JetFlavorAssociation.tcl
    1169 source  CLIC/CLICdet_JetFlavorAssociation_JER.tcl
    11701002
    11711003###########
     
    11751007
    11761008source  CLIC/CLICdet_BTagging.tcl
    1177 source  CLIC/CLICdet_BTagging_JER.tcl
    11781009
    11791010
     
    11841015
    11851016source CLIC/CLICdet_TauTagging.tcl
    1186 source CLIC/CLICdet_TauTagging_JER.tcl
    11871017
    11881018
  • cards/delphes_card_CLICdet_Stage3.tcl

    r0e7d64a re39abb4  
    11#######################################
    22# CLICdet model
    3 # based on arXiv:1812.07337 and
    4 # CLICdp-Note-2017-001
    5 #
     3# based on CLICdp-Note-2017-001
    64# Ulrike Schnoor ulrike.schnoor@cern.ch
     5#
    76#
    87# For the high energy stage of
     
    1211# use exclusive clustering with njets
    1312# according to final state
    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 
     13#
    2014#######################################
    2115# Order of execution of various modules
     
    131125
    132126    JetFlavorAssociation_R05N2
    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
     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
    279238    BTaggingWP50_R05_inclusive
    280239    BTaggingWP70_R05_inclusive
     
    293252    BTaggingWP90_R15_inclusive
    294253
    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      
     254   
    386255    TauTagging_R05N2
    387256    TauTagging_R05N3
     
    409278    TauTagging_R15N5
    410279    TauTagging_R15N6
     280
    411281    TauTagging_R05_inclusive
    412282    TauTagging_R07_inclusive
     
    415285    TauTagging_R15_inclusive
    416286
    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
    447287
    448288
     
    890730}
    891731
    892 
    893732##################
    894733# Photon isolation
     
    901740    set OutputArray photons
    902741
    903     set DeltaRMax 0.1
     742    set DeltaRMax 0.5
    904743
    905744    set PTMin 0.5
    906745
    907     set PTRatioMax 0.2
    908 }
    909 
     746    set PTRatioMax 0.12
     747}
    910748
    911749#####################
     
    1000838    set OutputArray electrons
    1001839
    1002     set DeltaRMax 0.1
     840    set DeltaRMax 0.5
    1003841
    1004842    set PTMin 0.5
    1005843
    1006     set PTRatioMax 0.2
     844    set PTRatioMax 0.12
    1007845}
    1008846
     
    1038876    set OutputArray muons
    1039877
    1040     set DeltaRMax 0.1
     878    set DeltaRMax 0.5
    1041879
    1042880    set PTMin 0.5
    1043881
    1044     set PTRatioMax 0.2
     882    set PTRatioMax 0.25
    1045883}
    1046884
     
    11651003
    11661004source  CLIC/CLICdet_JetFlavorAssociation.tcl
    1167 source  CLIC/CLICdet_JetFlavorAssociation_JER.tcl
    11681005
    11691006###########
     
    11731010
    11741011source  CLIC/CLICdet_BTagging.tcl
    1175 source  CLIC/CLICdet_BTagging_JER.tcl
    11761012
    11771013
     
    11821018
    11831019source CLIC/CLICdet_TauTagging.tcl
    1184 source CLIC/CLICdet_TauTagging_JER.tcl
    11851020
    11861021
  • classes/DelphesClasses.cc

    r0e7d64a re39abb4  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
     18
    1819
    1920/**
     
    121122  Charge(0), Mass(0.0),
    122123  IsPU(0), IsRecoPU(0), IsConstituent(0), IsFromConversion(0),
     124  ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0),
    123125  Flavor(0), FlavorAlgo(0), FlavorPhys(0),
    124126  BTag(0), BTagAlgo(0), BTagPhys(0),
     
    127129  Momentum(0.0, 0.0, 0.0, 0.0),
    128130  Position(0.0, 0.0, 0.0, 0.0),
     131  PositionError(0.0, 0.0, 0.0, 0.0),
    129132  InitialPosition(0.0, 0.0, 0.0, 0.0),
    130   PositionError(0.0, 0.0, 0.0, 0.0),
    131133  Area(0.0, 0.0, 0.0, 0.0),
    132134  L(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),
     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), 
    140142  TrackResolution(0),
    141143  NCharged(0),
     
    152154  SumPtChargedPU(-999),
    153155  SumPt(-999),
    154   ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0),
    155156  NSubJetsTrimmed(0),
    156157  NSubJetsPruned(0),
     
    235236  return kFALSE;
    236237}
     238
    237239
    238240//------------------------------------------------------------------------------
     
    302304  object.PT = PT;
    303305  object.ErrorPT = ErrorPT;
    304   object.CtgTheta = CtgTheta;
     306  object.CtgTheta = CtgTheta ;
    305307  object.ErrorCtgTheta = ErrorCtgTheta;
    306308  object.Phi = Phi;
    307   object.ErrorPhi = ErrorPhi;
     309  object.ErrorPhi = ErrorPhi; 
    308310  object.Xd = Xd;
    309311  object.Yd = Yd;
     
    325327  object.ClusterIndex = ClusterIndex;
    326328  object.ClusterNDF = ClusterNDF;
    327   object.ClusterSigma = ClusterSigma;
     329  object.ClusterSigma = ClusterSigma; 
    328330  object.SumPT2 = SumPT2;
    329 
     331 
    330332  object.FracPt[0] = FracPt[0];
    331333  object.FracPt[1] = FracPt[1];
     
    359361  object.NSubJetsSoftDropped = NSubJetsSoftDropped;
    360362
    361   object.SoftDroppedJet = SoftDroppedJet;
     363  object.SoftDroppedJet =SoftDroppedJet;
    362364  object.SoftDroppedSubJet1 = SoftDroppedSubJet1;
    363365  object.SoftDroppedSubJet2 = SoftDroppedSubJet2;
     
    382384//------------------------------------------------------------------------------
    383385
    384 void Candidate::Clear(Option_t *option)
     386void Candidate::Clear(Option_t* option)
    385387{
    386388  int i;
     
    389391  PID = 0;
    390392  Status = 0;
    391   M1 = -1;
    392   M2 = -1;
    393   D1 = -1;
    394   D2 = -1;
     393  M1 = -1; M2 = -1; D1 = -1; D2 = -1;
    395394  Charge = 0;
    396395  Mass = 0.0;
     
    421420  L = 0.0;
    422421  ErrorT = 0.0;
    423   D0 = 0.0;
     422  D0 = 0.0; 
    424423  ErrorD0 = 0.0;
    425424  DZ = 0.0;
    426425  ErrorDZ = 0.0;
    427   P = 0.0;
    428   ErrorP = 0.0;
     426  P =0.0;
     427  ErrorP =0.0;
    429428  PT = 0.0;
    430429  ErrorPT = 0.0;
     
    456455  ClusterIndex = -1;
    457456  ClusterNDF = -99;
    458   ClusterSigma = 0.0;
     457  ClusterSigma = 0.0; 
    459458  SumPT2 = 0.0;
    460459  BTVSumPT2 = 0.0;
    461460  GenDeltaZ = 0.0;
    462   GenSumPT2 = 0.0;
    463 
     461  GenSumPT2 = 0.0; 
     462 
    464463  FracPt[0] = 0.0;
    465464  FracPt[1] = 0.0;
     
    477476  SoftDroppedSubJet2.SetXYZT(0.0, 0.0, 0.0, 0.0);
    478477
     478
    479479  for(i = 0; i < 5; ++i)
    480480  {
  • classes/DelphesClasses.h

    r0e7d64a re39abb4  
    3232// Dependencies (#includes)
    3333
     34#include "TRef.h"
     35#include "TObject.h"
     36#include "TRefArray.h"
    3437#include "TLorentzVector.h"
    35 #include "TObject.h"
    36 #include "TRef.h"
    37 #include "TRefArray.h"
    3838
    3939#include "classes/SortableObject.h"
     
    4646{
    4747public:
     48
    4849  Long64_t Number; // event number
    4950
     
    5960{
    6061public:
     62
    6163  Int_t Trigger; // trigger word
    6264
     
    6971{
    7072public:
     73
    7174  Int_t ProcessID; // subprocess code for the event | hepup.IDPRUP
    7275
     
    7780  Float_t AlphaQCD; // value of the QCD coupling used in the event | hepup.AQCDUP
    7881
    79   ClassDef(LHEFEvent, 3)
     82  ClassDef(LHEFEvent, 2)
    8083};
    8184
     
    9699{
    97100public:
     101
    98102  Int_t ProcessID; // unique signal process id | signal_process_id()
    99103  Int_t MPI; // number of multi parton interactions | mpi ()
     
    118122  Float_t PDF2; // PDF (id2, x2, Q) | pdf_info()->pdf2()
    119123
    120   ClassDef(HepMCEvent, 3)
     124
     125
     126  ClassDef(HepMCEvent, 2)
    121127};
    122128
     
    175181{
    176182public:
     183
    177184  Float_t T; // vertex position (t component)
    178185  Float_t X; // vertex position (x component)
     
    253260{
    254261public:
     262
    255263  Float_t PT; // photon transverse momentum
    256264  Float_t Eta; // photon pseudorapidity
     
    279287  TLorentzVector P4() const;
    280288
    281   ClassDef(Photon, 4)
     289  ClassDef(Photon, 3)
    282290};
    283291
     
    287295{
    288296public:
     297
    289298  Float_t PT; // electron transverse momentum
    290299  Float_t Eta; // electron pseudorapidity
     
    306315  Float_t SumPt; // isolation variable
    307316
    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)
     317  static CompBase *fgCompare; //!
     318  const CompBase *GetCompare() const { return fgCompare; }
     319
     320  TLorentzVector P4() const;
     321
     322  ClassDef(Electron, 3)
    319323};
    320324
     
    324328{
    325329public:
     330
    326331  Float_t PT; // muon transverse momentum
    327332  Float_t Eta; // muon pseudorapidity
     
    341346  Float_t SumPt; // isolation variable
    342347
    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)
     348  static CompBase *fgCompare; //!
     349  const CompBase *GetCompare() const { return fgCompare; }
     350
     351  TLorentzVector P4() const;
     352
     353  ClassDef(Muon, 3)
    354354};
    355355
     
    359359{
    360360public:
     361
    361362  Float_t PT; // jet transverse momentum
    362363  Float_t Eta; // jet pseudorapidity
     
    367368  Float_t Mass; // jet invariant mass
    368369
    369   Float_t DeltaEta; // jet radius in pseudorapidity
    370   Float_t DeltaPhi; // jet radius in azimuthal angle
     370  Float_t DeltaEta;  // jet radius in pseudorapidity
     371  Float_t DeltaPhi;  // jet radius in azimuthal angle
    371372
    372373  UInt_t Flavor; // jet flavor
     
    403404  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
    404405
     406
    405407  Int_t NSubJetsTrimmed; // number of subjets trimmed
    406408  Int_t NSubJetsPruned; // number of subjets pruned
     
    411413  Double_t ExclYmerge45;
    412414  Double_t ExclYmerge56;
    413 
     415 
    414416  TRefArray Constituents; // references to constituents
    415417  TRefArray Particles; // references to generated particles
     
    421423  TLorentzVector Area;
    422424
    423   ClassDef(Jet, 4)
     425  ClassDef(Jet, 3)
    424426};
    425427
     
    614616
    615617  Int_t NTimeHits;
    616   std::vector<std::pair<Float_t, Float_t> > ECalEnergyTimePairs;
     618  std::vector< std::pair< Float_t, Float_t > > ECalEnergyTimePairs;
    617619
    618620  // Isolation variables
     
    658660  Double_t ExclYmerge45;
    659661  Double_t ExclYmerge56;
    660 
     662     
    661663  static CompBase *fgCompare; //!
    662664  const CompBase *GetCompare() const { return fgCompare; }
     
    669671  virtual void Copy(TObject &object) const;
    670672  virtual TObject *Clone(const char *newname = "") const;
    671   virtual void Clear(Option_t *option = "");
     673  virtual void Clear(Option_t* option = "");
    672674
    673675private:
     
    677679  void SetFactory(DelphesFactory *factory) { fFactory = factory; }
    678680
    679   ClassDef(Candidate, 6)
     681  ClassDef(Candidate, 5)
    680682};
    681683
    682684#endif // DelphesClasses_h
     685
     686
  • classes/DelphesCylindricalFormula.cc

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

    r0e7d64a re39abb4  
    2525{
    2626public:
     27
    2728  DelphesCylindricalFormula();
    2829
     
    3738
    3839#endif /* DelphesCylindricalFormula_h */
     40
  • classes/DelphesFactory.cc

    r0e7d64a re39abb4  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
     18
    1819
    1920/** \class DelphesFactory
     
    5051  if(fObjArrays) delete fObjArrays;
    5152
    52   map<const TClass *, ExRootTreeBranch *>::iterator itBranches;
     53  map< const TClass*, ExRootTreeBranch* >::iterator itBranches;
    5354  for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
    5455  {
    55     delete(itBranches->second);
     56    delete (itBranches->second);
    5657  }
    5758}
     
    5960//------------------------------------------------------------------------------
    6061
    61 void DelphesFactory::Clear(Option_t *option)
     62void DelphesFactory::Clear(Option_t* option)
    6263{
    6364  set<TObject *>::iterator itPool;
     
    6970  TProcessID::SetObjectCount(0);
    7071
    71   map<const TClass *, ExRootTreeBranch *>::iterator itBranches;
     72  map< const TClass*, ExRootTreeBranch* >::iterator itBranches;
    7273  for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
    7374  {
     
    119120
    120121//------------------------------------------------------------------------------
     122
  • classes/DelphesFactory.h

    r0e7d64a re39abb4  
    4242{
    4343public:
     44 
    4445  DelphesFactory(const char *name = "ObjectFactory");
    4546  ~DelphesFactory();
    4647
    47   virtual void Clear(Option_t *option = "");
    48 
     48  virtual void Clear(Option_t* option = "");
     49 
    4950  TObjArray *NewPermanentArray();
    5051
     
    5556  TObject *New(TClass *cl);
    5657
    57   template <typename T>
     58  template<typename T>
    5859  T *New() { return static_cast<T *>(New(T::Class())); }
    5960
    6061private:
     62
    6163  ExRootTreeBranch *fObjArrays; //!
    6264
    6365#if !defined(__CINT__) && !defined(__CLING__)
    64   std::map<const TClass *, ExRootTreeBranch *> fBranches; //!
     66  std::map< const TClass*, ExRootTreeBranch* > fBranches; //!
    6567#endif
    6668
    67   std::set<TObject *> fPool; //!
    68 
     69  std::set< TObject* > fPool; //!
     70 
    6971  ClassDef(DelphesFactory, 1)
    7072};
    7173
    7274#endif /* DelphesFactory */
     75
  • classes/DelphesFormula.cc

    r0e7d64a re39abb4  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
     18
    1819
    1920#include "classes/DelphesFormula.h"
     
    5354  for(it = expression; *it; ++it)
    5455  {
    55     if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
     56    if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
    5657    buffer.Append(*it);
    5758  }
     
    6061  buffer.ReplaceAll("phi", "z");
    6162  buffer.ReplaceAll("energy", "t");
    62   buffer.ReplaceAll("d0", "[0]");
    63   buffer.ReplaceAll("dz", "[1]");
    64   buffer.ReplaceAll("ctgTheta", "[2]");
    6563
    66 #if ROOT_VERSION_CODE < ROOT_VERSION(6, 3, 0)
    67   TFormula::SetMaxima(100000, 1000, 1000000);
    68 #endif
    6964
     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,
    80   Double_t energy, Double_t d0, Double_t dz,
    81   Double_t ctgTheta)
     79Double_t DelphesFormula::Eval(Double_t pt, Double_t eta, Double_t phi, Double_t energy)
    8280{
    83   Double_t x[4] = {pt, eta, phi, energy};
    84   Double_t params[3] = {d0, dz, ctgTheta};
    85   return EvalPar(x, params);
     81   Double_t x[4] = {pt, eta, phi, energy};
     82   return EvalPar(x);
    8683}
    8784
  • classes/DelphesFormula.h

    r0e7d64a re39abb4  
    2525{
    2626public:
     27
    2728  DelphesFormula();
    2829
     
    3334  Int_t Compile(const char *expression);
    3435
    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);
     36  Double_t Eval(Double_t pt, Double_t eta = 0, Double_t phi = 0, Double_t energy = 0);
    3837};
    3938
    4039#endif /* DelphesFormula_h */
     40
  • classes/DelphesHepMCReader.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesHepMCReader
    2021 *
     
    2728#include "classes/DelphesHepMCReader.h"
    2829
     30#include <stdexcept>
    2931#include <iostream>
    3032#include <sstream>
    31 #include <stdexcept>
    3233
    3334#include <map>
     
    3637#include <stdio.h>
    3738
     39#include "TObjArray.h"
     40#include "TStopwatch.h"
    3841#include "TDatabasePDG.h"
     42#include "TParticlePDG.h"
    3943#include "TLorentzVector.h"
    40 #include "TObjArray.h"
    41 #include "TParticlePDG.h"
    42 #include "TStopwatch.h"
    4344
    4445#include "classes/DelphesClasses.h"
     
    110111  TObjArray *partonOutputArray)
    111112{
    112   map<int, pair<int, int> >::iterator itMotherMap;
    113   map<int, pair<int, int> >::iterator itDaughterMap;
     113  map< int, pair< int, int > >::iterator itMotherMap;
     114  map< int, pair< int, int > >::iterator itDaughterMap;
    114115  char key, momentumUnit[4], positionUnit[3];
    115116  int i, rc, state;
     
    140141    if(!rc)
    141142    {
    142       cerr << "** ERROR: "
    143            << "invalid event format" << endl;
     143      cerr << "** ERROR: " << "invalid event format" << endl;
    144144      return kFALSE;
    145145    }
     
    155155    if(!rc)
    156156    {
    157       cerr << "** ERROR: "
    158            << "invalid event format" << endl;
     157      cerr << "** ERROR: " << "invalid event format" << endl;
    159158      return kFALSE;
    160159    }
     
    168167    if(!rc)
    169168    {
    170       cerr << "** ERROR: "
    171            << "invalid event format" << endl;
     169      cerr << "** ERROR: " << "invalid event format" << endl;
    172170      return kFALSE;
    173171    }
     
    179177    if(rc != 2)
    180178    {
    181       cerr << "** ERROR: "
    182            << "invalid units format" << endl;
     179      cerr << "** ERROR: " << "invalid units format" << endl;
    183180      return kFALSE;
    184181    }
     
    192189      fMomentumCoefficient = 0.001;
    193190    }
    194 
     191   
    195192    if(strncmp(positionUnit, "MM", 3) == 0)
    196193    {
     
    202199    }
    203200  }
    204 
     201 
    205202  else if(key == 'C')
    206203  {
     
    208205      && bufferStream.ReadDbl(fCrossSectionError);
    209206  }
    210 
     207 
    211208  else if(key == 'F')
    212209  {
     
    221218    if(!rc)
    222219    {
    223       cerr << "** ERROR: "
    224            << "invalid PDF format" << endl;
     220      cerr << "** ERROR: " << "invalid PDF format" << endl;
    225221      return kFALSE;
    226222    }
     
    239235    if(!rc)
    240236    {
    241       cerr << "** ERROR: "
    242            << "invalid vertex format" << endl;
     237      cerr << "** ERROR: " << "invalid vertex format" << endl;
    243238      return kFALSE;
    244239    }
     
    261256    if(!rc)
    262257    {
    263       cerr << "** ERROR: "
    264            << "invalid particle format" << endl;
     258      cerr << "** ERROR: " << "invalid particle format" << endl;
    265259      return kFALSE;
    266260    }
     
    351345{
    352346  Weight *element;
    353   vector<double>::const_iterator itWeight;
     347  vector< double >::const_iterator itWeight;
    354348
    355349  for(itWeight = fWeight.begin(); itWeight != fWeight.end(); ++itWeight)
     
    380374
    381375  pdgParticle = fPDG->GetParticle(fPID);
    382   candidate->Charge = pdgParticle ? int(pdgParticle->Charge() / 3.0) : -999;
     376  candidate->Charge = pdgParticle ? int(pdgParticle->Charge()/3.0) : -999;
    383377  candidate->Mass = fMass;
    384378
     
    433427{
    434428  Candidate *candidate;
    435   map<int, pair<int, int> >::iterator itMotherMap;
    436   map<int, pair<int, int> >::iterator itDaughterMap;
     429  map< int, pair< int, int > >::iterator itMotherMap;
     430  map< int, pair< int, int > >::iterator itDaughterMap;
    437431  int i;
    438432
  • classes/DelphesHepMCReader.h

    r0e7d64a re39abb4  
    4242{
    4343public:
     44
    4445  DelphesHepMCReader();
    4546  ~DelphesHepMCReader();
     
    6162
    6263private:
     64
    6365  void AnalyzeParticle(DelphesFactory *factory,
    6466    TObjArray *allParticleOutputArray,
     
    8082
    8183  int fStateSize;
    82   std::vector<int> fState;
     84  std::vector< int > fState;
    8385
    8486  int fWeightSize;
    85   std::vector<double> fWeight;
     87  std::vector< double > fWeight;
    8688
    8789  double fCrossSection, fCrossSectionError;
     
    98100  int fParticleCounter;
    99101
    100   std::map<int, std::pair<int, int> > fMotherMap;
    101   std::map<int, std::pair<int, int> > fDaughterMap;
     102  std::map< int, std::pair < int, int > > fMotherMap;
     103  std::map< int, std::pair < int, int > > fDaughterMap;
    102104};
    103105
    104106#endif // DelphesHepMCReader_h
     107
     108
  • classes/DelphesLHEFReader.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesLHEFReader
    2021 *
     
    2728#include "classes/DelphesLHEFReader.h"
    2829
     30#include <stdexcept>
    2931#include <iostream>
    3032#include <sstream>
    31 #include <stdexcept>
    3233
    3334#include <stdio.h>
    3435
     36#include "TObjArray.h"
     37#include "TStopwatch.h"
    3538#include "TDatabasePDG.h"
     39#include "TParticlePDG.h"
    3640#include "TLorentzVector.h"
    37 #include "TObjArray.h"
    38 #include "TParticlePDG.h"
    39 #include "TStopwatch.h"
    4041
    4142#include "classes/DelphesClasses.h"
     
    5354DelphesLHEFReader::DelphesLHEFReader() :
    5455  fInputFile(0), fBuffer(0), fPDG(0),
    55   fEventReady(kFALSE), fEventCounter(-1), fParticleCounter(-1), fCrossSection(1)
     56  fEventReady(kFALSE), fEventCounter(-1), fParticleCounter(-1),   fCrossSection(1)
    5657
    5758{
     
    123124    if(!rc)
    124125    {
    125       cerr << "** ERROR: "
    126            << "invalid event format" << endl;
     126      cerr << "** ERROR: " << "invalid event format" << endl;
    127127      return kFALSE;
    128128    }
     
    148148    if(!rc)
    149149    {
    150       cerr << "** ERROR: "
    151            << "invalid particle format" << endl;
     150      cerr << "** ERROR: " << "invalid particle format" << endl;
    152151      return kFALSE;
    153152    }
     
    163162    if(!pch)
    164163    {
    165       cerr << "** ERROR: "
    166            << "invalid weight format" << endl;
     164      cerr << "** ERROR: " << "invalid weight format" << endl;
    167165      return kFALSE;
    168166    }
     
    174172    if(!pch)
    175173    {
    176       cerr << "** ERROR: "
    177            << "invalid weight format" << endl;
     174      cerr << "** ERROR: " << "invalid weight format" << endl;
    178175      return kFALSE;
    179176    }
     
    184181    if(!rc)
    185182    {
    186       cerr << "** ERROR: "
    187            << "invalid weight format" << endl;
     183      cerr << "** ERROR: " << "invalid weight format" << endl;
    188184      return kFALSE;
    189185    }
     
    196192    if(!pch)
    197193    {
    198       cerr << "** ERROR: "
    199            << "invalid cross section format" << endl;
     194      cerr << "** ERROR: " << "invalid cross section format" << endl;
    200195      return kFALSE;
    201196    }
     
    204199    if(!pch)
    205200    {
    206       cerr << "** ERROR: "
    207            << "invalid cross section format" << endl;
     201      cerr << "** ERROR: " << "invalid cross section format" << endl;
    208202      return kFALSE;
    209203    }
     
    214208    if(!rc)
    215209    {
    216       cerr << "** ERROR: "
    217            << "invalid cross section format" << endl;
     210      cerr << "** ERROR: " << "invalid cross section format" << endl;
    218211      return kFALSE;
    219212    }
     
    256249{
    257250  LHEFWeight *element;
    258   vector<pair<int, double> >::const_iterator itWeightList;
     251  vector< pair< int, double > >::const_iterator itWeightList;
    259252
    260253  for(itWeightList = fWeightList.begin(); itWeightList != fWeightList.end(); ++itWeightList)
     
    286279
    287280  pdgParticle = fPDG->GetParticle(fPID);
    288   candidate->Charge = pdgParticle ? int(pdgParticle->Charge() / 3.0) : -999;
     281  candidate->Charge = pdgParticle ? int(pdgParticle->Charge()/3.0) : -999;
    289282  candidate->Mass = fMass;
    290283
  • classes/DelphesLHEFReader.h

    r0e7d64a re39abb4  
    3030#include <stdio.h>
    3131
     32#include <vector>
    3233#include <utility>
    33 #include <vector>
    3434
    3535class TObjArray;
     
    4242{
    4343public:
     44
    4445  DelphesLHEFReader();
    4546  ~DelphesLHEFReader();
     
    6162
    6263private:
     64
    6365  void AnalyzeParticle(DelphesFactory *factory,
    6466    TObjArray *allParticleOutputArray,
     
    8183  int fPID, fStatus, fM1, fM2, fC1, fC2;
    8284  double fPx, fPy, fPz, fE, fMass;
    83 
    84   std::vector<std::pair<int, double> > fWeightList;
     85 
     86  std::vector< std::pair< int, double > > fWeightList;
    8587};
    8688
    8789#endif // DelphesLHEFReader_h
     90
     91
  • classes/DelphesModule.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesModule
    2021 *
     
    2930#include "classes/DelphesFactory.h"
    3031
     32#include "ExRootAnalysis/ExRootTreeReader.h"
     33#include "ExRootAnalysis/ExRootTreeBranch.h"
     34#include "ExRootAnalysis/ExRootTreeWriter.h"
    3135#include "ExRootAnalysis/ExRootResult.h"
    32 #include "ExRootAnalysis/ExRootTreeBranch.h"
    33 #include "ExRootAnalysis/ExRootTreeReader.h"
    34 #include "ExRootAnalysis/ExRootTreeWriter.h"
    3536
     37#include "TROOT.h"
    3638#include "TClass.h"
    3739#include "TFolder.h"
    3840#include "TObjArray.h"
    39 #include "TROOT.h"
    4041
    4142#include <iostream>
     43#include <stdexcept>
    4244#include <sstream>
    43 #include <stdexcept>
    4445
    4546using namespace std;
     
    156157  return fFactory;
    157158}
     159
     160
  • classes/DelphesModule.h

    r0e7d64a re39abb4  
    4141class DelphesFactory;
    4242
    43 class DelphesModule: public ExRootTask
     43class DelphesModule: public ExRootTask 
    4444{
    4545public:
     46
    4647  DelphesModule();
    4748  ~DelphesModule();
     
    6061
    6162protected:
     63
    6264  ExRootTreeWriter *fTreeWriter;
    6365  DelphesFactory *fFactory;
    6466
    6567private:
     68
    6669  ExRootResult *fPlots;
    6770
     
    7275
    7376#endif /* DelphesModule_h */
     77
  • classes/DelphesPileUpReader.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesPileUpReader
    2021 *
     
    2728#include "classes/DelphesPileUpReader.h"
    2829
     30#include <stdexcept>
    2931#include <iostream>
    3032#include <sstream>
    31 #include <stdexcept>
    3233
     34#include <stdio.h>
    3335#include <stdint.h>
    34 #include <stdio.h>
    3536
    3637#include "classes/DelphesXDRReader.h"
     
    5152  stringstream message;
    5253
    53   fIndex = new uint8_t[kIndexSize * 8];
    54   fBuffer = new uint8_t[kBufferSize * kRecordSize * 4];
     54  fIndex = new uint8_t[kIndexSize*8];
     55  fBuffer = new uint8_t[kBufferSize*kRecordSize*4];
    5556  fInputReader = new DelphesXDRReader;
    5657  fIndexReader = new DelphesXDRReader;
     
    8182
    8283  // read index of events
    83   fseeko(fPileUpFile, -8 - 8 * fEntries, SEEK_END);
    84   fInputReader->ReadRaw(fIndex, fEntries * 8);
     84  fseeko(fPileUpFile, -8 - 8*fEntries, SEEK_END);
     85  fInputReader->ReadRaw(fIndex, fEntries*8);
    8586}
    8687
     
    129130
    130131  // read event position
    131   fIndexReader->SetOffset(8 * entry);
     132  fIndexReader->SetOffset(8*entry);
    132133  fIndexReader->ReadValue(&offset, 8);
    133134
     
    141142  }
    142143
    143   fInputReader->ReadRaw(fBuffer, fEntrySize * kRecordSize * 4);
     144  fInputReader->ReadRaw(fBuffer, fEntrySize*kRecordSize*4);
    144145  fBufferReader->SetOffset(0);
    145146  fCounter = 0;
  • classes/DelphesPileUpReader.h

    r0e7d64a re39abb4  
    2828 */
    2929
     30#include <stdio.h>
    3031#include <stdint.h>
    31 #include <stdio.h>
    3232
    3333class DelphesXDRReader;
     
    3636{
    3737public:
     38
    3839  DelphesPileUpReader(const char *fileName);
    3940
     
    4950
    5051private:
     52
    5153  int64_t fEntries;
    5254
  • classes/DelphesPileUpWriter.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesPileUpWriter
    2021 *
     
    2728#include "classes/DelphesPileUpWriter.h"
    2829
     30#include <stdexcept>
    2931#include <iostream>
    3032#include <sstream>
    31 #include <stdexcept>
    3233
     34#include <stdio.h>
    3335#include <stdint.h>
    34 #include <stdio.h>
    3536
    3637#include "classes/DelphesXDRWriter.h"
     
    5152  stringstream message;
    5253
    53   fIndex = new uint8_t[kIndexSize * 8];
    54   fBuffer = new uint8_t[kBufferSize * kRecordSize * 4];
     54  fIndex = new uint8_t[kIndexSize*8];
     55  fBuffer = new uint8_t[kBufferSize*kRecordSize*4];
    5556  fOutputWriter = new DelphesXDRWriter;
    5657  fIndexWriter = new DelphesXDRWriter;
     
    117118
    118119  fOutputWriter->WriteValue(&fEntrySize, 4);
    119   fOutputWriter->WriteRaw(fBuffer, fEntrySize * kRecordSize * 4);
     120  fOutputWriter->WriteRaw(fBuffer, fEntrySize*kRecordSize*4);
    120121
    121122  fIndexWriter->WriteValue(&fOffset, 8);
    122   fOffset += fEntrySize * kRecordSize * 4 + 4;
     123  fOffset += fEntrySize*kRecordSize*4 + 4;
    123124
    124125  fBufferWriter->SetOffset(0);
     
    132133void DelphesPileUpWriter::WriteIndex()
    133134{
    134   fOutputWriter->WriteRaw(fIndex, fEntries * 8);
     135  fOutputWriter->WriteRaw(fIndex, fEntries*8);
    135136  fOutputWriter->WriteValue(&fEntries, 8);
    136137}
  • classes/DelphesPileUpWriter.h

    r0e7d64a re39abb4  
    2828 */
    2929
     30#include <stdio.h>
    3031#include <stdint.h>
    31 #include <stdio.h>
    3232
    3333class DelphesXDRWriter;
     
    3636{
    3737public:
     38
    3839  DelphesPileUpWriter(const char *fileName);
    3940
     
    4950
    5051private:
     52
    5153  int64_t fEntries;
    5254  int32_t fEntrySize;
  • classes/DelphesSTDHEPReader.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesSTDHEPReader
    2021 *
     
    2728#include "classes/DelphesSTDHEPReader.h"
    2829
     30#include <stdexcept>
    2931#include <iostream>
    3032#include <sstream>
    31 #include <stdexcept>
    32 
     33
     34#include <stdio.h>
    3335#include <errno.h>
    3436#include <stdint.h>
    35 #include <stdio.h>
    3637#include <string.h>
    3738
     39#include "TObjArray.h"
     40#include "TStopwatch.h"
    3841#include "TDatabasePDG.h"
     42#include "TParticlePDG.h"
    3943#include "TLorentzVector.h"
    40 #include "TObjArray.h"
    41 #include "TParticlePDG.h"
    42 #include "TStopwatch.h"
    4344
    4445#include "classes/DelphesClasses.h"
     
    5051using namespace std;
    5152
    52 static const int kBufferSize = 1000000;
     53static const int kBufferSize  = 1000000;
    5354
    5455//---------------------------------------------------------------------------
     
    5758  fInputFile(0), fBuffer(0), fPDG(0), fBlockType(-1)
    5859{
    59   fBuffer = new uint8_t[kBufferSize * 96 + 24];
     60  fBuffer = new uint8_t[kBufferSize*96 + 24];
    6061
    6162  fPDG = TDatabasePDG::Instance();
     
    116117    ReadEventHeader();
    117118  }
    118   else if(fBlockType == MCFIO_STDHEPBEG || fBlockType == MCFIO_STDHEPEND)
     119  else if(fBlockType == MCFIO_STDHEPBEG ||
     120          fBlockType == MCFIO_STDHEPEND)
    119121  {
    120122    ReadSTDCM1();
     
    168170  uint32_t size;
    169171  fReader[0].ReadValue(&size, 4);
    170   SkipBytes(size * elsize);
     172  SkipBytes(size*elsize);
    171173}
    172174
     
    176178{
    177179  uint32_t i;
    178   enum STDHEPVersion
    179   {
    180     UNKNOWN,
    181     V1,
    182     V2,
    183     V21
    184   } version;
     180  enum STDHEPVersion {UNKNOWN, V1, V2, V21} version;
    185181
    186182  // version
    187183  fReader[0].ReadString(fBuffer, 100);
    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;
     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;
    198189
    199190  if(version == UNKNOWN)
     
    372363  // 4 + 4 + 4 + 4 + 4 + 4 = 96*n + 24
    373364
    374   fReader[0].ReadRaw(fBuffer, 96 * fEventSize + 24);
     365  fReader[0].ReadRaw(fBuffer, 96*fEventSize + 24);
    375366
    376367  fReader[1].SetBuffer(fBuffer);
    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);
     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);
    382373
    383374  fReader[1].ReadValue(&idhepSize, 4);
     
    400391  fAlphaQCD = 0.0;
    401392  fScaleSize = 0;
    402   memset(fScale, 0, 10 * sizeof(double));
     393  memset(fScale, 0, 10*sizeof(double));
    403394}
    404395
     
    503494
    504495    pdgParticle = fPDG->GetParticle(pid);
    505     candidate->Charge = pdgParticle ? int(pdgParticle->Charge() / 3.0) : -999;
     496    candidate->Charge = pdgParticle ? int(pdgParticle->Charge()/3.0) : -999;
    506497    candidate->Mass = mass;
    507498
  • classes/DelphesSTDHEPReader.h

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

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesStream
    2021 *
     
    2728#include "classes/DelphesStream.h"
    2829
     30#include <stdlib.h>
     31#include <limits.h>
     32#include <string.h>
     33#include <stdio.h>
    2934#include <errno.h>
    30 #include <limits.h>
    3135#include <math.h>
    32 #include <stdio.h>
    33 #include <stdlib.h>
    34 #include <string.h>
    3536
    3637#include <iostream>
     
    6465    if(fFirstHugePos && value == HUGE_VAL)
    6566    {
    66       fFirstHugePos = false;
     67      fFirstHugePos = false; 
    6768      cout << "** WARNING: too large positive value, return " << value << endl;
    6869    }
    6970    else if(fFirstHugeNeg && value == -HUGE_VAL)
    7071    {
    71       fFirstHugeNeg = false;
     72      fFirstHugeNeg = false; 
    7273      cout << "** WARNING: too large negative value, return " << value << endl;
    7374    }
    7475    else if(fFirstZero)
    7576    {
    76       fFirstZero = false;
     77      fFirstZero = false; 
    7778      value = 0.0;
    7879      cout << "** WARNING: too small value, return " << value << endl;
     
    9394    if(fFirstLongMin && value == LONG_MIN)
    9495    {
    95       fFirstLongMin = false;
     96      fFirstLongMin = false; 
    9697      cout << "** WARNING: too large positive value, return " << value << endl;
    9798    }
    9899    else if(fFirstLongMax && value == LONG_MAX)
    99100    {
    100       fFirstLongMax = false;
     101      fFirstLongMax = false; 
    101102      cout << "** WARNING: too large negative value, return " << value << endl;
    102103    }
  • classes/DelphesStream.h

    r0e7d64a re39abb4  
    3131{
    3232public:
     33
    3334  DelphesStream(char *buffer);
    3435
     
    3738
    3839private:
     40
    3941  char *fBuffer;
    40 
     42 
    4143  static bool fFirstLongMin;
    4244  static bool fFirstLongMax;
     
    4749
    4850#endif // DelphesStream_h
     51
     52
  • classes/DelphesTF2.cc

    r0e7d64a re39abb4  
    3232{
    3333
    34 #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 3, 0)
     34#if ROOT_VERSION_CODE >= ROOT_VERSION(6,04,00)
    3535  fFormula = new TFormula();
    3636#endif
     37
     38
    3739}
    3840
     
    5860  for(it = expression; *it; ++it)
    5961  {
    60     if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\') continue;
     62    if(*it == ' ' || *it == '\t' || *it == '\r' || *it == '\n' || *it == '\\' ) continue;
    6163    buffer.Append(*it);
    6264  }
    6365  buffer.ReplaceAll("z", "x");
    6466  buffer.ReplaceAll("t", "y");
    65 #if ROOT_VERSION_CODE < ROOT_VERSION(6, 3, 0)
     67#if ROOT_VERSION_CODE < ROOT_VERSION(6,04,00)
    6668  if(TF2::Compile(buffer) != 0)
    6769#else
  • classes/DelphesTF2.h

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

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesXDRReader
    2021 *
     
    2728#include "classes/DelphesXDRReader.h"
    2829
     30#include <stdio.h>
    2931#include <stdint.h>
    30 #include <stdio.h>
    3132#include <string.h>
    3233
     
    108109
    109110  if(size > maxSize) size = maxSize;
    110 
     111   
    111112  if(fBuffer)
    112113  {
  • classes/DelphesXDRReader.h

    r0e7d64a re39abb4  
    2828 */
    2929
     30#include <stdio.h>
    3031#include <stdint.h>
    31 #include <stdio.h>
    3232
    3333class DelphesXDRReader
    3434{
    3535public:
     36
    3637  DelphesXDRReader();
    3738
     
    4546
    4647private:
     48
    4749  FILE *fFile;
    4850  uint8_t *fBuffer;
  • classes/DelphesXDRWriter.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DelphesXDRWriter
    2021 *
     
    2728#include "classes/DelphesXDRWriter.h"
    2829
     30#include <stdio.h>
    2931#include <stdint.h>
    30 #include <stdio.h>
    3132#include <string.h>
    3233
  • classes/DelphesXDRWriter.h

    r0e7d64a re39abb4  
    2828 */
    2929
     30#include <stdio.h>
    3031#include <stdint.h>
    31 #include <stdio.h>
    3232
    3333class DelphesXDRWriter
    3434{
    3535public:
     36
    3637  DelphesXDRWriter();
    3738
     
    4445
    4546private:
     47
    4648  FILE *fFile;
    4749  uint8_t *fBuffer;
  • classes/SortableObject.h

    r0e7d64a re39abb4  
    2626 */
    2727
     28#include "TRef.h"
    2829#include "TObject.h"
    29 #include "TRef.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
    4950  Bool_t IsSortable() const { return GetCompare() ? GetCompare()->IsSortable(this) : kFALSE; }
    5051  Int_t Compare(const TObject *obj) const { return GetCompare()->Compare(this, obj); }
     
    6364{
    6465  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 
    9392public:
    9493  static CompPT *Instance()
     
    10099  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    101100  {
    102     const T *t1 = static_cast<const T *>(obj1);
    103     const T *t2 = static_cast<const T *>(obj2);
     101    const T *t1 = static_cast<const T*>(obj1);
     102    const T *t2 = static_cast<const T*>(obj2);
    104103    if(t1->PT > t2->PT)
    105104      return -1;
     
    117116{
    118117  CompMomentumPt() {}
    119 
    120118public:
    121119  static CompMomentumPt *Instance()
     
    127125  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    128126  {
    129     const T *t1 = static_cast<const T *>(obj1);
    130     const T *t2 = static_cast<const T *>(obj2);
     127    const T *t1 = static_cast<const T*>(obj1);
     128    const T *t2 = static_cast<const T*>(obj2);
    131129    if(t1->Momentum.Pt() > t2->Momentum.Pt())
    132130      return -1;
     
    144142{
    145143  CompET() {}
    146 
    147144public:
    148145  static CompET *Instance()
     
    154151  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    155152  {
    156     const T *t1 = static_cast<const T *>(obj1);
    157     const T *t2 = static_cast<const T *>(obj2);
     153    const T *t1 = static_cast<const T*>(obj1);
     154    const T *t2 = static_cast<const T*>(obj2);
    158155    if(t1->ET > t2->ET)
    159156      return -1;
     
    171168{
    172169  CompSumPT2() {}
    173 
    174170public:
    175171  static CompSumPT2 *Instance()
     
    181177  Int_t Compare(const TObject *obj1, const TObject *obj2) const
    182178  {
    183     const T *t1 = static_cast<const T *>(obj1);
    184     const T *t2 = static_cast<const T *>(obj2);
     179    const T *t1 = static_cast<const T*>(obj1);
     180    const T *t2 = static_cast<const T*>(obj2);
    185181    if(t1->SumPT2 > t2->SumPT2)
    186182      return -1;
     
    197193class CompDeltaR: public CompBase
    198194{
    199   CompDeltaR(const T2 *obj = 0) :
    200     fObj(obj) {}
     195  CompDeltaR(const T2 *obj = 0) : fObj(obj) {}
    201196
    202197  Double_t DeltaPhi(Double_t phi1, Double_t phi2)
    203198  {
    204199    Double_t phi = TMath::Abs(phi1 - phi2);
    205     return (phi <= TMath::Pi()) ? phi : (2.0 * TMath::Pi()) - phi;
    206   }
    207 
    208   Double_t Sqr(Double_t x) { return x * x; }
     200    return (phi <= TMath::Pi()) ? phi : (2.0*TMath::Pi()) - phi;
     201  }
     202
     203  Double_t Sqr(Double_t x) { return x*x; }
    209204
    210205  Double_t SumSqr(Double_t a, Double_t b)
     
    212207    Double_t aAbs = TMath::Abs(a);
    213208    Double_t bAbs = TMath::Abs(b);
    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));
     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));
    218211  };
    219212
     
    221214
    222215public:
    223   static CompDeltaR *Instance(const T2 *obj = 0)
    224   {
    225     static CompDeltaR single(obj);
    226     return &single;
     216    static CompDeltaR *Instance(const T2 *obj = 0)
     217  {
     218      static CompDeltaR single(obj);
     219      return &single;
    227220  }
    228221
     
    232225  {
    233226    Double_t eta[3], phi[3], deltaR[2];
    234     const T1 *t1 = static_cast<const T1 *>(obj1);
    235     const T1 *t2 = static_cast<const T1 *>(obj2);
     227    const T1 *t1 = static_cast<const T1*>(obj1);
     228    const T1 *t2 = static_cast<const T1*>(obj2);
    236229
    237230    eta[0] = fObj->Eta;
     
    257250
    258251#endif // SortableObject_h
     252
     253
  • converters/hepmc2pileup.cpp

    r0e7d64a re39abb4  
    1717 */
    1818
     19#include <stdexcept>
    1920#include <iostream>
    2021#include <sstream>
    21 #include <stdexcept>
    2222
    2323#include <signal.h>
    2424
     25#include "TROOT.h"
    2526#include "TApplication.h"
    26 #include "TROOT.h"
    2727
     28#include "TFile.h"
     29#include "TObjArray.h"
     30#include "TStopwatch.h"
    2831#include "TDatabasePDG.h"
    29 #include "TFile.h"
     32#include "TParticlePDG.h"
    3033#include "TLorentzVector.h"
    31 #include "TObjArray.h"
    32 #include "TParticlePDG.h"
    33 #include "TStopwatch.h"
    3434
    3535#include "classes/DelphesClasses.h"
     
    3838#include "classes/DelphesPileUpWriter.h"
    3939
     40#include "ExRootAnalysis/ExRootTreeWriter.h"
     41#include "ExRootAnalysis/ExRootTreeBranch.h"
    4042#include "ExRootAnalysis/ExRootProgressBar.h"
    41 #include "ExRootAnalysis/ExRootTreeBranch.h"
    42 #include "ExRootAnalysis/ExRootTreeWriter.h"
    4343
    4444using namespace std;
     
    7171  if(argc < 2)
    7272  {
    73     cout << " Usage: " << appName << " output_file"
    74          << " [input_file(s)]" << endl;
     73    cout << " Usage: " << appName << " output_file" << " [input_file(s)]" << endl;
    7574    cout << " output_file - output binary pile-up file," << endl;
    7675    cout << " input_file(s) - input file(s) in HepMC format," << endl;
     
    143142      reader->Clear();
    144143      while(reader->ReadBlock(factory, allParticleOutputArray,
    145               stableParticleOutputArray, partonOutputArray)
    146         && !interrupted)
     144        stableParticleOutputArray, partonOutputArray) && !interrupted)
    147145      {
    148146        if(reader->EventReady())
     
    151149
    152150          itParticle->Reset();
    153           while((candidate = static_cast<Candidate *>(itParticle->Next())))
     151          while((candidate = static_cast<Candidate*>(itParticle->Next())))
    154152          {
    155153            const TLorentzVector &position = candidate->Position;
     
    175173
    176174      ++i;
    177     } while(i < argc);
     175    }
     176    while(i < argc);
    178177
    179178    writer->WriteIndex();
  • converters/lhco2root.cpp

    r0e7d64a re39abb4  
    1717 */
    1818
     19#include <stdexcept>
    1920#include <iostream>
    2021#include <sstream>
    21 #include <stdexcept>
    22 
     22
     23#include <stdlib.h>
    2324#include <signal.h>
    2425#include <stdio.h>
    25 #include <stdlib.h>
    26 
     26
     27#include "TROOT.h"
    2728#include "TApplication.h"
    28 #include "TROOT.h"
    29 
     29
     30#include "TFile.h"
     31#include "TObjArray.h"
     32#include "TStopwatch.h"
    3033#include "TDatabasePDG.h"
    31 #include "TFile.h"
     34#include "TParticlePDG.h"
    3235#include "TLorentzVector.h"
    33 #include "TObjArray.h"
    34 #include "TParticlePDG.h"
    35 #include "TStopwatch.h"
    36 
     36
     37#include "modules/Delphes.h"
     38#include "classes/DelphesStream.h"
    3739#include "classes/DelphesClasses.h"
    3840#include "classes/DelphesFactory.h"
    39 #include "classes/DelphesStream.h"
    40 #include "modules/Delphes.h"
    41 
     41
     42#include "ExRootAnalysis/ExRootTreeWriter.h"
     43#include "ExRootAnalysis/ExRootTreeBranch.h"
    4244#include "ExRootAnalysis/ExRootProgressBar.h"
    43 #include "ExRootAnalysis/ExRootTreeBranch.h"
    44 #include "ExRootAnalysis/ExRootTreeWriter.h"
    4545
    4646using namespace std;
    4747
    48 static const int kBufferSize = 1024;
     48static const int kBufferSize  = 1024;
    4949
    5050/*
     
    7474
    7575private:
     76
    7677  void AddMissingEvents();
    7778
     
    8586  void AnalyseMissingET(ExRootTreeBranch *branch);
    8687
    87   enum
    88   {
    89     kIntParamSize = 2,
    90     kDblParamSize = 7
    91   };
     88  enum {kIntParamSize = 2, kDblParamSize = 7};
    9289  Int_t fIntParam[kIntParamSize];
    9390  Double_t fDblParam[kDblParamSize];
     
    109106  ExRootTreeBranch *fBranchJet;
    110107  ExRootTreeBranch *fBranchMissingET;
     108
    111109};
    112110
     
    171169    if(!rc)
    172170    {
    173       cerr << "** ERROR: "
    174            << "invalid event format" << endl;
     171      cerr << "** ERROR: " << "invalid event format" << endl;
    175172      return kFALSE;
    176173    }
     
    198195    if(!rc)
    199196    {
    200       cerr << "** ERROR: "
    201            << "invalid object format" << endl;
     197      cerr << "** ERROR: " << "invalid object format" << endl;
    202198      return kFALSE;
    203199    }
     
    205201    switch(fIntParam[1])
    206202    {
    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;
     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;
    213209    }
    214210  }
     
    232228  LHCOEvent *element;
    233229
    234   element = static_cast<LHCOEvent *>(branch->NewEntry());
     230  element = static_cast<LHCOEvent*>(branch->NewEntry());
    235231
    236232  element->Number = fEventNumber;
     
    244240  Photon *element;
    245241
    246   element = static_cast<Photon *>(branch->NewEntry());
     242  element = static_cast<Photon*>(branch->NewEntry());
    247243
    248244  element->Eta = fDblParam[0];
     
    258254  Electron *element;
    259255
    260   element = static_cast<Electron *>(branch->NewEntry());
     256  element = static_cast<Electron*>(branch->NewEntry());
    261257
    262258  element->Eta = fDblParam[0];
     
    265261
    266262  element->Charge = fDblParam[4] < 0.0 ? -1 : 1;
    267   /*
     263/*
    268264  element->Ntrk = TMath::Abs(fDblParam[4]);
    269265*/
     
    277273  Muon *element;
    278274
    279   element = static_cast<Muon *>(branch->NewEntry());
     275  element = static_cast<Muon*>(branch->NewEntry());
    280276
    281277  element->Eta = fDblParam[0];
     
    284280
    285281  element->Charge = fDblParam[4] < 0.0 ? -1 : 1;
    286   /*
     282/*
    287283  element->Ntrk = TMath::Abs(fDblParam[4]);
    288284
     
    300296  Jet *element;
    301297
    302   element = static_cast<Jet *>(branch->NewEntry());
     298  element = static_cast<Jet*>(branch->NewEntry());
    303299
    304300  element->Eta = fDblParam[0];
     
    312308
    313309  element->Charge = fDblParam[4] < 0 ? -1 : 1;
    314   /*
     310/*
    315311  element->Ntrk = TMath::Abs(fDblParam[4]);
    316312*/
     
    324320  Jet *element;
    325321
    326   element = static_cast<Jet *>(branch->NewEntry());
     322  element = static_cast<Jet*>(branch->NewEntry());
    327323
    328324  element->Eta = fDblParam[0];
     
    331327
    332328  element->Mass = fDblParam[3];
    333   /*
     329/*
    334330  element->Ntrk = TMath::Abs(Int_t(fDblParam[4]));
    335331*/
     
    340336
    341337  element->EhadOverEem = fDblParam[6];
    342   /*
     338/*
    343339  element->Index = fIntParam[0];
    344340*/
     
    351347  MissingET *element;
    352348
    353   element = static_cast<MissingET *>(branch->NewEntry());
     349  element = static_cast<MissingET*>(branch->NewEntry());
    354350
    355351  element->Phi = fDblParam[1];
     
    380376  if(argc < 2)
    381377  {
    382     cout << " Usage: " << appName << " output_file"
    383          << " [input_file(s)]" << endl;
     378    cout << " Usage: " << appName << " output_file" << " [input_file(s)]" << endl;
    384379    cout << " output_file - output file in ROOT format," << endl;
    385380    cout << " input_file(s) - input file(s) in LHCO format," << endl;
     
    461456
    462457      ++i;
    463     } while(i < argc);
     458    }
     459    while(i < argc);
    464460
    465461    cout << "** Exiting..." << endl;
     
    478474  }
    479475}
     476
     477
  • converters/pileup2root.cpp

    r0e7d64a re39abb4  
    1717 */
    1818
     19
     20#include <stdexcept>
    1921#include <iostream>
    2022#include <sstream>
    21 #include <stdexcept>
    22 
     23
     24#include <stdlib.h>
    2325#include <signal.h>
    2426#include <stdio.h>
    25 #include <stdlib.h>
    26 
     27
     28#include "TROOT.h"
    2729#include "TApplication.h"
    28 #include "TROOT.h"
    29 
     30
     31#include "TFile.h"
     32#include "TObjArray.h"
     33#include "TStopwatch.h"
    3034#include "TDatabasePDG.h"
    31 #include "TFile.h"
     35#include "TParticlePDG.h"
    3236#include "TLorentzVector.h"
    33 #include "TObjArray.h"
    34 #include "TParticlePDG.h"
    35 #include "TStopwatch.h"
    36 
     37
     38#include "classes/DelphesStream.h"
    3739#include "classes/DelphesClasses.h"
    3840#include "classes/DelphesFactory.h"
    3941#include "classes/DelphesPileUpReader.h"
    40 #include "classes/DelphesStream.h"
    41 
     42
     43#include "ExRootAnalysis/ExRootTreeWriter.h"
     44#include "ExRootAnalysis/ExRootTreeBranch.h"
    4245#include "ExRootAnalysis/ExRootProgressBar.h"
    43 #include "ExRootAnalysis/ExRootTreeBranch.h"
    44 #include "ExRootAnalysis/ExRootTreeWriter.h"
    4546
    4647using namespace std;
     
    6162  while(reader->ReadParticle(pid, x, y, z, t, px, py, pz, e))
    6263  {
    63     particle = static_cast<GenParticle *>(branch->NewEntry());
     64    particle = static_cast<GenParticle*>(branch->NewEntry());
    6465
    6566    particle->PID = pid;
     
    8384
    8485    pdgParticle = pdg->GetParticle(pid);
    85     particle->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
     86    particle->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    8687
    8788    particle->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
     
    9192    cosTheta = TMath::Abs(momentum.CosTheta());
    9293    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    93     eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
    94     rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
     94    eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
     95    rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
    9596
    9697    particle->Eta = eta;
     
    125126  if(argc != 3)
    126127  {
    127     cout << " Usage: " << appName << " output_file"
    128          << " input_file" << endl;
     128    cout << " Usage: " << appName << " output_file" << " 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

    r0e7d64a re39abb4  
    1717 */
    1818
     19#include <stdexcept>
     20#include <iostream>
    1921#include <fstream>
    20 #include <iostream>
    2122#include <sstream>
    22 #include <stdexcept>
    2323#include <string>
    2424
     25#include <stdlib.h>
    2526#include <signal.h>
    2627#include <stdio.h>
    27 #include <stdlib.h>
    28 
     28
     29#include "TROOT.h"
    2930#include "TApplication.h"
    30 #include "TROOT.h"
    31 
     31
     32#include "TFile.h"
    3233#include "TClonesArray.h"
    33 #include "TFile.h"
    3434
    3535#include "classes/DelphesClasses.h"
    3636
     37#include "ExRootAnalysis/ExRootTreeReader.h"
    3738#include "ExRootAnalysis/ExRootProgressBar.h"
    38 #include "ExRootAnalysis/ExRootTreeReader.h"
    3939
    4040using namespace std;
     
    6262
    6363private:
     64
    6465  void Reset();
    6566  void Write();
     
    7576  void AnalyseMissingET();
    7677
    77   enum
    78   {
    79     kIntParamSize = 2,
    80     kDblParamSize = 9
    81   };
     78  enum {kIntParamSize = 2, kDblParamSize = 9};
    8279  Int_t fIntParam[kIntParamSize];
    8380  Double_t fDblParam[kDblParamSize];
     
    135132  fBranchMissingET = fTreeReader->UseBranch("MissingET");
    136133
    137   if(!fBranchEvent || !fBranchTrack || !fBranchTower || !fBranchPhoton || !fBranchElectron || !fBranchMuon || !fBranchJet || !fBranchMissingET)
     134  if(!fBranchEvent || !fBranchTrack || !fBranchTower || !fBranchPhoton ||
     135     !fBranchElectron || !fBranchMuon || !fBranchJet || !fBranchMissingET)
    138136  {
    139137    throw runtime_error("ROOT file doesn't contain all required branches");
     
    204202  Event *element;
    205203
    206   element = static_cast<Event *>(fBranchEvent->At(0));
     204  element = static_cast<Event*>(fBranchEvent->At(0));
    207205
    208206  fprintf(fOutputFile, "%4d %13lld %8d\n", 0, element->Number, 0);
     
    218216
    219217  fItPhoton->Reset();
    220   while((element = static_cast<Photon *>(fItPhoton->Next())))
     218  while((element = static_cast<Photon*>(fItPhoton->Next())))
    221219  {
    222220    Reset();
     
    241239
    242240  fItElectron->Reset();
    243   while((element = static_cast<Electron *>(fItElectron->Next())))
     241  while((element = static_cast<Electron*>(fItElectron->Next())))
    244242  {
    245243    Reset();
     
    272270  muonCounter = 0;
    273271  fItMuon->Reset();
    274   while((element = static_cast<Muon *>(fItMuon->Next())))
     272  while((element = static_cast<Muon*>(fItMuon->Next())))
    275273  {
    276274    Reset();
     
    278276    sumPT = 0.0;
    279277    fItTrack->Reset();
    280     while((track = static_cast<Track *>(fItTrack->Next())))
     278    while((track = static_cast<Track*>(fItTrack->Next())))
    281279    {
    282280      if(element->P4().DeltaR(track->P4()) < 0.5) sumPT += track->PT;
     
    285283    sumET = 0.0;
    286284    fItTower->Reset();
    287     while((tower = static_cast<Tower *>(fItTower->Next())))
     285    while((tower = static_cast<Tower*>(fItTower->Next())))
    288286    {
    289287      if(element->P4().DeltaR(tower->P4()) < 0.5) sumET += tower->ET;
     
    295293    minDR = 1.0E9;
    296294    fItJet->Reset();
    297     while((jet = static_cast<Jet *>(fItJet->Next())))
     295    while((jet = static_cast<Jet*>(fItJet->Next())))
    298296    {
    299297      if(jet->TauTag != 0)
     
    327325    }
    328326
    329     ratET = sumET / element->PT;
     327    ratET = sumET/element->PT;
    330328    fDblParam[6] = Float_t(TMath::Nint(sumPT)) + (ratET < 1.0 ? ratET : 0.99);
    331329
     
    344342
    345343  fItJet->Reset();
    346   while((element = static_cast<Jet *>(fItJet->Next())))
     344  while((element = static_cast<Jet*>(fItJet->Next())))
    347345  {
    348346    if(element->TauTag == 0) continue;
     
    352350    counter = 1;
    353351
    354     /*
     352   /*
    355353    fItTrack->Reset();
    356354    while((track = static_cast<Track*>(fItTrack->Next())))
     
    382380
    383381  fItJet->Reset();
    384   while((element = static_cast<Jet *>(fItJet->Next())))
     382  while((element = static_cast<Jet*>(fItJet->Next())))
    385383  {
    386384    if(element->TauTag != 0) continue;
     
    390388    counter = 0;
    391389    fItTrack->Reset();
    392     while((track = static_cast<Track *>(fItTrack->Next())))
     390    while((track = static_cast<Track*>(fItTrack->Next())))
    393391    {
    394392      if(element->P4().DeltaR(track->P4()) < 0.5) ++counter;
     
    415413  MissingET *element;
    416414
    417   element = static_cast<MissingET *>(fBranchMissingET->At(0));
     415  element = static_cast<MissingET*>(fBranchMissingET->At(0));
    418416
    419417  Reset();
     
    473471  if(argc < 2 || argc > 4)
    474472  {
    475     cerr << " Usage: " << appName << " input_file"
    476          << " [output_file] [--jet-branch=Jet]" << endl;
     473    cerr << " Usage: " << appName << " input_file" << " [output_file] [--jet-branch=Jet]" << endl;
    477474    cerr << " input_file - input file in ROOT format," << endl;
    478475    cerr << " output_file - output file in LHCO format," << endl;
  • converters/root2pileup.cpp

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

    r0e7d64a re39abb4  
    1717 */
    1818
     19#include <stdexcept>
    1920#include <iostream>
    2021#include <sstream>
    21 #include <stdexcept>
    2222
    2323#include <signal.h>
    2424
     25#include "TROOT.h"
    2526#include "TApplication.h"
    26 #include "TROOT.h"
    2727
     28#include "TFile.h"
     29#include "TObjArray.h"
     30#include "TStopwatch.h"
    2831#include "TDatabasePDG.h"
    29 #include "TFile.h"
     32#include "TParticlePDG.h"
    3033#include "TLorentzVector.h"
    31 #include "TObjArray.h"
    32 #include "TParticlePDG.h"
    33 #include "TStopwatch.h"
    3434
    3535#include "classes/DelphesClasses.h"
    3636#include "classes/DelphesFactory.h"
     37#include "classes/DelphesSTDHEPReader.h"
    3738#include "classes/DelphesPileUpWriter.h"
    38 #include "classes/DelphesSTDHEPReader.h"
    3939
     40#include "ExRootAnalysis/ExRootTreeWriter.h"
     41#include "ExRootAnalysis/ExRootTreeBranch.h"
    4042#include "ExRootAnalysis/ExRootProgressBar.h"
    41 #include "ExRootAnalysis/ExRootTreeBranch.h"
    42 #include "ExRootAnalysis/ExRootTreeWriter.h"
    4343
    4444using namespace std;
     
    7171  if(argc < 2)
    7272  {
    73     cout << " Usage: " << appName << " output_file"
    74          << " [input_file(s)]" << endl;
     73    cout << " Usage: " << appName << " output_file" << " [input_file(s)]" << endl;
    7574    cout << " output_file - output binary pile-up file," << endl;
    7675    cout << " input_file(s) - input file(s) in STDHEP format," << endl;
     
    143142      reader->Clear();
    144143      while(reader->ReadBlock(factory, allParticleOutputArray,
    145               stableParticleOutputArray, partonOutputArray)
    146         && !interrupted)
     144        stableParticleOutputArray, partonOutputArray) && !interrupted)
    147145      {
    148146        if(reader->EventReady())
     
    151149
    152150          itParticle->Reset();
    153           while((candidate = static_cast<Candidate *>(itParticle->Next())))
     151          while((candidate = static_cast<Candidate*>(itParticle->Next())))
    154152          {
    155153            const TLorentzVector &position = candidate->Position;
     
    175173
    176174      ++i;
    177     } while(i < argc);
     175    }
     176    while(i < argc);
    178177
    179178    writer->WriteIndex();
  • display/Delphes3DGeometry.cc

    r0e7d64a re39abb4  
    1717 */
    1818
    19 #include <algorithm>
    20 #include <cassert>
     19#include <set>
    2120#include <map>
    22 #include <set>
    23 #include <sstream>
    2421#include <utility>
    2522#include <vector>
     23#include <algorithm>
     24#include <sstream>
     25#include <cassert>
    2626
    2727#include "TAxis.h"
     28#include "TGeoManager.h"
     29#include "TGeoVolume.h"
     30#include "TGeoMedium.h"
     31#include "TGeoNode.h"
     32#include "TGeoCompositeShape.h"
     33#include "TGeoMatrix.h"
     34#include "TGeoTube.h"
     35#include "TGeoCone.h"
     36#include "TGeoArb8.h"
    2837#include "TF2.h"
    2938#include "TFormula.h"
    30 #include "TGeoArb8.h"
    31 #include "TGeoCompositeShape.h"
    32 #include "TGeoCone.h"
    33 #include "TGeoManager.h"
    34 #include "TGeoMatrix.h"
    35 #include "TGeoMedium.h"
    36 #include "TGeoNode.h"
    37 #include "TGeoTube.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 
    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.;
     50Delphes3DGeometry::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.;
    8886}
    8987
    9088void Delphes3DGeometry::readFile(const char *configFile,
    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 
    205 TGeoVolume *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 
    236 std::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 
    253 std::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 
    297 std::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 
    317 void 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 }
     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
     199TGeoVolume* 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
     226std::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
     242std::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
     285std::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
     304void 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
  • display/Delphes3DGeometry.h

    r0e7d64a re39abb4  
    2020#define Delphes3DGeometry_h
    2121
     22#include <set>
    2223#include <map>
    23 #include <set>
    2424#include <vector>
    2525
     
    3333// TODO: asymmetric detector
    3434
    35 class Delphes3DGeometry
    36 {
    37 public:
    38   Delphes3DGeometry(TGeoManager *geom = NULL, bool transp = false);
    39   ~Delphes3DGeometry() {}
     35class Delphes3DGeometry {
     36   public:
     37     Delphes3DGeometry(TGeoManager *geom = NULL, bool transp = false);
     38     ~Delphes3DGeometry() {}
    4039
    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");
     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");
    4544
    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; }
     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; }
    5049
    51   TGeoVolume *getDetector(bool withTowers = true);
     50     TGeoVolume *getDetector(bool withTowers = true);
    5251
    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_); }
     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_); }
    5958
    60 private:
    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);
     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);
    6564
    66 private:
    67   TGeoManager *geom_;
     65   private:
    6866
    69   TGeoMedium *vacuum_;
    70   TGeoMedium *tkmed_;
    71   TGeoMedium *calomed_;
    72   TGeoMedium *mudetmed_;
     67     TGeoManager *geom_;
    7368
    74   TAxis *etaAxis_;
    75   TAxis *phiAxis_;
     69     TGeoMedium *vacuum_;
     70     TGeoMedium *tkmed_;
     71     TGeoMedium *calomed_;
     72     TGeoMedium *mudetmed_;
    7673
    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_;
     74     TAxis *etaAxis_;
     75     TAxis *phiAxis_;
    8776
    88   std::vector<std::string> calorimeters_;
    89   std::vector<std::string> muondets_;
     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_;
    9087
    91   std::map<std::string, Double_t> muonSystem_etamax_;
    92   std::map<std::string, std::set<std::pair<Double_t, Int_t> > > caloBinning_;
     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
    9394};
    9495
  • display/DelphesBranchElement.cc

    r0e7d64a re39abb4  
    1818
    1919#include "display/DelphesBranchElement.h"
    20 #include "TEveArrow.h"
     20#include "classes/DelphesClasses.h"
    2121#include "TEveJetCone.h"
    2222#include "TEveTrack.h"
    2323#include "TEveTrackPropagator.h"
     24#include "TEveArrow.h"
    2425#include "TEveVector.h"
    25 #include "classes/DelphesClasses.h"
    2626#include <iostream>
    2727
    2828// special case for calo towers
    29 template <>
    30 DelphesBranchElement<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 }
    38 template <>
    39 void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
    40 template <>
    41 void DelphesBranchElement<DelphesCaloData>::ReadBranch()
    42 {
    43   if(TString(GetType()) == "Tower")
    44   {
     29template<> 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}
     35template<> void DelphesBranchElement<DelphesCaloData>::Reset() { data_->ClearTowers(); }
     36template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch() {
     37  if(TString(GetType())=="Tower") {
    4538    // Loop over all towers
    4639    TIter itTower(branch_);
    4740    Tower *tower;
    48     while((tower = (Tower *)itTower.Next()))
    49     {
     41    while((tower = (Tower *) itTower.Next())) {
    5042      data_->AddTower(tower->Edges[0], tower->Edges[1], tower->Edges[2], tower->Edges[3]);
    5143      data_->FillSlice(0, tower->Eem);
     
    5547  }
    5648}
    57 template <>
    58 std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors()
    59 {
     49template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors() {
    6050  std::vector<TLorentzVector> output;
    61   if(TString(GetType()) == "Tower")
    62   {
     51  if(TString(GetType())=="Tower") {
    6352    TIter itTower(branch_);
    6453    Tower *tower;
    65     while((tower = (Tower *)itTower.Next()))
    66     {
     54    while((tower = (Tower *) itTower.Next())) {
    6755      TLorentzVector v;
    68       v.SetPtEtaPhiM(tower->Eem + tower->Ehad, (tower->Edges[0] + tower->Edges[1]) / 2., (tower->Edges[2] + tower->Edges[3]) / 2., 0.);
     56      v.SetPtEtaPhiM(tower->Eem+tower->Ehad,(tower->Edges[0]+tower->Edges[1])/2.,(tower->Edges[2]+tower->Edges[3])/2.,0.);
    6957      output.push_back(v);
    7058    }
     
    7462
    7563// special case for element lists
    76 template <>
    77 DelphesBranchElement<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 }
    83 template <>
    84 void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
    85 template <>
    86 void DelphesBranchElement<TEveElementList>::ReadBranch()
    87 {
    88   if(TString(GetType()) == "Jet")
    89   {
     64template<> 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}
     68template<> void DelphesBranchElement<TEveElementList>::Reset() { data_->DestroyElements(); }
     69template<> void DelphesBranchElement<TEveElementList>::ReadBranch() {
     70  if(TString(GetType())=="Jet") {
    9071    TIter itJet(branch_);
    9172    Jet *jet;
     
    9374    // Loop over all jets
    9475    Int_t counter = 0;
    95     while((jet = (Jet *)itJet.Next()))
    96     {
     76    while((jet = (Jet *) itJet.Next())) {
    9777      eveJetCone = new TEveJetCone();
    98       eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f", counter, jet->PT, jet->Eta, jet->Phi, jet->Mass));
     78      eveJetCone->SetTitle(Form("jet [%d]: Pt=%f, Eta=%f, \nPhi=%f, M=%f",counter,jet->PT, jet->Eta, jet->Phi, jet->Mass));
    9979      eveJetCone->SetName(Form("jet [%d]", counter++));
    10080      eveJetCone->SetMainTransparency(60);
     
    10686      data_->AddElement(eveJetCone);
    10787    }
    108   }
    109   else if(TString(GetType()) == "MissingET")
    110   {
     88  } else if(TString(GetType())=="MissingET") {
    11189    // MissingET as invisible track (like a photon)
    11290    MissingET *MET;
     
    11694    trkProp->SetMaxR(tkRadius_);
    11795    trkProp->SetMaxZ(tkHalfLength_);
    118     if(branch_->GetEntriesFast() > 0)
    119     {
    120       MET = (MissingET *)branch_->At(0);
     96    if(branch_->GetEntriesFast() > 0) {
     97      MET = (MissingET*) branch_->At(0);
    12198      TParticle pb(13, 1, 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);
     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);
    125102      eveMet = new TEveTrack(&pb, 0, trkProp);
    126103      eveMet->SetName("Missing Et");
     
    138115  }
    139116}
    140 template <>
    141 std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors()
    142 {
     117template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors() {
    143118  std::vector<TLorentzVector> output;
    144   if(TString(GetType()) == "Jet")
    145   {
     119  if(TString(GetType())=="Jet") {
    146120    TIter itJet(branch_);
    147121    Jet *jet;
    148122    // Loop over all jets
    149     while((jet = (Jet *)itJet.Next()))
    150     {
     123    while((jet = (Jet *) itJet.Next())) {
    151124      TLorentzVector v;
    152125      v.SetPtEtaPhiM(jet->PT, jet->Eta, jet->Phi, jet->Mass);
    153126      output.push_back(v);
    154127    }
    155   }
    156   else if(TString(GetType()) == "MissingET")
    157   {
     128  } else if(TString(GetType())=="MissingET") {
    158129    TIter itMet(branch_);
    159130    MissingET *MET;
    160131    // Missing Et
    161     while((MET = (MissingET *)itMet.Next()))
    162     {
     132    while((MET = (MissingET*) itMet.Next())) {
    163133      TLorentzVector v;
    164       v.SetPtEtaPhiM(MET->MET, MET->Eta, MET->Phi, 0.);
     134      v.SetPtEtaPhiM(MET->MET,MET->Eta,MET->Phi,0.);
    165135      output.push_back(v);
    166136    }
     
    170140
    171141// special case for track lists
    172 template <>
    173 DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt) :
    174   DelphesBranchBase(name, branch, color, maxPt)
    175 {
     142template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt):DelphesBranchBase(name, branch, color, maxPt) {
    176143  data_ = new TEveTrackList(name);
    177144  data_->SetMainColor(color_);
     
    180147  data_->SetMarkerSize(0.5);
    181148}
    182 template <>
    183 void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz)
    184 {
    185   tkRadius_ = r;
     149template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz) {
     150  tkRadius_ = r;
    186151  tkHalfLength_ = l;
    187152  tk_Bz_ = Bz;
     
    191156  trkProp->SetMaxZ(tkHalfLength_);
    192157}
    193 template <>
    194 void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
    195 template <>
    196 void DelphesBranchElement<TEveTrackList>::ReadBranch()
    197 {
     158template<> void DelphesBranchElement<TEveTrackList>::Reset() { data_->DestroyElements(); }
     159template<> void DelphesBranchElement<TEveTrackList>::ReadBranch() {
    198160  TString type = GetType();
    199161  TIter itTrack(branch_);
     
    205167  trkProp->SetMaxZ(tkHalfLength_);
    206168  GenParticle *particle;
    207   if(type == "Track")
    208   { // CASE 1: TRACKS
     169  if(type=="Track") { // CASE 1: TRACKS
    209170    Track *track;
    210     while((track = (Track *)itTrack.Next()))
    211     {
     171    while((track = (Track *) itTrack.Next())) {
    212172      TParticle pb(track->PID, 1, 0, 0, 0, 0,
    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
     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
    227185    Electron *electron;
    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
     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
    246201    Muon *muon;
    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
     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
    265217    Photon *photon;
    266     while((photon = (Photon *)itTrack.Next()))
    267     {
     218    while((photon = (Photon *) itTrack.Next())) {
    268219      TParticle pb(22, 1, 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);
     220                   photon->P4().Px(), photon->P4().Py(),
     221                   photon->P4().Pz(), photon->P4().E(),
     222                   0.0, 0.0, 0.0, 0.0);
    272223      eveTrack = new TEveTrack(&pb, counter, trkProp);
    273224      eveTrack->SetName(Form("%s [%d]", pb.GetName(), counter++));
     
    279230      eveTrack->MakeTrack();
    280231    }
    281   }
    282   else if(type == "GenParticle")
    283   { // CASE 5: GENPARTICLES
     232  } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
    284233    GenParticle *particle;
    285     while((particle = (GenParticle *)itTrack.Next()))
    286     {
     234    while((particle = (GenParticle *) itTrack.Next())) {
    287235      if(particle->Status != 1) continue;
    288236      TParticle pb(particle->PID, particle->Status, particle->M1, particle->M2, particle->D1, particle->D2,
    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 }
    303 template <>
    304 std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors()
    305 {
     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}
     251template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors() {
    306252  std::vector<TLorentzVector> output;
    307253  TString type = GetType();
    308254  TIter itTrack(branch_);
    309   if(type == "Track")
    310   { // CASE 1: TRACKS
     255  if(type=="Track") { // CASE 1: TRACKS
    311256    Track *track;
    312     while((track = (Track *)itTrack.Next()))
    313     {
     257    while((track = (Track *) itTrack.Next())) {
    314258      output.push_back(track->P4());
    315259    }
    316   }
    317   else if(type == "Electron")
    318   { // CASE 2: ELECTRONS
     260  } else if(type=="Electron") { // CASE 2: ELECTRONS
    319261    Electron *electron;
    320     while((electron = (Electron *)itTrack.Next()))
    321     {
     262    while((electron = (Electron *) itTrack.Next())) {
    322263      output.push_back(electron->P4());
    323264    }
    324   }
    325   else if(type == "Muon")
    326   { // CASE 3: MUONS
     265  } else if(type=="Muon") { // CASE 3: MUONS
    327266    Muon *muon;
    328     while((muon = (Muon *)itTrack.Next()))
    329     {
     267    while((muon = (Muon *) itTrack.Next())) {
    330268      output.push_back(muon->P4());
    331269    }
    332   }
    333   else if(type == "Photon")
    334   { // CASE 4: PHOTONS
     270  } else if(type=="Photon") { // CASE 4: PHOTONS
    335271    Photon *photon;
    336     while((photon = (Photon *)itTrack.Next()))
    337     {
     272    while((photon = (Photon *) itTrack.Next())) {
    338273      output.push_back(photon->P4());
    339274    }
    340   }
    341   else if(type == "GenParticle")
    342   { // CASE 5: GENPARTICLES
     275  } else if(type=="GenParticle") { // CASE 5: GENPARTICLES
    343276    GenParticle *particle;
    344     while((particle = (GenParticle *)itTrack.Next()))
    345     {
     277    while((particle = (GenParticle *) itTrack.Next())) {
    346278      if(particle->Status != 1) continue;
    347       output.push_back(particle->P4());
     279        output.push_back(particle->P4());
    348280    }
    349281  }
  • display/DelphesBranchElement.h

    r0e7d64a re39abb4  
    2020#define DelphesBranchElement_h
    2121
     22#include "TColor.h"
     23#include "TString.h"
     24#include "TClonesArray.h"
    2225#include "TClass.h"
    23 #include "TClonesArray.h"
    24 #include "TColor.h"
     26#include <exception>
     27#include <iostream>
     28#include "display/DelphesCaloData.h"
    2529#include "TEveElement.h"
    2630#include "TEveTrack.h"
    27 #include "TString.h"
    28 #include "display/DelphesCaloData.h"
    29 #include <exception>
    30 #include <iostream>
    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.) :
    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;
     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;
    5246
    53 protected:
    54   TString name_;
    55   Float_t maxPt_;
    56   TClonesArray *branch_;
    57   const enum EColor color_;
    58   Float_t tkRadius_, tkHalfLength_, tk_Bz_;
     47  protected:
     48    TString name_;
     49    Float_t maxPt_;
     50    TClonesArray* branch_;
     51    const enum EColor color_;
     52    Float_t tkRadius_,tkHalfLength_, tk_Bz_;
    5953};
    6054
    6155// concrete implementations. EveContainer can be a TrackList, ElementList or CaloData.
    62 template <typename EveContainer>
    63 class DelphesBranchElement: public DelphesBranchBase
     56template<typename EveContainer> class DelphesBranchElement: public DelphesBranchBase
    6457{
    65 public:
    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   }
     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    }
    7263
    73   // destructor
    74   virtual ~DelphesBranchElement() { delete data_; }
     64    // destructor
     65    virtual ~DelphesBranchElement() { delete data_; }
    7566
    76   // get the container (ElementList, TrackList, or CaloData)
    77   EveContainer *GetContainer() { return data_; }
     67    // get the container (ElementList, TrackList, or CaloData)
     68    EveContainer* GetContainer() { return data_; }
    7869
    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   }
     70    // tracking volume
     71    virtual void SetTrackingVolume(Float_t r, Float_t l, Float_t Bz=0.) { tkRadius_ = r; tkHalfLength_ = l; tk_Bz_ = Bz; }
    8672
    87   // resets the collection (before moving to the next event)
    88   virtual void Reset(){};
     73    // resets the collection (before moving to the next event)
     74    virtual void Reset() {};
    8975
    90   // template class name
    91   virtual const char *GetClassName() { return data_->ClassName(); }
     76    // template class name
     77    virtual const char* GetClassName() { return data_->ClassName(); }
    9278
    93   // read the branch and fill elements for display
    94   virtual void ReadBranch() {}
     79    // read the branch and fill elements for display
     80    virtual void ReadBranch() {}
    9581
    96   // return the vector for all elements
    97   virtual std::vector<TLorentzVector> GetVectors()
    98   {
    99     std::vector<TLorentzVector> v;
    100     return v;
    101   }
     82    // return the vector for all elements
     83    virtual std::vector<TLorentzVector> GetVectors() { std::vector<TLorentzVector> v; return v; }
    10284
    103 private:
    104   EveContainer *data_;
     85  private:
     86    EveContainer* data_;
    10587};
    10688
     
    10890
    10991// special case for calo towers
    110 template <>
    111 DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
    112 template <>
    113 void DelphesBranchElement<DelphesCaloData>::Reset();
    114 template <>
    115 void DelphesBranchElement<DelphesCaloData>::ReadBranch();
    116 template <>
    117 std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors();
     92template<> DelphesBranchElement<DelphesCaloData>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
     93template<> void DelphesBranchElement<DelphesCaloData>::Reset();
     94template<> void DelphesBranchElement<DelphesCaloData>::ReadBranch();
     95template<> std::vector<TLorentzVector> DelphesBranchElement<DelphesCaloData>::GetVectors();
    11896
    11997// special case for element lists
    120 template <>
    121 DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
    122 template <>
    123 void DelphesBranchElement<TEveElementList>::Reset();
    124 template <>
    125 void DelphesBranchElement<TEveElementList>::ReadBranch();
    126 template <>
    127 std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors();
     98template<> DelphesBranchElement<TEveElementList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
     99template<> void DelphesBranchElement<TEveElementList>::Reset();
     100template<> void DelphesBranchElement<TEveElementList>::ReadBranch();
     101template<> std::vector<TLorentzVector> DelphesBranchElement<TEveElementList>::GetVectors();
    128102
    129103// special case for track lists
    130 template <>
    131 DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char *name, TClonesArray *branch, const enum EColor color, Float_t maxPt);
    132 template <>
    133 void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
    134 template <>
    135 void DelphesBranchElement<TEveTrackList>::Reset();
    136 template <>
    137 void DelphesBranchElement<TEveTrackList>::ReadBranch();
    138 template <>
    139 std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors();
     104template<> DelphesBranchElement<TEveTrackList>::DelphesBranchElement(const char* name, TClonesArray* branch, const enum EColor color, Float_t maxPt);
     105template<> void DelphesBranchElement<TEveTrackList>::SetTrackingVolume(Float_t r, Float_t l, Float_t Bz);
     106template<> void DelphesBranchElement<TEveTrackList>::Reset();
     107template<> void DelphesBranchElement<TEveTrackList>::ReadBranch();
     108template<> std::vector<TLorentzVector> DelphesBranchElement<TEveTrackList>::GetVectors();
    140109
    141110#endif // CINT, CLING
  • display/DelphesCaloData.cc

    r0e7d64a re39abb4  
    1616 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    1717 */
     18
    1819
    1920#include "display/DelphesCaloData.h"
     
    3637void DelphesCaloData::ClearTowers()
    3738{
    38   fGeomVec.clear();
     39   fGeomVec.clear();
    3940}
    4041
  • display/DelphesCaloData.h

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

    r0e7d64a re39abb4  
    1717 */
    1818
    19 #include "TEveBrowser.h"
     19
    2020#include "TEveManager.h"
    21 #include "TEveProjectionAxes.h"
    22 #include "TEveProjectionManager.h"
    23 #include "TEveScene.h"
    2421#include "TEveViewer.h"
    25 #include "TEveWindow.h"
    2622#include "TGLViewer.h"
    2723#include "TGLWidget.h"
     24#include "TEveScene.h"
     25#include "TEveProjectionManager.h"
     26#include "TEveProjectionAxes.h"
     27#include "TEveBrowser.h"
     28#include "TEveWindow.h"
    2829#include "TGTab.h"
    2930
    3031#include "TEveCalo2DGL.h"
    31 #include "TEveCalo3DGL.h"
     32#include "TEveCalo3DGL.h" 
    3233#include "TEveCaloLegoGL.h"
    3334#include "TEveCaloLegoOverlay.h"
     
    4748  fRhoZMgr = new TEveProjectionManager(TEveProjection::kPT_RhoZ);
    4849
    49   fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry");
    50   fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry");
     50        fRPhiGeomScene = gEve->SpawnNewScene("RPhi Geometry");
     51        fRhoZGeomScene = gEve->SpawnNewScene("RhoZ Geometry");
    5152
    52   fRPhiCaloScene = gEve->SpawnNewScene("RPhi Calorimeter");
    53   fRhoZCaloScene = gEve->SpawnNewScene("RhoZ Calorimeter");
    54   fLegoCaloScene = gEve->SpawnNewScene("Lego Calorimeter");
     53        fRPhiCaloScene = gEve->SpawnNewScene("RPhi Calorimeter");
     54        fRhoZCaloScene = gEve->SpawnNewScene("RhoZ Calorimeter");
     55        fLegoCaloScene = gEve->SpawnNewScene("Lego Calorimeter");
    5556
    56   fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data");
    57   fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data");
    58 
     57        fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data");
     58        fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data");
     59 
    5960  axes = new TEveProjectionAxes(fRPhiMgr);
    6061  fRPhiGeomScene->AddElement(axes);
     
    8485  f3DimView->AddScene(gEve->GetGlobalScene());
    8586  f3DimView->AddScene(gEve->GetEventScene());
    86 
     87 
    8788  pack1->NewSlot()->MakeCurrent();
    8889  fLegoView = gEve->SpawnNewViewer("Lego View", "");
    8990  fLegoView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
    9091  fLegoView->AddScene(fLegoCaloScene);
    91 
     92 
    9293  pack0->NewSlot()->MakeCurrent();
    9394  fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
     
    9697  fRPhiView->AddScene(fRPhiCaloScene);
    9798  fRPhiView->AddScene(fRPhiEventScene);
    98 
     99       
    99100  pack0->NewSlot()->MakeCurrent();
    100101  fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
     
    113114//------------------------------------------------------------------------------
    114115
    115 void DelphesDisplay::ImportGeomRPhi(TEveElement *el)
    116 {
     116void DelphesDisplay::ImportGeomRPhi(TEveElement* el)
     117{ 
    117118  fRPhiMgr->ImportElements(el, fRPhiGeomScene);
    118119}
    119120
    120 void DelphesDisplay::ImportGeomRhoZ(TEveElement *el)
    121 {
     121void DelphesDisplay::ImportGeomRhoZ(TEveElement* el)
     122{ 
    122123  fRhoZMgr->ImportElements(el, fRhoZGeomScene);
    123124}
     
    136137{
    137138  TEveCaloLegoOverlay *overlay = new TEveCaloLegoOverlay();
    138 
     139 
    139140  overlay->SetCaloLego(calo);
    140141  fLegoView->GetGLViewer()->AddOverlayElement(overlay);
     
    143144}
    144145
    145 void DelphesDisplay::ImportEventRPhi(TEveElement *el)
    146 {
     146void DelphesDisplay::ImportEventRPhi(TEveElement* el)
     147{ 
    147148  fRPhiMgr->ImportElements(el, fRPhiEventScene);
    148149}
    149150
    150 void DelphesDisplay::ImportEventRhoZ(TEveElement *el)
    151 {
     151void DelphesDisplay::ImportEventRhoZ(TEveElement* el)
     152{ 
    152153  fRhoZMgr->ImportElements(el, fRhoZEventScene);
    153154}
     
    165166}
    166167//------------------------------------------------------------------------------
     168
  • display/DelphesDisplay.h

    r0e7d64a re39abb4  
    3030{
    3131public:
     32 
    3233  DelphesDisplay();
    3334
    3435  virtual ~DelphesDisplay();
    3536
    36   void ImportGeomRPhi(TEveElement *el);
    37   void ImportGeomRhoZ(TEveElement *el);
     37  void ImportGeomRPhi(TEveElement* el);
     38  void ImportGeomRhoZ(TEveElement* el);
    3839
    3940  void ImportCaloRPhi(TEveCalo3D *calo);
     
    4142  void ImportCaloLego(TEveCaloLego *calo);
    4243
    43   void ImportEventRPhi(TEveElement *el);
    44   void ImportEventRhoZ(TEveElement *el);
     44  void ImportEventRPhi(TEveElement* el);
     45  void ImportEventRhoZ(TEveElement* el);
    4546
    4647  void DestroyEventRPhi();
     
    4849
    4950private:
     51
    5052  TEveProjectionManager *fRPhiMgr;
    5153  TEveProjectionManager *fRhoZMgr;
     
    6870
    6971#endif /* DelphesDisplay_h */
     72
  • display/DelphesEventDisplay.cc

    r0e7d64a re39abb4  
    1717 */
    1818
    19 #include <algorithm>
    2019#include <cassert>
    2120#include <iostream>
    2221#include <utility>
    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"
     22#include <algorithm>
     23
     24#include "TGeoManager.h"
     25#include "TGeoVolume.h"
    3126#include "TEveElement.h"
    32 #include "TEveEventManager.h"
    33 #include "TEveGeoNode.h"
    3427#include "TEveJetCone.h"
    35 #include "TEveManager.h"
    3628#include "TEveTrack.h"
    3729#include "TEveTrackPropagator.h"
     30#include "TEveCalo.h"
     31#include "TEveManager.h"
     32#include "TEveGeoNode.h"
    3833#include "TEveTrans.h"
    3934#include "TEveViewer.h"
     35#include "TEveBrowser.h"
     36#include "TEveArrow.h"
     37#include "TMath.h"
     38#include "TSystem.h"
     39#include "TRootBrowser.h"
    4040#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"
    4151#include "TGHtml.h"
    42 #include "TGNumberEntry.h"
    43 #include "TGProgressBar.h"
    4452#include "TGStatusBar.h"
    45 #include "TGTextEntry.h"
    46 #include "TGeoManager.h"
    47 #include "TGeoVolume.h"
    48 #include "TH1F.h"
    49 #include "TMath.h"
    50 #include "TRootBrowser.h"
    51 #include "TRootEmbeddedCanvas.h"
    52 #include "TSystem.h"
    53 
     53
     54#include "display/DelphesCaloData.h"
     55#include "display/DelphesBranchElement.h"
    5456#include "display/Delphes3DGeometry.h"
    55 #include "display/DelphesBranchElement.h"
    56 #include "display/DelphesCaloData.h"
     57#include "display/DelphesEventDisplay.h"
    5758#include "display/DelphesDisplay.h"
    58 #include "display/DelphesEventDisplay.h"
     59#include "display/Delphes3DGeometry.h"
    5960#include "display/DelphesHtmlSummary.h"
    6061#include "display/DelphesPlotSummary.h"
     
    6667DelphesEventDisplay::DelphesEventDisplay()
    6768{
    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;
     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;
    7980}
    8081
    8182DelphesEventDisplay::~DelphesEventDisplay()
    8283{
    83   delete chain_;
     84   delete chain_;
    8485}
    8586
    8687void DelphesEventDisplay::EventChanged(Int_t e)
    8788{
    88   if(e != event_id_)
    89   {
     89  if( e!= event_id_ ) {
    9090    event_id_ = e;
    91     Emit("EventChanged(Int_t)", e);
     91    Emit("EventChanged(Int_t)",e);
    9292    load_event();
    9393  }
    9494}
    9595
    96 DelphesEventDisplay::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);
     96
     97DelphesEventDisplay::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
    189187}
    190188
    191189// function that parses the config to extract the branches of interest and prepare containers
    192 void 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);
     190void 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   }
     259}
     260
     261void DelphesEventDisplay::load_event()
     262{
     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();
     298}
     299
     300void DelphesEventDisplay::update_html_summary()
     301{
     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         }
    224351      }
    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   }
    283 }
    284 
    285 void DelphesEventDisplay::load_event()
    286 {
    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();
    324 }
    325 
    326 void DelphesEventDisplay::update_html_summary()
    327 {
    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);
    352       }
    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   }
     352      htmlSummary_->Build();
     353      gHtml_->Clear();
     354      gHtml_->ParseText((char*)htmlSummary_->Html().Data());
     355      gHtml_->Layout();
     356   }
     357 
    388358}
    389359
     
    394364void DelphesEventDisplay::make_gui()
    395365{
    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)");
     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
     448void DelphesEventDisplay::Fwd() { 
     449  if (event_id_ < treeReader_->GetEntries() - 2) {
     450     EventChanged(event_id_+1);
     451  } else {
     452     printf("Already at last event.\n");
    442453  }
    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()");
     454}
     455
     456void DelphesEventDisplay::Bck() {
     457  if (event_id_ > 0) {
     458     EventChanged(event_id_-1);
     459  } else {
     460     printf("Already at first event.\n");
    449461  }
    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 
    476 void 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 
    488 void 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 
    500 void DelphesEventDisplay::PreSetEv(char *ev)
    501 {
     462}
     463
     464void DelphesEventDisplay::PreSetEv(char *ev) {
    502465  event_id_tmp_ = Int_t(atoi(ev));
    503466}
    504467
    505 void DelphesEventDisplay::GoTo()
    506 {
    507   if(event_id_tmp_ >= 0 && event_id_tmp_ < treeReader_->GetEntries() - 1)
    508   {
     468void DelphesEventDisplay::GoTo() {
     469  if (event_id_tmp_>=0 && event_id_tmp_ < treeReader_->GetEntries()-1) {
    509470    EventChanged(event_id_tmp_);
    510   }
    511   else
    512   {
     471  } else {
    513472    printf("Error: no such event.\n");
    514473  }
    515474}
    516475
    517 void DelphesEventDisplay::InitSummaryPlots()
    518 {
     476void DelphesEventDisplay::InitSummaryPlots() {
    519477  plotSummary_->FillSample(treeReader_, event_id_);
    520478  plotSummary_->FillEvent();
     
    522480}
    523481
    524 void DelphesEventDisplay::DisplayProgress(Int_t p)
    525 {
    526   fStatusBar_->SetText(Form("Processing... %d %%", p), 1);
     482void DelphesEventDisplay::DisplayProgress(Int_t p) {
     483  fStatusBar_->SetText(Form("Processing... %d %%",p), 1);
    527484  gSystem->ProcessEvents();
    528485}
  • display/DelphesEventDisplay.h

    r0e7d64a re39abb4  
    2222#include <vector>
    2323
     24#include "Rtypes.h"
    2425#include "RQ_OBJECT.h"
    25 #include "Rtypes.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")
     48  public:
     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);
     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);
    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_;
     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();
    7377
    74   // gui controls
    75 public:
    76   void Fwd();
     78     void Bck();
    7779
    78   void Bck();
     80    void PreSetEv(char *ev);
    7981
    80   void PreSetEv(char *ev);
     82    void GoTo();
    8183
    82   void GoTo();
     84    void InitSummaryPlots();
    8385
    84   void InitSummaryPlots();
    85 
    86   void DisplayProgress(Int_t p);
     86    void DisplayProgress(Int_t p);
    8787};
    8888
  • display/DelphesHtmlSummary.cc

    r0e7d64a re39abb4  
    1818
    1919#include "display/DelphesHtmlSummary.h"
     20#include "TGHtml.h"
    2021#include "TEveElement.h"
     22#include "TEveManager.h"
    2123#include "TEveEventManager.h"
    22 #include "TEveManager.h"
    2324#include "TEvePointSet.h"
    2425#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   {
    65     BuildLabels();
    66     BuildTable();
    67   }
    68 
    69   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      BuildLabels();
     65      BuildTable();
     66   }
     67
     68   fHtml += "</table>";
    7069}
    7170
     
    7372void DelphesHtmlObjTable::BuildTitle()
    7473{
    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>";
     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>";
    9190}
    9291
     
    9493void DelphesHtmlObjTable::BuildLabels()
    9594{
    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>";
     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>";
    108106}
    109107
     
    111109void DelphesHtmlObjTable::BuildTable()
    112110{
    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]);
     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);
    138126      fHtml += "</td>";
    139     }
    140     fHtml += "</tr> ";
    141   }
    142 }
    143 
    144 //______________________________________________________________________________
    145 DelphesHtmlSummary::DelphesHtmlSummary(const char *title) :
    146   fNTables(0), fTitle(title)
    147 {
    148   // Constructor.
    149 
    150   fObjTables = new TOrdCollection();
     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//______________________________________________________________________________
     141DelphesHtmlSummary::DelphesHtmlSummary(const char *title) : fNTables(0), fTitle(title)
     142{
     143   // Constructor.
     144
     145   fObjTables = new TOrdCollection();
    151146}
    152147
     
    154149DelphesHtmlSummary::~DelphesHtmlSummary()
    155150{
    156   // Destructor.
    157 
    158   Reset();
     151   // Destructor.
     152
     153   Reset();
    159154}
    160155
    161156//______________________________________________________________________________
    162157DelphesHtmlObjTable *DelphesHtmlSummary::AddTable(const char *name, Int_t nfields, Int_t nvals,
    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;
     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;
    176171}
    177172
     
    179174void DelphesHtmlSummary::Clear(Option_t *option)
    180175{
    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;
     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;
    188183}
    189184
     
    191186void DelphesHtmlSummary::Reset(Option_t *)
    192187{
    193   // Reset (delete) the table list;
    194 
    195   delete fObjTables;
    196   fObjTables = 0;
    197   fNTables = 0;
     188   // Reset (delete) the table list;
     189
     190   delete fObjTables; fObjTables = 0;
     191   fNTables = 0;
    198192}
    199193
     
    201195void DelphesHtmlSummary::Build()
    202196{
    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();
     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();
    212205}
    213206
     
    215208void DelphesHtmlSummary::MakeHeader()
    216209{
    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;
     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;
    226219}
    227220
     
    229222void DelphesHtmlSummary::MakeFooter()
    230223{
    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 }
     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
  • display/DelphesHtmlSummary.h

    r0e7d64a re39abb4  
    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
    28 class DelphesHtmlObjTable: public TObject
     28
     29class DelphesHtmlObjTable : public TObject
    2930{
    30 public: // 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;
     31public:                     // make them public for shorter code
    3732
    38   TString fHtml; // HTML output code
     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;
    3939
    40   void Build();
    41   void BuildTitle();
    42   void BuildLabels();
    43   void BuildTable();
     40   TString   fHtml;         // HTML output code
     41
     42   void Build();
     43   void BuildTitle();
     44   void BuildLabels();
     45   void BuildTable();
    4446
    4547public:
    46   DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp = kTRUE);
    47   virtual ~DelphesHtmlObjTable();
     48   DelphesHtmlObjTable(const char *name, Int_t nfields, Int_t nvals, Bool_t exp=kTRUE);
     49   virtual ~DelphesHtmlObjTable();
    4850
    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; }
     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; }
    5254
    53   ClassDef(DelphesHtmlObjTable, 0);
     55   ClassDef(DelphesHtmlObjTable, 0);
    5456};
    5557
     
    5860class DelphesHtmlSummary
    5961{
    60 public: // 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
     62public:                           // 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
    6769
    68   void MakeHeader();
    69   void MakeFooter();
     70   void    MakeHeader();
     71   void    MakeFooter();
    7072
    7173public:
    72   DelphesHtmlSummary(const char *title);
    73   virtual ~DelphesHtmlSummary();
     74   DelphesHtmlSummary(const char *title);
     75   virtual ~DelphesHtmlSummary();
    7476
    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; }
     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; }
    8284
    83   ClassDef(DelphesHtmlSummary, 0);
     85   ClassDef(DelphesHtmlSummary, 0);
    8486};
    8587
  • display/DelphesPlotSummary.cc

    r0e7d64a re39abb4  
    2121#include <algorithm>
    2222
    23 bool vecsorter(TLorentzVector i, TLorentzVector j) { return (i.Pt() > j.Pt()); }
     23bool vecsorter (TLorentzVector i,TLorentzVector j) { return (i.Pt()>j.Pt()); }
    2424
    25 DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab *tab) :
    26   tab_(tab) {}
     25DelphesPlotSummary::DelphesPlotSummary(TEveWindowTab* tab):tab_(tab) {}
    2726
    2827DelphesPlotSummary::~DelphesPlotSummary() {}
     
    3029void DelphesPlotSummary::Progress(Int_t p)
    3130{
    32   Emit("Progress(Int_t)", p);
     31  Emit("Progress(Int_t)",p);
    3332}
    3433
    35 void DelphesPlotSummary::Init(std::vector<DelphesBranchBase *> &elements)
    36 {
     34void DelphesPlotSummary::Init(std::vector<DelphesBranchBase*>& elements) {
    3735  elements_ = &elements;
    3836  // loop on the elements, and create tabs
    39   for(std::vector<DelphesBranchBase *>::iterator data = elements.begin(); data < elements.end(); ++data)
    40   {
     37  for(std::vector<DelphesBranchBase*>::iterator data=elements.begin();data<elements.end();++data) {
    4138    // the canvas
    42     TEveWindowSlot *slot = tab_->NewSlot();
    43     TRootEmbeddedCanvas *trec = new TRootEmbeddedCanvas();
    44     TCanvas *canvas = trec->GetCanvas();
    45     TEveWindowFrame *wf = slot->MakeFrame(trec);
     39    TEveWindowSlot* slot = tab_->NewSlot();
     40    TRootEmbeddedCanvas* trec = new TRootEmbeddedCanvas();
     41    TCanvas* canvas = trec->GetCanvas();
     42    TEveWindowFrame * wf = slot->MakeFrame(trec);
    4643    wf->SetElementName((*data)->GetName());
    47     canvas->Divide(3, 3);
     44    canvas->Divide(3,3);
    4845    canvases_[(*data)->GetName()] = canvas;
    4946    // the histograms
    50     TH1F *h;
    51     std::vector<TH1F *> histograms;
     47    TH1F* h;
     48    std::vector<TH1F*> histograms;
    5249    histograms.reserve(9);
    53     h = new TH1F(Form("%sPt", (*data)->GetName()), Form("%s Pt", (*data)->GetName()), 100, 0, -1);
     50    h = new TH1F(Form("%sPt",(*data)->GetName()),Form("%s Pt",(*data)->GetName()),100,0,-1);
    5451    histograms.push_back(h);
    55     h = new TH1F(Form("%sEta", (*data)->GetName()), Form("%s Eta", (*data)->GetName()), 100, 0, -1);
     52    h = new TH1F(Form("%sEta",(*data)->GetName()),Form("%s Eta",(*data)->GetName()),100,0,-1);
    5653    histograms.push_back(h);
    57     h = new TH1F(Form("%sPhi", (*data)->GetName()), Form("%s Phi", (*data)->GetName()), 100, 0, -1);
     54    h = new TH1F(Form("%sPhi",(*data)->GetName()),Form("%s Phi",(*data)->GetName()),100,0,-1);
    5855    histograms.push_back(h);
    59     h = new TH1F(Form("l%sPt", (*data)->GetName()), Form("leading %s Pt", (*data)->GetName()), 100, 0, -1);
     56    h = new TH1F(Form("l%sPt",(*data)->GetName()),Form("leading %s Pt",(*data)->GetName()),100,0,-1);
    6057    histograms.push_back(h);
    61     h = new TH1F(Form("l%sEta", (*data)->GetName()), Form("leading %s Eta", (*data)->GetName()), 100, 0, -1);
     58    h = new TH1F(Form("l%sEta",(*data)->GetName()),Form("leading %s Eta",(*data)->GetName()),100,0,-1);
    6259    histograms.push_back(h);
    63     h = new TH1F(Form("l%sPhi", (*data)->GetName()), Form("leading %s Phi", (*data)->GetName()), 100, 0, -1);
     60    h = new TH1F(Form("l%sPhi",(*data)->GetName()),Form("leading %s Phi",(*data)->GetName()),100,0,-1);
    6461    histograms.push_back(h);
    65     h = new TH1F(Form("sl%sPt", (*data)->GetName()), Form("subleading %s Pt", (*data)->GetName()), 100, 0, -1);
     62    h = new TH1F(Form("sl%sPt",(*data)->GetName()),Form("subleading %s Pt",(*data)->GetName()),100,0,-1);
    6663    histograms.push_back(h);
    67     h = new TH1F(Form("sl%sEta", (*data)->GetName()), Form("subleading %s Eta", (*data)->GetName()), 100, 0, -1);
     64    h = new TH1F(Form("sl%sEta",(*data)->GetName()),Form("subleading %s Eta",(*data)->GetName()),100,0,-1);
    6865    histograms.push_back(h);
    69     h = new TH1F(Form("sl%sPhi", (*data)->GetName()), Form("subleading %s Phi", (*data)->GetName()), 100, 0, -1);
     66    h = new TH1F(Form("sl%sPhi",(*data)->GetName()),Form("subleading %s Phi",(*data)->GetName()),100,0,-1);
    7067    histograms.push_back(h);
    7168    histograms_[(*data)->GetName()] = histograms;
    7269    // the event histograms
    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;
     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;
    8374    hv.push_back(h1);
    8475    hv.push_back(h2);
     
    8778    // the event markers
    8879    TMarker *m;
    89     std::vector<TMarker *> mv;
    90     m = new TMarker(0, 0, 29);
    91     m->SetMarkerColor(kBlue);
    92     m->SetMarkerSize(3);
     80    std::vector<TMarker*> mv;
     81    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    9382    mv.push_back(m);
    94     m = new TMarker(0, 0, 29);
    95     m->SetMarkerColor(kBlue);
    96     m->SetMarkerSize(3);
     83    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    9784    mv.push_back(m);
    98     m = new TMarker(0, 0, 29);
    99     m->SetMarkerColor(kBlue);
    100     m->SetMarkerSize(3);
     85    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    10186    mv.push_back(m);
    102     m = new TMarker(0, 0, 29);
    103     m->SetMarkerColor(kBlue);
    104     m->SetMarkerSize(3);
     87    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    10588    mv.push_back(m);
    106     m = new TMarker(0, 0, 29);
    107     m->SetMarkerColor(kBlue);
    108     m->SetMarkerSize(3);
     89    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    10990    mv.push_back(m);
    110     m = new TMarker(0, 0, 29);
    111     m->SetMarkerColor(kBlue);
    112     m->SetMarkerSize(3);
     91    m = new TMarker(0,0,29); m->SetMarkerColor(kBlue); m->SetMarkerSize(3);
    11392    mv.push_back(m);
    11493    eventMarkers_[(*data)->GetName()] = mv;
     
    11695}
    11796
    118 void DelphesPlotSummary::FillSample(ExRootTreeReader *treeReader, Int_t event_id)
    119 {
     97void DelphesPlotSummary::FillSample(ExRootTreeReader* treeReader, Int_t event_id) {
    12098  Int_t entries = treeReader->GetEntries();
    121   for(Int_t i = 0; i < entries; ++i)
    122   {
     99  for(Int_t i=0;i<entries;++i) {
    123100    treeReader->ReadEntry(i);
    124     for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element)
    125     {
     101    for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) {
    126102      std::vector<TLorentzVector> vectors = (*element)->GetVectors();
    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       {
     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) {
    131106        histograms[0]->Fill(it->Pt());
    132107        histograms[1]->Fill(it->Eta());
    133108        histograms[2]->Fill(it->Phi());
    134         if(it == vectors.begin())
    135         {
     109        if(it==vectors.begin()) {
    136110          histograms[3]->Fill(it->Pt());
    137111          histograms[4]->Fill(it->Eta());
    138112          histograms[5]->Fill(it->Phi());
    139113        }
    140         if(it == vectors.begin() + 1)
    141         {
     114        if(it==vectors.begin()+1) {
    142115          histograms[6]->Fill(it->Pt());
    143116          histograms[7]->Fill(it->Eta());
     
    146119      }
    147120    }
    148     Progress(int(100 * i / entries));
     121    Progress(int(100*i/entries));
    149122  }
    150123  treeReader->ReadEntry(event_id);
     
    152125}
    153126
    154 void 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;
     127void 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;
    166136      histograms[i]->Draw();
    167       if(i < 3)
    168       {
     137      if(i<3) {
    169138        eventProfiles[i]->Draw("same");
    170       }
    171       else
    172       {
    173         eventMarkers[i - 3]->Draw("same");
     139      } else {
     140        eventMarkers[i-3]->Draw("same");
    174141      }
    175142    }
    176143    c->Update();
    177   }
     144  } 
    178145}
    179146
    180 void DelphesPlotSummary::FillEvent()
    181 {
     147void DelphesPlotSummary::FillEvent() {
    182148  // clear event histograms and markers
    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     {
     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) {
    187151      (*h)->Reset();
    188152    }
    189153  }
    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     {
     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) {
    194156      (*m)->SetMarkerSize(0);
    195157    }
    196158  }
    197159  // loop over the elements and fill markers with event data
    198   for(std::vector<DelphesBranchBase *>::iterator element = elements_->begin(); element < elements_->end(); ++element)
    199   {
     160  for(std::vector<DelphesBranchBase*>::iterator element = elements_->begin();element<elements_->end();++element) {
    200161    std::vector<TLorentzVector> vectors = (*element)->GetVectors();
    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     {
     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) {
    212169      h1->Fill(it->Pt());
    213170      h2->Fill(it->Eta());
    214171      h3->Fill(it->Phi());
    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);
     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);
    223176      }
    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);
     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);
    232181      }
    233182    }
  • display/DelphesPlotSummary.h

    r0e7d64a re39abb4  
    2020#define DelphesPlotSummary_h
    2121
    22 #include "DelphesBranchElement.h"
     22#include <vector>
     23#include <map>
     24#include "TString.h"
     25#include "TH1F.h"
    2326#include "TCanvas.h"
    2427#include "TEveWindow.h"
    25 #include "TH1F.h"
    26 #include "TString.h"
     28#include "DelphesBranchElement.h"
    2729#include "external/ExRootAnalysis/ExRootTreeReader.h"
    2830#include <RQ_OBJECT.h>
    29 #include <map>
    30 #include <vector>
     31
    3132
    3233class DelphesPlotSummary
    3334{
    34   RQ_OBJECT("DelphesPlotSummary")
    35 public:
    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*
     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*
    4344
    44 private:
    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_;
     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
    5153};
    5254
    5355#endif // DelphesPlotSummary_h
     56
  • doc/update_fastjet.sh

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

    r0e7d64a re39abb4  
    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)
    19 install(DIRECTORY ExternalFastJet DESTINATION examples)
    20 if(PYTHIA8_FOUND)
    21   install(DIRECTORY Pythia8 DESTINATION examples)
    22 endif()
  • examples/CaloGrid.cpp

    r0e7d64a re39abb4  
    11//calorimeter grid
    2 #include <algorithm>
    3 #include <cassert>
    4 #include <iostream>
     2#include <set>
    53#include <map>
    6 #include <set>
    7 #include <sstream>
    84#include <utility>
    95#include <vector>
     6#include <algorithm>
     7#include <sstream>
     8#include <iostream>
     9#include <cassert>
    1010
     11#include "display/Delphes3DGeometry.h"
     12#include "classes/DelphesClasses.h"
    1113#include "ExRootAnalysis/ExRootConfReader.h"
    12 #include "classes/DelphesClasses.h"
    13 #include "display/Delphes3DGeometry.h"
    1414
    1515#include "TCanvas.h"
     16#include "TStyle.h"
     17#include "TString.h"
     18#include "TText.h"
    1619#include "TH2F.h"
    1720#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 
     42  std::vector<std::string> calorimeters_;
     43  std::map<std::string, std::set< std::pair<Double_t, Int_t> > > caloBinning_;
     44   
     45  std::string s(argv[2]);
     46  std::replace( s.begin(), s.end(), ',', ' ' );
     47  std::istringstream stream( s );
     48  std::string word;
     49  while (stream >> word) calorimeters_.push_back(word);
    4150
    42   std::vector<std::string> calorimeters_;
    43   std::map<std::string, std::set<std::pair<Double_t, Int_t> > > caloBinning_;
     51  caloBinning_.clear();                                                         // calo binning
    4452
    45   std::string s(argv[2]);
    46   std::replace(s.begin(), s.end(), ',', ' ');
    47   std::istringstream stream(s);
    48   std::string word;
    49   while(stream >> word) calorimeters_.push_back(word);
    50 
    51   caloBinning_.clear(); // calo binning
    52 
    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);
     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) ;
    8184
    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 
     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 
    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     {
    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));
     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));
    104103    }
    105104    caloBinning_[*calo] = caloBinning;
    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)
     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++)
    115127    {
    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     }
     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 
    139143  }
    140144
    141145  TString text = TString(s);
    142   TText *th1 = new TText(5.00, 6.45, text);
    143   th1->SetTextAlign(31);
    144   th1->SetTextFont(132);
     146  TText *th1 = new TText(5.00,6.45,text);
     147  th1->SetTextAlign(31); 
     148  th1->SetTextFont(132); 
    145149  th1->SetTextSize(0.075);
    146150  th1->Draw();
    147151
     152
    148153  TString output = TString(s);
    149   c.Print(output + ".png", "png");
    150   c.Print(output + ".pdf", "pdf");
     154  c.Print(output+".png","png");
     155  c.Print(output+".pdf","pdf");
     156 
    151157}
  • examples/Example1.cpp

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920#include <iostream>
    2021#include <utility>
    2122#include <vector>
    2223
    23 #include "TApplication.h"
    2424#include "TROOT.h"
    2525#include "TSystem.h"
     26#include "TApplication.h"
    2627
    2728#include "TString.h"
    2829
    29 #include "TClonesArray.h"
    3030#include "TH2.h"
    3131#include "THStack.h"
    3232#include "TLegend.h"
     33#include "TPaveText.h"
     34#include "TClonesArray.h"
    3335#include "TLorentzVector.h"
    34 #include "TPaveText.h"
    3536
    3637#include "classes/DelphesClasses.h"
    3738
    38 #include "ExRootAnalysis/ExRootResult.h"
    39 #include "ExRootAnalysis/ExRootTreeBranch.h"
    4039#include "ExRootAnalysis/ExRootTreeReader.h"
    4140#include "ExRootAnalysis/ExRootTreeWriter.h"
     41#include "ExRootAnalysis/ExRootTreeBranch.h"
     42#include "ExRootAnalysis/ExRootResult.h"
    4243#include "ExRootAnalysis/ExRootUtilities.h"
    4344
     
    7172  TString inputFile(argv[1]);
    7273
    73   //------------------------------------------------------------------------------
     74//------------------------------------------------------------------------------
    7475
    75   // Here you call your macro's main function
     76// Here you call your macro's main function
    7677
    7778  Example1(inputFile);
    7879
    79   //------------------------------------------------------------------------------
     80//------------------------------------------------------------------------------
     81
    8082}
     83
     84
  • external/ExRootAnalysis/ExRootClassifier.h

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

    r0e7d64a re39abb4  
    1414#include "TSystem.h"
    1515
     16#include <iostream>
     17#include <iomanip>
    1618#include <fstream>
    17 #include <iomanip>
    18 #include <iostream>
     19#include <string>
     20#include <stdexcept>
    1921#include <sstream>
    20 #include <stdexcept>
    21 #include <string>
    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

    r0e7d64a re39abb4  
    2121{
    2222public:
     23
    2324  ExRootConfParam(const char *name = 0, Tcl_Obj *object = 0, Tcl_Interp *interp = 0);
    2425
     
    3334
    3435private:
     36
    3537  const char *fName; //!
    3638  Tcl_Obj *fObject; //!
     
    4042//------------------------------------------------------------------------------
    4143
    42 class ExRootConfReader: public TNamed
     44class ExRootConfReader : public TNamed
    4345{
    4446public:
     
    6466
    6567private:
     68
    6669  const char *fTopDir; //!
    6770
     
    7477
    7578#endif
     79
  • external/ExRootAnalysis/ExRootFilter.cc

    r0e7d64a re39abb4  
    1111#include "ExRootAnalysis/ExRootClassifier.h"
    1212
     13#include "TSeqCollection.h"
    1314#include "TObjArray.h"
    14 #include "TSeqCollection.h"
    1515
    1616#include <iostream>
     17#include <stdexcept>
    1718#include <sstream>
    18 #include <stdexcept>
    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

    r0e7d64a re39abb4  
    1414{
    1515public:
     16
    1617  ExRootFilter(const TSeqCollection *collection);
    1718  ~ExRootFilter();
     
    2223
    2324private:
     25
    2426  const TSeqCollection *fCollection; //!
    2527  TIterator *fIter; //!
    2628
    27   std::map<ExRootClassifier *, std::pair<Bool_t, std::map<Int_t, TObjArray *> > > fMap; //!
     29  std::map<ExRootClassifier*, std::pair<Bool_t, std::map<Int_t, TObjArray*> > > fMap; //!
     30
    2831};
    2932
    3033#endif /* ExRootFilter */
     34
  • external/ExRootAnalysis/ExRootProgressBar.cc

    r0e7d64a re39abb4  
    1414#include <iostream>
    1515
     16#include <string.h>
    1617#include <stdio.h>
    17 #include <string.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

    r0e7d64a re39abb4  
    77{
    88public:
     9
    910  ExRootProgressBar(Long64_t entries, Int_t width = 64);
    1011  ~ExRootProgressBar();
     
    1415
    1516private:
     17
    1618  Long64_t fEntries, fEventCounter;
    1719  Int_t fWidth;
     
    2123
    2224  char *fBar; //!
     25
    2326};
    2427
    2528#endif /* ExRootProgressBar */
     29
  • external/ExRootAnalysis/ExRootResult.cc

    r0e7d64a re39abb4  
    1212#include "ExRootAnalysis/ExRootUtilities.h"
    1313
     14#include "TROOT.h"
     15#include "TFile.h"
     16#include "TClass.h"
     17#include "TStyle.h"
    1418#include "TCanvas.h"
    15 #include "TClass.h"
    16 #include "TFile.h"
    17 #include "TFolder.h"
     19#include "TLegend.h"
     20#include "TPaveText.h"
     21#include "TPaveStats.h"
     22#include "TList.h"
    1823#include "TH2.h"
    1924#include "THStack.h"
    20 #include "TLegend.h"
    21 #include "TList.h"
     25#include "TProfile.h"
    2226#include "TObjArray.h"
    23 #include "TPaveStats.h"
    24 #include "TPaveText.h"
    25 #include "TProfile.h"
    26 #include "TROOT.h"
    27 #include "TStyle.h"
     27#include "TFolder.h"
    2828
    2929#include <iostream>
     
    3737//------------------------------------------------------------------------------
    3838
    39 ExRootResult::ExRootResult() :
    40   fCanvas(0), fFolder(0)
     39ExRootResult::ExRootResult() : fCanvas(0), fFolder(0)
    4140{
    4241}
     
    4645ExRootResult::~ExRootResult()
    4746{
    48   set<TObject *>::iterator itPool;
     47  set<TObject*>::iterator itPool;
    4948  for(itPool = fPool.begin(); itPool != fPool.end(); ++itPool)
    5049  {
     
    6968  TFile *file = new TFile(fileName, "RECREATE");
    7069  file->cd();
    71   std::map<TObject *, PlotSettings>::iterator itPlotMap;
     70  std::map<TObject*, PlotSettings>::iterator itPlotMap;
    7271  for(itPlotMap = fPlotMap.begin(); itPlotMap != fPlotMap.end(); ++itPlotMap)
    7372  {
     
    124123  // gStyle->SetOptFit(101);
    125124
    126   fCanvas = static_cast<TCanvas *>(gROOT->FindObject("c1"));
     125  fCanvas = static_cast<TCanvas*>(gROOT->FindObject("c1"));
    127126  if(fCanvas)
    128127  {
     
    155154  if(!plot) return;
    156155
    157   std::map<TObject *, PlotSettings>::iterator itPlotMap = fPlotMap.find(plot);
     156  std::map<TObject*, PlotSettings>::iterator itPlotMap = fPlotMap.find(plot);
    158157  if(itPlotMap != fPlotMap.end())
    159158  {
     
    179178  if(plot->IsA()->InheritsFrom(TH1::Class()))
    180179  {
    181     histogram = static_cast<TH1 *>(plot);
    182   }
    183 
    184   map<TObject *, PlotSettings>::iterator itPlotMap = fPlotMap.find(plot);
     180    histogram = static_cast<TH1*>(plot);
     181  }
     182
     183  map<TObject*, PlotSettings>::iterator itPlotMap = fPlotMap.find(plot);
    185184  if(itPlotMap != fPlotMap.end())
    186185  {
     
    225224  TCanvas *canvas = GetCanvas();
    226225
    227   map<TObject *, PlotSettings>::iterator itPlotMap;
     226  map<TObject*, PlotSettings>::iterator itPlotMap;
    228227
    229228  for(itPlotMap = fPlotMap.begin(); itPlotMap != fPlotMap.end(); ++itPlotMap)
     
    237236    if(object->IsA()->InheritsFrom(TH1::Class()))
    238237    {
    239       histogram = static_cast<TH1 *>(object);
     238      histogram = static_cast<TH1*>(object);
    240239    }
    241240    else if(object->IsA()->InheritsFrom(THStack::Class()))
    242241    {
    243       stack = static_cast<THStack *>(object);
    244       histogram = static_cast<TH1 *>(stack->GetHists()->First());
     242      stack = static_cast<THStack*>(object);
     243      histogram = static_cast<TH1*>(stack->GetHists()->First());
    245244    }
    246245
     
    272271    if(histogram)
    273272    {
    274       stats = static_cast<TPaveStats *>(histogram->FindObject("stats"));
     273      stats = static_cast<TPaveStats*>(histogram->FindObject("stats"));
    275274      if(stats)
    276275      {
     
    301300
    302301TH1 *ExRootResult::AddHist1D(const char *name, const char *title,
    303   const char *xlabel, const char *ylabel,
    304   Int_t nxbins, Axis_t xmin, Axis_t xmax,
    305   Int_t logx, Int_t logy)
     302                             const char *xlabel, const char *ylabel,
     303                             Int_t nxbins, Axis_t xmin, Axis_t xmax,
     304                             Int_t logx, Int_t logy)
    306305{
    307306  TH1F *hist = new TH1F(name, title, nxbins, xmin, xmax);
     
    325324
    326325TH1 *ExRootResult::AddHist1D(const char *name, const char *title,
    327   const char *xlabel, const char *ylabel,
    328   Int_t nxbins, const Float_t *bins,
    329   Int_t logx, Int_t logy)
     326                             const char *xlabel, const char *ylabel,
     327                             Int_t nxbins, const Float_t *bins,
     328                             Int_t logx, Int_t logy)
    330329{
    331330  TH1F *hist = new TH1F(name, title, nxbins, bins);
     
    349348
    350349TProfile *ExRootResult::AddProfile(const char *name, const char *title,
    351   const char *xlabel, const char *ylabel,
    352   Int_t nxbins, Axis_t xmin, Axis_t xmax,
    353   Int_t logx, Int_t logy)
     350                                   const char *xlabel, const char *ylabel,
     351                                   Int_t nxbins, Axis_t xmin, Axis_t xmax,
     352                                   Int_t logx, Int_t logy)
    354353{
    355354  TProfile *profile = new TProfile(name, title, nxbins, xmin, xmax);
     
    373372
    374373TH2 *ExRootResult::AddHist2D(const char *name, const char *title,
    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)
     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)
    379378{
    380379  TH2F *hist = new TH2F(name, title, nxbins, xmin, xmax, nybins, ymin, ymax);
  • external/ExRootAnalysis/ExRootResult.h

    r0e7d64a re39abb4  
    22#define ExRootResult_h
    33
     4#include "Rtypes.h"
    45#include "Gtypes.h"
    5 #include "Rtypes.h"
    66#include "TMath.h"
    77
     8#include <set>
    89#include <map>
    9 #include <set>
    1010
    1111class TH1;
     
    2323
    2424public:
     25
    2526  ExRootResult();
    2627  ~ExRootResult();
     
    3132
    3233  TH1 *AddHist1D(const char *name, const char *title,
    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);
     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);
    3637
    3738  TH1 *AddHist1D(const char *name, const char *title,
    38     const char *xlabel, const char *ylabel,
    39     Int_t nxbins, const Float_t *bins,
    40     Int_t logx = 0, Int_t logy = 0);
     39                 const char *xlabel, const char *ylabel,
     40                 Int_t nxbins, const Float_t *bins,
     41                 Int_t logx = 0, Int_t logy = 0);
    4142
    4243  TProfile *AddProfile(const char *name, const char *title,
    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);
     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);
    4647
    4748  TH2 *AddHist2D(const char *name, const char *title,
    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);
     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);
    5253
    5354  THStack *AddHistStack(const char *name, const char *title);
     
    6162  TCanvas *GetCanvas();
    6263
    63   void PrintPlot(TObject *plot, const char *sufix = "", const char *format = "eps");
     64  void PrintPlot(TObject *plot, const char *sufix = "",  const char *format = "eps");
    6465
    6566  void SetFolder(TFolder *folder) { fFolder = folder; }
    6667
    6768private:
     69
    6870  struct PlotSettings
    6971  {
     
    7779  TCanvas *fCanvas; //!
    7880
    79   std::set<TObject *> fPool; //!
     81  std::set<TObject*> fPool; //!
    8082
    81   std::map<TObject *, PlotSettings> fPlotMap; //!
     83  std::map<TObject*, PlotSettings> fPlotMap; //!
    8284
    8385  TFolder *fFolder; //!
     86
    8487};
    8588
    8689#endif /* ExRootResult_h */
     90
  • external/ExRootAnalysis/ExRootTask.cc

    r0e7d64a re39abb4  
    1111#include "ExRootAnalysis/ExRootConfReader.h"
    1212
     13#include "TROOT.h"
    1314#include "TClass.h"
    1415#include "TFolder.h"
    15 #include "TROOT.h"
    1616#include "TString.h"
    1717
     18#include <iostream>
    1819#include <iomanip>
    19 #include <iostream>
     20#include <stdexcept>
    2021#include <sstream>
    21 #include <stdexcept>
    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

    r0e7d64a re39abb4  
    1717class TFolder;
    1818
    19 class ExRootTask: public TTask
     19class ExRootTask : public TTask
    2020{
    2121public:
     22
    2223  ExRootTask();
    2324  virtual ~ExRootTask();
     
    4041  ExRootTask *NewTask(const char *className, const char *taskName);
    4142
    42   void Exec(Option_t *option);
     43  void Exec(Option_t* option);
    4344
    4445  int GetInt(const char *name, int defaultValue, int index = -1);
     
    5455
    5556protected:
     57
    5658  TFolder *GetFolder() const { return fFolder; }
    5759  ExRootConfReader *GetConfReader() const { return fConfReader; }
     
    6163
    6264private:
     65
    6366  TFolder *fFolder; //!
    6467  ExRootConfReader *fConfReader; //!
     
    6871
    6972#endif /* ExRootTask */
     73
  • external/ExRootAnalysis/ExRootTreeBranch.cc

    r0e7d64a re39abb4  
    1111#include "ExRootAnalysis/ExRootTreeBranch.h"
    1212
     13#include "TFile.h"
     14#include "TTree.h"
     15#include "TString.h"
    1316#include "TClonesArray.h"
    14 #include "TFile.h"
    15 #include "TString.h"
    16 #include "TTree.h"
    1717
    1818#include <iostream>
     19#include <stdexcept>
    1920#include <sstream>
    20 #include <stdexcept>
    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)
    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;
     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;
    7772
    7873    fData->ExpandCreateFast(fCapacity);
     
    8176    fData->ExpandCreateFast(fSize);
    8277  }
    83 
     78 
    8479  return fData->AddrAt(fSize++);
    8580}
     
    9489
    9590//------------------------------------------------------------------------------
     91
  • external/ExRootAnalysis/ExRootTreeBranch.h

    r0e7d64a re39abb4  
    1919{
    2020public:
     21
    2122  ExRootTreeBranch(const char *name, TClass *cl, TTree *tree = 0);
    2223  ~ExRootTreeBranch();
     
    2627
    2728private:
     29
    2830  Int_t fSize, fCapacity; //!
    2931  TClonesArray *fData; //!
     
    3133
    3234#endif /* ExRootTreeBranch */
     35
  • external/ExRootAnalysis/ExRootTreeReader.cc

    r0e7d64a re39abb4  
    1010#include "ExRootAnalysis/ExRootTreeReader.h"
    1111
    12 #include "TBranchElement.h"
     12#include "TH2.h"
     13#include "TStyle.h"
    1314#include "TCanvas.h"
    1415#include "TClonesArray.h"
    15 #include "TH2.h"
    16 #include "TStyle.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

    r0e7d64a re39abb4  
    1010 */
    1111
     12#include "TROOT.h"
     13#include "TNamed.h"
    1214#include "TChain.h"
    1315#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:
     21public :
     22
    2223  ExRootTreeReader(TTree *tree = 0);
    2324  ~ExRootTreeReader();
     
    3132
    3233private:
     34
    3335  Bool_t Notify();
    3436
     
    3638  Int_t fCurrentTree; //! current Tree number in a TChain
    3739
    38   typedef std::map<TString, std::pair<TBranch *, TClonesArray *> > TBranchMap;
     40  typedef std::map<TString, std::pair<TBranch*, TClonesArray*> > TBranchMap;
    3941
    4042  TBranchMap fBranchMap; //!
  • external/ExRootAnalysis/ExRootTreeWriter.cc

    r0e7d64a re39abb4  
    1111#include "ExRootAnalysis/ExRootTreeBranch.h"
    1212
     13#include "TROOT.h"
     14#include "TFile.h"
     15#include "TTree.h"
    1316#include "TClonesArray.h"
    14 #include "TFile.h"
    15 #include "TROOT.h"
    16 #include "TTree.h"
    1717
    1818#include <iostream>
     19#include <stdexcept>
    1920#include <sstream>
    20 #include <stdexcept>
    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

    r0e7d64a re39abb4  
    1919class ExRootTreeBranch;
    2020
    21 class ExRootTreeWriter: public TNamed
     21class ExRootTreeWriter : public TNamed
    2222{
    2323public:
     24
    2425  ExRootTreeWriter(TFile *file = 0, const char *treeName = "Analysis");
    2526  ~ExRootTreeWriter();
     
    3536
    3637private:
     38
    3739  TTree *NewTree();
    3840
     
    4244  TString fTreeName; //!
    4345
    44   std::set<ExRootTreeBranch *> fBranches; //!
     46  std::set<ExRootTreeBranch*> fBranches; //!
    4547
    4648  ClassDef(ExRootTreeWriter, 1)
     
    4850
    4951#endif /* ExRootTreeWriter */
     52
  • external/ExRootAnalysis/ExRootUtilities.cc

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

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

    r0e7d64a re39abb4  
    1 3.3.2
     13.3.1
  • external/fastjet/config_auto.h

    r0e7d64a re39abb4  
    6565
    6666/* compile the deprecated parts of the interface using auto-ptr */
    67 /* #undef HAVE_AUTO_PTR_INTERFACE */
     67#ifndef FASTJET_HAVE_AUTO_PTR_INTERFACE
     68#define FASTJET_HAVE_AUTO_PTR_INTERFACE  /**/
     69#endif
    6870
    6971/* compiler supports c++14 deprecated keyword */
     
    167169/* Define to the full name and version of this package. */
    168170#ifndef FASTJET_PACKAGE_STRING
    169 #define FASTJET_PACKAGE_STRING  "FastJet 3.3.2"
     171#define FASTJET_PACKAGE_STRING  "FastJet 3.3.1"
    170172#endif
    171173
     
    182184/* Define to the version of this package. */
    183185#ifndef FASTJET_PACKAGE_VERSION
    184 #define FASTJET_PACKAGE_VERSION  "3.3.2"
     186#define FASTJET_PACKAGE_VERSION  "3.3.1"
    185187#endif
    186188
     
    192194/* Version number of package */
    193195#ifndef FASTJET_VERSION
    194 #define FASTJET_VERSION  "3.3.2"
     196#define FASTJET_VERSION  "3.3.1"
    195197#endif
    196198
     
    207209/* Version of the package under the form XYYZZ (instead of X.Y.Z) */
    208210#ifndef FASTJET_VERSION_NUMBER
    209 #define FASTJET_VERSION_NUMBER  30302
     211#define FASTJET_VERSION_NUMBER  30301
    210212#endif
    211213
    212214/* Patch version of this package */
    213215#ifndef FASTJET_VERSION_PATCHLEVEL
    214 #define FASTJET_VERSION_PATCHLEVEL  2
     216#define FASTJET_VERSION_PATCHLEVEL  1
    215217#endif
    216218
  • external/fastjet/config_raw.h

    r0e7d64a re39abb4  
    3939
    4040/* compile the deprecated parts of the interface using auto-ptr */
    41 /* #undef HAVE_AUTO_PTR_INTERFACE */
     41#define 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.2"
     108#define PACKAGE_STRING "FastJet 3.3.1"
    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.2"
     117#define PACKAGE_VERSION "3.3.1"
    118118
    119119/* Define to 1 if you have the ANSI C header files. */
     
    121121
    122122/* Version number of package */
    123 #define VERSION "3.3.2"
     123#define VERSION "3.3.1"
    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 30302
     132#define VERSION_NUMBER 30301
    133133
    134134/* Patch version of this package */
    135 #define VERSION_PATCHLEVEL 2
     135#define VERSION_PATCHLEVEL 1
    136136
    137137/* Pre-release version of this package */
  • external/fastjet/config_win.h

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

    r0e7d64a re39abb4  
    1 The ValenciaPlugin FastJet contrib was written and is maintained and developed by: Ignacio Garcia Garcia, Marcel Vos, IFIC (UVEG/CSIC) Valencia, Spain
     1The ValenciaJetAlgorithm FastJet contrib was written and is maintained and developed by: Ignacio Garcia Garcia, Marcel Vos, IFIC (UVEG/CSIC) Valencia, Spain
    22
    3 The 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
    4 The authors acknowledge suggestions by Gavin P. Salam (CERN) and his help in assessing the IR safety of the algorithm
     3Acknowledging suggestions by Gavin P. Salam (CERN) and J. Thaler (MIT)
    54
    6 The 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)
     5A preprint motivating the algorithm and describing its performance is available on: "A new jet algorithm for lepton colliders", arXiv:1404.4294 (submitted to PLB)
    76
    87Please contact: marcel.vos@ific.uv.es for questions, queries and comments
  • external/fastjet/contribs/ValenciaPlugin/ChangeLog

    r0e7d64a re39abb4  
    1 22-12-2018: Gavin Salam <gavin.salam@cern.ch>
    2         * VERSION:
    3         * NEWS:
    4         updated version to 2.0.2
    5 
    6 2018-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 
    13 2018-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 
    24124-02-2015  Marcel Vos <marcel.vos@ific.uv.es>
    252
  • external/fastjet/contribs/ValenciaPlugin/NEWS

    r0e7d64a re39abb4  
    1 22 December 2018: bug-fix release 2.0.2, for negative beta
    2 04 December 2018: bug-fix release 2.0.1, for massive constituents
    3124 February 2015: version 2.0.0
    4221 February 2015: released 2.0-devel
  • external/fastjet/contribs/ValenciaPlugin/VERSION

    r0e7d64a re39abb4  
    1 2.0.2
     12.0.0
  • external/fastjet/contribs/ValenciaPlugin/ValenciaPlugin.cc

    r0e7d64a re39abb4  
    1 // $Id: ValenciaPlugin.cc 1209 2018-12-05 16:18:01Z vos $
     1// $Id: ValenciaPlugin.cc 776 2015-02-24 17:53:27Z 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     // 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());
     68    diB = pow(E,2*beta) * pow(jet.perp()/E,2*info->gamma()); 
    7069  }
    7170
     
    7978                   - nz*jet->nz;
    8079
    81     if (pow(jet->E,2*beta) < pow(E,2*beta))
     80    if (jet->E < E)
    8281      dij *= 2 * pow(jet->E,2*beta);
    8382    else
  • external/fastjet/contribs/ValenciaPlugin/ValenciaPlugin.hh

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

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

    r0e7d64a re39abb4  
    4848
    4949/* Define to the full name and version of this package. */
    50 #define PACKAGE_STRING "SISCone 3.0.4"
     50#define PACKAGE_STRING "SISCone 3.0.3"
    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.4"
     59#define PACKAGE_VERSION "3.0.3"
    6060
    6161/* Define to 1 if you have the ANSI C header files. */
     
    6666
    6767/* Version number of package */
    68 #define VERSION "3.0.4"
     68#define VERSION "3.0.3"
  • external/fastjet/plugins/SISCone/split_merge.h

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

    r0e7d64a re39abb4  
    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
    490498#   define Tcl_IncrRefCount(objPtr) \
    491499        ++(objPtr)->refCount
     
    494502#   define Tcl_IsShared(objPtr) \
    495503        ((objPtr)->refCount > 1)
     504#endif
    496505
    497506/*
    498507 * 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.
    499510 */
    500511
     
    508519EXTERN Tcl_Obj *        Tcl_NewStringObj _ANSI_ARGS_((char *bytes,
    509520                            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 */
    510538
    511539/*
     
    698726                            unsigned int size));
    699727
     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
     737EXTERN int              Tcl_DumpActiveMemory _ANSI_ARGS_((char *fileName));
     738EXTERN void             Tcl_ValidateAllMemory _ANSI_ARGS_((char *file,
     739                            int line));
     740
     741#else
     742
    700743/*
    701744 * If USE_TCLALLOC is true, then we need to call Tcl_Alloc instead of
     
    717760#  define Tcl_DumpActiveMemory(x)
    718761#  define Tcl_ValidateAllMemory(x,y)
     762
     763#endif /* TCL_MEM_DEBUG */
    719764
    720765/*
  • external/tcl/tclBasic.c

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

    r0e7d64a re39abb4  
    2222#define TRUE    1
    2323
    24 /*
    25  *----------------------------------------------------------------------
    26  *
    27  * Tcl_Alloc --
    28  *      Interface to TclpAlloc.
    29  *      It does check that memory was actually allocated.
    30  *
    31  *----------------------------------------------------------------------
    32  */
    33 
    34 char *
    35 Tcl_Alloc (size)
    36     unsigned int size;
    37 {
    38         char *result;
    39 
    40         result = TclpAlloc(size);
    41         if (result == NULL)
    42                 panic("unable to alloc %d bytes", size);
    43         return result;
    44 }
    45 
     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
     31typedef 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
     41static 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)
     51struct 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
     68static 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
     88static int total_mallocs = 0;
     89static int total_frees = 0;
     90static int current_bytes_malloced = 0;
     91static int maximum_bytes_malloced = 0;
     92static int current_malloc_packets = 0;
     93static int maximum_malloc_packets = 0;
     94static int break_on_malloc = 0;
     95static int trace_on_at_malloc = 0;
     96static int  alloc_tracing = FALSE;
     97static 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
     108static int              MemoryCmd _ANSI_ARGS_((ClientData clientData,
     109                            Tcl_Interp *interp, int argc, char **argv));
     110static 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 */
     123void
     124TclDumpMemoryInfo(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 */
     150static void
     151ValidateMemory(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 */
     221void
     222Tcl_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 */
     245int
     246Tcl_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 */
    46289char *
    47290Tcl_DbCkalloc(size, file, line)
     
    50293    int          line;
    51294{
    52     char *result;
    53 
    54     result = (char *) TclpAlloc(size);
    55 
     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);
    56302    if (result == NULL) {
    57303        fflush(stdout);
     304        TclDumpMemoryInfo(stderr);
    58305        panic("unable to alloc %d bytes, %s line %d", size, file,
    59306              line);
    60307    }
    61     return result;
    62 }
    63 
    64 
    65 
    66 /*
    67  *----------------------------------------------------------------------
    68  *
    69  * Tcl_Realloc --
    70  *      Interface to TclpRealloc.
    71  *      It does check that memory was actually allocated.
    72  *
    73  *----------------------------------------------------------------------
    74  */
    75 
    76 char *
    77 Tcl_Realloc(ptr, size)
    78     char *ptr;
    79     unsigned int size;
    80 {
    81     char *result;
    82 
    83     result = TclpRealloc(ptr, size);
    84     if (result == NULL)
    85         panic("unable to realloc %d bytes", size);
    86     return result;
    87 }
    88 
     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
     388int
     389Tcl_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 */
    89454char *
    90455Tcl_DbCkrealloc(ptr, size, file, line)
     
    94459    int line;
    95460{
     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
     505char *
     506Tcl_Alloc(size)
     507    unsigned int size;
     508{
     509    return Tcl_DbCkalloc(size, "unknown", 0);
     510}
     511
     512void
     513Tcl_Free(ptr)
     514    char *ptr;
     515{
     516    Tcl_DbCkfree(ptr, "unknown", 0);
     517}
     518
     519char *
     520Tcl_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 */
     546static int
     547MemoryCmd (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
     646argError:
     647    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
     648            " ", argv[1], " count\"", (char *) NULL);
     649    return TCL_ERROR;
     650
     651bad_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 */
     666void
     667Tcl_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
     678/*
     679 *----------------------------------------------------------------------
     680 *
     681 * Tcl_Alloc --
     682 *     Interface to TclpAlloc when TCL_MEM_DEBUG is disabled.  It does check
     683 *     that memory was actually allocated.
     684 *
     685 *----------------------------------------------------------------------
     686 */
     687
     688char *
     689Tcl_Alloc (size)
     690    unsigned int size;
     691{
     692        char *result;
     693
     694        result = TclpAlloc(size);
     695        if (result == NULL)
     696                panic("unable to alloc %d bytes", size);
     697        return result;
     698}
     699
     700char *
     701Tcl_DbCkalloc(size, file, line)
     702    unsigned int size;
     703    char        *file;
     704    int          line;
     705{
     706    char *result;
     707
     708    result = (char *) TclpAlloc(size);
     709
     710    if (result == NULL) {
     711        fflush(stdout);
     712        panic("unable to alloc %d bytes, %s line %d", size, file,
     713              line);
     714    }
     715    return result;
     716}
     717
     718
     719
     720/*
     721 *----------------------------------------------------------------------
     722 *
     723 * Tcl_Realloc --
     724 *     Interface to TclpRealloc when TCL_MEM_DEBUG is disabled.  It does
     725 *     check that memory was actually allocated.
     726 *
     727 *----------------------------------------------------------------------
     728 */
     729
     730char *
     731Tcl_Realloc(ptr, size)
     732    char *ptr;
     733    unsigned int size;
     734{
     735    char *result;
     736
     737    result = TclpRealloc(ptr, size);
     738    if (result == NULL)
     739        panic("unable to realloc %d bytes", size);
     740    return result;
     741}
     742
     743char *
     744Tcl_DbCkrealloc(ptr, size, file, line)
     745    char *ptr;
     746    unsigned int size;
     747    char *file;
     748    int line;
     749{
    96750    char *result;
    97751
     
    111765 *
    112766 * Tcl_Free --
    113  *      Interface to TclpFree.
     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.
    114770 *
    115771 *----------------------------------------------------------------------
     
    122778        TclpFree(ptr);
    123779}
     780
     781int
     782Tcl_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 */
     802void
     803Tcl_InitMemory(interp)
     804    Tcl_Interp *interp;
     805{
     806}
     807
     808#undef Tcl_DumpActiveMemory
     809#undef Tcl_ValidateAllMemory
     810
     811extern int              Tcl_DumpActiveMemory _ANSI_ARGS_((char *fileName));
     812extern void             Tcl_ValidateAllMemory _ANSI_ARGS_((char *file,
     813                            int line));
     814
     815int
     816Tcl_DumpActiveMemory(fileName)
     817    char *fileName;
     818{
     819    return TCL_OK;
     820}
     821
     822void
     823Tcl_ValidateAllMemory(file, line)
     824    char  *file;
     825    int    line;
     826{
     827}
     828
     829#endif
  • external/tcl/tclCompExpr.c

    r0e7d64a re39abb4  
    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
     40static int traceCompileExpr = 0;
     41#endif /* TCL_COMPILE_DEBUG */
    3342
    3443/*
     
    123132#define NOT             (COLON + 1)
    124133#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
     141static char *tokenStrings[] = {
     142    "LITERAL", "FUNCNAME",
     143    "[", "]", "(", ")", "$", "\"", ",", "END", "UNKNOWN",
     144    "*", "/", "%", "+", "-",
     145    "<<", ">>", "<", ">", "<=", ">=", "==", "!=",
     146    "&", "^", "|", "&&", "||", "?", ":",
     147    "!", "~"
     148};
     149#endif /* TCL_COMPILE_DEBUG */
    125150
    126151/*
     
    173198                            ExprInfo *infoPtr, CompileEnv *envPtr));
    174199
     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 */
    175215
    176216
     
    237277                                 * to execute the expression. */
    238278    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 */
    239285
    240286    /*
     
    363409    int elseCodeOffset, currCodeOffset, jumpDist, result;
    364410   
     411    HERE("condExpr", 1);
    365412    result = CompileLorExpr(interp, infoPtr, flags, envPtr);
    366413    if (result != TCL_OK) {
     
    524571    Tcl_Obj *objPtr;
    525572   
     573    HERE("lorExpr", 2);
    526574    result = CompileLandExpr(interp, infoPtr, flags, envPtr);
    527575    if ((result != TCL_OK) || (infoPtr->token != OR)) {
     
    691739    Tcl_Obj *objPtr;
    692740
     741    HERE("landExpr", 3);
    693742    result = CompileBitOrExpr(interp, infoPtr, flags, envPtr);
    694743    if ((result != TCL_OK) || (infoPtr->token != AND)) {
     
    850899    int result;
    851900
     901    HERE("bitOrExpr", 4);
    852902    result = CompileBitXorExpr(interp, infoPtr, flags, envPtr);
    853903    if (result != TCL_OK) {
     
    920970    int result;
    921971
     972    HERE("bitXorExpr", 5);
    922973    result = CompileBitAndExpr(interp, infoPtr, flags, envPtr);
    923974    if (result != TCL_OK) {
     
    9901041    int result;
    9911042
     1043    HERE("bitAndExpr", 6);
    9921044    result = CompileEqualityExpr(interp, infoPtr, flags, envPtr);
    9931045    if (result != TCL_OK) {
     
    10601112    int op, result;
    10611113
     1114    HERE("equalityExpr", 7);
    10621115    result = CompileRelationalExpr(interp, infoPtr, flags, envPtr);
    10631116    if (result != TCL_OK) {
     
    11371190    int op, result;
    11381191
     1192    HERE("relationalExpr", 8);
    11391193    result = CompileShiftExpr(interp, infoPtr, flags, envPtr);
    11401194    if (result != TCL_OK) {
     
    12231277    int op, result;
    12241278
     1279    HERE("shiftExpr", 9);
    12251280    result = CompileAddExpr(interp, infoPtr, flags, envPtr);
    12261281    if (result != TCL_OK) {
     
    13001355    int op, result;
    13011356
     1357    HERE("addExpr", 10);
    13021358    result = CompileMultiplyExpr(interp, infoPtr, flags, envPtr);
    13031359    if (result != TCL_OK) {
     
    13771433    int op, result;
    13781434
     1435    HERE("multiplyExpr", 11);
    13791436    result = CompileUnaryExpr(interp, infoPtr, flags, envPtr);
    13801437    if (result != TCL_OK) {
     
    14561513    int op, result;
    14571514
     1515    HERE("unaryExpr", 12);
    14581516    op = infoPtr->token;
    14591517    if ((op == PLUS) || (op == MINUS) || (op == BIT_NOT) || (op == NOT)) {
     
    15501608     */
    15511609
     1610    HERE("primaryExpr", 13);
    15521611    theToken = infoPtr->token;
    15531612
  • external/tcl/tclCompile.c

    r0e7d64a re39abb4  
    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
     29int tclTraceCompile = 0;
     30static 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
     38long tclNumCompilations = 0;
     39double tclTotalSourceBytes = 0.0;
     40double tclTotalCodeBytes = 0.0;
     41
     42double tclTotalInstBytes = 0.0;
     43double tclTotalObjBytes = 0.0;
     44double tclTotalExceptBytes = 0.0;
     45double tclTotalAuxBytes = 0.0;
     46double tclTotalCmdMapBytes = 0.0;
     47
     48double tclCurrentSourceBytes = 0.0;
     49double tclCurrentCodeBytes = 0.0;
     50
     51int tclSourceCount[32];
     52int tclByteCodeCount[32];
     53#endif /* TCL_COMPILE_STATS */
    1954
    2055/*
     
    408443 *----------------------------------------------------------------------
    409444 *
     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
     459void
     460TclPrintByteCodeObj(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
     731int
     732TclPrintInstruction(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 *
    410845 * TclPrintSource --
    411846 *
     
    537972    register int i;
    538973
     974#ifdef TCL_COMPILE_STATS   
     975    tclCurrentSourceBytes -= (double) codePtr->numSrcChars;
     976    tclCurrentCodeBytes -= (double) codePtr->totalSize;
     977#endif /* TCL_COMPILE_STATS */
     978
    539979    /*
    540980     * A single heap object holds the ByteCode structure and its code,
     
    6271067    int length, result;
    6281068
     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   
    6291077    string = Tcl_GetStringFromObj(objPtr, &length);
    6301078    TclInitCompileEnv(interp, &compEnv, string);
     
    6651113    TclFreeCompileEnv(&compEnv);
    6661114
     1115    if (result == TCL_OK) {
     1116        if (tclTraceCompile == 2) {
     1117            TclPrintByteCodeObj(interp, objPtr);
     1118        }
     1119    }
    6671120    return result;
    6681121}
     
    8581311    int numObjects, i;
    8591312    Namespace *namespacePtr;
     1313#ifdef TCL_COMPILE_STATS
     1314    int srcLenLog2, sizeLog2;
     1315#endif /*TCL_COMPILE_STATS*/
    8601316
    8611317    codeBytes = (envPtr->codeNext - envPtr->codeStart);
     
    8861342    }
    8871343    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 */   
    8881367
    8891368    if (envPtr->iPtr->varFramePtr != NULL) {
     
    13411820                cmdCodeOffset);
    13421821           
     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       
    13431848        while ((type != TCL_COMMAND_END)
    13441849                || ((c == ']') && !(flags & TCL_BRACKET_TERM))) {
  • external/tcl/tclCompile.h

    r0e7d64a re39abb4  
    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
     48extern 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
     60extern 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
     71extern long             tclNumCompilations;
     72extern double           tclTotalSourceBytes;
     73extern double           tclTotalCodeBytes;
     74
     75extern double           tclTotalInstBytes;
     76extern double           tclTotalObjBytes;
     77extern double           tclTotalExceptBytes;
     78extern double           tclTotalAuxBytes;
     79extern double           tclTotalCmdMapBytes;
     80
     81extern double           tclCurrentSourceBytes;
     82extern double           tclCurrentCodeBytes;
     83
     84extern int              tclSourceCount[32];
     85extern int              tclByteCodeCount[32];
     86#endif /* TCL_COMPILE_STATS */
    3887
    3988/*
     
    767816EXTERN void             TclInitJumpFixupArray _ANSI_ARGS_((
    768817                            JumpFixupArray *fixupArrayPtr));
     818#ifdef TCL_COMPILE_STATS
     819EXTERN int              TclLog2 _ANSI_ARGS_((int value));
     820#endif /*TCL_COMPILE_STATS*/
    769821EXTERN int              TclObjIndexForString _ANSI_ARGS_((char *start,
    770822                            int length, int allocStrRep, int inHeap,
    771823                            CompileEnv *envPtr));
     824EXTERN int              TclPrintInstruction _ANSI_ARGS_((ByteCode* codePtr,
     825                            unsigned char *pc));
    772826EXTERN void             TclPrintSource _ANSI_ARGS_((FILE *outFile,
    773827                            char *string, int maxChars));
  • external/tcl/tclExecute.c

    r0e7d64a re39abb4  
    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
     62int tclTraceExec = 0;
     63
     64/*
    5365 * The following global variable is use to signal matherr that Tcl
    5466 * is responsible for the arithmetic, so errors can be handled in a
     
    90102};
    91103   
     104/*
     105 * Mapping from Tcl result codes to strings; used for error and debugging
     106 * messages.
     107 */
     108
     109#ifdef TCL_COMPILE_DEBUG
     110static 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
     122static long numExecutions = 0;
     123static int instructionCount[256];
     124#endif /* TCL_COMPILE_STATS */
     125
    92126/*
    93127 * Macros for testing floating-point values for certain special cases. Test
     
    153187#define POP_OBJECT() \
    154188    (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 */
    155251
    156252/*
     
    178274static int              ExprUnaryFunc _ANSI_ARGS_((Tcl_Interp *interp,
    179275                            ExecEnv *eePtr, ClientData clientData));
     276#ifdef TCL_COMPILE_STATS
     277static int              EvalStatsCmd _ANSI_ARGS_((ClientData clientData,
     278                            Tcl_Interp *interp, int argc, char **argv));
     279#endif /* TCL_COMPILE_STATS */
    180280static void             FreeCmdNameInternalRep _ANSI_ARGS_((
    181281                            Tcl_Obj *objPtr));
     
    193293static int              SetCmdNameFromAny _ANSI_ARGS_((Tcl_Interp *interp,
    194294                            Tcl_Obj *objPtr));
     295#ifdef TCL_COMPILE_DEBUG
     296static char *           StringForResultCode _ANSI_ARGS_((int result));
     297#endif /* TCL_COMPILE_DEBUG */
    195298static void             UpdateStringOfCmdName _ANSI_ARGS_((Tcl_Obj *objPtr));
     299#ifdef TCL_COMPILE_DEBUG
     300static void             ValidatePcAndStackTop _ANSI_ARGS_((
     301                            ByteCode *codePtr, unsigned char *pc,
     302                            int stackTop, int stackLowerBound,
     303                            int stackUpperBound));
     304#endif /* TCL_COMPILE_DEBUG */
    196305
    197306/*
     
    259368 *
    260369 * Side effects:
    261  *      This procedure initializes the array of instruction names.
     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.
    262376 *
    263377 *----------------------------------------------------------------------
     
    277391    for (i = 0;  instructionTable[i].name != NULL;  i++) {
    278392        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");
    279407    }
    280408}
     
    470598                                 * process break, continue, and errors. */
    471599    int result = TCL_OK;        /* Return code returned after execution. */
     600    int traceInstructions = (tclTraceExec == 3);
    472601    Tcl_Obj *valuePtr, *value2Ptr, *namePtr, *objPtr;
    473602    char *bytes;
    474603    int length;
    475604    long i;
     605    Tcl_DString command;        /* Used for debugging. If tclTraceExec >= 2
     606                                 * holds a string representing the last
     607                                 * command invoked. */
    476608
    477609    /*
     
    488620
    489621    /*
     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    /*
    490641     * Make sure the catch stack is large enough to hold the maximum number
    491642     * of catch commands that could ever be executing at the same time. This
     
    508659
    509660    /*
     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    /*
    510668     * Loop executing instructions until a "done" instruction, a TCL_RETURN,
    511669     * or some error.
     
    513671
    514672    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       
    515689        opCode = *pc;
     690#ifdef TCL_COMPILE_STATS   
     691        instructionCount[opCode]++;
     692#endif /* TCL_COMPILE_STATS */
    516693
    517694        switch (opCode) {
     
    533710                panic("TclExecuteByteCode execution failure: end stack top != start stack top");
    534711            }
     712            TRACE_WITH_OBJ(("done => return code=%d, result is ", result),
     713                    iPtr->objResultPtr);
    535714            goto done;
    536715           
     
    538717            valuePtr = objArrayPtr[TclGetUInt1AtPtr(pc+1)];
    539718            PUSH_OBJECT(valuePtr);
     719            TRACE_WITH_OBJ(("push1 %u => ", TclGetUInt1AtPtr(pc+1)),
     720                    valuePtr);
    540721            ADJUST_PC(2);
    541722           
     
    543724            valuePtr = objArrayPtr[TclGetUInt4AtPtr(pc+1)];
    544725            PUSH_OBJECT(valuePtr);
     726            TRACE_WITH_OBJ(("push4 %u => ", TclGetUInt4AtPtr(pc+1)),
     727                    valuePtr);
    545728            ADJUST_PC(5);
    546729           
    547730        case INST_POP:
    548731            valuePtr = POP_OBJECT();
     732            TRACE_WITH_OBJ(("pop => discarding "), valuePtr);
    549733            TclDecrRefCount(valuePtr); /* finished with pop'ed object. */
    550734            ADJUST_PC(1);
     
    553737            valuePtr = stackPtr[stackTop].o;
    554738            PUSH_OBJECT(Tcl_DuplicateObj(valuePtr));
     739            TRACE_WITH_OBJ(("dup => "), valuePtr);
    555740            ADJUST_PC(1);
    556741
     
    605790               
    606791                PUSH_OBJECT(concatObjPtr);
     792                TRACE_WITH_OBJ(("concat %u => ", opnd), concatObjPtr);
    607793                ADJUST_PC(2);
    608794            }
     
    629815                                    * Init. to avoid compiler warning. */
    630816                Tcl_Command cmd;
     817#ifdef TCL_COMPILE_DEBUG
     818                int isUnknownCmd = 0;
     819                char cmdNameBuf[30];
     820#endif /* TCL_COMPILE_DEBUG */
    631821               
    632822                /*
     
    677867                                "invalid command name \"", cmdName, "\"",
    678868                                (char *) NULL);
     869                        TRACE(("%s %u => unknown proc not found: ",
     870                               opName[opCode], objc));
    679871                        result = TCL_ERROR;
    680872                        goto checkForCatch;
    681873                    }
    682874                    cmdPtr = (Command *) cmd;
     875#ifdef TCL_COMPILE_DEBUG
     876                    isUnknownCmd = 1;
     877#endif /*TCL_COMPILE_DEBUG*/                   
    683878                    stackTop++; /* need room for new inserted objv[0] */
    684879                    for (i = objc;  i >= 0;  i--) {
     
    723918                Tcl_ResetResult(interp);
    724919
     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
    725953                iPtr->cmdCount++;
    726954                DECACHE_STACK_INFO();
     
    768996                     */
    769997                    PUSH_OBJECT(Tcl_GetObjResult(interp));
     998                    TRACE_WITH_OBJ(("%s %u => ...after \"%.20s\", result=",
     999                            opName[opCode], objc, cmdNameBuf),
     1000                            Tcl_GetObjResult(interp));
    7701001                    ADJUST_PC(pcAdjustment);
    7711002                   
     
    7841015                            /*catchOnly*/ 0, codePtr);
    7851016                    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)));
    7861020                        goto abnormalReturn; /* no catch exists to check */
    7871021                    }
     
    7911025                            newPcOffset = rangePtr->breakOffset;
    7921026                        } 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)));
    7931030                            goto checkForCatch;
    7941031                        } else {
    7951032                            newPcOffset = rangePtr->continueOffset;
    7961033                        }
     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));
    7971038                        break;
    7981039                    case CATCH_EXCEPTION_RANGE:
     1040                        TRACE(("%s %u => ... after \"%.20s\", %s...\n",
     1041                               opName[opCode], objc, cmdNameBuf,
     1042                               StringForResultCode(result)));
    7991043                        goto processCatch; /* it will use rangePtr */
    8001044                    default:
     
    8101054                     * enclosing catch exception range, if any.
    8111055                     */
     1056                    TRACE_WITH_OBJ(("%s %u => ... after \"%.20s\", TCL_ERROR ",
     1057                            opName[opCode], objc, cmdNameBuf),
     1058                            Tcl_GetObjResult(interp));
    8121059                    goto checkForCatch;
    8131060
     
    8181065                     * for an enclosing catch exception range, if any.
    8191066                     */
     1067                    TRACE(("%s %u => ... after \"%.20s\", TCL_RETURN\n",
     1068                            opName[opCode], objc, cmdNameBuf));
    8201069                    goto checkForCatch;
    8211070
    8221071                default:
     1072                    TRACE_WITH_OBJ(("%s %u => ... after \"%.20s\", OTHER RETURN CODE %d ",
     1073                            opName[opCode], objc, cmdNameBuf, result),
     1074                            Tcl_GetObjResult(interp));
    8231075                    goto checkForCatch;
    8241076                } /* end of switch on result from invoke instruction */
     
    8361088               
    8371089                PUSH_OBJECT(Tcl_GetObjResult(interp));
     1090                TRACE_WITH_OBJ(("evalStk \"%.30s\" => ", O2S(objPtr)),
     1091                        Tcl_GetObjResult(interp));
    8381092                TclDecrRefCount(objPtr);
    8391093                ADJUST_PC(1);
     
    8551109                        codePtr);
    8561110                if (rangePtr == NULL) {
     1111                    TRACE(("evalStk \"%.30s\" => no encl. loop or catch, returning %s\n",
     1112                            O2S(objPtr), StringForResultCode(result)));
    8571113                    Tcl_DecrRefCount(objPtr);
    8581114                    goto abnormalReturn;    /* no catch exists to check */
     
    8631119                        newPcOffset = rangePtr->breakOffset;
    8641120                    } else if (rangePtr->continueOffset == -1) {
     1121                        TRACE(("evalStk \"%.30s\" => %s, loop w/o continue, checking for catch\n",
     1122                               O2S(objPtr), StringForResultCode(result)));
    8651123                        Tcl_DecrRefCount(objPtr);
    8661124                        goto checkForCatch;
     
    8691127                    }
    8701128                    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);
    8711132                    break;
    8721133                case CATCH_EXCEPTION_RANGE:
     1134                    TRACE_WITH_OBJ(("evalStk \"%.30s\" => %s ",
     1135                            O2S(objPtr), StringForResultCode(result)),
     1136                            valuePtr);
    8731137                    Tcl_DecrRefCount(objPtr);
    8741138                    goto processCatch;  /* it will use rangePtr */
     
    8801144                continue;       /* restart outer instruction loop at pc */
    8811145            } else { /* eval returned TCL_ERROR, TCL_RETURN, unknown code */
     1146                TRACE_WITH_OBJ(("evalStk \"%.30s\" => ERROR: ", O2S(objPtr)),
     1147                        Tcl_GetObjResult(interp));
    8821148                Tcl_DecrRefCount(objPtr);
    8831149                goto checkForCatch;
     
    8911157            CACHE_STACK_INFO();
    8921158            if (result != TCL_OK) {
     1159                TRACE_WITH_OBJ(("exprStk \"%.30s\" => ERROR: ",
     1160                        O2S(objPtr)), Tcl_GetObjResult(interp));
    8931161                Tcl_DecrRefCount(objPtr);
    8941162                goto checkForCatch;
    8951163            }
    8961164            stackPtr[++stackTop].o = valuePtr; /* already has right refct */
     1165            TRACE_WITH_OBJ(("exprStk \"%.30s\" => ", O2S(objPtr)), valuePtr);
    8971166            TclDecrRefCount(objPtr);
    8981167            ADJUST_PC(1);
     
    9131182            CACHE_STACK_INFO();
    9141183            if (valuePtr == NULL) {
     1184                TRACE_WITH_OBJ(("%s %u => ERROR: ", opName[opCode], opnd),
     1185                        Tcl_GetObjResult(interp));
    9151186                result = TCL_ERROR;
    9161187                goto checkForCatch;
    9171188            }
    9181189            PUSH_OBJECT(valuePtr);
     1190            TRACE_WITH_OBJ(("%s %u => ", opName[opCode], opnd), valuePtr);
    9191191            ADJUST_PC(pcAdjustment);
    9201192
     
    9261198            CACHE_STACK_INFO();
    9271199            if (valuePtr == NULL) {
     1200                TRACE_WITH_OBJ(("loadScalarStk \"%.30s\" => ERROR: ",
     1201                        O2S(namePtr)), Tcl_GetObjResult(interp));
    9281202                Tcl_DecrRefCount(namePtr);
    9291203                result = TCL_ERROR;
     
    9311205            }
    9321206            PUSH_OBJECT(valuePtr);
     1207            TRACE_WITH_OBJ(("loadScalarStk \"%.30s\" => ",
     1208                    O2S(namePtr)), valuePtr);
    9331209            TclDecrRefCount(namePtr);
    9341210            ADJUST_PC(1);
     
    9521228                CACHE_STACK_INFO();
    9531229                if (valuePtr == NULL) {
     1230                    TRACE_WITH_OBJ(("%s %u \"%.30s\" => ERROR: ",
     1231                            opName[opCode], opnd, O2S(elemPtr)),
     1232                            Tcl_GetObjResult(interp));
    9541233                    Tcl_DecrRefCount(elemPtr);
    9551234                    result = TCL_ERROR;
     
    9571236                }
    9581237                PUSH_OBJECT(valuePtr);
     1238                TRACE_WITH_OBJ(("%s %u \"%.30s\" => ",
     1239                        opName[opCode], opnd, O2S(elemPtr)), valuePtr);
    9591240                TclDecrRefCount(elemPtr);
    9601241            }
     
    9711252                CACHE_STACK_INFO();
    9721253                if (valuePtr == NULL) {
     1254                    TRACE_WITH_OBJ(("loadArrayStk \"%.30s(%.30s)\" => ERROR: ",
     1255                            O2S(namePtr), O2S(elemPtr)),
     1256                            Tcl_GetObjResult(interp));
    9731257                    Tcl_DecrRefCount(namePtr);
    9741258                    Tcl_DecrRefCount(elemPtr);
     
    9771261                }
    9781262                PUSH_OBJECT(valuePtr);
     1263                TRACE_WITH_OBJ(("loadArrayStk \"%.30s(%.30s)\" => ",
     1264                        O2S(namePtr), O2S(elemPtr)), valuePtr);
    9791265                TclDecrRefCount(namePtr);
    9801266                TclDecrRefCount(elemPtr);
     
    9891275            CACHE_STACK_INFO();
    9901276            if (valuePtr == NULL) {
     1277                TRACE_WITH_OBJ(("loadStk \"%.30s\" => ERROR: ",
     1278                        O2S(namePtr)), Tcl_GetObjResult(interp));
    9911279                Tcl_DecrRefCount(namePtr);
    9921280                result = TCL_ERROR;
     
    9941282            }
    9951283            PUSH_OBJECT(valuePtr);
     1284            TRACE_WITH_OBJ(("loadStk \"%.30s\" => ", O2S(namePtr)),
     1285                    valuePtr);
    9961286            TclDecrRefCount(namePtr);
    9971287            ADJUST_PC(1);
     
    10131303            CACHE_STACK_INFO();
    10141304            if (value2Ptr == NULL) {
     1305                TRACE_WITH_OBJ(("%s %u <- \"%.30s\" => ERROR: ",
     1306                        opName[opCode], opnd, O2S(valuePtr)),
     1307                        Tcl_GetObjResult(interp));
    10151308                Tcl_DecrRefCount(valuePtr);
    10161309                result = TCL_ERROR;
     
    10181311            }
    10191312            PUSH_OBJECT(value2Ptr);
     1313            TRACE_WITH_OBJ(("%s %u <- \"%.30s\" => ",
     1314                    opName[opCode], opnd, O2S(valuePtr)), value2Ptr);
    10201315            TclDecrRefCount(valuePtr);
    10211316            ADJUST_PC(pcAdjustment);
     
    10291324            CACHE_STACK_INFO();
    10301325            if (value2Ptr == NULL) {
     1326                TRACE_WITH_OBJ(
     1327                        ("storeScalarStk \"%.30s\" <- \"%.30s\" => ERROR: ",
     1328                        O2S(namePtr), O2S(valuePtr)),
     1329                        Tcl_GetObjResult(interp));
    10311330                Tcl_DecrRefCount(namePtr);
    10321331                Tcl_DecrRefCount(valuePtr);
     
    10351334            }
    10361335            PUSH_OBJECT(value2Ptr);
     1336            TRACE_WITH_OBJ(
     1337                    ("storeScalarStk \"%.30s\" <- \"%.30s\" => ",
     1338                    O2S(namePtr),
     1339                    O2S(valuePtr)),
     1340                    value2Ptr);
    10371341            TclDecrRefCount(namePtr);
    10381342            TclDecrRefCount(valuePtr);
     
    10591363                CACHE_STACK_INFO();
    10601364                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));
    10611369                    Tcl_DecrRefCount(elemPtr);
    10621370                    Tcl_DecrRefCount(valuePtr);
     
    10651373                }
    10661374                PUSH_OBJECT(value2Ptr);
     1375                TRACE_WITH_OBJ(("%s %u \"%.30s\" <- \"%.30s\" => ",
     1376                        opName[opCode], opnd, O2S(elemPtr), O2S(valuePtr)),
     1377                        value2Ptr);
    10671378                TclDecrRefCount(elemPtr);
    10681379                TclDecrRefCount(valuePtr);
     
    10821393                CACHE_STACK_INFO();
    10831394                if (value2Ptr == NULL) {
     1395                    TRACE_WITH_OBJ(("storeArrayStk \"%.30s(%.30s)\" <- \"%.30s\" => ERROR: ",
     1396                            O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),
     1397                            Tcl_GetObjResult(interp));
    10841398                    Tcl_DecrRefCount(namePtr);
    10851399                    Tcl_DecrRefCount(elemPtr);
     
    10891403                }
    10901404                PUSH_OBJECT(value2Ptr);
     1405                TRACE_WITH_OBJ(("storeArrayStk \"%.30s(%.30s)\" <- \"%.30s\" => ",
     1406                        O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),
     1407                        value2Ptr);
    10911408                TclDecrRefCount(namePtr);
    10921409                TclDecrRefCount(elemPtr);
     
    11031420            CACHE_STACK_INFO();
    11041421            if (value2Ptr == NULL) {
     1422                TRACE_WITH_OBJ(("storeStk \"%.30s\" <- \"%.30s\" => ERROR: ",
     1423                        O2S(namePtr), O2S(valuePtr)),
     1424                        Tcl_GetObjResult(interp));
    11051425                Tcl_DecrRefCount(namePtr);
    11061426                Tcl_DecrRefCount(valuePtr);
     
    11091429            }
    11101430            PUSH_OBJECT(value2Ptr);
     1431            TRACE_WITH_OBJ(("storeStk \"%.30s\" <- \"%.30s\" => ",
     1432                    O2S(namePtr), O2S(valuePtr)), value2Ptr);
    11111433            TclDecrRefCount(namePtr);
    11121434            TclDecrRefCount(valuePtr);
     
    11191441                result = tclIntType.setFromAnyProc(interp, valuePtr);
    11201442                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));
    11211445                    Tcl_DecrRefCount(valuePtr);
    11221446                    goto checkForCatch;
     
    11281452            CACHE_STACK_INFO();
    11291453            if (value2Ptr == NULL) {
     1454                TRACE_WITH_OBJ(("incrScalar1 %u (by %ld) => ERROR: ",
     1455                        opnd, i), Tcl_GetObjResult(interp));
    11301456                Tcl_DecrRefCount(valuePtr);
    11311457                result = TCL_ERROR;
     
    11331459            }
    11341460            PUSH_OBJECT(value2Ptr);
     1461            TRACE_WITH_OBJ(("incrScalar1 %u (by %ld) => ", opnd, i),
     1462                    value2Ptr);
    11351463            TclDecrRefCount(valuePtr);
    11361464            ADJUST_PC(2);
     
    11431471                result = tclIntType.setFromAnyProc(interp, valuePtr);
    11441472                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));
    11451476                    Tcl_DecrRefCount(namePtr);
    11461477                    Tcl_DecrRefCount(valuePtr);
     
    11541485            CACHE_STACK_INFO();
    11551486            if (value2Ptr == NULL) {
     1487                TRACE_WITH_OBJ(("%s \"%.30s\" (by %ld) => ERROR: ",
     1488                        opName[opCode], O2S(namePtr), i),
     1489                        Tcl_GetObjResult(interp));
    11561490                Tcl_DecrRefCount(namePtr);
    11571491                Tcl_DecrRefCount(valuePtr);
     
    11601494            }
    11611495            PUSH_OBJECT(value2Ptr);
     1496            TRACE_WITH_OBJ(("%s \"%.30s\" (by %ld) => ",
     1497                    opName[opCode], O2S(namePtr), i), value2Ptr);
    11621498            Tcl_DecrRefCount(namePtr);
    11631499            Tcl_DecrRefCount(valuePtr);
     
    11741510                    result = tclIntType.setFromAnyProc(interp, valuePtr);
    11751511                    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));
    11761515                        Tcl_DecrRefCount(elemPtr);
    11771516                        Tcl_DecrRefCount(valuePtr);
     
    11851524                CACHE_STACK_INFO();
    11861525                if (value2Ptr == NULL) {
     1526                    TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %ld) => ERROR: ",
     1527                            opnd, O2S(elemPtr), i),
     1528                            Tcl_GetObjResult(interp));
    11871529                    Tcl_DecrRefCount(elemPtr);
    11881530                    Tcl_DecrRefCount(valuePtr);
     
    11911533                }
    11921534                PUSH_OBJECT(value2Ptr);
     1535                TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %ld) => ",
     1536                        opnd, O2S(elemPtr), i), value2Ptr);
    11931537                Tcl_DecrRefCount(elemPtr);
    11941538                Tcl_DecrRefCount(valuePtr);
     
    12061550                    result = tclIntType.setFromAnyProc(interp, valuePtr);
    12071551                    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));
    12081555                        Tcl_DecrRefCount(namePtr);
    12091556                        Tcl_DecrRefCount(elemPtr);
     
    12181565                CACHE_STACK_INFO();
    12191566                if (value2Ptr == NULL) {
     1567                    TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %ld) => ERROR: ",
     1568                            O2S(namePtr), O2S(elemPtr), i),
     1569                            Tcl_GetObjResult(interp));
    12201570                    Tcl_DecrRefCount(namePtr);
    12211571                    Tcl_DecrRefCount(elemPtr);
     
    12251575                }
    12261576                PUSH_OBJECT(value2Ptr);
     1577                TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %ld) => ",
     1578                        O2S(namePtr), O2S(elemPtr), i), value2Ptr);
    12271579                Tcl_DecrRefCount(namePtr);
    12281580                Tcl_DecrRefCount(elemPtr);
     
    12381590            CACHE_STACK_INFO();
    12391591            if (value2Ptr == NULL) {
     1592                TRACE_WITH_OBJ(("incrScalar1Imm %u %ld => ERROR: ",
     1593                        opnd, i), Tcl_GetObjResult(interp));
    12401594                result = TCL_ERROR;
    12411595                goto checkForCatch;
    12421596            }
    12431597            PUSH_OBJECT(value2Ptr);
     1598            TRACE_WITH_OBJ(("incrScalar1Imm %u %ld => ", opnd, i),
     1599                    value2Ptr);
    12441600            ADJUST_PC(3);
    12451601
     
    12531609            CACHE_STACK_INFO();
    12541610            if (value2Ptr == NULL) {
     1611                TRACE_WITH_OBJ(("%s \"%.30s\" %ld => ERROR: ",
     1612                        opName[opCode], O2S(namePtr), i),
     1613                        Tcl_GetObjResult(interp));
    12551614                result = TCL_ERROR;
    12561615                Tcl_DecrRefCount(namePtr);
     
    12581617            }
    12591618            PUSH_OBJECT(value2Ptr);
     1619            TRACE_WITH_OBJ(("%s \"%.30s\" %ld => ",
     1620                    opName[opCode], O2S(namePtr), i), value2Ptr);
    12601621            TclDecrRefCount(namePtr);
    12611622            ADJUST_PC(2);
     
    12731634                CACHE_STACK_INFO();
    12741635                if (value2Ptr == NULL) {
     1636                    TRACE_WITH_OBJ(("incrArray1Imm %u \"%.30s\" (by %ld) => ERROR: ",
     1637                            opnd, O2S(elemPtr), i),
     1638                            Tcl_GetObjResult(interp));
    12751639                    Tcl_DecrRefCount(elemPtr);
    12761640                    result = TCL_ERROR;
     
    12781642                }
    12791643                PUSH_OBJECT(value2Ptr);
     1644                TRACE_WITH_OBJ(("incrArray1Imm %u \"%.30s\" (by %ld) => ",
     1645                        opnd, O2S(elemPtr), i), value2Ptr);
    12801646                Tcl_DecrRefCount(elemPtr);
    12811647            }
     
    12941660                CACHE_STACK_INFO();
    12951661                if (value2Ptr == NULL) {
     1662                    TRACE_WITH_OBJ(("incrArrayStkImm \"%.30s(%.30s)\" (by %ld) => ERROR: ",
     1663                            O2S(namePtr), O2S(elemPtr), i),
     1664                            Tcl_GetObjResult(interp));
    12961665                    Tcl_DecrRefCount(namePtr);
    12971666                    Tcl_DecrRefCount(elemPtr);
     
    13001669                }
    13011670                PUSH_OBJECT(value2Ptr);
     1671                TRACE_WITH_OBJ(("incrArrayStkImm \"%.30s(%.30s)\" (by %ld) => ",
     1672                        O2S(namePtr), O2S(elemPtr), i), value2Ptr);
    13021673                Tcl_DecrRefCount(namePtr);
    13031674                Tcl_DecrRefCount(elemPtr);
     
    13071678        case INST_JUMP1:
    13081679            opnd = TclGetInt1AtPtr(pc+1);
     1680            TRACE(("jump1 %d => new pc %u\n", opnd,
     1681                   (unsigned int)(pc + opnd - codePtr->codeStart)));
    13091682            ADJUST_PC(opnd);
    13101683
    13111684        case INST_JUMP4:
    13121685            opnd = TclGetInt4AtPtr(pc+1);
     1686            TRACE(("jump4 %d => new pc %u\n", opnd,
     1687                   (unsigned int)(pc + opnd - codePtr->codeStart)));
    13131688            ADJUST_PC(opnd);
    13141689
     
    13341709                    result = Tcl_GetBooleanFromObj(interp, valuePtr, &b);
    13351710                    if (result != TCL_OK) {
     1711                        TRACE_WITH_OBJ(("%s %d => ERROR: ", opName[opCode],
     1712                                opnd), Tcl_GetObjResult(interp));
    13361713                        Tcl_DecrRefCount(valuePtr);
    13371714                        goto checkForCatch;
     
    13391716                }
    13401717                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)));
    13411721                    TclDecrRefCount(valuePtr);
    13421722                    ADJUST_PC(opnd);
    13431723                } else {
     1724                    TRACE(("%s %d => %.20s false\n", opName[opCode], opnd,
     1725                            O2S(valuePtr)));
    13441726                    TclDecrRefCount(valuePtr);
    13451727                    ADJUST_PC(pcAdjustment);
     
    13681750                    result = Tcl_GetBooleanFromObj(interp, valuePtr, &b);
    13691751                    if (result != TCL_OK) {
     1752                        TRACE_WITH_OBJ(("%s %d => ERROR: ", opName[opCode],
     1753                                opnd), Tcl_GetObjResult(interp));
    13701754                        Tcl_DecrRefCount(valuePtr);
    13711755                        goto checkForCatch;
     
    13731757                }
    13741758                if (b) {
     1759                    TRACE(("%s %d => %.20s true\n", opName[opCode], opnd,
     1760                            O2S(valuePtr)));
    13751761                    TclDecrRefCount(valuePtr);
    13761762                    ADJUST_PC(pcAdjustment);
    13771763                } else {
     1764                    TRACE(("%s %d => %.20s false, new pc %u\n",
     1765                            opName[opCode], opnd, O2S(valuePtr),
     1766                           (unsigned int)(pc + opnd - codePtr->codeStart)));
    13781767                    TclDecrRefCount(valuePtr);
    13791768                    ADJUST_PC(opnd);
     
    14151804                    }
    14161805                    if (result != TCL_OK) {
     1806                        TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",
     1807                                opName[opCode], O2S(valuePtr),
     1808                                (t1Ptr? t1Ptr->name : "null")));
    14171809                        IllegalExprOperandType(interp, opCode, valuePtr);
    14181810                        Tcl_DecrRefCount(valuePtr);
     
    14381830                    }
    14391831                    if (result != TCL_OK) {
     1832                        TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",
     1833                                opName[opCode], O2S(value2Ptr),
     1834                                (t2Ptr? t2Ptr->name : "null")));
    14401835                        IllegalExprOperandType(interp, opCode, value2Ptr);
    14411836                        Tcl_DecrRefCount(valuePtr);
     
    14561851                if (Tcl_IsShared(valuePtr)) {
    14571852                    PUSH_OBJECT(Tcl_NewLongObj(iResult));
     1853                    TRACE(("%s %.20s %.20s => %d\n", opName[opCode],
     1854                           O2S(valuePtr), O2S(value2Ptr), iResult));
    14581855                    TclDecrRefCount(valuePtr);
    14591856                } 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));
    14601860                    Tcl_SetLongObj(valuePtr, iResult);
    14611861                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     
    16132013                if (Tcl_IsShared(valuePtr)) {
    16142014                    PUSH_OBJECT(Tcl_NewLongObj(iResult));
     2015                    TRACE(("%s %.20s %.20s => %ld\n", opName[opCode],
     2016                        O2S(valuePtr), O2S(value2Ptr), iResult));
    16152017                    TclDecrRefCount(valuePtr);
    16162018                } 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));
    16172022                    Tcl_SetLongObj(valuePtr, iResult);
    16182023                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     
    16442049                            valuePtr, &i);
    16452050                    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")));
    16462055                        IllegalExprOperandType(interp, opCode, valuePtr);
    16472056                        Tcl_DecrRefCount(valuePtr);
     
    16562065                            value2Ptr, &i2);
    16572066                    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")));
    16582071                        IllegalExprOperandType(interp, opCode, value2Ptr);
    16592072                        Tcl_DecrRefCount(valuePtr);
     
    16722085                     */
    16732086                    if (i2 == 0) {
     2087                        TRACE(("mod %ld %ld => DIVIDE BY ZERO\n", i, i2));
    16742088                        Tcl_DecrRefCount(valuePtr);
    16752089                        Tcl_DecrRefCount(value2Ptr);
     
    17232137                if (Tcl_IsShared(valuePtr)) {
    17242138                    PUSH_OBJECT(Tcl_NewLongObj(iResult));
     2139                    TRACE(("%s %ld %ld => %ld\n", opName[opCode], i, i2,
     2140                           iResult));
    17252141                    TclDecrRefCount(valuePtr);
    17262142                } 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 */
    17272145                    Tcl_SetLongObj(valuePtr, iResult);
    17282146                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     
    17682186                    }
    17692187                    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")));
    17702192                        IllegalExprOperandType(interp, opCode, valuePtr);
    17712193                        Tcl_DecrRefCount(valuePtr);
     
    17902212                    }
    17912213                    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")));
    17922218                        IllegalExprOperandType(interp, opCode, value2Ptr);
    17932219                        Tcl_DecrRefCount(valuePtr);
     
    18202246                    case INST_DIV:
    18212247                        if (d2 == 0.0) {
     2248                            TRACE(("div %.6g %.6g => DIVIDE BY ZERO\n",
     2249                                   d1, d2));
    18222250                            Tcl_DecrRefCount(valuePtr);
    18232251                            Tcl_DecrRefCount(value2Ptr);
     
    18332261                   
    18342262                    if (IS_NAN(dResult) || IS_INF(dResult)) {
     2263                        TRACE(("%s %.20s %.20s => IEEE FLOATING PT ERROR\n",
     2264                               opName[opCode], O2S(valuePtr), O2S(value2Ptr)));
    18352265                        TclExprFloatError(interp, dResult);
    18362266                        result = TCL_ERROR;
     
    18612291                         */
    18622292                        if (i2 == 0) {
     2293                            TRACE(("div %ld %ld => DIVIDE BY ZERO\n",
     2294                                    i, i2));
    18632295                            Tcl_DecrRefCount(valuePtr);
    18642296                            Tcl_DecrRefCount(value2Ptr);
     
    18862318                    if (doDouble) {
    18872319                        PUSH_OBJECT(Tcl_NewDoubleObj(dResult));
     2320                        TRACE(("%s %.6g %.6g => %.6g\n", opName[opCode],
     2321                               d1, d2, dResult));
    18882322                    } else {
    18892323                        PUSH_OBJECT(Tcl_NewLongObj(iResult));
     2324                        TRACE(("%s %ld %ld => %ld\n", opName[opCode],
     2325                               i, i2, iResult));
    18902326                    }
    18912327                    TclDecrRefCount(valuePtr);
    18922328                } else {            /* reuse the valuePtr object */
    18932329                    if (doDouble) { /* NB: stack top is off by 1 */
     2330                        TRACE(("%s %.6g %.6g => %.6g\n", opName[opCode],
     2331                               d1, d2, dResult));
    18942332                        Tcl_SetDoubleObj(valuePtr, dResult);
    18952333                    } else {
     2334                        TRACE(("%s %ld %ld => %ld\n", opName[opCode],
     2335                               i, i2, iResult));
    18962336                        Tcl_SetLongObj(valuePtr, iResult);
    18972337                    }
     
    19232363                    }
    19242364                    if (result != TCL_OK) {
     2365                        TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",
     2366                                opName[opCode], s,
     2367                                (tPtr? tPtr->name : "null")));
    19252368                        IllegalExprOperandType(interp, opCode, valuePtr);
    19262369                        goto checkForCatch;
    19272370                    }
    19282371                }
     2372                TRACE_WITH_OBJ(("uplus %s => ", O2S(valuePtr)), valuePtr);
    19292373            }
    19302374            ADJUST_PC(1);
     
    19552399                    }
    19562400                    if (result != TCL_OK) {
     2401                        TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s\n",
     2402                                opName[opCode], s,
     2403                               (tPtr? tPtr->name : "null")));
    19572404                        IllegalExprOperandType(interp, opCode, valuePtr);
    19582405                        Tcl_DecrRefCount(valuePtr);
     
    19702417                        objPtr = Tcl_NewLongObj(
    19712418                                (opCode == INST_UMINUS)? -i : !i);
     2419                        TRACE_WITH_OBJ(("%s %ld => ", opName[opCode], i),
     2420                                objPtr); /* NB: stack top is off by 1 */
    19722421                    } else {
    19732422                        d = valuePtr->internalRep.doubleValue;
     
    19812430                            objPtr = Tcl_NewLongObj((d==0.0)? 1 : 0);
    19822431                        }
     2432                        TRACE_WITH_OBJ(("%s %.6g => ", opName[opCode], d),
     2433                                objPtr); /* NB: stack top is off by 1 */
    19832434                    }
    19842435                    PUSH_OBJECT(objPtr);
     
    19922443                        Tcl_SetLongObj(valuePtr,
    19932444                                (opCode == INST_UMINUS)? -i : !i);
     2445                        TRACE_WITH_OBJ(("%s %ld => ", opName[opCode], i),
     2446                                valuePtr); /* NB: stack top is off by 1 */
    19942447                    } else {
    19952448                        d = valuePtr->internalRep.doubleValue;
     
    20032456                            Tcl_SetLongObj(valuePtr, (d==0.0)? 1 : 0);
    20042457                        }
     2458                        TRACE_WITH_OBJ(("%s %.6g => ", opName[opCode], d),
     2459                                valuePtr); /* NB: stack top is off by 1 */
    20052460                    }
    20062461                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     
    20262481                            valuePtr, &i);
    20272482                    if (result != TCL_OK) {   /* try to convert to double */
     2483                        TRACE(("bitnot \"%.20s\" => ILLEGAL TYPE %s\n",
     2484                               O2S(valuePtr), (tPtr? tPtr->name : "null")));
    20282485                        IllegalExprOperandType(interp, opCode, valuePtr);
    20292486                        Tcl_DecrRefCount(valuePtr);
     
    20352492                if (Tcl_IsShared(valuePtr)) {
    20362493                    PUSH_OBJECT(Tcl_NewLongObj(~i));
     2494                    TRACE(("bitnot 0x%lx => (%lu)\n", i, ~i));
    20372495                    TclDecrRefCount(valuePtr);
    20382496                } else {
     
    20422500                    Tcl_SetLongObj(valuePtr, ~i);
    20432501                    ++stackTop; /* valuePtr now on stk top has right r.c. */
     2502                    TRACE(("bitnot 0x%lx => (%lu)\n", i, ~i));
    20442503                }
    20452504            }
     
    20562515
    20572516                if ((opnd < 0) || (opnd > LAST_BUILTIN_FUNC)) {
     2517                    TRACE(("UNRECOGNIZED BUILTIN FUNC CODE %d\n", opnd));
    20582518                    panic("TclExecuteByteCode: unrecognized builtin function code %d", opnd);
    20592519                }
     
    20682528                    goto checkForCatch;
    20692529                }
     2530                TRACE_WITH_OBJ(("callBuiltinFunc1 %d => ", opnd),
     2531                        stackPtr[stackTop].o);
    20702532            }
    20712533            ADJUST_PC(2);
     
    20932555                    goto checkForCatch;
    20942556                }
     2557                TRACE_WITH_OBJ(("callFunc1 %d => ", objc),
     2558                        stackPtr[stackTop].o);
    20952559                ADJUST_PC(2);
    20962560            }
     
    21632627                        d = valuePtr->internalRep.doubleValue;
    21642628                        if (IS_NAN(d) || IS_INF(d)) {
     2629                            TRACE(("tryCvtToNumeric \"%.20s\" => IEEE FLOATING PT ERROR\n",
     2630                                   O2S(valuePtr)));
    21652631                            TclExprFloatError(interp, d);
    21662632                            result = TCL_ERROR;
     
    21702636                    shared = shared;            /* lint, shared not used. */
    21712637                    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)));
    21722645                }
    21732646            }
     
    21872660                    codePtr);
    21882661            if (rangePtr == NULL) {
     2662                TRACE(("break => no encl. loop or catch, returning TCL_BREAK\n"));
    21892663                result = TCL_BREAK;
    21902664                goto abnormalReturn; /* no catch exists to check */
     
    21932667            case LOOP_EXCEPTION_RANGE:
    21942668                result = TCL_OK;
     2669                TRACE(("break => range at %d, new pc %d\n",
     2670                       rangePtr->codeOffset, rangePtr->breakOffset));
    21952671                break;
    21962672            case CATCH_EXCEPTION_RANGE:
    21972673                result = TCL_BREAK;
     2674                TRACE(("break => ...\n"));
    21982675                goto processCatch; /* it will use rangePtr */
    21992676            default:
     
    22162693                    codePtr);
    22172694            if (rangePtr == NULL) {
     2695                TRACE(("continue => no encl. loop or catch, returning TCL_CONTINUE\n"));
    22182696                result = TCL_CONTINUE;
    22192697                goto abnormalReturn;
     
    22222700            case LOOP_EXCEPTION_RANGE:
    22232701                if (rangePtr->continueOffset == -1) {
     2702                    TRACE(("continue => loop w/o continue, checking for catch\n"));
    22242703                    goto checkForCatch;
    22252704                } else {
    22262705                    result = TCL_OK;
     2706                    TRACE(("continue => range at %d, new pc %d\n",
     2707                           rangePtr->codeOffset, rangePtr->continueOffset));
    22272708                }
    22282709                break;
    22292710            case CATCH_EXCEPTION_RANGE:
    22302711                result = TCL_CONTINUE;
     2712                TRACE(("continue => ...\n"));
    22312713                goto processCatch; /* it will use rangePtr */
    22322714            default:
     
    22622744                TclSetVarScalar(iterVarPtr);
    22632745                TclClearVarUndefined(iterVarPtr);
     2746                TRACE(("foreach_start4 %u => loop iter count temp %d\n",
     2747                        opnd, iterTmpIndex));
    22642748            }
    22652749            ADJUST_PC(5);
     
    23102794                    result = Tcl_ListObjLength(interp, listPtr, &listLen);
    23112795                    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));
    23122799                        goto checkForCatch;
    23132800                    }
     
    23532840                            CACHE_STACK_INFO();
    23542841                            if (value2Ptr == NULL) {
     2842                                TRACE_WITH_OBJ(("foreach_step4 %u => ERROR init. index temp %d: ",
     2843                                       opnd, varIndex),
     2844                                       Tcl_GetObjResult(interp));
    23552845                                if (setEmptyStr) {
    23562846                                    Tcl_DecrRefCount(elemPtr); /* unneeded */
     
    23722862
    23732863                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")));
    23742867            }
    23752868            ADJUST_PC(5);
     
    23822875             */
    23832876            catchStackPtr[++catchTop] = stackTop;
     2877            TRACE(("beginCatch4 %u => catchTop=%d, stackTop=%d\n",
     2878                    TclGetUInt4AtPtr(pc+1), catchTop, stackTop));
    23842879            ADJUST_PC(5);
    23852880
     
    23872882            catchTop--;
    23882883            result = TCL_OK;
     2884            TRACE(("endCatch => catchTop=%d\n", catchTop));
    23892885            ADJUST_PC(1);
    23902886
    23912887        case INST_PUSH_RESULT:
    23922888            PUSH_OBJECT(Tcl_GetObjResult(interp));
     2889            TRACE_WITH_OBJ(("pushResult => "), Tcl_GetObjResult(interp));
    23932890            ADJUST_PC(1);
    23942891
    23952892        case INST_PUSH_RETURN_CODE:
    23962893            PUSH_OBJECT(Tcl_NewLongObj(result));
     2894            TRACE(("pushReturnCode => %u\n", result));
    23972895            ADJUST_PC(1);
    23982896
    23992897        default:
     2898            TRACE(("UNRECOGNIZED INSTRUCTION %u\n", opCode));
    24002899            panic("TclExecuteByteCode: unrecognized opCode %u", opCode);
    24012900        } /* end of switch on opCode */
     
    24272926        rangePtr = TclGetExceptionRangeForPc(pc, /*catchOnly*/ 1, codePtr);
    24282927        if (rangePtr == NULL) {
     2928            TRACE(("   ... no enclosing catch, returning %s\n",
     2929                    StringForResultCode(result)));
    24292930            goto abnormalReturn;
    24302931        }
     
    24442945            TclDecrRefCount(valuePtr);
    24452946        }
     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)));
    24462950        pc = (codePtr->codeStart + rangePtr->catchOffset);
    24472951        continue;               /* restart the execution loop at pc */
     
    24712975#undef STATIC_CATCH_STACK_SIZE
    24722976}
     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
     2997static void
     2998PrintByteCodeInfo(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
     3064static void
     3065ValidatePcAndStackTop(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 */
    24733113
    24743114
     
    36314271
    36324272
     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
     4292int
     4293TclLog2(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
     4325static int
     4326EvalStatsCmd(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
    36334451/*
    36344452 *----------------------------------------------------------------------
     
    39404758    panic("UpdateStringOfCmdName should never be invoked");
    39414759}
     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
     4784static char *
     4785StringForResultCode(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

    r0e7d64a re39abb4  
    13261326
    13271327extern Tcl_Obj *        tclFreeObjList;
     1328
     1329#ifdef TCL_COMPILE_STATS
     1330extern long             tclObjsAlloced;
     1331extern long             tclObjsFreed;
     1332#endif /* TCL_COMPILE_STATS */
    13281333
    13291334/*
     
    14401445                            int objc, Tcl_Obj *CONST objv[], int flags));
    14411446EXTERN char *           TclpAlloc _ANSI_ARGS_((unsigned int size));
    1442 EXTERN void             TclpFree(char *cp);
     1447
    14431448EXTERN char *           TclpRealloc _ANSI_ARGS_((char *ptr,
    14441449                            unsigned int size));
     
    14671472EXTERN int              TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp,
    14681473                            Tcl_Interp *cmdInterp, Tcl_Command cmd));
     1474EXTERN void             TclPrintByteCodeObj _ANSI_ARGS_((Tcl_Interp *interp,
     1475                            Tcl_Obj *objPtr));
    14691476EXTERN void             TclProcCleanupProc _ANSI_ARGS_((Proc *procPtr));
    14701477EXTERN int              TclProcCompileProc _ANSI_ARGS_((Tcl_Interp *interp,
     
    16811688 */
    16821689
     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 */
    16831732#  define TclNewObj(objPtr) \
    16841733    if (tclFreeObjList == NULL) { \
     
    16911740    (objPtr)->bytes    = tclEmptyStringRep; \
    16921741    (objPtr)->length   = 0; \
    1693     (objPtr)->typePtr  = NULL;
     1742    (objPtr)->typePtr  = NULL; \
     1743    TclIncrObjsAllocated()
    16941744#  define TclDecrRefCount(objPtr) \
    16951745    if (--(objPtr)->refCount <= 0) { \
     
    17041754        (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \
    17051755        tclFreeObjList = (objPtr); \
     1756        TclIncrObjsFreed(); \
    17061757    }
     1758#endif /* TCL_MEM_DEBUG */
    17071759
    17081760/*
  • external/tcl/tclListObj.c

    r0e7d64a re39abb4  
    4646 * Tcl_NewListObj --
    4747 *
    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.
     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.
    5155 *
    5256 * Results:
     
    6266 *----------------------------------------------------------------------
    6367 */
     68
     69#ifdef TCL_MEM_DEBUG
     70#undef Tcl_NewListObj
     71
     72Tcl_Obj *
     73Tcl_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 */
    6481
    6582Tcl_Obj *
     
    95112    return listPtr;
    96113}
     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
     148Tcl_Obj *
     149Tcl_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
     187Tcl_Obj *
     188Tcl_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 */
    97199
    98200
  • external/tcl/tclObj.c

    r0e7d64a re39abb4  
    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
     45long tclObjsAlloced = 0;
     46long tclObjsFreed = 0;
     47#endif /* TCL_COMPILE_STATS */
    3848
    3949/*
     
    407417 * Tcl_NewObj --
    408418 *
    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.
     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.
    413427 *
    414428 * Results:
     
    417431 *      is set to 0.
    418432 *
    419  *----------------------------------------------------------------------
    420  */
     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
     443Tcl_Obj *
     444Tcl_NewObj()
     445{
     446    return Tcl_DbNewObj("unknown", 0);
     447}
     448
     449#else /* if not TCL_MEM_DEBUG */
    421450
    422451Tcl_Obj *
     
    439468    objPtr->length   = 0;
    440469    objPtr->typePtr  = NULL;
     470#ifdef TCL_COMPILE_STATS
     471    tclObjsAlloced++;
     472#endif /* TCL_COMPILE_STATS */
    441473    return objPtr;
    442474}
     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
     507Tcl_Obj *
     508Tcl_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
     534Tcl_Obj *
     535Tcl_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 */
    443544
    444545
     
    508609 *      after deallocating the string representation and calling the
    509610 *      type-specific Tcl_FreeInternalRepProc to deallocate the object's
    510  *      internal representation.
     611 *      internal representation. If compiling with TCL_COMPILE_STATS,
     612 *      this procedure increments the global count of freed objects
     613 *      (tclObjsFreed).
    511614 *
    512615 *----------------------------------------------------------------------
     
    519622    register Tcl_ObjType *typePtr = objPtr->typePtr;
    520623   
     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
    521630    Tcl_InvalidateStringRep(objPtr);
    522631    if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) {
     
    525634
    526635    /*
    527      * Deallocate the object by adding it onto the list of free
     636     * If debugging Tcl's memory usage, deallocate the object using ckfree.
     637     * Otherwise, deallocate it by adding it onto the list of free
    528638     * Tcl_Objs we maintain.
    529639     */
    530640   
     641#ifdef TCL_MEM_DEBUG
     642    ckfree((char *) objPtr);
     643#else
    531644    objPtr->internalRep.otherValuePtr = (VOID *) tclFreeObjList;
    532645    tclFreeObjList = objPtr;
     646#endif /* TCL_MEM_DEBUG */
     647
     648#ifdef TCL_COMPILE_STATS   
     649    tclObjsFreed++;
     650#endif /* TCL_COMPILE_STATS */   
    533651}
    534652
     
    676794 * Tcl_NewBooleanObj --
    677795 *
    678  *      This procedure creates a new boolean object and initializes it from
    679  *      the argument boolean value. A nonzero "boolValue" is coerced to 1.
     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.
    680803 *
    681804 * Results:
     
    688811 *----------------------------------------------------------------------
    689812 */
     813
     814#ifdef TCL_MEM_DEBUG
     815#undef Tcl_NewBooleanObj
    690816
    691817Tcl_Obj *
     
    693819    register int boolValue;     /* Boolean used to initialize new object. */
    694820{
     821    return Tcl_DbNewBooleanObj(boolValue, "unknown", 0);
     822}
     823
     824#else /* if not TCL_MEM_DEBUG */
     825
     826Tcl_Obj *
     827Tcl_NewBooleanObj(boolValue)
     828    register int boolValue;     /* Boolean used to initialize new object. */
     829{
    695830    register Tcl_Obj *objPtr;
    696831
     
    702837    return objPtr;
    703838}
     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
     870Tcl_Obj *
     871Tcl_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
     890Tcl_Obj *
     891Tcl_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 */
    704901
    705902
     
    9811178 * Tcl_NewDoubleObj --
    9821179 *
    983  *      This procedure creates a new double object and initializes it from
    984  *      the argument double value.
     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.
    9851186 *
    9861187 * Results:
     
    9931194 *----------------------------------------------------------------------
    9941195 */
     1196
     1197#ifdef TCL_MEM_DEBUG
     1198#undef Tcl_NewDoubleObj
    9951199
    9961200Tcl_Obj *
     
    9981202    register double dblValue;   /* Double used to initialize the object. */
    9991203{
     1204    return Tcl_DbNewDoubleObj(dblValue, "unknown", 0);
     1205}
     1206
     1207#else /* if not TCL_MEM_DEBUG */
     1208
     1209Tcl_Obj *
     1210Tcl_NewDoubleObj(dblValue)
     1211    register double dblValue;   /* Double used to initialize the object. */
     1212{
    10001213    register Tcl_Obj *objPtr;
    10011214
     
    10071220    return objPtr;
    10081221}
     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
     1253Tcl_Obj *
     1254Tcl_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
     1273Tcl_Obj *
     1274Tcl_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 */
    10091284
    10101285
     
    12561531 * Tcl_NewIntObj --
    12571532 *
    1258  *      Calls to Tcl_NewIntObj result in a call to one of the two
     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
    12591539 *      Tcl_NewIntObj implementations below. We provide two implementations
    12601540 *      so that the Tcl core can be compiled to do memory debugging of the
     
    12761556 */
    12771557
     1558#ifdef TCL_MEM_DEBUG
     1559#undef Tcl_NewIntObj
     1560
    12781561Tcl_Obj *
    12791562Tcl_NewIntObj(intValue)
    12801563    register int intValue;      /* Int used to initialize the new object. */
    12811564{
     1565    return Tcl_DbNewLongObj((long)intValue, "unknown", 0);
     1566}
     1567
     1568#else /* if not TCL_MEM_DEBUG */
     1569
     1570Tcl_Obj *
     1571Tcl_NewIntObj(intValue)
     1572    register int intValue;      /* Int used to initialize the new object. */
     1573{
    12821574    register Tcl_Obj *objPtr;
    12831575
     
    12891581    return objPtr;
    12901582}
     1583#endif /* if TCL_MEM_DEBUG */
    12911584
    12921585
     
    15631856 * Tcl_NewLongObj --
    15641857 *
    1565  *      Calls to Tcl_NewLongObj result in a call to one of the two
     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
    15661864 *      Tcl_NewLongObj implementations below. We provide two implementations
    15671865 *      so that the Tcl core can be compiled to do memory debugging of the
     
    15831881 */
    15841882
     1883#ifdef TCL_MEM_DEBUG
     1884#undef Tcl_NewLongObj
     1885
    15851886Tcl_Obj *
    15861887Tcl_NewLongObj(longValue)
     
    15881889                                 * new object. */
    15891890{
     1891    return Tcl_DbNewLongObj(longValue, "unknown", 0);
     1892}
     1893
     1894#else /* if not TCL_MEM_DEBUG */
     1895
     1896Tcl_Obj *
     1897Tcl_NewLongObj(longValue)
     1898    register long longValue;    /* Long integer used to initialize the
     1899                                 * new object. */
     1900{
    15901901    register Tcl_Obj *objPtr;
    15911902
     
    15971908    return objPtr;
    15981909}
     1910#endif /* if TCL_MEM_DEBUG */
    15991911
    16001912
     
    16041916 * Tcl_DbNewLongObj --
    16051917 *
    1606  *      This procedure just returns the result of calling Tcl_NewLongObj.
     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.
    16071934 *
    16081935 * Results:
     
    16161943 *----------------------------------------------------------------------
    16171944 */
     1945
     1946#ifdef TCL_MEM_DEBUG
    16181947
    16191948Tcl_Obj *
     
    16261955                                 * for debugging. */
    16271956{
     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
     1969Tcl_Obj *
     1970Tcl_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{
    16281978    return Tcl_NewLongObj(longValue);
    16291979}
     1980#endif /* TCL_MEM_DEBUG */
    16301981
    16311982
     
    17092060    return result;
    17102061}
     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
     2085void
     2086Tcl_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
     2125void
     2126Tcl_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
     2168int
     2169Tcl_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

    r0e7d64a re39abb4  
    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
    987998    iPtr->returnCode = TCL_OK;
    988999    procPtr->refCount++;
     
    11081119        int numChars;
    11091120        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        }
    11101137       
    11111138        /*
  • external/tcl/tclStringObj.c

    r0e7d64a re39abb4  
    5050 * Tcl_NewStringObj --
    5151 *
    52  *      This procedure creates a new string object and initializes it from
    53  *      the byte pointer and length arguments.
     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.
    5458 *
    5559 * Results:
     
    6670 *----------------------------------------------------------------------
    6771 */
     72
     73#ifdef TCL_MEM_DEBUG
     74#undef Tcl_NewStringObj
    6875
    6976Tcl_Obj *
     
    7683                                 * NULL byte. */
    7784{
     85    return Tcl_DbNewStringObj(bytes, length, "unknown", 0);
     86}
     87
     88#else /* if not TCL_MEM_DEBUG */
     89
     90Tcl_Obj *
     91Tcl_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{
    7899    register Tcl_Obj *objPtr;
    79100
     
    85106    return objPtr;
    86107}
     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
     143Tcl_Obj *
     144Tcl_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
     168Tcl_Obj *
     169Tcl_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 */
    87184
    88185
  • external/tcl/tclVar.c

    r0e7d64a re39abb4  
    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   
    713731    varPtr = &(compiledLocals[localIndex]);
    714732    varName = varPtr->name;
     
    814832    int new;
    815833
     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
    816852    /*
    817853     * THIS FAILS IF THE ELEMENT NAME OBJECT'S STRING REP HAS A NULL BYTE.
     
    14131449    Tcl_Obj *resultPtr = NULL;
    14141450
     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   
    14151469    varPtr = &(compiledLocals[localIndex]);
    14161470    varName = varPtr->name;
     
    15811635    int new;
    15821636   
     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
    15831655    /*
    15841656     * THIS FAILS IF THE ELEMENT NAME OBJECT'S STRING REP HAS A NULL BYTE.
  • modules/AngularSmearing.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class AngularSmearing
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    45 #include <algorithm>
     46#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    7677  fFormulaPhi->Compile(GetString("PhiResolutionFormula", "0.0"));
    7778
     79
    7880  // import input array
    7981
     
    101103
    102104  fItInputArray->Reset();
    103   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     105  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    104106  {
    105107    const TLorentzVector &candidatePosition = candidate->Position;
     
    114116    eta = gRandom->Gaus(eta, fFormulaEta->Eval(pt, eta, phi, e));
    115117    phi = gRandom->Gaus(phi, fFormulaPhi->Eval(pt, eta, phi, e));
    116 
     118   
    117119    if(pt <= 0.0) continue;
    118120
    119121    mother = candidate;
    120     candidate = static_cast<Candidate *>(candidate->Clone());
     122    candidate = static_cast<Candidate*>(candidate->Clone());
    121123    eta = candidateMomentum.Eta();
    122124    phi = candidateMomentum.Phi();
    123     candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt * TMath::CosH(eta));
     125    candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
    124126    candidate->AddCandidate(mother);
    125 
     127       
    126128    fOutputArray->Add(candidate);
    127129  }
  • modules/AngularSmearing.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  AngularSmearing();
    4041  ~AngularSmearing();
     
    4546
    4647private:
     48
    4749  DelphesFormula *fFormulaEta; //!
    4850  DelphesFormula *fFormulaPhi; //!
     
    5153
    5254  const TObjArray *fInputArray; //!
    53 
     55 
    5456  TObjArray *fOutputArray; //!
    5557
  • modules/BTagging.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class BTagging
    2021 *
     
    3334#include "classes/DelphesFormula.h"
    3435
     36#include "TMath.h"
     37#include "TString.h"
     38#include "TFormula.h"
     39#include "TRandom3.h"
     40#include "TObjArray.h"
    3541#include "TDatabasePDG.h"
    36 #include "TFormula.h"
    3742#include "TLorentzVector.h"
    38 #include "TMath.h"
    39 #include "TObjArray.h"
    40 #include "TRandom3.h"
    41 #include "TString.h"
    4243
    4344#include <algorithm>
     45#include <stdexcept>
    4446#include <iostream>
    4547#include <sstream>
    46 #include <stdexcept>
    4748
    4849using namespace std;
     
    6566void BTagging::Init()
    6667{
    67   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     68  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    6869  ExRootConfParam param;
    6970  DelphesFormula *formula;
     
    7778
    7879  fEfficiencyMap.clear();
    79   for(i = 0; i < size / 2; ++i)
     80  for(i = 0; i < size/2; ++i)
    8081  {
    8182    formula = new DelphesFormula;
    82     formula->Compile(param[i * 2 + 1].GetString());
     83    formula->Compile(param[i*2 + 1].GetString());
    8384
    84     fEfficiencyMap[param[i * 2].GetInt()] = formula;
     85    fEfficiencyMap[param[i*2].GetInt()] = formula;
    8586  }
    8687
     
    105106void BTagging::Finish()
    106107{
    107   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     108  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    108109  DelphesFormula *formula;
    109110
     
    123124  Candidate *jet;
    124125  Double_t pt, eta, phi, e;
    125   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     126  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    126127  DelphesFormula *formula;
    127128
    128129  // loop over all input jets
    129130  fItJetInputArray->Reset();
    130   while((jet = static_cast<Candidate *>(fItJetInputArray->Next())))
     131  while((jet = static_cast<Candidate*>(fItJetInputArray->Next())))
    131132  {
    132133    const TLorentzVector &jetMomentum = jet->Momentum;
  • modules/BTagging.h

    r0e7d64a re39abb4  
    4040{
    4141public:
     42
    4243  BTagging();
    4344  ~BTagging();
     
    4849
    4950private:
     51
    5052  Int_t fBitNumber;
    5153
    5254#if !defined(__CINT__) && !defined(__CLING__)
    53   std::map<Int_t, DelphesFormula *> fEfficiencyMap; //!
     55  std::map< Int_t, DelphesFormula * > fEfficiencyMap; //!
    5456#endif
    5557
    5658  TIterator *fItJetInputArray; //!
    57 
     59 
    5860  const TObjArray *fJetInputArray; //!
    5961
  • modules/BeamSpotFilter.cc

    r0e7d64a re39abb4  
    77 */
    88
     9
    910#include "modules/BeamSpotFilter.h"
    1011
     
    1314#include "classes/DelphesFormula.h"
    1415
     16#include "ExRootAnalysis/ExRootResult.h"
     17#include "ExRootAnalysis/ExRootFilter.h"
    1518#include "ExRootAnalysis/ExRootClassifier.h"
    16 #include "ExRootAnalysis/ExRootFilter.h"
    17 #include "ExRootAnalysis/ExRootResult.h"
    1819
     20#include "TMath.h"
     21#include "TString.h"
     22#include "TFormula.h"
     23#include "TRandom3.h"
     24#include "TObjArray.h"
    1925#include "TDatabasePDG.h"
    20 #include "TFormula.h"
    2126#include "TLorentzVector.h"
    22 #include "TMath.h"
    23 #include "TObjArray.h"
    24 #include "TRandom3.h"
    25 #include "TString.h"
    2627
    2728#include <algorithm>
     29#include <stdexcept>
    2830#include <iostream>
    2931#include <sstream>
    30 #include <stdexcept>
    3132
    3233using namespace std;
     
    4950void BeamSpotFilter::Init()
    5051{
    51 
     52 
    5253  // import input array
    5354  fInputArray = ImportArray(GetString("InputArray", "Delphes/allParticles"));
     
    7273  Candidate *candidate;
    7374  Bool_t passed = false;
    74 
     75 
    7576  fItInputArray->Reset();
    76   while((candidate = static_cast<Candidate *>(fItInputArray->Next())) && !passed)
     77  while((candidate = static_cast<Candidate*>(fItInputArray->Next())) && !passed)
    7778  {
    7879    if(candidate->IsPU == 0) passed = true;
    7980    fOutputArray->Add(candidate);
    8081  }
     82 
    8183}
     84
     85 
  • modules/BeamSpotFilter.h

    r0e7d64a re39abb4  
    2020{
    2121public:
     22
    2223  BeamSpotFilter();
    2324  ~BeamSpotFilter();
     
    2829
    2930private:
     31
    3032  Float_t fPassedOne;
    3133
  • modules/CMakeLists.txt

    r0e7d64a re39abb4  
    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
    32     DESTINATION lib)
    33   if(PYTHIA8_FOUND)
    34     install(FILES
    35       ${PROJECT_BINARY_DIR}/modules/libPythia8Dict_rdict.pcm
     30      ${PROJECT_BINARY_DIR}/modules/libModulesDict_rdict.pcm
     31      ${PROJECT_BINARY_DIR}/modules/libFastJetDict_rdict.pcm
    3632      DESTINATION lib)
    37   endif()
    3833endif()
  • modules/Calorimeter.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class Calorimeter
    2021 *
     
    3233#include "classes/DelphesFormula.h"
    3334
     35#include "ExRootAnalysis/ExRootResult.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
    3437#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    37 
     38
     39#include "TMath.h"
     40#include "TString.h"
     41#include "TFormula.h"
     42#include "TRandom3.h"
     43#include "TObjArray.h"
    3844#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4045#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TRandom3.h"
    44 #include "TString.h"
    4546
    4647#include <algorithm>
     48#include <stdexcept>
    4749#include <iostream>
    4850#include <sstream>
    49 #include <stdexcept>
    5051
    5152using namespace std;
     
    5758  fItParticleInputArray(0), fItTrackInputArray(0)
    5859{
    59 
     60 
    6061  fECalResolutionFormula = new DelphesFormula;
    6162  fHCalResolutionFormula = new DelphesFormula;
     
    6667  fHCalTowerTrackArray = new TObjArray;
    6768  fItHCalTowerTrackArray = fHCalTowerTrackArray->MakeIterator();
     69 
    6870}
    6971
     
    7274Calorimeter::~Calorimeter()
    7375{
    74 
     76 
    7577  if(fECalResolutionFormula) delete fECalResolutionFormula;
    7678  if(fHCalResolutionFormula) delete fHCalResolutionFormula;
     
    8183  if(fHCalTowerTrackArray) delete fHCalTowerTrackArray;
    8284  if(fItHCalTowerTrackArray) delete fItHCalTowerTrackArray;
     85 
    8386}
    8487
     
    9194  Double_t ecalFraction, hcalFraction;
    9295  TBinMap::iterator itEtaBin;
    93   set<Double_t>::iterator itPhiBin;
    94   vector<Double_t> *phiBins;
     96  set< Double_t >::iterator itPhiBin;
     97  vector< Double_t > *phiBins;
    9598
    9699  // read eta and phi bins
     
    100103  fEtaBins.clear();
    101104  fPhiBins.clear();
    102   for(i = 0; i < size / 2; ++i)
    103   {
    104     paramEtaBins = param[i * 2];
     105  for(i = 0; i < size/2; ++i)
     106  {
     107    paramEtaBins = param[i*2];
    105108    sizeEtaBins = paramEtaBins.GetSize();
    106     paramPhiBins = param[i * 2 + 1];
     109    paramPhiBins = param[i*2 + 1];
    107110    sizePhiBins = paramPhiBins.GetSize();
    108111
     
    121124  {
    122125    fEtaBins.push_back(itEtaBin->first);
    123     phiBins = new vector<double>(itEtaBin->second.size());
     126    phiBins = new vector< double >(itEtaBin->second.size());
    124127    fPhiBins.push_back(phiBins);
    125128    phiBins->clear();
     
    138141  fFractionMap[0] = make_pair(0.0, 1.0);
    139142
    140   for(i = 0; i < size / 2; ++i)
    141   {
    142     paramFractions = param[i * 2 + 1];
     143  for(i = 0; i < size/2; ++i)
     144  {
     145    paramFractions = param[i*2 + 1];
    143146
    144147    ecalFraction = paramFractions[0].GetDouble();
    145148    hcalFraction = paramFractions[1].GetDouble();
    146149
    147     fFractionMap[param[i * 2].GetInt()] = make_pair(ecalFraction, hcalFraction);
     150    fFractionMap[param[i*2].GetInt()] = make_pair(ecalFraction, hcalFraction);
    148151  }
    149152
    150153  // read min E value for timing measurement in ECAL
    151   fTimingEnergyMin = GetDouble("TimingEnergyMin", 4.);
     154  fTimingEnergyMin = GetDouble("TimingEnergyMin",4.);
    152155  // For timing
    153156  // So far this flag needs to be false
     
    189192void Calorimeter::Finish()
    190193{
    191   vector<vector<Double_t> *>::iterator itPhiBin;
     194  vector< vector< Double_t >* >::iterator itPhiBin;
    192195  if(fItParticleInputArray) delete fItParticleInputArray;
    193196  if(fItTrackInputArray) delete fItTrackInputArray;
     
    215218  TFractionMap::iterator itFractionMap;
    216219
    217   vector<Double_t>::iterator itEtaBin;
    218   vector<Double_t>::iterator itPhiBin;
    219   vector<Double_t> *phiBins;
    220 
    221   vector<Long64_t>::iterator itTowerHits;
     220  vector< Double_t >::iterator itEtaBin;
     221  vector< Double_t >::iterator itPhiBin;
     222  vector< Double_t > *phiBins;
     223
     224  vector< Long64_t >::iterator itTowerHits;
    222225
    223226  DelphesFactory *factory = GetFactory();
     
    231234  fItParticleInputArray->Reset();
    232235  number = -1;
    233   while((particle = static_cast<Candidate *>(fItParticleInputArray->Next())))
     236  while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
    234237  {
    235238    const TLorentzVector &particlePosition = particle->Position;
     
    277280  fItTrackInputArray->Reset();
    278281  number = -1;
    279   while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
     282  while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
    280283  {
    281284    const TLorentzVector &trackPosition = track->Position;
     
    328331    towerHit = (*itTowerHits);
    329332    flags = (towerHit >> 24) & 0x00000000000000FFLL;
    330     number = (towerHit)&0x0000000000FFFFFFLL;
     333    number = (towerHit) & 0x0000000000FFFFFFLL;
    331334    hitEtaPhi = towerHit >> 32;
    332335
     
    349352
    350353      // calculate eta and phi of the tower's center
    351       fTowerEta = 0.5 * (fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
    352       fTowerPhi = 0.5 * ((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
     354      fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
     355      fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
    353356
    354357      fTowerEdges[0] = fEtaBins[etaBin - 1];
     
    362365      fECalTrackEnergy = 0.0;
    363366      fHCalTrackEnergy = 0.0;
    364 
     367     
    365368      fECalTrackSigma = 0.0;
    366369      fHCalTrackSigma = 0.0;
    367 
     370     
    368371      fTowerTrackHits = 0;
    369372      fTowerPhotonHits = 0;
     
    371374      fECalTowerTrackArray->Clear();
    372375      fHCalTowerTrackArray->Clear();
     376   
    373377    }
    374378
     
    378382      ++fTowerTrackHits;
    379383
    380       track = static_cast<Candidate *>(fTrackInputArray->At(number));
     384      track = static_cast<Candidate*>(fTrackInputArray->At(number));
    381385      momentum = track->Momentum;
    382386      position = track->Position;
     
    396400      {
    397401        fECalTrackEnergy += ecalEnergy;
    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;
     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;
    405407        fECalTowerTrackArray->Add(track);
    406408      }
    407 
     409     
    408410      else if(fECalTrackFractions[number] < 1.0E-9 && fHCalTrackFractions[number] > 1.0E-9)
    409411      {
    410412        fHCalTrackEnergy += hcalEnergy;
    411413        hcalSigma = fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, momentum.E());
    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;
     414        if(hcalSigma/momentum.E() < track->TrackResolution) energyGuess = hcalEnergy;
     415        else 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
    527528
    528529  fTower->Momentum.SetPtEtaPhiE(pt, eta, phi, energy);
     
    544545    fTowerOutputArray->Add(fTower);
    545546  }
    546 
     547 
    547548  // fill energy flow candidates
    548549  fECalTrackSigma = TMath::Sqrt(fECalTrackSigma);
     
    550551
    551552  //compute neutral excesses
    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
     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
    559560  if(ecalNeutralEnergy > fECalEnergyMin && ecalNeutralSigma > fECalEnergySignificanceMin)
    560561  {
    561562    // create new photon tower
    562     tower = static_cast<Candidate *>(fTower->Clone());
    563     pt = ecalNeutralEnergy / TMath::CosH(eta);
    564 
     563    tower = static_cast<Candidate*>(fTower->Clone());
     564    pt =  ecalNeutralEnergy / TMath::CosH(eta);
     565   
    565566    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, ecalNeutralEnergy);
    566567    tower->Eem = ecalNeutralEnergy;
    567568    tower->Ehad = 0.0;
    568569    tower->PID = 22;
    569 
     570   
    570571    fEFlowPhotonOutputArray->Add(tower);
    571 
     572   
    572573    //clone tracks
    573574    fItECalTowerTrackArray->Reset();
    574     while((track = static_cast<Candidate *>(fItECalTowerTrackArray->Next())))
     575    while((track = static_cast<Candidate*>(fItECalTowerTrackArray->Next())))
    575576    {
    576577      mother = track;
    577       track = static_cast<Candidate *>(track->Clone());
     578      track = static_cast<Candidate*>(track->Clone());
    578579      track->AddCandidate(mother);
    579580
    580581      fEFlowTrackOutputArray->Add(track);
    581582    }
    582   }
    583 
     583 
     584  }
     585 
    584586  // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking
    585587  else if(fECalTrackEnergy > 0.0)
    586588  {
    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;
     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;
    592594
    593595    //rescale tracks
    594596    fItECalTowerTrackArray->Reset();
    595     while((track = static_cast<Candidate *>(fItECalTowerTrackArray->Next())))
    596     {
     597    while((track = static_cast<Candidate*>(fItECalTowerTrackArray->Next())))
     598    { 
    597599      mother = track;
    598       track = static_cast<Candidate *>(track->Clone());
     600      track = static_cast<Candidate*>(track->Clone());
    599601      track->AddCandidate(mother);
    600602
     
    604606    }
    605607  }
     608
    606609
    607610  // if hcal neutral excess is significant, simply create neutral EflowNeutralHadron tower and clone each track into eflowtrack
     
    609612  {
    610613    // create new photon tower
    611     tower = static_cast<Candidate *>(fTower->Clone());
    612     pt = hcalNeutralEnergy / TMath::CosH(eta);
    613 
     614    tower = static_cast<Candidate*>(fTower->Clone());
     615    pt =  hcalNeutralEnergy / TMath::CosH(eta);
     616   
    614617    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, hcalNeutralEnergy);
    615618    tower->Ehad = hcalNeutralEnergy;
    616619    tower->Eem = 0.0;
    617 
     620   
    618621    fEFlowNeutralHadronOutputArray->Add(tower);
    619 
     622   
    620623    //clone tracks
    621624    fItHCalTowerTrackArray->Reset();
    622     while((track = static_cast<Candidate *>(fItHCalTowerTrackArray->Next())))
     625    while((track = static_cast<Candidate*>(fItHCalTowerTrackArray->Next())))
    623626    {
    624627      mother = track;
    625       track = static_cast<Candidate *>(track->Clone());
     628      track = static_cast<Candidate*>(track->Clone());
    626629      track->AddCandidate(mother);
    627630
    628631      fEFlowTrackOutputArray->Add(track);
    629632    }
    630   }
    631 
     633 
     634  }
     635 
    632636  // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking
    633637  else if(fHCalTrackEnergy > 0.0)
    634638  {
    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);
     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);
    639643    rescaleFactor = bestEnergyEstimate / fHCalTrackEnergy;
    640644
    641645    //rescale tracks
    642646    fItHCalTowerTrackArray->Reset();
    643     while((track = static_cast<Candidate *>(fItHCalTowerTrackArray->Next())))
    644     {
     647    while((track = static_cast<Candidate*>(fItHCalTowerTrackArray->Next())))
     648    { 
    645649      mother = track;
    646       track = static_cast<Candidate *>(track->Clone());
     650      track = static_cast<Candidate*>(track->Clone());
    647651      track->AddCandidate(mother);
    648652
     
    652656    }
    653657  }
     658 
     659 
    654660}
    655661
     
    662668  if(mean > 0.0)
    663669  {
    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));
     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));
    668674  }
    669675  else
  • modules/Calorimeter.h

    r0e7d64a re39abb4  
    4242{
    4343public:
     44
    4445  Calorimeter();
    4546  ~Calorimeter();
     
    5051
    5152private:
    52   typedef std::map<Long64_t, std::pair<Double_t, Double_t> > TFractionMap; //!
    53   typedef std::map<Double_t, std::set<Double_t> > TBinMap; //!
     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; //!
    5456
    5557  Candidate *fTower;
     
    7779  TBinMap fBinMap; //!
    7880
    79   std::vector<Double_t> fEtaBins;
    80   std::vector<std::vector<Double_t> *> fPhiBins;
     81  std::vector < Double_t > fEtaBins;
     82  std::vector < std::vector < Double_t >* > fPhiBins;
    8183
    82   std::vector<Long64_t> fTowerHits;
     84  std::vector < Long64_t > fTowerHits;
    8385
    84   std::vector<Double_t> fECalTowerFractions;
    85   std::vector<Double_t> fHCalTowerFractions;
     86  std::vector < Double_t > fECalTowerFractions;
     87  std::vector < Double_t > fHCalTowerFractions;
    8688
    87   std::vector<Double_t> fECalTrackFractions;
    88   std::vector<Double_t> fHCalTrackFractions;
     89  std::vector < Double_t > fECalTrackFractions;
     90  std::vector < Double_t > fHCalTrackFractions;
    8991
    9092  DelphesFormula *fECalResolutionFormula; //!
  • modules/Cloner.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class Clone
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
    3738#include <algorithm>
     39#include <stdexcept>
    3840#include <iostream>
    3941#include <sstream>
    40 #include <stdexcept>
    4142
    4243using namespace std;
     
    4748  fItInputArray(0)
    4849{
     50
    4951}
    5052
     
    5355Cloner::~Cloner()
    5456{
     57
    5558}
    5659
     
    6770
    6871  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
     72
    6973}
    7074
     
    8185{
    8286  Candidate *candidate;
    83 
    84   // loop over all input candidates
     87 
     88 // loop over all input candidates
    8589  fItInputArray->Reset();
    86   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     90  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    8791  {
    88     candidate = static_cast<Candidate *>(candidate->Clone());
     92    candidate = static_cast<Candidate*>(candidate->Clone());
    8993    fOutputArray->Add(candidate);
    9094  }
  • modules/Cloner.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  Cloner();
    4041  ~Cloner();
     
    4546
    4647private:
     48
    4749  TIterator *fItInputArray; //!
    4850
  • modules/ConstituentFilter.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class ConstituentFilter
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    8788  param = GetParam("ConstituentInputArray");
    8889  size = param.GetSize();
    89   for(i = 0; i < size / 2; ++i)
     90  for(i = 0; i < size/2; ++i)
    9091  {
    91     array = ImportArray(param[i * 2].GetString());
     92    array = ImportArray(param[i*2].GetString());
    9293    iterator = array->MakeIterator();
    9394
    94     fInputMap[iterator] = ExportArray(param[i * 2 + 1].GetString());
     95    fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
    9596  }
    9697}
     
    100101void ConstituentFilter::Finish()
    101102{
    102   map<TIterator *, TObjArray *>::iterator itInputMap;
    103   vector<TIterator *>::iterator itInputList;
     103  map< TIterator *, TObjArray * >::iterator itInputMap;
     104  vector< TIterator * >::iterator itInputList;
    104105  TIterator *iterator;
    105106
     
    122123{
    123124  Candidate *jet, *constituent;
    124   map<TIterator *, TObjArray *>::iterator itInputMap;
    125   vector<TIterator *>::iterator itInputList;
     125  map< TIterator *, TObjArray * >::iterator itInputMap;
     126  vector< TIterator * >::iterator itInputList;
    126127  TIterator *iterator;
    127128  TObjArray *array;
     
    134135    // loop over all jets
    135136    iterator->Reset();
    136     while((jet = static_cast<Candidate *>(iterator->Next())))
     137    while((jet = static_cast<Candidate*>(iterator->Next())))
    137138    {
    138139      TIter itConstituents(jet->GetCandidates());
     
    141142
    142143      // loop over all constituents
    143       while((constituent = static_cast<Candidate *>(itConstituents.Next())))
     144      while((constituent = static_cast<Candidate*>(itConstituents.Next())))
    144145      {
    145146        // set the IsConstituent flag
     
    157158    // loop over all constituents
    158159    iterator->Reset();
    159     while((constituent = static_cast<Candidate *>(iterator->Next())))
     160    while((constituent = static_cast<Candidate*>(iterator->Next())))
    160161    {
    161162      // check the IsConstituent flag
  • modules/ConstituentFilter.h

    r0e7d64a re39abb4  
    3030#include "classes/DelphesModule.h"
    3131
     32#include <vector>
    3233#include <map>
    33 #include <vector>
    3434
    3535class TIterator;
     
    3939{
    4040public:
     41
    4142  ConstituentFilter();
    4243  ~ConstituentFilter();
     
    4748
    4849private:
     50
    4951  Double_t fJetPTMin;
    5052
    51   std::vector<TIterator *> fInputList; //!
     53  std::vector< TIterator * > fInputList; //!
    5254
    53   std::map<TIterator *, TObjArray *> fInputMap; //!
     55  std::map< TIterator *, TObjArray * > fInputMap; //!
    5456
    5557  TObjArray *fOutputArray; //!
  • modules/Delphes.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class Delphes
    2021 *
     
    3233#include "classes/DelphesFormula.h"
    3334
     35#include "ExRootAnalysis/ExRootResult.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
    3437#include "ExRootAnalysis/ExRootClassifier.h"
    3538#include "ExRootAnalysis/ExRootConfReader.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    37 #include "ExRootAnalysis/ExRootResult.h"
    3839#include "ExRootAnalysis/ExRootTreeWriter.h"
    3940
     41#include "TROOT.h"
     42#include "TMath.h"
     43#include "TFolder.h"
     44#include "TString.h"
     45#include "TFormula.h"
     46#include "TRandom3.h"
     47#include "TObjArray.h"
    4048#include "TDatabasePDG.h"
    41 #include "TFolder.h"
    42 #include "TFormula.h"
    4349#include "TLorentzVector.h"
    44 #include "TMath.h"
    45 #include "TObjArray.h"
    46 #include "TROOT.h"
    47 #include "TRandom3.h"
    48 #include "TString.h"
    4950
    50 #include <algorithm>
     51#include <algorithm>
     52#include <stdexcept>
    5153#include <iostream>
    5254#include <sstream>
    53 #include <stdexcept>
    5455
     56#include <string.h>
    5557#include <stdio.h>
    56 #include <string.h>
    5758
    5859using namespace std;
  • modules/Delphes.h

    r0e7d64a re39abb4  
    4141{
    4242public:
     43
    4344  Delphes(const char *name = "Delphes");
    4445  ~Delphes();
    4546
    4647  void SetTreeWriter(ExRootTreeWriter *treeWriter);
    47 
     48 
    4849  DelphesFactory *GetFactory() const { return fFactory; }
    4950
     
    5556
    5657private:
     58
    5759  DelphesFactory *fFactory;
    5860
     
    6163
    6264#endif /* Delphes_h */
     65
  • modules/DenseTrackFilter.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class DenseTrackFilter
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    36 
     37
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    7071  Long_t i, j, k, size, sizeEtaBins, sizePhiBins;
    7172  TBinMap::iterator itEtaBin;
    72   set<Double_t>::iterator itPhiBin;
    73   vector<Double_t> *phiBins;
     73  set< Double_t >::iterator itPhiBin;
     74  vector< Double_t > *phiBins;
    7475
    7576  // read eta and phi bins
     
    7980  fEtaBins.clear();
    8081  fPhiBins.clear();
    81   for(i = 0; i < size / 2; ++i)
    82   {
    83     paramEtaBins = param[i * 2];
     82  for(i = 0; i < size/2; ++i)
     83  {
     84    paramEtaBins = param[i*2];
    8485    sizeEtaBins = paramEtaBins.GetSize();
    85     paramPhiBins = param[i * 2 + 1];
     86    paramPhiBins = param[i*2 + 1];
    8687    sizePhiBins = paramPhiBins.GetSize();
    8788
     
    100101  {
    101102    fEtaBins.push_back(itEtaBin->first);
    102     phiBins = new vector<double>(itEtaBin->second.size());
     103    phiBins = new vector< double >(itEtaBin->second.size());
    103104    fPhiBins.push_back(phiBins);
    104105    phiBins->clear();
     
    125126void DenseTrackFilter::Finish()
    126127{
    127   vector<vector<Double_t> *>::iterator itPhiBin;
     128  vector< vector< Double_t >* >::iterator itPhiBin;
    128129  if(fItTrackInputArray) delete fItTrackInputArray;
    129130  for(itPhiBin = fPhiBins.begin(); itPhiBin != fPhiBins.end(); ++itPhiBin)
     
    144145  Double_t ptmax;
    145146
    146   vector<Double_t>::iterator itEtaBin;
    147   vector<Double_t>::iterator itPhiBin;
    148   vector<Double_t> *phiBins;
    149 
    150   vector<Long64_t>::iterator itTowerHits;
     147  vector< Double_t >::iterator itEtaBin;
     148  vector< Double_t >::iterator itPhiBin;
     149  vector< Double_t > *phiBins;
     150
     151  vector< Long64_t >::iterator itTowerHits;
    151152
    152153  fTowerHits.clear();
     
    155156  fItTrackInputArray->Reset();
    156157  number = -1;
    157   while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
     158  while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
    158159  {
    159160    const TLorentzVector &trackPosition = track->Position;
     
    195196    towerHit = (*itTowerHits);
    196197    flags = (towerHit >> 24) & 0x00000000000000FFLL;
    197     number = (towerHit)&0x0000000000FFFFFFLL;
     198    number = (towerHit) & 0x0000000000FFFFFFLL;
    198199    hitEtaPhi = towerHit >> 32;
    199200
     
    215216    {
    216217      ++fTowerTrackHits;
    217       track = static_cast<Candidate *>(fTrackInputArray->At(number));
     218      track = static_cast<Candidate*>(fTrackInputArray->At(number));
    218219      momentum = track->Momentum;
    219220
     
    225226      continue;
    226227    }
     228
    227229  }
    228230
    229231  // here fill last tower
    230232  FillTrack();
     233
    231234}
    232235
     
    242245  // saving track with highest pT that hit the tower
    243246  if(fTowerTrackHits < 1) return;
    244 
     247   
    245248  numberOfCandidates = fBestTrack->GetCandidates()->GetEntriesFast();
    246249  if(numberOfCandidates < 1) return;
    247250
    248   track = static_cast<Candidate *>(fBestTrack->GetCandidates()->At(numberOfCandidates - 1));
    249   candidate = static_cast<Candidate *>(track->Clone());
     251  track = static_cast<Candidate*>(fBestTrack->GetCandidates()->At(numberOfCandidates - 1));
     252  candidate = static_cast<Candidate*>(track->Clone());
    250253  pt = candidate->Momentum.Pt();
    251254  eta = candidate->Momentum.Eta();
     
    253256  eta = gRandom->Gaus(eta, fEtaPhiRes);
    254257  phi = gRandom->Gaus(phi, fEtaPhiRes);
    255   candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt * TMath::CosH(eta));
     258  candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
    256259  candidate->AddCandidate(track);
    257260
     
    259262  switch(TMath::Abs(candidate->PID))
    260263  {
    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 }
     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}
  • modules/DenseTrackFilter.h

    r0e7d64a re39abb4  
    4141{
    4242public:
     43
    4344  DenseTrackFilter();
    4445  ~DenseTrackFilter();
     
    4950
    5051private:
    51   typedef std::map<Double_t, std::set<Double_t> > TBinMap; //!
     52
     53  typedef std::map< Double_t, std::set< Double_t > > TBinMap; //!
    5254
    5355  Candidate *fBestTrack;
     
    5961  TBinMap fBinMap; //!
    6062
    61   std::vector<Double_t> fEtaBins;
    62   std::vector<std::vector<Double_t> *> fPhiBins;
     63  std::vector < Double_t > fEtaBins;
     64  std::vector < std::vector < Double_t >* > fPhiBins;
    6365
    64   std::vector<Long64_t> fTowerHits;
     66  std::vector < Long64_t > fTowerHits;
    6567
    6668  TIterator *fItTrackInputArray; //!
  • modules/Efficiency.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class Efficiency
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    45 #include <algorithm>
     46#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    9394
    9495void Efficiency::Process()
    95 {
     96{ 
    9697  Candidate *candidate;
    97   Double_t pt, eta, phi, e, d0, dz, ctgTheta;
     98  Double_t pt, eta, phi, e;
    9899
    99100  fItInputArray->Reset();
    100   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     101  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    101102  {
    102103    const TLorentzVector &candidatePosition = candidate->Position;
     
    106107    pt = candidateMomentum.Pt();
    107108    e = candidateMomentum.E();
    108     d0 = candidate->D0;
    109     dz = candidate->DZ;
    110     ctgTheta = candidate->CtgTheta;
    111109
    112110    // apply an efficency formula
    113     if(gRandom->Uniform() > fFormula->Eval(pt, eta, phi, e, d0, dz, ctgTheta)) continue;
    114 
     111    if(gRandom->Uniform() > fFormula->Eval(pt, eta, phi, e)) continue;
     112   
    115113    fOutputArray->Add(candidate);
    116114  }
  • modules/Efficiency.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  Efficiency();
    4041  ~Efficiency();
     
    4546
    4647private:
     48
    4749  DelphesFormula *fFormula; //!
    4850
  • modules/EnergyScale.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class EnergyScale
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    45 #include <algorithm>
     46#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    9798  TLorentzVector momentum;
    9899  Double_t scale;
    99 
     100 
    100101  fItInputArray->Reset();
    101   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     102  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    102103  {
    103104    momentum = candidate->Momentum;
     
    107108    if(scale > 0.0) momentum *= scale;
    108109
    109     candidate = static_cast<Candidate *>(candidate->Clone());
     110    candidate = static_cast<Candidate*>(candidate->Clone());
    110111    candidate->Momentum = momentum;
    111112
  • modules/EnergyScale.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  EnergyScale();
    4041  ~EnergyScale();
     
    4546
    4647private:
     48
    4749  DelphesFormula *fFormula; //!
    4850
     
    5052
    5153  const TObjArray *fInputArray; //!
    52 
     54 
    5355  TObjArray *fOutputArray; //!
    5456
  • modules/EnergySmearing.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class EnergySmearing
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    45 #include <algorithm>
     46#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    8687
    8788void EnergySmearing::Finish()
    88 {
     89{ 
    8990  if(fItInputArray) delete fItInputArray;
    9091}
     
    9899
    99100  fItInputArray->Reset();
    100   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     101  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    101102  {
    102103    const TLorentzVector &candidatePosition = candidate->Position;
    103104    const TLorentzVector &candidateMomentum = candidate->Momentum;
    104 
     105   
    105106    pt = candidatePosition.Pt();
    106107    eta = candidatePosition.Eta();
    107108    phi = candidatePosition.Phi();
    108109    energy = candidateMomentum.E();
    109 
     110 
    110111    // apply smearing formula
    111112    energy = gRandom->Gaus(energy, fFormula->Eval(pt, eta, phi, energy));
    112 
     113     
    113114    if(energy <= 0.0) continue;
    114 
     115 
    115116    mother = candidate;
    116     candidate = static_cast<Candidate *>(candidate->Clone());
     117    candidate = static_cast<Candidate*>(candidate->Clone());
    117118    eta = candidateMomentum.Eta();
    118119    phi = candidateMomentum.Phi();
    119     candidate->Momentum.SetPtEtaPhiE(energy / TMath::CosH(eta), eta, phi, energy);
    120     candidate->TrackResolution = fFormula->Eval(pt, eta, phi, energy) / candidateMomentum.E();
     120    candidate->Momentum.SetPtEtaPhiE(energy/TMath::CosH(eta), eta, phi, energy);
     121    candidate->TrackResolution = fFormula->Eval(pt, eta, phi, energy)/candidateMomentum.E();
    121122    candidate->AddCandidate(mother);
    122 
     123 
    123124    fOutputArray->Add(candidate);
    124125  }
  • modules/EnergySmearing.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  EnergySmearing();
    4041  ~EnergySmearing();
     
    4546
    4647private:
     48
    4749  DelphesFormula *fFormula; //!
    4850
     
    5052
    5153  const TObjArray *fInputArray; //!
    52 
     54 
    5355  TObjArray *fOutputArray; //!
    5456
  • modules/ExampleModule.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class ExampleModule
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    45 #include <algorithm>
     46#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    8687    fArrayParam.push_back(param[i].GetDouble());
    8788  }
    88 
     89 
    8990  // import input array(s)
    9091
     
    9596
    9697  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
     98
    9799}
    98100
     
    113115  // loop over all input candidates
    114116  fItInputArray->Reset();
    115   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     117  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    116118  {
    117119    candidatePosition = candidate->Position;
  • modules/ExampleModule.h

    r0e7d64a re39abb4  
    3838{
    3939public:
     40
    4041  ExampleModule();
    4142  ~ExampleModule();
     
    4647
    4748private:
     49
    4850  Int_t fIntParam;
    4951  Double_t fDoubleParam;
    50 
    51   std::deque<Double_t> fArrayParam;
    52 
     52 
     53  std::deque <Double_t> fArrayParam;
     54 
    5355  DelphesFormula *fFormula; //!
    5456
  • modules/FastJetFinder.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class FastJetFinder
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    36 
     37
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950#include <vector>
    5051
     52#include "fastjet/PseudoJet.hh"
     53#include "fastjet/JetDefinition.hh"
    5154#include "fastjet/ClusterSequence.hh"
     55#include "fastjet/Selector.hh"
    5256#include "fastjet/ClusterSequenceArea.hh"
    53 #include "fastjet/JetDefinition.hh"
    54 #include "fastjet/PseudoJet.hh"
    55 #include "fastjet/Selector.hh"
    5657#include "fastjet/tools/JetMedianBackgroundEstimator.hh"
    5758
     59#include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh"
     60#include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
    5861#include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh"
    59 #include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
    60 #include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh"
    61 
    62 #include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
     62
     63#include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
    6364#include "fastjet/contribs/Nsubjettiness/Njettiness.hh"
    6465#include "fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh"
    65 #include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
     66#include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
    6667
    6768#include "fastjet/contribs/ValenciaPlugin/ValenciaPlugin.hh"
    6869
    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"
    7273
    7374using namespace std;
    7475using namespace fastjet;
    7576using namespace fastjet::contrib;
     77
    7678
    7779//------------------------------------------------------------------------------
     
    8183  fDefinition(0), fAreaDefinition(0), fItInputArray(0)
    8284{
     85
    8386}
    8487
     
    8790FastJetFinder::~FastJetFinder()
    8891{
     92
    8993}
    9094
     
    116120  fJetPTMin = GetDouble("JetPTMin", 10.0);
    117121
     122 
    118123  //-- N(sub)jettiness parameters --
    119124
     
    122127  fAxisMode = GetInt("AxisMode", 1);
    123128  fRcutOff = GetDouble("RcutOff", 0.8); // 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)
     129  fN = GetInt("N", 2);                  // used only if Njettiness is used as jet clustering algo (case 8)
    125130
    126131  //-- Exclusive clustering for e+e- collisions --
    127 
    128   fNJets = GetInt("NJets", 2);
     132 
     133  fNJets = GetInt("NJets",2);
    129134  fExclusiveClustering = GetBool("ExclusiveClustering", false);
    130135
    131136  //-- Valencia Linear Collider algorithm
    132 
    133137  fGamma = GetDouble("Gamma", 1.0);
    134138  //fBeta parameter see above
    135 
     139 
    136140  fMeasureDef = new NormalizedMeasure(fBeta, fParameterR);
    137 
     141   
    138142  switch(fAxisMode)
    139143  {
    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   }
     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   }
    153157
    154158  //-- Trimming parameters --
    155 
     159 
    156160  fComputeTrimming = GetBool("ComputeTrimming", false);
    157161  fRTrim = GetDouble("RTrim", 0.2);
    158162  fPtFracTrim = GetDouble("PtFracTrim", 0.05);
     163 
    159164
    160165  //-- Pruning parameters --
    161 
     166 
    162167  fComputePruning = GetBool("ComputePruning", false);
    163168  fZcutPrun = GetDouble("ZcutPrun", 0.1);
    164169  fRcutPrun = GetDouble("RcutPrun", 0.5);
    165170  fRPrun = GetDouble("RPrun", 0.8);
    166 
     171 
    167172  //-- SoftDrop parameters --
    168 
    169   fComputeSoftDrop = GetBool("ComputeSoftDrop", false);
    170   fBetaSoftDrop = GetDouble("BetaSoftDrop", 0.0);
     173 
     174  fComputeSoftDrop     = GetBool("ComputeSoftDrop", false);
     175  fBetaSoftDrop        = GetDouble("BetaSoftDrop", 0.0);
    171176  fSymmetryCutSoftDrop = GetDouble("SymmetryCutSoftDrop", 0.1);
    172   fR0SoftDrop = GetDouble("R0SoftDrop=", 0.8);
     177  fR0SoftDrop= GetDouble("R0SoftDrop=", 0.8);
     178 
    173179
    174180  // ---  Jet Area Parameters ---
    175 
    176181  fAreaAlgorithm = GetInt("AreaAlgorithm", 0);
    177182  fComputeRho = GetBool("ComputeRho", false);
     
    190195  switch(fAreaAlgorithm)
    191196  {
    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;
     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;
    211216  }
    212217
    213218  switch(fJetAlgorithm)
    214219  {
    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;
     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;
    245250  case 9:
    246     fValenciaPlugin = new ValenciaPlugin(fParameterR, fBeta, fGamma);
    247     fDefinition = new JetDefinition(fValenciaPlugin);
    248     break;
    249   }
     251      fValenciaPlugin = new ValenciaPlugin(fParameterR, fBeta, fGamma);
     252      fDefinition = new JetDefinition(fValenciaPlugin);
     253      break;
     254
     255  }
     256
     257   
    250258
    251259  fPlugin = plugin;
     
    262270
    263271    fEstimators.clear();
    264     for(i = 0; i < size / 2; ++i)
    265     {
    266       etaMin = param[i * 2].GetDouble();
    267       etaMax = param[i * 2 + 1].GetDouble();
     272    for(i = 0; i < size/2; ++i)
     273    {
     274      etaMin = param[i*2].GetDouble();
     275      etaMax = param[i*2 + 1].GetDouble();
    268276      estimatorStruct.estimator = new JetMedianBackgroundEstimator(SelectorRapRange(etaMin, etaMax), *fDefinition, *fAreaDefinition);
    269277      estimatorStruct.etaMin = etaMin;
     
    282290  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
    283291  fRhoOutputArray = ExportArray(GetString("RhoOutputArray", "rho"));
    284   fConstituentsOutputArray = ExportArray(GetString("ConstituentsOutputArray", "constituents"));
    285292}
    286293
     
    289296void FastJetFinder::Finish()
    290297{
    291   vector<TEstimatorStruct>::iterator itEstimators;
     298  vector< TEstimatorStruct >::iterator itEstimators;
    292299
    293300  for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
     
    299306  if(fDefinition) delete fDefinition;
    300307  if(fAreaDefinition) delete fAreaDefinition;
    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);
     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);
    304311  if(fAxesDef) delete fAxesDef;
    305312  if(fMeasureDef) delete fMeasureDef;
    306   if(fValenciaPlugin) delete static_cast<JetDefinition::Plugin *>(fValenciaPlugin);
     313  if(fValenciaPlugin) delete static_cast<JetDefinition::Plugin*>(fValenciaPlugin);
     314
    307315}
    308316
     
    317325  Double_t time, timeWeight;
    318326  Int_t number, ncharged, nneutrals;
    319   Int_t charge;
     327  Int_t charge; 
    320328  Double_t rho = 0.0;
    321329  PseudoJet jet, area;
    322330  ClusterSequence *sequence;
    323   vector<PseudoJet> inputList, outputList, subjets;
    324   vector<PseudoJet>::iterator itInputList, itOutputList;
    325   vector<TEstimatorStruct>::iterator itEstimators;
     331  vector< PseudoJet > inputList, outputList, subjets;
     332  vector< PseudoJet >::iterator itInputList, itOutputList;
     333  vector< TEstimatorStruct >::iterator itEstimators;
    326334  Double_t excl_ymerge23 = 0.0;
    327335  Double_t excl_ymerge34 = 0.0;
    328336  Double_t excl_ymerge45 = 0.0;
    329337  Double_t excl_ymerge56 = 0.0;
    330 
     338 
    331339  DelphesFactory *factory = GetFactory();
    332340
     
    336344  fItInputArray->Reset();
    337345  number = 0;
    338   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     346  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    339347  {
    340348    momentum = candidate->Momentum;
     
    373381  outputList.clear();
    374382
     383 
    375384  if(fExclusiveClustering)
    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   }
     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    }
    391399  else
    392   {
    393     outputList = sorted_by_pt(sequence->inclusive_jets(fJetPTMin));
    394   }
     400    {
     401      outputList = sorted_by_pt(sequence->inclusive_jets(fJetPTMin));
     402    }
    395403
    396404  // loop over all jets and export them
    397405  detaMax = 0.0;
    398406  dphiMax = 0.0;
    399 
     407 
    400408  for(itOutputList = outputList.begin(); itOutputList != outputList.end(); ++itOutputList)
    401409  {
     
    408416    if(fAreaDefinition) area = itOutputList->area_4vector();
    409417
     418
     419   
    410420    candidate = factory->NewCandidate();
    411421
     
    424434    {
    425435      if(itInputList->user_index() < 0) continue;
    426       constituent = static_cast<Candidate *>(fInputArray->At(itInputList->user_index()));
     436      constituent = static_cast<Candidate*>(fInputArray->At(itInputList->user_index()));
    427437
    428438      deta = TMath::Abs(momentum.Eta() - constituent->Momentum.Eta());
     
    431441      if(dphi > dphiMax) dphiMax = dphi;
    432442
    433       if(constituent->Charge == 0)
    434         nneutrals++;
    435       else
    436         ncharged++;
    437 
    438       time += TMath::Sqrt(constituent->Momentum.E()) * (constituent->Position.T());
     443      if(constituent->Charge == 0) nneutrals++;
     444      else ncharged++;
     445
     446      time += TMath::Sqrt(constituent->Momentum.E())*(constituent->Position.T());
    439447      timeWeight += TMath::Sqrt(constituent->Momentum.E());
    440448
    441449      charge += constituent->Charge;
    442450
    443       fConstituentsOutputArray->Add(constituent);
    444451      candidate->AddCandidate(constituent);
    445452    }
    446453
    447454    candidate->Momentum = momentum;
    448     candidate->Position.SetT(time / timeWeight);
     455    candidate->Position.SetT(time/timeWeight);
    449456    candidate->Area.SetPxPyPzE(area.px(), area.py(), area.pz(), area.E());
    450457
    451458    candidate->DeltaEta = detaMax;
    452459    candidate->DeltaPhi = dphiMax;
    453     candidate->Charge = charge;
     460    candidate->Charge = charge; 
    454461    candidate->NNeutrals = nneutrals;
    455462    candidate->NCharged = ncharged;
     463
    456464
    457465    //for exclusive clustering, access y_n,n+1 as exclusive_ymerge (fNJets);
     
    460468    candidate->ExclYmerge45 = excl_ymerge45;
    461469    candidate->ExclYmerge56 = excl_ymerge56;
    462 
     470   
    463471    //------------------------------------
    464472    // Trimming
     
    468476    {
    469477
    470       fastjet::Filter trimmer(fastjet::JetDefinition(fastjet::kt_algorithm, fRTrim), fastjet::SelectorPtFractionMin(fPtFracTrim));
     478      fastjet::Filter    trimmer(fastjet::JetDefinition(fastjet::kt_algorithm,fRTrim),fastjet::SelectorPtFractionMin(fPtFracTrim));
    471479      fastjet::PseudoJet trimmed_jet = trimmer(*itOutputList);
    472 
     480     
    473481      trimmed_jet = join(trimmed_jet.constituents());
    474 
     482     
    475483      candidate->TrimmedP4[0].SetPtEtaPhiM(trimmed_jet.pt(), trimmed_jet.eta(), trimmed_jet.phi(), trimmed_jet.m());
    476 
    477       // four hardest subjets
     484       
     485      // four hardest subjets 
    478486      subjets.clear();
    479487      subjets = trimmed_jet.pieces();
    480488      subjets = sorted_by_pt(subjets);
    481 
     489     
    482490      candidate->NSubJetsTrimmed = subjets.size();
    483491
    484       for(size_t i = 0; i < subjets.size() and i < 4; i++)
     492      for (size_t i = 0; i < subjets.size() and i < 4; i++)
    485493      {
    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());
     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());
    488496      }
    489497    }
    490 
     498   
     499   
    491500    //------------------------------------
    492501    // Pruning
    493502    //------------------------------------
    494 
     503   
     504   
    495505    if(fComputePruning)
    496506    {
    497507
    498       fastjet::Pruner pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm, fRPrun), fZcutPrun, fRcutPrun);
     508      fastjet::Pruner    pruner(fastjet::JetDefinition(fastjet::cambridge_algorithm,fRPrun),fZcutPrun,fRcutPrun);
    499509      fastjet::PseudoJet pruned_jet = pruner(*itOutputList);
    500510
    501511      candidate->PrunedP4[0].SetPtEtaPhiM(pruned_jet.pt(), pruned_jet.eta(), pruned_jet.phi(), pruned_jet.m());
    502 
    503       // four hardest subjet
     512         
     513      // four hardest subjet 
    504514      subjets.clear();
    505515      subjets = pruned_jet.pieces();
    506516      subjets = sorted_by_pt(subjets);
    507 
     517     
    508518      candidate->NSubJetsPruned = subjets.size();
    509519
    510       for(size_t i = 0; i < subjets.size() and i < 4; i++)
     520      for (size_t i = 0; i < subjets.size() and i < 4; i++)
    511521      {
    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());
     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());
    514524      }
    515     }
    516 
     525
     526    }
     527     
    517528    //------------------------------------
    518529    // SoftDrop
    519530    //------------------------------------
    520 
     531   
    521532    if(fComputeSoftDrop)
    522533    {
    523 
    524       contrib::SoftDrop softDrop(fBetaSoftDrop, fSymmetryCutSoftDrop, fR0SoftDrop);
     534   
     535      contrib::SoftDrop softDrop(fBetaSoftDrop,fSymmetryCutSoftDrop,fR0SoftDrop);
    525536      fastjet::PseudoJet softdrop_jet = softDrop(*itOutputList);
    526 
     537     
    527538      candidate->SoftDroppedP4[0].SetPtEtaPhiM(softdrop_jet.pt(), softdrop_jet.eta(), softdrop_jet.phi(), softdrop_jet.m());
    528 
    529       // four hardest subjet
    530 
     539       
     540      // four hardest subjet 
     541     
    531542      subjets.clear();
    532       subjets = softdrop_jet.pieces();
    533       subjets = sorted_by_pt(subjets);
     543      subjets    = softdrop_jet.pieces();
     544      subjets    = sorted_by_pt(subjets);
    534545      candidate->NSubJetsSoftDropped = softdrop_jet.pieces().size();
    535546
    536547      candidate->SoftDroppedJet = candidate->SoftDroppedP4[0];
    537548
    538       for(size_t i = 0; i < subjets.size() and i < 4; i++)
     549      for (size_t i = 0; i < subjets.size() and i < 4; i++)
    539550      {
    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];
     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];
    544555      }
    545556    }
    546 
     557 
    547558    // --- compute N-subjettiness with N = 1,2,3,4,5 ----
    548559
    549560    if(fComputeNsubjettiness)
    550561    {
    551 
     562     
    552563      Nsubjettiness nSub1(1, *fAxesDef, *fMeasureDef);
    553564      Nsubjettiness nSub2(2, *fAxesDef, *fMeasureDef);
     
    555566      Nsubjettiness nSub4(4, *fAxesDef, *fMeasureDef);
    556567      Nsubjettiness nSub5(5, *fAxesDef, *fMeasureDef);
    557 
     568     
    558569      candidate->Tau[0] = nSub1(*itOutputList);
    559570      candidate->Tau[1] = nSub2(*itOutputList);
     
    561572      candidate->Tau[3] = nSub4(*itOutputList);
    562573      candidate->Tau[4] = nSub5(*itOutputList);
     574         
    563575    }
    564576
  • modules/FastJetFinder.h

    r0e7d64a re39abb4  
    3535class TIterator;
    3636
    37 namespace fastjet
    38 {
    39 class JetDefinition;
    40 class AreaDefinition;
    41 class JetMedianBackgroundEstimator;
    42 namespace contrib
    43 {
    44 class NjettinessPlugin;
    45 class ValenciaPlugin;
    46 class AxesDefinition;
    47 class MeasureDefinition;
    48 } // namespace contrib
    49 } // namespace fastjet
     37namespace 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}
    5048
    5149class FastJetFinder: public DelphesModule
    5250{
    5351public:
     52
    5453  FastJetFinder();
    5554  ~FastJetFinder();
     
    6059
    6160private:
     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; //!
    155154
    156155  ClassDef(FastJetFinder, 1)
  • modules/FastJetGridMedianEstimator.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class FastJetGridMedianEstimator
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
     50#include <vector>
    4951#include <utility>
    50 #include <vector>
    5152
     53#include "fastjet/PseudoJet.hh"
     54#include "fastjet/JetDefinition.hh"
    5255#include "fastjet/ClusterSequence.hh"
     56#include "fastjet/Selector.hh"
     57#include "fastjet/RectangularGrid.hh"
    5358#include "fastjet/ClusterSequenceArea.hh"
    54 #include "fastjet/JetDefinition.hh"
    55 #include "fastjet/PseudoJet.hh"
    56 #include "fastjet/RectangularGrid.hh"
    57 #include "fastjet/Selector.hh"
    5859#include "fastjet/tools/JetMedianBackgroundEstimator.hh"
    5960
    6061#include "fastjet/tools/GridMedianBackgroundEstimator.hh"
    6162
     63#include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh"
     64#include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
    6265#include "fastjet/plugins/CDFCones/fastjet/CDFJetCluPlugin.hh"
    63 #include "fastjet/plugins/CDFCones/fastjet/CDFMidPointPlugin.hh"
    64 #include "fastjet/plugins/SISCone/fastjet/SISConePlugin.hh"
    6566
    66 #include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
     67#include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
    6768#include "fastjet/contribs/Nsubjettiness/Njettiness.hh"
    6869#include "fastjet/contribs/Nsubjettiness/NjettinessPlugin.hh"
    69 #include "fastjet/contribs/Nsubjettiness/Nsubjettiness.hh"
     70#include "fastjet/contribs/Nsubjettiness/ExtraRecombiners.hh"
    7071
    7172using namespace std;
    7273using namespace fastjet;
    7374using namespace fastjet::contrib;
     75
    7476
    7577//------------------------------------------------------------------------------
     
    7880  fItInputArray(0)
    7981{
     82
    8083}
    8184
     
    8487FastJetGridMedianEstimator::~FastJetGridMedianEstimator()
    8588{
     89
    8690}
    8791
     
    100104
    101105  fEstimators.clear();
    102   for(i = 0; i < size / 4; ++i)
     106  for(i = 0; i < size/4; ++i)
    103107  {
    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();
     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();
    108112    fEstimators.push_back(new GridMedianBackgroundEstimator(rapMin, rapMax, drap, dphi));
    109113  }
     
    121125void FastJetGridMedianEstimator::Finish()
    122126{
    123   vector<GridMedianBackgroundEstimator *>::iterator itEstimators;
     127  vector< GridMedianBackgroundEstimator * >::iterator itEstimators;
    124128
    125129  for(itEstimators = fEstimators.begin(); itEstimators != fEstimators.end(); ++itEstimators)
     
    140144  Double_t rho = 0;
    141145  PseudoJet jet;
    142   vector<PseudoJet> inputList, outputList;
     146  vector< PseudoJet > inputList, outputList;
    143147
    144   vector<GridMedianBackgroundEstimator *>::iterator itEstimators;
    145   ;
     148  vector< GridMedianBackgroundEstimator * >::iterator itEstimators;;
    146149
    147150  DelphesFactory *factory = GetFactory();
     
    152155  fItInputArray->Reset();
    153156  number = 0;
    154   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     157  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    155158  {
    156159    momentum = candidate->Momentum;
  • modules/FastJetGridMedianEstimator.h

    r0e7d64a re39abb4  
    2020#define FastJetGridMedianEstimator_h
    2121
     22
    2223/** \class FastJetGridMedianEstimator
    2324 *
     
    3435class TIterator;
    3536
    36 namespace fastjet
    37 {
    38 class GridMedianBackgroundEstimator;
     37namespace fastjet {
     38  class GridMedianBackgroundEstimator;
    3939}
    4040
     
    4242{
    4343public:
     44
    4445  FastJetGridMedianEstimator();
    4546  ~FastJetGridMedianEstimator();
     
    5051
    5152private:
    52   std::vector<fastjet::GridMedianBackgroundEstimator *> fEstimators; //!
     53
     54  std::vector< fastjet::GridMedianBackgroundEstimator * > fEstimators; //!
    5355
    5456  TIterator *fItInputArray; //!
  • modules/Hector.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class Hector
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051#include "Hector/H_BeamLine.h"
     52#include "Hector/H_RecRPObject.h"
    5153#include "Hector/H_BeamParticle.h"
    52 #include "Hector/H_RecRPObject.h"
    5354
    5455using namespace std;
     
    119120
    120121  fItInputArray->Reset();
    121   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     122  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    122123  {
    123124    const TLorentzVector &candidatePosition = candidate->Position;
     
    131132    z = 1.0E-3 * candidatePosition.Z();
    132133
    133     //    tx = 1.0E6 * TMath::ATan(candidateMomentum.Px()/pz);
    134     //    ty = 1.0E6 * TMath::ATan(candidateMomentum.Py()/pz);
     134//    tx = 1.0E6 * TMath::ATan(candidateMomentum.Px()/pz);
     135//    ty = 1.0E6 * TMath::ATan(candidateMomentum.Py()/pz);
    135136
    136137    tx = 0.0;
    137138    ty = 0.0;
    138139
    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);
     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);
    142143
    143144    H_BeamParticle particle(candidate->Mass, candidate->Charge);
    144     //    particle.set4Momentum(candidateMomentum);
    145     particle.set4Momentum(candidateMomentum.Px(), candidateMomentum.Py(),
    146       candidateMomentum.Pz(), candidateMomentum.E());
     145//    particle.set4Momentum(candidateMomentum);
     146    particle.set4Momentum(candidateMomentum.Px(), candidateMomentum.Py(), 
     147                          candidateMomentum.Pz(), candidateMomentum.E());
    147148    particle.setPosition(x, y, tx, ty, z);
    148149
     
    157158
    158159    mother = candidate;
    159     candidate = static_cast<Candidate *>(candidate->Clone());
     160    candidate = static_cast<Candidate*>(candidate->Clone());
    160161    candidate->Position.SetXYZT(particle.getX(), particle.getY(), particle.getS(), time);
    161162    candidate->Momentum.SetPxPyPzE(particle.getTX(), particle.getTY(), 0.0, particle.getE());
  • modules/Hector.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  Hector();
    4041  ~Hector();
     
    4546
    4647private:
     48
    4749  Int_t fDirection;
    4850
  • modules/IdentificationMap.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class IdentificationMap
    2021 *
     
    3233#include "classes/DelphesFormula.h"
    3334
     35#include "ExRootAnalysis/ExRootResult.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
    3437#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    3738
     39#include "TMath.h"
     40#include "TString.h"
     41#include "TFormula.h"
     42#include "TRandom3.h"
     43#include "TObjArray.h"
    3844#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4045#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TRandom3.h"
    44 #include "TString.h"
    4546
    4647#include <algorithm>
     48#include <stdexcept>
    4749#include <iostream>
    4850#include <sstream>
    49 #include <stdexcept>
    5051
    5152using namespace std;
     
    7879
    7980  fEfficiencyMap.clear();
    80   for(i = 0; i < size / 3; ++i)
     81  for(i = 0; i < size/3; ++i)
    8182  {
    8283    formula = new DelphesFormula;
    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)));
     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)));
    8687  }
    8788
     
    128129  Double_t pt, eta, phi, e;
    129130  TMisIDMap::iterator itEfficiencyMap;
    130   pair<TMisIDMap::iterator, TMisIDMap::iterator> range;
     131  pair <TMisIDMap::iterator, TMisIDMap::iterator> range;
    131132  DelphesFormula *formula;
    132133  Int_t pdgCodeIn, pdgCodeOut, charge;
     
    135136
    136137  fItInputArray->Reset();
    137   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     138  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    138139  {
    139140    const TLorentzVector &candidatePosition = candidate->Position;
     
    143144    pt = candidateMomentum.Pt();
    144145    e = candidateMomentum.E();
    145 
     146   
    146147    pdgCodeIn = candidate->PID;
    147148    charge = candidate->Charge;
     
    170171      {
    171172        // change PID of particle
    172         if(pdgCodeOut != 0) candidate->PID = charge * pdgCodeOut;
     173        if(pdgCodeOut != 0) candidate->PID = charge*pdgCodeOut;
    173174        fOutputArray->Add(candidate);
    174175        break;
  • modules/IdentificationMap.h

    r0e7d64a re39abb4  
    2020#define IdentificationMap_h
    2121
     22
    2223/** \class IdentificationMap
    2324 *
     
    3839{
    3940public:
     41
    4042  IdentificationMap();
    4143  ~IdentificationMap();
     
    4648
    4749private:
    48   typedef std::multimap<Int_t, std::pair<Int_t, DelphesFormula *> > TMisIDMap; //!
     50
     51  typedef std::multimap< Int_t, std::pair< Int_t, DelphesFormula * > > TMisIDMap; //!
    4952
    5053  TMisIDMap fEfficiencyMap; //!
  • modules/ImpactParameterSmearing.cc

    r0e7d64a re39abb4  
    2525 */
    2626
     27
    2728#include "modules/ImpactParameterSmearing.h"
    2829
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    99100
    100101  fItInputArray->Reset();
    101   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     102  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    102103  {
    103104
    104105    // take momentum before smearing (otherwise apply double smearing on d0)
    105     particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     106    particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
    106107
    107108    const TLorentzVector &candidateMomentum = particle->Momentum;
     
    111112    phi = candidateMomentum.Phi();
    112113    e = candidateMomentum.E();
    113 
     114   
    114115    px = candidateMomentum.Px();
    115116    py = candidateMomentum.Py();
    116117
    117118    // calculate coordinates of closest approach to track circle in transverse plane xd, yd, zd
    118     xd = candidate->Xd;
    119     yd = candidate->Yd;
    120     zd = candidate->Zd;
     119    xd =  candidate->Xd;
     120    yd =  candidate->Yd;
     121    zd =  candidate->Zd;
    121122
    122123    // calculate smeared values
     
    130131
    131132    // calculate impact parameter (after-smearing)
    132     d0 = (xd * py - yd * px) / pt;
     133    d0 = (xd*py - yd*px)/pt;
    133134
    134135    dd0 = gRandom->Gaus(0.0, fFormula->Eval(pt, eta, phi, e));
     
    137138    mother = candidate;
    138139
    139     candidate = static_cast<Candidate *>(candidate->Clone());
     140    candidate = static_cast<Candidate*>(candidate->Clone());
    140141    candidate->Xd = xd;
    141142    candidate->Yd = yd;
  • modules/ImpactParameterSmearing.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  ImpactParameterSmearing();
    4041  ~ImpactParameterSmearing();
     
    4546
    4647private:
     48
    4749  DelphesFormula *fFormula; //!
    4850
     
    5052
    5153  const TObjArray *fInputArray; //!
    52 
     54 
    5355  TObjArray *fOutputArray; //!
    5456
  • modules/Isolation.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class Isolation
    2021 *
     
    3435#include "classes/DelphesFormula.h"
    3536
     37#include "ExRootAnalysis/ExRootResult.h"
     38#include "ExRootAnalysis/ExRootFilter.h"
    3639#include "ExRootAnalysis/ExRootClassifier.h"
    37 #include "ExRootAnalysis/ExRootFilter.h"
    38 #include "ExRootAnalysis/ExRootResult.h"
    39 
     40
     41#include "TMath.h"
     42#include "TString.h"
     43#include "TFormula.h"
     44#include "TRandom3.h"
     45#include "TObjArray.h"
    4046#include "TDatabasePDG.h"
    41 #include "TFormula.h"
    4247#include "TLorentzVector.h"
    43 #include "TMath.h"
    44 #include "TObjArray.h"
    45 #include "TRandom3.h"
    46 #include "TString.h"
    4748
    4849#include <algorithm>
     50#include <stdexcept>
    4951#include <iostream>
    5052#include <sstream>
    51 #include <stdexcept>
    5253
    5354using namespace std;
     
    5859{
    5960public:
     61
    6062  IsolationClassifier() {}
    6163
     
    6971Int_t IsolationClassifier::GetCategory(TObject *object)
    7072{
    71   Candidate *track = static_cast<Candidate *>(object);
     73  Candidate *track = static_cast<Candidate*>(object);
    7274  const TLorentzVector &momentum = track->Momentum;
    7375
     
    169171  // loop over all input jets
    170172  fItCandidateInputArray->Reset();
    171   while((candidate = static_cast<Candidate *>(fItCandidateInputArray->Next())))
     173  while((candidate = static_cast<Candidate*>(fItCandidateInputArray->Next())))
    172174  {
    173175    const TLorentzVector &candidateMomentum = candidate->Momentum;
     
    179181    {
    180182      fItRhoInputArray->Reset();
    181       while((object = static_cast<Candidate *>(fItRhoInputArray->Next())))
     183      while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
    182184      {
    183185        if(eta >= object->Edges[0] && eta < object->Edges[1])
     
    196198
    197199    itIsolationArray.Reset();
    198     while((isolation = static_cast<Candidate *>(itIsolationArray.Next())))
     200    while((isolation = static_cast<Candidate*>(itIsolationArray.Next())))
    199201    {
    200202      const TLorentzVector &isolationMomentum = isolation->Momentum;
     
    202204      if(fUseMiniCone)
    203205      {
    204         pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax && candidateMomentum.DeltaR(isolationMomentum) > fDeltaRMin;
     206         pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax &&
     207         candidateMomentum.DeltaR(isolationMomentum) > fDeltaRMin;
    205208      }
    206209      else
    207210      {
    208         pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax && candidate->GetUniqueID() != isolation->GetUniqueID();
     211         pass = candidateMomentum.DeltaR(isolationMomentum) <= fDeltaRMax &&
     212         candidate->GetUniqueID() != isolation->GetUniqueID();
    209213      }
    210214
     
    229233        }
    230234      }
     235
    231236    }
    232237
    233     // find rho
     238   // find rho
    234239    rho = 0.0;
    235240    if(fRhoInputArray)
    236241    {
    237242      fItRhoInputArray->Reset();
    238       while((object = static_cast<Candidate *>(fItRhoInputArray->Next())))
     243      while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
    239244      {
    240245        if(eta >= object->Edges[0] && eta < object->Edges[1])
     
    245250    }
    246251
     252
     253
    247254    // correct sum for pile-up contamination
    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();
     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();
    252259
    253260    candidate->IsolationVar = ratioDBeta;
  • modules/Isolation.h

    r0e7d64a re39abb4  
    4141{
    4242public:
     43
    4344  Isolation();
    4445  ~Isolation();
     
    4950
    5051private:
     52
    5153  Double_t fDeltaRMax;
    5254
  • modules/JetFakeParticle.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class JetFakeParticle
    2021 *
     
    3233#include "classes/DelphesFormula.h"
    3334
     35#include "ExRootAnalysis/ExRootResult.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
    3437#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    37 
     38
     39#include "TMath.h"
     40#include "TString.h"
     41#include "TFormula.h"
     42#include "TRandom3.h"
     43#include "TObjArray.h"
    3844#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4045#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TRandom3.h"
    44 #include "TString.h"
    4546
    4647#include <algorithm>
     48#include <stdexcept>
    4749#include <iostream>
    4850#include <sstream>
    49 #include <stdexcept>
     51
    5052
    5153using namespace std;
     
    7981  fEfficiencyMap.clear();
    8082
    81   for(i = 0; i < size / 2; ++i)
     83  for(i = 0; i < size/2; ++i)
    8284  {
    8385    formula = new DelphesFormula;
    84     formula->Compile(param[i * 2 + 1].GetString());
    85     pdgCode = param[i * 2].GetInt();
     86    formula->Compile(param[i*2 + 1].GetString());
     87    pdgCode = param[i*2].GetInt();
    8688
    8789    if(TMath::Abs(pdgCode) != 11 && TMath::Abs(pdgCode) != 13 && TMath::Abs(pdgCode) != 22)
     
    9092    }
    9193
    92     fEfficiencyMap[param[i * 2].GetInt()] = formula;
     94    fEfficiencyMap[param[i*2].GetInt()] = formula;
    9395  }
    9496
     
    114116  fPhotonOutputArray = ExportArray(GetString("PhotonOutputArray", "fakePhotons"));
    115117  fJetOutputArray = ExportArray(GetString("JetOutputArray", "jets"));
     118
    116119}
    117120
     
    144147
    145148  fItInputArray->Reset();
    146   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     149  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    147150  {
    148151    const TLorentzVector &candidatePosition = candidate->Position;
     
    167170      if(total <= r && r < total + p)
    168171      {
    169         fake = static_cast<Candidate *>(candidate->Clone());
     172        fake = static_cast<Candidate*>(candidate->Clone());
    170173
    171174        // convert jet
     
    175178          if(candidate->Charge != 0)
    176179          {
    177             fake->Charge = candidate->Charge / TMath::Abs(candidate->Charge);
     180            fake->Charge = candidate->Charge/TMath::Abs(candidate->Charge);
    178181          }
    179182          else
     
    181184            rs = gRandom->Uniform();
    182185            fake->Charge = (rs < 0.5) ? -1 : 1;
     186           
    183187          }
    184188        }
  • modules/JetFakeParticle.h

    r0e7d64a re39abb4  
    2020#define JetFakeParticle_h
    2121
     22
    2223/** \class JetFakeParticle
    2324 *
     
    3839{
    3940public:
     41
    4042  JetFakeParticle();
    4143  ~JetFakeParticle();
     
    4648
    4749private:
    48 #if !defined(__CINT__) && !defined(__CLING__)
    49   typedef std::map<Int_t, DelphesFormula *> TFakeMap; //!
     50
     51  #if !defined(__CINT__) && !defined(__CLING__)
     52  typedef std::map< Int_t, DelphesFormula * > TFakeMap; //!
    5053  TFakeMap fEfficiencyMap;
    51 #endif
     54  #endif
    5255
    5356  TIterator *fItInputArray; //!
  • modules/JetFlavorAssociation.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class JetFlavorAssociation
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    36 
     37
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    5253//------------------------------------------------------------------------------
    5354
    54 class PartonClassifier : public ExRootClassifier
     55class PartonClassifier: public ExRootClassifier
    5556{
    5657public:
     58
    5759  PartonClassifier() {}
    5860  Int_t GetCategory(TObject *object);
     
    6567Int_t PartonClassifier::GetCategory(TObject *object)
    6668{
    67   // select parton in the parton list
     69 // select parton in the parton list
    6870
    6971  Candidate *parton = static_cast<Candidate *>(object);
     
    8587//------------------------------------------------------------------------------
    8688
    87 class ParticleLHEFClassifier : public ExRootClassifier
     89class ParticleLHEFClassifier: public ExRootClassifier
    8890{
    8991public:
     92
    9093  ParticleLHEFClassifier() {}
    9194  Int_t GetCategory(TObject *object);
     
    187190//------------------------------------------------------------------------------
    188191
    189 void JetFlavorAssociation::Process()
    190 {
     192void JetFlavorAssociation::Process(){
    191193
    192194  Candidate *jet;
     
    199201  if(partonArray == 0) return;
    200202
    201   if(fParticleLHEFInputArray)
     203  if(fParticleLHEFInputArray) 
    202204  {
    203205    fParticleLHEFFilter->Reset();
     
    225227  Candidate *tempParton = 0, *tempPartonHighestPt = 0;
    226228  int pdgCode, pdgCodeMax = -1;
    227 
     229 
    228230  TIter itPartonArray(partonArray);
    229231  TIter itPartonLHEFArray(partonLHEFArray);
     
    239241      if(pdgCodeMax < pdgCode) pdgCodeMax = pdgCode;
    240242    }
    241 
     243 
    242244    if(!fParticleLHEFInputArray) continue;
    243 
     245 
    244246    itPartonLHEFArray.Reset();
    245247    while((partonLHEF = static_cast<Candidate *>(itPartonLHEFArray.Next())))
    246248    {
    247       if(parton->Momentum.DeltaR(partonLHEF->Momentum) < 0.001 && parton->PID == partonLHEF->PID && partonLHEF->Charge == parton->Charge)
    248       {
    249         break;
     249      if(parton->Momentum.DeltaR(partonLHEF->Momentum) < 0.001 &&
     250         parton->PID == partonLHEF->PID &&
     251         partonLHEF->Charge == parton->Charge)
     252      {     
     253         break;
    250254      }
    251255
     
    326330    while((partonLHEF = static_cast<Candidate *>(itPartonLHEFArray.Next())))
    327331    {
    328       if(parton->Momentum.DeltaR(partonLHEF->Momentum) < 0.01 && parton->PID == partonLHEF->PID && partonLHEF->Charge == parton->Charge)
     332      if(parton->Momentum.DeltaR(partonLHEF->Momentum) < 0.01 &&
     333         parton->PID == partonLHEF->PID &&
     334         partonLHEF->Charge == parton->Charge)
    329335      {
    330336        isGoodCandidate = false;
  • modules/JetFlavorAssociation.h

    r0e7d64a re39abb4  
    2828 */
    2929
     30#include "classes/DelphesModule.h"
    3031#include "classes/DelphesClasses.h"
    31 #include "classes/DelphesModule.h"
    3232#include <map>
    3333
     
    4242{
    4343public:
     44
    4445  JetFlavorAssociation();
    4546  ~JetFlavorAssociation();
     
    5354
    5455private:
     56
    5557  Double_t fDeltaR;
    5658
  • modules/JetPileUpSubtractor.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class JetPileUpSubtractor
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    5556  fItJetInputArray(0), fItRhoInputArray(0)
    5657{
     58
    5759}
    5860
     
    6163JetPileUpSubtractor::~JetPileUpSubtractor()
    6264{
     65
    6366}
    6467
     
    8083
    8184  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
     85
    8286}
    8387
     
    101105  // loop over all input candidates
    102106  fItJetInputArray->Reset();
    103   while((candidate = static_cast<Candidate *>(fItJetInputArray->Next())))
     107  while((candidate = static_cast<Candidate*>(fItJetInputArray->Next())))
    104108  {
    105109    momentum = candidate->Momentum;
     
    112116    {
    113117      fItRhoInputArray->Reset();
    114       while((object = static_cast<Candidate *>(fItRhoInputArray->Next())))
     118      while((object = static_cast<Candidate*>(fItRhoInputArray->Next())))
    115119      {
    116120        if(eta >= object->Edges[0] && eta < object->Edges[1])
     
    128132    if(momentum.Pt() <= fJetPTMin) continue;
    129133
    130     candidate = static_cast<Candidate *>(candidate->Clone());
     134    candidate = static_cast<Candidate*>(candidate->Clone());
    131135    candidate->Momentum = momentum;
    132136
  • modules/JetPileUpSubtractor.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  JetPileUpSubtractor();
    4041  ~JetPileUpSubtractor();
     
    4546
    4647private:
     48
    4749  Double_t fJetPTMin;
    4850
  • modules/LeptonDressing.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class LeptonDressing
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    45 #include <algorithm>
     46#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    5354
    5455LeptonDressing::LeptonDressing() :
    55   fItDressingInputArray(0), fItCandidateInputArray(0)
     56 fItDressingInputArray(0), fItCandidateInputArray(0)
    5657{
    5758}
     
    7374  fDressingInputArray = ImportArray(GetString("DressingInputArray", "Calorimeter/photons"));
    7475  fItDressingInputArray = fDressingInputArray->MakeIterator();
    75 
     76 
    7677  fCandidateInputArray = ImportArray(GetString("CandidateInputArray", "UniqueObjectFinder/electrons"));
    7778  fItCandidateInputArray = fCandidateInputArray->MakeIterator();
    78 
     79 
    7980  // create output array
    8081
     
    9697  Candidate *candidate, *dressing, *mother;
    9798  TLorentzVector momentum;
    98 
     99 
    99100  // loop over all input candidate
    100101  fItCandidateInputArray->Reset();
    101   while((candidate = static_cast<Candidate *>(fItCandidateInputArray->Next())))
     102  while((candidate = static_cast<Candidate*>(fItCandidateInputArray->Next())))
    102103  {
    103104    const TLorentzVector &candidateMomentum = candidate->Momentum;
     
    106107    fItDressingInputArray->Reset();
    107108    momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
    108     while((dressing = static_cast<Candidate *>(fItDressingInputArray->Next())))
     109    while((dressing = static_cast<Candidate*>(fItDressingInputArray->Next())))
    109110    {
    110111      const TLorentzVector &dressingMomentum = dressing->Momentum;
    111       if(dressingMomentum.Pt() > 0.1)
     112      if (dressingMomentum.Pt() > 0.1)
    112113      {
    113114        if(candidateMomentum.DeltaR(dressingMomentum) <= fDeltaR)
     
    119120
    120121    mother = candidate;
    121     candidate = static_cast<Candidate *>(candidate->Clone());
     122    candidate = static_cast<Candidate*>(candidate->Clone());
    122123
    123124    candidate->Momentum += momentum;
    124125    candidate->AddCandidate(mother);
    125 
     126   
    126127    fOutputArray->Add(candidate);
    127128  }
  • modules/LeptonDressing.h

    r0e7d64a re39abb4  
    3434{
    3535public:
     36
    3637  LeptonDressing();
    3738  ~LeptonDressing();
    38 
     39 
    3940  void Init();
    4041  void Process();
     
    4243
    4344private:
     45
    4446  Double_t fDeltaR;
    45 
     47 
    4648  TIterator *fItDressingInputArray; //!
    47 
     49 
    4850  TIterator *fItCandidateInputArray; //!
    4951
    5052  const TObjArray *fDressingInputArray; //!
    51 
     53 
    5254  const TObjArray *fCandidateInputArray; //!
    5355
  • modules/Merger.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class Merger
    2021 *
     
    3233#include "classes/DelphesFormula.h"
    3334
     35#include "ExRootAnalysis/ExRootResult.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
    3437#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    3738
     39#include "TMath.h"
     40#include "TString.h"
     41#include "TFormula.h"
     42#include "TRandom3.h"
     43#include "TObjArray.h"
    3844#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4045#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TRandom3.h"
    44 #include "TString.h"
    4546
    46 #include <algorithm>
     47#include <algorithm>
     48#include <stdexcept>
    4749#include <iostream>
    4850#include <sstream>
    49 #include <stdexcept>
    5051
    5152using namespace std;
     
    8889
    8990  fMomentumOutputArray = ExportArray(GetString("MomentumOutputArray", "momentum"));
    90 
     91 
    9192  fEnergyOutputArray = ExportArray(GetString("EnergyOutputArray", "energy"));
    9293}
     
    9697void Merger::Finish()
    9798{
    98   vector<TIterator *>::iterator itInputList;
     99  vector< TIterator * >::iterator itInputList;
    99100  TIterator *iterator;
    100101
     
    112113  Candidate *candidate;
    113114  TLorentzVector momentum;
    114   Double_t sumPT, sumE;
    115   vector<TIterator *>::iterator itInputList;
     115  Double_t sumPT, sumE; 
     116  vector< TIterator * >::iterator itInputList;
    116117  TIterator *iterator;
    117118
    118119  DelphesFactory *factory = GetFactory();
    119 
     120 
    120121  momentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
    121122  sumPT = 0;
     
    129130    // loop over all candidates
    130131    iterator->Reset();
    131     while((candidate = static_cast<Candidate *>(iterator->Next())))
     132    while((candidate = static_cast<Candidate*>(iterator->Next())))
    132133    {
    133134      const TLorentzVector &candidateMomentum = candidate->Momentum;
     
    142143
    143144  candidate = factory->NewCandidate();
    144 
     145 
    145146  candidate->Position.SetXYZT(0.0, 0.0, 0.0, 0.0);
    146147  candidate->Momentum = momentum;
    147 
     148 
    148149  fMomentumOutputArray->Add(candidate);
    149150
    150151  candidate = factory->NewCandidate();
    151 
     152 
    152153  candidate->Position.SetXYZT(0.0, 0.0, 0.0, 0.0);
    153154  candidate->Momentum.SetPtEtaPhiE(sumPT, 0.0, 0.0, sumE);
    154 
     155 
    155156  fEnergyOutputArray->Add(candidate);
    156157}
  • modules/Merger.h

    r0e7d64a re39abb4  
    3939{
    4040public:
     41
    4142  Merger();
    4243  ~Merger();
     
    4748
    4849private:
    49   std::vector<TIterator *> fInputList; //!
     50
     51  std::vector< TIterator * > fInputList; //!
    5052
    5153  TObjArray *fOutputArray; //!
  • modules/MomentumSmearing.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class MomentumSmearing
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    45 #include <algorithm>
     46#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    9899
    99100  fItInputArray->Reset();
    100   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     101  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    101102  {
    102103    const TLorentzVector &candidatePosition = candidate->Position;
     
    107108    e = candidateMomentum.E();
    108109    res = fFormula->Eval(pt, eta, phi, e);
    109 
     110 
    110111    // apply smearing formula
    111112    //pt = gRandom->Gaus(pt, fFormula->Eval(pt, eta, phi, e) * pt);
     113   
     114    res = ( res > 1.0 ) ? 1.0 : res;
    112115
    113     res = (res > 1.0) ? 1.0 : res;
    114 
    115     pt = LogNormal(pt, res * pt);
    116 
     116    pt = LogNormal(pt, res * pt );
     117   
    117118    //if(pt <= 0.0) continue;
    118119
    119120    mother = candidate;
    120     candidate = static_cast<Candidate *>(candidate->Clone());
     121    candidate = static_cast<Candidate*>(candidate->Clone());
    121122    eta = candidateMomentum.Eta();
    122123    phi = candidateMomentum.Phi();
    123     candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt * TMath::CosH(eta));
     124    candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt*TMath::CosH(eta));
    124125    //candidate->TrackResolution = fFormula->Eval(pt, eta, phi, e);
    125126    candidate->TrackResolution = res;
    126127    candidate->AddCandidate(mother);
    127 
     128       
    128129    fOutputArray->Add(candidate);
    129130  }
     
    137138  if(mean > 0.0)
    138139  {
    139     b = TMath::Sqrt(TMath::Log((1.0 + (sigma * sigma) / (mean * mean))));
    140     a = TMath::Log(mean) - 0.5 * b * b;
     140    b = TMath::Sqrt(TMath::Log((1.0 + (sigma*sigma)/(mean*mean))));
     141    a = TMath::Log(mean) - 0.5*b*b;
    141142
    142     return TMath::Exp(a + b * gRandom->Gaus(0.0, 1.0));
     143    return TMath::Exp(a + b*gRandom->Gaus(0.0, 1.0));
    143144  }
    144145  else
     
    148149}
    149150
     151
    150152//------------------------------------------------------------------------------
  • modules/MomentumSmearing.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  MomentumSmearing();
    4041  ~MomentumSmearing();
     
    4546
    4647private:
     48
    4749  Double_t LogNormal(Double_t mean, Double_t sigma);
    4850
     
    5254
    5355  const TObjArray *fInputArray; //!
    54 
     56 
    5557  TObjArray *fOutputArray; //!
    5658
  • modules/OldCalorimeter.cc

    r0e7d64a re39abb4  
    1919#include "classes/DelphesFormula.h"
    2020
     21#include "ExRootAnalysis/ExRootResult.h"
     22#include "ExRootAnalysis/ExRootFilter.h"
    2123#include "ExRootAnalysis/ExRootClassifier.h"
    22 #include "ExRootAnalysis/ExRootFilter.h"
    23 #include "ExRootAnalysis/ExRootResult.h"
    24 
     24
     25#include "TMath.h"
     26#include "TString.h"
     27#include "TFormula.h"
     28#include "TRandom3.h"
     29#include "TObjArray.h"
    2530#include "TDatabasePDG.h"
    26 #include "TFormula.h"
    2731#include "TLorentzVector.h"
    28 #include "TMath.h"
    29 #include "TObjArray.h"
    30 #include "TRandom3.h"
    31 #include "TString.h"
    3232
    3333#include <algorithm>
     34#include <stdexcept>
    3435#include <iostream>
    3536#include <sstream>
    36 #include <stdexcept>
    3737
    3838using namespace std;
     
    8282  if(fItTowerECalTrackArray) delete fItTowerECalTrackArray;
    8383  if(fTowerHCalTrackArray) delete fTowerHCalTrackArray;
    84   if(fItTowerHCalTrackArray) delete fItTowerHCalTrackArray;
    85 }
     84  if(fItTowerHCalTrackArray) delete fItTowerHCalTrackArray;}
    8685
    8786//------------------------------------------------------------------------------
     
    9392  Double_t ecalFraction, hcalFraction;
    9493  TBinMap::iterator itEtaBin;
    95   set<Double_t>::iterator itPhiBin;
    96   vector<Double_t> *phiBins;
     94  set< Double_t >::iterator itPhiBin;
     95  vector< Double_t > *phiBins;
    9796
    9897  // read eta and phi bins
     
    102101  fEtaBins.clear();
    103102  fPhiBins.clear();
    104   for(i = 0; i < size / 2; ++i)
    105   {
    106     paramEtaBins = param[i * 2];
     103  for(i = 0; i < size/2; ++i)
     104  {
     105    paramEtaBins = param[i*2];
    107106    sizeEtaBins = paramEtaBins.GetSize();
    108     paramPhiBins = param[i * 2 + 1];
     107    paramPhiBins = param[i*2 + 1];
    109108    sizePhiBins = paramPhiBins.GetSize();
    110109
     
    123122  {
    124123    fEtaBins.push_back(itEtaBin->first);
    125     phiBins = new vector<double>(itEtaBin->second.size());
     124    phiBins = new vector< double >(itEtaBin->second.size());
    126125    fPhiBins.push_back(phiBins);
    127126    phiBins->clear();
     
    140139  fFractionMap[0] = make_pair(0.0, 1.0);
    141140
    142   for(i = 0; i < size / 2; ++i)
    143   {
    144     paramFractions = param[i * 2 + 1];
     141  for(i = 0; i < size/2; ++i)
     142  {
     143    paramFractions = param[i*2 + 1];
    145144    sizeFractions = paramFractions.GetSize();
    146145
     
    148147    hcalFraction = paramFractions[1].GetDouble();
    149148
    150     fFractionMap[param[i * 2].GetInt()] = make_pair(ecalFraction, hcalFraction);
    151   }
    152   /*
     149    fFractionMap[param[i*2].GetInt()] = make_pair(ecalFraction, hcalFraction);
     150  }
     151/*
    153152  TFractionMap::iterator itFractionMap;
    154153  for(itFractionMap = fFractionMap.begin(); itFractionMap != fFractionMap.end(); ++itFractionMap)
     
    180179void OldCalorimeter::Finish()
    181180{
    182   vector<vector<Double_t> *>::iterator itPhiBin;
     181  vector< vector< Double_t>* >::iterator itPhiBin;
    183182  if(fItParticleInputArray) delete fItParticleInputArray;
    184183  if(fItTrackInputArray) delete fItTrackInputArray;
     
    204203  TFractionMap::iterator itFractionMap;
    205204
    206   vector<Double_t>::iterator itEtaBin;
    207   vector<Double_t>::iterator itPhiBin;
    208   vector<Double_t> *phiBins;
    209 
    210   vector<Long64_t>::iterator itTowerHits;
     205  vector< Double_t >::iterator itEtaBin;
     206  vector< Double_t >::iterator itPhiBin;
     207  vector< Double_t > *phiBins;
     208
     209  vector< Long64_t >::iterator itTowerHits;
    211210
    212211  DelphesFactory *factory = GetFactory();
     
    218217  fItParticleInputArray->Reset();
    219218  number = -1;
    220   while((particle = static_cast<Candidate *>(fItParticleInputArray->Next())))
     219  while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
    221220  {
    222221    const TLorentzVector &particlePosition = particle->Position;
     
    266265  fItTrackInputArray->Reset();
    267266  number = -1;
    268   while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
     267  while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
    269268  {
    270269    const TLorentzVector &trackPosition = track->Position;
     
    316315    towerHit = (*itTowerHits);
    317316    flags = (towerHit >> 24) & 0x00000000000000FFLL;
    318     number = (towerHit)&0x0000000000FFFFFFLL;
     317    number = (towerHit) & 0x0000000000FFFFFFLL;
    319318    hitEtaPhi = towerHit >> 32;
    320319
     
    337336
    338337      // calculate eta and phi of the tower's center
    339       fTowerEta = 0.5 * (fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
    340       fTowerPhi = 0.5 * ((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
     338      fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
     339      fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
    341340
    342341      fTowerEdges[0] = fEtaBins[etaBin - 1];
     
    369368    if(flags & 1)
    370369    {
    371       track = static_cast<Candidate *>(fTrackInputArray->At(number));
     370      track = static_cast<Candidate*>(fTrackInputArray->At(number));
    372371
    373372      ++fTowerTrackAllHits;
     
    409408    if(flags & 8) ++fTowerPhotonHits;
    410409
    411     particle = static_cast<Candidate *>(fParticleInputArray->At(number));
     410    particle = static_cast<Candidate*>(fParticleInputArray->At(number));
    412411    momentum = particle->Momentum;
    413412
     
    437436  if(!fTower) return;
    438437
    439   //  ecalEnergy = gRandom->Gaus(fTowerECalEnergy, fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy));
    440   //  if(ecalEnergy < 0.0) ecalEnergy = 0.0;
     438//  ecalEnergy = gRandom->Gaus(fTowerECalEnergy, fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy));
     439//  if(ecalEnergy < 0.0) ecalEnergy = 0.0;
    441440
    442441  ecalEnergy = LogNormal(fTowerECalEnergy, fECalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerECalEnergy));
    443442
    444   //  hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
    445   //  if(hcalEnergy < 0.0) hcalEnergy = 0.0;
     443//  hcalEnergy = gRandom->Gaus(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
     444//  if(hcalEnergy < 0.0) hcalEnergy = 0.0;
    446445
    447446  hcalEnergy = LogNormal(fTowerHCalEnergy, fHCalResolutionFormula->Eval(0.0, fTowerEta, 0.0, fTowerHCalEnergy));
     
    449448  energy = ecalEnergy + hcalEnergy;
    450449
    451   //  eta = fTowerEta;
    452   //  phi = fTowerPhi;
     450//  eta = fTowerEta;
     451//  phi = fTowerPhi;
    453452
    454453  eta = gRandom->Uniform(fTowerEdges[0], fTowerEdges[1]);
     
    482481  {
    483482    fItTowerTrackArray->Reset();
    484     while((track = static_cast<Candidate *>(fItTowerTrackArray->Next())))
     483    while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
    485484    {
    486485      fEFlowTrackOutputArray->Add(track);
    487486    }
    488487  }
    489   else if(fTowerTrackAllHits > 0 && fTowerECalHits + fTowerHCalHits == fTowerAllHits)
    490   {
    491     if(fTowerECalHits == fTowerECalTrackHits && fTowerHCalHits == fTowerHCalTrackHits)
     488  else if(fTowerTrackAllHits > 0 &&
     489          fTowerECalHits + fTowerHCalHits == fTowerAllHits)
     490  {
     491    if(fTowerECalHits == fTowerECalTrackHits &&
     492       fTowerHCalHits == fTowerHCalTrackHits)
    492493    {
    493494      itTowerTrackArray = fItTowerTrackArray;
     
    505506
    506507        fItTowerHCalArray->Reset();
    507         while((particle = static_cast<Candidate *>(fItTowerHCalArray->Next())))
     508        while((particle = static_cast<Candidate*>(fItTowerHCalArray->Next())))
    508509        {
    509510          tower->AddCandidate(particle);
     
    537538
    538539        fItTowerECalArray->Reset();
    539         while((particle = static_cast<Candidate *>(fItTowerECalArray->Next())))
     540        while((particle = static_cast<Candidate*>(fItTowerECalArray->Next())))
    540541        {
    541542          tower->AddCandidate(particle);
     
    566567    {
    567568      itTowerTrackArray->Reset();
    568       while((track = static_cast<Candidate *>(itTowerTrackArray->Next())))
     569      while((track = static_cast<Candidate*>(itTowerTrackArray->Next())))
    569570      {
    570571        fEFlowTrackOutputArray->Add(track);
     
    586587  if(mean > 0.0)
    587588  {
    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));
     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));
    592593  }
    593594  else
  • modules/OldCalorimeter.h

    r0e7d64a re39abb4  
    2828{
    2929public:
     30
    3031  OldCalorimeter();
    3132  ~OldCalorimeter();
     
    3637
    3738private:
    38   typedef std::map<Long64_t, std::pair<Double_t, Double_t> > TFractionMap; //!
    39   typedef std::map<Double_t, std::set<Double_t> > TBinMap; //!
     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; //!
    4042
    4143  Candidate *fTower;
     
    4951  TBinMap fBinMap; //!
    5052
    51   std::vector<Double_t> fEtaBins;
    52   std::vector<std::vector<Double_t> *> fPhiBins;
     53  std::vector < Double_t > fEtaBins;
     54  std::vector < std::vector < Double_t >* > fPhiBins;
    5355
    54   std::vector<Long64_t> fTowerHits;
     56  std::vector < Long64_t > fTowerHits;
    5557
    56   std::vector<Double_t> fECalFractions;
    57   std::vector<Double_t> fHCalFractions;
     58  std::vector < Double_t > fECalFractions;
     59  std::vector < Double_t > fHCalFractions;
    5860
    5961  DelphesFormula *fECalResolutionFormula; //!
  • modules/ParticlePropagator.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class ParticlePropagator
    2021 *
     
    3435#include "classes/DelphesFormula.h"
    3536
     37#include "ExRootAnalysis/ExRootResult.h"
     38#include "ExRootAnalysis/ExRootFilter.h"
    3639#include "ExRootAnalysis/ExRootClassifier.h"
    37 #include "ExRootAnalysis/ExRootFilter.h"
    38 #include "ExRootAnalysis/ExRootResult.h"
    39 
     40
     41#include "TMath.h"
     42#include "TString.h"
     43#include "TFormula.h"
     44#include "TRandom3.h"
     45#include "TObjArray.h"
    4046#include "TDatabasePDG.h"
    41 #include "TFormula.h"
    4247#include "TLorentzVector.h"
    43 #include "TMath.h"
    44 #include "TObjArray.h"
    45 #include "TRandom3.h"
    46 #include "TString.h"
    4748
    4849#include <algorithm>
     50#include <stdexcept>
    4951#include <iostream>
    5052#include <sstream>
    51 #include <stdexcept>
    5253
    5354using namespace std;
     
    6667}
    6768
     69
    6870//------------------------------------------------------------------------------
    6971
     
    7173{
    7274  fRadius = GetDouble("Radius", 1.0);
    73   fRadius2 = fRadius * fRadius;
     75  fRadius2 = fRadius*fRadius;
    7476  fHalfLength = GetDouble("HalfLength", 3.0);
    7577  fBz = GetDouble("Bz", 0.0);
     
    138140  const Double_t c_light = 2.99792458E8;
    139141
    140   if(!fBeamSpotInputArray || fBeamSpotInputArray->GetSize() == 0)
     142  if (!fBeamSpotInputArray || fBeamSpotInputArray->GetSize () == 0)
    141143    beamSpotPosition.SetXYZT(0.0, 0.0, 0.0, 0.0);
    142144  else
    143145  {
    144     Candidate &beamSpotCandidate = *((Candidate *)fBeamSpotInputArray->At(0));
     146    Candidate &beamSpotCandidate = *((Candidate *) fBeamSpotInputArray->At(0));
    145147    beamSpotPosition = beamSpotCandidate.Position;
    146148  }
    147149
    148150  fItInputArray->Reset();
    149   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     151  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    150152  {
    151153    if(candidate->GetCandidates()->GetEntriesFast() == 0)
     
    155157    else
    156158    {
    157       particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     159      particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
    158160    }
    159161
    160162    particlePosition = particle->Position;
    161163    particleMomentum = particle->Momentum;
    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;
     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;
    169171
    170172    q = particle->Charge;
     
    191193    {
    192194      mother = candidate;
    193       candidate = static_cast<Candidate *>(candidate->Clone());
     195      candidate = static_cast<Candidate*>(candidate->Clone());
    194196
    195197      candidate->InitialPosition = particlePosition;
     
    205207    {
    206208      // solve pt2*t^2 + 2*(px*x + py*y)*t - (fRadius2 - x*x - y*y) = 0
    207       tmp = px * y - py * x;
    208       discr2 = pt2 * fRadius2 - tmp * tmp;
     209      tmp = px*y - py*x;
     210      discr2 = pt2*fRadius2 - tmp*tmp;
    209211
    210212      if(discr2 < 0.0)
     
    214216      }
    215217
    216       tmp = px * x + py * y;
     218      tmp = px*x + py*y;
    217219      discr = TMath::Sqrt(discr2);
    218       t1 = (-tmp + discr) / pt2;
    219       t2 = (-tmp - discr) / pt2;
     220      t1 = (-tmp + discr)/pt2;
     221      t2 = (-tmp - discr)/pt2;
    220222      t = (t1 < 0.0) ? t2 : t1;
    221223
    222       z_t = z + pz * t;
     224      z_t = z + pz*t;
    223225      if(TMath::Abs(z_t) > fHalfLength)
    224226      {
     
    228230      }
    229231
    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));
     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));
    235237
    236238      mother = candidate;
    237       candidate = static_cast<Candidate *>(candidate->Clone());
     239      candidate = static_cast<Candidate*>(candidate->Clone());
    238240
    239241      candidate->InitialPosition = particlePosition;
    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;
     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;
    242244
    243245      candidate->Momentum = particleMomentum;
     
    249251        switch(TMath::Abs(candidate->PID))
    250252        {
    251         case 11:
    252           fElectronOutputArray->Add(candidate);
    253           break;
    254         case 13:
    255           fMuonOutputArray->Add(candidate);
    256           break;
    257         default:
    258           fChargedHadronOutputArray->Add(candidate);
     253          case 11:
     254            fElectronOutputArray->Add(candidate);
     255            break;
     256          case 13:
     257            fMuonOutputArray->Add(candidate);
     258            break;
     259          default:
     260            fChargedHadronOutputArray->Add(candidate);
    259261        }
    260262      }
    261263      else
    262264      {
    263         fNeutralOutputArray->Add(candidate);
     265         fNeutralOutputArray->Add(candidate);
    264266      }
    265267    }
     
    273275      //     helix radius r = p_{T0} / (omega gamma m)
    274276
    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]
     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]
    278280
    279281      phi_0 = TMath::ATan2(py, px); // [rad] in [-pi, pi]
    280282
    281283      // 2. helix axis coordinates
    282       x_c = x + r * TMath::Sin(phi_0);
    283       y_c = y - r * TMath::Cos(phi_0);
     284      x_c = x + r*TMath::Sin(phi_0);
     285      y_c = y - r*TMath::Cos(phi_0);
    284286      r_c = TMath::Hypot(x_c, y_c);
    285287      phi_c = TMath::ATan2(y_c, x_c);
     
    288290
    289291      rcu = TMath::Abs(r);
    290       rc2 = r_c * r_c;
     292      rc2 = r_c*r_c;
    291293
    292294      // calculate coordinates of closest approach to track circle in transverse plane xd, yd, zd
    293       xd = x_c * x_c * x_c - x_c * rcu * r_c + x_c * y_c * y_c;
     295      xd = x_c*x_c*x_c - x_c*rcu*r_c + x_c*y_c*y_c;
    294296      xd = (rc2 > 0.0) ? xd / rc2 : -999;
    295       yd = y_c * (-rcu * r_c + rc2);
     297      yd = y_c*(-rcu*r_c + rc2);
    296298      yd = (rc2 > 0.0) ? yd / rc2 : -999;
    297       zd = z + (TMath::Sqrt(xd * xd + yd * yd) - TMath::Sqrt(x * x + y * y)) * pz / pt;
     299      zd = z + (TMath::Sqrt(xd*xd + yd*yd) - TMath::Sqrt(x*x + y*y))*pz/pt;
    298300
    299301      // use perigee momentum rather than original particle
     
    309311      // calculate additional track parameters (correct for beamspot position)
    310312
    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());
     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
    315318
    316319      // 3. time evaluation t = TMath::Min(t_r, t_z)
     
    319322      t_r = 0.0; // in [ns]
    320323      int sign_pz = (pz > 0.0) ? 1 : -1;
    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)
     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)
    327328      {
    328329        // helix does not cross the cylinder sides
     
    331332      else
    332333      {
    333         asinrho = TMath::ASin((fRadius * fRadius - r_c * r_c - r * r) / (2 * TMath::Abs(r) * r_c));
     334        asinrho = TMath::ASin((fRadius*fRadius - r_c*r_c - r*r) / (2*TMath::Abs(r)*r_c));
    334335        delta = phi_0 - phi;
    335         if(delta < -TMath::Pi()) delta += 2 * TMath::Pi();
    336         if(delta > TMath::Pi()) delta -= 2 * TMath::Pi();
     336        if(delta <-TMath::Pi()) delta += 2*TMath::Pi();
     337        if(delta > TMath::Pi()) delta -= 2*TMath::Pi();
    337338        t1 = (delta + asinrho) / omega;
    338339        t2 = (delta + TMath::Pi() - asinrho) / omega;
     
    358359      x_t = x_c + r * TMath::Sin(omega * t - phi_0);
    359360      y_t = y_c + r * TMath::Cos(omega * t - phi_0);
    360       z_t = z + pz * 1.0E9 / c_light / gammam * t;
     361      z_t = z + pz*1.0E9 / c_light / gammam * t;
    361362      r_t = TMath::Hypot(x_t, y_t);
    362363
     364
    363365      // compute path length for an helix
    364366
    365       alpha = pz * 1.0E9 / c_light / gammam;
    366       l = t * TMath::Sqrt(alpha * alpha + r * r * omega * omega);
     367      alpha = pz*1.0E9 / c_light / gammam;
     368      l = t * TMath::Sqrt(alpha*alpha + r*r*omega*omega);
    367369
    368370      if(r_t > 0.0)
     
    372374        if(particle == candidate)
    373375        {
    374           particle->D0 = d0 * 1.0E3;
    375           particle->DZ = dz * 1.0E3;
     376          particle->D0 = d0*1.0E3;
     377          particle->DZ = dz*1.0E3;
    376378          particle->P = p;
    377379          particle->PT = pt;
     
    381383
    382384        mother = candidate;
    383         candidate = static_cast<Candidate *>(candidate->Clone());
     385        candidate = static_cast<Candidate*>(candidate->Clone());
    384386
    385387        candidate->InitialPosition = particlePosition;
    386         candidate->Position.SetXYZT(x_t * 1.0E3, y_t * 1.0E3, z_t * 1.0E3, particlePosition.T() + t * c_light * 1.0E3);
     388        candidate->Position.SetXYZT(x_t*1.0E3, y_t*1.0E3, z_t*1.0E3, particlePosition.T() + t*c_light*1.0E3);
    387389
    388390        candidate->Momentum = particleMomentum;
    389391
    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;
     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;
    395397
    396398        candidate->AddCandidate(mother);
     
    399401        switch(TMath::Abs(candidate->PID))
    400402        {
    401         case 11:
    402           fElectronOutputArray->Add(candidate);
    403           break;
    404         case 13:
    405           fMuonOutputArray->Add(candidate);
    406           break;
    407         default:
    408           fChargedHadronOutputArray->Add(candidate);
     403          case 11:
     404            fElectronOutputArray->Add(candidate);
     405            break;
     406          case 13:
     407            fMuonOutputArray->Add(candidate);
     408            break;
     409          default:
     410            fChargedHadronOutputArray->Add(candidate);
    409411        }
    410412      }
     
    414416
    415417//------------------------------------------------------------------------------
     418
  • modules/ParticlePropagator.h

    r0e7d64a re39abb4  
    4040{
    4141public:
     42
    4243  ParticlePropagator();
    4344  ~ParticlePropagator();
     
    4849
    4950private:
     51
    5052  Double_t fRadius, fRadius2, fRadiusMax, fHalfLength, fHalfLengthMax;
    5153  Double_t fBz;
  • modules/PdgCodeFilter.cc

    r0e7d64a re39abb4  
    3131#include "classes/DelphesFormula.h"
    3232
     33#include "ExRootAnalysis/ExRootResult.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3335#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3636
     37#include "TMath.h"
     38#include "TString.h"
     39#include "TFormula.h"
     40#include "TRandom3.h"
     41#include "TObjArray.h"
    3742#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3943#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4444
    4545#include <algorithm>
     46#include <stdexcept>
    4647#include <iostream>
    4748#include <sstream>
    48 #include <stdexcept>
    4949
    5050using namespace std;
     
    7575
    7676  fInvert = GetBool("Invert", false);
    77 
    78   // no pileup
    79   fRequireNotPileup = GetBool("RequireNotPileup", false);
    8077
    8178  fRequireStatus = GetBool("RequireStatus", false);
     
    121118
    122119  fItInputArray->Reset();
    123   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     120  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    124121  {
    125122    pdgCode = candidate->PID;
     
    130127    if(fRequireStatus && (candidate->Status != fStatus)) continue;
    131128    if(fRequireCharge && (candidate->Charge != fCharge)) continue;
    132     if(fRequireNotPileup && (candidate->IsPU > 0)) continue;
    133129
    134130    pass = kTRUE;
     
    139135  }
    140136}
     137
  • modules/PdgCodeFilter.h

    r0e7d64a re39abb4  
    3939{
    4040public:
     41
    4142  PdgCodeFilter();
    4243  ~PdgCodeFilter();
     
    4748
    4849private:
     50
    4951  Double_t fPTMin; //!
    5052  Bool_t fInvert; //!
     
    5355  Bool_t fRequireCharge; //!
    5456  Int_t fCharge; //!
    55   Bool_t fRequireNotPileup; //!
     57
    5658
    5759  std::vector<Int_t> fPdgCodes;
  • modules/PhotonConversions.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class PhotonConversions
    2021 *
     
    2930
    3031#include "classes/DelphesClasses.h"
     32#include "classes/DelphesFactory.h"
    3133#include "classes/DelphesCylindricalFormula.h"
    32 #include "classes/DelphesFactory.h"
    33 
     34
     35#include "ExRootAnalysis/ExRootResult.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
    3437#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    37 
     38
     39#include "TMath.h"
     40#include "TF1.h"
     41#include "TString.h"
     42#include "TFormula.h"
     43#include "TRandom3.h"
     44#include "TObjArray.h"
    3845#include "TDatabasePDG.h"
    39 #include "TF1.h"
    40 #include "TFormula.h"
    4146#include "TLorentzVector.h"
    42 #include "TMath.h"
    43 #include "TObjArray.h"
    44 #include "TRandom3.h"
    45 #include "TString.h"
    4647#include "TVector3.h"
    4748
    4849#include <algorithm>
     50#include <stdexcept>
    4951#include <iostream>
    5052#include <sstream>
    51 #include <stdexcept>
    5253
    5354using namespace std;
     
    5859  fItInputArray(0), fConversionMap(0), fDecayXsec(0)
    5960{
    60   fDecayXsec = new TF1("decayXsec", "1.0 - 4.0/3.0 * x * (1.0 - x)", 0.0, 1.0);
     61  fDecayXsec = new TF1("decayXsec","1.0 - 4.0/3.0 * x * (1.0 - x)", 0.0, 1.0);
    6162  fConversionMap = new DelphesCylindricalFormula;
    6263}
     
    7374{
    7475  fRadius = GetDouble("Radius", 1.0);
    75   fRadius2 = fRadius * fRadius;
     76  fRadius2 = fRadius*fRadius;
    7677
    7778  fHalfLength = GetDouble("HalfLength", 3.0);
     
    121122
    122123  fItInputArray->Reset();
    123   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     124  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    124125  {
    125126
     
    132133      candidatePosition = candidate->Position;
    133134      candidateMomentum = candidate->Momentum;
    134       x = candidatePosition.X() * 1.0E-3;
    135       y = candidatePosition.Y() * 1.0E-3;
    136       z = candidatePosition.Z() * 1.0E-3;
     135      x = candidatePosition.X()*1.0E-3;
     136      y = candidatePosition.Y()*1.0E-3;
     137      z = candidatePosition.Z()*1.0E-3;
    137138
    138139      // check that particle position is inside the cylinder
     
    151152
    152153      // solve pt2*t^2 + 2*(px*x + py*y)*t - (fRadius2 - x*x - y*y) = 0
    153       tmp = px * y - py * x;
    154       discr2 = pt2 * fRadius2 - tmp * tmp;
     154      tmp = px*y - py*x;
     155      discr2 = pt2*fRadius2 - tmp*tmp;
    155156
    156157      if(discr2 < 0.0)
     
    160161      }
    161162
    162       tmp = px * x + py * y;
     163      tmp = px*x + py*y;
    163164      discr = TMath::Sqrt(discr2);
    164       t1 = (-tmp + discr) / pt2;
    165       t2 = (-tmp - discr) / pt2;
     165      t1 = (-tmp + discr)/pt2;
     166      t2 = (-tmp - discr)/pt2;
    166167      t = (t1 < 0.0) ? t2 : t1;
    167168
    168       z_t = z + pz * t;
     169      z_t = z + pz*t;
    169170      if(TMath::Abs(z_t) > fHalfLength)
    170171      {
     
    175176
    176177      // final position
    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);
     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
    182184
    183185      // here starts conversion code
    184       nsteps = Int_t(r_t / fStep);
     186      nsteps = Int_t(r_t/fStep);
    185187
    186188      x_i = x;
     
    188190      z_i = z;
    189191
    190       dt = t / nsteps;
     192      dt = t/nsteps;
    191193
    192194      converted = false;
     
    194196      for(i = 0; i < nsteps; ++i)
    195197      {
    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);
     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);
    200202
    201203        // convert photon position into cylindrical coordinates, cylindrical r,phi,z !!
    202204
    203         r_i = TMath::Sqrt(x_i * x_i + y_i * y_i);
     205        r_i = TMath::Sqrt(x_i*x_i + y_i*y_i);
    204206        phi_i = pos_i.Phi();
    205207
     
    208210
    209211        // convert into conversion probability
    210         p_conv = 1 - TMath::Exp(-7.0 / 9.0 * fStep * rate);
     212        p_conv = 1 - TMath::Exp(-7.0/9.0*fStep*rate);
    211213
    212214        // case conversion occurs
     
    219221          x2 = 1 - x1;
    220222
    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);
     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);
    229231
    230232          ep->PID = -11;
     
    249251
    250252//------------------------------------------------------------------------------
     253
  • modules/PhotonConversions.h

    r0e7d64a re39abb4  
    3838{
    3939public:
     40
    4041  PhotonConversions();
    4142  ~PhotonConversions();
     
    4647
    4748private:
     49
    4850  Double_t fRadius, fRadius2, fHalfLength;
    4951  Double_t fEtaMin, fEtaMax;
  • modules/PhotonID.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class PhotonID
    2021 *
     
    3334#include "classes/DelphesFormula.h"
    3435
     36#include "ExRootAnalysis/ExRootResult.h"
     37#include "ExRootAnalysis/ExRootFilter.h"
    3538#include "ExRootAnalysis/ExRootClassifier.h"
    36 #include "ExRootAnalysis/ExRootFilter.h"
    37 #include "ExRootAnalysis/ExRootResult.h"
    38 
     39
     40#include "TMath.h"
     41#include "TString.h"
     42#include "TFormula.h"
     43#include "TRandom3.h"
     44#include "TObjArray.h"
    3945#include "TDatabasePDG.h"
    40 #include "TFormula.h"
    4146#include "TLorentzVector.h"
    42 #include "TMath.h"
    43 #include "TObjArray.h"
    44 #include "TRandom3.h"
    45 #include "TString.h"
    46 
    47 #include <algorithm>
     47
     48#include <algorithm>
     49#include <stdexcept>
    4850#include <iostream>
    4951#include <sstream>
    50 #include <stdexcept>
    5152
    5253using namespace std;
     
    5556
    5657PhotonID::PhotonID() :
    57   fPromptFormula(0), fNonPromptFormula(0), fFakeFormula(0), fItInputPhotonArray(0), fItInputGenArray(0)
    58 {
    59   fPromptFormula = new DelphesFormula;
    60   fNonPromptFormula = new DelphesFormula;
    61   fFakeFormula = new DelphesFormula;
     58  fPromptFormula(0), fNonPromptFormula(0), fFakeFormula(0), fItInputPhotonArray(0),  fItInputGenArray(0)
     59{
     60 fPromptFormula = new DelphesFormula;
     61 fNonPromptFormula = new DelphesFormula;
     62 fFakeFormula = new DelphesFormula;
    6263}
    6364
     
    8081  fNonPromptFormula->Compile(GetString("NonPromptFormula", "1.0"));
    8182  fFakeFormula->Compile(GetString("FakeFormula", "1.0"));
    82 
     83 
    8384  // import input arrays
    8485  fInputPhotonArray = ImportArray(GetString("InputPhotonArray", "PhotonIsolation/photons"));
     
    110111
    111112void PhotonID::Process()
    112 {
     113{ 
    113114  Candidate *candidate, *mother;
    114115  Double_t pt, eta, phi, e;
    115116  Double_t relIso;
    116117  Bool_t isolated;
    117 
     118 
    118119  //cout<< "----  new event ---------"<<endl;
    119120
    120121  fItInputPhotonArray->Reset();
    121   while((candidate = static_cast<Candidate *>(fItInputPhotonArray->Next())))
     122  while((candidate = static_cast<Candidate*>(fItInputPhotonArray->Next())))
    122123  {
    123124
    124125    mother = candidate;
    125     candidate = static_cast<Candidate *>(candidate->Clone());
     126    candidate = static_cast<Candidate*>(candidate->Clone());
    126127    candidate->AddCandidate(mother);
    127128
     
    133134    e = candidateMomentum.E();
    134135
    135     if(pt < fPTMin) continue;
     136    if (pt < fPTMin) continue;
    136137
    137138    //cout<< "              ---- photon -----: "<<pt<<","<<eta<<","<<phi<<endl;
    138 
     139   
    139140    // find out if photon matches does not match photon in gen collection and apply fae efficiency
    140     if(isFake(candidate))
     141    if (isFake(candidate) )
    141142    {
    142143      //cout<<"                    Fake!"<<endl;
     
    156157
    157158      // if isolated apply prompt formula
    158       if(isolated)
     159      if (isolated)
    159160      {
    160161        //cout<<"                       isolated!:   "<<relIso<<endl;
     
    163164        candidate->Status = 1;
    164165        fOutputArray->Add(candidate);
     166       
    165167      }
    166 
     168     
    167169      // if non-isolated apply non-prompt formula
    168170      else
     
    180182//------------------------------------------------------------------------------
    181183
    182 Bool_t PhotonID::isFake(const Candidate *obj)
    183 {
     184Bool_t PhotonID::isFake(const Candidate *obj){
    184185
    185186  const TLorentzVector &mom_rec = obj->Momentum;
    186 
     187 
    187188  Bool_t matches = false;
    188189  fItInputGenArray->Reset();
    189190  Candidate *gen;
    190 
    191   while((gen = static_cast<Candidate *>(fItInputGenArray->Next())))
     191 
     192  while((gen = static_cast<Candidate*>(fItInputGenArray->Next())))
    192193  {
    193194    const TLorentzVector &mom_gen = gen->Momentum;
    194195    Int_t status = gen->Status;
    195196    Int_t pdgCode = TMath::Abs(gen->PID);
    196     Float_t dPtOverPt = TMath::Abs((mom_gen.Pt() - mom_rec.Pt()) / mom_rec.Pt());
     197    Float_t dPtOverPt = TMath::Abs((mom_gen.Pt() - mom_rec.Pt())/mom_rec.Pt());
    197198    Float_t deltaR = mom_gen.DeltaR(mom_rec);
    198199
    199     if(status != 1) continue;
    200     if(pdgCode != 22) continue;
    201     if(dPtOverPt > 0.5) continue;
    202     if(deltaR > 0.1) continue;
     200    if (status != 1) continue;
     201    if (pdgCode != 22) continue;
     202    if (dPtOverPt > 0.5) continue;
     203    if (deltaR > 0.1) continue;
    203204
    204205    matches = true;
    205206    break;
     207
    206208  }
    207209
  • modules/PhotonID.h

    r0e7d64a re39abb4  
    4040{
    4141public:
     42
    4243  PhotonID();
    4344  ~PhotonID();
     
    4849
    4950private:
     51
    5052  DelphesFormula *fPromptFormula;
    5153  DelphesFormula *fNonPromptFormula;
    5254  DelphesFormula *fFakeFormula;
    53 
     55 
    5456  // import input arrays
    5557  const TObjArray *fInputPhotonArray;
  • modules/PileUpJetID.cc

    r0e7d64a re39abb4  
    1414#include "classes/DelphesFormula.h"
    1515
     16#include "ExRootAnalysis/ExRootResult.h"
     17#include "ExRootAnalysis/ExRootFilter.h"
    1618#include "ExRootAnalysis/ExRootClassifier.h"
    17 #include "ExRootAnalysis/ExRootFilter.h"
    18 #include "ExRootAnalysis/ExRootResult.h"
    19 
     19
     20#include "TMath.h"
     21#include "TString.h"
    2022#include "TFormula.h"
    21 #include "TMath.h"
     23#include "TRandom3.h"
    2224#include "TObjArray.h"
    23 #include "TRandom3.h"
    24 #include "TString.h"
    2525//#include "TDatabasePDG.h"
    2626#include "TLorentzVector.h"
    2727
    2828#include <algorithm>
     29#include <stdexcept>
    2930#include <iostream>
    3031#include <sstream>
    31 #include <stdexcept>
    3232
    3333using namespace std;
     
    3636
    3737PileUpJetID::PileUpJetID() :
    38   fItJetInputArray(0), fTrackInputArray(0), fNeutralInputArray(0)
    39 {
     38  fItJetInputArray(0),fTrackInputArray(0),fNeutralInputArray(0)
     39{
     40
    4041}
    4142
     
    4445PileUpJetID::~PileUpJetID()
    4546{
     47
    4648}
    4749
     
    5557  fUseConstituents = GetInt("UseConstituents", 0);
    5658
    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);
     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);
    6264  fJetPTMinForNeutrals = GetDouble("JetPTMinForNeutrals", 20.0);
    6365  fNeutralPTMin = GetDouble("NeutralPTMin", 2.0);
     
    8082  fOutputArray = ExportArray(GetString("OutputArray", "jets"));
    8183
    82   fNeutralsInPassingJets = ExportArray(GetString("NeutralsInPassingJets", "eflowtowers"));
     84  fNeutralsInPassingJets = ExportArray(GetString("NeutralsInPassingJets","eflowtowers"));
     85
    8386}
    8487
     
    9295  if(fItTrackInputArray) delete fItTrackInputArray;
    9396  if(fItNeutralInputArray) delete fItNeutralInputArray;
     97
    9498}
    9599
     
    105109  // loop over all input candidates
    106110  fItJetInputArray->Reset();
    107   while((candidate = static_cast<Candidate *>(fItJetInputArray->Next())))
     111  while((candidate = static_cast<Candidate*>(fItJetInputArray->Next())))
    108112  {
    109113    momentum = candidate->Momentum;
     
    129133    float pt_ann[5];
    130134
    131     for(int i = 0; i < 5; i++)
    132     {
     135    for (int i = 0 ; i < 5 ; i++) {
    133136      pt_ann[i] = 0.;
    134137    }
    135138
    136     if(fUseConstituents)
    137     {
     139    if (fUseConstituents) {
    138140      TIter itConstituents(candidate->GetCandidates());
    139       while((constituent = static_cast<Candidate *>(itConstituents.Next())))
    140       {
     141      while((constituent = static_cast<Candidate*>(itConstituents.Next()))) {
    141142        float pt = constituent->Momentum.Pt();
    142143        float dr = candidate->Momentum.DeltaR(constituent->Momentum);
    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;
     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;
    179170            tow_sumW += w;
    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     {
     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 {
    208194      // Not using constituents, using dr
    209195      fItTrackInputArray->Reset();
    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         }
     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        }
    237216      }
    238217      fItNeutralInputArray->Reset();
    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     {
     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 {
    267239      candidate->Beta = -999.;
    268240      candidate->BetaStar = -999.;
    269241    }
    270     if(sumptsq > 0.)
    271     {
    272       candidate->MeanSqDeltaR = sumdrsqptsq / sumptsq;
    273     }
    274     else
    275     {
     242    if (sumptsq > 0.) {
     243      candidate->MeanSqDeltaR = sumdrsqptsq/sumptsq;
     244    } else {
    276245      candidate->MeanSqDeltaR = -999.;
    277246    }
    278247    candidate->NCharged = nc;
    279248    candidate->NNeutrals = nn;
    280     if(sumpt > 0.)
    281     {
     249    if (sumpt > 0.) {
    282250      candidate->PTD = TMath::Sqrt(sumptsq) / sumpt;
    283       for(int i = 0; i < 5; i++)
    284       {
    285         candidate->FracPt[i] = pt_ann[i] / sumpt;
    286       }
    287     }
    288     else
    289     {
     251      for (int i = 0 ; i < 5 ; i++) {
     252        candidate->FracPt[i] = pt_ann[i]/sumpt;
     253      }
     254    } else {
    290255      candidate->PTD = -999.;
    291       for(int i = 0; i < 5; i++)
    292       {
     256      for (int i = 0 ; i < 5 ; i++) {
    293257        candidate->FracPt[i] = -999.;
    294258      }
     
    307271
    308272    bool passId = false;
    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()
     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()
    326284    //   << " " << candidate->Momentum.Eta() << " " << candidate->MeanSqDeltaR << " " << candidate->Beta << " " << passId << endl;
    327285
    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     }
     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
    355307  }
    356308}
  • modules/PileUpJetID.h

    r0e7d64a re39abb4  
    1010 */
    1111
     12
    1213#include "classes/DelphesModule.h"
    1314
     
    2021{
    2122public:
     23
    2224  PileUpJetID();
    2325  ~PileUpJetID();
     
    2830
    2931private:
     32
    3033  Double_t fJetPTMin;
    3134  Double_t fParameterR;
     
    8588  // If set to false, uses everything within dR < fParameterR even if in other jets &c.
    8689  // Results should be very similar for PF
    87   Int_t fUseConstituents;
     90  Int_t fUseConstituents; 
    8891
    8992  Bool_t fAverageEachTower;
     
    9497
    9598  const TObjArray *fTrackInputArray; // SCZ
    96   const TObjArray *fNeutralInputArray;
     99  const TObjArray *fNeutralInputArray; 
    97100
    98101  TIterator *fItTrackInputArray; // SCZ
     
    102105  TObjArray *fNeutralsInPassingJets; // SCZ
    103106
     107
    104108  ClassDef(PileUpJetID, 2)
    105109};
  • modules/PileUpMerger.cc

    r0e7d64a re39abb4  
    2929#include "classes/DelphesClasses.h"
    3030#include "classes/DelphesFactory.h"
     31#include "classes/DelphesTF2.h"
    3132#include "classes/DelphesPileUpReader.h"
    32 #include "classes/DelphesTF2.h"
    33 
     33
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3436#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    37 
     37
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3843#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4044#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TRandom3.h"
    44 #include "TString.h"
    4545
    4646#include <algorithm>
     47#include <stdexcept>
    4748#include <iostream>
    4849#include <sstream>
    49 #include <stdexcept>
    5050
    5151using namespace std;
     
    5959}
    6060
     61
    6162//------------------------------------------------------------------------------
    6263
     
    7475  fPileUpDistribution = GetInt("PileUpDistribution", 0);
    7576
    76   fMeanPileUp = GetDouble("MeanPileUp", 10);
     77  fMeanPileUp  = GetDouble("MeanPileUp", 10);
    7778
    7879  fZVertexSpread = GetDouble("ZVertexSpread", 0.15);
     
    134135  dt0 = -1.0e6;
    135136
    136   dt *= c_light * 1.0E3; // necessary in order to make t in mm/c
     137  dt *= c_light*1.0E3; // necessary in order to make t in mm/c
    137138  dz *= 1.0E3; // necessary in order to make z in mm
    138139
     
    149150  vertex = factory->NewCandidate();
    150151
    151   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     152  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    152153  {
    153154    vx += candidate->Position.X();
     
    158159
    159160    // take postion and time from first stable particle
    160     if(dz0 < -999999.0)
     161    if (dz0 < -999999.0)
    161162      dz0 = z;
    162     if(dt0 < -999999.0)
     163    if (dt0 < -999999.0)
    163164      dt0 = t;
    164165
     
    171172    fParticleOutputArray->Add(candidate);
    172173
    173     if(TMath::Abs(candidate->Charge) > 1.0E-9)
     174    if(TMath::Abs(candidate->Charge) >  1.0E-9)
    174175    {
    175176      nch++;
    176       sumpt2 += pt * pt;
     177      sumpt2 += pt*pt;
    177178      vertex->AddCandidate(candidate);
    178179    }
     
    197198  switch(fPileUpDistribution)
    198199  {
    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;
     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;
    211212  }
    212213
    213214  allEntries = fReader->GetEntries();
     215
    214216
    215217  for(event = 0; event < numberOfEvents; ++event)
     
    217219    do
    218220    {
    219       entry = TMath::Nint(gRandom->Rndm() * allEntries);
    220     } while(entry >= allEntries);
     221      entry = TMath::Nint(gRandom->Rndm()*allEntries);
     222    }
     223    while(entry >= allEntries);
    221224
    222225    fReader->ReadEntry(entry);
    223226
    224     // --- Pile-up vertex smearing
     227   // --- Pile-up vertex smearing
    225228
    226229    fFunction->GetRandom2(dz, dt);
    227230
    228     dt *= c_light * 1.0E3; // necessary in order to make t in mm/c
     231    dt *= c_light*1.0E3; // necessary in order to make t in mm/c
    229232    dz *= 1.0E3; // necessary in order to make z in mm
    230233
     
    249252
    250253      pdgParticle = pdg->GetParticle(pid);
    251       candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
     254      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    252255      candidate->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
    253256
     
    268271
    269272      ++numberOfParticles;
    270       if(TMath::Abs(candidate->Charge) > 1.0E-9)
     273      if(TMath::Abs(candidate->Charge) >  1.0E-9)
    271274      {
    272275        nch++;
    273         sumpt2 += pt * pt;
     276        sumpt2 += pt*pt;
    274277        vertex->AddCandidate(candidate);
    275278      }
     
    296299
    297300    fVertexOutputArray->Add(vertex);
     301
    298302  }
    299303}
  • modules/PileUpMerger.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  PileUpMerger();
    4041  ~PileUpMerger();
     
    4546
    4647private:
     48
    4749  Int_t fPileUpDistribution;
    4850  Double_t fMeanPileUp;
  • modules/PileUpMergerPythia8.cc

    r0e7d64a re39abb4  
    2929#include "classes/DelphesClasses.h"
    3030#include "classes/DelphesFactory.h"
     31#include "classes/DelphesTF2.h"
    3132#include "classes/DelphesPileUpReader.h"
    32 #include "classes/DelphesTF2.h"
    33 
     33
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3436#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    3737
    3838#include "Pythia.h"
    3939
     40#include "TMath.h"
     41#include "TString.h"
     42#include "TFormula.h"
     43#include "TRandom3.h"
     44#include "TObjArray.h"
    4045#include "TDatabasePDG.h"
    41 #include "TFormula.h"
    4246#include "TLorentzVector.h"
    43 #include "TMath.h"
    44 #include "TObjArray.h"
    45 #include "TRandom3.h"
    46 #include "TString.h"
    4747
    4848#include <algorithm>
     49#include <stdexcept>
    4950#include <iostream>
    5051#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 
    183     // --- Pile-up vertex smearing
     180    while(!fPythia->next());
     181
     182   // --- Pile-up vertex smearing
    184183
    185184    fFunction->GetRandom2(dz, dt);
    186185
    187     dt *= c_light * 1.0E3; // necessary in order to make t in mm/c
     186    dt *= c_light*1.0E3; // necessary in order to make t in mm/c
    188187    dz *= 1.0E3; // necessary in order to make z in mm
    189188
     
    202201
    203202      pid = particle.id();
    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();
     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();
    212205
    213206      candidate = factory->NewCandidate();
     
    218211
    219212      pdgParticle = pdg->GetParticle(pid);
    220       candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
     213      candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    221214      candidate->Mass = pdgParticle ? pdgParticle->Mass() : -999.9;
    222215
  • modules/PileUpMergerPythia8.h

    r0e7d64a re39abb4  
    3535namespace Pythia8
    3636{
    37 class Pythia;
     37 class Pythia;
    3838};
    3939
     
    4141{
    4242public:
     43
    4344  PileUpMergerPythia8();
    4445  ~PileUpMergerPythia8();
     
    4950
    5051private:
     52
    5153  Int_t fPileUpDistribution;
    5254  Double_t fMeanPileUp;
  • modules/RecoPuFilter.cc

    r0e7d64a re39abb4  
    3232#include "classes/DelphesFormula.h"
    3333
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3436#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    3737
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3843#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4044#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TRandom3.h"
    44 #include "TString.h"
    4545
    4646#include <algorithm>
     47#include <stdexcept>
    4748#include <iostream>
    4849#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

    r0e7d64a re39abb4  
    4040{
    4141public:
     42
    4243  RecoPuFilter();
    4344  ~RecoPuFilter();
     
    4849
    4950private:
     51
    5052  TIterator *fItInputArray; //!
    5153
  • modules/RunPUPPI.cc

    r0e7d64a re39abb4  
    11#include "modules/RunPUPPI.h"
    22
     3#include "PUPPI/RecoObj2.hh"
    34#include "PUPPI/AlgoObj.hh"
    45#include "PUPPI/PuppiContainer.hh"
    5 #include "PUPPI/RecoObj2.hh"
    66
    77#include "fastjet/PseudoJet.hh"
     
    1111#include "classes/DelphesFormula.h"
    1212
    13 #include <algorithm>
     13#include <algorithm>
     14#include <stdexcept>
    1415#include <iostream>
    1516#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 //------------------------------------------------------------------------------
    30 RunPUPPI::~RunPUPPI() {}
    31 
    32 //------------------------------------------------------------------------------
    33 
    34 void RunPUPPI::Init()
    35 {
     26{}
     27
     28//------------------------------------------------------------------------------
     29RunPUPPI::~RunPUPPI(){}
     30
     31//------------------------------------------------------------------------------
     32
     33void RunPUPPI::Init(){
    3634  // input collection
    37   fTrackInputArray = ImportArray(GetString("TrackInputArray", "Calorimeter/towers"));
    38   fItTrackInputArray = fTrackInputArray->MakeIterator();
    39   fNeutralInputArray = ImportArray(GetString("NeutralInputArray", "Calorimeter/towers"));
     35  fTrackInputArray     = ImportArray(GetString("TrackInputArray", "Calorimeter/towers"));
     36  fItTrackInputArray   = fTrackInputArray->MakeIterator();
     37  fNeutralInputArray   = ImportArray(GetString("NeutralInputArray", "Calorimeter/towers"));
    4038  fItNeutralInputArray = fNeutralInputArray->MakeIterator();
    41   fPVInputArray = ImportArray(GetString("PVInputArray", "PV"));
    42   fPVItInputArray = fPVInputArray->MakeIterator();
    43   // puppi parameters
    44   fApplyNoLep = GetBool("UseNoLep", true);
     39  fPVInputArray        = ImportArray(GetString("PVInputArray", "PV"));
     40  fPVItInputArray      = fPVInputArray->MakeIterator();
     41  // puppi parameters                                 
     42  fApplyNoLep     = GetBool("UseNoLep", true);   
    4543  fMinPuppiWeight = GetDouble("MinPuppiWeight", 0.01);
    46   fUseExp = GetBool("UseExp", false);
     44  fUseExp         = GetBool("UseExp", false);
    4745  // read eta min ranges
    4846  ExRootConfParam param = GetParam("EtaMinBin");
     
    5755  fPtMinBin.clear();
    5856  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fPtMinBin.push_back(param[iMap].GetDouble());
    59   // read cone size
     57  // read cone size                                                                                                                                                           
    6058  param = GetParam("ConeSizeBin");
    6159  fConeSizeBin.clear();
    6260  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fConeSizeBin.push_back(param[iMap].GetDouble());
    63   // read RMS min pt
     61  // read RMS min pt                                                                                                                                             
    6462  param = GetParam("RMSPtMinBin");
    6563  fRMSPtMinBin.clear();
     
    7775  fNeutralPtSlope.clear();
    7876  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fNeutralPtSlope.push_back(param[iMap].GetDouble());
    79   // read apply chs
     77  // read apply chs                                                                                                                                                           
    8078  //param = GetParam("ApplyCHS");
    8179  //fApplyCHS.clear();
     
    8987  fApplyLowPUCorr.clear();
    9088  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fApplyLowPUCorr.push_back(param[iMap].GetBool());
    91   // read metric id
     89  // read metric id                                                                                                                                                         
    9290  param = GetParam("MetricId");
    9391  fMetricId.clear();
     
    9896  for(int iMap = 0; iMap < param.GetSize(); ++iMap) fCombId.push_back(param[iMap].GetInt());
    9997  // create output array
    100   fOutputArray = ExportArray(GetString("OutputArray", "puppiParticles"));
    101   fOutputTrackArray = ExportArray(GetString("OutputArrayTracks", "puppiTracks"));
     98  fOutputArray        = ExportArray(GetString("OutputArray", "puppiParticles"));
     99  fOutputTrackArray   = ExportArray(GetString("OutputArrayTracks", "puppiTracks"));
    102100  fOutputNeutralArray = ExportArray(GetString("OutputArrayNeutrals", "puppiNeutrals"));
    103101  // Create algorithm list for puppi
    104102  std::vector<AlgoObj> puppiAlgo;
    105   if(puppiAlgo.empty())
    106   {
     103  if(puppiAlgo.empty()){
    107104    if(!(fEtaMinBin.size() == fEtaMaxBin.size() and fEtaMinBin.size() == fPtMinBin.size() and fEtaMinBin.size() == fConeSizeBin.size() and fEtaMinBin.size() == fRMSPtMinBin.size()
    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;
     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;
    113109      std::exit(EXIT_FAILURE);
    114110    }
    115111  }
    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);
     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);
    123118    algoTmp.minNeutralPtSlope = fNeutralPtSlope.at(iAlgo);
    124119    //Eta Extrapolation stuff is missing
    125120    //Loop through file requiring algos for same bins to be adjacent
    126     while(iAlgo < fEtaMinBin.size() and algoTmp.etaMin == fEtaMinBin.at(iAlgo) and algoTmp.etaMax == fEtaMaxBin.at(iAlgo))
    127     {
     121    while(iAlgo < fEtaMinBin.size() and algoTmp.etaMin == fEtaMinBin.at(iAlgo) and algoTmp.etaMax == fEtaMaxBin.at(iAlgo)) {
    128122      AlgoSubObj algoSubTmp;
    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);
     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);
    136130      algoTmp.subAlgos.push_back(algoSubTmp);
    137131      iAlgo++;
    138132    }
    139133    iAlgo--;
    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);
     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);
    144138}
    145139
    146140//------------------------------------------------------------------------------
    147141
    148 void RunPUPPI::Finish()
    149 {
    150   if(fItTrackInputArray) delete fItTrackInputArray;
     142void RunPUPPI::Finish(){
     143  if(fItTrackInputArray)   delete fItTrackInputArray;
    151144  if(fItNeutralInputArray) delete fItNeutralInputArray;
    152145  if(fPuppi) delete fPuppi;
     
    155148//------------------------------------------------------------------------------
    156149
    157 void RunPUPPI::Process()
    158 {
     150void RunPUPPI::Process(){
    159151
    160152  Candidate *candidate, *particle;
     
    164156
    165157  // loop over input objects
    166   fItTrackInputArray->Reset();
    167   fItNeutralInputArray->Reset();
    168   fPVItInputArray->Reset();
     158  fItTrackInputArray   ->Reset();
     159  fItNeutralInputArray ->Reset();
     160  fPVItInputArray      ->Reset();
    169161
    170162  std::vector<Candidate *> InputParticles;
    171163  InputParticles.clear();
    172164
    173   // take the leading vertex
     165  // take the leading vertex 
    174166  float PVZ = 0.;
    175   Candidate *pv = static_cast<Candidate *>(fPVItInputArray->Next());
    176   if(pv) PVZ = pv->Position.Z();
     167  Candidate *pv = static_cast<Candidate*>(fPVItInputArray->Next());
     168  if (pv) PVZ = pv->Position.Z();
    177169  // Fill input particles for puppi
    178170  std::vector<RecoObj> puppiInputVector;
    179171  puppiInputVector.clear();
    180   int lNBad = 0;
     172  int lNBad  = 0;
    181173  // Loop on charge track 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);
     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);
    263236  }
    264237  // Create PUPPI container
     
    268241
    269242  // Loop on final particles
    270   for(std::vector<PseudoJet>::iterator it = puppiParticles.begin(); it != puppiParticles.end(); it++)
    271   {
    272     if(it->user_index() <= int(InputParticles.size()))
    273     {
     243  for (std::vector<PseudoJet>::iterator it = puppiParticles.begin() ; it != puppiParticles.end() ; it++) {
     244    if(it->user_index() <= int(InputParticles.size())){     
    274245      candidate = static_cast<Candidate *>(InputParticles.at(it->user_index())->Clone());
    275       candidate->Momentum.SetPxPyPzE(it->px(), it->py(), it->pz(), it->e());
     246      candidate->Momentum.SetPxPyPzE(it->px(),it->py(),it->pz(),it->e());
    276247      fOutputArray->Add(candidate);
    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);
     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);
    281250    }
    282     else
    283     {
    284       std::cerr << " particle not found in the input Array --> skip " << std::endl;
     251    else{
     252      std::cerr<<" particle not found in the input Array --> skip "<<std::endl;
    285253      continue;
    286     }
    287   }
     254    }     
     255  }
     256
    288257}
  • modules/RunPUPPI.h

    r0e7d64a re39abb4  
    99class PuppiContainer;
    1010
    11 class RunPUPPI: public DelphesModule
    12 {
     11class RunPUPPI: public DelphesModule {
    1312
    14 public:
     13 public:
     14
    1515  RunPUPPI();
    1616  ~RunPUPPI();
     
    1919  void Process();
    2020  void Finish();
     21 
     22 private:
    2123
    22 private:
    2324  TIterator *fItTrackInputArray;
    2425  TIterator *fItNeutralInputArray; //!
    25   TIterator *fPVItInputArray; //!
    26 
     26  TIterator *fPVItInputArray; //!                                                                                                                                                     
     27 
    2728  const TObjArray *fTrackInputArray;
    2829  const TObjArray *fNeutralInputArray; //!
    29   const TObjArray *fPVInputArray; //!
    30   PuppiContainer *fPuppi;
     30  const TObjArray *fPVInputArray; //!                                                                                                                                                     
     31  PuppiContainer* fPuppi;
    3132  // puppi parameters
    3233  bool fApplyNoLep;
    3334  double fMinPuppiWeight;
    3435  bool fUseExp;
    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;
     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 ;
    4243  std::vector<float> fNeutralMinEBin;
    4344  std::vector<float> fNeutralPtSlope;
    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;
     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;
    4950
    5051  TObjArray *fOutputArray;
  • modules/SimpleCalorimeter.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class SimpleCalorimeter
    2021 *
     
    3233#include "classes/DelphesFormula.h"
    3334
     35#include "ExRootAnalysis/ExRootResult.h"
     36#include "ExRootAnalysis/ExRootFilter.h"
    3437#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    37 
     38
     39#include "TMath.h"
     40#include "TString.h"
     41#include "TFormula.h"
     42#include "TRandom3.h"
     43#include "TObjArray.h"
    3844#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4045#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TRandom3.h"
    44 #include "TString.h"
    4546
    4647#include <algorithm>
     48#include <stdexcept>
    4749#include <iostream>
    4850#include <sstream>
    49 #include <stdexcept>
    5051
    5152using namespace std;
     
    5758  fItParticleInputArray(0), fItTrackInputArray(0)
    5859{
    59 
     60 
    6061  fResolutionFormula = new DelphesFormula;
    6162  fTowerTrackArray = new TObjArray;
    6263  fItTowerTrackArray = fTowerTrackArray->MakeIterator();
     64 
    6365}
    6466
     
    6769SimpleCalorimeter::~SimpleCalorimeter()
    6870{
    69 
     71 
    7072  if(fResolutionFormula) delete fResolutionFormula;
    7173  if(fTowerTrackArray) delete fTowerTrackArray;
    7274  if(fItTowerTrackArray) delete fItTowerTrackArray;
     75 
    7376}
    7477
     
    8184  Double_t fraction;
    8285  TBinMap::iterator itEtaBin;
    83   set<Double_t>::iterator itPhiBin;
    84   vector<Double_t> *phiBins;
     86  set< Double_t >::iterator itPhiBin;
     87  vector< Double_t > *phiBins;
    8588
    8689  // read eta and phi bins
     
    9093  fEtaBins.clear();
    9194  fPhiBins.clear();
    92   for(i = 0; i < size / 2; ++i)
    93   {
    94     paramEtaBins = param[i * 2];
     95  for(i = 0; i < size/2; ++i)
     96  {
     97    paramEtaBins = param[i*2];
    9598    sizeEtaBins = paramEtaBins.GetSize();
    96     paramPhiBins = param[i * 2 + 1];
     99    paramPhiBins = param[i*2 + 1];
    97100    sizePhiBins = paramPhiBins.GetSize();
    98101
     
    111114  {
    112115    fEtaBins.push_back(itEtaBin->first);
    113     phiBins = new vector<double>(itEtaBin->second.size());
     116    phiBins = new vector< double >(itEtaBin->second.size());
    114117    fPhiBins.push_back(phiBins);
    115118    phiBins->clear();
     
    128131  fFractionMap[0] = 1.0;
    129132
    130   for(i = 0; i < size / 2; ++i)
    131   {
    132     paramFractions = param[i * 2 + 1];
     133  for(i = 0; i < size/2; ++i)
     134  {
     135    paramFractions = param[i*2 + 1];
    133136    fraction = paramFractions[0].GetDouble();
    134     fFractionMap[param[i * 2].GetInt()] = fraction;
     137    fFractionMap[param[i*2].GetInt()] = fraction;
    135138  }
    136139
     
    167170void SimpleCalorimeter::Finish()
    168171{
    169   vector<vector<Double_t> *>::iterator itPhiBin;
     172  vector< vector< Double_t >* >::iterator itPhiBin;
    170173  if(fItParticleInputArray) delete fItParticleInputArray;
    171174  if(fItTrackInputArray) delete fItTrackInputArray;
     
    194197  TFractionMap::iterator itFractionMap;
    195198
    196   vector<Double_t>::iterator itEtaBin;
    197   vector<Double_t>::iterator itPhiBin;
    198   vector<Double_t> *phiBins;
    199 
    200   vector<Long64_t>::iterator itTowerHits;
     199  vector< Double_t >::iterator itEtaBin;
     200  vector< Double_t >::iterator itPhiBin;
     201  vector< Double_t > *phiBins;
     202
     203  vector< Long64_t >::iterator itTowerHits;
    201204
    202205  DelphesFactory *factory = GetFactory();
     
    208211  fItParticleInputArray->Reset();
    209212  number = -1;
    210   while((particle = static_cast<Candidate *>(fItParticleInputArray->Next())))
     213  while((particle = static_cast<Candidate*>(fItParticleInputArray->Next())))
    211214  {
    212215    const TLorentzVector &particlePosition = particle->Position;
     
    251254  fItTrackInputArray->Reset();
    252255  number = -1;
    253   while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
     256  while((track = static_cast<Candidate*>(fItTrackInputArray->Next())))
    254257  {
    255258    const TLorentzVector &trackPosition = track->Position;
     
    300303    towerHit = (*itTowerHits);
    301304    flags = (towerHit >> 24) & 0x00000000000000FFLL;
    302     number = (towerHit)&0x0000000000FFFFFFLL;
     305    number = (towerHit) & 0x0000000000FFFFFFLL;
    303306    hitEtaPhi = towerHit >> 32;
    304307
     
    321324
    322325      // calculate eta and phi of the tower's center
    323       fTowerEta = 0.5 * (fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
    324       fTowerPhi = 0.5 * ((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
     326      fTowerEta = 0.5*(fEtaBins[etaBin - 1] + fEtaBins[etaBin]);
     327      fTowerPhi = 0.5*((*phiBins)[phiBin - 1] + (*phiBins)[phiBin]);
    325328
    326329      fTowerEdges[0] = fEtaBins[etaBin - 1];
     
    343346
    344347      fTowerTrackArray->Clear();
    345     }
     348     }
    346349
    347350    // check for track hits
     
    350353      ++fTowerTrackHits;
    351354
    352       track = static_cast<Candidate *>(fTrackInputArray->At(number));
     355      track = static_cast<Candidate*>(fTrackInputArray->At(number));
    353356      momentum = track->Momentum;
    354357      position = track->Position;
     
    356359      energy = momentum.E() * fTrackFractions[number];
    357360
    358       fTrackTime += TMath::Sqrt(energy) * position.T();
     361      fTrackTime += TMath::Sqrt(energy)*position.T();
    359362      fTrackTimeWeight += TMath::Sqrt(energy);
    360363
    361364      if(fTrackFractions[number] > 1.0E-9)
    362365      {
    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);
     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);
    374375      }
    375 
     376       
    376377      else
    377378      {
     
    385386    if(flags & 2) ++fTowerPhotonHits;
    386387
    387     particle = static_cast<Candidate *>(fParticleInputArray->At(number));
     388    particle = static_cast<Candidate*>(fParticleInputArray->At(number));
    388389    momentum = particle->Momentum;
    389390    position = particle->Position;
     
    394395    fTowerEnergy += energy;
    395396
    396     fTowerTime += energy * position.T();
     397    fTowerTime += energy*position.T();
    397398    fTowerTimeWeight += energy;
    398399
     
    409410{
    410411  Candidate *tower, *track, *mother;
    411   Double_t energy, neutralEnergy, pt, eta, phi;
     412  Double_t energy,neutralEnergy, pt, eta, phi;
    412413  Double_t sigma, neutralSigma;
    413414  Double_t time;
    414 
     415   
    415416  Double_t weightTrack, weightCalo, bestEnergyEstimate, rescaleFactor;
    416417
     
    424425  energy = LogNormal(fTowerEnergy, sigma);
    425426
    426   time = (fTowerTimeWeight < 1.0E-09) ? 0.0 : fTowerTime / fTowerTimeWeight;
     427  time = (fTowerTimeWeight < 1.0E-09 ) ? 0.0 : fTowerTime/fTowerTimeWeight;
    427428
    428429  sigma = fResolutionFormula->Eval(0.0, fTowerEta, 0.0, energy);
    429430
    430   if(energy < fEnergyMin || energy < fEnergySignificanceMin * sigma) energy = 0.0;
     431  if(energy < fEnergyMin || energy < fEnergySignificanceMin*sigma) energy = 0.0;
     432
    431433
    432434  if(fSmearTowerCenter)
     
    457459  if(energy > 0.0) fTowerOutputArray->Add(fTower);
    458460
     461 
    459462  // e-flow candidates
    460463
    461464  //compute neutral excess
    462 
     465 
    463466  fTrackSigma = TMath::Sqrt(fTrackSigma);
    464   neutralEnergy = max((energy - fTrackEnergy), 0.0);
    465 
     467  neutralEnergy = max( (energy - fTrackEnergy) , 0.0);
     468 
    466469  //compute sigma_trk total
    467   neutralSigma = neutralEnergy / TMath::Sqrt(fTrackSigma * fTrackSigma + sigma * sigma);
    468 
     470  neutralSigma = neutralEnergy / TMath::Sqrt(fTrackSigma*fTrackSigma+ sigma*sigma);
     471   
    469472  // if neutral excess is significant, simply create neutral Eflow tower and clone each track into eflowtrack
    470473  if(neutralEnergy > fEnergyMin && neutralSigma > fEnergySignificanceMin)
    471474  {
    472475    // create new photon tower
    473     tower = static_cast<Candidate *>(fTower->Clone());
     476    tower = static_cast<Candidate*>(fTower->Clone());
    474477    pt = neutralEnergy / TMath::CosH(eta);
    475478
     
    477480    tower->Ehad = (fIsEcal) ? 0 : neutralEnergy;
    478481    tower->PID = (fIsEcal) ? 22 : 0;
    479 
     482 
    480483    tower->Momentum.SetPtEtaPhiE(pt, eta, phi, neutralEnergy);
    481484    fEFlowTowerOutputArray->Add(tower);
    482 
     485   
    483486    fItTowerTrackArray->Reset();
    484     while((track = static_cast<Candidate *>(fItTowerTrackArray->Next())))
     487    while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
    485488    {
    486489      mother = track;
    487       track = static_cast<Candidate *>(track->Clone());
     490      track = static_cast<Candidate*>(track->Clone());
    488491      track->AddCandidate(mother);
    489492
     
    491494    }
    492495  }
    493 
     496   
    494497  // if neutral excess is not significant, rescale eflow tracks, such that the total charged equals the best measurement given by the calorimeter and tracking
    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 
     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   
    503506    fItTowerTrackArray->Reset();
    504     while((track = static_cast<Candidate *>(fItTowerTrackArray->Next())))
     507    while((track = static_cast<Candidate*>(fItTowerTrackArray->Next())))
    505508    {
    506509      mother = track;
    507       track = static_cast<Candidate *>(track->Clone());
     510      track = static_cast<Candidate*>(track->Clone());
    508511      track->AddCandidate(mother);
    509512
     
    513516    }
    514517  }
     518   
     519 }
     520
     521//------------------------------------------------------------------------------
     522
     523Double_t SimpleCalorimeter::LogNormal(Double_t mean, Double_t sigma)
     524{
     525  Double_t a, b;
     526
     527  if(mean > 0.0)
     528  {
     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));
     533  }
     534  else
     535  {
     536    return 0.0;
     537  }
    515538}
    516 
    517 //------------------------------------------------------------------------------
    518 
    519 Double_t SimpleCalorimeter::LogNormal(Double_t mean, Double_t sigma)
    520 {
    521   Double_t a, b;
    522 
    523   if(mean > 0.0)
    524   {
    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));
    529   }
    530   else
    531   {
    532     return 0.0;
    533   }
    534 }
  • modules/SimpleCalorimeter.h

    r0e7d64a re39abb4  
    4343{
    4444public:
     45
    4546  SimpleCalorimeter();
    4647  ~SimpleCalorimeter();
     
    5152
    5253private:
    53   typedef std::map<Long64_t, Double_t> TFractionMap; //!
    54   typedef std::map<Double_t, std::set<Double_t> > TBinMap; //!
     54
     55  typedef std::map< Long64_t, Double_t > TFractionMap; //!
     56  typedef std::map< Double_t, std::set< Double_t > > TBinMap; //!
    5557
    5658  Candidate *fTower;
     
    8082  TBinMap fBinMap; //!
    8183
    82   std::vector<Double_t> fEtaBins;
    83   std::vector<std::vector<Double_t> *> fPhiBins;
     84  std::vector < Double_t > fEtaBins;
     85  std::vector < std::vector < Double_t >* > fPhiBins;
    8486
    85   std::vector<Long64_t> fTowerHits;
     87  std::vector < Long64_t > fTowerHits;
    8688
    87   std::vector<Double_t> fTowerFractions;
     89  std::vector < Double_t > fTowerFractions;
    8890
    89   std::vector<Double_t> fTrackFractions;
     91  std::vector < Double_t > fTrackFractions;
    9092
    9193  DelphesFormula *fResolutionFormula; //!
  • modules/StatusPidFilter.cc

    r0e7d64a re39abb4  
    3232#include "classes/DelphesFormula.h"
    3333
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3436#include "ExRootAnalysis/ExRootClassifier.h"
    35 #include "ExRootAnalysis/ExRootFilter.h"
    36 #include "ExRootAnalysis/ExRootResult.h"
    37 
     37
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3843#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4044#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TRandom3.h"
    44 #include "TString.h"
    4545
    4646#include <algorithm>
     47#include <stdexcept>
    4748#include <iostream>
    4849#include <sstream>
    49 #include <stdexcept>
    5050
    5151using namespace std;
    5252
    53 namespace
    54 {
    55 // integer power (faster than TMath::Pow() + cast to integer)
    56 int 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..)
    71 int 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
    82 int 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 
    103 bool hasBottom(int pdgCode)
    104 {
    105   if((pdgCode / 10000000) > 0)
     53namespace {
     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
    106120    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 
    116 bool 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 
    133 bool 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
     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
    145136
    146137//------------------------------------------------------------------------------
     
    162153{
    163154  // PT threshold
     155
    164156  fPTMin = GetDouble("PTMin", 0.5);
    165 
    166   // keep or remove pileup particles
    167   fRequireNotPileup = GetBool("RequireNotPileup", false);
    168157
    169158  // import input array
     
    192181
    193182  fItInputArray->Reset();
    194   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     183  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    195184  {
    196185    status = candidate->Status;
     
    204193    // hard scattering particles (first condition for Py6, second for Py8)
    205194    if(status == 3) pass = kTRUE;
    206     if(status > 20 && status < 30) pass = kTRUE;
     195    if(status > 20 && status < 30 ) pass = kTRUE;
    207196
    208197    // electrons, muons, taus and neutrinos
     
    210199
    211200    // heavy quarks
    212     if(pdgCode == 4 || pdgCode == 5 || pdgCode == 6) pass = kTRUE;
     201    if(pdgCode == 4 ||pdgCode == 5 || pdgCode == 6) pass = kTRUE;
    213202
    214203    // Gauge bosons and other fundamental bosons
    215204    if(pdgCode > 22 && pdgCode < 43) pass = kTRUE;
    216205
    217     //Stable photons
    218     if(pdgCode == 22 && status == 1) pass = kTRUE;
     206    //Stable photons 
     207    if(pdgCode == 22 && status==1) pass = kTRUE;
    219208
    220209    // logic ported from HepPDF: http://lcgapp.cern.ch/project/simu/HepPDT/HepPDT.2.05.02/html/ParticleID_8cc-source.html#l00081
    221210    bool is_b_hadron = hasBottom(pdgCode);
    222     bool is_b_quark = (pdgCode == 5);
     211    bool is_b_quark  = (pdgCode == 5);
    223212
    224213    bool is_tau_daughter = isTauDaughter(pdgCode, candidate->M1, fInputArray);
    225214
    226     if(is_b_hadron)
     215    if (is_b_hadron)
    227216      pass = kTRUE;
    228217
    229     if(is_tau_daughter)
     218    if (is_tau_daughter)
    230219      pass = kTRUE;
    231220
    232221    bool is_W_daughter = isWDaughter(candidate->M1, fInputArray);
    233     if(is_W_daughter)
     222    if (is_W_daughter)
    234223      pass = kTRUE;
    235224
    236225    // fPTMin not applied to b_hadrons / b_quarks to allow for b-enriched sample stitching
    237226    // fPTMin not applied to tau decay products to allow visible-tau four momentum determination
    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;
     227    if(!pass || (candidate->Momentum.Pt() < fPTMin && !(is_b_hadron || is_b_quark || is_tau_daughter || is_W_daughter)) ) continue;
    242228
    243229    fOutputArray->Add(candidate);
    244230  }
    245231}
     232
  • modules/StatusPidFilter.h

    r0e7d64a re39abb4  
    3939{
    4040public:
     41
    4142  StatusPidFilter();
    4243  ~StatusPidFilter();
     
    4748
    4849private:
     50
    4951  Double_t fPTMin; //!
    50 
    51   Bool_t fRequireNotPileup; //!
    5252
    5353  TIterator *fItInputArray; //!
  • modules/TaggingParticlesSkimmer.cc

    r0e7d64a re39abb4  
    3535#include "classes/DelphesFormula.h"
    3636
     37#include "ExRootAnalysis/ExRootResult.h"
     38#include "ExRootAnalysis/ExRootFilter.h"
    3739#include "ExRootAnalysis/ExRootClassifier.h"
    38 #include "ExRootAnalysis/ExRootFilter.h"
    39 #include "ExRootAnalysis/ExRootResult.h"
    4040
     41#include "TMath.h"
     42#include "TString.h"
     43#include "TFormula.h"
     44#include "TRandom3.h"
     45#include "TObjArray.h"
    4146#include "TDatabasePDG.h"
    42 #include "TFormula.h"
    4347#include "TLorentzVector.h"
    44 #include "TMath.h"
    45 #include "TObjArray.h"
    46 #include "TRandom3.h"
    47 #include "TString.h"
    4848
    4949#include <algorithm>
     50#include <stdexcept>
    5051#include <iostream>
    5152#include <sstream>
    52 #include <stdexcept>
    5353
    5454using namespace std;
     55
    5556
    5657//------------------------------------------------------------------------------
    5758
    5859TaggingParticlesSkimmer::TaggingParticlesSkimmer() :
    59   fClassifier(0), fFilter(0), fItPartonInputArray(0),
    60   fPartonInputArray(0), fParticleInputArray(0), fOutputArray(0)
     60  fItPartonInputArray(0), fFilter(0), fClassifier(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 
    8485  fClassifier = new TauTaggingPartonClassifier(fParticleInputArray);
    8586  fClassifier->fPTMin = GetDouble("PTMin", 15.0);
    8687  fClassifier->fEtaMax = GetDouble("EtaMax", 2.5);
    8788
     89 
    8890  fFilter = new ExRootFilter(fPartonInputArray);
    8991
     
    9597
    9698void TaggingParticlesSkimmer::Finish()
    97 {
     99{ 
    98100  if(fItPartonInputArray) delete fItPartonInputArray;
    99101  if(fFilter) delete fFilter;
     
    125127    if(tau->D1 < 0) continue;
    126128
    127     if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
     129    if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
     130       tau->D2 >= fParticleInputArray->GetEntriesFast())
    128131    {
    129132      throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    131134
    132135    tauMomentum.SetPxPyPzE(0.0, 0.0, 0.0, 0.0);
    133 
     136   
    134137    for(i = tau->D1; i <= tau->D2; ++i)
    135138    {
     
    138141      tauMomentum += daughter->Momentum;
    139142    }
     143 
     144   candidate = static_cast<Candidate*>(tau->Clone());
     145   candidate->Momentum = tauMomentum;
    140146
    141     candidate = static_cast<Candidate *>(tau->Clone());
    142     candidate->Momentum = tauMomentum;
     147   
     148   fOutputArray->Add(candidate);
    143149
     150  }
     151
     152  // then add all other partons (except tau's to avoid double counting)
     153 
     154  fItPartonInputArray->Reset();
     155  while((candidate = static_cast<Candidate*>(fItPartonInputArray->Next())))
     156  {
     157    pdgCode = TMath::Abs(candidate->PID);
     158    if(pdgCode == 15) continue;
     159   
     160    pt = candidate->Momentum.Pt();
     161    if(pt < fPTMin) continue;
     162   
     163    eta = TMath::Abs(candidate->Momentum.Eta());
     164    if(eta > fEtaMax) continue;
     165       
    144166    fOutputArray->Add(candidate);
    145167  }
    146168
    147   // then add all other partons (except tau's to avoid double counting)
    148169
    149   fItPartonInputArray->Reset();
    150   while((candidate = static_cast<Candidate *>(fItPartonInputArray->Next())))
    151   {
    152     pdgCode = TMath::Abs(candidate->PID);
    153     if(pdgCode == 15) continue;
     170}
    154171
    155     pt = candidate->Momentum.Pt();
    156     if(pt < fPTMin) continue;
    157 
    158     eta = TMath::Abs(candidate->Momentum.Eta());
    159     if(eta > fEtaMax) continue;
    160 
    161     fOutputArray->Add(candidate);
    162   }
    163 }
  • modules/TaggingParticlesSkimmer.h

    r0e7d64a re39abb4  
    4242{
    4343public:
     44
    4445  TaggingParticlesSkimmer();
    4546  ~TaggingParticlesSkimmer();
     
    5051
    5152private:
     53
    5254  Double_t fPTMin; //!
    5355  Double_t fEtaMax; //!
    54 
     56 
    5557  TauTaggingPartonClassifier *fClassifier; //!
    56 
     58 
    5759  ExRootFilter *fFilter;
    5860
    5961  TIterator *fItPartonInputArray; //!
    60 
     62 
    6163  const TObjArray *fPartonInputArray; //!
    6264  const TObjArray *fParticleInputArray; //!
  • modules/TauTagging.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class TauTagging
    2021 *
     
    3334#include "classes/DelphesFormula.h"
    3435
     36#include "TMath.h"
     37#include "TString.h"
     38#include "TFormula.h"
     39#include "TRandom3.h"
     40#include "TObjArray.h"
    3541#include "TDatabasePDG.h"
    36 #include "TFormula.h"
    3742#include "TLorentzVector.h"
    38 #include "TMath.h"
    39 #include "TObjArray.h"
    40 #include "TRandom3.h"
    41 #include "TString.h"
    4243
    4344#include <algorithm>
     45#include <stdexcept>
    4446#include <iostream>
    4547#include <sstream>
    46 #include <stdexcept>
    4748
    4849using namespace std;
     50
    4951
    5052//------------------------------------------------------------------------------
     
    6163  Candidate *daughter1 = 0;
    6264  Candidate *daughter2 = 0;
    63 
     65 
    6466  const TLorentzVector &momentum = tau->Momentum;
    6567  Int_t pdgCode, i, j;
     
    7476  if(tau->D2 < tau->D1) return -1;
    7577
    76   if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
     78  if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
     79     tau->D2 >= fParticleInputArray->GetEntriesFast())
    7780  {
    7881    throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    8386    daughter1 = static_cast<Candidate *>(fParticleInputArray->At(i));
    8487    pdgCode = TMath::Abs(daughter1->PID);
    85     if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15)
    86       return -1;
     88    if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15) return -1;
    8789    else if(pdgCode == 24)
    8890    {
    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       }
     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       
    9699    }
    97100  }
     
    118121void TauTagging::Init()
    119122{
    120   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     123  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    121124  ExRootConfParam param;
    122125  DelphesFormula *formula;
     
    132135
    133136  fEfficiencyMap.clear();
    134   for(i = 0; i < size / 2; ++i)
     137  for(i = 0; i < size/2; ++i)
    135138  {
    136139    formula = new DelphesFormula;
    137     formula->Compile(param[i * 2 + 1].GetString());
    138 
    139     fEfficiencyMap[param[i * 2].GetInt()] = formula;
     140    formula->Compile(param[i*2 + 1].GetString());
     141
     142    fEfficiencyMap[param[i*2].GetInt()] = formula;
    140143  }
    141144
     
    171174void TauTagging::Finish()
    172175{
    173   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     176  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    174177  DelphesFormula *formula;
    175178
     
    194197  Double_t pt, eta, phi, e, eff;
    195198  TObjArray *tauArray;
    196   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     199  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    197200  DelphesFormula *formula;
    198201  Int_t pdgCode, charge, i;
     
    215218
    216219    // loop over all input taus
    217     if(tauArray)
    218     {
     220    if(tauArray){
    219221      TIter itTauArray(tauArray);
    220222      while((tau = static_cast<Candidate *>(itTauArray.Next())))
     
    222224        if(tau->D1 < 0) continue;
    223225
    224         if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
     226        if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
     227           tau->D2 >= fParticleInputArray->GetEntriesFast())
    225228        {
    226229          throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    254257    eff = formula->Eval(pt, eta, phi, e);
    255258    jet->TauTag |= (gRandom->Uniform() <= eff) << fBitNumber;
    256     jet->TauWeight = eff;
     259    jet->TauWeight = eff;     
    257260
    258261    // set tau charge
  • modules/TauTagging.h

    r0e7d64a re39abb4  
    3030 */
    3131
     32#include "classes/DelphesModule.h"
     33#include "ExRootAnalysis/ExRootResult.h"
     34#include "ExRootAnalysis/ExRootFilter.h"
    3235#include "ExRootAnalysis/ExRootClassifier.h"
    33 #include "ExRootAnalysis/ExRootFilter.h"
    34 #include "ExRootAnalysis/ExRootResult.h"
    35 #include "classes/DelphesModule.h"
    3636
    3737#include <map>
     
    4646{
    4747public:
     48
    4849  TauTagging();
    4950  ~TauTagging();
     
    5455
    5556private:
     57 
    5658  Int_t fBitNumber;
    57 
     59 
    5860  Double_t fDeltaR;
    5961
    6062#if !defined(__CINT__) && !defined(__CLING__)
    61   std::map<Int_t, DelphesFormula *> fEfficiencyMap; //!
     63  std::map< Int_t, DelphesFormula * > fEfficiencyMap; //!
    6264#endif
    63 
     65 
    6466  TauTaggingPartonClassifier *fClassifier; //!
    65 
     67 
    6668  ExRootFilter *fFilter;
    6769
    6870  TIterator *fItPartonInputArray; //!
    69 
     71 
    7072  TIterator *fItJetInputArray; //!
    7173
     
    7375
    7476  const TObjArray *fPartonInputArray; //!
    75 
     77 
    7678  const TObjArray *fJetInputArray; //!
    7779
     
    7981};
    8082
     83
    8184//------------------------------------------------------------------------------
    8285
    83 class TauTaggingPartonClassifier: public ExRootClassifier
     86class TauTaggingPartonClassifier : public ExRootClassifier
    8487{
    8588public:
     89
    8690  TauTaggingPartonClassifier(const TObjArray *array);
    8791
     
    9397};
    9498
     99
    95100#endif
  • modules/TimeSmearing.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class TimeSmearing
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    5354
    5455TimeSmearing::TimeSmearing() :
    55   fItInputArray(0)
     56fItInputArray(0)
    5657{
    5758}
     
    9697
    9798  fItInputArray->Reset();
    98   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     99  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    99100  {
    100101    const TLorentzVector &candidateInitialPosition = candidate->InitialPosition;
    101102    const TLorentzVector &candidateFinalPosition = candidate->Position;
    102103
    103     ti = candidateInitialPosition.T() * 1.0E-3 / c_light;
    104     tf = candidateFinalPosition.T() * 1.0E-3 / c_light;
     104    ti = candidateInitialPosition.T()*1.0E-3/c_light;
     105    tf = candidateFinalPosition.T()*1.0E-3/c_light;
    105106
    106107    // apply smearing formula
     
    108109    ti = ti + tf_smeared - tf;
    109110    tf = tf_smeared;
     111   
     112    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);
    110116
    111     mother = candidate;
    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);
    115 
    116     candidate->ErrorT = fTimeResolution * 1.0E3 * c_light;
     117    candidate->ErrorT = fTimeResolution*1.0E3*c_light;
    117118
    118119    candidate->AddCandidate(mother);
  • modules/TimeSmearing.h

    r0e7d64a re39abb4  
    3636{
    3737public:
     38
    3839  TimeSmearing();
    3940  ~TimeSmearing();
     
    4445
    4546private:
     47
    4648  Double_t fTimeResolution;
    4749
  • modules/TrackCountingBTagging.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class TrackCountingBTagging
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "TMath.h"
     35#include "TString.h"
    3336#include "TFormula.h"
     37#include "TRandom3.h"
     38#include "TObjArray.h"
    3439#include "TLorentzVector.h"
    35 #include "TMath.h"
    36 #include "TObjArray.h"
    37 #include "TRandom3.h"
    38 #include "TString.h"
    3940
    4041#include <algorithm>
     42#include <stdexcept>
    4143#include <iostream>
    4244#include <sstream>
    43 #include <stdexcept>
    4445
    4546using namespace std;
     
    106107  // loop over all input jets
    107108  fItJetInputArray->Reset();
    108   while((jet = static_cast<Candidate *>(fItJetInputArray->Next())))
     109  while((jet = static_cast<Candidate*>(fItJetInputArray->Next())))
    109110  {
    110111    const TLorentzVector &jetMomentum = jet->Momentum;
     
    117118    count = 0;
    118119    // stop once we have enough tracks
    119     while((track = static_cast<Candidate *>(fItTrackInputArray->Next())) and count < fNtracks)
     120    while((track = static_cast<Candidate*>(fItTrackInputArray->Next())) and count < fNtracks)
    120121    {
    121122      const TLorentzVector &trkMomentum = track->Momentum;
    122123      tpt = trkMomentum.Pt();
    123124      if(tpt < fPtMin) continue;
    124 
     125     
    125126      d0 = TMath::Abs(track->D0);
    126127      if(d0 > fIPmax) continue;
     
    136137      ddz = TMath::Abs(track->ErrorDZ);
    137138
    138       if(fUse3D)
    139       {
    140         sign = (jpx * xd + jpy * yd + jpz * zd > 0.0) ? 1 : -1;
     139      if(fUse3D){
     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       {
    146         sign = (jpx * xd + jpy * yd > 0.0) ? 1 : -1;
     144      else {
     145        sign = (jpx*xd + jpy*yd > 0.0) ? 1 : -1;
    147146        sip = sign * d0 / TMath::Abs(dd0);
    148147      }
  • modules/TrackCountingBTagging.h

    r0e7d64a re39abb4  
    3737{
    3838public:
     39
    3940  TrackCountingBTagging();
    4041  ~TrackCountingBTagging();
     
    4546
    4647private:
     48
    4749  Int_t fBitNumber;
    4850
     
    5153  Double_t fIPmax;
    5254  Double_t fSigMin;
    53   Int_t fNtracks;
    54   Bool_t fUse3D;
     55  Int_t    fNtracks;
     56  Bool_t   fUse3D;
    5557
    5658  TIterator *fItTrackInputArray; //!
  • modules/TrackCountingTauTagging.cc

    r0e7d64a re39abb4  
    2020#include "classes/DelphesFormula.h"
    2121
     22#include "ExRootAnalysis/ExRootResult.h"
     23#include "ExRootAnalysis/ExRootFilter.h"
    2224#include "ExRootAnalysis/ExRootClassifier.h"
    23 #include "ExRootAnalysis/ExRootFilter.h"
    24 #include "ExRootAnalysis/ExRootResult.h"
    25 
     25
     26#include "TMath.h"
     27#include "TString.h"
     28#include "TFormula.h"
     29#include "TRandom3.h"
     30#include "TObjArray.h"
    2631#include "TDatabasePDG.h"
    27 #include "TFormula.h"
    2832#include "TLorentzVector.h"
    29 #include "TMath.h"
    30 #include "TObjArray.h"
    31 #include "TRandom3.h"
    32 #include "TString.h"
    3333
    3434#include <algorithm>
     35#include <stdexcept>
    3536#include <iostream>
    3637#include <sstream>
    37 #include <stdexcept>
    3838
    3939using namespace std;
     
    4444{
    4545public:
     46
    4647  TrackCountingTauTaggingPartonClassifier(const TObjArray *array);
    4748
     
    6667  Candidate *daughter1 = 0;
    6768  Candidate *daughter2 = 0;
    68 
     69 
    6970  const TLorentzVector &momentum = tau->Momentum;
    7071  Int_t pdgCode, i, j;
     
    7980  if(tau->D2 < tau->D1) return -1;
    8081
    81   if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
     82  if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
     83     tau->D2 >= fParticleInputArray->GetEntriesFast())
    8284  {
    8385    throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    8890    daughter1 = static_cast<Candidate *>(fParticleInputArray->At(i));
    8991    pdgCode = TMath::Abs(daughter1->PID);
    90     if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15)
    91       return -1;
     92    if(pdgCode == 11 || pdgCode == 13 || pdgCode == 15) return -1;
    9293    else if(pdgCode == 24)
    9394    {
    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       }
     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       
    101103    }
    102104  }
     
    123125void TrackCountingTauTagging::Init()
    124126{
    125   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     127  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    126128  ExRootConfParam param;
    127129  DelphesFormula *formula;
     
    133135  fDeltaRTrack = GetDouble("DeltaRTrack", 0.2);
    134136  fTrackPTMin = GetDouble("TrackPTMin", 1.0);
    135 
     137 
    136138  // read efficiency formulas
    137139  param = GetParam("EfficiencyFormula");
     
    139141
    140142  fEfficiencyMap.clear();
    141   for(i = 0; i < size / 2; ++i)
     143  for(i = 0; i < size/2; ++i)
    142144  {
    143145    formula = new DelphesFormula;
    144     formula->Compile(param[i * 2 + 1].GetString());
    145 
    146     fEfficiencyMap[param[i * 2].GetInt()] = formula;
     146    formula->Compile(param[i*2 + 1].GetString());
     147
     148    fEfficiencyMap[param[i*2].GetInt()] = formula;
    147149  }
    148150
     
    170172  fTrackInputArray = ImportArray(GetString("TrackInputArray", "TrackMerger/tracks"));
    171173  fItTrackInputArray = fTrackInputArray->MakeIterator();
    172 
     174 
    173175  fFilter = new ExRootFilter(fPartonInputArray);
    174176
     
    181183void TrackCountingTauTagging::Finish()
    182184{
    183   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     185  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    184186  DelphesFormula *formula;
    185187
     
    205207  Double_t pt, eta, phi, e;
    206208  TObjArray *tauArray;
    207   map<Int_t, DelphesFormula *>::iterator itEfficiencyMap;
     209  map< Int_t, DelphesFormula * >::iterator itEfficiencyMap;
    208210  DelphesFormula *formula;
    209211  Int_t pdgCode, charge, i, identifier;
     
    230232    e = jetMomentum.E();
    231233
    232     // loop over all input tracks
     234
     235// loop over all input tracks
    233236    fItTrackInputArray->Reset();
    234237    while((track = static_cast<Candidate *>(fItTrackInputArray->Next())))
    235238    {
    236       if((track->Momentum).Pt() < fTrackPTMin) continue;
    237       if(jetMomentum.DeltaR(track->Momentum) <= fDeltaRTrack)
    238       {
    239         identifier -= 1;
    240         charge += track->Charge;
    241       }
     239        if((track->Momentum).Pt() < fTrackPTMin) continue;
     240        if(jetMomentum.DeltaR(track->Momentum) <= fDeltaRTrack) {
     241            identifier -= 1;
     242            charge += track->Charge;
     243        }
    242244    }
    243 
     245   
    244246    // loop over all input taus
    245247    itTauArray.Reset();
     
    249251      if(tau->D1 < 0) continue;
    250252
    251       if(tau->D1 >= fParticleInputArray->GetEntriesFast() || tau->D2 >= fParticleInputArray->GetEntriesFast())
     253      if(tau->D1 >= fParticleInputArray->GetEntriesFast() ||
     254         tau->D2 >= fParticleInputArray->GetEntriesFast())
    252255      {
    253256        throw runtime_error("tau's daughter index is greater than the ParticleInputArray size");
     
    260263        daughter = static_cast<Candidate *>(fParticleInputArray->At(i));
    261264        if(TMath::Abs(daughter->PID) == 16) continue;
    262         tauMomentum += daughter->Momentum;
     265        tauMomentum += daughter->Momentum; 
    263266      }
    264267
    265268      if(jetMomentum.DeltaR(tauMomentum) <= fDeltaR)
    266       {
     269      {       
    267270        matchedTau = true;
    268271        pdgCode = 15;
     
    270273    }
    271274    if(matchedTau)
    272       identifier *= -1;
     275        identifier *= -1;
    273276    // find an efficency formula
    274277    // If the identifier is larger than 2, set it to 2 (multiprong requires at least 2 tracks)
    275     if(identifier > 2)
    276       identifier = 2;
    277     else if(identifier < -2)
    278       identifier = -2;
    279 
     278    if (identifier > 2)
     279        identifier = 2;
     280    else if (identifier < -2)
     281        identifier = -2;
     282
     283   
    280284    itEfficiencyMap = fEfficiencyMap.find(identifier);
    281285    if(itEfficiencyMap == fEfficiencyMap.end())
     
    289293    // apply an efficency formula
    290294    jet->TauTag |= (gRandom->Uniform() <= formula->Eval(pt, eta, phi, e)) << fBitNumber;
    291 
     295   
     296   
    292297    // set tau charge
    293298    jet->Charge = charge;
  • modules/TrackCountingTauTagging.h

    r0e7d64a re39abb4  
    2929{
    3030public:
     31
    3132  TrackCountingTauTagging();
    3233  ~TrackCountingTauTagging();
     
    3738
    3839private:
     40
    3941  Int_t fBitNumber;
    4042
     
    4345  Double_t fTrackPTMin;
    4446
    45   std::map<Int_t, DelphesFormula *> fEfficiencyMap; //!
    46 
     47  std::map< Int_t, DelphesFormula * > fEfficiencyMap; //!
     48 
    4749  TrackCountingTauTaggingPartonClassifier *fClassifier; //!
    48 
     50 
    4951  ExRootFilter *fFilter;
    5052
    5153  TIterator *fItPartonInputArray; //!
    52 
     54 
    5355  TIterator *fItTrackInputArray; //!
    54 
     56 
    5557  TIterator *fItJetInputArray; //!
    5658
     
    6062
    6163  const TObjArray *fPartonInputArray; //!
    62 
     64 
    6365  const TObjArray *fJetInputArray; //!
    6466
  • modules/TrackPileUpSubtractor.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class TrackPileUpSubtractor
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    5354
    5455TrackPileUpSubtractor::TrackPileUpSubtractor() :
    55   fFormula(0)
     56fFormula(0)
    5657{
    5758  fFormula = new DelphesFormula;
     
    8788
    8889  size = param.GetSize();
    89   for(i = 0; i < size / 2; ++i)
     90  for(i = 0; i < size/2; ++i)
    9091  {
    91     array = ImportArray(param[i * 2].GetString());
     92    array = ImportArray(param[i*2].GetString());
    9293    iterator = array->MakeIterator();
    9394
    94     fInputMap[iterator] = ExportArray(param[i * 2 + 1].GetString());
     95    fInputMap[iterator] = ExportArray(param[i*2 + 1].GetString());
    9596  }
    9697}
     
    100101void TrackPileUpSubtractor::Finish()
    101102{
    102   map<TIterator *, TObjArray *>::iterator itInputMap;
     103  map< TIterator *, TObjArray * >::iterator itInputMap;
    103104  TIterator *iterator;
    104105
     
    118119{
    119120  Candidate *candidate, *particle;
    120   map<TIterator *, TObjArray *>::iterator itInputMap;
     121  map< TIterator *, TObjArray * >::iterator itInputMap;
    121122  TIterator *iterator;
    122123  TObjArray *array;
    123   Double_t z, zvtx = 0;
     124  Double_t z, zvtx=0;
    124125  Double_t pt, eta, phi, e;
     126
    125127
    126128  // find z position of primary vertex
    127129
    128130  fItVertexInputArray->Reset();
    129   while((candidate = static_cast<Candidate *>(fItVertexInputArray->Next())))
     131  while((candidate = static_cast<Candidate*>(fItVertexInputArray->Next())))
    130132  {
    131133    if(!candidate->IsPU)
     
    144146    // loop over all candidates
    145147    iterator->Reset();
    146     while((candidate = static_cast<Candidate *>(iterator->Next())))
     148    while((candidate = static_cast<Candidate*>(iterator->Next())))
    147149    {
    148       particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     150      particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
    149151      const TLorentzVector &candidateMomentum = particle->Momentum;
    150152
     
    153155      phi = candidateMomentum.Phi();
    154156      e = candidateMomentum.E();
    155 
     157     
    156158      z = particle->Position.Z();
    157159
     
    159161      // assume perfect pile-up subtraction for tracks outside fZVertexResolution
    160162
    161       if(candidate->Charge != 0 && candidate->IsPU && TMath::Abs(z - zvtx) > fFormula->Eval(pt, eta, phi, e) * 1.0e3)
     163      if(candidate->Charge !=0 && candidate->IsPU && TMath::Abs(z-zvtx) > fFormula->Eval(pt, eta, phi, e)* 1.0e3)
    162164      {
    163165        candidate->IsRecoPU = 1;
  • modules/TrackPileUpSubtractor.h

    r0e7d64a re39abb4  
    3939{
    4040public:
     41
    4142  TrackPileUpSubtractor();
    4243  ~TrackPileUpSubtractor();
     
    4748
    4849private:
     50
    4951  DelphesFormula *fFormula; //!
    5052
    5153  Double_t fPTMin;
    5254
    53   std::map<TIterator *, TObjArray *> fInputMap; //!
     55  std::map< TIterator *, TObjArray * > fInputMap; //!
    5456
    5557  ClassDef(TrackPileUpSubtractor, 1)
    5658
    57     TIterator *fItVertexInputArray; //!
     59  TIterator *fItVertexInputArray; //!
    5860
    5961  const TObjArray *fVertexInputArray; //!
     62
    6063};
    6164
  • modules/TrackSmearing.cc

    r0e7d64a re39abb4  
    1313#include "classes/DelphesFormula.h"
    1414
     15#include "ExRootAnalysis/ExRootResult.h"
     16#include "ExRootAnalysis/ExRootFilter.h"
    1517#include "ExRootAnalysis/ExRootClassifier.h"
    16 #include "ExRootAnalysis/ExRootFilter.h"
    17 #include "ExRootAnalysis/ExRootResult.h"
    18 
     18
     19#include "TMath.h"
     20#include "TString.h"
     21#include "TFormula.h"
     22#include "TRandom3.h"
     23#include "TObjArray.h"
    1924#include "TDatabasePDG.h"
     25#include "TLorentzVector.h"
    2026#include "TFile.h"
    21 #include "TFormula.h"
    22 #include "TLorentzVector.h"
    23 #include "TMath.h"
    24 #include "TObjArray.h"
    2527#include "TProfile2D.h"
    26 #include "TRandom3.h"
    27 #include "TString.h"
    28 
    29 #include <algorithm>
     28
     29#include <algorithm>
     30#include <stdexcept>
    3031#include <iostream>
    3132#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) : 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)
     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)
    246247      continue;
    247248
    248     if(fUseDZFormula)
     249    if (fUseDZFormula)
    249250      dzError = fDZFormula->Eval(pt, eta);
    250251    else
    251252    {
    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)
     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)
    261263      continue;
    262264
    263     if(fUsePFormula)
     265    if (fUsePFormula)
    264266      pError = fPFormula->Eval(pt, eta) * p;
    265267    else
    266268    {
    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)
     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)
    276279      continue;
    277280
    278     if(fUseCtgThetaFormula)
     281    if (fUseCtgThetaFormula)
    279282      ctgThetaError = fCtgThetaFormula->Eval(pt, eta);
    280283    else
    281284    {
    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)
     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)
    291295      continue;
    292296
    293     if(fUsePhiFormula)
     297    if (fUsePhiFormula)
    294298      phiError = fPhiFormula->Eval(pt, eta);
    295299    else
    296300    {
    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)
     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)
    306311      continue;
    307312
    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);
     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);
    315320    }
    316321
    317322    if(p < 0.0) continue;
    318     while(phi > TMath::Pi()) phi -= TMath::TwoPi();
    319     while(phi <= -TMath::Pi()) phi += TMath::TwoPi();
     323    while (phi > TMath::Pi ()) phi -= TMath::TwoPi ();
     324    while (phi <= -TMath::Pi ()) phi += TMath::TwoPi ();
    320325
    321326    mother = candidate;
    322     candidate = static_cast<Candidate *>(candidate->Clone());
     327    candidate = static_cast<Candidate*>(candidate->Clone());
    323328    candidate->D0 = d0;
    324329    candidate->DZ = dz;
     
    327332    candidate->Phi = phi;
    328333
    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 
     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   
    345350    // -- solve for delta: d0' = ( (x+delta)*py' - (y+delta)*px' )/pt'
    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();
     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 ();
    353358
    354359    candidate->InitialPosition.SetT(t);
     
    361366    q = candidate->Charge;
    362367
    363     r = pt / (q * fBz) * 1.0E9 / c_light; // in [m]
     368    r = pt / (q * fBz) * 1.0E9/c_light;        // in [m]
    364369    phi_0 = TMath::ATan2(py, px); // [rad] in [-pi, pi]
    365370
    366371    // 2. helix axis coordinates
    367     x_c = x + r * TMath::Sin(phi_0);
    368     y_c = y - r * TMath::Cos(phi_0);
     372    x_c = x + r*TMath::Sin(phi_0);
     373    y_c = y - r*TMath::Cos(phi_0);
    369374    r_c = TMath::Hypot(x_c, y_c);
    370375
    371376    rcu = TMath::Abs(r);
    372     rc2 = r_c * r_c;
     377    rc2 = r_c*r_c;
    373378
    374379    // calculate coordinates of closest approach to track circle in transverse plane xd, yd, zd
    375     xd = x_c * x_c * x_c - x_c * rcu * r_c + x_c * y_c * y_c;
     380    xd = x_c*x_c*x_c - x_c*rcu*r_c + x_c*y_c*y_c;
    376381    xd = (rc2 > 0.0) ? xd / rc2 : -999;
    377     yd = y_c * (-rcu * r_c + rc2);
     382    yd = y_c*(-rcu*r_c + rc2);
    378383    yd = (rc2 > 0.0) ? yd / rc2 : -999;
    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 
     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   
    396401    candidate->AddCandidate(mother);
    397402    fOutputArray->Add(candidate);
     
    401406}
    402407
    403 Double_t TrackSmearing::ptError(const Double_t p, const Double_t ctgTheta, const Double_t dP, const Double_t dCtgTheta)
     408Double_t TrackSmearing::ptError (const Double_t p, const Double_t ctgTheta, const Double_t dP, const Double_t dCtgTheta)
    404409{
    405410  Double_t a, b;
    406411  a = (p * p * ctgTheta * ctgTheta * dCtgTheta * dCtgTheta) / ((ctgTheta * ctgTheta + 1) * (ctgTheta * ctgTheta + 1) * (ctgTheta * ctgTheta + 1));
    407412  b = (dP * dP) / (ctgTheta * ctgTheta + 1);
    408   return sqrt(a + b);
    409 }
    410 
    411 //------------------------------------------------------------------------------
     413  return sqrt (a + b);
     414}
     415
     416//------------------------------------------------------------------------------
  • modules/TrackSmearing.h

    r0e7d64a re39abb4  
    2121{
    2222public:
     23
    2324  TrackSmearing();
    2425  ~TrackSmearing();
     
    2930
    3031private:
    31   Double_t ptError(const Double_t, const Double_t, const Double_t, const Double_t);
     32
     33  Double_t ptError (const Double_t, const Double_t, const Double_t, const Double_t);
    3234
    3335  Double_t fBz;
     
    6466  const TObjArray *fInputArray; //!
    6567  const TObjArray *fBeamSpotInputArray; //!
    66 
     68 
    6769  TObjArray *fOutputArray; //!
    6870
  • modules/TreeWriter.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class TreeWriter
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637#include "ExRootAnalysis/ExRootTreeBranch.h"
    3738
     39#include "TROOT.h"
     40#include "TMath.h"
     41#include "TString.h"
     42#include "TFormula.h"
     43#include "TRandom3.h"
     44#include "TObjArray.h"
    3845#include "TDatabasePDG.h"
    39 #include "TFormula.h"
    4046#include "TLorentzVector.h"
    41 #include "TMath.h"
    42 #include "TObjArray.h"
    43 #include "TROOT.h"
    44 #include "TRandom3.h"
    45 #include "TString.h"
    4647
    4748#include <algorithm>
     49#include <stdexcept>
    4850#include <iostream>
    4951#include <sstream>
    50 #include <stdexcept>
    5152
    5253using namespace std;
     
    8384
    8485  TBranchMap::iterator itBranchMap;
    85   map<TClass *, TProcessMethod>::iterator itClassMap;
     86  map< TClass *, TProcessMethod >::iterator itClassMap;
    8687
    8788  // read branch configuration and
     
    9697
    9798  size = param.GetSize();
    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();
     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();
    103104
    104105    branchClass = gROOT->GetClass(branchClassName);
     
    122123    fBranchMap.insert(make_pair(branch, make_pair(itClassMap->second, array)));
    123124  }
     125
    124126}
    125127
     
    137139  it1.Reset();
    138140  array->Clear();
    139   while((candidate = static_cast<Candidate *>(it1.Next())))
     141  while((candidate = static_cast<Candidate*>(it1.Next())))
    140142  {
    141143    TIter it2(candidate->GetCandidates());
     
    149151
    150152    // track
    151     candidate = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     153    candidate = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
    152154    if(candidate->GetCandidates()->GetEntriesFast() == 0)
    153155    {
     
    158160    // tower
    159161    it2.Reset();
    160     while((candidate = static_cast<Candidate *>(it2.Next())))
     162    while((candidate = static_cast<Candidate*>(it2.Next())))
    161163    {
    162164      array->Add(candidate->GetCandidates()->At(0));
     
    178180  // loop over all particles
    179181  iterator.Reset();
    180   while((candidate = static_cast<Candidate *>(iterator.Next())))
     182  while((candidate = static_cast<Candidate*>(iterator.Next())))
    181183  {
    182184    const TLorentzVector &momentum = candidate->Momentum;
    183185    const TLorentzVector &position = candidate->Position;
    184186
    185     entry = static_cast<GenParticle *>(branch->NewEntry());
     187    entry = static_cast<GenParticle*>(branch->NewEntry());
    186188
    187189    entry->SetBit(kIsReferenced);
     
    191193    cosTheta = TMath::Abs(momentum.CosTheta());
    192194    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    193     eta = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Eta());
    194     rapidity = (cosTheta == 1.0 ? signPz * 999.9 : momentum.Rapidity());
     195    eta = (cosTheta == 1.0 ? signPz*999.9 : momentum.Eta());
     196    rapidity = (cosTheta == 1.0 ? signPz*999.9 : momentum.Rapidity());
    195197
    196198    entry->PID = candidate->PID;
     
    213215    entry->Pz = momentum.Pz();
    214216
    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;
     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;
    221223
    222224    entry->Eta = eta;
     
    229231    entry->Y = position.Y();
    230232    entry->Z = position.Z();
    231     entry->T = position.T() * 1.0E-3 / c_light;
     233    entry->T = position.T()*1.0E-3/c_light;
    232234  }
    233235}
     
    253255  // loop over all vertices
    254256  iterator.Reset();
    255   while((candidate = static_cast<Candidate *>(iterator.Next())))
     257  while((candidate = static_cast<Candidate*>(iterator.Next())))
    256258  {
    257259
     
    267269    y = candidate->Position.Y();
    268270    z = candidate->Position.Z();
    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());
     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());
    277279
    278280    entry->Index = index;
     
    294296    entry->ErrorT = tError;
    295297
     298
    296299    TIter itConstituents(candidate->GetCandidates());
    297300    itConstituents.Reset();
    298301    entry->Constituents.Clear();
    299     while((constituent = static_cast<Candidate *>(itConstituents.Next())))
     302    while((constituent = static_cast<Candidate*>(itConstituents.Next())))
    300303    {
    301304      entry->Constituents.Add(constituent);
    302305    }
    303   }
    304 }
     306
     307  }
     308}
     309
    305310
    306311//------------------------------------------------------------------------------
     
    317322  // loop over all tracks
    318323  iterator.Reset();
    319   while((candidate = static_cast<Candidate *>(iterator.Next())))
     324  while((candidate = static_cast<Candidate*>(iterator.Next())))
    320325  {
    321326    const TLorentzVector &position = candidate->Position;
     
    323328    cosTheta = TMath::Abs(position.CosTheta());
    324329    signz = (position.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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());
    329334
    330335    entry->SetBit(kIsReferenced);
     
    341346    entry->YOuter = position.Y();
    342347    entry->ZOuter = position.Z();
    343     entry->TOuter = position.T() * 1.0E-3 / c_light;
     348    entry->TOuter = position.T()*1.0E-3/c_light;
    344349
    345350    entry->L = candidate->L;
    346351
    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;
     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;
    354359    entry->ErrorCtgTheta = candidate->ErrorCtgTheta;
    355     entry->ErrorPhi = candidate->ErrorPhi;
     360    entry->ErrorPhi      = candidate->ErrorPhi;
    356361
    357362    entry->Xd = candidate->Xd;
     
    364369    p = momentum.P();
    365370    phi = momentum.Phi();
    366     ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1 / TMath::Tan(momentum.Theta()) : 1e10;
     371    ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1/TMath::Tan(momentum.Theta()) : 1e10;
    367372
    368373    cosTheta = TMath::Abs(momentum.CosTheta());
    369374    signz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    370     eta = (cosTheta == 1.0 ? signz * 999.9 : momentum.Eta());
    371     rapidity = (cosTheta == 1.0 ? signz * 999.9 : momentum.Rapidity());
     375    eta = (cosTheta == 1.0 ? signz*999.9 : momentum.Eta());
     376    rapidity = (cosTheta == 1.0 ? signz*999.9 : momentum.Rapidity());
    372377
    373378    entry->P = p;
    374     entry->PT = pt;
     379    entry->PT  = pt;
    375380    entry->Eta = eta;
    376381    entry->Phi = phi;
    377382    entry->CtgTheta = ctgTheta;
    378383
    379     particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0));
     384    particle = static_cast<Candidate*>(candidate->GetCandidates()->At(0));
    380385    const TLorentzVector &initialPosition = particle->Position;
    381386
     
    383388    entry->Y = initialPosition.Y();
    384389    entry->Z = initialPosition.Z();
    385     entry->T = initialPosition.T() * 1.0E-3 / c_light;
     390    entry->T = initialPosition.T()*1.0E-3/c_light;
    386391
    387392    entry->Particle = particle;
    388393
    389394    entry->VertexIndex = candidate->ClusterIndex;
     395
    390396  }
    391397}
     
    403409  // loop over all towers
    404410  iterator.Reset();
    405   while((candidate = static_cast<Candidate *>(iterator.Next())))
     411  while((candidate = static_cast<Candidate*>(iterator.Next())))
    406412  {
    407413    const TLorentzVector &momentum = candidate->Momentum;
     
    411417    cosTheta = TMath::Abs(momentum.CosTheta());
    412418    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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());
    417423
    418424    entry->SetBit(kIsReferenced);
     
    430436    entry->Edges[3] = candidate->Edges[3];
    431437
    432     entry->T = position.T() * 1.0E-3 / c_light;
     438    entry->T = position.T()*1.0E-3/c_light;
    433439    entry->NTimeHits = candidate->NTimeHits;
    434440
     
    451457  // loop over all photons
    452458  iterator.Reset();
    453   while((candidate = static_cast<Candidate *>(iterator.Next())))
     459  while((candidate = static_cast<Candidate*>(iterator.Next())))
    454460  {
    455461    TIter it1(candidate->GetCandidates());
     
    460466    cosTheta = TMath::Abs(momentum.CosTheta());
    461467    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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());
    466472
    467473    entry->Eta = eta;
     
    469475    entry->PT = pt;
    470476    entry->E = momentum.E();
    471     entry->T = position.T() * 1.0E-3 / c_light;
     477    entry->T = position.T()*1.0E-3/c_light;
    472478
    473479    // Isolation variables
    474480
    475481    entry->IsolationVar = candidate->IsolationVar;
    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;
     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;
    483489
    484490    // 1: prompt -- 2: non prompt -- 3: fake
     
    503509  // loop over all electrons
    504510  iterator.Reset();
    505   while((candidate = static_cast<Candidate *>(iterator.Next())))
     511  while((candidate = static_cast<Candidate*>(iterator.Next())))
    506512  {
    507513    const TLorentzVector &momentum = candidate->Momentum;
     
    511517    cosTheta = TMath::Abs(momentum.CosTheta());
    512518    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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());
    517523
    518524    entry->Eta = eta;
     
    520526    entry->PT = pt;
    521527
    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;
     528    entry->T = position.T()*1.0E-3/c_light;
    529529
    530530    // Isolation variables
     531
    531532    entry->IsolationVar = candidate->IsolationVar;
    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;
     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
    537539
    538540    entry->Charge = candidate->Charge;
     
    559561  // loop over all muons
    560562  iterator.Reset();
    561   while((candidate = static_cast<Candidate *>(iterator.Next())))
     563  while((candidate = static_cast<Candidate*>(iterator.Next())))
    562564  {
    563565    const TLorentzVector &momentum = candidate->Momentum;
     
    567569    cosTheta = TMath::Abs(momentum.CosTheta());
    568570    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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());
    573575
    574576    entry->SetBit(kIsReferenced);
     
    579581    entry->PT = pt;
    580582
    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;
     583    entry->T = position.T()*1.0E-3/c_light;
    588584
    589585    // Isolation variables
    590586
    591587    entry->IsolationVar = candidate->IsolationVar;
    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;
     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 ;
    597593
    598594    entry->Charge = candidate->Charge;
     
    618614  // loop over all jets
    619615  iterator.Reset();
    620   while((candidate = static_cast<Candidate *>(iterator.Next())))
     616  while((candidate = static_cast<Candidate*>(iterator.Next())))
    621617  {
    622618    TIter itConstituents(candidate->GetCandidates());
     
    628624    cosTheta = TMath::Abs(momentum.CosTheta());
    629625    signPz = (momentum.Pz() >= 0.0) ? 1.0 : -1.0;
    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());
     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());
    634630
    635631    entry->Eta = eta;
     
    637633    entry->PT = pt;
    638634
    639     entry->T = position.T() * 1.0E-3 / c_light;
     635    entry->T = position.T()*1.0E-3/c_light;
    640636
    641637    entry->Mass = momentum.M();
     
    664660    ecalEnergy = 0.0;
    665661    hcalEnergy = 0.0;
    666     while((constituent = static_cast<Candidate *>(itConstituents.Next())))
     662    while((constituent = static_cast<Candidate*>(itConstituents.Next())))
    667663    {
    668664      entry->Constituents.Add(constituent);
     
    671667    }
    672668
    673     entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy / ecalEnergy : 999.9;
     669    entry->EhadOverEem = ecalEnergy > 0.0 ? hcalEnergy/ecalEnergy : 999.9;
    674670
    675671    //---   Pile-Up Jet ID variables ----
     
    688684    entry->NSubJetsSoftDropped = candidate->NSubJetsSoftDropped;
    689685
    690     entry->SoftDroppedJet = candidate->SoftDroppedJet;
    691     entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1;
     686    entry->SoftDroppedJet     = candidate->SoftDroppedJet ;
     687    entry->SoftDroppedSubJet1 = candidate->SoftDroppedSubJet1 ;
    692688    entry->SoftDroppedSubJet2 = candidate->SoftDroppedSubJet2;
     689
    693690
    694691    for(i = 0; i < 5; i++)
    695692    {
    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];
     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];
    701698    }
    702699
     
    705702    entry->ExclYmerge34 = candidate->ExclYmerge34;
    706703    entry->ExclYmerge45 = candidate->ExclYmerge45;
    707     entry->ExclYmerge56 = candidate->ExclYmerge56;
     704    entry->ExclYmerge56 = candidate->ExclYmerge56;   
     705
    708706
    709707    FillParticles(candidate, &entry->Particles);
     
    719717
    720718  // get the first entry
    721   if((candidate = static_cast<Candidate *>(array->At(0))))
    722   {
    723     const TLorentzVector &momentum = candidate->Momentum;
    724 
    725     entry = static_cast<MissingET *>(branch->NewEntry());
     719  if((candidate = static_cast<Candidate*>(array->At(0))))
     720  {
     721    const TLorentzVector &momentum = candidate->Momentum;
     722
     723    entry = static_cast<MissingET*>(branch->NewEntry());
    726724
    727725    entry->Eta = (-momentum).Eta();
     
    739737
    740738  // get the first entry
    741   if((candidate = static_cast<Candidate *>(array->At(0))))
    742   {
    743     const TLorentzVector &momentum = candidate->Momentum;
    744 
    745     entry = static_cast<ScalarHT *>(branch->NewEntry());
     739  if((candidate = static_cast<Candidate*>(array->At(0))))
     740  {
     741    const TLorentzVector &momentum = candidate->Momentum;
     742
     743    entry = static_cast<ScalarHT*>(branch->NewEntry());
    746744
    747745    entry->HT = momentum.Pt();
     
    759757  // loop over all rho
    760758  iterator.Reset();
    761   while((candidate = static_cast<Candidate *>(iterator.Next())))
    762   {
    763     const TLorentzVector &momentum = candidate->Momentum;
    764 
    765     entry = static_cast<Rho *>(branch->NewEntry());
     759  while((candidate = static_cast<Candidate*>(iterator.Next())))
     760  {
     761    const TLorentzVector &momentum = candidate->Momentum;
     762
     763    entry = static_cast<Rho*>(branch->NewEntry());
    766764
    767765    entry->Rho = momentum.E();
     
    779777
    780778  // get the first entry
    781   if((candidate = static_cast<Candidate *>(array->At(0))))
    782   {
    783     const TLorentzVector &momentum = candidate->Momentum;
    784 
    785     entry = static_cast<Weight *>(branch->NewEntry());
     779  if((candidate = static_cast<Candidate*>(array->At(0))))
     780  {
     781    const TLorentzVector &momentum = candidate->Momentum;
     782
     783    entry = static_cast<Weight*>(branch->NewEntry());
    786784
    787785    entry->Weight = momentum.E();
     
    799797  // loop over all roman pot hits
    800798  iterator.Reset();
    801   while((candidate = static_cast<Candidate *>(iterator.Next())))
     799  while((candidate = static_cast<Candidate*>(iterator.Next())))
    802800  {
    803801    const TLorentzVector &position = candidate->Position;
    804802    const TLorentzVector &momentum = candidate->Momentum;
    805803
    806     entry = static_cast<HectorHit *>(branch->NewEntry());
     804    entry = static_cast<HectorHit*>(branch->NewEntry());
    807805
    808806    entry->E = momentum.E();
  • modules/TreeWriter.h

    r0e7d64a re39abb4  
    4242{
    4343public:
     44
    4445  TreeWriter();
    4546  ~TreeWriter();
     
    5051
    5152private:
     53
    5254  void FillParticles(Candidate *candidate, TRefArray *array);
    5355
     
    7072  typedef void (TreeWriter::*TProcessMethod)(ExRootTreeBranch *, TObjArray *); //!
    7173
    72   typedef std::map<ExRootTreeBranch *, std::pair<TProcessMethod, TObjArray *> > TBranchMap; //!
     74  typedef std::map< ExRootTreeBranch *, std::pair< TProcessMethod, TObjArray * > > TBranchMap; //!
    7375
    7476  TBranchMap fBranchMap; //!
    7577
    76   std::map<TClass *, TProcessMethod> fClassMap; //!
     78  std::map< TClass *, TProcessMethod > fClassMap; //!
    7779#endif
    7880
  • modules/UniqueObjectFinder.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class UniqueObjectFinder
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    45 #include <algorithm>
     46#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    6667void UniqueObjectFinder::Init()
    6768{
    68   // use GetUniqueID algorithm to find unique objects (faster than the default Overlaps method)
    69   fUseUniqueID = GetBool("UseUniqueID", false);
    70 
    7169  // import arrays with output from other modules
    7270
     
    7977
    8078  size = param.GetSize();
    81   for(i = 0; i < size / 2; ++i)
     79  for(i = 0; i < size/2; ++i)
    8280  {
    83     array = ImportArray(param[i * 2].GetString());
     81    array = ImportArray(param[i*2].GetString());
    8482    iterator = array->MakeIterator();
    8583
    86     fInputMap.push_back(make_pair(iterator, ExportArray(param[i * 2 + 1].GetString())));
     84    fInputMap.push_back(make_pair(iterator, ExportArray(param[i*2 + 1].GetString())));
    8785  }
    8886}
     
    9290void UniqueObjectFinder::Finish()
    9391{
    94   vector<pair<TIterator *, TObjArray *> >::iterator itInputMap;
     92  vector< pair< TIterator *, TObjArray * > >::iterator itInputMap;
    9593  TIterator *iterator;
    9694
     
    108106{
    109107  Candidate *candidate;
    110   vector<pair<TIterator *, TObjArray *> >::iterator itInputMap;
     108  vector< pair< TIterator *, TObjArray * > >::iterator itInputMap;
    111109  TIterator *iterator;
    112110  TObjArray *array;
     
    120118    // loop over all candidates
    121119    iterator->Reset();
    122     while((candidate = static_cast<Candidate *>(iterator->Next())))
     120    while((candidate = static_cast<Candidate*>(iterator->Next())))
    123121    {
    124122      if(Unique(candidate, itInputMap))
     
    132130//------------------------------------------------------------------------------
    133131
    134 Bool_t UniqueObjectFinder::Unique(Candidate *candidate, vector<pair<TIterator *, TObjArray *> >::iterator itInputMap)
     132Bool_t UniqueObjectFinder::Unique(Candidate *candidate, vector< pair< TIterator *, TObjArray * > >::iterator itInputMap)
    135133{
    136134  Candidate *previousCandidate;
    137   vector<pair<TIterator *, TObjArray *> >::iterator previousItInputMap;
     135  vector< pair< TIterator *, TObjArray * > >::iterator previousItInputMap;
    138136  TObjArray *array;
    139137
     
    146144    // loop over all candidates
    147145    iterator.Reset();
    148     while((previousCandidate = static_cast<Candidate *>(iterator.Next())))
     146    while((previousCandidate = static_cast<Candidate*>(iterator.Next())))
    149147    {
    150       if(fUseUniqueID)
     148      if(candidate->Overlaps(previousCandidate))
    151149      {
    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         }
     150        return kFALSE;
    163151      }
    164152    }
  • modules/UniqueObjectFinder.h

    r0e7d64a re39abb4  
    3030#include "classes/DelphesModule.h"
    3131
     32#include <vector>
    3233#include <utility>
    33 #include <vector>
    3434
    3535class TIterator;
     
    4040{
    4141public:
     42
    4243  UniqueObjectFinder();
    4344  ~UniqueObjectFinder();
     
    4849
    4950private:
    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

    r0e7d64a re39abb4  
    77 */
    88
     9
    910#include "modules/VertexFinder.h"
    1011#include "classes/DelphesClasses.h"
     
    1314#include "classes/DelphesPileUpReader.h"
    1415
     16#include "ExRootAnalysis/ExRootResult.h"
     17#include "ExRootAnalysis/ExRootFilter.h"
    1518#include "ExRootAnalysis/ExRootClassifier.h"
    16 #include "ExRootAnalysis/ExRootFilter.h"
    17 #include "ExRootAnalysis/ExRootResult.h"
    18 
     19
     20#include "TMath.h"
     21#include "TString.h"
     22#include "TFormula.h"
     23#include "TRandom3.h"
     24#include "TObjArray.h"
    1925#include "TDatabasePDG.h"
    20 #include "TFormula.h"
    2126#include "TLorentzVector.h"
    22 #include "TMath.h"
    2327#include "TMatrixT.h"
    24 #include "TObjArray.h"
    25 #include "TRandom3.h"
    26 #include "TString.h"
    2728#include "TVector3.h"
    2829
     30#include <utility>
    2931#include <algorithm>
     32#include <stdexcept>
    3033#include <iostream>
     34#include <vector>
    3135#include <map>
    32 #include <stdexcept>
    3336#include <string>
    34 #include <utility>
    35 #include <vector>
    3637
    3738using namespace std;
    3839
    39 static const Double_t mm = 1.;
    40 static const Double_t m = 1000. * mm;
    41 static const Double_t ns = 1.;
    42 static const Double_t s = 1.e+9 * ns;
    43 static const Double_t c_light = 2.99792458e+8 * m / s;
     40static const Double_t mm  = 1.;
     41static const Double_t m = 1000.*mm;
     42static const Double_t ns  = 1.;
     43static const Double_t s = 1.e+9 *ns;
     44static const Double_t c_light   = 2.99792458e+8 * m/s;
    4445
    4546//------------------------------------------------------------------------------
     
    8384//------------------------------------------------------------------------------
    8485
    85 static Bool_t secondAscending(pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     86static Bool_t secondAscending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    8687{
    8788  return (pair0.second < pair1.second);
    8889}
    8990
    90 static Bool_t secondDescending(pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
     91static Bool_t secondDescending (pair<UInt_t, Double_t> pair0, pair<UInt_t, Double_t> pair1)
    9192{
    9293  return (pair0.second > pair1.second);
     
    100101
    101102  // Clear the track and cluster maps before starting
    102   trackIDToDouble.clear();
    103   trackIDToInt.clear();
    104   trackIDToBool.clear();
    105   clusterIDToDouble.clear();
    106   clusterIDToInt.clear();
    107   clusterIDToBool.clear();
    108   trackPT.clear();
    109   clusterSumPT2.clear();
     103  trackIDToDouble.clear ();
     104  trackIDToInt.clear ();
     105  trackIDToBool.clear ();
     106  clusterIDToDouble.clear ();
     107  clusterIDToInt.clear ();
     108  clusterIDToBool.clear ();
     109  trackPT.clear ();
     110  clusterSumPT2.clear ();
    110111
    111112  // Create the initial cluster seeds
    112   createSeeds();
     113  createSeeds ();
    113114
    114115  // In order of descending seed pt, grow each cluster. If a cluster ends up with
    115116  // fewer than MinNDF tracks, release the tracks for other clusters to claim.
    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   }
     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    }
    143144
    144145  // Add tracks to the output array after updating their ClusterIndex.
    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   }
     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    }
    153154
    154155  // Add clusters with at least MinNDF tracks to the output array in order of
    155156  // descending sum(pt**2).
    156   clusterSumPT2.clear();
    157   for(map<UInt_t, map<string, Int_t> >::const_iterator cluster = clusterIDToInt.begin(); cluster != clusterIDToInt.end(); cluster++)
     157  clusterSumPT2.clear ();
     158  for (map<UInt_t, map<string, Int_t> >::const_iterator cluster = clusterIDToInt.begin (); cluster != clusterIDToInt.end (); cluster++)
    158159  {
    159 
    160     if(cluster->second.at("ndf") < fMinNDF)
     160   
     161    if (cluster->second.at ("ndf") < fMinNDF)
    161162      continue;
    162     clusterSumPT2.push_back(make_pair(cluster->first, clusterIDToDouble.at(cluster->first).at("sumPT2")));
     163    clusterSumPT2.push_back (make_pair (cluster->first, clusterIDToDouble.at (cluster->first).at ("sumPT2")));
    163164  }
    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++)
     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++)
    167168  {
    168169    DelphesFactory *factory = GetFactory();
     
    170171
    171172    candidate->ClusterIndex = cluster->first;
    172     candidate->ClusterNDF = clusterIDToInt.at(cluster->first).at("ndf");
     173    candidate->ClusterNDF = clusterIDToInt.at (cluster->first).at ("ndf");
    173174    candidate->ClusterSigma = fSigma;
    174175    candidate->SumPT2 = cluster->second;
    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);
     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);
    177178
    178179    fVertexOutputArray->Add(candidate);
     
    182183//------------------------------------------------------------------------------
    183184
    184 void VertexFinder::createSeeds()
     185void VertexFinder::createSeeds ()
    185186{
    186187  Candidate *candidate;
     
    189190  // Loop over all tracks, initializing some variables.
    190191  fItInputArray->Reset();
    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   }
     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    }
    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())
    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)
     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)
     270                {
     271                  nearestID = track->first;
     272                  nearestDistance = distance;
     273                }
     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)
     287                {
     288                  nearestID = *track;
     289                  nearestDistance = distance;
     290                }
     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        {
    266298          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       }
    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)
    287         {
    288           nearestID = *track;
    289           nearestDistance = distance;
    290         }
    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 
    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);
     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

    r0e7d64a re39abb4  
    1010 */
    1111
     12
    1213#include "classes/DelphesModule.h"
    1314
    14 #include <map>
    1515#include <string>
    1616#include <vector>
     17#include <map>
    1718
    1819class TObjArray;
     
    2223{
    2324public:
     25
    2426  VertexFinder();
    2527  ~VertexFinder();
     
    3032
    3133private:
    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);
     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);
    3740
    3841  Double_t fSigma;
  • modules/VertexFinderDA4D.cc

    r0e7d64a re39abb4  
    77 */
    88
     9
    910#include "modules/VertexFinderDA4D.h"
    1011#include "classes/DelphesClasses.h"
     
    1314#include "classes/DelphesPileUpReader.h"
    1415
     16#include "ExRootAnalysis/ExRootResult.h"
     17#include "ExRootAnalysis/ExRootFilter.h"
    1518#include "ExRootAnalysis/ExRootClassifier.h"
    16 #include "ExRootAnalysis/ExRootFilter.h"
    17 #include "ExRootAnalysis/ExRootResult.h"
    18 
     19
     20#include "TMath.h"
     21#include "TString.h"
     22#include "TFormula.h"
     23#include "TRandom3.h"
     24#include "TObjArray.h"
    1925#include "TDatabasePDG.h"
    20 #include "TFormula.h"
    2126#include "TLorentzVector.h"
    22 #include "TMath.h"
    2327#include "TMatrixT.h"
    24 #include "TObjArray.h"
    25 #include "TRandom3.h"
    26 #include "TString.h"
    2728#include "TVector3.h"
    2829
     30#include <utility>
    2931#include <algorithm>
     32#include <stdexcept>
    3033#include <iostream>
    31 #include <stdexcept>
    32 #include <utility>
    3334#include <vector>
    3435
    3536using namespace std;
    3637
    37 static const Double_t mm = 1.;
    38 static const Double_t m = 1000. * mm;
    39 static const Double_t ns = 1.;
    40 static const Double_t s = 1.e+9 * ns;
    41 static const Double_t c_light = 2.99792458e+8 * m / s;
     38static const Double_t mm  = 1.;
     39static const Double_t m = 1000.*mm;
     40static const Double_t ns  = 1.;
     41static const Double_t s = 1.e+9 *ns;
     42static const Double_t c_light   = 2.99792458e+8 * m/s;
    4243
    4344struct track_t
    4445{
    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)
     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)
    5051  Candidate *tt; // a pointer to the Candidate Track
    51   double Z; // Z[i]   for DA clustering
    52   double pi; // track weight
     52  double Z;      // Z[i]   for DA clustering
     53  double pi;     // track weight
    5354  double pt;
    5455  double eta;
     
    6061  double z;
    6162  double t;
    62   double pk; // vertex weight for "constrained" clustering
     63  double pk;     // vertex weight for "constrained" clustering
    6364  // --- temporary numbers, used during update
    6465  double ei;
     
    7576static double update1(double beta, std::vector<track_t> &tks, std::vector<vertex_t> &y);
    7677static double update2(double beta, std::vector<track_t> &tks, std::vector<vertex_t> &y, double &rho0, const double dzCutOff);
    77 static void dump(const double beta, const std::vector<vertex_t> &y, const std::vector<track_t> &tks);
     78static void dump(const double beta, const std::vector<vertex_t> & y, const std::vector<track_t> & tks);
    7879static bool merge(std::vector<vertex_t> &);
    7980static bool merge(std::vector<vertex_t> &, double &);
    80 static bool purge(std::vector<vertex_t> &, std::vector<track_t> &, double &, const double, const double);
     81static bool purge(std::vector<vertex_t> &, std::vector<track_t> & , double &, const double, const double);
    8182static void splitAll(std::vector<vertex_t> &y);
    8283static double beta0(const double betamax, std::vector<track_t> &tks, std::vector<vertex_t> &y, const double coolingFactor);
    8384static double Eik(const track_t &t, const vertex_t &k);
    8485
    85 static bool recTrackLessZ1(const track_t &tk1, const track_t &tk2)
     86static bool recTrackLessZ1(const track_t & tk1, const track_t & tk2)
    8687{
    8788  return tk1.z < tk2.z;
     
    114115  fVertexSpaceSize = GetDouble("VertexSpaceSize", 0.5); //in mm
    115116  fVertexTimeSize = GetDouble("VertexTimeSize", 10E-12); //in s
    116   fUseTc = GetBool("UseTc", 1);
    117   fBetaMax = GetDouble("BetaMax ", 0.1);
    118   fBetaStop = GetDouble("BetaStop", 1.0);
     117  fUseTc         = GetBool("UseTc", 1);
     118  fBetaMax       = GetDouble("BetaMax ", 0.1);
     119  fBetaStop      = GetDouble("BetaStop", 1.0);
    119120  fCoolingFactor = GetDouble("CoolingFactor", 0.8);
    120121  fMaxIterations = GetInt("MaxIterations", 100);
    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
     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
    124125
    125126  // convert stuff in cm, ns
    126127  fVertexSpaceSize /= 10.0;
    127128  fVertexTimeSize *= 1E9;
    128   fDzCutOff /= 10.0; // Adaptive Fitter uses 3.0 but that appears to be a bit tight here sometimes
    129   fD0CutOff /= 10.0;
     129  fDzCutOff       /= 10.0;  // Adaptive Fitter uses 3.0 but that appears to be a bit tight here sometimes
     130  fD0CutOff       /= 10.0;
    130131
    131132  fInputArray = ImportArray(GetString("InputArray", "TrackSmearing/tracks"));
     
    156157
    157158  TLorentzVector pos, mom;
    158   if(fVerbose)
     159  if (fVerbose)
    159160  {
    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     }
     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     }
    171172  }
    172173
     
    174175  clusterize(*fInputArray, *ClusterArray);
    175176
    176   if(fVerbose)
    177   {
    178     std::cout << " clustering returned  " << ClusterArray->GetEntriesFast() << " clusters  from " << fInputArray->GetEntriesFast() << " selected tracks" << std::endl;
    179   }
     177  if (fVerbose){std::cout <<  " clustering returned  "<< ClusterArray->GetEntriesFast() << " clusters  from " << fInputArray->GetEntriesFast() << " selected tracks" <<std::endl;}
    180178
    181179  //loop over vertex candidates
    182180  ItClusterArray = ClusterArray->MakeIterator();
    183181  ItClusterArray->Reset();
    184   while((candidate = static_cast<Candidate *>(ItClusterArray->Next())))
     182  while((candidate = static_cast<Candidate*>(ItClusterArray->Next())))
    185183  {
    186184
    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){
     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){
    280278      sort(pvs.begin(), pvs.end(), VertexHigherPtSquared());
    281279    }
     
    283281
    284282  delete ClusterArray;
     283
    285284}
    286285
     
    289288void VertexFinderDA4D::clusterize(const TObjArray &tracks, TObjArray &clusters)
    290289{
    291   if(fVerbose)
    292   {
     290  if(fVerbose) {
    293291    cout << "###################################################" << endl;
    294     cout << "# VertexFinderDA4D::clusterize   nt=" << tracks.GetEntriesFast() << endl;
     292    cout << "# VertexFinderDA4D::clusterize   nt="<<tracks.GetEntriesFast() << endl;
    295293    cout << "###################################################" << endl;
    296294  }
    297295
    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   }
     296  vector< Candidate* > pv = vertices();
     297
     298  if(fVerbose){ cout << "# VertexFinderDA4D::clusterize   pv.size="<<pv.size() << endl;  }
     299  if (pv.size()==0){ return;  }
    308300
    309301  // convert into vector of candidates
    310302  //TObjArray *ClusterArray = pv.begin()->GetCandidates();
    311303  //Candidate *aCluster = static_cast<Candidate*>(&(pv.at(0)));
    312   Candidate *aCluster = pv.at(0);
     304   Candidate *aCluster = pv.at(0);
    313305
    314306  // fill into clusters and merge
    315307
    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);
     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);
    327317      std::cout << ' ' << (*k)->Position.Z() << ' ' << (*k)->Position.T() << std::endl;
    328318    }
    329319
     320
    330321    // TBC - check units here
    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     {
     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 ) {
    333324      // close a cluster
    334325      clusters.Add(aCluster);
     
    336327    }
    337328    //for(unsigned int i=0; i<k->GetCandidates().GetEntriesFast(); i++){
    338     aCluster = *k;
     329      aCluster = *k;
    339330    //}
     331
    340332  }
    341333  clusters.Add(aCluster);
    342334
    343   if(fVerbose)
    344   {
    345     std::cout << "# VertexFinderDA4D::clusterize clusters.size=" << clusters.GetEntriesFast() << std::endl;
    346   }
    347 }
    348 
    349 //------------------------------------------------------------------------------
    350 
    351 vector<Candidate *> VertexFinderDA4D::vertices()
     335  if(fVerbose) { std::cout << "# VertexFinderDA4D::clusterize clusters.size="<<clusters.GetEntriesFast() << std::endl; }
     336
     337}
     338
     339//------------------------------------------------------------------------------
     340
     341vector< Candidate* > VertexFinderDA4D::vertices()
    352342{
    353343  Candidate *candidate;
    354344  UInt_t clusterIndex = 0;
    355   vector<Candidate *> clusters;
     345  vector< Candidate* > clusters;
    356346
    357347  vector<track_t> tks;
     
    361351  // loop over input tracks
    362352  fItInputArray->Reset();
    363   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     353  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    364354  {
    365355    //TBC everything in cm
    366     z = candidate->DZ / 10;
     356    z = candidate->DZ/10;
    367357    tr.z = z;
    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
     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
    373363
    374364    // TBC: the time is in ns for now TBC
    375365    //t = candidate->Position.T()/c_light;
    376     t = candidate->InitialPosition.T() / c_light;
    377     l = candidate->L / c_light;
     366    t = candidate->InitialPosition.T()/c_light;
     367    l = candidate->L/c_light;
    378368    double pt = candidate->Momentum.Pt();
    379369    double eta = candidate->Momentum.Eta();
     
    385375    tr.t = t; //
    386376    tr.dtz = 0.;
    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)
     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)
    390380    {
    391381
    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
     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
    396387    }
    397388    else
    398389    {
    399       tr.pi = 1.;
    400     }
    401     tr.tt = &(*candidate);
    402     tr.Z = 1.;
     390      tr.pi=1.;
     391    }
     392    tr.tt=&(*candidate);
     393    tr.Z=1.;
    403394
    404395    // TBC now putting track selection here (> fPTMin)
     
    413404  if(fVerbose)
    414405  {
    415     std::cout << " start processing vertices ..." << std::endl;
    416     std::cout << " Found " << tks.size() << " input tracks" << std::endl;
     406    std::cout<<" start processing vertices ..."<<std::endl;
     407    std::cout<<" Found "<<tks.size()<<" input tracks"<<std::endl;
    417408    //loop over input tracks
    418409
    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;
     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;
    435426
    436427  vector<vertex_t> y; // the vertex prototypes
     
    438429  // initialize:single vertex at infinite temperature
    439430  vertex_t vstart;
    440   vstart.z = 0.;
    441   vstart.t = 0.;
    442   vstart.pk = 1.;
     431  vstart.z=0.;
     432  vstart.t=0.;
     433  vstart.pk=1.;
    443434  y.push_back(vstart);
    444   int niter = 0; // number of iterations
     435  int niter=0;      // number of iterations
    445436
    446437  // estimate first critical temperature
    447   double beta = beta0(fBetaMax, tks, y, fCoolingFactor);
    448   niter = 0;
    449   while((update1(beta, tks, y) > 1.e-6) && (niter++ < fMaxIterations))
    450   {
    451   }
     438  double beta=beta0(fBetaMax, tks, y, fCoolingFactor);
     439  niter=0; while((update1(beta, tks,y)>1.e-6)  && (niter++ < fMaxIterations)){ }
    452440
    453441  // annealing loop, stop when T<Tmin  (i.e. beta>1/Tmin)
    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;
     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;
    470451      splitAll(y);
    471452    }
    472453
    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   {
     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){
    482460    // last round of splitting, make sure no critical clusters are left
    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   {
     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{
    501471    // merge collapsed clusters
    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     }
     472    while(merge(y,beta)){update1(beta, tks,y);}
     473    if(fVerbose ){ cout << "dump after 1st merging " << endl;  dump(beta,y,tks);}
    511474  }
    512475
    513476  // switch on outlier rejection
    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   }
     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
    528481
    529482  // merge again  (some cluster split by outliers collapse here)
    530   while(merge(y))
    531   {
    532   }
    533   if(fVerbose)
    534   {
    535     cout << "dump after 2nd merging " << endl;
    536     dump(beta, y, tks);
    537   }
     483  while(merge(y)){}
     484  if(fVerbose  ){ cout << "dump after 2nd merging " << endl;  dump(beta,y,tks);}
     485
    538486
    539487  // continue from freeze-out to Tstop (=1) without splitting, eliminate insignificant vertices
    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   }
     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
    566508
    567509  // select significant tracks and use a TransientVertex as a container
     
    569511
    570512  // ensure correct normalization of probabilities, should make double assginment reasonably impossible
    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   {
     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++){
    582521
    583522    DelphesFactory *factory = GetFactory();
     
    593532    double expv_x2 = 0.;
    594533    double normw = 0.;
    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         {
     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 ) ){
    603539          //std::cout << "pushing back " << i << ' ' << tks[i].tt << std::endl;
    604540          //vertexTracks.push_back(*(tks[i].tt)); tks[i].Z=0;
    605541
    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;
     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;
    612547        } // setting Z=0 excludes double assignment
    613548      }
    614549    }
    615550
    616     mean = mean / normw;
    617     expv_x2 = expv_x2 / normw;
    618     const double time_var = expv_x2 - mean * mean;
     551    mean = mean/normw;
     552    expv_x2 = expv_x2/normw;
     553    const double time_var = expv_x2 - mean*mean;
    619554    const double crappy_error_guess = std::sqrt(time_var);
    620555    /*GlobalError dummyErrorWithTime(0,
     
    624559    //TransientVertex v(pos, time, dummyErrorWithTime, vertexTracks, 5);
    625560
    626     candidate->ClusterIndex = clusterIndex++;
    627     ;
    628     candidate->Position.SetXYZT(0.0, 0.0, z * 10.0, time * c_light);
     561
     562    candidate->ClusterIndex = clusterIndex++;;
     563    candidate->Position.SetXYZT(0.0, 0.0, z*10.0 , time*c_light);
    629564
    630565    // TBC - fill error later ...
    631     candidate->PositionError.SetXYZT(0.0, 0.0, 0.0, crappy_error_guess * c_light);
     566    candidate->PositionError.SetXYZT(0.0, 0.0, 0.0 , crappy_error_guess*c_light);
    632567
    633568    clusterIndex++;
     
    635570  }
    636571
     572
    637573  return clusters;
    638 }
    639 
    640 //------------------------------------------------------------------------------
    641 
    642 static 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;
     574
     575}
     576
     577//------------------------------------------------------------------------------
     578
     579static 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;
    645582}
    646583
     
    651588  // copy and sort for nicer printout
    652589  vector<track_t> tks;
    653   for(vector<track_t>::const_iterator t = tks0.begin(); t != tks0.end(); t++)
    654   {
    655     tks.push_back(*t);
    656   }
     590  for(vector<track_t>::const_iterator t=tks0.begin(); t!=tks0.end(); t++){tks.push_back(*t); }
    657591  std::stable_sort(tks.begin(), tks.end(), recTrackLessZ1);
    658592
     
    661595  cout << "                                                               z= ";
    662596  cout.precision(4);
    663   for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
    664   {
     597  for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
    665598    //cout  <<  setw(8) << fixed << k->z;
    666599  }
    667   cout << endl
    668        << "                                                               t= ";
    669   for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
    670   {
     600  cout << endl << "                                                               t= ";
     601  for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
    671602    //cout  <<  setw(8) << fixed << k->t;
    672603  }
    673604  //cout << endl << "T=" << setw(15) << 1./beta <<"                                             Tc= ";
    674   for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
    675   {
     605  for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
    676606    //cout  <<  setw(8) << fixed << k->Tc ;
    677607  }
    678608
    679   cout << endl
    680        << "                                                              pk=";
    681   double sumpk = 0;
    682   for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++)
    683   {
     609  cout << endl << "                                                              pk=";
     610  double sumpk=0;
     611  for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
    684612    //cout <<  setw(8) <<  setprecision(3) <<  fixed << k->pk;
    685     sumpk += k->pk;
    686   }
    687   cout << endl;
    688 
    689   double E = 0, F = 0;
     613    sumpk+=k->pk;
     614  }
     615  cout  << endl;
     616
     617  double E=0, F=0;
    690618  cout << endl;
    691619  cout << "----       z +/- dz        t +/- dt        ip +/-dip       pt    phi  eta    weights  ----" << endl;
    692620  cout.precision(4);
    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;
     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;
    701625    //cout <<  setw (3)<< i << ")" <<  setw (8) << fixed << setprecision(4)<<  tz << " +/-" <<  setw (6)<< sqrt(tks[i].dz2)
    702626    //     << setw(8) << fixed << setprecision(4) << tt << " +/-" << setw(6) << std::sqrt(tks[i].dt2)  ;
    703627
    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;
     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  }
    721643      }
    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;
     644      cout << endl;
     645    }
     646    cout << endl << "T=" << 1/beta  << " E=" << E << " n="<< y.size() << "  F= " << F <<  endl <<  "----------" << endl;
    732647}
    733648
     
    740655  // returns the squared sum of changes of vertex positions
    741656
    742   unsigned int nt = tks.size();
     657  unsigned int nt=tks.size();
    743658
    744659  //initialize sums
    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   }
     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
    755666
    756667  // loop over tracks
    757   for(unsigned int i = 0; i < nt; i++)
    758   {
     668  for(unsigned int i=0; i<nt; i++){
    759669
    760670    // update pik and Zi
    761671    double Zi = 0.;
    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;
     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;
    768677
    769678    // normalization for pk
    770     if(tks[i].Z > 0)
    771     {
     679    if (tks[i].Z>0){
    772680      sumpi += tks[i].pi;
    773681      // accumulate weighted z and weights for vertex update
    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;
     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;
    780687        k->swt += w * tks[i].t;
    781         k->swE += w * Eik(tks[i], *k);
     688  k->swE += w * Eik(tks[i],*k);
    782689      }
    783     }
    784     else
    785     {
     690    }else{
    786691      sumpi += tks[i].pi;
    787692    }
    788693
     694
    789695  } // end of track loop
    790696
     697
    791698  // now update z and pk
    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     {
     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{
    806709      // cout << " a cluster melted away ?  pk=" << k->pk <<  " sumw=" << k->sw <<  endl
    807       k->Tc = -1;
     710      k->Tc=-1;
    808711    }
    809712
     
    822725  // returns the squared sum of changes of vertex positions
    823726
    824   unsigned int nt = tks.size();
     727  unsigned int nt=tks.size();
    825728
    826729  //initialize sums
    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   }
     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
    836735
    837736  // loop over tracks
    838   for(unsigned int i = 0; i < nt; i++)
    839   {
     737  for(unsigned int i=0; i<nt; i++){
    840738
    841739    // update pik and Zi and Ti
    842     double Zi = rho0 * std::exp(-beta * (dzCutOff * dzCutOff)); // cut-off (eventually add finite size in time)
     740    double Zi = rho0*std::exp(-beta*(dzCutOff*dzCutOff));// cut-off (eventually add finite size in time)
    843741    //double Ti = 0.; // dt0*std::exp(-beta*fDtCutOff);
    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;
     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;
    850747
    851748    // normalization
    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;
     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;
    861756        k->swt += w * tks[i].t;
    862         k->swE += w * Eik(tks[i], *k);
     757  k->swE += w * Eik(tks[i],*k);
    863758      }
    864759    }
     
    867762
    868763  // now update z
    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     {
     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{
    883774      // cout << " a cluster melted away ?  pk=" << k->pk <<  " sumw=" << k->sw <<  endl;
    884775      k->Tc = 0;
    885776    }
     777
    886778  }
    887779
     
    896788  // merge clusters that collapsed or never separated, return true if vertices were merged, false otherwise
    897789
    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);
     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);
    914802      }
    915803      k->pk = rho;
    916804
    917       y.erase(k + 1);
     805      y.erase(k+1);
    918806      return true;
    919807    }
     
    930818  // only merge if the estimated critical temperature of the merged vertex is below the current temperature
    931819  // return true if vertices were merged, false otherwise
    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;
     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;
    960844      }
    961845    }
     
    967851//------------------------------------------------------------------------------
    968852
    969 static bool purge(vector<vertex_t> &y, vector<track_t> &tks, double &rho0, const double beta, const double dzCutOff)
     853static bool purge(vector<vertex_t> &y, vector<track_t> &tks, double & rho0, const double beta, const double dzCutOff)
    970854{
    971855  // eliminate clusters with only one significant/unique track
    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         }
     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++; }
    992870      }
    993871    }
    994872
    995     if((nUnique < 2) && (sump < sumpmin))
    996     {
    997       sumpmin = sump;
    998       k0 = k;
    999     }
    1000   }
    1001 
    1002   if(k0 != y.end())
    1003   {
     873    if((nUnique<2)&&(sump<sumpmin)){
     874      sumpmin=sump;
     875      k0=k;
     876    }
     877  }
     878
     879  if(k0!=y.end()){
    1004880    //cout << "eliminating prototype at " << k0->z << "," << k0->t << " with sump=" << sumpmin << endl;
    1005881    //rho0+=k0->pk;
    1006882    y.erase(k0);
    1007883    return true;
    1008   }
    1009   else
    1010   {
     884  }else{
    1011885    return false;
    1012886  }
     
    1018892{
    1019893
    1020   double T0 = 0; // max Tc for beta=0
     894  double T0=0; // max Tc for beta=0
    1021895  // estimate critical temperature from beta=0 (T=inf)
    1022   unsigned int nt = tks.size();
    1023 
    1024   for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); k++)
    1025   {
     896  unsigned int nt=tks.size();
     897
     898  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
    1026899
    1027900    // vertex fit at T=inf
    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;
     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;
    1040912
    1041913    // estimate Tcrit, eventually do this in the same loop
    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);
     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);
    1049920      b += w;
    1050921    }
    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   {
     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{
    1061929    // ensure at least one annealing step
    1062     return betamax / coolingFactor;
     930    return betamax/coolingFactor;
    1063931  }
    1064932}
     
    1078946
    1079947  std::vector<std::pair<double, unsigned int> > critical;
    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;
     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;
    1092957    // estimate subcluster positions and weight
    1093     double p1 = 0, z1 = 0, t1 = 0, w1 = 0;
    1094     double p2 = 0, z2 = 0, t2 = 0, w2 = 0;
     958    double p1=0, z1=0, t1=0, w1=0;
     959    double p2=0, z2=0, t2=0, w2=0;
    1095960    //double sumpi=0;
    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         }
     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  }
    1117971      }
    1118972    }
    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     }
     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;}
    1139975
    1140976    // reduce split size if there is not enough room
    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     }
     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); }
    1151979
    1152980    // split if the new subclusters are significantly separated
    1153     if((z2 - z1) > epsilon || std::abs(t2 - t1) > epsilon)
    1154     {
    1155       split = true;
     981    if( (z2-z1)>epsilon || std::abs(t2-t1) > epsilon){
     982      split=true;
    1156983      vertex_t vnew;
    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;
     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;
    1161988      y[ik].z = z2;
    1162989      y[ik].t = t2;
    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         }
     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++;}
    1172995      }
    1173996    }
     
    11831006{
    11841007
    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
     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
    11881012
    11891013  vector<vertex_t> y1;
    11901014
    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     {
     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)) {
    11951017      // isolated prototype, split
    11961018      vertex_t vnew;
    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;
     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;
    12031025      y1.push_back(vnew);
    12041026      y1.push_back(*k);
    1205     }
    1206     else if(y1.empty() || (y1.back().z < k->z - zsep) || (y1.back().t < k->t - tsep))
    1207     {
     1027
     1028    }else if( y1.empty() || (y1.back().z < k->z -zsep) || (y1.back().t < k->t - tsep) ){
    12081029      y1.push_back(*k);
    1209     }
    1210     else
    1211     {
     1030    }else{
    12121031      y1.back().z -= epsilon;
    12131032      y1.back().t -= epsilon;
     
    12161035      y1.push_back(*k);
    12171036    }
    1218   } // vertex loop
    1219 
    1220   y = y1;
    1221 }
     1037  }// vertex loop
     1038
     1039  y=y1;
     1040}
     1041
     1042
     1043
  • modules/VertexFinderDA4D.h

    r0e7d64a re39abb4  
    99 *
    1010 */
     11
    1112
    1213#include "classes/DelphesModule.h"
     
    2122{
    2223public:
     24
    2325  VertexFinderDA4D();
    2426  ~VertexFinderDA4D();
     
    2931
    3032  void clusterize(const TObjArray &tracks, TObjArray &clusters);
    31   std::vector<Candidate *> vertices();
     33  std::vector< Candidate* > vertices();
    3234
    3335private:
     36
    3437  Bool_t fVerbose;
    3538  Double_t fMinPT;
  • modules/VertexSorter.cc

    r0e7d64a re39abb4  
    1616#include "classes/DelphesPileUpReader.h"
    1717
     18#include "ExRootAnalysis/ExRootResult.h"
     19#include "ExRootAnalysis/ExRootFilter.h"
    1820#include "ExRootAnalysis/ExRootClassifier.h"
    19 #include "ExRootAnalysis/ExRootFilter.h"
    20 #include "ExRootAnalysis/ExRootResult.h"
    21 
     21
     22#include "TMath.h"
     23#include "TString.h"
     24#include "TFormula.h"
     25#include "TRandom3.h"
     26#include "TObjArray.h"
    2227#include "TDatabasePDG.h"
    23 #include "TFormula.h"
    2428#include "TLorentzVector.h"
    25 #include "TMath.h"
    2629#include "TMatrixT.h"
    27 #include "TObjArray.h"
    28 #include "TRandom3.h"
    29 #include "TString.h"
    3030#include "TVector3.h"
    3131
     32#include <utility>
    3233#include <algorithm>
     34#include <stdexcept>
    3335#include <iostream>
     36#include <vector>
    3437#include <map>
    35 #include <stdexcept>
    3638#include <string>
    37 #include <utility>
    38 #include <vector>
    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;
     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    }
     210  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;
    135217      throw 0;
    136218    }
    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   }
    210   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 //------------------------------------------------------------------------------
     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

    r0e7d64a re39abb4  
    2323{
    2424public:
     25
    2526  VertexSorter();
    2627  ~VertexSorter();
     
    3132
    3233private:
     34
    3335  TObjArray *fInputArray;
    3436
  • modules/Weighter.cc

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920/** \class Weighter
    2021 *
     
    3132#include "classes/DelphesFormula.h"
    3233
     34#include "ExRootAnalysis/ExRootResult.h"
     35#include "ExRootAnalysis/ExRootFilter.h"
    3336#include "ExRootAnalysis/ExRootClassifier.h"
    34 #include "ExRootAnalysis/ExRootFilter.h"
    35 #include "ExRootAnalysis/ExRootResult.h"
    3637
     38#include "TMath.h"
     39#include "TString.h"
     40#include "TFormula.h"
     41#include "TRandom3.h"
     42#include "TObjArray.h"
    3743#include "TDatabasePDG.h"
    38 #include "TFormula.h"
    3944#include "TLorentzVector.h"
    40 #include "TMath.h"
    41 #include "TObjArray.h"
    42 #include "TRandom3.h"
    43 #include "TString.h"
    4445
    4546#include <algorithm>
     47#include <stdexcept>
    4648#include <iostream>
    4749#include <sstream>
    48 #include <stdexcept>
    4950
    5051using namespace std;
     
    5253//------------------------------------------------------------------------------
    5354
    54 bool Weighter::TIndexStruct::operator<(const Weighter::TIndexStruct &value) const
     55bool Weighter::TIndexStruct::operator< (const Weighter::TIndexStruct &value) const
    5556{
    5657  Int_t i;
     
    8990  fWeightSet.clear();
    9091
     92
    9193  // set default weight value
    9294  fWeightMap.clear();
    93   memset(index.codes, 0, 4 * sizeof(Int_t));
     95  memset(index.codes, 0, 4*sizeof(Int_t));
    9496  fWeightMap[index] = 1.0;
    9597
     
    9799  param = GetParam("Weight");
    98100  size = param.GetSize();
    99   for(i = 0; i < size / 2; ++i)
     101  for(i = 0; i < size/2; ++i)
    100102  {
    101     paramCodes = param[i * 2];
     103    paramCodes = param[i*2];
    102104    sizeCodes = paramCodes.GetSize();
    103     weight = param[i * 2 + 1].GetDouble();
     105    weight = param[i*2 + 1].GetDouble();
    104106
    105107    if(sizeCodes < 1 || sizeCodes > 4)
     
    108110    }
    109111
    110     memset(index.codes, 0, 4 * sizeof(Int_t));
     112    memset(index.codes, 0, 4*sizeof(Int_t));
    111113
    112114    for(j = 0; j < sizeCodes; ++j)
     
    155157  fCodeSet.clear();
    156158  fItInputArray->Reset();
    157   while((candidate = static_cast<Candidate *>(fItInputArray->Next())))
     159  while((candidate = static_cast<Candidate*>(fItInputArray->Next())))
    158160  {
    159161    if(candidate->Status != 3) continue;
     
    165167
    166168  // find default weight value
    167   memset(index.codes, 0, 4 * sizeof(Int_t));
     169  memset(index.codes, 0, 4*sizeof(Int_t));
    168170  itWeightMap = fWeightMap.find(index);
    169171  weight = itWeightMap->second;
  • modules/Weighter.h

    r0e7d64a re39abb4  
    3030#include "classes/DelphesModule.h"
    3131
     32#include <set>
    3233#include <map>
    33 #include <set>
    3434
    3535class TObjArray;
     
    3838{
    3939public:
     40
    4041  Weighter();
    4142  ~Weighter();
     
    4647
    4748private:
     49
    4850#if !defined(__CINT__) && !defined(__CLING__)
    4951  struct TIndexStruct
    5052  {
    5153    Int_t codes[4];
    52     bool operator<(const TIndexStruct &value) const;
     54    bool operator< (const TIndexStruct &value) const;
    5355  };
    5456
  • readers/DelphesCMSFWLite.cpp

    r0e7d64a re39abb4  
    1818
    1919#include <algorithm>
     20#include <stdexcept>
    2021#include <iostream>
     22#include <sstream>
    2123#include <memory>
    22 #include <sstream>
    23 #include <stdexcept>
    2424
    2525#include <map>
    2626#include <vector>
    2727
     28#include <stdlib.h>
    2829#include <signal.h>
    2930#include <stdio.h>
    30 #include <stdlib.h>
    31 
     31
     32#include "TROOT.h"
    3233#include "TApplication.h"
    33 #include "TROOT.h"
    34 
     34
     35#include "TFile.h"
     36#include "TObjArray.h"
     37#include "TStopwatch.h"
    3538#include "TDatabasePDG.h"
    36 #include "TFile.h"
     39#include "TParticlePDG.h"
    3740#include "TLorentzVector.h"
    38 #include "TObjArray.h"
    39 #include "TParticlePDG.h"
    40 #include "TStopwatch.h"
    41 
     41
     42#include "modules/Delphes.h"
     43#include "classes/DelphesStream.h"
    4244#include "classes/DelphesClasses.h"
    4345#include "classes/DelphesFactory.h"
    44 #include "classes/DelphesStream.h"
    45 #include "modules/Delphes.h"
    46 
     46
     47#include "ExRootAnalysis/ExRootTreeWriter.h"
     48#include "ExRootAnalysis/ExRootTreeBranch.h"
    4749#include "ExRootAnalysis/ExRootProgressBar.h"
    48 #include "ExRootAnalysis/ExRootTreeBranch.h"
    49 #include "ExRootAnalysis/ExRootTreeWriter.h"
    50 
     50
     51#include "FWCore/FWLite/interface/FWLiteEnabler.h"
    5152#include "DataFormats/FWLite/interface/Event.h"
    5253#include "DataFormats/FWLite/interface/Handle.h"
    5354#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
    5455#include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
    55 #include "FWCore/FWLite/interface/FWLiteEnabler.h"
     56#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
    5657#include "SimDataFormats/GeneratorProducts/interface/GenEventInfoProduct.h"
    57 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.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();
    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();
     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();
    183177
    184178    candidate = factory->NewCandidate();
     
    202196
    203197    pdgParticle = pdg->GetParticle(pid);
    204     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
     198    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    205199    candidate->Mass = mass;
    206200
    207201    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
    208202
    209     candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0);
     203    candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
    210204
    211205    allParticleOutputArray->Add(candidate);
     
    238232    pid = particle.pdgId();
    239233    status = particle.status();
    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();
     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();
    248236
    249237    candidate = factory->NewCandidate();
     
    267255
    268256    pdgParticle = pdg->GetParticle(pid);
    269     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
     257    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    270258    candidate->Mass = mass;
    271259
    272260    candidate->Momentum.SetPxPyPzE(px, py, pz, e);
    273261
    274     candidate->Position.SetXYZT(x * 10.0, y * 10.0, z * 10.0, 0.0);
     262    candidate->Position.SetXYZT(x*10.0, y*10.0, z*10.0, 0.0);
    275263
    276264    allParticleOutputArray->Add(candidate);
     
    315303  if(argc < 4)
    316304  {
    317     cout << " Usage: " << appName << " config_file"
    318          << " output_file"
    319          << " input_file(s)" << endl;
     305    cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
    320306    cout << " config_file - configuration file in Tcl format," << endl;
    321307    cout << " output_file - output file in ROOT format," << endl;
  • readers/DelphesHepMC.cpp

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

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

    r0e7d64a re39abb4  
    1818 */
    1919
     20#include <stdexcept>
    2021#include <iostream>
     22#include <sstream>
    2123#include <memory>
    22 #include <sstream>
    23 #include <stdexcept>
    2424
    2525#include <map>
    2626
     27#include <stdlib.h>
    2728#include <signal.h>
    2829#include <stdio.h>
    29 #include <stdlib.h>
    30 
     30
     31#include "TROOT.h"
    3132#include "TApplication.h"
    32 #include "TROOT.h"
    33 
     33
     34#include "TFile.h"
     35#include "TObjArray.h"
     36#include "TStopwatch.h"
    3437#include "TDatabasePDG.h"
    35 #include "TFile.h"
     38#include "TParticlePDG.h"
    3639#include "TLorentzVector.h"
    37 #include "TObjArray.h"
    38 #include "TParticlePDG.h"
    39 #include "TStopwatch.h"
    40 
     40
     41#include "modules/Delphes.h"
     42#include "classes/DelphesStream.h"
    4143#include "classes/DelphesClasses.h"
    4244#include "classes/DelphesFactory.h"
    43 #include "classes/DelphesStream.h"
    44 #include "modules/Delphes.h"
    45 
     45
     46#include "ExRootAnalysis/ExRootTreeWriter.h"
     47#include "ExRootAnalysis/ExRootTreeBranch.h"
    4648#include "ExRootAnalysis/ExRootProgressBar.h"
    47 #include "ExRootAnalysis/ExRootTreeBranch.h"
    48 #include "ExRootAnalysis/ExRootTreeWriter.h"
    49 
     49
     50#include <proio/reader.h>
    5051#include <proio/event.h>
    5152#include <proio/model/mc.pb.h>
    52 #include <proio/reader.h>
    53 namespace model = proio::model::mc;
     53namespace model=proio::model::mc;
     54
    5455
    5556using namespace std;
     
    5859// This method dynamically checks the message type (varint or not) depending on
    5960// non-zero value of units momentumUnit and positionUnit.
    60 void ConvertInput(proio::Event *event, double momentumUnit, double positionUnit,
     61void ConvertInput(proio::Event *event, double momentumUnit, double positionUnit, 
    6162  ExRootTreeBranch *branch, DelphesFactory *factory,
    6263  TObjArray *allParticleOutputArray, TObjArray *stableParticleOutputArray,
     
    7980  element = static_cast<HepMCEvent *>(branch->NewEntry());
    8081
    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   };
     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 };
    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   if(momentumUnit > 0 && positionUnit > 0)
    117   {
    118 
    119     auto entries = event->TaggedEntries("VarintPackedParticles");
    120 
    121     for(uint64_t entryID : entries)
    122     {
    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         }
     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)
     158    {
     159      stableParticleOutputArray->Add(candidate);
     160    }
     161    else if(pdgCode <= 5 || pdgCode == 21 || pdgCode == 15)
     162    {
     163      partonOutputArray->Add(candidate);
     164    }
     165  }
     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       }
     205    }
     206
     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         };
    164220      }
    165     }
    166   }
    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       }
    251     }
    252 
    253   } // end particle type
     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
    254254}
    255255
     
    283283  if(argc < 4)
    284284  {
    285     cout << " Usage: " << appName << " config_file"
    286          << " output_file"
    287          << " input_file(s)" << endl;
     285    cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
    288286    cout << " config_file - configuration file in Tcl format," << endl;
    289287    cout << " output_file - output file in ROOT format," << endl;
     
    332330      cout << "** INFO: Reading " << argv[i] << endl;
    333331
    334       inputFile = new proio::Reader(argv[i]);
     332      inputFile=new proio::Reader( argv[i] );
    335333
    336334      if(inputFile == NULL)
     
    340338      }
    341339
    342       /*
     340
     341/*
    343342// this is slow method, but general
    344343      inputFile->SeekToStart();
     
    351350*/
    352351
    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);
     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
    367370
    368371      // Loop over all objects
     
    373376      for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter)
    374377      {
    375         inputFile->Next(event);
     378        inputFile->Next(event); 
    376379        if(event == 0) continue;
    377380
    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           }
     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);
    391391        }
     392       }
     393
    392394
    393395        readStopWatch.Stop();
     
    395397        procStopWatch.Start();
    396398
    397         ConvertInput(event, varint_energy, varint_length,
     399        ConvertInput(event, varint_energy, varint_length, 
    398400          branchEvent, factory,
    399401          allParticleOutputArray, stableParticleOutputArray,
    400402          partonOutputArray, &readStopWatch, &procStopWatch);
    401 
     403 
    402404        modularDelphes->ProcessTask();
    403405        procStopWatch.Stop();
     
    412414      }
    413415
     416
    414417      progressBar.Update(eventCounter, eventCounter, kTRUE);
    415418      progressBar.Finish();
     
    417420      delete inputFile;
    418421    }
     422
    419423
    420424    modularDelphes->FinishTask();
  • readers/DelphesProMC.cpp

    r0e7d64a re39abb4  
    1717 */
    1818
     19#include <stdexcept>
    1920#include <iostream>
     21#include <sstream>
    2022#include <memory>
    21 #include <sstream>
    22 #include <stdexcept>
    2323
    2424#include <map>
    2525
     26#include <stdlib.h>
    2627#include <signal.h>
    2728#include <stdio.h>
    28 #include <stdlib.h>
    29 
     29
     30#include "TROOT.h"
    3031#include "TApplication.h"
    31 #include "TROOT.h"
    32 
     32
     33#include "TFile.h"
     34#include "TObjArray.h"
     35#include "TStopwatch.h"
    3336#include "TDatabasePDG.h"
    34 #include "TFile.h"
     37#include "TParticlePDG.h"
    3538#include "TLorentzVector.h"
    36 #include "TObjArray.h"
    37 #include "TParticlePDG.h"
    38 #include "TStopwatch.h"
    39 
     39
     40#include "modules/Delphes.h"
     41#include "classes/DelphesStream.h"
    4042#include "classes/DelphesClasses.h"
    4143#include "classes/DelphesFactory.h"
    42 #include "classes/DelphesStream.h"
    43 #include "modules/Delphes.h"
    44 
     44
     45#include "ExRootAnalysis/ExRootTreeWriter.h"
     46#include "ExRootAnalysis/ExRootTreeBranch.h"
    4547#include "ExRootAnalysis/ExRootProgressBar.h"
    46 #include "ExRootAnalysis/ExRootTreeBranch.h"
    47 #include "ExRootAnalysis/ExRootTreeWriter.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 
    130127    candidate->M1 = mutableParticles->mother1(i);
    131128    candidate->M2 = mutableParticles->mother2(i);
     
    135132
    136133    pdgParticle = pdg->GetParticle(pid);
    137     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
     134    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    138135    candidate->Mass = mass;
    139136
     
    187184  if(argc < 4)
    188185  {
    189     cout << " Usage: " << appName << " config_file"
    190          << " output_file"
    191          << " input_file(s)" << endl;
     186    cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
    192187    cout << " config_file - configuration file in Tcl format," << endl;
    193188    cout << " output_file - output file in ROOT format," << endl;
     
    236231      cout << "** Reading " << argv[i] << endl;
    237232
    238       // use 64 bit
    239       //inputFile = new ProMCBook(argv[i], "r", true);
    240 
    241       //use 32 bit zip (faster but limitted to 64k events)
    242233      inputFile = new ProMCBook(argv[i], "r");
    243234
     
    246237      momentumUnit = static_cast<double>(header.momentumunit());
    247238      positionUnit = static_cast<double>(header.lengthunit());
     239
     240
    248241
    249242      if(inputFile == NULL)
  • readers/DelphesPythia8.cpp

    r0e7d64a re39abb4  
    1717 */
    1818
     19#include <stdexcept>
    1920#include <iostream>
    2021#include <sstream>
    21 #include <stdexcept>
    2222#include <string>
    2323
     
    2727#include "Pythia8Plugins/CombineMatchingInput.h"
    2828
     29#include "TROOT.h"
    2930#include "TApplication.h"
    30 #include "TROOT.h"
    31 
     31
     32#include "TFile.h"
     33#include "TObjArray.h"
     34#include "TStopwatch.h"
    3235#include "TDatabasePDG.h"
    33 #include "TFile.h"
     36#include "TParticlePDG.h"
    3437#include "TLorentzVector.h"
    35 #include "TObjArray.h"
    36 #include "TParticlePDG.h"
    37 #include "TStopwatch.h"
    38 
     38
     39#include "modules/Delphes.h"
    3940#include "classes/DelphesClasses.h"
    4041#include "classes/DelphesFactory.h"
    4142#include "classes/DelphesLHEFReader.h"
    42 #include "modules/Delphes.h"
    43 
     43
     44#include "ExRootAnalysis/ExRootTreeWriter.h"
     45#include "ExRootAnalysis/ExRootTreeBranch.h"
    4446#include "ExRootAnalysis/ExRootProgressBar.h"
    45 #include "ExRootAnalysis/ExRootTreeBranch.h"
    46 #include "ExRootAnalysis/ExRootTreeWriter.h"
    4747
    4848using namespace std;
     
    9898    pid = particle.id();
    9999    status = particle.statusHepMC();
    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();
     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();
    109102
    110103    candidate = factory->NewCandidate();
     
    122115
    123116    pdgParticle = pdg->GetParticle(pid);
    124     candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999;
     117    candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge()/3.0) : -999;
    125118    candidate->Mass = mass;
    126119
     
    173166
    174167  // pMin = 0.1 GeV for single particles
    175   pp = pow(10, -1.0 + (log10(pMax) + 1.0) * rndm.flat());
     168  pp = pow(10, - 1.0 + (log10(pMax) + 1.0) * rndm.flat());
    176169  eta = (2.0 * rndm.flat() - 1.0) * etaMax;
    177170  phi = 2.0 * M_PI * rndm.flat();
    178171  mm = pdt.mSel(id);
    179   ee = Pythia8::sqrtpos(pp * pp + mm * mm);
     172  ee = Pythia8::sqrtpos(pp*pp + mm*mm);
    180173  pt = pp / cosh(eta);
    181174
     
    200193  phi = 2.0 * M_PI * rndm.flat();
    201194  mm = pdt.mSel(id);
    202   ee = Pythia8::sqrtpos(pp * pp + mm * mm);
     195  ee = Pythia8::sqrtpos(pp*pp + mm*mm);
    203196  pt = pp / cosh(eta);
    204197
    205   if((id == 4 || id == 5) && pt < 10.0) return;
     198  if( (id == 4 || id == 5) && pt < 10.0) return;
    206199
    207200  if(id == 21)
     
    245238  // for matching
    246239  Pythia8::CombineMatchingInput *combined = 0;
    247   Pythia8::UserHooks *matching = 0;
     240  Pythia8::UserHooks* matching = 0;
    248241
    249242  if(argc != 4)
    250243  {
    251     cout << " Usage: " << appName << " config_file"
    252          << " pythia_card"
    253          << " output_file" << endl;
     244    cout << " Usage: " << appName << " config_file" << " pythia_card" << " output_file" << endl;
    254245    cout << " config_file - configuration file in Tcl format," << endl;
    255246    cout << " pythia_card - Pythia8 configuration file," << endl;
     
    302293    }
    303294    pythia->setUserHooksPtr(matching);
     295
    304296
    305297    if(pythia == NULL)
     
    356348    for(eventCounter = 0; eventCounter < numberOfEvents && !interrupted; ++eventCounter)
    357349    {
    358       while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF, stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady())
    359         ;
     350      while(reader && reader->ReadBlock(factory, allParticleOutputArrayLHEF,
     351        stableParticleOutputArrayLHEF, partonOutputArrayLHEF) && !reader->EventReady());
    360352
    361353      if(spareFlag1)
  • readers/DelphesROOT.cpp

    r0e7d64a re39abb4  
    1818
    1919#include <algorithm>
     20#include <stdexcept>
    2021#include <iostream>
     22#include <sstream>
    2123#include <memory>
    22 #include <sstream>
    23 #include <stdexcept>
    2424
    2525#include <map>
    2626#include <vector>
    2727
     28#include <stdlib.h>
    2829#include <signal.h>
    2930#include <stdio.h>
    30 #include <stdlib.h>
    31 
     31
     32#include "TROOT.h"
    3233#include "TApplication.h"
    33 #include "TROOT.h"
    34 
     34
     35#include "TFile.h"
    3536#include "TClonesArray.h"
     37#include "TObjArray.h"
     38#include "TStopwatch.h"
    3639#include "TDatabasePDG.h"
    37 #include "TFile.h"
     40#include "TParticlePDG.h"
    3841#include "TLorentzVector.h"
    39 #include "TObjArray.h"
    40 #include "TParticlePDG.h"
    41 #include "TStopwatch.h"
    42 
     42
     43#include "modules/Delphes.h"
     44#include "classes/DelphesStream.h"
    4345#include "classes/DelphesClasses.h"
    4446#include "classes/DelphesFactory.h"
    45 #include "classes/DelphesStream.h"
    46 #include "modules/Delphes.h"
    47 
     47
     48#include "ExRootAnalysis/ExRootTreeWriter.h"
     49#include "ExRootAnalysis/ExRootTreeReader.h"
     50#include "ExRootAnalysis/ExRootTreeBranch.h"
    4851#include "ExRootAnalysis/ExRootProgressBar.h"
    49 #include "ExRootAnalysis/ExRootTreeBranch.h"
    50 #include "ExRootAnalysis/ExRootTreeReader.h"
    51 #include "ExRootAnalysis/ExRootTreeWriter.h"
     52
     53
    5254
    5355using namespace std;
    5456
    5557//---------------------------------------------------------------------------
     58
    5659
    5760//---------------------------------------------------------------------------
     
    9194  if(argc < 4)
    9295  {
    93     cout << " Usage: " << appName << " config_file"
    94          << " output_file"
    95          << " input_file(s)" << endl;
     96    cout << " Usage: " << appName << " config_file" << " output_file" << " input_file(s)" << endl;
    9697    cout << " config_file - configuration file in Tcl format," << endl;
    9798    cout << " output_file - output file in ROOT format," << endl;
     
    121122
    122123    branchEvent = treeWriter->NewBranch("Event", HepMCEvent::Class());
    123 
     124   
    124125    confReader = new ExRootConfReader;
    125126    confReader->ReadFile(argv[1]);
     
    128129    modularDelphes->SetConfReader(confReader);
    129130    modularDelphes->SetTreeWriter(treeWriter);
    130 
     131   
    131132    TChain *chain = new TChain("Delphes");
    132 
     133   
    133134    factory = modularDelphes->GetFactory();
    134135    allParticleOutputArray = modularDelphes->ExportArray("allParticles");
     
    144145      chain->Add(argv[i]);
    145146      ExRootTreeReader *treeReader = new ExRootTreeReader(chain);
    146 
     147     
    147148      inputFile = TFile::Open(argv[i]);
    148149
     
    152153        throw runtime_error(message.str());
    153154      }
    154 
     155     
    155156      numberOfEvents = treeReader->GetEntries();
    156       TClonesArray *branchParticle = treeReader->UseBranch("Particle");
     157      TClonesArray *branchParticle   = treeReader->UseBranch("Particle");
    157158      TClonesArray *branchHepMCEvent = treeReader->UseBranch("Event");
    158 
     159     
    159160      if(numberOfEvents <= 0) continue;
    160161
     
    168169      for(Int_t entry = 0; entry < numberOfEvents && !interrupted; ++entry)
    169170      {
    170 
     171   
    171172        treeReader->ReadEntry(entry);
    172173
    173         // -- TBC need also to include event weights --
    174 
    175         eve = (HepMCEvent *)branchHepMCEvent->At(0);
     174        // -- TBC need also to include event weights -- 
     175       
     176        eve = (HepMCEvent*) branchHepMCEvent->At(0);
    176177        element = static_cast<HepMCEvent *>(branchEvent->NewEntry());
    177 
     178       
    178179        element->Number = eventCounter;
    179180
     
    196197        element->ProcTime = eve->ProcTime;
    197198
    198         for(Int_t j = 0; j < branchParticle->GetEntriesFast(); j++)
    199         {
    200 
    201           gen = (GenParticle *)branchParticle->At(j);
     199        for(Int_t j=0; j < branchParticle->GetEntriesFast(); j++)
     200        {     
     201         
     202          gen = (GenParticle*) branchParticle->At(j);     
    202203          candidate = factory->NewCandidate();
    203204
    204205          candidate->Momentum = gen->P4();
    205           candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T * 1.0E3 * c_light);
    206 
     206          candidate->Position.SetXYZT(gen->X, gen->Y, gen->Z, gen->T*1.0E3*c_light);
     207         
    207208          candidate->PID = gen->PID;
    208209          candidate->Status = gen->Status;
    209 
     210     
    210211          candidate->M1 = gen->M1;
    211212          candidate->M2 = gen->M2;
     
    215216
    216217          candidate->Charge = gen->Charge;
    217           candidate->Mass = gen->Mass;
    218 
     218          candidate->Mass   = gen->Mass;
     219   
    219220          allParticleOutputArray->Add(candidate);
    220 
     221 
    221222          pdgCode = TMath::Abs(gen->PID);
    222223
     
    230231          }
    231232        }
    232 
     233       
    233234        modularDelphes->ProcessTask();
    234235
     
    241242        ++eventCounter;
    242243      }
    243 
     244 
    244245      progressBar.Update(eventCounter, eventCounter, kTRUE);
    245246      progressBar.Finish();
    246247
    247248      inputFile->Close();
    248 
     249   
    249250      delete treeReader;
     251     
    250252    }
    251253
     
    260262    delete outputFile;
    261263    delete chain;
    262 
     264   
    263265    return 0;
    264266  }
  • readers/DelphesSTDHEP.cpp

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

    r0e7d64a re39abb4  
    1717 */
    1818
     19
    1920#include <iostream>
    20 #include <typeinfo>
    2121#include <utility>
    2222#include <vector>
    23 
    24 #include "TApplication.h"
     23#include <typeinfo>
     24
    2525#include "TROOT.h"
    2626#include "TSystem.h"
     27#include "TApplication.h"
    2728
    2829#include "TString.h"
    2930
    30 #include "TCanvas.h"
    31 #include "TClonesArray.h"
    32 #include "TGraph.h"
    33 #include "TGraphErrors.h"
    3431#include "TH1.h"
    3532#include "TH2.h"
     33#include "TMath.h"
     34#include "TStyle.h"
     35#include "TGraph.h"
     36#include "TCanvas.h"
    3637#include "THStack.h"
    3738#include "TLegend.h"
     39#include "TPaveText.h"
     40#include "TClonesArray.h"
    3841#include "TLorentzVector.h"
    39 #include "TMath.h"
     42#include "TGraphErrors.h"
    4043#include "TMultiGraph.h"
    41 #include "TPaveText.h"
    42 #include "TStyle.h"
    4344
    4445#include "classes/DelphesClasses.h"
    4546
    46 #include "ExRootAnalysis/ExRootResult.h"
    47 #include "ExRootAnalysis/ExRootTreeBranch.h"
    4847#include "ExRootAnalysis/ExRootTreeReader.h"
    4948#include "ExRootAnalysis/ExRootTreeWriter.h"
     49#include "ExRootAnalysis/ExRootTreeBranch.h"
     50#include "ExRootAnalysis/ExRootResult.h"
    5051#include "ExRootAnalysis/ExRootUtilities.h"
    5152
     
    8182unsigned int k;
    8283
     84
    8385struct resolPlot
    8486{
    85   TH1 *resolHist;
     87  TH1* resolHist;
    8688  double ptmin;
    8789  double ptmax;
     
    9799  void set(double ptdown, double ptup, TString object, double xmin = 0, double xmax = 2);
    98100  void set(double etadown, double etaup, double ptdown, double ptup, TString object, double xmin = 0, double xmax = 2);
    99   void print() { std::cout << ptmin << std::endl; }
     101  void print(){std::cout << ptmin << std::endl;}
    100102};
     103
    101104
    102105resolPlot::resolPlot()
     
    106109resolPlot::resolPlot(double ptdown, double ptup, TString object)
    107110{
    108   this->set(ptdown, ptup, object);
     111  this->set(ptdown,ptup,object);
    109112}
    110113
     
    120123  obj = object;
    121124
    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);
     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);
    123126}
    124127
     
    131134  obj = object;
    132135
    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);
     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);
    134137}
     138
     139
    135140
    136141void HistogramsCollection(std::vector<resolPlot> *histos, double ptmin, double ptmax, TString obj, double xmin = 0, double xmax = 2)
     
    141146  resolPlot ptemp;
    142147
    143   for(int i = 0; i < Nbins; i++)
     148  for (int i = 0; i < Nbins; i++)
    144149  {
    145150    width = (ptmax - ptmin) / Nbins;
    146     ptdown = TMath::Power(10, ptmin + i * width);
    147     ptup = TMath::Power(10, ptmin + (i + 1) * width);
     151    ptdown = TMath::Power(10,ptmin + i * width );
     152    ptup = TMath::Power(10,ptmin + (i+1) * width );
    148153    ptemp.set(ptdown, ptup, obj, xmin, xmax);
    149154    histos->push_back(ptemp);
    150155  }
    151156}
     157
    152158
    153159void HistogramsCollectionVsEta(std::vector<resolPlot> *histos, double etamin, double etamax, double ptmin, double ptmax, TString obj, double xmin = 0, double xmax = 2)
     
    158164  double etaup;
    159165
    160   for(int i = 0; i < Nbins; i++)
     166  for (int i = 0; i < Nbins; i++)
    161167  {
    162168    width = (etamax - etamin) / Nbins;
    163169    etadown = etamin + i * width;
    164     etaup = etamin + (i + 1) * width;
     170    etaup = etamin + (i+1) * width;
    165171
    166172    ptemp.set(etadown, etaup, ptmin, ptmax, obj, xmin, xmax);
     
    169175}
    170176
     177
    171178//------------------------------------------------------------------------------
    172179
     
    176183//------------------------------------------------------------------------------
    177184
    178 void BinLogX(TH1 *h)
     185void BinLogX(TH1*h)
    179186{
    180187  TAxis *axis = h->GetXaxis();
     
    186193  Axis_t *new_bins = new Axis_t[bins + 1];
    187194
    188   for(int i = 0; i <= bins; i++)
     195  for (int i = 0; i <= bins; i++)
    189196  {
    190197    new_bins[i] = TMath::Power(10, from + i * width);
     
    194201}
    195202
     203
    196204//------------------------------------------------------------------------------
    197205
    198 template <typename T>
    199 TH1D *GetEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     206template<typename T>
     207TH1D* GetEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    200208{
    201209
    202   cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     210  cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    203211
    204212  Long64_t allEntries = treeReader->GetEntries();
     
    215223  Int_t i, j;
    216224
    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));
     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));
    219227
    220228  histGenPt->SetDirectory(0);
     
    234242    {
    235243
    236       particle = (GenParticle *)branchParticle->At(i);
     244      particle = (GenParticle*) branchParticle->At(i);
    237245      genMomentum = particle->P4();
    238246
    239247      deltaR = 999;
    240248
    241       pt = genMomentum.Pt();
     249      pt  = genMomentum.Pt();
    242250      eta = TMath::Abs(genMomentum.Eta());
    243251
    244       if(eta > etamax || eta < etamin) continue;
    245 
    246       if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
     252
     253      if(eta > etamax || eta < etamin ) continue;
     254
     255      if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    247256      //if (TMath::Abs(particle->PID) == pdgID && (particle->Status>20 && particle->Status <30) && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    248257      {
     
    250259        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    251260        {
    252           recoObj = (T *)branchReco->At(j);
     261          recoObj = (T*)branchReco->At(j);
    253262          recoMomentum = recoObj->P4();
    254           //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
     263        //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
     264
     265
    255266
    256267          // take the closest parton candidate
     
    258269          {
    259270            Jet *jet = (Jet *)recoObj;
    260             if(!(jet->BTag & (1 << 0))) continue;
     271            if( !(jet->BTag & (1 << 0)) ) continue;
    261272
    262273            //if(jet->BTag != ) continue;
    263274          }
    264275
    265           if(TMath::Abs(pdgID) == 4)
     276            if(TMath::Abs(pdgID) == 4)
    266277          {
    267278            Jet *jet = (Jet *)recoObj;
    268             if(!(jet->BTag & (1 << 0))) continue;
     279            if( !(jet->BTag & (1 << 0)) ) continue;
    269280          }
    270281
    271           if(TMath::Abs(pdgID) == 1)
     282            if(TMath::Abs(pdgID) == 1)
    272283          {
    273284            Jet *jet = (Jet *)recoObj;
    274             if(!(jet->BTag & (1 << 0))) continue;
     285            if( !(jet->BTag & (1 << 0)) ) continue;
    275286          }
    276287
     
    280291            if(jet->TauTag != 1) continue;
    281292          }
     293
    282294
    283295          if(genMomentum.DeltaR(recoMomentum) < deltaR)
     
    288300        }
    289301        histGenPt->Fill(pt);
    290         if(deltaR < 0.3 && bestRecoMomentum.Pt() > 0.20 * pt)
    291         {
    292           histRecoPt->Fill(pt);
    293         }
     302        if(deltaR < 0.3 && bestRecoMomentum.Pt()> 0.20*pt ) { histRecoPt->Fill(pt);}
     303
    294304      }
    295305    }
     
    305315}
    306316
    307 template <typename T>
    308 TH1D *GetEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     317
     318template<typename T>
     319TH1D* GetEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    309320{
    310321
    311   cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     322  cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    312323
    313324  Long64_t allEntries = treeReader->GetEntries();
     
    324335  Int_t i, j;
    325336
    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);
     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);
    328339
    329340  histGenEta->SetDirectory(0);
     
    340351    {
    341352
    342       particle = (GenParticle *)branchParticle->At(i);
     353      particle = (GenParticle*) branchParticle->At(i);
    343354      genMomentum = particle->P4();
    344355
    345356      deltaR = 999;
    346357
    347       pt = genMomentum.Pt();
     358      pt  = genMomentum.Pt();
    348359      eta = genMomentum.Eta();
    349360
    350       if(pt > ptmax || pt < ptmin) continue;
    351 
    352       if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
     361      if(pt > ptmax || pt < ptmin ) continue;
     362
     363      if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    353364      //if (TMath::Abs(particle->PID) == pdgID && (particle->Status>20 && particle->Status <30) && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    354365      {
     
    356367        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    357368        {
    358           recoObj = (T *)branchReco->At(j);
     369          recoObj = (T*)branchReco->At(j);
    359370          recoMomentum = recoObj->P4();
    360371          // this is simply to avoid warnings from initial state particle
    361372          // having infite rapidity ...
    362           //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
     373        //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    363374
    364375          // take the closest parton candidate
     
    366377          {
    367378            Jet *jet = (Jet *)recoObj;
    368             if(!(jet->BTag & (1 << 0))) continue;
     379            if( !(jet->BTag & (1 << 0)) ) continue;
     380
    369381          }
    370382
     
    372384          {
    373385            Jet *jet = (Jet *)recoObj;
    374             if(!(jet->BTag & (1 << 0))) continue;
     386            if( !(jet->BTag & (1 << 0)) ) continue;
    375387          }
    376388
    377           if(TMath::Abs(pdgID) == 1)
     389           if(TMath::Abs(pdgID) == 1)
    378390          {
    379391            Jet *jet = (Jet *)recoObj;
    380             if(!(jet->BTag & (1 << 0))) continue;
     392            if( !(jet->BTag & (1 << 0)) ) continue;
    381393          }
    382394
     
    394406
    395407        histGenEta->Fill(eta);
    396         if(deltaR < 0.3)
    397         {
    398           histRecoEta->Fill(eta);
    399         }
     408        if(deltaR < 0.3) { histRecoEta->Fill(eta); }
     409
    400410      }
    401411    }
     
    411421}
    412422
     423
    413424//------------------------------------------------------------------------------
    414425
    415 template <typename T>
    416 TH1D *GetJetEffPt(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     426template<typename T>
     427TH1D* GetJetEffPt(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    417428{
    418429
    419   cout << "** Computing Efficiency of reconstructing " << branchJet->GetName() << " with PID " << pdgID << endl;
     430  cout << "** Computing Efficiency of reconstructing "<< branchJet->GetName() << " with PID " << pdgID << endl;
    420431
    421432  Long64_t allEntries = treeReader->GetEntries();
     
    430441  Int_t j;
    431442
    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));
     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));
    434445
    435446  histGenPt->SetDirectory(0);
     
    448459    for(j = 0; j < branchJet->GetEntriesFast(); ++j)
    449460    {
    450       recoObj = (T *)branchJet->At(j);
     461      recoObj = (T*)branchJet->At(j);
    451462      recoMomentum = recoObj->P4();
    452       pt = recoMomentum.Pt();
     463      pt =   recoMomentum.Pt();     
    453464      eta = TMath::Abs(recoMomentum.Eta());
    454465      Jet *jet = (Jet *)recoObj;
    455 
    456       if(eta > etamax || eta < etamin) continue;
     466         
     467      if(eta > etamax || eta < etamin ) continue;
    457468      if(pt < ptmin || pt > ptmax) continue;
    458 
     469     
    459470      Int_t flavor = jet->Flavor;
    460471      if(flavor == 21) flavor = 0;
    461 
     472   
    462473      if(TMath::Abs(pdgID) == 1)
    463474      {
    464 
     475       
    465476        if(flavor < 4)
    466477        {
    467478          histGenPt->Fill(pt);
    468           if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
     479          if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
    469480        }
    470481      }
     
    474485        {
    475486          histGenPt->Fill(pt);
    476           if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
     487          if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
    477488        }
    478489      }
     
    482493        {
    483494          histGenPt->Fill(pt);
    484           if(jet->BTag & (1 << 0)) histRecoPt->Fill(pt);
     495          if( jet->BTag & (1 << 0) ) histRecoPt->Fill(pt);
    485496        }
    486497      }
    487     }
     498   }
     499
    488500  }
    489501
     
    499511// ------------------------------------------------------------------------------------------------------------------------------------------------------
    500512
    501 template <typename T>
    502 TH1D *GetJetEffEta(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     513template<typename T>
     514TH1D* GetJetEffEta(TClonesArray *branchJet, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    503515{
    504516
    505   cout << "** Computing Efficiency of reconstructing " << branchJet->GetName() << " with PID " << pdgID << endl;
     517  cout << "** Computing Efficiency of reconstructing "<< branchJet->GetName() << " with PID " << pdgID << endl;
    506518
    507519  Long64_t allEntries = treeReader->GetEntries();
     
    516528  Int_t j;
    517529
    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);
     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);
    520532
    521533  histGenEta->SetDirectory(0);
     
    530542    for(j = 0; j < branchJet->GetEntriesFast(); ++j)
    531543    {
    532       recoObj = (T *)branchJet->At(j);
     544      recoObj = (T*)branchJet->At(j);
    533545      recoMomentum = recoObj->P4();
    534       pt = recoMomentum.Pt();
     546      pt =   recoMomentum.Pt();     
    535547      eta = recoMomentum.Eta();
    536548      Jet *jet = (Jet *)recoObj;
    537 
    538       if(eta > etamax || eta < etamin) continue;
     549         
     550      if(eta > etamax || eta < etamin ) continue;
    539551      if(pt < ptmin || pt > ptmax) continue;
    540 
     552     
    541553      Int_t flavor = jet->Flavor;
    542554      if(flavor == 21) flavor = 0;
    543 
     555         
    544556      if(TMath::Abs(pdgID) == 1)
    545557      {
    546         if(flavor == 1 || flavor == 21)
     558        if(flavor  == 1 || flavor == 21)
    547559        {
    548560          histGenEta->Fill(eta);
    549           if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
     561          if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
    550562        }
    551563      }
     
    555567        {
    556568          histGenEta->Fill(eta);
    557           if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
     569          if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
    558570        }
    559571      }
     
    563575        {
    564576          histGenEta->Fill(eta);
    565           if(jet->BTag & (1 << 0)) histRecoEta->Fill(eta);
     577          if( jet->BTag & (1 << 0) ) histRecoEta->Fill(eta);
    566578        }
    567579      }
    568     }
    569   }
     580   }
     581
     582  }
     583
    570584
    571585  histRecoEta->Sumw2();
     
    578592}
    579593
     594
    580595// -----------------------------------------------------------------------------------------------------------------------------------------------------
    581596
    582 template <typename T>
    583 TH1D *GetTauEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     597template<typename T>
     598TH1D* GetTauEffPt(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    584599{
    585600
    586   cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     601  cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    587602
    588603  Long64_t allEntries = treeReader->GetEntries();
     
    599614  Int_t i, j;
    600615
    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));
     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));
    603618
    604619  histGenPt->SetDirectory(0);
     
    618633    {
    619634
    620       particle = (GenParticle *)branchParticle->At(i);
     635      particle = (GenParticle*) branchParticle->At(i);
    621636      genMomentum = particle->P4();
    622637
    623638      deltaR = 999;
    624639
    625       pt = genMomentum.Pt();
     640      pt  = genMomentum.Pt();
    626641      eta = TMath::Abs(genMomentum.Eta());
    627642
    628       if(eta > etamax || eta < etamin) continue;
    629 
    630       if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
     643      if(eta > etamax || eta < etamin ) continue;
     644
     645      if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    631646      {
    632647        // Loop over all reco object in event
    633648        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    634649        {
    635           recoObj = (T *)branchReco->At(j);
     650          recoObj = (T*)branchReco->At(j);
    636651          recoMomentum = recoObj->P4();
    637652          // this is simply to avoid warnings from initial state particle
     
    642657          {
    643658            Jet *jet = (Jet *)recoObj;
    644             if(jet->TauTag != 1) continue;
     659            if( jet->TauTag != 1 ) continue;
    645660          }
    646661
     
    659674
    660675        histGenPt->Fill(pt);
    661         if(deltaR < 0.3)
    662         {
    663           histRecoPt->Fill(pt);
    664         }
     676        if(deltaR < 0.3) { histRecoPt->Fill(pt); }
     677
    665678      }
    666679    }
     
    670683  histGenPt->Sumw2();
    671684
     685
    672686  histRecoPt->Divide(histGenPt);
    673687  histRecoPt->Scale(100.);
    674   if(TMath::Abs(pdgID) == 15) histRecoPt->Scale(1 / 0.648);
     688  if(TMath::Abs(pdgID) == 15) histRecoPt->Scale(1/0.648);
    675689
    676690  return histRecoPt;
    677691}
    678692
    679 template <typename T>
    680 TH1D *GetTauEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
     693template<typename T>
     694TH1D* GetTauEffEta(TClonesArray *branchReco, TClonesArray *branchParticle, TString name, int pdgID, double ptmin, double ptmax, double etamin, double etamax, ExRootTreeReader *treeReader)
    681695{
    682696
    683   cout << "** Computing Efficiency of reconstructing " << branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
     697  cout << "** Computing Efficiency of reconstructing "<< branchReco->GetName() << " induced by " << branchParticle->GetName() << " with PID " << pdgID << endl;
    684698
    685699  Long64_t allEntries = treeReader->GetEntries();
     
    696710  Int_t i, j;
    697711
    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);
     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);
    700714
    701715  histGenEta->SetDirectory(0);
     
    712726    {
    713727
    714       particle = (GenParticle *)branchParticle->At(i);
     728      particle = (GenParticle*) branchParticle->At(i);
    715729      genMomentum = particle->P4();
    716730
    717731      deltaR = 999;
    718732
    719       pt = genMomentum.Pt();
     733      pt  = genMomentum.Pt();
    720734      eta = genMomentum.Eta();
    721735
    722       if(pt > ptmax || pt < ptmin) continue;
    723 
    724       if(particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax)
     736      if(pt > ptmax || pt < ptmin ) continue;
     737
     738      if (particle->PID == pdgID && genMomentum.Pt() > ptmin && genMomentum.Pt() < ptmax )
    725739      {
    726740        // Loop over all reco object in event
    727741        for(j = 0; j < branchReco->GetEntriesFast(); ++j)
    728742        {
    729           recoObj = (T *)branchReco->At(j);
     743          recoObj = (T*)branchReco->At(j);
    730744          recoMomentum = recoObj->P4();
    731745          // this is simply to avoid warnings from initial state particle
    732746          // having infite rapidity ...
    733           //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
    734 
    735           if(TMath::Abs(pdgID) == 1)
     747        //if(Momentum.Px() == 0 && genMomentum.Py() == 0) continue;
     748
     749         if(TMath::Abs(pdgID) == 1)
    736750          {
    737751            Jet *jet = (Jet *)recoObj;
    738             if(jet->TauTag != 1) continue;
     752            if( jet->TauTag != 1 ) continue;
    739753          }
    740754
     
    753767
    754768        histGenEta->Fill(eta);
    755         if(deltaR < 0.3)
    756         {
    757           histRecoEta->Fill(eta);
    758         }
     769        if(deltaR < 0.3) { histRecoEta->Fill(eta); }
     770
    759771      }
    760772    }
     
    766778  histRecoEta->Divide(histGenEta);
    767779  histRecoEta->Scale(100.);
    768   if(TMath::Abs(pdgID) == 15) histRecoEta->Scale(1 / 0.648);
     780  if(TMath::Abs(pdgID) == 15) histRecoEta->Scale(1/0.648);
    769781
    770782  return histRecoEta;
    771783}
    772784
    773 template <typename T>
     785
     786template<typename T>
    774787void GetPtres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t etaMin, Double_t etaMax, ExRootTreeReader *treeReader)
    775788{
     
    779792
    780793  GenParticle *particle;
    781   T *recoObj;
     794  T* recoObj;
    782795
    783796  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    798811    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    799812    {
    800       recoObj = (T *)branchReco->At(i);
     813      recoObj = (T*) branchReco->At(i);
    801814      recoMomentum = recoObj->P4();
    802815
    803816      deltaR = 999;
    804817
    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)
     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)
    810823        {
    811824          genMomentum = particle->P4();
     
    818831          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    819832          {
    820             deltaR = genMomentum.DeltaR(recoMomentum);
    821             bestGenMomentum = genMomentum;
     833             deltaR = genMomentum.DeltaR(recoMomentum);
     834             bestGenMomentum = genMomentum;
    822835          }
    823836        }
     
    826839      if(deltaR < 0.3)
    827840      {
    828         pt = bestGenMomentum.Pt();
     841        pt  = bestGenMomentum.Pt();
    829842        eta = TMath::Abs(bestGenMomentum.Eta());
    830843
    831         for(bin = 0; bin < Nbins; bin++)
     844        for (bin = 0; bin < Nbins; bin++)
    832845        {
    833846          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta > etaMin && eta < etaMax)
    834847          {
    835             histos->at(bin).resolHist->Fill(recoMomentum.Pt() / bestGenMomentum.Pt());
     848            histos->at(bin).resolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());
    836849          }
    837850        }
     
    841854}
    842855
    843 template <typename T>
     856
     857template<typename T>
    844858void GetEres(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t etaMin, Double_t etaMax, ExRootTreeReader *treeReader)
    845859{
     
    849863
    850864  GenParticle *particle;
    851   T *recoObj;
     865  T* recoObj;
    852866
    853867  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    865879    treeReader->ReadEntry(entry);
    866880
    867     // Loop over all reconstructed jets in event
     881     // Loop over all reconstructed jets in event
    868882    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    869883    {
    870       recoObj = (T *)branchReco->At(i);
     884      recoObj = (T*) branchReco->At(i);
    871885      recoMomentum = recoObj->P4();
    872886
    873887      deltaR = 999;
    874888
    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)
     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)
    880894        {
    881895          genMomentum = particle->P4();
     
    888902          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    889903          {
    890             deltaR = genMomentum.DeltaR(recoMomentum);
    891             bestGenMomentum = genMomentum;
     904             deltaR = genMomentum.DeltaR(recoMomentum);
     905             bestGenMomentum = genMomentum;
    892906          }
    893907        }
     
    896910      if(deltaR < 0.3)
    897911      {
    898         e = bestGenMomentum.E();
     912        e  = bestGenMomentum.E();
    899913        eta = TMath::Abs(bestGenMomentum.Eta());
    900914
    901         for(bin = 0; bin < Nbins; bin++)
     915        for (bin = 0; bin < Nbins; bin++)
    902916        {
    903917          if(e > histos->at(bin).ptmin && e < histos->at(bin).ptmax && eta > etaMin && eta < etaMax)
    904918          {
    905             histos->at(bin).resolHist->Fill(recoMomentum.E() / bestGenMomentum.E());
     919            histos->at(bin).resolHist->Fill(recoMomentum.E()/bestGenMomentum.E());
    906920          }
    907921        }
     
    911925}
    912926
    913 template <typename T>
     927
     928template<typename T>
    914929void GetPtresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t ptMin, Double_t ptMax, ExRootTreeReader *treeReader)
    915930{
     
    919934
    920935  GenParticle *particle;
    921   T *recoObj;
     936  T* recoObj;
    922937
    923938  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    938953    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    939954    {
    940       recoObj = (T *)branchReco->At(i);
     955      recoObj = (T*) branchReco->At(i);
    941956      recoMomentum = recoObj->P4();
    942957
    943958      deltaR = 999;
    944959
    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)
     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)
    950965        {
    951966          genMomentum = particle->P4();
     
    958973          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    959974          {
    960             deltaR = genMomentum.DeltaR(recoMomentum);
    961             bestGenMomentum = genMomentum;
     975             deltaR = genMomentum.DeltaR(recoMomentum);
     976             bestGenMomentum = genMomentum;
    962977          }
    963978        }
     
    966981      if(deltaR < 0.3)
    967982      {
    968         pt = bestGenMomentum.Pt();
     983        pt  = bestGenMomentum.Pt();
    969984        eta = bestGenMomentum.Eta();
    970985
    971         for(bin = 0; bin < Nbins; bin++)
     986        for (bin = 0; bin < Nbins; bin++)
    972987        {
    973988          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && pt > ptMin && pt < ptMax)
    974989          {
    975             histos->at(bin).resolHist->Fill(recoMomentum.Pt() / bestGenMomentum.Pt());
     990             histos->at(bin).resolHist->Fill(recoMomentum.Pt()/bestGenMomentum.Pt());
    976991          }
    977992        }
     
    981996}
    982997
    983 template <typename T>
     998template<typename T>
    984999void GetEresVsEta(std::vector<resolPlot> *histos, TClonesArray *branchReco, TClonesArray *branchParticle, int pdgID, Double_t eMin, Double_t eMax, ExRootTreeReader *treeReader)
    9851000{
     
    9891004
    9901005  GenParticle *particle;
    991   T *recoObj;
     1006  T* recoObj;
    9921007
    9931008  TLorentzVector recoMomentum, genMomentum, bestGenMomentum;
     
    10081023    for(i = 0; i < branchReco->GetEntriesFast(); ++i)
    10091024    {
    1010       recoObj = (T *)branchReco->At(i);
     1025      recoObj = (T*) branchReco->At(i);
    10111026      recoMomentum = recoObj->P4();
    10121027
    10131028      deltaR = 999;
    10141029
    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)
     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)
    10201035        {
    10211036          genMomentum = particle->P4();
     
    10281043          if(genMomentum.DeltaR(recoMomentum) < deltaR)
    10291044          {
    1030             deltaR = genMomentum.DeltaR(recoMomentum);
    1031             bestGenMomentum = genMomentum;
     1045             deltaR = genMomentum.DeltaR(recoMomentum);
     1046             bestGenMomentum = genMomentum;
    10321047          }
    10331048        }
     
    10361051      if(deltaR < 0.3)
    10371052      {
    1038         e = bestGenMomentum.E();
     1053        e  = bestGenMomentum.E();
    10391054        eta = bestGenMomentum.Eta();
    10401055
    1041         for(bin = 0; bin < Nbins; bin++)
     1056
     1057
     1058        for (bin = 0; bin < Nbins; bin++)
    10421059        {
    10431060          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && e > eMin && e < eMax)
    10441061          {
    1045             histos->at(bin).resolHist->Fill(recoMomentum.E() / bestGenMomentum.E());
     1062             histos->at(bin).resolHist->Fill(recoMomentum.E()/bestGenMomentum.E());
    10461063          }
    10471064        }
     
    10511068}
    10521069
     1070
     1071
    10531072void GetJetsEres(std::vector<resolPlot> *histos, TClonesArray *branchJet, TClonesArray *branchGenJet, ExRootTreeReader *treeReader, Double_t etaMin, Double_t etaMax)
    10541073{
     
    10741093    treeReader->ReadEntry(entry);
    10751094
    1076     if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
     1095    if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
    10771096
    10781097    // Loop over all reconstructed jets in event
    1079     for(i = 0; i < TMath::Min(2, branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
     1098    for(i = 0; i < TMath::Min(2,branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
    10801099    {
    10811100
    1082       jet = (Jet *)branchJet->At(i);
     1101      jet = (Jet*) branchJet->At(i);
    10831102      jetMomentum = jet->P4();
    10841103
    10851104      deltaR = 999;
    10861105
    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);
     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);
    10911110
    10921111        genJetMomentum = genjet->P4();
     
    10991118        if(genJetMomentum.DeltaR(jetMomentum) < deltaR)
    11001119        {
    1101           deltaR = genJetMomentum.DeltaR(jetMomentum);
    1102           bestGenJetMomentum = genJetMomentum;
     1120           deltaR = genJetMomentum.DeltaR(jetMomentum);
     1121           bestGenJetMomentum = genJetMomentum;
    11031122        }
    11041123      }
     
    11061125      if(deltaR < 0.3)
    11071126      {
    1108         pt = genJetMomentum.E();
     1127        pt  = genJetMomentum.E();
    11091128        eta = genJetMomentum.Eta();
    11101129
    1111         for(bin = 0; bin < Nbins; bin++)
     1130        for (bin = 0; bin < Nbins; bin++)
    11121131        {
    11131132          if(pt > histos->at(bin).ptmin && pt < histos->at(bin).ptmax && eta < etaMax && eta > etaMin)
    11141133          {
    1115             histos->at(bin).resolHist->Fill(jetMomentum.E() / bestGenJetMomentum.E());
     1134             histos->at(bin).resolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
    11161135          }
    11171136        }
     
    11441163    treeReader->ReadEntry(entry);
    11451164
    1146     if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
     1165    if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
    11471166
    11481167    // Loop over all reconstructed jets in event
    1149     for(i = 0; i < TMath::Min(2, branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
     1168    for(i = 0; i < TMath::Min(2,branchJet->GetEntriesFast()); ++i) //branchJet->GetEntriesFast(); ++i)
    11501169    {
    11511170
    1152       jet = (Jet *)branchJet->At(i);
     1171      jet = (Jet*) branchJet->At(i);
    11531172      jetMomentum = jet->P4();
    11541173
    11551174      deltaR = 999;
    11561175
    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);
     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);
    11611180
    11621181        genJetMomentum = genjet->P4();
     
    11691188        if(genJetMomentum.DeltaR(jetMomentum) < deltaR)
    11701189        {
    1171           deltaR = genJetMomentum.DeltaR(jetMomentum);
    1172           bestGenJetMomentum = genJetMomentum;
     1190           deltaR = genJetMomentum.DeltaR(jetMomentum);
     1191           bestGenJetMomentum = genJetMomentum;
    11731192        }
    11741193      }
     
    11771196      {
    11781197
    1179         pt = genJetMomentum.E();
     1198        pt  = genJetMomentum.E();
    11801199        eta = genJetMomentum.Eta();
    11811200
    1182         for(bin = 0; bin < Nbins; bin++)
     1201        for (bin = 0; bin < Nbins; bin++)
    11831202        {
    11841203          if(eta > histos->at(bin).etamin && eta < histos->at(bin).etamax && pt < eMax && pt > eMin)
    11851204          {
    1186             histos->at(bin).resolHist->Fill(jetMomentum.E() / bestGenJetMomentum.E());
     1205             histos->at(bin).resolHist->Fill(jetMomentum.E()/bestGenJetMomentum.E());
    11871206          }
    11881207        }
     
    11921211}
    11931212
    1194 std::pair<Double_t, Double_t> GausFit(TH1 *hist)
     1213
     1214
     1215std::pair<Double_t, Double_t> GausFit(TH1* hist)
    11951216{
    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");
     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");
    12011222
    12021223  Double_t sig = f2->GetParameter(2);
     
    12051226  delete f1;
    12061227  delete f2;
    1207   return make_pair(sig, sigErr);
     1228  return make_pair (sig, sigErr);
    12081229}
     1230
    12091231
    12101232TGraphErrors EresGraph(std::vector<resolPlot> *histos, bool rms = false)
     
    12121234  Int_t bin;
    12131235  Int_t count = 0;
    1214   TGraphErrors gr = TGraphErrors(Nbins / 2);
     1236  TGraphErrors gr = TGraphErrors(Nbins/2);
    12151237  double val, error;
    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++;
     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++;
    12391261  }
    12401262
     
    12461268  Int_t bin;
    12471269  Int_t count = 0;
    1248   TGraphErrors gr = TGraphErrors(Nbins / 2);
     1270  TGraphErrors gr = TGraphErrors(Nbins/2);
    12491271  double val, error;
    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++;
     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++;
    12721294  }
    12731295
    12741296  return gr;
    12751297}
     1298
     1299
    12761300
    12771301TGraphErrors EresGraphVsEta(std::vector<resolPlot> *histos, bool rms = false)
     
    12791303  Int_t bin;
    12801304  Int_t count = 0;
    1281   TGraphErrors gr = TGraphErrors(Nbins / 2);
     1305  TGraphErrors gr = TGraphErrors(Nbins/2);
    12821306  double val, error;
    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++;
     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++;
    13051329  }
    13061330
     
    13321356    treeReader->ReadEntry(entry);
    13331357
    1334     if(entry % 10000 == 0) cout << "Event number: " << entry << endl;
    1335 
    1336     if(branchJet->GetEntriesFast() > 1)
     1358    if(entry%10000 == 0) cout << "Event number: "<< entry <<endl;
     1359
     1360    if (branchJet->GetEntriesFast() > 1)
    13371361    {
    13381362
    1339       jet = (Jet *)branchJet->At(0);
     1363      jet = (Jet*) branchJet->At(0);
    13401364      p1 = jet->P4();
    1341       jet = (Jet *)branchJet->At(1);
     1365      jet = (Jet*) branchJet->At(1);
    13421366      p2 = jet->P4();
    13431367
    1344       met = (MissingET *)branchMet->At(0);
    1345       scalarHT = (ScalarHT *)branchScalarHT->At(0);
     1368      met = (MissingET*) branchMet->At(0);
     1369      scalarHT = (ScalarHT*) branchScalarHT->At(0);
    13461370      ht = scalarHT->HT;
    13471371
    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++)
     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++)
    13521376      {
    1353         if(ht > histos->at(bin).ptmin && ht < histos->at(bin).ptmax)
     1377        if(ht > histos->at(bin).ptmin && ht < histos->at(bin).ptmax )
    13541378        {
    13551379          histos->at(bin).resolHist->Fill(met->P4().Px());
     
    13601384}
    13611385
     1386
     1387
    13621388//------------------------------------------------------------------------------
     1389
    13631390
    13641391void addResoGraph(TMultiGraph *mg, TGraphErrors *gr, TLegend *leg, int style, Color_t color, TString text)
     
    13731400  std::cout << "Adding " << gr->GetName() << std::endl;
    13741401  mg->Add(gr);
    1375   leg->AddEntry(gr, text, "p");
     1402  leg->AddEntry(gr,text,"p");
     1403
    13761404}
     1405
    13771406
    13781407void DrawAxis(TMultiGraph *mg, TLegend *leg, double xmin, double xmax, double ymin, double ymax, TString tx, TString ty, bool logx = 0, bool logy = 0)
     
    13801409  mg->SetMinimum(ymin);
    13811410  mg->SetMaximum(ymax);
    1382   mg->GetXaxis()->SetLimits(xmin, xmax);
     1411  mg->GetXaxis()->SetLimits(xmin,xmax);
    13831412
    13841413  mg->GetXaxis()->SetTitle(tx);
     
    14111440  if(logy) gPad->SetLogy();
    14121441
     1442
    14131443  //gPad->SetGridx();
    14141444  //gPad->SetGridy();
     
    14171447  gPad->Modified();
    14181448  gPad->Update();
     1449
    14191450}
     1451
    14201452
    14211453void DelphesValidation(
     
    15131545  colors.push_back(kBlue);
    15141546  colors.push_back(kRed);
    1515   colors.push_back(kGreen + 1);
    1516   colors.push_back(kMagenta + 1);
     1547  colors.push_back(kGreen+1);
     1548  colors.push_back(kMagenta+1);
    15171549  colors.push_back(kOrange);
    15181550
     
    15341566  Int_t lastSlash = figPath.Last('/');
    15351567  Int_t sizePath = figPath.Length();
    1536   figPath.Remove(lastSlash + 1, sizePath);
     1568  figPath.Remove(lastSlash+1,sizePath);
    15371569
    15381570  TString header = pdfOutput;
     
    15411573  lastSlash = header.Last('/');
    15421574  sizePath = header.Length();
    1543   header.Remove(0, lastSlash + 1);
     1575  header.Remove(0,lastSlash+1);
    15441576
    15451577  TString vrs(version);
    15461578
    1547   TPaveText *pave = new TPaveText(0.0, 0.89, 0.94, 0.94, "NDC");
     1579  TPaveText *pave = new TPaveText(0.0, 0.89, 0.94, 0.94,"NDC");
    15481580  pave->SetTextAlign(30);
    15491581  pave->SetTextFont(132);
     
    15521584  pave->SetFillColor(0);
    15531585  pave->SetFillStyle(0);
    1554   pave->AddText("Delphes " + vrs + " - " + header);
     1586  pave->AddText("Delphes "+vrs+" - "+header);
    15551587
    15561588  TString s_etaMin, s_etaMax, s_eta, s_pt, s_e;
     
    15781610  etaVals.push_back(6.0);
    15791611
    1580   const int n_etabins = etaVals.size() - 1;
     1612  const int n_etabins = etaVals.size()-1;
    15811613  const int n_ptbins = ptVals.size();
    15821614
     
    15871619  // --------- Pion Tracks  --------- //
    15881620
    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];
     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];
    16011633  TGraphErrors *gr_trkpi_res_eta = new TGraphErrors[n_ptbins];
    16021634  TGraphErrors *gr_trkpi_eff_eta = new TGraphErrors[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];
     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];
    16071639
    16081640  // loop over eta bins
    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);
     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);
    16281660  }
    16291661
    16301662  // loop over pt
    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);
     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);
    16481681
    16491682  mg_trkpi_res_pt->Draw("APE");
     
    16521685  pave->Draw();
    16531686
    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);
     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);
    16591692
    16601693  mg_trkpi_res_eta->Draw("APE");
     
    16631696  pave->Draw();
    16641697
    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);
     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);
    16701703
    16711704  mg_trkpi_eff_pt->Draw("APE");
     
    16741707  pave->Draw();
    16751708
    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);
     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);
    16811714
    16821715  mg_trkpi_eff_eta->Draw("APE");
     
    16851718  pave->Draw();
    16861719
    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");
     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");
    16901724
    16911725  // --------- Electron Tracks  --------- //
    16921726
    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];
     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];
    17051739  TGraphErrors *gr_trkele_res_eta = new TGraphErrors[n_ptbins];
    17061740  TGraphErrors *gr_trkele_eff_eta = new TGraphErrors[n_ptbins];
    17071741
    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];
     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];
    17121746
    17131747  // loop over eta bins
    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);
     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);
    17331767  }
    17341768
    17351769  // loop over pt
    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);
     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);
    17531788
    17541789  mg_trkele_res_pt->Draw("APE");
     
    17571792  pave->Draw();
    17581793
    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);
     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);
    17641799
    17651800  mg_trkele_res_eta->Draw("APE");
     
    17681803  pave->Draw();
    17691804
    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);
     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);
    17751810
    17761811  mg_trkele_eff_pt->Draw("APE");
     
    17791814  pave->Draw();
    17801815
    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);
     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);
    17861821
    17871822  mg_trkele_eff_eta->Draw("APE");
     
    17901825  pave->Draw();
    17911826
    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");
     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
    17951831
    17961832  // --------- Muon Tracks  --------- //
    17971833
    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];
     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];
    18111848  TGraphErrors *gr_trkmu_res_eta = new TGraphErrors[n_ptbins];
    18121849  TGraphErrors *gr_trkmu_eff_eta = new TGraphErrors[n_ptbins];
    18131850
    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];
     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];
    18181855
    18191856  // loop over eta bins
    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);
     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);
    18391876  }
    18401877
    18411878  // loop over pt
    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);
     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);
    18591897
    18601898  mg_trkmu_res_pt->Draw("APE");
     
    18631901  pave->Draw();
    18641902
    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);
     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);
    18701908
    18711909  mg_trkmu_res_eta->Draw("APE");
     
    18741912  pave->Draw();
    18751913
    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);
     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);
    18811919
    18821920  mg_trkmu_eff_pt->Draw("APE");
     
    18851923  pave->Draw();
    18861924
    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);
     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);
    18921930
    18931931  mg_trkmu_eff_eta->Draw("APE");
     
    18961934  pave->Draw();
    18971935
    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");
     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
    19011940
    19021941  //////////////////////
     
    19041943  //////////////////////
    19051944
    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];
     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];
    19161956  std::vector<resolPlot> *plots_ecal_res_eta = new std::vector<resolPlot>[n_ptbins];
    19171957
    19181958  // loop over eta bins
    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);
     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);
    19331973  }
    19341974
    19351975  // loop over pt
    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);
     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);
    19491989
    19501990  mg_ecal_res_e->Draw("APE");
    1951   // DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.5, 100, "E [GeV]", "(ECAL resolution in E)/E (%)", true, true);
     1991 // DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.5, 100, "E [GeV]", "(ECAL resolution in E)/E (%)", true, true);
    19521992  DrawAxis(mg_ecal_res_e, leg_ecal_res_e, ptMin, ptMax, 0.0, 20, "E [GeV]", "(ECAL resolution in E)/E (%)", true, false);
    19531993  leg_ecal_res_e->Draw();
    19541994  pave->Draw();
    19551995
    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);
     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);
    19612001
    19622002  mg_ecal_res_eta->Draw("APE");
     
    19662006  pave->Draw();
    19672007
    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");
     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");
    19712011
    19722012  //////////////////////
     
    19742014  //////////////////////
    19752015
    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];
     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];
    19832024  TGraphErrors *gr_hcal_res_eta = new TGraphErrors[n_ptbins];
    19842025
    1985   std::vector<resolPlot> *plots_hcal_res_e = new std::vector<resolPlot>[n_etabins];
     2026  std::vector<resolPlot> *plots_hcal_res_e   = new std::vector<resolPlot>[n_etabins];
    19862027  std::vector<resolPlot> *plots_hcal_res_eta = new std::vector<resolPlot>[n_ptbins];
    19872028
    19882029  // loop over eta bins
    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);
     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);
    20042045  }
    20052046
    20062047  // loop over pt
    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);
     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);
    20202062
    20212063  mg_hcal_res_e->Draw("APE");
     
    20252067  pave->Draw();
    20262068
    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);
     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);
    20322074
    20332075  mg_hcal_res_eta->Draw("APE");
     
    20372079  pave->Draw();
    20382080
    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");
     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");
    20422084
    20432085  ////////////////////
     
    20562098  TGraphErrors *gr_trkele_res_eeta = new TGraphErrors[n_ptbins];
    20572099
    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];
     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];
    20612103  std::vector<resolPlot> *plots_trkele_res_eeta = new std::vector<resolPlot>[n_ptbins];
    20622104
     
    20642106  TCanvas *c_pfele_res_eta[n_ptbins];
    20652107
     2108
    20662109  // loop over eta bins
    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");
     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
    21442191  }
    21452192
     
    21542201  TLegend *leg_pfpi_res_eta[n_ptbins];
    21552202
    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];
     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];
    21602207  TGraphErrors *gr_trkpi_res_eeta = new TGraphErrors[n_ptbins];
    21612208
    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];
     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];
    21652212  std::vector<resolPlot> *plots_trkpi_res_eeta = new std::vector<resolPlot>[n_ptbins];
    21662213
     
    21682215  TCanvas *c_pfpi_res_eta[n_ptbins];
    21692216
     2217
    21702218  // loop over eta bins
    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   }
     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
    22492303
    22502304  /////////////////
     
    22582312  TLegend *leg_pfjet_res_eta[n_ptbins];
    22592313
    2260   TGraphErrors *gr_pfjet_res_e = new TGraphErrors[n_etabins];
     2314  TGraphErrors *gr_pfjet_res_e   = new TGraphErrors[n_etabins];
    22612315  TGraphErrors *gr_pfjet_res_eta = new TGraphErrors[n_ptbins];
    22622316
    2263   TGraphErrors *gr_cajet_res_e = new TGraphErrors[n_etabins];
     2317  TGraphErrors *gr_cajet_res_e   = new TGraphErrors[n_etabins];
    22642318  TGraphErrors *gr_cajet_res_eta = new TGraphErrors[n_ptbins];
    22652319
    2266   std::vector<resolPlot> *plots_pfjet_res_e = new std::vector<resolPlot>[n_etabins];
     2320  std::vector<resolPlot> *plots_pfjet_res_e   = new std::vector<resolPlot>[n_etabins];
    22672321  std::vector<resolPlot> *plots_pfjet_res_eta = new std::vector<resolPlot>[n_ptbins];
    2268   std::vector<resolPlot> *plots_cajet_res_e = new std::vector<resolPlot>[n_etabins];
     2322  std::vector<resolPlot> *plots_cajet_res_e   = new std::vector<resolPlot>[n_etabins];
    22692323  std::vector<resolPlot> *plots_cajet_res_eta = new std::vector<resolPlot>[n_ptbins];
    22702324
     
    22722326  TCanvas *c_pfjet_res_eta[n_ptbins];
    22732327
     2328
    22742329  // loop over eta bins
    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();
     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();
    23062441    pave->Draw();
    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();
     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++)
     2463    {
     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);
     2476    }
     2477
     2478    // loop over pt
     2479    for (k = 0; k < ptVals.size(); k++)
     2480    {
     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();
    23462495    pave->Draw();
    23472496
    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++)
     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++)
    29172529    {
    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();
     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);
    29272542    }
    29282543
    2929     for(k = 0; k < ptVals.size(); k++)
     2544    // loop over pt
     2545    for (k = 0; k < ptVals.size(); k++)
    29302546    {
    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();
     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
    29403009    }
    29413010
    29423011    plots_pfmet.at(bin).resolHist->Write();
    29433012    plots_camet.at(bin).resolHist->Write();
     3013
    29443014  }
    29453015
    29463016  fout->Write();
     3017
    29473018
    29483019  cout << "** Exiting..." << endl;
     
    29943065  DelphesValidation(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7], argv[8], argv[9], argv[10], argv[11]);
    29953066}
     3067
     3068
     3069
Note: See TracChangeset for help on using the changeset viewer.