Changes in / [2d7ff18:83ee320] in git
- Files:
-
- 25 added
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
.circleci/config.yml
r2d7ff18 r83ee320 8 8 command: | 9 9 make distclean 10 make -j `nproc`HAS_PYTHIA8=true10 make -j 8 HAS_PYTHIA8=true 11 11 - run: 12 12 name: Build Delphes using cmake … … 16 16 cd build 17 17 cmake .. 18 make -j `nproc`18 make -j 8 19 19 20 20 jobs: … … 27 27 docker: 28 28 - image: delphes/ubuntu:18.04 29 fedora- 28:29 fedora-30: 30 30 <<: *shared 31 31 docker: 32 - image: delphes/fedora: 2832 - image: delphes/fedora:30 33 33 34 34 workflows: … … 38 38 - ubuntu-1404 39 39 - ubuntu-1804 40 - fedora- 2840 - fedora-30 -
CHANGELOG
r2d7ff18 r83ee320 1 1 3.4.2: 2 2 - added DenseTrackFilter for modelling tracking inefficiencies in boosted, dense environments 3 - added detector cards for CLIC and HL-LHCdetectors3 - added detector cards for CLIC, HL-LHC and IDEA detectors 4 4 - added muons to Tower collection used for jets reconstruction and MET calculation in the ATLAS card (#1118) 5 5 - added Weight branch to HepMC -
Makefile
r2d7ff18 r83ee320 413 413 modules/DenseTrackFilter.h \ 414 414 modules/Calorimeter.h \ 415 modules/DualReadoutCalorimeter.h \ 415 416 modules/OldCalorimeter.h \ 416 417 modules/Isolation.h \ … … 427 428 modules/JetPileUpSubtractor.h \ 428 429 modules/TrackPileUpSubtractor.h \ 430 modules/TrackTimingPileUpSubtractor.h \ 429 431 modules/TaggingParticlesSkimmer.h \ 430 432 modules/PileUpJetID.h \ … … 443 445 modules/VertexFinder.h \ 444 446 modules/VertexFinderDA4D.h \ 447 modules/HighMassVertexRecover.h \ 448 modules/DecayFilter.h \ 445 449 modules/ExampleModule.h 446 450 tmp/modules/ModulesDict$(PcmSuf): \ … … 694 698 external/ExRootAnalysis/ExRootFilter.h \ 695 699 external/ExRootAnalysis/ExRootResult.h 700 tmp/modules/DecayFilter.$(ObjSuf): \ 701 modules/DecayFilter.$(SrcSuf) \ 702 modules/DecayFilter.h \ 703 classes/DelphesClasses.h \ 704 classes/DelphesFactory.h \ 705 classes/DelphesFormula.h \ 706 external/ExRootAnalysis/ExRootClassifier.h \ 707 external/ExRootAnalysis/ExRootFilter.h \ 708 external/ExRootAnalysis/ExRootResult.h 696 709 tmp/modules/Delphes.$(ObjSuf): \ 697 710 modules/Delphes.$(SrcSuf) \ … … 714 727 external/ExRootAnalysis/ExRootFilter.h \ 715 728 external/ExRootAnalysis/ExRootResult.h 729 tmp/modules/DualReadoutCalorimeter.$(ObjSuf): \ 730 modules/DualReadoutCalorimeter.$(SrcSuf) \ 731 modules/DualReadoutCalorimeter.h \ 732 classes/DelphesClasses.h \ 733 classes/DelphesFactory.h \ 734 classes/DelphesFormula.h \ 735 external/ExRootAnalysis/ExRootResult.h \ 736 external/ExRootAnalysis/ExRootFilter.h \ 737 external/ExRootAnalysis/ExRootClassifier.h 716 738 tmp/modules/Efficiency.$(ObjSuf): \ 717 739 modules/Efficiency.$(SrcSuf) \ … … 762 784 external/Hector/H_BeamParticle.h \ 763 785 external/Hector/H_RecRPObject.h 786 tmp/modules/HighMassVertexRecover.$(ObjSuf): \ 787 modules/HighMassVertexRecover.$(SrcSuf) \ 788 modules/HighMassVertexRecover.h \ 789 classes/DelphesClasses.h \ 790 classes/DelphesFactory.h \ 791 classes/DelphesFormula.h \ 792 external/ExRootAnalysis/ExRootResult.h \ 793 external/ExRootAnalysis/ExRootFilter.h \ 794 external/ExRootAnalysis/ExRootClassifier.h 764 795 tmp/modules/IdentificationMap.$(ObjSuf): \ 765 796 modules/IdentificationMap.$(SrcSuf) \ … … 996 1027 modules/TrackSmearing.$(SrcSuf) \ 997 1028 modules/TrackSmearing.h \ 1029 classes/DelphesClasses.h \ 1030 classes/DelphesFactory.h \ 1031 classes/DelphesFormula.h \ 1032 external/ExRootAnalysis/ExRootClassifier.h \ 1033 external/ExRootAnalysis/ExRootFilter.h \ 1034 external/ExRootAnalysis/ExRootResult.h 1035 tmp/modules/TrackTimingPileUpSubtractor.$(ObjSuf): \ 1036 modules/TrackTimingPileUpSubtractor.$(SrcSuf) \ 1037 modules/TrackTimingPileUpSubtractor.h \ 998 1038 classes/DelphesClasses.h \ 999 1039 classes/DelphesFactory.h \ … … 1038 1078 classes/DelphesFormula.h \ 1039 1079 classes/DelphesPileUpReader.h \ 1040 external/ExRootAnalysis/ExRoot Classifier.h \1041 external/ExRootAnalysis/ExRootFilter.h \ 1042 external/ExRootAnalysis/ExRoot Result.h1080 external/ExRootAnalysis/ExRootResult.h \ 1081 external/ExRootAnalysis/ExRootFilter.h \ 1082 external/ExRootAnalysis/ExRootClassifier.h 1043 1083 tmp/modules/VertexSorter.$(ObjSuf): \ 1044 1084 modules/VertexSorter.$(SrcSuf) \ … … 1117 1157 tmp/modules/Cloner.$(ObjSuf) \ 1118 1158 tmp/modules/ConstituentFilter.$(ObjSuf) \ 1159 tmp/modules/DecayFilter.$(ObjSuf) \ 1119 1160 tmp/modules/Delphes.$(ObjSuf) \ 1120 1161 tmp/modules/DenseTrackFilter.$(ObjSuf) \ 1162 tmp/modules/DualReadoutCalorimeter.$(ObjSuf) \ 1121 1163 tmp/modules/Efficiency.$(ObjSuf) \ 1122 1164 tmp/modules/EnergyScale.$(ObjSuf) \ … … 1124 1166 tmp/modules/ExampleModule.$(ObjSuf) \ 1125 1167 tmp/modules/Hector.$(ObjSuf) \ 1168 tmp/modules/HighMassVertexRecover.$(ObjSuf) \ 1126 1169 tmp/modules/IdentificationMap.$(ObjSuf) \ 1127 1170 tmp/modules/ImpactParameterSmearing.$(ObjSuf) \ … … 1150 1193 tmp/modules/TrackPileUpSubtractor.$(ObjSuf) \ 1151 1194 tmp/modules/TrackSmearing.$(ObjSuf) \ 1195 tmp/modules/TrackTimingPileUpSubtractor.$(ObjSuf) \ 1152 1196 tmp/modules/TreeWriter.$(ObjSuf) \ 1153 1197 tmp/modules/UniqueObjectFinder.$(ObjSuf) \ … … 1911 1955 @touch $@ 1912 1956 1957 modules/DecayFilter.h: \ 1958 classes/DelphesModule.h 1959 @touch $@ 1960 1913 1961 external/fastjet/internal/TilingExtent.hh: \ 1914 1962 external/fastjet/ClusterSequence.hh … … 2067 2115 @touch $@ 2068 2116 2117 modules/TrackTimingPileUpSubtractor.h: \ 2118 classes/DelphesModule.h 2119 @touch $@ 2120 2069 2121 modules/Delphes.h: \ 2070 2122 classes/DelphesModule.h … … 2243 2295 @touch $@ 2244 2296 2297 modules/HighMassVertexRecover.h: \ 2298 classes/DelphesModule.h \ 2299 classes/DelphesClasses.h 2300 @touch $@ 2301 2245 2302 classes/DelphesClasses.h: \ 2246 2303 classes/SortableObject.h … … 2257 2314 2258 2315 modules/BeamSpotFilter.h: \ 2316 classes/DelphesModule.h 2317 @touch $@ 2318 2319 modules/DualReadoutCalorimeter.h: \ 2259 2320 classes/DelphesModule.h 2260 2321 @touch $@ -
README
r2d7ff18 r83ee320 66 66 Open ROOT file and do some basic analysis using Draw or TBrowser: 67 67 68 TFile ::Open("delphes_output.root");69 Delphes->Draw("Electron.PT");68 TFile *f = TFile::Open("delphes_output.root"); 69 f->Get("Delphes")->Draw("Electron.PT"); 70 70 TBrowser browser; 71 71 -
README.md
r2d7ff18 r83ee320 89 89 90 90 ``` 91 TFile ::Open("delphes_output.root");92 Delphes->Draw("Electron.PT");91 TFile *f = TFile::Open("delphes_output.root"); 92 f->Get("Delphes")->Draw("Electron.PT"); 93 93 TBrowser browser; 94 94 ``` -
cards/FCC/FCChh.tcl
r2d7ff18 r83ee320 1239 1239 1240 1240 (pt <= 10.0) * (0.00) + 1241 (abs(eta) < 2.5) * (pt > 10.0 && pt < 5000.0) * (0. 6) + \1242 (abs(eta) < 2.5) * (pt > 5000.0 && pt < 34000.0) * (0. 6) *(8./9. - pt/30000.) + \1241 (abs(eta) < 2.5) * (pt > 10.0 && pt < 5000.0) * (0.8) + \ 1242 (abs(eta) < 2.5) * (pt > 5000.0 && pt < 34000.0) * (0.8) *(8./9. - pt/30000.) + \ 1243 1243 (abs(eta) < 2.5) * (pt > 34000.0) * (0.000) + \ 1244 (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 10.0 && pt < 5000.0) * (0. 45) + \1245 (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 5000.0 && pt < 34000.0) * (0. 45)*(8./9. - pt/30000.) + \1244 (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 10.0 && pt < 5000.0) * (0.65) + \ 1245 (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 5000.0 && pt < 34000.0) * (0.65)*(8./9. - pt/30000.) + \ 1246 1246 (abs(eta) > 2.5 && abs(eta) < 4.0) * (pt > 34000.0) * (0.00) + \ 1247 1247 (abs(eta) > 4.0) * (0.00)} -
cards/delphes_card_CLICdet_Stage1.tcl
r2d7ff18 r83ee320 1 1 ####################################### 2 2 # CLICdet model 3 # based on CLICdp-Note-2017-001 3 # based on arXiv:1812.07337 and 4 # CLICdp-Note-2017-001 5 # 4 6 # Ulrike Schnoor ulrike.schnoor@cern.ch 5 7 # … … 11 13 # according to final state 12 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 20 ####################################### 14 21 # Order of execution of various modules … … 707 714 set OutputArray photons 708 715 709 set DeltaRMax 0. 5716 set DeltaRMax 0.1 710 717 711 718 set PTMin 0.5 712 719 713 set PTRatioMax 0. 12720 set PTRatioMax 0.2 714 721 } 715 722 … … 805 812 set OutputArray electrons 806 813 807 set DeltaRMax 0. 5814 set DeltaRMax 0.1 808 815 809 816 set PTMin 0.5 810 817 811 set PTRatioMax 0. 12818 set PTRatioMax 0.2 812 819 } 813 820 … … 844 851 set OutputArray muons 845 852 846 set DeltaRMax 0. 5853 set DeltaRMax 0.1 847 854 848 855 set PTMin 0.5 849 856 850 set PTRatioMax 0.2 5857 set PTRatioMax 0.2 851 858 } 852 859 -
cards/delphes_card_CLICdet_Stage2.tcl
r2d7ff18 r83ee320 1 1 ####################################### 2 2 # CLICdet model 3 # based on CLICdp-Note-2017-001 3 # based on arXiv:1812.07337 and 4 # CLICdp-Note-2017-001 5 # 4 6 # Ulrike Schnoor ulrike.schnoor@cern.ch 5 7 # … … 11 13 # according to final state 12 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 20 ####################################### 14 21 # Order of execution of various modules … … 124 131 125 132 JetFlavorAssociation_R05N2 126 JetFlavorAssociation_R05N3 127 JetFlavorAssociation_R05N4 128 JetFlavorAssociation_R05N5 129 JetFlavorAssociation_R05N6 130 131 JetFlavorAssociation_R07N2 132 JetFlavorAssociation_R07N3 133 JetFlavorAssociation_R07N4 134 JetFlavorAssociation_R07N5 135 JetFlavorAssociation_R07N6 136 137 JetFlavorAssociation_R10N2 138 JetFlavorAssociation_R10N3 139 JetFlavorAssociation_R10N4 140 JetFlavorAssociation_R10N5 141 JetFlavorAssociation_R10N6 142 143 JetFlavorAssociation_R12N2 144 JetFlavorAssociation_R12N3 145 JetFlavorAssociation_R12N4 146 JetFlavorAssociation_R12N5 147 JetFlavorAssociation_R12N6 148 149 JetFlavorAssociation_R15N2 150 JetFlavorAssociation_R15N3 151 JetFlavorAssociation_R15N4 152 JetFlavorAssociation_R15N5 153 JetFlavorAssociation_R15N6 154 155 JetFlavorAssociation_R05_inclusive 156 JetFlavorAssociation_R07_inclusive 157 JetFlavorAssociation_R10_inclusive 158 JetFlavorAssociation_R12_inclusive 159 JetFlavorAssociation_R15_inclusive 160 161 162 BTaggingWP50_R05N2 163 BTaggingWP70_R05N2 164 BTaggingWP90_R05N2 165 BTaggingWP50_R05N3 166 BTaggingWP70_R05N3 167 BTaggingWP90_R05N3 168 BTaggingWP50_R05N4 169 BTaggingWP70_R05N4 170 BTaggingWP90_R05N4 171 BTaggingWP50_R05N5 172 BTaggingWP70_R05N5 173 BTaggingWP90_R05N5 174 BTaggingWP50_R05N6 175 BTaggingWP70_R05N6 176 BTaggingWP90_R05N6 177 BTaggingWP50_R07N2 178 BTaggingWP70_R07N2 179 BTaggingWP90_R07N2 180 BTaggingWP50_R07N3 181 BTaggingWP70_R07N3 182 BTaggingWP90_R07N3 183 BTaggingWP50_R07N4 184 BTaggingWP70_R07N4 185 BTaggingWP90_R07N4 186 BTaggingWP50_R07N5 187 BTaggingWP70_R07N5 188 BTaggingWP90_R07N5 189 BTaggingWP50_R07N6 190 BTaggingWP70_R07N6 191 BTaggingWP90_R07N6 192 BTaggingWP50_R10N2 193 BTaggingWP70_R10N2 194 BTaggingWP90_R10N2 195 BTaggingWP50_R10N3 196 BTaggingWP70_R10N3 197 BTaggingWP90_R10N3 198 BTaggingWP50_R10N4 199 BTaggingWP70_R10N4 200 BTaggingWP90_R10N4 201 BTaggingWP50_R10N5 202 BTaggingWP70_R10N5 203 BTaggingWP90_R10N5 204 BTaggingWP50_R10N6 205 BTaggingWP70_R10N6 206 BTaggingWP90_R10N6 207 BTaggingWP50_R12N2 208 BTaggingWP70_R12N2 209 BTaggingWP90_R12N2 210 BTaggingWP50_R12N3 211 BTaggingWP70_R12N3 212 BTaggingWP90_R12N3 213 BTaggingWP50_R12N4 214 BTaggingWP70_R12N4 215 BTaggingWP90_R12N4 216 BTaggingWP50_R12N5 217 BTaggingWP70_R12N5 218 BTaggingWP90_R12N5 219 BTaggingWP50_R12N6 220 BTaggingWP70_R12N6 221 BTaggingWP90_R12N6 222 BTaggingWP50_R15N2 223 BTaggingWP70_R15N2 224 BTaggingWP90_R15N2 225 BTaggingWP50_R15N3 226 BTaggingWP70_R15N3 227 BTaggingWP90_R15N3 228 BTaggingWP50_R15N4 229 BTaggingWP70_R15N4 230 BTaggingWP90_R15N4 231 BTaggingWP50_R15N5 232 BTaggingWP70_R15N5 233 BTaggingWP90_R15N5 234 BTaggingWP50_R15N6 235 BTaggingWP70_R15N6 236 BTaggingWP90_R15N6 133 JetFlavorAssociation_R05N3 134 JetFlavorAssociation_R05N4 135 JetFlavorAssociation_R05N5 136 JetFlavorAssociation_R05N6 137 138 JetFlavorAssociation_R07N2 139 JetFlavorAssociation_R07N3 140 JetFlavorAssociation_R07N4 141 JetFlavorAssociation_R07N5 142 JetFlavorAssociation_R07N6 143 144 JetFlavorAssociation_R10N2 145 JetFlavorAssociation_R10N3 146 JetFlavorAssociation_R10N4 147 JetFlavorAssociation_R10N5 148 JetFlavorAssociation_R10N6 149 150 JetFlavorAssociation_R12N2 151 JetFlavorAssociation_R12N3 152 JetFlavorAssociation_R12N4 153 JetFlavorAssociation_R12N5 154 JetFlavorAssociation_R12N6 155 156 JetFlavorAssociation_R15N2 157 JetFlavorAssociation_R15N3 158 JetFlavorAssociation_R15N4 159 JetFlavorAssociation_R15N5 160 JetFlavorAssociation_R15N6 161 162 JetFlavorAssociation_R05_inclusive 163 JetFlavorAssociation_R07_inclusive 164 JetFlavorAssociation_R10_inclusive 165 JetFlavorAssociation_R12_inclusive 166 JetFlavorAssociation_R15_inclusive 167 168 169 JetFlavorAssociation_JER_R05N2 170 JetFlavorAssociation_JER_R05N3 171 JetFlavorAssociation_JER_R05N4 172 JetFlavorAssociation_JER_R05N5 173 JetFlavorAssociation_JER_R05N6 174 175 JetFlavorAssociation_JER_R07N2 176 JetFlavorAssociation_JER_R07N3 177 JetFlavorAssociation_JER_R07N4 178 JetFlavorAssociation_JER_R07N5 179 JetFlavorAssociation_JER_R07N6 180 181 JetFlavorAssociation_JER_R10N2 182 JetFlavorAssociation_JER_R10N3 183 JetFlavorAssociation_JER_R10N4 184 JetFlavorAssociation_JER_R10N5 185 JetFlavorAssociation_JER_R10N6 186 187 JetFlavorAssociation_JER_R12N2 188 JetFlavorAssociation_JER_R12N3 189 JetFlavorAssociation_JER_R12N4 190 JetFlavorAssociation_JER_R12N5 191 JetFlavorAssociation_JER_R12N6 192 193 JetFlavorAssociation_JER_R15N2 194 JetFlavorAssociation_JER_R15N3 195 JetFlavorAssociation_JER_R15N4 196 JetFlavorAssociation_JER_R15N5 197 JetFlavorAssociation_JER_R15N6 198 199 JetFlavorAssociation_JER_R05_inclusive 200 JetFlavorAssociation_JER_R07_inclusive 201 JetFlavorAssociation_JER_R10_inclusive 202 JetFlavorAssociation_JER_R12_inclusive 203 JetFlavorAssociation_JER_R15_inclusive 204 205 206 BTaggingWP50_R05N2 207 BTaggingWP70_R05N2 208 BTaggingWP90_R05N2 209 BTaggingWP50_R05N3 210 BTaggingWP70_R05N3 211 BTaggingWP90_R05N3 212 BTaggingWP50_R05N4 213 BTaggingWP70_R05N4 214 BTaggingWP90_R05N4 215 BTaggingWP50_R05N5 216 BTaggingWP70_R05N5 217 BTaggingWP90_R05N5 218 BTaggingWP50_R05N6 219 BTaggingWP70_R05N6 220 BTaggingWP90_R05N6 221 BTaggingWP50_R07N2 222 BTaggingWP70_R07N2 223 BTaggingWP90_R07N2 224 BTaggingWP50_R07N3 225 BTaggingWP70_R07N3 226 BTaggingWP90_R07N3 227 BTaggingWP50_R07N4 228 BTaggingWP70_R07N4 229 BTaggingWP90_R07N4 230 BTaggingWP50_R07N5 231 BTaggingWP70_R07N5 232 BTaggingWP90_R07N5 233 BTaggingWP50_R07N6 234 BTaggingWP70_R07N6 235 BTaggingWP90_R07N6 236 BTaggingWP50_R10N2 237 BTaggingWP70_R10N2 238 BTaggingWP90_R10N2 239 BTaggingWP50_R10N3 240 BTaggingWP70_R10N3 241 BTaggingWP90_R10N3 242 BTaggingWP50_R10N4 243 BTaggingWP70_R10N4 244 BTaggingWP90_R10N4 245 BTaggingWP50_R10N5 246 BTaggingWP70_R10N5 247 BTaggingWP90_R10N5 248 BTaggingWP50_R10N6 249 BTaggingWP70_R10N6 250 BTaggingWP90_R10N6 251 BTaggingWP50_R12N2 252 BTaggingWP70_R12N2 253 BTaggingWP90_R12N2 254 BTaggingWP50_R12N3 255 BTaggingWP70_R12N3 256 BTaggingWP90_R12N3 257 BTaggingWP50_R12N4 258 BTaggingWP70_R12N4 259 BTaggingWP90_R12N4 260 BTaggingWP50_R12N5 261 BTaggingWP70_R12N5 262 BTaggingWP90_R12N5 263 BTaggingWP50_R12N6 264 BTaggingWP70_R12N6 265 BTaggingWP90_R12N6 266 BTaggingWP50_R15N2 267 BTaggingWP70_R15N2 268 BTaggingWP90_R15N2 269 BTaggingWP50_R15N3 270 BTaggingWP70_R15N3 271 BTaggingWP90_R15N3 272 BTaggingWP50_R15N4 273 BTaggingWP70_R15N4 274 BTaggingWP90_R15N4 275 BTaggingWP50_R15N5 276 BTaggingWP70_R15N5 277 BTaggingWP90_R15N5 278 BTaggingWP50_R15N6 279 BTaggingWP70_R15N6 280 BTaggingWP90_R15N6 237 281 BTaggingWP50_R05_inclusive 238 282 BTaggingWP70_R05_inclusive … … 251 295 BTaggingWP90_R15_inclusive 252 296 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 253 390 254 391 TauTagging_R05N2 … … 277 414 TauTagging_R15N5 278 415 TauTagging_R15N6 279 280 416 TauTagging_R05_inclusive 281 417 TauTagging_R07_inclusive … … 283 419 TauTagging_R12_inclusive 284 420 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 285 452 286 453 … … 739 906 set OutputArray photons 740 907 741 set DeltaRMax 0. 5908 set DeltaRMax 0.1 742 909 743 910 set PTMin 0.5 744 911 745 set PTRatioMax 0. 12912 set PTRatioMax 0.2 746 913 } 747 914 … … 837 1004 set OutputArray electrons 838 1005 839 set DeltaRMax 0. 51006 set DeltaRMax 0.1 840 1007 841 1008 set PTMin 0.5 842 1009 843 set PTRatioMax 0. 121010 set PTRatioMax 0.2 844 1011 } 845 1012 … … 875 1042 set OutputArray muons 876 1043 877 set DeltaRMax 0. 51044 set DeltaRMax 0.1 878 1045 879 1046 set PTMin 0.5 880 1047 881 set PTRatioMax 0.2 51048 set PTRatioMax 0.2 882 1049 } 883 1050 … … 1000 1167 1001 1168 source CLIC/CLICdet_JetFlavorAssociation.tcl 1169 source CLIC/CLICdet_JetFlavorAssociation_JER.tcl 1002 1170 1003 1171 ########### … … 1007 1175 1008 1176 source CLIC/CLICdet_BTagging.tcl 1177 source CLIC/CLICdet_BTagging_JER.tcl 1009 1178 1010 1179 … … 1015 1184 1016 1185 source CLIC/CLICdet_TauTagging.tcl 1186 source CLIC/CLICdet_TauTagging_JER.tcl 1017 1187 1018 1188 -
cards/delphes_card_CLICdet_Stage3.tcl
r2d7ff18 r83ee320 1 1 ####################################### 2 2 # CLICdet model 3 # based on CLICdp-Note-2017-001 3 # based on arXiv:1812.07337 and 4 # CLICdp-Note-2017-001 5 # 4 6 # Ulrike Schnoor ulrike.schnoor@cern.ch 5 #6 7 # 7 8 # For the high energy stage of … … 11 12 # use exclusive clustering with njets 12 13 # according to final state 13 # 14 # 15 # c-tagging capabilities of CLICdet are 16 # not yet implemented here. Please 17 # contact us if you want to use it. 18 ####################################### 19 14 20 ####################################### 15 21 # Order of execution of various modules … … 125 131 126 132 JetFlavorAssociation_R05N2 127 JetFlavorAssociation_R05N3 128 JetFlavorAssociation_R05N4 129 JetFlavorAssociation_R05N5 130 JetFlavorAssociation_R05N6 131 132 JetFlavorAssociation_R07N2 133 JetFlavorAssociation_R07N3 134 JetFlavorAssociation_R07N4 135 JetFlavorAssociation_R07N5 136 JetFlavorAssociation_R07N6 137 138 JetFlavorAssociation_R10N2 139 JetFlavorAssociation_R10N3 140 JetFlavorAssociation_R10N4 141 JetFlavorAssociation_R10N5 142 JetFlavorAssociation_R10N6 143 144 JetFlavorAssociation_R12N2 145 JetFlavorAssociation_R12N3 146 JetFlavorAssociation_R12N4 147 JetFlavorAssociation_R12N5 148 JetFlavorAssociation_R12N6 149 150 JetFlavorAssociation_R15N2 151 JetFlavorAssociation_R15N3 152 JetFlavorAssociation_R15N4 153 JetFlavorAssociation_R15N5 154 JetFlavorAssociation_R15N6 155 156 JetFlavorAssociation_R05_inclusive 157 JetFlavorAssociation_R07_inclusive 158 JetFlavorAssociation_R10_inclusive 159 JetFlavorAssociation_R12_inclusive 160 JetFlavorAssociation_R15_inclusive 161 162 163 BTaggingWP50_R05N2 164 BTaggingWP70_R05N2 165 BTaggingWP90_R05N2 166 BTaggingWP50_R05N3 167 BTaggingWP70_R05N3 168 BTaggingWP90_R05N3 169 BTaggingWP50_R05N4 170 BTaggingWP70_R05N4 171 BTaggingWP90_R05N4 172 BTaggingWP50_R05N5 173 BTaggingWP70_R05N5 174 BTaggingWP90_R05N5 175 BTaggingWP50_R05N6 176 BTaggingWP70_R05N6 177 BTaggingWP90_R05N6 178 BTaggingWP50_R07N2 179 BTaggingWP70_R07N2 180 BTaggingWP90_R07N2 181 BTaggingWP50_R07N3 182 BTaggingWP70_R07N3 183 BTaggingWP90_R07N3 184 BTaggingWP50_R07N4 185 BTaggingWP70_R07N4 186 BTaggingWP90_R07N4 187 BTaggingWP50_R07N5 188 BTaggingWP70_R07N5 189 BTaggingWP90_R07N5 190 BTaggingWP50_R07N6 191 BTaggingWP70_R07N6 192 BTaggingWP90_R07N6 193 BTaggingWP50_R10N2 194 BTaggingWP70_R10N2 195 BTaggingWP90_R10N2 196 BTaggingWP50_R10N3 197 BTaggingWP70_R10N3 198 BTaggingWP90_R10N3 199 BTaggingWP50_R10N4 200 BTaggingWP70_R10N4 201 BTaggingWP90_R10N4 202 BTaggingWP50_R10N5 203 BTaggingWP70_R10N5 204 BTaggingWP90_R10N5 205 BTaggingWP50_R10N6 206 BTaggingWP70_R10N6 207 BTaggingWP90_R10N6 208 BTaggingWP50_R12N2 209 BTaggingWP70_R12N2 210 BTaggingWP90_R12N2 211 BTaggingWP50_R12N3 212 BTaggingWP70_R12N3 213 BTaggingWP90_R12N3 214 BTaggingWP50_R12N4 215 BTaggingWP70_R12N4 216 BTaggingWP90_R12N4 217 BTaggingWP50_R12N5 218 BTaggingWP70_R12N5 219 BTaggingWP90_R12N5 220 BTaggingWP50_R12N6 221 BTaggingWP70_R12N6 222 BTaggingWP90_R12N6 223 BTaggingWP50_R15N2 224 BTaggingWP70_R15N2 225 BTaggingWP90_R15N2 226 BTaggingWP50_R15N3 227 BTaggingWP70_R15N3 228 BTaggingWP90_R15N3 229 BTaggingWP50_R15N4 230 BTaggingWP70_R15N4 231 BTaggingWP90_R15N4 232 BTaggingWP50_R15N5 233 BTaggingWP70_R15N5 234 BTaggingWP90_R15N5 235 BTaggingWP50_R15N6 236 BTaggingWP70_R15N6 237 BTaggingWP90_R15N6 133 JetFlavorAssociation_R05N3 134 JetFlavorAssociation_R05N4 135 JetFlavorAssociation_R05N5 136 JetFlavorAssociation_R05N6 137 138 JetFlavorAssociation_R07N2 139 JetFlavorAssociation_R07N3 140 JetFlavorAssociation_R07N4 141 JetFlavorAssociation_R07N5 142 JetFlavorAssociation_R07N6 143 144 JetFlavorAssociation_R10N2 145 JetFlavorAssociation_R10N3 146 JetFlavorAssociation_R10N4 147 JetFlavorAssociation_R10N5 148 JetFlavorAssociation_R10N6 149 150 JetFlavorAssociation_R12N2 151 JetFlavorAssociation_R12N3 152 JetFlavorAssociation_R12N4 153 JetFlavorAssociation_R12N5 154 JetFlavorAssociation_R12N6 155 156 JetFlavorAssociation_R15N2 157 JetFlavorAssociation_R15N3 158 JetFlavorAssociation_R15N4 159 JetFlavorAssociation_R15N5 160 JetFlavorAssociation_R15N6 161 162 JetFlavorAssociation_R05_inclusive 163 JetFlavorAssociation_R07_inclusive 164 JetFlavorAssociation_R10_inclusive 165 JetFlavorAssociation_R12_inclusive 166 JetFlavorAssociation_R15_inclusive 167 168 JetFlavorAssociation_JER_R05N2 169 JetFlavorAssociation_JER_R05N3 170 JetFlavorAssociation_JER_R05N4 171 JetFlavorAssociation_JER_R05N5 172 JetFlavorAssociation_JER_R05N6 173 174 JetFlavorAssociation_JER_R07N2 175 JetFlavorAssociation_JER_R07N3 176 JetFlavorAssociation_JER_R07N4 177 JetFlavorAssociation_JER_R07N5 178 JetFlavorAssociation_JER_R07N6 179 180 JetFlavorAssociation_JER_R10N2 181 JetFlavorAssociation_JER_R10N3 182 JetFlavorAssociation_JER_R10N4 183 JetFlavorAssociation_JER_R10N5 184 JetFlavorAssociation_JER_R10N6 185 186 JetFlavorAssociation_JER_R12N2 187 JetFlavorAssociation_JER_R12N3 188 JetFlavorAssociation_JER_R12N4 189 JetFlavorAssociation_JER_R12N5 190 JetFlavorAssociation_JER_R12N6 191 192 JetFlavorAssociation_JER_R15N2 193 JetFlavorAssociation_JER_R15N3 194 JetFlavorAssociation_JER_R15N4 195 JetFlavorAssociation_JER_R15N5 196 JetFlavorAssociation_JER_R15N6 197 198 JetFlavorAssociation_JER_R05_inclusive 199 JetFlavorAssociation_JER_R07_inclusive 200 JetFlavorAssociation_JER_R10_inclusive 201 JetFlavorAssociation_JER_R12_inclusive 202 JetFlavorAssociation_JER_R15_inclusive 203 204 BTaggingWP50_R05N2 205 BTaggingWP70_R05N2 206 BTaggingWP90_R05N2 207 BTaggingWP50_R05N3 208 BTaggingWP70_R05N3 209 BTaggingWP90_R05N3 210 BTaggingWP50_R05N4 211 BTaggingWP70_R05N4 212 BTaggingWP90_R05N4 213 BTaggingWP50_R05N5 214 BTaggingWP70_R05N5 215 BTaggingWP90_R05N5 216 BTaggingWP50_R05N6 217 BTaggingWP70_R05N6 218 BTaggingWP90_R05N6 219 BTaggingWP50_R07N2 220 BTaggingWP70_R07N2 221 BTaggingWP90_R07N2 222 BTaggingWP50_R07N3 223 BTaggingWP70_R07N3 224 BTaggingWP90_R07N3 225 BTaggingWP50_R07N4 226 BTaggingWP70_R07N4 227 BTaggingWP90_R07N4 228 BTaggingWP50_R07N5 229 BTaggingWP70_R07N5 230 BTaggingWP90_R07N5 231 BTaggingWP50_R07N6 232 BTaggingWP70_R07N6 233 BTaggingWP90_R07N6 234 BTaggingWP50_R10N2 235 BTaggingWP70_R10N2 236 BTaggingWP90_R10N2 237 BTaggingWP50_R10N3 238 BTaggingWP70_R10N3 239 BTaggingWP90_R10N3 240 BTaggingWP50_R10N4 241 BTaggingWP70_R10N4 242 BTaggingWP90_R10N4 243 BTaggingWP50_R10N5 244 BTaggingWP70_R10N5 245 BTaggingWP90_R10N5 246 BTaggingWP50_R10N6 247 BTaggingWP70_R10N6 248 BTaggingWP90_R10N6 249 BTaggingWP50_R12N2 250 BTaggingWP70_R12N2 251 BTaggingWP90_R12N2 252 BTaggingWP50_R12N3 253 BTaggingWP70_R12N3 254 BTaggingWP90_R12N3 255 BTaggingWP50_R12N4 256 BTaggingWP70_R12N4 257 BTaggingWP90_R12N4 258 BTaggingWP50_R12N5 259 BTaggingWP70_R12N5 260 BTaggingWP90_R12N5 261 BTaggingWP50_R12N6 262 BTaggingWP70_R12N6 263 BTaggingWP90_R12N6 264 BTaggingWP50_R15N2 265 BTaggingWP70_R15N2 266 BTaggingWP90_R15N2 267 BTaggingWP50_R15N3 268 BTaggingWP70_R15N3 269 BTaggingWP90_R15N3 270 BTaggingWP50_R15N4 271 BTaggingWP70_R15N4 272 BTaggingWP90_R15N4 273 BTaggingWP50_R15N5 274 BTaggingWP70_R15N5 275 BTaggingWP90_R15N5 276 BTaggingWP50_R15N6 277 BTaggingWP70_R15N6 278 BTaggingWP90_R15N6 238 279 BTaggingWP50_R05_inclusive 239 280 BTaggingWP70_R05_inclusive … … 252 293 BTaggingWP90_R15_inclusive 253 294 254 295 BTagging_JER_WP50_R05N2 296 BTagging_JER_WP70_R05N2 297 BTagging_JER_WP90_R05N2 298 BTagging_JER_WP50_R05N3 299 BTagging_JER_WP70_R05N3 300 BTagging_JER_WP90_R05N3 301 BTagging_JER_WP50_R05N4 302 BTagging_JER_WP70_R05N4 303 BTagging_JER_WP90_R05N4 304 BTagging_JER_WP50_R05N5 305 BTagging_JER_WP70_R05N5 306 BTagging_JER_WP90_R05N5 307 BTagging_JER_WP50_R05N6 308 BTagging_JER_WP70_R05N6 309 BTagging_JER_WP90_R05N6 310 BTagging_JER_WP50_R07N2 311 BTagging_JER_WP70_R07N2 312 BTagging_JER_WP90_R07N2 313 BTagging_JER_WP50_R07N3 314 BTagging_JER_WP70_R07N3 315 BTagging_JER_WP90_R07N3 316 BTagging_JER_WP50_R07N4 317 BTagging_JER_WP70_R07N4 318 BTagging_JER_WP90_R07N4 319 BTagging_JER_WP50_R07N5 320 BTagging_JER_WP70_R07N5 321 BTagging_JER_WP90_R07N5 322 BTagging_JER_WP50_R07N6 323 BTagging_JER_WP70_R07N6 324 BTagging_JER_WP90_R07N6 325 BTagging_JER_WP50_R10N2 326 BTagging_JER_WP70_R10N2 327 BTagging_JER_WP90_R10N2 328 BTagging_JER_WP50_R10N3 329 BTagging_JER_WP70_R10N3 330 BTagging_JER_WP90_R10N3 331 BTagging_JER_WP50_R10N4 332 BTagging_JER_WP70_R10N4 333 BTagging_JER_WP90_R10N4 334 BTagging_JER_WP50_R10N5 335 BTagging_JER_WP70_R10N5 336 BTagging_JER_WP90_R10N5 337 BTagging_JER_WP50_R10N6 338 BTagging_JER_WP70_R10N6 339 BTagging_JER_WP90_R10N6 340 BTagging_JER_WP50_R12N2 341 BTagging_JER_WP70_R12N2 342 BTagging_JER_WP90_R12N2 343 BTagging_JER_WP50_R12N3 344 BTagging_JER_WP70_R12N3 345 BTagging_JER_WP90_R12N3 346 BTagging_JER_WP50_R12N4 347 BTagging_JER_WP70_R12N4 348 BTagging_JER_WP90_R12N4 349 BTagging_JER_WP50_R12N5 350 BTagging_JER_WP70_R12N5 351 BTagging_JER_WP90_R12N5 352 BTagging_JER_WP50_R12N6 353 BTagging_JER_WP70_R12N6 354 BTagging_JER_WP90_R12N6 355 BTagging_JER_WP50_R15N2 356 BTagging_JER_WP70_R15N2 357 BTagging_JER_WP90_R15N2 358 BTagging_JER_WP50_R15N3 359 BTagging_JER_WP70_R15N3 360 BTagging_JER_WP90_R15N3 361 BTagging_JER_WP50_R15N4 362 BTagging_JER_WP70_R15N4 363 BTagging_JER_WP90_R15N4 364 BTagging_JER_WP50_R15N5 365 BTagging_JER_WP70_R15N5 366 BTagging_JER_WP90_R15N5 367 BTagging_JER_WP50_R15N6 368 BTagging_JER_WP70_R15N6 369 BTagging_JER_WP90_R15N6 370 BTagging_JER_WP50_R05_inclusive 371 BTagging_JER_WP70_R05_inclusive 372 BTagging_JER_WP90_R05_inclusive 373 BTagging_JER_WP50_R07_inclusive 374 BTagging_JER_WP70_R07_inclusive 375 BTagging_JER_WP90_R07_inclusive 376 BTagging_JER_WP50_R10_inclusive 377 BTagging_JER_WP70_R10_inclusive 378 BTagging_JER_WP90_R10_inclusive 379 BTagging_JER_WP50_R12_inclusive 380 BTagging_JER_WP70_R12_inclusive 381 BTagging_JER_WP90_R12_inclusive 382 BTagging_JER_WP50_R15_inclusive 383 BTagging_JER_WP70_R15_inclusive 384 BTagging_JER_WP90_R15_inclusive 385 255 386 TauTagging_R05N2 256 387 TauTagging_R05N3 … … 278 409 TauTagging_R15N5 279 410 TauTagging_R15N6 280 281 411 TauTagging_R05_inclusive 282 412 TauTagging_R07_inclusive … … 285 415 TauTagging_R15_inclusive 286 416 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 287 447 288 448 … … 730 890 } 731 891 892 732 893 ################## 733 894 # Photon isolation … … 740 901 set OutputArray photons 741 902 742 set DeltaRMax 0. 5903 set DeltaRMax 0.1 743 904 744 905 set PTMin 0.5 745 906 746 set PTRatioMax 0.12 747 } 907 set PTRatioMax 0.2 908 } 909 748 910 749 911 ##################### … … 838 1000 set OutputArray electrons 839 1001 840 set DeltaRMax 0. 51002 set DeltaRMax 0.1 841 1003 842 1004 set PTMin 0.5 843 1005 844 set PTRatioMax 0. 121006 set PTRatioMax 0.2 845 1007 } 846 1008 … … 876 1038 set OutputArray muons 877 1039 878 set DeltaRMax 0. 51040 set DeltaRMax 0.1 879 1041 880 1042 set PTMin 0.5 881 1043 882 set PTRatioMax 0.2 51044 set PTRatioMax 0.2 883 1045 } 884 1046 … … 1003 1165 1004 1166 source CLIC/CLICdet_JetFlavorAssociation.tcl 1167 source CLIC/CLICdet_JetFlavorAssociation_JER.tcl 1005 1168 1006 1169 ########### … … 1010 1173 1011 1174 source CLIC/CLICdet_BTagging.tcl 1175 source CLIC/CLICdet_BTagging_JER.tcl 1012 1176 1013 1177 … … 1018 1182 1019 1183 source CLIC/CLICdet_TauTagging.tcl 1184 source CLIC/CLICdet_TauTagging_JER.tcl 1020 1185 1021 1186 -
classes/ClassesLinkDef.h
r2d7ff18 r83ee320 60 60 #pragma link C++ class Track+; 61 61 #pragma link C++ class Tower+; 62 #pragma link C++ class ParticleFlowCandidate+; 62 63 #pragma link C++ class HectorHit+; 63 64 -
classes/DelphesClasses.cc
r2d7ff18 r83ee320 39 39 CompBase *Track::fgCompare = CompPT<Track>::Instance(); 40 40 CompBase *Tower::fgCompare = CompE<Tower>::Instance(); 41 CompBase *ParticleFlowCandidate::fgCompare = CompE<ParticleFlowCandidate>::Instance(); 41 42 CompBase *HectorHit::fgCompare = CompE<HectorHit>::Instance(); 42 43 CompBase *Vertex::fgCompare = CompSumPT2<Vertex>::Instance(); … … 112 113 TLorentzVector vec; 113 114 vec.SetPtEtaPhiM(ET, Eta, Phi, 0.0); 115 return vec; 116 } 117 118 //------------------------------------------------------------------------------ 119 120 TLorentzVector ParticleFlowCandidate::P4() const 121 { 122 TLorentzVector vec; 123 vec.SetPtEtaPhiM(PT, Eta, Phi, 0.0); 114 124 return vec; 115 125 } … … 121 131 Charge(0), Mass(0.0), 122 132 IsPU(0), IsRecoPU(0), IsConstituent(0), IsFromConversion(0), 123 ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0),124 133 Flavor(0), FlavorAlgo(0), FlavorPhys(0), 125 134 BTag(0), BTagAlgo(0), BTagPhys(0), … … 128 137 Momentum(0.0, 0.0, 0.0, 0.0), 129 138 Position(0.0, 0.0, 0.0, 0.0), 139 InitialPosition(0.0, 0.0, 0.0, 0.0), 130 140 PositionError(0.0, 0.0, 0.0, 0.0), 131 InitialPosition(0.0, 0.0, 0.0, 0.0),132 141 Area(0.0, 0.0, 0.0, 0.0), 133 142 L(0), … … 138 147 CtgTheta(0), ErrorCtgTheta(0), 139 148 Phi(0), ErrorPhi(0), 140 Xd(0), Yd(0), Zd(0), 149 Xd(0), Yd(0), Zd(0), Td(0), 150 VertexingWeight(0), 141 151 TrackResolution(0), 142 152 NCharged(0), 143 153 NNeutrals(0), 154 NeutralEnergyFraction(0), // charged energy fraction 155 ChargedEnergyFraction(0), // neutral energy fraction 144 156 Beta(0), 145 157 BetaStar(0), … … 153 165 SumPtChargedPU(-999), 154 166 SumPt(-999), 167 ClusterIndex(-1), ClusterNDF(0), ClusterSigma(0), SumPT2(0), BTVSumPT2(0), GenDeltaZ(0), GenSumPT2(0), 155 168 NSubJetsTrimmed(0), 156 169 NSubJetsPruned(0), … … 306 319 object.Phi = Phi; 307 320 object.ErrorPhi = ErrorPhi; 321 object.Td = Td; 308 322 object.Xd = Xd; 309 323 object.Yd = Yd; 310 324 object.Zd = Zd; 325 object.VertexingWeight = Zd; 311 326 object.TrackResolution = TrackResolution; 312 327 object.NCharged = NCharged; 313 328 object.NNeutrals = NNeutrals; 329 object.NeutralEnergyFraction = NeutralEnergyFraction; 330 object.ChargedEnergyFraction = ChargedEnergyFraction; 314 331 object.Beta = Beta; 315 332 object.BetaStar = BetaStar; … … 433 450 Phi = 0.0; 434 451 ErrorPhi = 0.0; 452 Td = 0.0; 435 453 Xd = 0.0; 436 454 Yd = 0.0; 437 455 Zd = 0.0; 456 VertexingWeight = 0.0; 438 457 TrackResolution = 0.0; 439 458 NCharged = 0; -
classes/DelphesClasses.h
r2d7ff18 r83ee320 387 387 Int_t NCharged; // number of charged constituents 388 388 Int_t NNeutrals; // number of neutral constituents 389 390 Float_t NeutralEnergyFraction; // charged energy fraction 391 Float_t ChargedEnergyFraction; // neutral energy fraction 392 389 393 Float_t Beta; // (sum pt of charged pile-up constituents)/(sum pt of charged constituents) 390 394 Float_t BetaStar; // (sum pt of charged constituents coming from hard interaction)/(sum pt of charged constituents) … … 452 456 Float_t ZOuter; // track position (z component) at the tracker edge 453 457 458 Float_t Td; // T coordinate of point of closest approach to vertex 454 459 Float_t Xd; // X coordinate of point of closest approach to vertex 455 460 Float_t Yd; // Y coordinate of point of closest approach to vertex 456 461 Float_t Zd; // Z coordinate of point of closest approach to vertex 462 463 Float_t TOFreco; // reconstructed time of flight 464 Float_t TOFgen; // gen time of flight 457 465 458 466 Float_t L; // track path length … … 478 486 TLorentzVector P4() const; 479 487 480 ClassDef(Track, 3)488 ClassDef(Track, 4) 481 489 }; 482 490 … … 508 516 509 517 ClassDef(Tower, 2) 518 }; 519 520 //--------------------------------------------------------------------------- 521 522 class ParticleFlowCandidate: public SortableObject 523 { 524 525 public: 526 Int_t PID; // HEP ID number 527 528 Int_t Charge; // track charge 529 530 Float_t E; // reconstructed energy [GeV] 531 Float_t P; // track momentum 532 Float_t PT; // track transverse momentum 533 Float_t Eta; // track pseudorapidity 534 Float_t Phi; // track azimuthal angle 535 Float_t CtgTheta; // track cotangent of theta 536 537 Float_t EtaOuter; // track pseudorapidity at the tracker edge 538 Float_t PhiOuter; // track azimuthal angle at the tracker edge 539 540 Float_t T; // track vertex position (t component) 541 Float_t X; // track vertex position (x component) 542 Float_t Y; // track vertex position (y component) 543 Float_t Z; // track vertex position (z component) 544 545 Float_t TOuter; // track position (t component) at the tracker edge 546 Float_t XOuter; // track position (x component) at the tracker edge 547 Float_t YOuter; // track position (y component) at the tracker edge 548 Float_t ZOuter; // track position (z component) at the tracker edge 549 550 Float_t Td; // X coordinate of point of closest approach to vertex 551 Float_t Xd; // X coordinate of point of closest approach to vertex 552 Float_t Yd; // Y coordinate of point of closest approach to vertex 553 Float_t Zd; // Z coordinate of point of closest approach to vertex 554 555 Float_t L; // track path length 556 Float_t D0; // track transverse impact parameter 557 Float_t DZ; // track longitudinal impact parameter 558 559 Float_t ErrorP; // track momentum error 560 Float_t ErrorPT; // track transverse momentum error 561 Float_t ErrorPhi; // track azimuthal angle error 562 Float_t ErrorCtgTheta; // track cotangent of theta error 563 564 Float_t ErrorT; // time measurement error 565 Float_t ErrorD0; // track transverse impact parameter error 566 Float_t ErrorDZ; // track longitudinal impact parameter error 567 568 Int_t VertexIndex; // reference to vertex 569 570 static CompBase *fgCompare; //! 571 const CompBase *GetCompare() const { return fgCompare; } 572 573 TLorentzVector P4() const; 574 575 Int_t NTimeHits; // number of hits contributing to time measurement 576 577 Float_t Eem; // calorimeter tower electromagnetic energy 578 Float_t Ehad; // calorimeter tower hadronic energy 579 580 Float_t Edges[4]; // calorimeter tower edges 581 582 TRefArray Particles; // references to generated particles 583 584 ClassDef(ParticleFlowCandidate, 1) 585 510 586 }; 511 587 … … 593 669 Float_t ErrorPhi; 594 670 671 Float_t Td; 595 672 Float_t Xd; 596 673 Float_t Yd; 597 674 Float_t Zd; 598 675 676 // Vertexing variables 677 Float_t VertexingWeight; 678 599 679 // tracking resolution 600 601 680 Float_t TrackResolution; 602 681 … … 610 689 Float_t PTD; 611 690 Float_t FracPt[5]; 691 Float_t NeutralEnergyFraction; // charged energy fraction 692 Float_t ChargedEnergyFraction; // neutral energy fraction 693 612 694 613 695 // Timing information -
external/Hector/H_Beam.h
r2d7ff18 r83ee320 107 107 //@{ 108 108 inline const float getEmittanceX() const { 109 if( !x_disp*tx_disp) cout<<"Warning : Degenerate Beam : x-emittance = 0"<<endl;109 if(x_disp * tx_disp == 0) cout<<"Warning : Degenerate Beam : x-emittance = 0"<<endl; 110 110 return x_disp * tan(tx_disp/URAD)/URAD; 111 111 } 112 112 inline const float getEmittanceY() const { 113 if(!y_disp*ty_disp) cout<<"Warning : Degenerate Beam : y-emittance = 0"<<endl;113 if(y_disp * ty_disp == 0) cout<<"Warning : Degenerate Beam : y-emittance = 0"<<endl; 114 114 return y_disp * tan(ty_disp/URAD)/URAD; 115 115 } -
external/fastjet/plugins/SISCone/split_merge.h
r2d7ff18 r83ee320 446 446 // jet information 447 447 /// list of jet candidates 448 #ifdef SISCONE_USES_UNIQUE_PTR_AS_AUTO_PTR 448 #if __cplusplus < 201103L 449 std::auto_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates; 450 #else 449 451 std::unique_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates; 450 #else451 std::auto_ptr<std::multiset<Cjet,Csplit_merge_ptcomparison> > candidates;452 452 #endif 453 453 -
external/tcl/tcl.h
r2d7ff18 r83ee320 488 488 EXTERN int Tcl_IsShared _ANSI_ARGS_((Tcl_Obj *objPtr)); 489 489 490 #ifdef TCL_MEM_DEBUG491 # 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 #else498 490 # define Tcl_IncrRefCount(objPtr) \ 499 491 ++(objPtr)->refCount … … 502 494 # define Tcl_IsShared(objPtr) \ 503 495 ((objPtr)->refCount > 1) 504 #endif505 496 506 497 /* 507 498 * Macros and definitions that help to debug the use of Tcl objects. 508 * When TCL_MEM_DEBUG is defined, the Tcl_New* declarations are509 * overridden to call debugging versions of the object creation procedures.510 499 */ 511 500 … … 519 508 EXTERN Tcl_Obj * Tcl_NewStringObj _ANSI_ARGS_((char *bytes, 520 509 int length)); 521 522 #ifdef TCL_MEM_DEBUG523 # 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 */538 510 539 511 /* … … 726 698 unsigned int size)); 727 699 728 #ifdef TCL_MEM_DEBUG729 730 # define Tcl_Alloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)731 # define Tcl_Free(x) Tcl_DbCkfree(x, __FILE__, __LINE__)732 # define Tcl_Realloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)733 # define ckalloc(x) Tcl_DbCkalloc(x, __FILE__, __LINE__)734 # define ckfree(x) Tcl_DbCkfree(x, __FILE__, __LINE__)735 # define ckrealloc(x,y) Tcl_DbCkrealloc((x), (y),__FILE__, __LINE__)736 737 EXTERN int Tcl_DumpActiveMemory _ANSI_ARGS_((char *fileName));738 EXTERN void Tcl_ValidateAllMemory _ANSI_ARGS_((char *file,739 int line));740 741 #else742 743 700 /* 744 701 * If USE_TCLALLOC is true, then we need to call Tcl_Alloc instead of … … 760 717 # define Tcl_DumpActiveMemory(x) 761 718 # define Tcl_ValidateAllMemory(x,y) 762 763 #endif /* TCL_MEM_DEBUG */764 719 765 720 /* -
external/tcl/tclBasic.c
r2d7ff18 r83ee320 3287 3287 TclInitByteCodeObj(objPtr, &compEnv); 3288 3288 codePtr = (ByteCode *) objPtr->internalRep.otherValuePtr; 3289 if (tclTraceCompile == 2) {3290 TclPrintByteCodeObj(interp, objPtr);3291 }3292 3289 TclFreeCompileEnv(&compEnv); 3293 3290 } else { -
external/tcl/tclCkalloc.c
r2d7ff18 r83ee320 22 22 #define TRUE 1 23 23 24 #ifdef TCL_MEM_DEBUG25 26 /*27 * One of the following structures is allocated each time the28 * "memory tag" command is invoked, to hold the current tag.29 */30 31 typedef struct MemTag {32 int refCount; /* Number of mem_headers referencing33 * this tag. */34 char string[4]; /* Actual size of string will be as35 * large as needed for actual tag. This36 * must be the last field in the structure. */37 } MemTag;38 39 #define TAG_SIZE(bytesInString) ((unsigned) sizeof(MemTag) + bytesInString - 3)40 41 static MemTag *curTagPtr = NULL;/* Tag to use in all future mem_headers42 * (set by "memory tag" command). */43 44 /*45 * One of the following structures is allocated just before each46 * dynamically allocated chunk of memory, both to record information47 * about the chunk and to help detect chunk under-runs.48 */49 50 #define LOW_GUARD_SIZE (8 + (32 - (sizeof(long) + sizeof(int)))%8)51 struct mem_header {52 struct mem_header *flink;53 struct mem_header *blink;54 MemTag *tagPtr; /* Tag from "memory tag" command; may be55 * 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, plus61 * provides at least 8 additional guard bytes62 * to detect underruns. */63 char body[1]; /* First byte of client's space. Actual64 * size of this field will be larger than65 * one. */66 };67 68 static struct mem_header *allocHead = NULL; /* List of allocated structures */69 70 #define GUARD_VALUE 014171 72 /*73 * The following macro determines the amount of guard space *above* each74 * chunk of memory.75 */76 77 #define HIGH_GUARD_SIZE 878 79 /*80 * The following macro computes the offset of the "body" field within81 * mem_header. It is used to get back to the header pointer from the82 * body pointer that's used by clients.83 */84 85 #define BODY_OFFSET \86 ((unsigned long) (&((struct mem_header *) 0)->body))87 88 static int total_mallocs = 0;89 static int total_frees = 0;90 static int current_bytes_malloced = 0;91 static int maximum_bytes_malloced = 0;92 static int current_malloc_packets = 0;93 static int maximum_malloc_packets = 0;94 static int break_on_malloc = 0;95 static int trace_on_at_malloc = 0;96 static int alloc_tracing = FALSE;97 static int init_malloced_bodies = TRUE;98 #ifdef MEM_VALIDATE99 static int validate_memory = TRUE;100 #else101 static int validate_memory = FALSE;102 #endif103 104 /*105 * Prototypes for procedures defined in this file:106 */107 108 static int MemoryCmd _ANSI_ARGS_((ClientData clientData,109 Tcl_Interp *interp, int argc, char **argv));110 static void ValidateMemory _ANSI_ARGS_((111 struct mem_header *memHeaderP, char *file,112 int line, int nukeGuards));113 114 115 /*116 *----------------------------------------------------------------------117 *118 * TclDumpMemoryInfo --119 * Display the global memory management statistics.120 *121 *----------------------------------------------------------------------122 */123 void124 TclDumpMemoryInfo(outFile)125 FILE *outFile;126 {127 fprintf(outFile,"total mallocs %10d\n",128 total_mallocs);129 fprintf(outFile,"total frees %10d\n",130 total_frees);131 fprintf(outFile,"current packets allocated %10d\n",132 current_malloc_packets);133 fprintf(outFile,"current bytes allocated %10d\n",134 current_bytes_malloced);135 fprintf(outFile,"maximum packets allocated %10d\n",136 maximum_malloc_packets);137 fprintf(outFile,"maximum bytes allocated %10d\n",138 maximum_bytes_malloced);139 }140 141 142 /*143 *----------------------------------------------------------------------144 *145 * ValidateMemory --146 * Procedure to validate allocted memory guard zones.147 *148 *----------------------------------------------------------------------149 */150 static void151 ValidateMemory(memHeaderP, file, line, nukeGuards)152 struct mem_header *memHeaderP;153 char *file;154 int line;155 int nukeGuards;156 {157 unsigned char *hiPtr;158 int idx;159 int guard_failed = FALSE;160 int byte;161 162 for (idx = 0; idx < LOW_GUARD_SIZE; idx++) {163 byte = *(memHeaderP->low_guard + idx);164 if (byte != GUARD_VALUE) {165 guard_failed = TRUE;166 fflush(stdout);167 byte &= 0xff;168 fprintf(stderr, "low guard byte %d is 0x%x \t%c\n", idx, byte,169 (isprint(UCHAR(byte)) ? byte : ' '));170 }171 }172 if (guard_failed) {173 TclDumpMemoryInfo (stderr);174 fprintf(stderr, "low guard failed at %lx, %s %d\n",175 (long unsigned int) memHeaderP->body, file, line);176 fflush(stderr); /* In case name pointer is bad. */177 fprintf(stderr, "%ld bytes allocated at (%s %d)\n", memHeaderP->length,178 memHeaderP->file, memHeaderP->line);179 panic ("Memory validation failure");180 }181 182 hiPtr = (unsigned char *)memHeaderP->body + memHeaderP->length;183 for (idx = 0; idx < HIGH_GUARD_SIZE; idx++) {184 byte = *(hiPtr + idx);185 if (byte != GUARD_VALUE) {186 guard_failed = TRUE;187 fflush (stdout);188 byte &= 0xff;189 fprintf(stderr, "hi guard byte %d is 0x%x \t%c\n", idx, byte,190 (isprint(UCHAR(byte)) ? byte : ' '));191 }192 }193 194 if (guard_failed) {195 TclDumpMemoryInfo (stderr);196 fprintf(stderr, "high guard failed at %lx, %s %d\n",197 (long unsigned int) memHeaderP->body, file, line);198 fflush(stderr); /* In case name pointer is bad. */199 fprintf(stderr, "%ld bytes allocated at (%s %d)\n",200 memHeaderP->length, memHeaderP->file,201 memHeaderP->line);202 panic("Memory validation failure");203 }204 205 if (nukeGuards) {206 memset ((char *) memHeaderP->low_guard, 0, LOW_GUARD_SIZE);207 memset ((char *) hiPtr, 0, HIGH_GUARD_SIZE);208 }209 210 }211 212 213 /*214 *----------------------------------------------------------------------215 *216 * Tcl_ValidateAllMemory --217 * Validates guard regions for all allocated memory.218 *219 *----------------------------------------------------------------------220 */221 void222 Tcl_ValidateAllMemory (file, line)223 char *file;224 int line;225 {226 struct mem_header *memScanP;227 228 for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink)229 ValidateMemory(memScanP, file, line, FALSE);230 231 }232 233 234 /*235 *----------------------------------------------------------------------236 *237 * Tcl_DumpActiveMemory --238 * Displays all allocated memory to stderr.239 *240 * Results:241 * Return TCL_ERROR if an error accessing the file occures, `errno'242 * will have the file error number left in it.243 *----------------------------------------------------------------------244 */245 int246 Tcl_DumpActiveMemory (fileName)247 char *fileName;248 {249 FILE *fileP;250 struct mem_header *memScanP;251 char *address;252 253 fileP = fopen(fileName, "w");254 if (fileP == NULL)255 return TCL_ERROR;256 257 for (memScanP = allocHead; memScanP != NULL; memScanP = memScanP->flink) {258 address = &memScanP->body [0];259 fprintf(fileP, "%8lx - %8lx %7ld @ %s %d %s",260 (long unsigned int) address,261 (long unsigned int) address + memScanP->length - 1,262 memScanP->length, memScanP->file, memScanP->line,263 (memScanP->tagPtr == NULL) ? "" : memScanP->tagPtr->string);264 (void) fputc('\n', fileP);265 }266 fclose (fileP);267 return TCL_OK;268 }269 270 271 /*272 *----------------------------------------------------------------------273 *274 * Tcl_DbCkalloc - debugging ckalloc275 *276 * Allocate the requested amount of space plus some extra for277 * guard bands at both ends of the request, plus a size, panicing278 * if there isn't enough space, then write in the guard bands279 * and return the address of the space in the middle that the280 * user asked for.281 *282 * The second and third arguments are file and line, these contain283 * the filename and line number corresponding to the caller.284 * These are sent by the ckalloc macro; it uses the preprocessor285 * autodefines __FILE__ and __LINE__.286 *287 *----------------------------------------------------------------------288 */289 char *290 Tcl_DbCkalloc(size, file, line)291 unsigned int size;292 char *file;293 int line;294 {295 struct mem_header *result;296 297 if (validate_memory)298 Tcl_ValidateAllMemory (file, line);299 300 result = (struct mem_header *) TclpAlloc((unsigned)size +301 sizeof(struct mem_header) + HIGH_GUARD_SIZE);302 if (result == NULL) {303 fflush(stdout);304 TclDumpMemoryInfo(stderr);305 panic("unable to alloc %d bytes, %s line %d", size, file,306 line);307 }308 309 /*310 * Fill in guard zones and size. Also initialize the contents of311 * 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 ckfree373 *374 * Verify that the low and high guards are intact, and if so375 * then free the buffer else panic.376 *377 * The guards are erased after being checked to catch duplicate378 * frees.379 *380 * The second and third arguments are file and line, these contain381 * the filename and line number corresponding to the caller.382 * These are sent by the ckfree macro; it uses the preprocessor383 * autodefines __FILE__ and __LINE__.384 *385 *----------------------------------------------------------------------386 */387 388 int389 Tcl_DbCkfree(ptr, file, line)390 char * ptr;391 char *file;392 int line;393 {394 /*395 * The following cast is *very* tricky. Must convert the pointer396 * to an integer before doing arithmetic on it, because otherwise397 * the arithmetic will be done differently (and incorrectly) on398 * 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 list430 */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 ckrealloc446 *447 * Reallocate a chunk of memory by allocating a new one of the448 * right size, copying the old data to the new location, and then449 * freeing the old memory space, using all the memory checking450 * features of this package.451 *452 *--------------------------------------------------------------------453 */454 char *455 Tcl_DbCkrealloc(ptr, size, file, line)456 char *ptr;457 unsigned int size;458 char *file;459 int line;460 {461 char *new;462 unsigned int copySize;463 464 /*465 * See comment from Tcl_DbCkfree before you change the following466 * 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 versions490 * 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_Alloc502 #undef Tcl_Free503 #undef Tcl_Realloc504 505 char *506 Tcl_Alloc(size)507 unsigned int size;508 {509 return Tcl_DbCkalloc(size, "unknown", 0);510 }511 512 void513 Tcl_Free(ptr)514 char *ptr;515 {516 Tcl_DbCkfree(ptr, "unknown", 0);517 }518 519 char *520 Tcl_Realloc(ptr, size)521 char *ptr;522 unsigned int size;523 {524 return Tcl_DbCkrealloc(ptr, size, "unknown", 0);525 }526 527 528 /*529 *----------------------------------------------------------------------530 *531 * MemoryCmd --532 * Implements the TCL memory command:533 * memory info534 * memory display535 * break_on_malloc count536 * trace_on_at_malloc count537 * trace on|off538 * validate on|off539 *540 * Results:541 * Standard TCL results.542 *543 *----------------------------------------------------------------------544 */545 /* ARGSUSED */546 static int547 MemoryCmd (clientData, interp, argc, argv)548 ClientData clientData;549 Tcl_Interp *interp;550 int argc;551 char **argv;552 {553 char *fileName;554 Tcl_DString buffer;555 int result;556 557 if (argc < 2) {558 Tcl_AppendResult(interp, "wrong # args: should be \"",559 argv[0], " option [args..]\"", (char *) NULL);560 return TCL_ERROR;561 }562 563 if (strcmp(argv[1],"active") == 0) {564 if (argc != 3) {565 Tcl_AppendResult(interp, "wrong # args: should be \"",566 argv[0], " active file\"", (char *) NULL);567 return TCL_ERROR;568 }569 fileName = Tcl_TranslateFileName(interp, argv[2], &buffer);570 if (fileName == NULL) {571 return TCL_ERROR;572 }573 result = Tcl_DumpActiveMemory (fileName);574 Tcl_DStringFree(&buffer);575 if (result != TCL_OK) {576 Tcl_AppendResult(interp, "error accessing ", argv[2],577 (char *) NULL);578 return TCL_ERROR;579 }580 return TCL_OK;581 }582 if (strcmp(argv[1],"break_on_malloc") == 0) {583 if (argc != 3) {584 goto argError;585 }586 if (Tcl_GetInt(interp, argv[2], &break_on_malloc) != TCL_OK) {587 return TCL_ERROR;588 }589 return TCL_OK;590 }591 if (strcmp(argv[1],"info") == 0) {592 TclDumpMemoryInfo(stdout);593 return TCL_OK;594 }595 if (strcmp(argv[1],"init") == 0) {596 if (argc != 3) {597 goto bad_suboption;598 }599 init_malloced_bodies = (strcmp(argv[2],"on") == 0);600 return TCL_OK;601 }602 if (strcmp(argv[1],"tag") == 0) {603 if (argc != 3) {604 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],605 " tag string\"", (char *) NULL);606 return TCL_ERROR;607 }608 if ((curTagPtr != NULL) && (curTagPtr->refCount == 0)) {609 TclpFree((char *) curTagPtr);610 }611 curTagPtr = (MemTag *) TclpAlloc(TAG_SIZE(strlen(argv[2])));612 curTagPtr->refCount = 0;613 strcpy(curTagPtr->string, argv[2]);614 return TCL_OK;615 }616 if (strcmp(argv[1],"trace") == 0) {617 if (argc != 3) {618 goto bad_suboption;619 }620 alloc_tracing = (strcmp(argv[2],"on") == 0);621 return TCL_OK;622 }623 624 if (strcmp(argv[1],"trace_on_at_malloc") == 0) {625 if (argc != 3) {626 goto argError;627 }628 if (Tcl_GetInt(interp, argv[2], &trace_on_at_malloc) != TCL_OK) {629 return TCL_ERROR;630 }631 return TCL_OK;632 }633 if (strcmp(argv[1],"validate") == 0) {634 if (argc != 3) {635 goto bad_suboption;636 }637 validate_memory = (strcmp(argv[2],"on") == 0);638 return TCL_OK;639 }640 641 Tcl_AppendResult(interp, "bad option \"", argv[1],642 "\": should be active, break_on_malloc, info, init, ",643 "tag, trace, trace_on_at_malloc, or validate", (char *) NULL);644 return TCL_ERROR;645 646 argError:647 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],648 " ", argv[1], " count\"", (char *) NULL);649 return TCL_ERROR;650 651 bad_suboption:652 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],653 " ", argv[1], " on|off\"", (char *) NULL);654 return TCL_ERROR;655 }656 657 658 /*659 *----------------------------------------------------------------------660 *661 * Tcl_InitMemory --662 * Initialize the memory command.663 *664 *----------------------------------------------------------------------665 */666 void667 Tcl_InitMemory(interp)668 Tcl_Interp *interp;669 {670 Tcl_CreateCommand (interp, "memory", MemoryCmd, (ClientData) NULL,671 (Tcl_CmdDeleteProc *) NULL);672 }673 674 #else675 676 677 678 24 /* 679 25 *---------------------------------------------------------------------- 680 26 * 681 27 * Tcl_Alloc -- 682 * Interface to TclpAlloc when TCL_MEM_DEBUG is disabled. It does check683 * 28 * Interface to TclpAlloc. 29 * It does check that memory was actually allocated. 684 30 * 685 31 *---------------------------------------------------------------------- … … 722 68 * 723 69 * Tcl_Realloc -- 724 * Interface to TclpRealloc when TCL_MEM_DEBUG is disabled. It does725 * 70 * Interface to TclpRealloc. 71 * It does check that memory was actually allocated. 726 72 * 727 73 *---------------------------------------------------------------------- … … 765 111 * 766 112 * Tcl_Free -- 767 * Interface to TclpFree when TCL_MEM_DEBUG is disabled. Done here 768 * rather in the macro to keep some modules from being compiled with 769 * TCL_MEM_DEBUG enabled and some with it disabled. 113 * Interface to TclpFree. 770 114 * 771 115 *---------------------------------------------------------------------- … … 778 122 TclpFree(ptr); 779 123 } 780 781 int782 Tcl_DbCkfree(ptr, file, line)783 char * ptr;784 char *file;785 int line;786 {787 TclpFree(ptr);788 return 0;789 }790 791 792 /*793 *----------------------------------------------------------------------794 *795 * Tcl_InitMemory --796 * Dummy initialization for memory command, which is only available797 * if TCL_MEM_DEBUG is on.798 *799 *----------------------------------------------------------------------800 */801 /* ARGSUSED */802 void803 Tcl_InitMemory(interp)804 Tcl_Interp *interp;805 {806 }807 808 #undef Tcl_DumpActiveMemory809 #undef Tcl_ValidateAllMemory810 811 extern int Tcl_DumpActiveMemory _ANSI_ARGS_((char *fileName));812 extern void Tcl_ValidateAllMemory _ANSI_ARGS_((char *file,813 int line));814 815 int816 Tcl_DumpActiveMemory(fileName)817 char *fileName;818 {819 return TCL_OK;820 }821 822 void823 Tcl_ValidateAllMemory(file, line)824 char *file;825 int line;826 {827 }828 829 #endif -
external/tcl/tclCompExpr.c
r2d7ff18 r83ee320 31 31 #define ERANGE 34 32 32 #endif 33 34 /*35 * Boolean variable that controls whether expression compilation tracing36 * is enabled.37 */38 39 #ifdef TCL_COMPILE_DEBUG40 static int traceCompileExpr = 0;41 #endif /* TCL_COMPILE_DEBUG */42 33 43 34 /* … … 132 123 #define NOT (COLON + 1) 133 124 #define BIT_NOT (NOT + 1) 134 135 /*136 * Mapping from tokens to strings; used for debugging messages. These137 * entries must match the order and number of the token definitions above.138 */139 140 #ifdef TCL_COMPILE_DEBUG141 static char *tokenStrings[] = {142 "LITERAL", "FUNCNAME",143 "[", "]", "(", ")", "$", "\"", ",", "END", "UNKNOWN",144 "*", "/", "%", "+", "-",145 "<<", ">>", "<", ">", "<=", ">=", "==", "!=",146 "&", "^", "|", "&&", "||", "?", ":",147 "!", "~"148 };149 #endif /* TCL_COMPILE_DEBUG */150 125 151 126 /* … … 198 173 ExprInfo *infoPtr, CompileEnv *envPtr)); 199 174 200 /*201 * Macro used to debug the execution of the recursive descent parser used202 * to compile expressions.203 */204 205 #ifdef TCL_COMPILE_DEBUG206 #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 #else213 #define HERE(production, level)214 #endif /* TCL_COMPILE_DEBUG */215 175 216 176 … … 277 237 * to execute the expression. */ 278 238 int result; 279 280 #ifdef TCL_COMPILE_DEBUG281 if (traceCompileExpr) {282 fprintf(stderr, "expr: string=\"%.30s\"\n", string);283 }284 #endif /* TCL_COMPILE_DEBUG */285 239 286 240 /* … … 409 363 int elseCodeOffset, currCodeOffset, jumpDist, result; 410 364 411 HERE("condExpr", 1);412 365 result = CompileLorExpr(interp, infoPtr, flags, envPtr); 413 366 if (result != TCL_OK) { … … 571 524 Tcl_Obj *objPtr; 572 525 573 HERE("lorExpr", 2);574 526 result = CompileLandExpr(interp, infoPtr, flags, envPtr); 575 527 if ((result != TCL_OK) || (infoPtr->token != OR)) { … … 739 691 Tcl_Obj *objPtr; 740 692 741 HERE("landExpr", 3);742 693 result = CompileBitOrExpr(interp, infoPtr, flags, envPtr); 743 694 if ((result != TCL_OK) || (infoPtr->token != AND)) { … … 899 850 int result; 900 851 901 HERE("bitOrExpr", 4);902 852 result = CompileBitXorExpr(interp, infoPtr, flags, envPtr); 903 853 if (result != TCL_OK) { … … 970 920 int result; 971 921 972 HERE("bitXorExpr", 5);973 922 result = CompileBitAndExpr(interp, infoPtr, flags, envPtr); 974 923 if (result != TCL_OK) { … … 1041 990 int result; 1042 991 1043 HERE("bitAndExpr", 6);1044 992 result = CompileEqualityExpr(interp, infoPtr, flags, envPtr); 1045 993 if (result != TCL_OK) { … … 1112 1060 int op, result; 1113 1061 1114 HERE("equalityExpr", 7);1115 1062 result = CompileRelationalExpr(interp, infoPtr, flags, envPtr); 1116 1063 if (result != TCL_OK) { … … 1190 1137 int op, result; 1191 1138 1192 HERE("relationalExpr", 8);1193 1139 result = CompileShiftExpr(interp, infoPtr, flags, envPtr); 1194 1140 if (result != TCL_OK) { … … 1277 1223 int op, result; 1278 1224 1279 HERE("shiftExpr", 9);1280 1225 result = CompileAddExpr(interp, infoPtr, flags, envPtr); 1281 1226 if (result != TCL_OK) { … … 1355 1300 int op, result; 1356 1301 1357 HERE("addExpr", 10);1358 1302 result = CompileMultiplyExpr(interp, infoPtr, flags, envPtr); 1359 1303 if (result != TCL_OK) { … … 1433 1377 int op, result; 1434 1378 1435 HERE("multiplyExpr", 11);1436 1379 result = CompileUnaryExpr(interp, infoPtr, flags, envPtr); 1437 1380 if (result != TCL_OK) { … … 1513 1456 int op, result; 1514 1457 1515 HERE("unaryExpr", 12);1516 1458 op = infoPtr->token; 1517 1459 if ((op == PLUS) || (op == MINUS) || (op == BIT_NOT) || (op == NOT)) { … … 1608 1550 */ 1609 1551 1610 HERE("primaryExpr", 13);1611 1552 theToken = infoPtr->token; 1612 1553 -
external/tcl/tclCompile.c
r2d7ff18 r83ee320 17 17 #include "tclInt.h" 18 18 #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 tracing24 * 1: summarize compilation of top level cmds and proc bodies25 * 2: display all instructions of each ByteCode compiled26 * This variable is linked to the Tcl variable "tcl_traceCompile".27 */28 29 int tclTraceCompile = 0;30 static int traceInitialized = 0;31 32 /*33 * Count of the number of compilations and various other compilation-34 * related statistics.35 */36 37 #ifdef TCL_COMPILE_STATS38 long tclNumCompilations = 0;39 double tclTotalSourceBytes = 0.0;40 double tclTotalCodeBytes = 0.0;41 42 double tclTotalInstBytes = 0.0;43 double tclTotalObjBytes = 0.0;44 double tclTotalExceptBytes = 0.0;45 double tclTotalAuxBytes = 0.0;46 double tclTotalCmdMapBytes = 0.0;47 48 double tclCurrentSourceBytes = 0.0;49 double tclCurrentCodeBytes = 0.0;50 51 int tclSourceCount[32];52 int tclByteCodeCount[32];53 #endif /* TCL_COMPILE_STATS */54 19 55 20 /* … … 443 408 *---------------------------------------------------------------------- 444 409 * 445 * TclPrintByteCodeObj --446 *447 * This procedure prints ("disassembles") the instructions of a448 * bytecode object to stdout.449 *450 * Results:451 * None.452 *453 * Side effects:454 * None.455 *456 *----------------------------------------------------------------------457 */458 459 void460 TclPrintByteCodeObj(interp, objPtr)461 Tcl_Interp *interp; /* Used only for Tcl_GetStringFromObj. */462 Tcl_Obj *objPtr; /* The bytecode object to disassemble. */463 {464 ByteCode* codePtr = (ByteCode *) objPtr->internalRep.otherValuePtr;465 unsigned char *codeStart, *codeLimit, *pc;466 unsigned char *codeDeltaNext, *codeLengthNext;467 unsigned char *srcDeltaNext, *srcLengthNext;468 int codeOffset, codeLen, srcOffset, srcLen;469 int numCmds, numObjs, delta, objBytes, i;470 471 if (codePtr->refCount <= 0) {472 return; /* already freed */473 }474 475 codeStart = codePtr->codeStart;476 codeLimit = (codeStart + codePtr->numCodeBytes);477 numCmds = codePtr->numCommands;478 numObjs = codePtr->numObjects;479 480 objBytes = (numObjs * sizeof(Tcl_Obj));481 for (i = 0; i < numObjs; i++) {482 Tcl_Obj *litObjPtr = codePtr->objArrayPtr[i];483 if (litObjPtr->bytes != NULL) {484 objBytes += litObjPtr->length;485 }486 }487 488 /*489 * Print header lines describing the ByteCode.490 */491 492 fprintf(stdout, "\nByteCode 0x%x, ref ct %u, epoch %u, interp 0x%x(epoch %u)\n",493 (unsigned int) codePtr, codePtr->refCount,494 codePtr->compileEpoch, (unsigned int) codePtr->iPtr,495 codePtr->iPtr->compileEpoch);496 fprintf(stdout, " Source ");497 TclPrintSource(stdout, codePtr->source,498 TclMin(codePtr->numSrcChars, 70));499 fprintf(stdout, "\n Cmds %d, chars %d, inst %d, objs %u, aux %d, stk depth %u, code/src %.2f\n",500 numCmds, codePtr->numSrcChars, codePtr->numCodeBytes, numObjs,501 codePtr->numAuxDataItems, codePtr->maxStackDepth,502 (codePtr->numSrcChars?503 ((float)codePtr->totalSize)/((float)codePtr->numSrcChars) : 0.0));504 fprintf(stdout, " Code %zu = %u(header)+%d(inst)+%d(objs)+%u(exc)+%u(aux)+%d(cmd map)\n",505 codePtr->totalSize, sizeof(ByteCode), codePtr->numCodeBytes,506 objBytes, (codePtr->numExcRanges * sizeof(ExceptionRange)),507 (codePtr->numAuxDataItems * sizeof(AuxData)),508 codePtr->numCmdLocBytes);509 510 /*511 * If the ByteCode is the compiled body of a Tcl procedure, print512 * information about that procedure. Note that we don't know the513 * 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 string575 * 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 source589 * 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 start648 * of a command, print the command's source. Note that we don't need649 * 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 a720 * bytecode object to stdout.721 *722 * Results:723 * Returns the length in bytes of the current instruiction.724 *725 * Side effects:726 * None.727 *728 *----------------------------------------------------------------------729 */730 731 int732 TclPrintInstruction(codePtr, pc)733 ByteCode* codePtr; /* Bytecode containing the instruction. */734 unsigned char *pc; /* Points to first byte of instruction. */735 {736 Proc *procPtr = codePtr->procPtr;737 unsigned char opCode = *pc;738 register InstructionDesc *instDesc = &instructionTable[opCode];739 unsigned char *codeStart = codePtr->codeStart;740 unsigned int pcOffset = (pc - codeStart);741 int opnd, elemLen, i, j;742 Tcl_Obj *elemPtr;743 char *string;744 745 fprintf(stdout, "(%u) %s ", pcOffset, instDesc->name);746 for (i = 0; i < instDesc->numOperands; i++) {747 switch (instDesc->opTypes[i]) {748 case OPERAND_INT1:749 opnd = TclGetInt1AtPtr(pc+1+i);750 if ((i == 0) && ((opCode == INST_JUMP1)751 || (opCode == INST_JUMP_TRUE1)752 || (opCode == INST_JUMP_FALSE1))) {753 fprintf(stdout, "%d # pc %u", opnd, (pcOffset + opnd));754 } else {755 fprintf(stdout, "%d", opnd);756 }757 break;758 case OPERAND_INT4:759 opnd = TclGetInt4AtPtr(pc+1+i);760 if ((i == 0) && ((opCode == INST_JUMP4)761 || (opCode == INST_JUMP_TRUE4)762 || (opCode == INST_JUMP_FALSE4))) {763 fprintf(stdout, "%d # pc %u", opnd, (pcOffset + opnd));764 } else {765 fprintf(stdout, "%d", opnd);766 }767 break;768 case OPERAND_UINT1:769 opnd = TclGetUInt1AtPtr(pc+1+i);770 if ((i == 0) && (opCode == INST_PUSH1)) {771 elemPtr = codePtr->objArrayPtr[opnd];772 string = Tcl_GetStringFromObj(elemPtr, &elemLen);773 fprintf(stdout, "%u # ", (unsigned int) opnd);774 TclPrintSource(stdout, string, TclMin(elemLen, 40));775 } else if ((i == 0) && ((opCode == INST_LOAD_SCALAR1)776 || (opCode == INST_LOAD_ARRAY1)777 || (opCode == INST_STORE_SCALAR1)778 || (opCode == INST_STORE_ARRAY1))) {779 int localCt = procPtr->numCompiledLocals;780 CompiledLocal *localPtr = procPtr->firstLocalPtr;781 if (opnd >= localCt) {782 panic("TclPrintInstruction: bad local var index %u (%u locals)\n",783 (unsigned int) opnd, localCt);784 return instDesc->numBytes;785 }786 for (j = 0; j < opnd; j++) {787 localPtr = localPtr->nextPtr;788 }789 if (TclIsVarTemporary(localPtr)) {790 fprintf(stdout, "%u # temp var %u",791 (unsigned int) opnd, (unsigned int) opnd);792 } else {793 fprintf(stdout, "%u # var ", (unsigned int) opnd);794 TclPrintSource(stdout, localPtr->name, 40);795 }796 } else {797 fprintf(stdout, "%u ", (unsigned int) opnd);798 }799 break;800 case OPERAND_UINT4:801 opnd = TclGetUInt4AtPtr(pc+1+i);802 if (opCode == INST_PUSH4) {803 elemPtr = codePtr->objArrayPtr[opnd];804 string = Tcl_GetStringFromObj(elemPtr, &elemLen);805 fprintf(stdout, "%u # ", opnd);806 TclPrintSource(stdout, string, TclMin(elemLen, 40));807 } else if ((i == 0) && ((opCode == INST_LOAD_SCALAR4)808 || (opCode == INST_LOAD_ARRAY4)809 || (opCode == INST_STORE_SCALAR4)810 || (opCode == INST_STORE_ARRAY4))) {811 int localCt = procPtr->numCompiledLocals;812 CompiledLocal *localPtr = procPtr->firstLocalPtr;813 if (opnd >= localCt) {814 panic("TclPrintInstruction: bad local var index %u (%u locals)\n",815 (unsigned int) opnd, localCt);816 return instDesc->numBytes;817 }818 for (j = 0; j < opnd; j++) {819 localPtr = localPtr->nextPtr;820 }821 if (TclIsVarTemporary(localPtr)) {822 fprintf(stdout, "%u # temp var %u",823 (unsigned int) opnd, (unsigned int) opnd);824 } else {825 fprintf(stdout, "%u # var ", (unsigned int) opnd);826 TclPrintSource(stdout, localPtr->name, 40);827 }828 } else {829 fprintf(stdout, "%u ", (unsigned int) opnd);830 }831 break;832 case OPERAND_NONE:833 default:834 break;835 }836 }837 fprintf(stdout, "\n");838 return instDesc->numBytes;839 }840 841 842 /*843 *----------------------------------------------------------------------844 *845 410 * TclPrintSource -- 846 411 * … … 972 537 register int i; 973 538 974 #ifdef TCL_COMPILE_STATS975 tclCurrentSourceBytes -= (double) codePtr->numSrcChars;976 tclCurrentCodeBytes -= (double) codePtr->totalSize;977 #endif /* TCL_COMPILE_STATS */978 979 539 /* 980 540 * A single heap object holds the ByteCode structure and its code, … … 1067 627 int length, result; 1068 628 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 1077 629 string = Tcl_GetStringFromObj(objPtr, &length); 1078 630 TclInitCompileEnv(interp, &compEnv, string); … … 1113 665 TclFreeCompileEnv(&compEnv); 1114 666 1115 if (result == TCL_OK) {1116 if (tclTraceCompile == 2) {1117 TclPrintByteCodeObj(interp, objPtr);1118 }1119 }1120 667 return result; 1121 668 } … … 1311 858 int numObjects, i; 1312 859 Namespace *namespacePtr; 1313 #ifdef TCL_COMPILE_STATS1314 int srcLenLog2, sizeLog2;1315 #endif /*TCL_COMPILE_STATS*/1316 860 1317 861 codeBytes = (envPtr->codeNext - envPtr->codeStart); … … 1342 886 } 1343 887 totalSize = (size + objBytes); 1344 1345 #ifdef TCL_COMPILE_STATS1346 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 */1367 888 1368 889 if (envPtr->iPtr->varFramePtr != NULL) { … … 1820 1341 cmdCodeOffset); 1821 1342 1822 if ((!(flags & TCL_BRACKET_TERM))1823 && (tclTraceCompile >= 1) && (envPtr->procPtr == NULL)) {1824 /*1825 * Display a line summarizing the top level command we are about1826 * 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 1848 1343 while ((type != TCL_COMMAND_END) 1849 1344 || ((c == ']') && !(flags & TCL_BRACKET_TERM))) { -
external/tcl/tclCompile.h
r2d7ff18 r83ee320 36 36 37 37 extern 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 tracing43 * 1: summarize compilation of top level cmds and proc bodies44 * 2: display all instructions of each ByteCode compiled45 * This variable is linked to the Tcl variable "tcl_traceCompile".46 */47 48 extern int tclTraceCompile;49 50 /*51 * Variable that controls whether execution tracing is enabled and, if so,52 * what level of tracing is desired:53 * 0: no execution tracing54 * 1: trace invocations of Tcl procs only55 * 2: trace invocations of all (not compiled away) commands56 * 3: display each instruction executed57 * This variable is linked to the Tcl variable "tcl_traceExec".58 */59 60 extern int tclTraceExec;61 62 /*63 * The number of bytecode compilations and various other compilation-related64 * statistics. The tclByteCodeCount and tclSourceCount arrays are used to65 * hold the count of ByteCodes and sources whose sizes fall into various66 * binary decades; e.g., tclByteCodeCount[5] is a count of the ByteCodes67 * with size larger than 2**4 and less than or equal to 2**5.68 */69 70 #ifdef TCL_COMPILE_STATS71 extern long tclNumCompilations;72 extern double tclTotalSourceBytes;73 extern double tclTotalCodeBytes;74 75 extern double tclTotalInstBytes;76 extern double tclTotalObjBytes;77 extern double tclTotalExceptBytes;78 extern double tclTotalAuxBytes;79 extern double tclTotalCmdMapBytes;80 81 extern double tclCurrentSourceBytes;82 extern double tclCurrentCodeBytes;83 84 extern int tclSourceCount[32];85 extern int tclByteCodeCount[32];86 #endif /* TCL_COMPILE_STATS */87 38 88 39 /* … … 816 767 EXTERN void TclInitJumpFixupArray _ANSI_ARGS_(( 817 768 JumpFixupArray *fixupArrayPtr)); 818 #ifdef TCL_COMPILE_STATS819 EXTERN int TclLog2 _ANSI_ARGS_((int value));820 #endif /*TCL_COMPILE_STATS*/821 769 EXTERN int TclObjIndexForString _ANSI_ARGS_((char *start, 822 770 int length, int allocStrRep, int inHeap, 823 771 CompileEnv *envPtr)); 824 EXTERN int TclPrintInstruction _ANSI_ARGS_((ByteCode* codePtr,825 unsigned char *pc));826 772 EXTERN void TclPrintSource _ANSI_ARGS_((FILE *outFile, 827 773 char *string, int maxChars)); -
external/tcl/tclExecute.c
r2d7ff18 r83ee320 51 51 52 52 /* 53 * Variable that controls whether execution tracing is enabled and, if so,54 * what level of tracing is desired:55 * 0: no execution tracing56 * 1: trace invocations of Tcl procs only57 * 2: trace invocations of all (not compiled away) commands58 * 3: display each instruction executed59 * This variable is linked to the Tcl variable "tcl_traceExec".60 */61 62 int tclTraceExec = 0;63 64 /*65 53 * The following global variable is use to signal matherr that Tcl 66 54 * is responsible for the arithmetic, so errors can be handled in a … … 102 90 }; 103 91 104 /*105 * Mapping from Tcl result codes to strings; used for error and debugging106 * messages.107 */108 109 #ifdef TCL_COMPILE_DEBUG110 static char *resultStrings[] = {111 "TCL_OK", "TCL_ERROR", "TCL_RETURN", "TCL_BREAK", "TCL_CONTINUE"112 };113 #endif /* TCL_COMPILE_DEBUG */114 115 /*116 * The following are statistics-related variables that record information117 * about the bytecode compiler and interpreter's operation. This includes118 * an array that records for each instruction how often it is executed.119 */120 121 #ifdef TCL_COMPILE_STATS122 static long numExecutions = 0;123 static int instructionCount[256];124 #endif /* TCL_COMPILE_STATS */125 126 92 /* 127 93 * Macros for testing floating-point values for certain special cases. Test … … 187 153 #define POP_OBJECT() \ 188 154 (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'S196 * STRING REP CONTAINS NULLS.197 */198 199 #ifdef TCL_COMPILE_DEBUG200 201 #define O2S(objPtr) \202 Tcl_GetStringFromObj((objPtr), &length)203 204 #ifdef TCL_COMPILE_STATS205 #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 */251 155 252 156 /* … … 274 178 static int ExprUnaryFunc _ANSI_ARGS_((Tcl_Interp *interp, 275 179 ExecEnv *eePtr, ClientData clientData)); 276 #ifdef TCL_COMPILE_STATS277 static int EvalStatsCmd _ANSI_ARGS_((ClientData clientData,278 Tcl_Interp *interp, int argc, char **argv));279 #endif /* TCL_COMPILE_STATS */280 180 static void FreeCmdNameInternalRep _ANSI_ARGS_(( 281 181 Tcl_Obj *objPtr)); … … 293 193 static int SetCmdNameFromAny _ANSI_ARGS_((Tcl_Interp *interp, 294 194 Tcl_Obj *objPtr)); 295 #ifdef TCL_COMPILE_DEBUG296 static char * StringForResultCode _ANSI_ARGS_((int result));297 #endif /* TCL_COMPILE_DEBUG */298 195 static void UpdateStringOfCmdName _ANSI_ARGS_((Tcl_Obj *objPtr)); 299 #ifdef TCL_COMPILE_DEBUG300 static void ValidatePcAndStackTop _ANSI_ARGS_((301 ByteCode *codePtr, unsigned char *pc,302 int stackTop, int stackLowerBound,303 int stackUpperBound));304 #endif /* TCL_COMPILE_DEBUG */305 196 306 197 /* … … 368 259 * 369 260 * Side effects: 370 * This procedure initializes the array of instruction names. If 371 * compiling with the TCL_COMPILE_STATS flag, it initializes the 372 * array that counts the executions of each instruction and it 373 * creates the "evalstats" command. It also registers the command name 374 * Tcl_ObjType. It also establishes the link between the Tcl 375 * "tcl_traceExec" and C "tclTraceExec" variables. 261 * This procedure initializes the array of instruction names. 376 262 * 377 263 *---------------------------------------------------------------------- … … 391 277 for (i = 0; instructionTable[i].name != NULL; i++) { 392 278 opName[i] = instructionTable[i].name; 393 }394 395 #ifdef TCL_COMPILE_STATS396 (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");407 279 } 408 280 } … … 598 470 * process break, continue, and errors. */ 599 471 int result = TCL_OK; /* Return code returned after execution. */ 600 int traceInstructions = (tclTraceExec == 3);601 472 Tcl_Obj *valuePtr, *value2Ptr, *namePtr, *objPtr; 602 473 char *bytes; 603 474 int length; 604 475 long i; 605 Tcl_DString command; /* Used for debugging. If tclTraceExec >= 2606 * holds a string representing the last607 * command invoked. */608 476 609 477 /* … … 620 488 621 489 /* 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_STATS628 fprintf(stdout, " Starting stack top=%d, system objects=%ld\n",629 eePtr->stackTop, (tclObjsAlloced - tclObjsFreed));630 #else631 fprintf(stdout, " Starting stack top=%d\n", eePtr->stackTop);632 #endif /* TCL_COMPILE_STATS */633 fflush(stdout);634 }635 636 #ifdef TCL_COMPILE_STATS637 numExecutions++;638 #endif /* TCL_COMPILE_STATS */639 640 /*641 490 * Make sure the catch stack is large enough to hold the maximum number 642 491 * of catch commands that could ever be executing at the same time. This … … 659 508 660 509 /* 661 * Initialize the buffer that holds a string containing the name and662 * arguments for the last invoked command.663 */664 665 Tcl_DStringInit(&command);666 667 /*668 510 * Loop executing instructions until a "done" instruction, a TCL_RETURN, 669 511 * or some error. … … 671 513 672 514 for (;;) { 673 #ifdef TCL_COMPILE_DEBUG674 ValidatePcAndStackTop(codePtr, pc, stackTop, initStackTop,675 eePtr->stackEnd);676 #else /* not TCL_COMPILE_DEBUG */677 if (traceInstructions) {678 #ifdef TCL_COMPILE_STATS679 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 689 515 opCode = *pc; 690 #ifdef TCL_COMPILE_STATS691 instructionCount[opCode]++;692 #endif /* TCL_COMPILE_STATS */693 516 694 517 switch (opCode) { … … 710 533 panic("TclExecuteByteCode execution failure: end stack top != start stack top"); 711 534 } 712 TRACE_WITH_OBJ(("done => return code=%d, result is ", result),713 iPtr->objResultPtr);714 535 goto done; 715 536 … … 717 538 valuePtr = objArrayPtr[TclGetUInt1AtPtr(pc+1)]; 718 539 PUSH_OBJECT(valuePtr); 719 TRACE_WITH_OBJ(("push1 %u => ", TclGetUInt1AtPtr(pc+1)),720 valuePtr);721 540 ADJUST_PC(2); 722 541 … … 724 543 valuePtr = objArrayPtr[TclGetUInt4AtPtr(pc+1)]; 725 544 PUSH_OBJECT(valuePtr); 726 TRACE_WITH_OBJ(("push4 %u => ", TclGetUInt4AtPtr(pc+1)),727 valuePtr);728 545 ADJUST_PC(5); 729 546 730 547 case INST_POP: 731 548 valuePtr = POP_OBJECT(); 732 TRACE_WITH_OBJ(("pop => discarding "), valuePtr);733 549 TclDecrRefCount(valuePtr); /* finished with pop'ed object. */ 734 550 ADJUST_PC(1); … … 737 553 valuePtr = stackPtr[stackTop].o; 738 554 PUSH_OBJECT(Tcl_DuplicateObj(valuePtr)); 739 TRACE_WITH_OBJ(("dup => "), valuePtr);740 555 ADJUST_PC(1); 741 556 … … 790 605 791 606 PUSH_OBJECT(concatObjPtr); 792 TRACE_WITH_OBJ(("concat %u => ", opnd), concatObjPtr);793 607 ADJUST_PC(2); 794 608 } … … 815 629 * Init. to avoid compiler warning. */ 816 630 Tcl_Command cmd; 817 #ifdef TCL_COMPILE_DEBUG818 int isUnknownCmd = 0;819 char cmdNameBuf[30];820 #endif /* TCL_COMPILE_DEBUG */821 631 822 632 /* … … 867 677 "invalid command name \"", cmdName, "\"", 868 678 (char *) NULL); 869 TRACE(("%s %u => unknown proc not found: ",870 opName[opCode], objc));871 679 result = TCL_ERROR; 872 680 goto checkForCatch; 873 681 } 874 682 cmdPtr = (Command *) cmd; 875 #ifdef TCL_COMPILE_DEBUG876 isUnknownCmd = 1;877 #endif /*TCL_COMPILE_DEBUG*/878 683 stackTop++; /* need room for new inserted objv[0] */ 879 684 for (i = objc; i >= 0; i--) { … … 918 723 Tcl_ResetResult(interp); 919 724 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_DEBUG928 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 953 725 iPtr->cmdCount++; 954 726 DECACHE_STACK_INFO(); … … 996 768 */ 997 769 PUSH_OBJECT(Tcl_GetObjResult(interp)); 998 TRACE_WITH_OBJ(("%s %u => ...after \"%.20s\", result=",999 opName[opCode], objc, cmdNameBuf),1000 Tcl_GetObjResult(interp));1001 770 ADJUST_PC(pcAdjustment); 1002 771 … … 1015 784 /*catchOnly*/ 0, codePtr); 1016 785 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)));1020 786 goto abnormalReturn; /* no catch exists to check */ 1021 787 } … … 1025 791 newPcOffset = rangePtr->breakOffset; 1026 792 } 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)));1030 793 goto checkForCatch; 1031 794 } else { 1032 795 newPcOffset = rangePtr->continueOffset; 1033 796 } 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));1038 797 break; 1039 798 case CATCH_EXCEPTION_RANGE: 1040 TRACE(("%s %u => ... after \"%.20s\", %s...\n",1041 opName[opCode], objc, cmdNameBuf,1042 StringForResultCode(result)));1043 799 goto processCatch; /* it will use rangePtr */ 1044 800 default: … … 1054 810 * enclosing catch exception range, if any. 1055 811 */ 1056 TRACE_WITH_OBJ(("%s %u => ... after \"%.20s\", TCL_ERROR ",1057 opName[opCode], objc, cmdNameBuf),1058 Tcl_GetObjResult(interp));1059 812 goto checkForCatch; 1060 813 … … 1065 818 * for an enclosing catch exception range, if any. 1066 819 */ 1067 TRACE(("%s %u => ... after \"%.20s\", TCL_RETURN\n",1068 opName[opCode], objc, cmdNameBuf));1069 820 goto checkForCatch; 1070 821 1071 822 default: 1072 TRACE_WITH_OBJ(("%s %u => ... after \"%.20s\", OTHER RETURN CODE %d ",1073 opName[opCode], objc, cmdNameBuf, result),1074 Tcl_GetObjResult(interp));1075 823 goto checkForCatch; 1076 824 } /* end of switch on result from invoke instruction */ … … 1088 836 1089 837 PUSH_OBJECT(Tcl_GetObjResult(interp)); 1090 TRACE_WITH_OBJ(("evalStk \"%.30s\" => ", O2S(objPtr)),1091 Tcl_GetObjResult(interp));1092 838 TclDecrRefCount(objPtr); 1093 839 ADJUST_PC(1); … … 1109 855 codePtr); 1110 856 if (rangePtr == NULL) { 1111 TRACE(("evalStk \"%.30s\" => no encl. loop or catch, returning %s\n",1112 O2S(objPtr), StringForResultCode(result)));1113 857 Tcl_DecrRefCount(objPtr); 1114 858 goto abnormalReturn; /* no catch exists to check */ … … 1119 863 newPcOffset = rangePtr->breakOffset; 1120 864 } else if (rangePtr->continueOffset == -1) { 1121 TRACE(("evalStk \"%.30s\" => %s, loop w/o continue, checking for catch\n",1122 O2S(objPtr), StringForResultCode(result)));1123 865 Tcl_DecrRefCount(objPtr); 1124 866 goto checkForCatch; … … 1127 869 } 1128 870 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);1132 871 break; 1133 872 case CATCH_EXCEPTION_RANGE: 1134 TRACE_WITH_OBJ(("evalStk \"%.30s\" => %s ",1135 O2S(objPtr), StringForResultCode(result)),1136 valuePtr);1137 873 Tcl_DecrRefCount(objPtr); 1138 874 goto processCatch; /* it will use rangePtr */ … … 1144 880 continue; /* restart outer instruction loop at pc */ 1145 881 } else { /* eval returned TCL_ERROR, TCL_RETURN, unknown code */ 1146 TRACE_WITH_OBJ(("evalStk \"%.30s\" => ERROR: ", O2S(objPtr)),1147 Tcl_GetObjResult(interp));1148 882 Tcl_DecrRefCount(objPtr); 1149 883 goto checkForCatch; … … 1157 891 CACHE_STACK_INFO(); 1158 892 if (result != TCL_OK) { 1159 TRACE_WITH_OBJ(("exprStk \"%.30s\" => ERROR: ",1160 O2S(objPtr)), Tcl_GetObjResult(interp));1161 893 Tcl_DecrRefCount(objPtr); 1162 894 goto checkForCatch; 1163 895 } 1164 896 stackPtr[++stackTop].o = valuePtr; /* already has right refct */ 1165 TRACE_WITH_OBJ(("exprStk \"%.30s\" => ", O2S(objPtr)), valuePtr);1166 897 TclDecrRefCount(objPtr); 1167 898 ADJUST_PC(1); … … 1182 913 CACHE_STACK_INFO(); 1183 914 if (valuePtr == NULL) { 1184 TRACE_WITH_OBJ(("%s %u => ERROR: ", opName[opCode], opnd),1185 Tcl_GetObjResult(interp));1186 915 result = TCL_ERROR; 1187 916 goto checkForCatch; 1188 917 } 1189 918 PUSH_OBJECT(valuePtr); 1190 TRACE_WITH_OBJ(("%s %u => ", opName[opCode], opnd), valuePtr);1191 919 ADJUST_PC(pcAdjustment); 1192 920 … … 1198 926 CACHE_STACK_INFO(); 1199 927 if (valuePtr == NULL) { 1200 TRACE_WITH_OBJ(("loadScalarStk \"%.30s\" => ERROR: ",1201 O2S(namePtr)), Tcl_GetObjResult(interp));1202 928 Tcl_DecrRefCount(namePtr); 1203 929 result = TCL_ERROR; … … 1205 931 } 1206 932 PUSH_OBJECT(valuePtr); 1207 TRACE_WITH_OBJ(("loadScalarStk \"%.30s\" => ",1208 O2S(namePtr)), valuePtr);1209 933 TclDecrRefCount(namePtr); 1210 934 ADJUST_PC(1); … … 1228 952 CACHE_STACK_INFO(); 1229 953 if (valuePtr == NULL) { 1230 TRACE_WITH_OBJ(("%s %u \"%.30s\" => ERROR: ",1231 opName[opCode], opnd, O2S(elemPtr)),1232 Tcl_GetObjResult(interp));1233 954 Tcl_DecrRefCount(elemPtr); 1234 955 result = TCL_ERROR; … … 1236 957 } 1237 958 PUSH_OBJECT(valuePtr); 1238 TRACE_WITH_OBJ(("%s %u \"%.30s\" => ",1239 opName[opCode], opnd, O2S(elemPtr)), valuePtr);1240 959 TclDecrRefCount(elemPtr); 1241 960 } … … 1252 971 CACHE_STACK_INFO(); 1253 972 if (valuePtr == NULL) { 1254 TRACE_WITH_OBJ(("loadArrayStk \"%.30s(%.30s)\" => ERROR: ",1255 O2S(namePtr), O2S(elemPtr)),1256 Tcl_GetObjResult(interp));1257 973 Tcl_DecrRefCount(namePtr); 1258 974 Tcl_DecrRefCount(elemPtr); … … 1261 977 } 1262 978 PUSH_OBJECT(valuePtr); 1263 TRACE_WITH_OBJ(("loadArrayStk \"%.30s(%.30s)\" => ",1264 O2S(namePtr), O2S(elemPtr)), valuePtr);1265 979 TclDecrRefCount(namePtr); 1266 980 TclDecrRefCount(elemPtr); … … 1275 989 CACHE_STACK_INFO(); 1276 990 if (valuePtr == NULL) { 1277 TRACE_WITH_OBJ(("loadStk \"%.30s\" => ERROR: ",1278 O2S(namePtr)), Tcl_GetObjResult(interp));1279 991 Tcl_DecrRefCount(namePtr); 1280 992 result = TCL_ERROR; … … 1282 994 } 1283 995 PUSH_OBJECT(valuePtr); 1284 TRACE_WITH_OBJ(("loadStk \"%.30s\" => ", O2S(namePtr)),1285 valuePtr);1286 996 TclDecrRefCount(namePtr); 1287 997 ADJUST_PC(1); … … 1303 1013 CACHE_STACK_INFO(); 1304 1014 if (value2Ptr == NULL) { 1305 TRACE_WITH_OBJ(("%s %u <- \"%.30s\" => ERROR: ",1306 opName[opCode], opnd, O2S(valuePtr)),1307 Tcl_GetObjResult(interp));1308 1015 Tcl_DecrRefCount(valuePtr); 1309 1016 result = TCL_ERROR; … … 1311 1018 } 1312 1019 PUSH_OBJECT(value2Ptr); 1313 TRACE_WITH_OBJ(("%s %u <- \"%.30s\" => ",1314 opName[opCode], opnd, O2S(valuePtr)), value2Ptr);1315 1020 TclDecrRefCount(valuePtr); 1316 1021 ADJUST_PC(pcAdjustment); … … 1324 1029 CACHE_STACK_INFO(); 1325 1030 if (value2Ptr == NULL) { 1326 TRACE_WITH_OBJ(1327 ("storeScalarStk \"%.30s\" <- \"%.30s\" => ERROR: ",1328 O2S(namePtr), O2S(valuePtr)),1329 Tcl_GetObjResult(interp));1330 1031 Tcl_DecrRefCount(namePtr); 1331 1032 Tcl_DecrRefCount(valuePtr); … … 1334 1035 } 1335 1036 PUSH_OBJECT(value2Ptr); 1336 TRACE_WITH_OBJ(1337 ("storeScalarStk \"%.30s\" <- \"%.30s\" => ",1338 O2S(namePtr),1339 O2S(valuePtr)),1340 value2Ptr);1341 1037 TclDecrRefCount(namePtr); 1342 1038 TclDecrRefCount(valuePtr); … … 1363 1059 CACHE_STACK_INFO(); 1364 1060 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));1369 1061 Tcl_DecrRefCount(elemPtr); 1370 1062 Tcl_DecrRefCount(valuePtr); … … 1373 1065 } 1374 1066 PUSH_OBJECT(value2Ptr); 1375 TRACE_WITH_OBJ(("%s %u \"%.30s\" <- \"%.30s\" => ",1376 opName[opCode], opnd, O2S(elemPtr), O2S(valuePtr)),1377 value2Ptr);1378 1067 TclDecrRefCount(elemPtr); 1379 1068 TclDecrRefCount(valuePtr); … … 1393 1082 CACHE_STACK_INFO(); 1394 1083 if (value2Ptr == NULL) { 1395 TRACE_WITH_OBJ(("storeArrayStk \"%.30s(%.30s)\" <- \"%.30s\" => ERROR: ",1396 O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),1397 Tcl_GetObjResult(interp));1398 1084 Tcl_DecrRefCount(namePtr); 1399 1085 Tcl_DecrRefCount(elemPtr); … … 1403 1089 } 1404 1090 PUSH_OBJECT(value2Ptr); 1405 TRACE_WITH_OBJ(("storeArrayStk \"%.30s(%.30s)\" <- \"%.30s\" => ",1406 O2S(namePtr), O2S(elemPtr), O2S(valuePtr)),1407 value2Ptr);1408 1091 TclDecrRefCount(namePtr); 1409 1092 TclDecrRefCount(elemPtr); … … 1420 1103 CACHE_STACK_INFO(); 1421 1104 if (value2Ptr == NULL) { 1422 TRACE_WITH_OBJ(("storeStk \"%.30s\" <- \"%.30s\" => ERROR: ",1423 O2S(namePtr), O2S(valuePtr)),1424 Tcl_GetObjResult(interp));1425 1105 Tcl_DecrRefCount(namePtr); 1426 1106 Tcl_DecrRefCount(valuePtr); … … 1429 1109 } 1430 1110 PUSH_OBJECT(value2Ptr); 1431 TRACE_WITH_OBJ(("storeStk \"%.30s\" <- \"%.30s\" => ",1432 O2S(namePtr), O2S(valuePtr)), value2Ptr);1433 1111 TclDecrRefCount(namePtr); 1434 1112 TclDecrRefCount(valuePtr); … … 1441 1119 result = tclIntType.setFromAnyProc(interp, valuePtr); 1442 1120 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));1445 1121 Tcl_DecrRefCount(valuePtr); 1446 1122 goto checkForCatch; … … 1452 1128 CACHE_STACK_INFO(); 1453 1129 if (value2Ptr == NULL) { 1454 TRACE_WITH_OBJ(("incrScalar1 %u (by %ld) => ERROR: ",1455 opnd, i), Tcl_GetObjResult(interp));1456 1130 Tcl_DecrRefCount(valuePtr); 1457 1131 result = TCL_ERROR; … … 1459 1133 } 1460 1134 PUSH_OBJECT(value2Ptr); 1461 TRACE_WITH_OBJ(("incrScalar1 %u (by %ld) => ", opnd, i),1462 value2Ptr);1463 1135 TclDecrRefCount(valuePtr); 1464 1136 ADJUST_PC(2); … … 1471 1143 result = tclIntType.setFromAnyProc(interp, valuePtr); 1472 1144 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));1476 1145 Tcl_DecrRefCount(namePtr); 1477 1146 Tcl_DecrRefCount(valuePtr); … … 1485 1154 CACHE_STACK_INFO(); 1486 1155 if (value2Ptr == NULL) { 1487 TRACE_WITH_OBJ(("%s \"%.30s\" (by %ld) => ERROR: ",1488 opName[opCode], O2S(namePtr), i),1489 Tcl_GetObjResult(interp));1490 1156 Tcl_DecrRefCount(namePtr); 1491 1157 Tcl_DecrRefCount(valuePtr); … … 1494 1160 } 1495 1161 PUSH_OBJECT(value2Ptr); 1496 TRACE_WITH_OBJ(("%s \"%.30s\" (by %ld) => ",1497 opName[opCode], O2S(namePtr), i), value2Ptr);1498 1162 Tcl_DecrRefCount(namePtr); 1499 1163 Tcl_DecrRefCount(valuePtr); … … 1510 1174 result = tclIntType.setFromAnyProc(interp, valuePtr); 1511 1175 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));1515 1176 Tcl_DecrRefCount(elemPtr); 1516 1177 Tcl_DecrRefCount(valuePtr); … … 1524 1185 CACHE_STACK_INFO(); 1525 1186 if (value2Ptr == NULL) { 1526 TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %ld) => ERROR: ",1527 opnd, O2S(elemPtr), i),1528 Tcl_GetObjResult(interp));1529 1187 Tcl_DecrRefCount(elemPtr); 1530 1188 Tcl_DecrRefCount(valuePtr); … … 1533 1191 } 1534 1192 PUSH_OBJECT(value2Ptr); 1535 TRACE_WITH_OBJ(("incrArray1 %u \"%.30s\" (by %ld) => ",1536 opnd, O2S(elemPtr), i), value2Ptr);1537 1193 Tcl_DecrRefCount(elemPtr); 1538 1194 Tcl_DecrRefCount(valuePtr); … … 1550 1206 result = tclIntType.setFromAnyProc(interp, valuePtr); 1551 1207 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));1555 1208 Tcl_DecrRefCount(namePtr); 1556 1209 Tcl_DecrRefCount(elemPtr); … … 1565 1218 CACHE_STACK_INFO(); 1566 1219 if (value2Ptr == NULL) { 1567 TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %ld) => ERROR: ",1568 O2S(namePtr), O2S(elemPtr), i),1569 Tcl_GetObjResult(interp));1570 1220 Tcl_DecrRefCount(namePtr); 1571 1221 Tcl_DecrRefCount(elemPtr); … … 1575 1225 } 1576 1226 PUSH_OBJECT(value2Ptr); 1577 TRACE_WITH_OBJ(("incrArrayStk \"%.30s(%.30s)\" (by %ld) => ",1578 O2S(namePtr), O2S(elemPtr), i), value2Ptr);1579 1227 Tcl_DecrRefCount(namePtr); 1580 1228 Tcl_DecrRefCount(elemPtr); … … 1590 1238 CACHE_STACK_INFO(); 1591 1239 if (value2Ptr == NULL) { 1592 TRACE_WITH_OBJ(("incrScalar1Imm %u %ld => ERROR: ",1593 opnd, i), Tcl_GetObjResult(interp));1594 1240 result = TCL_ERROR; 1595 1241 goto checkForCatch; 1596 1242 } 1597 1243 PUSH_OBJECT(value2Ptr); 1598 TRACE_WITH_OBJ(("incrScalar1Imm %u %ld => ", opnd, i),1599 value2Ptr);1600 1244 ADJUST_PC(3); 1601 1245 … … 1609 1253 CACHE_STACK_INFO(); 1610 1254 if (value2Ptr == NULL) { 1611 TRACE_WITH_OBJ(("%s \"%.30s\" %ld => ERROR: ",1612 opName[opCode], O2S(namePtr), i),1613 Tcl_GetObjResult(interp));1614 1255 result = TCL_ERROR; 1615 1256 Tcl_DecrRefCount(namePtr); … … 1617 1258 } 1618 1259 PUSH_OBJECT(value2Ptr); 1619 TRACE_WITH_OBJ(("%s \"%.30s\" %ld => ",1620 opName[opCode], O2S(namePtr), i), value2Ptr);1621 1260 TclDecrRefCount(namePtr); 1622 1261 ADJUST_PC(2); … … 1634 1273 CACHE_STACK_INFO(); 1635 1274 if (value2Ptr == NULL) { 1636 TRACE_WITH_OBJ(("incrArray1Imm %u \"%.30s\" (by %ld) => ERROR: ",1637 opnd, O2S(elemPtr), i),1638 Tcl_GetObjResult(interp));1639 1275 Tcl_DecrRefCount(elemPtr); 1640 1276 result = TCL_ERROR; … … 1642 1278 } 1643 1279 PUSH_OBJECT(value2Ptr); 1644 TRACE_WITH_OBJ(("incrArray1Imm %u \"%.30s\" (by %ld) => ",1645 opnd, O2S(elemPtr), i), value2Ptr);1646 1280 Tcl_DecrRefCount(elemPtr); 1647 1281 } … … 1660 1294 CACHE_STACK_INFO(); 1661 1295 if (value2Ptr == NULL) { 1662 TRACE_WITH_OBJ(("incrArrayStkImm \"%.30s(%.30s)\" (by %ld) => ERROR: ",1663 O2S(namePtr), O2S(elemPtr), i),1664 Tcl_GetObjResult(interp));1665 1296 Tcl_DecrRefCount(namePtr); 1666 1297 Tcl_DecrRefCount(elemPtr); … … 1669 1300 } 1670 1301 PUSH_OBJECT(value2Ptr); 1671 TRACE_WITH_OBJ(("incrArrayStkImm \"%.30s(%.30s)\" (by %ld) => ",1672 O2S(namePtr), O2S(elemPtr), i), value2Ptr);1673 1302 Tcl_DecrRefCount(namePtr); 1674 1303 Tcl_DecrRefCount(elemPtr); … … 1678 1307 case INST_JUMP1: 1679 1308 opnd = TclGetInt1AtPtr(pc+1); 1680 TRACE(("jump1 %d => new pc %u\n", opnd,1681 (unsigned int)(pc + opnd - codePtr->codeStart)));1682 1309 ADJUST_PC(opnd); 1683 1310 1684 1311 case INST_JUMP4: 1685 1312 opnd = TclGetInt4AtPtr(pc+1); 1686 TRACE(("jump4 %d => new pc %u\n", opnd,1687 (unsigned int)(pc + opnd - codePtr->codeStart)));1688 1313 ADJUST_PC(opnd); 1689 1314 … … 1709 1334 result = Tcl_GetBooleanFromObj(interp, valuePtr, &b); 1710 1335 if (result != TCL_OK) { 1711 TRACE_WITH_OBJ(("%s %d => ERROR: ", opName[opCode],1712 opnd), Tcl_GetObjResult(interp));1713 1336 Tcl_DecrRefCount(valuePtr); 1714 1337 goto checkForCatch; … … 1716 1339 } 1717 1340 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)));1721 1341 TclDecrRefCount(valuePtr); 1722 1342 ADJUST_PC(opnd); 1723 1343 } else { 1724 TRACE(("%s %d => %.20s false\n", opName[opCode], opnd,1725 O2S(valuePtr)));1726 1344 TclDecrRefCount(valuePtr); 1727 1345 ADJUST_PC(pcAdjustment); … … 1750 1368 result = Tcl_GetBooleanFromObj(interp, valuePtr, &b); 1751 1369 if (result != TCL_OK) { 1752 TRACE_WITH_OBJ(("%s %d => ERROR: ", opName[opCode],1753 opnd), Tcl_GetObjResult(interp));1754 1370 Tcl_DecrRefCount(valuePtr); 1755 1371 goto checkForCatch; … … 1757 1373 } 1758 1374 if (b) { 1759 TRACE(("%s %d => %.20s true\n", opName[opCode], opnd,1760 O2S(valuePtr)));1761 1375 TclDecrRefCount(valuePtr); 1762 1376 ADJUST_PC(pcAdjustment); 1763 1377 } else { 1764 TRACE(("%s %d => %.20s false, new pc %u\n",1765 opName[opCode], opnd, O2S(valuePtr),1766 (unsigned int)(pc + opnd - codePtr->codeStart)));1767 1378 TclDecrRefCount(valuePtr); 1768 1379 ADJUST_PC(opnd); … … 1804 1415 } 1805 1416 if (result != TCL_OK) { 1806 TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",1807 opName[opCode], O2S(valuePtr),1808 (t1Ptr? t1Ptr->name : "null")));1809 1417 IllegalExprOperandType(interp, opCode, valuePtr); 1810 1418 Tcl_DecrRefCount(valuePtr); … … 1830 1438 } 1831 1439 if (result != TCL_OK) { 1832 TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",1833 opName[opCode], O2S(value2Ptr),1834 (t2Ptr? t2Ptr->name : "null")));1835 1440 IllegalExprOperandType(interp, opCode, value2Ptr); 1836 1441 Tcl_DecrRefCount(valuePtr); … … 1851 1456 if (Tcl_IsShared(valuePtr)) { 1852 1457 PUSH_OBJECT(Tcl_NewLongObj(iResult)); 1853 TRACE(("%s %.20s %.20s => %d\n", opName[opCode],1854 O2S(valuePtr), O2S(value2Ptr), iResult));1855 1458 TclDecrRefCount(valuePtr); 1856 1459 } 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));1860 1460 Tcl_SetLongObj(valuePtr, iResult); 1861 1461 ++stackTop; /* valuePtr now on stk top has right r.c. */ … … 2013 1613 if (Tcl_IsShared(valuePtr)) { 2014 1614 PUSH_OBJECT(Tcl_NewLongObj(iResult)); 2015 TRACE(("%s %.20s %.20s => %ld\n", opName[opCode],2016 O2S(valuePtr), O2S(value2Ptr), iResult));2017 1615 TclDecrRefCount(valuePtr); 2018 1616 } 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));2022 1617 Tcl_SetLongObj(valuePtr, iResult); 2023 1618 ++stackTop; /* valuePtr now on stk top has right r.c. */ … … 2049 1644 valuePtr, &i); 2050 1645 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")));2055 1646 IllegalExprOperandType(interp, opCode, valuePtr); 2056 1647 Tcl_DecrRefCount(valuePtr); … … 2065 1656 value2Ptr, &i2); 2066 1657 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")));2071 1658 IllegalExprOperandType(interp, opCode, value2Ptr); 2072 1659 Tcl_DecrRefCount(valuePtr); … … 2085 1672 */ 2086 1673 if (i2 == 0) { 2087 TRACE(("mod %ld %ld => DIVIDE BY ZERO\n", i, i2));2088 1674 Tcl_DecrRefCount(valuePtr); 2089 1675 Tcl_DecrRefCount(value2Ptr); … … 2137 1723 if (Tcl_IsShared(valuePtr)) { 2138 1724 PUSH_OBJECT(Tcl_NewLongObj(iResult)); 2139 TRACE(("%s %ld %ld => %ld\n", opName[opCode], i, i2,2140 iResult));2141 1725 TclDecrRefCount(valuePtr); 2142 1726 } 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 */2145 1727 Tcl_SetLongObj(valuePtr, iResult); 2146 1728 ++stackTop; /* valuePtr now on stk top has right r.c. */ … … 2186 1768 } 2187 1769 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")));2192 1770 IllegalExprOperandType(interp, opCode, valuePtr); 2193 1771 Tcl_DecrRefCount(valuePtr); … … 2212 1790 } 2213 1791 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")));2218 1792 IllegalExprOperandType(interp, opCode, value2Ptr); 2219 1793 Tcl_DecrRefCount(valuePtr); … … 2246 1820 case INST_DIV: 2247 1821 if (d2 == 0.0) { 2248 TRACE(("div %.6g %.6g => DIVIDE BY ZERO\n",2249 d1, d2));2250 1822 Tcl_DecrRefCount(valuePtr); 2251 1823 Tcl_DecrRefCount(value2Ptr); … … 2261 1833 2262 1834 if (IS_NAN(dResult) || IS_INF(dResult)) { 2263 TRACE(("%s %.20s %.20s => IEEE FLOATING PT ERROR\n",2264 opName[opCode], O2S(valuePtr), O2S(value2Ptr)));2265 1835 TclExprFloatError(interp, dResult); 2266 1836 result = TCL_ERROR; … … 2291 1861 */ 2292 1862 if (i2 == 0) { 2293 TRACE(("div %ld %ld => DIVIDE BY ZERO\n",2294 i, i2));2295 1863 Tcl_DecrRefCount(valuePtr); 2296 1864 Tcl_DecrRefCount(value2Ptr); … … 2318 1886 if (doDouble) { 2319 1887 PUSH_OBJECT(Tcl_NewDoubleObj(dResult)); 2320 TRACE(("%s %.6g %.6g => %.6g\n", opName[opCode],2321 d1, d2, dResult));2322 1888 } else { 2323 1889 PUSH_OBJECT(Tcl_NewLongObj(iResult)); 2324 TRACE(("%s %ld %ld => %ld\n", opName[opCode],2325 i, i2, iResult));2326 1890 } 2327 1891 TclDecrRefCount(valuePtr); 2328 1892 } else { /* reuse the valuePtr object */ 2329 1893 if (doDouble) { /* NB: stack top is off by 1 */ 2330 TRACE(("%s %.6g %.6g => %.6g\n", opName[opCode],2331 d1, d2, dResult));2332 1894 Tcl_SetDoubleObj(valuePtr, dResult); 2333 1895 } else { 2334 TRACE(("%s %ld %ld => %ld\n", opName[opCode],2335 i, i2, iResult));2336 1896 Tcl_SetLongObj(valuePtr, iResult); 2337 1897 } … … 2363 1923 } 2364 1924 if (result != TCL_OK) { 2365 TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s \n",2366 opName[opCode], s,2367 (tPtr? tPtr->name : "null")));2368 1925 IllegalExprOperandType(interp, opCode, valuePtr); 2369 1926 goto checkForCatch; 2370 1927 } 2371 1928 } 2372 TRACE_WITH_OBJ(("uplus %s => ", O2S(valuePtr)), valuePtr);2373 1929 } 2374 1930 ADJUST_PC(1); … … 2399 1955 } 2400 1956 if (result != TCL_OK) { 2401 TRACE(("%s \"%.20s\" => ILLEGAL TYPE %s\n",2402 opName[opCode], s,2403 (tPtr? tPtr->name : "null")));2404 1957 IllegalExprOperandType(interp, opCode, valuePtr); 2405 1958 Tcl_DecrRefCount(valuePtr); … … 2417 1970 objPtr = Tcl_NewLongObj( 2418 1971 (opCode == INST_UMINUS)? -i : !i); 2419 TRACE_WITH_OBJ(("%s %ld => ", opName[opCode], i),2420 objPtr); /* NB: stack top is off by 1 */2421 1972 } else { 2422 1973 d = valuePtr->internalRep.doubleValue; … … 2430 1981 objPtr = Tcl_NewLongObj((d==0.0)? 1 : 0); 2431 1982 } 2432 TRACE_WITH_OBJ(("%s %.6g => ", opName[opCode], d),2433 objPtr); /* NB: stack top is off by 1 */2434 1983 } 2435 1984 PUSH_OBJECT(objPtr); … … 2443 1992 Tcl_SetLongObj(valuePtr, 2444 1993 (opCode == INST_UMINUS)? -i : !i); 2445 TRACE_WITH_OBJ(("%s %ld => ", opName[opCode], i),2446 valuePtr); /* NB: stack top is off by 1 */2447 1994 } else { 2448 1995 d = valuePtr->internalRep.doubleValue; … … 2456 2003 Tcl_SetLongObj(valuePtr, (d==0.0)? 1 : 0); 2457 2004 } 2458 TRACE_WITH_OBJ(("%s %.6g => ", opName[opCode], d),2459 valuePtr); /* NB: stack top is off by 1 */2460 2005 } 2461 2006 ++stackTop; /* valuePtr now on stk top has right r.c. */ … … 2481 2026 valuePtr, &i); 2482 2027 if (result != TCL_OK) { /* try to convert to double */ 2483 TRACE(("bitnot \"%.20s\" => ILLEGAL TYPE %s\n",2484 O2S(valuePtr), (tPtr? tPtr->name : "null")));2485 2028 IllegalExprOperandType(interp, opCode, valuePtr); 2486 2029 Tcl_DecrRefCount(valuePtr); … … 2492 2035 if (Tcl_IsShared(valuePtr)) { 2493 2036 PUSH_OBJECT(Tcl_NewLongObj(~i)); 2494 TRACE(("bitnot 0x%lx => (%lu)\n", i, ~i));2495 2037 TclDecrRefCount(valuePtr); 2496 2038 } else { … … 2500 2042 Tcl_SetLongObj(valuePtr, ~i); 2501 2043 ++stackTop; /* valuePtr now on stk top has right r.c. */ 2502 TRACE(("bitnot 0x%lx => (%lu)\n", i, ~i));2503 2044 } 2504 2045 } … … 2515 2056 2516 2057 if ((opnd < 0) || (opnd > LAST_BUILTIN_FUNC)) { 2517 TRACE(("UNRECOGNIZED BUILTIN FUNC CODE %d\n", opnd));2518 2058 panic("TclExecuteByteCode: unrecognized builtin function code %d", opnd); 2519 2059 } … … 2528 2068 goto checkForCatch; 2529 2069 } 2530 TRACE_WITH_OBJ(("callBuiltinFunc1 %d => ", opnd),2531 stackPtr[stackTop].o);2532 2070 } 2533 2071 ADJUST_PC(2); … … 2555 2093 goto checkForCatch; 2556 2094 } 2557 TRACE_WITH_OBJ(("callFunc1 %d => ", objc),2558 stackPtr[stackTop].o);2559 2095 ADJUST_PC(2); 2560 2096 } … … 2627 2163 d = valuePtr->internalRep.doubleValue; 2628 2164 if (IS_NAN(d) || IS_INF(d)) { 2629 TRACE(("tryCvtToNumeric \"%.20s\" => IEEE FLOATING PT ERROR\n",2630 O2S(valuePtr)));2631 2165 TclExprFloatError(interp, d); 2632 2166 result = TCL_ERROR; … … 2636 2170 shared = shared; /* lint, shared not used. */ 2637 2171 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)));2645 2172 } 2646 2173 } … … 2660 2187 codePtr); 2661 2188 if (rangePtr == NULL) { 2662 TRACE(("break => no encl. loop or catch, returning TCL_BREAK\n"));2663 2189 result = TCL_BREAK; 2664 2190 goto abnormalReturn; /* no catch exists to check */ … … 2667 2193 case LOOP_EXCEPTION_RANGE: 2668 2194 result = TCL_OK; 2669 TRACE(("break => range at %d, new pc %d\n",2670 rangePtr->codeOffset, rangePtr->breakOffset));2671 2195 break; 2672 2196 case CATCH_EXCEPTION_RANGE: 2673 2197 result = TCL_BREAK; 2674 TRACE(("break => ...\n"));2675 2198 goto processCatch; /* it will use rangePtr */ 2676 2199 default: … … 2693 2216 codePtr); 2694 2217 if (rangePtr == NULL) { 2695 TRACE(("continue => no encl. loop or catch, returning TCL_CONTINUE\n"));2696 2218 result = TCL_CONTINUE; 2697 2219 goto abnormalReturn; … … 2700 2222 case LOOP_EXCEPTION_RANGE: 2701 2223 if (rangePtr->continueOffset == -1) { 2702 TRACE(("continue => loop w/o continue, checking for catch\n"));2703 2224 goto checkForCatch; 2704 2225 } else { 2705 2226 result = TCL_OK; 2706 TRACE(("continue => range at %d, new pc %d\n",2707 rangePtr->codeOffset, rangePtr->continueOffset));2708 2227 } 2709 2228 break; 2710 2229 case CATCH_EXCEPTION_RANGE: 2711 2230 result = TCL_CONTINUE; 2712 TRACE(("continue => ...\n"));2713 2231 goto processCatch; /* it will use rangePtr */ 2714 2232 default: … … 2744 2262 TclSetVarScalar(iterVarPtr); 2745 2263 TclClearVarUndefined(iterVarPtr); 2746 TRACE(("foreach_start4 %u => loop iter count temp %d\n",2747 opnd, iterTmpIndex));2748 2264 } 2749 2265 ADJUST_PC(5); … … 2794 2310 result = Tcl_ListObjLength(interp, listPtr, &listLen); 2795 2311 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));2799 2312 goto checkForCatch; 2800 2313 } … … 2840 2353 CACHE_STACK_INFO(); 2841 2354 if (value2Ptr == NULL) { 2842 TRACE_WITH_OBJ(("foreach_step4 %u => ERROR init. index temp %d: ",2843 opnd, varIndex),2844 Tcl_GetObjResult(interp));2845 2355 if (setEmptyStr) { 2846 2356 Tcl_DecrRefCount(elemPtr); /* unneeded */ … … 2862 2372 2863 2373 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")));2867 2374 } 2868 2375 ADJUST_PC(5); … … 2875 2382 */ 2876 2383 catchStackPtr[++catchTop] = stackTop; 2877 TRACE(("beginCatch4 %u => catchTop=%d, stackTop=%d\n",2878 TclGetUInt4AtPtr(pc+1), catchTop, stackTop));2879 2384 ADJUST_PC(5); 2880 2385 … … 2882 2387 catchTop--; 2883 2388 result = TCL_OK; 2884 TRACE(("endCatch => catchTop=%d\n", catchTop));2885 2389 ADJUST_PC(1); 2886 2390 2887 2391 case INST_PUSH_RESULT: 2888 2392 PUSH_OBJECT(Tcl_GetObjResult(interp)); 2889 TRACE_WITH_OBJ(("pushResult => "), Tcl_GetObjResult(interp));2890 2393 ADJUST_PC(1); 2891 2394 2892 2395 case INST_PUSH_RETURN_CODE: 2893 2396 PUSH_OBJECT(Tcl_NewLongObj(result)); 2894 TRACE(("pushReturnCode => %u\n", result));2895 2397 ADJUST_PC(1); 2896 2398 2897 2399 default: 2898 TRACE(("UNRECOGNIZED INSTRUCTION %u\n", opCode));2899 2400 panic("TclExecuteByteCode: unrecognized opCode %u", opCode); 2900 2401 } /* end of switch on opCode */ … … 2926 2427 rangePtr = TclGetExceptionRangeForPc(pc, /*catchOnly*/ 1, codePtr); 2927 2428 if (rangePtr == NULL) { 2928 TRACE((" ... no enclosing catch, returning %s\n",2929 StringForResultCode(result)));2930 2429 goto abnormalReturn; 2931 2430 } … … 2945 2444 TclDecrRefCount(valuePtr); 2946 2445 } 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)));2950 2446 pc = (codePtr->codeStart + rangePtr->catchOffset); 2951 2447 continue; /* restart the execution loop at pc */ … … 2975 2471 #undef STATIC_CATCH_STACK_SIZE 2976 2472 } 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 the2986 * bytecode object if tclTraceExec has the value 2 or more.2987 *2988 * Results:2989 * None.2990 *2991 * Side effects:2992 * None.2993 *2994 *----------------------------------------------------------------------2995 */2996 2997 static void2998 PrintByteCodeInfo(codePtr)2999 register ByteCode *codePtr; /* The bytecode whose summary is printed3000 * 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 to3050 * verify that the program counter and stack top are valid during3051 * execution.3052 *3053 * Results:3054 * None.3055 *3056 * Side effects:3057 * Prints a message to stderr and panics if either the pc or stack3058 * top are invalid.3059 *3060 *----------------------------------------------------------------------3061 */3062 3063 #ifdef TCL_COMPILE_DEBUG3064 static void3065 ValidatePcAndStackTop(codePtr, pc, stackTop, stackLowerBound, stackUpperBound)3066 register ByteCode *codePtr; /* The bytecode whose summary is printed3067 * to stdout. */3068 unsigned char *pc; /* Points to first byte of a bytecode3069 * instruction. The program counter. */3070 int stackTop; /* Current stack top. Must be between3071 * stackLowerBound and stackUpperBound3072 * (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 */3113 2473 3114 2474 … … 4271 3631 4272 3632 4273 #ifdef TCL_COMPILE_STATS4274 /*4275 *----------------------------------------------------------------------4276 *4277 * TclLog2 --4278 *4279 * Procedure used while collecting compilation statistics to determine4280 * the log base 2 of an integer.4281 *4282 * Results:4283 * Returns the log base 2 of the operand. If the argument is less4284 * than or equal to zero, a zero is returned.4285 *4286 * Side effects:4287 * None.4288 *4289 *----------------------------------------------------------------------4290 */4291 4292 int4293 TclLog2(value)4294 register int value; /* The integer for which to compute the4295 * 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 execution4314 * counts to stdout.4315 *4316 * Results:4317 * Standard Tcl results.4318 *4319 * Side effects:4320 * None.4321 *4322 *----------------------------------------------------------------------4323 */4324 4325 static int4326 EvalStatsCmd(unused, interp, argc, argv)4327 ClientData unused; /* Unused. */4328 Tcl_Interp *interp; /* The current interpreter. */4329 int argc; /* The number of arguments. */4330 char **argv; /* The argument strings. */4331 {4332 register double total = 0.0;4333 register int i;4334 int maxSizeDecade = 0;4335 double totalHeaderBytes = (tclNumCompilations * sizeof(ByteCode));4336 4337 for (i = 0; i < 256; i++) {4338 if (instructionCount[i] != 0) {4339 total += instructionCount[i];4340 }4341 }4342 4343 for (i = 31; i >= 0; i--) {4344 if ((tclSourceCount[i] > 0) && (tclByteCodeCount[i] > 0)) {4345 maxSizeDecade = i;4346 break;4347 }4348 }4349 4350 fprintf(stdout, "\nNumber of compilations %ld\n",4351 tclNumCompilations);4352 fprintf(stdout, "Number of executions %ld\n",4353 numExecutions);4354 fprintf(stdout, "Average executions/compilation %.0f\n",4355 ((float) numExecutions/tclNumCompilations));4356 4357 fprintf(stdout, "\nInstructions executed %.0f\n",4358 total);4359 fprintf(stdout, "Average instructions/compile %.0f\n",4360 total/tclNumCompilations);4361 fprintf(stdout, "Average instructions/execution %.0f\n",4362 total/numExecutions);4363 4364 fprintf(stdout, "\nTotal source bytes %.6g\n",4365 tclTotalSourceBytes);4366 fprintf(stdout, "Total code bytes %.6g\n",4367 tclTotalCodeBytes);4368 fprintf(stdout, "Average code/compilation %.0f\n",4369 tclTotalCodeBytes/tclNumCompilations);4370 fprintf(stdout, "Average code/source %.2f\n",4371 tclTotalCodeBytes/tclTotalSourceBytes);4372 fprintf(stdout, "Current source bytes %.6g\n",4373 tclCurrentSourceBytes);4374 fprintf(stdout, "Current code bytes %.6g\n",4375 tclCurrentCodeBytes);4376 fprintf(stdout, "Current code/source %.2f\n",4377 tclCurrentCodeBytes/tclCurrentSourceBytes);4378 4379 fprintf(stdout, "\nTotal objects allocated %ld\n",4380 tclObjsAlloced);4381 fprintf(stdout, "Total objects freed %ld\n",4382 tclObjsFreed);4383 fprintf(stdout, "Current objects: %ld\n",4384 (tclObjsAlloced - tclObjsFreed));4385 4386 fprintf(stdout, "\nBreakdown of code byte requirements:\n");4387 fprintf(stdout, " Total bytes Pct of Avg per\n");4388 fprintf(stdout, " all code compile\n");4389 fprintf(stdout, "Total code %12.6g 100%% %8.2f\n",4390 tclTotalCodeBytes, tclTotalCodeBytes/tclNumCompilations);4391 fprintf(stdout, "Header %12.6g %8.2f%% %8.2f\n",4392 totalHeaderBytes,4393 ((totalHeaderBytes * 100.0) / tclTotalCodeBytes),4394 totalHeaderBytes/tclNumCompilations);4395 fprintf(stdout, "Instructions %12.6g %8.2f%% %8.2f\n",4396 tclTotalInstBytes,4397 ((tclTotalInstBytes * 100.0) / tclTotalCodeBytes),4398 tclTotalInstBytes/tclNumCompilations);4399 fprintf(stdout, "Objects %12.6g %8.2f%% %8.2f\n",4400 tclTotalObjBytes,4401 ((tclTotalObjBytes * 100.0) / tclTotalCodeBytes),4402 tclTotalObjBytes/tclNumCompilations);4403 fprintf(stdout, "Exception table %12.6g %8.2f%% %8.2f\n",4404 tclTotalExceptBytes,4405 ((tclTotalExceptBytes * 100.0) / tclTotalCodeBytes),4406 tclTotalExceptBytes/tclNumCompilations);4407 fprintf(stdout, "Auxiliary data %12.6g %8.2f%% %8.2f\n",4408 tclTotalAuxBytes,4409 ((tclTotalAuxBytes * 100.0) / tclTotalCodeBytes),4410 tclTotalAuxBytes/tclNumCompilations);4411 fprintf(stdout, "Command map %12.6g %8.2f%% %8.2f\n",4412 tclTotalCmdMapBytes,4413 ((tclTotalCmdMapBytes * 100.0) / tclTotalCodeBytes),4414 tclTotalCmdMapBytes/tclNumCompilations);4415 4416 fprintf(stdout, "\nSource and ByteCode size distributions:\n");4417 fprintf(stdout, " binary decade source code\n");4418 for (i = 0; i <= maxSizeDecade; i++) {4419 int decadeLow, decadeHigh;4420 4421 if (i == 0) {4422 decadeLow = 0;4423 } else {4424 decadeLow = 1 << i;4425 }4426 decadeHigh = (1 << (i+1)) - 1;4427 fprintf(stdout, " %6d -%6d %6d %6d\n",4428 decadeLow, decadeHigh,4429 tclSourceCount[i], tclByteCodeCount[i]);4430 }4431 4432 fprintf(stdout, "\nInstruction counts:\n");4433 for (i = 0; i < 256; i++) {4434 if (instructionCount[i]) {4435 fprintf(stdout, "%20s %8d %6.2f%%\n",4436 opName[i], instructionCount[i],4437 (instructionCount[i] * 100.0)/total);4438 }4439 }4440 4441 #ifdef TCL_MEM_DEBUG4442 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 4451 3633 /* 4452 3634 *---------------------------------------------------------------------- … … 4758 3940 panic("UpdateStringOfCmdName should never be invoked"); 4759 3941 } 4760 4761 4762 #ifdef TCL_COMPILE_DEBUG4763 /*4764 *----------------------------------------------------------------------4765 *4766 * StringForResultCode --4767 *4768 * Procedure that returns a human-readable string representing a4769 * Tcl result code such as TCL_ERROR.4770 *4771 * Results:4772 * If the result code is one of the standard Tcl return codes, the4773 * result is a string representing that code such as "TCL_ERROR".4774 * Otherwise, the result string is that code formatted as a4775 * sequence of decimal digit characters. Note that the resulting4776 * string must not be modified by the caller.4777 *4778 * Side effects:4779 * None.4780 *4781 *----------------------------------------------------------------------4782 */4783 4784 static char *4785 StringForResultCode(result)4786 int result; /* The Tcl result code for which to4787 * 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
r2d7ff18 r83ee320 1326 1326 1327 1327 extern Tcl_Obj * tclFreeObjList; 1328 1329 #ifdef TCL_COMPILE_STATS1330 extern long tclObjsAlloced;1331 extern long tclObjsFreed;1332 #endif /* TCL_COMPILE_STATS */1333 1328 1334 1329 /* … … 1445 1440 int objc, Tcl_Obj *CONST objv[], int flags)); 1446 1441 EXTERN char * TclpAlloc _ANSI_ARGS_((unsigned int size)); 1447 1442 EXTERN void TclpFree(char *cp); 1448 1443 EXTERN char * TclpRealloc _ANSI_ARGS_((char *ptr, 1449 1444 unsigned int size)); … … 1472 1467 EXTERN int TclPreventAliasLoop _ANSI_ARGS_((Tcl_Interp *interp, 1473 1468 Tcl_Interp *cmdInterp, Tcl_Command cmd)); 1474 EXTERN void TclPrintByteCodeObj _ANSI_ARGS_((Tcl_Interp *interp,1475 Tcl_Obj *objPtr));1476 1469 EXTERN void TclProcCleanupProc _ANSI_ARGS_((Proc *procPtr)); 1477 1470 EXTERN int TclProcCompileProc _ANSI_ARGS_((Tcl_Interp *interp, … … 1688 1681 */ 1689 1682 1690 #ifdef TCL_COMPILE_STATS1691 # define TclIncrObjsAllocated() \1692 tclObjsAlloced++1693 # define TclIncrObjsFreed() \1694 tclObjsFreed++1695 #else1696 # define TclIncrObjsAllocated()1697 # define TclIncrObjsFreed()1698 #endif /* TCL_COMPILE_STATS */1699 1700 #ifdef TCL_MEM_DEBUG1701 # 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 */1732 1683 # define TclNewObj(objPtr) \ 1733 1684 if (tclFreeObjList == NULL) { \ … … 1740 1691 (objPtr)->bytes = tclEmptyStringRep; \ 1741 1692 (objPtr)->length = 0; \ 1742 (objPtr)->typePtr = NULL; \ 1743 TclIncrObjsAllocated() 1693 (objPtr)->typePtr = NULL; 1744 1694 # define TclDecrRefCount(objPtr) \ 1745 1695 if (--(objPtr)->refCount <= 0) { \ … … 1754 1704 (objPtr)->internalRep.otherValuePtr = (VOID *) tclFreeObjList; \ 1755 1705 tclFreeObjList = (objPtr); \ 1756 TclIncrObjsFreed(); \1757 1706 } 1758 #endif /* TCL_MEM_DEBUG */1759 1707 1760 1708 /* -
external/tcl/tclListObj.c
r2d7ff18 r83ee320 46 46 * Tcl_NewListObj -- 47 47 * 48 * This procedure is normally called when not debugging: i.e., when 49 * TCL_MEM_DEBUG is not defined. It creates a new list object from an 50 * (objc,objv) array: that is, each of the objc elements of the array 51 * referenced by objv is inserted as an element into a new Tcl object. 52 * 53 * When TCL_MEM_DEBUG is defined, this procedure just returns the 54 * result of calling the debugging version Tcl_DbNewListObj. 48 * This procedure creates a new list object from an (objc,objv) array: 49 * that is, each of the objc elements of the array referenced by objv 50 * is inserted as an element into a new Tcl object. 55 51 * 56 52 * Results: … … 66 62 *---------------------------------------------------------------------- 67 63 */ 68 69 #ifdef TCL_MEM_DEBUG70 #undef Tcl_NewListObj71 72 Tcl_Obj *73 Tcl_NewListObj(objc, objv)74 int objc; /* Count of objects referenced by objv. */75 Tcl_Obj *CONST objv[]; /* An array of pointers to Tcl objects. */76 {77 return Tcl_DbNewListObj(objc, objv, "unknown", 0);78 }79 80 #else /* if not TCL_MEM_DEBUG */81 64 82 65 Tcl_Obj * … … 112 95 return listPtr; 113 96 } 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., when123 * TCL_MEM_DEBUG is defined. It creates new list objects. It is the124 * same as the Tcl_NewListObj procedure above except that it calls125 * Tcl_DbCkalloc directly with the file name and line number from its126 * caller. This simplifies debugging since then the checkmem command127 * will report the correct file name and line number when reporting128 * objects that haven't been freed.129 *130 * When TCL_MEM_DEBUG is not defined, this procedure just returns the131 * result of calling Tcl_NewListObj.132 *133 * Results:134 * A new list object is returned that is initialized from the object135 * pointers in objv. If objc is less than or equal to zero, an empty136 * object is returned. The new object's string representation137 * 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 the141 * resulting list now refers to them.142 *143 *----------------------------------------------------------------------144 */145 146 #ifdef TCL_MEM_DEBUG147 148 Tcl_Obj *149 Tcl_DbNewListObj(objc, objv, file, line)150 int objc; /* Count of objects referenced by objv. */151 Tcl_Obj *CONST objv[]; /* An array of pointers to Tcl objects. */152 char *file; /* The name of the source file calling this153 * procedure; used for debugging. */154 int line; /* Line number in the source file; used155 * for debugging. */156 {157 register Tcl_Obj *listPtr;158 register Tcl_Obj **elemPtrs;159 register List *listRepPtr;160 int i;161 162 TclDbNewObj(listPtr, file, line);163 164 if (objc > 0) {165 Tcl_InvalidateStringRep(listPtr);166 167 elemPtrs = (Tcl_Obj **)168 ckalloc((unsigned) (objc * sizeof(Tcl_Obj *)));169 for (i = 0; i < objc; i++) {170 elemPtrs[i] = objv[i];171 Tcl_IncrRefCount(elemPtrs[i]);172 }173 174 listRepPtr = (List *) ckalloc(sizeof(List));175 listRepPtr->maxElemCount = objc;176 listRepPtr->elemCount = objc;177 listRepPtr->elements = elemPtrs;178 179 listPtr->internalRep.otherValuePtr = (VOID *) listRepPtr;180 listPtr->typePtr = &tclListType;181 }182 return listPtr;183 }184 185 #else /* if not TCL_MEM_DEBUG */186 187 Tcl_Obj *188 Tcl_DbNewListObj(objc, objv, file, line)189 int objc; /* Count of objects referenced by objv. */190 Tcl_Obj *CONST objv[]; /* An array of pointers to Tcl objects. */191 char *file; /* The name of the source file calling this192 * procedure; used for debugging. */193 int line; /* Line number in the source file; used194 * for debugging. */195 {196 return Tcl_NewListObj(objc, objv);197 }198 #endif /* TCL_MEM_DEBUG */199 97 200 98 -
external/tcl/tclObj.c
r2d7ff18 r83ee320 36 36 37 37 char *tclEmptyStringRep = NULL; 38 39 /*40 * Count of the number of Tcl objects every allocated (by Tcl_NewObj) and41 * freed (by TclFreeObj).42 */43 44 #ifdef TCL_COMPILE_STATS45 long tclObjsAlloced = 0;46 long tclObjsFreed = 0;47 #endif /* TCL_COMPILE_STATS */48 38 49 39 /* … … 417 407 * Tcl_NewObj -- 418 408 * 419 * This procedure is normally called when not debugging: i.e., when 420 * TCL_MEM_DEBUG is not defined. It creates new Tcl objects that denote 421 * the empty string. These objects have a NULL object type and NULL 422 * string representation byte pointer. Type managers call this routine 423 * to allocate new objects that they further initialize. 424 * 425 * When TCL_MEM_DEBUG is defined, this procedure just returns the 426 * result of calling the debugging version Tcl_DbNewObj. 409 * This procedure creates new Tcl objects that denote the empty string. 410 * These objects have a NULL object type and NULL string representation 411 * byte pointer. Type managers call this routine to allocate new objects 412 * that they further initialize. 427 413 * 428 414 * Results: … … 431 417 * is set to 0. 432 418 * 433 * Side effects: 434 * If compiling with TCL_COMPILE_STATS, this procedure increments 435 * the global count of allocated objects (tclObjsAlloced). 436 * 437 *---------------------------------------------------------------------- 438 */ 439 440 #ifdef TCL_MEM_DEBUG 441 #undef Tcl_NewObj 442 443 Tcl_Obj * 444 Tcl_NewObj() 445 { 446 return Tcl_DbNewObj("unknown", 0); 447 } 448 449 #else /* if not TCL_MEM_DEBUG */ 419 *---------------------------------------------------------------------- 420 */ 450 421 451 422 Tcl_Obj * … … 468 439 objPtr->length = 0; 469 440 objPtr->typePtr = NULL; 470 #ifdef TCL_COMPILE_STATS471 tclObjsAlloced++;472 #endif /* TCL_COMPILE_STATS */473 441 return objPtr; 474 442 } 475 #endif /* TCL_MEM_DEBUG */476 477 478 /*479 *----------------------------------------------------------------------480 *481 * Tcl_DbNewObj --482 *483 * This procedure is normally called when debugging: i.e., when484 * TCL_MEM_DEBUG is defined. It creates new Tcl objects that denote the485 * empty string. It is the same as the Tcl_NewObj procedure above486 * except that it calls Tcl_DbCkalloc directly with the file name and487 * line number from its caller. This simplifies debugging since then488 * the checkmem command will report the correct file name and line489 * number when reporting objects that haven't been freed.490 *491 * When TCL_MEM_DEBUG is not defined, this procedure just returns the492 * 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 increments500 * the global count of allocated objects (tclObjsAlloced).501 *502 *----------------------------------------------------------------------503 */504 505 #ifdef TCL_MEM_DEBUG506 507 Tcl_Obj *508 Tcl_DbNewObj(file, line)509 register char *file; /* The name of the source file calling this510 * procedure; used for debugging. */511 register int line; /* Line number in the source file; used512 * 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_STATS527 tclObjsAlloced++;528 #endif /* TCL_COMPILE_STATS */529 return objPtr;530 }531 532 #else /* if not TCL_MEM_DEBUG */533 534 Tcl_Obj *535 Tcl_DbNewObj(file, line)536 char *file; /* The name of the source file calling this537 * procedure; used for debugging. */538 int line; /* Line number in the source file; used539 * for debugging. */540 {541 return Tcl_NewObj();542 }543 #endif /* TCL_MEM_DEBUG */544 443 545 444 … … 609 508 * after deallocating the string representation and calling the 610 509 * type-specific Tcl_FreeInternalRepProc to deallocate the object's 611 * internal representation. If compiling with TCL_COMPILE_STATS, 612 * this procedure increments the global count of freed objects 613 * (tclObjsFreed). 510 * internal representation. 614 511 * 615 512 *---------------------------------------------------------------------- … … 622 519 register Tcl_ObjType *typePtr = objPtr->typePtr; 623 520 624 #ifdef TCL_MEM_DEBUG625 if ((objPtr)->refCount < -1) {626 panic("Reference count for %lx was negative", objPtr);627 }628 #endif /* TCL_MEM_DEBUG */629 630 521 Tcl_InvalidateStringRep(objPtr); 631 522 if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) { … … 634 525 635 526 /* 636 * If debugging Tcl's memory usage, deallocate the object using ckfree. 637 * Otherwise, deallocate it by adding it onto the list of free 527 * Deallocate the object by adding it onto the list of free 638 528 * Tcl_Objs we maintain. 639 529 */ 640 530 641 #ifdef TCL_MEM_DEBUG642 ckfree((char *) objPtr);643 #else644 531 objPtr->internalRep.otherValuePtr = (VOID *) tclFreeObjList; 645 532 tclFreeObjList = objPtr; 646 #endif /* TCL_MEM_DEBUG */647 648 #ifdef TCL_COMPILE_STATS649 tclObjsFreed++;650 #endif /* TCL_COMPILE_STATS */651 533 } 652 534 … … 794 676 * Tcl_NewBooleanObj -- 795 677 * 796 * This procedure is normally called when not debugging: i.e., when 797 * TCL_MEM_DEBUG is not defined. It creates a new boolean object and 798 * initializes it from the argument boolean value. A nonzero 799 * "boolValue" is coerced to 1. 800 * 801 * When TCL_MEM_DEBUG is defined, this procedure just returns the 802 * result of calling the debugging version Tcl_DbNewBooleanObj. 678 * This procedure creates a new boolean object and initializes it from 679 * the argument boolean value. A nonzero "boolValue" is coerced to 1. 803 680 * 804 681 * Results: … … 811 688 *---------------------------------------------------------------------- 812 689 */ 813 814 #ifdef TCL_MEM_DEBUG815 #undef Tcl_NewBooleanObj816 690 817 691 Tcl_Obj * … … 819 693 register int boolValue; /* Boolean used to initialize new object. */ 820 694 { 821 return Tcl_DbNewBooleanObj(boolValue, "unknown", 0);822 }823 824 #else /* if not TCL_MEM_DEBUG */825 826 Tcl_Obj *827 Tcl_NewBooleanObj(boolValue)828 register int boolValue; /* Boolean used to initialize new object. */829 {830 695 register Tcl_Obj *objPtr; 831 696 … … 837 702 return objPtr; 838 703 } 839 #endif /* TCL_MEM_DEBUG */840 841 842 /*843 *----------------------------------------------------------------------844 *845 * Tcl_DbNewBooleanObj --846 *847 * This procedure is normally called when debugging: i.e., when848 * TCL_MEM_DEBUG is defined. It creates new boolean objects. It is the849 * same as the Tcl_NewBooleanObj procedure above except that it calls850 * Tcl_DbCkalloc directly with the file name and line number from its851 * caller. This simplifies debugging since then the checkmem command852 * will report the correct file name and line number when reporting853 * objects that haven't been freed.854 *855 * When TCL_MEM_DEBUG is not defined, this procedure just returns the856 * result of calling Tcl_NewBooleanObj.857 *858 * Results:859 * The newly created object is returned. This object will have an860 * invalid string representation. The returned object has ref count 0.861 *862 * Side effects:863 * None.864 *865 *----------------------------------------------------------------------866 */867 868 #ifdef TCL_MEM_DEBUG869 870 Tcl_Obj *871 Tcl_DbNewBooleanObj(boolValue, file, line)872 register int boolValue; /* Boolean used to initialize new object. */873 char *file; /* The name of the source file calling this874 * procedure; used for debugging. */875 int line; /* Line number in the source file; used876 * for debugging. */877 {878 register Tcl_Obj *objPtr;879 880 TclDbNewObj(objPtr, file, line);881 objPtr->bytes = NULL;882 883 objPtr->internalRep.longValue = (boolValue? 1 : 0);884 objPtr->typePtr = &tclBooleanType;885 return objPtr;886 }887 888 #else /* if not TCL_MEM_DEBUG */889 890 Tcl_Obj *891 Tcl_DbNewBooleanObj(boolValue, file, line)892 register int boolValue; /* Boolean used to initialize new object. */893 char *file; /* The name of the source file calling this894 * procedure; used for debugging. */895 int line; /* Line number in the source file; used896 * for debugging. */897 {898 return Tcl_NewBooleanObj(boolValue);899 }900 #endif /* TCL_MEM_DEBUG */901 704 902 705 … … 1178 981 * Tcl_NewDoubleObj -- 1179 982 * 1180 * This procedure is normally called when not debugging: i.e., when 1181 * TCL_MEM_DEBUG is not defined. It creates a new double object and 1182 * initializes it from the argument double value. 1183 * 1184 * When TCL_MEM_DEBUG is defined, this procedure just returns the 1185 * result of calling the debugging version Tcl_DbNewDoubleObj. 983 * This procedure creates a new double object and initializes it from 984 * the argument double value. 1186 985 * 1187 986 * Results: … … 1194 993 *---------------------------------------------------------------------- 1195 994 */ 1196 1197 #ifdef TCL_MEM_DEBUG1198 #undef Tcl_NewDoubleObj1199 995 1200 996 Tcl_Obj * … … 1202 998 register double dblValue; /* Double used to initialize the object. */ 1203 999 { 1204 return Tcl_DbNewDoubleObj(dblValue, "unknown", 0);1205 }1206 1207 #else /* if not TCL_MEM_DEBUG */1208 1209 Tcl_Obj *1210 Tcl_NewDoubleObj(dblValue)1211 register double dblValue; /* Double used to initialize the object. */1212 {1213 1000 register Tcl_Obj *objPtr; 1214 1001 … … 1220 1007 return objPtr; 1221 1008 } 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., when1231 * TCL_MEM_DEBUG is defined. It creates new double objects. It is the1232 * same as the Tcl_NewDoubleObj procedure above except that it calls1233 * Tcl_DbCkalloc directly with the file name and line number from its1234 * caller. This simplifies debugging since then the checkmem command1235 * will report the correct file name and line number when reporting1236 * objects that haven't been freed.1237 *1238 * When TCL_MEM_DEBUG is not defined, this procedure just returns the1239 * result of calling Tcl_NewDoubleObj.1240 *1241 * Results:1242 * The newly created object is returned. This object will have an1243 * invalid string representation. The returned object has ref count 0.1244 *1245 * Side effects:1246 * None.1247 *1248 *----------------------------------------------------------------------1249 */1250 1251 #ifdef TCL_MEM_DEBUG1252 1253 Tcl_Obj *1254 Tcl_DbNewDoubleObj(dblValue, file, line)1255 register double dblValue; /* Double used to initialize the object. */1256 char *file; /* The name of the source file calling this1257 * procedure; used for debugging. */1258 int line; /* Line number in the source file; used1259 * for debugging. */1260 {1261 register Tcl_Obj *objPtr;1262 1263 TclDbNewObj(objPtr, file, line);1264 objPtr->bytes = NULL;1265 1266 objPtr->internalRep.doubleValue = dblValue;1267 objPtr->typePtr = &tclDoubleType;1268 return objPtr;1269 }1270 1271 #else /* if not TCL_MEM_DEBUG */1272 1273 Tcl_Obj *1274 Tcl_DbNewDoubleObj(dblValue, file, line)1275 register double dblValue; /* Double used to initialize the object. */1276 char *file; /* The name of the source file calling this1277 * procedure; used for debugging. */1278 int line; /* Line number in the source file; used1279 * for debugging. */1280 {1281 return Tcl_NewDoubleObj(dblValue);1282 }1283 #endif /* TCL_MEM_DEBUG */1284 1009 1285 1010 … … 1531 1256 * Tcl_NewIntObj -- 1532 1257 * 1533 * If a client is compiled with TCL_MEM_DEBUG defined, calls to 1534 * Tcl_NewIntObj to create a new integer object end up calling the 1535 * debugging procedure Tcl_DbNewLongObj instead. 1536 * 1537 * Otherwise, if the client is compiled without TCL_MEM_DEBUG defined, 1538 * calls to Tcl_NewIntObj result in a call to one of the two 1258 * Calls to Tcl_NewIntObj result in a call to one of the two 1539 1259 * Tcl_NewIntObj implementations below. We provide two implementations 1540 1260 * so that the Tcl core can be compiled to do memory debugging of the … … 1556 1276 */ 1557 1277 1558 #ifdef TCL_MEM_DEBUG1559 #undef Tcl_NewIntObj1560 1561 1278 Tcl_Obj * 1562 1279 Tcl_NewIntObj(intValue) 1563 1280 register int intValue; /* Int used to initialize the new object. */ 1564 1281 { 1565 return Tcl_DbNewLongObj((long)intValue, "unknown", 0);1566 }1567 1568 #else /* if not TCL_MEM_DEBUG */1569 1570 Tcl_Obj *1571 Tcl_NewIntObj(intValue)1572 register int intValue; /* Int used to initialize the new object. */1573 {1574 1282 register Tcl_Obj *objPtr; 1575 1283 … … 1581 1289 return objPtr; 1582 1290 } 1583 #endif /* if TCL_MEM_DEBUG */1584 1291 1585 1292 … … 1856 1563 * Tcl_NewLongObj -- 1857 1564 * 1858 * If a client is compiled with TCL_MEM_DEBUG defined, calls to 1859 * Tcl_NewLongObj to create a new long integer object end up calling 1860 * the debugging procedure Tcl_DbNewLongObj instead. 1861 * 1862 * Otherwise, if the client is compiled without TCL_MEM_DEBUG defined, 1863 * calls to Tcl_NewLongObj result in a call to one of the two 1565 * Calls to Tcl_NewLongObj result in a call to one of the two 1864 1566 * Tcl_NewLongObj implementations below. We provide two implementations 1865 1567 * so that the Tcl core can be compiled to do memory debugging of the … … 1881 1583 */ 1882 1584 1883 #ifdef TCL_MEM_DEBUG1884 #undef Tcl_NewLongObj1885 1886 1585 Tcl_Obj * 1887 1586 Tcl_NewLongObj(longValue) … … 1889 1588 * new object. */ 1890 1589 { 1891 return Tcl_DbNewLongObj(longValue, "unknown", 0);1892 }1893 1894 #else /* if not TCL_MEM_DEBUG */1895 1896 Tcl_Obj *1897 Tcl_NewLongObj(longValue)1898 register long longValue; /* Long integer used to initialize the1899 * new object. */1900 {1901 1590 register Tcl_Obj *objPtr; 1902 1591 … … 1908 1597 return objPtr; 1909 1598 } 1910 #endif /* if TCL_MEM_DEBUG */1911 1599 1912 1600 … … 1916 1604 * Tcl_DbNewLongObj -- 1917 1605 * 1918 * If a client is compiled with TCL_MEM_DEBUG defined, calls to 1919 * Tcl_NewIntObj and Tcl_NewLongObj to create new integer or 1920 * long integer objects end up calling the debugging procedure 1921 * Tcl_DbNewLongObj instead. We provide two implementations of 1922 * Tcl_DbNewLongObj so that whether the Tcl core is compiled to do 1923 * memory debugging of the core is independent of whether a client 1924 * requests debugging for itself. 1925 * 1926 * When the core is compiled with TCL_MEM_DEBUG defined, 1927 * Tcl_DbNewLongObj calls Tcl_DbCkalloc directly with the file name and 1928 * line number from its caller. This simplifies debugging since then 1929 * the checkmem command will report the caller's file name and line 1930 * number when reporting objects that haven't been freed. 1931 * 1932 * Otherwise, when the core is compiled without TCL_MEM_DEBUG defined, 1933 * this procedure just returns the result of calling Tcl_NewLongObj. 1606 * This procedure just returns the result of calling Tcl_NewLongObj. 1934 1607 * 1935 1608 * Results: … … 1943 1616 *---------------------------------------------------------------------- 1944 1617 */ 1945 1946 #ifdef TCL_MEM_DEBUG1947 1618 1948 1619 Tcl_Obj * … … 1955 1626 * for debugging. */ 1956 1627 { 1957 register Tcl_Obj *objPtr;1958 1959 TclDbNewObj(objPtr, file, line);1960 objPtr->bytes = NULL;1961 1962 objPtr->internalRep.longValue = longValue;1963 objPtr->typePtr = &tclIntType;1964 return objPtr;1965 }1966 1967 #else /* if not TCL_MEM_DEBUG */1968 1969 Tcl_Obj *1970 Tcl_DbNewLongObj(longValue, file, line)1971 register long longValue; /* Long integer used to initialize the1972 * new object. */1973 char *file; /* The name of the source file calling this1974 * procedure; used for debugging. */1975 int line; /* Line number in the source file; used1976 * for debugging. */1977 {1978 1628 return Tcl_NewLongObj(longValue); 1979 1629 } 1980 #endif /* TCL_MEM_DEBUG */1981 1630 1982 1631 … … 2060 1709 return result; 2061 1710 } 2062 2063 2064 /*2065 *----------------------------------------------------------------------2066 *2067 * Tcl_DbIncrRefCount --2068 *2069 * This procedure is normally called when debugging: i.e., when2070 * TCL_MEM_DEBUG is defined. This checks to see whether or not2071 * the memory has been freed before incrementing the ref count.2072 *2073 * When TCL_MEM_DEBUG is not defined, this procedure just increments2074 * the reference count of the object.2075 *2076 * Results:2077 * None.2078 *2079 * Side effects:2080 * The object's ref count is incremented.2081 *2082 *----------------------------------------------------------------------2083 */2084 2085 void2086 Tcl_DbIncrRefCount(objPtr, file, line)2087 register Tcl_Obj *objPtr; /* The object we are adding a reference to. */2088 char *file; /* The name of the source file calling this2089 * procedure; used for debugging. */2090 int line; /* Line number in the source file; used2091 * for debugging. */2092 {2093 #ifdef TCL_MEM_DEBUG2094 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 #endif2100 ++(objPtr)->refCount;2101 }2102 2103 2104 /*2105 *----------------------------------------------------------------------2106 *2107 * Tcl_DbDecrRefCount --2108 *2109 * This procedure is normally called when debugging: i.e., when2110 * TCL_MEM_DEBUG is defined. This checks to see whether or not2111 * the memory has been freed before incrementing the ref count.2112 *2113 * When TCL_MEM_DEBUG is not defined, this procedure just increments2114 * the reference count of the object.2115 *2116 * Results:2117 * None.2118 *2119 * Side effects:2120 * The object's ref count is incremented.2121 *2122 *----------------------------------------------------------------------2123 */2124 2125 void2126 Tcl_DbDecrRefCount(objPtr, file, line)2127 register Tcl_Obj *objPtr; /* The object we are adding a reference to. */2128 char *file; /* The name of the source file calling this2129 * procedure; used for debugging. */2130 int line; /* Line number in the source file; used2131 * for debugging. */2132 {2133 #ifdef TCL_MEM_DEBUG2134 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 #endif2140 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., when2152 * TCL_MEM_DEBUG is defined. This checks to see whether or not2153 * the memory has been freed before incrementing the ref count.2154 *2155 * When TCL_MEM_DEBUG is not defined, this procedure just decrements2156 * the reference count of the object and throws it away if the count2157 * is 0 or less.2158 *2159 * Results:2160 * None.2161 *2162 * Side effects:2163 * The object's ref count is incremented.2164 *2165 *----------------------------------------------------------------------2166 */2167 2168 int2169 Tcl_DbIsShared(objPtr, file, line)2170 register Tcl_Obj *objPtr; /* The object we are adding a reference to. */2171 char *file; /* The name of the source file calling this2172 * procedure; used for debugging. */2173 int line; /* Line number in the source file; used2174 * for debugging. */2175 {2176 #ifdef TCL_MEM_DEBUG2177 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 #endif2183 return ((objPtr)->refCount > 1);2184 } -
external/tcl/tclProc.c
r2d7ff18 r83ee320 985 985 */ 986 986 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 998 987 iPtr->returnCode = TCL_OK; 999 988 procPtr->refCount++; … … 1119 1108 int numChars; 1120 1109 char *ellipsis; 1121 1122 if (tclTraceCompile >= 1) {1123 /*1124 * Display a line summarizing the top level command we1125 * 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 }1137 1110 1138 1111 /* -
external/tcl/tclStringObj.c
r2d7ff18 r83ee320 50 50 * Tcl_NewStringObj -- 51 51 * 52 * This procedure is normally called when not debugging: i.e., when 53 * TCL_MEM_DEBUG is not defined. It creates a new string object and 54 * initializes it from the byte pointer and length arguments. 55 * 56 * When TCL_MEM_DEBUG is defined, this procedure just returns the 57 * result of calling the debugging version Tcl_DbNewStringObj. 52 * This procedure creates a new string object and initializes it from 53 * the byte pointer and length arguments. 58 54 * 59 55 * Results: … … 70 66 *---------------------------------------------------------------------- 71 67 */ 72 73 #ifdef TCL_MEM_DEBUG74 #undef Tcl_NewStringObj75 68 76 69 Tcl_Obj * … … 83 76 * NULL byte. */ 84 77 { 85 return Tcl_DbNewStringObj(bytes, length, "unknown", 0);86 }87 88 #else /* if not TCL_MEM_DEBUG */89 90 Tcl_Obj *91 Tcl_NewStringObj(bytes, length)92 register char *bytes; /* Points to the first of the length bytes93 * used to initialize the new object. */94 register int length; /* The number of bytes to copy from "bytes"95 * when initializing the new object. If96 * negative, use bytes up to the first97 * NULL byte. */98 {99 78 register Tcl_Obj *objPtr; 100 79 … … 106 85 return objPtr; 107 86 } 108 #endif /* TCL_MEM_DEBUG */109 110 111 /*112 *----------------------------------------------------------------------113 *114 * Tcl_DbNewStringObj --115 *116 * This procedure is normally called when debugging: i.e., when117 * TCL_MEM_DEBUG is defined. It creates new string objects. It is the118 * same as the Tcl_NewStringObj procedure above except that it calls119 * Tcl_DbCkalloc directly with the file name and line number from its120 * caller. This simplifies debugging since then the checkmem command121 * will report the correct file name and line number when reporting122 * objects that haven't been freed.123 *124 * When TCL_MEM_DEBUG is not defined, this procedure just returns the125 * 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 a132 * copy of the length bytes starting at "bytes". If "length" is133 * 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 set135 * to NULL. An extra NULL is added to the end of the new object's byte136 * array.137 *138 *----------------------------------------------------------------------139 */140 141 #ifdef TCL_MEM_DEBUG142 143 Tcl_Obj *144 Tcl_DbNewStringObj(bytes, length, file, line)145 register char *bytes; /* Points to the first of the length bytes146 * used to initialize the new object. */147 register int length; /* The number of bytes to copy from "bytes"148 * when initializing the new object. If149 * negative, use bytes up to the first150 * NULL byte. */151 char *file; /* The name of the source file calling this152 * procedure; used for debugging. */153 int line; /* Line number in the source file; used154 * for debugging. */155 {156 register Tcl_Obj *objPtr;157 158 if (length < 0) {159 length = (bytes? strlen(bytes) : 0);160 }161 TclDbNewObj(objPtr, file, line);162 TclInitStringRep(objPtr, bytes, length);163 return objPtr;164 }165 166 #else /* if not TCL_MEM_DEBUG */167 168 Tcl_Obj *169 Tcl_DbNewStringObj(bytes, length, file, line)170 register char *bytes; /* Points to the first of the length bytes171 * used to initialize the new object. */172 register int length; /* The number of bytes to copy from "bytes"173 * when initializing the new object. If174 * negative, use bytes up to the first175 * NULL byte. */176 char *file; /* The name of the source file calling this177 * procedure; used for debugging. */178 int line; /* Line number in the source file; used179 * for debugging. */180 {181 return Tcl_NewStringObj(bytes, length);182 }183 #endif /* TCL_MEM_DEBUG */184 87 185 88 -
external/tcl/tclVar.c
r2d7ff18 r83ee320 711 711 char *msg; 712 712 713 #ifdef TCL_COMPILE_DEBUG714 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 731 713 varPtr = &(compiledLocals[localIndex]); 732 714 varName = varPtr->name; … … 832 814 int new; 833 815 834 #ifdef TCL_COMPILE_DEBUG835 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 852 816 /* 853 817 * THIS FAILS IF THE ELEMENT NAME OBJECT'S STRING REP HAS A NULL BYTE. … … 1449 1413 Tcl_Obj *resultPtr = NULL; 1450 1414 1451 #ifdef TCL_COMPILE_DEBUG1452 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 1469 1415 varPtr = &(compiledLocals[localIndex]); 1470 1416 varName = varPtr->name; … … 1635 1581 int new; 1636 1582 1637 #ifdef TCL_COMPILE_DEBUG1638 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 1655 1583 /* 1656 1584 * THIS FAILS IF THE ELEMENT NAME OBJECT'S STRING REP HAS A NULL BYTE. -
modules/FastJetFinder.cc
r2d7ff18 r83ee320 316 316 Double_t deta, dphi, detaMax, dphiMax; 317 317 Double_t time, timeWeight; 318 Double_t neutralEnergyFraction, chargedEnergyFraction; 319 318 320 Int_t number, ncharged, nneutrals; 319 321 Int_t charge; … … 418 420 nneutrals = 0; 419 421 422 neutralEnergyFraction =0.; 423 chargedEnergyFraction =0.; 424 420 425 inputList.clear(); 421 426 inputList = sequence->constituents(*itOutputList); … … 432 437 433 438 if(constituent->Charge == 0) 439 { 434 440 nneutrals++; 441 neutralEnergyFraction += constituent->Momentum.E(); 442 } 435 443 else 444 { 436 445 ncharged++; 437 446 chargedEnergyFraction += constituent->Momentum.E(); 447 } 448 438 449 time += TMath::Sqrt(constituent->Momentum.E()) * (constituent->Position.T()); 439 450 timeWeight += TMath::Sqrt(constituent->Momentum.E()); … … 454 465 candidate->NNeutrals = nneutrals; 455 466 candidate->NCharged = ncharged; 467 468 candidate->NeutralEnergyFraction = (momentum.E() > 0 ) ? neutralEnergyFraction/momentum.E() : 0.0; 469 candidate->ChargedEnergyFraction = (momentum.E() > 0 ) ? chargedEnergyFraction/momentum.E() : 0.0; 456 470 457 471 //for exclusive clustering, access y_n,n+1 as exclusive_ymerge (fNJets); -
modules/ModulesLinkDef.h
r2d7ff18 r83ee320 41 41 #include "modules/DenseTrackFilter.h" 42 42 #include "modules/Calorimeter.h" 43 #include "modules/DualReadoutCalorimeter.h" 43 44 #include "modules/OldCalorimeter.h" 44 45 #include "modules/Isolation.h" … … 55 56 #include "modules/JetPileUpSubtractor.h" 56 57 #include "modules/TrackPileUpSubtractor.h" 58 #include "modules/TrackTimingPileUpSubtractor.h" 57 59 #include "modules/TaggingParticlesSkimmer.h" 58 60 #include "modules/PileUpJetID.h" … … 71 73 #include "modules/VertexFinder.h" 72 74 #include "modules/VertexFinderDA4D.h" 75 #include "modules/HighMassVertexRecover.h" 76 #include "modules/DecayFilter.h" 73 77 #include "modules/ExampleModule.h" 74 78 … … 94 98 #pragma link C++ class DenseTrackFilter+; 95 99 #pragma link C++ class Calorimeter+; 100 #pragma link C++ class DualReadoutCalorimeter+; 96 101 #pragma link C++ class OldCalorimeter+; 97 102 #pragma link C++ class Isolation+; … … 108 113 #pragma link C++ class JetPileUpSubtractor+; 109 114 #pragma link C++ class TrackPileUpSubtractor+; 115 #pragma link C++ class TrackTimingPileUpSubtractor+; 110 116 #pragma link C++ class TaggingParticlesSkimmer+; 111 117 #pragma link C++ class PileUpJetID+; … … 124 130 #pragma link C++ class VertexFinder+; 125 131 #pragma link C++ class VertexFinderDA4D+; 132 #pragma link C++ class HighMassVertexRecover+; 133 #pragma link C++ class DecayFilter+; 126 134 #pragma link C++ class ExampleModule+; 127 135 -
modules/MomentumSmearing.cc
r2d7ff18 r83ee320 95 95 { 96 96 Candidate *candidate, *mother; 97 Double_t pt, eta, phi, e, res;97 Double_t pt, eta, phi, e, m, res; 98 98 99 99 fItInputArray->Reset(); … … 106 106 pt = candidateMomentum.Pt(); 107 107 e = candidateMomentum.E(); 108 m = candidateMomentum.M(); 109 108 110 res = fFormula->Eval(pt, eta, phi, e); 109 110 // apply smearing formula111 //pt = gRandom->Gaus(pt, fFormula->Eval(pt, eta, phi, e) * pt);112 113 111 res = (res > 1.0) ? 1.0 : res; 114 112 115 113 pt = LogNormal(pt, res * pt); 116 117 //if(pt <= 0.0) continue;118 114 119 115 mother = candidate; … … 121 117 eta = candidateMomentum.Eta(); 122 118 phi = candidateMomentum.Phi(); 123 candidate->Momentum.SetPtEtaPhiE(pt, eta, phi, pt * TMath::CosH(eta)); 124 //candidate->TrackResolution = fFormula->Eval(pt, eta, phi, e); 119 candidate->Momentum.SetPtEtaPhiM(pt, eta, phi, m); 120 candidate->ErrorPT = res*pt; 121 candidate->PT = pt; 122 125 123 candidate->TrackResolution = res; 126 124 candidate->AddCandidate(mother); -
modules/TaggingParticlesSkimmer.cc
r2d7ff18 r83ee320 57 57 58 58 TaggingParticlesSkimmer::TaggingParticlesSkimmer() : 59 fItPartonInputArray(0), fFilter(0), fClassifier(0) 59 fClassifier(0), fFilter(0), fItPartonInputArray(0), 60 fPartonInputArray(0), fParticleInputArray(0), fOutputArray(0) 60 61 { 61 62 } -
modules/TimeSmearing.cc
r2d7ff18 r83ee320 53 53 54 54 TimeSmearing::TimeSmearing() : 55 f ItInputArray(0)55 fFormula(0), fItInputArray(0) 56 56 { 57 fFormula = new DelphesFormula; 57 58 } 58 59 … … 61 62 TimeSmearing::~TimeSmearing() 62 63 { 64 if(fFormula) delete fFormula; 63 65 } 64 66 … … 69 71 // read resolution formula 70 72 71 fTimeResolution = GetDouble("TimeResolution", 1.0E-10); 73 fFormula->Compile(GetString("TimeResolution", "1.0")); 74 72 75 // import input array 73 76 fEtaMax = GetDouble("EtaMax", 6.); 74 77 fInputArray = ImportArray(GetString("InputArray", "MuonMomentumSmearing/muons")); 75 78 fItInputArray = fInputArray->MakeIterator(); … … 92 95 { 93 96 Candidate *candidate, *mother; 94 Double_t ti, tf_smeared, tf; 97 Double_t ti, tf_smeared, tf, timeResolution; 98 Double_t pt, eta, phi, e, d0, dz, ctgTheta; 99 100 95 101 const Double_t c_light = 2.99792458E8; 96 102 97 103 fItInputArray->Reset(); 98 while((candidate = static_cast<Candidate 104 while((candidate = static_cast<Candidate*>(fItInputArray->Next()))) 99 105 { 100 const TLorentzVector &candidateInitialPosition = candidate->InitialPosition; 101 const TLorentzVector &candidateFinalPosition = candidate->Position; 102 103 ti = candidateInitialPosition.T() * 1.0E-3 / c_light; 104 tf = candidateFinalPosition.T() * 1.0E-3 / c_light; 106 ti = candidate->InitialPosition.T()*1.0E-3/c_light; 107 tf = candidate->Position.T()*1.0E-3/c_light; 108 109 // dummy, only need to properly call TFormula 110 const TLorentzVector &candidatePosition = candidate->Position; 111 const TLorentzVector &candidateMomentum = candidate->Momentum; 112 eta = candidatePosition.Eta(); 113 phi = candidatePosition.Phi(); 114 pt = candidateMomentum.Pt(); 115 e = candidateMomentum.E(); 116 d0 = candidate->D0; 117 dz = candidate->DZ; 118 ctgTheta = candidate->CtgTheta; 105 119 106 120 // apply smearing formula 107 tf_smeared = gRandom->Gaus(tf, fTimeResolution); 108 ti = ti + tf_smeared - tf; 109 tf = tf_smeared; 121 122 timeResolution = fFormula->Eval(pt, eta, phi, e, d0, dz, ctgTheta); 123 if(fabs(candidate->Position.Eta())<fEtaMax) 124 { 125 tf_smeared = tf + timeResolution*gRandom->Gaus(0, 1); 126 } 127 else continue; 128 129 // double beta_particle = candidate->Momentum.P()/candidate->Momentum.E(); 130 // ti = tf_smeared - candidate->Ld*1.0E-3/(c_light*beta_particle); 110 131 111 132 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 133 candidate = static_cast<Candidate*>(candidate->Clone()); 118 134 candidate->AddCandidate(mother); 135 candidate->InitialPosition.SetT((100+ti)*1.0E3*c_light); 136 candidate->Position.SetT(tf_smeared*1.0E3*c_light); 137 candidate->ErrorT = timeResolution*1.0E3*c_light; 119 138 120 139 fOutputArray->Add(candidate); -
modules/TimeSmearing.h
r2d7ff18 r83ee320 32 32 class TIterator; 33 33 class TObjArray; 34 class DelphesFormula; 34 35 35 36 class TimeSmearing: public DelphesModule … … 44 45 45 46 private: 46 Double_t fTimeResolution; 47 DelphesFormula *fFormula; //! 48 Double_t fEtaMax; 47 49 48 50 TIterator *fItInputArray; //! -
modules/TrackPileUpSubtractor.cc
r2d7ff18 r83ee320 117 117 void TrackPileUpSubtractor::Process() 118 118 { 119 Candidate *candidate, *particle ;119 Candidate *candidate, *particle, *particleTest; 120 120 map<TIterator *, TObjArray *>::iterator itInputMap; 121 121 TIterator *iterator; … … 123 123 Double_t z, zvtx = 0; 124 124 Double_t pt, eta, phi, e; 125 125 Double_t sumPT2 = 0; 126 Double_t sumSquare = 0; 127 int counter = 0; 128 Double_t tempPTSquare = 0; 129 Double_t tempZVertex = 0; 126 130 // find z position of primary vertex 127 131 132 cout << " ---------- NEW EVENT --------- " << endl; 133 128 134 fItVertexInputArray->Reset(); 135 cout << " NUMBER OF VERTICES : " << fVertexInputArray->GetEntriesFast() << endl; 129 136 while((candidate = static_cast<Candidate *>(fItVertexInputArray->Next()))) 130 137 { 131 if(!candidate->IsPU) 132 { 133 zvtx = candidate->Position.Z(); 134 // break; 135 } 138 cout << " ---------- NEW VERTEX --------- " << candidate->IsPU << endl; 139 tempZVertex = candidate->Position.Z(); 140 tempPTSquare = candidate->SumPT2; 141 if(tempPTSquare > sumSquare) 142 { 143 sumSquare = tempPTSquare; 144 zvtx = tempZVertex; 145 cout << " Sum Square : " << sumSquare << " Z of Vertex : " << zvtx << " Is PileUp : " << candidate->IsPU << endl; 146 } 147 148 /* 149 for(int i = 0; i < candidate->GetCandidates()->GetEntriesFast(); i++) 150 { 151 particleTest = static_cast<Candidate *>(candidate->GetCandidates()->At(i)); 152 TLorentzVector &candidateMomentumNew = particleTest->Momentum; 153 if(candidateMomentumNew.Pt() > 1.0) 154 sumSquare += (candidateMomentumNew.Pt()*candidateMomentumNew.Pt()); 155 cout << candidateMomentumNew.Pt() << " " << candidate->SumPT2 << " counter : " << candidate->GetCandidates()->GetEntriesFast() << endl; 156 } 157 */ 136 158 } 137 159 … … 147 169 { 148 170 particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0)); 149 const TLorentzVector &candidateMomentum = particle->Momentum;171 const TLorentzVector &candidateMomentum = candidate->Momentum; 150 172 151 173 eta = candidateMomentum.Eta(); … … 154 176 e = candidateMomentum.E(); 155 177 156 z = particle->Position.Z(); 178 z = candidate->Position.Z(); 179 counter ++; 180 //sum = pt*pt; 181 if(pt > 1.0) 182 sumPT2 += pt*pt; 157 183 158 184 // apply pile-up subtraction 159 185 // assume perfect pile-up subtraction for tracks outside fZVertexResolution 160 161 if(candidate->Charge != 0 && candidate->IsPU && TMath::Abs(z - zvtx) > fFormula->Eval(pt, eta, phi, e) * 1.0e3) 186 // cout << particle->IsRecoPU << " ParticleSumSquare : " << sumPT2 << " VertexResult : " << sumSquare << " Added SumSquare : " << zvtx << endl; 187 //cout << pt << " " << candidate->IsPU << " " << TMath::Abs(z - zvtx) << " " << sumPT2 << " " << sumPT2 << endl; 188 189 190 if(particle->Charge != 0 && TMath::Abs(z - zvtx) > fFormula->Eval(pt, eta, phi, e) * 1.0e3) 162 191 { 163 192 candidate->IsRecoPU = 1; 193 //cout << TMath::Abs(z - zvtx) << " " << fFormula->Eval(pt, eta, phi, e) * 1.0e3 << endl; 164 194 } 165 195 else -
modules/TrackSmearing.cc
r2d7ff18 r83ee320 158 158 TLorentzVector beamSpotPosition; 159 159 Candidate *candidate, *mother; 160 Double_t pt, eta, d0, d0Error, trueD0, dz, dzError, trueDZ, p, pError, trueP, ctgTheta, ctgThetaError, trueCtgTheta, phi, phiError, truePhi ;160 Double_t pt, eta, d0, d0Error, trueD0, dz, dzError, trueDZ, p, pError, trueP, ctgTheta, ctgThetaError, trueCtgTheta, phi, phiError, truePhi, m; 161 161 Double_t x, y, z, t, px, py, pz, theta; 162 162 Double_t q, r; … … 328 328 329 329 theta = TMath::ACos(ctgTheta / TMath::Sqrt(1.0 + ctgTheta * ctgTheta)); 330 m = candidate->Momentum.M(); 331 330 332 candidate->Momentum.SetPx(p * TMath::Cos(phi) * TMath::Sin(theta)); 331 333 candidate->Momentum.SetPy(p * TMath::Sin(phi) * TMath::Sin(theta)); 332 334 candidate->Momentum.SetPz(p * TMath::Cos(theta)); 333 candidate->Momentum.SetE(candidate->Momentum.Pt() * TMath::CosH(eta)); 335 //candidate->Momentum.SetE(candidate->Momentum.Pt() * TMath::CosH(eta)); 336 candidate->Momentum.SetE( TMath::Sqrt(m*m + p*p) ); 334 337 candidate->PT = candidate->Momentum.Pt(); 335 338 … … 382 385 candidate->Yd = yd * 1.0E3; 383 386 candidate->Zd = zd * 1.0E3; 384 387 candidate->Td = -9999*c_light*1E-3; 388 385 389 if(fApplyToPileUp || !candidate->IsPU) 386 390 { -
modules/TreeWriter.cc
r2d7ff18 r83ee320 72 72 fClassMap[Track::Class()] = &TreeWriter::ProcessTracks; 73 73 fClassMap[Tower::Class()] = &TreeWriter::ProcessTowers; 74 fClassMap[ParticleFlowCandidate::Class()] = &TreeWriter::ProcessParticleFlowCandidates; 74 75 fClassMap[Photon::Class()] = &TreeWriter::ProcessPhotons; 75 76 fClassMap[Electron::Class()] = &TreeWriter::ProcessElectrons; … … 137 138 it1.Reset(); 138 139 array->Clear(); 140 139 141 while((candidate = static_cast<Candidate *>(it1.Next()))) 140 142 { … … 358 360 entry->Yd = candidate->Yd; 359 361 entry->Zd = candidate->Zd; 362 entry->Td = candidate->Td*1.0E-3/c_light; 363 364 if(candidate->ClusterIndex != -1) 365 { 366 entry->TOFreco = 1E-3*(candidate->Position.T() - candidate->InitialPosition.T())/c_light; 367 } 368 else 369 { 370 entry->TOFreco =-1E6; 371 } 360 372 361 373 const TLorentzVector &momentum = candidate->Momentum; … … 378 390 379 391 particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0)); 392 entry->TOFgen = 1E-3*particle->L/(c_light*particle->Momentum.P()/particle->Momentum.E()); 393 380 394 const TLorentzVector &initialPosition = particle->Position; 381 395 … … 439 453 //------------------------------------------------------------------------------ 440 454 455 void TreeWriter::ProcessParticleFlowCandidates(ExRootTreeBranch *branch, TObjArray *array) 456 { 457 458 TIter iterator(array); 459 Candidate *candidate = 0; 460 Candidate *particle = 0; 461 ParticleFlowCandidate *entry = 0; 462 Double_t e, pt, signz, cosTheta, eta, rapidity, p, ctgTheta, phi; 463 const Double_t c_light = 2.99792458E8; 464 465 // loop over all tracks 466 iterator.Reset(); 467 while((candidate = static_cast<Candidate *>(iterator.Next()))) 468 { 469 const TLorentzVector &position = candidate->Position; 470 471 cosTheta = TMath::Abs(position.CosTheta()); 472 signz = (position.Pz() >= 0.0) ? 1.0 : -1.0; 473 eta = (cosTheta == 1.0 ? signz * 999.9 : position.Eta()); 474 rapidity = (cosTheta == 1.0 ? signz * 999.9 : position.Rapidity()); 475 476 entry = static_cast<ParticleFlowCandidate *>(branch->NewEntry()); 477 478 entry->SetBit(kIsReferenced); 479 entry->SetUniqueID(candidate->GetUniqueID()); 480 481 entry->PID = candidate->PID; 482 483 entry->Charge = candidate->Charge; 484 485 entry->EtaOuter = eta; 486 entry->PhiOuter = position.Phi(); 487 488 entry->XOuter = position.X(); 489 entry->YOuter = position.Y(); 490 entry->ZOuter = position.Z(); 491 entry->TOuter = position.T() * 1.0E-3 / c_light; 492 493 entry->L = candidate->L; 494 495 entry->D0 = candidate->D0; 496 entry->ErrorD0 = candidate->ErrorD0; 497 entry->DZ = candidate->DZ; 498 entry->ErrorDZ = candidate->ErrorDZ; 499 500 entry->ErrorP = candidate->ErrorP; 501 entry->ErrorPT = candidate->ErrorPT; 502 entry->ErrorCtgTheta = candidate->ErrorCtgTheta; 503 entry->ErrorPhi = candidate->ErrorPhi; 504 505 entry->Xd = candidate->Xd; 506 entry->Yd = candidate->Yd; 507 entry->Zd = candidate->Zd; 508 509 const TLorentzVector &momentum = candidate->Momentum; 510 511 e = momentum.E(); 512 pt = momentum.Pt(); 513 p = momentum.P(); 514 phi = momentum.Phi(); 515 ctgTheta = (TMath::Tan(momentum.Theta()) != 0) ? 1 / TMath::Tan(momentum.Theta()) : 1e10; 516 517 entry->E = e; 518 entry->P = p; 519 entry->PT = pt; 520 entry->Eta = eta; 521 entry->Phi = phi; 522 entry->CtgTheta = ctgTheta; 523 524 particle = static_cast<Candidate *>(candidate->GetCandidates()->At(0)); 525 const TLorentzVector &initialPosition = particle->Position; 526 527 entry->X = initialPosition.X(); 528 entry->Y = initialPosition.Y(); 529 entry->Z = initialPosition.Z(); 530 entry->T = initialPosition.T() * 1.0E-3 / c_light; 531 532 entry->VertexIndex = candidate->ClusterIndex; 533 534 entry->Eem = candidate->Eem; 535 entry->Ehad = candidate->Ehad; 536 entry->Edges[0] = candidate->Edges[0]; 537 entry->Edges[1] = candidate->Edges[1]; 538 entry->Edges[2] = candidate->Edges[2]; 539 entry->Edges[3] = candidate->Edges[3]; 540 541 entry->T = position.T() * 1.0E-3 / c_light; 542 entry->NTimeHits = candidate->NTimeHits; 543 544 FillParticles(candidate, &entry->Particles); 545 546 } 547 } 548 549 //------------------------------------------------------------------------------ 550 441 551 void TreeWriter::ProcessPhotons(ExRootTreeBranch *branch, TObjArray *array) 442 552 { … … 677 787 entry->NCharged = candidate->NCharged; 678 788 entry->NNeutrals = candidate->NNeutrals; 789 790 entry->NeutralEnergyFraction = candidate->NeutralEnergyFraction; 791 entry->ChargedEnergyFraction = candidate->ChargedEnergyFraction; 679 792 entry->Beta = candidate->Beta; 680 793 entry->BetaStar = candidate->BetaStar; -
modules/TreeWriter.h
r2d7ff18 r83ee320 56 56 void ProcessTracks(ExRootTreeBranch *branch, TObjArray *array); 57 57 void ProcessTowers(ExRootTreeBranch *branch, TObjArray *array); 58 void ProcessParticleFlowCandidates(ExRootTreeBranch *branch, TObjArray *array); 58 59 void ProcessPhotons(ExRootTreeBranch *branch, TObjArray *array); 59 60 void ProcessElectrons(ExRootTreeBranch *branch, TObjArray *array); … … 77 78 #endif 78 79 79 ClassDef(TreeWriter, 1)80 ClassDef(TreeWriter, 2) 80 81 }; 81 82 -
modules/VertexFinderDA4D.cc
r2d7ff18 r83ee320 3 3 * Cluster vertices from tracks using deterministic annealing and timing information 4 4 * 5 * \authors M. Selvaggi, L. Gray5 * \authors O. Cerri 6 6 * 7 7 */ 8 8 9 9 10 #include "modules/VertexFinderDA4D.h" … … 13 14 #include "classes/DelphesPileUpReader.h" 14 15 16 #include "ExRootAnalysis/ExRootResult.h" 17 #include "ExRootAnalysis/ExRootFilter.h" 15 18 #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" 19 25 #include "TDatabasePDG.h" 20 #include "TFormula.h"21 26 #include "TLorentzVector.h" 22 #include "TMath.h"23 27 #include "TMatrixT.h" 24 #include "TObjArray.h" 25 #include "TRandom3.h" 28 #include "TLatex.h" 29 #include "TVector3.h" 30 31 #include "TAxis.h" 32 #include "TGraphErrors.h" 33 #include "TCanvas.h" 26 34 #include "TString.h" 27 #include "TVector3.h" 28 35 #include "TLegend.h" 36 #include "TFile.h" 37 #include "TColor.h" 38 #include "TLegend.h" 39 40 #include <utility> 29 41 #include <algorithm> 42 #include <stdexcept> 30 43 #include <iostream> 31 #include <stdexcept>32 #include <utility>33 44 #include <vector> 34 45 35 46 using namespace std; 36 47 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; 42 43 struct track_t 44 { 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) 50 Candidate *tt; // a pointer to the Candidate Track 51 double Z; // Z[i] for DA clustering 52 double pi; // track weight 53 double pt; 54 double eta; 55 double phi; 56 }; 57 58 struct vertex_t 59 { 60 double z; 61 double t; 62 double pk; // vertex weight for "constrained" clustering 63 // --- temporary numbers, used during update 64 double ei; 65 double sw; 66 double swz; 67 double swt; 68 double se; 69 // ---for Tc 70 double swE; 71 double Tc; 72 }; 73 74 static bool split(double beta, std::vector<track_t> &tks, std::vector<vertex_t> &y); 75 static double update1(double beta, std::vector<track_t> &tks, std::vector<vertex_t> &y); 76 static 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); 78 static bool merge(std::vector<vertex_t> &); 79 static bool merge(std::vector<vertex_t> &, double &); 80 static bool purge(std::vector<vertex_t> &, std::vector<track_t> &, double &, const double, const double); 81 static void splitAll(std::vector<vertex_t> &y); 82 static double beta0(const double betamax, std::vector<track_t> &tks, std::vector<vertex_t> &y, const double coolingFactor); 83 static double Eik(const track_t &t, const vertex_t &k); 84 85 static bool recTrackLessZ1(const track_t &tk1, const track_t &tk2) 86 { 87 return tk1.z < tk2.z; 88 } 89 90 using namespace std; 48 namespace vtx_DAZT 49 { 50 static const Double_t c_light = 2.99792458e+8; // [m/s] 51 } 52 using namespace vtx_DAZT; 91 53 92 54 //------------------------------------------------------------------------------ 93 55 94 VertexFinderDA4D::VertexFinderDA4D() : 95 fVerbose(0), fMinPT(0), fVertexSpaceSize(0), fVertexTimeSize(0), 96 fUseTc(0), fBetaMax(0), fBetaStop(0), fCoolingFactor(0), 97 fMaxIterations(0), fDzCutOff(0), fD0CutOff(0), fDtCutOff(0) 98 { 56 VertexFinderDA4D::VertexFinderDA4D() 57 { 58 fVerbose = 0; 59 fMaxIterations = 0; 60 fBetaMax = 0; 61 fBetaStop = 0; 62 fBetaPurge = 0; 63 fVertexZSize = 0; 64 fVertexTSize = 0; 65 fCoolingFactor = 0; 66 fDzCutOff = 0; 67 fD0CutOff = 0; 68 fDtCutOff = 0; 69 fPtMin = 0; 70 fPtMax = 0; 71 fD2Merge = 0; 72 fMuOutlayer = 0; 73 fMinTrackProb = 0; 99 74 } 100 75 … … 109 84 void VertexFinderDA4D::Init() 110 85 { 111 112 fVerbose = GetBool("Verbose", 1); 113 fMinPT = GetDouble("MinPT", 0.1); 114 fVertexSpaceSize = GetDouble("VertexSpaceSize", 0.5); //in mm 115 fVertexTimeSize = GetDouble("VertexTimeSize", 10E-12); //in s 116 fUseTc = GetBool("UseTc", 1); 117 fBetaMax = GetDouble("BetaMax ", 0.1); 118 fBetaStop = GetDouble("BetaStop", 1.0); 119 fCoolingFactor = GetDouble("CoolingFactor", 0.8); 120 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 124 125 // convert stuff in cm, ns 126 fVertexSpaceSize /= 10.0; 127 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; 86 fVerbose = GetInt("Verbose", 0); 87 88 fMaxIterations = GetInt("MaxIterations", 100); 89 fMaxVertexNumber = GetInt("MaxVertexNumber", 500); 90 91 fBetaMax = GetDouble("BetaMax", 1.5); 92 fBetaPurge = GetDouble("BetaPurge", 1.); 93 fBetaStop = GetDouble("BetaStop", 0.2); 94 95 fVertexZSize = GetDouble("VertexZSize", 0.1); //in mm 96 fVertexTSize = 1E12*GetDouble("VertexTimeSize", 15E-12); //Convert from [s] to [ps] 97 98 fCoolingFactor = GetDouble("CoolingFactor", 0.8); // Multiply T so to cooldown must be <1 99 100 fDzCutOff = GetDouble("DzCutOff", 40); // For the moment 3*DzCutOff is hard cut off for the considered tracks 101 fD0CutOff = GetDouble("D0CutOff", .5); // d0/sigma_d0, used to compute the pi (weight) of the track 102 fDtCutOff = GetDouble("DtCutOff", 160); // [ps], 3*DtCutOff is hard cut off for tracks 103 fPtMin = GetDouble("PtMin", 0.5); // Minimum pt accepted for tracks 104 fPtMax = GetDouble("PtMax", 50); // Maximum pt accepted for tracks 105 106 107 fD2UpdateLim = GetDouble("D2UpdateLim", .5); // ((dz/ZSize)^2+(dt/TSize)^2)/nv limit for merging vertices 108 fD2Merge = GetDouble("D2Merge", 4.0); // (dz/ZSize)^2+(dt/TSize)^2 limit for merging vertices 109 fMuOutlayer = GetDouble("MuOutlayer", 4); // Outlayer rejection exponent 110 fMinTrackProb = GetDouble("MinTrackProb", 0.6); // Minimum probability to be assigned at a vertex 111 fMinNTrack = GetInt("MinNTrack", 10); // Minimum number of tracks per vertex 112 113 fFigFolderPath = GetString("DebugFigPath", "."); 130 114 131 115 fInputArray = ImportArray(GetString("InputArray", "TrackSmearing/tracks")); 132 116 fItInputArray = fInputArray->MakeIterator(); 133 117 134 f OutputArray = ExportArray(GetString("OutputArray", "tracks"));118 fTrackOutputArray = ExportArray(GetString("TrackOutputArray", "tracks")); 135 119 fVertexOutputArray = ExportArray(GetString("VertexOutputArray", "vertices")); 120 121 fInputGenVtx = ImportArray(GetString("InputGenVtx", "PileUpMerger/vertices")); 122 fItInputGenVtx = fInputGenVtx->MakeIterator(); 123 124 if (fBetaMax < fBetaPurge) 125 { 126 fBetaPurge = fBetaMax; 127 if (fVerbose) 128 { 129 cout << "BetaPurge set to " << fBetaPurge << endl; 130 } 131 } 132 133 if (fBetaPurge < fBetaStop) 134 { 135 fBetaStop = fBetaPurge; 136 if (fVerbose) 137 { 138 cout << "BetaPurge set to " << fBetaPurge << endl; 139 } 140 } 136 141 } 137 142 … … 147 152 void VertexFinderDA4D::Process() 148 153 { 149 Candidate *candidate, *track;150 TObjArray *ClusterArray;151 ClusterArray = new TObjArray;152 TIterator *ItClusterArray;153 Int_t ivtx = 0;154 155 154 fInputArray->Sort(); 156 155 157 TLorentzVector pos, mom; 156 if (fVerbose) 157 { 158 cout<< endl << " Start processing vertices with VertexFinderDA4D" << endl; 159 cout<<" Found "<<fInputArray->GetEntriesFast()<<" input tracks"<<endl; 160 } 161 162 // clusterize tracks 163 TObjArray *ClusterArray = new TObjArray; 164 clusterize(*ClusterArray); 165 166 if(fVerbose>10) 167 { 168 unsigned int N = fEnergy_rec.size(); 169 TGraph* gr1 = new TGraph(N, &fBeta_rec[0], &fNvtx_rec[0]); 170 gr1->SetName("gr1"); 171 gr1->GetXaxis()->SetTitle("beta"); 172 gr1->GetYaxis()->SetTitle("# Vtx"); 173 TGraph* gr2 = new TGraph(N, &fBeta_rec[0], &fEnergy_rec[0]); 174 gr2->SetName("gr2"); 175 gr2->GetXaxis()->SetTitle("beta"); 176 gr2->GetYaxis()->SetTitle("Total Energy"); 177 TGraph* gr3 = new TGraph(N, &fNvtx_rec[0], &fEnergy_rec[0]); 178 gr3->SetName("gr3"); 179 gr3->GetXaxis()->SetTitle("# Vtx"); 180 gr3->GetYaxis()->SetTitle("Total Energy"); 181 182 auto f = new TFile("~/Desktop/debug/EnergyStat.root", "recreate"); 183 gr1->Write("gr1"); 184 gr2->Write("gr2"); 185 gr3->Write("gr3"); 186 187 f->Close(); 188 } 189 190 if (fVerbose){std::cout << " clustering returned "<< ClusterArray->GetEntriesFast() << " clusters from " << fInputArray->GetEntriesFast() << " input tracks" <<std::endl;} 191 192 // //loop over vertex candidates 193 TIterator * ItClusterArray = ClusterArray->MakeIterator(); 194 ItClusterArray->Reset(); 195 Candidate *candidate; 196 unsigned int k = 0; 197 while((candidate = static_cast<Candidate*>(ItClusterArray->Next()))) 198 { 199 if(fVerbose) 200 { 201 cout << Form("Cluster %d has %d tracks ", k, candidate->GetCandidates()->GetEntriesFast()) << endl; 202 } 203 if(candidate->ClusterNDF>0) 204 { 205 // Estimate the vertex resolution 206 // loop over tracks belonging to this vertex 207 TIter it1(candidate->GetCandidates()); 208 it1.Reset(); 209 210 Candidate *track; 211 double sum_Dt_2 = 0; 212 double sum_Dz_2 = 0; 213 double sum_wt = 0; 214 double sum_wz = 0; 215 while((track = static_cast<Candidate*>(it1.Next()))) 216 { 217 double dz = candidate->Position.Z() - track->Zd; 218 double dt = candidate->Position.T() - track->Td; 219 220 double wz = track->VertexingWeight/(track->ErrorDZ*track->ErrorDZ); 221 double wt = track->VertexingWeight/(track->ErrorT*track->ErrorT); 222 223 sum_Dt_2 += wt*dt*dt; 224 sum_Dz_2 += wz*dz*dz; 225 sum_wt += wt; 226 sum_wz += wz; 227 } 228 229 double sigma_z = sqrt(sum_Dz_2/sum_wz); 230 double sigma_t = sqrt(sum_Dt_2/sum_wt); 231 candidate->PositionError.SetXYZT(0.0, 0.0, sigma_z , sigma_t); 232 if(fVerbose > 3) 233 { 234 cout << "k: " << k << endl; 235 cout << "Sigma z: " << sigma_z*1E3 << " um" << endl; 236 cout << "Sigma t: " << sigma_t*1E9/c_light << " ps" << endl; 237 } 238 239 fVertexOutputArray->Add(candidate); 240 k++; 241 } 242 }// end of cluster loop 243 244 delete ClusterArray; 245 } 246 247 //------------------------------------------------------------------------------ 248 249 void VertexFinderDA4D::clusterize(TObjArray &clusters) 250 { 251 tracks_t tks; 252 fill(tks); 253 unsigned int nt=tks.getSize(); 158 254 if(fVerbose) 159 255 { 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 } 171 } 172 173 // clusterize tracks in Z 174 clusterize(*fInputArray, *ClusterArray); 175 176 if(fVerbose) 177 { 178 std::cout << " clustering returned " << ClusterArray->GetEntriesFast() << " clusters from " << fInputArray->GetEntriesFast() << " selected tracks" << std::endl; 179 } 180 181 //loop over vertex candidates 182 ItClusterArray = ClusterArray->MakeIterator(); 183 ItClusterArray->Reset(); 184 while((candidate = static_cast<Candidate *>(ItClusterArray->Next()))) 185 { 186 187 double meantime = 0.; 188 double expv_x2 = 0.; 189 double normw = 0.; 190 double errtime = 0; 191 192 double meanpos = 0.; 193 double meanerr2 = 0.; 194 double normpos = 0.; 195 double errpos = 0.; 196 197 double sumpt2 = 0.; 198 199 int itr = 0; 200 201 if(fVerbose) cout << "this vertex has: " << candidate->GetCandidates()->GetEntriesFast() << " tracks" << endl; 202 203 // loop over tracks belonging to this vertex 204 TIter it1(candidate->GetCandidates()); 205 it1.Reset(); 206 207 while((track = static_cast<Candidate *>(it1.Next()))) 208 { 209 210 itr++; 211 // TBC: the time is in ns for now TBC 212 double t = track->InitialPosition.T() / c_light; 213 double dt = track->ErrorT / c_light; 214 const double time = t; 215 const double inverr = 1.0 / dt; 216 meantime += time * inverr; 217 expv_x2 += time * time * inverr; 218 normw += inverr; 219 220 // compute error position TBC 221 const double pt = track->Momentum.Pt(); 222 const double z = track->DZ / 10.0; 223 const double err_pt = track->ErrorPT; 224 const double err_z = track->ErrorDZ; 225 226 const double wi = (pt / (err_pt * err_z)) * (pt / (err_pt * err_z)); 227 meanpos += z * wi; 228 229 meanerr2 += err_z * err_z * wi; 230 normpos += wi; 231 sumpt2 += pt * pt; 232 233 // while we are here store cluster index in tracks 234 track->ClusterIndex = ivtx; 235 } 236 237 meantime = meantime / normw; 238 expv_x2 = expv_x2 / normw; 239 errtime = TMath::Sqrt((expv_x2 - meantime * meantime) / itr); 240 meanpos = meanpos / normpos; 241 meanerr2 = meanerr2 / normpos; 242 errpos = TMath::Sqrt(meanerr2 / itr); 243 244 candidate->Position.SetXYZT(0.0, 0.0, meanpos * 10.0, meantime * c_light); 245 candidate->PositionError.SetXYZT(0.0, 0.0, errpos * 10.0, errtime * c_light); 246 candidate->SumPT2 = sumpt2; 247 candidate->ClusterNDF = itr; 248 candidate->ClusterIndex = ivtx; 249 250 fVertexOutputArray->Add(candidate); 251 252 ivtx++; 253 254 if(fVerbose) 255 { 256 std::cout << "x,y,z"; 257 std::cout << ",t"; 258 std::cout << "=" << candidate->Position.X() / 10.0 << " " << candidate->Position.Y() / 10.0 << " " << candidate->Position.Z() / 10.0; 259 std::cout << " " << candidate->Position.T() / c_light; 260 261 std::cout << std::endl; 262 std::cout << "sumpt2 " << candidate->SumPT2 << endl; 263 264 std::cout << "ex,ey,ez"; 265 std::cout << ",et"; 266 std::cout << "=" << candidate->PositionError.X() / 10.0 << " " << candidate->PositionError.Y() / 10.0 << " " << candidate->PositionError.Z() / 10.0; 267 std::cout << " " << candidate->PositionError.T() / c_light; 268 std::cout << std::endl; 269 } 270 } // end of cluster loop 271 272 if(fVerbose) 273 { 274 std::cout << "PrimaryVertexProducerAlgorithm::vertices candidates =" << ClusterArray->GetEntriesFast() << std::endl; 275 } 276 277 //TBC maybe this can be done later 278 // sort vertices by pt**2 vertex (aka signal vertex tagging) 279 /*if(pvs.size()>1){ 280 sort(pvs.begin(), pvs.end(), VertexHigherPtSquared()); 281 } 282 */ 283 284 delete ClusterArray; 256 cout << "Tracks added: " << nt << endl; 257 } 258 if (nt == 0) return; 259 260 261 262 vertex_t vtx; // the vertex prototypes 263 vtx.ZSize = fVertexZSize; 264 vtx.TSize = fVertexTSize; 265 // initialize:single vertex at infinite temperature 266 vtx.addItem(0, 0, 1); 267 268 // Fit the vertex at T=inf and return the starting temperature 269 double beta=beta0(tks, vtx); 270 271 if( fVerbose > 1 ) 272 { 273 cout << "Cluster position at T=inf: z = " << vtx.z[0] << " mm , t = " << vtx.t[0] << " ps" << " pk = " << vtx.pk[0] << endl; 274 cout << Form("Beta Start = %2.1e", beta) << endl; 275 } 276 277 if( fVerbose > 10 ) plot_status(beta, vtx, tks, 0, "Ast"); 278 279 if( fVerbose > 2){cout << "Cool down untill reaching the temperature to finish increasing the number of vertexes" << endl;} 280 281 double rho0=0.0; // start with no outlier rejection 282 283 unsigned int last_round = 0; 284 while(last_round < 2) 285 { 286 287 unsigned int niter=0; 288 double delta2 = 0; 289 do { 290 delta2 = update(beta, tks, vtx, rho0); 291 292 if( fVerbose > 10 ) plot_status(beta, vtx, tks, niter, "Bup"); 293 if (fVerbose > 3) 294 { 295 cout << "Update " << niter << " : " << delta2 << endl; 296 } 297 niter++; 298 } 299 while (delta2 > fD2UpdateLim && niter < fMaxIterations); 300 301 302 unsigned int n_it = 0; 303 while(merge(vtx, fD2Merge) && n_it < fMaxIterations) 304 { 305 unsigned int niter=0; 306 double delta2 = 0; 307 do { 308 delta2 = update(beta, tks, vtx, rho0); 309 niter++; 310 } 311 while (delta2 > fD2UpdateLim && niter < fMaxIterations); 312 n_it++; 313 314 if( fVerbose > 10 ) plot_status(beta, vtx, tks, n_it, "Cme"); 315 } 316 317 beta /= fCoolingFactor; 318 319 if( beta < fBetaStop ) 320 { 321 split(beta, vtx, tks); 322 if( fVerbose > 10 ) plot_status(beta, vtx, tks, 0, "Asp"); 323 } 324 else 325 { 326 beta = fBetaStop; 327 last_round++; 328 } 329 330 if(fVerbose > 3) 331 { 332 cout << endl << endl << " ----- Beta = " << beta << " --------" << endl; 333 cout << "Nv: " << vtx.getSize() << endl; 334 } 335 } 336 337 if( fVerbose > 4) 338 { 339 for(unsigned int k = 0; k < vtx.getSize(); k++) 340 { 341 cout << Form("Vertex %d next beta_c = %.3f", k, vtx.beta_c[k]) << endl; 342 } 343 } 344 345 if(fVerbose > 2) {cout << "Adiabatic switch on of outlayr rejection" << endl;} 346 rho0 = 1./nt; 347 const double N_cycles = 10; 348 for(unsigned int f = 1; f <= N_cycles; f++) 349 { 350 unsigned int niter=0; 351 double delta2 = 0; 352 do { 353 delta2 = update(beta, tks, vtx, rho0 * f/N_cycles); 354 niter++; 355 } 356 while (delta2 > 0.3*fD2UpdateLim && niter < fMaxIterations); 357 if( fVerbose > 10 ) plot_status(beta, vtx, tks, f, "Dadout"); 358 } 359 360 do { 361 beta /= fCoolingFactor; 362 if(beta > fBetaPurge) beta = fBetaPurge; 363 unsigned int i_pu = 0; 364 for(int min_trk = 2; min_trk<=fMinNTrack; min_trk++) 365 { 366 while( purge(vtx, tks, rho0, beta, fMinTrackProb, min_trk) ) 367 { 368 unsigned int niter=0; 369 double delta2 = 0; 370 do { 371 delta2 = update(beta, tks, vtx, rho0); 372 niter++; 373 } 374 while (delta2 > fD2UpdateLim && niter < fMaxIterations); 375 if( fVerbose > 10 ) plot_status(beta, vtx, tks, i_pu, Form("Eprg%d",min_trk)); 376 i_pu++; 377 } 378 } 379 380 unsigned int n_it = 0; 381 while(merge(vtx, fD2Merge) && n_it < fMaxIterations) 382 { 383 unsigned int niter=0; 384 double delta2 = 0; 385 do { 386 delta2 = update(beta, tks, vtx, rho0); 387 niter++; 388 } 389 while (delta2 > fD2UpdateLim && niter < fMaxIterations); 390 n_it++; 391 392 if( fVerbose > 10 ) plot_status(beta, vtx, tks, n_it, "Cme"); 393 } 394 } while( beta < fBetaPurge ); 395 396 397 if(fVerbose > 2){cout << "Cooldown untill the limit before assigning track to vertices" << endl;} 398 last_round = 0; 399 while(last_round < 2) 400 { 401 unsigned int niter=0; 402 double delta2 = 0; 403 do { 404 delta2 = update(beta, tks, vtx, rho0); 405 niter++; 406 if( fVerbose > 10 ) plot_status(beta, vtx, tks, 0, "Bup"); 407 } 408 while (delta2 > 0.3*fD2UpdateLim && niter < fMaxIterations); 409 410 beta /= fCoolingFactor; 411 if ( beta >= fBetaMax ) 412 { 413 beta = fBetaMax; 414 last_round++; 415 } 416 } 417 418 419 // Build the cluster candidates 420 for(unsigned int k = 0; k < vtx.getSize(); k++) 421 { 422 DelphesFactory *factory = GetFactory(); 423 Candidate * candidate = factory->NewCandidate(); 424 425 candidate->ClusterIndex = k; 426 candidate->Position.SetXYZT(0.0, 0.0, vtx.z[k] , vtx.t[k]*1E-9*c_light); 427 candidate->PositionError.SetXYZT(0.0, 0.0, fVertexZSize , fVertexTSize*1E-9*c_light); 428 candidate->SumPT2 = 0; 429 candidate->SumPt = 0; 430 candidate->ClusterNDF = 0; 431 432 clusters.Add(candidate); 433 } 434 435 436 // Assign each track to the most probable vertex 437 double Z_init = rho0 * exp(-beta * fMuOutlayer * fMuOutlayer); // Add fDtCutOff here toghether with this 438 vector<double> pk_exp_mBetaE = Compute_pk_exp_mBetaE(beta, vtx, tks, Z_init); 439 for(unsigned int i = 0; i< tks.getSize(); i++) 440 { 441 if(tks.w[i] <= 0) continue; 442 443 double p_max = 0; 444 unsigned int k_max = 0; 445 446 for(unsigned int k = 0; k < vtx.getSize(); k++) 447 { 448 unsigned int idx = k*nt + i; 449 if(pk_exp_mBetaE[idx] == 0 || tks.Z[i] == 0 || vtx.pk[k] == 0) 450 { 451 continue; 452 } 453 454 double pv_max = vtx.pk[k] / (vtx.pk[k] + rho0 * exp(-beta * fMuOutlayer* fMuOutlayer)); 455 double p = pk_exp_mBetaE[idx] / tks.Z[i]; 456 457 p /= pv_max; 458 459 if(p > p_max) 460 { 461 p_max = p; 462 k_max = k; 463 } 464 } 465 466 if(p_max > fMinTrackProb) 467 { 468 tks.tt[i]->ClusterIndex = k_max; 469 tks.tt[i]->InitialPosition.SetT(1E-9*vtx.t[k_max]*c_light); 470 tks.tt[i]->InitialPosition.SetZ(vtx.z[k_max]); 471 472 ((Candidate *) clusters.At(k_max))->AddCandidate(tks.tt[i]); 473 ((Candidate *) clusters.At(k_max))->SumPT2 += tks.tt[i]->Momentum.Pt()*tks.tt[i]->Momentum.Pt(); 474 ((Candidate *) clusters.At(k_max))->SumPt += tks.tt[i]->Momentum.Pt(); 475 ((Candidate *) clusters.At(k_max))->ClusterNDF += 1; 476 } 477 else 478 { 479 tks.tt[i]->ClusterIndex = -1; 480 tks.tt[i]->InitialPosition.SetT(1E3*1000000*c_light); 481 tks.tt[i]->InitialPosition.SetZ(1E8); 482 } 483 fTrackOutputArray->Add(tks.tt[i]); 484 } 485 486 if(fVerbose > 10) plot_status_end(vtx, tks); 487 285 488 } 286 489 287 490 //------------------------------------------------------------------------------ 288 289 void VertexFinderDA4D::clusterize(const TObjArray &tracks, TObjArray &clusters) 290 { 291 if(fVerbose) 292 { 293 cout << "###################################################" << endl; 294 cout << "# VertexFinderDA4D::clusterize nt=" << tracks.GetEntriesFast() << endl; 295 cout << "###################################################" << endl; 296 } 297 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 } 308 309 // convert into vector of candidates 310 //TObjArray *ClusterArray = pv.begin()->GetCandidates(); 311 //Candidate *aCluster = static_cast<Candidate*>(&(pv.at(0))); 312 Candidate *aCluster = pv.at(0); 313 314 // fill into clusters and merge 315 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); 327 std::cout << ' ' << (*k)->Position.Z() << ' ' << (*k)->Position.T() << std::endl; 328 } 329 330 // 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 { 333 // close a cluster 334 clusters.Add(aCluster); 335 //aCluster.clear(); 336 } 337 //for(unsigned int i=0; i<k->GetCandidates().GetEntriesFast(); i++){ 338 aCluster = *k; 339 //} 340 } 341 clusters.Add(aCluster); 342 343 if(fVerbose) 344 { 345 std::cout << "# VertexFinderDA4D::clusterize clusters.size=" << clusters.GetEntriesFast() << std::endl; 346 } 491 // Definition of the distance metrci between track and vertex 492 double VertexFinderDA4D::Energy(double t_z, double v_z, double dz2_o, double t_t, double v_t, double dt2_o) 493 { 494 return (t_z - v_z)*(t_z - v_z)* dz2_o + (t_t - v_t)*(t_t - v_t)*dt2_o; 347 495 } 348 496 349 497 //------------------------------------------------------------------------------ 350 351 vector<Candidate *> VertexFinderDA4D::vertices() 352 { 498 // Fill tks with the input candidates array 499 void VertexFinderDA4D::fill(tracks_t &tks) 500 { 501 tks.sum_w_o_dt2 = 0; 502 tks.sum_w_o_dz2 = 0; 503 tks.sum_w = 0; 504 353 505 Candidate *candidate; 354 UInt_t clusterIndex = 0; 355 vector<Candidate *> clusters; 356 357 vector<track_t> tks; 358 track_t tr; 359 Double_t z, dz, t, l, dt, d0, d0error; 360 361 // loop over input tracks 506 362 507 fItInputArray->Reset(); 363 while((candidate = static_cast<Candidate *>(fItInputArray->Next()))) 364 { 365 //TBC everything in cm 366 z = candidate->DZ / 10; 367 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 373 374 // TBC: the time is in ns for now TBC 375 //t = candidate->Position.T()/c_light; 376 t = candidate->InitialPosition.T() / c_light; 377 l = candidate->L / c_light; 508 while((candidate = static_cast<Candidate*>(fItInputArray->Next()))) 509 { 510 unsigned int discard = 0; 511 378 512 double pt = candidate->Momentum.Pt(); 379 double eta = candidate->Momentum.Eta(); 380 double phi = candidate->Momentum.Phi(); 381 382 tr.pt = pt; 383 tr.eta = eta; 384 tr.phi = phi; 385 tr.t = t; // 386 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) 390 { 391 392 d0 = TMath::Abs(candidate->D0) / 10.0; 393 d0error = candidate->ErrorD0 / 10.0; 394 395 tr.pi = 1. / (1. + exp((d0 * d0) / (d0error * d0error) - fD0CutOff * fD0CutOff)); // reduce weight for high ip tracks 513 if(pt<fPtMin || pt>fPtMax) discard = 1; 514 515 // ------------- Compute cloasest approach Z ---------------- 516 double z = candidate->DZ; // [mm] 517 518 candidate->Zd = candidate->DZ; //Set the cloasest approach z 519 if(fabs(z) > 3*fDzCutOff) discard = 1; 520 521 // ------------- Compute cloasest approach T ---------------- 522 //Asumme pion mass which is the most common particle 523 double M = 0.139570; 524 candidate->Mass = M; 525 double p = pt * sqrt(1 + candidate->CtgTheta*candidate->CtgTheta); 526 double e = sqrt(p*p + M*M); 527 528 double t = candidate->Position.T()*1.E9/c_light; // from [mm] to [ps] 529 if(t <= -9999) discard = 1; // Means that the time information has not been added 530 531 // DEBUG Here backpropagete for the whole length and not noly for z. Could improve resolution 532 // double bz = pt * candidate->CtgTheta/e; 533 // t += (z - candidate->Position.Z())*1E9/(c_light*bz); 534 535 // Use full path Length 536 t -= candidate->L*1E9/(c_light*p/e); 537 538 candidate->Td = t*1E-9*c_light; 539 if(fabs(t) > 3*fDtCutOff) discard = 1; 540 541 // auto genp = (Candidate*) candidate->GetCandidates()->At(0); 542 // cout << "Eta: " << candidate->Position.Eta() << endl; 543 // cout << genp->Momentum.Pt() << " -- " << candidate->Momentum.Pt() << endl; 544 // cout << genp->Momentum.Pz() << " -- " << candidate->Momentum.Pz() << endl; 545 // cout << genp->Momentum.P() << " -- " << p << endl; 546 // cout << genp->Momentum.E() << " -- " << e << endl; 547 // cout << Form("bz_true: %.4f -- bz_gen: %.4f", genp->Momentum.Pz()/genp->Momentum.E(), bz) << endl; 548 549 double dz2_o = candidate->ErrorDZ*candidate->ErrorDZ; 550 dz2_o += fVertexZSize*fVertexZSize; 551 // when needed add beam spot width (x-y)?? mha? 552 dz2_o = 1/dz2_o; //Multipling is faster than dividing all the times 553 554 double dt2_o = candidate->ErrorT*1.E9/c_light; // [ps] 555 dt2_o *= dt2_o; 556 dt2_o += fVertexTSize*fVertexTSize; // [ps^2] 557 // Ideally we should also add the induced uncertantiy from dz, z_out, pt, ctgthetaand all the other thing used above (total around 5ps). For the moment we compensae using a high value for vertex time. 558 dt2_o = 1/dt2_o; 559 560 double w; 561 if(fD0CutOff > 0 && candidate->ErrorD0 > 0) 562 { 563 double d0_sig = fabs(candidate->D0/candidate->ErrorD0); 564 w = exp(d0_sig*d0_sig - fD0CutOff*fD0CutOff); 565 w = 1./(1. + w); 566 if (w < 1E-4) discard = 1; 396 567 } 397 568 else 398 569 { 399 tr.pi = 1.; 400 } 401 tr.tt = &(*candidate); 402 tr.Z = 1.; 403 404 // TBC now putting track selection here (> fPTMin) 405 if(tr.pi > 1e-3 && tr.pt > fMinPT) 406 { 407 tks.push_back(tr); 408 } 409 } 410 411 //print out input tracks 412 413 if(fVerbose) 414 { 415 std::cout << " start processing vertices ..." << std::endl; 416 std::cout << " Found " << tks.size() << " input tracks" << std::endl; 417 //loop over input tracks 418 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; 435 436 vector<vertex_t> y; // the vertex prototypes 437 438 // initialize:single vertex at infinite temperature 439 vertex_t vstart; 440 vstart.z = 0.; 441 vstart.t = 0.; 442 vstart.pk = 1.; 443 y.push_back(vstart); 444 int niter = 0; // number of iterations 445 446 // 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 } 452 453 // 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)) 570 w = 1; 571 } 572 candidate->VertexingWeight = w; 573 574 575 if(discard) 576 { 577 candidate->ClusterIndex = -1; 578 candidate->InitialPosition.SetT(1E3*1000000*c_light); 579 candidate->InitialPosition.SetZ(1E8); 580 fTrackOutputArray->Add(candidate); 581 } 582 else 583 { 584 tks.sum_w_o_dt2 += w * dt2_o; 585 tks.sum_w_o_dz2 += w * dz2_o; 586 tks.sum_w += w; 587 tks.addItem(z, t, dz2_o, dt2_o, &(*candidate), w, candidate->PID); //PROVA: rimuovi &(*---) 588 } 589 590 } 591 592 if(fVerbose > 1) 593 { 594 cout << "----->Filled tracks" << endl; 595 cout << "M z dz t dt w" << endl; 596 for(unsigned int i = 0; i < tks.getSize(); i++) 597 { 598 cout << Form("%d\t%1.1e\t%1.1e\t%1.1e\t%1.1e\t%1.1e", tks.PID[i], tks.z[i], 1/sqrt(tks.dz2_o[i]), tks.t[i], 1/sqrt(tks.dt2_o[i]), tks.w[i]) << endl; 599 } 600 } 601 602 return; 603 } 604 605 //------------------------------------------------------------------------------ 606 // Compute higher phase transition temperature 607 double VertexFinderDA4D::beta0(tracks_t & tks, vertex_t &vtx) 608 { 609 if(vtx.getSize() != 1) 610 { 611 throw std::invalid_argument( "Unexpected number of vertices" ); 612 } 613 614 unsigned int nt = tks.getSize(); 615 616 //Set vertex position at T=inf as the weighted average of the tracks 617 double sum_wz = 0, sum_wt = 0; 618 for(unsigned int i = 0; i < nt; i++) 619 { 620 sum_wz += tks.w[i] * tks.z[i] * tks.dz2_o[i]; 621 sum_wt += tks.w[i] * tks.t[i] * tks.dt2_o[i]; 622 } 623 vtx.t[0] = sum_wt / tks.sum_w_o_dt2; 624 vtx.z[0] = sum_wz / tks.sum_w_o_dz2; 625 626 // Compute the posterior distribution covariance matrix elements 627 double s_zz = 0, s_tt = 0, s_tz = 0; 628 for(unsigned int i = 0; i < nt; i++) 629 { 630 double dz = (tks.z[i] - vtx.z[0]) * tks.dz_o[i]; 631 double dt = (tks.t[i] - vtx.t[0]) * tks.dt_o[i]; 632 633 s_zz += tks.w[i] * dz * dz; 634 s_tt += tks.w[i] * dt * dt; 635 s_tz += tks.w[i] * dt * dz; 636 } 637 s_tt /= tks.sum_w; 638 s_zz /= tks.sum_w; 639 s_tz /= tks.sum_w; 640 641 // Copute the max eighenvalue 642 double beta_c = (s_tt - s_zz)*(s_tt - s_zz) + 4*s_tz*s_tz; 643 beta_c = 1. / (s_tt + s_zz + sqrt(beta_c)); 644 645 double out; 646 if (beta_c < fBetaMax) 647 { 648 // Cool down up to a step before the phase transition 649 out = beta_c * sqrt(fCoolingFactor); 650 } 651 else 652 { 653 out = fBetaMax * fCoolingFactor; 654 } 655 656 return out; 657 } 658 659 //------------------------------------------------------------------------------ 660 // Compute the new vertexes position and mass (probability) -- mass constrained annealing without noise 661 // Compute and store the posterior covariance matrix elements 662 // Returns the squared sum of changes of vertexex position normalized by the vertex size declared in the init 663 double VertexFinderDA4D::update(double beta, tracks_t &tks, vertex_t &vtx, double rho0) 664 { 665 unsigned int nt = tks.getSize(); 666 unsigned int nv = vtx.getSize(); 667 668 //initialize sums 669 double Z_init = rho0 * exp(-beta * fMuOutlayer * fMuOutlayer); 670 671 // Compute all the energies (aka distances) and normalization partition function 672 vector<double> pk_exp_mBetaE = Compute_pk_exp_mBetaE(beta, vtx, tks, Z_init); 673 674 double sum_pk = 0; 675 double delta2_max = 0; 676 for (unsigned int k = 0; k < nv; k++) 677 { 678 // Compute the new vertex positions and masses 679 double pk_new = 0; 680 double sw_z = 0, sw_t = 0; 681 // Compute the posterior covariance matrix Elements 682 double szz = 0, stt = 0, stz = 0; 683 double sum_wt = 0, sum_wz = 0; 684 double sum_ptt = 0, sum_pzz = 0, sum_ptz = 0; 685 686 687 for (unsigned int i = 0; i < nt; i++) 688 { 689 unsigned int idx = k*nt + i; 690 691 if(pk_exp_mBetaE[idx] == 0 || tks.Z[i] == 0) 461 692 { 462 update1(beta, tks, y); 463 } 464 split(beta, tks, y); 465 beta = beta / fCoolingFactor; 693 continue; 694 } 695 696 double p_ygx = pk_exp_mBetaE[idx] / tks.Z[i]; //p(y|x), Gibbs distribution 697 if(std::isnan(p_ygx) || std::isinf(p_ygx) || p_ygx > 1) 698 { 699 cout << Form("%1.6e %1.6e", pk_exp_mBetaE[idx], tks.Z[i]); 700 throw std::invalid_argument(Form("p_ygx is %.8f", p_ygx)); 701 } 702 pk_new += tks.w[i] * p_ygx; 703 704 double wt = tks.w[i] * p_ygx * tks.dt2_o[i]; 705 sw_t += wt * tks.t[i]; 706 sum_wt += wt; 707 708 double wz = tks.w[i] * p_ygx * tks.dz2_o[i]; 709 sw_z += wz * tks.z[i]; 710 sum_wz += wz; 711 712 // Add the track contribution to the covariance matrix 713 double p_xgy = p_ygx * tks.w[i] / vtx.pk[k]; 714 double dt = (tks.t[i] - vtx.t[k]) * tks.dt_o[i]; 715 double dz = (tks.z[i] - vtx.z[k]) * tks.dz_o[i]; 716 717 double wtt = p_xgy * tks.dt2_o[i]; 718 double wzz = p_xgy * tks.dz2_o[i]; 719 double wtz = p_xgy * tks.dt_o[i] * tks.dz_o[i]; 720 721 stt += wtt * dt * dt; 722 szz += wzz * dz * dz; 723 stz += wtz * dt * dz; 724 725 sum_ptt += wtt; 726 sum_pzz += wzz; 727 sum_ptz += wtz; 728 } 729 if(pk_new == 0) 730 { 731 vtx.removeItem(k); 732 k--; 733 // throw std::invalid_argument(Form("pk_new is %.8f", pk_new)); 466 734 } 467 735 else 468 736 { 469 beta = beta / fCoolingFactor; 470 splitAll(y); 471 } 472 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 { 482 // 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)) 737 pk_new /= tks.sum_w; 738 sum_pk += pk_new; 739 740 stt /= sum_ptt; 741 szz /= sum_pzz; 742 stz /= sum_ptz; 743 744 double new_t = sw_t/sum_wt; 745 double new_z = sw_z/sum_wz; 746 if(std::isnan(new_z) || std::isnan(new_t)) 493 747 { 494 } 495 merge(y, beta); 496 update1(beta, tks, y); 497 } 748 cout << endl << endl; 749 cout << Form("t: %.3e / %.3e", sw_t, sum_wt) << endl; 750 cout << Form("z: %.3e / %.3e", sw_z, sum_wz) << endl; 751 cout << "pk " << k << " " << vtx.pk[k] << endl; 752 throw std::invalid_argument("new_z is nan"); 753 } 754 755 double z_displ = (new_z - vtx.z[k])/fVertexZSize; 756 double t_displ = (new_t - vtx.t[k])/fVertexTSize; 757 double delta2 = z_displ*z_displ + t_displ*t_displ; 758 759 if (delta2 > delta2_max) delta2_max = delta2; 760 761 vtx.z[k] = new_z; 762 vtx.t[k] = new_t; 763 vtx.pk[k] = pk_new; 764 vtx.szz[k] = szz; 765 vtx.stt[k] = stt; 766 vtx.stz[k] = stz; 767 } 768 } 769 770 if(fabs((sum_pk - 1.) > 1E-4)) 771 { 772 cout << "sum_pk " << sum_pk << endl; 773 for (unsigned int k = 0; k < nv; k++) 774 { 775 cout << Form("%d: %1.4e", k, vtx.pk[k]) << endl; 776 } 777 throw std::invalid_argument("Sum of masses not unitary"); 778 } 779 // if(fVerbose > 3) 780 // { 781 // cout << "===Update over" << endl; 782 // for (unsigned int k = 0; k < nv; k++) 783 // { 784 // cout << k << endl; 785 // cout << "z: " << vtx.z[k] << " , t: " << vtx.t[k] << " , p: " << vtx.pk[k] << endl; 786 // cout << " | " << vtx.szz[k] << " " << vtx.stz[k] << "|" << endl; 787 // cout << " | " << vtx.stz[k] << " " << vtx.stt[k] << "|" << endl << endl; 788 // } 789 // cout << "=======" << endl; 790 // } 791 792 return delta2_max; 793 } 794 795 //------------------------------------------------------------------------------ 796 // Split critical vertices (beta_c < beta) 797 // Returns true if at least one cluster was split 798 bool VertexFinderDA4D::split(double &beta, vertex_t &vtx, tracks_t & tks) 799 { 800 bool split = false; 801 802 auto pair_bc_k = vtx.ComputeAllBeta_c(fVerbose); 803 804 // If minimum beta_c is higher than beta, no split is necessaire 805 if( pair_bc_k.first > beta ) 806 { 807 split = false; 498 808 } 499 809 else 500 810 { 501 // 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 } 511 } 512 513 // 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 } 528 529 // 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 } 538 539 // 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)) 811 const unsigned int nv = vtx.getSize(); 812 for(unsigned int k = 0; k < nv; k++) 813 { 814 if( fVerbose > 3 ) 546 815 { 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 } 566 567 // select significant tracks and use a TransientVertex as a container 568 //GlobalError dummyError; 569 570 // 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 { 582 583 DelphesFactory *factory = GetFactory(); 584 candidate = factory->NewCandidate(); 585 586 //cout<<"new vertex"<<endl; 587 //GlobalPoint pos(0, 0, k->z); 588 double time = k->t; 589 double z = k->z; 590 //vector< reco::TransientTrack > vertexTracks; 591 //double max_track_time_err2 = 0; 592 double mean = 0.; 593 double expv_x2 = 0.; 594 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) 816 cout << "vtx " << k << " beta_c = " << vtx.beta_c[k] << endl; 817 } 818 if(vtx.beta_c[k] <= beta) 599 819 { 600 double p = k->pk * exp(-beta * Eik(tks[i], *k)) / tks[i].Z; 601 if((tks[i].pi > 0) && (p > 0.5)) 820 double z_old = vtx.z[k]; 821 double t_old = vtx.t[k]; 822 double pk_old = vtx.pk[k]; 823 824 // Compute splitting direction: given by the max eighenvalue eighenvector 825 double zn = (vtx.szz[k] - vtx.stt[k])*(vtx.szz[k] - vtx.stt[k]) + 4*vtx.stz[k]*vtx.stz[k]; 826 zn = vtx.szz[k] - vtx.stt[k] + sqrt(zn); 827 double tn = 2*vtx.stz[k]; 828 double norm = hypot(zn, tn); 829 tn /= norm; 830 zn /= norm; 831 832 // Estimate subcluster positions and weight 833 double p1=0, z1=0, t1=0, wz1=0, wt1=0; 834 double p2=0, z2=0, t2=0, wz2=0, wt2=0; 835 const unsigned int nt = tks.getSize(); 836 for(unsigned int i=0; i<nt; ++i) 602 837 { 603 //std::cout << "pushing back " << i << ' ' << tks[i].tt << std::endl; 604 //vertexTracks.push_back(*(tks[i].tt)); tks[i].Z=0; 605 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; 612 } // setting Z=0 excludes double assignment 613 } 614 } 615 616 mean = mean / normw; 617 expv_x2 = expv_x2 / normw; 618 const double time_var = expv_x2 - mean * mean; 619 const double crappy_error_guess = std::sqrt(time_var); 620 /*GlobalError dummyErrorWithTime(0, 621 0,0, 622 0,0,0, 623 0,0,0,crappy_error_guess);*/ 624 //TransientVertex v(pos, time, dummyErrorWithTime, vertexTracks, 5); 625 626 candidate->ClusterIndex = clusterIndex++; 627 ; 628 candidate->Position.SetXYZT(0.0, 0.0, z * 10.0, time * c_light); 629 630 // TBC - fill error later ... 631 candidate->PositionError.SetXYZT(0.0, 0.0, 0.0, crappy_error_guess * c_light); 632 633 clusterIndex++; 634 clusters.push_back(candidate); 635 } 636 637 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; 645 } 646 647 //------------------------------------------------------------------------------ 648 649 static void dump(const double beta, const vector<vertex_t> &y, const vector<track_t> &tks0) 650 { 651 // copy and sort for nicer printout 652 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 } 657 std::stable_sort(tks.begin(), tks.end(), recTrackLessZ1); 658 659 cout << "-----DAClusterizerInZT::dump ----" << endl; 660 cout << " beta=" << beta << endl; 661 cout << " z= "; 662 cout.precision(4); 663 for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++) 664 { 665 //cout << setw(8) << fixed << k->z; 666 } 667 cout << endl 668 << " t= "; 669 for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++) 670 { 671 //cout << setw(8) << fixed << k->t; 672 } 673 //cout << endl << "T=" << setw(15) << 1./beta <<" Tc= "; 674 for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++) 675 { 676 //cout << setw(8) << fixed << k->Tc ; 677 } 678 679 cout << endl 680 << " pk="; 681 double sumpk = 0; 682 for(vector<vertex_t>::const_iterator k = y.begin(); k != y.end(); k++) 683 { 684 //cout << setw(8) << setprecision(3) << fixed << k->pk; 685 sumpk += k->pk; 686 } 687 cout << endl; 688 689 double E = 0, F = 0; 690 cout << endl; 691 cout << "---- z +/- dz t +/- dt ip +/-dip pt phi eta weights ----" << endl; 692 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; 701 //cout << setw (3)<< i << ")" << setw (8) << fixed << setprecision(4)<< tz << " +/-" << setw (6)<< sqrt(tks[i].dz2) 702 // << setw(8) << fixed << setprecision(4) << tt << " +/-" << setw(6) << std::sqrt(tks[i].dt2) ; 703 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) 838 if (tks.Z[i] > 0) 839 { 840 double lr = (tks.t[i] - vtx.t[k]) * tn + (tks.z[i]-vtx.z[k]) * zn; 841 // winner-takes-all, usually overestimates splitting 842 double tl = lr < 0 ? 1.: 0.; 843 double tr = 1. - tl; 844 845 // soften it, especially at low T 846 // double arg = lr * sqrt(beta * ( zn*zn*tks.dz2_o[i] + tn*tn*tks.dt2_o[i] ) ); 847 // if(abs(arg) < 20) 848 // { 849 // double t = exp(-arg); 850 // tl = t/(t+1.); 851 // tr = 1/(t+1.); 852 // } 853 854 double p = vtx.pk[k] * tks.w[i]; 855 p *= exp(-beta * Energy(tks.z[i], vtx.z[k], tks.dz2_o[i], tks.t[i], vtx.t[k], tks.dt2_o[i])) / tks.Z[i]; 856 double wt = p*tks.dt2_o[i]; 857 double wz = p*tks.dz2_o[i]; 858 p1 += p*tl; z1 += wz*tl*tks.z[i]; t1 += wt*tl*tks.t[i]; wz1 += wz*tl; wt1 += wt*tl; 859 p2 += p*tr; z2 += wz*tr*tks.z[i]; t2 += wt*tr*tks.t[i]; wz2 += wz*tr; wt2 += wt*tr; 860 } 861 } 862 863 if(wz1 > 0 && wt1 > 0 && wz2 > 0 && wt2 > 0) 712 864 { 713 //cout << setw (8) << setprecision(3) << p; 865 t1 /= wt1; 866 z1 /= wz1; 867 t2 /= wt2; 868 z2 /= wz2; 869 870 if( fVerbose > 3 ) 871 { 872 double aux = (z1-z2)*(z1-z2)/(fVertexZSize*fVertexZSize) + (t1-t2)*(t1-t2)/(fVertexTSize*fVertexTSize); 873 cout << "weighted split: delta = " << sqrt(aux) << endl; 874 } 714 875 } 715 876 else 716 877 { 717 cout << " . "; 878 continue; 879 // plot_split_crush(zn, tn, vtx, tks, k); 880 // throw std::invalid_argument( "0 division" ); 718 881 } 719 E += p * Eik(tks[i], *k); 720 sump += p; 721 } 722 else 882 883 while(vtx.NearestCluster(t1, z1) != k || vtx.NearestCluster(t2, z2) != k) 884 { 885 t1 = 0.5 * (t1 + t_old); 886 z1 = 0.5 * (z1 + z_old); 887 t2 = 0.5 * (t2 + t_old); 888 z2 = 0.5 * (z2 + z_old); 889 } 890 891 // Compute final distance and split if the distance is enough 892 double delta2 = (z1-z2)*(z1-z2)/(fVertexZSize*fVertexZSize) + (t1-t2)*(t1-t2)/(fVertexTSize*fVertexTSize); 893 if(delta2 > fD2Merge) 894 { 895 split = true; 896 vtx.t[k] = t1; 897 vtx.z[k] = z1; 898 vtx.pk[k] = p1 * pk_old/(p1+p2); 899 900 double new_t = t2; 901 double new_z = z2; 902 double new_pk = p2 * pk_old/(p1+p2); 903 904 vtx.addItem(new_z, new_t, new_pk); 905 906 if( fVerbose > 3 ) 907 { 908 cout << "===Split happened on vtx " << k << endl; 909 cout << "OLD z: " << z_old << " , t: " << t_old << " , pk: " << pk_old << endl; 910 cout << "NEW+ z: " << vtx.z[k] << " , t: " << vtx.t[k] << " , pk: " << vtx.pk[k] << endl; 911 cout << "NEW- z: " << new_z << " , t: " << new_t << " , pk: " << new_pk << endl; 912 } 913 } 914 } 915 } 916 } 917 return split; 918 } 919 920 921 //------------------------------------------------------------------------------ 922 // Merge vertexes closer than declared dimensions 923 bool VertexFinderDA4D::merge(vertex_t & vtx, double d2_merge = 2) 924 { 925 bool merged = false; 926 927 if(vtx.getSize() < 2) return merged; 928 929 bool last_merge = false; 930 do { 931 double min_d2 = d2_merge; 932 unsigned int k1_min, k2_min; 933 for(unsigned int k1 = 0; k1 < vtx.getSize(); k1++) 934 { 935 for(unsigned int k2 = k1+1; k2 < vtx.getSize();k2++) 723 936 { 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; 937 double d2_tmp = vtx.DistanceSquare(k1, k2); 938 if(d2_tmp < min_d2) 939 { 940 min_d2 = d2_tmp; 941 k1_min = k1; 942 k2_min = k2; 943 } 944 } 945 } 946 947 if(min_d2 < d2_merge) 948 { 949 vtx.mergeItems(k1_min, k2_min); 950 last_merge = true; 951 merged = true; 952 } 953 else last_merge = false; 954 } while(last_merge); 955 956 return merged; 957 } 958 959 // ----------------------------------------------------------------------------- 960 // Compute all the energies and set the partition function normalization for each track 961 vector<double> VertexFinderDA4D::Compute_pk_exp_mBetaE(double beta, vertex_t &vtx, tracks_t &tks, double Z_init) 962 { 963 unsigned int nt = tks.getSize(); 964 unsigned int nv = vtx.getSize(); 965 966 vector<double> pk_exp_mBetaE(nt * nv); 967 for (unsigned int k = 0; k < nv; k++) 968 { 969 for (unsigned int i = 0; i < nt; i++) 970 { 971 if(k == 0) tks.Z[i] = Z_init; 972 973 double aux = Energy(tks.z[i], vtx.z[k], tks.dz2_o[i], tks.t[i], vtx.t[k], tks.dt2_o[i]); 974 aux = vtx.pk[k] * exp(-beta * aux); 975 // if(aux < 1E-10) continue; 976 tks.Z[i] += aux; 977 978 unsigned int idx = k*nt + i; 979 pk_exp_mBetaE[idx] = aux; 980 } 981 } 982 return pk_exp_mBetaE; 732 983 } 733 984 734 985 //------------------------------------------------------------------------------ 735 736 static double update1(double beta, vector<track_t> &tks, vector<vertex_t> &y) 737 { 738 //update weights and vertex positions 739 // mass constrained annealing without noise 740 // returns the squared sum of changes of vertex positions 741 742 unsigned int nt = tks.size(); 743 744 //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 } 755 756 // loop over tracks 757 for(unsigned int i = 0; i < nt; i++) 758 { 759 760 // update pik and Zi 761 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; 768 769 // normalization for pk 770 if(tks[i].Z > 0) 771 { 772 sumpi += tks[i].pi; 773 // accumulate weighted z and weights for vertex update 774 for(vector<vertex_t>::iterator k = y.begin(); k != y.end(); ++k) 986 // Eliminate clusters with only one significant/unique track 987 bool VertexFinderDA4D::purge(vertex_t & vtx, tracks_t & tks, double & rho0, const double beta, double min_prob, double min_trk) 988 { 989 const unsigned int nv = vtx.getSize(); 990 const unsigned int nt = tks.getSize(); 991 992 if (nv < 2) 993 return false; 994 995 double sumpmin = nt; 996 unsigned int k0 = nv; 997 998 int nUnique = 0; 999 double sump = 0; 1000 1001 double Z_init = rho0 * exp(-beta * fMuOutlayer * fMuOutlayer); // Add fDtCutOff here toghether with this 1002 vector<double> pk_exp_mBetaE = Compute_pk_exp_mBetaE(beta, vtx, tks, Z_init); 1003 1004 for (unsigned int k = 0; k < nv; ++k) { 1005 1006 nUnique = 0; 1007 sump = 0; 1008 1009 double pmax = vtx.pk[k] / (vtx.pk[k] + rho0 * exp(-beta * fMuOutlayer* fMuOutlayer)); 1010 double pcut = min_prob * pmax; 1011 1012 for (unsigned int i = 0; i < nt; ++i) { 1013 unsigned int idx = k*nt + i; 1014 1015 if(pk_exp_mBetaE[idx] == 0 || tks.Z[i] == 0) 775 1016 { 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; 780 k->swt += w * tks[i].t; 781 k->swE += w * Eik(tks[i], *k); 782 } 783 } 784 else 785 { 786 sumpi += tks[i].pi; 787 } 788 789 } // end of track loop 790 791 // 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 { 806 // cout << " a cluster melted away ? pk=" << k->pk << " sumw=" << k->sw << endl 807 k->Tc = -1; 808 } 809 810 k->pk = k->pk * k->se / sumpi; 811 } 812 813 // return how much the prototypes moved 814 return delta; 815 } 816 817 //------------------------------------------------------------------------------ 818 819 static double update2(double beta, vector<track_t> &tks, vector<vertex_t> &y, double &rho0, double dzCutOff) 820 { 821 // MVF style, no more vertex weights, update tracks weights and vertex positions, with noise 822 // returns the squared sum of changes of vertex positions 823 824 unsigned int nt = tks.size(); 825 826 //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 } 836 837 // loop over tracks 838 for(unsigned int i = 0; i < nt; i++) 839 { 840 841 // update pik and Zi and Ti 842 double Zi = rho0 * std::exp(-beta * (dzCutOff * dzCutOff)); // cut-off (eventually add finite size in time) 843 //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; 850 851 // 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; 861 k->swt += w * tks[i].t; 862 k->swE += w * Eik(tks[i], *k); 863 } 864 } 865 866 } // end of track loop 867 868 // 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 { 883 // cout << " a cluster melted away ? pk=" << k->pk << " sumw=" << k->sw << endl; 884 k->Tc = 0; 885 } 886 } 887 888 // return how much the prototypes moved 889 return delta; 890 } 891 892 //------------------------------------------------------------------------------ 893 894 static bool merge(vector<vertex_t> &y) 895 { 896 // merge clusters that collapsed or never separated, return true if vertices were merged, false otherwise 897 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); 914 } 915 k->pk = rho; 916 917 y.erase(k + 1); 918 return true; 919 } 920 } 921 922 return false; 923 } 924 925 //------------------------------------------------------------------------------ 926 927 static bool merge(vector<vertex_t> &y, double &beta) 928 { 929 // merge clusters that collapsed or never separated, 930 // only merge if the estimated critical temperature of the merged vertex is below the current temperature 931 // 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; 960 } 961 } 962 } 963 964 return false; 965 } 966 967 //------------------------------------------------------------------------------ 968 969 static bool purge(vector<vertex_t> &y, vector<track_t> &tks, double &rho0, const double beta, const double dzCutOff) 970 { 971 // 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 } 992 } 993 } 994 995 if((nUnique < 2) && (sump < sumpmin)) 996 { 1017 continue; 1018 } 1019 1020 double p = pk_exp_mBetaE[idx] / tks.Z[i]; 1021 sump += p; 1022 if( ( p > pcut ) & ( tks.w[i] > 0 ) ) nUnique++; 1023 } 1024 1025 if ((nUnique < min_trk) && (sump < sumpmin)) { 997 1026 sumpmin = sump; 998 1027 k0 = k; 999 1028 } 1000 } 1001 1002 if(k0 != y.end()) 1003 { 1004 //cout << "eliminating prototype at " << k0->z << "," << k0->t << " with sump=" << sumpmin << endl; 1005 //rho0+=k0->pk; 1006 y.erase(k0); 1029 1030 } 1031 1032 if (k0 != nv) { 1033 if (fVerbose > 5) { 1034 std::cout << Form("eliminating prototype at z = %.3f mm, t = %.0f ps", vtx.z[k0], vtx.t[k0]) << " with sump=" << sumpmin 1035 << " rho*nt =" << vtx.pk[k0]*nt 1036 << endl; 1037 } 1038 vtx.removeItem(k0); 1007 1039 return true; 1008 } 1009 else 1010 { 1040 } else { 1011 1041 return false; 1012 1042 } 1013 1043 } 1014 1044 1015 //------------------------------------------------------------------------------ 1016 1017 static double beta0(double betamax, vector<track_t> &tks, vector<vertex_t> &y, const double coolingFactor) 1018 { 1019 1020 double T0 = 0; // max Tc for beta=0 1021 // 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 { 1026 1027 // 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; 1040 1041 // 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); 1049 b += w; 1050 } 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 { 1061 // ensure at least one annealing step 1062 return betamax / coolingFactor; 1063 } 1064 } 1065 1066 //------------------------------------------------------------------------------ 1067 1068 static bool split(double beta, vector<track_t> &tks, vector<vertex_t> &y) 1069 { 1070 // split only critical vertices (Tc >~ T=1/beta <==> beta*Tc>~1) 1071 // an update must have been made just before doing this (same beta, no merging) 1072 // returns true if at least one cluster was split 1073 1074 const double epsilon = 1e-3; // split all single vertices by 10 um 1075 bool split = false; 1076 1077 // avoid left-right biases by splitting highest Tc first 1078 1079 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; 1092 // 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; 1095 //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 } 1117 } 1118 } 1119 if(w1 > 0) 1120 { 1121 z1 = z1 / w1; 1122 t1 = t1 / w1; 1045 1046 // ----------------------------------------------------------------------------- 1047 // Plot status 1048 void VertexFinderDA4D::plot_status(double beta, vertex_t &vtx, tracks_t &tks, int n_it, const char* flag) 1049 { 1050 vector<int> vtx_color = {2,4,8,1,5,6,9,14,46,3}; 1051 while(vtx.getSize() > vtx_color.size()) vtx_color.push_back(40); 1052 1053 vector<double> t_PV, dt_PV, z_PV, dz_PV; 1054 vector<double> t_PU, dt_PU, z_PU, dz_PU; 1055 1056 double ETot = 0; 1057 vector<double> pk_exp_mBetaE = Compute_pk_exp_mBetaE(beta, vtx, tks, 0); 1058 1059 for(unsigned int i = 0; i < tks.getSize(); i++) 1060 { 1061 for(unsigned int k = 0; k < vtx.getSize(); k++) 1062 { 1063 unsigned int idx = k*tks.getSize() + i; 1064 if(pk_exp_mBetaE[idx] == 0) continue; 1065 1066 double p_ygx = pk_exp_mBetaE[idx] / tks.Z[i]; 1067 1068 ETot += tks.w[i] * p_ygx * Energy(tks.z[i], vtx.z[k], tks.dz2_o[i], tks.t[i], vtx.t[k], tks.dt2_o[i]); 1069 } 1070 1071 if(tks.tt[i]->IsPU) 1072 { 1073 t_PU.push_back(tks.t[i]); 1074 dt_PU.push_back(1./tks.dt_o[i]); 1075 z_PU.push_back(tks.z[i]); 1076 dz_PU.push_back(1./tks.dz_o[i]); 1123 1077 } 1124 1078 else 1125 1079 { 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 } 1139 1140 // 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 } 1151 1152 // split if the new subclusters are significantly separated 1153 if((z2 - z1) > epsilon || std::abs(t2 - t1) > epsilon) 1154 { 1155 split = true; 1156 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; 1161 y[ik].z = z2; 1162 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 } 1172 } 1173 } 1174 } 1175 1176 // stable_sort(y.begin(), y.end(), clusterLessZ); 1177 return split; 1178 } 1179 1180 //------------------------------------------------------------------------------ 1181 1182 void splitAll(vector<vertex_t> &y) 1183 { 1184 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 1188 1189 vector<vertex_t> y1; 1190 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 { 1195 // isolated prototype, split 1196 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; 1203 y1.push_back(vnew); 1204 y1.push_back(*k); 1205 } 1206 else if(y1.empty() || (y1.back().z < k->z - zsep) || (y1.back().t < k->t - tsep)) 1207 { 1208 y1.push_back(*k); 1209 } 1210 else 1211 { 1212 y1.back().z -= epsilon; 1213 y1.back().t -= epsilon; 1214 k->z += epsilon; 1215 k->t += epsilon; 1216 y1.push_back(*k); 1217 } 1218 } // vertex loop 1219 1220 y = y1; 1221 } 1080 t_PV.push_back(tks.t[i]); 1081 dt_PV.push_back(1./tks.dt_o[i]); 1082 z_PV.push_back(tks.z[i]); 1083 dz_PV.push_back(1./tks.dz_o[i]); 1084 } 1085 } 1086 1087 1088 ETot /= tks.sum_w; 1089 fEnergy_rec.push_back(ETot); 1090 fBeta_rec.push_back(beta); 1091 fNvtx_rec.push_back(vtx.getSize()); 1092 1093 double t_min = TMath::Min( TMath::MinElement(t_PV.size(), &t_PV[0]), TMath::MinElement(t_PU.size(), &t_PU[0]) ); 1094 t_min = TMath::Min(t_min, TMath::MinElement(vtx.getSize(), &(vtx.t[0])) ) - fVertexTSize; 1095 double t_max = TMath::Max( TMath::MaxElement(t_PV.size(), &t_PV[0]), TMath::MaxElement(t_PU.size(), &t_PU[0]) ); 1096 t_max = TMath::Max(t_max, TMath::MaxElement(vtx.getSize(), &(vtx.t[0])) ) + fVertexTSize; 1097 1098 double z_min = TMath::Min( TMath::MinElement(z_PV.size(), &z_PV[0]), TMath::MinElement(z_PU.size(), &z_PU[0]) ); 1099 z_min = TMath::Min(z_min, TMath::MinElement(vtx.getSize(), &(vtx.z[0])) ) - 5; 1100 double z_max = TMath::Max( TMath::MaxElement(z_PV.size(), &z_PV[0]), TMath::MaxElement(z_PU.size(), &z_PU[0]) ); 1101 z_max = TMath::Max(z_max, TMath::MaxElement(vtx.getSize(), &(vtx.z[0])) ) + 5; 1102 1103 auto c_2Dspace = new TCanvas("c_2Dspace", "c_2Dspace", 800, 600); 1104 1105 TGraphErrors* gr_PVtks = new TGraphErrors(t_PV.size(), &t_PV[0], &z_PV[0], &dt_PV[0], &dz_PV[0]); 1106 gr_PVtks->SetTitle(Form("Clustering space - #beta = %.6f", beta)); 1107 gr_PVtks->GetXaxis()->SetTitle("t CA [ps]"); 1108 gr_PVtks->GetXaxis()->SetLimits(t_min, t_max); 1109 gr_PVtks->GetYaxis()->SetTitle("z CA [mm]"); 1110 gr_PVtks->GetYaxis()->SetRangeUser(z_min, z_max); 1111 gr_PVtks->SetMarkerStyle(4); 1112 gr_PVtks->SetMarkerColor(8); 1113 gr_PVtks->SetLineColor(8); 1114 gr_PVtks->Draw("APE1"); 1115 1116 TGraphErrors* gr_PUtks = new TGraphErrors(t_PU.size(), &t_PU[0], &z_PU[0], &dt_PU[0], &dz_PU[0]); 1117 gr_PUtks->SetMarkerStyle(3); 1118 gr_PUtks->Draw("PE1"); 1119 1120 TGraph* gr_vtx = new TGraph(vtx.getSize(), &(vtx.t[0]), &(vtx.z[0])); 1121 gr_vtx->SetMarkerStyle(28); 1122 gr_vtx->SetMarkerColor(2); 1123 gr_vtx->SetMarkerSize(2.); 1124 gr_vtx->Draw("PE1"); 1125 1126 fItInputGenVtx->Reset(); 1127 TGraph* gr_genvtx = new TGraph(fInputGenVtx->GetEntriesFast()); 1128 Candidate *candidate; 1129 unsigned int k = 0; 1130 while((candidate = static_cast<Candidate*>(fItInputGenVtx->Next()))) 1131 { 1132 gr_genvtx->SetPoint(k, candidate->Position.T()*1E9/c_light, candidate->Position.Z()); 1133 k++; 1134 } 1135 gr_genvtx->SetMarkerStyle(33); 1136 gr_genvtx->SetMarkerColor(6); 1137 gr_genvtx->SetMarkerSize(2.); 1138 gr_genvtx->Draw("PE1"); 1139 1140 // auto leg = new TLegend(0.1, 0.1); 1141 // leg->AddEntry(gr_PVtks, "PV tks", "ep"); 1142 // leg->AddEntry(gr_PUtks, "PU tks", "ep"); 1143 // leg->AddEntry(gr_vtx, "Cluster center", "p"); 1144 // leg->Draw(); 1145 1146 c_2Dspace->SetGrid(); 1147 c_2Dspace->SaveAs(fFigFolderPath + Form("/c_2Dspace_beta%010.0f-%s%d.png", 1E7*beta, flag, n_it)); 1148 1149 delete c_2Dspace; 1150 } 1151 1152 // ----------------------------------------------------------------------------- 1153 // Plot status at the end 1154 void VertexFinderDA4D::plot_status_end(vertex_t &vtx, tracks_t &tks) 1155 { 1156 unsigned int nv = vtx.getSize(); 1157 1158 // Define colors in a meaningfull way 1159 vector<int> MyPalette(nv); 1160 1161 const int Number = 3; 1162 double Red[Number] = { 1.00, 0.00, 0.00}; 1163 double Green[Number] = { 0.00, 1.00, 0.00}; 1164 double Blue[Number] = { 1.00, 0.00, 1.00}; 1165 double Length[Number] = { 0.00, 0.50, 1.00 }; 1166 int FI = TColor::CreateGradientColorTable(Number,Length,Red,Green,Blue,nv); 1167 for (unsigned int i=0;i<nv;i++) MyPalette[i] = FI+i; 1168 1169 TCanvas * c_out = new TCanvas("c_out", "c_out", 800, 600); 1170 double t_min = TMath::Min( TMath::MinElement(tks.getSize(), &tks.t[0]), TMath::MinElement(vtx.getSize(), &(vtx.t[0])) ) - 2*fVertexTSize; 1171 double t_max = TMath::Max(TMath::MaxElement(tks.getSize(), &tks.t[0]), TMath::MaxElement(vtx.getSize(), &(vtx.t[0])) ) + 2*fVertexTSize; 1172 1173 double z_min = TMath::Min( TMath::MinElement(tks.getSize(), &tks.z[0]), TMath::MinElement(vtx.getSize(), &(vtx.z[0])) ) - 15; 1174 double z_max = TMath::Max( TMath::MaxElement(tks.getSize(), &tks.z[0]), TMath::MaxElement(vtx.getSize(), &(vtx.z[0])) ) + 15; 1175 1176 // Draw tracks 1177 for(unsigned int i = 0; i < tks.getSize(); i++) 1178 { 1179 double dt[] = {1./tks.dt_o[i]}; 1180 double dz[] = {1./tks.dz_o[i]}; 1181 TGraphErrors* gr = new TGraphErrors(1, &(tks.t[i]), &(tks.z[i]), dt, dz); 1182 1183 gr->SetNameTitle(Form("gr%d",i), Form("gr%d",i)); 1184 1185 int marker = tks.tt[i]->IsPU? 1 : 4; 1186 gr->SetMarkerStyle(marker); 1187 1188 int idx = tks.tt[i]->ClusterIndex; 1189 int color = idx>=0 ? MyPalette[idx] : 13; 1190 gr->SetMarkerColor(color); 1191 gr->SetLineColor(color); 1192 1193 int line_style = idx>=0 ? 1 : 3; 1194 gr->SetLineStyle(line_style); 1195 1196 if(i==0) 1197 { 1198 gr->SetTitle(Form("Clustering space - Tot Vertexes = %d", nv)); 1199 gr->GetXaxis()->SetTitle("t CA [ps]"); 1200 gr->GetXaxis()->SetLimits(t_min, t_max); 1201 gr->GetYaxis()->SetTitle("z CA [mm]"); 1202 gr->GetYaxis()->SetRangeUser(z_min, z_max); 1203 gr->Draw("APE1"); 1204 } 1205 else gr->Draw("PE1"); 1206 } 1207 1208 // Draw vertices 1209 for(unsigned int k = 0; k < vtx.getSize(); k++) 1210 { 1211 TGraph* gr = new TGraph(1, &(vtx.t[k]), &(vtx.z[k])); 1212 1213 gr->SetNameTitle(Form("grv%d",k), Form("grv%d",k)); 1214 1215 gr->SetMarkerStyle(41); 1216 gr->SetMarkerSize(2.); 1217 gr->SetMarkerColor(MyPalette[k]); 1218 1219 gr->Draw("P"); 1220 } 1221 1222 fItInputGenVtx->Reset(); 1223 TGraph* gr_genvtx = new TGraph(fInputGenVtx->GetEntriesFast()); 1224 TGraph* gr_genPV = new TGraph(1); 1225 Candidate *candidate; 1226 unsigned int k = 0; 1227 while((candidate = static_cast<Candidate*>(fItInputGenVtx->Next()))) 1228 { 1229 if(k == 0 ) { 1230 gr_genPV->SetPoint(k, candidate->Position.T()*1E9/c_light, candidate->Position.Z()); 1231 } 1232 else gr_genvtx->SetPoint(k, candidate->Position.T()*1E9/c_light, candidate->Position.Z()); 1233 1234 k++; 1235 } 1236 gr_genvtx->SetMarkerStyle(20); 1237 gr_genvtx->SetMarkerColorAlpha(kBlack, 0.8); 1238 gr_genvtx->SetMarkerSize(.8); 1239 gr_genvtx->Draw("PE1"); 1240 gr_genPV->SetMarkerStyle(33); 1241 gr_genPV->SetMarkerColorAlpha(kBlack, 1); 1242 gr_genPV->SetMarkerSize(2.5); 1243 gr_genPV->Draw("PE1"); 1244 1245 // auto note = new TLatex(); 1246 // note->DrawLatexNDC(0.5, 0.8, Form("#splitline{Vertexes Reco = %d }{Vertexes gen = %d}", vtx.getSize(), k) ); 1247 1248 c_out->SetGrid(); 1249 c_out->SaveAs(fFigFolderPath + Form("/c_final.root")); 1250 delete c_out; 1251 } 1252 1253 // ----------------------------------------------------------------------------- 1254 // Plot splitting 1255 void VertexFinderDA4D::plot_split_crush(double zn, double tn, vertex_t &vtx, tracks_t &tks, int i_vtx) 1256 { 1257 vector<double> t, dt, z, dz; 1258 1259 for(unsigned int i = 0; i < tks.getSize(); i++) 1260 { 1261 t.push_back(tks.t[i]); 1262 dt.push_back(1./tks.dt_o[i]); 1263 z.push_back(tks.z[i]); 1264 dz.push_back(1./tks.dz_o[i]); 1265 } 1266 1267 1268 double t_min = TMath::Min(TMath::MinElement(t.size(), &t[0]), TMath::MinElement(vtx.getSize(), &(vtx.t[0])) ) - 50; 1269 double t_max = TMath::Max(TMath::MaxElement(t.size(), &t[0]), TMath::MaxElement(vtx.getSize(), &(vtx.t[0])) ) + 50; 1270 1271 double z_min = TMath::Min(TMath::MinElement(z.size(), &z[0]), TMath::MinElement(vtx.getSize(), &(vtx.z[0])) ) - 5; 1272 double z_max = TMath::Max(TMath::MaxElement(z.size(), &z[0]), TMath::MaxElement(vtx.getSize(), &(vtx.z[0])) ) + 5; 1273 1274 auto c_2Dspace = new TCanvas("c_2Dspace", "c_2Dspace", 800, 600); 1275 1276 TGraphErrors* gr_PVtks = new TGraphErrors(t.size(), &t[0], &z[0], &dt[0], &dz[0]); 1277 gr_PVtks->SetTitle(Form("Clustering space")); 1278 gr_PVtks->GetXaxis()->SetTitle("t CA [ps]"); 1279 gr_PVtks->GetXaxis()->SetLimits(t_min, t_max); 1280 gr_PVtks->GetYaxis()->SetTitle("z CA [mm]"); 1281 gr_PVtks->GetYaxis()->SetRangeUser(z_min, z_max); 1282 gr_PVtks->SetMarkerStyle(4); 1283 gr_PVtks->SetMarkerColor(1); 1284 gr_PVtks->SetLineColor(1); 1285 gr_PVtks->Draw("APE1"); 1286 1287 TGraph* gr_vtx = new TGraph(1, &(vtx.t[i_vtx]), &(vtx.z[i_vtx])); 1288 gr_vtx->SetMarkerStyle(28); 1289 gr_vtx->SetMarkerColor(2); 1290 gr_vtx->SetMarkerSize(2.); 1291 gr_vtx->Draw("PE1"); 1292 1293 double t_pos[] = {vtx.t[i_vtx], vtx.t[i_vtx]+100}; 1294 double t_neg[] = {vtx.t[i_vtx], vtx.t[i_vtx]-100}; 1295 double z_pos[] = {vtx.z[i_vtx], vtx.z[i_vtx]+(zn/tn)*100}; 1296 double z_neg[] = {vtx.z[i_vtx], vtx.z[i_vtx]-(zn/tn)*100}; 1297 1298 TGraph* gr_pos = new TGraph(2, &t_pos[0], &z_pos[0]); 1299 gr_pos->SetLineColor(8); 1300 gr_pos->SetMarkerColor(8); 1301 gr_pos->Draw("PL"); 1302 TGraph* gr_neg = new TGraph(2, &t_neg[0], &z_neg[0]); 1303 gr_neg->SetLineColor(4); 1304 gr_neg->SetMarkerColor(4); 1305 gr_neg->Draw("PL"); 1306 1307 1308 c_2Dspace->SetGrid(); 1309 c_2Dspace->SaveAs(fFigFolderPath + Form("/crush_splitting.png")); 1310 1311 delete c_2Dspace; 1312 } -
modules/VertexFinderDA4D.h
r2d7ff18 r83ee320 6 6 * Cluster vertices from tracks using deterministic annealing and timing information 7 7 * 8 * \authors M. Selvaggi, L. Gray8 * Author O. Cerri 9 9 * 10 10 */ … … 13 13 14 14 #include <vector> 15 #include <iostream> 15 16 16 17 class TObjArray; … … 20 21 class VertexFinderDA4D: public DelphesModule 21 22 { 22 public: 23 VertexFinderDA4D(); 24 ~VertexFinderDA4D(); 25 26 void Init(); 27 void Process(); 28 void Finish(); 29 30 void clusterize(const TObjArray &tracks, TObjArray &clusters); 31 std::vector<Candidate *> vertices(); 32 33 private: 34 Bool_t fVerbose; 35 Double_t fMinPT; 36 37 Float_t fVertexSpaceSize; 38 Float_t fVertexTimeSize; 39 Bool_t fUseTc; 40 Float_t fBetaMax; 41 Float_t fBetaStop; 42 Double_t fCoolingFactor; 43 Int_t fMaxIterations; 44 Double_t fDzCutOff; 45 Double_t fD0CutOff; 46 Double_t fDtCutOff; // for when the beamspot has time 47 48 TObjArray *fInputArray; 49 TIterator *fItInputArray; 50 51 TObjArray *fOutputArray; 52 TObjArray *fVertexOutputArray; 53 54 ClassDef(VertexFinderDA4D, 1) 23 public: 24 25 class tracks_t 26 { 27 public: 28 std::vector<double> z; // z-coordinate at point of closest approach to the beamline [mm] 29 std::vector<double> r; // z-coordinate at point of closest approach to the beamline [mm] 30 31 std::vector<double> t; // t-coordinate at point of closest approach to the beamline [ps] 32 33 std::vector<double> dz2_o; //1 over the squared error of z(pca) 34 std::vector<double> dz_o; 35 std::vector<double> dt2_o; //1 over the squared error of t(pca) 36 std::vector<double> dt_o; 37 38 std::vector<Candidate*> tt; // a pointer to the Candidate Track 39 std::vector<double> Z; // Normalization of P(y|x) = p_k * exp(-beta*E_ik)/Z_i 40 41 std::vector<double> w; // track weight 42 43 // std::vector<double> pt; 44 // std::vector<double> pz; 45 46 std::vector<int> PID; 47 48 double sum_w_o_dz2 = 0; 49 double sum_w_o_dt2 = 0; 50 double sum_w = 0; 51 52 tracks_t(){} 53 ~tracks_t(){} 54 55 void addItem( double new_z, double new_t, double new_dz2_o, double new_dt2_o, Candidate * new_tt, double new_w, int new_PID) 56 { 57 z.push_back( new_z ); 58 t.push_back( new_t ); 59 dz2_o.push_back( new_dz2_o ); 60 dz_o.push_back( sqrt(new_dz2_o) ); 61 dt2_o.push_back( new_dt2_o ); 62 dt_o.push_back( sqrt(new_dt2_o) ); 63 tt.push_back( new_tt ); 64 65 w.push_back( new_w ); 66 Z.push_back( 1.0 ); 67 68 PID.push_back(new_PID); 69 } 70 71 unsigned int getSize() 72 { 73 return z.size(); 74 } 75 76 }; 77 78 class vertex_t 79 { 80 public: 81 std::vector<double> z; // z coordinate 82 std::vector<double> t; // t coordinate 83 std::vector<double> pk; // vertex weight for "constrained" clustering 84 85 // Elements of the covariance matrix of the posterior distribution 86 std::vector<double> szz, stt, stz; 87 std::vector<double> beta_c; 88 89 double ZSize; 90 double TSize; 91 92 // Used in the tracks-cluster assignment 93 double sum_pt; 94 std::vector<unsigned int> i_tracks; 95 96 97 vertex_t(){} 98 ~vertex_t(){} 99 100 void addItem( double new_z, double new_t, double new_pk) 101 { 102 z.push_back( new_z); 103 t.push_back( new_t); 104 pk.push_back( new_pk); 105 106 szz.push_back(0); 107 stt.push_back(0); 108 stz.push_back(0); 109 beta_c.push_back(0); 110 } 111 112 void removeItem( unsigned int i ) 113 { 114 z.erase( z.begin() + i ); 115 t.erase( t.begin() + i ); 116 pk.erase( pk.begin() + i ); 117 118 szz.erase(szz.begin() + i); 119 stt.erase(stt.begin() + i); 120 stz.erase(stz.begin() + i); 121 beta_c.erase(beta_c.begin() + i); 122 } 123 124 void mergeItems(unsigned int k1, unsigned int k2) 125 { 126 double new_pk = pk[k1] + pk[k2]; 127 double new_z = (z[k1]*pk[k1] + z[k2]*pk[k2])/new_pk; 128 double new_t = (t[k1]*pk[k1] + t[k2]*pk[k2])/new_pk; 129 130 removeItem(k2); 131 z[k1] = new_z; 132 t[k1] = new_t; 133 pk[k1] = new_pk; 134 } 135 136 unsigned int getSize() const 137 { 138 return z.size(); 139 } 140 141 double DistanceSquare(unsigned int k1, unsigned int k2) 142 { 143 double dz = (z[k1] - z[k2])/ZSize; 144 double dt = (t[k1] - t[k2])/TSize; 145 146 return dz*dz + dt*dt; 147 } 148 149 unsigned int NearestCluster(double t_, double z_) 150 { 151 unsigned int k_min = 0; 152 double d2_min = 0; 153 154 for(unsigned int k = 0; k < getSize(); k++) 155 { 156 double dt = (t[k] - t_)/TSize; 157 double dz = (z[k] - z_)/ZSize; 158 double d2 = dt*dt + dz*dz; 159 if(k == 0 || d2 < d2_min) 160 { 161 k_min = k; 162 d2_min = d2; 163 } 164 } 165 166 return k_min; 167 } 168 169 std::pair<double, unsigned int> ComputeAllBeta_c(unsigned int verbose = 0) 170 { 171 unsigned int nv = getSize(); 172 unsigned int k_min = 0; 173 double beta_c_min = 0; 174 for(unsigned int k = 0; k < nv; k++) 175 { 176 if(szz[k] == 0 || stt[k] == 0) 177 { 178 beta_c[k] = 1000; 179 if(verbose>5) 180 { 181 std::cout << std::endl << Form("Varianca too small! beta_c set to 1000\nVertex %d: t=%1.2e, z=%1.2e, pk=%1.2e, szz=%1.2e, stt=%1.2e, stz=%1.2e", k, t[k], z[k], pk[k], szz[k], stt[k], stz[k]); 182 // throw std::invalid_argument( "Attempting to compute beta c for uninitialized vertex" ); 183 } 184 } 185 186 double aux = (stt[k] - szz[k])*(stt[k] - szz[k]) + 4*stz[k]*stz[k]; 187 aux = 1. / (stt[k] + szz[k] + sqrt(aux)); 188 189 if(k == 0 || aux < beta_c_min) 190 { 191 beta_c_min = aux; 192 k_min = k; 193 } 194 195 beta_c[k] = aux; 196 } 197 198 std::pair<double, unsigned int> out(beta_c_min, k_min); 199 return out; 200 } 201 }; 202 203 VertexFinderDA4D(); 204 ~VertexFinderDA4D(); 205 206 void Init(); 207 void Process(); 208 void Finish(); 209 210 void clusterize(TObjArray &clusters); 211 212 // Define the distance metric between tracks and vertices 213 double Energy(double t_z, double v_z, double dz2_o, double t_t, double v_t, double dt2_o); 214 215 // Fill the tracks structure from the input array 216 void fill(tracks_t &tks); 217 218 // Compute higher phase transition temperature 219 double beta0(tracks_t & tks, vertex_t &vtx); 220 221 // Compute the new vertexes position and mass 222 double update(double beta, tracks_t &tks, vertex_t &vtx, double rho0); 223 224 // If a vertex has beta_c lower than beta, split it 225 bool split(double &beta, vertex_t & vtx, tracks_t & tks); 226 227 // Merge vertexes closer than declared dimensions 228 bool merge(vertex_t & vtx, double d2_merge); 229 230 // Eliminate clusters with only one significant/unique track 231 bool purge(vertex_t & vtx, tracks_t & tks, double & rho0, const double beta, double min_prob, double min_trk); 232 233 // Compute all the energies and set the partition function normalization for each track 234 std::vector<double> Compute_pk_exp_mBetaE(double beta, vertex_t &vtx, tracks_t &tks, double Z_init); 235 236 // Plot status of tracks and Vertices 237 void plot_status(double beta, vertex_t &vtx, tracks_t &tks, int n_it = 0, const char* flag =""); 238 239 // Plot status at the end of the fitting 240 void plot_status_end(vertex_t &vtx, tracks_t &tks); 241 242 // Plot Crush 243 void plot_split_crush(double zn, double tn, vertex_t &vtx, tracks_t &tks, int i_vtx); 244 245 246 private: 247 248 unsigned int fVerbose; 249 250 UInt_t fMaxIterations; 251 UInt_t fMaxVertexNumber; 252 253 Float_t fBetaMax; 254 Float_t fBetaStop; 255 Float_t fBetaPurge; 256 257 258 Float_t fVertexZSize; 259 Float_t fVertexTSize; 260 261 Double_t fCoolingFactor; 262 263 Double_t fDzCutOff; 264 Double_t fD0CutOff; 265 Double_t fDtCutOff; 266 Double_t fPtMin; 267 Double_t fPtMax; 268 269 Double_t fD2UpdateLim; 270 Double_t fD2Merge; 271 Double_t fMuOutlayer; 272 Double_t fMinTrackProb; 273 Int_t fMinNTrack; 274 275 TObjArray *fInputArray; 276 TIterator *fItInputArray; 277 278 TObjArray *fTrackOutputArray; 279 TObjArray *fVertexOutputArray; 280 281 ClassDef(VertexFinderDA4D, 1) 282 283 //Used to keep track of number of verices in verbose mode 284 std::vector<double> fEnergy_rec; 285 std::vector<double> fBeta_rec; 286 std::vector<double> fNvtx_rec; 287 288 // Debug purpose only 289 TObjArray *fInputGenVtx; 290 TIterator *fItInputGenVtx; 291 292 TString fFigFolderPath = ""; 55 293 }; 56 294 -
readers/DelphesPythia8.cpp
r2d7ff18 r83ee320 122 122 123 123 pdgParticle = pdg->GetParticle(pid); 124 candidate->Charge = pdgParticle ? Int_t(pdgParticle->Charge() / 3.0) : -999; 124 125 if(pdgParticle) 126 { 127 candidate->Charge = int(pdgParticle->Charge()/3.0); 128 } 129 else if(abs(pid) == 1000612) candidate->Charge = TMath::Sign(1, pid); 130 else if(abs(pid) == 1000622) candidate->Charge = 0; 131 else if(abs(pid) == 1000632) candidate->Charge = TMath::Sign(1, pid); 132 else if(abs(pid) == 1000642) candidate->Charge = 0; 133 else if(abs(pid) == 1000652) candidate->Charge = TMath::Sign(1, pid); 134 else if(abs(pid) == 1006113) candidate->Charge = 0; 135 else if(abs(pid) == 1006211) candidate->Charge = TMath::Sign(1, pid); 136 else if(abs(pid) == 1006213) candidate->Charge = TMath::Sign(1, pid); 137 else if(abs(pid) == 1006223) candidate->Charge = TMath::Sign(2, pid); 138 else if(abs(pid) == 1006311) candidate->Charge = 0; 139 else if(abs(pid) == 1006313) candidate->Charge = 0; 140 else if(abs(pid) == 1006321) candidate->Charge = TMath::Sign(1, pid); 141 else if(abs(pid) == 1006323) candidate->Charge = TMath::Sign(1, pid); 142 else if(abs(pid) == 1006333) candidate->Charge = 0; 143 else { 144 candidate->Charge = -999; 145 cout << "[WARNING] Unrecognised particle. PID: " << pid << endl; 146 } 147 125 148 candidate->Mass = mass; 126 149 … … 128 151 129 152 candidate->Position.SetXYZT(x, y, z, t); 130 131 153 allParticleOutputArray->Add(candidate); 132 154 133 if(!pdgParticle) continue; 155 if(!pdgParticle && (abs(pid) > 1006333 || abs(pid) < 1000612) ) 156 continue; 134 157 135 158 if(status == 1)
Note:
See TracChangeset
for help on using the changeset viewer.