Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-17 23:31:47

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 numberOfDetUnits = 0;
2267   int numberOfClusters = 0;
2268   int numberOfPixels = 0;
2269   int numberOfNoneEdgePixels = 0;
2270   int numberOfDetUnits1 = 0;
2271   int numOfClustersPerDet1 = 0;
2272   int numOfClustersPerLay1 = 0;
2273   int numberOfDetUnits2 = 0;
2274   int numOfClustersPerDet2 = 0;
2275   int numOfClustersPerLay2 = 0;
2276   int numberOfDetUnits3 = 0;
2277   int numOfClustersPerDet3 = 0;
2278   int numOfClustersPerLay3 = 0;
2279 
2280   int numOfPixPerLay1 = 0;
2281   int numOfPixPerLay2 = 0;
2282   int numOfPixPerLay3 = 0;
2283 
2284   int numOfPixPerDet1 = 0;
2285   int numOfPixPerDet2 = 0;
2286   int numOfPixPerDet3 = 0;
2287 
2288   int numOfPixPerLink11 = 0;
2289   int numOfPixPerLink12 = 0;
2290   int numOfPixPerLink21 = 0;
2291   int numOfPixPerLink22 = 0;
2292   //int numOfPixPerLink3=0;
2293 
2294   int maxClusPerDet = 0;
2295   int maxPixPerDet = 0;
2296   unsigned int maxPixPerClu = 0;
2297 
2298   int numOfClustersPerDisk1 = 0;
2299   int numOfClustersPerDisk2 = 0;
2300   int numOfClustersPerDisk3 = 0;
2301   int numOfClustersPerDisk4 = 0;
2302   int numOfPixPerDisk1 = 0;
2303   int numOfPixPerDisk2 = 0;
2304   int numOfPixPerDisk3 = 0;
2305   int numOfPixPerDisk4 = 0;
2306 
2307   float avCharge1 = 0., avCharge2 = 0., avCharge3 = 0., avCharge4 = 0., avCharge5 = 0.;
2308 
2309   //static int module1[416][160] = {{0}};
2310   //static int module2[416][160] = {{0}};
2311   //static int module3[416][160] = {{0}};
2312 
2313   // get vector of detunit ids
2314   //--- Loop over detunits.
2315   edmNew::DetSetVector<SiPixelCluster>::const_iterator DSViter = input.begin();
2316   for (; DSViter != input.end(); DSViter++) {
2317     //bool valid = false;
2318     unsigned int detid = DSViter->detId();
2319     // Det id
2320     DetId detId = DetId(detid);             // Get the Detid object
2321     unsigned int detType = detId.det();     // det type, pixel=1
2322     unsigned int subid = detId.subdetId();  //subdetector type, barrel=1
2323 
2324     if (PRINT)
2325       edm::LogPrint("TestClusters") << "Det: " << detId.rawId() << " " << detId.null() << " " << detType << " "
2326                                     << subid;
2327 
2328 #ifdef HISTOS
2329       //hdetunit->Fill(float(detid));
2330       //hpixid->Fill(float(detType));
2331       //hpixsubid->Fill(float(subid));
2332 #endif  // HISTOS
2333 
2334     if (detType != 1)
2335       continue;  // look only at pixels
2336     ++numberOfDetUnits;
2337 
2338     //const GeomDetUnit * genericDet = geom->idToDet(detId);
2339     //const PixelGeomDetUnit * pixDet =
2340     //dynamic_cast<const PixelGeomDetUnit*>(genericDet);
2341 
2342     // Get the geom-detector
2343     const PixelGeomDetUnit *theGeomDet = dynamic_cast<const PixelGeomDetUnit *>(theTracker.idToDet(detId));
2344     double detZ = theGeomDet->surface().position().z();
2345     double detR = theGeomDet->surface().position().perp();
2346 
2347     //const BoundPlane& plane = theGeomDet->surface(); //for transf.
2348 
2349     //double detThick = theGeomDet->specificSurface().bounds().thickness();
2350     //int cols = theGeomDet->specificTopology().ncolumns();
2351     //int rows = theGeomDet->specificTopology().nrows();
2352 
2353     const PixelTopology *topol = &(theGeomDet->specificTopology());
2354 
2355     // barrel ids
2356     unsigned int layerC = 0;
2357     unsigned int ladderC = 0;
2358     unsigned int zindex = 0;
2359     int shell = 0;      // shell id // Shell { mO = 1, mI = 2 , pO =3 , pI =4 };
2360     int sector = 0;     // 1-8
2361     int ladder = 0;     // 1-22
2362     int layer = 0;      // 1-3
2363     int module = 0;     // 1-4
2364     bool half = false;  //
2365 
2366     // Endcap ids
2367     unsigned int disk = 0;     //1,2,3
2368     unsigned int blade = 0;    //1-24
2369     unsigned int zindexF = 0;  //
2370     unsigned int side = 0;     //size=1 for -z, 2 for +z
2371     unsigned int panel = 0;    //panel=1
2372 
2373     edmNew::DetSet<SiPixelCluster>::const_iterator clustIt;
2374 
2375     // Subdet id, pix barrel=1, forward=2
2376     if (subid == 2) {  // forward
2377 
2378 #ifdef NEW_ID
2379       disk = tTopo->pxfDisk(detid);      //1,2,3
2380       blade = tTopo->pxfBlade(detid);    //1-24
2381       zindex = tTopo->pxfModule(detid);  //
2382       side = tTopo->pxfSide(detid);      //size=1 for -z, 2 for +z
2383       panel = tTopo->pxfPanel(detid);    //panel=1
2384 #else
2385       PXFDetId pdetId = PXFDetId(detid);
2386       disk = pdetId.disk();       //1,2,3
2387       blade = pdetId.blade();     //1-24
2388       moduleF = pdetId.module();  // plaquette
2389       side = pdetId.side();       //size=1 for -z, 2 for +z
2390       panel = pdetId.panel();     //panel=1
2391 #endif
2392 
2393       if (PRINT)
2394         edm::LogPrint("TestClusters") << " forward det, disk " << disk << ", blade " << blade << ", module " << zindexF
2395                                       << ", side " << side << ", panel " << panel << " pos = " << detZ << " " << detR;
2396 
2397     } else if (subid == 1) {  // barrel
2398 
2399 #ifdef NEW_ID
2400       layerC = tTopo->pxbLayer(detid);
2401       ladderC = tTopo->pxbLadder(detid);
2402       zindex = tTopo->pxbModule(detid);
2403       PixelBarrelName pbn(detid);
2404 #else
2405       PXBDetId pdetId = PXBDetId(detid);
2406       //unsigned int detTypeP=pdetId.det();
2407       //unsigned int subidP=pdetId.subdetId();
2408       // Barell layer = 1,2,3
2409       layerC = pdetId.layer();
2410       // Barrel ladder id 1-20,32,44.
2411       ladderC = pdetId.ladder();
2412       // Barrel Z-index=1,8
2413       zindex = pdetId.module();
2414       // Convert to online
2415       PixelBarrelName pbn(pdetId);
2416 #endif
2417 
2418       // Shell { mO = 1, mI = 2 , pO =3 , pI =4 };
2419       PixelBarrelName::Shell sh = pbn.shell();  //enum
2420       sector = pbn.sectorName();
2421       ladder = pbn.ladderName();
2422       layer = pbn.layerName();
2423       module = pbn.moduleName();
2424       half = pbn.isHalfModule();
2425       shell = int(sh);
2426       // change the module sign for z<0
2427       if (shell == 1 || shell == 2)
2428         module = -module;
2429       // change ladeer sign for Outer )x<0)
2430       if (shell == 1 || shell == 3)
2431         ladder = -ladder;
2432 
2433       if (PRINT) {
2434         edm::LogPrint("TestClusters") << " Barrel layer, ladder, module " << layerC << " " << ladderC << " " << zindex
2435                                       << " " << sh << "(" << shell << ") " << sector << " " << layer << " " << ladder
2436                                       << " " << module << " " << half;
2437         //edm::LogPrint("TestClusters")<<" Barrel det, thick "<<detThick<<" "
2438         //  <<" layer, ladder, module "
2439         //  <<layer<<" "<<ladder<<" "<<zindex<<endl;
2440         //edm::LogPrint("TestClusters")<<" col/row, pitch "<<cols<<" "<<rows<<" "
2441         //  <<pitchX<<" "<<pitchY<<endl;
2442       }
2443 
2444     }  // if subid
2445 
2446     if (PRINT) {
2447       edm::LogPrint("TestClusters") << "List clusters : ";
2448       edm::LogPrint("TestClusters") << "Num Charge Size SizeX SizeY X Y Xmin Xmax Ymin Ymax Edge";
2449     }
2450 
2451     // Loop over clusters
2452     for (clustIt = DSViter->begin(); clustIt != DSViter->end(); clustIt++) {
2453       sumClusters++;
2454       numberOfClusters++;
2455       float ch = float(clustIt->charge()) / 1000.;  // convert ke to electrons
2456       int size = clustIt->size();
2457       int sizeX = clustIt->sizeX();  //x=row=rfi,
2458       int sizeY = clustIt->sizeY();  //y=col=z_global
2459       float x = clustIt->x();        // row, cluster position in pitch units, as float (int+0.5)
2460       float y = clustIt->y();        // col, analog average
2461       // Returns int index of the cluster min/max
2462       int minPixelRow = clustIt->minPixelRow();  //x
2463       int maxPixelRow = clustIt->maxPixelRow();
2464       int minPixelCol = clustIt->minPixelCol();  //y
2465       int maxPixelCol = clustIt->maxPixelCol();
2466 
2467       //unsigned int geoId = clustIt->geographicalId(); // always 0?!
2468       // edge method moved to topologu class
2469       bool edgeHitX = (topol->isItEdgePixelInX(minPixelRow)) || (topol->isItEdgePixelInX(maxPixelRow));
2470       bool edgeHitY = (topol->isItEdgePixelInY(minPixelCol)) || (topol->isItEdgePixelInY(maxPixelCol));
2471 
2472       bool edgeHitX2 = false;  // edge method moved
2473       bool edgeHitY2 = false;  // to topologu class
2474 
2475       if (PRINT)
2476         edm::LogPrint("TestClusters") << numberOfClusters << " " << ch << " " << size << " " << sizeX << " " << sizeY
2477                                       << " " << x << " " << y << " " << minPixelRow << " " << maxPixelRow << " "
2478                                       << minPixelCol << " " << maxPixelCol << " " << edgeHitX << " " << edgeHitY;
2479 
2480       // get global z position of teh cluster
2481       LocalPoint lp = topol->localPosition(MeasurementPoint(x, y));
2482       float lx = lp.x();  // local cluster position in cm
2483       float ly = lp.y();
2484 
2485       float zPos = detZ - ly;
2486       float rPos = detR + lx;
2487 
2488       // Get the pixels in the Cluster
2489       const vector<SiPixelCluster::Pixel> &pixelsVec = clustIt->pixels();
2490       if (PRINT)
2491         edm::LogPrint("TestClusters") << " Pixels in this cluster ";
2492       //bool bigInX=false, bigInY=false;
2493       // Look at pixels in this cluster. ADC is calibrated, in electrons
2494       bool edgeInX = false;  // edge method moved
2495       bool edgeInY = false;  // to topologu class
2496       //bool cluBigInX = false; // does this clu include a big pixel
2497       //bool cluBigInY = false; // does this clu include a big pixel
2498       //int noisy = 0;
2499 
2500       if (pixelsVec.size() > maxPixPerClu)
2501         maxPixPerClu = pixelsVec.size();
2502 
2503       for (unsigned int i = 0; i < pixelsVec.size(); ++i) {  // loop over pixels
2504         sumPixels++;
2505         numberOfPixels++;
2506         float pixx = pixelsVec[i].x;  // index as float=iteger, row index
2507         float pixy = pixelsVec[i].y;  // same, col index
2508         float adc = (float(pixelsVec[i].adc) / 1000.);
2509 #ifdef ROC_EFF
2510         int roc = rocId(int(pixy), int(pixx));  // column, row
2511 #endif
2512         //int chan = PixelChannelIdentifier::pixelToChannel(int(pixx),int(pixy));
2513 
2514         bool bigInX = topol->isItBigPixelInX(int(pixx));
2515         bool bigInY = topol->isItBigPixelInY(int(pixy));
2516         if (!(bigInX || bigInY))
2517           numberOfNoneEdgePixels++;
2518 
2519 #ifdef HISTOS
2520         // Pixel histos
2521         if (subid == 1 && (selectEvent == -1 || countEvents == selectEvent)) {  // barrel
2522           if (layer == 1) {
2523             numOfPixPerDet1++;
2524             numOfPixPerLay1++;
2525             //valid = valid || true;
2526             hpixcharge1->Fill(adc);
2527             hpixDetMap1->Fill(pixy, pixx);
2528             hpDetMap1->Fill(float(module), float(ladder));
2529             //module1[int(pixx)][int(pixy)]++;
2530 
2531             hpcols1->Fill(pixy);
2532             hprows1->Fill(pixx);
2533 
2534             if (ladder == -1 && module == -1)
2535               hpixDetMap10->Fill(pixy, pixx);  // ineff
2536             //else if(ladder==-4 && module==-1) hpixDetMap11->Fill(pixy,pixx); // ineff
2537             //else if(ladder== 2 && module== 2) hpixDetMap12->Fill(pixy,pixx); // ineff
2538             else if (ladder == 2 && module == 8)
2539               hpixDetMap11->Fill(pixy, pixx);  // roc ineff (1run)
2540             else if (ladder == 2 && module == -2)
2541               hpixDetMap12->Fill(pixy, pixx);  // roc ineff (1 run)
2542 
2543             else if (ladder == -9 && module == 4)
2544               hpixDetMap13->Fill(pixy, pixx);  // ineff
2545             else if (ladder == -8 && module == -4)
2546               hpixDetMap14->Fill(pixy, pixx);  // bad al, ENE
2547             else if (ladder == 6 && module == 4)
2548               hpixDetMap15->Fill(pixy, pixx);  // pix 0,0
2549             else if (ladder == 9 && module == 4)
2550               hpixDetMap16->Fill(pixy, pixx);  // gain low off
2551             else if (ladder == -3 && module == -3)
2552               hpixDetMap17->Fill(pixy, pixx);  // bad col
2553             else if (ladder == -7 && module == -4)
2554               hpixDetMap18->Fill(pixy, pixx);  // bad col
2555             else if (ladder == -5 && module == -4)
2556               hpixDetMap19->Fill(pixy, pixx);  // low ROC eff (1 run)
2557 
2558             //if(module1[int(pixx)][int(pixy)]>MAX_CUT)
2559             //edm::LogPrint("TestClusters")<<" module "<<layer<<" "<<ladder<<" "<<module<<" "
2560             //  <<pixx<<" "<<pixy<<" "<<module1[int(pixx)][int(pixy)]<<endl;
2561 
2562             if (pixx < 80.)
2563               numOfPixPerLink11++;
2564             else
2565               numOfPixPerLink12++;
2566 
2567             hpixchar1->Fill(zPos, adc);
2568             hcharPixbx->Fill(bx, adc);
2569             hcharPixls->Fill(lumiBlock, adc);
2570             hcharPixLumi->Fill(instlumi, adc);
2571 
2572 #ifdef VDM_STUDIES
2573             hcharPixls1->Fill(lumiBlock, adc);
2574 #endif
2575 
2576 #if defined(BX) || defined(BX_NEW)
2577             if (bxId > -1) {
2578               if (bxId == 3)
2579                 hpixChargebx1->Fill(adc);  // coll
2580               else if (bxId == 4)
2581                 hpixChargebx2->Fill(adc);  // coll+1
2582               else if (bxId == 0)
2583                 hpixChargebx6->Fill(adc);  // empty
2584               else if (bxId == 1)
2585                 hpixChargebx3->Fill(adc);  // beam1
2586               else if (bxId == 2)
2587                 hpixChargebx3->Fill(adc);  // beam2
2588               else if (bxId == 5 || bxId == 6)
2589                 hpixChargebx5->Fill(adc);  // beam1/2+1
2590               else
2591                 edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
2592             }
2593 #endif
2594 
2595 #ifdef ROC_EFF
2596             pixEff->addPixel(1, ladder, module, roc);  // count pixels
2597 
2598             //index = lumiBlock/5;
2599             //     if     (ladder== 3 && module== 3)  hmoduleHits1ls->Fill(float(lumiBlock),0);
2600             //     if     (ladder==-9 && module==-3 && roc== 9)  hrocHits1ls->Fill(float(lumiBlock),0);
2601             //     else if(ladder==-9 && module==-1 && roc== 0)  hrocHits1ls->Fill(float(lumiBlock),1);
2602             //     else if(ladder==-8 && module==-1 && roc== 2)  hrocHits1ls->Fill(float(lumiBlock),2);
2603             //     else if(ladder==-8 && module== 1 && roc== 2)  hrocHits1ls->Fill(float(lumiBlock),3);
2604             //     else if(ladder==-4 && module==-2 && roc== 2)  hrocHits1ls->Fill(float(lumiBlock),4);
2605             //     else if(ladder== 2 && module== 2 && roc== 4)  hrocHits1ls->Fill(float(lumiBlock),5);
2606             //     else if(ladder== 3 && module==-2 && roc== 4)  hrocHits1ls->Fill(float(lumiBlock),6);
2607             //     else if(ladder== 3 && module== 1 && roc== 6)  hrocHits1ls->Fill(float(lumiBlock),7);
2608             //     else if(ladder== 4 && module== 3 && roc== 8)  hrocHits1ls->Fill(float(lumiBlock),8);
2609             //     else if(ladder== 8 && module==-4 && roc==11)  hrocHits1ls->Fill(float(lumiBlock),9);
2610             // run 176286
2611             //if     (ladder==-3 && module== 1 && roc== 5)  hrocHits1ls->Fill(float(lumiBlock),0);
2612             //else if(ladder== 2 && module==-1 && roc==13)  hrocHits1ls->Fill(float(lumiBlock),1);
2613             //else if(ladder== 3 && module== 4 && roc== 9)  hrocHits1ls->Fill(float(lumiBlock),2);
2614             //else if(ladder== 5 && module== 2 && roc== 3)  hrocHits1ls->Fill(float(lumiBlock),3);
2615             //else if(ladder== 7 && module==-1 && roc== 8)  hrocHits1ls->Fill(float(lumiBlock),4);
2616             //else if(ladder== 2 && module== 1 && roc== 0)  hrocHits1ls->Fill(float(lumiBlock),5);
2617             // run 180250
2618             if (ladder == -9 && module == 4 && roc == 12)
2619               hrocHits1ls->Fill(float(lumiBlock), 0);
2620             else if (ladder == -7 && module == -4 && roc == 3)
2621               hrocHits1ls->Fill(float(lumiBlock), 1);
2622             else if (ladder == -5 && module == -4 && roc == 11)
2623               hrocHits1ls->Fill(float(lumiBlock), 2);
2624             else if (ladder == 2 && module == -2 && roc == 1)
2625               hrocHits1ls->Fill(float(lumiBlock), 3);
2626             else if (ladder == 8 && module == 2 && roc == 1)
2627               hrocHits1ls->Fill(float(lumiBlock), 4);
2628               //else if(ladder== 2 && module== 1 && roc== 0)  hrocHits1ls->Fill(float(lumiBlock),5);
2629 #endif
2630 
2631           } else if (layer == 2) {
2632             numOfPixPerDet2++;
2633             numOfPixPerLay2++;
2634 
2635             hpcols2->Fill(pixy);
2636             hprows2->Fill(pixx);
2637 
2638             if (ladder == -11 && module == -2)
2639               hpixDetMap20->Fill(pixy, pixx);  // ineff
2640             else if (ladder == -7 && module == -3)
2641               hpixDetMap21->Fill(pixy, pixx);  // ineff
2642             else if (ladder == -2 && module == 1)
2643               hpixDetMap22->Fill(pixy, pixx);  // ineff
2644             else if (ladder == -14 && module == 4)
2645               hpixDetMap23->Fill(pixy, pixx);  // ineff
2646             else if (ladder == -14 && module == 1)
2647               hpixDetMap24->Fill(pixy, pixx);  // bad al
2648             else if (ladder == -14 && module == -1)
2649               hpixDetMap25->Fill(pixy, pixx);  // evn errors
2650             //else if(ladder== 14 && module== 2) hpixDetMap26->Fill(pixy,pixx); // gain cal poor eff
2651             else if (ladder == -4 && module == 4)
2652               hpixDetMap26->Fill(pixy, pixx);  // bad dcol
2653             else if (ladder == 6 && module == -2)
2654               hpixDetMap27->Fill(pixy, pixx);  // bad dcol
2655             //else if(ladder==-4  && module== 2) hpixDetMap28->Fill(pixy,pixx); // pix0
2656 
2657             else if (ladder == -10 && module == -3)
2658               hpixDetMap28->Fill(pixy, pixx);  // roc eff 1 run
2659             else if (ladder == 14 && module == 3)
2660               hpixDetMap29->Fill(pixy, pixx);  // "
2661 
2662             if (pixx < 80.)
2663               numOfPixPerLink21++;
2664             else
2665               numOfPixPerLink22++;
2666 
2667 #if defined(BX) || defined(BX_NEW)
2668             if (bxId > -1) {
2669               if (bxId == 3)
2670                 hpixChargebx1->Fill(adc);  // coll
2671               else if (bxId == 4)
2672                 hpixChargebx2->Fill(adc);  // coll+1
2673               else if (bxId == 0)
2674                 hpixChargebx6->Fill(adc);  // empty
2675               else if (bxId == 1)
2676                 hpixChargebx3->Fill(adc);  // beam1
2677               else if (bxId == 2)
2678                 hpixChargebx3->Fill(adc);  // beam2
2679               else if (bxId == 5 || bxId == 6)
2680                 hpixChargebx5->Fill(adc);  // beam1/2+1
2681               else
2682                 edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
2683             }
2684 #endif
2685 
2686 #ifdef ROC_EFF
2687             pixEff->addPixel(2, ladder, module, roc);
2688 
2689             //index = lumiBlock/5;
2690             //      if     (ladder==10 && module== 2)  hmoduleHits2ls->Fill(float(lumiBlock),0); // many resyncs
2691 
2692             //     if     (ladder==-2 && module== 1 && roc==10)  hrocHits2ls->Fill(float(lumiBlock),0);
2693             //     else if(ladder== 1 && module== 1 && roc== 3)  hrocHits2ls->Fill(float(lumiBlock),1);
2694             //     else if(ladder== 1 && module== 2 && roc== 4)  hrocHits2ls->Fill(float(lumiBlock),2);
2695             //     else if(ladder== 2 && module==-4 && roc== 3)  hrocHits2ls->Fill(float(lumiBlock),3);
2696             //     else if(ladder==10 && module==-3 && roc== 1)  hrocHits2ls->Fill(float(lumiBlock),4);
2697             //     else if(ladder==10 && module==-1 && roc==10)  hrocHits2ls->Fill(float(lumiBlock),5);
2698             //     else if(ladder==11 && module== 3 && roc==13)  hrocHits2ls->Fill(float(lumiBlock),6);
2699             //     else if(ladder==12 && module==-4 && roc==14)  hrocHits2ls->Fill(float(lumiBlock),7);
2700             //     else if(ladder==12 && module==-1 && roc== 3)  hrocHits2ls->Fill(float(lumiBlock),8);
2701             //     else if(ladder==-5 && module==-2 && roc==10)  hrocHits2ls->Fill(float(lumiBlock),9);
2702             //     else if(ladder==10 && module== 2 && roc== 0)  hrocHits3ls->Fill(float(lumiBlock),9); // many resuncs
2703 
2704             // run 176286
2705             //if     (ladder==-5 && module==-2 && roc==10)  hrocHits2ls->Fill(float(lumiBlock),0);
2706             //else if(ladder==-2 && module==-4 && roc==12)  hrocHits2ls->Fill(float(lumiBlock),1);
2707             //else if(ladder==15 && module==-1 && roc==11)  hrocHits2ls->Fill(float(lumiBlock),2);
2708             //else if(ladder== 2 && module==1  && roc== 0)  hrocHits2ls->Fill(float(lumiBlock),3);
2709             // run 180250
2710             if (ladder == -2 && module == 1 && roc == 10)
2711               hrocHits2ls->Fill(float(lumiBlock), 0);
2712             else if (ladder == 10 && module == -3 && roc == 2)
2713               hrocHits2ls->Fill(float(lumiBlock), 1);
2714             else if (ladder == 15 && module == 3 && roc == 7)
2715               hrocHits2ls->Fill(float(lumiBlock), 2);
2716               //else if(ladder== 2 && module==1  && roc== 0)  hrocHits2ls->Fill(float(lumiBlock),3);
2717 #endif
2718 
2719             hpixcharge2->Fill(adc);
2720             hpixDetMap2->Fill(pixy, pixx);
2721             hpDetMap2->Fill(float(module), float(ladder));
2722             //module2[int(pixx)][int(pixy)]++;
2723 
2724             hpixchar2->Fill(zPos, adc);
2725             hcharPixbx->Fill(bx, adc);
2726             hcharPixls->Fill(lumiBlock, adc);
2727             hcharPixLumi->Fill(instlumi, adc);
2728 
2729 #ifdef VDM_STUDIES
2730             hcharPixls2->Fill(lumiBlock, adc);
2731 #endif
2732             //if( (ladder==-11 && module==-1) || (ladder==-11 && module== 1) ) {
2733             //hpixchargen->Fill(adc);
2734             //if(       ladder==-11 && module==-1 ) hpixchargen1->Fill(adc);
2735             //else if ( ladder==-11 && module== 1 ) hpixchargen2->Fill(adc);
2736             //}
2737 
2738             //if(module2[int(pixx)][int(pixy)]>MAX_CUT)
2739             // edm::LogPrint("TestClusters")<<" module "<<layer<<" "<<ladder<<" "<<module<<" "
2740             //  <<pixx<<" "<<pixy<<" "<<module2[int(pixx)][int(pixy)]<<endl;
2741 
2742           } else if (layer == 3) {
2743             numOfPixPerDet3++;
2744             numOfPixPerLay3++;
2745             //valid = valid || true;
2746             hpixcharge3->Fill(adc);
2747             hpixDetMap3->Fill(pixy, pixx);
2748             //if(ladder==l3ldr&&module==l3mod) hpixDetMap30->Fill(pixy,pixx,adc);
2749             hpDetMap3->Fill(float(module), float(ladder));
2750             //module3[int(pixx)][int(pixy)]++;
2751 
2752             hpcols3->Fill(pixy);
2753             hprows3->Fill(pixx);
2754 
2755             if (ladder == -5 && module == -4)
2756               hpixDetMap30->Fill(pixy, pixx);  // ineff
2757             else if (ladder == 9 && module == 4)
2758               hpixDetMap31->Fill(pixy, pixx);  // adr errors, NOR
2759             else if (ladder == 15 && module == -3)
2760               hpixDetMap32->Fill(pixy, pixx);  // ineff
2761             else if (ladder == 17 && module == -4)
2762               hpixDetMap33->Fill(pixy, pixx);  // ineff, NOR
2763             //else if(ladder== 6   && module== 4) hpixDetMap34->Fill(pixy,pixx); // gain ineff
2764             //else if(ladder==-14  && module==-3) hpixDetMap35->Fill(pixy,pixx); // gain low slope
2765             else if (ladder == -6 && module == -1)
2766               hpixDetMap34->Fill(pixy, pixx);  // roc eff 1 run
2767             else if (ladder == -13 && module == 4)
2768               hpixDetMap35->Fill(pixy, pixx);  // "
2769             else if (ladder == 14 && module == -4)
2770               hpixDetMap36->Fill(pixy, pixx);  // ineff pixel alive
2771             else if (ladder == -6 && module == 2)
2772               hpixDetMap37->Fill(pixy, pixx);  // E pattern
2773             else if (ladder == 19 && module == -4)
2774               hpixDetMap38->Fill(pixy, pixx);  // large thr.
2775             //else if(ladder==-8   && module==-1) hpixDetMap39->Fill(pixy,pixx); // large thr rms
2776             //else if(ladder== 11 && module== 1) hpixDetMap39->Fill(pixy,pixx); // old ROCs
2777             else if (ladder == -7 && module == -4)
2778               hpixDetMap39->Fill(pixy, pixx);  // roc eff (1 run)
2779 
2780             hpixchar3->Fill(zPos, adc);
2781             hcharPixbx->Fill(bx, adc);
2782             hcharPixls->Fill(lumiBlock, adc);
2783             hcharPixLumi->Fill(instlumi, adc);
2784 
2785             //      if(     countEvents== 66  && ladder==-17 && module== 4) hpixDetMap300->Fill(pixy,pixx);
2786             //      else if(countEvents==502  && ladder== 14 && module== 3) hpixDetMap301->Fill(pixy,pixx);
2787             //      else if(countEvents==1830 && ladder== 14 && module==-2) hpixDetMap302->Fill(pixy,pixx);
2788             //      else if(countEvents==4720 && ladder== 12 && module==-3) hpixDetMap303->Fill(pixy,pixx);
2789             //      else if(countEvents==7241 && ladder== -2 && module== 4) hpixDetMap304->Fill(pixy,pixx);
2790             //      else if(countEvents==8845 && ladder== -5 && module== 4) hpixDetMap305->Fill(pixy,pixx);
2791             //      else if(countEvents==9267 && ladder==  6 && module== 4) hpixDetMap306->Fill(pixy,pixx);
2792 
2793             //if(module3[int(pixx)][int(pixy)]>MAX_CUT)
2794             //edm::LogPrint("TestClusters")<<" module "<<layer<<" "<<ladder<<" "<<module<<" "
2795             //  <<pixx<<" "<<pixy<<" "<<module3[int(pixx)][int(pixy)]<<endl;
2796 
2797 #ifdef VDM_STUDIES
2798             hcharPixls3->Fill(lumiBlock, adc);
2799 #endif
2800 
2801 #if defined(BX) || defined(BX_NEW)
2802             if (bxId > -1) {
2803               if (bxId == 3)
2804                 hpixChargebx1->Fill(adc);  // coll
2805               else if (bxId == 4)
2806                 hpixChargebx2->Fill(adc);  // coll+1
2807               else if (bxId == 0)
2808                 hpixChargebx6->Fill(adc);  // empty
2809               else if (bxId == 1)
2810                 hpixChargebx3->Fill(adc);  // beam1
2811               else if (bxId == 2)
2812                 hpixChargebx3->Fill(adc);  // beam2
2813               else if (bxId == 5 || bxId == 6)
2814                 hpixChargebx5->Fill(adc);  // beam1/2+1
2815               else
2816                 edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
2817             }
2818 #endif
2819 
2820 #ifdef ROC_EFF
2821             pixEff->addPixel(3, ladder, module, roc);
2822 
2823             //index = lumiBlock/5;
2824             //      if     (ladder==11 && module== 1)  hmoduleHits3ls->Fill(float(lumiBlock),0);
2825 
2826             //      if     (ladder==-18 && module==-3 && roc== 0)  hrocHits3ls->Fill(float(lumiBlock),0);
2827             //      else if(ladder== 5  && module== 1 && roc== 5)  hrocHits3ls->Fill(float(lumiBlock),1);
2828             //      else if(ladder== 9  && module==-1 && roc== 2)  hrocHits3ls->Fill(float(lumiBlock),2);
2829             //      else if(ladder==10  && module==-3 && roc== 8)  hrocHits3ls->Fill(float(lumiBlock),3);
2830             //      else if(ladder==12  && module==-3 && roc==12)  hrocHits3ls->Fill(float(lumiBlock),4);
2831             //      else if(ladder==-18 && module==-2 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),5);
2832             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),6);
2833             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),7);
2834             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),8);
2835             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),9);
2836 
2837             // run 176286
2838             //if     (ladder==-18 && module==-2 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),0);
2839             //else if(ladder==-3  && module==-3 && roc==14)  hrocHits3ls->Fill(float(lumiBlock),1);
2840             //else if(ladder== 3  && module==-1 && roc==12)  hrocHits3ls->Fill(float(lumiBlock),2);
2841             //else if(ladder==16  && module==-3 && roc== 6)  hrocHits3ls->Fill(float(lumiBlock),3);
2842             //else if(ladder== 2  && module== 1 && roc== 0)  hrocHits3ls->Fill(float(lumiBlock),4);
2843             // run 180250
2844             if (ladder == -13 && module == 4 && roc == 12)
2845               hrocHits3ls->Fill(float(lumiBlock), 0);
2846             else if (ladder == -7 && module == -4 && roc == 15)
2847               hrocHits3ls->Fill(float(lumiBlock), 1);
2848             else if (ladder == -6 && module == -2 && roc == 10)
2849               hrocHits3ls->Fill(float(lumiBlock), 2);
2850               //else if(ladder==16  && module==-3 && roc== 6)  hrocHits3ls->Fill(float(lumiBlock),3);
2851               //else if(ladder== 2  && module== 1 && roc== 0)  hrocHits3ls->Fill(float(lumiBlock),4);
2852 
2853 #endif
2854 
2855           }  // if layer
2856 
2857         } else if (subid == 2 && (selectEvent == -1 || countEvents == selectEvent)) {  // endcap
2858           // pixels
2859 
2860           if (disk == 1) {  // disk1 -+z
2861             if (side == 1)
2862               numOfPixPerDisk2++;  // d1,-z
2863             else if (side == 2)
2864               numOfPixPerDisk3++;  // d1, +z
2865             else
2866               edm::LogPrint("TestClusters") << " unknown side " << side;
2867 
2868             hpixcharge4->Fill(adc);
2869             hpixDiskR1->Fill(rPos);
2870 
2871           } else if (disk == 2) {  // disk2 -+z
2872 
2873             if (side == 1)
2874               numOfPixPerDisk1++;  // d2, -z
2875             else if (side == 2)
2876               numOfPixPerDisk4++;  // d2, +z
2877             else
2878               edm::LogPrint("TestClusters") << " unknown side " << side;
2879 
2880             hpixcharge5->Fill(adc);
2881             hpixDiskR2->Fill(rPos);
2882 
2883           } else
2884             edm::LogPrint("TestClusters") << " unknown disk " << disk;
2885 
2886         }  // end if subdet (pixel loop)
2887 
2888 #endif  // HISTOS
2889 
2890         // Find if this cluster includes an edge pixel
2891         edgeInX = topol->isItEdgePixelInX(int(pixx));
2892         edgeInY = topol->isItEdgePixelInY(int(pixy));
2893 
2894         if (PRINT)
2895           edm::LogPrint("TestClusters") << i << " " << pixx << " " << pixy << " " << adc << " " << bigInX << " "
2896                                         << bigInY << " " << edgeInX << " " << edgeInY;
2897 
2898         if (edgeInX)
2899           edgeHitX2 = true;
2900         if (edgeInY)
2901           edgeHitY2 = true;
2902         //if(bigInX) cluBigInX=true;
2903         //if(bigInY) cluBigInY=true;
2904 
2905       }  // pixel loop
2906 
2907 #ifdef HISTOS
2908 
2909       // Cluster histos
2910       if (subid == 1 && (selectEvent == -1 || countEvents == selectEvent)) {  // barrel
2911         //if (subid==1) {  // barrel
2912 
2913         if (layer == 1) {  // layer 1
2914 
2915           hDetMap1->Fill(float(module), float(ladder));
2916           hsizeDetMap1->Fill(float(module), float(ladder), float(size));
2917           //hsizeXDetMap1->Fill(float(module),float(ladder),float(sizeX));
2918           //hsizeYDetMap1->Fill(float(module),float(ladder),float(sizeY));
2919 
2920           hcluDetMap1->Fill(y, x);
2921           hcharge1->Fill(ch);
2922           //hcols1->Fill(y);
2923           //hrows1->Fill(x);
2924           hsize1->Fill(float(size));
2925           hsizex1->Fill(float(sizeX));
2926           hsizey1->Fill(float(sizeY));
2927           numOfClustersPerDet1++;
2928           numOfClustersPerLay1++;
2929           avCharge1 += ch;
2930 
2931           //if(numOf<10) hcharge11->Fill(ch);
2932           //else if(numOf<25) hcharge12->Fill(ch);
2933           //else if(numOf<100) hcharge13->Fill(ch);
2934           //else hcharge14->Fill(ch);
2935 
2936           hgz1->Fill(zPos);
2937           hclumult1->Fill(zPos, size);
2938           hclumultx1->Fill(zPos, sizeX);
2939           hclumulty1->Fill(zPos, sizeY);
2940           hcluchar1->Fill(zPos, ch);
2941 
2942 #if defined(BX) || defined(BX_NEW)
2943           if (bxId > -1) {
2944             if (bxId == 3) {
2945               hchargebx1->Fill(ch);
2946               hsizebx1->Fill(size);
2947             }  // coll
2948             else if (bxId == 4) {
2949               hchargebx2->Fill(ch);
2950               hsizebx2->Fill(size);
2951             }  // coll+1
2952             else if (bxId == 0) {
2953               hchargebx6->Fill(ch);
2954               hsizebx6->Fill(size);
2955             }  // empty
2956             else if (bxId == 1) {
2957               hchargebx3->Fill(ch);
2958               hsizebx3->Fill(size);
2959             }  // beam1
2960             else if (bxId == 2) {
2961               hchargebx4->Fill(ch);
2962               hsizebx3->Fill(size);
2963             }  // beam2
2964             else if (bxId == 5 || bxId == 6) {
2965               hchargebx5->Fill(ch);
2966               hsizebx5->Fill(size);
2967             }  // beam1/2+1
2968             else
2969               edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
2970           }
2971           //if(bxId==0) htestbx->Fill(bx,ch);
2972 #endif
2973 
2974           hcharClubx->Fill(bx, ch);
2975           hsizeClubx->Fill(bx, size);
2976           hsizeYClubx->Fill(bx, sizeY);
2977           hcharCluls->Fill(lumiBlock, ch);
2978           hsizeCluls->Fill(lumiBlock, size);
2979           hsizeXCluls->Fill(lumiBlock, sizeX);
2980 
2981           hcharCluLumi->Fill(instlumi, ch);
2982           hsizeCluLumi->Fill(instlumi, size);
2983           hsizeXCluLumi->Fill(instlumi, sizeX);
2984           hsizeYCluLumi->Fill(instlumi, sizeY);
2985 
2986           //hchargen5->Fill(ch,float(size));
2987           //hchargen3->Fill(ch);
2988           //if(size==1) hchargen4->Fill(ch);
2989 
2990 #ifdef VDM_STUDIES
2991           hcharCluls1->Fill(lumiBlock, ch);
2992           hsizeCluls1->Fill(lumiBlock, size);
2993           hsizeXCluls1->Fill(lumiBlock, sizeX);
2994 #endif
2995 
2996         } else if (layer == 2) {
2997           hDetMap2->Fill(float(module), float(ladder));
2998           hsizeDetMap2->Fill(float(module), float(ladder), float(size));
2999           //hsizeXDetMap2->Fill(float(module),float(ladder),float(sizeX));
3000           //hsizeYDetMap2->Fill(float(module),float(ladder),float(sizeY));
3001 
3002           hcluDetMap2->Fill(y, x);
3003           hcharge2->Fill(ch);
3004           //hcols2->Fill(y);
3005           //hrows2->Fill(x);
3006           hsize2->Fill(float(size));
3007           hsizex2->Fill(float(sizeX));
3008           hsizey2->Fill(float(sizeY));
3009           numOfClustersPerDet2++;
3010           numOfClustersPerLay2++;
3011           avCharge2 += ch;
3012           hgz2->Fill(zPos);
3013           hclumult2->Fill(zPos, size);
3014           hclumultx2->Fill(zPos, sizeX);
3015           hclumulty2->Fill(zPos, sizeY);
3016           hcluchar2->Fill(zPos, ch);
3017 
3018           if ((ladder == -11 && module == -1) || (ladder == -11 && module == 1)) {
3019             //hchargen->Fill(ch);
3020             //hsizen->Fill(float(size));
3021             //hsizexn->Fill(float(sizeX));
3022             //hsizeyn->Fill(float(sizeY));
3023             // if( (ladder==-11 && module==-1) ) {
3024             //   hchargen1->Fill(ch);
3025             //   hsizen1->Fill(float(size));
3026             //   hsizexn1->Fill(float(sizeX));
3027             //   hsizeyn1->Fill(float(sizeY));
3028             // } else {
3029             //   hchargen2->Fill(ch);
3030             //   hsizen2->Fill(float(size));
3031             //   hsizexn2->Fill(float(sizeX));
3032             //   hsizeyn2->Fill(float(sizeY));
3033             // }
3034           }
3035 
3036 #if defined(BX) || defined(BX_NEW)
3037           if (bxId > -1) {
3038             if (bxId == 3) {
3039               hchargebx1->Fill(ch);
3040               hsizebx1->Fill(size);
3041             }  // coll
3042             else if (bxId == 4) {
3043               hchargebx2->Fill(ch);
3044               hsizebx2->Fill(size);
3045             }  // coll+1
3046             else if (bxId == 0) {
3047               hchargebx6->Fill(ch);
3048               hsizebx6->Fill(size);
3049             }  // empty
3050             else if (bxId == 1) {
3051               hchargebx3->Fill(ch);
3052               hsizebx3->Fill(size);
3053             }  // beam1
3054             else if (bxId == 2) {
3055               hchargebx4->Fill(ch);
3056               hsizebx3->Fill(size);
3057             }  // beam2
3058             else if (bxId == 5 || bxId == 6) {
3059               hchargebx5->Fill(ch);
3060               hsizebx5->Fill(size);
3061             }  // beam1/2+1
3062             else
3063               edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
3064           }
3065 #endif
3066 
3067           hcharClubx->Fill(bx, ch);
3068           hsizeClubx->Fill(bx, size);
3069           hsizeYClubx->Fill(bx, sizeY);
3070           hcharCluls->Fill(lumiBlock, ch);
3071           hsizeCluls->Fill(lumiBlock, size);
3072           hsizeXCluls->Fill(lumiBlock, sizeX);
3073           hcharCluLumi->Fill(instlumi, ch);
3074           hsizeCluLumi->Fill(instlumi, size);
3075           hsizeXCluLumi->Fill(instlumi, sizeX);
3076           hsizeYCluLumi->Fill(instlumi, sizeY);
3077 
3078           //hchargen5->Fill(ch,float(size));
3079           //hchargen3->Fill(ch);
3080           //if(size==1) hchargen4->Fill(ch);
3081 
3082 #ifdef VDM_STUDIES
3083           hcharCluls2->Fill(lumiBlock, ch);
3084           hsizeCluls2->Fill(lumiBlock, size);
3085           hsizeXCluls2->Fill(lumiBlock, sizeX);
3086 #endif
3087 
3088         } else if (layer == 3) {
3089           hDetMap3->Fill(float(module), float(ladder));
3090           hsizeDetMap3->Fill(float(module), float(ladder), float(size));
3091           //hsizeXDetMap3->Fill(float(module),float(ladder),float(sizeX));
3092           //hsizeYDetMap3->Fill(float(module),float(ladder),float(sizeY));
3093 
3094           hcluDetMap3->Fill(y, x);
3095           hcharge3->Fill(ch);
3096           //hcols3->Fill(y);
3097           //hrows3->Fill(x);
3098           hsize3->Fill(float(size));
3099           hsizex3->Fill(float(sizeX));
3100           hsizey3->Fill(float(sizeY));
3101           numOfClustersPerDet3++;
3102           numOfClustersPerLay3++;
3103           avCharge3 += ch;
3104           hgz3->Fill(zPos);
3105           hclumult3->Fill(zPos, size);
3106           hclumultx3->Fill(zPos, sizeX);
3107           hclumulty3->Fill(zPos, sizeY);
3108           hcluchar3->Fill(zPos, ch);
3109 
3110 #if defined(BX) || defined(BX_NEW)
3111           if (bxId > -1) {
3112             if (bxId == 3) {
3113               hchargebx1->Fill(ch);
3114               hsizebx1->Fill(size);
3115             }  // coll
3116             else if (bxId == 4) {
3117               hchargebx2->Fill(ch);
3118               hsizebx2->Fill(size);
3119             }  // coll+1
3120             else if (bxId == 0) {
3121               hchargebx6->Fill(ch);
3122               hsizebx6->Fill(size);
3123             }  // empty
3124             else if (bxId == 1) {
3125               hchargebx3->Fill(ch);
3126               hsizebx3->Fill(size);
3127             }  // beam1
3128             else if (bxId == 2) {
3129               hchargebx4->Fill(ch);
3130               hsizebx3->Fill(size);
3131             }  // beam2
3132             else if (bxId == 5 || bxId == 6) {
3133               hchargebx5->Fill(ch);
3134               hsizebx5->Fill(size);
3135             }  // beam1/2+1
3136             else
3137               edm::LogPrint("TestClusters") << " wrong bx id " << bxId;
3138           }
3139 #endif
3140 
3141           hcharClubx->Fill(bx, ch);
3142           hsizeClubx->Fill(bx, size);
3143           hsizeYClubx->Fill(bx, sizeY);
3144           hcharCluls->Fill(lumiBlock, ch);
3145           hsizeCluls->Fill(lumiBlock, size);
3146           hsizeXCluls->Fill(lumiBlock, sizeX);
3147           hcharCluLumi->Fill(instlumi, ch);
3148           hsizeCluLumi->Fill(instlumi, size);
3149           hsizeXCluLumi->Fill(instlumi, sizeX);
3150           hsizeYCluLumi->Fill(instlumi, sizeY);
3151 
3152           //hchargen5->Fill(ch,float(size));
3153           //hchargen3->Fill(ch);
3154           //if(size==1) hchargen4->Fill(ch);
3155 
3156 #ifdef VDM_STUDIES
3157           hcharCluls3->Fill(lumiBlock, ch);
3158           hsizeCluls3->Fill(lumiBlock, size);
3159           hsizeXCluls3->Fill(lumiBlock, sizeX);
3160 #endif
3161 
3162         }  // end if layer
3163 
3164       } else if (subid == 2 && (selectEvent == -1 || countEvents == selectEvent)) {  // endcap
3165 
3166         //edm::LogPrint("TestClusters")<<disk<<" "<<side<<endl;
3167         if (disk == 1) {  // disk1 -+z
3168           if (side == 1) {
3169             numOfClustersPerDisk2++;  // d1,-z
3170             avCharge4 += ch;
3171           } else if (side == 2) {
3172             numOfClustersPerDisk3++;  // d1, +z
3173             avCharge5 += ch;
3174           } else
3175             edm::LogPrint("TestClusters") << " unknown side " << side;
3176 
3177           hcharge4->Fill(ch);
3178 
3179         } else if (disk == 2) {  // disk2 -+z
3180 
3181           if (side == 1) {
3182             numOfClustersPerDisk1++;  // d2, -z
3183             avCharge4 += ch;
3184           } else if (side == 2) {
3185             numOfClustersPerDisk4++;  // d2, +z
3186             avCharge5 += ch;
3187           } else
3188             edm::LogPrint("TestClusters") << " unknown side " << side;
3189 
3190           hcharge5->Fill(ch);
3191 
3192         } else
3193           edm::LogPrint("TestClusters") << " unknown disk " << disk;
3194 
3195       }  // end barrel/forward cluster loop
3196 
3197 #endif  // HISTOS
3198 
3199       if ((edgeHitX != edgeHitX2) && sizeX < 64)
3200         edm::LogPrint("TestClusters") << " wrong egdeX " << edgeHitX << " " << edgeHitX2;
3201       if ((edgeHitY != edgeHitY2) && sizeY < 64)
3202         edm::LogPrint("TestClusters") << " wrong egdeY " << edgeHitY << " " << edgeHitY2;
3203 
3204     }  // clusters
3205 
3206     if (numOfClustersPerDet1 > maxClusPerDet)
3207       maxClusPerDet = numOfClustersPerDet1;
3208     if (numOfClustersPerDet2 > maxClusPerDet)
3209       maxClusPerDet = numOfClustersPerDet2;
3210     if (numOfClustersPerDet3 > maxClusPerDet)
3211       maxClusPerDet = numOfClustersPerDet3;
3212 
3213     if (PRINT) {
3214       if (layer == 1)
3215         edm::LogPrint("TestClusters") << "Lay1: number of clusters per det = " << numOfClustersPerDet1;
3216       else if (layer == 2)
3217         edm::LogPrint("TestClusters") << "Lay2: number of clusters per det = " << numOfClustersPerDet1;
3218       else if (layer == 3)
3219         edm::LogPrint("TestClusters") << "Lay3: number of clusters per det = " << numOfClustersPerDet1;
3220     }  // end if PRINT
3221 
3222 #ifdef HISTOS
3223     if (subid == 1 && (selectEvent == -1 || countEvents == selectEvent)) {  // barrel
3224       //if (subid==1 && countEvents==selectEvent) {  // barrel
3225 
3226       //hlayerid->Fill(float(layer));
3227 
3228       // Det histos
3229       if (layer == 1) {
3230         hladder1id->Fill(float(ladder));
3231         hz1id->Fill(float(module));
3232         ++numberOfDetUnits1;
3233         hclusPerDet1->Fill(float(numOfClustersPerDet1));
3234         hpixPerDet1->Fill(float(numOfPixPerDet1));
3235         if (numOfPixPerDet1 > maxPixPerDet)
3236           maxPixPerDet = numOfPixPerDet1;
3237         //if(numOfPixPerLink11>798 || numOfPixPerLink12>798) select=true;
3238         hpixPerLink1->Fill(float(numOfPixPerLink11));
3239         hpixPerLink1->Fill(float(numOfPixPerLink12));
3240         hDetsMap1->Fill(float(module), float(ladder));
3241 
3242         if (abs(module) == 1)
3243           hpixPerDet11->Fill(float(numOfPixPerDet1));
3244         else if (abs(module) == 2)
3245           hpixPerDet12->Fill(float(numOfPixPerDet1));
3246         else if (abs(module) == 3)
3247           hpixPerDet13->Fill(float(numOfPixPerDet1));
3248         else if (abs(module) == 4)
3249           hpixPerDet14->Fill(float(numOfPixPerDet1));
3250 
3251         numOfClustersPerDet1 = 0;
3252         numOfPixPerDet1 = 0;
3253         numOfPixPerLink11 = 0;
3254         numOfPixPerLink12 = 0;
3255 
3256       } else if (layer == 2) {
3257         hladder2id->Fill(float(ladder));
3258         hz2id->Fill(float(module));
3259         ++numberOfDetUnits2;
3260         hclusPerDet2->Fill(float(numOfClustersPerDet2));
3261         hpixPerDet2->Fill(float(numOfPixPerDet2));
3262         if (numOfPixPerDet2 > maxPixPerDet)
3263           maxPixPerDet = numOfPixPerDet2;
3264         hpixPerLink2->Fill(float(numOfPixPerLink21));
3265         hpixPerLink2->Fill(float(numOfPixPerLink22));
3266         hDetsMap2->Fill(float(module), float(ladder));
3267 
3268         if (abs(module) == 1)
3269           hpixPerDet21->Fill(float(numOfPixPerDet2));
3270         else if (abs(module) == 2)
3271           hpixPerDet22->Fill(float(numOfPixPerDet2));
3272         else if (abs(module) == 3)
3273           hpixPerDet23->Fill(float(numOfPixPerDet2));
3274         else if (abs(module) == 4)
3275           hpixPerDet24->Fill(float(numOfPixPerDet2));
3276 
3277         numOfClustersPerDet2 = 0;
3278         numOfPixPerDet2 = 0;
3279         numOfPixPerLink21 = 0;
3280         numOfPixPerLink22 = 0;
3281 
3282       } else if (layer == 3) {
3283         hladder3id->Fill(float(ladder));
3284         hz3id->Fill(float(module));
3285         ++numberOfDetUnits3;
3286         hclusPerDet3->Fill(float(numOfClustersPerDet3));
3287         hpixPerDet3->Fill(float(numOfPixPerDet3));
3288         if (numOfPixPerDet3 > maxPixPerDet)
3289           maxPixPerDet = numOfPixPerDet3;
3290         hDetsMap3->Fill(float(module), float(ladder));
3291 
3292         if (abs(module) == 1)
3293           hpixPerDet31->Fill(float(numOfPixPerDet3));
3294         else if (abs(module) == 2)
3295           hpixPerDet32->Fill(float(numOfPixPerDet3));
3296         else if (abs(module) == 3)
3297           hpixPerDet33->Fill(float(numOfPixPerDet3));
3298         else if (abs(module) == 4)
3299           hpixPerDet34->Fill(float(numOfPixPerDet3));
3300 
3301         //  if(      module==-2&& ladder==13)  hpixPerDet100->Fill(float(numOfPixPerDet3));
3302         //  else if( module==+1&& ladder==11)  hpixPerDet101->Fill(float(numOfPixPerDet3));
3303         //  else if( module==-1&& ladder==9 )  hpixPerDet102->Fill(float(numOfPixPerDet3));
3304         //  else if( module==-4&& ladder==11)  hpixPerDet103->Fill(float(numOfPixPerDet3));
3305         //  else if( module==-2&& ladder==11)  hpixPerDet104->Fill(float(numOfPixPerDet3));
3306         //  else if( module==-2&& ladder==19)  hpixPerDet105->Fill(float(numOfPixPerDet3));
3307 
3308         //  if( numOfPixPerDet3>191 ) {
3309         //    edm::LogPrint("TestClusters")<<" Layer 3 module "<<ladder<<" "<<module<<" "<<numOfPixPerDet3<<endl;
3310         //    select = true;
3311         //  }
3312 
3313         numOfClustersPerDet3 = 0;
3314         numOfPixPerDet3 = 0;
3315         //numOfPixPerLink3=0;
3316 
3317       }  // layer
3318 
3319     }  // end barrel/forward
3320 
3321 #endif  // HISTOS
3322 
3323   }  // detunits loop
3324 
3325   if (PRINT || countEvents == selectEvent) {  //
3326     edm::LogPrint("TestClusters") << "run " << run << " event " << event << " bx " << bx << " lumi " << lumiBlock
3327                                   << " orbit " << orbit << " " << countEvents;
3328     edm::LogPrint("TestClusters") << "Num of pix " << numberOfPixels << " num of clus " << numberOfClusters
3329                                   << " max clus per det " << maxClusPerDet << " max pix per clu " << maxPixPerClu
3330                                   << " count " << countEvents;
3331     edm::LogPrint("TestClusters") << "Number of clusters per Lay1,2,3: " << numOfClustersPerLay1 << " "
3332                                   << numOfClustersPerLay2 << " " << numOfClustersPerLay3;
3333     edm::LogPrint("TestClusters") << "Number of pixels per Lay1,2,3: " << numOfPixPerLay1 << " " << numOfPixPerLay2
3334                                   << " " << numOfPixPerLay3;
3335     edm::LogPrint("TestClusters") << "Number of dets with clus in Lay1,2,3: " << numberOfDetUnits1 << " "
3336                                   << numberOfDetUnits2 << " " << numberOfDetUnits3;
3337   }  // if PRINT
3338 
3339 #ifdef HISTOS
3340 
3341   //if(numberOfClusters<=3) continue; // skip events
3342   if ((selectEvent == -1 || countEvents == selectEvent)) {
3343     hdets2->Fill(float(numOf));  // number of modules with pix
3344     hlumi1->Fill(float(lumiBlock));
3345 
3346     //if(bptx_m && bptx_xor) hbx7->Fill(float(bx));
3347     //if(bptx_p && bptx_xor) hbx8->Fill(float(bx));
3348     //if(bptx_and) hbx9->Fill(float(bx));
3349     //if(bptx_or)  hbx10->Fill(float(bx));
3350 
3351     hdigis->Fill(float(numberOfPixels));   // all pix
3352     hdigis2->Fill(float(numberOfPixels));  // same zoomed
3353 
3354     int pixb = numOfPixPerLay1 + numOfPixPerLay2 + numOfPixPerLay3;
3355     hdigisB->Fill(float(pixb));  // pix in bpix
3356     int pixf = numOfPixPerDisk1 + numOfPixPerDisk2 + numOfPixPerDisk3 + numOfPixPerDisk4;
3357     hdigisF->Fill(float(pixf));  // pix in fpix
3358 
3359     hclus->Fill(float(numberOfClusters));   // clusters fpix+bpix
3360     hclus2->Fill(float(numberOfClusters));  // same, zoomed
3361 
3362     //h2clupv->Fill(float(numberOfClusters),float(numPVsGood));
3363     //h2pixpv->Fill(float(numberOfPixels),float(numPVsGood));
3364     hclupv->Fill(float(numberOfClusters), float(numPVsGood));
3365     hpixpv->Fill(float(numberOfPixels), float(numPVsGood));
3366     //if(numPVsGood>0) {
3367     //float tmp = float(numberOfClusters)/float(numPVsGood);
3368     //hclupvlsn->Fill(float(lumiBlock),tmp);
3369     //tmp = float(numberOfPixels)/float(numPVsGood);
3370     //hpixpvlsn->Fill(float(lumiBlock),tmp);
3371     //}
3372 
3373     int clusb = numOfClustersPerLay1 + numOfClustersPerLay2 + numOfClustersPerLay3;
3374     hclusBPix->Fill(float(clusb));  // clusters in bpix
3375 
3376     int clusf = numOfClustersPerDisk1 + numOfClustersPerDisk2 + numOfClustersPerDisk3 + numOfClustersPerDisk4;
3377     hclusFPix->Fill(float(clusf));  // clusters in fpix
3378 
3379     hclus5->Fill(float(numberOfNoneEdgePixels));               // count none edge pixels
3380     hclusls->Fill(float(lumiBlock), float(numberOfClusters));  // clusters fpix+bpix
3381     hpixls->Fill(float(lumiBlock), float(numberOfPixels));     // pixels fpix+bpix
3382 
3383     hclubx->Fill(float(bx), float(numberOfClusters));  // clusters fpix+bpix
3384     hpixbx->Fill(float(bx), float(numberOfPixels));    // pixels fpix+bpix
3385     hpvbx->Fill(float(bx), float(numPVsGood));         // pvs
3386 
3387 #ifdef VDM_STUDIES
3388     hclusls1->Fill(float(lumiBlock), float(numOfClustersPerLay1));  // clusters bpix1
3389     hpixls1->Fill(float(lumiBlock), float(numOfPixPerLay1));        // pixels bpix1
3390     hclusls2->Fill(float(lumiBlock), float(numOfClustersPerLay2));  // clusters bpix2
3391     hpixls2->Fill(float(lumiBlock), float(numOfPixPerLay2));        // pixels bpix2
3392     hclusls3->Fill(float(lumiBlock), float(numOfClustersPerLay3));  // clusters bpix3
3393     hpixls3->Fill(float(lumiBlock), float(numOfPixPerLay3));        // pixels bpix3
3394 #endif
3395 
3396     if (instlumi > 0.) {
3397       hcluLumi->Fill(instlumi, float(numberOfClusters));  // clus
3398       hpixLumi->Fill(instlumi, float(numberOfPixels));    // pix
3399 
3400 #ifdef INSTLUMI_STUDIES
3401 
3402       float tmp = float(numberOfClusters) / instlumi;
3403       hcluslsn->Fill(float(lumiBlock), tmp);  // clusters fpix+bpix
3404       tmp = float(numberOfPixels) / instlumi;
3405       hpixlsn->Fill(float(lumiBlock), tmp);  // pixels fpix+bpix
3406 
3407       // pix & clus per lumi
3408       tmp = float(pixb);
3409       hpixbl->Fill(instlumi, tmp);  // pixels bpix
3410 
3411       tmp = float(numOfPixPerLay1);
3412       hpixb1l->Fill(instlumi, tmp);  // pixels bpix
3413       tmp = float(numOfPixPerLay2);
3414       hpixb2l->Fill(instlumi, tmp);  // pixels bpix
3415       tmp = float(numOfPixPerLay3);
3416       hpixb3l->Fill(instlumi, tmp);  // pixels bpix
3417 
3418       tmp = float(pixf);
3419       hpixfl->Fill(instlumi, tmp);  // pixels fpix
3420 
3421       tmp = float(numOfPixPerDisk1 + numOfPixPerDisk2);  // -z
3422       hpixfml->Fill(instlumi, tmp);                      // pixels fpix
3423       tmp = float(numOfPixPerDisk3 + numOfPixPerDisk4);  // +z
3424       hpixfpl->Fill(instlumi, tmp);                      // pixels fpix
3425 
3426       tmp = float(clusb);
3427       hclusbl->Fill(instlumi, tmp);  // clus bpix
3428       tmp = float(numOfClustersPerLay1);
3429       hclusb1l->Fill(instlumi, tmp);  // clus bpix
3430       tmp = float(numOfClustersPerLay2);
3431       hclusb2l->Fill(instlumi, tmp);  // clus bpix
3432       tmp = float(numOfClustersPerLay3);
3433       hclusb3l->Fill(instlumi, tmp);  // clus bpix
3434 
3435       tmp = float(clusf);
3436       hclusfl->Fill(instlumi, tmp);  // clus  fpix
3437       tmp = float(numOfClustersPerDisk1 + numOfClustersPerDisk2);
3438       hclusfml->Fill(instlumi, tmp);  // clus fpix
3439       tmp = float(numOfClustersPerDisk3 + numOfClustersPerDisk4);
3440       hclusfpl->Fill(instlumi, tmp);  // clus fpix
3441 
3442       // bx
3443       tmp = float(numberOfClusters) / instlumi;
3444       hclubxn->Fill(float(bx), tmp);  // clusters fpix+bpix
3445       tmp = float(numberOfPixels) / instlumi;
3446       hpixbxn->Fill(float(bx), tmp);  // pixels fpix+bpix
3447       tmp = float(numPVsGood) / instlumi;
3448       hpvbxn->Fill(float(bx), tmp);  // pvs
3449 
3450       //       tmp = float(numOfClustersPerLay1)/float(numOfClustersPerLay3);
3451       //       hclus13ls->Fill(float(lumiBlock),tmp); // clus 1/3
3452       //       tmp = float(numOfClustersPerLay2)/float(numOfClustersPerLay3);
3453       //       hclus23ls->Fill(float(lumiBlock),tmp); // clus 2/3
3454       //       tmp = float(numOfClustersPerLay1)/float(numOfClustersPerLay2);
3455       //       hclus12ls->Fill(float(lumiBlock),tmp); // clus 1/2
3456       //       tmp = float(clusf)/float(numOfClustersPerLay3);
3457       //       hclusf3ls->Fill(float(lumiBlock),tmp); // clus f/3
3458 
3459 #endif  // INSTLUMI_STUDIES
3460 
3461     }  // if instlumi
3462 
3463     hclusPerLay1->Fill(float(numOfClustersPerLay1));
3464     hclusPerLay2->Fill(float(numOfClustersPerLay2));
3465     hclusPerLay3->Fill(float(numOfClustersPerLay3));
3466     hpixPerLay1->Fill(float(numOfPixPerLay1));
3467     hpixPerLay2->Fill(float(numOfPixPerLay2));
3468     hpixPerLay3->Fill(float(numOfPixPerLay3));
3469     if (numOfClustersPerLay1 > 0)
3470       hdetsPerLay1->Fill(float(numberOfDetUnits1));
3471     if (numOfClustersPerLay2 > 0)
3472       hdetsPerLay2->Fill(float(numberOfDetUnits2));
3473     if (numOfClustersPerLay3 > 0)
3474       hdetsPerLay3->Fill(float(numberOfDetUnits3));
3475 
3476     hclusPerDisk1->Fill(float(numOfClustersPerDisk1));
3477     hclusPerDisk2->Fill(float(numOfClustersPerDisk2));
3478     hclusPerDisk3->Fill(float(numOfClustersPerDisk3));
3479     hclusPerDisk4->Fill(float(numOfClustersPerDisk4));
3480 
3481     hpixPerDisk1->Fill(float(numOfPixPerDisk1));
3482     hpixPerDisk2->Fill(float(numOfPixPerDisk2));
3483     hpixPerDisk3->Fill(float(numOfPixPerDisk3));
3484     hpixPerDisk4->Fill(float(numOfPixPerDisk4));
3485 
3486     hmaxPixPerDet->Fill(float(maxPixPerDet));
3487 
3488     //     // Check mod and roc time dependence
3489     //     if( (lumiBlock%5) == 0 ) { // do every 5 lumi blocks
3490 
3491     //       int id=0, lad=0, mod=0, roc=0, layer=0, index=0;
3492     //       float tmp=0;
3493     //       // ROCs
3494     //       // Layer 1,
3495     //       layer=1;
3496     //       id = 0;
3497     //       lad=-3;mod=1;roc=5;
3498     //       tmp = pixEff->getRoc(layer,lad,mod,roc);
3499     //       tmp = tmp - rocHits[layer-1][id];
3500     //       rocHits[layer-1][id] = tmp;
3501     //       index = lumiBlock/5;
3502     //       hrocHits1ls->Fill(float(index),id,tmp);
3503 
3504     //       // Layer 2,
3505     //       layer=2;
3506     //       id = 0;
3507     //       lad=-5;mod=-2;roc=10;
3508     //       tmp = pixEff->getRoc(layer,lad,mod,roc);
3509     //       tmp = tmp - rocHits[layer-1][id];
3510     //       rocHits[layer-1][id] = tmp;
3511     //       index = lumiBlock/5;
3512     //       hrocHits2ls->Fill(float(index),id,tmp);
3513     //       // Layer 3,
3514     //       layer=3;
3515     //       id = 0;
3516     //       lad=-18;mod=-2;roc=14;
3517     //       tmp = pixEff->getRoc(layer,lad,mod,roc);
3518     //       tmp = tmp - rocHits[layer-1][id];
3519     //       rocHits[layer-1][id] = tmp;
3520     //       index = lumiBlock/5;
3521     //       hrocHits3ls->Fill(float(index),id,tmp);
3522     //       // MODULES
3523     //       float half1=0, half2=0;
3524     //       // Layer 1,
3525     //       layer=1;
3526     //       id = 0;
3527     //       lad=-3;mod=1;
3528     //       tmp = pixEff->getModule(layer,lad,mod,half1,half2);
3529     //       tmp = tmp - moduleHits[layer-1][id];
3530     //       moduleHits[layer-1][id] = tmp;
3531     //       index = lumiBlock/5;
3532     //       hmoduleHits1ls->Fill(float(index),id,tmp);
3533 
3534     //     }
3535 
3536 #ifdef SEB
3537 //     float tmp0=0., tmp3=0., tmp4=0., tmp5=0.;
3538 //     //if(numOfClustersPerLay1>0) { tmp0 = avCharge1/float(numOfClustersPerLay1); havCharge1->Fill(tmp0);}
3539 //     //if(numOfClustersPerLay2>0) { tmp0 = avCharge2/float(numOfClustersPerLay2); havCharge1->Fill(tmp0);}
3540 //     //if(numOfClustersPerLay3>0) { tmp0 = avCharge3/float(numOfClustersPerLay3); havCharge1->Fill(tmp0);}
3541 //     if( (numOfClustersPerDisk1 + numOfClustersPerDisk2) > 0 )
3542 //       tmp4 = avCharge4/float(numOfClustersPerDisk2 + numOfClustersPerDisk1);
3543 //     if( (numOfClustersPerDisk3 + numOfClustersPerDisk4) > 0 )
3544 //       tmp5 = avCharge5/float(numOfClustersPerDisk3 + numOfClustersPerDisk4);
3545 //     //tmp4 = float(numOfClustersPerDisk2 + numOfClustersPerDisk1);
3546 //     //tmp5 = float(numOfClustersPerDisk3 + numOfClustersPerDisk4);
3547 //     havCharge6->Fill(float(tmp4));
3548 //     havCharge6->Fill(float(tmp5));
3549 //     float tmp8=1.03;
3550 //     if( (tmp4+tmp5) > 0. ) tmp8 = tmp5/(tmp4+tmp5);
3551 //     else tmp8 = 1.05;
3552 //     havCharge3->Fill(tmp8);
3553 //     if(tmp1>0) {
3554 //       tmp3 = (avCharge1 + avCharge2 + avCharge3)/float(tmp1);  // average over bpix
3555 //       havCharge2->Fill(tmp3);
3556 //       //h2d1->Fill(tmp1,tmp3);  // bpix num of clusters vs av cluster charge
3557 //       //float tmp6 = float(numberOfDetUnits1 + numberOfDetUnits2 + numberOfDetUnits3); //num of dets
3558 //       //float tmp7 = float(tmp1)/float(tmp6);  // ave clusters per module
3559 //       //h2d2->Fill(tmp8,tmp3); //
3560 //       //h2d3->Fill(tmp8,tmp1); //
3561 //       if(tmp8>1.02) { // no signal in fpix
3562 //  havCharge1->Fill(tmp3);
3563 //  hclus20->Fill(float(numberOfClusters));
3564 //       } else if (tmp8>0.05 && tmp8<0.95) { // some signal in both disks
3565 //  havCharge4->Fill(tmp3);
3566 //  hclus21->Fill(float(numberOfClusters));
3567 //       } else { // tmp=0., 1., signal in only one disk
3568 //  havCharge5->Fill(tmp3);
3569 //  hclus22->Fill(float(numberOfClusters));
3570 //       }
3571 //     } else {  // no bpix hits
3572 //       hclus23->Fill(float(numberOfClusters));
3573 //     }
3574 #endif  // SEB
3575 
3576 #ifdef L1
3577     //int numberOfClusters0 = numberOfClusters;  // select all clusters
3578 
3579     //if(bptx3) hclus1->Fill(float(numberOfClusters0));
3580     //if(bptx4) hclus2->Fill(float(numberOfClusters0));
3581     //if(bit0)  hclus10->Fill(float(numberOfClusters0));   //
3582     //if(bptx_and) hclus11->Fill(float(numberOfClusters0));
3583     //if(bptx_xor) hclus12->Fill(float(numberOfClusters0));
3584     //if(!bptx_xor && !bptx_and) hclus13->Fill(float(numberOfClusters0));
3585     //if(bptx_m)   hclus14->Fill(float(numberOfClusters0));
3586     //if(bptx_p)   hclus15->Fill(float(numberOfClusters0));
3587 
3588     //if(bcs_all)   hclus4->Fill(float(numberOfClusters0));       // or of all BCS bits
3589     //else      hclus17->Fill(float(numberOfClusters0));      // no BCS
3590     //if(bit126) hclus6->Fill(float(numberOfClusters0));   // bit 126
3591     //if(bit124) hclus7->Fill(float(numberOfClusters0));
3592     //if(bit122) hclus26->Fill(float(numberOfClusters0));
3593     //if(bcsOR)      hclus8->Fill(float(numberOfClusters0));  // bit 34
3594     //if(bcs)        hclus9->Fill(float(numberOfClusters0));  // all bcs except 34
3595     //if(bcs_bptx)   hclus29->Fill(float(numberOfClusters0)); // bits 124,126
3596     //if(bcs_double) hclus28->Fill(float(numberOfClusters0)); // 36-39, 40-43
3597     //if(bit32_33)   hclus25->Fill(float(numberOfClusters0)); // bits 32,33? is this usefull
3598     //if(halo)       hclus3->Fill(float(numberOfClusters0));  // bits 36-39
3599     //if(bit85) hclus18->Fill(float(numberOfClusters0));      // bit85
3600     //if(minBias) hclus19->Fill(float(numberOfClusters0));    // bits 40,41
3601     // #ifdef BX
3602     //     if     (bxId==1)  {hclus30->Fill(float(numberOfClusters0));hdigis30->Fill(float(numberOfPixels));}
3603     //     else if(bxId==2)  {hclus31->Fill(float(numberOfClusters0));hdigis31->Fill(float(numberOfPixels));}
3604     //     else if(bxId==3)  {hclus32->Fill(float(numberOfClusters0));hdigis32->Fill(float(numberOfPixels));}
3605     //     else if(bxId==4)  {hclus33->Fill(float(numberOfClusters0));hdigis33->Fill(float(numberOfPixels));}
3606     //     else if(bxId==5)  {hclus34->Fill(float(numberOfClusters0));hdigis34->Fill(float(numberOfPixels));}
3607     //     else if(bxId==6)  {hclus35->Fill(float(numberOfClusters0));hdigis35->Fill(float(numberOfPixels));}
3608     //     else if(bxId==-1) {hclus36->Fill(float(numberOfClusters0));hdigis36->Fill(float(numberOfPixels));}
3609     //     else              {hclus37->Fill(float(numberOfClusters0));hdigis37->Fill(float(numberOfPixels));}
3610     //     if(run>=160888 && run<=160940) { // 64bx
3611     //       // Fill 1638
3612     //       if(bx==442)       {hclus7->Fill(float(numberOfClusters0));  hdigis7->Fill(float(numberOfPixels));} //B1, 1st
3613     //       else if(bx==3136) {hclus18->Fill(float(numberOfClusters0)); hdigis18->Fill(float(numberOfPixels));} //B1, last
3614     //       else if(bx==466)  {hclus25->Fill(float(numberOfClusters0)); hdigis25->Fill(float(numberOfPixels));} //B2, last
3615     //       else if(bx==3112) {hclus26->Fill(float(numberOfClusters0)); hdigis26->Fill(float(numberOfPixels));} //B2, 1st
3616     //     } else if(run>=160955 && run<=161176) { // 136bx
3617     //       // Fill 1640
3618     //       if(bx==149)       hclus7->Fill(float(numberOfClusters0));
3619     //       else if(bx==3184) hclus18->Fill(float(numberOfClusters0));
3620     //       else if(bx==173)  hclus25->Fill(float(numberOfClusters0));
3621     //       else if(bx==3112) hclus26->Fill(float(numberOfClusters0));
3622     //     } else if(run>=161216 && run<=161312) { // 200bx
3623     //       // Fill 1645
3624     //       if(bx==1 || bx==4) {
3625     //  hclus7->Fill(float(numberOfClusters0));
3626     //  hdigis7->Fill(float(numberOfPixels));
3627     //       } else if( bx==1950 || bx==1953 || bx==1956 || bx==1959 ) {
3628     //  hclus18->Fill(float(numberOfClusters0));
3629     //  hdigis18->Fill(float(numberOfPixels));
3630     //       } else if(bx==25 || bx==28) {
3631     //  hclus25->Fill(float(numberOfClusters0));
3632     //  hdigis25->Fill(float(numberOfPixels));
3633     //       } else if( bx==1878 || bx==1881 || bx==1884 || bx==1887 ) {
3634     //  hclus26->Fill(float(numberOfClusters0));
3635     //  hdigis26->Fill(float(numberOfPixels));      }
3636     //     }
3637     // #endif
3638 
3639     // Check L1 bits with pixel selection
3640     if (L1GTRR.isValid()) {
3641       //bool l1a = L1GTRR->decision();
3642       //edm::LogPrint("TestClusters")<<" L1 status :"<<l1a<<" "<<hex;
3643       for (unsigned int i = 0; i < L1GTRR->decisionWord().size(); ++i) {
3644         int l1flag = L1GTRR->decisionWord()[i];
3645         int t1flag = L1GTRR->technicalTriggerWord()[i];
3646         if (l1flag > 0)
3647           hl1a1->Fill(float(i));
3648         if (t1flag > 0 && i < 64)
3649           hl1t1->Fill(float(i));
3650       }  // for loop
3651     }    // if l1a
3652 
3653     // HLT bits
3654     for (unsigned int i = 0; i < 256; i++)
3655       if (hlt[i])
3656         hlt3->Fill(float(i));
3657 
3658 #endif  // L1
3659 
3660   }  // if select event
3661 
3662 #endif  // HISTOS
3663 
3664 }  // end
3665 
3666 //define this as a plug-in
3667 DEFINE_FWK_MODULE(TestClusters);