1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
|
#include "TArrow.h"
#include "TAxis.h"
#include "TCanvas.h"
#include "TF1.h"
#include "TFile.h"
#include "TGaxis.h"
#include "TGraph.h"
#include "TGraphAsymmErrors.h"
#include "TGraphErrors.h"
#include "TH1F.h"
#include "TH2F.h"
#include "TLatex.h"
#include "TLegend.h"
#include "TList.h"
#include "TMath.h"
#include "TObjArray.h"
#include "TObjString.h"
#include "TPad.h"
#include "TPaveText.h"
#include "TProcPool.h"
#include "TProfile.h"
#include "TROOT.h"
#include "TStyle.h"
#include "TSystem.h"
#include "TSystemDirectory.h"
#include "TSystemFile.h"
#include <TStopwatch.h>
#include <algorithm>
#include <bitset>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <sstream>
#include <vector>
/*!
* \def some convenient I/O
*/
#define logInfo std::cout << "INFO: "
#define logWarning std::cout << "WARNING: "
#define logError std::cout << "ERROR!!! "
/*!
* \def boolean to decide if it is in debug mode
*/
#define VERBOSE false
/*!
* \def number of workers
*/
const size_t nWorkers = 20;
/*!
* \def basically the y-values of a TGraph
*/
typedef std::map<TString, std::vector<double> > alignmentTrend;
namespace pv {
enum view { dxyphi, dzphi, dxyeta, dzeta, pT, generic };
/*! \fn closest
* \brief method to find first value that doesn not compare left
*/
int closest(std::vector<int> const &vec, int value) {
auto const it = std::lower_bound(vec.begin(), vec.end(), value);
if (it == vec.end()) {
return -1;
}
return *it;
}
const Int_t markers[8] = {kFullSquare,
kFullCircle,
kFullTriangleDown,
kOpenSquare,
kOpenCircle,
kFullTriangleUp,
kOpenTriangleDown,
kOpenTriangleUp};
const Int_t colors[8] = {kBlack, kRed, kBlue, kGreen + 2, kMagenta, kViolet, kCyan, kYellow};
/*! \struct biases
* \brief Structure biases
* Contains characterization of a single run PV bias plot
*
* @param m_mean: mean value of the profile points
* @param m_rms: RMS value of the profle points
* @param m_w_mean: mean weighted on the errors
* @param m_w_rms: RMS weighted on the errors
* @param m_min: minimum of the profile
* @param m_max: maximum of the profile
* @param m_chi2: chi2 of a liner fit
* @param m_ndf: number of the dof of the linear fit
* @param m_ks: Kolmogorov-Smirnov score of comparison with flat line
*/
struct biases {
// contructor
biases(double mean, double rms, double wmean, double wrms, double min, double max, double chi2, int ndf, double ks) {
m_mean = mean;
m_rms = rms;
m_w_mean = wmean;
m_w_rms = wrms;
m_min = min;
m_max = max;
m_chi2 = chi2;
m_ndf = ndf;
m_ks = ks;
}
// empty constructor
biases() { init(); }
/*! \fn init
* \brief initialising all members one by one
*/
void init() {
m_mean = 0;
m_rms = 0.;
m_min = +999.;
m_max = -999.;
m_w_mean = 0.;
m_w_rms = 0.;
m_chi2 = -1.;
m_ndf = 0.;
m_ks = 9999.;
}
double getMean() { return m_mean; }
double getWeightedMean() { return m_w_mean; }
double getRMS() { return m_rms; }
double getWeightedRMS() { return m_w_rms; }
double getMin() { return m_min; }
double getMax() { return m_max; }
double getChi2() { return m_chi2; }
double getNDF() { return m_ndf; }
double getNormChi2() { return double(m_chi2) / double(m_ndf); }
double getChi2Prob() { return TMath::Prob(m_chi2, m_ndf); }
double getKSScore() { return m_ks; }
private:
double m_mean;
double m_min;
double m_max;
double m_rms;
double m_w_mean;
double m_w_rms;
double m_chi2;
int m_ndf;
double m_ks;
};
/*! \struct wrappedTrends
* \brief Structure wrappedTrends
* Contains the ensemble vs run number of the alignmentTrend characterization
*
* @param mean: alignmentTrend of the mean value of the profile points
* @param low: alignmentTrend of the lowest value of the profle points
* @param high: alignmentTrend of the highest value of the profile points
* @param lowerr: alignmentTrend of the difference between the lowest value and the mean of the profile points
* @param higherr: alignmentTrend of the difference between the highest value and the mean of the profile points
* @param chi2: alignmentTrend of the chi2 value of a linear fit to the profile points
* @param KS: alignmentTrend of the Kolmogorow-Smirnov score of the comarison of the profile points to a flat line
*/
struct wrappedTrends {
/*! \fn wrappedTrends
* \brief Constructor of structure wrappedTrends, initialising all members from DMRs directly (with split)
*/
wrappedTrends(alignmentTrend mean,
alignmentTrend low,
alignmentTrend high,
alignmentTrend lowerr,
alignmentTrend higherr,
alignmentTrend chi2,
alignmentTrend KS) {
logInfo << "pv::wrappedTrends c'tor" << std::endl;
m_mean = mean;
m_low = low;
m_high = high;
m_lowerr = lowerr;
m_higherr = higherr;
m_chi2 = chi2;
m_KS = KS;
}
alignmentTrend getMean() const { return m_mean; }
alignmentTrend getLow() const { return m_low; }
alignmentTrend getHigh() const { return m_high; }
alignmentTrend getLowErr() const { return m_lowerr; }
alignmentTrend getHighErr() const { return m_higherr; }
alignmentTrend getChi2() const { return m_chi2; }
alignmentTrend getKS() const { return m_KS; }
private:
alignmentTrend m_mean;
alignmentTrend m_low;
alignmentTrend m_high;
alignmentTrend m_lowerr;
alignmentTrend m_higherr;
alignmentTrend m_chi2;
alignmentTrend m_KS;
};
/*! \struct bundle
* \brief Structure bundle
* Contains the ensemble of all the information to build the graphs alignmentTrends
*
* @param nObjects int, number of alignments to be considered
* @param dataType TString, type of the data to be displayed (time, lumi)
* @param dataTypeLabel TString, x-axis label
* @param lumiMapByrun std::map of the luminoisty by run number
* @param times std::map of the date (UTC) by run number
* @param lumiaxisformat boolean, is the x-axis of the type lumi
* @param timeaxisformat boolean, is the x-axis of the type time
*/
struct bundle {
bundle(int nObjects,
const TString &dataType,
const TString &dataTypeLabel,
const std::map<int, double> &lumiMapByRun,
const std::map<int, TDatime> ×,
const bool &lumiaxisformat,
const bool &timeaxisformat,
const bool &useRMS) {
m_nObjects = nObjects;
m_datatype = dataType.Data();
m_datatypelabel = dataTypeLabel.Data();
m_lumiMapByRun = lumiMapByRun;
m_times = times;
m_useRMS = useRMS;
logInfo << "pv::bundle c'tor: " << dataTypeLabel << " member: " << m_datatypelabel << std::endl;
// make sure you don't use them at the same time
if (lumiaxisformat || timeaxisformat) {
assert(lumiaxisformat != timeaxisformat);
}
if (lumiaxisformat) {
logInfo << "is lumiaxis format" << std::endl;
m_axis_types.set(0);
} else if (timeaxisformat) {
logInfo << "is timeaxis format" << std::endl;
m_axis_types.set(1);
} else {
logInfo << "is runaxis format" << std::endl;
}
logInfo << m_axis_types << std::endl;
m_totalLumi = lumiMapByRun.rbegin()->second;
}
int getNObjects() const { return m_nObjects; }
const char *getDataType() const { return m_datatype; }
const char *getDataTypeLabel() const { return m_datatypelabel; }
const std::map<int, double> getLumiMapByRun() const { return m_lumiMapByRun; }
double getTotalLumi() const { return m_totalLumi; }
const std::map<int, TDatime> getTimes() const { return m_times; }
bool isLumiAxis() const { return m_axis_types.test(0); }
bool isTimeAxis() const { return m_axis_types.test(1); }
bool isUsingRMS() const { return m_useRMS; }
void printAll() {
logInfo << "dataType " << m_datatype << std::endl;
logInfo << "dataTypeLabel " << m_datatypelabel << std::endl;
if (this->isLumiAxis())
logInfo << "is lumi axis" << std::endl;
if (this->isTimeAxis())
logInfo << "is time axis" << std::endl;
}
private:
int m_nObjects;
const char *m_datatype;
const char *m_datatypelabel;
float m_totalLumi;
std::map<int, double> m_lumiMapByRun;
std::map<int, TDatime> m_times;
std::bitset<2> m_axis_types;
bool m_useRMS;
};
} // namespace pv
// auxilliary struct to store
// histogram features
struct unrolledHisto {
double m_y_min;
double m_y_max;
unsigned int m_n_bins;
std::vector<double> m_bincontents;
unrolledHisto() {
m_y_min = 0.;
m_y_max = 0.;
m_n_bins = 0;
m_bincontents.clear();
} // first constructor empty
unrolledHisto(const double &y_min,
const double &y_max,
const unsigned int &n_bins,
const std::vector<double> &bincontents) {
m_y_min = y_min;
m_y_max = y_max;
m_n_bins = n_bins;
m_bincontents = bincontents;
} //look, a constructor
double get_y_min() { return m_y_min; }
double get_y_max() { return m_y_max; }
unsigned int get_n_bins() { return m_n_bins; }
std::vector<double> get_bin_contents() { return m_bincontents; }
double get_integral() {
double ret(0.);
for (const auto &binc : m_bincontents) {
ret += binc;
}
return ret;
}
};
/*! \struct outTrends
* \brief Structure outTrends
* Contains the ensemble of all the alignmentTrends built by the functor
*
* @param m_index int, to keep track of which chunk of data has been processed
* @param m_lumiSoFar double, luminosity in this section of the data
* @param m_runs std::vector, list of the run processed in this section
* @param m_lumiByRun std::vector, list of the luminisoties per run, indexed
* @param m_lumiMarpByRun std::map, map of the luminosities per run
* @param m_dxyPhiMeans alignmentTrend of the mean values of the profile dxy vs phi
* @param m_dxyPhiChi2 alignmentTrend of chi2 of the linear fit per profile dxy vs phi
* @param m_dxyPhiKS alignmentTrend of Kolmogorow-Smirnov score of comparison of dxy vs phi profile with flat line
* @param m_dxyPhiHi alignmentTrend of the highest value of the profile dxy vs phi
* @param m_dxyPhiLo alignmentTrend of the lowest value of the profile dxy vs phi
* @param m_dxyEtaMeans alignmentTrend of the mean values of the profile dxy vs eta
* @param m_dxyEtaChi2 alignmentTrend of chi2 of the linear fit per profile dxy vs eta
* @param m_dxyEtaKS alignmentTrend of Kolmogorow-Smirnov score of comparison of dxy vs eta profile with flat line
* @param m_dxyEtaHi alignmentTrend of the highest value of the profile dxy vs eta
* @param m_dxyEtaLo alignmentTrend of the lowest value of the profile dxy vs eta
* @param m_dzPhiMeans alignmentTrend of the mean values of the profile dz vs phi
* @param m_dzPhiChi2 alignmentTrend of chi2 of the linear fit per profile dz vs phi
* @param m_dzPhiKS alignmentTrend of Kolmogorow-Smirnov score of comparison of dz vs phi profile with flat line
* @param m_dzPhiHi alignmentTrend of the highest value of the profile dz vs phi
* @param m_dzPhiLo alignmentTrend of the lowest value of the profile dz vs phi
* @param m_dzEtaMeans alignmentTrend of the mean values of the profile dz vs eta
* @param m_dzEtaChi2 alignmentTrend of chi2 of the linear fit per profile dz vs eta
* @param m_dzEtaKS alignmentTrend of Kolmogorow-Smirnov score of comparison of dz vs eta profile with flat line
* @param m_dzEtaHi alignmentTrend of the highest value of the profile dz vs eta
* @param m_dzEtaLo alignmentTrend of the lowest value of the profile dz vs eta
* @param m_dxyVect map of the unrolled histograms for dxy residuals
* @param m_dzVect map of the unrolled histograms for dz residulas
*/
struct outTrends {
int m_index;
double m_lumiSoFar;
std::vector<double> m_runs;
std::vector<double> m_lumiByRun;
std::map<int, double> m_lumiMapByRun;
alignmentTrend m_dxyPhiMeans;
alignmentTrend m_dxyPhiChi2;
alignmentTrend m_dxyPhiKS;
alignmentTrend m_dxyPhiHi;
alignmentTrend m_dxyPhiLo;
alignmentTrend m_dxyEtaMeans;
alignmentTrend m_dxyEtaChi2;
alignmentTrend m_dxyEtaKS;
alignmentTrend m_dxyEtaHi;
alignmentTrend m_dxyEtaLo;
alignmentTrend m_dzPhiMeans;
alignmentTrend m_dzPhiChi2;
alignmentTrend m_dzPhiKS;
alignmentTrend m_dzPhiHi;
alignmentTrend m_dzPhiLo;
alignmentTrend m_dzEtaMeans;
alignmentTrend m_dzEtaChi2;
alignmentTrend m_dzEtaKS;
alignmentTrend m_dzEtaHi;
alignmentTrend m_dzEtaLo;
std::map<TString, std::vector<unrolledHisto> > m_dxyVect;
std::map<TString, std::vector<unrolledHisto> > m_dzVect;
void init() {
m_index = -1;
m_lumiSoFar = 0.;
m_runs.clear();
m_lumiByRun.clear();
m_lumiMapByRun.clear();
m_dxyPhiMeans.clear();
m_dxyPhiChi2.clear();
m_dxyPhiKS.clear();
m_dxyPhiHi.clear();
m_dxyPhiLo.clear();
m_dxyEtaMeans.clear();
m_dxyEtaChi2.clear();
m_dxyEtaKS.clear();
m_dxyEtaHi.clear();
m_dxyEtaLo.clear();
m_dzPhiMeans.clear();
m_dzPhiChi2.clear();
m_dzPhiKS.clear();
m_dzPhiHi.clear();
m_dzPhiLo.clear();
m_dzEtaMeans.clear();
m_dzEtaChi2.clear();
m_dzEtaKS.clear();
m_dzEtaHi.clear();
m_dzEtaLo.clear();
m_dxyVect.clear();
m_dzVect.clear();
}
};
// forward declarations
void MultiRunPVValidation(TString namesandlabels = "",
bool lumi_axis_format = false,
bool time_axis_format = false,
bool useRMS = true,
TString lumiInputFile = "");
outTrends processData(size_t iter,
std::vector<int> intersection,
const Int_t nDirs_,
const char *dirs[10],
TString LegLabels[10],
bool useRMS);
void arrangeOutCanvas(TCanvas *canv,
TH1F *m_11Trend[100],
TH1F *m_12Trend[100],
TH1F *m_21Trend[100],
TH1F *m_22Trend[100],
Int_t nFiles,
TString LegLabels[10],
unsigned int theRun);
pv::biases getBiases(TH1F *hist);
unrolledHisto getUnrolledHisto(TH1F *hist);
TH1F *DrawConstant(TH1F *hist, Int_t iter, Double_t theConst);
TH1F *DrawConstantWithErr(TH1F *hist, Int_t iter, Double_t theConst);
TH1F *DrawConstantGraph(TGraph *graph, Int_t iter, Double_t theConst);
std::vector<int> list_files(const char *dirname = ".", const char *ext = ".root");
TH1F *checkTH1AndReturn(TFile *f, TString address);
void MakeNiceTrendPlotStyle(TH1 *hist, Int_t color);
void cmsPrel(TPad *pad, size_t ipads = 1);
void makeNewXAxis(TH1 *h);
void beautify(TGraph *g);
void beautify(TH1 *h);
void adjustmargins(TCanvas *canv);
void adjustmargins(TVirtualPad *canv);
void setStyle();
pv::view checkTheView(const TString &toCheck);
template <typename T>
void timify(T *mgr);
Double_t getMaximumFromArray(TObjArray *array);
void superImposeIOVBoundaries(TCanvas *c,
bool lumi_axis_format,
bool time_axis_format,
const std::map<int, double> &lumiMapByRun,
const std::map<int, TDatime> &timeMap,
bool drawText = true);
void outputGraphs(const pv::wrappedTrends &allInputs,
const std::vector<double> &ticks,
const std::vector<double> &ex_ticks,
TCanvas *&canv,
TCanvas *&mean_canv,
TCanvas *&rms_canv,
TGraph *&g_mean,
TGraph *&g_chi2,
TGraph *&g_KS,
TGraph *&g_low,
TGraph *&g_high,
TGraphAsymmErrors *&g_asym,
TH1F *h_RMS[],
const pv::bundle &mybundle,
const pv::view &theView,
const int index,
TObjArray *&array,
const TString &label,
TLegend *&legend);
/*! \fn split
* \brief utility function to split strings
*/
/*--------------------------------------------------------------------*/
std::vector<std::string> split(const std::string &s, char delimiter)
/*--------------------------------------------------------------------*/
{
std::vector<std::string> tokens;
std::string token;
std::istringstream tokenStream(s);
while (std::getline(tokenStream, token, delimiter)) {
tokens.push_back(token);
}
return tokens;
}
///////////////////////////////////
//
// Main function
//
///////////////////////////////////
void MultiRunPVValidation(
TString namesandlabels, bool lumi_axis_format, bool time_axis_format, bool useRMS, TString lumiInputFile) {
TStopwatch timer;
timer.Start();
using namespace std::placeholders; // for _1, _2, _3...
gROOT->ProcessLine("gErrorIgnoreLevel = kError;");
ROOT::EnableThreadSafety();
TH1::AddDirectory(kFALSE);
// consistency check, we cannot do plot vs lumi if time_axis
if (lumi_axis_format && time_axis_format) {
logError << "##########################################################################################"
<< std::endl;
logError << "msg-i: MultiRunPVValidation(): you're requesting both summary vs lumi and vs time, " << std::endl;
logError << " this combination is inconsistent --> exiting!" << std::endl;
exit(EXIT_FAILURE);
}
// preload the dates from file
std::map<int, TDatime> times;
if (time_axis_format) {
std::ifstream infile("times.txt");
if (!infile) {
logError << "Required time axis options, but missing input times file :(" << std::endl;
logError << " -- exiting" << std::endl;
exit(EXIT_FAILURE);
}
std::string line;
while (std::getline(infile, line)) {
std::istringstream iss(line);
std::string a, b, c;
if (!(iss >> a >> b >> c)) {
break;
} // error
//logInfo<<a<<" "<<b<<" "<<c<<" "<<std::endl;
int run = std::stoi(a);
auto tokens_b = split(b, '-');
int year = std::stoi(tokens_b[0]);
int month = std::stoi(tokens_b[1]);
int day = std::stoi(tokens_b[2]);
auto tokens_c = split(c, '.');
auto tokens_c1 = split(tokens_c[0], ':');
int hour = std::stoi(tokens_c1[0]);
int minute = std::stoi(tokens_c1[2]);
int second = std::stoi(tokens_c1[2]);
//logInfo<<run<<" "<<year<<" "<<month<<" "<<day<<" "<<hour<<" "<<minute<<" "<<second<<" "<<std::endl;
TDatime da(year, month, day, hour, minute, second);
times[run] = da;
}
} // if time axis in the plots
//std::ofstream outfile ("lumiByRun.txt");
std::ofstream outfile("log.txt");
setStyle();
TList *DirList = new TList();
TList *LabelList = new TList();
TObjArray *nameandlabelpairs = namesandlabels.Tokenize(",");
for (Int_t i = 0; i < nameandlabelpairs->GetEntries(); ++i) {
TObjArray *aFileLegPair = TString(nameandlabelpairs->At(i)->GetName()).Tokenize("=");
if (aFileLegPair->GetEntries() == 2) {
DirList->Add(aFileLegPair->At(0));
LabelList->Add(aFileLegPair->At(1));
} else {
logError << "Please give file name and legend entry in the following form:\n"
<< " filename1=legendentry1,filename2=legendentry2\n";
}
}
const Int_t nDirs_ = DirList->GetSize();
TString LegLabels[10];
const char *dirs[10];
std::vector<int> intersection;
std::vector<double> runs;
std::vector<double> x_ticks;
std::vector<double> ex_ticks = {0.};
std::vector<double> runtimes;
if (time_axis_format) {
for (const auto &element : times) {
runtimes.push_back((element.second).Convert());
}
}
for (Int_t j = 0; j < nDirs_; j++) {
// Retrieve labels
TObjString *legend = (TObjString *)LabelList->At(j);
TObjString *dir = (TObjString *)DirList->At(j);
LegLabels[j] = legend->String();
dirs[j] = (dir->String()).Data();
logInfo << "MultiRunPVValidation(): label[" << j << "]" << LegLabels[j] << endl;
std::vector<int> currentList = list_files(dirs[j]);
std::vector<int> tempSwap;
std::sort(currentList.begin(), currentList.end());
if (j == 0) {
intersection = currentList;
}
std::sort(intersection.begin(), intersection.end());
std::set_intersection(
currentList.begin(), currentList.end(), intersection.begin(), intersection.end(), std::back_inserter(tempSwap));
intersection.clear();
intersection = tempSwap;
tempSwap.clear();
}
// prelod the lumi from file
std::vector<double> lumiByRun;
std::map<int, double> lumiMapByRun;
bool useLumiByFile = (lumiInputFile.Length() > 0);
if (lumi_axis_format && useLumiByFile) {
std::ifstream lumifile(lumiInputFile.Data());
if (!lumifile) {
logError << "Required luminosity from file, but missing input file :(" << std::endl;
logError << " -- exiting" << std::endl;
exit(EXIT_FAILURE);
}
std::string line;
double lumiSoFar = 0.0;
while (std::getline(lumifile, line)) {
std::istringstream iss(line);
std::string a, b;
if (!(iss >> a >> b)) {
break;
} // error
int run = std::stoi(a);
double lumi = std::stod(b) / 1000.;
// check if the run is in the list
if (std::find(intersection.begin(), intersection.end(), run) != intersection.end()) {
lumiByRun.push_back(lumiSoFar + lumi);
lumiMapByRun[run] = (lumiSoFar + lumi);
} else {
logWarning << " Run: " << run << " is not found in the intersection" << std::endl;
}
// fill the lumi so far irrespective if the run is in the intersection or not
// this corrects the global scale
lumiSoFar += lumi;
logInfo << run << " ====> lumi so far: " << lumiSoFar << std::endl;
}
}
// debug only
for (UInt_t index = 0; index < intersection.size(); index++) {
logInfo << index << " " << intersection[index] << std::endl;
}
// book the vectors of values
alignmentTrend dxyPhiMeans_;
alignmentTrend dxyPhiChi2_;
alignmentTrend dxyPhiHiErr_;
alignmentTrend dxyPhiLoErr_;
alignmentTrend dxyPhiKS_;
alignmentTrend dxyPhiHi_;
alignmentTrend dxyPhiLo_;
alignmentTrend dxyEtaMeans_;
alignmentTrend dxyEtaChi2_;
alignmentTrend dxyEtaHiErr_;
alignmentTrend dxyEtaLoErr_;
alignmentTrend dxyEtaKS_;
alignmentTrend dxyEtaHi_;
alignmentTrend dxyEtaLo_;
alignmentTrend dzPhiMeans_;
alignmentTrend dzPhiChi2_;
alignmentTrend dzPhiHiErr_;
alignmentTrend dzPhiLoErr_;
alignmentTrend dzPhiKS_;
alignmentTrend dzPhiHi_;
alignmentTrend dzPhiLo_;
alignmentTrend dzEtaMeans_;
alignmentTrend dzEtaChi2_;
alignmentTrend dzEtaHiErr_;
alignmentTrend dzEtaLoErr_;
alignmentTrend dzEtaKS_;
alignmentTrend dzEtaHi_;
alignmentTrend dzEtaLo_;
// unrolled histos
std::map<TString, std::vector<unrolledHisto> > dxyVect;
std::map<TString, std::vector<unrolledHisto> > dzVect;
double lumiSoFar = 0.0;
// loop over the runs in the intersection
//unsigned int last = (DEBUG==true) ? 50 : intersection.size();
//std::function<void()> f_processData = std::bind(processData,1,intersection,nDirs_,dirs,LegLabels,lumiSoFar,runs,lumiByRun,lumiMapByRun,useRMS,dxyPhiMeans_,dxyPhiHi_,dxyPhiLo_,dxyEtaMeans_,dxyEtaHi_,dxyEtaLo_,dzPhiMeans_,dzPhiHi_,dzPhiLo_,dzEtaMeans_,dzEtaHi_,dzEtaLo_,dxyVect,dzVect);
logInfo << " pre do-stuff: " << runs.size() << std::endl;
//we should use std::bind to create a functor and then pass it to the procPool
auto f_processData = std::bind(processData, _1, intersection, nDirs_, dirs, LegLabels, useRMS);
//f_processData(0);
//logInfo<<" post do-stuff: " << runs.size() << std::endl;
TProcPool procPool(std::min(nWorkers, intersection.size()));
std::vector<size_t> range(std::min(nWorkers, intersection.size()));
std::iota(range.begin(), range.end(), 0);
//procPool.Map([&f_processData](size_t a) { f_processData(a); },{1,2,3});
auto extracts = procPool.Map(f_processData, range);
// sort the extracts according to the global index
std::sort(extracts.begin(), extracts.end(), [](const outTrends &a, const outTrends &b) -> bool {
return a.m_index < b.m_index;
});
// re-assemble everything together
for (auto extractedTrend : extracts) {
if (!useLumiByFile) {
logInfo << "lumiSoFar: " << lumiSoFar << "/fb" << std::endl;
}
runs.insert(std::end(runs), std::begin(extractedTrend.m_runs), std::end(extractedTrend.m_runs));
// luminosity needs a different treatment
// we need to re-sum the luminosity so far
for (const auto &run : extractedTrend.m_runs) {
if (!useLumiByFile) {
logInfo << run << " ====> lumi so far: " << lumiSoFar + extractedTrend.m_lumiMapByRun[run] << std::endl;
lumiByRun.push_back(lumiSoFar + extractedTrend.m_lumiMapByRun[run]);
lumiMapByRun[run] = (lumiSoFar + extractedTrend.m_lumiMapByRun[run]);
}
}
lumiSoFar += (extractedTrend.m_lumiSoFar / 1000.);
/*
lumiByRun.insert(std::end(lumiByRun), std::begin(extractedTrend.m_lumiByRun), std::end(extractedTrend.m_lumiByRun));
lumiMapByRun.insert(extractedTrend.m_lumiMapByRun.begin(),extractedTrend.m_lumiMapByRun.end());
*/
for (const auto &label : LegLabels) {
//******************************//
dxyPhiMeans_[label].insert(std::end(dxyPhiMeans_[label]),
std::begin(extractedTrend.m_dxyPhiMeans[label]),
std::end(extractedTrend.m_dxyPhiMeans[label]));
dxyPhiChi2_[label].insert(std::end(dxyPhiChi2_[label]),
std::begin(extractedTrend.m_dxyPhiChi2[label]),
std::end(extractedTrend.m_dxyPhiChi2[label]));
dxyPhiKS_[label].insert(std::end(dxyPhiKS_[label]),
std::begin(extractedTrend.m_dxyPhiKS[label]),
std::end(extractedTrend.m_dxyPhiKS[label]));
dxyPhiHi_[label].insert(std::end(dxyPhiHi_[label]),
std::begin(extractedTrend.m_dxyPhiHi[label]),
std::end(extractedTrend.m_dxyPhiHi[label]));
dxyPhiLo_[label].insert(std::end(dxyPhiLo_[label]),
std::begin(extractedTrend.m_dxyPhiLo[label]),
std::end(extractedTrend.m_dxyPhiLo[label]));
//******************************//
dzPhiMeans_[label].insert(std::end(dzPhiMeans_[label]),
std::begin(extractedTrend.m_dzPhiMeans[label]),
std::end(extractedTrend.m_dzPhiMeans[label]));
dzPhiChi2_[label].insert(std::end(dzPhiChi2_[label]),
std::begin(extractedTrend.m_dzPhiChi2[label]),
std::end(extractedTrend.m_dzPhiChi2[label]));
dzPhiKS_[label].insert(std::end(dzPhiKS_[label]),
std::begin(extractedTrend.m_dzPhiKS[label]),
std::end(extractedTrend.m_dzPhiKS[label]));
dzPhiHi_[label].insert(std::end(dzPhiHi_[label]),
std::begin(extractedTrend.m_dzPhiHi[label]),
std::end(extractedTrend.m_dzPhiHi[label]));
dzPhiLo_[label].insert(std::end(dzPhiLo_[label]),
std::begin(extractedTrend.m_dzPhiLo[label]),
std::end(extractedTrend.m_dzPhiLo[label]));
//******************************//
dxyEtaMeans_[label].insert(std::end(dxyEtaMeans_[label]),
std::begin(extractedTrend.m_dxyEtaMeans[label]),
std::end(extractedTrend.m_dxyEtaMeans[label]));
dxyEtaChi2_[label].insert(std::end(dxyEtaChi2_[label]),
std::begin(extractedTrend.m_dxyEtaChi2[label]),
std::end(extractedTrend.m_dxyEtaChi2[label]));
dxyEtaKS_[label].insert(std::end(dxyEtaKS_[label]),
std::begin(extractedTrend.m_dxyEtaKS[label]),
std::end(extractedTrend.m_dxyEtaKS[label]));
dxyEtaHi_[label].insert(std::end(dxyEtaHi_[label]),
std::begin(extractedTrend.m_dxyEtaHi[label]),
std::end(extractedTrend.m_dxyEtaHi[label]));
dxyEtaLo_[label].insert(std::end(dxyEtaLo_[label]),
std::begin(extractedTrend.m_dxyEtaLo[label]),
std::end(extractedTrend.m_dxyEtaLo[label]));
//******************************//
dzEtaMeans_[label].insert(std::end(dzEtaMeans_[label]),
std::begin(extractedTrend.m_dzEtaMeans[label]),
std::end(extractedTrend.m_dzEtaMeans[label]));
dzEtaChi2_[label].insert(std::end(dzEtaChi2_[label]),
std::begin(extractedTrend.m_dzEtaChi2[label]),
std::end(extractedTrend.m_dzEtaChi2[label]));
dzEtaKS_[label].insert(std::end(dzEtaKS_[label]),
std::begin(extractedTrend.m_dzEtaKS[label]),
std::end(extractedTrend.m_dzEtaKS[label]));
dzEtaHi_[label].insert(std::end(dzEtaHi_[label]),
std::begin(extractedTrend.m_dzEtaHi[label]),
std::end(extractedTrend.m_dzEtaHi[label]));
dzEtaLo_[label].insert(std::end(dzEtaLo_[label]),
std::begin(extractedTrend.m_dzEtaLo[label]),
std::end(extractedTrend.m_dzEtaLo[label]));
//******************************//
dxyVect[label].insert(std::end(dxyVect[label]),
std::begin(extractedTrend.m_dxyVect[label]),
std::end(extractedTrend.m_dxyVect[label]));
dzVect[label].insert(std::end(dzVect[label]),
std::begin(extractedTrend.m_dzVect[label]),
std::end(extractedTrend.m_dzVect[label]));
}
}
// extra vectors for low and high boundaries
for (const auto &label : LegLabels) {
for (unsigned int it = 0; it < dxyPhiMeans_[label].size(); it++) {
dxyPhiHiErr_[label].push_back(std::abs(dxyPhiHi_[label][it] - dxyPhiMeans_[label][it]));
dxyPhiLoErr_[label].push_back(std::abs(dxyPhiLo_[label][it] - dxyPhiMeans_[label][it]));
dxyEtaHiErr_[label].push_back(std::abs(dxyEtaHi_[label][it] - dxyEtaMeans_[label][it]));
dxyEtaLoErr_[label].push_back(std::abs(dxyEtaLo_[label][it] - dxyEtaMeans_[label][it]));
if (VERBOSE) {
logInfo << "label: " << label << " means:" << dxyEtaMeans_[label][it] << " low: " << dxyEtaLo_[label][it]
<< " loErr: " << dxyEtaLoErr_[label][it] << std::endl;
}
dzPhiHiErr_[label].push_back(std::abs(dzPhiHi_[label][it] - dzPhiMeans_[label][it]));
dzPhiLoErr_[label].push_back(std::abs(dzPhiLo_[label][it] - dzPhiMeans_[label][it]));
dzEtaHiErr_[label].push_back(std::abs(dzEtaHi_[label][it] - dzEtaMeans_[label][it]));
dzEtaLoErr_[label].push_back(std::abs(dzEtaLo_[label][it] - dzEtaMeans_[label][it]));
}
}
// just check runs are ordered
//for(const auto &run : runs){
// logInfo<<" "<< run ;
// }
// main function call
/*
processData(0,intersection,nDirs_,dirs,LegLabels,lumiSoFar,runs,lumiByRun,lumiMapByRun,useRMS,
dxyPhiMeans_,dxyPhiHi_,dxyPhiLo_,
dxyEtaMeans_,dxyEtaHi_,dxyEtaLo_,
dzPhiMeans_,dzPhiHi_,dzPhiLo_,
dzEtaMeans_,dzEtaHi_,dzEtaLo_,
dxyVect,dzVect
);
*/
// do the trend-plotting!
TCanvas *c_dxy_phi_vs_run = new TCanvas("c_dxy_phi_vs_run", "dxy(#phi) bias vs run number", 2000, 800);
TCanvas *c_dxy_eta_vs_run = new TCanvas("c_dxy_eta_vs_run", "dxy(#eta) bias vs run number", 2000, 800);
TCanvas *c_dz_phi_vs_run = new TCanvas("c_dz_phi_vs_run", "dz(#phi) bias vs run number", 2000, 800);
TCanvas *c_dz_eta_vs_run = new TCanvas("c_dz_eta_vs_run", "dz(#eta) bias vs run number", 2000, 800);
TCanvas *c_RMS_dxy_phi_vs_run = new TCanvas("c_RMS_dxy_phi_vs_run", "dxy(#phi) bias vs run number", 2000, 800);
TCanvas *c_RMS_dxy_eta_vs_run = new TCanvas("c_RMS_dxy_eta_vs_run", "dxy(#eta) bias vs run number", 2000, 800);
TCanvas *c_RMS_dz_phi_vs_run = new TCanvas("c_RMS_dz_phi_vs_run", "dxy(#phi) bias vs run number", 2000, 800);
TCanvas *c_RMS_dz_eta_vs_run = new TCanvas("c_RMS_dz_eta_vs_run", "dxy(#eta) bias vs run number", 2000, 800);
TCanvas *c_mean_dxy_phi_vs_run = new TCanvas("c_mean_dxy_phi_vs_run", "dxy(#phi) bias vs run number", 2000, 800);
TCanvas *c_mean_dxy_eta_vs_run = new TCanvas("c_mean_dxy_eta_vs_run", "dxy(#eta) bias vs run number", 2000, 800);
TCanvas *c_mean_dz_phi_vs_run = new TCanvas("c_mean_dz_phi_vs_run", "dxy(#phi) bias vs run number", 2000, 800);
TCanvas *c_mean_dz_eta_vs_run = new TCanvas("c_mean_dz_eta_vs_run", "dxy(#eta) bias vs run number", 2000, 800);
TCanvas *Scatter_dxy_vs_run = new TCanvas("Scatter_dxy_vs_run", "dxy bias vs run number", 2000, 800);
Scatter_dxy_vs_run->Divide(1, nDirs_);
TCanvas *Scatter_dz_vs_run = new TCanvas("Scatter_dz_vs_run", "dxy bias vs run number", 2000, 800);
Scatter_dz_vs_run->Divide(1, nDirs_);
TCanvas *c_chisquare_vs_run = new TCanvas("c_chisquare_vs_run", "chi2 of pol0 fit vs run number", 2000, 800);
c_chisquare_vs_run->Divide(2, 2);
TCanvas *c_KSScore_vs_run = new TCanvas("c_KSScore_vs_run", "KS score compatibility to 0 vs run number", 2000, 1000);
c_KSScore_vs_run->Divide(2, 2);
// bias on the mean
TGraph *g_dxy_phi_vs_run[nDirs_];
TGraphAsymmErrors *gerr_dxy_phi_vs_run[nDirs_];
TGraph *g_chi2_dxy_phi_vs_run[nDirs_];
TGraph *g_KS_dxy_phi_vs_run[nDirs_];
TGraph *gprime_dxy_phi_vs_run[nDirs_];
TGraph *g_dxy_phi_hi_vs_run[nDirs_];
TGraph *g_dxy_phi_lo_vs_run[nDirs_];
TGraph *g_dxy_eta_vs_run[nDirs_];
TGraphAsymmErrors *gerr_dxy_eta_vs_run[nDirs_];
TGraph *g_chi2_dxy_eta_vs_run[nDirs_];
TGraph *g_KS_dxy_eta_vs_run[nDirs_];
TGraph *gprime_dxy_eta_vs_run[nDirs_];
TGraph *g_dxy_eta_hi_vs_run[nDirs_];
TGraph *g_dxy_eta_lo_vs_run[nDirs_];
TGraph *g_dz_phi_vs_run[nDirs_];
TGraphAsymmErrors *gerr_dz_phi_vs_run[nDirs_];
TGraph *g_chi2_dz_phi_vs_run[nDirs_];
TGraph *g_KS_dz_phi_vs_run[nDirs_];
TGraph *gprime_dz_phi_vs_run[nDirs_];
TGraph *g_dz_phi_hi_vs_run[nDirs_];
TGraph *g_dz_phi_lo_vs_run[nDirs_];
TGraph *g_dz_eta_vs_run[nDirs_];
TGraphAsymmErrors *gerr_dz_eta_vs_run[nDirs_];
TGraph *g_chi2_dz_eta_vs_run[nDirs_];
TGraph *g_KS_dz_eta_vs_run[nDirs_];
TGraph *gprime_dz_eta_vs_run[nDirs_];
TGraph *g_dz_eta_hi_vs_run[nDirs_];
TGraph *g_dz_eta_lo_vs_run[nDirs_];
// resolutions
TH1F *h_RMS_dxy_phi_vs_run[nDirs_];
TH1F *h_RMS_dxy_eta_vs_run[nDirs_];
TH1F *h_RMS_dz_phi_vs_run[nDirs_];
TH1F *h_RMS_dz_eta_vs_run[nDirs_];
// scatters of integrated bias
TH2F *h2_scatter_dxy_vs_run[nDirs_];
TH2F *h2_scatter_dz_vs_run[nDirs_];
// decide the type
TString theType = "";
TString theTypeLabel = "";
if (lumi_axis_format) {
theType = "luminosity";
theTypeLabel = "Processed luminosity [1/fb]";
if (!useLumiByFile) {
x_ticks = lumiByRun;
} else {
// x_ticks = lumiByRun; (generally it's wrong)
// in case we are passing the luminosity per run by file, need to re-check the map
// in order to fill the x ticks of the graph only for the run which actually pass the selection
double lastLumi(0.);
for (const auto &iRun : runs) {
if (lumiMapByRun.find(iRun) != lumiMapByRun.end()) {
x_ticks.push_back(lumiMapByRun[iRun]);
lastLumi = x_ticks.back();
} else {
// if the run is not find in the lumiMapByRun we just use the lumi of
// the last run analyzed (so we assume that run has lumi=0)
x_ticks.push_back(lastLumi);
}
}
}
} else {
if (!time_axis_format) {
theType = "run number";
theTypeLabel = "run number";
x_ticks = runs;
} else {
theType = "date";
theTypeLabel = "UTC date";
for (const auto &run : runs) {
x_ticks.push_back(times[run].Convert());
}
}
}
//TLegend *my_lego = new TLegend(0.08,0.80,0.18,0.93);
//my_lego-> SetNColumns(2);
TLegend *my_lego = new TLegend(0.75, 0.76, 0.92, 0.93);
//TLegend *my_lego = new TLegend(0.75,0.26,0.92,0.43);
//my_lego->SetHeader("2017 Data","C");
TLine *line = new TLine(0, 0, 1, 0);
line->SetLineColor(kBlue);
line->SetLineStyle(9);
line->SetLineWidth(1);
my_lego->AddEntry(line, "pixel calibration update", "L");
my_lego->SetFillColor(10);
my_lego->SetTextSize(0.042);
my_lego->SetTextFont(42);
my_lego->SetFillColor(10);
my_lego->SetLineColor(10);
my_lego->SetShadowColor(10);
// arrays for storing RMS histograms
TObjArray *arr_dxy_phi = new TObjArray();
TObjArray *arr_dz_phi = new TObjArray();
TObjArray *arr_dxy_eta = new TObjArray();
TObjArray *arr_dz_eta = new TObjArray();
arr_dxy_phi->Expand(nDirs_);
arr_dz_phi->Expand(nDirs_);
arr_dxy_eta->Expand(nDirs_);
arr_dz_eta->Expand(nDirs_);
int ccc = 0;
for (const auto &tick : x_ticks) {
outfile << "***************************************" << std::endl;
outfile << tick << std::endl;
for (Int_t j = 0; j < nDirs_; j++) {
double RMSxyphi = std::abs(dxyPhiLo_[LegLabels[j]][ccc] - dxyPhiHi_[LegLabels[j]][ccc]);
double RMSxyeta = std::abs(dxyEtaLo_[LegLabels[j]][ccc] - dxyEtaHi_[LegLabels[j]][ccc]);
double RMSzphi = std::abs(dzPhiLo_[LegLabels[j]][ccc] - dzPhiHi_[LegLabels[j]][ccc]);
double RMSzeta = std::abs(dzEtaLo_[LegLabels[j]][ccc] - dzEtaHi_[LegLabels[j]][ccc]);
if (RMSxyphi > 100 || RMSxyeta > 100 || RMSzphi > 100 || RMSzeta > 100) {
outfile << LegLabels[j] << " dxy(phi) " << dxyPhiMeans_[LegLabels[j]][ccc] << " "
<< dxyPhiLo_[LegLabels[j]][ccc] << " " << dxyPhiHi_[LegLabels[j]][ccc] << " "
<< std::abs(dxyPhiLo_[LegLabels[j]][ccc] - dxyPhiHi_[LegLabels[j]][ccc]) << std::endl;
outfile << LegLabels[j] << " dxy(eta) " << dxyEtaMeans_[LegLabels[j]][ccc] << " "
<< dxyEtaLo_[LegLabels[j]][ccc] << " " << dxyEtaHi_[LegLabels[j]][ccc] << " "
<< std::abs(dxyEtaLo_[LegLabels[j]][ccc] - dxyEtaHi_[LegLabels[j]][ccc]) << std::endl;
outfile << LegLabels[j] << " dz (phi) " << dzPhiMeans_[LegLabels[j]][ccc] << " " << dzPhiLo_[LegLabels[j]][ccc]
<< " " << dzPhiHi_[LegLabels[j]][ccc] << " "
<< std::abs(dzPhiLo_[LegLabels[j]][ccc] - dzPhiHi_[LegLabels[j]][ccc]) << std::endl;
outfile << LegLabels[j] << " dz (eta) " << dzEtaMeans_[LegLabels[j]][ccc] << " " << dzEtaLo_[LegLabels[j]][ccc]
<< " " << dzEtaHi_[LegLabels[j]][ccc] << " "
<< std::abs(dzEtaLo_[LegLabels[j]][ccc] - dzEtaHi_[LegLabels[j]][ccc]) << std::endl;
}
}
ccc++;
}
outfile << std::endl;
pv::bundle theBundle =
pv::bundle(nDirs_, theType, theTypeLabel, lumiMapByRun, times, lumi_axis_format, time_axis_format, useRMS);
theBundle.printAll();
for (Int_t j = 0; j < nDirs_; j++) {
// check on the sanity
logInfo << "x_ticks.size()= " << x_ticks.size() << " dxyPhiMeans_[LegLabels[" << j
<< "]].size()=" << dxyPhiMeans_[LegLabels[j]].size() << std::endl;
// otherwise something very bad has happened
assert(x_ticks.size() == dxyPhiMeans_[LegLabels[j]].size());
// *************************************
// dxy vs phi
// *************************************
auto dxyPhiInputs =
pv::wrappedTrends(dxyPhiMeans_, dxyPhiLo_, dxyPhiHi_, dxyPhiLoErr_, dxyPhiHiErr_, dxyPhiChi2_, dxyPhiKS_);
outputGraphs(dxyPhiInputs,
x_ticks,
ex_ticks,
c_dxy_phi_vs_run,
c_mean_dxy_phi_vs_run,
c_RMS_dxy_phi_vs_run,
g_dxy_phi_vs_run[j],
g_chi2_dxy_phi_vs_run[j],
g_KS_dxy_phi_vs_run[j],
g_dxy_phi_lo_vs_run[j],
g_dxy_phi_hi_vs_run[j],
gerr_dxy_phi_vs_run[j],
h_RMS_dxy_phi_vs_run,
theBundle,
pv::dxyphi,
j,
arr_dxy_phi,
LegLabels[j],
my_lego);
// *************************************
// dxy vs eta
// *************************************
auto dxyEtaInputs =
pv::wrappedTrends(dxyEtaMeans_, dxyEtaLo_, dxyEtaHi_, dxyEtaLoErr_, dxyEtaHiErr_, dxyEtaChi2_, dxyEtaKS_);
outputGraphs(dxyEtaInputs,
x_ticks,
ex_ticks,
c_dxy_eta_vs_run,
c_mean_dxy_eta_vs_run,
c_RMS_dxy_eta_vs_run,
g_dxy_eta_vs_run[j],
g_chi2_dxy_eta_vs_run[j],
g_KS_dxy_eta_vs_run[j],
g_dxy_eta_lo_vs_run[j],
g_dxy_eta_hi_vs_run[j],
gerr_dxy_eta_vs_run[j],
h_RMS_dxy_eta_vs_run,
theBundle,
pv::dxyeta,
j,
arr_dxy_eta,
LegLabels[j],
my_lego);
// *************************************
// dz vs phi
// *************************************
auto dzPhiInputs =
pv::wrappedTrends(dzPhiMeans_, dzPhiLo_, dzPhiHi_, dzPhiLoErr_, dzPhiHiErr_, dzPhiChi2_, dzPhiKS_);
outputGraphs(dzPhiInputs,
x_ticks,
ex_ticks,
c_dz_phi_vs_run,
c_mean_dz_phi_vs_run,
c_RMS_dz_phi_vs_run,
g_dz_phi_vs_run[j],
g_chi2_dz_phi_vs_run[j],
g_KS_dz_phi_vs_run[j],
g_dz_phi_lo_vs_run[j],
g_dz_phi_hi_vs_run[j],
gerr_dz_phi_vs_run[j],
h_RMS_dz_phi_vs_run,
theBundle,
pv::dzphi,
j,
arr_dz_phi,
LegLabels[j],
my_lego);
// *************************************
// dz vs eta
// *************************************
auto dzEtaInputs =
pv::wrappedTrends(dzEtaMeans_, dzEtaLo_, dzEtaHi_, dzEtaLoErr_, dzEtaHiErr_, dzEtaChi2_, dzEtaKS_);
outputGraphs(dzEtaInputs,
x_ticks,
ex_ticks,
c_dz_eta_vs_run,
c_mean_dz_eta_vs_run,
c_RMS_dz_eta_vs_run,
g_dz_eta_vs_run[j],
g_chi2_dz_eta_vs_run[j],
g_KS_dz_eta_vs_run[j],
g_dz_eta_lo_vs_run[j],
g_dz_eta_hi_vs_run[j],
gerr_dz_eta_vs_run[j],
h_RMS_dz_eta_vs_run,
theBundle,
pv::dzeta,
j,
arr_dz_eta,
LegLabels[j],
my_lego);
// *************************************
// Integrated bias dxy scatter plots
// *************************************
h2_scatter_dxy_vs_run[j] =
new TH2F(Form("h2_scatter_dxy_%s", LegLabels[j].Data()),
Form("scatter of d_{xy} vs %s;%s;d_{xy} [cm]", theType.Data(), theTypeLabel.Data()),
x_ticks.size() - 1,
&(x_ticks[0]),
dxyVect[LegLabels[j]][0].get_n_bins(),
dxyVect[LegLabels[j]][0].get_y_min(),
dxyVect[LegLabels[j]][0].get_y_max());
h2_scatter_dxy_vs_run[j]->SetStats(kFALSE);
for (unsigned int runindex = 0; runindex < x_ticks.size(); runindex++) {
for (unsigned int binindex = 0; binindex < dxyVect[LegLabels[j]][runindex].get_n_bins(); binindex++) {
h2_scatter_dxy_vs_run[j]->SetBinContent(runindex + 1,
binindex + 1,
dxyVect[LegLabels[j]][runindex].get_bin_contents().at(binindex) /
dxyVect[LegLabels[j]][runindex].get_integral());
}
}
//Scatter_dxy_vs_run->cd();
h2_scatter_dxy_vs_run[j]->SetFillColorAlpha(pv::colors[j], 0.3);
h2_scatter_dxy_vs_run[j]->SetMarkerColor(pv::colors[j]);
h2_scatter_dxy_vs_run[j]->SetLineColor(pv::colors[j]);
h2_scatter_dxy_vs_run[j]->SetMarkerStyle(pv::markers[j]);
auto h_dxypfx_tmp = (TProfile *)(((TH2F *)h2_scatter_dxy_vs_run[j])->ProfileX(Form("_apfx_%i", j), 1, -1, "o"));
h_dxypfx_tmp->SetName(TString(h2_scatter_dxy_vs_run[j]->GetName()) + "_pfx");
h_dxypfx_tmp->SetStats(kFALSE);
h_dxypfx_tmp->SetMarkerColor(pv::colors[j]);
h_dxypfx_tmp->SetLineColor(pv::colors[j]);
h_dxypfx_tmp->SetLineWidth(2);
h_dxypfx_tmp->SetMarkerSize(1);
h_dxypfx_tmp->SetMarkerStyle(pv::markers[j]);
beautify(h2_scatter_dxy_vs_run[j]);
beautify(h_dxypfx_tmp);
Scatter_dxy_vs_run->cd(j + 1);
adjustmargins(Scatter_dxy_vs_run->cd(j + 1));
//h_dxypfx_tmp->GetYaxis()->SetRangeUser(-0.01,0.01);
//h2_scatter_dxy_vs_run[j]->GetYaxis()->SetRangeUser(-0.5,0.5);
h2_scatter_dxy_vs_run[j]->Draw("colz");
h_dxypfx_tmp->Draw("same");
// *************************************
// Integrated bias dz scatter plots
// *************************************
h2_scatter_dz_vs_run[j] =
new TH2F(Form("h2_scatter_dz_%s", LegLabels[j].Data()),
Form("scatter of d_{z} vs %s;%s;d_{z} [cm]", theType.Data(), theTypeLabel.Data()),
x_ticks.size() - 1,
&(x_ticks[0]),
dzVect[LegLabels[j]][0].get_n_bins(),
dzVect[LegLabels[j]][0].get_y_min(),
dzVect[LegLabels[j]][0].get_y_max());
h2_scatter_dz_vs_run[j]->SetStats(kFALSE);
for (unsigned int runindex = 0; runindex < x_ticks.size(); runindex++) {
for (unsigned int binindex = 0; binindex < dzVect[LegLabels[j]][runindex].get_n_bins(); binindex++) {
h2_scatter_dz_vs_run[j]->SetBinContent(runindex + 1,
binindex + 1,
dzVect[LegLabels[j]][runindex].get_bin_contents().at(binindex) /
dzVect[LegLabels[j]][runindex].get_integral());
}
}
//Scatter_dz_vs_run->cd();
h2_scatter_dz_vs_run[j]->SetFillColorAlpha(pv::colors[j], 0.3);
h2_scatter_dz_vs_run[j]->SetMarkerColor(pv::colors[j]);
h2_scatter_dz_vs_run[j]->SetLineColor(pv::colors[j]);
h2_scatter_dz_vs_run[j]->SetMarkerStyle(pv::markers[j]);
auto h_dzpfx_tmp = (TProfile *)(((TH2F *)h2_scatter_dz_vs_run[j])->ProfileX(Form("_apfx_%i", j), 1, -1, "o"));
h_dzpfx_tmp->SetName(TString(h2_scatter_dz_vs_run[j]->GetName()) + "_pfx");
h_dzpfx_tmp->SetStats(kFALSE);
h_dzpfx_tmp->SetMarkerColor(pv::colors[j]);
h_dzpfx_tmp->SetLineColor(pv::colors[j]);
h_dzpfx_tmp->SetLineWidth(2);
h_dzpfx_tmp->SetMarkerSize(1);
h_dzpfx_tmp->SetMarkerStyle(pv::markers[j]);
beautify(h2_scatter_dz_vs_run[j]);
beautify(h_dzpfx_tmp);
Scatter_dz_vs_run->cd(j + 1);
adjustmargins(Scatter_dz_vs_run->cd(j + 1));
//h_dzpfx_tmp->GetYaxis()->SetRangeUser(-0.01,0.01);
//h2_scatter_dz_vs_run[j]->GetYaxis()->SetRangeUser(-0.5,0.5);
h2_scatter_dz_vs_run[j]->Draw("colz");
h_dzpfx_tmp->Draw("same");
// ****************************************
// Canvas for chi2 goodness of pol0 fit
// ****************************************
// 1st pad
c_chisquare_vs_run->cd(1);
adjustmargins(c_chisquare_vs_run->cd(1));
g_chi2_dxy_phi_vs_run[j]->SetMarkerStyle(pv::markers[j]);
g_chi2_dxy_phi_vs_run[j]->SetMarkerColor(pv::colors[j]);
g_chi2_dxy_phi_vs_run[j]->SetLineColor(pv::colors[j]);
g_chi2_dxy_phi_vs_run[j]->SetName(Form("g_chi2_dxy_phi_%s", LegLabels[j].Data()));
g_chi2_dxy_phi_vs_run[j]->SetTitle(Form("log_{10}(#chi2/ndf) of d_{xy}(#varphi) fit vs %s", theType.Data()));
g_chi2_dxy_phi_vs_run[j]->GetXaxis()->SetTitle(theTypeLabel.Data());
g_chi2_dxy_phi_vs_run[j]->GetYaxis()->SetTitle("log_{10}(#chi^{2}/ndf) of d_{xy}(#phi) pol0 fit");
g_chi2_dxy_phi_vs_run[j]->GetYaxis()->SetRangeUser(-0.5, 4.5);
if (lumi_axis_format) {
g_chi2_dxy_phi_vs_run[j]->GetXaxis()->SetRangeUser(0., theBundle.getTotalLumi());
}
beautify(g_chi2_dxy_phi_vs_run[j]);
//g_chi2_dxy_phi_vs_run[j]->GetYaxis()->SetTitleOffset(1.3);
if (j == 0) {
g_chi2_dxy_phi_vs_run[j]->Draw("APL");
} else {
g_chi2_dxy_phi_vs_run[j]->Draw("PLsame");
}
if (time_axis_format) {
timify(g_chi2_dxy_phi_vs_run[j]);
}
if (j == nDirs_ - 1) {
my_lego->Draw("same");
}
auto current_pad = static_cast<TCanvas *>(gPad);
superImposeIOVBoundaries(current_pad, lumi_axis_format, time_axis_format, lumiMapByRun, times, false);
// 2nd pad
c_chisquare_vs_run->cd(2);
adjustmargins(c_chisquare_vs_run->cd(2));
g_chi2_dxy_eta_vs_run[j]->SetMarkerStyle(pv::markers[j]);
g_chi2_dxy_eta_vs_run[j]->SetMarkerColor(pv::colors[j]);
g_chi2_dxy_eta_vs_run[j]->SetLineColor(pv::colors[j]);
g_chi2_dxy_eta_vs_run[j]->SetName(Form("g_chi2_dxy_eta_%s", LegLabels[j].Data()));
g_chi2_dxy_eta_vs_run[j]->SetTitle(Form("log_{10}(#chi2/ndf) of d_{xy}(#eta) fit vs %s", theType.Data()));
g_chi2_dxy_eta_vs_run[j]->GetXaxis()->SetTitle(theTypeLabel.Data());
g_chi2_dxy_eta_vs_run[j]->GetYaxis()->SetTitle("log_{10}(#chi^{2}/ndf) of d_{xy}(#eta) pol0 fit");
g_chi2_dxy_eta_vs_run[j]->GetYaxis()->SetRangeUser(-0.5, 4.5);
if (lumi_axis_format) {
g_chi2_dxy_eta_vs_run[j]->GetXaxis()->SetRangeUser(0., theBundle.getTotalLumi());
}
beautify(g_chi2_dxy_eta_vs_run[j]);
//g_chi2_dxy_eta_vs_run[j]->GetYaxis()->SetTitleOffset(1.3);
if (j == 0) {
g_chi2_dxy_eta_vs_run[j]->Draw("APL");
} else {
g_chi2_dxy_eta_vs_run[j]->Draw("PLsame");
}
if (time_axis_format) {
timify(g_chi2_dxy_eta_vs_run[j]);
}
if (j == nDirs_ - 1) {
my_lego->Draw("same");
}
current_pad = static_cast<TCanvas *>(gPad);
superImposeIOVBoundaries(current_pad, lumi_axis_format, time_axis_format, lumiMapByRun, times, false);
//3d pad
c_chisquare_vs_run->cd(3);
adjustmargins(c_chisquare_vs_run->cd(3));
g_chi2_dz_phi_vs_run[j]->SetMarkerStyle(pv::markers[j]);
g_chi2_dz_phi_vs_run[j]->SetMarkerColor(pv::colors[j]);
g_chi2_dz_phi_vs_run[j]->SetLineColor(pv::colors[j]);
g_chi2_dz_phi_vs_run[j]->SetName(Form("g_chi2_dz_phi_%s", LegLabels[j].Data()));
g_chi2_dz_phi_vs_run[j]->SetTitle(Form("log_{10}(#chi2/ndf) of d_{z}(#varphi) fit vs %s", theType.Data()));
g_chi2_dz_phi_vs_run[j]->GetXaxis()->SetTitle(theTypeLabel.Data());
g_chi2_dz_phi_vs_run[j]->GetYaxis()->SetTitle("log_{10}(#chi^{2}/ndf) of d_{z}(#phi) pol0 fit");
g_chi2_dz_phi_vs_run[j]->GetYaxis()->SetRangeUser(-0.5, 4.5);
if (lumi_axis_format) {
g_chi2_dz_phi_vs_run[j]->GetXaxis()->SetRangeUser(0., theBundle.getTotalLumi());
}
beautify(g_chi2_dz_phi_vs_run[j]);
//g_chi2_dz_phi_vs_run[j]->GetYaxis()->SetTitleOffset(1.3);
if (j == 0) {
g_chi2_dz_phi_vs_run[j]->Draw("APL");
} else {
g_chi2_dz_phi_vs_run[j]->Draw("PLsame");
}
if (time_axis_format) {
timify(g_chi2_dz_phi_vs_run[j]);
}
if (j == nDirs_ - 1) {
my_lego->Draw("same");
}
current_pad = static_cast<TCanvas *>(gPad);
superImposeIOVBoundaries(current_pad, lumi_axis_format, time_axis_format, lumiMapByRun, times, false);
//4th pad
c_chisquare_vs_run->cd(4);
adjustmargins(c_chisquare_vs_run->cd(4));
g_chi2_dz_eta_vs_run[j]->SetMarkerStyle(pv::markers[j]);
g_chi2_dz_eta_vs_run[j]->SetMarkerColor(pv::colors[j]);
g_chi2_dz_eta_vs_run[j]->SetLineColor(pv::colors[j]);
g_chi2_dz_eta_vs_run[j]->SetName(Form("g_chi2_dz_eta_%s", LegLabels[j].Data()));
g_chi2_dz_eta_vs_run[j]->SetTitle(Form("log_{10}(#chi2/ndf) of d_{z}(#eta) fit vs %s", theType.Data()));
g_chi2_dz_eta_vs_run[j]->GetXaxis()->SetTitle(theTypeLabel.Data());
g_chi2_dz_eta_vs_run[j]->GetYaxis()->SetTitle("log_{10}(#chi^{2}/ndf) of d_{z}(#eta) pol0 fit");
g_chi2_dz_eta_vs_run[j]->GetYaxis()->SetRangeUser(-0.5, 4.5);
if (lumi_axis_format) {
g_chi2_dz_eta_vs_run[j]->GetXaxis()->SetRangeUser(0., theBundle.getTotalLumi());
}
beautify(g_chi2_dz_eta_vs_run[j]);
//g_chi2_dz_eta_vs_run[j]->GetYaxis()->SetTitleOffset(1.3);
if (j == 0) {
g_chi2_dz_eta_vs_run[j]->Draw("APL");
} else {
g_chi2_dz_eta_vs_run[j]->Draw("PLsame");
}
if (time_axis_format) {
timify(g_chi2_dz_eta_vs_run[j]);
}
if (j == nDirs_ - 1) {
my_lego->Draw("same");
}
current_pad = static_cast<TCanvas *>(gPad);
superImposeIOVBoundaries(current_pad, lumi_axis_format, time_axis_format, lumiMapByRun, times, false);
// ****************************************
// Canvas for Kolmogorov-Smirnov test
// ****************************************
// 1st pad
c_KSScore_vs_run->cd(1);
adjustmargins(c_KSScore_vs_run->cd(1));
g_KS_dxy_phi_vs_run[j]->SetMarkerStyle(pv::markers[j]);
g_KS_dxy_phi_vs_run[j]->SetMarkerColor(pv::colors[j]);
g_KS_dxy_phi_vs_run[j]->SetLineColor(pv::colors[j]);
g_KS_dxy_phi_vs_run[j]->SetName(Form("g_KS_dxy_phi_%s", LegLabels[j].Data()));
g_KS_dxy_phi_vs_run[j]->SetTitle(Form("log_{10}(KS-score) of d_{xy}(#varphi) vs %s", theType.Data()));
g_KS_dxy_phi_vs_run[j]->GetXaxis()->SetTitle(theTypeLabel.Data());
g_KS_dxy_phi_vs_run[j]->GetYaxis()->SetTitle("log_{10}(KS-score) of d_{xy}(#phi) w.r.t 0");
g_KS_dxy_phi_vs_run[j]->GetYaxis()->SetRangeUser(-20., 1.);
beautify(g_KS_dxy_phi_vs_run[j]);
//g_KS_dxy_phi_vs_run[j]->GetYaxis()->SetTitleOffset(1.3);
if (j == 0) {
g_KS_dxy_phi_vs_run[j]->Draw("AP");
} else {
g_KS_dxy_phi_vs_run[j]->Draw("Psame");
}
if (time_axis_format) {
timify(g_KS_dxy_phi_vs_run[j]);
}
if (j == nDirs_ - 1) {
my_lego->Draw("same");
}
// 2nd pad
c_KSScore_vs_run->cd(2);
adjustmargins(c_KSScore_vs_run->cd(2));
g_KS_dxy_eta_vs_run[j]->SetMarkerStyle(pv::markers[j]);
g_KS_dxy_eta_vs_run[j]->SetMarkerColor(pv::colors[j]);
g_KS_dxy_eta_vs_run[j]->SetLineColor(pv::colors[j]);
g_KS_dxy_eta_vs_run[j]->SetName(Form("g_KS_dxy_eta_%s", LegLabels[j].Data()));
g_KS_dxy_eta_vs_run[j]->SetTitle(Form("log_{10}(KS-score) of d_{xy}(#eta) vs %s", theType.Data()));
g_KS_dxy_eta_vs_run[j]->GetXaxis()->SetTitle(theTypeLabel.Data());
g_KS_dxy_eta_vs_run[j]->GetYaxis()->SetTitle("log_{10}(KS-score) of d_{xy}(#eta) w.r.t 0");
g_KS_dxy_eta_vs_run[j]->GetYaxis()->SetRangeUser(-20., 1.);
beautify(g_KS_dxy_eta_vs_run[j]);
//g_KS_dxy_eta_vs_run[j]->GetYaxis()->SetTitleOffset(1.3);
if (j == 0) {
g_KS_dxy_eta_vs_run[j]->Draw("AP");
} else {
g_KS_dxy_eta_vs_run[j]->Draw("Psame");
}
if (time_axis_format) {
timify(g_KS_dxy_eta_vs_run[j]);
}
if (j == nDirs_ - 1) {
my_lego->Draw("same");
}
//3d pad
c_KSScore_vs_run->cd(3);
adjustmargins(c_KSScore_vs_run->cd(3));
g_KS_dz_phi_vs_run[j]->SetMarkerStyle(pv::markers[j]);
g_KS_dz_phi_vs_run[j]->SetMarkerColor(pv::colors[j]);
g_KS_dz_phi_vs_run[j]->SetLineColor(pv::colors[j]);
g_KS_dz_phi_vs_run[j]->SetName(Form("g_KS_dz_phi_%s", LegLabels[j].Data()));
g_KS_dz_phi_vs_run[j]->SetTitle(Form("log_{10}(KS-score) of d_{z}(#varphi) vs %s", theType.Data()));
g_KS_dz_phi_vs_run[j]->GetXaxis()->SetTitle(theTypeLabel.Data());
g_KS_dz_phi_vs_run[j]->GetYaxis()->SetTitle("log_{10}(KS-score) of d_{z}(#phi) w.r.t 0");
g_KS_dz_phi_vs_run[j]->GetYaxis()->SetRangeUser(-20., 1.);
beautify(g_KS_dz_phi_vs_run[j]);
//g_KS_dz_phi_vs_run[j]->GetYaxis()->SetTitleOffset(1.3);
if (j == 0) {
g_KS_dz_phi_vs_run[j]->Draw("AP");
} else {
g_KS_dz_phi_vs_run[j]->Draw("Psame");
}
if (time_axis_format) {
timify(g_KS_dz_phi_vs_run[j]);
}
if (j == nDirs_ - 1) {
my_lego->Draw("same");
}
//4th pad
c_KSScore_vs_run->cd(4);
adjustmargins(c_KSScore_vs_run->cd(4));
g_KS_dz_eta_vs_run[j]->SetMarkerStyle(pv::markers[j]);
g_KS_dz_eta_vs_run[j]->SetMarkerColor(pv::colors[j]);
g_KS_dz_eta_vs_run[j]->SetLineColor(pv::colors[j]);
g_KS_dz_eta_vs_run[j]->SetName(Form("g_KS_dz_eta_%s", LegLabels[j].Data()));
g_KS_dz_eta_vs_run[j]->SetTitle(Form("log_{10}(KS-score) of d_{z}(#eta) vs %s", theType.Data()));
g_KS_dz_eta_vs_run[j]->GetXaxis()->SetTitle(theTypeLabel.Data());
g_KS_dz_eta_vs_run[j]->GetYaxis()->SetTitle("log_{10}(KS-score) of d_{z}(#eta) w.r.t 0");
g_KS_dz_eta_vs_run[j]->GetYaxis()->SetRangeUser(-20., 1.);
beautify(g_KS_dz_eta_vs_run[j]);
//g_KS_dz_eta_vs_run[j]->GetYaxis()->SetTitleOffset(1.3);
if (j == 0) {
g_KS_dz_eta_vs_run[j]->Draw("AP");
} else {
g_KS_dz_eta_vs_run[j]->Draw("Psame");
}
if (time_axis_format) {
timify(g_KS_dz_eta_vs_run[j]);
}
if (j == nDirs_ - 1) {
my_lego->Draw("same");
}
}
// delete the array for the maxima
delete arr_dxy_phi;
delete arr_dz_phi;
delete arr_dxy_eta;
delete arr_dz_eta;
TString append;
if (lumi_axis_format) {
append = "lumi";
} else {
if (time_axis_format) {
append = "date";
} else {
append = "run";
}
}
c_dxy_phi_vs_run->SaveAs("dxy_phi_vs_" + append + ".pdf");
c_dxy_phi_vs_run->SaveAs("dxy_phi_vs_" + append + ".png");
c_dxy_phi_vs_run->SaveAs("dxy_phi_vs_" + append + ".eps");
c_dxy_eta_vs_run->SaveAs("dxy_eta_vs_" + append + ".pdf");
c_dxy_eta_vs_run->SaveAs("dxy_eta_vs_" + append + ".png");
c_dxy_eta_vs_run->SaveAs("dxy_eta_vs_" + append + ".eps");
c_dz_phi_vs_run->SaveAs("dz_phi_vs_" + append + ".pdf");
c_dz_phi_vs_run->SaveAs("dz_phi_vs_" + append + ".png");
c_dz_phi_vs_run->SaveAs("dz_phi_vs_" + append + ".eps");
c_dz_eta_vs_run->SaveAs("dz_eta_vs_" + append + ".pdf");
c_dz_eta_vs_run->SaveAs("dz_eta_vs_" + append + ".png");
c_dz_eta_vs_run->SaveAs("dz_eta_vs_" + append + ".eps");
TCanvas dummyC("dummyC", "dummyC", 2000, 800);
dummyC.Print("combined.pdf[");
c_dxy_phi_vs_run->Print("combined.pdf");
c_dxy_eta_vs_run->Print("combined.pdf");
c_dz_phi_vs_run->Print("combined.pdf");
c_dz_eta_vs_run->Print("combined.pdf");
dummyC.Print("combined.pdf]");
// mean
c_mean_dxy_phi_vs_run->SaveAs("mean_dxy_phi_vs_" + append + ".pdf");
c_mean_dxy_phi_vs_run->SaveAs("mean_dxy_phi_vs_" + append + ".png");
c_mean_dxy_eta_vs_run->SaveAs("mean_dxy_eta_vs_" + append + ".pdf");
c_mean_dxy_eta_vs_run->SaveAs("mean_dxy_eta_vs_" + append + ".png");
c_mean_dz_phi_vs_run->SaveAs("mean_dz_phi_vs_" + append + ".pdf");
c_mean_dz_phi_vs_run->SaveAs("mean_dz_phi_vs_" + append + ".png");
c_mean_dz_eta_vs_run->SaveAs("mean_dz_eta_vs_" + append + ".pdf");
c_mean_dz_eta_vs_run->SaveAs("mean_dz_eta_vs_" + append + ".png");
TCanvas dummyC2("dummyC2", "dummyC2", 2000, 800);
dummyC2.Print("means.pdf[");
c_mean_dxy_phi_vs_run->Print("means.pdf");
c_mean_dxy_eta_vs_run->Print("means.pdf");
c_mean_dz_phi_vs_run->Print("means.pdf");
c_mean_dz_eta_vs_run->Print("means.pdf");
dummyC2.Print("means.pdf]");
// RMS
c_RMS_dxy_phi_vs_run->SaveAs("RMS_dxy_phi_vs_" + append + ".pdf");
c_RMS_dxy_phi_vs_run->SaveAs("RMS_dxy_phi_vs_" + append + ".png");
c_RMS_dxy_eta_vs_run->SaveAs("RMS_dxy_eta_vs_" + append + ".pdf");
c_RMS_dxy_eta_vs_run->SaveAs("RMS_dxy_eta_vs_" + append + ".png");
c_RMS_dz_phi_vs_run->SaveAs("RMS_dz_phi_vs_" + append + ".pdf");
c_RMS_dz_phi_vs_run->SaveAs("RMS_dz_phi_vs_" + append + ".png");
c_RMS_dz_eta_vs_run->SaveAs("RMS_dz_eta_vs_" + append + ".pdf");
c_RMS_dz_eta_vs_run->SaveAs("RMS_dz_eta_vs_" + append + ".png");
TCanvas dummyC3("dummyC3", "dummyC3", 2000, 800);
dummyC3.Print("RMSs.pdf[");
c_RMS_dxy_phi_vs_run->Print("RMSs.pdf");
c_RMS_dxy_eta_vs_run->Print("RMSs.pdf");
c_RMS_dz_phi_vs_run->Print("RMSs.pdf");
c_RMS_dz_eta_vs_run->Print("RMSs.pdf");
dummyC3.Print("RMSs.pdf]");
// scatter
Scatter_dxy_vs_run->SaveAs("Scatter_dxy_vs_" + append + ".pdf");
Scatter_dxy_vs_run->SaveAs("Scatter_dxy_vs_" + append + ".png");
Scatter_dz_vs_run->SaveAs("Scatter_dz_vs_" + append + ".pdf");
Scatter_dz_vs_run->SaveAs("Scatter_dz_vs_" + append + ".png");
// chi2
c_chisquare_vs_run->SaveAs("chi2pol0fit_vs_" + append + ".pdf");
c_chisquare_vs_run->SaveAs("chi2pol0fit_vs_" + append + ".png");
// KS score
c_KSScore_vs_run->SaveAs("KSScore_vs_" + append + ".pdf");
c_KSScore_vs_run->SaveAs("KSScore_vs_" + append + ".png");
// do all the deletes
for (int iDir = 0; iDir < nDirs_; iDir++) {
delete g_dxy_phi_vs_run[iDir];
delete g_chi2_dxy_phi_vs_run[iDir];
delete g_KS_dxy_phi_vs_run[iDir];
delete g_dxy_phi_hi_vs_run[iDir];
delete g_dxy_phi_lo_vs_run[iDir];
delete g_dxy_eta_vs_run[iDir];
delete g_chi2_dxy_eta_vs_run[iDir];
delete g_KS_dxy_eta_vs_run[iDir];
delete g_dxy_eta_hi_vs_run[iDir];
delete g_dxy_eta_lo_vs_run[iDir];
delete g_dz_phi_vs_run[iDir];
delete g_chi2_dz_phi_vs_run[iDir];
delete g_KS_dz_phi_vs_run[iDir];
delete g_dz_phi_hi_vs_run[iDir];
delete g_dz_phi_lo_vs_run[iDir];
delete g_dz_eta_vs_run[iDir];
delete g_chi2_dz_eta_vs_run[iDir];
delete g_KS_dz_eta_vs_run[iDir];
delete g_dz_eta_hi_vs_run[iDir];
delete g_dz_eta_lo_vs_run[iDir];
delete h_RMS_dxy_phi_vs_run[iDir];
delete h_RMS_dxy_eta_vs_run[iDir];
delete h_RMS_dz_phi_vs_run[iDir];
delete h_RMS_dz_eta_vs_run[iDir];
}
// mv the run-by-run plots into the folders
gSystem->mkdir("Biases");
TString processline = ".! mv Bias*.p* ./Biases/";
logInfo << "Executing: \n" << processline << "\n" << std::endl;
gROOT->ProcessLine(processline.Data());
gSystem->Sleep(100);
processline.Clear();
gSystem->mkdir("ResolutionsVsPt");
processline = ".! mv ResolutionsVsPt*.p* ./ResolutionsVsPt/";
logInfo << "Executing: \n" << processline << "\n" << std::endl;
gROOT->ProcessLine(processline.Data());
gSystem->Sleep(100);
processline.Clear();
gSystem->mkdir("Resolutions");
processline = ".! mv Resolutions*.p* ./Resolutions/";
logInfo << "Executing: \n" << processline << "\n" << std::endl;
gROOT->ProcessLine(processline.Data());
gSystem->Sleep(100);
processline.Clear();
gSystem->mkdir("Pulls");
processline = ".! mv Pulls*.p* ./Pulls/";
logInfo << "Executing: \n" << processline << "\n" << std::endl;
gROOT->ProcessLine(processline.Data());
gSystem->Sleep(100);
processline.Clear();
timer.Stop();
timer.Print();
}
/*! \fn outputGraphs
* \brief function to build the output graphs
*/
/*--------------------------------------------------------------------*/
void outputGraphs(const pv::wrappedTrends &allInputs,
const std::vector<double> &ticks,
const std::vector<double> &ex_ticks,
TCanvas *&canv,
TCanvas *&mean_canv,
TCanvas *&rms_canv,
TGraph *&g_mean,
TGraph *&g_chi2,
TGraph *&g_KS,
TGraph *&g_low,
TGraph *&g_high,
TGraphAsymmErrors *&g_asym,
TH1F *h_RMS[],
const pv::bundle &mybundle,
const pv::view &theView,
const int index,
TObjArray *&array,
const TString &label,
TLegend *&legend)
/*--------------------------------------------------------------------*/
{
g_mean = new TGraph(ticks.size(), &(ticks[0]), &((allInputs.getMean()[label])[0]));
g_chi2 = new TGraph(ticks.size(), &(ticks[0]), &((allInputs.getChi2()[label])[0]));
g_KS = new TGraph(ticks.size(), &(ticks[0]), &((allInputs.getKS()[label])[0]));
g_high = new TGraph(ticks.size(), &(ticks[0]), &((allInputs.getHigh()[label])[0]));
g_low = new TGraph(ticks.size(), &(ticks[0]), &((allInputs.getLow()[label])[0]));
g_asym = new TGraphAsymmErrors(ticks.size(),
&(ticks[0]),
&((allInputs.getMean()[label])[0]),
&(ex_ticks[0]),
&(ex_ticks[0]),
&((allInputs.getLowErr()[label])[0]),
&((allInputs.getHighErr()[label])[0]));
adjustmargins(canv);
canv->cd();
g_asym->SetFillStyle(3005);
g_asym->SetFillColor(pv::colors[index]);
g_mean->SetMarkerStyle(pv::markers[index]);
g_mean->SetMarkerColor(pv::colors[index]);
g_mean->SetLineColor(pv::colors[index]);
g_mean->SetMarkerSize(1.);
g_high->SetLineColor(pv::colors[index]);
g_low->SetLineColor(pv::colors[index]);
beautify(g_mean);
beautify(g_asym);
if (theView == pv::dxyphi) {
legend->AddEntry(g_mean, label, "PL");
}
const char *coord;
const char *kin;
float ampl;
switch (theView) {
case pv::dxyphi:
coord = "xy";
kin = "phi";
ampl = 40;
break;
case pv::dzphi:
coord = "z";
kin = "phi";
ampl = 40;
break;
case pv::dxyeta:
coord = "xy";
kin = "eta";
ampl = 40;
break;
case pv::dzeta:
coord = "z";
kin = "eta";
ampl = 60;
break;
default:
coord = "unknown";
kin = "unknown";
break;
}
g_mean->SetName(Form("g_bias_d%s_%s_%s", coord, kin, label.Data()));
g_mean->SetTitle(Form("Bias of d_{%s}(#%s) vs %s", coord, kin, mybundle.getDataType()));
g_mean->GetXaxis()->SetTitle(mybundle.getDataTypeLabel());
g_mean->GetYaxis()->SetTitle(Form("#LT d_{%s}(#%s) #GT [#mum]", coord, kin));
g_mean->GetYaxis()->SetRangeUser(-ampl, ampl);
logInfo << "===================================================================================================="
<< std::endl;
logInfo << "Total Luminosity: " << mybundle.getTotalLumi() << std::endl;
logInfo << "===================================================================================================="
<< std::endl;
g_asym->SetName(Form("gerr_bias_d%s_%s_%s", coord, kin, label.Data()));
g_asym->SetTitle(Form("Bias of d_{%s}(#%s) vs %s", coord, kin, mybundle.getDataType()));
g_asym->GetXaxis()->SetTitle(mybundle.getDataTypeLabel());
g_asym->GetYaxis()->SetTitle(Form("#LT d_{%s}(#%s) #GT [#mum]", coord, kin));
g_asym->GetYaxis()->SetRangeUser(-ampl, ampl);
//g_mean->GetXaxis()->UnZoom();
//g_asym->GetXaxis()->UnZoom();
if (index == 0) {
g_asym->GetXaxis()->SetRangeUser(0., mybundle.getTotalLumi());
g_mean->Draw("AP");
g_asym->Draw("P3same");
} else {
g_mean->Draw("Psame");
g_asym->Draw("3same");
}
g_high->Draw("Lsame");
g_low->Draw("Lsame");
if (mybundle.isTimeAxis()) {
timify(g_asym);
timify(g_mean);
timify(g_high);
timify(g_low);
}
if (mybundle.isLumiAxis()) {
g_asym->GetXaxis()->SetRangeUser(0., mybundle.getTotalLumi());
g_mean->GetXaxis()->SetRangeUser(0., mybundle.getTotalLumi());
g_high->GetXaxis()->SetRangeUser(0., mybundle.getTotalLumi());
g_low->GetXaxis()->SetRangeUser(0., mybundle.getTotalLumi());
}
if (index == (mybundle.getNObjects() - 1)) {
legend->Draw("same");
TH1F *theZero = DrawConstantGraph(g_mean, 1, 0.);
theZero->Draw("E1same][");
}
auto current_pad = static_cast<TPad *>(gPad);
cmsPrel(current_pad);
superImposeIOVBoundaries(
canv, mybundle.isLumiAxis(), mybundle.isTimeAxis(), mybundle.getLumiMapByRun(), mybundle.getTimes());
// mean only
adjustmargins(mean_canv);
mean_canv->cd();
auto gprime = (TGraph *)g_mean->Clone();
if (index == 0) {
gprime->GetYaxis()->SetRangeUser(-10., 10.);
if (mybundle.isLumiAxis())
gprime->GetXaxis()->SetRangeUser(0., mybundle.getTotalLumi());
gprime->Draw("AP");
} else {
gprime->Draw("Psame");
}
if (index == (mybundle.getNObjects() - 1)) {
legend->Draw("same");
}
if (index == 0) {
TH1F *theZero = DrawConstantGraph(gprime, 2, 0.);
theZero->Draw("E1same][");
auto current_pad = static_cast<TPad *>(gPad);
cmsPrel(current_pad);
superImposeIOVBoundaries(
mean_canv, mybundle.isLumiAxis(), mybundle.isTimeAxis(), mybundle.getLumiMapByRun(), mybundle.getTimes());
}
// scatter or RMS TH1
h_RMS[index] = new TH1F(Form("h_RMS_dz_eta_%s", label.Data()),
Form("scatter of d_{%s}(#%s) vs %s;%s;%s of d_{%s}(#%s) [#mum]",
coord,
kin,
mybundle.getDataType(),
mybundle.getDataTypeLabel(),
(mybundle.isUsingRMS() ? "RMS" : "peak-to-peak deviation"),
coord,
kin),
ticks.size() - 1,
&(ticks[0]));
h_RMS[index]->SetStats(kFALSE);
int bincounter = 0;
for (const auto &tick : ticks) {
bincounter++;
h_RMS[index]->SetBinContent(
bincounter, std::abs(allInputs.getHigh()[label][bincounter - 1] - allInputs.getLow()[label][bincounter - 1]));
h_RMS[index]->SetBinError(bincounter, 0.01);
}
h_RMS[index]->SetLineColor(pv::colors[index]);
h_RMS[index]->SetLineWidth(2);
h_RMS[index]->SetMarkerSize(1.);
h_RMS[index]->SetMarkerStyle(pv::markers[index]);
h_RMS[index]->SetMarkerColor(pv::colors[index]);
adjustmargins(rms_canv);
rms_canv->cd();
beautify(h_RMS[index]);
if (mybundle.isTimeAxis()) {
timify(h_RMS[index]);
}
array->Add(h_RMS[index]);
// at the last file re-loop
if (index == (mybundle.getNObjects() - 1)) {
auto theMax = getMaximumFromArray(array);
logInfo << "the max for d" << coord << "(" << kin << ") RMS is " << theMax << std::endl;
for (Int_t k = 0; k < mybundle.getNObjects(); k++) {
//h_RMS[k]->GetYaxis()->SetRangeUser(-theMax*0.45,theMax*1.40);
h_RMS[k]->GetYaxis()->SetRangeUser(0., theMax * 1.80);
if (k == 0) {
h_RMS[k]->Draw("L");
} else {
h_RMS[k]->Draw("Lsame");
}
}
legend->Draw("same");
TH1F *theConst = DrawConstant(h_RMS[index], 1, 0.);
//theConst->Draw("same][");
current_pad = static_cast<TPad *>(gPad);
cmsPrel(current_pad);
superImposeIOVBoundaries(
rms_canv, mybundle.isLumiAxis(), mybundle.isTimeAxis(), mybundle.getLumiMapByRun(), mybundle.getTimes());
}
}
/*! \fn list_files
* \brief utility function to list of filles in a directory
*/
/*--------------------------------------------------------------------*/
std::vector<int> list_files(const char *dirname, const char *ext)
/*--------------------------------------------------------------------*/
{
std::vector<int> theRunNumbers;
TSystemDirectory dir(dirname, dirname);
TList *files = dir.GetListOfFiles();
if (files) {
TSystemFile *file;
TString fname;
TIter next(files);
while ((file = (TSystemFile *)next())) {
fname = file->GetName();
if (!file->IsDirectory() && fname.EndsWith(ext) && fname.BeginsWith("PVValidation")) {
//logInfo << fname.Data() << std::endl;
TObjArray *bits = fname.Tokenize("_");
TString theRun = bits->At(2)->GetName();
//logInfo << theRun << std::endl;
TString formatRun = (theRun.ReplaceAll(".root", "")).ReplaceAll("_", "");
//logInfo << dirname << " "<< formatRun.Atoi() << std::endl;
theRunNumbers.push_back(formatRun.Atoi());
}
}
}
return theRunNumbers;
}
/*! \fn arrangeOutCanvas
* \brief utility function to arrange the plots per run nicely in a TCanvas
*/
/*--------------------------------------------------------------------*/
void arrangeOutCanvas(TCanvas *canv,
TH1F *m_11Trend[100],
TH1F *m_12Trend[100],
TH1F *m_21Trend[100],
TH1F *m_22Trend[100],
Int_t nDirs,
TString LegLabels[10],
unsigned int theRun) {
/*--------------------------------------------------------------------*/
TLegend *lego = new TLegend(0.19, 0.80, 0.79, 0.93);
//lego-> SetNColumns(2);
lego->SetFillColor(10);
lego->SetTextSize(0.042);
lego->SetTextFont(42);
lego->SetFillColor(10);
lego->SetLineColor(10);
lego->SetShadowColor(10);
TPaveText *ptDate = new TPaveText(0.19, 0.95, 0.45, 0.99, "blNDC");
ptDate->SetFillColor(kYellow);
//ptDate->SetFillColor(10);
ptDate->SetBorderSize(1);
ptDate->SetLineColor(kBlue);
ptDate->SetLineWidth(1);
ptDate->SetTextFont(42);
TText *textDate = ptDate->AddText(Form("Run: %i", theRun));
textDate->SetTextSize(0.04);
textDate->SetTextColor(kBlue);
textDate->SetTextAlign(22);
canv->SetFillColor(10);
canv->Divide(2, 2);
TH1F *dBiasTrend[4][nDirs];
for (Int_t i = 0; i < nDirs; i++) {
dBiasTrend[0][i] = m_11Trend[i];
dBiasTrend[1][i] = m_12Trend[i];
dBiasTrend[2][i] = m_21Trend[i];
dBiasTrend[3][i] = m_22Trend[i];
}
Double_t absmin[4] = {999., 999., 999., 999.};
Double_t absmax[4] = {-999., -999. - 999., -999.};
for (Int_t k = 0; k < 4; k++) {
canv->cd(k + 1)->SetBottomMargin(0.14);
canv->cd(k + 1)->SetLeftMargin(0.18);
canv->cd(k + 1)->SetRightMargin(0.01);
canv->cd(k + 1)->SetTopMargin(0.06);
canv->cd(k + 1);
for (Int_t i = 0; i < nDirs; i++) {
if (dBiasTrend[k][i]->GetMaximum() > absmax[k])
absmax[k] = dBiasTrend[k][i]->GetMaximum();
if (dBiasTrend[k][i]->GetMinimum() < absmin[k])
absmin[k] = dBiasTrend[k][i]->GetMinimum();
}
Double_t safeDelta = (absmax[k] - absmin[k]) / 8.;
Double_t theExtreme = std::max(absmax[k], TMath::Abs(absmin[k]));
for (Int_t i = 0; i < nDirs; i++) {
if (i == 0) {
TString theTitle = dBiasTrend[k][i]->GetName();
if (theTitle.Contains("norm")) {
//dBiasTrend[k][i]->GetYaxis()->SetRangeUser(std::min(-0.48,absmin[k]-safeDelta/2.),std::max(0.48,absmax[k]+safeDelta/2.));
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0., 1.8);
} else {
if (!theTitle.Contains("width")) {
if (theTitle.Contains("ladder") || theTitle.Contains("modZ")) {
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(std::min(-40., -theExtreme - (safeDelta / 2.)),
std::max(40., theExtreme + (safeDelta / 2.)));
} else {
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(-40., 40.);
}
} else {
// dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0.,theExtreme+(safeDelta/2.));
// if(theTitle.Contains("eta")) {
// dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0.,500.);
// } else {
// dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0.,200.);
// }
auto my_view = checkTheView(theTitle);
//logInfo<<" ----------------------------------> " << theTitle << " view: " << my_view << std::endl;
switch (my_view) {
case pv::dxyphi:
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0., 200.);
break;
case pv::dzphi:
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0., 400.);
break;
case pv::dxyeta:
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0., 300.);
break;
case pv::dzeta:
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0., 1.e3);
break;
case pv::pT:
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0., 200.);
break;
case pv::generic:
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0., 350.);
break;
default:
dBiasTrend[k][i]->GetYaxis()->SetRangeUser(0., 300.);
}
}
}
dBiasTrend[k][i]->Draw("Le1");
makeNewXAxis(dBiasTrend[k][i]);
Double_t theC = -1.;
if (theTitle.Contains("width")) {
if (theTitle.Contains("norm")) {
theC = 1.;
} else {
theC = -1.;
}
} else {
theC = 0.;
}
TH1F *theConst = DrawConstant(dBiasTrend[k][i], 1, theC);
theConst->Draw("PLsame][");
} else {
dBiasTrend[k][i]->Draw("Le1sames");
makeNewXAxis(dBiasTrend[k][i]);
}
TPad *current_pad = static_cast<TPad *>(canv->GetPad(k + 1));
cmsPrel(current_pad, 2);
ptDate->Draw("same");
if (k == 0) {
lego->AddEntry(dBiasTrend[k][i], LegLabels[i]);
}
}
lego->Draw();
}
}
/*! \fn MakeNiceTrendPlotStype
* \brief utility function to embellish trend plot style
*/
/*--------------------------------------------------------------------*/
void MakeNiceTrendPlotStyle(TH1 *hist, Int_t color)
/*--------------------------------------------------------------------*/
{
hist->SetStats(kFALSE);
hist->SetLineWidth(2);
hist->GetXaxis()->CenterTitle(true);
hist->GetYaxis()->CenterTitle(true);
hist->GetXaxis()->SetTitleFont(42);
hist->GetYaxis()->SetTitleFont(42);
hist->GetXaxis()->SetTitleSize(0.065);
hist->GetYaxis()->SetTitleSize(0.065);
hist->GetXaxis()->SetTitleOffset(1.0);
hist->GetYaxis()->SetTitleOffset(1.2);
hist->GetXaxis()->SetLabelFont(42);
hist->GetYaxis()->SetLabelFont(42);
hist->GetYaxis()->SetLabelSize(.05);
hist->GetXaxis()->SetLabelSize(.07);
//hist->GetXaxis()->SetNdivisions(505);
if (color != 8) {
hist->SetMarkerSize(1.5);
} else {
hist->SetLineWidth(3);
hist->SetMarkerSize(0.0);
}
hist->SetMarkerStyle(pv::markers[color]);
hist->SetLineColor(pv::colors[color]);
hist->SetMarkerColor(pv::colors[color]);
}
/*! \fn maxkeNewAxis
* \brief utility function to re-make x-axis with correct binning
*/
/*--------------------------------------------------------------------*/
void makeNewXAxis(TH1 *h)
/*--------------------------------------------------------------------*/
{
TString myTitle = h->GetName();
float axmin = -999;
float axmax = 999.;
int ndiv = 510;
if (myTitle.Contains("eta")) {
axmin = -2.7;
axmax = 2.7;
ndiv = 505;
} else if (myTitle.Contains("phi")) {
axmin = -TMath::Pi();
axmax = TMath::Pi();
ndiv = 510;
} else if (myTitle.Contains("pT")) {
axmin = 0;
axmax = 19.99;
ndiv = 510;
} else if (myTitle.Contains("ladder")) {
axmin = 0;
axmax = 12;
ndiv = 510;
} else if (myTitle.Contains("modZ")) {
axmin = 0;
axmax = 8;
ndiv = 510;
} else {
logError << "unrecognized variable" << std::endl;
}
// Remove the current axis
h->GetXaxis()->SetLabelOffset(999);
h->GetXaxis()->SetTickLength(0);
if (myTitle.Contains("phi")) {
h->GetXaxis()->SetTitle("#varphi (sector) [rad]");
}
// Redraw the new axis
gPad->Update();
TGaxis *newaxis =
new TGaxis(gPad->GetUxmin(), gPad->GetUymin(), gPad->GetUxmax(), gPad->GetUymin(), axmin, axmax, ndiv, "SDH");
TGaxis *newaxisup =
new TGaxis(gPad->GetUxmin(), gPad->GetUymax(), gPad->GetUxmax(), gPad->GetUymax(), axmin, axmax, ndiv, "-SDH");
newaxis->SetLabelOffset(0.02);
newaxis->SetLabelFont(42);
newaxis->SetLabelSize(0.05);
newaxisup->SetLabelOffset(-0.02);
newaxisup->SetLabelFont(42);
newaxisup->SetLabelSize(0);
newaxis->Draw();
newaxisup->Draw();
}
/*! \fn setStyle
* \brief main function to set the plotting style
*/
/*--------------------------------------------------------------------*/
void setStyle() {
/*--------------------------------------------------------------------*/
TGaxis::SetMaxDigits(6);
TH1::StatOverflows(kTRUE);
gStyle->SetOptTitle(0);
gStyle->SetOptStat("e");
//gStyle->SetPadTopMargin(0.05);
//gStyle->SetPadBottomMargin(0.15);
//gStyle->SetPadLeftMargin(0.17);
//gStyle->SetPadRightMargin(0.02);
gStyle->SetPadBorderMode(0);
gStyle->SetTitleFillColor(10);
gStyle->SetTitleFont(42);
gStyle->SetTitleColor(1);
gStyle->SetTitleTextColor(1);
gStyle->SetTitleFontSize(0.06);
gStyle->SetTitleBorderSize(0);
gStyle->SetStatColor(kWhite);
gStyle->SetStatFont(42);
gStyle->SetStatFontSize(0.05); ///---> gStyle->SetStatFontSize(0.025);
gStyle->SetStatTextColor(1);
gStyle->SetStatFormat("6.4g");
gStyle->SetStatBorderSize(1);
gStyle->SetPadTickX(1); // To get tick marks on the opposite side of the frame
gStyle->SetPadTickY(1);
gStyle->SetPadBorderMode(0);
gStyle->SetOptFit(1);
gStyle->SetNdivisions(510);
//gStyle->SetPalette(kInvertedDarkBodyRadiator);
const Int_t NRGBs = 5;
const Int_t NCont = 255;
/*
Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
*/
Double_t stops[NRGBs] = {0.00, 0.01, 0.05, 0.09, 0.1};
Double_t red[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
Double_t green[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
Double_t blue[NRGBs] = {1.00, 0.84, 0.61, 0.34, 0.00};
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
gStyle->SetNumberContours(NCont);
}
// /*--------------------------------------------------------------------*/
// void cmsPrel(TPad* pad) {
// /*--------------------------------------------------------------------*/
// float H = pad->GetWh();
// float W = pad->GetWw();
// float l = pad->GetLeftMargin();
// float t = pad->GetTopMargin();
// float r = pad->GetRightMargin();
// float b = pad->GetBottomMargin();
// float relPosX = 0.009;
// float relPosY = 0.045;
// float lumiTextOffset = 0.8;
// TLatex *latex = new TLatex();
// latex->SetNDC();
// latex->SetTextSize(0.045);
// float posX_ = 1-r - relPosX*(1-l-r);
// float posXCMS_ = posX_- 0.125;
// float posY_ = 1-t + 0.05; /// - relPosY*(1-t-b);
// float factor = 1./0.86;
// latex->SetTextAlign(33);
// latex->SetTextFont(61);
// latex->SetTextSize(0.045*factor);
// latex->DrawLatex(posXCMS_,posY_,"CMS");
// latex->SetTextSize(0.045);
// latex->SetTextFont(42); //22
// latex->DrawLatex(posX_,posY_,"Internal (13 TeV)");
// //latex->DrawLatex(posX_,posY_,"CMS Preliminary (13 TeV)");
// //latex->DrawLatex(posX_,posY_,"CMS 2017 Work in progress (13 TeV)");
// }
/*! \fn cmsPrel
* \brief utility function to put the CMS paraphernalia on canvas
*/
/*--------------------------------------------------------------------*/
void cmsPrel(TPad *pad, size_t ipads) {
/*--------------------------------------------------------------------*/
float H = pad->GetWh();
float W = pad->GetWw();
float l = pad->GetLeftMargin();
float t = pad->GetTopMargin();
float r = pad->GetRightMargin();
float b = pad->GetBottomMargin();
float relPosX = 0.009;
float relPosY = 0.045;
float lumiTextOffset = 0.8;
TLatex *latex = new TLatex();
latex->SetNDC();
latex->SetTextSize(0.045);
float posX_ = 1 - (r / ipads);
float posY_ = 1 - t + 0.05; /// - relPosY*(1-t-b);
float factor = 1. / 0.82;
latex->SetTextAlign(33);
latex->SetTextSize(0.045);
latex->SetTextFont(42); //22
latex->DrawLatex(posX_, posY_, "Internal (13 TeV)");
UInt_t w;
UInt_t h;
latex->GetTextExtent(w, h, "Internal (13 TeV)");
float size = w / (W / ipads);
//logInfo<<w<<" "<<" "<<W<<" "<<size<<std::endl;
float posXCMS_ = posX_ - size * (1 + 0.025 * ipads);
latex->SetTextAlign(33);
latex->SetTextFont(61);
latex->SetTextSize(0.045 * factor);
latex->DrawLatex(posXCMS_, posY_ + 0.004, "CMS");
//latex->DrawLatex(posX_,posY_,"CMS Preliminary (13 TeV)");
//latex->DrawLatex(posX_,posY_,"CMS 2017 Work in progress (13 TeV)");
}
/*! \fn DrawConstant
* \brief utility function to draw a constant histogram
*/
/*--------------------------------------------------------------------*/
TH1F *DrawConstant(TH1F *hist, Int_t iter, Double_t theConst)
/*--------------------------------------------------------------------*/
{
Int_t nbins = hist->GetNbinsX();
Double_t lowedge = hist->GetBinLowEdge(1);
Double_t highedge = hist->GetBinLowEdge(nbins + 1);
TH1F *hzero = new TH1F(Form("hconst_%s_%i", hist->GetName(), iter),
Form("hconst_%s_%i", hist->GetName(), iter),
nbins,
lowedge,
highedge);
for (Int_t i = 0; i <= hzero->GetNbinsX(); i++) {
hzero->SetBinContent(i, theConst);
hzero->SetBinError(i, 0.);
}
hzero->SetLineWidth(2);
hzero->SetLineStyle(9);
hzero->SetLineColor(kMagenta);
return hzero;
}
/*! \fn DrawConstant
* \brief utility function to draw a constant histogram with erros !=0
*/
/*--------------------------------------------------------------------*/
TH1F *DrawConstantWithErr(TH1F *hist, Int_t iter, Double_t theConst)
/*--------------------------------------------------------------------*/
{
Int_t nbins = hist->GetNbinsX();
Double_t lowedge = hist->GetBinLowEdge(1);
Double_t highedge = hist->GetBinLowEdge(nbins + 1);
TH1F *hzero = new TH1F(Form("hconst_%s_%i", hist->GetName(), iter),
Form("hconst_%s_%i", hist->GetName(), iter),
nbins,
lowedge,
highedge);
for (Int_t i = 0; i <= hzero->GetNbinsX(); i++) {
hzero->SetBinContent(i, theConst);
hzero->SetBinError(i, hist->GetBinError(i));
}
hzero->SetLineWidth(2);
hzero->SetLineStyle(9);
hzero->SetLineColor(kMagenta);
return hzero;
}
/*! \fn DrawConstantGraph
* \brief utility function to draw a constant TGraph
*/
/*--------------------------------------------------------------------*/
TH1F *DrawConstantGraph(TGraph *graph, Int_t iter, Double_t theConst)
/*--------------------------------------------------------------------*/
{
Double_t xmin = graph->GetXaxis()->GetXmin(); //TMath::MinElement(graph->GetN(),graph->GetX());
Double_t xmax = graph->GetXaxis()->GetXmax(); //TMath::MaxElement(graph->GetN(),graph->GetX());
//logInfo<<xmin<<" : "<<xmax<<std::endl;
TH1F *hzero = new TH1F(Form("hconst_%s_%i", graph->GetName(), iter),
Form("hconst_%s_%i", graph->GetName(), iter),
graph->GetN(),
xmin,
xmax);
for (Int_t i = 0; i <= hzero->GetNbinsX(); i++) {
hzero->SetBinContent(i, theConst);
hzero->SetBinError(i, 0.);
}
hzero->SetLineWidth(2);
hzero->SetLineStyle(9);
hzero->SetLineColor(kMagenta);
return hzero;
}
/*! \fn getUnrolledHisto
* \brief utility function to tranform a TH1 into a vector of floats
*/
/*--------------------------------------------------------------------*/
unrolledHisto getUnrolledHisto(TH1F *hist)
/*--------------------------------------------------------------------*/
{
/*
Double_t y_min = hist->GetBinLowEdge(1);
Double_t y_max = hist->GetBinLowEdge(hist->GetNbinsX()+1);
*/
Double_t y_min = -0.1;
Double_t y_max = 0.1;
std::vector<Double_t> contents;
for (int j = 0; j < hist->GetNbinsX(); j++) {
if (std::abs(hist->GetXaxis()->GetBinCenter(j)) <= 0.1)
contents.push_back(hist->GetBinContent(j + 1));
}
auto ret = unrolledHisto(y_min, y_max, contents.size(), contents);
return ret;
}
/*! \fn getBiases
* \brief utility function to extract characterization of the PV bias plot
*/
/*--------------------------------------------------------------------*/
pv::biases getBiases(TH1F *hist)
/*--------------------------------------------------------------------*/
{
int nbins = hist->GetNbinsX();
//extract median from histogram
double *y = new double[nbins];
double *err = new double[nbins];
// remember for weight means <x> = sum_i (x_i* w_i) / sum_i w_i ; where w_i = 1/sigma^2_i
for (int j = 0; j < nbins; j++) {
y[j] = hist->GetBinContent(j + 1);
if (hist->GetBinError(j + 1) != 0.) {
err[j] = 1. / (hist->GetBinError(j + 1) * hist->GetBinError(j + 1));
} else {
err[j] = 0.;
}
}
Double_t w_mean = TMath::Mean(nbins, y, err);
Double_t w_rms = TMath::RMS(nbins, y, err);
Double_t mean = TMath::Mean(nbins, y);
Double_t rms = TMath::RMS(nbins, y);
Double_t max = hist->GetMaximum();
Double_t min = hist->GetMinimum();
// in case one would like to use a pol0 fit
hist->Fit("pol0", "Q0+");
TF1 *f = (TF1 *)hist->FindObject("pol0");
//f->SetLineColor(hist->GetLineColor());
//f->SetLineStyle(hist->GetLineStyle());
Double_t chi2 = f->GetChisquare();
Int_t ndf = f->GetNDF();
TH1F *theZero = DrawConstantWithErr(hist, 1, 1.);
TH1F *displaced = (TH1F *)hist->Clone("displaced");
displaced->Add(theZero);
Double_t ksScore = std::max(-20., TMath::Log10(displaced->KolmogorovTest(theZero)));
Double_t chi2Score = displaced->Chi2Test(theZero);
/*
std::pair<std::pair<Double_t,Double_t>, Double_t> result;
std::pair<Double_t,Double_t> resultBounds;
resultBounds = useRMS_ ? std::make_pair(mean-rms,mean+rms) : std::make_pair(min,max) ;
result = make_pair(resultBounds,mean);
*/
pv::biases result(mean, rms, w_mean, w_rms, min, max, chi2, ndf, ksScore);
delete theZero;
delete displaced;
return result;
}
/*! \fn beautify
* \brief utility function to beautify a TGraph
*/
/*--------------------------------------------------------------------*/
void beautify(TGraph *g) {
/*--------------------------------------------------------------------*/
g->GetXaxis()->SetLabelFont(42);
g->GetYaxis()->SetLabelFont(42);
g->GetYaxis()->SetLabelSize(.055);
g->GetXaxis()->SetLabelSize(.055);
g->GetYaxis()->SetTitleSize(.055);
g->GetXaxis()->SetTitleSize(.055);
g->GetXaxis()->SetTitleOffset(1.1);
g->GetYaxis()->SetTitleOffset(0.6);
g->GetXaxis()->SetTitleFont(42);
g->GetYaxis()->SetTitleFont(42);
g->GetXaxis()->CenterTitle(true);
g->GetYaxis()->CenterTitle(true);
g->GetXaxis()->SetNdivisions(505);
}
/*! \fn beautify
* \brief utility function to beautify a TH1
*/
/*--------------------------------------------------------------------*/
void beautify(TH1 *h) {
/*--------------------------------------------------------------------*/
h->SetMinimum(0.);
h->GetXaxis()->SetLabelFont(42);
h->GetYaxis()->SetLabelFont(42);
h->GetYaxis()->SetLabelSize(.055);
h->GetXaxis()->SetLabelSize(.055);
h->GetYaxis()->SetTitleSize(.055);
h->GetXaxis()->SetTitleSize(.055);
h->GetXaxis()->SetTitleOffset(1.1);
h->GetYaxis()->SetTitleOffset(0.6);
h->GetXaxis()->SetTitleFont(42);
h->GetYaxis()->SetTitleFont(42);
h->GetXaxis()->CenterTitle(true);
h->GetYaxis()->CenterTitle(true);
h->GetXaxis()->SetNdivisions(505);
}
/*! \fn adjustmargins
* \brief utility function to adjust margins of a TCanvas
*/
/*--------------------------------------------------------------------*/
void adjustmargins(TCanvas *canv) {
/*--------------------------------------------------------------------*/
canv->cd()->SetBottomMargin(0.14);
canv->cd()->SetLeftMargin(0.07);
canv->cd()->SetRightMargin(0.03);
canv->cd()->SetTopMargin(0.06);
}
/*! \fn adjustmargins
* \brief utility function to adjust margins of a TVirtualPad
*/
/*--------------------------------------------------------------------*/
void adjustmargins(TVirtualPad *canv) {
/*--------------------------------------------------------------------*/
canv->SetBottomMargin(0.12);
canv->SetLeftMargin(0.07);
canv->SetRightMargin(0.01);
canv->SetTopMargin(0.02);
}
/*! \fn checkTH1AndReturn
* \brief utility function to check if a TH1 exists in a TFile before returning it
*/
/*--------------------------------------------------------------------*/
TH1F *checkTH1AndReturn(TFile *f, TString address) {
/*--------------------------------------------------------------------*/
TH1F *h = NULL;
if (f->GetListOfKeys()->Contains(address)) {
h = (TH1F *)f->Get(address);
}
return h;
}
/*! \fn checkThView
* \brief utility function to return the pv::view corresponding to a given PV bias plot
*/
/*--------------------------------------------------------------------*/
pv::view checkTheView(const TString &toCheck) {
/*--------------------------------------------------------------------*/
if (toCheck.Contains("dxy")) {
if (toCheck.Contains("phi") || toCheck.Contains("ladder")) {
return pv::dxyphi;
} else if (toCheck.Contains("eta") || toCheck.Contains("modZ")) {
return pv::dxyeta;
} else {
return pv::pT;
}
} else if (toCheck.Contains("dz")) {
if (toCheck.Contains("phi") || toCheck.Contains("ladder")) {
return pv::dzphi;
} else if (toCheck.Contains("eta") || toCheck.Contains("modZ")) {
return pv::dzeta;
} else {
return pv::pT;
}
} else {
return pv::generic;
}
}
/*! \fn timify
* \brief utility function to make a histogram x-axis of the time type
*/
/*--------------------------------------------------------------------*/
template <typename T>
void timify(T *mgr)
/*--------------------------------------------------------------------*/
{
mgr->GetXaxis()->SetTimeDisplay(1);
mgr->GetXaxis()->SetNdivisions(510);
mgr->GetXaxis()->SetTimeFormat("%Y-%m-%d");
mgr->GetXaxis()->SetTimeOffset(0, "gmt");
mgr->GetXaxis()->SetLabelSize(.035);
}
struct increase {
template <class T>
bool operator()(T const &a, T const &b) const {
return a > b;
}
};
/*! \fn getMaximumFromArray
* \brief utility function to extract the maximum out of an array of histograms
*/
/*--------------------------------------------------------------------*/
Double_t getMaximumFromArray(TObjArray *array)
/*--------------------------------------------------------------------*/
{
Double_t theMaximum = -999.; //(static_cast<TH1*>(array->At(0)))->GetMaximum();
for (Int_t i = 0; i < array->GetSize(); i++) {
double theMaxForThisHist;
auto hist = static_cast<TH1 *>(array->At(i));
std::vector<double> maxima;
for (int j = 0; j < hist->GetNbinsX(); j++)
maxima.push_back(hist->GetBinContent(j));
std::sort(std::begin(maxima), std::end(maxima)); //,increase());
double rms_maxima = TMath::RMS(hist->GetNbinsX(), &(maxima[0]));
double mean_maxima = TMath::Mean(hist->GetNbinsX(), &(maxima[0]));
const Int_t nq = 100;
Double_t xq[nq]; // position where to compute the quantiles in [0,1]
Double_t yq[nq]; // array to contain the quantiles
for (Int_t i = 0; i < nq; i++)
xq[i] = 0.9 + (Float_t(i + 1) / nq) * 0.10;
TMath::Quantiles(maxima.size(), nq, &(maxima[0]), yq, xq);
//for(int q=0;q<nq;q++){
// logInfo<<q<<" "<<xq[q]<<" "<<yq[q]<<std::endl;
//}
//for (const auto &element : maxima){
// if(element<1.5*mean_maxima){
// theMaxForThisHist=element;
// break;
// }
//}
theMaxForThisHist = yq[80];
logInfo << "rms_maxima[" << i << "]: " << rms_maxima << " mean maxima[" << mean_maxima
<< "] purged maximum:" << theMaxForThisHist << std::endl;
if (theMaxForThisHist > theMaximum)
theMaximum = theMaxForThisHist;
/*
if( (static_cast<TH1*>(array->At(i)))->GetMaximum() > theMaximum){
theMaximum = (static_cast<TH1*>(array->At(i)))->GetMaximum();
//logInfo<<"i= "<<i<<" theMaximum="<<theMaximum<<endl;
}
*/
}
return theMaximum;
}
/*! \fn superImposeIOVBoundaries
* \brief utility function to superimpose the IOV boundaries on the trend plot
*/
/*--------------------------------------------------------------------*/
void superImposeIOVBoundaries(TCanvas *c,
bool lumi_axis_format,
bool time_axis_format,
const std::map<int, double> &lumiMapByRun,
const std::map<int, TDatime> &timeMap,
bool drawText)
/*--------------------------------------------------------------------*/
{
// get the vector of runs in the lumiMap
std::vector<int> vruns;
for (auto const &imap : lumiMapByRun) {
vruns.push_back(imap.first);
//logInfo<<" run:" << imap.first << " lumi: "<< imap.second << std::endl;
}
//std::vector<vint> truns;
for (auto const &imap : timeMap) {
logInfo << " run:" << imap.first << " time: " << imap.second.Convert() << std::endl;
}
/* Run-2 Ultra-Legacy ReReco IOVs (from tag SiPixelTemplateDBObject_38T_v16_offline)
1 271866 2016-04-28 2cc9ecb98e8ba900b26701d6adf052ba59c1f5e1 SiPixelTemplateDBObject 2016
2 276315 2016-07-04 28a6077528012fe0abb03df9ef52e5976137c324 SiPixelTemplateDBObject
3 278271 2016-08-05 43744865be66299a3a37599961a9faf5a0d2bd78 SiPixelTemplateDBObject
4 280928 2016-09-16 7533fd5b60c10a9c55cddc6d2677d3fae6e8bb14 SiPixelTemplateDBObject
5 290543 2017-03-30 05803622f45cf4ee2c07af2bb97875bd1010bfea SiPixelTemplateDBObject 2017
6 297281 2017-06-22 0ed971165dda7ae1db50c6636dab049087cad9a1 SiPixelTemplateDBObject
7 298653 2017-07-09 e3af935c8f4eded04455a88959501d7408895501 SiPixelTemplateDBObject
8 299443 2017-07-19 e2203ad6babf1885d754ae1392e4841a9b20c02e SiPixelTemplateDBObject
9 300389 2017-08-03 d512d75856a89b7602c143046f9e030e112c81e5 SiPixelTemplateDBObject
10 301046 2017-08-12 c624d964356bf70df4a33761c32f8976a0d89257 SiPixelTemplateDBObject
11 302131 2017-08-31 ca6f56bb82434b69bd951d5ca89cdce841473ce0 SiPixelTemplateDBObject
12 303790 2017-09-23 cbb7b82c563a21f06bf7e57bec3a490625c98d18 SiPixelTemplateDBObject
13 303998 2017-09-27 7aec56e15aed26f7b686535ecaff59911947f802 SiPixelTemplateDBObject
14 304911 2017-10-13 d5bc4c312735d2d97e617ae3d45c735639a1cd82 SiPixelTemplateDBObject
15 313041 2018-03-28 f3752b4a1fac4aa65c6439ab75d216dcc3ed27a9 SiPixelTemplateDBObject 2018
16 314881 2018-04-22 bc8784a015d78068c51c9a581328b064299a31b4 SiPixelTemplateDBObject
17 316758 2018-05-22 3a8abe693d1d3df829212e1049330e68f3392282 SiPixelTemplateDBObject
18 317475 2018-06-05 83e09d34c122040bca0f5daf4b89a0435663c230 SiPixelTemplateDBObject
19 317485 2018-06-05 3a8abe693d1d3df829212e1049330e68f3392282 SiPixelTemplateDBObject
20 317527 2018-06-06 356b03fcd7e869ef8f28153318f0cd32c27b1f40 SiPixelTemplateDBObject
21 317661 2018-06-10 1cbb2fc3edf448c50d00fac3aa47c8cf3b19ac6f SiPixelTemplateDBObject
22 317664 2018-06-11 356b03fcd7e869ef8f28153318f0cd32c27b1f40 SiPixelTemplateDBObject
23 318227 2018-06-21 1cbb2fc3edf448c50d00fac3aa47c8cf3b19ac6f SiPixelTemplateDBObject
24 320377 2018-07-26 5e9cd265167ec543aac49685cf706a58014c08f8 SiPixelTemplateDBObject
25 321831 2018-08-27 e47d453934b47f06e53a323bd9ae16b38ec1bbd1 SiPixelTemplateDBObject
26 322510 2018-09-09 df783de5f30a99bc036d8973e48da78513206aba SiPixelTemplateDBObject
27 322603 2018-09-09 e47d453934b47f06e53a323bd9ae16b38ec1bbd1 SiPixelTemplateDBObject
28 323232 2018-09-21 9e660fd65e392f01f69cde77a52f59e934d7737d SiPixelTemplateDBObject
29 324245 2018-10-08 6caa50b30aa80ede330585888cdc5e804853d1da SiPixelTemplateDBObject
*/
static const int nIOVs =
29; // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int IOVboundaries[nIOVs] = {
271866,
276315,
278271,
280928,
290543,
297281,
298653,
299443,
300389,
301046,
302131,
303790,
303998,
304911,
313041,
// 16 17 18 19 20 21 22 23 24 25 26 27 28 29
314881,
316758,
317475,
317485,
317527,
317661,
317664,
318227,
320377,
321831,
322510,
322603,
323232,
324245};
int benchmarkruns[nIOVs] = {271866, 276315, 278271, 280928, 290543, 297281, 298653, 299443, 300389, 301046,
302131, 303790, 303998, 304911, 313041, 314881, 316758, 317475, 317485, 317527,
317661, 317664, 318227, 320377, 321831, 322510, 322603, 323232, 324245};
std::string dates[nIOVs] = {"2016-04-28", "2016-07-04", "2016-08-05", "2016-09-16", "2017-03-30", "2017-06-22",
"2017-07-09", "2017-07-19", "2017-08-03", "2017-08-12", "2017-08-31", "2017-09-23",
"2017-09-27", "2017-10-13", "2018-03-28", "2018-04-22", "2018-05-22", "2018-06-05",
"2018-06-05", "2018-06-06", "2018-06-10", "2018-06-11", "2018-06-21", "2018-07-26",
"2018-08-27", "2018-09-09", "2018-09-09", "2018-09-21", "2018-10-08"};
TArrow *IOV_lines[nIOVs];
c->cd();
c->Update();
TArrow *a_lines[nIOVs];
TArrow *b_lines[nIOVs];
for (Int_t IOV = 0; IOV < nIOVs; IOV++) {
// check we are not in the RMS histogram to avoid first line
if (IOVboundaries[IOV] < vruns.front())
continue;
//&& ((TString)c->GetName()).Contains("RMS")) continue;
int closestrun = pv::closest(vruns, IOVboundaries[IOV]);
int closestbenchmark = pv::closest(vruns, benchmarkruns[IOV]);
if (lumi_axis_format) {
if (closestrun < 0)
continue;
//logInfo<< "natural boundary: " << IOVboundaries[IOV] << " closest:" << closestrun << std::endl;
a_lines[IOV] = new TArrow(
lumiMapByRun.at(closestrun), (c->GetUymin()), lumiMapByRun.at(closestrun), c->GetUymax(), 0.5, "|>");
if (closestbenchmark < 0)
continue;
b_lines[IOV] = new TArrow(lumiMapByRun.at(closestbenchmark),
(c->GetUymin()),
lumiMapByRun.at(closestbenchmark),
c->GetUymax(),
0.5,
"|>");
} else if (time_axis_format) {
if (closestrun < 0)
continue;
logInfo << "natural boundary: " << IOVboundaries[IOV] << " closest:" << closestrun << std::endl;
a_lines[IOV] = new TArrow(
timeMap.at(closestrun).Convert(), (c->GetUymin()), timeMap.at(closestrun).Convert(), c->GetUymax(), 0.5, "|>");
if (closestbenchmark < 0)
continue;
b_lines[IOV] = new TArrow(timeMap.at(closestbenchmark).Convert(),
(c->GetUymin()),
timeMap.at(closestbenchmark).Convert(),
c->GetUymax(),
0.5,
"|>");
} else {
a_lines[IOV] = new TArrow(IOVboundaries[IOV],
(c->GetUymin()),
IOVboundaries[IOV],
0.65 * c->GetUymax(),
0.5,
"|>"); //(c->GetUymin()+0.2*(c->GetUymax()-c->GetUymin()) ),0.5,"|>");
b_lines[IOV] = new TArrow(benchmarkruns[IOV],
(c->GetUymin()),
benchmarkruns[IOV],
0.65 * c->GetUymax(),
0.5,
"|>"); //(c->GetUymin()+0.2*(c->GetUymax()-c->GetUymin()) ),0.5,"|>");
}
a_lines[IOV]->SetLineColor(kBlue);
a_lines[IOV]->SetLineStyle(9);
a_lines[IOV]->SetLineWidth(1);
a_lines[IOV]->Draw("same");
b_lines[IOV]->SetLineColor(kGray);
b_lines[IOV]->SetLineStyle(1);
b_lines[IOV]->SetLineWidth(2);
//b_lines[IOV]->Draw("same");
}
TPaveText *runnumbers[nIOVs];
for (Int_t IOV = 0; IOV < nIOVs; IOV++) {
if (IOVboundaries[IOV] < vruns.front())
continue;
//&& ((TString)c->GetName()).Contains("RMS")) continue;
int closestrun = pv::closest(vruns, IOVboundaries[IOV]);
Int_t ix1;
Int_t ix2;
Int_t iw = gPad->GetWw();
Int_t ih = gPad->GetWh();
Double_t x1p, y1p, x2p, y2p;
gPad->GetPadPar(x1p, y1p, x2p, y2p);
ix1 = (Int_t)(iw * x1p);
ix2 = (Int_t)(iw * x2p);
Double_t wndc = TMath::Min(1., (Double_t)iw / (Double_t)ih);
Double_t rw = wndc / (Double_t)iw;
Double_t x1ndc = (Double_t)ix1 * rw;
Double_t x2ndc = (Double_t)ix2 * rw;
Double_t rx1, ry1, rx2, ry2;
gPad->GetRange(rx1, ry1, rx2, ry2);
Double_t rx = (x2ndc - x1ndc) / (rx2 - rx1);
Double_t _sx;
if (lumi_axis_format) {
if (closestrun < 0)
break;
_sx = rx * (lumiMapByRun.at(closestrun) - rx1) + x1ndc; //-0.05;
} else if (time_axis_format) {
if (closestrun < 0)
break;
_sx = rx * (timeMap.at(closestrun).Convert() - rx1) + x1ndc; //-0.05;
} else {
_sx = rx * (IOVboundaries[IOV] - rx1) + x1ndc; //-0.05
}
Double_t _dx = _sx + 0.03;
Int_t index = IOV % 5;
// if(IOV<5)
// index=IOV;
// else{
// index=IOV-5;
// }
//runnumbers[IOV] = new TPaveText(_sx+0.001,0.14+(0.03*index),_dx,(0.17+0.03*index),"blNDC");
runnumbers[IOV] = new TPaveText(_sx + 0.001, 0.89 - (0.05 * index), _dx + 0.024, (0.92 - 0.05 * index), "blNDC");
//runnumbers[IOV]->SetTextAlign(11);
TText *textRun = runnumbers[IOV]->AddText(Form("%i", int(IOVboundaries[IOV])));
//TText *textRun = runnumbers[IOV]->AddText(Form("%s",dates[IOV].c_str()));
textRun->SetTextSize(0.038);
textRun->SetTextColor(kBlue);
runnumbers[IOV]->SetFillColor(10);
runnumbers[IOV]->SetLineColor(kBlue);
runnumbers[IOV]->SetBorderSize(1);
runnumbers[IOV]->SetLineWidth(1);
runnumbers[IOV]->SetTextColor(kBlue);
runnumbers[IOV]->SetTextFont(42);
if (drawText)
runnumbers[IOV]->Draw("same");
}
}
/*! \fn processData
* \brief function where the magic happens, take the raw inputs and creates the output trends
*/
/*--------------------------------------------------------------------*/
outTrends processData(size_t iter,
std::vector<int> intersection,
const Int_t nDirs_,
const char *dirs[10],
TString LegLabels[10],
bool useRMS)
/*--------------------------------------------------------------------*/
{
outTrends ret;
ret.init();
unsigned int effSize = std::min(nWorkers, intersection.size());
unsigned int pitch = std::floor(intersection.size() / effSize);
unsigned int first = iter * pitch;
unsigned int last = (iter == (effSize - 1)) ? intersection.size() : ((iter + 1) * pitch);
logInfo << "iter:" << iter << "| pitch: " << pitch << " [" << first << "-" << last << ")" << std::endl;
ret.m_index = iter;
for (unsigned int n = first; n < last; n++) {
//in case of debug, use only 50
//for(unsigned int n=0; n<50;n++){
//if(intersection.at(n)!=283946)
// continue;
if (VERBOSE) {
logInfo << "iter: " << iter << " " << n << " " << intersection.at(n) << std::endl;
}
TFile *fins[nDirs_];
TH1F *dxyPhiMeanTrend[nDirs_];
TH1F *dxyPhiWidthTrend[nDirs_];
TH1F *dzPhiMeanTrend[nDirs_];
TH1F *dzPhiWidthTrend[nDirs_];
TH1F *dxyLadderMeanTrend[nDirs_];
TH1F *dxyLadderWidthTrend[nDirs_];
TH1F *dzLadderWidthTrend[nDirs_];
TH1F *dzLadderMeanTrend[nDirs_];
TH1F *dxyModZMeanTrend[nDirs_];
TH1F *dxyModZWidthTrend[nDirs_];
TH1F *dzModZMeanTrend[nDirs_];
TH1F *dzModZWidthTrend[nDirs_];
TH1F *dxyEtaMeanTrend[nDirs_];
TH1F *dxyEtaWidthTrend[nDirs_];
TH1F *dzEtaMeanTrend[nDirs_];
TH1F *dzEtaWidthTrend[nDirs_];
TH1F *dxyNormPhiWidthTrend[nDirs_];
TH1F *dxyNormEtaWidthTrend[nDirs_];
TH1F *dzNormPhiWidthTrend[nDirs_];
TH1F *dzNormEtaWidthTrend[nDirs_];
TH1F *dxyNormPtWidthTrend[nDirs_];
TH1F *dzNormPtWidthTrend[nDirs_];
TH1F *dxyPtWidthTrend[nDirs_];
TH1F *dzPtWidthTrend[nDirs_];
TH1F *dxyIntegralTrend[nDirs_];
TH1F *dzIntegralTrend[nDirs_];
bool areAllFilesOK = true;
Int_t lastOpen = 0;
// loop over the objects
for (Int_t j = 0; j < nDirs_; j++) {
//fins[j] = TFile::Open(Form("%s/PVValidation_%s_%i.root",dirs[j],dirs[j],intersection[n]));
size_t position = std::string(dirs[j]).find("/");
string stem = std::string(dirs[j]).substr(position + 1); // get from position to the end
fins[j] = new TFile(Form("%s/PVValidation_%s_%i.root", dirs[j], stem.c_str(), intersection[n]));
if (fins[j]->IsZombie()) {
logError << Form("%s/PVValidation_%s_%i.root", dirs[j], stem.c_str(), intersection[n])
<< " is a Zombie! cannot combine" << std::endl;
areAllFilesOK = false;
lastOpen = j;
break;
}
if (VERBOSE) {
logInfo << Form("%s/PVValidation_%s_%i.root", dirs[j], stem.c_str(), intersection[n])
<< " has size: " << fins[j]->GetSize() << " b ";
}
// sanity check
TH1F *h_tracks = (TH1F *)fins[j]->Get("PVValidation/EventFeatures/h_nTracks");
if (j == 0) {
TH1F *h_lumi = (TH1F *)fins[j]->Get("PVValidation/EventFeatures/h_lumiFromConfig");
double lumi = h_lumi->GetBinContent(1);
ret.m_lumiSoFar += lumi;
//logInfo<<"lumi: "<<lumi
// <<" ,lumi so far: "<<lumiSoFar<<std::endl;
//outfile<<"run "<<intersection[n]<<" lumi: "<<lumi
// <<" ,lumi so far: "<<lumiSoFar<<std::endl;
}
Double_t numEvents = h_tracks->GetEntries();
if (numEvents < 2500) {
logWarning << "excluding run " << intersection[n] << " because it has less than 2.5k events" << std::endl;
areAllFilesOK = false;
lastOpen = j;
break;
}
dxyPhiMeanTrend[j] = (TH1F *)fins[j]->Get("PVValidation/MeanTrends/means_dxy_phi");
//dxyPhiMeanTrend[j] = checkTH1AndReturn(fins[j],"PVValidation/MeanTrends/means_dxy_phi");
dxyPhiWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dxy_phi");
dzPhiMeanTrend[j] = (TH1F *)fins[j]->Get("PVValidation/MeanTrends/means_dz_phi");
dzPhiWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dz_phi");
dxyLadderMeanTrend[j] = (TH1F *)fins[j]->Get("PVValidation/MeanTrends/means_dxy_ladder");
dxyLadderWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dxy_ladder");
dzLadderMeanTrend[j] = (TH1F *)fins[j]->Get("PVValidation/MeanTrends/means_dz_ladder");
dzLadderWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dz_ladder");
dxyEtaMeanTrend[j] = (TH1F *)fins[j]->Get("PVValidation/MeanTrends/means_dxy_eta");
dxyEtaWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dxy_eta");
dzEtaMeanTrend[j] = (TH1F *)fins[j]->Get("PVValidation/MeanTrends/means_dz_eta");
dzEtaWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dz_eta");
dxyModZMeanTrend[j] = (TH1F *)fins[j]->Get("PVValidation/MeanTrends/means_dxy_modZ");
dxyModZWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dxy_modZ");
dzModZMeanTrend[j] = (TH1F *)fins[j]->Get("PVValidation/MeanTrends/means_dz_modZ");
dzModZWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dz_modZ");
dxyNormPhiWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/norm_widths_dxy_phi");
dxyNormEtaWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/norm_widths_dxy_eta");
dzNormPhiWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/norm_widths_dz_phi");
dzNormEtaWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/norm_widths_dz_eta");
dxyNormPtWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/norm_widths_dxy_pTCentral");
dzNormPtWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/norm_widths_dz_pTCentral");
dxyPtWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dxy_pTCentral");
dzPtWidthTrend[j] = (TH1F *)fins[j]->Get("PVValidation/WidthTrends/widths_dz_pTCentral");
dxyIntegralTrend[j] = (TH1F *)fins[j]->Get("PVValidation/ProbeTrackFeatures/h_probedxyRefitV");
dzIntegralTrend[j] = (TH1F *)fins[j]->Get("PVValidation/ProbeTrackFeatures/h_probedzRefitV");
// fill the vectors of biases
auto dxyPhiBiases = getBiases(dxyPhiMeanTrend[j]);
//logInfo<<"\n" <<j<<" "<< LegLabels[j] << " dxy(phi) mean: "<< dxyPhiBiases.getWeightedMean()
// <<" dxy(phi) max: "<< dxyPhiBiases.getMax()
// <<" dxy(phi) min: "<< dxyPhiBiases.getMin()
// << std::endl;
ret.m_dxyPhiMeans[LegLabels[j]].push_back(dxyPhiBiases.getWeightedMean());
ret.m_dxyPhiChi2[LegLabels[j]].push_back(TMath::Log10(dxyPhiBiases.getNormChi2()));
ret.m_dxyPhiKS[LegLabels[j]].push_back(dxyPhiBiases.getKSScore());
//logInfo<<"\n" <<j<<" "<< LegLabels[j] << " dxy(phi) ks score: "<< dxyPhiBiases.getKSScore() << std::endl;
useRMS
? ret.m_dxyPhiLo[LegLabels[j]].push_back(dxyPhiBiases.getWeightedMean() - 2 * dxyPhiBiases.getWeightedRMS())
: ret.m_dxyPhiLo[LegLabels[j]].push_back(dxyPhiBiases.getMin());
useRMS
? ret.m_dxyPhiHi[LegLabels[j]].push_back(dxyPhiBiases.getWeightedMean() + 2 * dxyPhiBiases.getWeightedRMS())
: ret.m_dxyPhiHi[LegLabels[j]].push_back(dxyPhiBiases.getMax());
auto dxyEtaBiases = getBiases(dxyEtaMeanTrend[j]);
ret.m_dxyEtaMeans[LegLabels[j]].push_back(dxyEtaBiases.getWeightedMean());
ret.m_dxyEtaChi2[LegLabels[j]].push_back(TMath::Log10(dxyEtaBiases.getNormChi2()));
ret.m_dxyEtaKS[LegLabels[j]].push_back(dxyEtaBiases.getKSScore());
useRMS
? ret.m_dxyEtaLo[LegLabels[j]].push_back(dxyEtaBiases.getWeightedMean() - 2 * dxyEtaBiases.getWeightedRMS())
: ret.m_dxyEtaLo[LegLabels[j]].push_back(dxyEtaBiases.getMin());
useRMS
? ret.m_dxyEtaHi[LegLabels[j]].push_back(dxyEtaBiases.getWeightedMean() + 2 * dxyEtaBiases.getWeightedRMS())
: ret.m_dxyEtaHi[LegLabels[j]].push_back(dxyEtaBiases.getMax());
auto dzPhiBiases = getBiases(dzPhiMeanTrend[j]);
ret.m_dzPhiMeans[LegLabels[j]].push_back(dzPhiBiases.getWeightedMean());
ret.m_dzPhiChi2[LegLabels[j]].push_back(TMath::Log10(dzPhiBiases.getNormChi2()));
ret.m_dzPhiKS[LegLabels[j]].push_back(dzPhiBiases.getKSScore());
useRMS ? ret.m_dzPhiLo[LegLabels[j]].push_back(dzPhiBiases.getWeightedMean() - 2 * dzPhiBiases.getWeightedRMS())
: ret.m_dzPhiLo[LegLabels[j]].push_back(dzPhiBiases.getMin());
useRMS ? ret.m_dzPhiHi[LegLabels[j]].push_back(dzPhiBiases.getWeightedMean() + 2 * dzPhiBiases.getWeightedRMS())
: ret.m_dzPhiHi[LegLabels[j]].push_back(dzPhiBiases.getMax());
auto dzEtaBiases = getBiases(dzEtaMeanTrend[j]);
ret.m_dzEtaMeans[LegLabels[j]].push_back(dzEtaBiases.getWeightedMean());
ret.m_dzEtaChi2[LegLabels[j]].push_back(TMath::Log10(dzEtaBiases.getNormChi2()));
ret.m_dzEtaKS[LegLabels[j]].push_back(dzEtaBiases.getKSScore());
useRMS ? ret.m_dzEtaLo[LegLabels[j]].push_back(dzEtaBiases.getWeightedMean() - 2 * dzEtaBiases.getWeightedRMS())
: ret.m_dzEtaLo[LegLabels[j]].push_back(dzEtaBiases.getMin());
useRMS ? ret.m_dzEtaHi[LegLabels[j]].push_back(dzEtaBiases.getWeightedMean() + 2 * dzEtaBiases.getWeightedRMS())
: ret.m_dzEtaHi[LegLabels[j]].push_back(dzEtaBiases.getMax());
// unrolled histograms
ret.m_dxyVect[LegLabels[j]].push_back(getUnrolledHisto(dxyIntegralTrend[j]));
ret.m_dzVect[LegLabels[j]].push_back(getUnrolledHisto(dzIntegralTrend[j]));
//logInfo<<std::endl;
//logInfo<<" n. bins: "<< dxyVect[LegLabels[j]].back().get_n_bins()
// <<" y-min: "<< dxyVect[LegLabels[j]].back().get_y_min()
// <<" y-max: "<< dxyVect[LegLabels[j]].back().get_y_max() << std::endl;
// beautify the histograms
MakeNiceTrendPlotStyle(dxyPhiMeanTrend[j], j);
MakeNiceTrendPlotStyle(dxyPhiWidthTrend[j], j);
MakeNiceTrendPlotStyle(dzPhiMeanTrend[j], j);
MakeNiceTrendPlotStyle(dzPhiWidthTrend[j], j);
MakeNiceTrendPlotStyle(dxyLadderMeanTrend[j], j);
MakeNiceTrendPlotStyle(dxyLadderWidthTrend[j], j);
MakeNiceTrendPlotStyle(dzLadderMeanTrend[j], j);
MakeNiceTrendPlotStyle(dzLadderWidthTrend[j], j);
MakeNiceTrendPlotStyle(dxyEtaMeanTrend[j], j);
MakeNiceTrendPlotStyle(dxyEtaWidthTrend[j], j);
MakeNiceTrendPlotStyle(dzEtaMeanTrend[j], j);
MakeNiceTrendPlotStyle(dzEtaWidthTrend[j], j);
MakeNiceTrendPlotStyle(dxyModZMeanTrend[j], j);
MakeNiceTrendPlotStyle(dxyModZWidthTrend[j], j);
MakeNiceTrendPlotStyle(dzModZMeanTrend[j], j);
MakeNiceTrendPlotStyle(dzModZWidthTrend[j], j);
MakeNiceTrendPlotStyle(dxyNormPhiWidthTrend[j], j);
MakeNiceTrendPlotStyle(dxyNormEtaWidthTrend[j], j);
MakeNiceTrendPlotStyle(dzNormPhiWidthTrend[j], j);
MakeNiceTrendPlotStyle(dzNormEtaWidthTrend[j], j);
MakeNiceTrendPlotStyle(dxyNormPtWidthTrend[j], j);
MakeNiceTrendPlotStyle(dzNormPtWidthTrend[j], j);
MakeNiceTrendPlotStyle(dxyPtWidthTrend[j], j);
MakeNiceTrendPlotStyle(dzPtWidthTrend[j], j);
}
if (!areAllFilesOK) {
// do all the necessary deletions
logWarning << "====> not all files are OK" << std::endl;
for (int i = 0; i < lastOpen; i++) {
fins[i]->Close();
}
continue;
} else {
ret.m_runs.push_back(intersection.at(n));
// push back the vector of lumi (in fb at this point)
ret.m_lumiByRun.push_back(ret.m_lumiSoFar / 1000.);
ret.m_lumiMapByRun[intersection.at(n)] = ret.m_lumiSoFar / 1000.;
}
if (VERBOSE) {
logInfo << "I am still here - runs.size(): " << ret.m_runs.size() << std::endl;
}
// Bias plots
TCanvas *BiasesCanvas = new TCanvas(Form("Biases_%i", intersection.at(n)), "Biases", 1200, 1200);
arrangeOutCanvas(BiasesCanvas,
dxyPhiMeanTrend,
dzPhiMeanTrend,
dxyEtaMeanTrend,
dzEtaMeanTrend,
nDirs_,
LegLabels,
intersection.at(n));
BiasesCanvas->SaveAs(Form("Biases_%i.pdf", intersection.at(n)));
BiasesCanvas->SaveAs(Form("Biases_%i.png", intersection.at(n)));
// Bias vs L1 modules position
TCanvas *BiasesL1Canvas = new TCanvas(Form("BiasesL1_%i", intersection.at(n)), "BiasesL1", 1200, 1200);
arrangeOutCanvas(BiasesL1Canvas,
dxyLadderMeanTrend,
dzLadderMeanTrend,
dxyModZMeanTrend,
dzModZMeanTrend,
nDirs_,
LegLabels,
intersection.at(n));
BiasesL1Canvas->SaveAs(Form("BiasesL1_%i.pdf", intersection.at(n)));
BiasesL1Canvas->SaveAs(Form("BiasesL1_%i.png", intersection.at(n)));
// Resolution plots
TCanvas *ResolutionsCanvas = new TCanvas(Form("Resolutions_%i", intersection.at(n)), "Resolutions", 1200, 1200);
arrangeOutCanvas(ResolutionsCanvas,
dxyPhiWidthTrend,
dzPhiWidthTrend,
dxyEtaWidthTrend,
dzEtaWidthTrend,
nDirs_,
LegLabels,
intersection.at(n));
ResolutionsCanvas->SaveAs(Form("Resolutions_%i.pdf", intersection.at(n)));
ResolutionsCanvas->SaveAs(Form("Resolutions_%i.png", intersection.at(n)));
// Resolution plots vs L1 modules position
TCanvas *ResolutionsL1Canvas = new TCanvas(Form("ResolutionsL1_%i", intersection.at(n)), "Resolutions", 1200, 1200);
arrangeOutCanvas(ResolutionsL1Canvas,
dxyLadderWidthTrend,
dzLadderWidthTrend,
dxyModZWidthTrend,
dzModZWidthTrend,
nDirs_,
LegLabels,
intersection.at(n));
ResolutionsL1Canvas->SaveAs(Form("ResolutionsL1_%i.pdf", intersection.at(n)));
ResolutionsL1Canvas->SaveAs(Form("ResolutionsL1_%i.png", intersection.at(n)));
// Pull plots
TCanvas *PullsCanvas = new TCanvas(Form("Pulls_%i", intersection.at(n)), "Pulls", 1200, 1200);
arrangeOutCanvas(PullsCanvas,
dxyNormPhiWidthTrend,
dzNormPhiWidthTrend,
dxyNormEtaWidthTrend,
dzNormEtaWidthTrend,
nDirs_,
LegLabels,
intersection.at(n));
PullsCanvas->SaveAs(Form("Pulls_%i.pdf", intersection.at(n)));
PullsCanvas->SaveAs(Form("Pulls_%i.png", intersection.at(n)));
// pT plots
TCanvas *ResolutionsVsPt =
new TCanvas(Form("ResolutionsVsPT_%i", intersection.at(n)), "ResolutionsVsPt", 1200, 1200);
arrangeOutCanvas(ResolutionsVsPt,
dxyPtWidthTrend,
dzPtWidthTrend,
dxyNormPtWidthTrend,
dzNormPtWidthTrend,
nDirs_,
LegLabels,
intersection.at(n));
ResolutionsVsPt->SaveAs(Form("ResolutionsVsPt_%i.pdf", intersection.at(n)));
ResolutionsVsPt->SaveAs(Form("ResolutionsVsPt_%i.png", intersection.at(n)));
// do all the necessary deletions
for (int i = 0; i < nDirs_; i++) {
delete dxyPhiMeanTrend[i];
delete dzPhiMeanTrend[i];
delete dxyEtaMeanTrend[i];
delete dzEtaMeanTrend[i];
delete dxyPhiWidthTrend[i];
delete dzPhiWidthTrend[i];
delete dxyEtaWidthTrend[i];
delete dzEtaWidthTrend[i];
delete dxyNormPhiWidthTrend[i];
delete dxyNormEtaWidthTrend[i];
delete dzNormPhiWidthTrend[i];
delete dzNormEtaWidthTrend[i];
delete dxyNormPtWidthTrend[i];
delete dzNormPtWidthTrend[i];
delete dxyPtWidthTrend[i];
delete dzPtWidthTrend[i];
fins[i]->Close();
}
delete BiasesCanvas;
delete BiasesL1Canvas;
delete ResolutionsCanvas;
delete ResolutionsL1Canvas;
delete PullsCanvas;
delete ResolutionsVsPt;
if (VERBOSE) {
logInfo << std::endl;
}
}
return ret;
}
|