Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:37:43

0001 // File: TestClusters.cc
0002 // Description: T0 test the pixel clusters.
0003 // Author: Danek Kotlinski
0004 // Creation Date:  Initial version. 3/06
0005 // Modify to work with CMSSW354, 11/03/10 d.k.
0006 // Modify to work with CMSSW620, SLC6, CMSSW700, 10/10/13 d.k.
0007 // Change to ByToken (clusters only)
0008 //--------------------------------------------
0009 #include <memory>
0010 #include <string>
0011 #include <iostream>
0012 
0013 #include "DataFormats/Common/interface/Handle.h"
0014 #include "FWCore/Framework/interface/ESHandle.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 
0017 #include "FWCore/Framework/interface/Frameworkfwd.h"
0018 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0019 
0020 #include "FWCore/Framework/interface/Event.h"
0021 #include "FWCore/Framework/interface/MakerMacros.h"
0022 //#include "DataFormats/Common/interface/Handle.h"
0023 
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 #include "FWCore/ServiceRegistry/interface/Service.h"
0026 #include "FWCore/Utilities/interface/InputTag.h"
0027 
0028 #include "DataFormats/SiPixelCluster/interface/SiPixelCluster.h"
0029 #include "DataFormats/Common/interface/DetSetVector.h"
0030 #include "DataFormats/Common/interface/Ref.h"
0031 #include "DataFormats/DetId/interface/DetId.h"
0032 
0033 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
0034 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
0035 
0036 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0037 #include "Geometry/CommonDetUnit/interface/PixelGeomDetType.h"
0038 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0039 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0040 #include "Geometry/CommonDetUnit/interface/GeomDetType.h"
0041 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
0042 //#include "Geometry/TrackerTopology/interface/RectangularPixelTopology.h"
0043 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0044 
0045 // For L1
0046 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
0047 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0048 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
0049 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0050 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h"
0051 
0052 // For HLT
0053 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
0054 #include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
0055 #include "DataFormats/Common/interface/TriggerResults.h"
0056 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
0057 #include "FWCore/Common/interface/TriggerNames.h"
0058 
0059 // for resyncs
0060 #include "DataFormats/Scalers/interface/Level1TriggerScalers.h"
0061 
0062 // For luminisoty
0063 #include "DataFormats/Luminosity/interface/LumiSummary.h"
0064 #include "DataFormats/Luminosity/interface/LumiDetails.h"
0065 #include "DataFormats/Common/interface/ConditionsInEdm.h"
0066 #include "RecoLuminosity/LumiProducer/interface/LumiCorrector.h"
0067 
0068 // For PVs
0069 #include "DataFormats/VertexReco/interface/Vertex.h"
0070 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0071 
0072 // To use root histos
0073 #include "FWCore/ServiceRegistry/interface/Service.h"
0074 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0075 
0076 // For ROOT
0077 #include <TROOT.h>
0078 #include <TChain.h>
0079 #include <TFile.h>
0080 #include <TF1.h>
0081 #include <TH2F.h>
0082 #include <TH1F.h>
0083 #include <TProfile.h>
0084 
0085 #define NEW_ID
0086 #ifdef NEW_ID
0087 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0088 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0089 #else
0090 #include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
0091 #include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
0092 #endif
0093 
0094 #include "DataFormats/Provenance/interface/RunLumiEventNumber.h"
0095 
0096 using namespace std;
0097 
0098 #define HISTOS
0099 //#define L1
0100 //#define HLT
0101 //#define HI
0102 //#define ROC_EFF
0103 //#define Lumi
0104 //#define USE_RESYNCS  // get theinfo about recyncs
0105 
0106 // special hitos with parameters normalized to intlumi (usually disabled)
0107 //#define INSTLUMI_STUDIES
0108 //#define VDM_STUDIES
0109 
0110 //#define BX
0111 #define BX_NEW
0112 
0113 //=======================================================================
0114 #ifdef BX_NEW
0115 
0116 class getBX {
0117 public:
0118   getBX(void);
0119   ~getBX(void);
0120   static int find(int bx);
0121 
0122 private:
0123 };
0124 
0125 getBX::getBX(void) { edm::LogPrint("TestClusters") << " bx ctor "; }
0126 
0127 getBX::~getBX(void) {}
0128 
0129 int getBX::find(int bx) {
0130   // invalid -1, empty 0, beam1 1, beam2 2, collision 3, collison+1 4, beam1+1 5,  beam2+1 6
0131 
0132   const int limit = 3394;
0133 
0134   // For the 48-35 fill used for VdM
0135   //   const int coll_num = 35;
0136   //   const int coll[35] = {
0137   //        1,41,81,121,161,201,241,721,761,801,841,881,921,961,1581,1621,1661,1701,1741,1781,1821,2161,2201,2241,2281,
0138   //        2321,2361,2401,2881,2921,2961,3001,3041,3081,3121
0139   //   };
0140   //   const int beam1_num=13;
0141   //   const int beam1[13] = {
0142   //     301,341,381,541,581,621,661,1335,1375,1415,1455,1495,1535
0143   //   };
0144   //   const int beam2_num=13;
0145   //   const int beam2[13] = {
0146   //     441,481,521,561,601,641,1192,1232,1272,2001,2041,2081,2121
0147   //   };
0148 
0149   // For the usuall 1375-1368 50ns fill
0150   const int coll_num = 1368;
0151   const int coll[1368] = {
0152       66,   68,   70,   72,   74,   76,   78,   80,   82,   84,   86,   88,   90,   92,   94,   96,   98,   100,  102,
0153       104,  106,  108,  110,  112,  114,  116,  118,  120,  122,  124,  126,  128,  130,  132,  134,  136,  146,  148,
0154       150,  152,  154,  156,  158,  160,  162,  164,  166,  168,  170,  172,  174,  176,  178,  180,  182,  184,  186,
0155       188,  190,  192,  194,  196,  198,  200,  202,  204,  206,  208,  210,  212,  214,  216,  226,  228,  230,  232,
0156       234,  236,  238,  240,  242,  244,  246,  248,  250,  252,  254,  256,  258,  260,  262,  264,  266,  268,  270,
0157       272,  274,  276,  278,  280,  282,  284,  286,  288,  290,  292,  294,  296,  306,  308,  310,  312,  314,  316,
0158       318,  320,  322,  324,  326,  328,  330,  332,  334,  336,  338,  340,  342,  344,  346,  348,  350,  352,  354,
0159       356,  358,  360,  362,  364,  366,  368,  370,  372,  374,  376,  413,  415,  417,  419,  421,  423,  425,  427,
0160       429,  431,  433,  435,  437,  439,  441,  443,  445,  447,  449,  451,  453,  455,  457,  459,  461,  463,  465,
0161       467,  469,  471,  473,  475,  477,  479,  481,  483,  493,  495,  497,  499,  501,  503,  505,  507,  509,  511,
0162       513,  515,  517,  519,  521,  523,  525,  527,  529,  531,  533,  535,  537,  539,  541,  543,  545,  547,  549,
0163       551,  553,  555,  557,  559,  561,  563,  573,  575,  577,  579,  581,  583,  585,  587,  589,  591,  593,  595,
0164       597,  599,  601,  603,  605,  607,  609,  611,  613,  615,  617,  619,  621,  623,  625,  627,  629,  631,  633,
0165       635,  637,  639,  641,  643,  653,  655,  657,  659,  661,  663,  665,  667,  669,  671,  673,  675,  677,  679,
0166       681,  683,  685,  687,  689,  691,  693,  695,  697,  699,  701,  703,  705,  707,  709,  711,  713,  715,  717,
0167       719,  721,  723,  773,  775,  777,  779,  781,  783,  785,  787,  789,  791,  793,  795,  797,  799,  801,  803,
0168       805,  807,  809,  811,  813,  815,  817,  819,  821,  823,  825,  827,  829,  831,  833,  835,  837,  839,  841,
0169       843,  853,  855,  857,  859,  861,  863,  865,  867,  869,  871,  873,  875,  877,  879,  881,  883,  885,  887,
0170       889,  891,  893,  895,  897,  899,  901,  903,  905,  907,  909,  911,  913,  915,  917,  919,  921,  923,  960,
0171       962,  964,  966,  968,  970,  972,  974,  976,  978,  980,  982,  984,  986,  988,  990,  992,  994,  996,  998,
0172       1000, 1002, 1004, 1006, 1008, 1010, 1012, 1014, 1016, 1018, 1020, 1022, 1024, 1026, 1028, 1030, 1040, 1042, 1044,
0173       1046, 1048, 1050, 1052, 1054, 1056, 1058, 1060, 1062, 1064, 1066, 1068, 1070, 1072, 1074, 1076, 1078, 1080, 1082,
0174       1084, 1086, 1088, 1090, 1092, 1094, 1096, 1098, 1100, 1102, 1104, 1106, 1108, 1110, 1120, 1122, 1124, 1126, 1128,
0175       1130, 1132, 1134, 1136, 1138, 1140, 1142, 1144, 1146, 1148, 1150, 1152, 1154, 1156, 1158, 1160, 1162, 1164, 1166,
0176       1168, 1170, 1172, 1174, 1176, 1178, 1180, 1182, 1184, 1186, 1188, 1190, 1200, 1202, 1204, 1206, 1208, 1210, 1212,
0177       1214, 1216, 1218, 1220, 1222, 1224, 1226, 1228, 1230, 1232, 1234, 1236, 1238, 1240, 1242, 1244, 1246, 1248, 1250,
0178       1252, 1254, 1256, 1258, 1260, 1262, 1264, 1266, 1268, 1270, 1307, 1309, 1311, 1313, 1315, 1317, 1319, 1321, 1323,
0179       1325, 1327, 1329, 1331, 1333, 1335, 1337, 1339, 1341, 1343, 1345, 1347, 1349, 1351, 1353, 1355, 1357, 1359, 1361,
0180       1363, 1365, 1367, 1369, 1371, 1373, 1375, 1377, 1387, 1389, 1391, 1393, 1395, 1397, 1399, 1401, 1403, 1405, 1407,
0181       1409, 1411, 1413, 1415, 1417, 1419, 1421, 1423, 1425, 1427, 1429, 1431, 1433, 1435, 1437, 1439, 1441, 1443, 1445,
0182       1447, 1449, 1451, 1453, 1455, 1457, 1467, 1469, 1471, 1473, 1475, 1477, 1479, 1481, 1483, 1485, 1487, 1489, 1491,
0183       1493, 1495, 1497, 1499, 1501, 1503, 1505, 1507, 1509, 1511, 1513, 1515, 1517, 1519, 1521, 1523, 1525, 1527, 1529,
0184       1531, 1533, 1535, 1537, 1547, 1549, 1551, 1553, 1555, 1557, 1559, 1561, 1563, 1565, 1567, 1569, 1571, 1573, 1575,
0185       1577, 1579, 1581, 1583, 1585, 1587, 1589, 1591, 1593, 1595, 1597, 1599, 1601, 1603, 1605, 1607, 1609, 1611, 1613,
0186       1615, 1617, 1667, 1669, 1671, 1673, 1675, 1677, 1679, 1681, 1683, 1685, 1687, 1689, 1691, 1693, 1695, 1697, 1699,
0187       1701, 1703, 1705, 1707, 1709, 1711, 1713, 1715, 1717, 1719, 1721, 1723, 1725, 1727, 1729, 1731, 1733, 1735, 1737,
0188       1747, 1749, 1751, 1753, 1755, 1757, 1759, 1761, 1763, 1765, 1767, 1769, 1771, 1773, 1775, 1777, 1779, 1781, 1783,
0189       1785, 1787, 1789, 1791, 1793, 1795, 1797, 1799, 1801, 1803, 1805, 1807, 1809, 1811, 1813, 1815, 1817, 1854, 1856,
0190       1858, 1860, 1862, 1864, 1866, 1868, 1870, 1872, 1874, 1876, 1878, 1880, 1882, 1884, 1886, 1888, 1890, 1892, 1894,
0191       1896, 1898, 1900, 1902, 1904, 1906, 1908, 1910, 1912, 1914, 1916, 1918, 1920, 1922, 1924, 1934, 1936, 1938, 1940,
0192       1942, 1944, 1946, 1948, 1950, 1952, 1954, 1956, 1958, 1960, 1962, 1964, 1966, 1968, 1970, 1972, 1974, 1976, 1978,
0193       1980, 1982, 1984, 1986, 1988, 1990, 1992, 1994, 1996, 1998, 2000, 2002, 2004, 2014, 2016, 2018, 2020, 2022, 2024,
0194       2026, 2028, 2030, 2032, 2034, 2036, 2038, 2040, 2042, 2044, 2046, 2048, 2050, 2052, 2054, 2056, 2058, 2060, 2062,
0195       2064, 2066, 2068, 2070, 2072, 2074, 2076, 2078, 2080, 2082, 2084, 2094, 2096, 2098, 2100, 2102, 2104, 2106, 2108,
0196       2110, 2112, 2114, 2116, 2118, 2120, 2122, 2124, 2126, 2128, 2130, 2132, 2134, 2136, 2138, 2140, 2142, 2144, 2146,
0197       2148, 2150, 2152, 2154, 2156, 2158, 2160, 2162, 2164, 2201, 2203, 2205, 2207, 2209, 2211, 2213, 2215, 2217, 2219,
0198       2221, 2223, 2225, 2227, 2229, 2231, 2233, 2235, 2237, 2239, 2241, 2243, 2245, 2247, 2249, 2251, 2253, 2255, 2257,
0199       2259, 2261, 2263, 2265, 2267, 2269, 2271, 2281, 2283, 2285, 2287, 2289, 2291, 2293, 2295, 2297, 2299, 2301, 2303,
0200       2305, 2307, 2309, 2311, 2313, 2315, 2317, 2319, 2321, 2323, 2325, 2327, 2329, 2331, 2333, 2335, 2337, 2339, 2341,
0201       2343, 2345, 2347, 2349, 2351, 2361, 2363, 2365, 2367, 2369, 2371, 2373, 2375, 2377, 2379, 2381, 2383, 2385, 2387,
0202       2389, 2391, 2393, 2395, 2397, 2399, 2401, 2403, 2405, 2407, 2409, 2411, 2413, 2415, 2417, 2419, 2421, 2423, 2425,
0203       2427, 2429, 2431, 2441, 2443, 2445, 2447, 2449, 2451, 2453, 2455, 2457, 2459, 2461, 2463, 2465, 2467, 2469, 2471,
0204       2473, 2475, 2477, 2479, 2481, 2483, 2485, 2487, 2489, 2491, 2493, 2495, 2497, 2499, 2501, 2503, 2505, 2507, 2509,
0205       2511, 2549, 2551, 2553, 2555, 2557, 2559, 2561, 2563, 2565, 2567, 2569, 2571, 2573, 2575, 2577, 2579, 2581, 2583,
0206       2585, 2587, 2589, 2591, 2593, 2595, 2597, 2599, 2601, 2603, 2605, 2607, 2609, 2611, 2613, 2615, 2617, 2619, 2629,
0207       2631, 2633, 2635, 2637, 2639, 2641, 2643, 2645, 2647, 2649, 2651, 2653, 2655, 2657, 2659, 2661, 2663, 2665, 2667,
0208       2669, 2671, 2673, 2675, 2677, 2679, 2681, 2683, 2685, 2687, 2689, 2691, 2693, 2695, 2697, 2699, 2736, 2738, 2740,
0209       2742, 2744, 2746, 2748, 2750, 2752, 2754, 2756, 2758, 2760, 2762, 2764, 2766, 2768, 2770, 2772, 2774, 2776, 2778,
0210       2780, 2782, 2784, 2786, 2788, 2790, 2792, 2794, 2796, 2798, 2800, 2802, 2804, 2806, 2816, 2818, 2820, 2822, 2824,
0211       2826, 2828, 2830, 2832, 2834, 2836, 2838, 2840, 2842, 2844, 2846, 2848, 2850, 2852, 2854, 2856, 2858, 2860, 2862,
0212       2864, 2866, 2868, 2870, 2872, 2874, 2876, 2878, 2880, 2882, 2884, 2886, 2896, 2898, 2900, 2902, 2904, 2906, 2908,
0213       2910, 2912, 2914, 2916, 2918, 2920, 2922, 2924, 2926, 2928, 2930, 2932, 2934, 2936, 2938, 2940, 2942, 2944, 2946,
0214       2948, 2950, 2952, 2954, 2956, 2958, 2960, 2962, 2964, 2966, 2976, 2978, 2980, 2982, 2984, 2986, 2988, 2990, 2992,
0215       2994, 2996, 2998, 3000, 3002, 3004, 3006, 3008, 3010, 3012, 3014, 3016, 3018, 3020, 3022, 3024, 3026, 3028, 3030,
0216       3032, 3034, 3036, 3038, 3040, 3042, 3044, 3046, 3083, 3085, 3087, 3089, 3091, 3093, 3095, 3097, 3099, 3101, 3103,
0217       3105, 3107, 3109, 3111, 3113, 3115, 3117, 3119, 3121, 3123, 3125, 3127, 3129, 3131, 3133, 3135, 3137, 3139, 3141,
0218       3143, 3145, 3147, 3149, 3151, 3153, 3163, 3165, 3167, 3169, 3171, 3173, 3175, 3177, 3179, 3181, 3183, 3185, 3187,
0219       3189, 3191, 3193, 3195, 3197, 3199, 3201, 3203, 3205, 3207, 3209, 3211, 3213, 3215, 3217, 3219, 3221, 3223, 3225,
0220       3227, 3229, 3231, 3233, 3243, 3245, 3247, 3249, 3251, 3253, 3255, 3257, 3259, 3261, 3263, 3265, 3267, 3269, 3271,
0221       3273, 3275, 3277, 3279, 3281, 3283, 3285, 3287, 3289, 3291, 3293, 3295, 3297, 3299, 3301, 3303, 3305, 3307, 3309,
0222       3311, 3313, 3323, 3325, 3327, 3329, 3331, 3333, 3335, 3337, 3339, 3341, 3343, 3345, 3347, 3349, 3351, 3353, 3355,
0223       3357, 3359, 3361, 3363, 3365, 3367, 3369, 3371, 3373, 3375, 3377, 3379, 3381, 3383, 3385, 3387, 3389, 3391, 3393};
0224   const int beam1_num = 6;
0225   const int beam1[6] = {1, 3, 5, 7, 9, 11};
0226   const int beam2_num = 6;
0227   const int beam2[6] = {
0228       13,
0229       15,
0230       17,
0231       19,
0232       21,
0233       23,
0234   };
0235 
0236   if (bx > limit)
0237     return (-1);
0238   //edm::LogPrint("TestClusters")<<bx<<endl;
0239 
0240   // Check collisions
0241   for (int i = 0; i < coll_num; ++i) {
0242     if (bx == coll[i])
0243       return (3);  // collision
0244     else if (bx == (coll[i] + 1))
0245       return (4);  // collision+1
0246   }
0247 
0248   // Check beam1
0249   for (int i = 0; i < beam1_num; ++i) {
0250     if (bx == beam1[i])
0251       return (1);  // collision
0252     else if (bx == (beam1[i] + 1))
0253       return (5);  // collision+1
0254   }
0255 
0256   // Check beam1
0257   for (int i = 0; i < beam2_num; ++i) {
0258     if (bx == beam2[i])
0259       return (2);  // collision
0260     else if (bx == (beam2[i] + 1))
0261       return (6);  // collision+1
0262   }
0263 
0264   return 0;  // return no collision
0265 }
0266 
0267 #endif  // BX_NEW
0268 
0269 //=======================================================================
0270 #ifdef BX
0271 class getBX {
0272 public:
0273   getBX(void);
0274   ~getBX(void);
0275   int find(int bx);
0276 
0277 private:
0278   int limit;
0279   int trains;
0280   int train_start[40];
0281   int train_stop[40];
0282   int beam1_start[40];
0283   int beam1_stop[40];
0284   int beam2_start[40];
0285   int beam2_stop[40];
0286 };
0287 
0288 getBX::getBX(void) {
0289   limit = 1841;
0290   trains = 22;
0291   int count = 0;
0292 
0293   // train 1
0294   train_start[count] = 7;
0295   train_stop[count] = 24;
0296   beam1_start[count] = 1;
0297   beam1_stop[count] = 5;
0298   beam2_start[count] = 25;
0299   beam2_stop[count] = 29;
0300 
0301   // train 2
0302   count++;
0303   train_start[count] = 66;
0304   train_stop[count] = 137;
0305   beam1_start[count] = -1;
0306   beam1_stop[count] = -1;
0307   beam2_start[count] = -1;
0308   beam2_stop[count] = -1;
0309 
0310   // train 3
0311   count++;
0312   train_start[count] = 146;
0313   train_stop[count] = 217;
0314   beam1_start[count] = -1;
0315   beam1_stop[count] = -1;
0316   beam2_start[count] = -1;
0317   beam2_stop[count] = -1;
0318 
0319   // train 4
0320   count++;
0321   train_start[count] = 226;
0322   train_stop[count] = 297;
0323   beam1_start[count] = -1;
0324   beam1_stop[count] = -1;
0325   beam2_start[count] = -1;
0326   beam2_stop[count] = -1;
0327 
0328   // train 5
0329   count++;
0330   train_start[count] = 306;
0331   train_stop[count] = 377;
0332   beam1_start[count] = -1;
0333   beam1_stop[count] = -1;
0334   beam2_start[count] = -1;
0335   beam2_stop[count] = -1;
0336 
0337   // train 6
0338   count++;
0339   train_start[count] = 413;
0340   train_stop[count] = 484;
0341   beam1_start[count] = -1;
0342   beam1_stop[count] = -1;
0343   beam2_start[count] = -1;
0344   beam2_stop[count] = -1;
0345 
0346   // train 7
0347   count++;
0348   train_start[count] = 493;
0349   train_stop[count] = 564;
0350   beam1_start[count] = -1;
0351   beam1_stop[count] = -1;
0352   beam2_start[count] = -1;
0353   beam2_stop[count] = -1;
0354 
0355   // train 8
0356   count++;
0357   train_start[count] = 573;
0358   train_stop[count] = 644;
0359   beam1_start[count] = -1;
0360   beam1_stop[count] = -1;
0361   beam2_start[count] = -1;
0362   beam2_stop[count] = -1;
0363 
0364   // train 9
0365   count++;
0366   train_start[count] = 653;
0367   train_stop[count] = 724;
0368   beam1_start[count] = -1;
0369   beam1_stop[count] = -1;
0370   beam2_start[count] = -1;
0371   beam2_stop[count] = -1;
0372 
0373   // train 10
0374   count++;
0375   train_start[count] = 773;
0376   train_stop[count] = 844;
0377   beam1_start[count] = -1;
0378   beam1_stop[count] = -1;
0379   beam2_start[count] = -1;
0380   beam2_stop[count] = -1;
0381 
0382   // train 11
0383   count++;
0384   train_start[count] = 853;
0385   train_stop[count] = 924;
0386   beam1_start[count] = -1;
0387   beam1_stop[count] = -1;
0388   beam2_start[count] = -1;
0389   beam2_stop[count] = -1;
0390 
0391   // train 12
0392   count++;
0393   train_start[count] = 960;
0394   train_stop[count] = 1031;
0395   beam1_start[count] = -1;
0396   beam1_stop[count] = -1;
0397   beam2_start[count] = -1;
0398   beam2_stop[count] = -1;
0399 
0400   // train 13
0401   count++;
0402   train_start[count] = 1040;
0403   train_stop[count] = 1111;
0404   beam1_start[count] = -1;
0405   beam1_stop[count] = -1;
0406   beam2_start[count] = -1;
0407   beam2_stop[count] = -1;
0408 
0409   // train 14
0410   count++;
0411   train_start[count] = 1120;
0412   train_stop[count] = 1191;
0413   beam1_start[count] = -1;
0414   beam1_stop[count] = -1;
0415   beam2_start[count] = -1;
0416   beam2_stop[count] = -1;
0417 
0418   // train 15
0419   count++;
0420   train_start[count] = 1200;
0421   train_stop[count] = 1271;
0422   beam1_start[count] = -1;
0423   beam1_stop[count] = -1;
0424   beam2_start[count] = -1;
0425   beam2_stop[count] = -1;
0426 
0427   // train 16
0428   count++;
0429   train_start[count] = 1307;
0430   train_stop[count] = 1378;
0431   beam1_start[count] = -1;
0432   beam1_stop[count] = -1;
0433   beam2_start[count] = -1;
0434   beam2_stop[count] = -1;
0435 
0436   // train 17
0437   count++;
0438   train_start[count] = 1387;
0439   train_stop[count] = 1458;
0440   beam1_start[count] = -1;
0441   beam1_stop[count] = -1;
0442   beam2_start[count] = -1;
0443   beam2_stop[count] = -1;
0444 
0445   // train 18
0446   count++;
0447   train_start[count] = 1467;
0448   train_stop[count] = 1538;
0449   beam1_start[count] = -1;
0450   beam1_stop[count] = -1;
0451   beam2_start[count] = -1;
0452   beam2_stop[count] = -1;
0453 
0454   // train 19
0455   count++;
0456   train_start[count] = 1547;
0457   train_stop[count] = 1618;
0458   beam1_start[count] = -1;
0459   beam1_stop[count] = -1;
0460   beam2_start[count] = -1;
0461   beam2_stop[count] = -1;
0462 
0463   // train 20
0464   count++;
0465   train_start[count] = 1667;
0466   train_stop[count] = 1726;
0467   beam1_start[count] = 1727;
0468   beam1_stop[count] = 1734;
0469   beam2_start[count] = 1655;
0470   beam2_stop[count] = 1666;
0471 
0472   // train 21
0473   count++;
0474   train_start[count] = 1735;
0475   train_stop[count] = 1738;
0476   beam1_start[count] = -1;
0477   beam1_stop[count] = -1;
0478   beam2_start[count] = -1;
0479   beam2_stop[count] = -1;
0480 
0481   // train 22
0482   count++;
0483   train_start[count] = 1747;
0484   train_stop[count] = 1806;
0485   beam1_start[count] = 1807;
0486   beam1_stop[count] = 1818;
0487   beam2_start[count] = 1739;
0488   beam2_stop[count] = 1745;
0489 
0490   edm::LogPrint("TestClusters") << " number of trains " << trains << " " << limit;
0491 }
0492 
0493 getBX::~getBX(void) {}
0494 
0495 int getBX::find(int bx) {
0496   // invalid -1, empty 0. beam1 1, beam2 2, collision 3, collison+1 4, beam1+1 5,  beam2+1 6
0497 
0498   if (bx > limit)
0499     return (-1);
0500   //edm::LogPrint("TestClusters")<<bx<<endl;
0501 
0502   // Check collisions
0503   for (int train = 0; train < trains; ++train) {
0504     //edm::LogPrint("TestClusters")<<bx<<" "<<train<<endl;
0505 
0506     for (int b = train_start[train]; b <= train_stop[train]; b += 2) {
0507       //edm::LogPrint("TestClusters")<<bx<<" "<<train<<" "<<b<<endl;
0508       if (bx == b)
0509         return (3);  // collision
0510       else if (bx == (b + 1))
0511         return (4);  // collision+1
0512     }
0513 
0514     if (beam1_start[train] != -1) {
0515       for (int b = beam1_start[train]; b <= beam1_stop[train]; b += 2) {
0516         //edm::LogPrint("TestClusters")<<bx<<" "<<train<<" "<<b<<endl;
0517         if (bx == b)
0518           return (1);  // beam1
0519         else if (bx == (b + 1))
0520           return (5);  // beam1+1
0521       }
0522     }
0523 
0524     if (beam2_start[train] != -1) {
0525       for (int b = beam2_start[train]; b <= beam2_stop[train]; b += 2) {
0526         //edm::LogPrint("TestClusters")<<bx<<" "<<train<<" "<<b<<endl;
0527         if (bx == b)
0528           return (2);  // beam1
0529         else if (bx == (b + 1))
0530           return (6);  // beam1+1
0531       }
0532     }
0533 
0534   }  // loop trains
0535 
0536   //edm::LogPrint("TestClusters")<<bx<<endl;
0537 
0538   return 0;  // return no collision
0539 }
0540 
0541 #endif
0542 //=========================================================================
0543 
0544 //=======================================================================
0545 
0546 // decode a simplified ROC address
0547 int rocId(int col, int row) {
0548   int rocRow = row / 80;
0549   int rocCol = col / 52;
0550   int rocId = rocCol + rocRow * 8;
0551   return rocId;
0552 }
0553 
0554 //=========================================================================
0555 #ifdef ROC_EFF
0556 
0557 class rocEfficiency {
0558 public:
0559   rocEfficiency(void);
0560   ~rocEfficiency(void);
0561   void addPixel(int layer, int ladder, int module, int roc);
0562   float getRoc(int layer, int ladder, int module, int roc);
0563   float getModule(int layer, int ladder, int module, float &half1, float &half2);
0564   //int analyzeModule(int layer, int ladder, int module);
0565 
0566   // return array index
0567   inline int transformLadder1(int ladder) {
0568     if (ladder > 10 || ladder < -10 || ladder == 0) {
0569       edm::LogPrint("TestClusters") << " wrong ladder-1 id " << ladder << edm::LogPrint("TestClusters");
0570       return (-1);
0571     }
0572     if (ladder < 0)
0573       return (ladder + 10);
0574     else
0575       return (ladder + 10 - 1);
0576   };
0577   inline int transformLadder2(int ladder) {
0578     if (ladder > 16 || ladder < -16 || ladder == 0) {
0579       edm::LogPrint("TestClusters") << " wrong ladder-2 id " << ladder << edm::LogPrint("TestClusters");
0580       return (-1);
0581     }
0582     if (ladder < 0)
0583       return (ladder + 16);
0584     else
0585       return (ladder + 16 - 1);
0586   };
0587   inline int transformLadder3(int ladder) {
0588     if (ladder > 22 || ladder < -22 || ladder == 0) {
0589       edm::LogPrint("TestClusters") << " wrong ladder-3 id " << ladder << edm::LogPrint("TestClusters");
0590       return (-1);
0591     }
0592     if (ladder < 0)
0593       return (ladder + 22);
0594     else
0595       return (ladder + 22 - 1);
0596   };
0597   inline int transformModule(int module) {
0598     if (module > 4 || module < -4 || module == 0) {
0599       edm::LogPrint("TestClusters") << " wrong module id " << module << edm::LogPrint("TestClusters");
0600       return (-1);
0601     }
0602     if (module < 0)
0603       return (module + 4);
0604     else
0605       return (module + 4 - 1);
0606   };
0607 
0608 private:
0609   int pixelsLayer1[20][8][16];
0610   int pixelsLayer2[32][8][16];
0611   int pixelsLayer3[44][8][16];
0612 };
0613 
0614 rocEfficiency::rocEfficiency(void) {
0615   edm::LogPrint("TestClusters") << " clear";
0616   for (int lad1 = 0; lad1 < 20; ++lad1)
0617     for (int mod1 = 0; mod1 < 8; ++mod1)
0618       for (int roc1 = 0; roc1 < 16; ++roc1)
0619         pixelsLayer1[lad1][mod1][roc1] = 0;
0620 
0621   for (int lad2 = 0; lad2 < 32; ++lad2)
0622     for (int mod2 = 0; mod2 < 8; ++mod2)
0623       for (int roc2 = 0; roc2 < 16; ++roc2)
0624         pixelsLayer2[lad2][mod2][roc2] = 0;
0625 
0626   for (int lad3 = 0; lad3 < 44; ++lad3)
0627     for (int mod3 = 0; mod3 < 8; ++mod3)
0628       for (int roc3 = 0; roc3 < 16; ++roc3)
0629         pixelsLayer3[lad3][mod3][roc3] = 0;
0630 }
0631 
0632 rocEfficiency::~rocEfficiency(void) {
0633   //   edm::LogPrint("TestClusters")<<" clear"<<endl;
0634   //   for(int lad1=0;lad1<20;++lad1)
0635   //     for(int mod1=0;mod1<8;++mod1)
0636   //       for(int col1=0;col1<416;++col1)
0637   //      for(int row1=0;row1<160;++row1)
0638   //        if(pixelsLayer1[lad1][mod1][col1][row1]>0)
0639   //          edm::LogPrint("TestClusters")<<lad1<<" "<<mod1<<" "<<col1<<" "<<row1<<" "
0640   //              <<pixelsLayer1[lad1][mod1][col1][row1] <<endl;
0641 }
0642 
0643 void rocEfficiency::addPixel(int layer, int ladder, int module, int roc) {
0644   if (roc < 0 || roc >= 16) {
0645     edm::LogPrint("TestClusters") << " wrong roc number " << roc;
0646     return;
0647   }
0648 
0649   int module0 = transformModule(module);
0650   if (module0 < 0 || module0 >= 8) {
0651     edm::LogPrint("TestClusters") << " wrong module index " << module0 << " " << module;
0652     return;
0653   }
0654 
0655   int ladder0 = 0;
0656   switch (layer) {
0657     case 1:
0658       ladder0 = transformLadder1(ladder);
0659       //edm::LogPrint("TestClusters")<<layer<<" "<<ladder0<<" "<<module0<<" "<<col<<" "<<row<<endl;
0660       if (ladder0 < 0 || ladder0 >= 20)
0661         edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0662       else
0663         pixelsLayer1[ladder0][module0][roc]++;
0664       break;
0665     case 2:
0666       ladder0 = transformLadder2(ladder);
0667       if (ladder0 < 0 || ladder0 >= 32)
0668         edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0669       else
0670         pixelsLayer2[ladder0][module0][roc]++;
0671       break;
0672     case 3:
0673       ladder0 = transformLadder3(ladder);
0674       if (ladder0 < 0 || ladder0 >= 44)
0675         edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0676       else
0677         pixelsLayer3[ladder0][module0][roc]++;
0678       break;
0679     default:
0680       break;
0681   }
0682 }
0683 
0684 float rocEfficiency::getRoc(int layer, int ladder, int module, int roc) {
0685   if (roc < 0 || roc >= 16) {
0686     edm::LogPrint("TestClusters") << " wrong roc number " << roc;
0687     return -1.;
0688   }
0689   int module0 = transformModule(module);
0690   if (module0 < 0 || module0 >= 8) {
0691     edm::LogPrint("TestClusters") << " wrong module index " << module0 << " " << module;
0692     return -1.;
0693   }
0694 
0695   float count = 0.;
0696   int ladder0 = 0;
0697 
0698   switch (layer) {
0699     case 1:
0700       if ((abs(ladder) == 1 || abs(ladder) == 10) && roc > 7) {  // find half modules
0701         count = -1.;                                             // invalid
0702       } else {
0703         ladder0 = transformLadder1(ladder);
0704         if (ladder0 < 0 || ladder0 >= 20) {
0705           edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0706           count = -1.;
0707         } else
0708           count = float(pixelsLayer1[ladder0][module0][roc]);
0709         //if(ladder0==10 && module0==5 && col==9 && row==0) edm::LogPrint("TestClusters")<<count<<endl;
0710       }
0711       break;
0712     case 2:
0713       if ((abs(ladder) == 1 || abs(ladder) == 16) && roc > 7) {  // find half modules
0714         count = -1.;                                             // invalid
0715       } else {
0716         ladder0 = transformLadder2(ladder);
0717         if (ladder0 < 0 || ladder0 >= 32) {
0718           edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0719           count = -1.;
0720         } else
0721           count = float(pixelsLayer2[ladder0][module0][roc]);
0722       }
0723       break;
0724     case 3:
0725       if ((abs(ladder) == 1 || abs(ladder) == 22) && roc > 7) {  // find half modules
0726         count = -1;                                              // invalid
0727       } else {
0728         ladder0 = transformLadder3(ladder);
0729         if (ladder0 < 0 || ladder0 >= 44) {
0730           edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0731           count = -1.;
0732         } else
0733           count = float(pixelsLayer3[ladder0][module0][roc]);
0734       }
0735       break;
0736     default:
0737       break;
0738   }
0739   return count;
0740 }
0741 
0742 // Return counts averaged per ROC (count per module / number of full ROCs )
0743 float rocEfficiency::getModule(int layer, int ladder, int module, float &half1, float &half2) {
0744   half1 = 0;
0745   half2 = 0;
0746   int module0 = transformModule(module);
0747   if (module0 < 0 || module0 >= 8) {
0748     edm::LogPrint("TestClusters") << " wrong module index " << module0 << " " << module;
0749     return -1.;
0750   }
0751 
0752   float count = 0;
0753   int rocs = 0;
0754   int ladder0 = 0;
0755 
0756   switch (layer) {
0757     case 1:
0758       ladder0 = transformLadder1(ladder);
0759       if (ladder0 < 0 || ladder0 >= 20) {
0760         edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0761         return -1.;
0762       }
0763       for (int roc = 0; roc < 16; ++roc) {
0764         //if( !((abs(ladder)==1 || abs(ladder)==10) && roc>7) ) // treat half-modules
0765         float tmp = float(pixelsLayer1[ladder0][module0][roc]);
0766         count += tmp;
0767         if (roc < 8)
0768           half1 += tmp;
0769         else
0770           half2 += tmp;
0771         if (tmp > 0)
0772           rocs++;
0773       }
0774       break;
0775 
0776     case 2:
0777       ladder0 = transformLadder2(ladder);
0778       if (ladder0 < 0 || ladder0 >= 32) {
0779         edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0780         return -1.;
0781       }
0782       for (int roc = 0; roc < 16; ++roc) {
0783         //if( !((abs(ladder)==1 || abs(ladder)==22) && roc>7) ) // treat half-modules
0784         float tmp = float(pixelsLayer2[ladder0][module0][roc]);
0785         count += tmp;
0786         if (roc < 8)
0787           half1 += tmp;
0788         else
0789           half2 += tmp;
0790         if (tmp > 0)
0791           rocs++;
0792       }
0793       break;
0794 
0795     case 3:
0796       ladder0 = transformLadder3(ladder);
0797       if (ladder0 < 0 || ladder0 >= 44) {
0798         edm::LogPrint("TestClusters") << " wrong ladder index " << ladder0 << " " << ladder;
0799         return -1.;
0800       }
0801       for (int roc = 0; roc < 16; ++roc) {
0802         //if( !((abs(ladder)==1 || abs(ladder)==22) && roc>7) ) // treat half-modules
0803         float tmp = float(pixelsLayer3[ladder0][module0][roc]);
0804         count += tmp;
0805         if (roc < 8)
0806           half1 += tmp;
0807         else
0808           half2 += tmp;
0809         if (tmp > 0)
0810           rocs++;
0811       }
0812       break;
0813 
0814     default:
0815       break;
0816   }
0817   //edm::LogPrint("TestClusters")<<count<<" "<<rocs<<" "<<ladder<<" "<<module<<" "<<ladder0<<" "<<module0<<endl;
0818   if (rocs > 0)
0819     count = count / float(rocs);  // return counts per ROC (full rocs only)
0820   if (count < 0)
0821     edm::LogPrint("TestClusters") << " VERY VERY WRONG " << count;
0822   return count;
0823 }
0824 
0825 #endif
0826 
0827 //==========================================================================================
0828 
0829 class TestClusters : public edm::one::EDAnalyzer<edm::one::SharedResources> {
0830 public:
0831   explicit TestClusters(const edm::ParameterSet &conf);
0832   virtual ~TestClusters();
0833   virtual void analyze(const edm::Event &e, const edm::EventSetup &c) override;
0834   virtual void beginJob() override;
0835   virtual void endJob() override;
0836 
0837 private:
0838   //const static bool PRINT = false;
0839   bool PRINT;
0840   int select1, select2;
0841   int countEvents, countAllEvents;
0842   double sumClusters, sumPixels, countLumi;
0843   //float rocHits[3][10]; // layer, ids, store hits in 30 rocs
0844   //float moduleHits[3][10]; // layer, ids, store hits in 30 modules
0845 
0846   // Needed for the ByToken method
0847   edm::EDGetTokenT<edmNew::DetSetVector<SiPixelCluster> > myClus;
0848   edm::EDGetTokenT<LumiSummary> lumiSummaryToken_;
0849   edm::EDGetTokenT<LumiDetails> lumiDetailsToken_;
0850   edm::EDGetTokenT<edm::ConditionsInLumiBlock> condToken_;
0851   edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> l1gtrrToken_;
0852   edm::EDGetTokenT<Level1TriggerScalersCollection> l1tsToken_;
0853   edm::EDGetTokenT<edm::TriggerResults> hltToken_;
0854   edm::EDGetTokenT<reco::VertexCollection> vtxToken_;
0855 
0856   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> trackerTopoToken_;
0857   edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> trackerGeomToken_;
0858 
0859   //TFile* hFile;
0860   TH1D *hdetunit;
0861   TH1D *hpixid, *hpixsubid, *hlayerid, *hladder1id, *hladder2id, *hladder3id, *hz1id, *hz2id, *hz3id;
0862 
0863   TH1D *hcharge1, *hcharge2, *hcharge3, *hcharge4, *hcharge5;
0864   //TH1D *hcharge11,*hcharge12, *hcharge13, *hcharge14;
0865   TH1D *hpixcharge1, *hpixcharge2, *hpixcharge3, *hpixcharge4, *hpixcharge5;
0866   //TH1D *hcols1,*hcols2,*hcols3,*hrows1,*hrows2,*hrows3;
0867   TH1D *hpcols1, *hpcols2, *hpcols3, *hprows1, *hprows2, *hprows3;
0868   TH1D *hsize1, *hsize2, *hsize3, *hsizex1, *hsizex2, *hsizex3, *hsizey1, *hsizey2, *hsizey3;
0869   //TH1D *havCharge1,*havCharge2,*havCharge3,*havCharge4,*havCharge5,*havCharge6;
0870   //TH1D *hchargen1,*hsizen1, *hsizexn1, *hsizeyn1, *hpixchargen1;
0871   //TH1D *hchargen2,*hsizen2, *hsizexn2, *hsizeyn2, *hpixchargen2;
0872   //TH1D *hchargen3,*hchargen4;
0873   //TH2D *hchargen5;
0874 
0875 #if defined(BX) || defined(BX_NEW)
0876   TH1D *hchargebx1, *hchargebx2, *hchargebx3, *hchargebx4, *hchargebx5, *hchargebx6;
0877   TH1D *hpixChargebx1, *hpixChargebx2, *hpixChargebx3, *hpixChargebx4, *hpixChargebx5, *hpixChargebx6;
0878   TH1D *hsizebx1, *hsizebx2, *hsizebx3, *hsizebx4, *hsizebx5, *hsizebx6;
0879 
0880 #endif
0881 
0882   TH1D *hclusPerDet1, *hclusPerDet2, *hclusPerDet3;
0883   TH1D *hpixPerDet1, *hpixPerDet2, *hpixPerDet3;
0884   TH1D *hpixPerLink1, *hpixPerLink2, *hpixPerLink3;
0885   TH1D *hclusPerLay1, *hclusPerLay2, *hclusPerLay3;
0886   TH1D *hpixPerLay1, *hpixPerLay2, *hpixPerLay3;
0887   TH1D *hdetsPerLay1, *hdetsPerLay2, *hdetsPerLay3;
0888   TH1D *hclus, *hclusBPix, *hclusFPix, *hdigis, *hdigis2, *hdigisB, *hdigisF;
0889   //TH1D *hdigis30,*hdigis31,*hdigis32,*hdigis33,*hdigis34,*hdigis35,*hdigis36,*hdigis37,*hdigis38,
0890   //*hdigis39,*hdigis7,*hdigis18,*hdigis25,*hdigis26;
0891   TH1D *hclus2, *hclus5;  // *hclus6,*hclus7,*hclus8,*hclus9;
0892   //*hclus10,*hclus11,*hclus12,*hclus13,*hclus14,*hclus15,*hclus16,*hclus17,*hclus18,*hclus19,
0893   TH1D *hdets, *hdets2;
0894 
0895   TH1D *hpixDiskR1, *hpixDiskR2;  // *hdetr, *hdetz;
0896 
0897   TH2F *hDetsMap1, *hDetsMap2, *hDetsMap3;  // all modules
0898   TH2F *hDetMap1, *hDetMap2, *hDetMap3;     // all modules
0899   TH2F *hpDetMap1, *hpDetMap2, *hpDetMap3;  // all modules
0900   TH2F *hsizeDetMap1, *hsizeDetMap2, *hsizeDetMap3;
0901   //TH2F *hsizeXDetMap1, *hsizeXDetMap2, *hsizeXDetMap3;
0902   //TH2F *hsizeYDetMap1, *hsizeYDetMap2, *hsizeYDetMap3;
0903 
0904   TH2F *hpixDetMap1, *hpixDetMap2, *hpixDetMap3;  // in a  modules
0905   TH2F *hcluDetMap1, *hcluDetMap2, *hcluDetMap3;  // in a  modules
0906 
0907   //TH1D *hncharge1,*hncharge2, *hncharge3;
0908   //TH1D *hnpixcharge1,*hnpixcharge2,*hnpixcharge3;
0909 
0910   TH2F *hpixDetMap10, *hpixDetMap20, *hpixDetMap30;
0911   TH2F *hpixDetMap11, *hpixDetMap12, *hpixDetMap13, *hpixDetMap14, *hpixDetMap15;
0912   TH2F *hpixDetMap21, *hpixDetMap22, *hpixDetMap23, *hpixDetMap24, *hpixDetMap25;
0913   TH2F *hpixDetMap31, *hpixDetMap32, *hpixDetMap33, *hpixDetMap34, *hpixDetMap35;
0914   TH2F *hpixDetMap16, *hpixDetMap17, *hpixDetMap18, *hpixDetMap19;
0915   TH2F *hpixDetMap26, *hpixDetMap27, *hpixDetMap28, *hpixDetMap29;
0916   TH2F *hpixDetMap36, *hpixDetMap37, *hpixDetMap38, *hpixDetMap39;
0917 
0918   //TH2F *h2d1, *h2d2, *h2d3;
0919 
0920   TH1D *hevent, *hlumi, *hlumi0, *hlumi1, *hlumi10, *hlumi11, *hlumi12, *hlumi13,
0921       *hlumi14;  //  *hlumi15, *hlumi16, *hlumi17, *hlumi18, *hlumi19;
0922   TH1D *hbx, *hbx0, *hbx1, *hbx2, *hbx3, *hbx4, *hbx5, *hbx6, *hbx7;  // *hbx8,*hbx9,*hbx10; // *hbx11,*hbx12;
0923   TH1D *hmaxPixPerDet;
0924 
0925   TH1D *hclusPerDisk1, *hclusPerDisk2, *hclusPerDisk3, *hclusPerDisk4;
0926   TH1D *hpixPerDisk1, *hpixPerDisk2, *hpixPerDisk3, *hpixPerDisk4;
0927   TH1D *hl1a, *hl1t, *hltt;
0928   TH1D *hl1a1, *hl1t1;
0929   TH1D *hlt1, *hlt2, *hlt3;
0930 
0931   TH1D *hpixPerDet11, *hpixPerDet12, *hpixPerDet13, *hpixPerDet14;
0932   TH1D *hpixPerDet21, *hpixPerDet22, *hpixPerDet23, *hpixPerDet24;
0933   TH1D *hpixPerDet31, *hpixPerDet32, *hpixPerDet33, *hpixPerDet34;
0934   //TH1D *hpixPerDet100,*hpixPerDet101,*hpixPerDet102,*hpixPerDet103,*hpixPerDet104,*hpixPerDet105;
0935 
0936   TH1D *hgz1, *hgz2, *hgz3;
0937   //TH2F *hclusls2, *hpixls2, *h2clupv, *h2pixpv;
0938   TH1D *hintg, *hinst, *hpvs;
0939 
0940 #ifdef USE_RESYNCS
0941   TH1D *htest1, *htest2, *htest3, *htest4, *htest5, *htest6;
0942 #endif
0943 
0944   TProfile *hclumult1, *hclumult2, *hclumult3;
0945   TProfile *hclumultx1, *hclumultx2, *hclumultx3;
0946   TProfile *hclumulty1, *hclumulty2, *hclumulty3;
0947   TProfile *hcluchar1, *hcluchar2, *hcluchar3;
0948   TProfile *hpixchar1, *hpixchar2, *hpixchar3;
0949   TProfile *hclusls, *hpixls, *hinstls, *hinstlsbx;
0950   TProfile *hpvls, *hclupv, *hpixpv;  //  *hclupvlsn, *hpixpvlsn;
0951   TProfile *hcharCluls, *hcharPixls, *hsizeCluls, *hsizeXCluls;
0952   TProfile *hpixbx, *hclubx, *hpvbx, *hcharClubx, *hcharPixbx, *hsizeClubx, *hsizeYClubx;
0953   TProfile *hinstbx;
0954   TProfile *hcharCluLumi, *hcharPixLumi, *hsizeCluLumi, *hsizeXCluLumi, *hsizeYCluLumi;
0955 
0956   TProfile *hcluLumi, *hpixLumi;
0957 
0958   //TProfile *hclus13ls,*hclus23ls,*hclus12ls,*hclusf3ls;
0959   //TProfile *hclusbx1lsn,*hclusbx2lsn,*hclusbx3lsn,*hclusbx4lsn,*hclusbx5lsn,*hclusbx6lsn,*hclusbx7lsn,
0960   //*hclusbx8lsn,*hclusbx9lsn;
0961   //TProfile *hclusbx11lsn,*hclusbx12lsn,*hclusbx13lsn,*hclusbx14lsn,*hclusbx15lsn,*hclusbx16lsn,*hclusbx17lsn,
0962   //*hclusbx18lsn,*hclusbx19lsn;
0963 
0964 #ifdef INSTLUMI_STUDIES
0965   TProfile *hcluslsn, *hpixlsn;
0966   TProfile *hpixbl, *hpixb1l, *hpixb2l, *hpixb3l, *hpixfl, *hpixfml, *hpixfpl;
0967   TProfile *hclusbl, *hclusb1l, *hclusb2l, *hclusb3l, *hclusfl, *hclusfml, *hclusfpl;
0968   TProfile *hpixbxn, *hclubxn, *hpvbxn;
0969 #endif
0970 
0971 #ifdef VDM_STUDIES
0972   TProfile *hcharCluls1, *hcharPixls1, *hsizeCluls1, *hsizeXCluls1;
0973   TProfile *hcharCluls2, *hcharPixls2, *hsizeCluls2, *hsizeXCluls2;
0974   TProfile *hcharCluls3, *hcharPixls3, *hsizeCluls3, *hsizeXCluls3;
0975   TProfile *hclusls1, *hpixls1, *hclusls2, *hpixls2, *hclusls3, *hpixls3;
0976 #endif
0977 
0978 #ifdef ROC_EFF
0979   rocEfficiency *pixEff;
0980 
0981   TH2F *hbadMap1, *hbadMap2, *hbadMap3;  // modules with bad rocs
0982   TH2F *hrocHits1ls, *hrocHits2ls, *hrocHits3ls, *hmoduleHits1ls, *hmoduleHits2ls, *hmoduleHits3ls;
0983   TH1D *hcountInRoc1, *hcountInRoc2, *hcountInRoc3, *hcountInRoc12, *hcountInRoc22, *hcountInRoc32;
0984 #endif
0985 
0986 #ifdef BX
0987   getBX *getbx;
0988 #endif
0989 
0990   // To correct lumi
0991   LumiCorrector *lumiCorrector;
0992 };
0993 
0994 /////////////////////////////////////////////////////////////////
0995 // Contructor, empty.
0996 TestClusters::TestClusters(edm::ParameterSet const &conf) {
0997   usesResource(TFileService::kSharedResource);
0998   PRINT = conf.getUntrackedParameter<bool>("Verbosity", false);
0999   select1 = conf.getUntrackedParameter<int>("Select1", 0);
1000   select2 = conf.getUntrackedParameter<int>("Select2", 0);
1001   if (PRINT)
1002     edm::LogPrint("TestClusters") << " Construct ";
1003 
1004   // For the ByToken method
1005   myClus = consumes<edmNew::DetSetVector<SiPixelCluster> >(conf.getParameter<edm::InputTag>("src"));
1006   lumiSummaryToken_ = consumes<LumiSummary>(edm::InputTag("lumiProducer"));
1007   lumiDetailsToken_ = consumes<LumiDetails>(edm::InputTag("lumiProducer"));
1008   condToken_ = consumes<edm::ConditionsInLumiBlock>(edm::InputTag("conditionsInEdm"));
1009   l1gtrrToken_ = consumes<L1GlobalTriggerReadoutRecord>(edm::InputTag("gtDigis"));
1010   l1tsToken_ = consumes<Level1TriggerScalersCollection>(edm::InputTag("scalersRawToDigi"));
1011   hltToken_ = consumes<edm::TriggerResults>(edm::InputTag("TriggerResults", "", "HLT"));
1012   vtxToken_ = consumes<reco::VertexCollection>(edm::InputTag("offlinePrimaryVertices"));
1013   trackerTopoToken_ = esConsumes<TrackerTopology, TrackerTopologyRcd>();
1014   trackerGeomToken_ = esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>();
1015 }
1016 // Virtual destructor needed.
1017 TestClusters::~TestClusters() = default;
1018 
1019 // ------------ method called at the begining   ------------
1020 void TestClusters::beginJob() {
1021   edm::LogPrint("TestClusters") << "Initialize PixelClusterTest ";
1022 
1023   edm::Service<TFileService> fs;
1024 
1025   //=====================================================================
1026 
1027   hladder1id = fs->make<TH1D>("hladder1id", "Ladder L1 id", 23, -11.5, 11.5);
1028   hladder2id = fs->make<TH1D>("hladder2id", "Ladder L2 id", 35, -17.5, 17.5);
1029   hladder3id = fs->make<TH1D>("hladder3id", "Ladder L3 id", 47, -23.5, 23.5);
1030   hz1id = fs->make<TH1D>("hz1id", "Z-index id L1", 11, -5.5, 5.5);
1031   hz2id = fs->make<TH1D>("hz2id", "Z-index id L2", 11, -5.5, 5.5);
1032   hz3id = fs->make<TH1D>("hz3id", "Z-index id L3", 11, -5.5, 5.5);
1033 
1034   int sizeH = 200;
1035   float lowH = -0.5;
1036   float highH = 199.5;
1037 
1038   hclusPerDet1 = fs->make<TH1D>("hclusPerDet1", "Clus per det l1", sizeH, lowH, highH);
1039   hclusPerDet2 = fs->make<TH1D>("hclusPerDet2", "Clus per det l2", sizeH, lowH, highH);
1040   hclusPerDet3 = fs->make<TH1D>("hclusPerDet3", "Clus per det l3", sizeH, lowH, highH);
1041 
1042   sizeH = 1000;
1043   highH = 1999.5;
1044   hpixPerDet1 = fs->make<TH1D>("hpixPerDet1", "Pix per det l1", sizeH, lowH, highH);
1045   hpixPerDet2 = fs->make<TH1D>("hpixPerDet2", "Pix per det l2", sizeH, lowH, highH);
1046   hpixPerDet3 = fs->make<TH1D>("hpixPerDet3", "Pix per det l3", sizeH, lowH, highH);
1047 
1048   hpixPerDet11 = fs->make<TH1D>("hpixPerDet11", "Pix per det l1 - ring 1", sizeH, lowH, highH);
1049   hpixPerDet12 = fs->make<TH1D>("hpixPerDet12", "Pix per det l1 - ring 2", sizeH, lowH, highH);
1050   hpixPerDet13 = fs->make<TH1D>("hpixPerDet13", "Pix per det l1 - ring 3", sizeH, lowH, highH);
1051   hpixPerDet14 = fs->make<TH1D>("hpixPerDet14", "Pix per det l1 - ring 4", sizeH, lowH, highH);
1052   hpixPerDet21 = fs->make<TH1D>("hpixPerDet21", "Pix per det l2 - ring 1", sizeH, lowH, highH);
1053   hpixPerDet22 = fs->make<TH1D>("hpixPerDet22", "Pix per det l2 - ring 2", sizeH, lowH, highH);
1054   hpixPerDet23 = fs->make<TH1D>("hpixPerDet23", "Pix per det l2 - ring 3", sizeH, lowH, highH);
1055   hpixPerDet24 = fs->make<TH1D>("hpixPerDet24", "Pix per det l2 - ring 4", sizeH, lowH, highH);
1056   hpixPerDet31 = fs->make<TH1D>("hpixPerDet31", "Pix per det l3 - ring 1", sizeH, lowH, highH);
1057   hpixPerDet32 = fs->make<TH1D>("hpixPerDet32", "Pix per det l3 - ring 2", sizeH, lowH, highH);
1058   hpixPerDet33 = fs->make<TH1D>("hpixPerDet33", "Pix per det l3 - ring 3", sizeH, lowH, highH);
1059   hpixPerDet34 = fs->make<TH1D>("hpixPerDet34", "Pix per det l3 - ring 4", sizeH, lowH, highH);
1060 
1061   //   hpixPerDet100 = fs->make<TH1D>( "hpixPerDet100", "Pix per det",
1062   //                sizeH, lowH, highH);
1063   //   hpixPerDet101 = fs->make<TH1D>( "hpixPerDet101", "Pix per det",
1064   //                sizeH, lowH, highH);
1065   //   hpixPerDet102 = fs->make<TH1D>( "hpixPerDet102", "Pix per det",
1066   //                sizeH, lowH, highH);
1067   //   hpixPerDet103 = fs->make<TH1D>( "hpixPerDet103", "Pix per det",
1068   //                sizeH, lowH, highH);
1069   //   hpixPerDet104 = fs->make<TH1D>( "hpixPerDet104", "Pix per det",
1070   //                sizeH, lowH, highH);
1071   //   hpixPerDet105 = fs->make<TH1D>( "hpixPerDet105", "Pix per det",
1072   //                sizeH, lowH, highH);
1073 
1074   sizeH = 1000;
1075   highH = 999.5;
1076   hpixPerLink1 = fs->make<TH1D>("hpixPerLink1", "Pix per link l1", sizeH, lowH, highH);
1077   hpixPerLink2 = fs->make<TH1D>("hpixPerLink2", "Pix per link l2", sizeH, lowH, highH);
1078   hpixPerLink3 = fs->make<TH1D>("hpixPerLink3", "Pix per link l3", sizeH, lowH, highH);
1079 
1080   sizeH = 5000;
1081 #ifdef HI
1082   highH = 19999.5;
1083 #else
1084   highH = 4999.5;
1085 #endif
1086 
1087   hclusPerLay1 = fs->make<TH1D>("hclusPerLay1", "Clus per layer l1", sizeH, lowH, highH);
1088   hclusPerLay2 = fs->make<TH1D>("hclusPerLay2", "Clus per layer l2", sizeH, lowH, highH);
1089   hclusPerLay3 = fs->make<TH1D>("hclusPerLay3", "Clus per layer l3", sizeH, lowH, highH);
1090 
1091   hclus = fs->make<TH1D>("hclus", "Clus per event", sizeH, lowH, 5. * highH);
1092   hclusBPix = fs->make<TH1D>("hclusBPix", "Bpix Clus per event", sizeH, lowH, 4. * highH);
1093   hclusFPix = fs->make<TH1D>("hclusFPix", "Fpix Clus per event", sizeH, lowH, 2. * highH);
1094 
1095 #ifdef HI
1096   highH = 3999.5;
1097 #else
1098   highH = 1999.5;
1099 #endif
1100 
1101   hclusPerDisk1 = fs->make<TH1D>("hclusPerDisk1", "Clus per disk1", sizeH, lowH, highH);
1102   hclusPerDisk2 = fs->make<TH1D>("hclusPerDisk2", "Clus per disk2", sizeH, lowH, highH);
1103   hclusPerDisk3 = fs->make<TH1D>("hclusPerDisk3", "Clus per disk3", sizeH, lowH, highH);
1104   hclusPerDisk4 = fs->make<TH1D>("hclusPerDisk4", "Clus per disk4", sizeH, lowH, highH);
1105 
1106 #ifdef HI
1107   highH = 9999.5;
1108 #else
1109   highH = 3999.5;
1110 #endif
1111 
1112   hpixPerDisk1 = fs->make<TH1D>("hpixPerDisk1", "Pix per disk1", sizeH, lowH, highH);
1113   hpixPerDisk2 = fs->make<TH1D>("hpixPerDisk2", "Pix per disk2", sizeH, lowH, highH);
1114   hpixPerDisk3 = fs->make<TH1D>("hpixPerDisk3", "Pix per disk3", sizeH, lowH, highH);
1115   hpixPerDisk4 = fs->make<TH1D>("hpixPerDisk4", "Pix per disk4", sizeH, lowH, highH);
1116 
1117   sizeH = 2000;
1118 #ifdef HI
1119   highH = 99999.5;
1120 #else
1121   highH = 19999.5;
1122 #endif
1123 
1124   hpixPerLay1 = fs->make<TH1D>("hpixPerLay1", "Pix per layer l1", sizeH, lowH, highH);
1125   hpixPerLay2 = fs->make<TH1D>("hpixPerLay2", "Pix per layer l2", sizeH, lowH, highH);
1126   hpixPerLay3 = fs->make<TH1D>("hpixPerLay3", "Pix per layer l3", sizeH, lowH, highH);
1127 
1128   hdigis = fs->make<TH1D>("hdigis", "All Digis in clus per event", sizeH, lowH, 5. * highH);
1129   hdigisB = fs->make<TH1D>("hdigisB", "BPix Digis in clus per event", sizeH, lowH, 4. * highH);
1130   hdigisF = fs->make<TH1D>("hdigisF", "FPix Digis in clus per event", sizeH, lowH, 2. * highH);
1131   hdigis2 = fs->make<TH1D>("hdigis2", "Digis per event - zoomed", 1000, -0.5, 999.5);
1132 
1133   //#ifdef BX
1134   //   hdigis30 = fs->make<TH1D>("hdigis30","Digis",sizeH,lowH,4.*highH);
1135   //   hdigis31 = fs->make<TH1D>("hdigis31","Digis",sizeH,lowH,4.*highH);
1136   //   hdigis32 = fs->make<TH1D>("hdigis32","Digis",sizeH,lowH,4.*highH);
1137   //   hdigis33 = fs->make<TH1D>("hdigis33","Digis",sizeH,lowH,4.*highH);
1138   //   hdigis34 = fs->make<TH1D>("hdigis34","Digis",sizeH,lowH,4.*highH);
1139   //   hdigis35 = fs->make<TH1D>("hdigis35","Digis",sizeH,lowH,4.*highH);
1140   //   hdigis36 = fs->make<TH1D>("hdigis36","Digis",sizeH,lowH,4.*highH);
1141   //   hdigis37 = fs->make<TH1D>("hdigis37","Digis",sizeH,lowH,4.*highH);
1142   //   hdigis38 = fs->make<TH1D>("hdigis38","Digis",sizeH,lowH,4.*highH);
1143   //   hdigis39 = fs->make<TH1D>("hdigis39","Digis",sizeH,lowH,4.*highH);
1144   //   hdigis7 = fs->make<TH1D>("hdigis7","Digis",sizeH,lowH,4.*highH);
1145   //   hdigis18 = fs->make<TH1D>("hdigis18","Digis",sizeH,lowH,4.*highH);
1146   //   hdigis25 = fs->make<TH1D>("hdigis25","Digis",sizeH,lowH,4.*highH);
1147   //   hdigis26 = fs->make<TH1D>("hdigis26","Digis",sizeH,lowH,4.*highH);
1148   //#endif
1149 
1150   sizeH = 1000;
1151 #ifdef HI
1152   highH = 19999.5;
1153 #else
1154   highH = 4999.5;
1155 #endif
1156 
1157   hclus2 = fs->make<TH1D>("hclus2", "Clus per event - zoomed", 1000, -0.5, 999.5);
1158   //hclus3 = fs->make<TH1D>( "hclus3", "Clus per event",sizeH, lowH, highH);
1159   //hclus4 = fs->make<TH1D>( "hclus4", "Clus per event",sizeH, lowH, highH);
1160   hclus5 = fs->make<TH1D>("hclus5", "Clus per event", sizeH, lowH, highH);
1161   //hclus6 = fs->make<TH1D>( "hclus6", "Clus per event",sizeH, lowH, highH);
1162   //hclus7 = fs->make<TH1D>( "hclus7", "Clus per event",sizeH, lowH, highH);
1163   //hclus8 = fs->make<TH1D>( "hclus8", "Clus per event",sizeH, lowH, highH);
1164   //hclus9 = fs->make<TH1D>( "hclus9", "Clus per event",sizeH, lowH, highH);
1165   //hclus10 = fs->make<TH1D>( "hclus10", "Clus per event",
1166   //            sizeH, lowH, highH);
1167 
1168   // #ifdef BX
1169   //   hclus30=fs->make<TH1D>("hclus30","Clus per event",sizeH, lowH, highH);
1170   //   hclus31=fs->make<TH1D>("hclus31","Clus per event",sizeH, lowH, highH);
1171   //   hclus32=fs->make<TH1D>("hclus32","Clus per event",sizeH, lowH, highH);
1172   //   hclus33=fs->make<TH1D>("hclus33","Clus per event",sizeH, lowH, highH);
1173   //   hclus34=fs->make<TH1D>("hclus34","Clus per event",sizeH, lowH, highH);
1174   //   hclus35=fs->make<TH1D>("hclus35","Clus per event",sizeH, lowH, highH);
1175   //   hclus36=fs->make<TH1D>("hclus36","Clus per event",sizeH, lowH, highH);
1176   //   hclus37=fs->make<TH1D>("hclus37","Clus per event",sizeH, lowH, highH);
1177   //   hclus38=fs->make<TH1D>("hclus38","Clus per event",sizeH, lowH, highH);
1178   //   hclus39=fs->make<TH1D>("hclus39","Clus per event",sizeH, lowH, highH);
1179   // #endif
1180 
1181   hdetsPerLay1 = fs->make<TH1D>("hdetsPerLay1", "Full dets per layer l1", 161, -0.5, 160.5);
1182   hdetsPerLay3 = fs->make<TH1D>("hdetsPerLay3", "Full dets per layer l3", 353, -0.5, 352.5);
1183   hdetsPerLay2 = fs->make<TH1D>("hdetsPerLay2", "Full dets per layer l2", 257, -0.5, 256.5);
1184 
1185   hdets2 = fs->make<TH1D>("hdets2", "Dets per event", 2000, 0.5, 1999.5);
1186   hdets = fs->make<TH1D>("hdets", "Dets per event", 2000, -0.5, 1999.5);
1187   hmaxPixPerDet = fs->make<TH1D>("hmaxPixPerDet", "Max pixels per det", 1000, -0.5, 999.5);
1188 
1189   sizeH = 400;
1190   lowH = 0.;
1191   highH = 100.0;                                                             // charge limit in kelec
1192   hcharge1 = fs->make<TH1D>("hcharge1", "Clu charge l1", sizeH, 0., highH);  //in ke
1193   hcharge2 = fs->make<TH1D>("hcharge2", "Clu charge l2", sizeH, 0., highH);
1194   hcharge3 = fs->make<TH1D>("hcharge3", "Clu charge l3", sizeH, 0., highH);
1195   hcharge4 = fs->make<TH1D>("hcharge4", "Clu charge d1", sizeH, 0., highH);
1196   hcharge5 = fs->make<TH1D>("hcharge5", "Clu charge d2", sizeH, 0., highH);
1197   //hchargen = fs->make<TH1D>( "hchargen", "Clu charge", sizeH, 0.,highH);
1198   //hchargen1 = fs->make<TH1D>( "hchargen1", "Clu charge", sizeH, 0.,highH);
1199   //hchargen2 = fs->make<TH1D>( "hchargen2", "Clu charge", sizeH, 0.,highH);
1200   //hchargen3 = fs->make<TH1D>( "hchargen3", "Clu charge", sizeH, 0.,highH);
1201   //hchargen4 = fs->make<TH1D>( "hchargen4", "Clu charge", sizeH, 0.,highH);
1202   //hchargen5 = fs->make<TH2D>( "hchargen5", "Clu charge-size", sizeH, 0.,highH,10,0.,10.);
1203 
1204   //havCharge1 = fs->make<TH1D>( "havCharge1", "Clu charge l1", sizeH, 0.,2.*highH); //in ke
1205   //havCharge2 = fs->make<TH1D>( "havCharge2", "Clu charge l2", sizeH, 0.,2.*highH);
1206   //havCharge3 = fs->make<TH1D>( "havCharge3", "Clu charge l3", 110, 0.,1.1);
1207   //havCharge4 = fs->make<TH1D>( "havCharge4", "Clu charge d1", sizeH, 0.,2.*highH);
1208   //havCharge5 = fs->make<TH1D>( "havCharge5", "Clu charge d2", sizeH, 0.,2.*highH);
1209   //havCharge6 = fs->make<TH1D>( "havCharge6", "Clu charge d2", sizeH, 0.,2.*highH);
1210 
1211   //hcharge11 = fs->make<TH1D>( "hcharge11", "Clu charge l1", sizeH, 0.,highH);
1212   //hcharge12 = fs->make<TH1D>( "hcharge12", "Clu charge l1", sizeH, 0.,highH);
1213   //hcharge13 = fs->make<TH1D>( "hcharge13", "Clu charge l1", sizeH, 0.,highH);
1214   //hcharge14 = fs->make<TH1D>( "hcharge14", "Clu charge l1", sizeH, 0.,highH);
1215 
1216 #if defined(BX) || defined(BX_NEW)
1217   hchargebx1 = fs->make<TH1D>("hchargebx1", "Clu charge", 100, 0., highH);          //in ke
1218   hchargebx2 = fs->make<TH1D>("hchargebx2", "Clu charge", 100, 0., highH);          //in ke
1219   hchargebx3 = fs->make<TH1D>("hchargebx3", "Clu charge", 100, 0., highH);          //in ke
1220   hchargebx4 = fs->make<TH1D>("hchargebx4", "Clu charge", 100, 0., highH);          //in ke
1221   hchargebx5 = fs->make<TH1D>("hchargebx5", "Clu charge", 100, 0., highH);          //in ke
1222   hchargebx6 = fs->make<TH1D>("hchargebx6", "Clu charge", 100, 0., highH);          //in ke
1223   sizeH = 300;                                                                      // 600
1224   highH = 60.0;                                                                     // charge limit in kelec
1225   hpixChargebx1 = fs->make<TH1D>("hpixChargebx1", "Pix charge", sizeH, 0., highH);  //in ke
1226   hpixChargebx2 = fs->make<TH1D>("hpixChargebx2", "Pix charge", sizeH, 0., highH);  //in ke
1227   hpixChargebx3 = fs->make<TH1D>("hpixChargebx3", "Pix charge", sizeH, 0., highH);  //in ke
1228   hpixChargebx5 = fs->make<TH1D>("hpixChargebx5", "Pix charge", sizeH, 0., highH);  //in ke
1229   hpixChargebx6 = fs->make<TH1D>("hpixChargebx6", "Pix charge", sizeH, 0., highH);  //in ke
1230 
1231   sizeH = 200;
1232   highH = 199.5;  // charge limit in kelec
1233   hsizebx1 = fs->make<TH1D>("hsizebx1", "clu size", sizeH, -0.5, highH);
1234   hsizebx2 = fs->make<TH1D>("hsizebx2", "clu size", sizeH, -0.5, highH);
1235   hsizebx3 = fs->make<TH1D>("hsizebx3", "clu size", sizeH, -0.5, highH);
1236   hsizebx5 = fs->make<TH1D>("hsizebx5", "clu size", sizeH, -0.5, highH);
1237   hsizebx6 = fs->make<TH1D>("hsizebx6", "clu size", sizeH, -0.5, highH);
1238 #endif
1239 
1240   sizeH = 300;                                                                     // 600
1241   highH = 60.0;                                                                    // charge limit in kelec
1242   hpixcharge1 = fs->make<TH1D>("hpixcharge1", "Pix charge l1", sizeH, 0., highH);  //in ke
1243   hpixcharge2 = fs->make<TH1D>("hpixcharge2", "Pix charge l2", sizeH, 0., highH);
1244   hpixcharge3 = fs->make<TH1D>("hpixcharge3", "Pix charge l3", sizeH, 0., highH);
1245   hpixcharge4 = fs->make<TH1D>("hpixcharge4", "Pix charge d1", sizeH, 0., highH);
1246   hpixcharge5 = fs->make<TH1D>("hpixcharge5", "Pix charge d2", sizeH, 0., highH);
1247   //hpixchargen = fs->make<TH1D>( "hpixchargen", "Pix charge",sizeH, 0.,highH);
1248   //hpixchargen1 = fs->make<TH1D>( "hpixchargen1", "Pix charge",sizeH, 0.,highH);
1249   //hpixchargen2 = fs->make<TH1D>( "hpixchargen2", "Pix charge",sizeH, 0.,highH);
1250 
1251   //hnpixcharge1 = fs->make<TH1D>( "hnpixcharge1", "Noise pix charge l1",sizeH, 0.,highH);
1252   //hnpixcharge2 = fs->make<TH1D>( "hnpixcharge2", "Noise pix charge l2",sizeH, 0.,highH);
1253   //hnpixcharge3 = fs->make<TH1D>( "hnpixcharge3", "Noise pix charge l3",sizeH, 0.,highH);
1254 
1255   //hcols1 = fs->make<TH1D>( "hcols1", "Layer 1 cols", 500,-0.5,499.5);
1256   //hcols2 = fs->make<TH1D>( "hcols2", "Layer 2 cols", 500,-0.5,499.5);
1257   //hcols3 = fs->make<TH1D>( "hcols3", "Layer 3 cols", 500,-0.5,499.5);
1258   //hrows1 = fs->make<TH1D>( "hrows1", "Layer 1 rows", 200,-0.5,199.5);
1259   //hrows2 = fs->make<TH1D>( "hrows2", "Layer 2 rows", 200,-0.5,199.5);
1260   //hrows3 = fs->make<TH1D>( "hrows3", "layer 3 rows", 200,-0.5,199.5);
1261 
1262   hpcols1 = fs->make<TH1D>("hpcols1", "Layer 1 pix cols", 500, -0.5, 499.5);
1263   hpcols2 = fs->make<TH1D>("hpcols2", "Layer 2 pix cols", 500, -0.5, 499.5);
1264   hpcols3 = fs->make<TH1D>("hpcols3", "Layer 3 pix cols", 500, -0.5, 499.5);
1265 
1266   hprows1 = fs->make<TH1D>("hprows1", "Layer 1 pix rows", 200, -0.5, 199.5);
1267   hprows2 = fs->make<TH1D>("hprows2", "Layer 2 pix rows", 200, -0.5, 199.5);
1268   hprows3 = fs->make<TH1D>("hprows3", "layer 3 pix rows", 200, -0.5, 199.5);
1269 
1270   sizeH = 1000;
1271   highH = 999.5;  // charge limit in kelec
1272   hsize1 = fs->make<TH1D>("hsize1", "layer 1 clu size", sizeH, -0.5, highH);
1273   hsize2 = fs->make<TH1D>("hsize2", "layer 2 clu size", sizeH, -0.5, highH);
1274   hsize3 = fs->make<TH1D>("hsize3", "layer 3 clu size", sizeH, -0.5, highH);
1275   //hsizen = fs->make<TH1D>( "hsizen", "clu size",sizeH,-0.5,highH);
1276   //hsizen1 = fs->make<TH1D>( "hsizen1", "clu size",sizeH,-0.5,highH);
1277   //hsizen2 = fs->make<TH1D>( "hsizen2", "clu size",sizeH,-0.5,highH);
1278 
1279   hsizex1 = fs->make<TH1D>("hsizex1", "lay1 clu size in x", 100, -0.5, 99.5);
1280   hsizex2 = fs->make<TH1D>("hsizex2", "lay2 clu size in x", 100, -0.5, 99.5);
1281   hsizex3 = fs->make<TH1D>("hsizex3", "lay3 clu size in x", 100, -0.5, 99.5);
1282   //hsizexn = fs->make<TH1D>( "hsizexn", "clu size in x",
1283   //          20,-0.5,19.5);
1284   // hsizexn1 = fs->make<TH1D>( "hsizexn1", "clu size in x",
1285   //              20,-0.5,19.5);
1286   // hsizexn2 = fs->make<TH1D>( "hsizexn2", "clu size in x",
1287   //              20,-0.5,19.5);
1288   hsizey1 = fs->make<TH1D>("hsizey1", "lay1 clu size in y", 100, -0.5, 99.5);
1289   hsizey2 = fs->make<TH1D>("hsizey2", "lay2 clu size in y", 100, -0.5, 99.5);
1290   hsizey3 = fs->make<TH1D>("hsizey3", "lay3 clu size in y", 100, -0.5, 99.5);
1291   //hsizeyn = fs->make<TH1D>( "hsizeyn", "lay3 clu size in y",
1292   //          30,-0.5,29.5);
1293   // hsizeyn1 = fs->make<TH1D>( "hsizeyn1", "lay3 clu size in y",
1294   //              30,-0.5,29.5);
1295   // hsizeyn2 = fs->make<TH1D>( "hsizeyn2", "lay3 clu size in y",
1296   //              30,-0.5,29.5);
1297 
1298   hpixDiskR1 = fs->make<TH1D>("hpixDiskR1", "pix vs. r, disk 1", 200, 0., 20.);
1299   hpixDiskR2 = fs->make<TH1D>("hpixDiskR2", "pix vs. r, disk 2", 200, 0., 20.);
1300 
1301   hevent = fs->make<TH1D>("hevent", "event", 100, 0, 10000000.);
1302   //horbit = fs->make<TH1D>("horbit","orbit",100, 0,100000000.);
1303 
1304   hlumi1 = fs->make<TH1D>("hlumi1", "lumi", 2000, 0, 2000.);
1305   hlumi0 = fs->make<TH1D>("hlumi0", "lumi", 2000, 0, 2000.);
1306   hlumi = fs->make<TH1D>("hlumi", "lumi", 2000, 0, 2000.);
1307   hlumi10 = fs->make<TH1D>("hlumi10", "lumi10", 2000, 0, 2000.);
1308   hlumi11 = fs->make<TH1D>("hlumi11", "lumi11", 2000, 0, 2000.);
1309   hlumi12 = fs->make<TH1D>("hlumi12", "lumi12", 2000, 0, 2000.);
1310   hlumi13 = fs->make<TH1D>("hlumi13", "lumi13", 2000, 0, 2000.);
1311   hlumi14 = fs->make<TH1D>("hlumi14", "lumi14", 2000, 0, 2000.);
1312   //hlumi15 = fs->make<TH1D>("hlumi15", "lumi15",   2000,0,2000.);
1313   //hlumi16 = fs->make<TH1D>("hlumi16", "lumi16",   2000,0,2000.);
1314   //hlumi17 = fs->make<TH1D>("hlumi17", "lumi17",   2000,0,2000.);
1315   //hlumi18 = fs->make<TH1D>("hlumi18", "lumi18",   2000,0,2000.);
1316   //hlumi19 = fs->make<TH1D>("hlumi19", "lumi19",   2000,0,2000.);
1317 
1318   //hbx11   = fs->make<TH1D>("hbx11",   "bx",   4000,0,4000.);
1319   // hbx10   = fs->make<TH1D>("hbx10",   "bx",   4000,0,4000.);
1320   // hbx9    = fs->make<TH1D>("hbx9",   "bx",   4000,0,4000.);
1321   // hbx8    = fs->make<TH1D>("hbx8",   "bx",   4000,0,4000.);
1322   // hbx7    = fs->make<TH1D>("hbx7",   "bx",   4000,0,4000.);
1323   hbx6 = fs->make<TH1D>("hbx6", "bx", 4000, 0, 4000.);
1324   hbx5 = fs->make<TH1D>("hbx5", "bx", 4000, 0, 4000.);
1325   hbx4 = fs->make<TH1D>("hbx4", "bx", 4000, 0, 4000.);
1326   hbx3 = fs->make<TH1D>("hbx3", "bx", 4000, 0, 4000.);
1327   hbx2 = fs->make<TH1D>("hbx2", "bx", 4000, 0, 4000.);
1328   hbx1 = fs->make<TH1D>("hbx1", "bx", 4000, 0, 4000.);
1329   hbx0 = fs->make<TH1D>("hbx0", "bx", 4000, 0, 4000.);
1330   hbx = fs->make<TH1D>("hbx", "bx", 4000, 0, 4000.);
1331 
1332   hl1a = fs->make<TH1D>("hl1a", "l1a", 128, -0.5, 127.5);
1333   hl1t = fs->make<TH1D>("hl1t", "l1t", 128, -0.5, 127.5);
1334   hltt = fs->make<TH1D>("hltt", "ltt", 128, -0.5, 127.5);
1335   hl1t1 = fs->make<TH1D>("hl1t1", "l1t1", 128, -0.5, 127.5);
1336   hl1a1 = fs->make<TH1D>("hl1a1", "l1a1", 128, -0.5, 127.5);
1337 
1338   //hmbits1 = fs->make<TH1D>("hmbits1","hmbits1",50,-0.5,49.5);
1339   //hmbits2 = fs->make<TH1D>("hmbits2","hmbits2",50,-0.5,49.5);
1340   //hmbits3 = fs->make<TH1D>("hmbits3","hmbits3",50,-0.5,49.5);
1341 
1342   hlt1 = fs->make<TH1D>("hlt1", "hlt1", 256, -0.5, 255.5);
1343   hlt2 = fs->make<TH1D>("hlt2", "hlt2", 256, -0.5, 255.5);
1344   hlt3 = fs->make<TH1D>("hlt3", "hlt3", 256, -0.5, 255.5);
1345 
1346   hgz1 = fs->make<TH1D>("hgz1", "layer1, clu global z", 600, -30., 30.);
1347   hgz2 = fs->make<TH1D>("hgz2", "layer2, clu global z", 600, -30., 30.);
1348   hgz3 = fs->make<TH1D>("hgz3", "layer3, clu global z", 600, -30., 30.);
1349 
1350 #ifdef USE_RESYNCS
1351   htest1 = fs->make<TH1D>("htest1", "test1", 1000, 0., 1000.);
1352   htest2 = fs->make<TH1D>("htest2", "test2", 1000, 0., 1000.);
1353   htest3 = fs->make<TH1D>("htest3", "test3", 1000, 0., 3.0E8);
1354   htest4 = fs->make<TH1D>("htest4", "test4", 1000, 0., 3.0E8);
1355 #endif
1356 
1357   // dets hit per event
1358   hDetsMap1 = fs->make<TH2F>("hDetsMap1", " ", 9, -4.5, 4.5, 21, -10.5, 10.5);
1359   hDetsMap1->SetOption("colz");
1360   hDetsMap2 = fs->make<TH2F>("hDetsMap2", " ", 9, -4.5, 4.5, 33, -16.5, 16.5);
1361   hDetsMap2->SetOption("colz");
1362   hDetsMap3 = fs->make<TH2F>("hDetsMap3", " ", 9, -4.5, 4.5, 45, -22.5, 22.5);
1363   hDetsMap3->SetOption("colz");
1364   // clus per det
1365   hDetMap1 = fs->make<TH2F>("hDetMap1", " ", 9, -4.5, 4.5, 21, -10.5, 10.5);
1366   hDetMap1->SetOption("colz");
1367   hDetMap2 = fs->make<TH2F>("hDetMap2", " ", 9, -4.5, 4.5, 33, -16.5, 16.5);
1368   hDetMap2->SetOption("colz");
1369   hDetMap3 = fs->make<TH2F>("hDetMap3", " ", 9, -4.5, 4.5, 45, -22.5, 22.5);
1370   hDetMap3->SetOption("colz");
1371   // pix per det
1372   hpDetMap1 = fs->make<TH2F>("hpDetMap1", " ", 9, -4.5, 4.5, 21, -10.5, 10.5);
1373   hpDetMap1->SetOption("colz");
1374   hpDetMap2 = fs->make<TH2F>("hpDetMap2", " ", 9, -4.5, 4.5, 33, -16.5, 16.5);
1375   hpDetMap2->SetOption("colz");
1376   hpDetMap3 = fs->make<TH2F>("hpDetMap3", " ", 9, -4.5, 4.5, 45, -22.5, 22.5);
1377   hpDetMap3->SetOption("colz");
1378 
1379   hsizeDetMap1 = fs->make<TH2F>("hsizeDetMap1", " ", 9, -4.5, 4.5, 21, -10.5, 10.5);
1380   hsizeDetMap1->SetOption("colz");
1381   hsizeDetMap2 = fs->make<TH2F>("hsizeDetMap2", " ", 9, -4.5, 4.5, 33, -16.5, 16.5);
1382   hsizeDetMap2->SetOption("colz");
1383   hsizeDetMap3 = fs->make<TH2F>("hsizeDetMap3", " ", 9, -4.5, 4.5, 45, -22.5, 22.5);
1384   hsizeDetMap3->SetOption("colz");
1385 
1386   //hsizeXDetMap1 = fs->make<TH2F>("hsizeXDetMap1"," ",9,-4.5,4.5,21,-10.5,10.5);
1387   //hsizeXDetMap1->SetOption("colz");
1388   //hsizeXDetMap2 = fs->make<TH2F>("hsizeXDetMap2"," ",9,-4.5,4.5,33,-16.5,16.5);
1389   //hsizeXDetMap2->SetOption("colz");
1390   //hsizeXDetMap3 = fs->make<TH2F>("hsizeXDetMap3"," ",9,-4.5,4.5,45,-22.5,22.5);
1391   //hsizeXDetMap3->SetOption("colz");
1392 
1393   //hsizeYDetMap1 = fs->make<TH2F>("hsizeYDetMap1"," ",9,-4.5,4.5,21,-10.5,10.5);
1394   //hsizeYDetMap1->SetOption("colz");
1395   //hsizeYDetMap2 = fs->make<TH2F>("hsizeYDetMap2"," ",9,-4.5,4.5,33,-16.5,16.5);
1396   //hsizeYDetMap2->SetOption("colz");
1397   //hsizeYDetMap3 = fs->make<TH2F>("hsizeYDetMap3"," ",9,-4.5,4.5,45,-22.5,22.5);
1398   //hsizeYDetMap3->SetOption("colz");
1399 
1400   hpixDetMap1 = fs->make<TH2F>("hpixDetMap1", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1401   hpixDetMap2 = fs->make<TH2F>("hpixDetMap2", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1402   hpixDetMap3 = fs->make<TH2F>("hpixDetMap3", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1403 
1404   hcluDetMap1 = fs->make<TH2F>("hcluDetMap1", "clu det layer 1", 416, 0., 416., 160, 0., 160.);
1405   hcluDetMap2 = fs->make<TH2F>("hcluDetMap2", "clu det layer 1", 416, 0., 416., 160, 0., 160.);
1406   hcluDetMap3 = fs->make<TH2F>("hcluDetMap3", "clu det layer 1", 416, 0., 416., 160, 0., 160.);
1407 
1408   // Special test hitos for inefficiency effects
1409   hpixDetMap10 = fs->make<TH2F>("hpixDetMap10", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1410   hpixDetMap20 = fs->make<TH2F>("hpixDetMap20", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1411   hpixDetMap30 = fs->make<TH2F>("hpixDetMap30", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1412   hpixDetMap11 = fs->make<TH2F>("hpixDetMap11", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1413   hpixDetMap12 = fs->make<TH2F>("hpixDetMap12", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1414   hpixDetMap13 = fs->make<TH2F>("hpixDetMap13", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1415   hpixDetMap14 = fs->make<TH2F>("hpixDetMap14", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1416   hpixDetMap15 = fs->make<TH2F>("hpixDetMap15", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1417   hpixDetMap16 = fs->make<TH2F>("hpixDetMap16", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1418   hpixDetMap17 = fs->make<TH2F>("hpixDetMap17", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1419   hpixDetMap18 = fs->make<TH2F>("hpixDetMap18", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1420   hpixDetMap19 = fs->make<TH2F>("hpixDetMap19", "pix det layer 1", 416, 0., 416., 160, 0., 160.);
1421 
1422   hpixDetMap21 = fs->make<TH2F>("hpixDetMap21", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1423   hpixDetMap22 = fs->make<TH2F>("hpixDetMap22", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1424   hpixDetMap23 = fs->make<TH2F>("hpixDetMap23", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1425   hpixDetMap24 = fs->make<TH2F>("hpixDetMap24", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1426   hpixDetMap25 = fs->make<TH2F>("hpixDetMap25", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1427   hpixDetMap26 = fs->make<TH2F>("hpixDetMap26", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1428   hpixDetMap27 = fs->make<TH2F>("hpixDetMap27", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1429   hpixDetMap28 = fs->make<TH2F>("hpixDetMap28", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1430   hpixDetMap29 = fs->make<TH2F>("hpixDetMap29", "pix det layer 2", 416, 0., 416., 160, 0., 160.);
1431 
1432   hpixDetMap31 = fs->make<TH2F>("hpixDetMap31", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1433   hpixDetMap32 = fs->make<TH2F>("hpixDetMap32", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1434   hpixDetMap33 = fs->make<TH2F>("hpixDetMap33", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1435   hpixDetMap34 = fs->make<TH2F>("hpixDetMap34", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1436   hpixDetMap35 = fs->make<TH2F>("hpixDetMap35", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1437   hpixDetMap36 = fs->make<TH2F>("hpixDetMap36", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1438   hpixDetMap37 = fs->make<TH2F>("hpixDetMap37", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1439   hpixDetMap38 = fs->make<TH2F>("hpixDetMap38", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1440   hpixDetMap39 = fs->make<TH2F>("hpixDetMap39", "pix det layer 3", 416, 0., 416., 160, 0., 160.);
1441 
1442   //h2d1 = fs->make<TH2F>( "h2d1", "2d 1",200,0.,4000.,50,0., 200.);
1443   //h2d2 = fs->make<TH2F>( "h2d2", "2d 2", 55,0.,1.1, 150,0., 150.);
1444   //h2d3 = fs->make<TH2F>( "h2d3", "2d 3", 55,0.,1.1, 300,0.,4000.);
1445 
1446   hclumult1 = fs->make<TProfile>("hclumult1", "cluster size layer 1", 56, -28., 28., 0.0, 100.);
1447   hclumult2 = fs->make<TProfile>("hclumult2", "cluster size layer 2", 56, -28., 28., 0.0, 100.);
1448   hclumult3 = fs->make<TProfile>("hclumult3", "cluster size layer 3", 56, -28., 28., 0.0, 100.);
1449 
1450   hclumultx1 = fs->make<TProfile>("hclumultx1", "cluster x-size layer 1", 56, -28., 28., 0.0, 100.);
1451   hclumultx2 = fs->make<TProfile>("hclumultx2", "cluster x-size layer 2", 56, -28., 28., 0.0, 100.);
1452   hclumultx3 = fs->make<TProfile>("hclumultx3", "cluster x-size layer 3", 56, -28., 28., 0.0, 100.);
1453 
1454   hclumulty1 = fs->make<TProfile>("hclumulty1", "cluster y-size layer 1", 56, -28., 28., 0.0, 100.);
1455   hclumulty2 = fs->make<TProfile>("hclumulty2", "cluster y-size layer 2", 56, -28., 28., 0.0, 100.);
1456   hclumulty3 = fs->make<TProfile>("hclumulty3", "cluster y-size layer 3", 56, -28., 28., 0.0, 100.);
1457 
1458   hcluchar1 = fs->make<TProfile>("hcluchar1", "cluster char layer 1", 56, -28., 28., 0.0, 1000.);
1459   hcluchar2 = fs->make<TProfile>("hcluchar2", "cluster char layer 2", 56, -28., 28., 0.0, 1000.);
1460   hcluchar3 = fs->make<TProfile>("hcluchar3", "cluster char layer 3", 56, -28., 28., 0.0, 1000.);
1461 
1462   hpixchar1 = fs->make<TProfile>("hpixchar1", "pix char layer 1", 56, -28., 28., 0.0, 1000.);
1463   hpixchar2 = fs->make<TProfile>("hpixchar2", "pix char layer 2", 56, -28., 28., 0.0, 1000.);
1464   hpixchar3 = fs->make<TProfile>("hpixchar3", "pix char layer 3", 56, -28., 28., 0.0, 1000.);
1465 
1466   sizeH = 1000;
1467   highH = 3000.;
1468   hclusls = fs->make<TProfile>("hclusls", "clus vs ls", sizeH, 0., highH, 0.0, 30000.);
1469   hpixls = fs->make<TProfile>("hpixls", "pix vs ls ", sizeH, 0., highH, 0.0, 100000.);
1470   hpvls = fs->make<TProfile>("hpvls", "pvs vs ls", sizeH, 0., highH, 0.0, 10000.);
1471   //hpvlsn = fs->make<TProfile>("hpvlsn","pvs/lumi vs ls",sizeH,0.,highH,0.0,1000.);
1472 
1473   hcharCluls = fs->make<TProfile>("hcharCluls", "clu char vs ls", sizeH, 0., highH, 0.0, 100.);
1474   hcharPixls = fs->make<TProfile>("hcharPixls", "pix char vs ls", sizeH, 0., highH, 0.0, 100.);
1475   hsizeCluls = fs->make<TProfile>("hsizeCluls", "clu size vs ls", sizeH, 0., highH, 0.0, 1000.);
1476   hsizeXCluls = fs->make<TProfile>("hsizeXCluls", "clu size-x vs ls", sizeH, 0., highH, 0.0, 100.);
1477 
1478   // sizeH = 100;
1479   // highH =  10.;
1480   // hpixbl   = fs->make<TProfile>("hpixbl",  "pixb vs lumi ", sizeH,0.,highH,0.0,100000.);
1481   // hclusbl  = fs->make<TProfile>("hclusbl", "clusb vs lumi", sizeH,0.,highH,0.0,30000.);
1482   // hpixb1l  = fs->make<TProfile>("hpixb1l", "pixb1 vs lumi", sizeH,0.,highH,0.0,100000.);
1483   // hclusb1l = fs->make<TProfile>("hclusb1l","clusb1 vs lumi",sizeH,0.,highH,0.0,30000.);
1484   // hpixb2l  = fs->make<TProfile>("hpixb2l", "pixb2 vs lumi ",sizeH,0.,highH,0.0,100000.);
1485   // hclusb2l = fs->make<TProfile>("hclusb2l","clusb2 vs lumi",sizeH,0.,highH,0.0,30000.);
1486   // hpixb3l  = fs->make<TProfile>("hpixb3l", "pixb3 vs lumi ",sizeH,0.,highH,0.0,100000.);
1487   // hclusb3l = fs->make<TProfile>("hclusb3l","clusb3 vs lumi",sizeH,0.,highH,0.0,30000.);
1488   // hpixfl   = fs->make<TProfile>("hpixfl",  "pixf vs lumi ", sizeH,0.,highH,0.0,100000.);
1489   // hclusfl  = fs->make<TProfile>("hclusfl", "clusf vs lumi", sizeH,0.,highH,0.0,30000.);
1490   // hpixfml  = fs->make<TProfile>("hpixfml", "pixfm vs lumi ",sizeH,0.,highH,0.0,100000.);
1491   // hclusfml = fs->make<TProfile>("hclusfml","clusfm vs lumi",sizeH,0.,highH,0.0,30000.);
1492   // hpixfpl  = fs->make<TProfile>("hpixfpl", "pixfp vs lumi ",sizeH,0.,highH,0.0,100000.);
1493   // hclusfpl = fs->make<TProfile>("hclusfpl","clusfp vs lumi",sizeH,0.,highH,0.0,30000.);
1494 
1495   sizeH = 1000;
1496   highH = 3000.;
1497   //hpixpvlsn  = fs->make<TProfile>("hpixpvlsn","pix/pv vs ls",sizeH,0.,highH,0.0,100000.);
1498   //hclupvlsn  = fs->make<TProfile>("hclupvlsn","clu/pv vs ls",sizeH,0.,highH,0.0,30000.);
1499 
1500   hpixpv = fs->make<TProfile>("hpixpv", "pix vs pv", 1000, 0., 20000, 0.0, 1000.);
1501   hclupv = fs->make<TProfile>("hclupv", "clu vs pv", 1000, 0., 10000, 0.0, 1000.);
1502 
1503   //hintgls  = fs->make<TProfile>("hintgls", "intg lumi vs ls ",sizeH,0.,highH,0.0,10000.);
1504   hinstls = fs->make<TProfile>("hinstls", "inst bx lumi vs ls ", sizeH, 0., highH, 0.0, 1000.);
1505   hinstlsbx = fs->make<TProfile>("hinstlsbx", "inst bx lumi vs ls ", sizeH, 0., highH, 0.0, 1000.);
1506   //hbeam1  = fs->make<TProfile>("hbeam1", "beam1 vs ls ",sizeH,0.,highH,0.0,1000.);
1507   //hbeam2  = fs->make<TProfile>("hbeam2", "beam2 vs ls ",sizeH,0.,highH,0.0,1000.);
1508 
1509   hpixbx = fs->make<TProfile>("hpixbx", "pix vs bx ", 4000, -0.5, 3999.5, 0.0, 1000000.);
1510   hclubx = fs->make<TProfile>("hclubx", "clu vs bx ", 4000, -0.5, 3999.5, 0.0, 1000000.);
1511   hpvbx = fs->make<TProfile>("hpvbx", "pv vs bx ", 4000, -0.5, 3999.5, 0.0, 1000000.);
1512   //hpixbxn = fs->make<TProfile>("hpixbxn","pix/lumi vs bx ",4000,-0.5,3999.5,0.0,1000000.);
1513   //hclubxn = fs->make<TProfile>("hclubxn","clu/lumi vs bx ",4000,-0.5,3999.5,0.0,1000000.);
1514   //hpvbxn  = fs->make<TProfile>("hpvbxn", "pv/lumi vs bx ", 4000,-0.5,3999.5,0.0,1000000.);
1515 
1516   hcharClubx = fs->make<TProfile>("hcharClubx", "clu charge vs bx ", 4000, -0.5, 3999.5, 0.0, 100.);
1517   hcharPixbx = fs->make<TProfile>("hcharPixbx", "pix charge vs bx ", 4000, -0.5, 3999.5, 0.0, 100.);
1518   hsizeClubx = fs->make<TProfile>("hsizeClubx", "clu size vs bx ", 4000, -0.5, 3999.5, 0.0, 1000.);
1519   hsizeYClubx = fs->make<TProfile>("hsizeYClubx", "clu size-y vs bx ", 4000, -0.5, 3999.5, 0.0, 1000.);
1520 
1521   hinstbx = fs->make<TProfile>("hinstbx", "inst lumi vs bx ", 4000, -0.5, 3999.5, 0.0, 100.);
1522 
1523   hcluLumi = fs->make<TProfile>("hcluLumi", "clus vs inst lumi", 100, 0.0, 10., 0.0, 100000.);
1524   hpixLumi = fs->make<TProfile>("hpixLumi", "pixs vs inst lumi", 100, 0.0, 10., 0.0, 100000.);
1525   hcharCluLumi = fs->make<TProfile>("hcharCluLumi", "clu char vs inst lumi", 100, 0.0, 10., 0.0, 100.);
1526   hcharPixLumi = fs->make<TProfile>("hcharPixLumi", "pix char vs inst lumi", 100, 0.0, 10., 0.0, 100.);
1527   hsizeCluLumi = fs->make<TProfile>("hsizeCluLumi", "clu size vs inst lumi", 100, 0.0, 10., 0.0, 100.);
1528   hsizeXCluLumi = fs->make<TProfile>("hsizeXCluLumi", "clu size-x vs inst lumi", 100, 0.0, 10., 0.0, 100.);
1529   hsizeYCluLumi = fs->make<TProfile>("hsizeYCluLumi", "clu size-y vs inst lumi", 100, 0.0, 10., 0.0, 100.);
1530 
1531   //hclus13ls  = fs->make<TProfile>("hclus13ls", "clus1/clus3 vs ls", sizeH,0.,highH,0.0,30000.);
1532   //hclus23ls  = fs->make<TProfile>("hclus23ls", "clus2/clus3 vs ls", sizeH,0.,highH,0.0,30000.);
1533   //hclus12ls  = fs->make<TProfile>("hclus12ls", "clus1/clus2 vs ls", sizeH,0.,highH,0.0,30000.);
1534   //hclusf3ls  = fs->make<TProfile>("hclusf3ls", "clusf/clus3 vs ls", sizeH,0.,highH,0.0,30000.);
1535 
1536   //    hclusbx1lsn  = fs->make<TProfile>("hclusbx1lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1537   //    hclusbx2lsn  = fs->make<TProfile>("hclusbx2lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1538   //    hclusbx3lsn  = fs->make<TProfile>("hclusbx3lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1539   //    hclusbx4lsn  = fs->make<TProfile>("hclusbx4lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1540   //    hclusbx5lsn  = fs->make<TProfile>("hclusbx5lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1541   //    hclusbx6lsn  = fs->make<TProfile>("hclusbx6lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1542   //    hclusbx7lsn  = fs->make<TProfile>("hclusbx7lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1543   //    hclusbx8lsn  = fs->make<TProfile>("hclusbx8lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1544   //    hclusbx9lsn  = fs->make<TProfile>("hclusbx9lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1545 
1546   //    hclusbx11lsn  = fs->make<TProfile>("hclusbx11lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1547   //    hclusbx12lsn  = fs->make<TProfile>("hclusbx12lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1548   //    hclusbx13lsn  = fs->make<TProfile>("hclusbx13lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1549   //    hclusbx14lsn  = fs->make<TProfile>("hclusbx14lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1550   //    hclusbx15lsn  = fs->make<TProfile>("hclusbx15lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1551   //    hclusbx16lsn  = fs->make<TProfile>("hclusbx16lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1552   //    hclusbx17lsn  = fs->make<TProfile>("hclusbx17lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1553   //    hclusbx18lsn  = fs->make<TProfile>("hclusbx18lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1554   //    hclusbx19lsn  = fs->make<TProfile>("hclusbx19lsn", "clus vs ls for bx", sizeH,0.,highH,0.0,30000.);
1555 
1556   //hclusls2 = fs->make<TH2F>("hclusls2","clus bs ls", 300,0.,900.,100,0.,5000.);
1557   //hpixls2  = fs->make<TH2F>("hpixls2", "pix per ls ",300,0.,900.,100,0.,20000.);
1558   //h2pixpv  = fs->make<TH2F>("h2pixpv","pix vs pv",100,0.,40000, 25,0.0,50.);
1559   //h2clupv  = fs->make<TH2F>("h2clupv","clu vs pv",100,0.,20000, 25,0.0,50.);
1560 
1561   //hclusls1 = fs->make<TH1D>("hclusls1","av clus/lumi",200,0.,2000.);
1562   //hpixls1  = fs->make<TH1D>("hpixls1", "av pix/lumi ",500,0.,5000.);
1563 
1564   //hintg  = fs->make<TH1D>("hintg", "intg lumi",100,0.0,1000.);
1565   hinst = fs->make<TH1D>("hinst", "inst lumi", 100, 0.0, 10.);
1566   hpvs = fs->make<TH1D>("hpvs", "pvs", 100, -0.5, 99.5);
1567 
1568 #ifdef VDM_STUDIES
1569   hcharCluls1 = fs->make<TProfile>("hcharCluls1", "clu char vs ls", sizeH, 0., highH, 0.0, 100.);
1570   hcharPixls1 = fs->make<TProfile>("hcharPixls1", "pix char vs ls", sizeH, 0., highH, 0.0, 100.);
1571   hsizeCluls1 = fs->make<TProfile>("hsizeCluls1", "clu size vs ls", sizeH, 0., highH, 0.0, 1000.);
1572   hsizeXCluls1 = fs->make<TProfile>("hsizeXCluls1", "clu size-x vs ls", sizeH, 0., highH, 0.0, 100.);
1573   hcharCluls2 = fs->make<TProfile>("hcharCluls2", "clu char vs ls", sizeH, 0., highH, 0.0, 100.);
1574   hcharPixls2 = fs->make<TProfile>("hcharPixls2", "pix char vs ls", sizeH, 0., highH, 0.0, 100.);
1575   hsizeCluls2 = fs->make<TProfile>("hsizeCluls2", "clu size vs ls", sizeH, 0., highH, 0.0, 1000.);
1576   hsizeXCluls2 = fs->make<TProfile>("hsizeXCluls2", "clu size-x vs ls", sizeH, 0., highH, 0.0, 100.);
1577   hcharCluls3 = fs->make<TProfile>("hcharCluls3", "clu char vs ls", sizeH, 0., highH, 0.0, 100.);
1578   hcharPixls3 = fs->make<TProfile>("hcharPixls3", "pix char vs ls", sizeH, 0., highH, 0.0, 100.);
1579   hsizeCluls3 = fs->make<TProfile>("hsizeCluls3", "clu size vs ls", sizeH, 0., highH, 0.0, 1000.);
1580   hsizeXCluls3 = fs->make<TProfile>("hsizeXCluls3", "clu size-x vs ls", sizeH, 0., highH, 0.0, 100.);
1581   hclusls1 = fs->make<TProfile>("hclusls1", "clus vs ls", sizeH, 0., highH, 0.0, 30000.);
1582   hpixls1 = fs->make<TProfile>("hpixls1", "pix vs ls ", sizeH, 0., highH, 0.0, 100000.);
1583   hclusls2 = fs->make<TProfile>("hclusls2", "clus vs ls", sizeH, 0., highH, 0.0, 30000.);
1584   hpixls2 = fs->make<TProfile>("hpixls2", "pix vs ls ", sizeH, 0., highH, 0.0, 100000.);
1585   hclusls3 = fs->make<TProfile>("hclusls3", "clus vs ls", sizeH, 0., highH, 0.0, 30000.);
1586   hpixls3 = fs->make<TProfile>("hpixls3", "pix vs ls ", sizeH, 0., highH, 0.0, 100000.);
1587 #endif  // VDM_STUDIES
1588 
1589 #ifdef INSTLUMI_STUDIES
1590   hcluslsn = fs->make<TProfile>("hcluslsn", "clus/lumi", sizeH, 0., highH, 0.0, 30000.);
1591   hpixlsn = fs->make<TProfile>("hpixlsn", "pix/lumi ", sizeH, 0., highH, 0.0, 100000.);
1592   sizeH = 100;
1593   highH = 10.;
1594   hpixbl = fs->make<TProfile>("hpixbl", "pixb vs lumi ", sizeH, 0., highH, 0.0, 100000.);
1595   hclusbl = fs->make<TProfile>("hclusbl", "clusb vs lumi", sizeH, 0., highH, 0.0, 30000.);
1596   hpixb1l = fs->make<TProfile>("hpixb1l", "pixb1 vs lumi", sizeH, 0., highH, 0.0, 100000.);
1597   hclusb1l = fs->make<TProfile>("hclusb1l", "clusb1 vs lumi", sizeH, 0., highH, 0.0, 30000.);
1598   hpixb2l = fs->make<TProfile>("hpixb2l", "pixb2 vs lumi ", sizeH, 0., highH, 0.0, 100000.);
1599   hclusb2l = fs->make<TProfile>("hclusb2l", "clusb2 vs lumi", sizeH, 0., highH, 0.0, 30000.);
1600   hpixb3l = fs->make<TProfile>("hpixb3l", "pixb3 vs lumi ", sizeH, 0., highH, 0.0, 100000.);
1601   hclusb3l = fs->make<TProfile>("hclusb3l", "clusb3 vs lumi", sizeH, 0., highH, 0.0, 30000.);
1602   hpixfl = fs->make<TProfile>("hpixfl", "pixf vs lumi ", sizeH, 0., highH, 0.0, 100000.);
1603   hclusfl = fs->make<TProfile>("hclusfl", "clusf vs lumi", sizeH, 0., highH, 0.0, 30000.);
1604   hpixfml = fs->make<TProfile>("hpixfml", "pixfm vs lumi ", sizeH, 0., highH, 0.0, 100000.);
1605   hclusfml = fs->make<TProfile>("hclusfml", "clusfm vs lumi", sizeH, 0., highH, 0.0, 30000.);
1606   hpixfpl = fs->make<TProfile>("hpixfpl", "pixfp vs lumi ", sizeH, 0., highH, 0.0, 100000.);
1607   hclusfpl = fs->make<TProfile>("hclusfpl", "clusfp vs lumi", sizeH, 0., highH, 0.0, 30000.);
1608 
1609   hpixbxn = fs->make<TProfile>("hpixbxn", "pix/lumi vs bx ", 4000, -0.5, 3999.5, 0.0, 1000000.);
1610   hclubxn = fs->make<TProfile>("hclubxn", "clu/lumi vs bx ", 4000, -0.5, 3999.5, 0.0, 1000000.);
1611   hpvbxn = fs->make<TProfile>("hpvbxn", "pv/lumi vs bx ", 4000, -0.5, 3999.5, 0.0, 1000000.);
1612 #endif  // INSTLUMI_STUDIES
1613 
1614 #ifdef ROC_EFF
1615   // dets with bad rocs
1616   hbadMap1 = fs->make<TH2F>("hbadMap1", " ", 9, -4.5, 4.5, 21, -10.5, 10.5);
1617   hbadMap1->SetOption("colz");
1618   hbadMap2 = fs->make<TH2F>("hbadMap2", " ", 9, -4.5, 4.5, 33, -16.5, 16.5);
1619   hbadMap2->SetOption("colz");
1620   hbadMap3 = fs->make<TH2F>("hbadMap3", " ", 9, -4.5, 4.5, 45, -22.5, 22.5);
1621   hbadMap3->SetOption("colz");
1622 
1623   hrocHits1ls = fs->make<TH2F>("hrocHits1ls", " ", 1000, 0., 3000., 10, 0., 10.);
1624   hrocHits1ls->SetOption("colz");
1625   hrocHits2ls = fs->make<TH2F>("hrocHits2ls", " ", 1000, 0., 3000., 10, 0., 10.);
1626   hrocHits2ls->SetOption("colz");
1627   hrocHits3ls = fs->make<TH2F>("hrocHits3ls", " ", 1000, 0., 3000., 10, 0., 10.);
1628   hrocHits3ls->SetOption("colz");
1629 
1630   hcountInRoc1 = fs->make<TH1D>("hcountInRoc1", "roc 1 count", 10000, -0.5, 999999.5);
1631   hcountInRoc2 = fs->make<TH1D>("hcountInRoc2", "roc 2 count", 10000, -0.5, 999999.5);
1632   hcountInRoc3 = fs->make<TH1D>("hcountInRoc3", "roc 3 count", 10000, -0.5, 999999.5);
1633   hcountInRoc12 = fs->make<TH1D>("hcountInRoc12", "roc 1 count norm", 500, -0.5, 4.5);
1634   hcountInRoc22 = fs->make<TH1D>("hcountInRoc22", "roc 2 count norm", 500, -0.5, 4.5);
1635   hcountInRoc32 = fs->make<TH1D>("hcountInRoc32", "roc 3 count norm", 500, -0.5, 4.5);
1636 
1637   //   hmoduleHits1ls = fs->make<TH2F>("hmoduleHits1ls"," ",3000,0.,3000.,3,0.,3.);
1638   //   hmoduleHits1ls->SetOption("colz");
1639   //   hmoduleHits2ls = fs->make<TH2F>("hmoduleHits2ls"," ",3000,0.,3000.,3,0.,3.);
1640   //   hmoduleHits2ls->SetOption("colz");
1641   //   hmoduleHits3ls = fs->make<TH2F>("hmoduleHits3ls"," ",3000,0.,3000.,3,0.,3.);
1642   //   hmoduleHits3ls->SetOption("colz");
1643 
1644 #endif  // ROC_EFF
1645 
1646   countEvents = 0;
1647   countAllEvents = 0;
1648   sumClusters = 0., sumPixels = 0.;
1649   countLumi = 0.;
1650 
1651   //for(int ilayer = 0; ilayer<3; ++ilayer)
1652   //for(int id=0;id<10;++id) {rocHits[ilayer][id]=0.; moduleHits[ilayer][id]=0.;}
1653 
1654 #ifdef ROC_EFF
1655   // Analyze single pixel efficiency
1656   pixEff = new rocEfficiency();
1657 #endif
1658 
1659 #ifdef BX
1660   getbx = new getBX();
1661 #endif
1662 
1663   lumiCorrector = new LumiCorrector();
1664 }
1665 // ------------ method called to at the end of the job  ------------
1666 void TestClusters::endJob() {
1667   double norm = 1;
1668 #ifdef ROC_EFF
1669   double totClusters = sumClusters;  // save the total cluster number
1670 #endif
1671 
1672   if (countEvents > 0) {
1673     sumClusters = sumClusters / float(countEvents);
1674     sumPixels = sumPixels / float(countEvents);
1675     norm = 1. / float(countEvents);
1676   }
1677 
1678   countLumi /= 1000.;
1679   double c1 = 0, c2 = 0;
1680   double c3 = hinst->GetMean();
1681   if (c3 > 0.) {
1682     c1 = sumClusters / c3;
1683     c2 = sumPixels / c3;
1684   }
1685 
1686   edm::LogPrint("TestClusters") << " End PixelClusTest, events all/with hits=  " << countAllEvents << "/" << countEvents
1687                                 << " clus/pix per full event " << sumClusters << "/" << sumPixels;
1688   edm::LogPrint("TestClusters") << " Lumi = " << countLumi << " still the /10 bug? "
1689                                 << "clu and pix per lumi unit" << c1 << " " << c2;
1690 
1691   //Divide the size histos
1692   hsizeDetMap1->Divide(hsizeDetMap1, hDetMap1, 1., 1.);
1693   hsizeDetMap2->Divide(hsizeDetMap2, hDetMap2, 1., 1.);
1694   hsizeDetMap3->Divide(hsizeDetMap3, hDetMap3, 1., 1.);
1695 
1696   // Rescale all 2D plots
1697   hDetsMap1->Scale(norm);
1698   hDetsMap2->Scale(norm);
1699   hDetsMap3->Scale(norm);
1700   hDetMap1->Scale(norm);
1701   hDetMap2->Scale(norm);
1702   hDetMap3->Scale(norm);
1703   hpDetMap1->Scale(norm);
1704   hpDetMap2->Scale(norm);
1705   hpDetMap3->Scale(norm);
1706   hpixDetMap1->Scale(norm);
1707   hpixDetMap2->Scale(norm);
1708   hpixDetMap3->Scale(norm);
1709   hcluDetMap1->Scale(norm);
1710   hcluDetMap2->Scale(norm);
1711   hcluDetMap3->Scale(norm);
1712 
1713 #ifdef ROC_EFF
1714   // Do this only if there is enough statistics
1715   double clusPerROC = totClusters / 15000.;
1716   if (clusPerROC < 1000.) {
1717     edm::LogPrint("TestClusters")
1718         << " The average number of clusters per ROC is too low to do teh ROF efficiency analysis " << clusPerROC;
1719 
1720   } else {  // do it
1721 
1722     int deadRocs1 = 0, ineffRocs1 = 0, deadRocs2 = 0, ineffRocs2 = 0, deadRocs3 = 0, ineffRocs3 = 0;
1723     const int ladders1[20] = {-10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
1724     const int ladders2[32] = {-16, -15, -14, -13, -12, -11, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1,
1725                               1,   2,   3,   4,   5,   6,   7,   8,  9,  10, 11, 12, 13, 14, 15, 16};
1726     const int ladders3[44] = {-22, -21, -20, -19, -18, -17, -16, -15, -14, -13, -12, -11, -10, -9, -8,
1727                               -7,  -6,  -5,  -4,  -3,  -2,  -1,  1,   2,   3,   4,   5,   6,   7,  8,
1728                               9,   10,  11,  12,  13,  14,  15,  16,  17,  18,  19,  20,  21,  22};
1729     const int modules[8] = {-4, -3, -2, -1, 1, 2, 3, 4};
1730     const float effCut = 0.25;
1731     float half1 = 1, half2 = 0;
1732 
1733     // layer 1
1734     for (int ilad = 0; ilad < 20; ++ilad) {
1735       int lad = ladders1[ilad];
1736       for (int imod = 0; imod < 8; ++imod) {
1737         int mod = modules[imod];
1738         half1 = 0;
1739         half2 = 0;
1740         float count = pixEff->getModule(1, lad, mod, half1, half2);
1741         //edm::LogPrint("TestClusters")<<" layer 1 "<<lad<<" "<<mod<<" "<<count<<endl;
1742         if (count < 1.)
1743           continue;  // skip dead modules
1744         for (int roc = 0; roc < 16; ++roc) {
1745           if (roc < 8 && half1 == 0)
1746             continue;
1747           else if (roc > 7 && half2 == 0)
1748             continue;
1749           float tmp = pixEff->getRoc(1, lad, mod, roc);
1750           if (tmp < 0.) {                                          // half-module rocs will show up here
1751             if ((abs(lad) == 1 || abs(lad) == 10) && (roc > 7)) {  // OK half module
1752               continue;
1753             } else {
1754               edm::LogPrint("TestClusters")
1755                   << " Layer1, wrong number of hits, roc " << tmp << " " << lad << " " << mod << " " << roc;
1756             }
1757           } else if (tmp == 0.) {
1758             deadRocs1++;
1759             edm::LogPrint("TestClusters") << " layer1, dead  roc " << lad << " " << mod << " " << roc << " - " << count
1760                                           << " " << half1 << " " << half2;
1761           } else {
1762             hcountInRoc1->Fill(tmp);
1763             float tmp1 = tmp / count;
1764             //edm::LogPrint("TestClusters")<<" roc "<<roc<<" "<<tmp<<" "<<tmp1<<endl;
1765             hcountInRoc12->Fill(tmp1);
1766             if (abs(1. - tmp1) > effCut) {
1767               ineffRocs1++;
1768               edm::LogPrint("TestClusters") << "LOW-EFF/NOISY ROC, Layer 1: " << tmp1 << "/" << tmp << " ladder " << lad
1769                                             << " module " << mod << " roc(false #) " << roc;
1770               hbadMap1->Fill(float(mod), float(lad));
1771             }
1772           }  //if
1773         }  // loop over rocs
1774       }  // mod
1775     }  // lad
1776 
1777     for (int ilad = 0; ilad < 32; ++ilad) {
1778       int lad = ladders2[ilad];
1779       for (int imod = 0; imod < 8; ++imod) {
1780         int mod = modules[imod];
1781         half1 = 0;
1782         half2 = 0;
1783         float count = pixEff->getModule(2, lad, mod, half1, half2);
1784         //edm::LogPrint("TestClusters")<<" layer 2 "<<lad<<" "<<mod<<" "<<count<<endl;
1785         if (count < 1.)
1786           continue;  // skip dead whole modules
1787         for (int roc = 0; roc < 16; ++roc) {
1788           if (roc < 8 && half1 == 0)
1789             continue;
1790           else if (roc > 7 && half2 == 0)
1791             continue;
1792           float tmp = pixEff->getRoc(2, lad, mod, roc);
1793           if (tmp < 0.) {
1794             if ((abs(lad) == 1 || abs(lad) == 16) && (roc > 7)) {  // OK half module
1795               continue;
1796             } else {
1797               edm::LogPrint("TestClusters")
1798                   << " Layer 2, wrong number of hits, roc " << tmp << " " << lad << " " << mod << " " << roc;
1799             }
1800           } else if (tmp == 0.) {
1801             deadRocs2++;
1802             edm::LogPrint("TestClusters") << " layer2, dead  roc " << lad << " " << mod << " " << roc << " - " << count
1803                                           << " " << half1 << " " << half2;
1804           } else {
1805             hcountInRoc2->Fill(tmp);
1806             float tmp1 = tmp / count;
1807             //edm::LogPrint("TestClusters")<<" roc "<<roc<<" "<<tmp<<" "<<tmp1<<endl;
1808             hcountInRoc22->Fill(tmp1);
1809             if (abs(1. - tmp1) > effCut) {
1810               ineffRocs2++;
1811               edm::LogPrint("TestClusters") << "LOW-EFF/NOISY ROC, Layer 2: " << tmp1 << "/" << tmp << " ladder " << lad
1812                                             << " module " << mod << " roc(false) " << roc;
1813               hbadMap2->Fill(float(mod), float(lad));
1814             }
1815           }  //if
1816         }  // loop over rocs
1817       }  // mod
1818     }  // lad
1819 
1820     for (int ilad = 0; ilad < 44; ++ilad) {
1821       int lad = ladders3[ilad];
1822       for (int imod = 0; imod < 8; ++imod) {
1823         int mod = modules[imod];
1824         half1 = 0;
1825         half2 = 0;
1826         float count = pixEff->getModule(3, lad, mod, half1, half2);
1827         //edm::LogPrint("TestClusters")<<" layer 3"<<lad<<" "<<mod<<" "<<count<<endl;
1828         if (count < 1.)
1829           continue;  // skip dead whole modules
1830         for (int roc = 0; roc < 16; ++roc) {
1831           float tmp = pixEff->getRoc(3, lad, mod, roc);
1832           if (tmp < 0.) {
1833             if ((abs(lad) == 1 || abs(lad) == 22) && (roc > 7)) {  // OK half module
1834               continue;
1835             } else {
1836               edm::LogPrint("TestClusters")
1837                   << " Layer 3: wrong number of hits, roc " << tmp << " " << lad << " " << mod << " " << roc;
1838             }
1839           } else if (tmp == 0.) {
1840             deadRocs3++;
1841             edm::LogPrint("TestClusters") << " layer3, dead  roc " << lad << " " << mod << " " << roc << " - " << count
1842                                           << " " << half1 << " " << half2;
1843           } else {
1844             hcountInRoc3->Fill(tmp);
1845             float tmp1 = tmp / count;
1846             //edm::LogPrint("TestClusters")<<" roc "<<roc<<" "<<tmp<<" "<<tmp1<<endl;
1847             hcountInRoc32->Fill(tmp1);
1848             if (abs(1. - tmp1) > effCut) {
1849               ineffRocs3++;
1850               edm::LogPrint("TestClusters") << "LOW-EFF/NOISY ROC, Layer 3: " << tmp1 << "/" << tmp << " ladder " << lad
1851                                             << " module " << mod << " roc(false) " << roc;
1852               hbadMap3->Fill(float(mod), float(lad));
1853             }
1854           }  //if
1855         }  // loop over rocs
1856       }  // mod
1857     }  // lad
1858 
1859     edm::LogPrint("TestClusters") << " Bad Rocs " << deadRocs1 << " " << deadRocs2 << " " << deadRocs3
1860                                   << ", Inefficient Rocs " << ineffRocs1 << " " << ineffRocs2 << " " << ineffRocs3;
1861   }  // if DO IT
1862 
1863 #endif  // ROC_EFF
1864 }
1865 //////////////////////////////////////////////////////////////////
1866 // Functions that gets called by framework every event
1867 void TestClusters::analyze(const edm::Event &e, const edm::EventSetup &es) {
1868   using namespace edm;
1869   //const int MAX_CUT = 1000000; unused
1870   const int selectEvent = -1;
1871   //bool select = false; unused
1872   static RunNumber_t runNumberOld = -1;
1873   static int countRuns = 0;
1874   //static double pixsum = 0., clussum=0.;
1875   //static int nsum = 0, lsold=-999, lumiold=0.;
1876 
1877   // Get event setup
1878   edm::ESHandle<TrackerGeometry> geom = es.getHandle(trackerGeomToken_);
1879   const TrackerGeometry &theTracker(*geom);
1880 
1881   countAllEvents++;
1882   RunNumber_t const run = e.id().run();
1883   EventNumber_t const event = e.id().event();
1884   LuminosityBlockNumber_t const lumiBlock = e.luminosityBlock();
1885 
1886   int bx = e.bunchCrossing();
1887   int orbit = e.orbitNumber();
1888 
1889   hbx0->Fill(float(bx));
1890   hlumi0->Fill(float(lumiBlock));
1891 
1892   //if(lumiBlock<127) return;
1893   //if(event!=3787937) return;
1894 
1895   float instlumi = 0;
1896   //int beamint1=0, beamint2=0;
1897 
1898 #ifdef Lumi
1899   float instlumiAv = 0, instlumiBx = 0;
1900 
1901   // Lumi
1902   edm::LuminosityBlock const &iLumi = e.getLuminosityBlock();
1903   edm::Handle<LumiSummary> lumi;
1904   edm::Handle<LumiDetails> ld;
1905   iLumi.getByToken(lumiSummaryToken_, lumi);
1906   iLumi.getByToken(lumiDetailsToken_, ld);
1907 
1908   edm::Handle<edm::ConditionsInLumiBlock> cond;
1909   iLumi.getByToken(condToken_, cond);
1910   // This will only work when running on RECO until (if) they fix it in the FW
1911   // When running on RAW and reconstructing, the LumiSummary will not appear
1912   // in the event before reaching endLuminosityBlock(). Therefore, it is not
1913   // possible to get this info in the event
1914   if (lumi.isValid()) {
1915     //intlumi =(lumi->intgRecLumi())/1000.; // integrated lumi per LS in -pb
1916     //instlumi=(lumi->avgInsDelLumi())/1000.; //ave. inst lumi per LS in -pb
1917     float tmp0 = (lumi->avgInsDelLumi());  //ave. inst lumi per LS in -nb
1918     //beamint1=(cond->totalIntensityBeam1)/1000;
1919     //beamint2=(cond->totalIntensityBeam2)/1000;
1920     const int nbx = 1331;  // for 1380 fills
1921     float corr = lumiCorrector->TotalNormOcc1((tmp0 / 1000.), nbx);
1922     //float tmp2 = lumiCorrector->TotalNormOcc2(tmp0,nbx);
1923     //float tmp3 = lumiCorrector->TotalNormET(tmp0,nbx);
1924     float tmp1 = tmp0 * corr;
1925     //instlumiAv = tmp1/1000000.;  // in 10^33
1926     float tmp2 = tmp1 / float(nbx) / 1000.;  // per bx
1927     instlumiAv = tmp2;                       // use per bx lumi
1928 
1929     if (ld.isValid()) {
1930       instlumiBx = ld->lumiValue(LumiDetails::kOCC1, bx) * 6.37;  // cor=6.37 in 2011, 7.13 in 2012?
1931     }
1932 
1933     //edm::LogPrint("TestClusters")<<run<<" "<<lumiBlock<<" "<<tmp0<<" "<<corr<<" "<<tmp1<<" "<<instlumiAv<<" "<<tmp2<<" ";
1934     //edm::LogPrint("TestClusters")<<instlumiBx<<endl;
1935 
1936   } else {
1937     //std::edm::LogPrint("TestClusters") << "** ERROR: Event does not get lumi info\n";
1938   }
1939 
1940   hinst->Fill(float(instlumiBx));
1941   //hintg->Fill(float(intlumi));
1942   hinstls->Fill(float(lumiBlock), float(instlumiAv));
1943   hinstlsbx->Fill(float(lumiBlock), float(instlumiBx));
1944   hinstbx->Fill(float(bx), float(instlumiBx));
1945   //hbeam1->Fill(float(lumiBlock),float(beamint1));
1946   //hbeam2->Fill(float(lumiBlock),float(beamint2));
1947 
1948   // Use this per bx as int lumi
1949   instlumi = instlumiBx;
1950 
1951 #endif
1952 
1953   // PVs
1954   int numPVsGood = 0;
1955   if (select2 < 11 && run > 165000) {  // skip for earlier runs, crashes
1956     edm::Handle<reco::VertexCollection> vertices;
1957     e.getByToken(vtxToken_, vertices);
1958 
1959     //int numPVs = vertices->size(); // unused
1960     if (!vertices.failedToGet() && vertices.isValid()) {
1961       for (reco::VertexCollection::const_iterator iVertex = vertices->begin(); iVertex != vertices->end(); ++iVertex) {
1962         if (!iVertex->isValid())
1963           continue;
1964         if (iVertex->isFake())
1965           continue;
1966         numPVsGood++;
1967 
1968         if (PRINT) {
1969           edm::LogPrint("TestClusters") << "vertex";
1970           edm::LogPrint("TestClusters") << ": x " << iVertex->x();
1971           edm::LogPrint("TestClusters") << ", y " << iVertex->y();
1972           edm::LogPrint("TestClusters") << ", z " << iVertex->z();
1973           edm::LogPrint("TestClusters") << ", ndof " << iVertex->ndof();
1974           edm::LogPrint("TestClusters") << ", sumpt " << iVertex->p4().pt();
1975           edm::LogPrint("TestClusters");
1976         }  // print
1977       }  // for loop
1978     }  // if vertex
1979 
1980     hpvs->Fill(float(numPVsGood));
1981     hpvls->Fill(float(lumiBlock), float(numPVsGood));
1982     //if(instlumi>0.) {
1983     //float tmp = float(numPVsGood)/instlumi;
1984     //hpvlsn->Fill(float(lumiBlock),tmp);
1985     //}
1986   }  // if run
1987 
1988   int bxId = -1;
1989 #ifdef BX
1990   //edm::LogPrint("TestClusters")<<" for bx "<<bx<<endl;
1991   bxId = getbx->find(bx);  // get the bunch type
1992   //edm::LogPrint("TestClusters")<<" id is "<<bxId<<endl;
1993 #endif  // BX
1994 
1995 #ifdef BX_NEW
1996   //edm::LogPrint("TestClusters")<<" for bx "<<bx<<endl;
1997   bxId = getBX::find(bx);  // get the bunch type
1998   //edm::LogPrint("TestClusters")<<" id is "<<bxId<<endl;
1999 #endif  // BX_NEW
2000 
2001 #if defined(BX) || defined(BX_NEW)
2002   if (bxId == 3)
2003     hbx1->Fill(float(bx));  // collision
2004   else if (bxId == 4)
2005     hbx2->Fill(float(bx));  // collision+1
2006   else if (bxId == 1)
2007     hbx3->Fill(float(bx));  // beam1
2008   else if (bxId == 2)
2009     hbx4->Fill(float(bx));  // beam2
2010   else if (bxId == 5 || bxId == 6)
2011     hbx5->Fill(float(bx));  // beam1,2+1
2012   else if (bxId == 0)
2013     hbx6->Fill(float(bx));  // empty
2014 
2015 #endif
2016 
2017   // Get Cluster Collection from InputTag
2018   edm::Handle<edmNew::DetSetVector<SiPixelCluster> > clusters;
2019   // New By Token method
2020   e.getByToken(myClus, clusters);
2021 
2022   const edmNew::DetSetVector<SiPixelCluster> &input = *clusters;
2023   int numOf = input.size();
2024 
2025   //edm::LogPrint("TestClusters")<<numOf<<endl;
2026   //if(numOf<1) return; // skip events with no pixels
2027 
2028   //edm::LogPrint("TestClusters")<<"run "<<run<<" event "<<event<<" bx "<<bx<<" lumi "<<lumiBlock<<" orbit "<<orbit<<" "
2029   //  <<numOf<<" lumi "<<instlumi<<endl;
2030 
2031   if (PRINT)
2032     edm::LogPrint("TestClusters") << "run " << run << " event " << event << " bx " << bx << " lumi " << lumiBlock
2033                                   << " orbit " << orbit << " " << numOf << " lumi " << instlumi;
2034 
2035     // For L1
2036     //bool bit0=false; // , bit126=false, bit121=false,bit122=false;
2037     //bool bptx_m=false, bptx_p=false, bptxAnd=false,
2038     //bptx3=false, bptx4=false, bptx5=false, bptx6=false,bptx7=false;
2039     //bool  bcsOR=false, bit32_33=false, bit40=false, bit41=false, halo=false, splash1=false, splash2=false;
2040 
2041 #ifdef L1
2042   // Get L1
2043   Handle<L1GlobalTriggerReadoutRecord> L1GTRR;
2044   e.getByToken(l1gtrrToken_, L1GTRR);
2045 
2046   if (L1GTRR.isValid()) {
2047     //bool l1a = L1GTRR->decision();  // global decission?  unused
2048     const L1GtPsbWord psb = L1GTRR->gtPsbWord(0xbb09, 0);  // select PSB#9 and bunch crossing 0
2049     int techLowNonPres = 65536 * psb.bData(0) + psb.aData(0);
2050     int techHighNonPres = 65536 * psb.bData(1) + psb.aData(1);
2051 
2052     //edm::LogPrint("TestClusters") << hex << "high word: " << ( 65536*psb.bData(1) + psb.aData(1) )
2053     // << " low word: " << ( 65536*psb.bData(0) + psb.aData(0) ) << " "
2054     // <<techLowNonPres<<" "<<techHighNonPres<<dec<<endl;
2055 
2056     //edm::LogPrint("TestClusters")<<" L1 status = "<<l1a<<" : ";
2057     for (unsigned int i = 0; i < L1GTRR->decisionWord().size(); ++i) {
2058       int l1flag = L1GTRR->decisionWord()[i];
2059       int t1flag = L1GTRR->technicalTriggerWord()[i];
2060       int techflag = 0;
2061       if (i < 32)
2062         techflag = (techLowNonPres & (0x1 << i));
2063       else if (i < 64)
2064         techflag = (techHighNonPres & (0x1 << i));
2065 
2066       if (l1flag > 0) {  // look at L1A algoritmic bits
2067         //edm::LogPrint("TestClusters")<<" la "<<i<<" ";
2068         hl1a->Fill(float(i));
2069         //if(i==0) bit0=true;
2070         // 3-pre, 4-bg_bsc, 5-bg_hf, 6-inter_bsc, 7-inter_hf, 8-halo
2071         //else if(i==121) bit121=true;
2072         //else if(i==122) bit122=true;
2073         //else if(i==126) bit126=true; //bscOR and bptx
2074       }
2075       if (techflag > 0 && i < 64) {  // look at nonprescaled technical bits
2076         //edm::LogPrint("TestClusters")<<" t1 "<<i<<" ";
2077         hl1t->Fill(float(i));  // non- prescaled
2078                                //if(i==0) bptxAnd=true;  // bptxAnd
2079                                //else if(i==1) bptx_p=true;
2080                                //else if(i==2) bptx_m=true;
2081                                //else if(i==3) bptx3=true; // OR
2082                                //else if(i==4) bptx4=true; // AND
2083                                //else if(i==5) bptx5=true; // p not m
2084                                //else if(i==6) bptx6=true; // m not p
2085                                //else if(i==7) bptx7=true; // quite
2086                                //else if(i==9) hf=true;
2087                                //else if(i==10) hf=true;
2088       }
2089       if (t1flag > 0 && i < 64) {  // look at prescaled L1T technical bits
2090         //edm::LogPrint("TestClusters")<<" lt "<<i<<" ";
2091         hltt->Fill(float(i));  // prescaled
2092       }
2093 
2094     }  // for loop
2095     //edm::LogPrint("TestClusters")<<dec<<endl;
2096 
2097   }  // if l1a
2098 #endif
2099 
2100   //bool bptx_and = bptx_m && bptx_p;
2101   //bool bptx_or  = bptx_m || bptx_p;
2102   //bool bptx_xor = bptx_or && !bptx_and;
2103 
2104   //---------------------------------------
2105   // Analyse HLT
2106   //bool passHLT1=false,passHLT2=false,passHLT3=false,passHLT4=false,passHLT5=false;
2107   bool hlt[256];
2108   for (int i = 0; i < 256; ++i)
2109     hlt[i] = false;
2110 
2111 #ifdef HLT
2112 
2113   edm::TriggerNames TrigNames;
2114   edm::Handle<edm::TriggerResults> HLTResults;
2115 
2116   // Extract the HLT results
2117   e.getByToken(hltToken_, HLTResults);
2118   if ((HLTResults.isValid() == true) && (HLTResults->size() > 0)) {
2119     //TrigNames.init(*HLTResults);
2120     const edm::TriggerNames &TrigNames = e.triggerNames(*HLTResults);
2121 
2122     //edm::LogPrint("TestClusters")<<TrigNames.triggerNames().size()<<endl;
2123 
2124     for (unsigned int i = 0; i < TrigNames.triggerNames().size(); i++) {  // loop over trigger
2125       if (countAllEvents == 1)
2126         edm::LogPrint("TestClusters") << i << " " << TrigNames.triggerName(i);
2127 
2128       if ((HLTResults->wasrun(TrigNames.triggerIndex(TrigNames.triggerName(i))) == true) &&
2129           (HLTResults->accept(TrigNames.triggerIndex(TrigNames.triggerName(i))) == true) &&
2130           (HLTResults->error(TrigNames.triggerIndex(TrigNames.triggerName(i))) == false)) {
2131         hlt[i] = true;
2132         hlt1->Fill(float(i));
2133 
2134         //  if (      TrigNames.triggerName(i) == "HLT_L1Tech_BSC_minBias") passHLT1=true;
2135         //  else if  (TrigNames.triggerName(i) == "HLT_L1Tech_BSC_minBias_OR") passHLT2=true;
2136         //  else if  (TrigNames.triggerName(i) == "HLT_L1_BptxXOR_BscMinBiasOR")
2137         //    passHLT3=true;
2138         //  else if  (TrigNames.triggerName(i) == "HLT_L1Tech_BSC_halo_forPhysicsBackground") passHLT4=true;
2139         //  //
2140         //  //else if  (TrigNames.triggerName(i) == "HLT_L1_BPTX") passHLT5=true;
2141         //  else if  (TrigNames.triggerName(i) == "HLT_L1_ZeroBias") passHLT5=true;
2142         //  //else if  (TrigNames.triggerName(i) == "HLT_L1_BPTX_MinusOnly") passHLT5=true;
2143         //  //else if  (TrigNames.triggerName(i) == "HLT_L1_BPTX_PlusOnly") passHLT5=true;
2144         //  else if ((TrigNames.triggerName(i) == "HLT_MinBiasPixel_SingleTrac") ||
2145         //       (TrigNames.triggerName(i) == "HLT_MinBiasPixel_DoubleTrack") ||
2146         //       (TrigNames.triggerName(i) == "HLT_MinBiasPixel_DoubleIsoTrack5") )
2147         //    passHLT5=true;
2148 
2149       }  // if hlt
2150 
2151     }  // loop
2152   }  // if valid
2153 #endif  // HLT
2154 
2155 #ifdef USE_RESYNCS
2156   Handle<Level1TriggerScalersCollection> l1ts;
2157   e.getByToken(l1tsToken_, l1ts);
2158 
2159   if (l1ts->size() > 0) {
2160     int r1 = (*l1ts)[0].lastResync();
2161     // int r2 = (*l1ts)[0].lastOrbitCounter0();
2162     // int r3 = (*l1ts)[0].lastEventCounter0();
2163     // int r4 = (*l1ts)[0].lastHardReset();
2164     // int r5 = (*l1ts)[0].eventID();
2165     // int r6 = (*l1ts)[0].bunchNumber();
2166     // int r7 = (*l1ts)[0].lumiSegmentNr();
2167     // int r8 = (*l1ts)[0].lumiSegmentOrbits();
2168     // int r9 = (*l1ts)[0].orbitNr();
2169     // int r10 = (*l1ts)[0].lastStart();
2170 
2171     float t1 = r1 / 2.621E5;              // orbit to LS
2172     float t2 = (orbit - r1) * 88.924E-6;  // orbit diff (event-resync) to time in sec
2173 
2174     //edm::LogPrint("TestClusters")<<"run "<<run<<" event "<<event<<" bx "<<bx<<" lumi "<<lumiBlock<<" orbit "<<orbit<<" "
2175     //<<numOf<<" lumi "<<instlumi<<" - ";
2176     //edm::LogPrint("TestClusters") <<t1<<" "<<t2<<" "<<r1 <<" "<<r2 <<" "<<r3 <<" "<<r4 <<" "<<r5 <<" "<<r6 <<" "<<r7 <<" "<<r8 <<" "<<r9 <<" "<<r10<<endl;
2177 
2178     htest1->Fill(t1);
2179     htest2->Fill(t2);
2180     htest3->Fill(float(r1));
2181     htest4->Fill(float(orbit));
2182   }
2183 
2184 #endif
2185 
2186   //----------------------------------------------
2187 
2188   // Select trigger bits  SELECT-EVENTS
2189   //if( bptx_xor || bptx_and ) return; // select no bptx events
2190   //if(!bptx_and ) return; // select coll  events
2191   //if(!bptx_xor ) return; // select single beams
2192 
2193   // if(select2>0 && select2<11) {
2194   //   if(select2==1 && !bptx_and) return;  // select bptx_and only
2195   //   if(select2==2 && !bptx_xor) return;  // select bptx_xor
2196   //   if(select2==3 && !bptx_or) return;  // select bptx_or
2197   //   if(select2==4 && !bptx_p) return;   // select bptix plus
2198   //   if(select2==5 && !bptx_m) return;  // select bptx minus
2199   //   if(select2==6 && bptx_or) return;  // select NO bptx
2200   // }
2201 
2202   hdets->Fill(float(numOf));  // number of modules with pix
2203 
2204   // Select events with pixels
2205   //if(numOf<1) return; // skip events with  pixel dets
2206 
2207   if (select1 <= 0) {
2208     if (numOf < 4)
2209       return;
2210   }  // skip events with few pixel dets
2211   else {
2212     if (numOf < select1)
2213       return;
2214   }  // skip events with few pixel dets
2215 
2216   hevent->Fill(float(event));
2217   hlumi->Fill(float(lumiBlock));
2218   hbx->Fill(float(bx));
2219   //horbit->Fill(float(orbit));
2220   for (unsigned int i = 0; i < 256; i++)
2221     if (hlt[i] == true)
2222       hlt2->Fill(float(i));
2223 
2224   if (run != runNumberOld) {
2225     runNumberOld = run;
2226     countRuns++;
2227   }
2228   switch (countRuns) {
2229     case 1: {
2230       hlumi10->Fill(float(lumiBlock));
2231       break;
2232     }
2233     case 2: {
2234       hlumi11->Fill(float(lumiBlock));
2235       break;
2236     }
2237     case 3: {
2238       hlumi12->Fill(float(lumiBlock));
2239       break;
2240     }
2241     case 4: {
2242       hlumi13->Fill(float(lumiBlock));
2243       break;
2244     }
2245     case 5: {
2246       hlumi14->Fill(float(lumiBlock));
2247       break;
2248     }
2249     //case 6: {hlumi15->Fill(float(lumiBlock)); break;}
2250     //case 7: {hlumi16->Fill(float(lumiBlock)); break;}
2251     //case 8: {hlumi17->Fill(float(lumiBlock)); break;}
2252     //case 9: {hlumi18->Fill(float(lumiBlock)); break;}
2253     //case 10: {hlumi19->Fill(float(lumiBlock)); break;}
2254     default:
2255       edm::LogPrint("TestClusters") << " too many runs " << countRuns;
2256   }
2257 
2258 #ifdef NEW_ID
2259   //Retrieve tracker topology from geometry
2260   edm::ESHandle<TrackerTopology> tTopo = es.getHandle(trackerTopoToken_);
2261 #endif
2262 
2263   //---------------------------------------
2264 
2265   countEvents++;
2266   int numberOfClusters = 0;
2267   int numberOfPixels = 0;
2268   int numberOfNoneEdgePixels = 0;
2269   int numberOfDetUnits1 = 0;
2270   int numOfClustersPerDet1 = 0;
2271   int numOfClustersPerLay1 = 0;
2272   int numberOfDetUnits2 = 0;
2273   int numOfClustersPerDet2 = 0;
2274   int numOfClustersPerLay2 = 0;
2275   int numberOfDetUnits3 = 0;
2276   int numOfClustersPerDet3 = 0;
2277   int numOfClustersPerLay3 = 0;
2278 
2279   int numOfPixPerLay1 = 0;
2280   int numOfPixPerLay2 = 0;
2281   int numOfPixPerLay3 = 0;
2282 
2283   int numOfPixPerDet1 = 0;
2284   int numOfPixPerDet2 = 0;
2285   int numOfPixPerDet3 = 0;
2286 
2287   int numOfPixPerLink11 = 0;
2288   int numOfPixPerLink12 = 0;
2289   int numOfPixPerLink21 = 0;
2290   int numOfPixPerLink22 = 0;
2291   //int numOfPixPerLink3=0;
2292 
2293   int maxClusPerDet = 0;
2294   int maxPixPerDet = 0;
2295   unsigned int maxPixPerClu = 0;
2296 
2297   int numOfClustersPerDisk1 = 0;
2298   int numOfClustersPerDisk2 = 0;
2299   int numOfClustersPerDisk3 = 0;
2300   int numOfClustersPerDisk4 = 0;
2301   int numOfPixPerDisk1 = 0;
2302   int numOfPixPerDisk2 = 0;
2303   int numOfPixPerDisk3 = 0;
2304   int numOfPixPerDisk4 = 0;
2305 
2306   //float avCharge1 = 0., avCharge2 = 0., avCharge3 = 0., avCharge4 = 0., avCharge5 = 0.;
2307 
2308   //static int module1[416][160] = {{0}};
2309   //static int module2[416][160] = {{0}};
2310   //static int module3[416][160] = {{0}};
2311 
2312   // get vector of detunit ids
2313   //--- Loop over detunits.
2314   edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter = input.begin();
2315   for (; DSViter != input.end(); DSViter++) {
2316     //bool valid = false;
2317     unsigned int detid = DSViter->detId();
2318     // Det id
2319     DetId detId = DetId(detid);             // Get the Detid object
2320     unsigned int detType = detId.det();     // det type, pixel=1
2321     unsigned int subid = detId.subdetId();  //subdetector type, barrel=1
2322 
2323     if (PRINT)
2324       edm::LogPrint("TestClusters") << "Det: " << detId.rawId() << " " << detId.null() << " " << detType << " "
2325                                     << subid;
2326 
2327 #ifdef HISTOS
2328       //hdetunit->Fill(float(detid));
2329       //hpixid->Fill(float(detType));
2330       //hpixsubid->Fill(float(subid));
2331 #endif  // HISTOS
2332 
2333     if (detType != 1)
2334       continue;  // look only at pixels
2335 
2336     //const GeomDetUnit * genericDet = geom->idToDet(detId);
2337     //const PixelGeomDetUnit * pixDet =
2338     //dynamic_cast<const PixelGeomDetUnit*>(genericDet);
2339 
2340     // Get the geom-detector
2341     const PixelGeomDetUnit *theGeomDet = dynamic_cast<const PixelGeomDetUnit *>(theTracker.idToDet(detId));
2342     double detZ = theGeomDet->surface().position().z();
2343     double detR = theGeomDet->surface().position().perp();
2344 
2345     //const BoundPlane& plane = theGeomDet->surface(); //for transf.
2346 
2347     //double detThick = theGeomDet->specificSurface().bounds().thickness();
2348     //int cols = theGeomDet->specificTopology().ncolumns();
2349     //int rows = theGeomDet->specificTopology().nrows();
2350 
2351     const PixelTopology *topol = &(theGeomDet->specificTopology());
2352 
2353     // barrel ids
2354     unsigned int layerC = 0;
2355     unsigned int ladderC = 0;
2356     unsigned int zindex = 0;
2357     int shell = 0;      // shell id // Shell { mO = 1, mI = 2 , pO =3 , pI =4 };
2358     int sector = 0;     // 1-8
2359     int ladder = 0;     // 1-22
2360     int layer = 0;      // 1-3
2361     int module = 0;     // 1-4
2362     bool half = false;  //
2363 
2364     // Endcap ids
2365     unsigned int disk = 0;     //1,2,3
2366     unsigned int blade = 0;    //1-24
2367     unsigned int zindexF = 0;  //
2368     unsigned int side = 0;     //size=1 for -z, 2 for +z
2369     unsigned int panel = 0;    //panel=1
2370 
2371     edmNew::DetSet<SiPixelCluster>::const_iterator clustIt;
2372 
2373     // Subdet id, pix barrel=1, forward=2
2374     if (subid == 2) {  // forward
2375 
2376 #ifdef NEW_ID
2377       disk = tTopo->pxfDisk(detid);      //1,2,3
2378       blade = tTopo->pxfBlade(detid);    //1-24
2379       zindex = tTopo->pxfModule(detid);  //
2380       side = tTopo->pxfSide(detid);      //size=1 for -z, 2 for +z
2381       panel = tTopo->pxfPanel(detid);    //panel=1
2382 #else
2383       PXFDetId pdetId = PXFDetId(detid);
2384       disk = pdetId.disk();       //1,2,3
2385       blade = pdetId.blade();     //1-24
2386       moduleF = pdetId.module();  // plaquette
2387       side = pdetId.side();       //size=1 for -z, 2 for +z
2388       panel = pdetId.panel();     //panel=1
2389 #endif
2390 
2391       if (PRINT)
2392         edm::LogPrint("TestClusters") << " forward det, disk " << disk << ", blade " << blade << ", module " << zindexF
2393                                       << ", side " << side << ", panel " << panel << " pos = " << detZ << " " << detR;
2394 
2395     } else if (subid == 1) {  // barrel
2396 
2397 #ifdef NEW_ID
2398       layerC = tTopo->pxbLayer(detid);
2399       ladderC = tTopo->pxbLadder(detid);
2400       zindex = tTopo->pxbModule(detid);
2401       PixelBarrelName pbn(detid);
2402 #else
2403       PXBDetId pdetId = PXBDetId(detid);
2404       //unsigned int detTypeP=pdetId.det();
2405       //unsigned int subidP=pdetId.subdetId();
2406       // Barell layer = 1,2,3
2407       layerC = pdetId.layer();
2408       // Barrel ladder id 1-20,32,44.
2409       ladderC = pdetId.ladder();
2410       // Barrel Z-index=1,8
2411       zindex = pdetId.module();
2412       // Convert to online
2413       PixelBarrelName pbn(pdetId);
2414 #endif
2415 
2416       // Shell { mO = 1, mI = 2 , pO =3 , pI =4 };
2417       PixelBarrelName::Shell sh = pbn.shell();  //enum
2418       sector = pbn.sectorName();
2419       ladder = pbn.ladderName();
2420       layer = pbn.layerName();
2421       module = pbn.moduleName();
2422       half = pbn.isHalfModule();
2423       shell = int(sh);
2424       // change the module sign for z<0
2425       if (shell == 1 || shell == 2)
2426         module = -module;
2427       // change ladeer sign for Outer )x<0)
2428       if (shell == 1 || shell == 3)
2429         ladder = -ladder;
2430 
2431       if (PRINT) {
2432         edm::LogPrint("TestClusters") << " Barrel layer, ladder, module " << layerC << " " << ladderC << " " << zindex
2433                                       << " " << sh << "(" << shell << ") " << sector << " " << layer << " " << ladder
2434                                       << " " << module << " " << half;
2435         //edm::LogPrint("TestClusters")<<" Barrel det, thick "<<detThick<<" "
2436         //  <<" layer, ladder, module "
2437         //  <<layer<<" "<<ladder<<" "<<zindex<<endl;
2438         //edm::LogPrint("TestClusters")<<" col/row, pitch "<<cols<<" "<<rows<<" "
2439         //  <<pitchX<<" "<<pitchY<<endl;
2440       }
2441 
2442     }  // if subid
2443 
2444     if (PRINT) {
2445       edm::LogPrint("TestClusters") << "List clusters : ";
2446       edm::LogPrint("TestClusters") << "Num Charge Size SizeX SizeY X Y Xmin Xmax Ymin Ymax Edge";
2447     }
2448 
2449     // Loop over clusters
2450     for (clustIt = DSViter->begin(); clustIt != DSViter->end(); clustIt++) {
2451       sumClusters++;
2452       numberOfClusters++;
2453       float ch = float(clustIt->charge()) / 1000.;  // convert ke to electrons
2454       int size = clustIt->size();
2455       int sizeX = clustIt->sizeX();  //x=row=rfi,
2456       int sizeY = clustIt->sizeY();  //y=col=z_global
2457       float x = clustIt->x();        // row, cluster position in pitch units, as float (int+0.5)
2458       float y = clustIt->y();        // col, analog average
2459       // Returns int index of the cluster min/max
2460       int minPixelRow = clustIt->minPixelRow();  //x
2461       int maxPixelRow = clustIt->maxPixelRow();
2462       int minPixelCol = clustIt->minPixelCol();  //y
2463       int maxPixelCol = clustIt->maxPixelCol();
2464 
2465       //unsigned int geoId = clustIt->geographicalId(); // always 0?!
2466       // edge method moved to topologu class
2467       bool edgeHitX = (topol->isItEdgePixelInX(minPixelRow)) || (topol->isItEdgePixelInX(maxPixelRow));
2468       bool edgeHitY = (topol->isItEdgePixelInY(minPixelCol)) || (topol->isItEdgePixelInY(maxPixelCol));
2469 
2470       bool edgeHitX2 = false;  // edge method moved
2471       bool edgeHitY2 = false;  // to topologu class
2472 
2473       if (PRINT)
2474         edm::LogPrint("TestClusters") << numberOfClusters << " " << ch << " " << size << " " << sizeX << " " << sizeY
2475                                       << " " << x << " " << y << " " << minPixelRow << " " << maxPixelRow << " "
2476                                       << minPixelCol << " " << maxPixelCol << " " << edgeHitX << " " << edgeHitY;
2477 
2478       // get global z position of teh cluster
2479       LocalPoint lp = topol->localPosition(MeasurementPoint(x, y));
2480       float lx = lp.x();  // local cluster position in cm
2481       float ly = lp.y();
2482 
2483       float zPos = detZ - ly;
2484       float rPos = detR + lx;
2485 
2486       // Get the pixels in the Cluster
2487       const vector<SiPixelCluster::Pixel> &pixelsVec = clustIt->pixels();
2488       if (PRINT)
2489         edm::LogPrint("TestClusters") << " Pixels in this cluster ";
2490       //bool bigInX=false, bigInY=false;
2491       // Look at pixels in this cluster. ADC is calibrated, in electrons
2492       bool edgeInX = false;  // edge method moved
2493       bool edgeInY = false;  // to topologu class
2494       //bool cluBigInX = false; // does this clu include a big pixel
2495       //bool cluBigInY = false; // does this clu include a big pixel
2496       //int noisy = 0;
2497 
2498       if (pixelsVec.size() > maxPixPerClu)
2499         maxPixPerClu = pixelsVec.size();
2500 
2501       for (unsigned int i = 0; i < pixelsVec.size(); ++i) {  // loop over pixels
2502         sumPixels++;
2503         numberOfPixels++;
2504         float pixx = pixelsVec[i].x;  // index as float=iteger, row index
2505         float pixy = pixelsVec[i].y;  // same, col index
2506         float adc = (float(pixelsVec[i].adc) / 1000.);
2507 #ifdef ROC_EFF
2508         int roc = rocId(int(pixy), int(pixx));  // column, row
2509 #endif
2510         //int chan = PixelChannelIdentifier::pixelToChannel(int(pixx),int(pixy));
2511 
2512         bool bigInX = topol->isItBigPixelInX(int(pixx));
2513         bool bigInY = topol->isItBigPixelInY(int(pixy));
2514         if (!(bigInX || bigInY))
2515           numberOfNoneEdgePixels++;
2516 
2517 #ifdef HISTOS
2518         // Pixel histos
2519         if (subid == 1 && (selectEvent == -1 || countEvents == selectEvent)) {  // barrel
2520           if (layer == 1) {
2521             numOfPixPerDet1++;
2522             numOfPixPerLay1++;
2523             //valid = valid || true;
2524             hpixcharge1->Fill(adc);
2525             hpixDetMap1->Fill(pixy, pixx);
2526             hpDetMap1->Fill(float(module), float(ladder));
2527             //module1[int(pixx)][int(pixy)]++;
2528 
2529             hpcols1->Fill(pixy);
2530             hprows1->Fill(pixx);
2531 
2532             if (ladder == -1 && module == -1)
2533               hpixDetMap10->Fill(pixy, pixx);  // ineff
2534             //else if(ladder==-4 && module==-1) hpixDetMap11->Fill(pixy,pixx); // ineff
2535             //else if(ladder== 2 && module== 2) hpixDetMap12->Fill(pixy,pixx); // ineff
2536             else if (ladder == 2 && module == 8)
2537               hpixDetMap11->Fill(pixy, pixx);  // roc ineff (1run)
2538             else if (ladder == 2 && module == -2)
2539               hpixDetMap12->Fill(pixy, pixx);  // roc ineff (1 run)
2540 
2541             else if (ladder == -9 && module == 4)
2542               hpixDetMap13->Fill(pixy, pixx);  // ineff
2543             else if (ladder == -8 && module == -4)
2544               hpixDetMap14->Fill(pixy, pixx);  // bad al, ENE
2545             else if (ladder == 6 && module == 4)
2546               hpixDetMap15->Fill(pixy, pixx);  // pix 0,0
2547             else if (ladder == 9 && module == 4)
2548               hpixDetMap16->Fill(pixy, pixx);  // gain low off
2549             else if (ladder == -3 && module == -3)
2550               hpixDetMap17->Fill(pixy, pixx);  // bad col
2551             else if (ladder == -7 && module == -4)
2552               hpixDetMap18->Fill(pixy, pixx);  // bad col
2553             else if (ladder == -5 && module == -4)
2554               hpixDetMap19->Fill(pixy, pixx);  // low ROC eff (1 run)
2555 
2556             //if(module1[int(pixx)][int(pixy)]>MAX_CUT)
2557             //edm::LogPrint("TestClusters")<<" module "<<layer<<" "<<ladder<<" "<<module<<" "
2558             //  <<pixx<<" "<<pixy<<" "<<module1[int(pixx)][int(pixy)]<<endl;
2559 
2560             if (pixx < 80.)
2561               numOfPixPerLink11++;
2562             else
2563               numOfPixPerLink12++;
2564 
2565             hpixchar1->Fill(zPos, adc);
2566             hcharPixbx->Fill(bx, adc);
2567             hcharPixls->Fill(lumiBlock, adc);
2568             hcharPixLumi->Fill(instlumi, adc);
2569 
2570 #ifdef VDM_STUDIES
2571             hcharPixls1->Fill(lumiBlock, adc);
2572 #endif
2573 
2574 #if defined(BX) || defined(BX_NEW)
2575             if (bxId > -1) {
2576               if (bxId == 3)
2577                 hpixChargebx1->Fill(adc);  // coll
2578               else if (bxId == 4)
2579                 hpixChargebx2->Fill(adc);  // coll+1
2580               else if (bxId == 0)
2581                 hpixChargebx6->Fill(adc);  // empty
2582               else if (bxId == 1)
2583                 hpixChargebx3->Fill(adc);  // beam1
2584               else if (bxId == 2)
2585                 hpixChargebx3->Fill(adc);  // beam2
2586               else if (bxId == 5 || bxId == 6)
2587                 hpixChargebx5->Fill(adc);  // beam1/2+1
2588               else
2589                 edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
2590             }
2591 #endif
2592 
2593 #ifdef ROC_EFF
2594             pixEff->addPixel(1, ladder, module, roc);  // count pixels
2595 
2596             //index = lumiBlock/5;
2597             //     if     (ladder== 3 && module== 3)  hmoduleHits1ls->Fill(float(lumiBlock),0);
2598             //     if     (ladder==-9 && module==-3 && roc== 9)  hrocHits1ls->Fill(float(lumiBlock),0);
2599             //     else if(ladder==-9 && module==-1 && roc== 0)  hrocHits1ls->Fill(float(lumiBlock),1);
2600             //     else if(ladder==-8 && module==-1 && roc== 2)  hrocHits1ls->Fill(float(lumiBlock),2);
2601             //     else if(ladder==-8 && module== 1 && roc== 2)  hrocHits1ls->Fill(float(lumiBlock),3);
2602             //     else if(ladder==-4 && module==-2 && roc== 2)  hrocHits1ls->Fill(float(lumiBlock),4);
2603             //     else if(ladder== 2 && module== 2 && roc== 4)  hrocHits1ls->Fill(float(lumiBlock),5);
2604             //     else if(ladder== 3 && module==-2 && roc== 4)  hrocHits1ls->Fill(float(lumiBlock),6);
2605             //     else if(ladder== 3 && module== 1 && roc== 6)  hrocHits1ls->Fill(float(lumiBlock),7);
2606             //     else if(ladder== 4 && module== 3 && roc== 8)  hrocHits1ls->Fill(float(lumiBlock),8);
2607             //     else if(ladder== 8 && module==-4 && roc==11)  hrocHits1ls->Fill(float(lumiBlock),9);
2608             // run 176286
2609             //if     (ladder==-3 && module== 1 && roc== 5)  hrocHits1ls->Fill(float(lumiBlock),0);
2610             //else if(ladder== 2 && module==-1 && roc==13)  hrocHits1ls->Fill(float(lumiBlock),1);
2611             //else if(ladder== 3 && module== 4 && roc== 9)  hrocHits1ls->Fill(float(lumiBlock),2);
2612             //else if(ladder== 5 && module== 2 && roc== 3)  hrocHits1ls->Fill(float(lumiBlock),3);
2613             //else if(ladder== 7 && module==-1 && roc== 8)  hrocHits1ls->Fill(float(lumiBlock),4);
2614             //else if(ladder== 2 && module== 1 && roc== 0)  hrocHits1ls->Fill(float(lumiBlock),5);
2615             // run 180250
2616             if (ladder == -9 && module == 4 && roc == 12)
2617               hrocHits1ls->Fill(float(lumiBlock), 0);
2618             else if (ladder == -7 && module == -4 && roc == 3)
2619               hrocHits1ls->Fill(float(lumiBlock), 1);
2620             else if (ladder == -5 && module == -4 && roc == 11)
2621               hrocHits1ls->Fill(float(lumiBlock), 2);
2622             else if (ladder == 2 && module == -2 && roc == 1)
2623               hrocHits1ls->Fill(float(lumiBlock), 3);
2624             else if (ladder == 8 && module == 2 && roc == 1)
2625               hrocHits1ls->Fill(float(lumiBlock), 4);
2626               //else if(ladder== 2 && module== 1 && roc== 0)  hrocHits1ls->Fill(float(lumiBlock),5);
2627 #endif
2628 
2629           } else if (layer == 2) {
2630             numOfPixPerDet2++;
2631             numOfPixPerLay2++;
2632 
2633             hpcols2->Fill(pixy);
2634             hprows2->Fill(pixx);
2635 
2636             if (ladder == -11 && module == -2)
2637               hpixDetMap20->Fill(pixy, pixx);  // ineff
2638             else if (ladder == -7 && module == -3)
2639               hpixDetMap21->Fill(pixy, pixx);  // ineff
2640             else if (ladder == -2 && module == 1)
2641               hpixDetMap22->Fill(pixy, pixx);  // ineff
2642             else if (ladder == -14 && module == 4)
2643               hpixDetMap23->Fill(pixy, pixx);  // ineff
2644             else if (ladder == -14 && module == 1)
2645               hpixDetMap24->Fill(pixy, pixx);  // bad al
2646             else if (ladder == -14 && module == -1)
2647               hpixDetMap25->Fill(pixy, pixx);  // evn errors
2648             //else if(ladder== 14 && module== 2) hpixDetMap26->Fill(pixy,pixx); // gain cal poor eff
2649             else if (ladder == -4 && module == 4)
2650               hpixDetMap26->Fill(pixy, pixx);  // bad dcol
2651             else if (ladder == 6 && module == -2)
2652               hpixDetMap27->Fill(pixy, pixx);  // bad dcol
2653             //else if(ladder==-4  && module== 2) hpixDetMap28->Fill(pixy,pixx); // pix0
2654 
2655             else if (ladder == -10 && module == -3)
2656               hpixDetMap28->Fill(pixy, pixx);  // roc eff 1 run
2657             else if (ladder == 14 && module == 3)
2658               hpixDetMap29->Fill(pixy, pixx);  // "
2659 
2660             if (pixx < 80.)
2661               numOfPixPerLink21++;
2662             else
2663               numOfPixPerLink22++;
2664 
2665 #if defined(BX) || defined(BX_NEW)
2666             if (bxId > -1) {
2667               if (bxId == 3)
2668                 hpixChargebx1->Fill(adc);  // coll
2669               else if (bxId == 4)
2670                 hpixChargebx2->Fill(adc);  // coll+1
2671               else if (bxId == 0)
2672                 hpixChargebx6->Fill(adc);  // empty
2673               else if (bxId == 1)
2674                 hpixChargebx3->Fill(adc);  // beam1
2675               else if (bxId == 2)
2676                 hpixChargebx3->Fill(adc);  // beam2
2677               else if (bxId == 5 || bxId == 6)
2678                 hpixChargebx5->Fill(adc);  // beam1/2+1
2679               else
2680                 edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
2681             }
2682 #endif
2683 
2684 #ifdef ROC_EFF
2685             pixEff->addPixel(2, ladder, module, roc);
2686 
2687             //index = lumiBlock/5;
2688             //      if     (ladder==10 && module== 2)  hmoduleHits2ls->Fill(float(lumiBlock),0); // many resyncs
2689 
2690             //     if     (ladder==-2 && module== 1 && roc==10)  hrocHits2ls->Fill(float(lumiBlock),0);
2691             //     else if(ladder== 1 && module== 1 && roc== 3)  hrocHits2ls->Fill(float(lumiBlock),1);
2692             //     else if(ladder== 1 && module== 2 && roc== 4)  hrocHits2ls->Fill(float(lumiBlock),2);
2693             //     else if(ladder== 2 && module==-4 && roc== 3)  hrocHits2ls->Fill(float(lumiBlock),3);
2694             //     else if(ladder==10 && module==-3 && roc== 1)  hrocHits2ls->Fill(float(lumiBlock),4);
2695             //     else if(ladder==10 && module==-1 && roc==10)  hrocHits2ls->Fill(float(lumiBlock),5);
2696             //     else if(ladder==11 && module== 3 && roc==13)  hrocHits2ls->Fill(float(lumiBlock),6);
2697             //     else if(ladder==12 && module==-4 && roc==14)  hrocHits2ls->Fill(float(lumiBlock),7);
2698             //     else if(ladder==12 && module==-1 && roc== 3)  hrocHits2ls->Fill(float(lumiBlock),8);
2699             //     else if(ladder==-5 && module==-2 && roc==10)  hrocHits2ls->Fill(float(lumiBlock),9);
2700             //     else if(ladder==10 && module== 2 && roc== 0)  hrocHits3ls->Fill(float(lumiBlock),9); // many resuncs
2701 
2702             // run 176286
2703             //if     (ladder==-5 && module==-2 && roc==10)  hrocHits2ls->Fill(float(lumiBlock),0);
2704             //else if(ladder==-2 && module==-4 && roc==12)  hrocHits2ls->Fill(float(lumiBlock),1);
2705             //else if(ladder==15 && module==-1 && roc==11)  hrocHits2ls->Fill(float(lumiBlock),2);
2706             //else if(ladder== 2 && module==1  && roc== 0)  hrocHits2ls->Fill(float(lumiBlock),3);
2707             // run 180250
2708             if (ladder == -2 && module == 1 && roc == 10)
2709               hrocHits2ls->Fill(float(lumiBlock), 0);
2710             else if (ladder == 10 && module == -3 && roc == 2)
2711               hrocHits2ls->Fill(float(lumiBlock), 1);
2712             else if (ladder == 15 && module == 3 && roc == 7)
2713               hrocHits2ls->Fill(float(lumiBlock), 2);
2714               //else if(ladder== 2 && module==1  && roc== 0)  hrocHits2ls->Fill(float(lumiBlock),3);
2715 #endif
2716 
2717             hpixcharge2->Fill(adc);
2718             hpixDetMap2->Fill(pixy, pixx);
2719             hpDetMap2->Fill(float(module), float(ladder));
2720             //module2[int(pixx)][int(pixy)]++;
2721 
2722             hpixchar2->Fill(zPos, adc);
2723             hcharPixbx->Fill(bx, adc);
2724             hcharPixls->Fill(lumiBlock, adc);
2725             hcharPixLumi->Fill(instlumi, adc);
2726 
2727 #ifdef VDM_STUDIES
2728             hcharPixls2->Fill(lumiBlock, adc);
2729 #endif
2730             //if( (ladder==-11 && module==-1) || (ladder==-11 && module== 1) ) {
2731             //hpixchargen->Fill(adc);
2732             //if(       ladder==-11 && module==-1 ) hpixchargen1->Fill(adc);
2733             //else if ( ladder==-11 && module== 1 ) hpixchargen2->Fill(adc);
2734             //}
2735 
2736             //if(module2[int(pixx)][int(pixy)]>MAX_CUT)
2737             // edm::LogPrint("TestClusters")<<" module "<<layer<<" "<<ladder<<" "<<module<<" "
2738             //  <<pixx<<" "<<pixy<<" "<<module2[int(pixx)][int(pixy)]<<endl;
2739 
2740           } else if (layer == 3) {
2741             numOfPixPerDet3++;
2742             numOfPixPerLay3++;
2743             //valid = valid || true;
2744             hpixcharge3->Fill(adc);
2745             hpixDetMap3->Fill(pixy, pixx);
2746             //if(ladder==l3ldr&&module==l3mod) hpixDetMap30->Fill(pixy,pixx,adc);
2747             hpDetMap3->Fill(float(module), float(ladder));
2748             //module3[int(pixx)][int(pixy)]++;
2749 
2750             hpcols3->Fill(pixy);
2751             hprows3->Fill(pixx);
2752 
2753             if (ladder == -5 && module == -4)
2754               hpixDetMap30->Fill(pixy, pixx);  // ineff
2755             else if (ladder == 9 && module == 4)
2756               hpixDetMap31->Fill(pixy, pixx);  // adr errors, NOR
2757             else if (ladder == 15 && module == -3)
2758               hpixDetMap32->Fill(pixy, pixx);  // ineff
2759             else if (ladder == 17 && module == -4)
2760               hpixDetMap33->Fill(pixy, pixx);  // ineff, NOR
2761             //else if(ladder== 6   && module== 4) hpixDetMap34->Fill(pixy,pixx); // gain ineff
2762             //else if(ladder==-14  && module==-3) hpixDetMap35->Fill(pixy,pixx); // gain low slope
2763             else if (ladder == -6 && module == -1)
2764               hpixDetMap34->Fill(pixy, pixx);  // roc eff 1 run
2765             else if (ladder == -13 && module == 4)
2766               hpixDetMap35->Fill(pixy, pixx);  // "
2767             else if (ladder == 14 && module == -4)
2768               hpixDetMap36->Fill(pixy, pixx);  // ineff pixel alive
2769             else if (ladder == -6 && module == 2)
2770               hpixDetMap37->Fill(pixy, pixx);  // E pattern
2771             else if (ladder == 19 && module == -4)
2772               hpixDetMap38->Fill(pixy, pixx);  // large thr.
2773             //else if(ladder==-8   && module==-1) hpixDetMap39->Fill(pixy,pixx); // large thr rms
2774             //else if(ladder== 11 && module== 1) hpixDetMap39->Fill(pixy,pixx); // old ROCs
2775             else if (ladder == -7 && module == -4)
2776               hpixDetMap39->Fill(pixy, pixx);  // roc eff (1 run)
2777 
2778             hpixchar3->Fill(zPos, adc);
2779             hcharPixbx->Fill(bx, adc);
2780             hcharPixls->Fill(lumiBlock, adc);
2781             hcharPixLumi->Fill(instlumi, adc);
2782 
2783             //      if(     countEvents== 66  && ladder==-17 && module== 4) hpixDetMap300->Fill(pixy,pixx);
2784             //      else if(countEvents==502  && ladder== 14 && module== 3) hpixDetMap301->Fill(pixy,pixx);
2785             //      else if(countEvents==1830 && ladder== 14 && module==-2) hpixDetMap302->Fill(pixy,pixx);
2786             //      else if(countEvents==4720 && ladder== 12 && module==-3) hpixDetMap303->Fill(pixy,pixx);
2787             //      else if(countEvents==7241 && ladder== -2 && module== 4) hpixDetMap304->Fill(pixy,pixx);
2788             //      else if(countEvents==8845 && ladder== -5 && module== 4) hpixDetMap305->Fill(pixy,pixx);
2789             //      else if(countEvents==9267 && ladder==  6 && module== 4) hpixDetMap306->Fill(pixy,pixx);
2790 
2791             //if(module3[int(pixx)][int(pixy)]>MAX_CUT)
2792             //edm::LogPrint("TestClusters")<<" module "<<layer<<" "<<ladder<<" "<<module<<" "
2793             //  <<pixx<<" "<<pixy<<" "<<module3[int(pixx)][int(pixy)]<<endl;
2794 
2795 #ifdef VDM_STUDIES
2796             hcharPixls3->Fill(lumiBlock, adc);
2797 #endif
2798 
2799 #if defined(BX) || defined(BX_NEW)
2800             if (bxId > -1) {
2801               if (bxId == 3)
2802                 hpixChargebx1->Fill(adc);  // coll
2803               else if (bxId == 4)
2804                 hpixChargebx2->Fill(adc);  // coll+1
2805               else if (bxId == 0)
2806                 hpixChargebx6->Fill(adc);  // empty
2807               else if (bxId == 1)
2808                 hpixChargebx3->Fill(adc);  // beam1
2809               else if (bxId == 2)
2810                 hpixChargebx3->Fill(adc);  // beam2
2811               else if (bxId == 5 || bxId == 6)
2812                 hpixChargebx5->Fill(adc);  // beam1/2+1
2813               else
2814                 edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
2815             }
2816 #endif
2817 
2818 #ifdef ROC_EFF
2819             pixEff->addPixel(3, ladder, module, roc);
2820 
2821             //index = lumiBlock/5;
2822             //      if     (ladder==11 && module== 1)  hmoduleHits3ls->Fill(float(lumiBlock),0);
2823 
2824             //      if     (ladder==-18 && module==-3 && roc== 0)  hrocHits3ls->Fill(float(lumiBlock),0);
2825             //      else if(ladder== 5  && module== 1 && roc== 5)  hrocHits3ls->Fill(float(lumiBlock),1);
2826             //      else if(ladder== 9  && module==-1 && roc== 2)  hrocHits3ls->Fill(float(lumiBlock),2);
2827             //      else if(ladder==10  && module==-3 && roc== 8)  hrocHits3ls->Fill(float(lumiBlock),3);
2828             //      else if(ladder==12  && module==-3 && roc==12)  hrocHits3ls->Fill(float(lumiBlock),4);
2829             //      else if(ladder==-18 && module==-2 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),5);
2830             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),6);
2831             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),7);
2832             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),8);
2833             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),9);
2834 
2835             // run 176286
2836             //if     (ladder==-18 && module==-2 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),0);
2837             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),1);
2838             //else if(ladder== 3  && module==-1 && roc==12)  hrocHits3ls->Fill(float(lumiBlock),2);
2839             //else if(ladder==16  && module==-3 && roc== 6)  hrocHits3ls->Fill(float(lumiBlock),3);
2840             //else if(ladder== 2  && module== 1 && roc== 0)  hrocHits3ls->Fill(float(lumiBlock),4);
2841             // run 180250
2842             if (ladder == -13 && module == 4 && roc == 12)
2843               hrocHits3ls->Fill(float(lumiBlock), 0);
2844             else if (ladder == -7 && module == -4 && roc == 15)
2845               hrocHits3ls->Fill(float(lumiBlock), 1);
2846             else if (ladder == -6 && module == -2 && roc == 10)
2847               hrocHits3ls->Fill(float(lumiBlock), 2);
2848               //else if(ladder==16  && module==-3 && roc== 6)  hrocHits3ls->Fill(float(lumiBlock),3);
2849               //else if(ladder== 2  && module== 1 && roc== 0)  hrocHits3ls->Fill(float(lumiBlock),4);
2850 
2851 #endif
2852 
2853           }  // if layer
2854 
2855         } else if (subid == 2 && (selectEvent == -1 || countEvents == selectEvent)) {  // endcap
2856           // pixels
2857 
2858           if (disk == 1) {  // disk1 -+z
2859             if (side == 1)
2860               numOfPixPerDisk2++;  // d1,-z
2861             else if (side == 2)
2862               numOfPixPerDisk3++;  // d1, +z
2863             else
2864               edm::LogPrint("TestClusters") << " unknown side " << side;
2865 
2866             hpixcharge4->Fill(adc);
2867             hpixDiskR1->Fill(rPos);
2868 
2869           } else if (disk == 2) {  // disk2 -+z
2870 
2871             if (side == 1)
2872               numOfPixPerDisk1++;  // d2, -z
2873             else if (side == 2)
2874               numOfPixPerDisk4++;  // d2, +z
2875             else
2876               edm::LogPrint("TestClusters") << " unknown side " << side;
2877 
2878             hpixcharge5->Fill(adc);
2879             hpixDiskR2->Fill(rPos);
2880 
2881           } else
2882             edm::LogPrint("TestClusters") << " unknown disk " << disk;
2883 
2884         }  // end if subdet (pixel loop)
2885 
2886 #endif  // HISTOS
2887 
2888         // Find if this cluster includes an edge pixel
2889         edgeInX = topol->isItEdgePixelInX(int(pixx));
2890         edgeInY = topol->isItEdgePixelInY(int(pixy));
2891 
2892         if (PRINT)
2893           edm::LogPrint("TestClusters") << i << " " << pixx << " " << pixy << " " << adc << " " << bigInX << " "
2894                                         << bigInY << " " << edgeInX << " " << edgeInY;
2895 
2896         if (edgeInX)
2897           edgeHitX2 = true;
2898         if (edgeInY)
2899           edgeHitY2 = true;
2900         //if(bigInX) cluBigInX=true;
2901         //if(bigInY) cluBigInY=true;
2902 
2903       }  // pixel loop
2904 
2905 #ifdef HISTOS
2906 
2907       // Cluster histos
2908       if (subid == 1 && (selectEvent == -1 || countEvents == selectEvent)) {  // barrel
2909         //if (subid==1) {  // barrel
2910 
2911         if (layer == 1) {  // layer 1
2912 
2913           hDetMap1->Fill(float(module), float(ladder));
2914           hsizeDetMap1->Fill(float(module), float(ladder), float(size));
2915           //hsizeXDetMap1->Fill(float(module),float(ladder),float(sizeX));
2916           //hsizeYDetMap1->Fill(float(module),float(ladder),float(sizeY));
2917 
2918           hcluDetMap1->Fill(y, x);
2919           hcharge1->Fill(ch);
2920           //hcols1->Fill(y);
2921           //hrows1->Fill(x);
2922           hsize1->Fill(float(size));
2923           hsizex1->Fill(float(sizeX));
2924           hsizey1->Fill(float(sizeY));
2925           numOfClustersPerDet1++;
2926           numOfClustersPerLay1++;
2927           //avCharge1 += ch;
2928 
2929           //if(numOf<10) hcharge11->Fill(ch);
2930           //else if(numOf<25) hcharge12->Fill(ch);
2931           //else if(numOf<100) hcharge13->Fill(ch);
2932           //else hcharge14->Fill(ch);
2933 
2934           hgz1->Fill(zPos);
2935           hclumult1->Fill(zPos, size);
2936           hclumultx1->Fill(zPos, sizeX);
2937           hclumulty1->Fill(zPos, sizeY);
2938           hcluchar1->Fill(zPos, ch);
2939 
2940 #if defined(BX) || defined(BX_NEW)
2941           if (bxId > -1) {
2942             if (bxId == 3) {
2943               hchargebx1->Fill(ch);
2944               hsizebx1->Fill(size);
2945             }  // coll
2946             else if (bxId == 4) {
2947               hchargebx2->Fill(ch);
2948               hsizebx2->Fill(size);
2949             }  // coll+1
2950             else if (bxId == 0) {
2951               hchargebx6->Fill(ch);
2952               hsizebx6->Fill(size);
2953             }  // empty
2954             else if (bxId == 1) {
2955               hchargebx3->Fill(ch);
2956               hsizebx3->Fill(size);
2957             }  // beam1
2958             else if (bxId == 2) {
2959               hchargebx4->Fill(ch);
2960               hsizebx3->Fill(size);
2961             }  // beam2
2962             else if (bxId == 5 || bxId == 6) {
2963               hchargebx5->Fill(ch);
2964               hsizebx5->Fill(size);
2965             }  // beam1/2+1
2966             else
2967               edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
2968           }
2969           //if(bxId==0) htestbx->Fill(bx,ch);
2970 #endif
2971 
2972           hcharClubx->Fill(bx, ch);
2973           hsizeClubx->Fill(bx, size);
2974           hsizeYClubx->Fill(bx, sizeY);
2975           hcharCluls->Fill(lumiBlock, ch);
2976           hsizeCluls->Fill(lumiBlock, size);
2977           hsizeXCluls->Fill(lumiBlock, sizeX);
2978 
2979           hcharCluLumi->Fill(instlumi, ch);
2980           hsizeCluLumi->Fill(instlumi, size);
2981           hsizeXCluLumi->Fill(instlumi, sizeX);
2982           hsizeYCluLumi->Fill(instlumi, sizeY);
2983 
2984           //hchargen5->Fill(ch,float(size));
2985           //hchargen3->Fill(ch);
2986           //if(size==1) hchargen4->Fill(ch);
2987 
2988 #ifdef VDM_STUDIES
2989           hcharCluls1->Fill(lumiBlock, ch);
2990           hsizeCluls1->Fill(lumiBlock, size);
2991           hsizeXCluls1->Fill(lumiBlock, sizeX);
2992 #endif
2993 
2994         } else if (layer == 2) {
2995           hDetMap2->Fill(float(module), float(ladder));
2996           hsizeDetMap2->Fill(float(module), float(ladder), float(size));
2997           //hsizeXDetMap2->Fill(float(module),float(ladder),float(sizeX));
2998           //hsizeYDetMap2->Fill(float(module),float(ladder),float(sizeY));
2999 
3000           hcluDetMap2->Fill(y, x);
3001           hcharge2->Fill(ch);
3002           //hcols2->Fill(y);
3003           //hrows2->Fill(x);
3004           hsize2->Fill(float(size));
3005           hsizex2->Fill(float(sizeX));
3006           hsizey2->Fill(float(sizeY));
3007           numOfClustersPerDet2++;
3008           numOfClustersPerLay2++;
3009           //avCharge2 += ch;
3010           hgz2->Fill(zPos);
3011           hclumult2->Fill(zPos, size);
3012           hclumultx2->Fill(zPos, sizeX);
3013           hclumulty2->Fill(zPos, sizeY);
3014           hcluchar2->Fill(zPos, ch);
3015 
3016           if ((ladder == -11 && module == -1) || (ladder == -11 && module == 1)) {
3017             //hchargen->Fill(ch);
3018             //hsizen->Fill(float(size));
3019             //hsizexn->Fill(float(sizeX));
3020             //hsizeyn->Fill(float(sizeY));
3021             // if( (ladder==-11 && module==-1) ) {
3022             //   hchargen1->Fill(ch);
3023             //   hsizen1->Fill(float(size));
3024             //   hsizexn1->Fill(float(sizeX));
3025             //   hsizeyn1->Fill(float(sizeY));
3026             // } else {
3027             //   hchargen2->Fill(ch);
3028             //   hsizen2->Fill(float(size));
3029             //   hsizexn2->Fill(float(sizeX));
3030             //   hsizeyn2->Fill(float(sizeY));
3031             // }
3032           }
3033 
3034 #if defined(BX) || defined(BX_NEW)
3035           if (bxId > -1) {
3036             if (bxId == 3) {
3037               hchargebx1->Fill(ch);
3038               hsizebx1->Fill(size);
3039             }  // coll
3040             else if (bxId == 4) {
3041               hchargebx2->Fill(ch);
3042               hsizebx2->Fill(size);
3043             }  // coll+1
3044             else if (bxId == 0) {
3045               hchargebx6->Fill(ch);
3046               hsizebx6->Fill(size);
3047             }  // empty
3048             else if (bxId == 1) {
3049               hchargebx3->Fill(ch);
3050               hsizebx3->Fill(size);
3051             }  // beam1
3052             else if (bxId == 2) {
3053               hchargebx4->Fill(ch);
3054               hsizebx3->Fill(size);
3055             }  // beam2
3056             else if (bxId == 5 || bxId == 6) {
3057               hchargebx5->Fill(ch);
3058               hsizebx5->Fill(size);
3059             }  // beam1/2+1
3060             else
3061               edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
3062           }
3063 #endif
3064 
3065           hcharClubx->Fill(bx, ch);
3066           hsizeClubx->Fill(bx, size);
3067           hsizeYClubx->Fill(bx, sizeY);
3068           hcharCluls->Fill(lumiBlock, ch);
3069           hsizeCluls->Fill(lumiBlock, size);
3070           hsizeXCluls->Fill(lumiBlock, sizeX);
3071           hcharCluLumi->Fill(instlumi, ch);
3072           hsizeCluLumi->Fill(instlumi, size);
3073           hsizeXCluLumi->Fill(instlumi, sizeX);
3074           hsizeYCluLumi->Fill(instlumi, sizeY);
3075 
3076           //hchargen5->Fill(ch,float(size));
3077           //hchargen3->Fill(ch);
3078           //if(size==1) hchargen4->Fill(ch);
3079 
3080 #ifdef VDM_STUDIES
3081           hcharCluls2->Fill(lumiBlock, ch);
3082           hsizeCluls2->Fill(lumiBlock, size);
3083           hsizeXCluls2->Fill(lumiBlock, sizeX);
3084 #endif
3085 
3086         } else if (layer == 3) {
3087           hDetMap3->Fill(float(module), float(ladder));
3088           hsizeDetMap3->Fill(float(module), float(ladder), float(size));
3089           //hsizeXDetMap3->Fill(float(module),float(ladder),float(sizeX));
3090           //hsizeYDetMap3->Fill(float(module),float(ladder),float(sizeY));
3091 
3092           hcluDetMap3->Fill(y, x);
3093           hcharge3->Fill(ch);
3094           //hcols3->Fill(y);
3095           //hrows3->Fill(x);
3096           hsize3->Fill(float(size));
3097           hsizex3->Fill(float(sizeX));
3098           hsizey3->Fill(float(sizeY));
3099           numOfClustersPerDet3++;
3100           numOfClustersPerLay3++;
3101           //avCharge3 += ch;
3102           hgz3->Fill(zPos);
3103           hclumult3->Fill(zPos, size);
3104           hclumultx3->Fill(zPos, sizeX);
3105           hclumulty3->Fill(zPos, sizeY);
3106           hcluchar3->Fill(zPos, ch);
3107 
3108 #if defined(BX) || defined(BX_NEW)
3109           if (bxId > -1) {
3110             if (bxId == 3) {
3111               hchargebx1->Fill(ch);
3112               hsizebx1->Fill(size);
3113             }  // coll
3114             else if (bxId == 4) {
3115               hchargebx2->Fill(ch);
3116               hsizebx2->Fill(size);
3117             }  // coll+1
3118             else if (bxId == 0) {
3119               hchargebx6->Fill(ch);
3120               hsizebx6->Fill(size);
3121             }  // empty
3122             else if (bxId == 1) {
3123               hchargebx3->Fill(ch);
3124               hsizebx3->Fill(size);
3125             }  // beam1
3126             else if (bxId == 2) {
3127               hchargebx4->Fill(ch);
3128               hsizebx3->Fill(size);
3129             }  // beam2
3130             else if (bxId == 5 || bxId == 6) {
3131               hchargebx5->Fill(ch);
3132               hsizebx5->Fill(size);
3133             }  // beam1/2+1
3134             else
3135               edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
3136           }
3137 #endif
3138 
3139           hcharClubx->Fill(bx, ch);
3140           hsizeClubx->Fill(bx, size);
3141           hsizeYClubx->Fill(bx, sizeY);
3142           hcharCluls->Fill(lumiBlock, ch);
3143           hsizeCluls->Fill(lumiBlock, size);
3144           hsizeXCluls->Fill(lumiBlock, sizeX);
3145           hcharCluLumi->Fill(instlumi, ch);
3146           hsizeCluLumi->Fill(instlumi, size);
3147           hsizeXCluLumi->Fill(instlumi, sizeX);
3148           hsizeYCluLumi->Fill(instlumi, sizeY);
3149 
3150           //hchargen5->Fill(ch,float(size));
3151           //hchargen3->Fill(ch);
3152           //if(size==1) hchargen4->Fill(ch);
3153 
3154 #ifdef VDM_STUDIES
3155           hcharCluls3->Fill(lumiBlock, ch);
3156           hsizeCluls3->Fill(lumiBlock, size);
3157           hsizeXCluls3->Fill(lumiBlock, sizeX);
3158 #endif
3159 
3160         }  // end if layer
3161 
3162       } else if (subid == 2 && (selectEvent == -1 || countEvents == selectEvent)) {  // endcap
3163 
3164         //edm::LogPrint("TestClusters")<<disk<<" "<<side<<endl;
3165         if (disk == 1) {  // disk1 -+z
3166           if (side == 1) {
3167             numOfClustersPerDisk2++;  // d1,-z
3168             //avCharge4 += ch;
3169           } else if (side == 2) {
3170             numOfClustersPerDisk3++;  // d1, +z
3171             //avCharge5 += ch;
3172           } else
3173             edm::LogPrint("TestClusters") << " unknown side " << side;
3174 
3175           hcharge4->Fill(ch);
3176 
3177         } else if (disk == 2) {  // disk2 -+z
3178 
3179           if (side == 1) {
3180             numOfClustersPerDisk1++;  // d2, -z
3181             //avCharge4 += ch;
3182           } else if (side == 2) {
3183             numOfClustersPerDisk4++;  // d2, +z
3184             //avCharge5 += ch;
3185           } else
3186             edm::LogPrint("TestClusters") << " unknown side " << side;
3187 
3188           hcharge5->Fill(ch);
3189 
3190         } else
3191           edm::LogPrint("TestClusters") << " unknown disk " << disk;
3192 
3193       }  // end barrel/forward cluster loop
3194 
3195 #endif  // HISTOS
3196 
3197       if ((edgeHitX != edgeHitX2) && sizeX < 64)
3198         edm::LogPrint("TestClusters") << " wrong egdeX " << edgeHitX << " " << edgeHitX2;
3199       if ((edgeHitY != edgeHitY2) && sizeY < 64)
3200         edm::LogPrint("TestClusters") << " wrong egdeY " << edgeHitY << " " << edgeHitY2;
3201 
3202     }  // clusters
3203 
3204     if (numOfClustersPerDet1 > maxClusPerDet)
3205       maxClusPerDet = numOfClustersPerDet1;
3206     if (numOfClustersPerDet2 > maxClusPerDet)
3207       maxClusPerDet = numOfClustersPerDet2;
3208     if (numOfClustersPerDet3 > maxClusPerDet)
3209       maxClusPerDet = numOfClustersPerDet3;
3210 
3211     if (PRINT) {
3212       if (layer == 1)
3213         edm::LogPrint("TestClusters") << "Lay1: number of clusters per det = " << numOfClustersPerDet1;
3214       else if (layer == 2)
3215         edm::LogPrint("TestClusters") << "Lay2: number of clusters per det = " << numOfClustersPerDet1;
3216       else if (layer == 3)
3217         edm::LogPrint("TestClusters") << "Lay3: number of clusters per det = " << numOfClustersPerDet1;
3218     }  // end if PRINT
3219 
3220 #ifdef HISTOS
3221     if (subid == 1 && (selectEvent == -1 || countEvents == selectEvent)) {  // barrel
3222       //if (subid==1 && countEvents==selectEvent) {  // barrel
3223 
3224       //hlayerid->Fill(float(layer));
3225 
3226       // Det histos
3227       if (layer == 1) {
3228         hladder1id->Fill(float(ladder));
3229         hz1id->Fill(float(module));
3230         ++numberOfDetUnits1;
3231         hclusPerDet1->Fill(float(numOfClustersPerDet1));
3232         hpixPerDet1->Fill(float(numOfPixPerDet1));
3233         if (numOfPixPerDet1 > maxPixPerDet)
3234           maxPixPerDet = numOfPixPerDet1;
3235         //if(numOfPixPerLink11>798 || numOfPixPerLink12>798) select=true;
3236         hpixPerLink1->Fill(float(numOfPixPerLink11));
3237         hpixPerLink1->Fill(float(numOfPixPerLink12));
3238         hDetsMap1->Fill(float(module), float(ladder));
3239 
3240         if (abs(module) == 1)
3241           hpixPerDet11->Fill(float(numOfPixPerDet1));
3242         else if (abs(module) == 2)
3243           hpixPerDet12->Fill(float(numOfPixPerDet1));
3244         else if (abs(module) == 3)
3245           hpixPerDet13->Fill(float(numOfPixPerDet1));
3246         else if (abs(module) == 4)
3247           hpixPerDet14->Fill(float(numOfPixPerDet1));
3248 
3249         numOfClustersPerDet1 = 0;
3250         numOfPixPerDet1 = 0;
3251         numOfPixPerLink11 = 0;
3252         numOfPixPerLink12 = 0;
3253 
3254       } else if (layer == 2) {
3255         hladder2id->Fill(float(ladder));
3256         hz2id->Fill(float(module));
3257         ++numberOfDetUnits2;
3258         hclusPerDet2->Fill(float(numOfClustersPerDet2));
3259         hpixPerDet2->Fill(float(numOfPixPerDet2));
3260         if (numOfPixPerDet2 > maxPixPerDet)
3261           maxPixPerDet = numOfPixPerDet2;
3262         hpixPerLink2->Fill(float(numOfPixPerLink21));
3263         hpixPerLink2->Fill(float(numOfPixPerLink22));
3264         hDetsMap2->Fill(float(module), float(ladder));
3265 
3266         if (abs(module) == 1)
3267           hpixPerDet21->Fill(float(numOfPixPerDet2));
3268         else if (abs(module) == 2)
3269           hpixPerDet22->Fill(float(numOfPixPerDet2));
3270         else if (abs(module) == 3)
3271           hpixPerDet23->Fill(float(numOfPixPerDet2));
3272         else if (abs(module) == 4)
3273           hpixPerDet24->Fill(float(numOfPixPerDet2));
3274 
3275         numOfClustersPerDet2 = 0;
3276         numOfPixPerDet2 = 0;
3277         numOfPixPerLink21 = 0;
3278         numOfPixPerLink22 = 0;
3279 
3280       } else if (layer == 3) {
3281         hladder3id->Fill(float(ladder));
3282         hz3id->Fill(float(module));
3283         ++numberOfDetUnits3;
3284         hclusPerDet3->Fill(float(numOfClustersPerDet3));
3285         hpixPerDet3->Fill(float(numOfPixPerDet3));
3286         if (numOfPixPerDet3 > maxPixPerDet)
3287           maxPixPerDet = numOfPixPerDet3;
3288         hDetsMap3->Fill(float(module), float(ladder));
3289 
3290         if (abs(module) == 1)
3291           hpixPerDet31->Fill(float(numOfPixPerDet3));
3292         else if (abs(module) == 2)
3293           hpixPerDet32->Fill(float(numOfPixPerDet3));
3294         else if (abs(module) == 3)
3295           hpixPerDet33->Fill(float(numOfPixPerDet3));
3296         else if (abs(module) == 4)
3297           hpixPerDet34->Fill(float(numOfPixPerDet3));
3298 
3299         //  if(      module==-2&& ladder==13)  hpixPerDet100->Fill(float(numOfPixPerDet3));
3300         //  else if( module==+1&& ladder==11)  hpixPerDet101->Fill(float(numOfPixPerDet3));
3301         //  else if( module==-1&& ladder==9 )  hpixPerDet102->Fill(float(numOfPixPerDet3));
3302         //  else if( module==-4&& ladder==11)  hpixPerDet103->Fill(float(numOfPixPerDet3));
3303         //  else if( module==-2&& ladder==11)  hpixPerDet104->Fill(float(numOfPixPerDet3));
3304         //  else if( module==-2&& ladder==19)  hpixPerDet105->Fill(float(numOfPixPerDet3));
3305 
3306         //  if( numOfPixPerDet3>191 ) {
3307         //    edm::LogPrint("TestClusters")<<" Layer 3 module "<<ladder<<" "<<module<<" "<<numOfPixPerDet3<<endl;
3308         //    select = true;
3309         //  }
3310 
3311         numOfClustersPerDet3 = 0;
3312         numOfPixPerDet3 = 0;
3313         //numOfPixPerLink3=0;
3314 
3315       }  // layer
3316 
3317     }  // end barrel/forward
3318 
3319 #endif  // HISTOS
3320 
3321   }  // detunits loop
3322 
3323   if (PRINT || countEvents == selectEvent) {  //
3324     edm::LogPrint("TestClusters") << "run " << run << " event " << event << " bx " << bx << " lumi " << lumiBlock
3325                                   << " orbit " << orbit << " " << countEvents;
3326     edm::LogPrint("TestClusters") << "Num of pix " << numberOfPixels << " num of clus " << numberOfClusters
3327                                   << " max clus per det " << maxClusPerDet << " max pix per clu " << maxPixPerClu
3328                                   << " count " << countEvents;
3329     edm::LogPrint("TestClusters") << "Number of clusters per Lay1,2,3: " << numOfClustersPerLay1 << " "
3330                                   << numOfClustersPerLay2 << " " << numOfClustersPerLay3;
3331     edm::LogPrint("TestClusters") << "Number of pixels per Lay1,2,3: " << numOfPixPerLay1 << " " << numOfPixPerLay2
3332                                   << " " << numOfPixPerLay3;
3333     edm::LogPrint("TestClusters") << "Number of dets with clus in Lay1,2,3: " << numberOfDetUnits1 << " "
3334                                   << numberOfDetUnits2 << " " << numberOfDetUnits3;
3335   }  // if PRINT
3336 
3337 #ifdef HISTOS
3338 
3339   //if(numberOfClusters<=3) continue; // skip events
3340   if ((selectEvent == -1 || countEvents == selectEvent)) {
3341     hdets2->Fill(float(numOf));  // number of modules with pix
3342     hlumi1->Fill(float(lumiBlock));
3343 
3344     //if(bptx_m && bptx_xor) hbx7->Fill(float(bx));
3345     //if(bptx_p && bptx_xor) hbx8->Fill(float(bx));
3346     //if(bptx_and) hbx9->Fill(float(bx));
3347     //if(bptx_or)  hbx10->Fill(float(bx));
3348 
3349     hdigis->Fill(float(numberOfPixels));   // all pix
3350     hdigis2->Fill(float(numberOfPixels));  // same zoomed
3351 
3352     int pixb = numOfPixPerLay1 + numOfPixPerLay2 + numOfPixPerLay3;
3353     hdigisB->Fill(float(pixb));  // pix in bpix
3354     int pixf = numOfPixPerDisk1 + numOfPixPerDisk2 + numOfPixPerDisk3 + numOfPixPerDisk4;
3355     hdigisF->Fill(float(pixf));  // pix in fpix
3356 
3357     hclus->Fill(float(numberOfClusters));   // clusters fpix+bpix
3358     hclus2->Fill(float(numberOfClusters));  // same, zoomed
3359 
3360     //h2clupv->Fill(float(numberOfClusters),float(numPVsGood));
3361     //h2pixpv->Fill(float(numberOfPixels),float(numPVsGood));
3362     hclupv->Fill(float(numberOfClusters), float(numPVsGood));
3363     hpixpv->Fill(float(numberOfPixels), float(numPVsGood));
3364     //if(numPVsGood>0) {
3365     //float tmp = float(numberOfClusters)/float(numPVsGood);
3366     //hclupvlsn->Fill(float(lumiBlock),tmp);
3367     //tmp = float(numberOfPixels)/float(numPVsGood);
3368     //hpixpvlsn->Fill(float(lumiBlock),tmp);
3369     //}
3370 
3371     int clusb = numOfClustersPerLay1 + numOfClustersPerLay2 + numOfClustersPerLay3;
3372     hclusBPix->Fill(float(clusb));  // clusters in bpix
3373 
3374     int clusf = numOfClustersPerDisk1 + numOfClustersPerDisk2 + numOfClustersPerDisk3 + numOfClustersPerDisk4;
3375     hclusFPix->Fill(float(clusf));  // clusters in fpix
3376 
3377     hclus5->Fill(float(numberOfNoneEdgePixels));               // count none edge pixels
3378     hclusls->Fill(float(lumiBlock), float(numberOfClusters));  // clusters fpix+bpix
3379     hpixls->Fill(float(lumiBlock), float(numberOfPixels));     // pixels fpix+bpix
3380 
3381     hclubx->Fill(float(bx), float(numberOfClusters));  // clusters fpix+bpix
3382     hpixbx->Fill(float(bx), float(numberOfPixels));    // pixels fpix+bpix
3383     hpvbx->Fill(float(bx), float(numPVsGood));         // pvs
3384 
3385 #ifdef VDM_STUDIES
3386     hclusls1->Fill(float(lumiBlock), float(numOfClustersPerLay1));  // clusters bpix1
3387     hpixls1->Fill(float(lumiBlock), float(numOfPixPerLay1));        // pixels bpix1
3388     hclusls2->Fill(float(lumiBlock), float(numOfClustersPerLay2));  // clusters bpix2
3389     hpixls2->Fill(float(lumiBlock), float(numOfPixPerLay2));        // pixels bpix2
3390     hclusls3->Fill(float(lumiBlock), float(numOfClustersPerLay3));  // clusters bpix3
3391     hpixls3->Fill(float(lumiBlock), float(numOfPixPerLay3));        // pixels bpix3
3392 #endif
3393 
3394     if (instlumi > 0.) {
3395       hcluLumi->Fill(instlumi, float(numberOfClusters));  // clus
3396       hpixLumi->Fill(instlumi, float(numberOfPixels));    // pix
3397 
3398 #ifdef INSTLUMI_STUDIES
3399 
3400       float tmp = float(numberOfClusters) / instlumi;
3401       hcluslsn->Fill(float(lumiBlock), tmp);  // clusters fpix+bpix
3402       tmp = float(numberOfPixels) / instlumi;
3403       hpixlsn->Fill(float(lumiBlock), tmp);  // pixels fpix+bpix
3404 
3405       // pix & clus per lumi
3406       tmp = float(pixb);
3407       hpixbl->Fill(instlumi, tmp);  // pixels bpix
3408 
3409       tmp = float(numOfPixPerLay1);
3410       hpixb1l->Fill(instlumi, tmp);  // pixels bpix
3411       tmp = float(numOfPixPerLay2);
3412       hpixb2l->Fill(instlumi, tmp);  // pixels bpix
3413       tmp = float(numOfPixPerLay3);
3414       hpixb3l->Fill(instlumi, tmp);  // pixels bpix
3415 
3416       tmp = float(pixf);
3417       hpixfl->Fill(instlumi, tmp);  // pixels fpix
3418 
3419       tmp = float(numOfPixPerDisk1 + numOfPixPerDisk2);  // -z
3420       hpixfml->Fill(instlumi, tmp);                      // pixels fpix
3421       tmp = float(numOfPixPerDisk3 + numOfPixPerDisk4);  // +z
3422       hpixfpl->Fill(instlumi, tmp);                      // pixels fpix
3423 
3424       tmp = float(clusb);
3425       hclusbl->Fill(instlumi, tmp);  // clus bpix
3426       tmp = float(numOfClustersPerLay1);
3427       hclusb1l->Fill(instlumi, tmp);  // clus bpix
3428       tmp = float(numOfClustersPerLay2);
3429       hclusb2l->Fill(instlumi, tmp);  // clus bpix
3430       tmp = float(numOfClustersPerLay3);
3431       hclusb3l->Fill(instlumi, tmp);  // clus bpix
3432 
3433       tmp = float(clusf);
3434       hclusfl->Fill(instlumi, tmp);  // clus  fpix
3435       tmp = float(numOfClustersPerDisk1 + numOfClustersPerDisk2);
3436       hclusfml->Fill(instlumi, tmp);  // clus fpix
3437       tmp = float(numOfClustersPerDisk3 + numOfClustersPerDisk4);
3438       hclusfpl->Fill(instlumi, tmp);  // clus fpix
3439 
3440       // bx
3441       tmp = float(numberOfClusters) / instlumi;
3442       hclubxn->Fill(float(bx), tmp);  // clusters fpix+bpix
3443       tmp = float(numberOfPixels) / instlumi;
3444       hpixbxn->Fill(float(bx), tmp);  // pixels fpix+bpix
3445       tmp = float(numPVsGood) / instlumi;
3446       hpvbxn->Fill(float(bx), tmp);  // pvs
3447 
3448       //       tmp = float(numOfClustersPerLay1)/float(numOfClustersPerLay3);
3449       //       hclus13ls->Fill(float(lumiBlock),tmp); // clus 1/3
3450       //       tmp = float(numOfClustersPerLay2)/float(numOfClustersPerLay3);
3451       //       hclus23ls->Fill(float(lumiBlock),tmp); // clus 2/3
3452       //       tmp = float(numOfClustersPerLay1)/float(numOfClustersPerLay2);
3453       //       hclus12ls->Fill(float(lumiBlock),tmp); // clus 1/2
3454       //       tmp = float(clusf)/float(numOfClustersPerLay3);
3455       //       hclusf3ls->Fill(float(lumiBlock),tmp); // clus f/3
3456 
3457 #endif  // INSTLUMI_STUDIES
3458 
3459     }  // if instlumi
3460 
3461     hclusPerLay1->Fill(float(numOfClustersPerLay1));
3462     hclusPerLay2->Fill(float(numOfClustersPerLay2));
3463     hclusPerLay3->Fill(float(numOfClustersPerLay3));
3464     hpixPerLay1->Fill(float(numOfPixPerLay1));
3465     hpixPerLay2->Fill(float(numOfPixPerLay2));
3466     hpixPerLay3->Fill(float(numOfPixPerLay3));
3467     if (numOfClustersPerLay1 > 0)
3468       hdetsPerLay1->Fill(float(numberOfDetUnits1));
3469     if (numOfClustersPerLay2 > 0)
3470       hdetsPerLay2->Fill(float(numberOfDetUnits2));
3471     if (numOfClustersPerLay3 > 0)
3472       hdetsPerLay3->Fill(float(numberOfDetUnits3));
3473 
3474     hclusPerDisk1->Fill(float(numOfClustersPerDisk1));
3475     hclusPerDisk2->Fill(float(numOfClustersPerDisk2));
3476     hclusPerDisk3->Fill(float(numOfClustersPerDisk3));
3477     hclusPerDisk4->Fill(float(numOfClustersPerDisk4));
3478 
3479     hpixPerDisk1->Fill(float(numOfPixPerDisk1));
3480     hpixPerDisk2->Fill(float(numOfPixPerDisk2));
3481     hpixPerDisk3->Fill(float(numOfPixPerDisk3));
3482     hpixPerDisk4->Fill(float(numOfPixPerDisk4));
3483 
3484     hmaxPixPerDet->Fill(float(maxPixPerDet));
3485 
3486     //     // Check mod and roc time dependence
3487     //     if( (lumiBlock%5) == 0 ) { // do every 5 lumi blocks
3488 
3489     //       int id=0, lad=0, mod=0, roc=0, layer=0, index=0;
3490     //       float tmp=0;
3491     //       // ROCs
3492     //       // Layer 1,
3493     //       layer=1;
3494     //       id = 0;
3495     //       lad=-3;mod=1;roc=5;
3496     //       tmp = pixEff->getRoc(layer,lad,mod,roc);
3497     //       tmp = tmp - rocHits[layer-1][id];
3498     //       rocHits[layer-1][id] = tmp;
3499     //       index = lumiBlock/5;
3500     //       hrocHits1ls->Fill(float(index),id,tmp);
3501 
3502     //       // Layer 2,
3503     //       layer=2;
3504     //       id = 0;
3505     //       lad=-5;mod=-2;roc=10;
3506     //       tmp = pixEff->getRoc(layer,lad,mod,roc);
3507     //       tmp = tmp - rocHits[layer-1][id];
3508     //       rocHits[layer-1][id] = tmp;
3509     //       index = lumiBlock/5;
3510     //       hrocHits2ls->Fill(float(index),id,tmp);
3511     //       // Layer 3,
3512     //       layer=3;
3513     //       id = 0;
3514     //       lad=-18;mod=-2;roc=14;
3515     //       tmp = pixEff->getRoc(layer,lad,mod,roc);
3516     //       tmp = tmp - rocHits[layer-1][id];
3517     //       rocHits[layer-1][id] = tmp;
3518     //       index = lumiBlock/5;
3519     //       hrocHits3ls->Fill(float(index),id,tmp);
3520     //       // MODULES
3521     //       float half1=0, half2=0;
3522     //       // Layer 1,
3523     //       layer=1;
3524     //       id = 0;
3525     //       lad=-3;mod=1;
3526     //       tmp = pixEff->getModule(layer,lad,mod,half1,half2);
3527     //       tmp = tmp - moduleHits[layer-1][id];
3528     //       moduleHits[layer-1][id] = tmp;
3529     //       index = lumiBlock/5;
3530     //       hmoduleHits1ls->Fill(float(index),id,tmp);
3531 
3532     //     }
3533 
3534 #ifdef SEB
3535 //     float tmp0=0., tmp3=0., tmp4=0., tmp5=0.;
3536 //     //if(numOfClustersPerLay1>0) { tmp0 = avCharge1/float(numOfClustersPerLay1); havCharge1->Fill(tmp0);}
3537 //     //if(numOfClustersPerLay2>0) { tmp0 = avCharge2/float(numOfClustersPerLay2); havCharge1->Fill(tmp0);}
3538 //     //if(numOfClustersPerLay3>0) { tmp0 = avCharge3/float(numOfClustersPerLay3); havCharge1->Fill(tmp0);}
3539 //     if( (numOfClustersPerDisk1 + numOfClustersPerDisk2) > 0 )
3540 //       tmp4 = avCharge4/float(numOfClustersPerDisk2 + numOfClustersPerDisk1);
3541 //     if( (numOfClustersPerDisk3 + numOfClustersPerDisk4) > 0 )
3542 //       tmp5 = avCharge5/float(numOfClustersPerDisk3 + numOfClustersPerDisk4);
3543 //     //tmp4 = float(numOfClustersPerDisk2 + numOfClustersPerDisk1);
3544 //     //tmp5 = float(numOfClustersPerDisk3 + numOfClustersPerDisk4);
3545 //     havCharge6->Fill(float(tmp4));
3546 //     havCharge6->Fill(float(tmp5));
3547 //     float tmp8=1.03;
3548 //     if( (tmp4+tmp5) > 0. ) tmp8 = tmp5/(tmp4+tmp5);
3549 //     else tmp8 = 1.05;
3550 //     havCharge3->Fill(tmp8);
3551 //     if(tmp1>0) {
3552 //       tmp3 = (avCharge1 + avCharge2 + avCharge3)/float(tmp1);  // average over bpix
3553 //       havCharge2->Fill(tmp3);
3554 //       //h2d1->Fill(tmp1,tmp3);  // bpix num of clusters vs av cluster charge
3555 //       //float tmp6 = float(numberOfDetUnits1 + numberOfDetUnits2 + numberOfDetUnits3); //num of dets
3556 //       //float tmp7 = float(tmp1)/float(tmp6);  // ave clusters per module
3557 //       //h2d2->Fill(tmp8,tmp3); //
3558 //       //h2d3->Fill(tmp8,tmp1); //
3559 //       if(tmp8>1.02) { // no signal in fpix
3560 //  havCharge1->Fill(tmp3);
3561 //  hclus20->Fill(float(numberOfClusters));
3562 //       } else if (tmp8>0.05 && tmp8<0.95) { // some signal in both disks
3563 //  havCharge4->Fill(tmp3);
3564 //  hclus21->Fill(float(numberOfClusters));
3565 //       } else { // tmp=0., 1., signal in only one disk
3566 //  havCharge5->Fill(tmp3);
3567 //  hclus22->Fill(float(numberOfClusters));
3568 //       }
3569 //     } else {  // no bpix hits
3570 //       hclus23->Fill(float(numberOfClusters));
3571 //     }
3572 #endif  // SEB
3573 
3574 #ifdef L1
3575     //int numberOfClusters0 = numberOfClusters;  // select all clusters
3576 
3577     //if(bptx3) hclus1->Fill(float(numberOfClusters0));
3578     //if(bptx4) hclus2->Fill(float(numberOfClusters0));
3579     //if(bit0)  hclus10->Fill(float(numberOfClusters0));   //
3580     //if(bptx_and) hclus11->Fill(float(numberOfClusters0));
3581     //if(bptx_xor) hclus12->Fill(float(numberOfClusters0));
3582     //if(!bptx_xor && !bptx_and) hclus13->Fill(float(numberOfClusters0));
3583     //if(bptx_m)   hclus14->Fill(float(numberOfClusters0));
3584     //if(bptx_p)   hclus15->Fill(float(numberOfClusters0));
3585 
3586     //if(bcs_all)   hclus4->Fill(float(numberOfClusters0));       // or of all BCS bits
3587     //else      hclus17->Fill(float(numberOfClusters0));      // no BCS
3588     //if(bit126) hclus6->Fill(float(numberOfClusters0));   // bit 126
3589     //if(bit124) hclus7->Fill(float(numberOfClusters0));
3590     //if(bit122) hclus26->Fill(float(numberOfClusters0));
3591     //if(bcsOR)      hclus8->Fill(float(numberOfClusters0));  // bit 34
3592     //if(bcs)        hclus9->Fill(float(numberOfClusters0));  // all bcs except 34
3593     //if(bcs_bptx)   hclus29->Fill(float(numberOfClusters0)); // bits 124,126
3594     //if(bcs_double) hclus28->Fill(float(numberOfClusters0)); // 36-39, 40-43
3595     //if(bit32_33)   hclus25->Fill(float(numberOfClusters0)); // bits 32,33? is this usefull
3596     //if(halo)       hclus3->Fill(float(numberOfClusters0));  // bits 36-39
3597     //if(bit85) hclus18->Fill(float(numberOfClusters0));      // bit85
3598     //if(minBias) hclus19->Fill(float(numberOfClusters0));    // bits 40,41
3599     // #ifdef BX
3600     //     if     (bxId==1)  {hclus30->Fill(float(numberOfClusters0));hdigis30->Fill(float(numberOfPixels));}
3601     //     else if(bxId==2)  {hclus31->Fill(float(numberOfClusters0));hdigis31->Fill(float(numberOfPixels));}
3602     //     else if(bxId==3)  {hclus32->Fill(float(numberOfClusters0));hdigis32->Fill(float(numberOfPixels));}
3603     //     else if(bxId==4)  {hclus33->Fill(float(numberOfClusters0));hdigis33->Fill(float(numberOfPixels));}
3604     //     else if(bxId==5)  {hclus34->Fill(float(numberOfClusters0));hdigis34->Fill(float(numberOfPixels));}
3605     //     else if(bxId==6)  {hclus35->Fill(float(numberOfClusters0));hdigis35->Fill(float(numberOfPixels));}
3606     //     else if(bxId==-1) {hclus36->Fill(float(numberOfClusters0));hdigis36->Fill(float(numberOfPixels));}
3607     //     else              {hclus37->Fill(float(numberOfClusters0));hdigis37->Fill(float(numberOfPixels));}
3608     //     if(run>=160888 && run<=160940) { // 64bx
3609     //       // Fill 1638
3610     //       if(bx==442)       {hclus7->Fill(float(numberOfClusters0));  hdigis7->Fill(float(numberOfPixels));} //B1, 1st
3611     //       else if(bx==3136) {hclus18->Fill(float(numberOfClusters0)); hdigis18->Fill(float(numberOfPixels));} //B1, last
3612     //       else if(bx==466)  {hclus25->Fill(float(numberOfClusters0)); hdigis25->Fill(float(numberOfPixels));} //B2, last
3613     //       else if(bx==3112) {hclus26->Fill(float(numberOfClusters0)); hdigis26->Fill(float(numberOfPixels));} //B2, 1st
3614     //     } else if(run>=160955 && run<=161176) { // 136bx
3615     //       // Fill 1640
3616     //       if(bx==149)       hclus7->Fill(float(numberOfClusters0));
3617     //       else if(bx==3184) hclus18->Fill(float(numberOfClusters0));
3618     //       else if(bx==173)  hclus25->Fill(float(numberOfClusters0));
3619     //       else if(bx==3112) hclus26->Fill(float(numberOfClusters0));
3620     //     } else if(run>=161216 && run<=161312) { // 200bx
3621     //       // Fill 1645
3622     //       if(bx==1 || bx==4) {
3623     //  hclus7->Fill(float(numberOfClusters0));
3624     //  hdigis7->Fill(float(numberOfPixels));
3625     //       } else if( bx==1950 || bx==1953 || bx==1956 || bx==1959 ) {
3626     //  hclus18->Fill(float(numberOfClusters0));
3627     //  hdigis18->Fill(float(numberOfPixels));
3628     //       } else if(bx==25 || bx==28) {
3629     //  hclus25->Fill(float(numberOfClusters0));
3630     //  hdigis25->Fill(float(numberOfPixels));
3631     //       } else if( bx==1878 || bx==1881 || bx==1884 || bx==1887 ) {
3632     //  hclus26->Fill(float(numberOfClusters0));
3633     //  hdigis26->Fill(float(numberOfPixels));      }
3634     //     }
3635     // #endif
3636 
3637     // Check L1 bits with pixel selection
3638     if (L1GTRR.isValid()) {
3639       //bool l1a = L1GTRR->decision();
3640       //edm::LogPrint("TestClusters")<<" L1 status :"<<l1a<<" "<<hex;
3641       for (unsigned int i = 0; i < L1GTRR->decisionWord().size(); ++i) {
3642         int l1flag = L1GTRR->decisionWord()[i];
3643         int t1flag = L1GTRR->technicalTriggerWord()[i];
3644         if (l1flag > 0)
3645           hl1a1->Fill(float(i));
3646         if (t1flag > 0 && i < 64)
3647           hl1t1->Fill(float(i));
3648       }  // for loop
3649     }  // if l1a
3650 
3651     // HLT bits
3652     for (unsigned int i = 0; i < 256; i++)
3653       if (hlt[i])
3654         hlt3->Fill(float(i));
3655 
3656 #endif  // L1
3657 
3658   }  // if select event
3659 
3660 #endif  // HISTOS
3661 
3662 }  // end
3663 
3664 //define this as a plug-in
3665 DEFINE_FWK_MODULE(TestClusters);