00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include <stdlib.h>
00013 #include <string.h>
00014 #include <stdio.h>
00015 #include <ctype.h>
00016
00017 #include "Riostream.h"
00018 #include "TROOT.h"
00019 #include "TClass.h"
00020 #include "TSystem.h"
00021 #include "THistPainter.h"
00022 #include "TH2.h"
00023 #include "TH2Poly.h"
00024 #include "TH3.h"
00025 #include "TProfile.h"
00026 #include "THStack.h"
00027 #include "TF2.h"
00028 #include "TF3.h"
00029 #include "TCutG.h"
00030 #include "TMatrixDBase.h"
00031 #include "TMatrixFBase.h"
00032 #include "TVectorD.h"
00033 #include "TVectorF.h"
00034 #include "TPad.h"
00035 #include "TPaveStats.h"
00036 #include "TFrame.h"
00037 #include "TLatex.h"
00038 #include "TLine.h"
00039 #include "TPolyLine.h"
00040 #include "TPoints.h"
00041 #include "TStyle.h"
00042 #include "TGraph.h"
00043 #include "TMultiGraph.h"
00044 #include "TPie.h"
00045 #include "TGaxis.h"
00046 #include "TColor.h"
00047 #include "TPainter3dAlgorithms.h"
00048 #include "TGraph2DPainter.h"
00049 #include "TGraphDelaunay.h"
00050 #include "TView.h"
00051 #include "TMath.h"
00052 #include "TRandom.h"
00053 #include "TObjArray.h"
00054 #include "TVectorD.h"
00055 #include "Hoption.h"
00056 #include "Hparam.h"
00057 #include "TPluginManager.h"
00058 #include "TPaletteAxis.h"
00059 #include "TCrown.h"
00060 #include "TVirtualPadEditor.h"
00061 #include "TEnv.h"
00062 #include "TPoint.h"
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330
02331
02332
02333
02334
02335
02336
02337
02338
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441
02442
02443
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478
02479
02480
02481
02482
02483
02484
02485
02486
02487
02488
02489
02490
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525
02526
02527
02528
02529
02530
02531
02532
02533
02534
02535
02536
02537
02538
02539
02540
02541
02542
02543
02544
02545
02546
02547
02548
02549
02550
02551
02552
02553
02554
02555
02556
02557
02558
02559
02560
02561
02562
02563
02564
02565
02566
02567
02568
02569
02570
02571
02572
02573
02574
02575
02576
02577
02578
02579
02580
02581
02582
02583
02584
02585
02586
02587
02588
02589
02590
02591
02592
02593
02594
02595
02596
02597
02598
02599
02600
02601
02602
02603
02604
02605
02606
02607
02608
02609
02610
02611
02612
02613
02614
02615
02616
02617
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636
02637
02638
02639
02640
02641
02642
02643
02644
02645
02646
02647
02648
02649
02650
02651
02652 TH1 *gCurrentHist = 0;
02653
02654 Hoption_t Hoption;
02655 Hparam_t Hparam;
02656
02657 const Int_t kNMAX = 2000;
02658
02659 const Int_t kMAXCONTOUR = 104;
02660 const UInt_t kCannotRotate = BIT(11);
02661
02662 static TString gStringEntries;
02663 static TString gStringMean;
02664 static TString gStringMeanX;
02665 static TString gStringMeanY;
02666 static TString gStringMeanZ;
02667 static TString gStringRMS;
02668 static TString gStringRMSX;
02669 static TString gStringRMSY;
02670 static TString gStringRMSZ;
02671 static TString gStringUnderflow;
02672 static TString gStringOverflow;
02673 static TString gStringIntegral;
02674 static TString gStringSkewness;
02675 static TString gStringSkewnessX;
02676 static TString gStringSkewnessY;
02677 static TString gStringSkewnessZ;
02678 static TString gStringKurtosis;
02679 static TString gStringKurtosisX;
02680 static TString gStringKurtosisY;
02681 static TString gStringKurtosisZ;
02682
02683 ClassImp(THistPainter)
02684
02685
02686
02687 THistPainter::THistPainter()
02688 {
02689
02690
02691
02692
02693 fH = 0;
02694 fXaxis = 0;
02695 fYaxis = 0;
02696 fZaxis = 0;
02697 fFunctions = 0;
02698 fXbuf = 0;
02699 fYbuf = 0;
02700 fNcuts = 0;
02701 fStack = 0;
02702 fLego = 0;
02703 fPie = 0;
02704 fGraph2DPainter = 0;
02705 fShowProjection = 0;
02706 fShowOption = "";
02707 for (int i=0; i<kMaxCuts; i++) {
02708 fCuts[i] = 0;
02709 fCutsOpt[i] = 0;
02710 }
02711
02712 gStringEntries = gEnv->GetValue("Hist.Stats.Entries", "Entries");
02713 gStringMean = gEnv->GetValue("Hist.Stats.Mean", "Mean");
02714 gStringMeanX = gEnv->GetValue("Hist.Stats.MeanX", "Mean x");
02715 gStringMeanY = gEnv->GetValue("Hist.Stats.MeanY", "Mean y");
02716 gStringMeanZ = gEnv->GetValue("Hist.Stats.MeanZ", "Mean z");
02717 gStringRMS = gEnv->GetValue("Hist.Stats.RMS", "RMS");
02718 gStringRMSX = gEnv->GetValue("Hist.Stats.RMSX", "RMS x");
02719 gStringRMSY = gEnv->GetValue("Hist.Stats.RMSY", "RMS y");
02720 gStringRMSZ = gEnv->GetValue("Hist.Stats.RMSZ", "RMS z");
02721 gStringUnderflow = gEnv->GetValue("Hist.Stats.Underflow", "Underflow");
02722 gStringOverflow = gEnv->GetValue("Hist.Stats.Overflow", "Overflow");
02723 gStringIntegral = gEnv->GetValue("Hist.Stats.Integral", "Integral");
02724 gStringSkewness = gEnv->GetValue("Hist.Stats.Skewness", "Skewness");
02725 gStringSkewnessX = gEnv->GetValue("Hist.Stats.SkewnessX", "Skewness x");
02726 gStringSkewnessY = gEnv->GetValue("Hist.Stats.SkewnessY", "Skewness y");
02727 gStringSkewnessZ = gEnv->GetValue("Hist.Stats.SkewnessZ", "Skewness z");
02728 gStringKurtosis = gEnv->GetValue("Hist.Stats.Kurtosis", "Kurtosis");
02729 gStringKurtosisX = gEnv->GetValue("Hist.Stats.KurtosisX", "Kurtosis x");
02730 gStringKurtosisY = gEnv->GetValue("Hist.Stats.KurtosisY", "Kurtosis y");
02731 gStringKurtosisZ = gEnv->GetValue("Hist.Stats.KurtosisZ", "Kurtosis z");
02732 }
02733
02734
02735
02736 THistPainter::~THistPainter()
02737 {
02738
02739
02740
02741 }
02742
02743
02744
02745 Int_t THistPainter::DistancetoPrimitive(Int_t px, Int_t py)
02746 {
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757
02758 const Int_t big = 9999;
02759 const Int_t kMaxDiff = 7;
02760
02761 if (fPie) return fPie->DistancetoPrimitive(px, py);
02762
02763 Double_t x = gPad->AbsPixeltoX(px);
02764 Double_t x1 = gPad->AbsPixeltoX(px+1);
02765
02766 Int_t puxmin = gPad->XtoAbsPixel(gPad->GetUxmin());
02767 Int_t puymin = gPad->YtoAbsPixel(gPad->GetUymin());
02768 Int_t puxmax = gPad->XtoAbsPixel(gPad->GetUxmax());
02769 Int_t puymax = gPad->YtoAbsPixel(gPad->GetUymax());
02770 Int_t curdist = big;
02771 Int_t yxaxis, dyaxis,xyaxis, dxaxis;
02772 Bool_t dsame;
02773 TString doption = gPad->GetPadPointer()->GetDrawOption();
02774 Double_t factor = 1;
02775 if (fH->GetNormFactor() != 0) {
02776 factor = fH->GetNormFactor()/fH->GetSumOfWeights();
02777 }
02778
02779
02780
02781 TView *view = gPad->GetView();
02782 Int_t d1,d2,d3;
02783 if (view && Hoption.Contour != 14) {
02784 Double_t ratio;
02785 d3 = view->GetDistancetoAxis(3, px, py, ratio);
02786 if (d3 <= kMaxDiff) {gPad->SetSelected(fZaxis); return 0;}
02787 d1 = view->GetDistancetoAxis(1, px, py, ratio);
02788 if (d1 <= kMaxDiff) {gPad->SetSelected(fXaxis); return 0;}
02789 d2 = view->GetDistancetoAxis(2, px, py, ratio);
02790 if (d2 <= kMaxDiff) {gPad->SetSelected(fYaxis); return 0;}
02791 if ( px > puxmin && px < puxmax && py > puymax && py < puymin) curdist = 1;
02792 goto FUNCTIONS;
02793 }
02794
02795 doption.ToLower();
02796 dsame = kFALSE;
02797 if (doption.Contains("same")) dsame = kTRUE;
02798
02799 dyaxis = Int_t(2*(puymin-puymax)*fYaxis->GetLabelSize());
02800 if (doption.Contains("y+")) {
02801 xyaxis = puxmax + Int_t((puxmax-puxmin)*fYaxis->GetLabelOffset());
02802 if (px <= xyaxis+dyaxis && px >= xyaxis && py >puymax && py < puymin) {
02803 if (!dsame) {
02804 if (gPad->IsVertical()) gPad->SetSelected(fYaxis);
02805 else gPad->SetSelected(fXaxis);
02806 return 0;
02807 }
02808 }
02809 } else {
02810 xyaxis = puxmin - Int_t((puxmax-puxmin)*fYaxis->GetLabelOffset());
02811 if (px >= xyaxis-dyaxis && px <= xyaxis && py >puymax && py < puymin) {
02812 if (!dsame) {
02813 if (gPad->IsVertical()) gPad->SetSelected(fYaxis);
02814 else gPad->SetSelected(fXaxis);
02815 return 0;
02816 }
02817 }
02818 }
02819
02820 dxaxis = Int_t((puymin-puymax)*fXaxis->GetLabelSize());
02821 if (doption.Contains("x+")) {
02822 yxaxis = puymax - Int_t((puymin-puymax)*fXaxis->GetLabelOffset());
02823 if (py >= yxaxis-dxaxis && py <= yxaxis && px <puxmax && px > puxmin) {
02824 if (!dsame) {
02825 if (gPad->IsVertical()) gPad->SetSelected(fXaxis);
02826 else gPad->SetSelected(fYaxis);
02827 return 0;
02828 }
02829 }
02830 } else {
02831 yxaxis = puymin + Int_t((puymin-puymax)*fXaxis->GetLabelOffset());
02832 if (yxaxis < puymin) yxaxis = puymin;
02833 if (py <= yxaxis+dxaxis && py >= yxaxis && px <puxmax && px > puxmin) {
02834 if (!dsame) {
02835 if (gPad->IsVertical()) gPad->SetSelected(fXaxis);
02836 else gPad->SetSelected(fYaxis);
02837 return 0;
02838 }
02839 }
02840 }
02841
02842
02843 if (fH->GetDimension() == 2) {
02844 if (fH->InheritsFrom(TH2Poly::Class())) {
02845 TH2Poly *th2 = (TH2Poly*)fH;
02846 Int_t bin = th2->FindBin(gPad->AbsPixeltoX(px), gPad->AbsPixeltoY(py));
02847 if (bin>0) {curdist =1; goto FUNCTIONS;}
02848 else return big;
02849 }
02850 Int_t delta2 = 5;
02851 if ( px > puxmin + delta2
02852 && px < puxmax - delta2
02853 && py > puymax + delta2
02854 && py < puymin - delta2) {curdist =1; goto FUNCTIONS;}
02855 }
02856
02857
02858 if (gPad->IsVertical()) {
02859 Int_t bin = fXaxis->FindFixBin(gPad->PadtoX(x));
02860 Int_t binsup = fXaxis->FindFixBin(gPad->PadtoX(x1));
02861 Double_t binval = factor*fH->GetBinContent(bin);
02862 Int_t pybin = gPad->YtoAbsPixel(gPad->YtoPad(binval));
02863 if (binval == 0 && pybin < puymin) pybin = 10000;
02864
02865 if (binsup-bin>1) {
02866 Double_t binvalmin, binvalmax;
02867 binvalmin=binval;
02868 binvalmax=binval;
02869 for (Int_t ibin=bin+1; ibin<binsup; ibin++) {
02870 Double_t binvaltmp = factor*fH->GetBinContent(ibin);
02871 if (binvalmin>binvaltmp) binvalmin=binvaltmp;
02872 if (binvalmax<binvaltmp) binvalmax=binvaltmp;
02873 }
02874 Int_t pybinmin = gPad->YtoAbsPixel(gPad->YtoPad(binvalmax));
02875 Int_t pybinmax = gPad->YtoAbsPixel(gPad->YtoPad(binvalmin));
02876 if (py<pybinmax+kMaxDiff/2 && py>pybinmin-kMaxDiff/2) pybin = py;
02877 }
02878 if (TMath::Abs(py - pybin) <= kMaxDiff) return TMath::Abs(py - pybin);
02879 } else {
02880 Double_t y = gPad->AbsPixeltoY(py);
02881 Double_t y1 = gPad->AbsPixeltoY(py+1);
02882 Int_t bin = fXaxis->FindFixBin(gPad->PadtoY(y));
02883 Int_t binsup = fXaxis->FindFixBin(gPad->PadtoY(y1));
02884 Double_t binval = factor*fH->GetBinContent(bin);
02885 Int_t pxbin = gPad->XtoAbsPixel(gPad->XtoPad(binval));
02886 if (binval == 0 && pxbin > puxmin) pxbin = 10000;
02887
02888 if (binsup-bin>1) {
02889 Double_t binvalmin, binvalmax;
02890 binvalmin=binval;
02891 binvalmax=binval;
02892 for (Int_t ibin=bin+1; ibin<binsup; ibin++) {
02893 Double_t binvaltmp = factor*fH->GetBinContent(ibin);
02894 if (binvalmin>binvaltmp) binvalmin=binvaltmp;
02895 if (binvalmax<binvaltmp) binvalmax=binvaltmp;
02896 }
02897 Int_t pxbinmin = gPad->XtoAbsPixel(gPad->XtoPad(binvalmax));
02898 Int_t pxbinmax = gPad->XtoAbsPixel(gPad->XtoPad(binvalmin));
02899 if (px<pxbinmax+kMaxDiff/2 && px>pxbinmin-kMaxDiff/2) pxbin = px;
02900 }
02901 if (TMath::Abs(px - pxbin) <= kMaxDiff) return TMath::Abs(px - pxbin);
02902 }
02903
02904 FUNCTIONS:
02905 TObject *f;
02906 TIter next(fFunctions);
02907 while ((f = (TObject*) next())) {
02908 Int_t dist;
02909 if (f->InheritsFrom(TF1::Class())) dist = f->DistancetoPrimitive(-px,py);
02910 else dist = f->DistancetoPrimitive(px,py);
02911 if (dist < kMaxDiff) {gPad->SetSelected(f); return dist;}
02912 }
02913 return curdist;
02914 }
02915
02916
02917
02918 void THistPainter::DrawPanel()
02919 {
02920
02921
02922
02923
02924 gCurrentHist = fH;
02925 if (!gPad) {
02926 Error("DrawPanel", "need to draw histogram first");
02927 return;
02928 }
02929 TVirtualPadEditor *editor = TVirtualPadEditor::GetPadEditor();
02930 editor->Show();
02931 gROOT->ProcessLine(Form("((TCanvas*)0x%lx)->Selected((TVirtualPad*)0x%lx,(TObject*)0x%lx,1)",
02932 (ULong_t)gPad->GetCanvas(), (ULong_t)gPad, (ULong_t)fH));
02933 }
02934
02935
02936
02937 void THistPainter::ExecuteEvent(Int_t event, Int_t px, Int_t py)
02938 {
02939
02940
02941
02942
02943
02944
02945
02946 static Int_t bin, px1, py1, px2, py2, pyold;
02947 Double_t xlow, xup, ylow, binval, x, baroffset, barwidth, binwidth;
02948
02949 if (!gPad->IsEditable()) return;
02950
02951 if (fPie) {
02952 fPie->ExecuteEvent(event, px, py);
02953 return;
02954 }
02955
02956 TView *view = gPad->GetView();
02957
02958 if (!fShowProjection && view && view->TestBit(kCannotRotate) == 0) {
02959 view->ExecuteRotateView(event, px, py);
02960 return;
02961 }
02962
02963 Double_t factor = 1;
02964 if (fH->GetNormFactor() != 0) {
02965 factor = fH->GetNormFactor()/fH->GetSumOfWeights();
02966 }
02967
02968 switch (event) {
02969
02970 case kButton1Down:
02971
02972 gVirtualX->SetLineColor(-1);
02973 fH->TAttLine::Modify();
02974
02975
02976
02977 case kMouseMotion:
02978
02979 if (fShowProjection) {ShowProjection3(px,py); break;}
02980
02981 if (Hoption.Bar) {
02982 baroffset = fH->GetBarOffset();
02983 barwidth = fH->GetBarWidth();
02984 } else {
02985 baroffset = 0;
02986 barwidth = 1;
02987 }
02988 x = gPad->AbsPixeltoX(px);
02989 bin = fXaxis->FindFixBin(gPad->PadtoX(x));
02990 binwidth = fH->GetBinWidth(bin);
02991 xlow = gPad->XtoPad(fH->GetBinLowEdge(bin) + baroffset*binwidth);
02992 xup = gPad->XtoPad(xlow + barwidth*binwidth);
02993 ylow = gPad->GetUymin();
02994 px1 = gPad->XtoAbsPixel(xlow);
02995 px2 = gPad->XtoAbsPixel(xup);
02996 py1 = gPad->YtoAbsPixel(ylow);
02997 py2 = py;
02998 pyold = py;
02999 if (gROOT->GetEditHistograms()) gPad->SetCursor(kArrowVer);
03000 else gPad->SetCursor(kPointer);
03001
03002 break;
03003
03004 case kButton1Motion:
03005
03006 if (gROOT->GetEditHistograms()) {
03007 gVirtualX->DrawBox(px1, py1, px2, py2,TVirtualX::kHollow);
03008 py2 += py - pyold;
03009 gVirtualX->DrawBox(px1, py1, px2, py2,TVirtualX::kHollow);
03010 pyold = py;
03011 }
03012
03013 break;
03014
03015 case kButton1Up:
03016
03017 if (gROOT->GetEditHistograms()) {
03018 binval = gPad->PadtoY(gPad->AbsPixeltoY(py2))/factor;
03019 fH->SetBinContent(bin,binval);
03020 PaintInit();
03021 }
03022
03023
03024 RecalculateRange();
03025
03026 gPad->Modified(kTRUE);
03027 gVirtualX->SetLineColor(-1);
03028
03029 break;
03030
03031 case kButton1Locate:
03032
03033 ExecuteEvent(kButton1Down, px, py);
03034
03035 while (1) {
03036 px = py = 0;
03037 event = gVirtualX->RequestLocator(1, 1, px, py);
03038
03039 ExecuteEvent(kButton1Motion, px, py);
03040
03041 if (event != -1) {
03042 ExecuteEvent(kButton1Up, px, py);
03043 return;
03044 }
03045 }
03046 }
03047 }
03048
03049
03050 TList *THistPainter::GetContourList(Double_t contour) const
03051 {
03052
03053
03054
03055
03056 TGraphDelaunay *dt;
03057
03058
03059 TList *hl = fH->GetListOfFunctions();
03060 dt = (TGraphDelaunay*)hl->FindObject("TGraphDelaunay");
03061 if (!dt) return 0;
03062
03063 gCurrentHist = fH;
03064
03065 if (!fGraph2DPainter) ((THistPainter*)this)->fGraph2DPainter = new TGraph2DPainter(dt);
03066
03067 return fGraph2DPainter->GetContourList(contour);
03068 }
03069
03070
03071
03072 char *THistPainter::GetObjectInfo(Int_t px, Int_t py) const
03073 {
03074
03075
03076
03077
03078
03079 if (!gPad) return (char*)"";
03080 static char info[100];
03081 Double_t x = gPad->PadtoX(gPad->AbsPixeltoX(px));
03082 Double_t y = gPad->PadtoY(gPad->AbsPixeltoY(py));
03083 Double_t x1 = gPad->PadtoX(gPad->AbsPixeltoX(px+1));
03084 const char *drawOption = fH->GetDrawOption();
03085 Double_t xmin, xmax, uxmin,uxmax;
03086 Double_t ymin, ymax, uymin,uymax;
03087 if (fH->GetDimension() == 2) {
03088 if (gPad->GetView() || strncmp(drawOption,"cont",4) == 0
03089 || strncmp(drawOption,"CONT",4) == 0) {
03090 uxmin=gPad->GetUxmin();
03091 uxmax=gPad->GetUxmax();
03092 xmin = fXaxis->GetBinLowEdge(fXaxis->GetFirst());
03093 xmax = fXaxis->GetBinUpEdge(fXaxis->GetLast());
03094 x = xmin +(xmax-xmin)*(x-uxmin)/(uxmax-uxmin);
03095 uymin=gPad->GetUymin();
03096 uymax=gPad->GetUymax();
03097 ymin = fYaxis->GetBinLowEdge(fYaxis->GetFirst());
03098 ymax = fYaxis->GetBinUpEdge(fYaxis->GetLast());
03099 y = ymin +(ymax-ymin)*(y-uymin)/(uymax-uymin);
03100 }
03101 }
03102 Int_t binx,biny,binmin,binx1;
03103 if (gPad->IsVertical()) {
03104 binx = fXaxis->FindFixBin(x);
03105 binmin = fXaxis->GetFirst();
03106 binx1 = fXaxis->FindFixBin(x1);
03107
03108 if (binx1-binx>1 && fH->GetDimension() == 1) {
03109 Double_t binval=fH->GetBinContent(binx);
03110 Int_t binnear=binx;
03111 for (Int_t ibin=binx+1; ibin<binx1; ibin++) {
03112 Double_t binvaltmp = fH->GetBinContent(ibin);
03113 if (TMath::Abs(y-binvaltmp) < TMath::Abs(y-binval)) {
03114 binval=binvaltmp;
03115 binnear=ibin;
03116 }
03117 }
03118 binx = binnear;
03119 }
03120 } else {
03121 x1 = gPad->PadtoY(gPad->AbsPixeltoY(py+1));
03122 binx = fXaxis->FindFixBin(y);
03123 binmin = fXaxis->GetFirst();
03124 binx1 = fXaxis->FindFixBin(x1);
03125
03126 if (binx1-binx>1 && fH->GetDimension() == 1) {
03127 Double_t binval=fH->GetBinContent(binx);
03128 Int_t binnear=binx;
03129 for (Int_t ibin=binx+1; ibin<binx1; ibin++) {
03130 Double_t binvaltmp = fH->GetBinContent(ibin);
03131 if (TMath::Abs(x-binvaltmp) < TMath::Abs(x-binval)) {
03132 binval=binvaltmp;
03133 binnear=ibin;
03134 }
03135 }
03136 binx = binnear;
03137 }
03138 }
03139 if (fH->GetDimension() == 1) {
03140 Double_t integ = 0;
03141 for (Int_t bin=binmin;bin<=binx;bin++) {integ += fH->GetBinContent(bin);}
03142 snprintf(info,100,"(x=%g, y=%g, binx=%d, binc=%g, Sum=%g)",x,y,binx,fH->GetBinContent(binx),integ);
03143 } else {
03144 if (fH->InheritsFrom(TH2Poly::Class())) {
03145 TH2Poly *th2 = (TH2Poly*)fH;
03146 biny = th2->FindBin(x,y);
03147 snprintf(info,100,"%s (x=%g, y=%g, bin=%d, binc=%g)",th2->GetBinTitle(biny),x,y,biny,th2->GetBinContent(biny));
03148 } else {
03149 biny = fYaxis->FindFixBin(y);
03150 snprintf(info,100,"(x=%g, y=%g, binx=%d, biny=%d, binc=%g)",x,y,binx,biny,fH->GetCellContent(binx,biny));
03151 }
03152 }
03153 return info;
03154 }
03155
03156
03157
03158 Bool_t THistPainter::IsInside(Int_t ix, Int_t iy)
03159 {
03160
03161
03162
03163
03164 for (Int_t i=0;i<fNcuts;i++) {
03165 Double_t x = fXaxis->GetBinCenter(ix);
03166 Double_t y = fYaxis->GetBinCenter(iy);
03167 if (fCutsOpt[i] > 0) {
03168 if (!fCuts[i]->IsInside(x,y)) return kFALSE;
03169 } else {
03170 if (fCuts[i]->IsInside(x,y)) return kFALSE;
03171 }
03172 }
03173 return kTRUE;
03174 }
03175
03176
03177
03178 Bool_t THistPainter::IsInside(Double_t x, Double_t y)
03179 {
03180
03181
03182
03183
03184 for (Int_t i=0;i<fNcuts;i++) {
03185 if (fCutsOpt[i] > 0) {
03186 if (!fCuts[i]->IsInside(x,y)) return kFALSE;
03187 } else {
03188 if (fCuts[i]->IsInside(x,y)) return kFALSE;
03189 }
03190 }
03191 return kTRUE;
03192 }
03193
03194
03195
03196 Int_t THistPainter::MakeChopt(Option_t *choptin)
03197 {
03198
03199
03200
03201
03202 char *l;
03203 char chopt[128];
03204 Int_t nch = strlen(choptin);
03205 strlcpy(chopt,choptin,128);
03206
03207 Hoption.Axis = Hoption.Bar = Hoption.Curve = Hoption.Error = 0;
03208 Hoption.Hist = Hoption.Line = Hoption.Mark = Hoption.Fill = 0;
03209 Hoption.Same = Hoption.Func = Hoption.Scat = 0;
03210 Hoption.Star = Hoption.Arrow = Hoption.Box = Hoption.Text = 0;
03211 Hoption.Char = Hoption.Color = Hoption.Contour = Hoption.Logx = 0;
03212 Hoption.Logy = Hoption.Logz = Hoption.Lego = Hoption.Surf = 0;
03213 Hoption.Off = Hoption.Tri = Hoption.Proj = Hoption.AxisPos = 0;
03214 Hoption.Spec = Hoption.Pie = 0;
03215
03216
03217 Hoption.List = 0;
03218 Hoption.Zscale = 0;
03219 Hoption.FrontBox = 1;
03220 Hoption.BackBox = 1;
03221 Hoption.System = kCARTESIAN;
03222
03223 Hoption.HighRes = 0;
03224
03225 Hoption.Zero = 0;
03226
03227
03228 MakeCuts(chopt);
03229
03230 for (Int_t i=0;i<nch;i++) chopt[i] = toupper(chopt[i]);
03231 if (fH->GetDimension() > 1) Hoption.Scat = 1;
03232 if (!nch) Hoption.Hist = 1;
03233 if (fFunctions->First()) Hoption.Func = 2;
03234 if (fH->GetSumw2N() && fH->GetDimension() == 1) Hoption.Error = 2;
03235
03236 l = strstr(chopt,"SPEC");
03237 if (l) {
03238 Hoption.Scat = 0;
03239 strncpy(l," ",4);
03240 Int_t bs=0;
03241 l = strstr(chopt,"BF(");
03242 if (l) {
03243 if (sscanf(&l[3],"%d",&bs) > 0) {
03244 Int_t i=0;
03245 while (l[i]!=')') {
03246 l[i] = ' ';
03247 i++;
03248 }
03249 l[i] = ' ';
03250 }
03251 }
03252 Hoption.Spec = TMath::Max(1600,bs);
03253 return 1;
03254 }
03255
03256 l = strstr(chopt,"GL");
03257 if (l) {
03258 strncpy(l," ",2);
03259 }
03260 l = strstr(chopt,"X+");
03261 if (l) {
03262 Hoption.AxisPos = 10;
03263 strncpy(l," ",2);
03264 }
03265 l = strstr(chopt,"Y+");
03266 if (l) {
03267 Hoption.AxisPos += 1;
03268 strncpy(l," ",2);
03269 }
03270 if((Hoption.AxisPos == 10 || Hoption.AxisPos == 1) && (nch == 2)) Hoption.Hist = 1;
03271 if(Hoption.AxisPos == 11 && nch == 4) Hoption.Hist = 1;
03272
03273 l = strstr(chopt,"SAMES");
03274 if (l) {
03275 if (nch == 5) Hoption.Hist = 1;
03276 Hoption.Same = 2;
03277 strncpy(l," ",5);
03278 }
03279 l = strstr(chopt,"SAME");
03280 if (l) {
03281 if (nch == 4) Hoption.Hist = 1;
03282 Hoption.Same = 1;
03283 strncpy(l," ",4);
03284 }
03285
03286 l = strstr(chopt,"PIE");
03287 if (l) {
03288 Hoption.Pie = 1;
03289 strncpy(l," ",3);
03290 }
03291
03292 l = strstr(chopt,"LEGO");
03293 if (l) {
03294 Hoption.Scat = 0;
03295 Hoption.Lego = 1; strncpy(l," ",4);
03296 if (l[4] == '1') { Hoption.Lego = 11; l[4] = ' '; }
03297 if (l[4] == '2') { Hoption.Lego = 12; l[4] = ' '; }
03298 l = strstr(chopt,"FB"); if (l) { Hoption.FrontBox = 0; strncpy(l," ",2); }
03299 l = strstr(chopt,"BB"); if (l) { Hoption.BackBox = 0; strncpy(l," ",2); }
03300 l = strstr(chopt,"0"); if (l) { Hoption.Zero = 1; strncpy(l," ",1); }
03301 }
03302
03303 l = strstr(chopt,"SURF");
03304 if (l) {
03305 Hoption.Scat = 0;
03306 Hoption.Surf = 1; strncpy(l," ",4);
03307 if (l[4] == '1') { Hoption.Surf = 11; l[4] = ' '; }
03308 if (l[4] == '2') { Hoption.Surf = 12; l[4] = ' '; }
03309 if (l[4] == '3') { Hoption.Surf = 13; l[4] = ' '; }
03310 if (l[4] == '4') { Hoption.Surf = 14; l[4] = ' '; }
03311 if (l[4] == '5') { Hoption.Surf = 15; l[4] = ' '; }
03312 if (l[4] == '6') { Hoption.Surf = 16; l[4] = ' '; }
03313 if (l[4] == '7') { Hoption.Surf = 17; l[4] = ' '; }
03314 l = strstr(chopt,"FB"); if (l) { Hoption.FrontBox = 0; strncpy(l," ",2); }
03315 l = strstr(chopt,"BB"); if (l) { Hoption.BackBox = 0; strncpy(l," ",2); }
03316 }
03317
03318 l = strstr(chopt,"TF3");
03319 if (l) {
03320 l = strstr(chopt,"FB"); if (l) { Hoption.FrontBox = 0; strncpy(l," ",2); }
03321 l = strstr(chopt,"BB"); if (l) { Hoption.BackBox = 0; strncpy(l," ",2); }
03322 }
03323
03324 l = strstr(chopt,"ISO");
03325 if (l) {
03326 l = strstr(chopt,"FB"); if (l) { Hoption.FrontBox = 0; strncpy(l," ",2); }
03327 l = strstr(chopt,"BB"); if (l) { Hoption.BackBox = 0; strncpy(l," ",2); }
03328 }
03329
03330 l = strstr(chopt,"LIST"); if (l) { Hoption.List = 1; strncpy(l," ",4);}
03331
03332 l = strstr(chopt,"CONT");
03333 if (l) {
03334 Hoption.Scat = 0;
03335 Hoption.Contour = 1; strncpy(l," ",4);
03336 if (l[4] == '1') { Hoption.Contour = 11; l[4] = ' '; }
03337 if (l[4] == '2') { Hoption.Contour = 12; l[4] = ' '; }
03338 if (l[4] == '3') { Hoption.Contour = 13; l[4] = ' '; }
03339 if (l[4] == '4') { Hoption.Contour = 14; l[4] = ' '; }
03340 if (l[4] == '5') { Hoption.Contour = 15; l[4] = ' '; }
03341 }
03342 l = strstr(chopt,"HBAR");
03343 if (l) {
03344 Hoption.Hist = 0;
03345 Hoption.Bar = 20; strncpy(l," ",4);
03346 if (l[4] == '1') { Hoption.Bar = 21; l[4] = ' '; }
03347 if (l[4] == '2') { Hoption.Bar = 22; l[4] = ' '; }
03348 if (l[4] == '3') { Hoption.Bar = 23; l[4] = ' '; }
03349 if (l[4] == '4') { Hoption.Bar = 24; l[4] = ' '; }
03350 }
03351 l = strstr(chopt,"BAR");
03352 if (l) {
03353 Hoption.Hist = 0;
03354 Hoption.Bar = 10; strncpy(l," ",3);
03355 if (l[3] == '1') { Hoption.Bar = 11; l[3] = ' '; }
03356 if (l[3] == '2') { Hoption.Bar = 12; l[3] = ' '; }
03357 if (l[3] == '3') { Hoption.Bar = 13; l[3] = ' '; }
03358 if (l[3] == '4') { Hoption.Bar = 14; l[3] = ' '; }
03359 }
03360
03361 l = strstr(chopt,"ARR" ); if (l) { Hoption.Arrow = 1; strncpy(l," ", 3); Hoption.Scat = 0; }
03362 l = strstr(chopt,"BOX" );
03363 if (l) {
03364 Hoption.Scat = 0;
03365 Hoption.Box = 1; strncpy(l," ", 3);
03366 if (l[3] == '1') { Hoption.Box = 11; l[3] = ' '; }
03367 }
03368 l = strstr(chopt,"COLZ"); if (l) { Hoption.Color = 2; strncpy(l," ",4); Hoption.Scat = 0; Hoption.Zscale = 1;}
03369 l = strstr(chopt,"COL" ); if (l) { Hoption.Color = 1; strncpy(l," ", 3); Hoption.Scat = 0; }
03370 l = strstr(chopt,"CHAR"); if (l) { Hoption.Char = 1; strncpy(l," ",4); Hoption.Scat = 0; }
03371 l = strstr(chopt,"FUNC"); if (l) { Hoption.Func = 2; strncpy(l," ",4); Hoption.Hist = 0; }
03372 l = strstr(chopt,"HIST"); if (l) { Hoption.Hist = 2; strncpy(l," ",4); Hoption.Func = 0; Hoption.Error = 0;}
03373 l = strstr(chopt,"AXIS"); if (l) { Hoption.Axis = 1; strncpy(l," ",4); }
03374 l = strstr(chopt,"AXIG"); if (l) { Hoption.Axis = 2; strncpy(l," ",4); }
03375 l = strstr(chopt,"SCAT"); if (l) { Hoption.Scat = 1; strncpy(l," ",4); }
03376 l = strstr(chopt,"TEXT");
03377 if (l) {
03378 Int_t angle;
03379 if (sscanf(&l[4],"%d",&angle) > 0) {
03380 if (angle < 0) angle=0;
03381 if (angle > 90) angle=90;
03382 Hoption.Text = 1000+angle;
03383 } else {
03384 Hoption.Text = 1;
03385 }
03386 strncpy(l," ", 4);
03387 l = strstr(chopt,"N");
03388 if (l && fH->InheritsFrom(TH2Poly::Class())) Hoption.Text += 3000;
03389 Hoption.Scat = 0;
03390 }
03391 l = strstr(chopt,"POL"); if (l) { Hoption.System = kPOLAR; strncpy(l," ",3); }
03392 l = strstr(chopt,"CYL"); if (l) { Hoption.System = kCYLINDRICAL; strncpy(l," ",3); }
03393 l = strstr(chopt,"SPH"); if (l) { Hoption.System = kSPHERICAL; strncpy(l," ",3); }
03394 l = strstr(chopt,"PSR"); if (l) { Hoption.System = kRAPIDITY; strncpy(l," ",3); }
03395
03396 l = strstr(chopt,"TRI");
03397 if (l) {
03398 Hoption.Scat = 0;
03399 Hoption.Color = 0;
03400 Hoption.Tri = 1; strncpy(l," ",3);
03401 l = strstr(chopt,"FB"); if (l) { Hoption.FrontBox = 0; strncpy(l," ",2); }
03402 l = strstr(chopt,"BB"); if (l) { Hoption.BackBox = 0; strncpy(l," ",2); }
03403 l = strstr(chopt,"ERR"); if (l) strncpy(l," ",3);
03404 }
03405
03406 l = strstr(chopt,"AITOFF");
03407 if (l) {
03408 Hoption.Proj = 1; strncpy(l," ",6);
03409 }
03410 l = strstr(chopt,"MERCATOR");
03411 if (l) {
03412 Hoption.Proj = 2; strncpy(l," ",8);
03413 }
03414 l = strstr(chopt,"SINUSOIDAL");
03415 if (l) {
03416 Hoption.Proj = 3; strncpy(l," ",10);
03417 }
03418 l = strstr(chopt,"PARABOLIC");
03419 if (l) {
03420 Hoption.Proj = 4; strncpy(l," ",9);
03421 }
03422 if (Hoption.Proj > 0) {
03423 Hoption.Scat = 0;
03424 Hoption.Contour = 14;
03425 }
03426
03427 if (strstr(chopt,"A")) Hoption.Axis = -1;
03428 if (strstr(chopt,"B")) Hoption.Bar = 1;
03429 if (strstr(chopt,"C")) { Hoption.Curve =1; Hoption.Hist = -1;}
03430 if (strstr(chopt,"F")) Hoption.Fill =1;
03431 if (strstr(chopt,"][")) {Hoption.Off =1; Hoption.Hist =1;}
03432 if (strstr(chopt,"F2")) Hoption.Fill =2;
03433 if (strstr(chopt,"L")) { Hoption.Line =1; Hoption.Hist = -1;}
03434 if (strstr(chopt,"P")) { Hoption.Mark =1; Hoption.Hist = -1;}
03435 if (strstr(chopt,"Z")) Hoption.Zscale =1;
03436 if (strstr(chopt,"*")) Hoption.Star =1;
03437 if (strstr(chopt,"H")) Hoption.Hist =2;
03438 if (strstr(chopt,"P0")) Hoption.Mark =10;
03439
03440 if (strstr(chopt,"E")) {
03441 if (fH->GetDimension() == 1) {
03442 Hoption.Error = 1;
03443 if (strstr(chopt,"E0")) Hoption.Error = 10;
03444 if (strstr(chopt,"E1")) Hoption.Error = 11;
03445 if (strstr(chopt,"E2")) Hoption.Error = 12;
03446 if (strstr(chopt,"E3")) Hoption.Error = 13;
03447 if (strstr(chopt,"E4")) Hoption.Error = 14;
03448 if (strstr(chopt,"E5")) Hoption.Error = 15;
03449 if (strstr(chopt,"E6")) Hoption.Error = 16;
03450 if (strstr(chopt,"X0")) {
03451 if (Hoption.Error == 1) Hoption.Error += 20;
03452 Hoption.Error += 10;
03453 }
03454 if (Hoption.Text && fH->InheritsFrom(TProfile::Class())) {
03455 Hoption.Text += 2000;
03456 Hoption.Error = 0;
03457 }
03458 } else {
03459 if (Hoption.Error == 0) {
03460 Hoption.Error = 100;
03461 Hoption.Scat = 0;
03462 }
03463 if (Hoption.Text) {
03464 Hoption.Text += 2000;
03465 Hoption.Error = 0;
03466 }
03467 }
03468 }
03469
03470 if (strstr(chopt,"9")) Hoption.HighRes = 1;
03471
03472 if (Hoption.Surf == 15) {
03473 if (Hoption.System == kPOLAR || Hoption.System == kCARTESIAN) {
03474 Hoption.Surf = 13;
03475 Warning("MakeChopt","option SURF5 is not supported in Cartesian and Polar modes");
03476 }
03477 }
03478
03479
03480 Hoption.Logx = gPad->GetLogx();
03481 Hoption.Logy = gPad->GetLogy();
03482 Hoption.Logz = gPad->GetLogz();
03483
03484
03485 if (Hoption.Bar == 1) Hoption.Hist = -1;
03486 return 1;
03487 }
03488
03489
03490
03491 Int_t THistPainter::MakeCuts(char *choptin)
03492 {
03493
03494
03495
03496
03497 fNcuts = 0;
03498 char *left = (char*)strchr(choptin,'[');
03499 if (!left) return 0;
03500 char *right = (char*)strchr(choptin,']');
03501 if (!right) return 0;
03502 Int_t nch = right-left;
03503 if (nch < 2) return 0;
03504 char *cuts = left+1;
03505 *right = 0;
03506 char *comma, *minus;
03507 Int_t i;
03508 while(1) {
03509 comma = strchr(cuts,',');
03510 if (comma) *comma = 0;
03511 minus = strchr(cuts,'-');
03512 if (minus) cuts = minus+1;
03513 while (*cuts == ' ') cuts++;
03514 Int_t nc = strlen(cuts);
03515 while (cuts[nc-1] == ' ') {cuts[nc-1] = 0; nc--;}
03516 TIter next(gROOT->GetListOfSpecials());
03517 TCutG *cut=0;
03518 TObject *obj;
03519 while ((obj = next())) {
03520 if (!obj->InheritsFrom(TCutG::Class())) continue;
03521 if (strcmp(obj->GetName(),cuts)) continue;
03522 cut = (TCutG*)obj;
03523 break;
03524 }
03525 if (cut) {
03526 fCuts[fNcuts] = cut;
03527 fCutsOpt[fNcuts] = 1;
03528 if (minus) fCutsOpt[fNcuts] = -1;
03529 fNcuts++;
03530 }
03531 if (!comma) break;
03532 cuts = comma+1;
03533 }
03534 for (i=0;i<=nch;i++) left[i] = ' ';
03535 return fNcuts;
03536 }
03537
03538
03539
03540 void THistPainter::Paint(Option_t *option)
03541 {
03542
03543
03544
03545
03546 if (fH->GetBuffer()) fH->BufferEmpty(-1);
03547
03548 gPad->SetVertical(kTRUE);
03549
03550 TH1 *oldhist = gCurrentHist;
03551 gCurrentHist = fH;
03552 TH1 *hsave = fH;
03553 Double_t minsav = fH->GetMinimumStored();
03554
03555 if (!MakeChopt(option)) return;
03556
03557
03558 if (Hoption.Spec) {
03559 if (!TableInit()) return;
03560 if (!TClass::GetClass("TSpectrum2Painter")) gSystem->Load("libSpectrumPainter");
03561 gROOT->ProcessLineFast(Form("TSpectrum2Painter::PaintSpectrum((TH2F*)0x%lx,\"%s\",%d)",
03562 (ULong_t)fH, option, Hoption.Spec));
03563 return;
03564 }
03565
03566 if (Hoption.Pie) {
03567 if (!fPie) fPie = new TPie(fH);
03568 fPie->Paint(option);
03569 return;
03570 } else {
03571 if (fPie) delete fPie;
03572 fPie = 0;
03573 }
03574
03575 fXbuf = new Double_t[kNMAX];
03576 fYbuf = new Double_t[kNMAX];
03577 if (fH->GetDimension() > 2) {
03578 PaintH3(option);
03579 fH->SetMinimum(minsav);
03580 if (Hoption.Func) {
03581 Hoption_t hoptsave = Hoption;
03582 Hparam_t hparsave = Hparam;
03583 PaintFunction(option);
03584 SetHistogram(hsave);
03585 Hoption = hoptsave;
03586 Hparam = hparsave;
03587 }
03588 gCurrentHist = oldhist;
03589 delete [] fXbuf; delete [] fYbuf;
03590 return;
03591 }
03592 TView *view = gPad->GetView();
03593 if (view) {
03594 if (!Hoption.Lego && !Hoption.Surf && !Hoption.Tri) {
03595 delete view;
03596 gPad->SetView(0);
03597 }
03598 }
03599 if (fH->GetDimension() > 1 || Hoption.Lego || Hoption.Surf) {
03600
03601 Int_t logysav=0, logzsav=0;
03602 if (fH->GetDimension() == 1) {
03603 logysav = Hoption.Logy;
03604 logzsav = Hoption.Logz;
03605 Hoption.Logz = 0;
03606 if (Hoption.Logy) {
03607 Hoption.Logz = 1;
03608 Hoption.Logy = 0;
03609 }
03610 }
03611 PaintTable(option);
03612 fH->SetMinimum(minsav);
03613 if (Hoption.Func) {
03614 Hoption_t hoptsave = Hoption;
03615 Hparam_t hparsave = Hparam;
03616 PaintFunction(option);
03617 SetHistogram(hsave);
03618 Hoption = hoptsave;
03619 Hparam = hparsave;
03620 }
03621 gCurrentHist = oldhist;
03622 delete [] fXbuf; delete [] fYbuf;
03623 if (fH->GetDimension() == 1) {
03624 Hoption.Logy = logysav;
03625 Hoption.Logz = logzsav;
03626 }
03627 return;
03628 }
03629
03630 if (Hoption.Bar >= 20) {PaintBarH(option);
03631 delete [] fXbuf; delete [] fYbuf;
03632 return;
03633 }
03634
03635
03636 if (!PaintInit()) {
03637 delete [] fXbuf; delete [] fYbuf;
03638 return;
03639 }
03640
03641
03642
03643 PaintFrame();
03644
03645
03646 Bool_t gridx = gPad->GetGridx();
03647 Bool_t gridy = gPad->GetGridy();
03648 if (Hoption.Axis > 0) {
03649 if (Hoption.Axis > 1) PaintAxis(kTRUE);
03650 else {
03651 if (gridx) gPad->SetGridx(0);
03652 if (gridy) gPad->SetGridy(0);
03653 PaintAxis(kFALSE);
03654 if (gridx) gPad->SetGridx(1);
03655 if (gridy) gPad->SetGridy(1);
03656 }
03657 if (Hoption.Same ==1) Hoption.Same = 2;
03658 goto paintstat;
03659 }
03660 if (gridx || gridy) PaintAxis(kTRUE);
03661
03662
03663 if (Hoption.Bar >= 10) {
03664 PaintBar(option);
03665 }
03666
03667
03668 if (!Hoption.Error) {
03669 if (Hoption.Hist && Hoption.Bar<10) PaintHist(option);
03670 }
03671
03672
03673 if (Hoption.Error) {
03674 PaintErrors(option);
03675 if (Hoption.Hist == 2) PaintHist(option);
03676 }
03677
03678 if (Hoption.Text) PaintText(option);
03679
03680
03681 if (Hoption.Func) {
03682 Hoption_t hoptsave = Hoption;
03683 Hparam_t hparsave = Hparam;
03684 PaintFunction(option);
03685 SetHistogram(hsave);
03686 Hoption = hoptsave;
03687 Hparam = hparsave;
03688 }
03689
03690 if (gridx) gPad->SetGridx(0);
03691 if (gridy) gPad->SetGridy(0);
03692 PaintAxis(kFALSE);
03693 if (gridx) gPad->SetGridx(1);
03694 if (gridy) gPad->SetGridy(1);
03695
03696 PaintTitle();
03697
03698
03699 paintstat:
03700 if (Hoption.Same != 1 && !fH->TestBit(TH1::kNoStats)) {
03701 TIter next(fFunctions);
03702 TObject *obj = 0;
03703 while ((obj = next())) {
03704 if (obj->InheritsFrom(TF1::Class())) break;
03705 obj = 0;
03706 }
03707 PaintStat(gStyle->GetOptStat(),(TF1*)obj);
03708 }
03709 fH->SetMinimum(minsav);
03710 gCurrentHist = oldhist;
03711 delete [] fXbuf; fXbuf = 0;
03712 delete [] fYbuf; fYbuf = 0;
03713
03714 }
03715
03716
03717
03718 void THistPainter::PaintArrows(Option_t *)
03719 {
03720
03721
03722
03723
03724 Style_t linesav = fH->GetLineStyle();
03725 Width_t widthsav = fH->GetLineWidth();
03726 fH->SetLineStyle(1);
03727 fH->SetLineWidth(1);
03728 fH->TAttLine::Modify();
03729
03730 Double_t xk, xstep, yk, ystep;
03731 Double_t dx, dy, si, co, anr, x1, x2, y1, y2, xc, yc, dxn, dyn;
03732 Int_t ncx = Hparam.xlast - Hparam.xfirst + 1;
03733 Int_t ncy = Hparam.ylast - Hparam.yfirst + 1;
03734 Double_t xrg = gPad->GetUxmin();
03735 Double_t yrg = gPad->GetUymin();
03736 Double_t xln = gPad->GetUxmax() - xrg;
03737 Double_t yln = gPad->GetUymax() - yrg;
03738 Double_t cx = (xln/Double_t(ncx) -0.03)/2;
03739 Double_t cy = (yln/Double_t(ncy) -0.03)/2;
03740 Double_t dn = 1.E-30;
03741
03742 for (Int_t id=1;id<=2;id++) {
03743 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
03744 yk = fYaxis->GetBinLowEdge(j);
03745 ystep = fYaxis->GetBinWidth(j);
03746 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
03747 xk = fXaxis->GetBinLowEdge(i);
03748 xstep = fXaxis->GetBinWidth(i);
03749 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep)) continue;
03750 if (i == Hparam.xfirst) {
03751 dx = fH->GetCellContent(i+1, j) - fH->GetCellContent(i, j);
03752 } else if (i == Hparam.xlast) {
03753 dx = fH->GetCellContent(i, j) - fH->GetCellContent(i-1, j);
03754 } else {
03755 dx = 0.5*(fH->GetCellContent(i+1, j) - fH->GetCellContent(i-1, j));
03756 }
03757 if (j == Hparam.yfirst) {
03758 dy = fH->GetCellContent(i, j+1) - fH->GetCellContent(i, j);
03759 } else if (j == Hparam.ylast) {
03760 dy = fH->GetCellContent(i, j) - fH->GetCellContent(i, j-1);
03761 } else {
03762 dy = 0.5*(fH->GetCellContent(i, j+1) - fH->GetCellContent(i, j-1));
03763 }
03764 if (id == 1) {
03765 dn = TMath::Max(dn, TMath::Abs(dx));
03766 dn = TMath::Max(dn, TMath::Abs(dy));
03767 } else if (id == 2) {
03768 xc = xrg + xln*(Double_t(i - Hparam.xfirst+1)-0.5)/Double_t(ncx);
03769 dxn = cx*dx/dn;
03770 x1 = xc - dxn;
03771 x2 = xc + dxn;
03772 yc = yrg + yln*(Double_t(j - Hparam.yfirst+1)-0.5)/Double_t(ncy);
03773 dyn = cy*dy/dn;
03774 y1 = yc - dyn;
03775 y2 = yc + dyn;
03776 fXbuf[0] = x1;
03777 fXbuf[1] = x2;
03778 fYbuf[0] = y1;
03779 fYbuf[1] = y2;
03780 if (TMath::Abs(x2-x1) > 0.01 || TMath::Abs(y2-y1) > 0.01) {
03781 anr = 0.005*.5*TMath::Sqrt(2/(dxn*dxn + dyn*dyn));
03782 si = anr*(dxn + dyn);
03783 co = anr*(dxn - dyn);
03784 fXbuf[2] = x2 - si;
03785 fYbuf[2] = y2 + co;
03786 gPad->PaintPolyLine(3, fXbuf, fYbuf);
03787 fXbuf[0] = x2;
03788 fXbuf[1] = x2 - co;
03789 fYbuf[0] = y2;
03790 fYbuf[1] = y2 - si;
03791 gPad->PaintPolyLine(2, fXbuf, fYbuf);
03792 }
03793 else {
03794 gPad->PaintPolyLine(2, fXbuf, fYbuf);
03795 }
03796 }
03797 }
03798 }
03799 }
03800
03801 if (Hoption.Zscale) PaintPalette();
03802 fH->SetLineStyle(linesav);
03803 fH->SetLineWidth(widthsav);
03804 fH->TAttLine::Modify();
03805 }
03806
03807
03808
03809 void THistPainter::PaintAxis(Bool_t drawGridOnly)
03810 {
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820 if (Hoption.Axis == -1) return;
03821 if (Hoption.Same && Hoption.Axis <= 0) return;
03822
03823
03824
03825 TAxis *xaxis = 0;
03826 TAxis *yaxis = 0;
03827 if (Hoption.Same && Hoption.Axis) {
03828 if (fXaxis->GetLabels() || fYaxis->GetLabels()) {
03829 TIter next(gPad->GetListOfPrimitives());
03830 TObject *obj;
03831
03832 while ((obj = next())) {
03833 if (!obj->InheritsFrom(TH1::Class()) &&
03834 !obj->InheritsFrom(THStack::Class())) continue;
03835 TString opt = obj->GetDrawOption();
03836 opt.ToLower();
03837
03838 if (strstr(opt,"hbar")) {
03839 gPad->SetVertical(kFALSE);
03840 xaxis = fXaxis;
03841 yaxis = fYaxis;
03842 if (!strcmp(xaxis->GetName(),"xaxis")) {
03843 fXaxis = yaxis;
03844 fYaxis = xaxis;
03845 }
03846 }
03847 break;
03848 }
03849 }
03850 }
03851
03852 static char chopt[10] = "";
03853 Double_t gridl = 0;
03854 Int_t ndiv, ndivx, ndivy, nx1, nx2, ndivsave;
03855 Int_t useHparam = 0;
03856 Double_t umin, umax, uminsave, umaxsave;
03857 Short_t xAxisPos = Hoption.AxisPos/10;
03858 Short_t yAxisPos = Hoption.AxisPos - 10*xAxisPos;
03859
03860 Double_t axmin = gPad->GetUxmin();
03861 Double_t axmax = gPad->GetUxmax();
03862 Double_t aymin = gPad->GetUymin();
03863 Double_t aymax = gPad->GetUymax();
03864 char *cw = 0;
03865 TGaxis axis;
03866
03867
03868
03869 if (Hoption.Contour == 14) useHparam = 1;
03870 if (Hoption.Same) {
03871 TObject *obj;
03872 TIter next(gPad->GetListOfPrimitives());
03873 while ((obj=next())) {
03874 if (strstr(obj->GetDrawOption(),"cont4")) {
03875 useHparam = 1;
03876 break;
03877 }
03878 }
03879 }
03880
03881
03882 ndivx = fXaxis->GetNdivisions();
03883 if (ndivx > 1000) {
03884 nx2 = ndivx/100;
03885 nx1 = TMath::Max(1, ndivx%100);
03886 ndivx = 100*nx2 + Int_t(Float_t(nx1)*gPad->GetAbsWNDC());
03887 }
03888 axis.SetTextAngle(0);
03889 axis.ImportAxisAttributes(fXaxis);
03890
03891 chopt[0] = 0;
03892
03893 strlcat(chopt, "SDH",10);
03894
03895 if (ndivx < 0) strlcat(chopt, "N",10);
03896 if (gPad->GetGridx()) {
03897 gridl = (aymax-aymin)/(gPad->GetY2() - gPad->GetY1());
03898
03899 strlcat(chopt, "W",10);
03900 }
03901
03902
03903 if (Hoption.Logx) {
03904
03905 strlcat(chopt, "G",10);
03906 ndiv = TMath::Abs(ndivx);
03907 if (useHparam) {
03908 umin = TMath::Power(10,Hparam.xmin);
03909 umax = TMath::Power(10,Hparam.xmax);
03910 } else {
03911 umin = TMath::Power(10,axmin);
03912 umax = TMath::Power(10,axmax);
03913 }
03914 } else {
03915 ndiv = TMath::Abs(ndivx);
03916 if (useHparam) {
03917 umin = Hparam.xmin;
03918 umax = Hparam.xmax;
03919 } else {
03920 umin = axmin;
03921 umax = axmax;
03922 }
03923 }
03924
03925
03926 if (fXaxis->GetTimeDisplay()) {
03927
03928 strlcat(chopt,"t",10);
03929 if (strlen(fXaxis->GetTimeFormatOnly()) == 0) {
03930 axis.SetTimeFormat(fXaxis->ChooseTimeFormat(Hparam.xmax-Hparam.xmin));
03931 }
03932 }
03933
03934
03935 Double_t xAxisYPos1, xAxisYPos2;
03936 if (xAxisPos == 1) {
03937
03938 xAxisYPos1 = aymax;
03939 xAxisYPos2 = aymin;
03940 } else {
03941
03942 xAxisYPos1 = aymin;
03943 xAxisYPos2 = aymax;
03944 }
03945
03946
03947 uminsave = umin;
03948 umaxsave = umax;
03949 ndivsave = ndiv;
03950 axis.SetOption(chopt);
03951 if (xAxisPos) {
03952
03953 strlcat(chopt, "-",10);
03954 gridl = -gridl;
03955 }
03956 if (Hoption.Same && Hoption.Axis) {
03957 axis.SetLabelSize(0.);
03958 axis.SetTitle("");
03959 }
03960 axis.PaintAxis(axmin, xAxisYPos1,
03961 axmax, xAxisYPos1,
03962 umin, umax, ndiv, chopt, gridl, drawGridOnly);
03963
03964
03965 if (gPad->GetTickx()) {
03966 if (xAxisPos) {
03967 cw=strstr(chopt,"-");
03968 *cw='z';
03969 } else {
03970
03971 strlcat(chopt, "-",10);
03972 }
03973
03974 if (gPad->GetTickx() < 2) strlcat(chopt, "U",10);
03975 if ((cw=strstr(chopt,"W"))) *cw='z';
03976 axis.SetTitle("");
03977 axis.PaintAxis(axmin, xAxisYPos2,
03978 axmax, xAxisYPos2,
03979 uminsave, umaxsave, ndivsave, chopt, gridl, drawGridOnly);
03980 }
03981
03982
03983 ndivy = fYaxis->GetNdivisions();
03984 axis.ImportAxisAttributes(fYaxis);
03985
03986 chopt[0] = 0;
03987
03988 strlcat(chopt, "SDH",10);
03989
03990 if (ndivy < 0) strlcat(chopt, "N",10);
03991 if (gPad->GetGridy()) {
03992 gridl = (axmax-axmin)/(gPad->GetX2() - gPad->GetX1());
03993
03994 strlcat(chopt, "W",10);
03995 }
03996
03997
03998 if (Hoption.Logy) {
03999
04000 strlcat(chopt, "G",10);
04001 ndiv = TMath::Abs(ndivy);
04002 if (useHparam) {
04003 umin = TMath::Power(10,Hparam.ymin);
04004 umax = TMath::Power(10,Hparam.ymax);
04005 } else {
04006 umin = TMath::Power(10,aymin);
04007 umax = TMath::Power(10,aymax);
04008 }
04009 } else {
04010 ndiv = TMath::Abs(ndivy);
04011 if (useHparam) {
04012 umin = Hparam.ymin;
04013 umax = Hparam.ymax;
04014 } else {
04015 umin = aymin;
04016 umax = aymax;
04017 }
04018 }
04019
04020
04021 if (fYaxis->GetTimeDisplay()) {
04022
04023 strlcat(chopt,"t",10);
04024 if (strlen(fYaxis->GetTimeFormatOnly()) == 0) {
04025 axis.SetTimeFormat(fYaxis->ChooseTimeFormat(Hparam.ymax-Hparam.ymin));
04026 }
04027 }
04028
04029
04030 Double_t yAxisXPos1, yAxisXPos2;
04031 if (yAxisPos == 1) {
04032
04033 yAxisXPos1 = axmax;
04034 yAxisXPos2 = axmin;
04035 } else {
04036
04037 yAxisXPos1 = axmin;
04038 yAxisXPos2 = axmax;
04039 }
04040
04041
04042 uminsave = umin;
04043 umaxsave = umax;
04044 ndivsave = ndiv;
04045 axis.SetOption(chopt);
04046 if (yAxisPos) {
04047
04048 strlcat(chopt, "+L",10);
04049 gridl = -gridl;
04050 }
04051 if (Hoption.Same && Hoption.Axis) {
04052 axis.SetLabelSize(0.);
04053 axis.SetTitle("");
04054 }
04055 axis.PaintAxis(yAxisXPos1, aymin,
04056 yAxisXPos1, aymax,
04057 umin, umax, ndiv, chopt, gridl, drawGridOnly);
04058
04059
04060 if (gPad->GetTicky()) {
04061 if (gPad->GetTicky() < 2) {
04062
04063 strlcat(chopt, "U",10);
04064 axis.SetTickSize(-fYaxis->GetTickLength());
04065 } else {
04066
04067 strlcat(chopt, "+L",10);
04068 }
04069 if ((cw=strstr(chopt,"W"))) *cw='z';
04070 axis.SetTitle("");
04071 axis.PaintAxis(yAxisXPos2, aymin,
04072 yAxisXPos2, aymax,
04073 uminsave, umaxsave, ndivsave, chopt, gridl, drawGridOnly);
04074 }
04075
04076
04077 if (xaxis) {
04078 fXaxis = xaxis;
04079 fYaxis = yaxis;
04080 }
04081 }
04082
04083
04084
04085 void THistPainter::PaintBar(Option_t *)
04086 {
04087
04088
04089
04090
04091 Int_t bar = Hoption.Bar - 10;
04092 Double_t xmin,xmax,ymin,ymax,umin,umax,w,y;
04093 Double_t offset = fH->GetBarOffset();
04094 Double_t width = fH->GetBarWidth();
04095 TBox box;
04096 Int_t hcolor = fH->GetFillColor();
04097 Int_t hstyle = fH->GetFillStyle();
04098 box.SetFillColor(hcolor);
04099 box.SetFillStyle(hstyle);
04100 for (Int_t bin=fXaxis->GetFirst();bin<=fXaxis->GetLast();bin++) {
04101 y = fH->GetBinContent(bin);
04102 xmin = gPad->XtoPad(fXaxis->GetBinLowEdge(bin));
04103 xmax = gPad->XtoPad(fXaxis->GetBinUpEdge(bin));
04104 ymin = gPad->GetUymin();
04105 ymax = gPad->YtoPad(y);
04106 if (ymax < gPad->GetUymin()) continue;
04107 if (ymax > gPad->GetUymax()) ymax = gPad->GetUymax();
04108 if (ymin < gPad->GetUymin()) ymin = gPad->GetUymin();
04109 if (gStyle->GetHistMinimumZero() && ymin < 0)
04110 ymin=TMath::Min(0.,gPad->GetUymax());
04111 w = (xmax-xmin)*width;
04112 xmin += offset*(xmax-xmin);
04113 xmax = xmin + w;
04114 if (bar < 1) {
04115 box.PaintBox(xmin,ymin,xmax,ymax);
04116 } else {
04117 umin = xmin + bar*(xmax-xmin)/10.;
04118 umax = xmax - bar*(xmax-xmin)/10.;
04119
04120 box.SetFillColor(TColor::GetColorBright(hcolor));
04121 box.PaintBox(xmin,ymin,umin,ymax);
04122 box.SetFillColor(hcolor);
04123 box.PaintBox(umin,ymin,umax,ymax);
04124 box.SetFillColor(TColor::GetColorDark(hcolor));
04125 box.PaintBox(umax,ymin,xmax,ymax);
04126 }
04127 }
04128 }
04129
04130
04131
04132 void THistPainter::PaintBarH(Option_t *)
04133 {
04134
04135
04136
04137
04138 gPad->SetVertical(kFALSE);
04139
04140 PaintInitH();
04141
04142 TAxis *xaxis = fXaxis;
04143 TAxis *yaxis = fYaxis;
04144 if (!strcmp(xaxis->GetName(),"xaxis")) {
04145 fXaxis = yaxis;
04146 fYaxis = xaxis;
04147 }
04148
04149 PaintFrame();
04150
04151 Int_t bar = Hoption.Bar - 20;
04152 Double_t xmin,xmax,ymin,ymax,umin,umax,w;
04153 Double_t offset = fH->GetBarOffset();
04154 Double_t width = fH->GetBarWidth();
04155 TBox box;
04156 Int_t hcolor = fH->GetFillColor();
04157 Int_t hstyle = fH->GetFillStyle();
04158 box.SetFillColor(hcolor);
04159 box.SetFillStyle(hstyle);
04160 for (Int_t bin=fYaxis->GetFirst();bin<=fYaxis->GetLast();bin++) {
04161 ymin = gPad->YtoPad(fYaxis->GetBinLowEdge(bin));
04162 ymax = gPad->YtoPad(fYaxis->GetBinUpEdge(bin));
04163 xmin = gPad->GetUxmin();
04164 xmax = gPad->XtoPad(fH->GetBinContent(bin));
04165 if (xmax < gPad->GetUxmin()) continue;
04166 if (xmax > gPad->GetUxmax()) xmax = gPad->GetUxmax();
04167 if (xmin < gPad->GetUxmin()) xmin = gPad->GetUxmin();
04168 if (gStyle->GetHistMinimumZero() && xmin < 0)
04169 xmin=TMath::Min(0.,gPad->GetUxmax());
04170 w = (ymax-ymin)*width;
04171 ymin += offset*(ymax-ymin);
04172 ymax = ymin + w;
04173 if (bar < 1) {
04174 box.PaintBox(xmin,ymin,xmax,ymax);
04175 } else {
04176 umin = ymin + bar*(ymax-ymin)/10.;
04177 umax = ymax - bar*(ymax-ymin)/10.;
04178 box.SetFillColor(TColor::GetColorDark(hcolor));
04179 box.PaintBox(xmin,ymin,xmax,umin);
04180 box.SetFillColor(hcolor);
04181 box.PaintBox(xmin,umin,xmax,umax);
04182 box.SetFillColor(TColor::GetColorBright(hcolor));
04183 box.PaintBox(xmin,umax,xmax,ymax);
04184 }
04185 }
04186
04187 PaintTitle();
04188
04189 if (Hoption.Same != 1 && !fH->TestBit(TH1::kNoStats)) {
04190 TIter next(fFunctions);
04191 TObject *obj = 0;
04192 while ((obj = next())) {
04193 if (obj->InheritsFrom(TF1::Class())) break;
04194 obj = 0;
04195 }
04196 PaintStat(gStyle->GetOptStat(),(TF1*)obj);
04197 }
04198
04199 PaintAxis(kFALSE);
04200 fXaxis = xaxis;
04201 fYaxis = yaxis;
04202 }
04203
04204
04205
04206 void THistPainter::PaintBoxes(Option_t *)
04207 {
04208
04209
04210
04211
04212 Style_t fillsav = fH->GetFillStyle();
04213 Style_t colsav = fH->GetFillColor();
04214 if (fH->GetFillColor() == 0) fH->SetFillStyle(0);
04215 if (Hoption.Box == 11) fH->SetFillStyle(1001);
04216 fH->TAttLine::Modify();
04217 fH->TAttFill::Modify();
04218
04219 Double_t z, xk,xstep, yk, ystep, xcent, ycent, xlow, xup, ylow, yup;
04220 Double_t ux1 = gPad->PixeltoX(1);
04221 Double_t ux0 = gPad->PixeltoX(0);
04222 Double_t uy1 = gPad->PixeltoY(1);
04223 Double_t uy0 = gPad->PixeltoY(0);
04224 Double_t dxmin = 0.51*(gPad->PadtoX(ux1)-gPad->PadtoX(ux0));
04225 Double_t dymin = 0.51*(gPad->PadtoY(uy0)-gPad->PadtoY(uy1));
04226
04227 Double_t zmin = fH->GetMinimum();
04228 Double_t zmax = fH->GetMaximum();
04229
04230 if (Hoption.Logz) {
04231 if (zmin > 0) {
04232 zmin = TMath::Log10(zmin*0.1);
04233 zmax = TMath::Log10(zmax);
04234 } else {
04235 return;
04236 }
04237 } else {
04238 zmax = TMath::Max(TMath::Abs(zmin),TMath::Abs(zmax));
04239 zmin = 0;
04240 }
04241
04242
04243
04244 if (Hoption.Same) {
04245 TH2 *h2;
04246 TIter next(gPad->GetListOfPrimitives());
04247 while ((h2 = (TH2 *)next())) {
04248 if (!h2->InheritsFrom(TH2::Class())) continue;
04249 zmin = h2->GetMinimum();
04250 zmax = h2->GetMaximum();
04251 if (Hoption.Logz) {
04252 zmax = TMath::Log10(zmax);
04253 if (zmin <= 0) {
04254 zmin = TMath::Log10(zmax*0.001);
04255 } else {
04256 zmin = TMath::Log10(zmin);
04257 }
04258 }
04259 break;
04260 }
04261 }
04262
04263 Double_t zratio, dz = zmax - zmin;
04264 Bool_t kZNeg = kFALSE;
04265
04266
04267 Color_t color = fH->GetFillColor();
04268 Color_t light=0, dark=0;
04269 if (Hoption.Box == 11) {
04270 light = TColor::GetColorBright(color);
04271 dark = TColor::GetColorDark(color);
04272
04273
04274
04275
04276
04277
04278
04279
04280
04281
04282
04283
04284
04285
04286
04287
04288
04289
04290
04291 }
04292
04293
04294 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
04295 yk = fYaxis->GetBinLowEdge(j);
04296 ystep = fYaxis->GetBinWidth(j);
04297 ycent = 0.5*ystep;
04298 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
04299 Int_t bin = j*(fXaxis->GetNbins()+2) + i;
04300 xk = fXaxis->GetBinLowEdge(i);
04301 xstep = fXaxis->GetBinWidth(i);
04302 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep)) continue;
04303 xcent = 0.5*xstep;
04304 z = Hparam.factor*fH->GetBinContent(bin);
04305 kZNeg = kFALSE;
04306 if (z < 0) {
04307 if (Hoption.Logz) continue;
04308 z = -z;
04309 kZNeg = kTRUE;
04310 }
04311 if (Hoption.Logz) {
04312 if (z != 0) z = TMath::Log10(z);
04313 else z = zmin;
04314 }
04315
04316 if (z < zmin) continue;
04317 if (z > zmax) z = zmax;
04318
04319 if (dz == 0) continue;
04320 zratio = TMath::Sqrt((z-zmin)/dz);
04321 if (zratio == 0) continue;
04322
04323 xup = xcent*zratio + xk + xcent;
04324 xlow = 2*(xk + xcent) - xup;
04325 if (xup-xlow < dxmin) xup = xlow+dxmin;
04326 if (Hoption.Logx) {
04327 if (xup > 0) xup = TMath::Log10(xup);
04328 else continue;
04329 if (xlow > 0) xlow = TMath::Log10(xlow);
04330 else continue;
04331 }
04332
04333 yup = ycent*zratio + yk + ycent;
04334 ylow = 2*(yk + ycent) - yup;
04335 if (yup-ylow < dymin) yup = ylow+dymin;
04336 if (Hoption.Logy) {
04337 if (yup > 0) yup = TMath::Log10(yup);
04338 else continue;
04339 if (ylow > 0) ylow = TMath::Log10(ylow);
04340 else continue;
04341 }
04342
04343 xlow = TMath::Max(xlow, gPad->GetUxmin());
04344 ylow = TMath::Max(ylow, gPad->GetUymin());
04345 xup = TMath::Min(xup , gPad->GetUxmax());
04346 yup = TMath::Min(yup , gPad->GetUymax());
04347
04348 if (Hoption.Box == 1) {
04349 fH->SetFillColor(color);
04350 fH->TAttFill::Modify();
04351 gPad->PaintBox(xlow, ylow, xup, yup);
04352 if (kZNeg) {
04353 gPad->PaintLine(xlow, ylow, xup, yup);
04354 gPad->PaintLine(xlow, yup, xup, ylow);
04355 }
04356 } else if (Hoption.Box == 11) {
04357
04358 fH->SetFillColor(color);
04359 fH->TAttFill::Modify();
04360 gPad->PaintBox(xlow, ylow, xup, yup);
04361
04362
04363 Double_t x[7], y[7];
04364 Double_t bwidth = 0.1;
04365 x[0] = xlow; y[0] = ylow;
04366 x[1] = xlow + bwidth*(xup-xlow); y[1] = ylow + bwidth*(yup-ylow);
04367 x[2] = x[1]; y[2] = yup - bwidth*(yup-ylow);
04368 x[3] = xup - bwidth*(xup-xlow); y[3] = y[2];
04369 x[4] = xup; y[4] = yup;
04370 x[5] = xlow; y[5] = yup;
04371 x[6] = xlow; y[6] = ylow;
04372 if (kZNeg) fH->SetFillColor(dark);
04373 else fH->SetFillColor(light);
04374 fH->TAttFill::Modify();
04375 gPad->PaintFillArea(7, x, y);
04376
04377
04378 x[0] = xlow; y[0] = ylow;
04379 x[1] = xlow + bwidth*(xup-xlow); y[1] = ylow + bwidth*(yup-ylow);
04380 x[2] = xup - bwidth*(xup-xlow); y[2] = y[1];
04381 x[3] = x[2]; y[3] = yup - bwidth*(yup-ylow);
04382 x[4] = xup; y[4] = yup;
04383 x[5] = xup; y[5] = ylow;
04384 x[6] = xlow; y[6] = ylow;
04385 if (kZNeg) fH->SetFillColor(light);
04386 else fH->SetFillColor(dark);
04387 fH->TAttFill::Modify();
04388 gPad->PaintFillArea(7, x, y);
04389 }
04390 }
04391 }
04392
04393 if (Hoption.Zscale) PaintPalette();
04394 fH->SetFillStyle(fillsav);
04395 fH->SetFillColor(colsav);
04396 fH->TAttFill::Modify();
04397 }
04398
04399
04400
04401 void THistPainter::PaintColorLevels(Option_t *)
04402 {
04403
04404
04405
04406
04407 Double_t z, zc, xk, xstep, yk, ystep, xlow, xup, ylow, yup;
04408
04409 Double_t zmin = fH->GetMinimum();
04410 Double_t zmax = fH->GetMaximum();
04411
04412 Double_t dz = zmax - zmin;
04413 if (dz <= 0) {
04414 zmax += 0.1*TMath::Abs(zmax);
04415 zmin -= 0.1*TMath::Abs(zmin);
04416 dz = zmax - zmin;
04417 }
04418
04419 if (Hoption.Logz) {
04420 if (zmin > 0) {
04421 zmin = TMath::Log10(zmin);
04422 zmax = TMath::Log10(zmax);
04423 dz = zmax - zmin;
04424 } else {
04425 return;
04426 }
04427 }
04428
04429 Style_t fillsav = fH->GetFillStyle();
04430 Style_t colsav = fH->GetFillColor();
04431 fH->SetFillStyle(1001);
04432 fH->TAttFill::Modify();
04433
04434
04435 Int_t ncolors = gStyle->GetNumberOfColors();
04436 Int_t ndiv = fH->GetContour();
04437 if (ndiv == 0 ) {
04438 ndiv = gStyle->GetNumberContours();
04439 fH->SetContour(ndiv);
04440 }
04441 Int_t ndivz = TMath::Abs(ndiv);
04442 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
04443 Double_t scale = ndivz/dz;
04444
04445 Int_t color;
04446 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
04447 yk = fYaxis->GetBinLowEdge(j);
04448 ystep = fYaxis->GetBinWidth(j);
04449 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
04450 Int_t bin = j*(fXaxis->GetNbins()+2) + i;
04451 xk = fXaxis->GetBinLowEdge(i);
04452 xstep = fXaxis->GetBinWidth(i);
04453 if (Hoption.System == kPOLAR && xk<0) xk= 2*TMath::Pi()+xk;
04454 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep)) continue;
04455 z = fH->GetBinContent(bin);
04456 if (z == 0 && (zmin >= 0 || Hoption.Logz)) continue;
04457 if (Hoption.Logz) {
04458 if (z > 0) z = TMath::Log10(z);
04459 else z = zmin;
04460 }
04461 if (z < zmin) continue;
04462 xup = xk + xstep;
04463 xlow = xk;
04464 if (Hoption.Logx) {
04465 if (xup > 0) xup = TMath::Log10(xup);
04466 else continue;
04467 if (xlow > 0) xlow = TMath::Log10(xlow);
04468 else continue;
04469 }
04470 yup = yk + ystep;
04471 ylow = yk;
04472 if (Hoption.System != kPOLAR) {
04473 if (Hoption.Logy) {
04474 if (yup > 0) yup = TMath::Log10(yup);
04475 else continue;
04476 if (ylow > 0) ylow = TMath::Log10(ylow);
04477 else continue;
04478 }
04479 if (xup < gPad->GetUxmin()) continue;
04480 if (yup < gPad->GetUymin()) continue;
04481 if (xlow > gPad->GetUxmax()) continue;
04482 if (ylow > gPad->GetUymax()) continue;
04483 if (xlow < gPad->GetUxmin()) xlow = gPad->GetUxmin();
04484 if (ylow < gPad->GetUymin()) ylow = gPad->GetUymin();
04485 if (xup > gPad->GetUxmax()) xup = gPad->GetUxmax();
04486 if (yup > gPad->GetUymax()) yup = gPad->GetUymax();
04487 }
04488
04489 if (fH->TestBit(TH1::kUserContour)) {
04490 zc = fH->GetContourLevelPad(0);
04491 if (z < zc) continue;
04492 color = -1;
04493 for (Int_t k=0; k<ndiv; k++) {
04494 zc = fH->GetContourLevelPad(k);
04495 if (z < zc) {
04496 continue;
04497 } else {
04498 color++;
04499 }
04500 }
04501 } else {
04502 color = Int_t(0.01+(z-zmin)*scale);
04503 }
04504
04505 Int_t theColor = Int_t((color+0.99)*Float_t(ncolors)/Float_t(ndivz));
04506 if (theColor > ncolors-1) theColor = ncolors-1;
04507 fH->SetFillColor(gStyle->GetColorPalette(theColor));
04508 fH->TAttFill::Modify();
04509 if (Hoption.System != kPOLAR) {
04510 gPad->PaintBox(xlow, ylow, xup, yup);
04511 } else {
04512 TCrown crown(0,0,ylow,yup,xlow*TMath::RadToDeg(),xup*TMath::RadToDeg());
04513 crown.SetFillColor(gStyle->GetColorPalette(theColor));
04514 crown.Paint();
04515 }
04516 }
04517 }
04518
04519 if (Hoption.Zscale) PaintPalette();
04520
04521 fH->SetFillStyle(fillsav);
04522 fH->SetFillColor(colsav);
04523 fH->TAttFill::Modify();
04524
04525 }
04526
04527
04528
04529 void THistPainter::PaintContour(Option_t *option)
04530 {
04531
04532
04533
04534
04535 Int_t i, j, count, ncontour, icol, n, lj, m, ix, jx, ljfill;
04536 Int_t itars, mode, ir[4];
04537 Double_t xsave, ysave, thesave,phisave,x[4], y[4], zc[4];
04538
04539 if (Hoption.Contour == 14) {
04540 Hoption.Surf = 12;
04541 Hoption.Axis = 1;
04542 thesave = gPad->GetTheta();
04543 phisave = gPad->GetPhi();
04544 gPad->SetPhi(0.);
04545 gPad->SetTheta(90.);
04546 PaintSurface(option);
04547 gPad->SetPhi(phisave);
04548 gPad->SetTheta(thesave);
04549 gPad->GetView()->SetBit(kCannotRotate);
04550 PaintAxis();
04551 return;
04552 }
04553
04554 if (Hoption.Same) {
04555
04556
04557 TObject *obj;
04558 TIter next(gPad->GetListOfPrimitives());
04559 while ((obj=next())) {
04560 if (strstr(obj->GetDrawOption(),"surf") ||
04561 strstr(obj->GetDrawOption(),"lego") ||
04562 strstr(obj->GetDrawOption(),"tri")) {
04563 Hoption.Surf = 16;
04564 PaintSurface(option);
04565 return;
04566 }
04567 }
04568 }
04569
04570 if (Hoption.Contour == 15) {
04571 TGraphDelaunay *dt;
04572 TList *hl = fH->GetListOfFunctions();
04573 dt = (TGraphDelaunay*)hl->FindObject("TGraphDelaunay");
04574 if (!dt) return;
04575 if (!fGraph2DPainter) fGraph2DPainter = new TGraph2DPainter(dt);
04576 fGraph2DPainter->Paint(option);
04577 return;
04578 }
04579
04580 gPad->SetBit(TGraph::kClipFrame);
04581
04582 Double_t *levels = new Double_t[2*kMAXCONTOUR];
04583 Double_t *xarr = new Double_t[2*kMAXCONTOUR];
04584 Double_t *yarr = new Double_t[2*kMAXCONTOUR];
04585 Int_t *itarr = new Int_t[2*kMAXCONTOUR];
04586
04587 Int_t npmax = 0;
04588 for (i=0;i<2*kMAXCONTOUR;i++) itarr[i] = 0;
04589
04590 ncontour = fH->GetContour();
04591 if (ncontour == 0) {
04592 ncontour = gStyle->GetNumberContours();
04593 fH->SetContour(ncontour);
04594 }
04595 if (ncontour > kMAXCONTOUR) {
04596 Warning("PaintContour", "maximum number of contours is %d, asked for %d",
04597 kMAXCONTOUR, ncontour);
04598 ncontour = kMAXCONTOUR-1;
04599 }
04600 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ncontour);
04601
04602 for (i=0;i<ncontour;i++) levels[i] = fH->GetContourLevelPad(i);
04603
04604
04605 Int_t linesav = fH->GetLineStyle();
04606 Int_t colorsav = fH->GetLineColor();
04607 Int_t fillsav = fH->GetFillColor();
04608 if (Hoption.Contour == 13) {
04609 fH->TAttLine::Modify();
04610 }
04611
04612 TPolyLine **polys = 0;
04613 TPolyLine *poly=0;
04614 TObjArray *contours = 0;
04615 TList *list = 0;
04616 TGraph *graph = 0;
04617 Int_t *np = 0;
04618 if (Hoption.Contour == 1) {
04619 np = new Int_t[ncontour];
04620 for (i=0;i<ncontour;i++) np[i] = 0;
04621 polys = new TPolyLine*[ncontour];
04622 for (i=0;i<ncontour;i++) {
04623 polys[i] = new TPolyLine(100);
04624 }
04625 if (Hoption.List == 1) {
04626 contours = (TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours");
04627 if (contours) {
04628 gROOT->GetListOfSpecials()->Remove(contours);
04629 count = contours->GetSize();
04630 for (i=0;i<count;i++) {
04631 list = (TList*)contours->At(i);
04632 if (list) list->Delete();
04633 }
04634 }
04635 contours = new TObjArray(ncontour);
04636 contours->SetName("contours");
04637 gROOT->GetListOfSpecials()->Add(contours);
04638 for (i=0;i<ncontour;i++) {
04639 list = new TList();
04640 contours->Add(list);
04641 }
04642 }
04643 }
04644 Int_t theColor;
04645 Int_t ncolors = gStyle->GetNumberOfColors();
04646 Int_t ndivz = TMath::Abs(ncontour);
04647
04648 Int_t k,ipoly;
04649 for (j=Hparam.yfirst; j<Hparam.ylast; j++) {
04650 y[0] = fYaxis->GetBinCenter(j);
04651 y[1] = y[0];
04652 y[2] = fYaxis->GetBinCenter(j+1);
04653 y[3] = y[2];
04654 for (i=Hparam.xfirst; i<Hparam.xlast; i++) {
04655 zc[0] = fH->GetBinContent(i, j);
04656 zc[1] = fH->GetBinContent(i+1, j);
04657 zc[2] = fH->GetBinContent(i+1, j+1);
04658 zc[3] = fH->GetBinContent(i, j+1);
04659 if (!IsInside(fXaxis->GetBinCenter(i),fYaxis->GetBinCenter(j))) continue;
04660 if (Hoption.Logz) {
04661 if (zc[0] > 0) zc[0] = TMath::Log10(zc[0]);
04662 else zc[0] = Hparam.zmin;
04663 if (zc[1] > 0) zc[1] = TMath::Log10(zc[1]);
04664 else zc[1] = Hparam.zmin;
04665 if (zc[2] > 0) zc[2] = TMath::Log10(zc[2]);
04666 else zc[2] = Hparam.zmin;
04667 if (zc[3] > 0) zc[3] = TMath::Log10(zc[3]);
04668 else zc[3] = Hparam.zmin;
04669 }
04670 for (k=0;k<4;k++) {
04671 ir[k] = TMath::BinarySearch(ncontour,levels,zc[k]);
04672 }
04673 if (ir[0] != ir[1] || ir[1] != ir[2] || ir[2] != ir[3] || ir[3] != ir[0]) {
04674 x[0] = fXaxis->GetBinCenter(i);
04675 x[3] = x[0];
04676 x[1] = fXaxis->GetBinCenter(i+1);
04677 x[2] = x[1];
04678 if (zc[0] <= zc[1]) n = 0; else n = 1;
04679 if (zc[2] <= zc[3]) m = 2; else m = 3;
04680 if (zc[n] > zc[m]) n = m;
04681 n++;
04682 lj=1;
04683 for (ix=1;ix<=4;ix++) {
04684 m = n%4 + 1;
04685 ljfill = PaintContourLine(zc[n-1],ir[n-1],x[n-1],y[n-1],zc[m-1],
04686 ir[m-1],x[m-1],y[m-1],&xarr[lj-1],&yarr[lj-1],&itarr[lj-1], levels);
04687 lj += 2*ljfill;
04688 n = m;
04689 }
04690
04691 if (zc[0] <= zc[1]) n = 0; else n = 1;
04692 if (zc[2] <= zc[3]) m = 2; else m = 3;
04693 if (zc[n] > zc[m]) n = m;
04694 n++;
04695 lj=2;
04696 for (ix=1;ix<=4;ix++) {
04697 if (n == 1) m = 4;
04698 else m = n-1;
04699 ljfill = PaintContourLine(zc[n-1],ir[n-1],x[n-1],y[n-1],zc[m-1],
04700 ir[m-1],x[m-1],y[m-1],&xarr[lj-1],&yarr[lj-1],&itarr[lj-1], levels);
04701 lj += 2*ljfill;
04702 n = m;
04703 }
04704
04705
04706
04707 count = 0;
04708 for (ix=1; ix<=lj-5; ix +=2) {
04709
04710 while (itarr[ix-1] != itarr[ix]) {
04711 xsave = xarr[ix];
04712 ysave = yarr[ix];
04713 itars = itarr[ix];
04714 for (jx=ix; jx<=lj-5; jx +=2) {
04715 xarr[jx] = xarr[jx+2];
04716 yarr[jx] = yarr[jx+2];
04717 itarr[jx] = itarr[jx+2];
04718 }
04719 xarr[lj-3] = xsave;
04720 yarr[lj-3] = ysave;
04721 itarr[lj-3] = itars;
04722 if (count > 100) break;
04723 count++;
04724 }
04725 }
04726
04727 if (count > 100) continue;
04728 for (ix=1; ix<=lj-2; ix +=2) {
04729 theColor = Int_t((itarr[ix-1]+0.99)*Float_t(ncolors)/Float_t(ndivz));
04730 icol = gStyle->GetColorPalette(theColor);
04731 if (Hoption.Contour == 11) {
04732 fH->SetLineColor(icol);
04733 }
04734 if (Hoption.Contour == 12) {
04735 mode = icol%5;
04736 if (mode == 0) mode = 5;
04737 fH->SetLineStyle(mode);
04738 }
04739 if (Hoption.Contour != 1) {
04740 fH->TAttLine::Modify();
04741 gPad->PaintPolyLine(2,&xarr[ix-1],&yarr[ix-1]);
04742 continue;
04743 }
04744
04745 ipoly = itarr[ix-1];
04746 if (ipoly >=0 && ipoly <ncontour) {
04747 poly = polys[ipoly];
04748 poly->SetPoint(np[ipoly] ,xarr[ix-1],yarr[ix-1]);
04749 poly->SetPoint(np[ipoly]+1,xarr[ix], yarr[ix]);
04750 np[ipoly] += 2;
04751 if (npmax < np[ipoly]) npmax = np[ipoly];
04752 }
04753 }
04754 }
04755 }
04756 }
04757
04758 Double_t xmin,ymin;
04759 Double_t *xp, *yp;
04760 Int_t nadd,iminus,iplus;
04761 Double_t *xx, *yy;
04762 Int_t istart;
04763 Int_t first = ncontour;
04764 Int_t *polysort = 0;
04765 Int_t contListNb;
04766 if (Hoption.Contour != 1) goto theEND;
04767
04768
04769
04770
04771
04772 xmin = gPad->GetUxmin();
04773 ymin = gPad->GetUymin();
04774 xp = new Double_t[2*npmax];
04775 yp = new Double_t[2*npmax];
04776 polysort = new Int_t[ncontour];
04777
04778 for (ipoly=0;ipoly<ncontour;ipoly++) {
04779 if (levels[ipoly] >= 0) {first = ipoly; break;}
04780 }
04781
04782 k = 0;
04783 for (ipoly=first-1;ipoly>=0;ipoly--) {polysort[k] = ipoly; k++;}
04784 for (ipoly=first;ipoly<ncontour;ipoly++) {polysort[k] = ipoly; k++;}
04785
04786 contListNb = 0;
04787 fH->SetFillStyle(1001);
04788 for (k=0;k<ncontour;k++) {
04789 ipoly = polysort[k];
04790 if (np[ipoly] == 0) continue;
04791 if (Hoption.List) list = (TList*)contours->At(contListNb);
04792 contListNb++;
04793 poly = polys[ipoly];
04794 xx = poly->GetX();
04795 yy = poly->GetY();
04796 istart = 0;
04797 while (1) {
04798 iminus = npmax;
04799 iplus = iminus+1;
04800 xp[iminus]= xx[istart]; yp[iminus] = yy[istart];
04801 xp[iplus] = xx[istart+1]; yp[iplus] = yy[istart+1];
04802 xx[istart] = xmin; yy[istart] = ymin;
04803 xx[istart+1] = xmin; yy[istart+1] = ymin;
04804 while (1) {
04805 nadd = 0;
04806 for (i=2;i<np[ipoly];i+=2) {
04807 if (xx[i] == xp[iplus] && yy[i] == yp[iplus]) {
04808 iplus++;
04809 xp[iplus] = xx[i+1]; yp[iplus] = yy[i+1];
04810 xx[i] = xmin; yy[i] = ymin;
04811 xx[i+1] = xmin; yy[i+1] = ymin;
04812 nadd++;
04813 }
04814 if (xx[i+1] == xp[iminus] && yy[i+1] == yp[iminus]) {
04815 iminus--;
04816 xp[iminus] = xx[i]; yp[iminus] = yy[i];
04817 xx[i] = xmin; yy[i] = ymin;
04818 xx[i+1] = xmin; yy[i+1] = ymin;
04819 nadd++;
04820 }
04821 }
04822 if (nadd == 0) break;
04823 }
04824 theColor = Int_t((ipoly+0.99)*Float_t(ncolors)/Float_t(ndivz));
04825 icol = gStyle->GetColorPalette(theColor);
04826 if (ndivz > 1) fH->SetFillColor(icol);
04827 fH->TAttFill::Modify();
04828 gPad->PaintFillArea(iplus-iminus+1,&xp[iminus],&yp[iminus]);
04829 if (Hoption.List) {
04830 graph = new TGraph(iplus-iminus+1,&xp[iminus],&yp[iminus]);
04831 graph->SetFillColor(icol);
04832 graph->SetLineWidth(fH->GetLineWidth());
04833 list->Add(graph);
04834 }
04835
04836 istart = 0;
04837 for (i=2;i<np[ipoly];i+=2) {
04838 if (xx[i] != xmin && yy[i] != ymin) {
04839 istart = i;
04840 break;
04841 }
04842 }
04843 if (istart == 0) break;
04844 }
04845 }
04846
04847 for (i=0;i<ncontour;i++) delete polys[i];
04848 delete [] polys;
04849 delete [] xp;
04850 delete [] yp;
04851 delete [] polysort;
04852
04853 theEND:
04854 gPad->ResetBit(TGraph::kClipFrame);
04855 if (Hoption.Zscale) PaintPalette();
04856 fH->SetLineStyle(linesav);
04857 fH->SetLineColor(colorsav);
04858 fH->SetFillColor(fillsav);
04859 if (np) delete [] np;
04860 delete [] xarr;
04861 delete [] yarr;
04862 delete [] itarr;
04863 delete [] levels;
04864 }
04865
04866
04867
04868 Int_t THistPainter::PaintContourLine(Double_t elev1, Int_t icont1, Double_t x1, Double_t y1,
04869 Double_t elev2, Int_t icont2, Double_t x2, Double_t y2,
04870 Double_t *xarr, Double_t *yarr, Int_t *itarr, Double_t *levels)
04871 {
04872
04873
04874
04875
04876 Bool_t vert;
04877 Double_t tlen, tdif, elev, diff, pdif, xlen;
04878 Int_t n, i, icount;
04879
04880 if (x1 == x2) {
04881 vert = kTRUE;
04882 tlen = y2 - y1;
04883 } else {
04884 vert = kFALSE;
04885 tlen = x2 - x1;
04886 }
04887
04888 n = icont1 +1;
04889 tdif = elev2 - elev1;
04890 i = 0;
04891 icount = 0;
04892 while (n <= icont2 && i <= kMAXCONTOUR/2 -3) {
04893
04894 elev = levels[n];
04895 diff = elev - elev1;
04896 pdif = diff/tdif;
04897 xlen = tlen*pdif;
04898 if (vert) {
04899 if (Hoption.Logx)
04900 xarr[i] = TMath::Log10(x1);
04901 else
04902 xarr[i] = x1;
04903 if (Hoption.Logy)
04904 yarr[i] = TMath::Log10(y1 + xlen);
04905 else
04906 yarr[i] = y1 + xlen;
04907 } else {
04908 if (Hoption.Logx)
04909 xarr[i] = TMath::Log10(x1 + xlen);
04910 else
04911 xarr[i] = x1 + xlen;
04912 if (Hoption.Logy)
04913 yarr[i] = TMath::Log10(y1);
04914 else
04915 yarr[i] = y1;
04916 }
04917 itarr[i] = n;
04918 icount++;
04919 i +=2;
04920 n++;
04921 }
04922 return icount;
04923 }
04924
04925
04926
04927 void THistPainter::PaintErrors(Option_t *)
04928 {
04929
04930
04931
04932
04933 const Int_t kBASEMARKER=8;
04934 Double_t xp, yp, ex1, ex2, ey1, ey2;
04935 Double_t delta;
04936 Double_t s2x, s2y, bxsize, bysize, symbolsize, xerror, sbase;
04937 Double_t xi1, xi2, xi3, xi4, yi1, yi2, yi3, yi4;
04938 Double_t xmin, xmax, ymin, ymax;
04939 Double_t logxmin = 0;
04940 Double_t logymin = 0;
04941 Int_t i, k, npoints, first, last, fixbin;
04942 Int_t if1 = 0;
04943 Int_t if2 = 0;
04944 Int_t drawmarker, errormarker;
04945 Int_t option0, option1, option2, option3, option4, optionE, optionEX0, optionI0;
04946
04947 Double_t *xline = 0;
04948 Double_t *yline = 0;
04949 option0 = option1 = option2 = option3 = option4 = optionE = optionEX0 = optionI0 = 0;
04950 if (Int_t(Hoption.Error/10) == 2) {optionEX0 = 1; Hoption.Error -= 10;}
04951 if (Hoption.Error == 31) {optionEX0 = 1; Hoption.Error = 1;}
04952 if (Hoption.Error == 10) option0 = 1;
04953 if (Hoption.Error == 11) option1 = 1;
04954 if (Hoption.Error == 12) option2 = 1;
04955 if (Hoption.Error == 13) option3 = 1;
04956 if (Hoption.Error == 14) {option4 = 1; option3 = 1;}
04957 if (Hoption.Error == 15) {optionI0 = 1; option3 = 1;}
04958 if (Hoption.Error == 16) {optionI0 = 1; option4 = 1; option3 = 1;}
04959 if (option2+option3 == 0) optionE = 1;
04960 if (Hoption.Error == 0) optionE = 0;
04961 if (fXaxis->GetXbins()->fN) fixbin = 0;
04962 else fixbin = 1;
04963
04964 errormarker = fH->GetMarkerStyle();
04965 if (optionEX0) {
04966 xerror = 0;
04967 } else {
04968 xerror = gStyle->GetErrorX();
04969 }
04970 symbolsize = fH->GetMarkerSize();
04971 if (errormarker == 1) symbolsize = 0.01;
04972 sbase = symbolsize*kBASEMARKER;
04973
04974
04975 fH->TAttLine::Modify();
04976 fH->TAttFill::Modify();
04977 fH->TAttMarker::Modify();
04978
04979
04980
04981 Double_t factor = Hparam.factor;
04982 first = Hparam.xfirst;
04983 last = Hparam.xlast;
04984 npoints = last - first +1;
04985 xmin = gPad->GetUxmin();
04986 xmax = gPad->GetUxmax();
04987 ymin = gPad->GetUymin();
04988 ymax = gPad->GetUymax();
04989
04990
04991 if (option3) {
04992 xline = new Double_t[2*npoints];
04993 yline = new Double_t[2*npoints];
04994 if (!xline || !yline) {
04995 Error("PaintErrors", "too many points, out of memory");
04996 return;
04997 }
04998 if1 = 1;
04999 if2 = 2*npoints;
05000 }
05001
05002
05003 s2x = gPad->PixeltoX(Int_t(0.5*sbase)) - gPad->PixeltoX(0);
05004 s2y =-gPad->PixeltoY(Int_t(0.5*sbase)) + gPad->PixeltoY(0);
05005
05006
05007 Int_t dxend = Int_t(gStyle->GetEndErrorSize());
05008 bxsize = gPad->PixeltoX(dxend) - gPad->PixeltoX(0);
05009 bysize =-gPad->PixeltoY(dxend) + gPad->PixeltoY(0);
05010
05011
05012 if (fixbin) {
05013 if (Hoption.Logx) xp = TMath::Power(10,Hparam.xmin) + 0.5*Hparam.xbinsize;
05014 else xp = Hparam.xmin + 0.5*Hparam.xbinsize;
05015 }
05016 else {
05017 delta = fH->GetBinWidth(first);
05018 xp = fH->GetBinLowEdge(first) + 0.5*delta;
05019 }
05020
05021
05022 if (Hoption.Logx) logxmin = TMath::Power(10,Hparam.xmin);
05023 if (Hoption.Logy) logymin = TMath::Power(10,Hparam.ymin);
05024
05025
05026 for (k=first; k<=last; k++) {
05027
05028
05029
05030
05031
05032
05033
05034
05035
05036
05037 if (Hoption.Logx) {
05038 if (xp <= 0) goto L30;
05039 if (xp < logxmin) goto L30;
05040 if (xp > TMath::Power(10,xmax)) break;
05041 } else {
05042 if (xp < xmin) goto L30;
05043 if (xp > xmax) break;
05044 }
05045 yp = factor*fH->GetBinContent(k);
05046 if (optionI0 && yp==0) goto L30;
05047 if (fixbin) {
05048 ex1 = xerror*Hparam.xbinsize;
05049 } else {
05050 delta = fH->GetBinWidth(k);
05051 ex1 = xerror*delta;
05052 }
05053 ey1 = factor*fH->GetBinError(k);
05054 ex2 = ex1;
05055 ey2 = ey1;
05056
05057 xi4 = xp;
05058 xi3 = xp;
05059 xi2 = xp + ex2;
05060 xi1 = xp - ex1;
05061
05062 yi1 = yp;
05063 yi2 = yp;
05064 yi3 = yp - ey1;
05065 yi4 = yp + ey2;
05066
05067
05068 if (Hoption.Logx) {
05069 xi1 = TMath::Log10(TMath::Max(xi1,logxmin));
05070 xi2 = TMath::Log10(TMath::Max(xi2,logxmin));
05071 xi3 = TMath::Log10(TMath::Max(xi3,logxmin));
05072 xi4 = TMath::Log10(TMath::Max(xi4,logxmin));
05073 }
05074 if (Hoption.Logy) {
05075 yi1 = TMath::Log10(TMath::Max(yi1,logymin));
05076 yi2 = TMath::Log10(TMath::Max(yi2,logymin));
05077 yi3 = TMath::Log10(TMath::Max(yi3,logymin));
05078 yi4 = TMath::Log10(TMath::Max(yi4,logymin));
05079 }
05080
05081
05082
05083
05084 xi1 = TMath::Max(xi1,xmin);
05085 xi2 = TMath::Min(xi2,xmax);
05086 yi3 = TMath::Max(yi3,ymin);
05087 yi4 = TMath::Min(yi4,ymax);
05088
05089
05090
05091
05092 drawmarker = kTRUE;
05093 if (!option0 && !option3) {
05094 if (Hoption.Logy && yp < logymin) goto L30;
05095 if (yi1 < ymin || yi1 > ymax) goto L30;
05096 if (Hoption.Error != 0 && yp == 0 && ey1 <= 0) drawmarker = kFALSE;
05097 }
05098 if (!symbolsize || !errormarker) drawmarker = kFALSE;
05099
05100
05101 if (option2) gPad->PaintBox(xi1,yi3,xi2,yi4);
05102
05103
05104 if (option3) {
05105 xline[if1-1] = xi3;
05106 xline[if2-1] = xi3;
05107 yline[if1-1] = yi4;
05108 yline[if2-1] = yi3;
05109 if1++;
05110 if2--;
05111 }
05112
05113
05114
05115 if (optionE && drawmarker) {
05116 if (yi3 < yi1 - s2y) gPad->PaintLine(xi3,yi3,xi4,yi1 - s2y);
05117 if (yi1 + s2y < yi4) gPad->PaintLine(xi3,yi1 + s2y,xi4,yi4);
05118
05119 if (Hoption.Hist != 2){
05120 if (xi1 < xi3 - s2x) gPad->PaintLine(xi1,yi1,xi3 - s2x,yi2);
05121 if (xi3 + s2x < xi2) gPad->PaintLine(xi3 + s2x,yi1,xi2,yi2);
05122 }
05123 }
05124 if (optionE && !drawmarker && ey1 != 0) {
05125 if (yi3 < yi4) gPad->PaintLine(xi3,yi3,xi4,yi4);
05126 if (yi1 < yi4) gPad->PaintLine(xi3,yi1,xi4,yi4);
05127
05128 if (Hoption.Hist != 2){
05129 if (xi1 < xi3) gPad->PaintLine(xi1,yi1,xi3,yi2);
05130 if (xi3 < xi2) gPad->PaintLine(xi3,yi1,xi2,yi2);
05131 }
05132 }
05133
05134
05135
05136 if (option1 && drawmarker) {
05137 if (yi3 < yi1-s2y) gPad->PaintLine(xi3 - bxsize,yi3,xi3 + bxsize,yi3);
05138 if (yi4 > yi1+s2y) gPad->PaintLine(xi3 - bxsize,yi4,xi3 + bxsize,yi4);
05139 if (xi1 < xi3-s2x) gPad->PaintLine(xi1,yi1 - bysize,xi1,yi1 + bysize);
05140 if (xi2 > xi3+s2x) gPad->PaintLine(xi2,yi1 - bysize,xi2,yi1 + bysize);
05141 }
05142
05143
05144
05145 if (drawmarker) gPad->PaintPolyMarker(1, &xi3, &yi1);
05146
05147 L30:
05148 if (fixbin) xp += Hparam.xbinsize;
05149 else {
05150 if (k < last) {
05151 delta = fH->GetBinWidth(k+1);
05152 xp = fH->GetBinLowEdge(k+1) + 0.5*delta;
05153 }
05154 }
05155 }
05156
05157
05158
05159 if (option3) {
05160 TGraph graph;
05161 graph.SetLineStyle(fH->GetLineStyle());
05162 graph.SetLineColor(fH->GetLineColor());
05163 graph.SetLineWidth(fH->GetLineWidth());
05164 graph.SetFillStyle(fH->GetFillStyle());
05165 graph.SetFillColor(fH->GetFillColor());
05166 Int_t logx = gPad->GetLogx();
05167 Int_t logy = gPad->GetLogy();
05168 gPad->SetLogx(0);
05169 gPad->SetLogy(0);
05170
05171
05172
05173
05174 if (if2 > npoints) {
05175 for(i=1; i<if1 ;i++) {
05176 xline[if1-2+i] = xline[if2-1+i];
05177 yline[if1-2+i] = yline[if2-1+i];
05178 }
05179 npoints = if1-1;
05180 }
05181 if (option4) graph.PaintGraph(2*npoints,xline,yline,"FC");
05182 else graph.PaintGraph(2*npoints,xline,yline,"F");
05183 gPad->SetLogx(logx);
05184 gPad->SetLogy(logy);
05185 delete [] xline;
05186 delete [] yline;
05187 }
05188 }
05189
05190
05191
05192 void THistPainter::Paint2DErrors(Option_t *)
05193 {
05194
05195
05196
05197
05198 fH->TAttMarker::Modify();
05199 fH->TAttLine::Modify();
05200
05201
05202 fXbuf[0] = Hparam.xmin;
05203 fYbuf[0] = Hparam.xmax;
05204 fXbuf[1] = Hparam.ymin;
05205 fYbuf[1] = Hparam.ymax;
05206 fXbuf[2] = Hparam.zmin;
05207 fYbuf[2] = Hparam.zmax;
05208 fLego = new TPainter3dAlgorithms(fXbuf, fYbuf);
05209 TView *view = gPad->GetView();
05210 if (!view) {
05211 Error("Paint2DErrors", "no TView in current pad");
05212 return;
05213 }
05214 Double_t thedeg = 90 - gPad->GetTheta();
05215 Double_t phideg = -90 - gPad->GetPhi();
05216 Double_t psideg = view->GetPsi();
05217 Int_t irep;
05218 view->SetView(phideg, thedeg, psideg, irep);
05219
05220
05221 fLego->SetFillStyle(gPad->GetFrameFillStyle());
05222 fLego->SetFillColor(gPad->GetFrameFillColor());
05223 fLego->TAttFill::Modify();
05224 Int_t backcolor = gPad->GetFrameFillColor();
05225 if (Hoption.System != kCARTESIAN) backcolor = 0;
05226 view->PadRange(backcolor);
05227 fLego->SetFillStyle(fH->GetFillStyle());
05228 fLego->SetFillColor(fH->GetFillColor());
05229 fLego->TAttFill::Modify();
05230
05231
05232 if (Hoption.BackBox && !Hoption.Same && !Hoption.Lego && !Hoption.Surf) {
05233 fLego->InitMoveScreen(-1.1,1.1);
05234 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
05235 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
05236 fLego->BackBox(90);
05237 }
05238
05239
05240 Double_t x, ex, x1, x2;
05241 Double_t y, ey, y1, y2;
05242 Double_t z, ez, z1, z2;
05243 Double_t temp1[3],temp2[3];
05244 Double_t xyerror;
05245 if (Hoption.Error == 110) {
05246 xyerror = 0 ;
05247 } else {
05248 xyerror = gStyle->GetErrorX();
05249 }
05250
05251 Double_t xk, xstep, yk, ystep;
05252 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
05253 y = fYaxis->GetBinCenter(j);
05254 ey = fYaxis->GetBinWidth(j)*xyerror;
05255 y1 = y-ey;
05256 y2 = y+ey;
05257 if (Hoption.Logy) {
05258 if (y > 0) y = TMath::Log10(y);
05259 else continue;
05260 if (y1 > 0) y1 = TMath::Log10(y1);
05261 else y1 = Hparam.ymin;
05262 if (y2 > 0) y2 = TMath::Log10(y2);
05263 else y2 = Hparam.ymin;
05264 }
05265 yk = fYaxis->GetBinLowEdge(j);
05266 ystep = fYaxis->GetBinWidth(j);
05267 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
05268 xk = fXaxis->GetBinLowEdge(i);
05269 xstep = fXaxis->GetBinWidth(i);
05270 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep)) continue;
05271 Int_t bin = fH->GetBin(i,j);
05272 x = fXaxis->GetBinCenter(i);
05273 ex = fXaxis->GetBinWidth(i)*xyerror;
05274 x1 = x-ex;
05275 x2 = x+ex;
05276 if (Hoption.Logx) {
05277 if (x > 0) x = TMath::Log10(x);
05278 else continue;
05279 if (x1 > 0) x1 = TMath::Log10(x1);
05280 else x1 = Hparam.xmin;
05281 if (x2 > 0) x2 = TMath::Log10(x2);
05282 else x2 = Hparam.xmin;
05283 }
05284 z = fH->GetBinContent(bin);
05285 ez = fH->GetBinError(bin);
05286 z1 = z-ez;
05287 z2 = z+ez;
05288 if (Hoption.Logz) {
05289 if (z > 0) z = TMath::Log10(z);
05290 else z = Hparam.zmin;
05291 if (z1 > 0) z1 = TMath::Log10(z1);
05292 else z1 = Hparam.zmin;
05293 if (z2 > 0) z2 = TMath::Log10(z2);
05294 else z2 = Hparam.zmin;
05295
05296 }
05297 if (z <= Hparam.zmin) continue;
05298 if (z > Hparam.zmax) z = Hparam.zmax;
05299
05300 temp1[0] = x1;
05301 temp1[1] = y;
05302 temp1[2] = z;
05303 temp2[0] = x2;
05304 temp2[1] = y;
05305 temp2[2] = z;
05306 gPad->PaintLine3D(temp1, temp2);
05307 temp1[0] = x;
05308 temp1[1] = y1;
05309 temp1[2] = z;
05310 temp2[0] = x;
05311 temp2[1] = y2;
05312 temp2[2] = z;
05313 gPad->PaintLine3D(temp1, temp2);
05314 temp1[0] = x;
05315 temp1[1] = y;
05316 temp1[2] = z1;
05317 temp2[0] = x;
05318 temp2[1] = y;
05319 temp2[2] = z2;
05320 gPad->PaintLine3D(temp1, temp2);
05321 temp1[0] = x;
05322 temp1[1] = y;
05323 temp1[2] = z;
05324 view->WCtoNDC(temp1, &temp2[0]);
05325 gPad->PaintPolyMarker(1, &temp2[0], &temp2[1]);
05326 }
05327 }
05328
05329
05330 if (Hoption.FrontBox) {
05331 fLego->InitMoveScreen(-1.1,1.1);
05332 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
05333 fLego->FrontBox(90);
05334 }
05335
05336
05337 if (!Hoption.Axis && !Hoption.Same && !Hoption.Lego && !Hoption.Surf) {
05338 TGaxis *axis = new TGaxis();
05339 PaintLegoAxis(axis, 90);
05340 delete axis;
05341 }
05342
05343 delete fLego; fLego = 0;
05344 }
05345
05346
05347
05348 void THistPainter::PaintFrame()
05349 {
05350
05351
05352
05353
05354 if (Hoption.Same) return;
05355
05356 RecalculateRange();
05357
05358 if (Hoption.Lego || Hoption.Surf || Hoption.Tri ||
05359 Hoption.Contour == 14 || Hoption.Error >= 100) {
05360 TObject *frame = gPad->FindObject("TFrame");
05361 if (frame) gPad->GetListOfPrimitives()->Remove(frame);
05362 return;
05363 }
05364 gPad->PaintPadFrame(Hparam.xmin,Hparam.ymin,Hparam.xmax,Hparam.ymax);
05365 }
05366
05367
05368
05369 void THistPainter::PaintFunction(Option_t *)
05370 {
05371
05372
05373
05374
05375 TObjOptLink *lnk = (TObjOptLink*)fFunctions->FirstLink();
05376 TObject *obj;
05377
05378 while (lnk) {
05379 obj = lnk->GetObject();
05380 TVirtualPad *padsave = gPad;
05381 if (obj->InheritsFrom(TF1::Class())) {
05382 if (obj->TestBit(TF1::kNotDraw) == 0) obj->Paint("lsame");
05383 } else {
05384 obj->Paint(lnk->GetOption());
05385 }
05386 lnk = (TObjOptLink*)lnk->Next();
05387 padsave->cd();
05388 }
05389 }
05390
05391
05392
05393 void THistPainter::PaintHist(Option_t *)
05394 {
05395
05396
05397
05398
05399 static char chopth[17];
05400
05401 Int_t htype, oldhtype;
05402 Int_t i, j, first, last, nbins, fixbin;
05403 Double_t c1, yb;
05404 yb = 0;
05405
05406 strlcpy(chopth, " ",17);
05407
05408 Double_t ymin = Hparam.ymin;
05409 Double_t ymax = Hparam.ymax;
05410 Double_t baroffset = fH->GetBarOffset();
05411 Double_t barwidth = fH->GetBarWidth();
05412 Double_t baroffsetsave = gStyle->GetBarOffset();
05413 Double_t barwidthsave = gStyle->GetBarWidth();
05414 gStyle->SetBarOffset(baroffset);
05415 gStyle->SetBarWidth(barwidth);
05416
05417
05418
05419 first = Hparam.xfirst;
05420 last = Hparam.xlast;
05421 nbins = last - first + 1;
05422
05423 Double_t *keepx = 0;
05424 Double_t *keepy = 0;
05425 if (fXaxis->GetXbins()->fN) fixbin = 0;
05426 else fixbin = 1;
05427 if (fixbin) keepx = new Double_t[2];
05428 else keepx = new Double_t[nbins+1];
05429 keepy = new Double_t[nbins];
05430 Double_t logymin = 0;
05431 if (Hoption.Logy) logymin = TMath::Power(10,ymin);
05432
05433
05434
05435 for (j=first; j<=last;j++) {
05436 c1 = Hparam.factor*fH->GetBinContent(j);
05437 if (TMath::Abs(ymax-ymin) > 0) {
05438 if (Hoption.Logy) yb = TMath::Log10(TMath::Max(c1,.1*logymin));
05439 else yb = c1;
05440 }
05441 yb = TMath::Max(yb, ymin);
05442 yb = TMath::Min(yb, ymax);
05443 keepy[j-first] = yb;
05444 }
05445
05446
05447
05448 if (fixbin) { keepx[0] = Hparam.xmin; keepx[1] = Hparam.xmax; }
05449 else {
05450 for (i=0; i<nbins; i++) keepx[i] = fXaxis->GetBinLowEdge(i+first);
05451 keepx[nbins] = fXaxis->GetBinUpEdge(nbins-1+first);
05452 }
05453
05454
05455
05456 oldhtype = fH->GetFillStyle();
05457 htype = oldhtype;
05458 if (Hoption.Bar) {
05459 if (htype == 0 || htype == 1000) htype = 1001;
05460 }
05461
05462 Width_t lw = (Width_t)fH->GetLineWidth();
05463
05464
05465
05466 if (Hoption.Line) chopth[0] = 'L';
05467 if (Hoption.Star) chopth[1] = '*';
05468 if (Hoption.Mark) chopth[2] = 'P';
05469 if (Hoption.Mark == 10) chopth[3] = '0';
05470 if (Hoption.Line || Hoption.Curve || Hoption.Hist || Hoption.Bar) {
05471 if (Hoption.Curve) chopth[3] = 'C';
05472 if (Hoption.Hist > 0) chopth[4] = 'H';
05473 else if (Hoption.Bar) chopth[5] = 'B';
05474 if (fH->GetFillColor() && htype) {
05475 if (Hoption.Logy) {
05476 chopth[6] = '1';
05477 }
05478 if (Hoption.Hist > 0 || Hoption.Curve || Hoption.Line) {
05479 chopth[7] = 'F';
05480 }
05481 }
05482 }
05483 if (!fixbin && strlen(chopth)) {
05484 chopth[8] = 'N';
05485 }
05486
05487
05488 if (Hoption.Fill == 2) strlcat(chopth,"2",17);
05489
05490 if (Hoption.HighRes != 0) strlcat(chopth,"9",17);
05491
05492
05493
05494 if (Hoption.Logx) {
05495 chopth[9] = 'G';
05496 chopth[10] = 'X';
05497 if (fixbin) {
05498 keepx[0] = TMath::Power(10,keepx[0]);
05499 keepx[1] = TMath::Power(10,keepx[1]);
05500 }
05501 }
05502
05503 if (Hoption.Off) {
05504 chopth[11] = ']';
05505 chopth[12] = '[';
05506 }
05507
05508
05509
05510 TGraph graph;
05511 graph.SetLineWidth(lw);
05512 graph.SetLineStyle(fH->GetLineStyle());
05513 graph.SetLineColor(fH->GetLineColor());
05514 graph.SetFillStyle(htype);
05515 graph.SetFillColor(fH->GetFillColor());
05516 graph.SetMarkerStyle(fH->GetMarkerStyle());
05517 graph.SetMarkerSize(fH->GetMarkerSize());
05518 graph.SetMarkerColor(fH->GetMarkerColor());
05519 if (!Hoption.Same) graph.ResetBit(TGraph::kClipFrame);
05520
05521 graph.PaintGrapHist(nbins, keepx, keepy ,chopth);
05522
05523 delete [] keepx;
05524 delete [] keepy;
05525 gStyle->SetBarOffset(baroffsetsave);
05526 gStyle->SetBarWidth(barwidthsave);
05527
05528 htype=oldhtype;
05529 }
05530
05531
05532
05533 void THistPainter::PaintH3(Option_t *option)
05534 {
05535
05536
05537
05538
05539 char *cmd;
05540 TString opt = fH->GetDrawOption();
05541 opt.ToLower();
05542
05543 if (fH->GetDrawOption() && (strstr(opt,"box") || strstr(opt,"lego"))) {
05544 cmd = Form("TMarker3DBox::PaintH3((TH1 *)0x%lx,\"%s\");",(Long_t)fH,option);
05545 } else if (fH->GetDrawOption() && strstr(opt,"iso")) {
05546 PaintH3Iso();
05547 return;
05548 } else if (strstr(option,"tf3")) {
05549 PaintTF3();
05550 return;
05551 } else {
05552 cmd = Form("TPolyMarker3D::PaintH3((TH1 *)0x%lx,\"%s\");",(Long_t)fH,option);
05553 }
05554 gROOT->ProcessLine(cmd);
05555
05556
05557 if (Hoption.Same) return;
05558 TView *view = gPad->GetView();
05559 if (!view) return;
05560 view->SetOutlineToCube();
05561 view->GetOutline()->Paint(option);
05562 Hoption.System = kCARTESIAN;
05563 TGaxis *axis = new TGaxis();
05564 PaintLegoAxis(axis,90);
05565 delete axis;
05566
05567
05568
05569 if (fH->GetDrawOption() && strstr(opt,"colz")) {
05570 Int_t ndiv = fH->GetContour();
05571 if (ndiv == 0 ) {
05572 ndiv = gStyle->GetNumberContours();
05573 fH->SetContour(ndiv);
05574 }
05575 PaintPalette();
05576 }
05577
05578
05579 PaintTitle();
05580
05581
05582 TF1 *fit = 0;
05583 TIter next(fFunctions);
05584 TObject *obj;
05585 while ((obj = next())) {
05586 if (obj->InheritsFrom(TF1::Class())) {
05587 fit = (TF1*)obj;
05588 break;
05589 }
05590 }
05591 if (Hoption.Same != 1) {
05592 if (!fH->TestBit(TH1::kNoStats)) {
05593 PaintStat3(gStyle->GetOptStat(),fit);
05594 }
05595 }
05596
05597 }
05598
05599
05600
05601 Int_t THistPainter::PaintInit()
05602 {
05603
05604
05605
05606
05607 if (fH->GetDimension() > 1 || Hoption.Lego || Hoption.Surf) return 1;
05608
05609 static const char *where = "PaintInit";
05610 Double_t yMARGIN = gStyle->GetHistTopMargin();
05611 Int_t maximum = 0;
05612 Int_t minimum = 0;
05613 if (fH->GetMaximumStored() != -1111) maximum = 1;
05614 if (fH->GetMinimumStored() != -1111) minimum = 1;
05615
05616
05617
05618 Int_t last = fXaxis->GetLast();
05619 Int_t first = fXaxis->GetFirst();
05620 Hparam.xlowedge = fXaxis->GetBinLowEdge(first);
05621 Hparam.xbinsize = fXaxis->GetBinWidth(first);
05622 Hparam.xlast = last;
05623 Hparam.xfirst = first;
05624 Hparam.xmin = Hparam.xlowedge;
05625 Hparam.xmax = fXaxis->GetBinLowEdge(last)+fXaxis->GetBinWidth(last);
05626
05627
05628 if (Hoption.Logx) {
05629 if (Hparam.xlowedge <=0 ) {
05630 if (Hoption.Same) {
05631 Hparam.xlowedge = TMath::Power(10, gPad->GetUxmin());
05632 } else {
05633 Hparam.xlowedge = 0.1*Hparam.xbinsize;
05634 }
05635 Hparam.xmin = Hparam.xlowedge;
05636 }
05637 if (Hparam.xmin <=0 || Hparam.xmax <=0) {
05638 Error(where, "cannot set X axis to log scale");
05639 return 0;
05640 }
05641 Hparam.xfirst= fXaxis->FindFixBin(Hparam.xmin);
05642 Hparam.xlast = fXaxis->FindFixBin(Hparam.xmax);
05643 Hparam.xmin = TMath::Log10(Hparam.xmin);
05644 Hparam.xmax = TMath::Log10(Hparam.xmax);
05645 if (Hparam.xlast > last) Hparam.xlast = last;
05646 if (Hparam.xfirst < first) Hparam.xfirst = first;
05647 }
05648
05649
05650 Double_t bigp = TMath::Power(10,32);
05651 Double_t ymax = -bigp;
05652 Double_t ymin = bigp;
05653 Double_t c1, e1;
05654 Double_t xv[1];
05655 Double_t fval;
05656 Int_t i;
05657 TObject *f;
05658 TF1 *f1;
05659 Double_t allchan = 0;
05660 Int_t nonNullErrors = 0;
05661 TIter next(fFunctions);
05662 for (i=first; i<=last;i++) {
05663 c1 = fH->GetBinContent(i);
05664 ymax = TMath::Max(ymax,c1);
05665 if (Hoption.Logy) {
05666 if (c1 > 0) ymin = TMath::Min(ymin,c1);
05667 } else {
05668 ymin = TMath::Min(ymin,c1);
05669 }
05670 if (Hoption.Error) {
05671 e1 = fH->GetBinError(i);
05672 if (e1 > 0) nonNullErrors++;
05673 ymax = TMath::Max(ymax,c1+e1);
05674 if (Hoption.Logy) {
05675 if (c1-e1>0.01*TMath::Abs(c1)) ymin = TMath::Min(ymin,c1-e1);
05676 } else {
05677 ymin = TMath::Min(ymin,c1-e1);
05678 }
05679 }
05680 if (Hoption.Func) {
05681 xv[0] = fXaxis->GetBinCenter(i);
05682 while ((f = (TObject*) next())) {
05683 if (f->IsA() == TF1::Class()) {
05684 f1 = (TF1*)f;
05685 if (xv[0] < f1->GetXmin() || xv[0] > f1->GetXmax()) continue;
05686 fval = f1->Eval(xv[0],0,0);
05687 ymax = TMath::Max(ymax,fval);
05688 if (Hoption.Logy) {
05689 if (c1 > 0 && fval > 0.3*c1) ymin = TMath::Min(ymin,fval);
05690 }
05691 }
05692 }
05693 next.Reset();
05694 }
05695 allchan += c1;
05696 }
05697 if (!nonNullErrors) {
05698 if (Hoption.Error) {
05699 if (!Hoption.Mark && !Hoption.Line && !Hoption.Star && !Hoption.Curve) Hoption.Hist = 2;
05700 Hoption.Error=0;
05701 }
05702 }
05703
05704
05705
05706
05707 if (Hoption.Logy && ymin <= 0) {
05708 if (ymax >= 1) ymin = TMath::Max(.005,ymax*1e-10);
05709 else ymin = 0.001*ymax;
05710 }
05711
05712 Double_t xm = ymin;
05713 if (maximum) ymax = fH->GetMaximumStored();
05714 if (minimum) xm = fH->GetMinimumStored();
05715 if (Hoption.Logy && xm < 0) {
05716 Error(where, "log scale requested with a negative argument (%f)", xm);
05717 return 0;
05718 } else if (Hoption.Logy && xm>=0 && ymax==0) {
05719 ymin = 0.01;
05720 ymax = 10.;
05721 } else {
05722 ymin = xm;
05723 }
05724
05725 if (ymin >= ymax) {
05726 if (Hoption.Logy) {
05727 if (ymax > 0) ymin = 0.001*ymax;
05728 else {
05729 if (!Hoption.Same) Error(where, "log scale is requested but maximum is less or equal 0 (%f)", ymax);
05730 return 0;
05731 }
05732 }
05733 else {
05734 if (ymin > 0) {
05735 ymin = 0;
05736 ymax *= 2;
05737 } else if (ymin < 0) {
05738 ymax = 0;
05739 ymin *= 2;
05740 } else {
05741 ymin = 0;
05742 ymax = 1;
05743 }
05744 }
05745 }
05746
05747
05748 if(TMath::AreEqualRel(ymin,ymax,1E-15)) {
05749 ymin = ymin*(1-1E-14);
05750 ymax = ymax*(1+1E-14);
05751 }
05752
05753
05754 Hparam.allchan = allchan;
05755 Double_t factor = allchan;
05756 if (fH->GetNormFactor() > 0) factor = fH->GetNormFactor();
05757 if (allchan) factor /= allchan;
05758 if (factor == 0) factor = 1;
05759 Hparam.factor = factor;
05760 ymax = factor*ymax;
05761 ymin = factor*ymin;
05762
05763
05764 if (ymax < ymin) {
05765 Double_t temp = ymax;
05766 ymax = ymin;
05767 ymin = temp;
05768 }
05769
05770
05771
05772
05773
05774 if (Hoption.Logy) {
05775 if (ymin <=0 || ymax <=0) {
05776 Error(where, "Cannot set Y axis to log scale");
05777 return 0;
05778 }
05779 ymin = TMath::Log10(ymin);
05780 if (!minimum) ymin += TMath::Log10(0.5);
05781 ymax = TMath::Log10(ymax);
05782 if (!maximum) ymax += TMath::Log10(2*(0.9/0.95));
05783 if (!Hoption.Same) {
05784 Hparam.ymin = ymin;
05785 Hparam.ymax = ymax;
05786 }
05787 return 1;
05788 }
05789
05790
05791
05792
05793 if (!minimum) {
05794 if (gStyle->GetHistMinimumZero()) {
05795 if (ymin >= 0) ymin = 0;
05796 else ymin -= yMARGIN*(ymax-ymin);
05797 } else {
05798 Double_t dymin = yMARGIN*(ymax-ymin);
05799 if (ymin >= 0 && (ymin-dymin <= 0)) ymin = 0;
05800 else ymin -= dymin;
05801 }
05802 }
05803
05804
05805
05806
05807 if (!maximum) {
05808 ymax += yMARGIN*(ymax-ymin);
05809 }
05810
05811 Hparam.ymin = ymin;
05812 Hparam.ymax = ymax;
05813 return 1;
05814 }
05815
05816
05817
05818 Int_t THistPainter::PaintInitH()
05819 {
05820
05821
05822
05823
05824 static const char *where = "PaintInitH";
05825 Double_t yMARGIN = gStyle->GetHistTopMargin();
05826 Int_t maximum = 0;
05827 Int_t minimum = 0;
05828 if (fH->GetMaximumStored() != -1111) maximum = 1;
05829 if (fH->GetMinimumStored() != -1111) minimum = 1;
05830
05831
05832
05833 Int_t last = fXaxis->GetLast();
05834 Int_t first = fXaxis->GetFirst();
05835 Hparam.xlowedge = fXaxis->GetBinLowEdge(first);
05836 Hparam.xbinsize = fXaxis->GetBinWidth(first);
05837 Hparam.xlast = last;
05838 Hparam.xfirst = first;
05839 Hparam.ymin = Hparam.xlowedge;
05840 Hparam.ymax = fXaxis->GetBinLowEdge(last)+fXaxis->GetBinWidth(last);
05841
05842
05843 if (Hoption.Logy) {
05844 if (Hparam.xlowedge <=0 ) {
05845 Hparam.xlowedge = 0.1*Hparam.xbinsize;
05846 Hparam.ymin = Hparam.xlowedge;
05847 }
05848 if (Hparam.ymin <=0 || Hparam.ymax <=0) {
05849 Error(where, "cannot set Y axis to log scale");
05850 return 0;
05851 }
05852 Hparam.xfirst= fXaxis->FindFixBin(Hparam.ymin);
05853 Hparam.xlast = fXaxis->FindFixBin(Hparam.ymax);
05854 Hparam.ymin = TMath::Log10(Hparam.ymin);
05855 Hparam.ymax = TMath::Log10(Hparam.ymax);
05856 if (Hparam.xlast > last) Hparam.xlast = last;
05857 }
05858
05859
05860 Double_t bigp = TMath::Power(10,32);
05861 Double_t xmax = -bigp;
05862 Double_t xmin = bigp;
05863 Double_t c1, e1;
05864 Double_t xv[1];
05865 Double_t fval;
05866 Int_t i;
05867 TObject *f;
05868 TF1 *f1;
05869 Double_t allchan = 0;
05870 TIter next(fFunctions);
05871 for (i=first; i<=last;i++) {
05872 c1 = fH->GetBinContent(i);
05873 xmax = TMath::Max(xmax,c1);
05874 xmin = TMath::Min(xmin,c1);
05875 if (Hoption.Error) {
05876 e1 = fH->GetBinError(i);
05877 xmax = TMath::Max(xmax,c1+e1);
05878 xmin = TMath::Min(xmin,c1-e1);
05879 }
05880 if (Hoption.Func) {
05881 xv[0] = fXaxis->GetBinCenter(i);
05882 while ((f = (TObject*) next())) {
05883 if (f->IsA() == TF1::Class()) {
05884 f1 = (TF1*)f;
05885 if (xv[0] < f1->GetXmin() || xv[0] > f1->GetXmax()) continue;
05886 fval = f1->Eval(xv[0],0,0);
05887 xmax = TMath::Max(xmax,fval);
05888 if (Hoption.Logy) {
05889 if (fval > 0.3*c1) xmin = TMath::Min(xmin,fval);
05890 }
05891 }
05892 }
05893 next.Reset();
05894 }
05895 allchan += c1;
05896 }
05897
05898
05899
05900 if (Hoption.Logx && xmin <= 0) {
05901 if (xmax >= 1) xmin = TMath::Max(.5,xmax*1e-10);
05902 else xmin = 0.001*xmax;
05903 }
05904 Double_t xm = xmin;
05905 if (maximum) xmax = fH->GetMaximumStored();
05906 if (minimum) xm = fH->GetMinimumStored();
05907 if (Hoption.Logx && xm <= 0) {
05908 Error(where, "log scale requested with zero or negative argument (%f)", xm);
05909 return 0;
05910 }
05911 else xmin = xm;
05912 if (xmin >= xmax) {
05913 if (Hoption.Logx) {
05914 if (xmax > 0) xmin = 0.001*xmax;
05915 else {
05916 if (!Hoption.Same) Error(where, "log scale is requested but maximum is less or equal 0 (%f)", xmax);
05917 return 0;
05918 }
05919 }
05920 else {
05921 if (xmin > 0) {
05922 xmin = 0;
05923 xmax *= 2;
05924 } else if (xmin < 0) {
05925 xmax = 0;
05926 xmin *= 2;
05927 } else {
05928 xmin = -1;
05929 xmax = 1;
05930 }
05931 }
05932 }
05933
05934
05935 Hparam.allchan = allchan;
05936 Double_t factor = allchan;
05937 if (fH->GetNormFactor() > 0) factor = fH->GetNormFactor();
05938 if (allchan) factor /= allchan;
05939 if (factor == 0) factor = 1;
05940 Hparam.factor = factor;
05941 xmax = factor*xmax;
05942 xmin = factor*xmin;
05943
05944
05945
05946
05947
05948 if (Hoption.Logx) {
05949 if (xmin <=0 || xmax <=0) {
05950 Error(where, "Cannot set Y axis to log scale");
05951 return 0;
05952 }
05953 xmin = TMath::Log10(xmin);
05954 if (!minimum) xmin += TMath::Log10(0.5);
05955 xmax = TMath::Log10(xmax);
05956 if (!maximum) xmax += TMath::Log10(2*(0.9/0.95));
05957 if (!Hoption.Same) {
05958 Hparam.xmin = xmin;
05959 Hparam.xmax = xmax;
05960 }
05961 return 1;
05962 }
05963
05964
05965
05966
05967 if (!minimum) {
05968 if (xmin >= 0) xmin = 0;
05969 else xmin -= yMARGIN*(xmax-xmin);
05970 }
05971
05972
05973
05974
05975 if (!maximum) {
05976 xmax += yMARGIN*(xmax-xmin);
05977 }
05978 Hparam.xmin = xmin;
05979 Hparam.xmax = xmax;
05980 return 1;
05981 }
05982
05983
05984
05985 void THistPainter::PaintH3Iso()
05986 {
05987
05988
05989
05990
05991 const Double_t ydiff = 1;
05992 const Double_t yligh1 = 10;
05993 const Double_t qa = 0.15;
05994 const Double_t qd = 0.15;
05995 const Double_t qs = 0.8;
05996 Double_t fmin, fmax;
05997 Int_t i, irep;
05998 Int_t nbcol = 28;
05999 Int_t icol1 = 201;
06000 Int_t ic1 = icol1;
06001 Int_t ic2 = ic1+nbcol;
06002 Int_t ic3 = ic2+nbcol;
06003
06004 TGaxis *axis = new TGaxis();
06005 TAxis *xaxis = fH->GetXaxis();
06006 TAxis *yaxis = fH->GetYaxis();
06007 TAxis *zaxis = fH->GetZaxis();
06008
06009 Int_t nx = fH->GetNbinsX();
06010 Int_t ny = fH->GetNbinsY();
06011 Int_t nz = fH->GetNbinsZ();
06012
06013 Double_t *x = new Double_t[nx];
06014 Double_t *y = new Double_t[ny];
06015 Double_t *z = new Double_t[nz];
06016
06017 for ( i=0 ; i<nx ; i++) x[i] = xaxis->GetBinCenter(i+1);
06018 for ( i=0 ; i<ny ; i++) y[i] = yaxis->GetBinCenter(i+1);
06019 for ( i=0 ; i<nz ; i++) z[i] = zaxis->GetBinCenter(i+1);
06020
06021 fXbuf[0] = xaxis->GetBinLowEdge(xaxis->GetFirst());
06022 fYbuf[0] = xaxis->GetBinUpEdge(xaxis->GetLast());
06023 fXbuf[1] = yaxis->GetBinLowEdge(yaxis->GetFirst());
06024 fYbuf[1] = yaxis->GetBinUpEdge(yaxis->GetLast());
06025 fXbuf[2] = zaxis->GetBinLowEdge(zaxis->GetFirst());
06026 fYbuf[2] = zaxis->GetBinUpEdge(zaxis->GetLast());
06027
06028 Double_t s[3];
06029 s[0] = fH->GetSumOfWeights()/(fH->GetNbinsX()*fH->GetNbinsY()*fH->GetNbinsZ());
06030 s[1] = 0.5*s[0];
06031 s[2] = 1.5*s[0];
06032
06033 fLego = new TPainter3dAlgorithms(fXbuf, fYbuf);
06034
06035 TView *view = gPad->GetView();
06036 if (!view) {
06037 Error("PaintH3Iso", "no TView in current pad");
06038 delete [] x;
06039 delete [] y;
06040 delete [] z;
06041 return;
06042 }
06043 Double_t thedeg = 90 - gPad->GetTheta();
06044 Double_t phideg = -90 - gPad->GetPhi();
06045 Double_t psideg = view->GetPsi();
06046 view->SetView(phideg, thedeg, psideg, irep);
06047
06048 Int_t backcolor = gPad->GetFrameFillColor();
06049 if (Hoption.System != kCARTESIAN) backcolor = 0;
06050 view->PadRange(backcolor);
06051
06052 Double_t dcol = 0.5/Double_t(nbcol);
06053 TColor *colref = gROOT->GetColor(fH->GetFillColor());
06054 Float_t r, g, b, hue, light, satur;
06055 colref->GetRGB(r,g,b);
06056 TColor::RGBtoHLS(r,g,b,hue,light,satur);
06057 TColor *acol;
06058 for (Int_t col=0;col<nbcol;col++) {
06059 acol = gROOT->GetColor(col+icol1);
06060 TColor::HLStoRGB(hue, .4+col*dcol, satur, r, g, b);
06061 acol->SetRGB(r, g, b);
06062 }
06063
06064 fLego->InitMoveScreen(-1.1,1.1);
06065
06066 if (Hoption.BackBox) {
06067 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
06068 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
06069 fLego->BackBox(90);
06070 }
06071
06072 fLego->LightSource(0, ydiff, 0, 0, 0, irep);
06073 fLego->LightSource(1, yligh1, 1, 1, 1, irep);
06074 fLego->SurfaceProperty(qa, qd, qs, 1, irep);
06075 fmin = ydiff*qa;
06076 fmax = ydiff*qa + (yligh1+0.1)*(qd+qs);
06077 fLego->SetIsoSurfaceParameters(fmin, fmax, nbcol, ic1, ic2, ic3);
06078
06079 fLego->IsoSurface(1, s, nx, ny, nz, x, y, z, "BF");
06080
06081 if (Hoption.FrontBox) {
06082 fLego->InitMoveScreen(-1.1,1.1);
06083 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
06084 fLego->FrontBox(90);
06085 }
06086 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
06087
06088 PaintTitle();
06089
06090 delete axis;
06091 delete fLego; fLego = 0;
06092 delete [] x;
06093 delete [] y;
06094 delete [] z;
06095 }
06096
06097
06098
06099 void THistPainter::PaintLego(Option_t *)
06100 {
06101
06102
06103
06104
06105 Int_t raster = 1;
06106 if (Hparam.zmin == 0 && Hparam.zmax == 0) {Hparam.zmin = -1; Hparam.zmax = 1;}
06107 Int_t nx = Hparam.xlast - Hparam.xfirst + 1;
06108 Int_t ny = Hparam.ylast - Hparam.yfirst + 1;
06109 Double_t zmin = Hparam.zmin;
06110 Double_t zmax = Hparam.zmax;
06111 Double_t xlab1 = Hparam.xmin;
06112 Double_t xlab2 = Hparam.xmax;
06113 Double_t ylab1 = Hparam.ymin;
06114 Double_t ylab2 = Hparam.ymax;
06115 Double_t dangle = 10*3.141592/180;
06116 Double_t deltaz = TMath::Abs(zmin);
06117 if (deltaz == 0) deltaz = 1;
06118 if (zmin >= zmax) {
06119 zmin -= 0.5*deltaz;
06120 zmax += 0.5*deltaz;
06121 }
06122 Double_t z1c = zmin;
06123 Double_t z2c = zmin + (zmax-zmin)*(1+gStyle->GetHistTopMargin());
06124
06125
06126 fXbuf[0] = -1;
06127 fYbuf[0] = 1;
06128 fXbuf[1] = -1;
06129 fYbuf[1] = 1;
06130 if (Hoption.System == kPOLAR) {
06131 fXbuf[2] = z1c;
06132 fYbuf[2] = z2c;
06133 } else if (Hoption.System == kCYLINDRICAL) {
06134 if (Hoption.Logy) {
06135 if (ylab1 > 0) fXbuf[2] = TMath::Log10(ylab1);
06136 else fXbuf[2] = 0;
06137 if (ylab2 > 0) fYbuf[2] = TMath::Log10(ylab2);
06138 else fYbuf[2] = 0;
06139 } else {
06140 fXbuf[2] = ylab1;
06141 fYbuf[2] = ylab2;
06142 }
06143 z1c = 0; z2c = 1;
06144 } else if (Hoption.System == kSPHERICAL) {
06145 fXbuf[2] = -1;
06146 fYbuf[2] = 1;
06147 z1c = 0; z2c = 1;
06148 } else if (Hoption.System == kRAPIDITY) {
06149 fXbuf[2] = -1/TMath::Tan(dangle);
06150 fYbuf[2] = 1/TMath::Tan(dangle);
06151 } else {
06152 fXbuf[0] = xlab1;
06153 fYbuf[0] = xlab2;
06154 fXbuf[1] = ylab1;
06155 fYbuf[1] = ylab2;
06156 fXbuf[2] = z1c;
06157 fYbuf[2] = z2c;
06158 raster = 0;
06159 }
06160
06161 fLego = new TPainter3dAlgorithms(fXbuf, fYbuf, Hoption.System);
06162
06163
06164
06165 TGaxis *axis = new TGaxis();
06166
06167
06168 Int_t ndiv = fH->GetContour();
06169 if (ndiv == 0 ) {
06170 ndiv = gStyle->GetNumberContours();
06171 fH->SetContour(ndiv);
06172 }
06173 Int_t ndivz = TMath::Abs(ndiv);
06174 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
06175
06176
06177 if (Hoption.Lego == 1) {
06178 Color_t colormain = fH->GetLineColor();
06179 fLego->SetColorMain(colormain,0);
06180 }
06181 if (Hoption.Lego == 11) {
06182 Int_t nids = 1;
06183 if (fStack) nids = fStack->GetSize();
06184 TH1 *hid = fH;
06185 for (Int_t id=0;id<=nids;id++) {
06186 if (id > 0 && fStack) hid = (TH1*)fStack->At(id-1);
06187 Color_t colormain = hid->GetFillColor();
06188 if (colormain == 1) colormain = 17;
06189 Color_t colordark = TColor::GetColorDark(colormain);
06190 fLego->SetColorMain(colormain,id);
06191 fLego->SetColorDark(colordark,id);
06192 if (id == 0) fLego->SetColorMain(colormain,-1);
06193 if (id == nids) fLego->SetColorMain(colormain,99);
06194 }
06195 }
06196
06197
06198 Int_t irep = 0;
06199
06200 TView *view = gPad->GetView();
06201 if (!view) {
06202 Error("PaintLego", "no TView in current pad");
06203 return;
06204 }
06205
06206 Double_t thedeg = 90 - gPad->GetTheta();
06207 Double_t phideg = -90 - gPad->GetPhi();
06208 Double_t psideg = view->GetPsi();
06209 view->SetView(phideg, thedeg, psideg, irep);
06210
06211 fLego->SetLineColor(fH->GetLineColor());
06212 fLego->SetFillStyle(fH->GetFillStyle());
06213
06214
06215 fLego->SetFillStyle(gPad->GetFrameFillStyle());
06216 fLego->SetFillColor(gPad->GetFrameFillColor());
06217 fLego->TAttFill::Modify();
06218
06219 Int_t backcolor = gPad->GetFrameFillColor();
06220 if (Hoption.System != kCARTESIAN) backcolor = 0;
06221 view->PadRange(backcolor);
06222
06223 fLego->SetFillStyle(fH->GetFillStyle());
06224 fLego->SetFillColor(fH->GetFillColor());
06225 fLego->TAttFill::Modify();
06226
06227 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
06228
06229 if (raster) fLego->InitRaster(-1.1,-1.1,1.1,1.1,1000,800);
06230 else fLego->InitMoveScreen(-1.1,1.1);
06231
06232 if (Hoption.Lego == 11 || Hoption.Lego == 12) {
06233 if (Hoption.System == kCARTESIAN && Hoption.BackBox) {
06234 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
06235 fLego->BackBox(90);
06236 }
06237 }
06238
06239 if (Hoption.Lego == 12) DefineColorLevels(ndivz);
06240
06241 fLego->SetLegoFunction(&TPainter3dAlgorithms::LegoFunction);
06242 if (Hoption.Lego == 1) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceRaster2);
06243 if (Hoption.Lego == 11) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode3);
06244 if (Hoption.Lego == 12) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode2);
06245 if (Hoption.System == kPOLAR) {
06246 if (Hoption.Lego == 1) fLego->LegoPolar(1,nx,ny,"FB");
06247 if (Hoption.Lego == 11) fLego->LegoPolar(1,nx,ny,"BF");
06248 if (Hoption.Lego == 12) fLego->LegoPolar(1,nx,ny,"BF");
06249 } else if (Hoption.System == kCYLINDRICAL) {
06250 if (Hoption.Lego == 1) fLego->LegoCylindrical(1,nx,ny,"FB");
06251 if (Hoption.Lego == 11) fLego->LegoCylindrical(1,nx,ny,"BF");
06252 if (Hoption.Lego == 12) fLego->LegoCylindrical(1,nx,ny,"BF");
06253 } else if (Hoption.System == kSPHERICAL) {
06254 if (Hoption.Lego == 1) fLego->LegoSpherical(0,1,nx,ny,"FB");
06255 if (Hoption.Lego == 11) fLego->LegoSpherical(0,1,nx,ny,"BF");
06256 if (Hoption.Lego == 12) fLego->LegoSpherical(0,1,nx,ny,"BF");
06257 } else if (Hoption.System == kRAPIDITY) {
06258 if (Hoption.Lego == 1) fLego->LegoSpherical(1,1,nx,ny,"FB");
06259 if (Hoption.Lego == 11) fLego->LegoSpherical(1,1,nx,ny,"BF");
06260 if (Hoption.Lego == 12) fLego->LegoSpherical(1,1,nx,ny,"BF");
06261 } else {
06262 if (Hoption.Lego == 1) {
06263 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
06264 fLego->LegoCartesian(90,nx,ny,"FB");}
06265 if (Hoption.Lego == 11) fLego->LegoCartesian(90,nx,ny,"BF");
06266 if (Hoption.Lego == 12) fLego->LegoCartesian(90,nx,ny,"BF");
06267 }
06268
06269 if (Hoption.Lego == 1 || Hoption.Lego == 11) {
06270 fLego->SetLineColor(1);
06271 if (Hoption.System == kCARTESIAN && Hoption.BackBox) {
06272 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
06273 fLego->BackBox(90);
06274 }
06275 }
06276 if (Hoption.System == kCARTESIAN) {
06277 fLego->InitMoveScreen(-1.1,1.1);
06278 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
06279 if (Hoption.FrontBox) fLego->FrontBox(90);
06280 }
06281 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
06282 if (Hoption.Zscale) PaintPalette();
06283 delete axis;
06284 delete fLego; fLego = 0;
06285 }
06286
06287
06288
06289 void THistPainter::PaintLegoAxis(TGaxis *axis, Double_t ang)
06290 {
06291
06292
06293
06294
06295 static Double_t epsil = 0.001;
06296
06297 Double_t cosa, sina;
06298 Double_t bmin, bmax;
06299 Double_t r[24] ;
06300 Int_t ndivx, ndivy, ndivz, i;
06301 Double_t x1[3], x2[3], y1[3], y2[3], z1[3], z2[3], av[24] ;
06302 static char chopax[8], chopay[8], chopaz[8];
06303 Int_t ix1, ix2, iy1, iy2, iz1, iz2;
06304 Double_t rad;
06305
06306 TView *view = gPad->GetView();
06307 if (!view) {
06308 Error("PaintLegoAxis", "no TView in current pad");
06309 return;
06310 }
06311
06312
06313
06314 if (Hoption.System == kPOLAR) {
06315 r[0] = 1;
06316 r[1] = 0;
06317 r[2] = 0;
06318 view->WCtoNDC(r, x1);
06319 r[0] = 1.1;
06320 r[1] = 0;
06321 r[2] = 0;
06322 view->WCtoNDC(r, x2);
06323 gPad->PaintLine(x1[0],x1[1],x2[0],x2[1]);
06324 return ;
06325 }
06326
06327 if (Hoption.System != kCARTESIAN) return ;
06328
06329 rad = TMath::ATan(1.) * 4. /180.;
06330 cosa = TMath::Cos(ang*rad);
06331 sina = TMath::Sin(ang*rad);
06332
06333 view->AxisVertex(ang, av, ix1, ix2, iy1, iy2, iz1, iz2);
06334 for (i = 1; i <= 8; ++i) {
06335 r[i*3 - 3] = av[i*3 - 3] + av[i*3 - 2]*cosa;
06336 r[i*3 - 2] = av[i*3 - 2]*sina;
06337 r[i*3 - 1] = av[i*3 - 1];
06338 }
06339
06340 view->WCtoNDC(&r[ix1*3 - 3], x1);
06341 view->WCtoNDC(&r[ix2*3 - 3], x2);
06342 view->WCtoNDC(&r[iy1*3 - 3], y1);
06343 view->WCtoNDC(&r[iy2*3 - 3], y2);
06344 view->WCtoNDC(&r[iz1*3 - 3], z1);
06345 view->WCtoNDC(&r[iz2*3 - 3], z2);
06346
06347 view->SetAxisNDC(x1, x2, y1, y2, z1, z2);
06348
06349 Double_t *rmin = view->GetRmin();
06350 Double_t *rmax = view->GetRmax();
06351
06352
06353 if (x1[0] > x2[0]) strlcpy(chopax, "SDH=+",8);
06354 else strlcpy(chopax, "SDH=-",8);
06355 if (y1[0] > y2[0]) strlcpy(chopay, "SDH=+",8);
06356 else strlcpy(chopay, "SDH=-",8);
06357 strlcpy(chopaz, "SDH+=",8);
06358
06359
06360
06361 if (Hoption.Logx) strlcat(chopax,"G",8);
06362
06363 if (Hoption.Logy) strlcat(chopay,"G",8);
06364
06365 if (Hoption.Logz) strlcat(chopaz,"G",8);
06366
06367
06368
06369 ndivx = fXaxis->GetNdivisions();
06370 ndivy = fYaxis->GetNdivisions();
06371 ndivz = fZaxis->GetNdivisions();
06372 if (ndivx < 0) {
06373 ndivx = TMath::Abs(ndivx);
06374
06375 strlcat(chopax, "N",8);
06376 }
06377 if (ndivy < 0) {
06378 ndivy = TMath::Abs(ndivy);
06379
06380 strlcat(chopay, "N",8);
06381 }
06382 if (ndivz < 0) {
06383 ndivz = TMath::Abs(ndivz);
06384
06385 strlcat(chopaz, "N",8);
06386 }
06387
06388
06389
06390
06391
06392 axis->SetLineWidth(1);
06393
06394
06395 if (TMath::Abs(x1[0] - x2[0]) >= epsil || TMath::Abs(x1[1] - x2[1]) > epsil) {
06396 axis->ImportAxisAttributes(fXaxis);
06397 axis->SetLabelOffset(fXaxis->GetLabelOffset()+fXaxis->GetTickLength());
06398 if (Hoption.Logx && !fH->InheritsFrom(TH3::Class())) {
06399 bmin = TMath::Power(10, rmin[0]);
06400 bmax = TMath::Power(10, rmax[0]);
06401 } else {
06402 bmin = rmin[0];
06403 bmax = rmax[0];
06404 }
06405
06406 if (fXaxis->GetTimeDisplay()) {
06407
06408 strlcat(chopax,"t",8);
06409 if (strlen(fXaxis->GetTimeFormatOnly()) == 0) {
06410 axis->SetTimeFormat(fXaxis->ChooseTimeFormat(bmax-bmin));
06411 } else {
06412 axis->SetTimeFormat(fXaxis->GetTimeFormat());
06413 }
06414 }
06415 axis->SetOption(chopax);
06416 axis->PaintAxis(x1[0], x1[1], x2[0], x2[1], bmin, bmax, ndivx, chopax);
06417 }
06418
06419
06420 if (TMath::Abs(y1[0] - y2[0]) >= epsil || TMath::Abs(y1[1] - y2[1]) > epsil) {
06421 axis->ImportAxisAttributes(fYaxis);
06422 axis->SetLabelOffset(fYaxis->GetLabelOffset()+fYaxis->GetTickLength());
06423
06424 if (fH->GetDimension() < 2) {
06425 strlcpy(chopay, "V=+UN",8);
06426 ndivy = 0;
06427 }
06428 if (TMath::Abs(y1[0] - y2[0]) < epsil) {
06429 y2[0] = y1[0];
06430 }
06431 if (Hoption.Logy && !fH->InheritsFrom(TH3::Class())) {
06432 bmin = TMath::Power(10, rmin[1]);
06433 bmax = TMath::Power(10, rmax[1]);
06434 } else {
06435 bmin = rmin[1];
06436 bmax = rmax[1];
06437 }
06438
06439 if (fYaxis->GetTimeDisplay()) {
06440
06441 strlcat(chopay,"t",8);
06442 if (strlen(fYaxis->GetTimeFormatOnly()) == 0) {
06443 axis->SetTimeFormat(fYaxis->ChooseTimeFormat(bmax-bmin));
06444 } else {
06445 axis->SetTimeFormat(fYaxis->GetTimeFormat());
06446 }
06447 }
06448 axis->SetOption(chopay);
06449 axis->PaintAxis(y1[0], y1[1], y2[0], y2[1], bmin, bmax, ndivy, chopay);
06450 }
06451
06452
06453 if (TMath::Abs(z1[0] - z2[0]) >= 100*epsil || TMath::Abs(z1[1] - z2[1]) > 100*epsil) {
06454 axis->ImportAxisAttributes(fZaxis);
06455 if (Hoption.Logz && !fH->InheritsFrom(TH3::Class())) {
06456 bmin = TMath::Power(10, rmin[2]);
06457 bmax = TMath::Power(10, rmax[2]);
06458 } else {
06459 bmin = rmin[2];
06460 bmax = rmax[2];
06461 }
06462
06463 if (fZaxis->GetTimeDisplay()) {
06464
06465 strlcat(chopaz,"t",8);
06466 if (strlen(fZaxis->GetTimeFormatOnly()) == 0) {
06467 axis->SetTimeFormat(fZaxis->ChooseTimeFormat(bmax-bmin));
06468 } else {
06469 axis->SetTimeFormat(fZaxis->GetTimeFormat());
06470 }
06471 }
06472 axis->SetOption(chopaz);
06473 axis->PaintAxis(z1[0], z1[1], z2[0], z2[1], bmin, bmax, ndivz, chopaz);
06474 }
06475
06476 fH->SetLineStyle(1);
06477 }
06478
06479
06480
06481 void THistPainter::PaintPalette()
06482 {
06483
06484
06485
06486
06487 TPaletteAxis *palette = (TPaletteAxis*)fFunctions->FindObject("palette");
06488 TView *view = gPad->GetView();
06489 if (palette) {
06490 if (view) {
06491 if (!palette->TestBit(TPaletteAxis::kHasView)) {
06492 delete palette; palette = 0;
06493 }
06494 } else {
06495 if (palette->TestBit(TPaletteAxis::kHasView)) {
06496 delete palette; palette = 0;
06497 }
06498 }
06499 }
06500
06501 if (!palette) {
06502 Double_t xup = gPad->GetUxmax();
06503 Double_t x2 = gPad->PadtoX(gPad->GetX2());
06504 Double_t ymin = gPad->PadtoY(gPad->GetUymin());
06505 Double_t ymax = gPad->PadtoY(gPad->GetUymax());
06506 Double_t xr = 0.05*(gPad->GetX2() - gPad->GetX1());
06507 Double_t xmin = gPad->PadtoX(xup +0.1*xr);
06508 Double_t xmax = gPad->PadtoX(xup + xr);
06509 if (xmax > x2) xmax = gPad->PadtoX(gPad->GetX2()-0.01*xr);
06510 palette = new TPaletteAxis(xmin,ymin,xmax,ymax,fH);
06511 fFunctions->Add(palette);
06512 palette->Paint();
06513 }
06514 }
06515
06516
06517
06518 void THistPainter::PaintScatterPlot(Option_t *option)
06519 {
06520
06521
06522
06523
06524 fH->TAttMarker::Modify();
06525
06526 Int_t k, marker;
06527 Double_t dz, z, xk,xstep, yk, ystep;
06528 Double_t scale = 1;
06529 Bool_t ltest = kFALSE;
06530 Double_t zmax = fH->GetMaximum();
06531 Double_t zmin = fH->GetMinimum();
06532 if (zmin == 0 && zmax == 0) return;
06533 if (zmin == zmax) {
06534 zmax += 0.1*TMath::Abs(zmax);
06535 zmin -= 0.1*TMath::Abs(zmin);
06536 }
06537 Int_t ncells = (Hparam.ylast-Hparam.yfirst)*(Hparam.xlast-Hparam.xfirst);
06538 if (Hoption.Logz) {
06539 if (zmin > 0) zmin = TMath::Log10(zmin);
06540 else zmin = 0;
06541 if (zmax > 0) zmax = TMath::Log10(zmax);
06542 else zmax = 0;
06543 if (zmin == 0 && zmax == 0) return;
06544 dz = zmax - zmin;
06545 scale = 100/dz;
06546 if (ncells > 10000) scale /= 5;
06547 ltest = kTRUE;
06548 } else {
06549 dz = zmax - zmin;
06550 if (dz >= kNMAX || zmax < 1) {
06551 scale = (kNMAX-1)/dz;
06552 if (ncells > 10000) scale /= 5;
06553 ltest = kTRUE;
06554 }
06555 }
06556 if (fH->GetMinimumStored() == -1111) {
06557 Double_t yMARGIN = gStyle->GetHistTopMargin();
06558 if (gStyle->GetHistMinimumZero()) {
06559 if (zmin >= 0) zmin = 0;
06560 else zmin -= yMARGIN*(zmax-zmin);
06561 } else {
06562 Double_t dzmin = yMARGIN*(zmax-zmin);
06563 if (zmin >= 0 && (zmin-dzmin <= 0)) zmin = 0;
06564 else zmin -= dzmin;
06565 }
06566 }
06567
06568 TString opt = option;
06569 opt.ToLower();
06570 if (opt.Contains("scat=")) {
06571 char optscat[100];
06572 strlcpy(optscat,opt.Data(),100);
06573 char *oscat = strstr(optscat,"scat=");
06574 char *blank = strstr(oscat," "); if (blank) *blank = 0;
06575 sscanf(oscat+5,"%lg",&scale);
06576 }
06577 UInt_t seedsave = gRandom->GetSeed();
06578 gRandom->SetSeed();
06579 marker=0;
06580 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
06581 yk = fYaxis->GetBinLowEdge(j);
06582 ystep = fYaxis->GetBinWidth(j);
06583 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
06584 Int_t bin = j*(fXaxis->GetNbins()+2) + i;
06585 xk = fXaxis->GetBinLowEdge(i);
06586 xstep = fXaxis->GetBinWidth(i);
06587 if (!IsInside(xk+0.5*xstep,yk+0.5*ystep)) continue;
06588 z = fH->GetBinContent(bin);
06589 if (z < zmin) z = zmin;
06590 if (z > zmax) z = zmax;
06591 if (Hoption.Logz) {
06592 if (z > 0) z = TMath::Log10(z) - zmin;
06593 } else {
06594 z -= zmin;
06595 }
06596 if (z <= 0) continue;
06597 k = Int_t(z*scale);
06598 if (ltest) k++;
06599 if (k > 0) {
06600 for (Int_t loop=0; loop<k; loop++) {
06601 if (k+marker >= kNMAX) {
06602 gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
06603 marker=0;
06604 }
06605 fXbuf[marker] = (gRandom->Rndm(loop)*xstep) + xk;
06606 fYbuf[marker] = (gRandom->Rndm(loop)*ystep) + yk;
06607 if (Hoption.Logx){
06608 if (fXbuf[marker] > 0) fXbuf[marker] = TMath::Log10(fXbuf[marker]);
06609 else break;
06610 }
06611 if (Hoption.Logy){
06612 if (fYbuf[marker] > 0) fYbuf[marker] = TMath::Log10(fYbuf[marker]);
06613 else break;
06614 }
06615 if (fXbuf[marker] < gPad->GetUxmin()) break;
06616 if (fYbuf[marker] < gPad->GetUymin()) break;
06617 if (fXbuf[marker] > gPad->GetUxmax()) break;
06618 if (fYbuf[marker] > gPad->GetUymax()) break;
06619 marker++;
06620 }
06621 }
06622 }
06623 }
06624 if (marker > 0) gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
06625 gRandom->SetSeed(seedsave);
06626
06627 if (Hoption.Zscale) PaintPalette();
06628 }
06629
06630
06631
06632 void THistPainter::PaintSpecialObjects(const TObject *obj, Option_t *option)
06633 {
06634
06635
06636
06637
06638
06639
06640
06641 if (!obj) return;
06642 Bool_t status = TH1::AddDirectoryStatus();
06643 TH1::AddDirectory(kFALSE);
06644
06645 if (obj->InheritsFrom(TMatrixFBase::Class())) {
06646
06647 TH2F *R__TMatrixFBase = new TH2F((TMatrixFBase &)*obj);
06648 R__TMatrixFBase->SetBit(kCanDelete);
06649 R__TMatrixFBase->Draw(option);
06650
06651 } else if (obj->InheritsFrom(TMatrixDBase::Class())) {
06652
06653 TH2D *R__TMatrixDBase = new TH2D((TMatrixDBase &)*obj);
06654 R__TMatrixDBase->SetBit(kCanDelete);
06655 R__TMatrixDBase->Draw(option);
06656
06657 } else if (obj->InheritsFrom(TVectorF::Class())) {
06658
06659 TH1F *R__TVectorF = new TH1F((TVectorF &)*obj);
06660 R__TVectorF->SetBit(kCanDelete);
06661 R__TVectorF->Draw(option);
06662
06663 } else if (obj->InheritsFrom(TVectorD::Class())) {
06664
06665 TH1D *R__TVectorD = new TH1D((TVectorD &)*obj);
06666 R__TVectorD->SetBit(kCanDelete);
06667 R__TVectorD->Draw(option);
06668 }
06669
06670 TH1::AddDirectory(status);
06671 }
06672
06673
06674
06675 void THistPainter::PaintStat(Int_t dostat, TF1 *fit)
06676 {
06677
06678
06679
06680
06681 static char t[100];
06682 Int_t dofit;
06683 TPaveStats *stats = 0;
06684 TIter next(fFunctions);
06685 TObject *obj;
06686 while ((obj = next())) {
06687 if (obj->InheritsFrom(TPaveStats::Class())) {
06688 stats = (TPaveStats*)obj;
06689 break;
06690 }
06691 }
06692
06693 if (stats && dostat) {
06694 dofit = stats->GetOptFit();
06695 dostat = stats->GetOptStat();
06696 } else {
06697 dofit = gStyle->GetOptFit();
06698 }
06699 if (!dofit) fit = 0;
06700 if (dofit == 1) dofit = 111;
06701 if (dostat == 1) dostat = 1111;
06702 Int_t print_name = dostat%10;
06703 Int_t print_entries = (dostat/10)%10;
06704 Int_t print_mean = (dostat/100)%10;
06705 Int_t print_rms = (dostat/1000)%10;
06706 Int_t print_under = (dostat/10000)%10;
06707 Int_t print_over = (dostat/100000)%10;
06708 Int_t print_integral= (dostat/1000000)%10;
06709 Int_t print_skew = (dostat/10000000)%10;
06710 Int_t print_kurt = (dostat/100000000)%10;
06711 Int_t nlines = print_name + print_entries + print_mean + print_rms +
06712 print_under + print_over + print_integral +
06713 print_skew + print_kurt;
06714 Int_t print_fval = dofit%10;
06715 Int_t print_ferrors = (dofit/10)%10;
06716 Int_t print_fchi2 = (dofit/100)%10;
06717 Int_t print_fprob = (dofit/1000)%10;
06718 Int_t nlinesf = print_fval + print_fchi2 + print_fprob;
06719 if (fit) {
06720 if (print_fval < 2) nlinesf += fit->GetNumberFreeParameters();
06721 else nlinesf += fit->GetNpar();
06722 }
06723 if (fH->InheritsFrom(TProfile::Class())) nlinesf += print_mean + print_rms;
06724
06725
06726 Bool_t done = kFALSE;
06727 if (!dostat && !fit) {
06728 if (stats) { fFunctions->Remove(stats); delete stats;}
06729 return;
06730 }
06731 Double_t statw = gStyle->GetStatW();
06732 if (fit) statw = 1.8*gStyle->GetStatW();
06733 Double_t stath = (nlines+nlinesf)*gStyle->GetStatFontSize();
06734 if (stath <= 0 || 3 == (gStyle->GetStatFont()%10)) {
06735 stath = 0.25*(nlines+nlinesf)*gStyle->GetStatH();
06736 }
06737 if (stats) {
06738 stats->Clear();
06739 done = kTRUE;
06740 } else {
06741 stats = new TPaveStats(
06742 gStyle->GetStatX()-statw,
06743 gStyle->GetStatY()-stath,
06744 gStyle->GetStatX(),
06745 gStyle->GetStatY(),"brNDC");
06746
06747 stats->SetParent(fH);
06748 stats->SetOptFit(dofit);
06749 stats->SetOptStat(dostat);
06750 stats->SetFillColor(gStyle->GetStatColor());
06751 stats->SetFillStyle(gStyle->GetStatStyle());
06752 stats->SetBorderSize(gStyle->GetStatBorderSize());
06753 stats->SetTextFont(gStyle->GetStatFont());
06754 if (gStyle->GetStatFont()%10 > 2)
06755 stats->SetTextSize(gStyle->GetStatFontSize());
06756 stats->SetFitFormat(gStyle->GetFitFormat());
06757 stats->SetStatFormat(gStyle->GetStatFormat());
06758 stats->SetName("stats");
06759
06760 stats->SetTextColor(gStyle->GetStatTextColor());
06761 stats->SetTextAlign(12);
06762 stats->SetBit(kCanDelete);
06763 stats->SetBit(kMustCleanup);
06764 }
06765 if (print_name) stats->AddText(fH->GetName());
06766 if (print_entries) {
06767 if (fH->GetEntries() < 1e7) snprintf(t,100,"%s = %-7d",gStringEntries.Data(),Int_t(fH->GetEntries()+0.5));
06768 else snprintf(t,100,"%s = %14.7g",gStringEntries.Data(),Float_t(fH->GetEntries()));
06769 stats->AddText(t);
06770 }
06771 char textstats[50];
06772 if (print_mean) {
06773 if (print_mean == 1) {
06774 snprintf(textstats,50,"%s = %s%s",gStringMean.Data(),"%",stats->GetStatFormat());
06775 snprintf(t,100,textstats,fH->GetMean(1));
06776 } else {
06777 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringMean.Data(),"%",stats->GetStatFormat()
06778 ,"%",stats->GetStatFormat());
06779 snprintf(t,100,textstats,fH->GetMean(1),fH->GetMeanError(1));
06780 }
06781 stats->AddText(t);
06782 if (fH->InheritsFrom(TProfile::Class())) {
06783 if (print_mean == 1) {
06784 snprintf(textstats,50,"%s = %s%s",gStringMeanY.Data(),"%",stats->GetStatFormat());
06785 snprintf(t,100,textstats,fH->GetMean(2));
06786 } else {
06787 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringMeanY.Data(),"%",stats->GetStatFormat()
06788 ,"%",stats->GetStatFormat());
06789 snprintf(t,100,textstats,fH->GetMean(2),fH->GetMeanError(2));
06790 }
06791 stats->AddText(t);
06792 }
06793 }
06794 if (print_rms) {
06795 if (print_rms == 1) {
06796 snprintf(textstats,50,"%s = %s%s",gStringRMS.Data(),"%",stats->GetStatFormat());
06797 snprintf(t,100,textstats,fH->GetRMS(1));
06798 } else {
06799 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringRMS.Data(),"%",stats->GetStatFormat()
06800 ,"%",stats->GetStatFormat());
06801 snprintf(t,100,textstats,fH->GetRMS(1),fH->GetRMSError(1));
06802 }
06803 stats->AddText(t);
06804 if(fH->InheritsFrom(TProfile::Class())) {
06805 if (print_rms == 1) {
06806 snprintf(textstats,50,"%s = %s%s",gStringRMSY.Data(),"%",stats->GetStatFormat());
06807 snprintf(t,100,textstats,fH->GetRMS(2));
06808 } else {
06809 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringRMSY.Data(),"%",stats->GetStatFormat()
06810 ,"%",stats->GetStatFormat());
06811 snprintf(t,100,textstats,fH->GetRMS(2),fH->GetRMSError(2));
06812 }
06813 stats->AddText(t);
06814 }
06815 }
06816 if (print_under) {
06817 snprintf(textstats,50,"%s = %s%s",gStringUnderflow.Data(),"%",stats->GetStatFormat());
06818 snprintf(t,100,textstats,fH->GetBinContent(0));
06819 stats->AddText(t);
06820 }
06821 if (print_over) {
06822 snprintf(textstats,50,"%s = %s%s",gStringOverflow.Data(),"%",stats->GetStatFormat());
06823 snprintf(t,100,textstats,fH->GetBinContent(fXaxis->GetNbins()+1));
06824 stats->AddText(t);
06825 }
06826 if (print_integral) {
06827 snprintf(textstats,50,"%s = %s%s",gStringIntegral.Data(),"%",stats->GetStatFormat());
06828 snprintf(t,100,textstats,fH->Integral());
06829 stats->AddText(t);
06830 }
06831 if (print_skew) {
06832 if (print_skew == 1) {
06833 snprintf(textstats,50,"%s = %s%s",gStringSkewness.Data(),"%",stats->GetStatFormat());
06834 snprintf(t,100,textstats,fH->GetSkewness(1));
06835 } else {
06836 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringSkewness.Data(),"%",stats->GetStatFormat()
06837 ,"%",stats->GetStatFormat());
06838 snprintf(t,100,textstats,fH->GetSkewness(1),fH->GetSkewness(11));
06839 }
06840 stats->AddText(t);
06841 }
06842 if (print_kurt) {
06843 if (print_kurt == 1) {
06844 snprintf(textstats,50,"%s = %s%s",gStringKurtosis.Data(),"%",stats->GetStatFormat());
06845 snprintf(t,100,textstats,fH->GetKurtosis(1));
06846 } else {
06847 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringKurtosis.Data(),"%",stats->GetStatFormat()
06848 ,"%",stats->GetStatFormat());
06849 snprintf(t,100,textstats,fH->GetKurtosis(1),fH->GetKurtosis(11));
06850 }
06851 stats->AddText(t);
06852 }
06853
06854
06855 if (fit) {
06856 Int_t ndf = fit->GetNDF();
06857 snprintf(textstats,50,"#chi^{2} / ndf = %s%s / %d","%",stats->GetFitFormat(),ndf);
06858 snprintf(t,100,textstats,(Float_t)fit->GetChisquare());
06859 if (print_fchi2) stats->AddText(t);
06860 if (print_fprob) {
06861 snprintf(textstats,50,"Prob = %s%s","%",stats->GetFitFormat());
06862 snprintf(t,100,textstats,(Float_t)TMath::Prob(fit->GetChisquare(),ndf));
06863 stats->AddText(t);
06864 }
06865 if (print_fval || print_ferrors) {
06866 Double_t parmin,parmax;
06867 for (Int_t ipar=0;ipar<fit->GetNpar();ipar++) {
06868 fit->GetParLimits(ipar,parmin,parmax);
06869 if (print_fval < 2 && parmin*parmax != 0 && parmin >= parmax) continue;
06870 if (print_ferrors) {
06871 snprintf(textstats,50,"%-8s = %s%s #pm %s ",fit->GetParName(ipar), "%",stats->GetFitFormat(),
06872 GetBestFormat(fit->GetParameter(ipar), fit->GetParError(ipar), stats->GetFitFormat()));
06873 snprintf(t,100,textstats,(Float_t)fit->GetParameter(ipar)
06874 ,(Float_t)fit->GetParError(ipar));
06875 } else {
06876 snprintf(textstats,50,"%-8s = %s%s ",fit->GetParName(ipar),"%",stats->GetFitFormat());
06877 snprintf(t,100,textstats,(Float_t)fit->GetParameter(ipar));
06878 }
06879 t[63] = 0;
06880 stats->AddText(t);
06881 }
06882 }
06883 }
06884
06885 if (!done) fFunctions->Add(stats);
06886 stats->Paint();
06887 }
06888
06889
06890
06891 void THistPainter::PaintStat2(Int_t dostat, TF1 *fit)
06892 {
06893
06894
06895
06896
06897 if (fH->GetDimension() != 2) return;
06898 TH2 *h2 = (TH2*)fH;
06899
06900 static char t[100];
06901 Int_t dofit;
06902 TPaveStats *stats = 0;
06903 TIter next(fFunctions);
06904 TObject *obj;
06905 while ((obj = next())) {
06906 if (obj->InheritsFrom(TPaveStats::Class())) {
06907 stats = (TPaveStats*)obj;
06908 break;
06909 }
06910 }
06911 if (stats && dostat) {
06912 dofit = stats->GetOptFit();
06913 dostat = stats->GetOptStat();
06914 } else {
06915 dofit = gStyle->GetOptFit();
06916 }
06917 if (dostat == 1) dostat = 1111;
06918 Int_t print_name = dostat%10;
06919 Int_t print_entries = (dostat/10)%10;
06920 Int_t print_mean = (dostat/100)%10;
06921 Int_t print_rms = (dostat/1000)%10;
06922 Int_t print_under = (dostat/10000)%10;
06923 Int_t print_over = (dostat/100000)%10;
06924 Int_t print_integral= (dostat/1000000)%10;
06925 Int_t print_skew = (dostat/10000000)%10;
06926 Int_t print_kurt = (dostat/100000000)%10;
06927 Int_t nlines = print_name + print_entries + 2*print_mean + 2*print_rms + print_integral;
06928 if (print_under || print_over) nlines += 3;
06929
06930
06931 if (!gStyle->GetOptFit()) fit = 0;
06932 Bool_t done = kFALSE;
06933 if (!dostat && !fit) {
06934 if (stats) delete stats;
06935 return;
06936 }
06937 Double_t statw = gStyle->GetStatW();
06938 if (fit) statw = 1.8*gStyle->GetStatW();
06939 Double_t stath = nlines*gStyle->GetStatFontSize();
06940 if (stath <= 0 || 3 == (gStyle->GetStatFont()%10)) {
06941 stath = 0.25*nlines*gStyle->GetStatH();
06942 }
06943 if (fit) stath += gStyle->GetStatH();
06944 if (stats) {
06945 stats->Clear();
06946 done = kTRUE;
06947 } else {
06948 stats = new TPaveStats(
06949 gStyle->GetStatX()-statw,
06950 gStyle->GetStatY()-stath,
06951 gStyle->GetStatX(),
06952 gStyle->GetStatY(),"brNDC");
06953
06954 stats->SetParent(fH);
06955 stats->SetOptFit(dofit);
06956 stats->SetOptStat(dostat);
06957 stats->SetFillColor(gStyle->GetStatColor());
06958 stats->SetFillStyle(gStyle->GetStatStyle());
06959 stats->SetBorderSize(gStyle->GetStatBorderSize());
06960 stats->SetName("stats");
06961
06962 stats->SetTextColor(gStyle->GetStatTextColor());
06963 stats->SetTextAlign(12);
06964 stats->SetTextFont(gStyle->GetStatFont());
06965 if (gStyle->GetStatFont()%10 > 2)
06966 stats->SetTextSize(gStyle->GetStatFontSize());
06967 stats->SetFitFormat(gStyle->GetFitFormat());
06968 stats->SetStatFormat(gStyle->GetStatFormat());
06969 stats->SetBit(kCanDelete);
06970 stats->SetBit(kMustCleanup);
06971 }
06972 if (print_name) stats->AddText(h2->GetName());
06973 if (print_entries) {
06974 if (h2->GetEntries() < 1e7) snprintf(t,100,"%s = %-7d",gStringEntries.Data(),Int_t(h2->GetEntries()+0.5));
06975 else snprintf(t,100,"%s = %14.7g",gStringEntries.Data(),Float_t(h2->GetEntries()));
06976 stats->AddText(t);
06977 }
06978 char textstats[50];
06979 if (print_mean) {
06980 if (print_mean == 1) {
06981 snprintf(textstats,50,"%s = %s%s",gStringMeanX.Data(),"%",stats->GetStatFormat());
06982 snprintf(t,50,textstats,h2->GetMean(1));
06983 stats->AddText(t);
06984 snprintf(textstats,50,"%s = %s%s",gStringMeanY.Data(),"%",stats->GetStatFormat());
06985 snprintf(t,100,textstats,h2->GetMean(2));
06986 stats->AddText(t);
06987 } else {
06988 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringMeanX.Data(),"%",stats->GetStatFormat()
06989 ,"%",stats->GetStatFormat());
06990 snprintf(t,100,textstats,h2->GetMean(1),h2->GetMeanError(1));
06991 stats->AddText(t);
06992 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringMeanY.Data(),"%",stats->GetStatFormat()
06993 ,"%",stats->GetStatFormat());
06994 snprintf(t,100,textstats,h2->GetMean(2),h2->GetMeanError(2));
06995 stats->AddText(t);
06996 }
06997 }
06998 if (print_rms) {
06999 if (print_rms == 1) {
07000 snprintf(textstats,50,"%s = %s%s",gStringRMSX.Data(),"%",stats->GetStatFormat());
07001 snprintf(t,100,textstats,h2->GetRMS(1));
07002 stats->AddText(t);
07003 snprintf(textstats,50,"%s = %s%s",gStringRMSY.Data(),"%",stats->GetStatFormat());
07004 snprintf(t,100,textstats,h2->GetRMS(2));
07005 stats->AddText(t);
07006 } else {
07007 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringRMSX.Data(),"%",stats->GetStatFormat()
07008 ,"%",stats->GetStatFormat());
07009 snprintf(t,100,textstats,h2->GetRMS(1),h2->GetRMSError(1));
07010 stats->AddText(t);
07011 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringRMSY.Data(),"%",stats->GetStatFormat()
07012 ,"%",stats->GetStatFormat());
07013 snprintf(t,100,textstats,h2->GetRMS(2),h2->GetRMSError(2));
07014 stats->AddText(t);
07015 }
07016 }
07017 if (print_integral) {
07018 snprintf(t,100,"%s = %6.4g",gStringIntegral.Data(),h2->Integral());
07019 stats->AddText(t);
07020 }
07021 if (print_skew) {
07022 if (print_skew == 1) {
07023 snprintf(textstats,50,"%s = %s%s",gStringSkewnessX.Data(),"%",stats->GetStatFormat());
07024 snprintf(t,100,textstats,h2->GetSkewness(1));
07025 stats->AddText(t);
07026 snprintf(textstats,50,"%s = %s%s",gStringSkewnessY.Data(),"%",stats->GetStatFormat());
07027 snprintf(t,100,textstats,h2->GetSkewness(2));
07028 stats->AddText(t);
07029 } else {
07030 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringSkewnessX.Data(),"%",stats->GetStatFormat()
07031 ,"%",stats->GetStatFormat());
07032 snprintf(t,100,textstats,h2->GetSkewness(1),h2->GetSkewness(11));
07033 stats->AddText(t);
07034 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringSkewnessY.Data(),"%",stats->GetStatFormat()
07035 ,"%",stats->GetStatFormat());
07036 snprintf(t,100,textstats,h2->GetSkewness(2),h2->GetSkewness(12));
07037 stats->AddText(t);
07038 }
07039 }
07040 if (print_kurt) {
07041 if (print_kurt == 1) {
07042 snprintf(textstats,50,"%s = %s%s",gStringKurtosisX.Data(),"%",stats->GetStatFormat());
07043 snprintf(t,100,textstats,h2->GetKurtosis(1));
07044 stats->AddText(t);
07045 snprintf(textstats,50,"%s = %s%s",gStringKurtosisY.Data(),"%",stats->GetStatFormat());
07046 snprintf(t,100,textstats,h2->GetKurtosis(2));
07047 stats->AddText(t);
07048 } else {
07049 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringKurtosisX.Data(),"%",stats->GetStatFormat()
07050 ,"%",stats->GetStatFormat());
07051 snprintf(t,100,textstats,h2->GetKurtosis(1),h2->GetKurtosis(11));
07052 stats->AddText(t);
07053 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringKurtosisY.Data(),"%",stats->GetStatFormat()
07054 ,"%",stats->GetStatFormat());
07055 snprintf(t,100,textstats,h2->GetKurtosis(2),h2->GetKurtosis(12));
07056 stats->AddText(t);
07057 }
07058 }
07059 if (print_under || print_over) {
07060
07061 Double_t unov[9];
07062
07063 unov[0] = h2->Integral(0,h2->GetXaxis()->GetFirst()-1,h2->GetYaxis()->GetLast()+1,h2->GetYaxis()->GetNbins()+1);
07064 unov[1] = h2->Integral(h2->GetXaxis()->GetFirst(),h2->GetXaxis()->GetLast(),h2->GetYaxis()->GetLast()+1,h2->GetYaxis()->GetNbins()+1);
07065 unov[2] = h2->Integral(h2->GetXaxis()->GetLast()+1,h2->GetXaxis()->GetNbins()+1,h2->GetYaxis()->GetLast()+1,h2->GetYaxis()->GetNbins()+1);
07066 unov[3] = h2->Integral(0,h2->GetXaxis()->GetFirst()-1,h2->GetYaxis()->GetFirst(),h2->GetYaxis()->GetLast());
07067 unov[4] = h2->Integral(h2->GetXaxis()->GetFirst(),h2->GetXaxis()->GetLast(),h2->GetYaxis()->GetFirst(),h2->GetYaxis()->GetLast());
07068 unov[5] = h2->Integral(h2->GetXaxis()->GetLast()+1,h2->GetXaxis()->GetNbins()+1,h2->GetYaxis()->GetFirst(),h2->GetYaxis()->GetLast());
07069 unov[6] = h2->Integral(0,h2->GetXaxis()->GetFirst()-1,0,h2->GetYaxis()->GetFirst()-1);
07070 unov[7] = h2->Integral(h2->GetXaxis()->GetFirst(),h2->GetXaxis()->GetLast(),0,h2->GetYaxis()->GetFirst()-1);
07071 unov[8] = h2->Integral(h2->GetXaxis()->GetLast()+1,h2->GetXaxis()->GetNbins()+1,0,h2->GetYaxis()->GetFirst()-1);
07072
07073 snprintf(t, 100," %7d|%7d|%7d\n", (Int_t)unov[0], (Int_t)unov[1], (Int_t)unov[2]);
07074 stats->AddText(t);
07075 if (h2->GetEntries() < 1e7)
07076 snprintf(t, 100," %7d|%7d|%7d\n", (Int_t)unov[3], (Int_t)unov[4], (Int_t)unov[5]);
07077 else
07078 snprintf(t, 100," %7d|%14.7g|%7d\n", (Int_t)unov[3], (Float_t)unov[4], (Int_t)unov[5]);
07079 stats->AddText(t);
07080 snprintf(t, 100," %7d|%7d|%7d\n", (Int_t)unov[6], (Int_t)unov[7], (Int_t)unov[8]);
07081 stats->AddText(t);
07082 }
07083
07084
07085 if (fit) {
07086 Int_t ndf = fit->GetNDF();
07087 snprintf(t,100,"#chi^{2} / ndf = %6.4g / %d",(Float_t)fit->GetChisquare(),ndf);
07088 stats->AddText(t);
07089 for (Int_t ipar=0;ipar<fit->GetNpar();ipar++) {
07090 snprintf(t,100,"%-8s = %5.4g #pm %5.4g ",fit->GetParName(ipar)
07091 ,(Float_t)fit->GetParameter(ipar)
07092 ,(Float_t)fit->GetParError(ipar));
07093 t[32] = 0;
07094 stats->AddText(t);
07095 }
07096 }
07097
07098 if (!done) fFunctions->Add(stats);
07099 stats->Paint();
07100 }
07101
07102
07103
07104 void THistPainter::PaintStat3(Int_t dostat, TF1 *fit)
07105 {
07106
07107
07108
07109
07110 if (fH->GetDimension() != 3) return;
07111 TH3 *h3 = (TH3*)fH;
07112
07113 static char t[100];
07114 Int_t dofit;
07115 TPaveStats *stats = 0;
07116 TIter next(fFunctions);
07117 TObject *obj;
07118 while ((obj = next())) {
07119 if (obj->InheritsFrom(TPaveStats::Class())) {
07120 stats = (TPaveStats*)obj;
07121 break;
07122 }
07123 }
07124 if (stats && dostat) {
07125 dofit = stats->GetOptFit();
07126 dostat = stats->GetOptStat();
07127 } else {
07128 dofit = gStyle->GetOptFit();
07129 }
07130 if (dostat == 1) dostat = 1111;
07131 Int_t print_name = dostat%10;
07132 Int_t print_entries = (dostat/10)%10;
07133 Int_t print_mean = (dostat/100)%10;
07134 Int_t print_rms = (dostat/1000)%10;
07135 Int_t print_under = (dostat/10000)%10;
07136 Int_t print_over = (dostat/100000)%10;
07137 Int_t print_integral= (dostat/1000000)%10;
07138 Int_t print_skew = (dostat/10000000)%10;
07139 Int_t print_kurt = (dostat/100000000)%10;
07140 Int_t nlines = print_name + print_entries + 3*print_mean + 3*print_rms + print_integral;
07141 if (print_under || print_over) nlines += 3;
07142
07143
07144 if (!gStyle->GetOptFit()) fit = 0;
07145 Bool_t done = kFALSE;
07146 if (!dostat && !fit) {
07147 if (stats) delete stats;
07148 return;
07149 }
07150 Double_t statw = gStyle->GetStatW();
07151 if (fit) statw = 1.8*gStyle->GetStatW();
07152 Double_t stath = nlines*gStyle->GetStatFontSize();
07153 if (stath <= 0 || 3 == (gStyle->GetStatFont()%10)) {
07154 stath = 0.25*nlines*gStyle->GetStatH();
07155 }
07156 if (fit) stath += gStyle->GetStatH();
07157 if (stats) {
07158 stats->Clear();
07159 done = kTRUE;
07160 } else {
07161 stats = new TPaveStats(
07162 gStyle->GetStatX()-statw,
07163 gStyle->GetStatY()-stath,
07164 gStyle->GetStatX(),
07165 gStyle->GetStatY(),"brNDC");
07166
07167 stats->SetParent(fH);
07168 stats->SetOptFit(dofit);
07169 stats->SetOptStat(dostat);
07170 stats->SetFillColor(gStyle->GetStatColor());
07171 stats->SetFillStyle(gStyle->GetStatStyle());
07172 stats->SetBorderSize(gStyle->GetStatBorderSize());
07173 stats->SetName("stats");
07174
07175 stats->SetTextColor(gStyle->GetStatTextColor());
07176 stats->SetTextAlign(12);
07177 stats->SetTextFont(gStyle->GetStatFont());
07178 stats->SetFitFormat(gStyle->GetFitFormat());
07179 stats->SetStatFormat(gStyle->GetStatFormat());
07180 stats->SetBit(kCanDelete);
07181 stats->SetBit(kMustCleanup);
07182 }
07183 if (print_name) stats->AddText(h3->GetName());
07184 if (print_entries) {
07185 if (h3->GetEntries() < 1e7) snprintf(t,100,"%s = %-7d",gStringEntries.Data(),Int_t(h3->GetEntries()+0.5));
07186 else snprintf(t,100,"%s = %14.7g",gStringEntries.Data(),Float_t(h3->GetEntries()+0.5));
07187 stats->AddText(t);
07188 }
07189 char textstats[50];
07190 if (print_mean) {
07191 if (print_mean == 1) {
07192 snprintf(textstats,50,"%s = %s%s",gStringMeanX.Data(),"%",stats->GetStatFormat());
07193 snprintf(t,100,textstats,h3->GetMean(1));
07194 stats->AddText(t);
07195 snprintf(textstats,50,"%s = %s%s",gStringMeanY.Data(),"%",stats->GetStatFormat());
07196 snprintf(t,100,textstats,h3->GetMean(2));
07197 stats->AddText(t);
07198 snprintf(textstats,50,"%s = %s%s",gStringMeanZ.Data(),"%",stats->GetStatFormat());
07199 snprintf(t,100,textstats,h3->GetMean(3));
07200 stats->AddText(t);
07201 } else {
07202 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringMeanX.Data(),"%",stats->GetStatFormat()
07203 ,"%",stats->GetStatFormat());
07204 snprintf(t,100,textstats,h3->GetMean(1),h3->GetMeanError(1));
07205 stats->AddText(t);
07206 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringMeanY.Data(),"%",stats->GetStatFormat()
07207 ,"%",stats->GetStatFormat());
07208 snprintf(t,100,textstats,h3->GetMean(2),h3->GetMeanError(2));
07209 stats->AddText(t);
07210 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringMeanZ.Data(),"%",stats->GetStatFormat()
07211 ,"%",stats->GetStatFormat());
07212 snprintf(t,100,textstats,h3->GetMean(3),h3->GetMeanError(3));
07213 stats->AddText(t);
07214 }
07215 }
07216 if (print_rms) {
07217 if (print_rms == 1) {
07218 snprintf(textstats,50,"%s = %s%s",gStringRMSX.Data(),"%",stats->GetStatFormat());
07219 snprintf(t,100,textstats,h3->GetRMS(1));
07220 stats->AddText(t);
07221 snprintf(textstats,50,"%s = %s%s",gStringRMSY.Data(),"%",stats->GetStatFormat());
07222 snprintf(t,100,textstats,h3->GetRMS(2));
07223 stats->AddText(t);
07224 snprintf(textstats,50,"%s = %s%s",gStringRMSZ.Data(),"%",stats->GetStatFormat());
07225 snprintf(t,100,textstats,h3->GetRMS(3));
07226 stats->AddText(t);
07227 } else {
07228 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringRMSX.Data(),"%",stats->GetStatFormat()
07229 ,"%",stats->GetStatFormat());
07230 snprintf(t,100,textstats,h3->GetRMS(1),h3->GetRMSError(1));
07231 stats->AddText(t);
07232 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringRMSY.Data(),"%",stats->GetStatFormat()
07233 ,"%",stats->GetStatFormat());
07234 snprintf(t,100,textstats,h3->GetRMS(2),h3->GetRMSError(2));
07235 stats->AddText(t);
07236 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringRMSZ.Data(),"%",stats->GetStatFormat()
07237 ,"%",stats->GetStatFormat());
07238 snprintf(t,100,textstats,h3->GetRMS(3),h3->GetRMSError(3));
07239 stats->AddText(t);
07240 }
07241 }
07242 if (print_integral) {
07243 snprintf(t,100,"%s = %6.4g",gStringIntegral.Data(),h3->Integral());
07244 stats->AddText(t);
07245 }
07246 if (print_skew) {
07247 if (print_skew == 1) {
07248 snprintf(textstats,50,"%s = %s%s",gStringSkewnessX.Data(),"%",stats->GetStatFormat());
07249 snprintf(t,100,textstats,h3->GetSkewness(1));
07250 stats->AddText(t);
07251 snprintf(textstats,50,"%s = %s%s",gStringSkewnessY.Data(),"%",stats->GetStatFormat());
07252 snprintf(t,100,textstats,h3->GetSkewness(2));
07253 stats->AddText(t);
07254 snprintf(textstats,50,"%s = %s%s",gStringSkewnessZ.Data(),"%",stats->GetStatFormat());
07255 snprintf(t,100,textstats,h3->GetSkewness(3));
07256 stats->AddText(t);
07257 } else {
07258 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringSkewnessX.Data(),"%",stats->GetStatFormat()
07259 ,"%",stats->GetStatFormat());
07260 snprintf(t,100,textstats,h3->GetSkewness(1),h3->GetSkewness(11));
07261 stats->AddText(t);
07262 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringSkewnessY.Data(),"%",stats->GetStatFormat()
07263 ,"%",stats->GetStatFormat());
07264 snprintf(t,100,textstats,h3->GetSkewness(2),h3->GetSkewness(12));
07265 stats->AddText(t);
07266 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringSkewnessZ.Data(),"%",stats->GetStatFormat()
07267 ,"%",stats->GetStatFormat());
07268 snprintf(t,100,textstats,h3->GetSkewness(3),h3->GetSkewness(13));
07269 stats->AddText(t);
07270 }
07271 }
07272 if (print_kurt) {
07273 if (print_kurt == 1) {
07274 snprintf(textstats,50,"%s = %s%s",gStringKurtosisX.Data(),"%",stats->GetStatFormat());
07275 snprintf(t,100,textstats,h3->GetKurtosis(1));
07276 stats->AddText(t);
07277 snprintf(textstats,50,"%s = %s%s",gStringKurtosisY.Data(),"%",stats->GetStatFormat());
07278 snprintf(t,100,textstats,h3->GetKurtosis(2));
07279 stats->AddText(t);
07280 snprintf(textstats,50,"%s = %s%s",gStringKurtosisZ.Data(),"%",stats->GetStatFormat());
07281 snprintf(t,100,textstats,h3->GetKurtosis(3));
07282 stats->AddText(t);
07283 } else {
07284 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringKurtosisX.Data(),"%",stats->GetStatFormat()
07285 ,"%",stats->GetStatFormat());
07286 snprintf(t,100,textstats,h3->GetKurtosis(1),h3->GetKurtosis(11));
07287 stats->AddText(t);
07288 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringKurtosisY.Data(),"%",stats->GetStatFormat()
07289 ,"%",stats->GetStatFormat());
07290 snprintf(t,100,textstats,h3->GetKurtosis(2),h3->GetKurtosis(12));
07291 stats->AddText(t);
07292 snprintf(textstats,50,"%s = %s%s #pm %s%s",gStringKurtosisZ.Data(),"%",stats->GetStatFormat()
07293 ,"%",stats->GetStatFormat());
07294 snprintf(t,100,textstats,h3->GetKurtosis(3),h3->GetKurtosis(13));
07295 stats->AddText(t);
07296 }
07297 }
07298 if (print_under || print_over) {
07299
07300
07301
07302
07303
07304
07305
07306
07307
07308
07309
07310
07311
07312
07313
07314
07315
07316
07317
07318
07319
07320
07321
07322
07323 }
07324
07325
07326 if (fit) {
07327 Int_t ndf = fit->GetNDF();
07328 snprintf(t,100,"#chi^{2} / ndf = %6.4g / %d",(Float_t)fit->GetChisquare(),ndf);
07329 stats->AddText(t);
07330 for (Int_t ipar=0;ipar<fit->GetNpar();ipar++) {
07331 snprintf(t,100,"%-8s = %5.4g #pm %5.4g ",fit->GetParName(ipar)
07332 ,(Float_t)fit->GetParameter(ipar)
07333 ,(Float_t)fit->GetParError(ipar));
07334 t[32] = 0;
07335 stats->AddText(t);
07336 }
07337 }
07338
07339 if (!done) fFunctions->Add(stats);
07340 stats->Paint();
07341 }
07342
07343
07344
07345 void THistPainter::PaintSurface(Option_t *)
07346 {
07347
07348
07349
07350
07351 const Double_t ydiff = 1;
07352 const Double_t yligh1 = 10;
07353 const Double_t qa = 0.15;
07354 const Double_t qd = 0.15;
07355 const Double_t qs = 0.8;
07356 Double_t fmin, fmax;
07357 Int_t raster = 0;
07358 Int_t irep = 0;
07359
07360 if (Hparam.zmin == 0 && Hparam.zmax == 0) {Hparam.zmin = -1; Hparam.zmax = 1;}
07361 Int_t nx = Hparam.xlast - Hparam.xfirst;
07362 Int_t ny = Hparam.ylast - Hparam.yfirst;
07363 Double_t zmin = Hparam.zmin;
07364 Double_t zmax = Hparam.zmax;
07365 Double_t xlab1 = Hparam.xmin;
07366 Double_t xlab2 = Hparam.xmax;
07367 Double_t ylab1 = Hparam.ymin;
07368 Double_t ylab2 = Hparam.ymax;
07369 Double_t dangle = 10*3.141592/180;
07370 Double_t deltaz = TMath::Abs(zmin);
07371 if (deltaz == 0) deltaz = 1;
07372 if (zmin >= zmax) {
07373 zmin -= 0.5*deltaz;
07374 zmax += 0.5*deltaz;
07375 }
07376 Double_t z1c = zmin;
07377 Double_t z2c = zmin + (zmax-zmin)*(1+gStyle->GetHistTopMargin());
07378
07379 fXbuf[0] = -1;
07380 fYbuf[0] = 1;
07381 fXbuf[1] = -1;
07382 fYbuf[1] = 1;
07383 if (Hoption.System >= kPOLAR && (Hoption.Surf == 1 || Hoption.Surf == 13)) raster = 1;
07384 if (Hoption.System == kPOLAR) {
07385 fXbuf[2] = z1c;
07386 fYbuf[2] = z2c;
07387 } else if (Hoption.System == kCYLINDRICAL) {
07388 if (Hoption.Logy) {
07389 if (ylab1 > 0) fXbuf[2] = TMath::Log10(ylab1);
07390 else fXbuf[2] = 0;
07391 if (ylab2 > 0) fYbuf[2] = TMath::Log10(ylab2);
07392 else fYbuf[2] = 0;
07393 } else {
07394 fXbuf[2] = ylab1;
07395 fYbuf[2] = ylab2;
07396 }
07397 z1c = 0; z2c = 1;
07398 } else if (Hoption.System == kSPHERICAL) {
07399 fXbuf[2] = -1;
07400 fYbuf[2] = 1;
07401 z1c = 0; z2c = 1;
07402 } else if (Hoption.System == kRAPIDITY) {
07403 fXbuf[2] = -1/TMath::Tan(dangle);
07404 fYbuf[2] = 1/TMath::Tan(dangle);
07405 } else {
07406 fXbuf[0] = xlab1;
07407 fYbuf[0] = xlab2;
07408 fXbuf[1] = ylab1;
07409 fYbuf[1] = ylab2;
07410 fXbuf[2] = z1c;
07411 fYbuf[2] = z2c;
07412 }
07413
07414 fLego = new TPainter3dAlgorithms(fXbuf, fYbuf, Hoption.System);
07415 fLego->SetLineColor(fH->GetLineColor());
07416 fLego->SetFillColor(fH->GetFillColor());
07417
07418
07419
07420 TGaxis *axis = new TGaxis();
07421
07422
07423 Int_t ndiv = fH->GetContour();
07424 if (ndiv == 0 ) {
07425 ndiv = gStyle->GetNumberContours();
07426 fH->SetContour(ndiv);
07427 }
07428 Int_t ndivz = TMath::Abs(ndiv);
07429 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
07430
07431 if (Hoption.Surf == 13 || Hoption.Surf == 15) fLego->SetMesh(3);
07432 if (Hoption.Surf == 12 || Hoption.Surf == 14 || Hoption.Surf == 17) fLego->SetMesh(0);
07433
07434
07435
07436 if (Hoption.System != kCARTESIAN) {nx++; ny++;}
07437
07438
07439
07440 TView *view = gPad->GetView();
07441 if (!view) {
07442 Error("PaintSurface", "no TView in current pad");
07443 return;
07444 }
07445
07446 Double_t thedeg = 90 - gPad->GetTheta();
07447 Double_t phideg = -90 - gPad->GetPhi();
07448 Double_t psideg = view->GetPsi();
07449 view->SetView(phideg, thedeg, psideg, irep);
07450
07451
07452 if (Hoption.Same) {
07453 fLego->SetFillStyle(0);
07454 fLego->SetFillColor(1);
07455 } else {
07456 fLego->SetFillStyle(gPad->GetFrameFillStyle());
07457 fLego->SetFillColor(gPad->GetFrameFillColor());
07458 }
07459 fLego->TAttFill::Modify();
07460
07461 Int_t backcolor = gPad->GetFrameFillColor();
07462 if (Hoption.System != kCARTESIAN) backcolor = 0;
07463 view->PadRange(backcolor);
07464
07465 fLego->SetFillStyle(fH->GetFillStyle());
07466 fLego->SetFillColor(fH->GetFillColor());
07467 fLego->TAttFill::Modify();
07468
07469
07470 Int_t icol1 = fH->GetFillColor();
07471
07472 Int_t hoption35 = Hoption.Surf;
07473 if (Hoption.Surf == 13 || Hoption.Surf == 15) {
07474 DefineColorLevels(ndivz);
07475 Hoption.Surf = 23;
07476 fLego->SetSurfaceFunction(&TPainter3dAlgorithms::SurfaceFunction);
07477 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode2);
07478 if (Hoption.System == kPOLAR) fLego->SurfacePolar(1,nx,ny,"BF");
07479 if (Hoption.System == kCYLINDRICAL) fLego->SurfaceCylindrical(1,nx,ny,"BF");
07480 if (Hoption.System == kSPHERICAL) fLego->SurfaceSpherical(0,1,nx,ny,"BF");
07481 if (Hoption.System == kRAPIDITY ) fLego->SurfaceSpherical(1,1,nx,ny,"BF");
07482 if (Hoption.System == kCARTESIAN) fLego->SurfaceCartesian(90,nx,ny,"BF");
07483 Hoption.Surf = hoption35;
07484 fLego->SetMesh(1);
07485 }
07486
07487 if (raster) fLego->InitRaster(-1.1,-1.1,1.1,1.1,1000,800);
07488 else fLego->InitMoveScreen(-1.1,1.1);
07489
07490 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 14 || Hoption.Surf == 17) {
07491 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
07492 fLego->SetLineColor(1);
07493 if (Hoption.System == kCARTESIAN && Hoption.BackBox) {
07494 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
07495 fLego->BackBox(90);
07496 }
07497 }
07498
07499
07500 if (Hoption.Surf == 14) {
07501
07502 fLego->LightSource(0, ydiff, 0,0,0,irep);
07503 fLego->LightSource(1, yligh1 ,1,1,1,irep);
07504 fLego->SurfaceProperty(qa, qd, qs, 1, irep);
07505 fmin = ydiff*qa;
07506 fmax = fmin + (yligh1+0.1)*(qd+qs);
07507 Int_t nbcol = 28;
07508 icol1 = 201;
07509 Double_t dcol = 0.5/Double_t(nbcol);
07510 TColor *colref = gROOT->GetColor(fH->GetFillColor());
07511 Float_t r,g,b,hue,light,satur;
07512 colref->GetRGB(r,g,b);
07513 TColor::RGBtoHLS(r,g,b,hue,light,satur);
07514 TColor *acol;
07515 for (Int_t col=0;col<nbcol;col++) {
07516 acol = gROOT->GetColor(col+icol1);
07517 TColor::HLStoRGB(hue,.4+col*dcol,satur,r,g,b);
07518 acol->SetRGB(r,g,b);
07519 }
07520 fLego->Spectrum(nbcol, fmin, fmax, icol1, 1, irep);
07521 fLego->SetSurfaceFunction(&TPainter3dAlgorithms::GouraudFunction);
07522 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode2);
07523 if (Hoption.System == kPOLAR) fLego->SurfacePolar(1,nx,ny,"BF");
07524 if (Hoption.System == kCYLINDRICAL) fLego->SurfaceCylindrical(1,nx,ny,"BF");
07525 if (Hoption.System == kSPHERICAL) fLego->SurfaceSpherical(0,1,nx,ny,"BF");
07526 if (Hoption.System == kRAPIDITY ) fLego->SurfaceSpherical(1,1,nx,ny,"BF");
07527 if (Hoption.System == kCARTESIAN) fLego->SurfaceCartesian(90,nx,ny,"BF");
07528 } else if (Hoption.Surf == 15) {
07529
07530 } else {
07531
07532 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 16 || Hoption.Surf == 17) {
07533 DefineColorLevels(ndivz);
07534 } else {
07535 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
07536 }
07537 fLego->SetSurfaceFunction(&TPainter3dAlgorithms::SurfaceFunction);
07538 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceRaster1);
07539 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode2);
07540 if (Hoption.System == kPOLAR) {
07541 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SurfacePolar(1,nx,ny,"FB");
07542 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfacePolar(1,nx,ny,"BF");
07543 } else if (Hoption.System == kCYLINDRICAL) {
07544 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SurfaceCylindrical(1,nx,ny,"FB");
07545 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfaceCylindrical(1,nx,ny,"BF");
07546 } else if (Hoption.System == kSPHERICAL) {
07547 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SurfaceSpherical(0,1,nx,ny,"FB");
07548 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfaceSpherical(0,1,nx,ny,"BF");
07549 } else if (Hoption.System == kRAPIDITY) {
07550 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SurfaceSpherical(1,1,nx,ny,"FB");
07551 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfaceSpherical(1,1,nx,ny,"BF");
07552 } else {
07553 if (Hoption.Surf == 1 || Hoption.Surf == 13) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
07554 if (Hoption.Surf == 16) fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove3);
07555 if (Hoption.Surf == 1 || Hoption.Surf == 13 || Hoption.Surf == 16) fLego->SurfaceCartesian(90,nx,ny,"FB");
07556 if (Hoption.Surf == 11 || Hoption.Surf == 12 || Hoption.Surf == 17) fLego->SurfaceCartesian(90,nx,ny,"BF");
07557 }
07558 }
07559
07560
07561 if (Hoption.Surf == 17) {
07562 fLego->InitMoveScreen(-1.1,1.1);
07563 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
07564 Hoption.Surf = 23;
07565 fLego->SetSurfaceFunction(&TPainter3dAlgorithms::SurfaceFunction);
07566 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove3);
07567 if (Hoption.System == kPOLAR) fLego->SurfacePolar(1,nx,ny,"FB");
07568 if (Hoption.System == kCYLINDRICAL) fLego->SurfaceCylindrical(1,nx,ny,"FB");
07569 if (Hoption.System == kSPHERICAL) fLego->SurfaceSpherical(0,1,nx,ny,"FB");
07570 if (Hoption.System == kRAPIDITY ) fLego->SurfaceSpherical(1,1,nx,ny,"FB");
07571 if (Hoption.System == kCARTESIAN) fLego->SurfaceCartesian(90,nx,ny,"FB");
07572 }
07573
07574 if ((!Hoption.Same) &&
07575 (Hoption.Surf == 1 || Hoption.Surf == 13 || Hoption.Surf == 16)) {
07576 fLego->SetLineColor(1);
07577 if (Hoption.System == kCARTESIAN && Hoption.BackBox) {
07578 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
07579 fLego->BackBox(90);
07580 }
07581 }
07582 if (Hoption.System == kCARTESIAN) {
07583 fLego->InitMoveScreen(-1.1,1.1);
07584 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
07585 if (Hoption.FrontBox) fLego->FrontBox(90);
07586 }
07587 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
07588
07589 if (Hoption.Zscale) PaintPalette();
07590
07591 delete axis;
07592 delete fLego; fLego = 0;
07593 }
07594
07595
07596
07597 void THistPainter::PaintTriangles(Option_t *option)
07598 {
07599
07600
07601
07602
07603 TGraphDelaunay *dt;
07604
07605
07606 TList *hl = fH->GetListOfFunctions();
07607 dt = (TGraphDelaunay*)hl->FindObject("TGraphDelaunay");
07608 if (!dt) return;
07609
07610
07611 if (!fGraph2DPainter) fGraph2DPainter = new TGraph2DPainter(dt);
07612
07613
07614 if (Hoption.Same) {
07615 TView *viewsame = gPad->GetView();
07616 if (!viewsame) {
07617 Error("PaintTriangles", "no TView in current pad, do not use option SAME");
07618 return;
07619 }
07620 Double_t *rmin = viewsame->GetRmin();
07621 Double_t *rmax = viewsame->GetRmax();
07622 fXbuf[0] = rmin[0];
07623 fYbuf[0] = rmax[0];
07624 fXbuf[1] = rmin[1];
07625 fYbuf[1] = rmax[1];
07626 fXbuf[2] = rmin[2];
07627 fYbuf[2] = rmax[2];
07628 } else {
07629 fXbuf[0] = Hparam.xmin;
07630 fYbuf[0] = Hparam.xmax;
07631 fXbuf[1] = Hparam.ymin;
07632 fYbuf[1] = Hparam.ymax;
07633 fXbuf[2] = Hparam.zmin;
07634 fYbuf[2] = Hparam.zmax;
07635 }
07636
07637 fLego = new TPainter3dAlgorithms(fXbuf, fYbuf);
07638 TView *view = gPad->GetView();
07639 if (!view) {
07640 Error("PaintTriangles", "no TView in current pad");
07641 return;
07642 }
07643 Double_t thedeg = 90 - gPad->GetTheta();
07644 Double_t phideg = -90 - gPad->GetPhi();
07645 Double_t psideg = view->GetPsi();
07646 Int_t irep;
07647 view->SetView(phideg, thedeg, psideg, irep);
07648
07649
07650 fLego->SetFillStyle(gPad->GetFrameFillStyle());
07651 fLego->SetFillColor(gPad->GetFrameFillColor());
07652 fLego->TAttFill::Modify();
07653 Int_t backcolor = gPad->GetFrameFillColor();
07654 if (Hoption.System != kCARTESIAN) backcolor = 0;
07655 view->PadRange(backcolor);
07656 fLego->SetFillStyle(fH->GetFillStyle());
07657 fLego->SetFillColor(fH->GetFillColor());
07658 fLego->TAttFill::Modify();
07659
07660
07661 if (Hoption.BackBox && !Hoption.Same) {
07662 fLego->InitMoveScreen(-1.1,1.1);
07663 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
07664 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
07665 fLego->BackBox(90);
07666 }
07667
07668
07669 fGraph2DPainter->Paint(option);
07670
07671
07672 if (Hoption.FrontBox) {
07673 fLego->InitMoveScreen(-1.1,1.1);
07674 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
07675 fLego->FrontBox(90);
07676 }
07677
07678
07679 if (!Hoption.Axis && !Hoption.Same) {
07680 TGaxis *axis = new TGaxis();
07681 PaintLegoAxis(axis, 90);
07682 delete axis;
07683 }
07684
07685 if (Hoption.Zscale) PaintPalette();
07686
07687 delete fLego; fLego = 0;
07688 }
07689
07690
07691
07692 void THistPainter::DefineColorLevels(Int_t ndivz)
07693 {
07694
07695
07696
07697
07698 Int_t i, irep;
07699
07700
07701 if (ndivz >= 100) {
07702 Warning("PaintSurface", "too many color levels, %d, reset to 8", ndivz);
07703 ndivz = 8;
07704 }
07705 Double_t *funlevel = new Double_t[ndivz+1];
07706 Int_t *colorlevel = new Int_t[ndivz+1];
07707 Int_t theColor;
07708 Int_t ncolors = gStyle->GetNumberOfColors();
07709 for (i = 0; i < ndivz; ++i) {
07710 funlevel[i] = fH->GetContourLevelPad(i);
07711 theColor = Int_t((i+0.99)*Float_t(ncolors)/Float_t(ndivz));
07712 colorlevel[i] = gStyle->GetColorPalette(theColor);
07713 }
07714 colorlevel[ndivz] = gStyle->GetColorPalette(ncolors-1);
07715 fLego->ColorFunction(ndivz, funlevel, colorlevel, irep);
07716 delete [] colorlevel;
07717 delete [] funlevel;
07718 }
07719
07720
07721
07722 void THistPainter::PaintTable(Option_t *option)
07723 {
07724
07725
07726
07727
07728 if (!TableInit()) return;
07729
07730 PaintFrame();
07731
07732
07733 if (!Hoption.Zscale) {
07734 TObject *palette = fFunctions->FindObject("palette");
07735 if (palette) delete palette;
07736 }
07737
07738 if (fH->InheritsFrom(TH2Poly::Class())) {
07739 if (Hoption.Color) PaintTH2PolyColorLevels(option);
07740 if (Hoption.Scat) PaintTH2PolyScatterPlot(option);
07741 if (Hoption.Text) PaintTH2PolyText(option);
07742 } else if (fH->GetEntries() != 0 && Hoption.Axis<=0) {
07743 if (Hoption.Scat) PaintScatterPlot(option);
07744 if (Hoption.Arrow) PaintArrows(option);
07745 if (Hoption.Box) PaintBoxes(option);
07746 if (Hoption.Color) PaintColorLevels(option);
07747 if (Hoption.Contour) PaintContour(option);
07748 if (Hoption.Text) PaintText(option);
07749 if (Hoption.Error >= 100) Paint2DErrors(option);
07750 }
07751
07752 if (Hoption.Lego) PaintLego(option);
07753 if (Hoption.Surf && !Hoption.Contour) PaintSurface(option);
07754 if (Hoption.Tri) PaintTriangles(option);
07755
07756 if (!Hoption.Lego && !Hoption.Surf &&
07757 !Hoption.Tri && !(Hoption.Error >= 100)) PaintAxis(kFALSE);
07758
07759 PaintTitle();
07760
07761 TF1 *fit = 0;
07762 TIter next(fFunctions);
07763 TObject *obj;
07764 while ((obj = next())) {
07765 if (obj->InheritsFrom(TF1::Class())) {
07766 fit = (TF1*)obj;
07767 break;
07768 }
07769 }
07770 if (Hoption.Same != 1) {
07771 if (!fH->TestBit(TH1::kNoStats)) {
07772 PaintStat2(gStyle->GetOptStat(),fit);
07773 }
07774 }
07775 }
07776
07777
07778
07779 void THistPainter::PaintTH2PolyBins(Option_t *option)
07780 {
07781
07782
07783
07784
07785
07786
07787
07788 TString opt = option;
07789 opt.ToLower();
07790 Bool_t line = kFALSE;
07791 Bool_t fill = kFALSE;
07792 Bool_t mark = kFALSE;
07793 if (opt.Contains("l")) line = kTRUE;
07794 if (opt.Contains("f")) fill = kTRUE;
07795 if (opt.Contains("p")) mark = kTRUE;
07796
07797 TH2PolyBin *b;
07798
07799 TIter next(((TH2Poly*)fH)->GetBins());
07800 TObject *obj, *poly;
07801
07802 while ((obj=next())) {
07803 b = (TH2PolyBin*)obj;
07804 poly = b->GetPolygon();
07805
07806
07807 if (poly->IsA() == TGraph::Class()) {
07808 TGraph *g = (TGraph*)poly;
07809 g->TAttLine::Modify();
07810 g->TAttMarker::Modify();
07811 g->TAttFill::Modify();
07812 if (line) g->Paint("L");
07813 if (fill) g->Paint("F");
07814 if (mark) g->Paint("P");
07815 }
07816
07817
07818 if (poly->IsA() == TMultiGraph::Class()) {
07819 TMultiGraph *mg = (TMultiGraph*)poly;
07820 TList *gl = mg->GetListOfGraphs();
07821 if (!gl) return;
07822 TGraph *g;
07823 TIter nextg(gl);
07824 while ((g = (TGraph*) nextg())) {
07825 g->TAttLine::Modify();
07826 g->TAttMarker::Modify();
07827 g->TAttFill::Modify();
07828 if (line) g->Paint("L");
07829 if (fill) g->Paint("F");
07830 if (mark) g->Paint("P");
07831 }
07832 }
07833 }
07834 }
07835
07836
07837
07838 void THistPainter::PaintTH2PolyColorLevels(Option_t *)
07839 {
07840
07841
07842
07843
07844 Int_t ncolors, color, theColor;
07845 Double_t z, zc;
07846 Double_t zmin = fH->GetMinimum();
07847 Double_t zmax = fH->GetMaximum();
07848 if (Hoption.Logz) {
07849 if (zmax > 0) {
07850 if (zmin <= 0) zmin = TMath::Min((Double_t)1, (Double_t)0.001*zmax);
07851 zmin = TMath::Log10(zmin);
07852 zmax = TMath::Log10(zmax);
07853 } else {
07854 return;
07855 }
07856 }
07857 Double_t dz = zmax - zmin;
07858
07859
07860 ncolors = gStyle->GetNumberOfColors();
07861 Int_t ndiv = fH->GetContour();
07862 if (ndiv == 0 ) {
07863 ndiv = gStyle->GetNumberContours();
07864 fH->SetContour(ndiv);
07865 }
07866 Int_t ndivz = TMath::Abs(ndiv);
07867 if (fH->TestBit(TH1::kUserContour) == 0) fH->SetContour(ndiv);
07868 Double_t scale = ndivz/dz;
07869
07870 TH2PolyBin *b;
07871
07872 TIter next(((TH2Poly*)fH)->GetBins());
07873 TObject *obj, *poly;
07874
07875 while ((obj=next())) {
07876 b = (TH2PolyBin*)obj;
07877 poly = b->GetPolygon();
07878
07879 z = b->GetContent();
07880 if (Hoption.Logz) {
07881 if (z > 0) z = TMath::Log10(z);
07882 else z = zmin;
07883 }
07884 if (z < zmin) continue;
07885
07886
07887 if (fH->TestBit(TH1::kUserContour)) {
07888 zc = fH->GetContourLevelPad(0);
07889 if (z < zc) continue;
07890 color = -1;
07891 for (Int_t k=0; k<ndiv; k++) {
07892 zc = fH->GetContourLevelPad(k);
07893 if (z < zc) {
07894 continue;
07895 } else {
07896 color++;
07897 }
07898 }
07899 } else {
07900 color = Int_t(0.01+(z-zmin)*scale);
07901 }
07902 theColor = Int_t((color+0.99)*Float_t(ncolors)/Float_t(ndivz));
07903 if (theColor > ncolors-1) theColor = ncolors-1;
07904
07905
07906 if (poly->IsA() == TGraph::Class()) {
07907 TGraph *g = (TGraph*)poly;
07908 g->SetFillColor(gStyle->GetColorPalette(theColor));
07909 g->TAttFill::Modify();
07910 g->Paint("F");
07911 }
07912
07913
07914 if (poly->IsA() == TMultiGraph::Class()) {
07915 TMultiGraph *mg = (TMultiGraph*)poly;
07916 TList *gl = mg->GetListOfGraphs();
07917 if (!gl) return;
07918 TGraph *g;
07919 TIter nextg(gl);
07920 while ((g = (TGraph*) nextg())) {
07921 g->SetFillColor(gStyle->GetColorPalette(theColor));
07922 g->TAttFill::Modify();
07923 g->Paint("F");
07924 }
07925 }
07926 }
07927 if (Hoption.Zscale) PaintPalette();
07928 }
07929
07930
07931
07932 void THistPainter::PaintTH2PolyScatterPlot(Option_t *)
07933 {
07934
07935
07936
07937
07938 Int_t k, loop, marker=0;
07939 Double_t z, xk,xstep, yk, ystep, xp, yp;
07940 Double_t scale = 1;
07941 Double_t zmin = fH->GetMinimum();
07942 Double_t zmax = fH->GetMaximum();
07943 if (Hoption.Logz) {
07944 if (zmax > 0) {
07945 if (zmin <= 0) zmin = TMath::Min((Double_t)1, (Double_t)0.001*zmax);
07946 zmin = TMath::Log10(zmin);
07947 zmax = TMath::Log10(zmax);
07948 } else {
07949 return;
07950 }
07951 }
07952 Double_t dz = zmax - zmin;
07953 scale = (kNMAX-1)/dz;
07954
07955 UInt_t seedsave = gRandom->GetSeed();
07956 gRandom->SetSeed();
07957
07958 TH2PolyBin *b;
07959
07960 TIter next(((TH2Poly*)fH)->GetBins());
07961 TObject *obj, *poly;
07962
07963 Double_t maxarea = 0, a;
07964 while ((obj=next())) {
07965 b = (TH2PolyBin*)obj;
07966 a = b->GetArea();
07967 if (a>maxarea) maxarea = a;
07968 }
07969
07970 next.Reset();
07971
07972 while ((obj=next())) {
07973 b = (TH2PolyBin*)obj;
07974 poly = b->GetPolygon();
07975 z = b->GetContent();
07976 if (z < zmin) z = zmin;
07977 if (z > zmax) z = zmax;
07978 if (Hoption.Logz) {
07979 if (z > 0) z = TMath::Log10(z) - zmin;
07980 } else {
07981 z -= zmin;
07982 }
07983 k = Int_t((z*scale)*(b->GetArea()/maxarea));
07984 xk = b->GetXMin();
07985 yk = b->GetYMin();
07986 xstep = b->GetXMax()-xk;
07987 ystep = b->GetYMax()-yk;
07988
07989
07990 if (poly->IsA() == TGraph::Class()) {
07991 TGraph *g = (TGraph*)poly;
07992 if (k <= 0 || z <= 0) continue;
07993 loop = 0;
07994 while (loop<k) {
07995 if (k+marker >= kNMAX) {
07996 gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
07997 marker=0;
07998 }
07999 xp = (gRandom->Rndm(loop)*xstep) + xk;
08000 yp = (gRandom->Rndm(loop)*ystep) + yk;
08001 if (g->IsInside(xp,yp)) {
08002 fXbuf[marker] = xp;
08003 fYbuf[marker] = yp;
08004 marker++;
08005 loop++;
08006 }
08007 }
08008 if (marker > 0) gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
08009 }
08010
08011
08012 if (poly->IsA() == TMultiGraph::Class()) {
08013 TMultiGraph *mg = (TMultiGraph*)poly;
08014 TList *gl = mg->GetListOfGraphs();
08015 if (!gl) return;
08016 if (k <= 0 || z <= 0) continue;
08017 loop = 0;
08018 while (loop<k) {
08019 if (k+marker >= kNMAX) {
08020 gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
08021 marker=0;
08022 }
08023 xp = (gRandom->Rndm(loop)*xstep) + xk;
08024 yp = (gRandom->Rndm(loop)*ystep) + yk;
08025 if (mg->IsInside(xp,yp)) {
08026 fXbuf[marker] = xp;
08027 fYbuf[marker] = yp;
08028 marker++;
08029 loop++;
08030 }
08031 }
08032 if (marker > 0) gPad->PaintPolyMarker(marker, fXbuf, fYbuf);
08033 }
08034 }
08035 PaintTH2PolyBins("l");
08036 gRandom->SetSeed(seedsave);
08037 }
08038
08039
08040
08041 void THistPainter::PaintTH2PolyText(Option_t *)
08042 {
08043
08044
08045
08046
08047 TLatex text;
08048 text.SetTextFont(gStyle->GetTextFont());
08049 text.SetTextColor(fH->GetMarkerColor());
08050 text.SetTextSize(0.02*fH->GetMarkerSize());
08051
08052 Double_t x, y, z, e, angle = 0;
08053 char value[50];
08054 char format[32];
08055 snprintf(format,32,"%s%s","%",gStyle->GetPaintTextFormat());
08056 if (Hoption.Text >= 1000) angle = Hoption.Text%1000;
08057 Int_t opt = (Int_t)Hoption.Text/1000;
08058
08059 text.SetTextAlign(22);
08060 if (Hoption.Text == 1) angle = 0;
08061 text.SetTextAngle(angle);
08062 text.TAttText::Modify();
08063
08064 TH2PolyBin *b;
08065
08066 TIter next(((TH2Poly*)fH)->GetBins());
08067 TObject *obj, *p;
08068
08069 while ((obj=next())) {
08070 b = (TH2PolyBin*)obj;
08071 p = b->GetPolygon();
08072 x = (b->GetXMin()+b->GetXMax())/2;
08073 if (Hoption.Logx) {
08074 if (x > 0) x = TMath::Log10(x);
08075 else continue;
08076 }
08077 y = (b->GetYMin()+b->GetYMax())/2;
08078 if (Hoption.Logy) {
08079 if (y > 0) y = TMath::Log10(y);
08080 else continue;
08081 }
08082 z = b->GetContent();
08083 if (z < Hparam.zmin || (z == 0 && !gStyle->GetHistMinimumZero()) ) continue;
08084 if (opt==2) {
08085 e = fH->GetBinError(b->GetBinNumber());
08086 snprintf(format,32,"#splitline{%s%s}{#pm %s%s}",
08087 "%",gStyle->GetPaintTextFormat(),
08088 "%",gStyle->GetPaintTextFormat());
08089 snprintf(value,50,format,z,e);
08090 } else {
08091 snprintf(value,50,format,z);
08092 }
08093 if (opt==3) text.PaintLatex(x,y,angle,0.02*fH->GetMarkerSize(),p->GetName());
08094 else text.PaintLatex(x,y,angle,0.02*fH->GetMarkerSize(),value);
08095 }
08096
08097 PaintTH2PolyBins("l");
08098 }
08099
08100
08101
08102 void THistPainter::PaintText(Option_t *)
08103 {
08104
08105
08106
08107
08108 TLatex text;
08109 text.SetTextFont(gStyle->GetTextFont());
08110 text.SetTextColor(fH->GetMarkerColor());
08111 text.SetTextSize(0.02*fH->GetMarkerSize());
08112
08113 Double_t x, y, z, e, angle = 0;
08114 char value[50];
08115 char format[32];
08116 snprintf(format,32,"%s%s","%",gStyle->GetPaintTextFormat());
08117 if (Hoption.Text >= 1000) angle = Hoption.Text%1000;
08118
08119
08120 if (fH->GetDimension() == 1) {
08121 Bool_t getentries = kFALSE;
08122 Double_t yt;
08123 TProfile *hp = (TProfile*)fH;
08124 if (Hoption.Text>2000 && fH->InheritsFrom(TProfile::Class())) {
08125 Hoption.Text = Hoption.Text-2000;
08126 getentries = kTRUE;
08127 }
08128 if (Hoption.Text == 1) angle = 90;
08129 text.SetTextAlign(11);
08130 if (angle == 90) text.SetTextAlign(12);
08131 if (angle == 0) text.SetTextAlign(21);
08132 text.TAttText::Modify();
08133 Double_t dt = 0.02*(gPad->GetY2()-gPad->GetY1());
08134 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
08135 x = fH->GetXaxis()->GetBinCenter(i);
08136 y = fH->GetBinContent(i);
08137 yt = y;
08138 if (getentries) yt = hp->GetBinEntries(i);
08139 snprintf(value,50,format,yt);
08140 if (Hoption.Logx) {
08141 if (x > 0) x = TMath::Log10(x);
08142 else continue;
08143 }
08144 if (Hoption.Logy) {
08145 if (y > 0) y = TMath::Log10(y);
08146 else continue;
08147 }
08148 if (y >= gPad->GetY2()) continue;
08149 if (y <= gPad->GetY1()) continue;
08150 text.PaintLatex(x,y+0.2*dt,angle,0.02*fH->GetMarkerSize(),value);
08151 }
08152
08153
08154 } else {
08155 text.SetTextAlign(22);
08156 if (Hoption.Text == 1) angle = 0;
08157 text.SetTextAngle(angle);
08158 text.TAttText::Modify();
08159 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
08160 y = fYaxis->GetBinCenter(j);
08161 if (Hoption.Logy) {
08162 if (y > 0) y = TMath::Log10(y);
08163 else continue;
08164 }
08165 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
08166 Int_t bin = j*(fXaxis->GetNbins()+2) + i;
08167 x = fXaxis->GetBinCenter(i);
08168 if (Hoption.Logx) {
08169 if (x > 0) x = TMath::Log10(x);
08170 else continue;
08171 }
08172 if (!IsInside(x,y)) continue;
08173 z = fH->GetBinContent(bin);
08174 if (z < Hparam.zmin || (z == 0 && !gStyle->GetHistMinimumZero()) ) continue;
08175 if (Hoption.Text>2000) {
08176 e = fH->GetBinError(bin);
08177 snprintf(format,32,"#splitline{%s%s}{#pm %s%s}",
08178 "%",gStyle->GetPaintTextFormat(),
08179 "%",gStyle->GetPaintTextFormat());
08180 snprintf(value,50,format,z,e);
08181 } else {
08182 snprintf(value,50,format,z);
08183 }
08184 text.PaintLatex(x,y,angle,0.02*fH->GetMarkerSize(),value);
08185 }
08186 }
08187 }
08188 }
08189
08190
08191
08192 void THistPainter::PaintTF3()
08193 {
08194
08195
08196
08197
08198 Int_t irep;
08199
08200 TGaxis *axis = new TGaxis();
08201 TAxis *xaxis = fH->GetXaxis();
08202 TAxis *yaxis = fH->GetYaxis();
08203 TAxis *zaxis = fH->GetZaxis();
08204
08205 fXbuf[0] = xaxis->GetBinLowEdge(xaxis->GetFirst());
08206 fYbuf[0] = xaxis->GetBinUpEdge(xaxis->GetLast());
08207 fXbuf[1] = yaxis->GetBinLowEdge(yaxis->GetFirst());
08208 fYbuf[1] = yaxis->GetBinUpEdge(yaxis->GetLast());
08209 fXbuf[2] = zaxis->GetBinLowEdge(zaxis->GetFirst());
08210 fYbuf[2] = zaxis->GetBinUpEdge(zaxis->GetLast());
08211
08212 fLego = new TPainter3dAlgorithms(fXbuf, fYbuf);
08213
08214 TView *view = gPad->GetView();
08215 if (!view) {
08216 Error("PaintTF3", "no TView in current pad");
08217 return;
08218 }
08219 Double_t thedeg = 90 - gPad->GetTheta();
08220 Double_t phideg = -90 - gPad->GetPhi();
08221 Double_t psideg = view->GetPsi();
08222 view->SetView(phideg, thedeg, psideg, irep);
08223
08224 fLego->InitMoveScreen(-1.1,1.1);
08225
08226 if (Hoption.BackBox) {
08227 fLego->DefineGridLevels(fZaxis->GetNdivisions()%100);
08228 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove1);
08229 fLego->BackBox(90);
08230 }
08231
08232 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMode1);
08233
08234 fLego->ImplicitFunction(fXbuf, fYbuf, fH->GetNbinsX(),
08235 fH->GetNbinsY(),
08236 fH->GetNbinsZ(), "BF");
08237
08238 if (Hoption.FrontBox) {
08239 fLego->InitMoveScreen(-1.1,1.1);
08240 fLego->SetDrawFace(&TPainter3dAlgorithms::DrawFaceMove2);
08241 fLego->FrontBox(90);
08242 }
08243 if (!Hoption.Axis && !Hoption.Same) PaintLegoAxis(axis, 90);
08244
08245 PaintTitle();
08246
08247 delete axis;
08248 delete fLego; fLego = 0;
08249 }
08250
08251
08252
08253 void THistPainter::PaintTitle()
08254 {
08255
08256
08257
08258
08259
08260
08261
08262
08263
08264
08265
08266
08267
08268
08269
08270 if (Hoption.Same) return;
08271 if (fH->TestBit(TH1::kNoTitle)) return;
08272 Int_t nt = strlen(fH->GetTitle());
08273 TPaveText *title = 0;
08274 TObject *obj;
08275 TIter next(gPad->GetListOfPrimitives());
08276 while ((obj = next())) {
08277 if (!obj->InheritsFrom(TPaveText::Class())) continue;
08278 title = (TPaveText*)obj;
08279 if (strcmp(title->GetName(),"title")) {title = 0; continue;}
08280 break;
08281 }
08282 if (nt == 0 || gStyle->GetOptTitle() <= 0) {
08283 if (title) delete title;
08284 return;
08285 }
08286 Double_t ht = gStyle->GetTitleH();
08287 Double_t wt = gStyle->GetTitleW();
08288 if (ht <= 0) ht = 1.1*gStyle->GetTitleFontSize();
08289 if (ht <= 0) ht = 0.05;
08290 if (wt <= 0) {
08291 TLatex l;
08292 l.SetTextSize(ht);
08293 l.SetTitle(fH->GetTitle());
08294
08295 ht = TMath::Max(ht, 1.2*l.GetYsize()/(gPad->GetY2() - gPad->GetY1()));
08296 Double_t wndc = l.GetXsize()/(gPad->GetX2() - gPad->GetX1());
08297 wt = TMath::Min(0.7, 0.02+wndc);
08298 }
08299 if (title) {
08300 TText *t0 = (TText*)title->GetLine(0);
08301 if (t0) {
08302 if (!strcmp(t0->GetTitle(),fH->GetTitle())) return;
08303 t0->SetTitle(fH->GetTitle());
08304 if (wt > 0) title->SetX2NDC(title->GetX1NDC()+wt);
08305 }
08306 return;
08307 }
08308
08309 Int_t talh = gStyle->GetTitleAlign()/10;
08310 if (talh < 1) talh = 1; if (talh > 3) talh = 3;
08311 Int_t talv = gStyle->GetTitleAlign()%10;
08312 if (talv < 1) talv = 1; if (talv > 3) talv = 3;
08313 Double_t xpos, ypos;
08314 xpos = gStyle->GetTitleX();
08315 ypos = gStyle->GetTitleY();
08316 if (talh == 2) xpos = xpos-wt/2.;
08317 if (talh == 3) xpos = xpos-wt;
08318 if (talv == 2) ypos = ypos+ht/2.;
08319 if (talv == 1) ypos = ypos+ht;
08320
08321 TPaveText *ptitle = new TPaveText(xpos, ypos-ht, xpos+wt, ypos,"blNDC");
08322
08323
08324 ptitle->SetFillColor(gStyle->GetTitleFillColor());
08325 ptitle->SetFillStyle(gStyle->GetTitleStyle());
08326 ptitle->SetName("title");
08327 ptitle->SetBorderSize(gStyle->GetTitleBorderSize());
08328 ptitle->SetTextColor(gStyle->GetTitleTextColor());
08329 ptitle->SetTextFont(gStyle->GetTitleFont(""));
08330 if (gStyle->GetTitleFont("")%10 > 2)
08331 ptitle->SetTextSize(gStyle->GetTitleFontSize());
08332 ptitle->AddText(fH->GetTitle());
08333 ptitle->SetBit(kCanDelete);
08334 ptitle->Draw();
08335 ptitle->Paint();
08336
08337 }
08338
08339
08340
08341 void THistPainter::ProcessMessage(const char *mess, const TObject *obj)
08342 {
08343
08344
08345
08346
08347 if (!strcmp(mess,"SetF3")) {
08348 TPainter3dAlgorithms::SetF3((TF3*)obj);
08349 } else if (!strcmp(mess,"SetF3ClippingBoxOff")) {
08350 TPainter3dAlgorithms::SetF3ClippingBoxOff();
08351 } else if (!strcmp(mess,"SetF3ClippingBoxOn")) {
08352 TVectorD &v = (TVectorD&)(*obj);
08353 Double_t xclip = v(0);
08354 Double_t yclip = v(1);
08355 Double_t zclip = v(2);
08356 TPainter3dAlgorithms::SetF3ClippingBoxOn(xclip,yclip,zclip);
08357 }
08358 }
08359
08360
08361
08362 Int_t THistPainter::ProjectAitoff2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
08363 {
08364
08365
08366
08367
08368
08369
08370
08371
08372
08373
08374
08375
08376 Double_t x, y;
08377
08378 Double_t alpha2 = (l/2)*TMath::DegToRad();
08379 Double_t delta = b*TMath::DegToRad();
08380 Double_t r2 = TMath::Sqrt(2.);
08381 Double_t f = 2*r2/TMath::Pi();
08382 Double_t cdec = TMath::Cos(delta);
08383 Double_t denom = TMath::Sqrt(1. + cdec*TMath::Cos(alpha2));
08384 x = cdec*TMath::Sin(alpha2)*2.*r2/denom;
08385 y = TMath::Sin(delta)*r2/denom;
08386 x *= TMath::RadToDeg()/f;
08387 y *= TMath::RadToDeg()/f;
08388
08389 Al = x;
08390 Ab = y;
08391
08392 return 0;
08393 }
08394
08395
08396
08397 Int_t THistPainter::ProjectMercator2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
08398 {
08399
08400
08401
08402
08403
08404
08405
08406
08407
08408
08409
08410
08411
08412 Al = l;
08413 Double_t aid = TMath::Tan((TMath::PiOver2() + b*TMath::DegToRad())/2);
08414 Ab = TMath::Log(aid);
08415 return 0;
08416 }
08417
08418
08419
08420 Int_t THistPainter::ProjectSinusoidal2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
08421 {
08422
08423
08424
08425
08426 Al = l*cos(b*TMath::DegToRad());
08427 Ab = b;
08428 return 0;
08429 }
08430
08431
08432
08433 Int_t THistPainter::ProjectParabolic2xy(Double_t l, Double_t b, Double_t &Al, Double_t &Ab)
08434 {
08435
08436
08437
08438
08439 Al = l*(2.*TMath::Cos(2*b*TMath::DegToRad()/3) - 1);
08440 Ab = 180*TMath::Sin(b*TMath::DegToRad()/3);
08441 return 0;
08442 }
08443
08444
08445
08446 void THistPainter::RecalculateRange()
08447 {
08448
08449
08450
08451
08452 if (Hoption.Same) return;
08453
08454
08455 Double_t xmin = Hparam.xmin;
08456 Double_t xmax = Hparam.xmax;
08457 Double_t ymin = Hparam.ymin;
08458 Double_t ymax = Hparam.ymax;
08459
08460 Double_t xmin_aid, ymin_aid, xmax_aid, ymax_aid;
08461 if (Hoption.Proj ==1) {
08462
08463 THistPainter::ProjectAitoff2xy(Hparam.xmin, Hparam.ymin, xmin_aid, ymin_aid);
08464 THistPainter::ProjectAitoff2xy(Hparam.xmin, Hparam.ymax, xmin, ymax_aid);
08465 THistPainter::ProjectAitoff2xy(Hparam.xmax, Hparam.ymax, xmax_aid, ymax);
08466 THistPainter::ProjectAitoff2xy(Hparam.xmax, Hparam.ymin, xmax, ymin);
08467
08468 if (xmin > xmin_aid) xmin = xmin_aid;
08469 if (ymin > ymin_aid) ymin = ymin_aid;
08470 if (xmax < xmax_aid) xmax = xmax_aid;
08471 if (ymax < ymax_aid) ymax = ymax_aid;
08472 if (Hparam.ymin<0 && Hparam.ymax>0) {
08473
08474 THistPainter::ProjectAitoff2xy(Hparam.xmin*0.9999, 0, xmin_aid, ymin_aid);
08475 THistPainter::ProjectAitoff2xy(Hparam.xmax*0.9999, 0, xmax_aid, ymin_aid);
08476 if (xmin >xmin_aid) xmin = xmin_aid;
08477 if (xmax <xmax_aid) xmax = xmax_aid;
08478 }
08479 if (Hparam.xmin<0 && Hparam.xmax>0) {
08480 THistPainter::ProjectAitoff2xy(0, Hparam.ymin, xmin_aid, ymin_aid);
08481 THistPainter::ProjectAitoff2xy(0, Hparam.ymax, xmax_aid, ymax_aid);
08482 if (ymin >ymin_aid) ymin = ymin_aid;
08483 if (ymax <ymax_aid) ymax = ymax_aid;
08484 }
08485 } else if ( Hoption.Proj ==2) {
08486 if (Hparam.ymin <= -90 || Hparam.ymax >=90) {
08487 Warning("Mercator Projection", "Latitude out of range %f or %f", Hparam.ymin, Hparam.ymax);
08488 Hoption.Proj = 0;
08489 } else {
08490 THistPainter::ProjectMercator2xy(Hparam.xmin, Hparam.ymin, xmin, ymin);
08491 THistPainter::ProjectMercator2xy(Hparam.xmax, Hparam.ymax, xmax, ymax);
08492 }
08493 } else if (Hoption.Proj == 3) {
08494 THistPainter::ProjectSinusoidal2xy(Hparam.xmin, Hparam.ymin, xmin_aid, ymin_aid);
08495 THistPainter::ProjectSinusoidal2xy(Hparam.xmin, Hparam.ymax, xmin, ymax_aid);
08496 THistPainter::ProjectSinusoidal2xy(Hparam.xmax, Hparam.ymax, xmax_aid, ymax);
08497 THistPainter::ProjectSinusoidal2xy(Hparam.xmax, Hparam.ymin, xmax, ymin);
08498
08499 if (xmin > xmin_aid) xmin = xmin_aid;
08500 if (ymin > ymin_aid) ymin = ymin_aid;
08501 if (xmax < xmax_aid) xmax = xmax_aid;
08502 if (ymax < ymax_aid) ymax = ymax_aid;
08503 if (Hparam.ymin<0 && Hparam.ymax>0) {
08504 THistPainter::ProjectSinusoidal2xy(Hparam.xmin, 0, xmin_aid, ymin_aid);
08505 THistPainter::ProjectSinusoidal2xy(Hparam.xmax, 0, xmax_aid, ymin_aid);
08506 if (xmin >xmin_aid) xmin = xmin_aid;
08507 if (xmax <xmax_aid) xmax = xmax_aid;
08508 }
08509 if (Hparam.xmin<0 && Hparam.xmax>0) {
08510 THistPainter::ProjectSinusoidal2xy(0,Hparam.ymin, xmin_aid, ymin_aid);
08511 THistPainter::ProjectSinusoidal2xy(0, Hparam.ymax, xmax_aid, ymin_aid);
08512 if (ymin >ymin_aid) ymin = ymin_aid;
08513 if (ymax <ymax_aid) ymax = ymax_aid;
08514 }
08515 } else if (Hoption.Proj == 4) {
08516 THistPainter::ProjectParabolic2xy(Hparam.xmin, Hparam.ymin, xmin_aid, ymin_aid);
08517 THistPainter::ProjectParabolic2xy(Hparam.xmin, Hparam.ymax, xmin, ymax_aid);
08518 THistPainter::ProjectParabolic2xy(Hparam.xmax, Hparam.ymax, xmax_aid, ymax);
08519 THistPainter::ProjectParabolic2xy(Hparam.xmax, Hparam.ymin, xmax, ymin);
08520
08521 if (xmin > xmin_aid) xmin = xmin_aid;
08522 if (ymin > ymin_aid) ymin = ymin_aid;
08523 if (xmax < xmax_aid) xmax = xmax_aid;
08524 if (ymax < ymax_aid) ymax = ymax_aid;
08525 if (Hparam.ymin<0 && Hparam.ymax>0) {
08526 THistPainter::ProjectParabolic2xy(Hparam.xmin, 0, xmin_aid, ymin_aid);
08527 THistPainter::ProjectParabolic2xy(Hparam.xmax, 0, xmax_aid, ymin_aid);
08528 if (xmin >xmin_aid) xmin = xmin_aid;
08529 if (xmax <xmax_aid) xmax = xmax_aid;
08530 }
08531 if (Hparam.xmin<0 && Hparam.xmax>0) {
08532 THistPainter::ProjectParabolic2xy(0, Hparam.ymin, xmin_aid, ymin_aid);
08533 THistPainter::ProjectParabolic2xy(0, Hparam.ymax, xmax_aid, ymin_aid);
08534 if (ymin >ymin_aid) ymin = ymin_aid;
08535 if (ymax <ymax_aid) ymax = ymax_aid;
08536 }
08537 }
08538 Hparam.xmin= xmin;
08539 Hparam.xmax= xmax;
08540 Hparam.ymin= ymin;
08541 Hparam.ymax= ymax;
08542
08543 Double_t dx = xmax-xmin;
08544 Double_t dy = ymax-ymin;
08545 Double_t dxr = dx/(1 - gPad->GetLeftMargin() - gPad->GetRightMargin());
08546 Double_t dyr = dy/(1 - gPad->GetBottomMargin() - gPad->GetTopMargin());
08547
08548
08549
08550 gPad->Range(xmin - dxr*gPad->GetLeftMargin(),
08551 ymin - dyr*gPad->GetBottomMargin(),
08552 xmax + dxr*gPad->GetRightMargin(),
08553 ymax + dyr*gPad->GetTopMargin());
08554 gPad->RangeAxis(xmin, ymin, xmax, ymax);
08555 }
08556
08557
08558
08559 void THistPainter::SetHistogram(TH1 *h)
08560 {
08561
08562
08563
08564
08565 if (h == 0) return;
08566 fH = h;
08567 fXaxis = h->GetXaxis();
08568 fYaxis = h->GetYaxis();
08569 fZaxis = h->GetZaxis();
08570 fFunctions = fH->GetListOfFunctions();
08571 }
08572
08573
08574
08575 Int_t THistPainter::TableInit()
08576 {
08577
08578
08579
08580
08581 static const char *where = "TableInit";
08582
08583 Int_t first, last;
08584 Double_t yMARGIN= gStyle->GetHistTopMargin();
08585 Double_t zmin, zmax;
08586 Int_t maximum = 0;
08587 Int_t minimum = 0;
08588 if (fH->GetMaximumStored() != -1111) maximum = 1;
08589 if (fH->GetMinimumStored() != -1111) minimum = 1;
08590
08591
08592 first = fXaxis->GetFirst();
08593 last = fXaxis->GetLast();
08594 Hparam.xlast = last;
08595 Hparam.xfirst = first;
08596 Hparam.xlowedge = fXaxis->GetBinLowEdge(first);
08597 Hparam.xbinsize = fXaxis->GetBinWidth(first);
08598 Hparam.xmin = Hparam.xlowedge;
08599 Hparam.xmax = fXaxis->GetBinLowEdge(last)+fXaxis->GetBinWidth(last);
08600
08601
08602 if (Hoption.Logx) {
08603
08604 if (Hparam.xlowedge <=0 ) {
08605 Hparam.xlowedge = fXaxis->GetBinUpEdge(fXaxis->FindFixBin(0.01*Hparam.xbinsize));
08606 Hparam.xmin = Hparam.xlowedge;
08607 }
08608 if (Hparam.xmin <=0 || Hparam.xmax <=0) {
08609 Error(where, "cannot set X axis to log scale");
08610 return 0;
08611 }
08612 Hparam.xfirst= fXaxis->FindFixBin(Hparam.xmin);
08613 if (Hparam.xfirst < first) Hparam.xfirst = first;
08614 Hparam.xlast = fXaxis->FindFixBin(Hparam.xmax);
08615 if (Hparam.xlast > last) Hparam.xlast = last;
08616 Hparam.xmin = TMath::Log10(Hparam.xmin);
08617 Hparam.xmax = TMath::Log10(Hparam.xmax);
08618 }
08619
08620
08621 first = fYaxis->GetFirst();
08622 last = fYaxis->GetLast();
08623 Hparam.ylast = last;
08624 Hparam.yfirst = first;
08625 Hparam.ylowedge = fYaxis->GetBinLowEdge(first);
08626 Hparam.ybinsize = fYaxis->GetBinWidth(first);
08627 if (!Hparam.ybinsize) Hparam.ybinsize = 1;
08628 Hparam.ymin = Hparam.ylowedge;
08629 Hparam.ymax = fYaxis->GetBinLowEdge(last)+fYaxis->GetBinWidth(last);
08630
08631
08632 if (Hoption.Logy) {
08633 if (Hparam.ylowedge <=0 ) {
08634 Hparam.ylowedge = fYaxis->GetBinUpEdge(fYaxis->FindFixBin(0.01*Hparam.ybinsize));
08635 Hparam.ymin = Hparam.ylowedge;
08636 }
08637 if (Hparam.ymin <=0 || Hparam.ymax <=0) {
08638 Error(where, "cannot set Y axis to log scale");
08639 return 0;
08640 }
08641 Hparam.yfirst= fYaxis->FindFixBin(Hparam.ymin);
08642 if (Hparam.yfirst < first) Hparam.yfirst = first;
08643 Hparam.ylast = fYaxis->FindFixBin(Hparam.ymax);
08644 if (Hparam.ylast > last) Hparam.ylast = last;
08645 Hparam.ymin = TMath::Log10(Hparam.ymin);
08646 Hparam.ymax = TMath::Log10(Hparam.ymax);
08647 }
08648
08649
08650
08651 Double_t bigp = TMath::Power(10,32);
08652 zmax = -bigp;
08653 zmin = bigp;
08654 Double_t c1, e1;
08655 Double_t allchan = 0;
08656 for (Int_t j=Hparam.yfirst; j<=Hparam.ylast;j++) {
08657 for (Int_t i=Hparam.xfirst; i<=Hparam.xlast;i++) {
08658 c1 = fH->GetCellContent(i,j);
08659 zmax = TMath::Max(zmax,c1);
08660 if (Hoption.Error) {
08661 e1 = fH->GetCellError(i,j);
08662 zmax = TMath::Max(zmax,c1+e1);
08663 }
08664 zmin = TMath::Min(zmin,c1);
08665 allchan += c1;
08666 }
08667 }
08668
08669
08670
08671 if (maximum) zmax = fH->GetMaximumStored();
08672 if (minimum) zmin = fH->GetMinimumStored();
08673 if (Hoption.Logz && zmax < 0) {
08674 if (!Hoption.Same) Error(where, "log scale is requested but maximum is less or equal 0 (%f)", zmax);
08675 return 0;
08676 } else if (Hoption.Logz && zmin>=0 && zmax==0) {
08677 zmin = 0.01;
08678 zmax = 10.;
08679 }
08680 if (zmin >= zmax) {
08681 if (Hoption.Logz) {
08682 if (zmax > 0) zmin = 0.001*zmax;
08683 else {
08684 if (!Hoption.Same) Error(where, "log scale is requested but maximum is less or equal 0 (%f)", zmax);
08685 return 0;
08686 }
08687 }
08688 }
08689
08690
08691 Hparam.allchan = allchan;
08692 Double_t factor = allchan;
08693 if (fH->GetNormFactor() > 0) factor = fH->GetNormFactor();
08694 if (allchan) factor /= allchan;
08695 if (factor == 0) factor = 1;
08696 Hparam.factor = factor;
08697 zmax = factor*zmax;
08698 zmin = factor*zmin;
08699 c1 = zmax;
08700 if (TMath::Abs(zmin) > TMath::Abs(c1)) c1 = zmin;
08701
08702
08703
08704
08705
08706 if (Hoption.Logz) {
08707 if (zmin <= 0) {
08708 zmin = TMath::Min((Double_t)1, (Double_t)0.001*zmax);
08709 fH->SetMinimum(zmin);
08710 }
08711 zmin = TMath::Log10(zmin);
08712 if (!minimum) zmin += TMath::Log10(0.5);
08713 zmax = TMath::Log10(zmax);
08714 if (!maximum) zmax += TMath::Log10(2*(0.9/0.95));
08715 goto LZMIN;
08716 }
08717
08718
08719
08720
08721
08722
08723 if (!maximum) {
08724 zmax += yMARGIN*(zmax-zmin);
08725 }
08726
08727
08728
08729
08730 if (!minimum) {
08731 if (gStyle->GetHistMinimumZero()) {
08732 if (zmin >= 0) zmin = 0;
08733 else zmin -= yMARGIN*(zmax-zmin);
08734 } else {
08735 Double_t dzmin = yMARGIN*(zmax-zmin);
08736 if (zmin >= 0 && (zmin-dzmin <= 0)) zmin = 0;
08737 else zmin -= dzmin;
08738 }
08739 }
08740
08741 LZMIN:
08742 Hparam.zmin = zmin;
08743 Hparam.zmax = zmax;
08744
08745
08746 Hparam.baroffset = fH->GetBarOffset();
08747 Hparam.barwidth = fH->GetBarWidth();
08748
08749 return 1;
08750 }
08751
08752
08753
08754 const char * THistPainter::GetBestFormat(Double_t v, Double_t e, const char *f)
08755 {
08756
08757
08758
08759
08760
08761 static char ef[20];
08762 char tf[20], tv[64];
08763
08764
08765 snprintf(tf,20,"%s%s","%",f);
08766 snprintf(tv,64,tf,v);
08767
08768
08769 TString sv = tv;
08770 int ie = sv.Index("e");
08771 int iE = sv.Index("E");
08772 int id = sv.Index(".");
08773
08774
08775
08776 if (ie >= 0 || iE >= 0) {
08777 if (sv.Index("+") >= 0) {
08778 if (e < 1) {
08779 snprintf(ef,20,"%s.1f","%");
08780 } else {
08781 if (ie >= 0) {
08782 snprintf(ef,20,"%s.%de","%",ie-id-1);
08783 } else {
08784 snprintf(ef,20,"%s.%dE","%",iE-id-1);
08785 }
08786 }
08787 } else {
08788 if (ie >= 0) {
08789 snprintf(ef,20,"%s.%de","%",ie-id-1);
08790 } else {
08791 snprintf(ef,20,"%s.%dE","%",iE-id-1);
08792 }
08793 }
08794
08795
08796 } else if (id < 0) {
08797 snprintf(ef,20,"%s.1f","%");
08798
08799
08800
08801 } else {
08802 snprintf(ef,20,"%s.%df","%",sv.Length()-id-1);
08803 }
08804
08805 return ef;
08806 }
08807
08808
08809
08810 void THistPainter::SetShowProjection(const char *option,Int_t nbins)
08811 {
08812
08813
08814
08815
08816 if (fShowProjection) return;
08817 TString opt = option;
08818 opt.ToLower();
08819 Int_t projection = 0;
08820 if (opt.Contains("x")) projection = 1;
08821 if (opt.Contains("y")) projection = 2;
08822 if (opt.Contains("z")) projection = 3;
08823 if (opt.Contains("xy")) projection = 4;
08824 if (opt.Contains("yx")) projection = 5;
08825 if (opt.Contains("xz")) projection = 6;
08826 if (opt.Contains("zx")) projection = 7;
08827 if (opt.Contains("yz")) projection = 8;
08828 if (opt.Contains("zy")) projection = 9;
08829 if (projection < 4) fShowOption = option+1;
08830 else fShowOption = option+2;
08831 fShowProjection = projection+100*nbins;
08832 gROOT->MakeDefCanvas();
08833 gPad->SetName(Form("%lx_c_projection_%d", (ULong_t)fH, fShowProjection));
08834 gPad->SetGrid();
08835 }
08836
08837
08838
08839 void THistPainter::ShowProjectionX(Int_t , Int_t py)
08840 {
08841
08842
08843
08844
08845 Int_t nbins = (Int_t)fShowProjection/100;
08846 gPad->SetDoubleBuffer(0);
08847 gVirtualX->SetDrawMode(TVirtualX::kInvert);
08848
08849
08850 static int pyold1 = 0;
08851 static int pyold2 = 0;
08852 float uxmin = gPad->GetUxmin();
08853 float uxmax = gPad->GetUxmax();
08854 int pxmin = gPad->XtoAbsPixel(uxmin);
08855 int pxmax = gPad->XtoAbsPixel(uxmax);
08856 Float_t upy = gPad->AbsPixeltoY(py);
08857 Float_t y = gPad->PadtoY(upy);
08858 Int_t biny1 = fH->GetYaxis()->FindBin(y);
08859 Int_t biny2 = TMath::Min(biny1+nbins-1, fH->GetYaxis()->GetNbins());
08860 Int_t py1 = gPad->YtoAbsPixel(fH->GetYaxis()->GetBinLowEdge(biny1));
08861 Int_t py2 = gPad->YtoAbsPixel(fH->GetYaxis()->GetBinUpEdge(biny2));
08862
08863 if (pyold1 || pyold2) gVirtualX->DrawBox(pxmin,pyold1,pxmax,pyold2,TVirtualX::kFilled);
08864 gVirtualX->DrawBox(pxmin,py1,pxmax,py2,TVirtualX::kFilled);
08865 pyold1 = py1;
08866 pyold2 = py2;
08867
08868
08869 TVirtualPad *padsav = gPad;
08870 TVirtualPad *c = (TVirtualPad*)gROOT->GetListOfCanvases()->FindObject(Form("%lx_c_projection_%d",
08871 (ULong_t)fH, fShowProjection));
08872 if (c) {
08873 c->Clear();
08874 } else {
08875 fShowProjection = 0;
08876 pyold1 = 0;
08877 pyold2 = 0;
08878 return;
08879 }
08880 c->cd();
08881 c->SetLogy(padsav->GetLogz());
08882 c->SetLogx(padsav->GetLogx());
08883
08884
08885 TH1D *hp = ((TH2*)fH)->ProjectionX("_px", biny1, biny2);
08886 hp->SetFillColor(38);
08887 if (biny1 == biny2) hp->SetTitle(Form("ProjectionX of biny=%d", biny1));
08888 else hp->SetTitle(Form("ProjectionX of biny=[%d,%d]", biny1,biny2));
08889 hp->SetXTitle(fH->GetXaxis()->GetTitle());
08890 hp->SetYTitle("Number of Entries");
08891 hp->Draw();
08892 c->Update();
08893 padsav->cd();
08894 }
08895
08896
08897
08898 void THistPainter::ShowProjectionY(Int_t px, Int_t )
08899 {
08900
08901
08902
08903
08904 Int_t nbins = (Int_t)fShowProjection/100;
08905 gPad->SetDoubleBuffer(0);
08906 gVirtualX->SetDrawMode(TVirtualX::kInvert);
08907
08908
08909 static int pxold1 = 0;
08910 static int pxold2 = 0;
08911 float uymin = gPad->GetUymin();
08912 float uymax = gPad->GetUymax();
08913 int pymin = gPad->YtoAbsPixel(uymin);
08914 int pymax = gPad->YtoAbsPixel(uymax);
08915 Float_t upx = gPad->AbsPixeltoX(px);
08916 Float_t x = gPad->PadtoX(upx);
08917 Int_t binx1 = fH->GetXaxis()->FindBin(x);
08918 Int_t binx2 = TMath::Min(binx1+nbins-1, fH->GetXaxis()->GetNbins());
08919 Int_t px1 = gPad->XtoAbsPixel(fH->GetXaxis()->GetBinLowEdge(binx1));
08920 Int_t px2 = gPad->XtoAbsPixel(fH->GetXaxis()->GetBinUpEdge(binx2));
08921
08922 if (pxold1 || pxold2) gVirtualX->DrawBox(pxold1,pymin,pxold2,pymax,TVirtualX::kFilled);
08923 gVirtualX->DrawBox(px1,pymin,px2,pymax,TVirtualX::kFilled);
08924 pxold1 = px1;
08925 pxold2 = px2;
08926
08927
08928 TVirtualPad *padsav = gPad;
08929 TVirtualPad *c = (TVirtualPad*)gROOT->GetListOfCanvases()->FindObject(Form("%lx_c_projection_%d",
08930 (ULong_t)fH, fShowProjection));
08931 if(c) {
08932 c->Clear();
08933 } else {
08934 fShowProjection = 0;
08935 pxold1 = 0;
08936 pxold2 = 0;
08937 return;
08938 }
08939 c->cd();
08940 c->SetLogy(padsav->GetLogz());
08941 c->SetLogx(padsav->GetLogy());
08942
08943
08944 TH1D *hp = ((TH2*)fH)->ProjectionY("_py", binx1, binx2);
08945 hp->SetFillColor(38);
08946 if (binx1 == binx2) hp->SetTitle(Form("ProjectionY of binx=%d", binx1));
08947 else hp->SetTitle(Form("ProjectionY of binx=[%d,%d]", binx1,binx2));
08948 hp->SetXTitle(fH->GetYaxis()->GetTitle());
08949 hp->SetYTitle("Number of Entries");
08950 hp->Draw();
08951 c->Update();
08952 padsav->cd();
08953 }
08954
08955
08956
08957 void THistPainter::ShowProjection3(Int_t px, Int_t py)
08958 {
08959
08960
08961
08962
08963
08964
08965
08966
08967 Int_t nbins=(Int_t)fShowProjection/100;
08968 if (fH->GetDimension() < 3) {
08969 if (fShowProjection%100 == 1) {ShowProjectionX(px,py); return;}
08970 if (fShowProjection%100 == 2) {ShowProjectionY(px,py); return;}
08971 }
08972
08973 gPad->SetDoubleBuffer(0);
08974 gVirtualX->SetDrawMode(TVirtualX::kInvert);
08975
08976
08977 TView *view = gPad->GetView();
08978 TH3 *h3 = (TH3*)fH;
08979 TAxis *xaxis = h3->GetXaxis();
08980 TAxis *yaxis = h3->GetYaxis();
08981 TAxis *zaxis = h3->GetZaxis();
08982 Double_t u[3],xx[3];
08983
08984 static TPoint line1[2];
08985 static TPoint line2[2];
08986 static TPoint line3[2];
08987 static TPoint line4[2];
08988 static TPoint endface1[5];
08989 static TPoint endface2[5];
08990 static TPoint rect1[5];
08991 static TPoint rect2[5];
08992
08993 Double_t value1=0, value2=0;
08994 Double_t uxmin = gPad->GetUxmin();
08995 Double_t uxmax = gPad->GetUxmax();
08996 Double_t uymin = gPad->GetUymin();
08997 Double_t uymax = gPad->GetUymax();
08998
08999 int pxmin = gPad->XtoAbsPixel(uxmin);
09000 int pxmax = gPad->XtoAbsPixel(uxmax);
09001 int pymin = gPad->YtoAbsPixel(uymin);
09002 int pymax = gPad->YtoAbsPixel(uymax);
09003 Double_t cx = (pxmax-pxmin)/(uxmax-uxmin);
09004 Double_t cy = (pymax-pymin)/(uymax-uymin);
09005 TVirtualPad *padsav = gPad;
09006 TVirtualPad *c = (TVirtualPad*)gROOT->GetListOfCanvases()->FindObject(Form("%lx_c_projection_%d",
09007 (ULong_t)fH, fShowProjection));
09008 if(!c) {
09009 fShowProjection = 0;
09010 return;
09011 }
09012
09013 switch ((Int_t)fShowProjection%100) {
09014 case 1:
09015
09016 {
09017 Int_t firstY = yaxis->GetFirst();
09018 Int_t lastY = yaxis->GetLast();
09019 Int_t biny = firstY + Int_t((lastY-firstY)*(px-pxmin)/(pxmax-pxmin));
09020 yaxis->SetRange(biny,biny+nbins-1);
09021 Int_t firstZ = zaxis->GetFirst();
09022 Int_t lastZ = zaxis->GetLast();
09023 Int_t binz = firstZ + Int_t((lastZ-firstZ)*(py-pymin)/(pymax-pymin));
09024 zaxis->SetRange(binz,binz+nbins-1);
09025 if(line1[0].GetX()) gVirtualX->DrawPolyLine(2,line1);
09026 if (nbins>1 && line1[0].GetX()) {
09027 gVirtualX->DrawPolyLine(2,line2);
09028 gVirtualX->DrawPolyLine(2,line3);
09029 gVirtualX->DrawPolyLine(2,line4);
09030 gVirtualX->DrawPolyLine(5,endface1);
09031 gVirtualX->DrawPolyLine(5,endface2);
09032 }
09033 xx[0] = xaxis->GetXmin();
09034 xx[2] = zaxis->GetBinCenter(binz);
09035 xx[1] = yaxis->GetBinCenter(biny);
09036 view->WCtoNDC(xx,u);
09037 line1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09038 line1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09039 xx[0] = xaxis->GetXmax();
09040 view->WCtoNDC(xx,u);
09041 line1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09042 line1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09043 gVirtualX->DrawPolyLine(2,line1);
09044 if (nbins>1) {
09045 xx[0] = xaxis->GetXmin();
09046 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
09047 xx[1] = yaxis->GetBinCenter(biny);
09048 view->WCtoNDC(xx,u);
09049 line2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09050 line2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09051 xx[0] = xaxis->GetXmax();
09052 view->WCtoNDC(xx,u);
09053 line2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09054 line2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09055
09056 xx[0] = xaxis->GetXmin();
09057 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
09058 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
09059 view->WCtoNDC(xx,u);
09060 line3[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09061 line3[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09062 xx[0] = xaxis->GetXmax();
09063 view->WCtoNDC(xx,u);
09064 line3[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09065 line3[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09066
09067 xx[0] = xaxis->GetXmin();
09068 xx[2] = zaxis->GetBinCenter(binz);
09069 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
09070 view->WCtoNDC(xx,u);
09071 line4[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09072 line4[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09073 xx[0] = xaxis->GetXmax();
09074 view->WCtoNDC(xx,u);
09075 line4[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09076 line4[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09077
09078 endface1[0].SetX(line1[0].GetX());
09079 endface1[0].SetY(line1[0].GetY());
09080 endface1[1].SetX(line2[0].GetX());
09081 endface1[1].SetY(line2[0].GetY());
09082 endface1[2].SetX(line3[0].GetX());
09083 endface1[2].SetY(line3[0].GetY());
09084 endface1[3].SetX(line4[0].GetX());
09085 endface1[3].SetY(line4[0].GetY());
09086 endface1[4].SetX(line1[0].GetX());
09087 endface1[4].SetY(line1[0].GetY());
09088
09089 endface2[0].SetX(line1[1].GetX());
09090 endface2[0].SetY(line1[1].GetY());
09091 endface2[1].SetX(line2[1].GetX());
09092 endface2[1].SetY(line2[1].GetY());
09093 endface2[2].SetX(line3[1].GetX());
09094 endface2[2].SetY(line3[1].GetY());
09095 endface2[3].SetX(line4[1].GetX());
09096 endface2[3].SetY(line4[1].GetY());
09097 endface2[4].SetX(line1[1].GetX());
09098 endface2[4].SetY(line1[1].GetY());
09099
09100 gVirtualX->DrawPolyLine(2,line2);
09101 gVirtualX->DrawPolyLine(2,line3);
09102 gVirtualX->DrawPolyLine(2,line4);
09103 gVirtualX->DrawPolyLine(5,endface1);
09104 gVirtualX->DrawPolyLine(5,endface2);
09105 }
09106 c->Clear();
09107 c->cd();
09108 TH1 *hp = h3->Project3D("x");
09109 yaxis->SetRange(firstY,lastY);
09110 zaxis->SetRange(firstZ,lastZ);
09111 hp->SetFillColor(38);
09112 hp->SetTitle(Form("ProjectionX of biny=%d binz=%d", biny, binz));
09113 hp->SetXTitle(fH->GetXaxis()->GetTitle());
09114 hp->SetYTitle("Number of Entries");
09115 hp->Draw(fShowOption.Data());
09116 }
09117 break;
09118
09119 case 2:
09120
09121 {
09122 Int_t firstX = xaxis->GetFirst();
09123 Int_t lastX = xaxis->GetLast();
09124 Int_t binx = firstX + Int_t((lastX-firstX)*(px-pxmin)/(pxmax-pxmin));
09125 xaxis->SetRange(binx,binx+nbins-1);
09126 Int_t firstZ = zaxis->GetFirst();
09127 Int_t lastZ = zaxis->GetLast();
09128 Int_t binz = firstZ + Int_t((lastZ-firstZ)*(py-pymin)/(pymax-pymin));
09129 zaxis->SetRange(binz,binz+nbins-1);
09130 if(line1[0].GetX()) gVirtualX->DrawPolyLine(2,line1);
09131 if (nbins>1 && line1[0].GetX()) {
09132 gVirtualX->DrawPolyLine(2,line2);
09133 gVirtualX->DrawPolyLine(2,line3);
09134 gVirtualX->DrawPolyLine(2,line4);
09135 gVirtualX->DrawPolyLine(5,endface1);
09136 gVirtualX->DrawPolyLine(5,endface2);
09137 }
09138 xx[0]=xaxis->GetBinCenter(binx);
09139 xx[2] = zaxis->GetBinCenter(binz);
09140 xx[1] = yaxis->GetXmin();
09141 view->WCtoNDC(xx,u);
09142 line1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09143 line1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09144 xx[1] = yaxis->GetXmax();
09145 view->WCtoNDC(xx,u);
09146 line1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09147 line1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09148 gVirtualX->DrawPolyLine(2,line1);
09149 if (nbins>1) {
09150 xx[1] = yaxis->GetXmin();
09151 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
09152 xx[0] = xaxis->GetBinCenter(binx);
09153 view->WCtoNDC(xx,u);
09154 line2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09155 line2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09156 xx[1] = yaxis->GetXmax();
09157 view->WCtoNDC(xx,u);
09158 line2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09159 line2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09160
09161 xx[1] = yaxis->GetXmin();
09162 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
09163 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
09164 view->WCtoNDC(xx,u);
09165 line3[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09166 line3[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09167 xx[1] = yaxis->GetXmax();
09168 view->WCtoNDC(xx,u);
09169 line3[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09170 line3[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09171
09172 xx[1] = yaxis->GetXmin();
09173 xx[2] = zaxis->GetBinCenter(binz);
09174 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
09175 view->WCtoNDC(xx,u);
09176 line4[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09177 line4[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09178 xx[1] = yaxis->GetXmax();
09179 view->WCtoNDC(xx,u);
09180 line4[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09181 line4[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09182
09183 endface1[0].SetX(line1[0].GetX());
09184 endface1[0].SetY(line1[0].GetY());
09185 endface1[1].SetX(line2[0].GetX());
09186 endface1[1].SetY(line2[0].GetY());
09187 endface1[2].SetX(line3[0].GetX());
09188 endface1[2].SetY(line3[0].GetY());
09189 endface1[3].SetX(line4[0].GetX());
09190 endface1[3].SetY(line4[0].GetY());
09191 endface1[4].SetX(line1[0].GetX());
09192 endface1[4].SetY(line1[0].GetY());
09193
09194 endface2[0].SetX(line1[1].GetX());
09195 endface2[0].SetY(line1[1].GetY());
09196 endface2[1].SetX(line2[1].GetX());
09197 endface2[1].SetY(line2[1].GetY());
09198 endface2[2].SetX(line3[1].GetX());
09199 endface2[2].SetY(line3[1].GetY());
09200 endface2[3].SetX(line4[1].GetX());
09201 endface2[3].SetY(line4[1].GetY());
09202 endface2[4].SetX(line1[1].GetX());
09203 endface2[4].SetY(line1[1].GetY());
09204
09205 gVirtualX->DrawPolyLine(2,line2);
09206 gVirtualX->DrawPolyLine(2,line3);
09207 gVirtualX->DrawPolyLine(2,line4);
09208 gVirtualX->DrawPolyLine(5,endface1);
09209 gVirtualX->DrawPolyLine(5,endface2);
09210 }
09211 c->Clear();
09212 c->cd();
09213 TH1 *hp = h3->Project3D("y");
09214 xaxis->SetRange(firstX,lastX);
09215 zaxis->SetRange(firstZ,lastZ);
09216 hp->SetFillColor(38);
09217 hp->SetTitle(Form("ProjectionY of binx=%d binz=%d", binx, binz));
09218 hp->SetXTitle(fH->GetYaxis()->GetTitle());
09219 hp->SetYTitle("Number of Entries");
09220 hp->Draw(fShowOption.Data());
09221 }
09222 break;
09223
09224 case 3:
09225
09226 {
09227 Int_t firstX = xaxis->GetFirst();
09228 Int_t lastX = xaxis->GetLast();
09229 Int_t binx = firstX + Int_t((lastX-firstX)*(px-pxmin)/(pxmax-pxmin));
09230 xaxis->SetRange(binx,binx+nbins-1);
09231 Int_t firstY = yaxis->GetFirst();
09232 Int_t lastY = yaxis->GetLast();
09233 Int_t biny = firstY + Int_t((lastY-firstY)*(py-pymin)/(pymax-pymin));
09234 yaxis->SetRange(biny,biny+nbins-1);
09235 if(line1[0].GetX()) gVirtualX->DrawPolyLine(2,line1);
09236 if (nbins>1 && line1[0].GetX()) {
09237 gVirtualX->DrawPolyLine(2,line2);
09238 gVirtualX->DrawPolyLine(2,line3);
09239 gVirtualX->DrawPolyLine(2,line4);
09240 gVirtualX->DrawPolyLine(5,endface1);
09241 gVirtualX->DrawPolyLine(5,endface2);
09242 }
09243 xx[0] = xaxis->GetBinCenter(binx);
09244 xx[1] = yaxis->GetBinCenter(biny);
09245 xx[2] = zaxis->GetXmin();
09246 view->WCtoNDC(xx,u);
09247 line1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09248 line1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09249 xx[2] = zaxis->GetXmax();
09250 view->WCtoNDC(xx,u);
09251 line1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09252 line1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09253 gVirtualX->DrawPolyLine(2,line1);
09254 if (nbins>1) {
09255 xx[2] = zaxis->GetXmin();
09256 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
09257 xx[0] = xaxis->GetBinCenter(binx);
09258 view->WCtoNDC(xx,u);
09259 line2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09260 line2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09261 xx[2] = zaxis->GetXmax();
09262 view->WCtoNDC(xx,u);
09263 line2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09264 line2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09265
09266 xx[2] = zaxis->GetXmin();
09267 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
09268 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
09269 view->WCtoNDC(xx,u);
09270 line3[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09271 line3[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09272 xx[2] = zaxis->GetXmax();
09273 view->WCtoNDC(xx,u);
09274 line3[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09275 line3[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09276
09277 xx[2] = zaxis->GetXmin();
09278 xx[1] = yaxis->GetBinCenter(biny);
09279 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
09280 view->WCtoNDC(xx,u);
09281 line4[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09282 line4[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09283 xx[2] = zaxis->GetXmax();
09284 view->WCtoNDC(xx,u);
09285 line4[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09286 line4[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09287
09288 endface1[0].SetX(line1[0].GetX());
09289 endface1[0].SetY(line1[0].GetY());
09290 endface1[1].SetX(line2[0].GetX());
09291 endface1[1].SetY(line2[0].GetY());
09292 endface1[2].SetX(line3[0].GetX());
09293 endface1[2].SetY(line3[0].GetY());
09294 endface1[3].SetX(line4[0].GetX());
09295 endface1[3].SetY(line4[0].GetY());
09296 endface1[4].SetX(line1[0].GetX());
09297 endface1[4].SetY(line1[0].GetY());
09298
09299 endface2[0].SetX(line1[1].GetX());
09300 endface2[0].SetY(line1[1].GetY());
09301 endface2[1].SetX(line2[1].GetX());
09302 endface2[1].SetY(line2[1].GetY());
09303 endface2[2].SetX(line3[1].GetX());
09304 endface2[2].SetY(line3[1].GetY());
09305 endface2[3].SetX(line4[1].GetX());
09306 endface2[3].SetY(line4[1].GetY());
09307 endface2[4].SetX(line1[1].GetX());
09308 endface2[4].SetY(line1[1].GetY());
09309
09310 gVirtualX->DrawPolyLine(2,line2);
09311 gVirtualX->DrawPolyLine(2,line3);
09312 gVirtualX->DrawPolyLine(2,line4);
09313 gVirtualX->DrawPolyLine(5,endface1);
09314 gVirtualX->DrawPolyLine(5,endface2);
09315 }
09316 c->Clear();
09317 c->cd();
09318 TH1 *hp = h3->Project3D("z");
09319 xaxis->SetRange(firstX,lastX);
09320 yaxis->SetRange(firstY,lastY);
09321 hp->SetFillColor(38);
09322 hp->SetTitle(Form("ProjectionZ of binx=%d biny=%d", binx, biny));
09323 hp->SetXTitle(fH->GetZaxis()->GetTitle());
09324 hp->SetYTitle("Number of Entries");
09325 hp->Draw(fShowOption.Data());
09326 }
09327 break;
09328
09329 case 4:
09330
09331 {
09332 Int_t first = zaxis->GetFirst();
09333 Int_t last = zaxis->GetLast();
09334 Int_t binz = first + Int_t((last-first)*(py-pymin)/(pymax-pymin));
09335 zaxis->SetRange(binz,binz+nbins-1);
09336 if(rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
09337 if(nbins>1 && rect2[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
09338 xx[0] = xaxis->GetXmin();
09339 xx[1] = yaxis->GetXmax();
09340 xx[2] = zaxis->GetBinCenter(binz);
09341 value1=xx[2];
09342 view->WCtoNDC(xx,u);
09343 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09344 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09345 rect1[4].SetX(rect1[0].GetX());
09346 rect1[4].SetY(rect1[0].GetY());
09347 xx[0] = xaxis->GetXmax();
09348 view->WCtoNDC(xx,u);
09349 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09350 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09351 xx[1] = yaxis->GetXmin();
09352 view->WCtoNDC(xx,u);
09353 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09354 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09355 xx[0] = xaxis->GetXmin();
09356 view->WCtoNDC(xx,u);
09357 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09358 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09359 gVirtualX->DrawPolyLine(5,rect1);
09360 if (nbins>1) {
09361 xx[0] = xaxis->GetXmin();
09362 xx[1] = yaxis->GetXmax();
09363 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
09364 value2=xx[2];
09365 view->WCtoNDC(xx,u);
09366 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09367 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09368 rect2[4].SetX(rect2[0].GetX());
09369 rect2[4].SetY(rect2[0].GetY());
09370 xx[0] = xaxis->GetXmax();
09371 view->WCtoNDC(xx,u);
09372 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09373 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09374 xx[1] = yaxis->GetXmin();
09375 view->WCtoNDC(xx,u);
09376 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09377 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09378 xx[0] = xaxis->GetXmin();
09379 view->WCtoNDC(xx,u);
09380 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09381 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09382 gVirtualX->DrawPolyLine(5,rect2);
09383 }
09384
09385 c->Clear();
09386 c->cd();
09387 TH2 *hp = (TH2*)h3->Project3D("xy");
09388 zaxis->SetRange(first,last);
09389 hp->SetFillColor(38);
09390 if(nbins==1)hp->SetTitle(Form("ProjectionXY of binz=%d (%.1f)", binz,value1));
09391 else hp->SetTitle(Form("ProjectionXY, binz range=%d-%d (%.1f-%.1f)", binz,binz+nbins-1,value1,value2));
09392 hp->SetXTitle(fH->GetYaxis()->GetTitle());
09393 hp->SetYTitle(fH->GetXaxis()->GetTitle());
09394 hp->SetZTitle("Number of Entries");
09395 hp->Draw(fShowOption.Data());
09396 }
09397 break;
09398
09399 case 5:
09400
09401 {
09402 Int_t first = zaxis->GetFirst();
09403 Int_t last = zaxis->GetLast();
09404 Int_t binz = first + Int_t((last-first)*(py-pymin)/(pymax-pymin));
09405 zaxis->SetRange(binz,binz+nbins-1);
09406 if(rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
09407 if(nbins>1 && rect2[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
09408 xx[0] = xaxis->GetXmin();
09409 xx[1] = yaxis->GetXmax();
09410 xx[2] = zaxis->GetBinCenter(binz);
09411 value1=xx[2];
09412 view->WCtoNDC(xx,u);
09413 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09414 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09415 rect1[4].SetX(rect1[0].GetX());
09416 rect1[4].SetY(rect1[0].GetY());
09417 xx[0] = xaxis->GetXmax();
09418 view->WCtoNDC(xx,u);
09419 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09420 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09421 xx[1] = yaxis->GetXmin();
09422 view->WCtoNDC(xx,u);
09423 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09424 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09425 xx[0] = xaxis->GetXmin();
09426 view->WCtoNDC(xx,u);
09427 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09428 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09429 gVirtualX->DrawPolyLine(5,rect1);
09430 if (nbins>1) {
09431 xx[0] = xaxis->GetXmin();
09432 xx[1] = yaxis->GetXmax();
09433 xx[2] = zaxis->GetBinCenter(binz+nbins-1);
09434 value2=xx[2];
09435 view->WCtoNDC(xx,u);
09436 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09437 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09438 rect2[4].SetX(rect2[0].GetX());
09439 rect2[4].SetY(rect2[0].GetY());
09440 xx[0] = xaxis->GetXmax();
09441 view->WCtoNDC(xx,u);
09442 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09443 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09444 xx[1] = yaxis->GetXmin();
09445 view->WCtoNDC(xx,u);
09446 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09447 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09448 xx[0] = xaxis->GetXmin();
09449 view->WCtoNDC(xx,u);
09450 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09451 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09452 gVirtualX->DrawPolyLine(5,rect2);
09453 }
09454 c->Clear();
09455 c->cd();
09456 TH2 *hp = (TH2*)h3->Project3D("yx");
09457 zaxis->SetRange(first,last);
09458 hp->SetFillColor(38);
09459 if(nbins==1)hp->SetTitle(Form("ProjectionYX of binz=%d (%.1f)", binz,value1));
09460 else hp->SetTitle(Form("ProjectionXY, binz range=%d-%d (%.1f-%.1f)", binz,binz+nbins-1,value1,value2));
09461 hp->SetXTitle(fH->GetXaxis()->GetTitle());
09462 hp->SetYTitle(fH->GetYaxis()->GetTitle());
09463 hp->SetZTitle("Number of Entries");
09464 hp->Draw(fShowOption.Data());
09465 }
09466 break;
09467
09468 case 6:
09469
09470 {
09471 Int_t first = yaxis->GetFirst();
09472 Int_t last = yaxis->GetLast();
09473 Int_t biny = first + Int_t((last-first)*(py-pymin)/(pymax-pymin));
09474 yaxis->SetRange(biny,biny+nbins-1);
09475 if(rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
09476 if(nbins>1 && rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
09477 xx[0] = xaxis->GetXmin();
09478 xx[2] = zaxis->GetXmax();
09479 xx[1] = yaxis->GetBinCenter(biny);
09480 value1=xx[1];
09481 view->WCtoNDC(xx,u);
09482 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09483 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09484 rect1[4].SetX(rect1[0].GetX());
09485 rect1[4].SetY(rect1[0].GetY());
09486 xx[0] = xaxis->GetXmax();
09487 view->WCtoNDC(xx,u);
09488 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09489 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09490 xx[2] = zaxis->GetXmin();
09491 view->WCtoNDC(xx,u);
09492 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09493 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09494 xx[0] = xaxis->GetXmin();
09495 view->WCtoNDC(xx,u);
09496 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09497 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09498 gVirtualX->DrawPolyLine(5,rect1);
09499 if (nbins>1) {
09500 xx[0] = xaxis->GetXmin();
09501 xx[2] = zaxis->GetXmax();
09502 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
09503 value2=xx[1];
09504 view->WCtoNDC(xx,u);
09505 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09506 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09507 rect2[4].SetX(rect2[0].GetX());
09508 rect2[4].SetY(rect2[0].GetY());
09509 xx[0] = xaxis->GetXmax();
09510 view->WCtoNDC(xx,u);
09511 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09512 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09513 xx[2] = zaxis->GetXmin();
09514 view->WCtoNDC(xx,u);
09515 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09516 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09517 xx[0] = xaxis->GetXmin();
09518 view->WCtoNDC(xx,u);
09519 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09520 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09521 gVirtualX->DrawPolyLine(5,rect2);
09522 }
09523 c->Clear();
09524 c->cd();
09525 TH2 *hp = (TH2*)h3->Project3D("xz");
09526 yaxis->SetRange(first,last);
09527 hp->SetFillColor(38);
09528 if(nbins==1)hp->SetTitle(Form("ProjectionXZ of biny=%d (%.1f)", biny,value1));
09529 else hp->SetTitle(Form("ProjectionXZ, biny range=%d-%d (%.1f-%.1f)", biny,biny+nbins-1,value1,value2));
09530 hp->SetXTitle(fH->GetZaxis()->GetTitle());
09531 hp->SetYTitle(fH->GetXaxis()->GetTitle());
09532 hp->SetZTitle("Number of Entries");
09533 hp->Draw(fShowOption.Data());
09534 }
09535 break;
09536
09537 case 7:
09538
09539 {
09540 Int_t first = yaxis->GetFirst();
09541 Int_t last = yaxis->GetLast();
09542 Int_t biny = first + Int_t((last-first)*(py-pymin)/(pymax-pymin));
09543 yaxis->SetRange(biny,biny+nbins-1);
09544 if(rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
09545 if(nbins>1 && rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
09546 xx[0] = xaxis->GetXmin();
09547 xx[2] = zaxis->GetXmax();
09548 xx[1] = yaxis->GetBinCenter(biny);
09549 value1=xx[1];
09550 view->WCtoNDC(xx,u);
09551 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09552 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09553 rect1[4].SetX(rect1[0].GetX());
09554 rect1[4].SetY(rect1[0].GetY());
09555 xx[0] = xaxis->GetXmax();
09556 view->WCtoNDC(xx,u);
09557 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09558 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09559 xx[2] = zaxis->GetXmin();
09560 view->WCtoNDC(xx,u);
09561 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09562 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09563 xx[0] = xaxis->GetXmin();
09564 view->WCtoNDC(xx,u);
09565 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09566 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09567 gVirtualX->DrawPolyLine(5,rect1);
09568 if (nbins>1) {
09569 xx[0] = xaxis->GetXmin();
09570 xx[2] = zaxis->GetXmax();
09571 xx[1] = yaxis->GetBinCenter(biny+nbins-1);
09572 value2=xx[1];
09573 view->WCtoNDC(xx,u);
09574 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09575 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09576 rect2[4].SetX(rect2[0].GetX());
09577 rect2[4].SetY(rect2[0].GetY());
09578 xx[0] = xaxis->GetXmax();
09579 view->WCtoNDC(xx,u);
09580 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09581 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09582 xx[2] = zaxis->GetXmin();
09583 view->WCtoNDC(xx,u);
09584 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09585 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09586 xx[0] = xaxis->GetXmin();
09587 view->WCtoNDC(xx,u);
09588 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09589 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09590 gVirtualX->DrawPolyLine(5,rect2);
09591 }
09592 c->Clear();
09593 c->cd();
09594 TH2 *hp = (TH2*)h3->Project3D("zx");
09595 yaxis->SetRange(first,last);
09596 hp->SetFillColor(38);
09597 if(nbins==1)hp->SetTitle(Form("ProjectionZX of biny=%d (%.1f)", biny,value1));
09598 else hp->SetTitle(Form("ProjectionZX, binY range=%d-%d (%.1f-%.1f)", biny,biny+nbins-1,value1,value2));
09599 hp->SetXTitle(fH->GetXaxis()->GetTitle());
09600 hp->SetYTitle(fH->GetZaxis()->GetTitle());
09601 hp->SetZTitle("Number of Entries");
09602 hp->Draw(fShowOption.Data());
09603 }
09604 break;
09605
09606 case 8:
09607
09608 {
09609 Int_t first = xaxis->GetFirst();
09610 Int_t last = xaxis->GetLast();
09611 Int_t binx = first + Int_t((last-first)*(px-pxmin)/(pxmax-pxmin));
09612 xaxis->SetRange(binx,binx+nbins-1);
09613 if(rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
09614 if(nbins>1 && rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
09615 xx[2] = zaxis->GetXmin();
09616 xx[1] = yaxis->GetXmax();
09617 xx[0] = xaxis->GetBinCenter(binx);
09618 value1=xx[0];
09619 view->WCtoNDC(xx,u);
09620 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09621 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09622 rect1[4].SetX(rect1[0].GetX());
09623 rect1[4].SetY(rect1[0].GetY());
09624 xx[2] = zaxis->GetXmax();
09625 view->WCtoNDC(xx,u);
09626 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09627 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09628 xx[1] = yaxis->GetXmin();
09629 view->WCtoNDC(xx,u);
09630 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09631 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09632 xx[2] = zaxis->GetXmin();
09633 view->WCtoNDC(xx,u);
09634 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09635 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09636 gVirtualX->DrawPolyLine(5,rect1);
09637 if (nbins>1) {
09638 xx[2] = zaxis->GetXmin();
09639 xx[1] = yaxis->GetXmax();
09640 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
09641 value2=xx[0];
09642 view->WCtoNDC(xx,u);
09643 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09644 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09645 rect2[4].SetX(rect2[0].GetX());
09646 rect2[4].SetY(rect2[0].GetY());
09647 xx[2] = zaxis->GetXmax();
09648 view->WCtoNDC(xx,u);
09649 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09650 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09651 xx[1] = yaxis->GetXmin();
09652 view->WCtoNDC(xx,u);
09653 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09654 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09655 xx[2] = zaxis->GetXmin();
09656 view->WCtoNDC(xx,u);
09657 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09658 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09659 gVirtualX->DrawPolyLine(5,rect2);
09660 }
09661 c->Clear();
09662 c->cd();
09663 TH2 *hp = (TH2*)h3->Project3D("yz");
09664 xaxis->SetRange(first,last);
09665 hp->SetFillColor(38);
09666 if(nbins==1)hp->SetTitle(Form("ProjectionYZ of binx=%d (%.1f)", binx,value1));
09667 else hp->SetTitle(Form("ProjectionYZ, binx range=%d-%d (%.1f-%.1f)", binx,binx+nbins-1,value1,value2));
09668 hp->SetXTitle(fH->GetZaxis()->GetTitle());
09669 hp->SetYTitle(fH->GetYaxis()->GetTitle());
09670 hp->SetZTitle("Number of Entries");
09671 hp->Draw(fShowOption.Data());
09672 }
09673 break;
09674
09675 case 9:
09676
09677 {
09678 Int_t first = xaxis->GetFirst();
09679 Int_t last = xaxis->GetLast();
09680 Int_t binx = first + Int_t((last-first)*(px-pxmin)/(pxmax-pxmin));
09681 xaxis->SetRange(binx,binx+nbins-1);
09682 if(rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect1);
09683 if(nbins>1 && rect1[0].GetX()) gVirtualX->DrawPolyLine(5,rect2);
09684 xx[2] = zaxis->GetXmin();
09685 xx[1] = yaxis->GetXmax();
09686 xx[0] = xaxis->GetBinCenter(binx);
09687 value1=xx[0];
09688 view->WCtoNDC(xx,u);
09689 rect1[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09690 rect1[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09691 rect1[4].SetX(rect1[0].GetX());
09692 rect1[4].SetY(rect1[0].GetY());
09693 xx[2] = zaxis->GetXmax();
09694 view->WCtoNDC(xx,u);
09695 rect1[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09696 rect1[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09697 xx[1] = yaxis->GetXmin();
09698 view->WCtoNDC(xx,u);
09699 rect1[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09700 rect1[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09701 xx[2] = zaxis->GetXmin();
09702 view->WCtoNDC(xx,u);
09703 rect1[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09704 rect1[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09705 gVirtualX->DrawPolyLine(5,rect1);
09706 if (nbins>1) {
09707 xx[2] = zaxis->GetXmin();
09708 xx[1] = yaxis->GetXmax();
09709 xx[0] = xaxis->GetBinCenter(binx+nbins-1);
09710 value2=xx[0];
09711 view->WCtoNDC(xx,u);
09712 rect2[0].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09713 rect2[0].SetY(pymin + Int_t((u[1]-uymin)*cy));
09714 rect2[4].SetX(rect2[0].GetX());
09715 rect2[4].SetY(rect2[0].GetY());
09716 xx[2] = zaxis->GetXmax();
09717 view->WCtoNDC(xx,u);
09718 rect2[1].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09719 rect2[1].SetY(pymin + Int_t((u[1]-uymin)*cy));
09720 xx[1] = yaxis->GetXmin();
09721 view->WCtoNDC(xx,u);
09722 rect2[2].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09723 rect2[2].SetY(pymin + Int_t((u[1]-uymin)*cy));
09724 xx[2] = zaxis->GetXmin();
09725 view->WCtoNDC(xx,u);
09726 rect2[3].SetX(pxmin + Int_t((u[0]-uxmin)*cx));
09727 rect2[3].SetY(pymin + Int_t((u[1]-uymin)*cy));
09728 gVirtualX->DrawPolyLine(5,rect2);
09729 }
09730 c->Clear();
09731 c->cd();
09732 TH2 *hp = (TH2*)h3->Project3D("zy");
09733 xaxis->SetRange(first,last);
09734 hp->SetFillColor(38);
09735
09736 if(nbins==1)hp->SetTitle(Form("ProjectionZY of binx=%d (%.1f)", binx,value1));
09737 else hp->SetTitle(Form("ProjectionZY, binx range=%d-%d (%.1f-%.1f)", binx,binx+nbins-1,value1,value2));
09738 hp->SetXTitle(fH->GetYaxis()->GetTitle());
09739 hp->SetYTitle(fH->GetZaxis()->GetTitle());
09740 hp->SetZTitle("Number of Entries");
09741 hp->Draw(fShowOption.Data());
09742 }
09743 break;
09744
09745 }
09746 c->Update();
09747 padsav->cd();
09748 }