Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-13 02:31:43

0001 /*
0002  *  Offline DQM module for CSC local reconstruction - based on CSCValidation
0003  *
0004  */
0005 
0006 #include "DQMOffline/Muon/interface/CSCOfflineMonitor.h"
0007 
0008 using namespace std;
0009 
0010 ///////////////////
0011 //  CONSTRUCTOR  //
0012 ///////////////////
0013 CSCOfflineMonitor::CSCOfflineMonitor(const edm::ParameterSet& pset)
0014     : cscGeomToken_(esConsumes<CSCGeometry, MuonGeometryRecord>()),
0015       hcrateToken_(esConsumes<CSCCrateMap, CSCCrateMapRcd>()) {
0016   rd_token = consumes<FEDRawDataCollection>(pset.getParameter<edm::InputTag>("FEDRawDataCollectionTag"));
0017   sd_token = consumes<CSCStripDigiCollection>(pset.getParameter<edm::InputTag>("stripDigiTag"));
0018   wd_token = consumes<CSCWireDigiCollection>(pset.getParameter<edm::InputTag>("wireDigiTag"));
0019   al_token = consumes<CSCALCTDigiCollection>(pset.getParameter<edm::InputTag>("alctDigiTag"));
0020   cl_token = consumes<CSCCLCTDigiCollection>(pset.getParameter<edm::InputTag>("clctDigiTag"));
0021   rh_token = consumes<CSCRecHit2DCollection>(pset.getParameter<edm::InputTag>("cscRecHitTag"));
0022   se_token = consumes<CSCSegmentCollection>(pset.getParameter<edm::InputTag>("cscSegTag"));
0023 }
0024 
0025 void CSCOfflineMonitor::bookHistograms(DQMStore::IBooker& ibooker,
0026                                        edm::Run const& iRun,
0027                                        edm::EventSetup const& /* iSetup */) {
0028   // occupancies
0029   ibooker.cd();
0030   ibooker.setCurrentFolder("CSC/CSCOfflineMonitor/Occupancy");
0031 
0032   hCSCOccupancy = ibooker.book1D("hCSCOccupancy", "overall CSC occupancy", 13, -0.5, 12.5);
0033   hCSCOccupancy->setBinLabel(2, "Total Events");
0034   hCSCOccupancy->setBinLabel(4, "# Events with Wires");
0035   hCSCOccupancy->setBinLabel(6, "# Events with Strips");
0036   hCSCOccupancy->setBinLabel(8, "# Events with Wires&Strips");
0037   hCSCOccupancy->setBinLabel(10, "# Events with Rechits");
0038   hCSCOccupancy->setBinLabel(12, "# Events with Segments");
0039   hOWiresAndCLCT = ibooker.book2D("hOWiresAndCLCT", "Wire and CLCT Digi Occupancy ", 36, 0.5, 36.5, 20, 0.5, 20.5);
0040   hOWires = ibooker.book2D("hOWires", "Wire Digi Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
0041   hOWireSerial = ibooker.book1D("hOWireSerial", "Wire Occupancy by Chamber Serial", 601, -0.5, 600.5);
0042   hOWireSerial->setAxisTitle("Chamber Serial Number");
0043   hOStrips = ibooker.book2D("hOStrips", "Strip Digi Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
0044   hOStripSerial = ibooker.book1D("hOStripSerial", "Strip Occupancy by Chamber Serial", 601, -0.5, 600.5);
0045   hOStripSerial->setAxisTitle("Chamber Serial Number");
0046   hOStripsAndWiresAndCLCT =
0047       ibooker.book2D("hOStripsAndWiresAndCLCT", "Strip And Wire And CLCT Digi Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
0048   hOStripsAndWiresAndCLCT->setAxisTitle("Chamber #");
0049   hORecHits = ibooker.book2D("hORecHits", "RecHit Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
0050   hORecHitsSerial = ibooker.book1D("hORecHitSerial", "RecHit Occupancy by Chamber Serial", 601, -0.5, 600.5);
0051   hORecHitsSerial->setAxisTitle("Chamber Serial Number");
0052   hOSegments = ibooker.book2D("hOSegments", "Segment Occupancy", 36, 0.5, 36.5, 20, 0.5, 20.5);
0053   hOSegmentsSerial = ibooker.book1D("hOSegmentSerial", "Segment Occupancy by Chamber Serial", 601, -0.5, 600.5);
0054   hOSegmentsSerial->setAxisTitle("Chamber Serial Number");
0055 
0056   // wire digis
0057   ibooker.setCurrentFolder("CSC/CSCOfflineMonitor/Digis");
0058 
0059   // For low multiplicities (e.g. low or no pileup)
0060   hWirenGroupsTotal =
0061       ibooker.book1D("hWirenGroupsTotal", "Fired Wires per Event; # Wiregroups Fired", 250, 0., 250.);  // 1 bin is 1
0062   // For high multiplcities (e.g. with pileup)
0063   hWirenGroupsTotalHi =
0064       ibooker.book1D("hWirenGroupsTotalHi", "Fired Wires per Event; # Wiregroups Fired", 250, 0., 1000.);  // i bin is 4
0065 
0066   hWireTBin.push_back(ibooker.book1D("hWireTBin_m42", "Wire TBin Fired (ME -4/2); Time Bin (25ns)", 17, -0.5, 16.5));
0067   hWireTBin.push_back(ibooker.book1D("hWireTBin_m41", "Wire TBin Fired (ME -4/1); Time Bin (25ns)", 17, -0.5, 16.5));
0068   hWireTBin.push_back(ibooker.book1D("hWireTBin_m32", "Wire TBin Fired (ME -3/2); Time Bin (25ns)", 17, -0.5, 16.5));
0069   hWireTBin.push_back(ibooker.book1D("hWireTBin_m31", "Wire TBin Fired (ME -3/1); Time Bin (25ns)", 17, -0.5, 16.5));
0070   hWireTBin.push_back(ibooker.book1D("hWireTBin_m22", "Wire TBin Fired (ME -2/2); Time Bin (25ns)", 17, -0.5, 16.5));
0071   hWireTBin.push_back(ibooker.book1D("hWireTBin_m21", "Wire TBin Fired (ME -2/1); Time Bin (25ns)", 17, -0.5, 16.5));
0072   hWireTBin.push_back(ibooker.book1D("hWireTBin_m11a", "Wire TBin Fired (ME -1/1a); Time Bin (25ns)", 17, -0.5, 16.5));
0073   hWireTBin.push_back(ibooker.book1D("hWireTBin_m13", "Wire TBin Fired (ME -1/3); Time Bin (25ns)", 17, -0.5, 16.5));
0074   hWireTBin.push_back(ibooker.book1D("hWireTBin_m12", "Wire TBin Fired (ME -1/2); Time Bin (25ns)", 17, -0.5, 16.5));
0075   hWireTBin.push_back(ibooker.book1D("hWireTBin_m11b", "Wire TBin Fired (ME -1/1b); Time Bin (25ns)", 17, -0.5, 16.5));
0076   hWireTBin.push_back(ibooker.book1D("hWireTBin_p11b", "Wire TBin Fired (ME +1/1b); Time Bin (25ns)", 17, -0.5, 16.5));
0077   hWireTBin.push_back(ibooker.book1D("hWireTBin_p12", "Wire TBin Fired (ME +1/2); Time Bin (25ns)", 17, -0.5, 16.5));
0078   hWireTBin.push_back(ibooker.book1D("hWireTBin_p13", "Wire TBin Fired (ME +1/3); Time Bin (25ns)", 17, -0.5, 16.5));
0079   hWireTBin.push_back(ibooker.book1D("hWireTBin_p11a", "Wire TBin Fired (ME +1/1a); Time Bin (25ns)", 17, -0.5, 16.5));
0080   hWireTBin.push_back(ibooker.book1D("hWireTBin_p21", "Wire TBin Fired (ME +2/1); Time Bin (25ns)", 17, -0.5, 16.5));
0081   hWireTBin.push_back(ibooker.book1D("hWireTBin_p22", "Wire TBin Fired (ME +2/2); Time Bin (25ns)", 17, -0.5, 16.5));
0082   hWireTBin.push_back(ibooker.book1D("hWireTBin_p31", "Wire TBin Fired (ME +3/1); Time Bin (25ns)", 17, -0.5, 16.5));
0083   hWireTBin.push_back(ibooker.book1D("hWireTBin_p32", "Wire TBin Fired (ME +3/2); Time Bin (25ns)", 17, -0.5, 16.5));
0084   hWireTBin.push_back(ibooker.book1D("hWireTBin_p41", "Wire TBin Fired (ME +4/1); Time Bin (25ns)", 17, -0.5, 16.5));
0085   hWireTBin.push_back(ibooker.book1D("hWireTBin_p42", "Wire TBin Fired (ME +4/2); Time Bin (25ns)", 17, -0.5, 16.5));
0086   hWireNumber.push_back(
0087       ibooker.book1D("hWireNumber_m42", "Wiregroup Number Fired (ME -4/2); Wiregroup #", 113, -0.5, 112.5));
0088   hWireNumber.push_back(
0089       ibooker.book1D("hWireNumber_m41", "Wiregroup Number Fired (ME -4/1); Wiregroup #", 113, -0.5, 112.5));
0090   hWireNumber.push_back(
0091       ibooker.book1D("hWireNumber_m32", "Wiregroup Number Fired (ME -3/2); Wiregroup #", 113, -0.5, 112.5));
0092   hWireNumber.push_back(
0093       ibooker.book1D("hWireNumber_m31", "Wiregroup Number Fired (ME -3/1); Wiregroup #", 113, -0.5, 112.5));
0094   hWireNumber.push_back(
0095       ibooker.book1D("hWireNumber_m22", "Wiregroup Number Fired (ME -2/2); Wiregroup #", 113, -0.5, 112.5));
0096   hWireNumber.push_back(
0097       ibooker.book1D("hWireNumber_m21", "Wiregroup Number Fired (ME -2/1); Wiregroup #", 113, -0.5, 112.5));
0098   hWireNumber.push_back(
0099       ibooker.book1D("hWireNumber_m11a", "Wiregroup Number Fired (ME -1/1a); Wiregroup #", 113, -0.5, 112.5));
0100   hWireNumber.push_back(
0101       ibooker.book1D("hWireNumber_m13", "Wiregroup Number Fired (ME -1/3); Wiregroup #", 113, -0.5, 112.5));
0102   hWireNumber.push_back(
0103       ibooker.book1D("hWireNumber_m12", "Wiregroup Number Fired (ME -1/2); Wiregroup #", 113, -0.5, 112.5));
0104   hWireNumber.push_back(
0105       ibooker.book1D("hWireNumber_m11b", "Wiregroup Number Fired (ME -1/1b); Wiregroup #", 113, -0.5, 112.5));
0106   hWireNumber.push_back(
0107       ibooker.book1D("hWireNumber_p11b", "Wiregroup Number Fired (ME +1/1b); Wiregroup #", 113, -0.5, 112.5));
0108   hWireNumber.push_back(
0109       ibooker.book1D("hWireNumber_p12", "Wiregroup Number Fired (ME +1/2); Wiregroup #", 113, -0.5, 112.5));
0110   hWireNumber.push_back(
0111       ibooker.book1D("hWireNumber_p13", "Wiregroup Number Fired (ME +1/3); Wiregroup #", 113, -0.5, 112.5));
0112   hWireNumber.push_back(
0113       ibooker.book1D("hWireNumber_p11a", "Wiregroup Number Fired (ME +1/1a); Wiregroup #", 113, -0.5, 112.5));
0114   hWireNumber.push_back(
0115       ibooker.book1D("hWireNumber_p21", "Wiregroup Number Fired (ME +2/1); Wiregroup #", 113, -0.5, 112.5));
0116   hWireNumber.push_back(
0117       ibooker.book1D("hWireNumber_p22", "Wiregroup Number Fired (ME +2/2); Wiregroup #", 113, -0.5, 112.5));
0118   hWireNumber.push_back(
0119       ibooker.book1D("hWireNumber_p31", "Wiregroup Number Fired (ME +3/1); Wiregroup #", 113, -0.5, 112.5));
0120   hWireNumber.push_back(
0121       ibooker.book1D("hWireNumber_p32", "Wiregroup Number Fired (ME +3/2); Wiregroup #", 113, -0.5, 112.5));
0122   hWireNumber.push_back(
0123       ibooker.book1D("hWireNumber_p41", "Wiregroup Number Fired (ME +4/1); Wiregroup #", 113, -0.5, 112.5));
0124   hWireNumber.push_back(
0125       ibooker.book1D("hWireNumber_p42", "Wiregroup Number Fired (ME +4/2); Wiregroup #", 113, -0.5, 112.5));
0126 
0127   // strip digis
0128 
0129   // For low multiplicities (e.g. low or no pileup)
0130   hStripNFired = ibooker.book1D(
0131       "hStripNFired", "Fired Strips per Event; # Strips Fired (above 13 ADC)", 400, 0., 400.);  // 1 bin is 1
0132   // For high multiplcities (e.g. with pileup)
0133   hStripNFiredHi = ibooker.book1D(
0134       "hStripNFiredHi", "Fired Strips per Event; # Strips Fired (above 13 ADC)", 500, 0., 2000.);  // 1 bin is 4
0135 
0136   hStripNumber.push_back(
0137       ibooker.book1D("hStripNumber_m42", "Strip Number Fired (ME -4/2); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0138   hStripNumber.push_back(
0139       ibooker.book1D("hStripNumber_m41", "Strip Number Fired (ME -4/1); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0140   hStripNumber.push_back(
0141       ibooker.book1D("hStripNumber_m32", "Strip Number Fired (ME -3/2); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0142   hStripNumber.push_back(
0143       ibooker.book1D("hStripNumber_m31", "Strip Number Fired (ME -3/1); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0144   hStripNumber.push_back(
0145       ibooker.book1D("hStripNumber_m22", "Strip Number Fired (ME -2/2); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0146   hStripNumber.push_back(
0147       ibooker.book1D("hStripNumber_m21", "Strip Number Fired (ME -2/1); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0148   hStripNumber.push_back(ibooker.book1D(
0149       "hStripNumber_m11a", "Strip Number Fired (ME -1/1a); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0150   hStripNumber.push_back(
0151       ibooker.book1D("hStripNumber_m13", "Strip Number Fired (ME -1/3); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0152   hStripNumber.push_back(
0153       ibooker.book1D("hStripNumber_m12", "Strip Number Fired (ME -1/2); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0154   hStripNumber.push_back(ibooker.book1D(
0155       "hStripNumber_m11b", "Strip Number Fired (ME -1/1b); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0156   hStripNumber.push_back(ibooker.book1D(
0157       "hStripNumber_p11b", "Strip Number Fired (ME +1/1b); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0158   hStripNumber.push_back(
0159       ibooker.book1D("hStripNumber_p12", "Strip Number Fired (ME +1/2); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0160   hStripNumber.push_back(
0161       ibooker.book1D("hStripNumber_p13", "Strip Number Fired (ME +1/3); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0162   hStripNumber.push_back(ibooker.book1D(
0163       "hStripNumber_p11a", "Strip Number Fired (ME +1/1a); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0164   hStripNumber.push_back(
0165       ibooker.book1D("hStripNumber_p21", "Strip Number Fired (ME +2/1); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0166   hStripNumber.push_back(
0167       ibooker.book1D("hStripNumber_p22", "Strip Number Fired (ME +2/2); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0168   hStripNumber.push_back(
0169       ibooker.book1D("hStripNumber_p31", "Strip Number Fired (ME +3/1); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0170   hStripNumber.push_back(
0171       ibooker.book1D("hStripNumber_p32", "Strip Number Fired (ME +3/2); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0172   hStripNumber.push_back(
0173       ibooker.book1D("hStripNumber_p41", "Strip Number Fired (ME +4/1); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0174   hStripNumber.push_back(ibooker.book1D(
0175       "hStripNumber_p42", "Stripgroup Number Fired (ME +4/2); Strip # Fired (above 13 ADC)", 81, -0.5, 80.5));
0176 
0177   // pedestal noise
0178   ibooker.setCurrentFolder("CSC/CSCOfflineMonitor/PedestalNoise");
0179 
0180   hStripPed.push_back(
0181       ibooker.book1D("hStripPedMEm42", "Pedestal Noise Distribution Chamber ME -4/2; ADC Counts", 50, -25., 25.));
0182   hStripPed.push_back(
0183       ibooker.book1D("hStripPedMEm41", "Pedestal Noise Distribution Chamber ME -4/1; ADC Counts", 50, -25., 25.));
0184   hStripPed.push_back(
0185       ibooker.book1D("hStripPedMEm32", "Pedestal Noise Distribution Chamber ME -3/2; ADC Counts", 50, -25., 25.));
0186   hStripPed.push_back(
0187       ibooker.book1D("hStripPedMEm31", "Pedestal Noise Distribution Chamber ME -3/1; ADC Counts", 50, -25., 25.));
0188   hStripPed.push_back(
0189       ibooker.book1D("hStripPedMEm22", "Pedestal Noise Distribution Chamber ME -2/2; ADC Counts", 50, -25., 25.));
0190   hStripPed.push_back(
0191       ibooker.book1D("hStripPedMEm21", "Pedestal Noise Distribution Chamber ME -2/1; ADC Counts", 50, -25., 25.));
0192   hStripPed.push_back(
0193       ibooker.book1D("hStripPedMEm11a", "Pedestal Noise Distribution Chamber ME -1/1; ADC Counts", 50, -25., 25.));
0194   hStripPed.push_back(
0195       ibooker.book1D("hStripPedMEm13", "Pedestal Noise Distribution Chamber ME -1/3; ADC Counts", 50, -25., 25.));
0196   hStripPed.push_back(
0197       ibooker.book1D("hStripPedMEm12", "Pedestal Noise Distribution Chamber ME -1/2; ADC Counts", 50, -25., 25.));
0198   hStripPed.push_back(
0199       ibooker.book1D("hStripPedMEm11b", "Pedestal Noise Distribution Chamber ME -1/1; ADC Counts", 50, -25., 25.));
0200   hStripPed.push_back(
0201       ibooker.book1D("hStripPedMEp11b", "Pedestal Noise Distribution Chamber ME +1/1; ADC Counts", 50, -25., 25.));
0202   hStripPed.push_back(
0203       ibooker.book1D("hStripPedMEp12", "Pedestal Noise Distribution Chamber ME +1/2; ADC Counts", 50, -25., 25.));
0204   hStripPed.push_back(
0205       ibooker.book1D("hStripPedMEp13", "Pedestal Noise Distribution Chamber ME +1/3; ADC Counts", 50, -25., 25.));
0206   hStripPed.push_back(
0207       ibooker.book1D("hStripPedMEp11a", "Pedestal Noise Distribution Chamber ME +1/1; ADC Counts", 50, -25., 25.));
0208   hStripPed.push_back(
0209       ibooker.book1D("hStripPedMEp21", "Pedestal Noise Distribution Chamber ME +2/1; ADC Counts", 50, -25., 25.));
0210   hStripPed.push_back(
0211       ibooker.book1D("hStripPedMEp22", "Pedestal Noise Distribution Chamber ME +2/2; ADC Counts", 50, -25., 25.));
0212   hStripPed.push_back(
0213       ibooker.book1D("hStripPedMEp31", "Pedestal Noise Distribution Chamber ME +3/1; ADC Counts", 50, -25., 25.));
0214   hStripPed.push_back(
0215       ibooker.book1D("hStripPedMEp32", "Pedestal Noise Distribution Chamber ME +3/2; ADC Counts", 50, -25., 25.));
0216   hStripPed.push_back(
0217       ibooker.book1D("hStripPedMEp41", "Pedestal Noise Distribution Chamber ME +4/1; ADC Counts", 50, -25., 25.));
0218   hStripPed.push_back(
0219       ibooker.book1D("hStripPedMEp42", "Pedestal Noise Distribution Chamber ME +4/2; ADC Counts", 50, -25., 25.));
0220 
0221   // rechits
0222   ibooker.setCurrentFolder("CSC/CSCOfflineMonitor/recHits");
0223 
0224   // For low multiplicities (e.g. low or no pileup)
0225   hRHnrechits = ibooker.book1D("hRHnrechits", "RecHits per Event; # of RecHits", 100, 0., 100.);  // 1 bin is 1
0226   // For high multiplcities (e.g. with pileup)
0227   hRHnrechitsHi = ibooker.book1D("hRHnrechitsHi", "RecHits per Event; # of RecHits", 250, 0., 1000.);  // 1 bin is 4
0228 
0229   hRHGlobal.push_back(ibooker.book2D(
0230       "hRHGlobalp1", "recHit global X,Y station +1; Global X (cm); Global Y (cm)", 100, -800., 800., 100, -800., 800.));
0231   hRHGlobal.push_back(ibooker.book2D(
0232       "hRHGlobalp2", "recHit global X,Y station +2; Global X (cm); Global Y (cm)", 100, -800., 800., 100, -800., 800.));
0233   hRHGlobal.push_back(ibooker.book2D(
0234       "hRHGlobalp3", "recHit global X,Y station +3; Global X (cm); Global Y (cm)", 100, -800., 800., 100, -800., 800.));
0235   hRHGlobal.push_back(ibooker.book2D(
0236       "hRHGlobalp4", "recHit global X,Y station +4; Global X (cm); Global Y (cm)", 100, -800., 800., 100, -800., 800.));
0237   hRHGlobal.push_back(ibooker.book2D(
0238       "hRHGlobalm1", "recHit global X,Y station -1; Global X (cm); Global Y (cm)", 100, -800., 800., 100, -800., 800.));
0239   hRHGlobal.push_back(ibooker.book2D(
0240       "hRHGlobalm2", "recHit global X,Y station -2; Global X (cm); Global Y (cm)", 100, -800., 800., 100, -800., 800.));
0241   hRHGlobal.push_back(ibooker.book2D(
0242       "hRHGlobalm3", "recHit global X,Y station -3; Global X (cm); Global Y (cm)", 100, -800., 800., 100, -800., 800.));
0243   hRHGlobal.push_back(ibooker.book2D(
0244       "hRHGlobalm4", "recHit global X,Y station -4; Global X (cm); Global Y (cm)", 100, -800., 800., 100, -800., 800.));
0245   hRHSumQ.push_back(ibooker.book1D("hRHSumQm42", "Sum 3x3 recHit Charge (ME -4/2); ADC counts", 100, 0, 2000));
0246   hRHSumQ.push_back(ibooker.book1D("hRHSumQm41", "Sum 3x3 recHit Charge (ME -4/1); ADC counts", 100, 0, 2000));
0247   hRHSumQ.push_back(ibooker.book1D("hRHSumQm32", "Sum 3x3 recHit Charge (ME -3/2); ADC counts", 100, 0, 2000));
0248   hRHSumQ.push_back(ibooker.book1D("hRHSumQm31", "Sum 3x3 recHit Charge (ME -3/1); ADC counts", 100, 0, 2000));
0249   hRHSumQ.push_back(ibooker.book1D("hRHSumQm22", "Sum 3x3 recHit Charge (ME -2/2); ADC counts", 100, 0, 2000));
0250   hRHSumQ.push_back(ibooker.book1D("hRHSumQm21", "Sum 3x3 recHit Charge (ME -2/1); ADC counts", 100, 0, 2000));
0251   hRHSumQ.push_back(ibooker.book1D("hRHSumQm11a", "Sum 3x3 recHit Charge (ME -1/1a); ADC counts", 100, 0, 4000));
0252   hRHSumQ.push_back(ibooker.book1D("hRHSumQm13", "Sum 3x3 recHit Charge (ME -1/3); ADC counts", 100, 0, 2000));
0253   hRHSumQ.push_back(ibooker.book1D("hRHSumQm12", "Sum 3x3 recHit Charge (ME -1/2); ADC counts", 100, 0, 2000));
0254   hRHSumQ.push_back(ibooker.book1D("hRHSumQm11b", "Sum 3x3 recHit Charge (ME -1/1b); ADC counts", 100, 0, 4000));
0255   hRHSumQ.push_back(ibooker.book1D("hRHSumQp11b", "Sum 3x3 recHit Charge (ME +1/1b); ADC counts", 100, 0, 4000));
0256   hRHSumQ.push_back(ibooker.book1D("hRHSumQp12", "Sum 3x3 recHit Charge (ME +1/2); ADC counts", 100, 0, 2000));
0257   hRHSumQ.push_back(ibooker.book1D("hRHSumQp13", "Sum 3x3 recHit Charge (ME +1/3); ADC counts", 100, 0, 2000));
0258   hRHSumQ.push_back(ibooker.book1D("hRHSumQp11a", "Sum 3x3 recHit Charge (ME +1/1a); ADC counts", 100, 0, 4000));
0259   hRHSumQ.push_back(ibooker.book1D("hRHSumQp21", "Sum 3x3 recHit Charge (ME +2/1); ADC counts", 100, 0, 2000));
0260   hRHSumQ.push_back(ibooker.book1D("hRHSumQp22", "Sum 3x3 recHit Charge (ME +2/2); ADC counts", 100, 0, 2000));
0261   hRHSumQ.push_back(ibooker.book1D("hRHSumQp31", "Sum 3x3 recHit Charge (ME +3/1); ADC counts", 100, 0, 2000));
0262   hRHSumQ.push_back(ibooker.book1D("hRHSumQp32", "Sum 3x3 recHit Charge (ME +3/2); ADC counts", 100, 0, 2000));
0263   hRHSumQ.push_back(ibooker.book1D("hRHSumQp41", "Sum 3x3 recHit Charge (ME +4/1); ADC counts", 100, 0, 2000));
0264   hRHSumQ.push_back(ibooker.book1D("hRHSumQp42", "Sum 3x3 recHit Charge (ME +4/2); ADC counts", 100, 0, 2000));
0265   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQm42", "Charge Ratio (Ql+Qr)/Qt (ME -4/2); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0266   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQm41", "Charge Ratio (Ql+Qr)/Qt (ME -4/1); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0267   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQm32", "Charge Ratio (Ql+Qr)/Qt (ME -3/2); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0268   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQm31", "Charge Ratio (Ql+Qr)/Qt (ME -3/1); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0269   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQm22", "Charge Ratio (Ql+Qr)/Qt (ME -2/2); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0270   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQm21", "Charge Ratio (Ql+Qr)/Qt (ME -2/1); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0271   hRHRatioQ.push_back(
0272       ibooker.book1D("hRHRatioQm11a", "Charge Ratio (Ql+Qr)/Qt (ME -1/1a); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0273   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQm13", "Charge Ratio (Ql+Qr)/Qt (ME -1/3); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0274   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQm12", "Charge Ratio (Ql+Qr)/Qt (ME -1/2); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0275   hRHRatioQ.push_back(
0276       ibooker.book1D("hRHRatioQm11b", "Charge Ratio (Ql+Qr)/Qt (ME -1/1b); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0277   hRHRatioQ.push_back(
0278       ibooker.book1D("hRHRatioQp11b", "Charge Ratio (Ql+Qr)/Qt (ME +1/1b); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0279   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQp12", "Charge Ratio (Ql+Qr)/Qt (ME +1/2); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0280   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQp13", "Charge Ratio (Ql+Qr)/Qt (ME +1/3); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0281   hRHRatioQ.push_back(
0282       ibooker.book1D("hRHRatioQp11a", "Charge Ratio (Ql+Qr)/Qt (ME +1/1a); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0283   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQp21", "Charge Ratio (Ql+Qr)/Qt (ME +2/1); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0284   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQp22", "Charge Ratio (Ql+Qr)/Qt (ME +2/2); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0285   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQp31", "Charge Ratio (Ql+Qr)/Qt (ME +3/1); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0286   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQp32", "Charge Ratio (Ql+Qr)/Qt (ME +3/2); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0287   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQp41", "Charge Ratio (Ql+Qr)/Qt (ME +4/1); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0288   hRHRatioQ.push_back(ibooker.book1D("hRHRatioQp42", "Charge Ratio (Ql+Qr)/Qt (ME +4/2); (Ql+Qr)/Qt", 100, -0.1, 1.1));
0289   hRHTiming.push_back(ibooker.book1D("hRHTimingm42", "recHit Time (ME -4/2); ns", 200, -500., 500.));
0290   hRHTiming.push_back(ibooker.book1D("hRHTimingm41", "recHit Time (ME -4/1); ns", 200, -500., 500.));
0291   hRHTiming.push_back(ibooker.book1D("hRHTimingm32", "recHit Time (ME -3/2); ns", 200, -500., 500.));
0292   hRHTiming.push_back(ibooker.book1D("hRHTimingm31", "recHit Time (ME -3/1); ns", 200, -500., 500.));
0293   hRHTiming.push_back(ibooker.book1D("hRHTimingm22", "recHit Time (ME -2/2); ns", 200, -500., 500.));
0294   hRHTiming.push_back(ibooker.book1D("hRHTimingm21", "recHit Time (ME -2/1); ns", 200, -500., 500.));
0295   hRHTiming.push_back(ibooker.book1D("hRHTimingm11a", "recHit Time (ME -1/1a); ns", 200, -500., 500.));
0296   hRHTiming.push_back(ibooker.book1D("hRHTimingm13", "recHit Time (ME -1/3); ns", 200, -500., 500.));
0297   hRHTiming.push_back(ibooker.book1D("hRHTimingm12", "recHit Time (ME -1/2); ns", 200, -500., 500.));
0298   hRHTiming.push_back(ibooker.book1D("hRHTimingm11b", "recHit Time (ME -1/1b); ns", 200, -500., 500.));
0299   hRHTiming.push_back(ibooker.book1D("hRHTimingp11b", "recHit Time (ME +1/1b); ns", 200, -500., 500.));
0300   hRHTiming.push_back(ibooker.book1D("hRHTimingp12", "recHit Time (ME +1/2); ns", 200, -500., 500.));
0301   hRHTiming.push_back(ibooker.book1D("hRHTimingp13", "recHit Time (ME +1/3); ns", 200, -500., 500.));
0302   hRHTiming.push_back(ibooker.book1D("hRHTimingp11a", "recHit Time (ME +1/1a); ns", 200, -500., 500.));
0303   hRHTiming.push_back(ibooker.book1D("hRHTimingp21", "recHit Time (ME +2/1); ns", 200, -500., 500.));
0304   hRHTiming.push_back(ibooker.book1D("hRHTimingp22", "recHit Time (ME +2/2); ns", 200, -500., 500.));
0305   hRHTiming.push_back(ibooker.book1D("hRHTimingp31", "recHit Time (ME +3/1); ns", 200, -500., 500.));
0306   hRHTiming.push_back(ibooker.book1D("hRHTimingp32", "recHit Time (ME +3/2); ns", 200, -500., 500.));
0307   hRHTiming.push_back(ibooker.book1D("hRHTimingp41", "recHit Time (ME +4/1); ns", 200, -500., 500.));
0308   hRHTiming.push_back(ibooker.book1D("hRHTimingp42", "recHit Time (ME +4/2); ns", 200, -500., 500.));
0309   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem42", "Anode recHit Time (ME -4/2); ns", 80, -500., 500.));
0310   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem41", "Anode recHit Time (ME -4/1); ns", 80, -500., 500.));
0311   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem32", "Anode recHit Time (ME -3/2); ns", 80, -500., 500.));
0312   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem31", "Anode recHit Time (ME -3/1); ns", 80, -500., 500.));
0313   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem22", "Anode recHit Time (ME -2/2); ns", 80, -500., 500.));
0314   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem21", "Anode recHit Time (ME -2/1); ns", 80, -500., 500.));
0315   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem11a", "Anode recHit Time (ME -1/1a); ns", 80, -500., 500.));
0316   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem13", "Anode recHit Time (ME -1/3); ns", 80, -500., 500.));
0317   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem12", "Anode recHit Time (ME -1/2); ns", 80, -500., 500.));
0318   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodem11b", "Anode recHit Time (ME -1/1b); ns", 80, -500., 500.));
0319   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep11b", "Anode recHit Time (ME +1/1b); ns", 80, -500., 500.));
0320   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep12", "Anode recHit Time (ME +1/2); ns", 80, -500., 500.));
0321   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep13", "Anode recHit Time (ME +1/3); ns", 80, -500., 500.));
0322   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep11a", "Anode recHit Time (ME +1/1a); ns", 80, -500., 500.));
0323   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep21", "Anode recHit Time (ME +2/1); ns", 80, -500., 500.));
0324   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep22", "Anode recHit Time (ME +2/2); ns", 80, -500., 500.));
0325   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep31", "Anode recHit Time (ME +3/1); ns", 80, -500., 500.));
0326   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep32", "Anode recHit Time (ME +3/2); ns", 80, -500., 500.));
0327   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep41", "Anode recHit Time (ME +4/1); ns", 80, -500., 500.));
0328   hRHTimingAnode.push_back(ibooker.book1D("hRHTimingAnodep42", "Anode recHit Time (ME +4/2); ns", 80, -500., 500.));
0329   hRHstpos.push_back(
0330       ibooker.book1D("hRHstposm42", "Reconstructed Position on Strip (ME -4/2); Strip Widths", 120, -0.6, 0.6));
0331   hRHstpos.push_back(
0332       ibooker.book1D("hRHstposm41", "Reconstructed Position on Strip (ME -4/1); Strip Widths", 120, -0.6, 0.6));
0333   hRHstpos.push_back(
0334       ibooker.book1D("hRHstposm32", "Reconstructed Position on Strip (ME -3/2); Strip Widths", 120, -0.6, 0.6));
0335   hRHstpos.push_back(
0336       ibooker.book1D("hRHstposm31", "Reconstructed Position on Strip (ME -3/1); Strip Widths", 120, -0.6, 0.6));
0337   hRHstpos.push_back(
0338       ibooker.book1D("hRHstposm22", "Reconstructed Position on Strip (ME -2/2); Strip Widths", 120, -0.6, 0.6));
0339   hRHstpos.push_back(
0340       ibooker.book1D("hRHstposm21", "Reconstructed Position on Strip (ME -2/1); Strip Widths", 120, -0.6, 0.6));
0341   hRHstpos.push_back(
0342       ibooker.book1D("hRHstposm11a", "Reconstructed Position on Strip (ME -1/1a); Strip Widths", 120, -0.6, 0.6));
0343   hRHstpos.push_back(
0344       ibooker.book1D("hRHstposm13", "Reconstructed Position on Strip (ME -1/3); Strip Widths", 120, -0.6, 0.6));
0345   hRHstpos.push_back(
0346       ibooker.book1D("hRHstposm12", "Reconstructed Position on Strip (ME -1/2); Strip Widths", 120, -0.6, 0.6));
0347   hRHstpos.push_back(
0348       ibooker.book1D("hRHstposm11b", "Reconstructed Position on Strip (ME -1/1b); Strip Widths", 120, -0.6, 0.6));
0349   hRHstpos.push_back(
0350       ibooker.book1D("hRHstposp11b", "Reconstructed Position on Strip (ME +1/1b); Strip Widths", 120, -0.6, 0.6));
0351   hRHstpos.push_back(
0352       ibooker.book1D("hRHstposp12", "Reconstructed Position on Strip (ME +1/2); Strip Widths", 120, -0.6, 0.6));
0353   hRHstpos.push_back(
0354       ibooker.book1D("hRHstposp13", "Reconstructed Position on Strip (ME +1/3); Strip Widths", 120, -0.6, 0.6));
0355   hRHstpos.push_back(
0356       ibooker.book1D("hRHstposp11a", "Reconstructed Position on Strip (ME +1/1a); Strip Widths", 120, -0.6, 0.6));
0357   hRHstpos.push_back(
0358       ibooker.book1D("hRHstposp21", "Reconstructed Position on Strip (ME +2/1); Strip Widths", 120, -0.6, 0.6));
0359   hRHstpos.push_back(
0360       ibooker.book1D("hRHstposp22", "Reconstructed Position on Strip (ME +2/2); Strip Widths", 120, -0.6, 0.6));
0361   hRHstpos.push_back(
0362       ibooker.book1D("hRHstposp31", "Reconstructed Position on Strip (ME +3/1); Strip Widths", 120, -0.6, 0.6));
0363   hRHstpos.push_back(
0364       ibooker.book1D("hRHstposp32", "Reconstructed Position on Strip (ME +3/2); Strip Widths", 120, -0.6, 0.6));
0365   hRHstpos.push_back(
0366       ibooker.book1D("hRHstposp41", "Reconstructed Position on Strip (ME +4/1); Strip Widths", 120, -0.6, 0.6));
0367   hRHstpos.push_back(
0368       ibooker.book1D("hRHstposp42", "Reconstructed Position on Strip (ME +4/2); Strip Widths", 120, -0.6, 0.6));
0369   hRHsterr.push_back(
0370       ibooker.book1D("hRHsterrm42", "Estimated Error on Strip Measurement (ME -4/2); Strip Widths", 75, -0.01, 0.24));
0371   hRHsterr.push_back(
0372       ibooker.book1D("hRHsterrm41", "Estimated Error on Strip Measurement (ME -4/1); Strip Widths", 75, -0.01, 0.24));
0373   hRHsterr.push_back(
0374       ibooker.book1D("hRHsterrm32", "Estimated Error on Strip Measurement (ME -3/2); Strip Widths", 75, -0.01, 0.24));
0375   hRHsterr.push_back(
0376       ibooker.book1D("hRHsterrm31", "Estimated Error on Strip Measurement (ME -3/1); Strip Widths", 75, -0.01, 0.24));
0377   hRHsterr.push_back(
0378       ibooker.book1D("hRHsterrm22", "Estimated Error on Strip Measurement (ME -2/2); Strip Widths", 75, -0.01, 0.24));
0379   hRHsterr.push_back(
0380       ibooker.book1D("hRHsterrm21", "Estimated Error on Strip Measurement (ME -2/1); Strip Widths", 75, -0.01, 0.24));
0381   hRHsterr.push_back(
0382       ibooker.book1D("hRHsterrm11a", "Estimated Error on Strip Measurement (ME -1/1a); Strip Widths", 75, -0.01, 0.24));
0383   hRHsterr.push_back(
0384       ibooker.book1D("hRHsterrm13", "Estimated Error on Strip Measurement (ME -1/3); Strip Widths", 75, -0.01, 0.24));
0385   hRHsterr.push_back(
0386       ibooker.book1D("hRHsterrm12", "Estimated Error on Strip Measurement (ME -1/2); Strip Widths", 75, -0.01, 0.24));
0387   hRHsterr.push_back(
0388       ibooker.book1D("hRHsterrm11b", "Estimated Error on Strip Measurement (ME -1/1b); Strip Widths", 75, -0.01, 0.24));
0389   hRHsterr.push_back(
0390       ibooker.book1D("hRHsterrp11b", "Estimated Error on Strip Measurement (ME +1/1b); Strip Widths", 75, -0.01, 0.24));
0391   hRHsterr.push_back(
0392       ibooker.book1D("hRHsterrp12", "Estimated Error on Strip Measurement (ME +1/2); Strip Widths", 75, -0.01, 0.24));
0393   hRHsterr.push_back(
0394       ibooker.book1D("hRHsterrp13", "Estimated Error on Strip Measurement (ME +1/3); Strip Widths", 75, -0.01, 0.24));
0395   hRHsterr.push_back(
0396       ibooker.book1D("hRHsterrp11a", "Estimated Error on Strip Measurement (ME +1/1a); Strip Widths", 75, -0.01, 0.24));
0397   hRHsterr.push_back(
0398       ibooker.book1D("hRHsterrp21", "Estimated Error on Strip Measurement (ME +2/1); Strip Widths", 75, -0.01, 0.24));
0399   hRHsterr.push_back(
0400       ibooker.book1D("hRHsterrp22", "Estimated Error on Strip Measurement (ME +2/2); Strip Widths", 75, -0.01, 0.24));
0401   hRHsterr.push_back(
0402       ibooker.book1D("hRHsterrp31", "Estimated Error on Strip Measurement (ME +3/1); Strip Widths", 75, -0.01, 0.24));
0403   hRHsterr.push_back(
0404       ibooker.book1D("hRHsterrp32", "Estimated Error on Strip Measurement (ME +3/2); Strip Widths", 75, -0.01, 0.24));
0405   hRHsterr.push_back(
0406       ibooker.book1D("hRHsterrp41", "Estimated Error on Strip Measurement (ME +4/1); Strip Widths", 75, -0.01, 0.24));
0407   hRHsterr.push_back(
0408       ibooker.book1D("hRHsterrp42", "Estimated Error on Strip Measurement (ME +4/2); Strip Widths", 75, -0.01, 0.24));
0409 
0410   // segments
0411   ibooker.setCurrentFolder("CSC/CSCOfflineMonitor/Segments");
0412 
0413   hSnSegments = ibooker.book1D("hSnSegments", "Segments per Event; # of Segments", 100, 0., 100.);  // 1 bin is 1
0414 
0415   hSnhitsAll = ibooker.book1D("hSnhits", "N hits on Segments; # of hits", 8, -0.5, 7.5);
0416   hSnhits.push_back(ibooker.book1D("hSnhitsm42", "# of hits on Segments (ME -4/2); # of hits", 8, -0.5, 7.5));
0417   hSnhits.push_back(ibooker.book1D("hSnhitsm41", "# of hits on Segments (ME -4/1); # of hits", 8, -0.5, 7.5));
0418   hSnhits.push_back(ibooker.book1D("hSnhitsm32", "# of hits on Segments (ME -3/2); # of hits", 8, -0.5, 7.5));
0419   hSnhits.push_back(ibooker.book1D("hSnhitsm31", "# of hits on Segments (ME -3/1); # of hits", 8, -0.5, 7.5));
0420   hSnhits.push_back(ibooker.book1D("hSnhitsm22", "# of hits on Segments (ME -2/2); # of hits", 8, -0.5, 7.5));
0421   hSnhits.push_back(ibooker.book1D("hSnhitsm21", "# of hits on Segments (ME -2/1); # of hits", 8, -0.5, 7.5));
0422   hSnhits.push_back(ibooker.book1D("hSnhitsm11a", "# of hits on Segments (ME -1/1a); # of hits", 8, -0.5, 7.5));
0423   hSnhits.push_back(ibooker.book1D("hSnhitsm13", "# of hits on Segments (ME -1/3); # of hits", 8, -0.5, 7.5));
0424   hSnhits.push_back(ibooker.book1D("hSnhitsm12", "# of hits on Segments (ME -1/2); # of hits", 8, -0.5, 7.5));
0425   hSnhits.push_back(ibooker.book1D("hSnhitsm11b", "# of hits on Segments (ME -1/1b); # of hits", 8, -0.5, 7.5));
0426   hSnhits.push_back(ibooker.book1D("hSnhitsp11b", "# of hits on Segments (ME +1/1b); # of hits", 8, -0.5, 7.5));
0427   hSnhits.push_back(ibooker.book1D("hSnhitsp12", "# of hits on Segments (ME +1/2); # of hits", 8, -0.5, 7.5));
0428   hSnhits.push_back(ibooker.book1D("hSnhitsp13", "# of hits on Segments (ME +1/3); # of hits", 8, -0.5, 7.5));
0429   hSnhits.push_back(ibooker.book1D("hSnhitsp11a", "# of hits on Segments (ME +1/1a); # of hits", 8, -0.5, 7.5));
0430   hSnhits.push_back(ibooker.book1D("hSnhitsp21", "# of hits on Segments (ME +2/1); # of hits", 8, -0.5, 7.5));
0431   hSnhits.push_back(ibooker.book1D("hSnhitsp22", "# of hits on Segments (ME +2/2); # of hits", 8, -0.5, 7.5));
0432   hSnhits.push_back(ibooker.book1D("hSnhitsp31", "# of hits on Segments (ME +3/1); # of hits", 8, -0.5, 7.5));
0433   hSnhits.push_back(ibooker.book1D("hSnhitsp32", "# of hits on Segments (ME +3/2); # of hits", 8, -0.5, 7.5));
0434   hSnhits.push_back(ibooker.book1D("hSnhitsp41", "# of hits on Segments (ME +4/1); # of hits", 8, -0.5, 7.5));
0435   hSnhits.push_back(ibooker.book1D("hSnhitsp42", "# of hits on Segments (ME +4/2); # of hits", 8, -0.5, 7.5));
0436   hSChiSqAll = ibooker.book1D("hSChiSq", "Segment Normalized Chi2; Chi2/ndof", 110, -0.05, 10.5);
0437   hSChiSq.push_back(ibooker.book1D("hSChiSqm42", "Segment Normalized Chi2 (ME -4/2); Chi2/ndof", 110, -0.05, 10.5));
0438   hSChiSq.push_back(ibooker.book1D("hSChiSqm41", "Segment Normalized Chi2 (ME -4/1); Chi2/ndof", 110, -0.05, 10.5));
0439   hSChiSq.push_back(ibooker.book1D("hSChiSqm32", "Segment Normalized Chi2 (ME -3/2); Chi2/ndof", 110, -0.05, 10.5));
0440   hSChiSq.push_back(ibooker.book1D("hSChiSqm31", "Segment Normalized Chi2 (ME -3/1); Chi2/ndof", 110, -0.05, 10.5));
0441   hSChiSq.push_back(ibooker.book1D("hSChiSqm22", "Segment Normalized Chi2 (ME -2/2); Chi2/ndof", 110, -0.05, 10.5));
0442   hSChiSq.push_back(ibooker.book1D("hSChiSqm21", "Segment Normalized Chi2 (ME -2/1); Chi2/ndof", 110, -0.05, 10.5));
0443   hSChiSq.push_back(ibooker.book1D("hSChiSqm11a", "Segment Normalized Chi2 (ME -1/1a); Chi2/ndof", 110, -0.05, 10.5));
0444   hSChiSq.push_back(ibooker.book1D("hSChiSqm13", "Segment Normalized Chi2 (ME -1/3); Chi2/ndof", 110, -0.05, 10.5));
0445   hSChiSq.push_back(ibooker.book1D("hSChiSqm12", "Segment Normalized Chi2 (ME -1/2); Chi2/ndof", 110, -0.05, 10.5));
0446   hSChiSq.push_back(ibooker.book1D("hSChiSqm11b", "Segment Normalized Chi2 (ME -1/1b); Chi2/ndof", 110, -0.05, 10.5));
0447   hSChiSq.push_back(ibooker.book1D("hSChiSqp11b", "Segment Normalized Chi2 (ME +1/1b); Chi2/ndof", 110, -0.05, 10.5));
0448   hSChiSq.push_back(ibooker.book1D("hSChiSqp12", "Segment Normalized Chi2 (ME +1/2); Chi2/ndof", 110, -0.05, 10.5));
0449   hSChiSq.push_back(ibooker.book1D("hSChiSqp13", "Segment Normalized Chi2 (ME +1/3); Chi2/ndof", 110, -0.05, 10.5));
0450   hSChiSq.push_back(ibooker.book1D("hSChiSqp11a", "Segment Normalized Chi2 (ME +1/1a); Chi2/ndof", 110, -0.05, 10.5));
0451   hSChiSq.push_back(ibooker.book1D("hSChiSqp21", "Segment Normalized Chi2 (ME +2/1); Chi2/ndof", 110, -0.05, 10.5));
0452   hSChiSq.push_back(ibooker.book1D("hSChiSqp22", "Segment Normalized Chi2 (ME +2/2); Chi2/ndof", 110, -0.05, 10.5));
0453   hSChiSq.push_back(ibooker.book1D("hSChiSqp31", "Segment Normalized Chi2 (ME +3/1); Chi2/ndof", 110, -0.05, 10.5));
0454   hSChiSq.push_back(ibooker.book1D("hSChiSqp32", "Segment Normalized Chi2 (ME +3/2); Chi2/ndof", 110, -0.05, 10.5));
0455   hSChiSq.push_back(ibooker.book1D("hSChiSqp41", "Segment Normalized Chi2 (ME +4/1); Chi2/ndof", 110, -0.05, 10.5));
0456   hSChiSq.push_back(ibooker.book1D("hSChiSqp42", "Segment Normalized Chi2 (ME +4/2); Chi2/ndof", 110, -0.05, 10.5));
0457   hSChiSqProbAll = ibooker.book1D("hSChiSqProb", "Segment chi2 Probability; Probability", 110, -0.05, 1.05);
0458   hSChiSqProb.push_back(
0459       ibooker.book1D("hSChiSqProbm42", "Segment chi2 Probability (ME -4/2); Probability", 110, -0.05, 1.05));
0460   hSChiSqProb.push_back(
0461       ibooker.book1D("hSChiSqProbm41", "Segment chi2 Probability (ME -4/1); Probability", 110, -0.05, 1.05));
0462   hSChiSqProb.push_back(
0463       ibooker.book1D("hSChiSqProbm32", "Segment chi2 Probability (ME -3/2); Probability", 110, -0.05, 1.05));
0464   hSChiSqProb.push_back(
0465       ibooker.book1D("hSChiSqProbm31", "Segment chi2 Probability (ME -3/1); Probability", 110, -0.05, 1.05));
0466   hSChiSqProb.push_back(
0467       ibooker.book1D("hSChiSqProbm22", "Segment chi2 Probability (ME -2/2); Probability", 110, -0.05, 1.05));
0468   hSChiSqProb.push_back(
0469       ibooker.book1D("hSChiSqProbm21", "Segment chi2 Probability (ME -2/1); Probability", 110, -0.05, 1.05));
0470   hSChiSqProb.push_back(
0471       ibooker.book1D("hSChiSqProbm11a", "Segment chi2 Probability (ME -1/1a); Probability", 110, -0.05, 1.05));
0472   hSChiSqProb.push_back(
0473       ibooker.book1D("hSChiSqProbm13", "Segment chi2 Probability (ME -1/3); Probability", 110, -0.05, 1.05));
0474   hSChiSqProb.push_back(
0475       ibooker.book1D("hSChiSqProbm12", "Segment chi2 Probability (ME -1/2); Probability", 110, -0.05, 1.05));
0476   hSChiSqProb.push_back(
0477       ibooker.book1D("hSChiSqProbm11b", "Segment chi2 Probability (ME -1/1b); Probability", 110, -0.05, 1.05));
0478   hSChiSqProb.push_back(
0479       ibooker.book1D("hSChiSqProbp11b", "Segment chi2 Probability (ME +1/1b); Probability", 110, -0.05, 1.05));
0480   hSChiSqProb.push_back(
0481       ibooker.book1D("hSChiSqProbp12", "Segment chi2 Probability (ME +1/2); Probability", 110, -0.05, 1.05));
0482   hSChiSqProb.push_back(
0483       ibooker.book1D("hSChiSqProbp13", "Segment chi2 Probability (ME +1/3); Probability", 110, -0.05, 1.05));
0484   hSChiSqProb.push_back(
0485       ibooker.book1D("hSChiSqProbp11a", "Segment chi2 Probability (ME +1/1a); Probability", 110, -0.05, 1.05));
0486   hSChiSqProb.push_back(
0487       ibooker.book1D("hSChiSqProbp21", "Segment chi2 Probability (ME +2/1); Probability", 110, -0.05, 1.05));
0488   hSChiSqProb.push_back(
0489       ibooker.book1D("hSChiSqProbp22", "Segment chi2 Probability (ME +2/2); Probability", 110, -0.05, 1.05));
0490   hSChiSqProb.push_back(
0491       ibooker.book1D("hSChiSqProbp31", "Segment chi2 Probability (ME +3/1); Probability", 110, -0.05, 1.05));
0492   hSChiSqProb.push_back(
0493       ibooker.book1D("hSChiSqProbp32", "Segment chi2 Probability (ME +3/2); Probability", 110, -0.05, 1.05));
0494   hSChiSqProb.push_back(
0495       ibooker.book1D("hSChiSqProbp41", "Segment chi2 Probability (ME +4/1); Probability", 110, -0.05, 1.05));
0496   hSChiSqProb.push_back(
0497       ibooker.book1D("hSChiSqProbp42", "Segment chi2 Probability (ME +4/2); Probability", 110, -0.05, 1.05));
0498   hSGlobalTheta =
0499       ibooker.book1D("hSGlobalTheta", "Segment Direction (Global Theta); Global Theta (radians)", 136, -0.1, 3.3);
0500   hSGlobalPhi = ibooker.book1D("hSGlobalPhi", "Segment Direction (Global Phi); Global Phi (radians)", 128, -3.2, 3.2);
0501 
0502   hSTimeDiff = ibooker.book1D("hSTimeDiff", "Anode Minus Cathode Segment Time [ns]", 50, -50, 50);
0503   hSTimeDiffByChamberType.push_back(
0504       ibooker.book1D("hSTimeDiff_m42", "Anode Minus Cathode Segment Time (ME -4/2) [ns]", 50, -50, 50));
0505   hSTimeDiffByChamberType.push_back(
0506       ibooker.book1D("hSTimeDiff_m41", "Anode Minus Cathode Segment Time (ME -4/1) [ns]", 50, -50, 50));
0507   hSTimeDiffByChamberType.push_back(
0508       ibooker.book1D("hSTimeDiff_m32", "Anode Minus Cathode Segment Time (ME -3/2) [ns]", 50, -50, 50));
0509   hSTimeDiffByChamberType.push_back(
0510       ibooker.book1D("hSTimeDiff_m31", "Anode Minus Cathode Segment Time (ME -3/2) [ns]", 50, -50, 50));
0511   hSTimeDiffByChamberType.push_back(
0512       ibooker.book1D("hSTimeDiff_m22", "Anode Minus Cathode Segment Time (ME -2/2) [ns]", 50, -50, 50));
0513   hSTimeDiffByChamberType.push_back(
0514       ibooker.book1D("hSTimeDiff_m21", "Anode Minus Cathode Segment Time (ME -2/1) [ns]", 50, -50, 50));
0515   hSTimeDiffByChamberType.push_back(
0516       ibooker.book1D("hSTimeDiff_m11a", "Anode Minus Cathode Segment Time (ME -1/1a) [ns]", 50, -50, 50));
0517   hSTimeDiffByChamberType.push_back(
0518       ibooker.book1D("hSTimeDiff_m13", "Anode Minus Cathode Segment Time (ME -1/3) [ns]", 50, -50, 50));
0519   hSTimeDiffByChamberType.push_back(
0520       ibooker.book1D("hSTimeDiff_m12", "Anode Minus Cathode Segment Time (ME -1/2) [ns]", 50, -50, 50));
0521   hSTimeDiffByChamberType.push_back(
0522       ibooker.book1D("hSTimeDiff_m11b", "Anode Minus Cathode Segment Time (ME -1/1b) [ns]", 50, -50, 50));
0523   hSTimeDiffByChamberType.push_back(
0524       ibooker.book1D("hSTimeDiff_p11b", "Anode Minus Cathode Segment Time (ME +1/1b) [ns]", 50, -50, 50));
0525   hSTimeDiffByChamberType.push_back(
0526       ibooker.book1D("hSTimeDiff_p12", "Anode Minus Cathode Segment Time (ME +1/2) [ns]", 50, -50, 50));
0527   hSTimeDiffByChamberType.push_back(
0528       ibooker.book1D("hSTimeDiff_p13", "Anode Minus Cathode Segment Time (ME +1/3) [ns]", 50, -50, 50));
0529   hSTimeDiffByChamberType.push_back(
0530       ibooker.book1D("hSTimeDiff_p11a", "Anode Minus Cathode Segment Time (ME +1/1a) [ns]", 50, -50, 50));
0531   hSTimeDiffByChamberType.push_back(
0532       ibooker.book1D("hSTimeDiff_p21", "Anode Minus Cathode Segment Time (ME +2/1) [ns]", 50, -50, 50));
0533   hSTimeDiffByChamberType.push_back(
0534       ibooker.book1D("hSTimeDiff_p22", "Anode Minus Cathode Segment Time (ME +2/2) [ns]", 50, -50, 50));
0535   hSTimeDiffByChamberType.push_back(
0536       ibooker.book1D("hSTimeDiff_p31", "Anode Minus Cathode Segment Time (ME +3/1) [ns]", 50, -50, 50));
0537   hSTimeDiffByChamberType.push_back(
0538       ibooker.book1D("hSTimeDiff_p32", "Anode Minus Cathode Segment Time (ME +3/2) [ns]", 50, -50, 50));
0539   hSTimeDiffByChamberType.push_back(
0540       ibooker.book1D("hSTimeDiff_p41", "Anode Minus Cathode Segment Time (ME +4/1) [ns]", 50, -50, 50));
0541   hSTimeDiffByChamberType.push_back(
0542       ibooker.book1D("hSTimeDiff_p42", "Anode Minus Cathode Segment Time (ME +4/2) [ns]", 50, -50, 50));
0543 
0544   hSTimeAnode = ibooker.book1D("hSTimeAnode", "Anode Only Segment Time  [ns]", 200, -200, 200);
0545   hSTimeAnodeByChamberType.push_back(
0546       ibooker.book1D("hSTimeAnode_m42", "Anode Only Segment Time (ME -4/2) [ns]", 200, -200, 200));
0547   hSTimeAnodeByChamberType.push_back(
0548       ibooker.book1D("hSTimeAnode_m41", "Anode Only Segment Time (ME -4/1) [ns]", 200, -200, 200));
0549   hSTimeAnodeByChamberType.push_back(
0550       ibooker.book1D("hSTimeAnode_m32", "Anode Only Segment Time (ME -3/2) [ns]", 200, -200, 200));
0551   hSTimeAnodeByChamberType.push_back(
0552       ibooker.book1D("hSTimeAnode_m31", "Anode Only Segment Time (ME -3/2) [ns]", 200, -200, 200));
0553   hSTimeAnodeByChamberType.push_back(
0554       ibooker.book1D("hSTimeAnode_m22", "Anode Only Segment Time (ME -2/2) [ns]", 200, -200, 200));
0555   hSTimeAnodeByChamberType.push_back(
0556       ibooker.book1D("hSTimeAnode_m21", "Anode Only Segment Time (ME -2/1) [ns]", 200, -200, 200));
0557   hSTimeAnodeByChamberType.push_back(
0558       ibooker.book1D("hSTimeAnode_m11a", "Anode Only Segment Time (ME -1/1a) [ns]", 200, -200, 200));
0559   hSTimeAnodeByChamberType.push_back(
0560       ibooker.book1D("hSTimeAnode_m13", "Anode Only Segment Time (ME -1/3) [ns]", 200, -200, 200));
0561   hSTimeAnodeByChamberType.push_back(
0562       ibooker.book1D("hSTimeAnode_m12", "Anode Only Segment Time (ME -1/2) [ns]", 200, -200, 200));
0563   hSTimeAnodeByChamberType.push_back(
0564       ibooker.book1D("hSTimeAnode_m11b", "Anode Only Segment Time (ME -1/1b) [ns]", 200, -200, 200));
0565   hSTimeAnodeByChamberType.push_back(
0566       ibooker.book1D("hSTimeAnode_p11b", "Anode Only Segment Time (ME +1/1b) [ns]", 200, -200, 200));
0567   hSTimeAnodeByChamberType.push_back(
0568       ibooker.book1D("hSTimeAnode_p12", "Anode Only Segment Time (ME +1/2) [ns]", 200, -200, 200));
0569   hSTimeAnodeByChamberType.push_back(
0570       ibooker.book1D("hSTimeAnode_p13", "Anode Only Segment Time (ME +1/3) [ns]", 200, -200, 200));
0571   hSTimeAnodeByChamberType.push_back(
0572       ibooker.book1D("hSTimeAnode_p11a", "Anode Only Segment Time (ME +1/1a) [ns]", 200, -200, 200));
0573   hSTimeAnodeByChamberType.push_back(
0574       ibooker.book1D("hSTimeAnode_p21", "Anode Only Segment Time (ME +2/1) [ns]", 200, -200, 200));
0575   hSTimeAnodeByChamberType.push_back(
0576       ibooker.book1D("hSTimeAnode_p22", "Anode Only Segment Time (ME +2/2) [ns]", 200, -200, 200));
0577   hSTimeAnodeByChamberType.push_back(
0578       ibooker.book1D("hSTimeAnode_p31", "Anode Only Segment Time (ME +3/1) [ns]", 200, -200, 200));
0579   hSTimeAnodeByChamberType.push_back(
0580       ibooker.book1D("hSTimeAnode_p32", "Anode Only Segment Time (ME +3/2) [ns]", 200, -200, 200));
0581   hSTimeAnodeByChamberType.push_back(
0582       ibooker.book1D("hSTimeAnode_p41", "Anode Only Segment Time (ME +4/1) [ns]", 200, -200, 200));
0583   hSTimeAnodeByChamberType.push_back(
0584       ibooker.book1D("hSTimeAnode_p42", "Anode Only Segment Time (ME +4/2) [ns]", 200, -200, 200));
0585 
0586   hSTimeCathode = ibooker.book1D("hSTimeCathode", "Cathode Only Segment Time  [ns]", 200, -200, 200);
0587   hSTimeCathodeByChamberType.push_back(
0588       ibooker.book1D("hSTimeCathode_m42", "Cathode Only Segment Time (ME -4/2) [ns]", 200, -200, 200));
0589   hSTimeCathodeByChamberType.push_back(
0590       ibooker.book1D("hSTimeCathode_m41", "Cathode Only Segment Time (ME -4/1) [ns]", 200, -200, 200));
0591   hSTimeCathodeByChamberType.push_back(
0592       ibooker.book1D("hSTimeCathode_m32", "Cathode Only Segment Time (ME -3/2) [ns]", 200, -200, 200));
0593   hSTimeCathodeByChamberType.push_back(
0594       ibooker.book1D("hSTimeCathode_m31", "Cathode Only Segment Time (ME -3/2) [ns]", 200, -200, 200));
0595   hSTimeCathodeByChamberType.push_back(
0596       ibooker.book1D("hSTimeCathode_m22", "Cathode Only Segment Time (ME -2/2) [ns]", 200, -200, 200));
0597   hSTimeCathodeByChamberType.push_back(
0598       ibooker.book1D("hSTimeCathode_m21", "Cathode Only Segment Time (ME -2/1) [ns]", 200, -200, 200));
0599   hSTimeCathodeByChamberType.push_back(
0600       ibooker.book1D("hSTimeCathode_m11a", "Cathode Only Segment Time (ME -1/1a) [ns]", 200, -200, 200));
0601   hSTimeCathodeByChamberType.push_back(
0602       ibooker.book1D("hSTimeCathode_m13", "Cathode Only Segment Time (ME -1/3) [ns]", 200, -200, 200));
0603   hSTimeCathodeByChamberType.push_back(
0604       ibooker.book1D("hSTimeCathode_m12", "Cathode Only Segment Time (ME -1/2) [ns]", 200, -200, 200));
0605   hSTimeCathodeByChamberType.push_back(
0606       ibooker.book1D("hSTimeCathode_m11b", "Cathode Only Segment Time (ME -1/1b) [ns]", 200, -200, 200));
0607   hSTimeCathodeByChamberType.push_back(
0608       ibooker.book1D("hSTimeCathode_p11b", "Cathode Only Segment Time (ME +1/1b) [ns]", 200, -200, 200));
0609   hSTimeCathodeByChamberType.push_back(
0610       ibooker.book1D("hSTimeCathode_p12", "Cathode Only Segment Time (ME +1/2) [ns]", 200, -200, 200));
0611   hSTimeCathodeByChamberType.push_back(
0612       ibooker.book1D("hSTimeCathode_p13", "Cathode Only Segment Time (ME +1/3) [ns]", 200, -200, 200));
0613   hSTimeCathodeByChamberType.push_back(
0614       ibooker.book1D("hSTimeCathode_p11a", "Cathode Only Segment Time (ME +1/1a) [ns]", 200, -200, 200));
0615   hSTimeCathodeByChamberType.push_back(
0616       ibooker.book1D("hSTimeCathode_p21", "Cathode Only Segment Time (ME +2/1) [ns]", 200, -200, 200));
0617   hSTimeCathodeByChamberType.push_back(
0618       ibooker.book1D("hSTimeCathode_p22", "Cathode Only Segment Time (ME +2/2) [ns]", 200, -200, 200));
0619   hSTimeCathodeByChamberType.push_back(
0620       ibooker.book1D("hSTimeCathode_p31", "Cathode Only Segment Time (ME +3/1) [ns]", 200, -200, 200));
0621   hSTimeCathodeByChamberType.push_back(
0622       ibooker.book1D("hSTimeCathode_p32", "Cathode Only Segment Time (ME +3/2) [ns]", 200, -200, 200));
0623   hSTimeCathodeByChamberType.push_back(
0624       ibooker.book1D("hSTimeCathode_p41", "Cathode Only Segment Time (ME +4/1) [ns]", 200, -200, 200));
0625   hSTimeCathodeByChamberType.push_back(
0626       ibooker.book1D("hSTimeCathode_p42", "Cathode Only Segment Time (ME +4/2) [ns]", 200, -200, 200));
0627 
0628   hSTimeCombined = ibooker.book1D("hSTimeCombined", "Segment Time (anode+cathode times) [ns]", 200, -200, 200);
0629   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0630       "hSTimeCombined_m42", "Segment Time (anode+cathode times) Segment Time (ME -4/2) [ns]", 200, -200, 200));
0631   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0632       "hSTimeCombined_m41", "Segment Time (anode+cathode times) Segment Time (ME -4/1) [ns]", 200, -200, 200));
0633   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0634       "hSTimeCombined_m32", "Segment Time (anode+cathode times) Segment Time (ME -3/2) [ns]", 200, -200, 200));
0635   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0636       "hSTimeCombined_m31", "Segment Time (anode+cathode times) Segment Time (ME -3/2) [ns]", 200, -200, 200));
0637   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0638       "hSTimeCombined_m22", "Segment Time (anode+cathode times) Segment Time (ME -2/2) [ns]", 200, -200, 200));
0639   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0640       "hSTimeCombined_m21", "Segment Time (anode+cathode times) Segment Time (ME -2/1) [ns]", 200, -200, 200));
0641   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0642       "hSTimeCombined_m11a", "Segment Time (anode+cathode times) Segment Time (ME -1/1a) [ns]", 200, -200, 200));
0643   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0644       "hSTimeCombined_m13", "Segment Time (anode+cathode times) Segment Time (ME -1/3) [ns]", 200, -200, 200));
0645   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0646       "hSTimeCombined_m12", "Segment Time (anode+cathode times) Segment Time (ME -1/2) [ns]", 200, -200, 200));
0647   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0648       "hSTimeCombined_m11b", "Segment Time (anode+cathode times) Segment Time (ME -1/1b) [ns]", 200, -200, 200));
0649   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0650       "hSTimeCombined_p11b", "Segment Time (anode+cathode times) Segment Time (ME +1/1b) [ns]", 200, -200, 200));
0651   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0652       "hSTimeCombined_p12", "Segment Time (anode+cathode times) Segment Time (ME +1/2) [ns]", 200, -200, 200));
0653   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0654       "hSTimeCombined_p13", "Segment Time (anode+cathode times) Segment Time (ME +1/3) [ns]", 200, -200, 200));
0655   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0656       "hSTimeCombined_p11a", "Segment Time (anode+cathode times) Segment Time (ME +1/1a) [ns]", 200, -200, 200));
0657   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0658       "hSTimeCombined_p21", "Segment Time (anode+cathode times) Segment Time (ME +2/1) [ns]", 200, -200, 200));
0659   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0660       "hSTimeCombined_p22", "Segment Time (anode+cathode times) Segment Time (ME +2/2) [ns]", 200, -200, 200));
0661   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0662       "hSTimeCombined_p31", "Segment Time (anode+cathode times) Segment Time (ME +3/1) [ns]", 200, -200, 200));
0663   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0664       "hSTimeCombined_p32", "Segment Time (anode+cathode times) Segment Time (ME +3/2) [ns]", 200, -200, 200));
0665   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0666       "hSTimeCombined_p41", "Segment Time (anode+cathode times) Segment Time (ME +4/1) [ns]", 200, -200, 200));
0667   hSTimeCombinedByChamberType.push_back(ibooker.book1D(
0668       "hSTimeCombined_p42", "Segment Time (anode+cathode times) Segment Time (ME +4/2) [ns]", 200, -200, 200));
0669 
0670   hSTimeDiffSerial =
0671       ibooker.book2D("hSTimeDiffSerial", "Anode Minus Cathode Segment Time  [ns]", 601, -0.5, 600.5, 200, -50, 50);
0672   hSTimeAnodeSerial =
0673       ibooker.book2D("hSTimeAnodeSerial", "Anode Only Segment Time  [ns]", 601, -0.5, 600.5, 200, -200, 200);
0674   hSTimeCathodeSerial =
0675       ibooker.book2D("hSTimeCathodeSerial", "Cathode Only Segment Time  [ns]", 601, -0.5, 600.5, 200, -200, 200);
0676   hSTimeCombinedSerial = ibooker.book2D(
0677       "hSTimeCombinedSerial", "Segment Time (anode+cathode times) [ns]", 601, -0.5, 600.5, 200, -200, 200);
0678 
0679   hSTimeVsZ = ibooker.book2D("hSTimeVsZ", "Segment Time vs. Z; [ns] vs. [cm]", 200, -1200, 1200, 200, -200, 200);
0680   hSTimeVsTOF =
0681       ibooker.book2D("hSTimeVsTOF", "Segment Time vs. Distance from IP; [ns] vs. [cm]", 180, 500, 1400, 200, -200, 200);
0682 
0683   // resolution
0684   ibooker.setCurrentFolder("CSC/CSCOfflineMonitor/Resolution");
0685 
0686   hSResid.push_back(ibooker.book1D(
0687       "hSResidm42", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -4/2); Strip Widths", 100, -0.5, 0.5));
0688   hSResid.push_back(ibooker.book1D(
0689       "hSResidm41", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -4/1); Strip Widths", 100, -0.5, 0.5));
0690   hSResid.push_back(ibooker.book1D(
0691       "hSResidm32", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -3/2); Strip Widths", 100, -0.5, 0.5));
0692   hSResid.push_back(ibooker.book1D(
0693       "hSResidm31", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -3/1); Strip Widths", 100, -0.5, 0.5));
0694   hSResid.push_back(ibooker.book1D(
0695       "hSResidm22", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -2/2); Strip Widths", 100, -0.5, 0.5));
0696   hSResid.push_back(ibooker.book1D(
0697       "hSResidm21", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -2/1); Strip Widths", 100, -0.5, 0.5));
0698   hSResid.push_back(ibooker.book1D(
0699       "hSResidm11a", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/1a); Strip Widths", 100, -0.5, 0.5));
0700   hSResid.push_back(ibooker.book1D(
0701       "hSResidm13", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/3); Strip Widths", 100, -0.5, 0.5));
0702   hSResid.push_back(ibooker.book1D(
0703       "hSResidm12", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/2); Strip Widths", 100, -0.5, 0.5));
0704   hSResid.push_back(ibooker.book1D(
0705       "hSResidm11b", "Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/1b); Strip Widths", 100, -0.5, 0.5));
0706   hSResid.push_back(ibooker.book1D(
0707       "hSResidp11b", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/1b); Strip Widths", 100, -0.5, 0.5));
0708   hSResid.push_back(ibooker.book1D(
0709       "hSResidp12", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/2); Strip Widths", 100, -0.5, 0.5));
0710   hSResid.push_back(ibooker.book1D(
0711       "hSResidp13", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/3); Strip Widths", 100, -0.5, 0.5));
0712   hSResid.push_back(ibooker.book1D(
0713       "hSResidp11a", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/1a); Strip Widths", 100, -0.5, 0.5));
0714   hSResid.push_back(ibooker.book1D(
0715       "hSResidp21", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +2/1); Strip Widths", 100, -0.5, 0.5));
0716   hSResid.push_back(ibooker.book1D(
0717       "hSResidp22", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +2/2); Strip Widths", 100, -0.5, 0.5));
0718   hSResid.push_back(ibooker.book1D(
0719       "hSResidp31", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +3/1); Strip Widths", 100, -0.5, 0.5));
0720   hSResid.push_back(ibooker.book1D(
0721       "hSResidp32", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +3/2); Strip Widths", 100, -0.5, 0.5));
0722   hSResid.push_back(ibooker.book1D(
0723       "hSResidp41", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +4/1); Strip Widths", 100, -0.5, 0.5));
0724   hSResid.push_back(ibooker.book1D(
0725       "hSResidp42", "Fitted Position on Strip - Reconstructed for Layer 3 (ME +4/2); Strip Widths", 100, -0.5, 0.5));
0726 
0727   // efficiency
0728   ibooker.setCurrentFolder("CSC/CSCOfflineMonitor/Efficiency");
0729 
0730   //      hSSTE = ibooker.book1D("hSSTE","hSSTE",40,0.5,40.5);
0731   //      hRHSTE = ibooker.book1D("hRHSTE","hRHSTE",40,0.5,40.5);
0732   hSnum = ibooker.book1D("hSnum", "CSC w rechits in 2+ layers && segment(s)", 20, 0.5, 20.5);
0733   hSden = ibooker.book1D("hSden", "CSC w rechits in 2+ layers", 20, 0.5, 20.5);
0734   hRHnum = ibooker.book1D("hRHnum", "CSC w segment(s) && rechits in 6 layers", 20, 0.5, 20.5);
0735   hRHden = ibooker.book1D("hRHden", "CSC w segment(s)", 20, 0.5, 20.5);
0736   applyCSClabels(hSnum, EXTENDED, X);
0737   applyCSClabels(hSden, EXTENDED, X);
0738   applyCSClabels(hRHnum, EXTENDED, X);
0739   applyCSClabels(hRHden, EXTENDED, X);
0740 
0741   //      hSEff = ibooker.book1D("hSEff","Segment Efficiency",20,0.5,20.5);
0742   //      hRHEff = ibooker.book1D("hRHEff","recHit Efficiency",20,0.5,20.5);
0743   hSSTE2 = ibooker.book2D("hSSTE2", "hSSTE2", 36, 0.5, 36.5, 20, 0.5, 20.5);
0744   hRHSTE2 = ibooker.book2D("hRHSTE2", "hRHSTE2", 36, 0.5, 36.5, 20, 0.5, 20.5);
0745   hStripSTE2 = ibooker.book2D("hStripSTE2", "hStripSTE2", 36, 0.5, 36.5, 20, 0.5, 20.5);
0746   hWireSTE2 = ibooker.book2D("hWireSTE2", "hWireSTE2", 36, 0.5, 36.5, 20, 0.5, 20.5);
0747   hEffDenominator = ibooker.book2D("hEffDenominator", "hEffDenominator", 36, 0.5, 36.5, 20, 0.5, 20.5);
0748   //      hSEff2 = ibooker.book2D("hSEff2","Segment Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
0749   //      hRHEff2 = ibooker.book2D("hRHEff2","recHit Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
0750   //      hStripReadoutEff2 = ibooker.book2D("hStripReadoutEff2","strip readout ratio [(strip+clct+wires)/(clct+wires)] 2D",36,0.5,36.5, 20, 0.5, 20.5);
0751   //      hStripReadoutEff2->setAxisTitle("Chamber #");
0752   //      hStripEff2 = ibooker.book2D("hStripEff2","strip Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
0753   //      hWireEff2 = ibooker.book2D("hWireEff2","wire Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
0754   hSensitiveAreaEvt =
0755       ibooker.book2D("hSensitiveAreaEvt", "Events Passing Selection for Efficiency", 36, 0.5, 36.5, 20, 0.5, 20.5);
0756 
0757   // bx monitor for trigger synchronization
0758   ibooker.setCurrentFolder("CSC/CSCOfflineMonitor/BXMonitor");
0759 
0760   hALCTgetBX = ibooker.book1D("hALCTgetBX", "ALCT position in ALCT-L1A match window [BX]", 7, -0.5, 6.5);
0761   //      hALCTgetBXChamberMeans = ibooker.book1D("hALCTgetBXChamberMeans","Chamber Mean ALCT position in ALCT-L1A match window [BX]",60,0,6);
0762   hALCTgetBXSerial =
0763       ibooker.book2D("hALCTgetBXSerial", "ALCT position in ALCT-L1A match window [BX]", 601, -0.5, 600.5, 7, -0.5, 6.5);
0764   hALCTgetBXSerial->setAxisTitle("Chamber Serial Number");
0765   hALCTgetBX2DNumerator = ibooker.book2D(
0766       "hALCTgetBX2DNumerator", "ALCT position in ALCT-L1A match window [BX] (sum)", 36, 0.5, 36.5, 20, 0.5, 20.5);
0767   //      hALCTgetBX2DMeans = ibooker.book2D("hALCTgetBX2DMeans","ALCT position in ALCT-L1A match window [BX]",36,0.5,36.5,20,0.5,20.5);
0768   hALCTgetBX2Denominator =
0769       ibooker.book2D("hALCTgetBX2Denominator", "Number of ALCT Digis checked", 36, 0.5, 36.5, 20, 0.5, 20.5);
0770   //      hALCTgetBX2DMeans->setAxisTitle("Chamber #");
0771   hALCTgetBX2Denominator->setAxisTitle("Chamber #");
0772   hALCTMatch = ibooker.book1D("hALCTMatch", "ALCT position in ALCT-CLCT match window [BX]", 7, -0.5, 6.5);
0773   //      hALCTMatchChamberMeans = ibooker.book1D("hALCTMatchChamberMeans","Chamber Mean ALCT position in ALCT-CLCT match window [BX]",60,0,6);
0774   hALCTMatchSerial = ibooker.book2D(
0775       "hALCTMatchSerial", "ALCT position in ALCT-CLCT match window [BX]", 601, -0.5, 600.5, 7, -0.5, 6.5);
0776   hALCTMatchSerial->setAxisTitle("Chamber Serial Number");
0777   hALCTMatch2DNumerator = ibooker.book2D(
0778       "hALCTMatch2DNumerator", "ALCT position in ALCT-CLCT match window [BX] (sum)", 36, 0.5, 36.5, 20, 0.5, 20.5);
0779   //      hALCTMatch2DMeans = ibooker.book2D("hALCTMatch2DMeans","ALCT position in ALCT-CLCT match window [BX]",36,0.5,36.5,20,0.5,20.5);
0780   hALCTMatch2Denominator =
0781       ibooker.book2D("hALCTMatch2Denominator", "Number of ALCT-CLCT matches checked", 36, 0.5, 36.5, 20, 0.5, 20.5);
0782   //      hALCTMatch2DMeans->setAxisTitle("Chamber #");
0783   hALCTMatch2Denominator->setAxisTitle("Chamber #");
0784   hCLCTL1A = ibooker.book1D("hCLCTL1A", "L1A - CLCTpreTrigger at TMB [BX]", 40, 149.5, 189.5);
0785   //      hCLCTL1AChamberMeans = ibooker.book1D("hCLCTL1AChamberMeans","Chamber Mean L1A - CLCTpreTrigger at TMB [BX]",90,150,159);
0786   hCLCTL1ASerial =
0787       ibooker.book2D("hCLCTL1ASerial", "L1A - CLCTpreTrigger at TMB [BX]", 601, -0.5, 600.5, 40, 149.5, 189.5);
0788   hCLCTL1ASerial->setAxisTitle("Chamber Serial Number");
0789   hCLCTL1A2DNumerator =
0790       ibooker.book2D("hCLCTL1A2DNumerator", "L1A - CLCTpreTrigger at TMB [BX] (sum)", 36, 0.5, 36.5, 20, 0.5, 20.5);
0791   //      hCLCTL1A2DMeans = ibooker.book2D("hCLCTL1A2DMeans","L1A - CLCTpreTrigger at TMB [BX]",36,0.5,36.5,20,0.5,20.5);
0792   hCLCTL1A2Denominator =
0793       ibooker.book2D("hCLCTL1A2Denominator", "Number of TMB CLCTs checked", 36, 0.5, 36.5, 20, 0.5, 20.5);
0794 
0795   // labels
0796   applyCSClabels(hOWiresAndCLCT, EXTENDED, Y);
0797   applyCSClabels(hOWires, EXTENDED, Y);
0798   applyCSClabels(hOStrips, EXTENDED, Y);
0799   applyCSClabels(hOStripsAndWiresAndCLCT, EXTENDED, Y);
0800   applyCSClabels(hORecHits, EXTENDED, Y);
0801   applyCSClabels(hOSegments, EXTENDED, Y);
0802   //      applyCSClabels(hSEff, EXTENDED, X);
0803   //      applyCSClabels(hRHEff, EXTENDED, X);
0804   //      applyCSClabels(hSEff2, SMALL, Y);
0805   applyCSClabels(hSSTE2, EXTENDED, Y);
0806   applyCSClabels(hEffDenominator, EXTENDED, Y);
0807   //      applyCSClabels(hRHEff2, SMALL, Y);
0808   applyCSClabels(hRHSTE2, EXTENDED, Y);
0809   //      applyCSClabels(hStripReadoutEff2, EXTENDED, Y);
0810   //      applyCSClabels(hStripEff2, SMALL, Y);
0811   applyCSClabels(hStripSTE2, EXTENDED, Y);
0812   //      applyCSClabels(hWireEff2, SMALL, Y);
0813   applyCSClabels(hWireSTE2, EXTENDED, Y);
0814   applyCSClabels(hSensitiveAreaEvt, EXTENDED, Y);
0815   //      applyCSClabels(hALCTgetBX2DMeans, EXTENDED, Y);
0816   applyCSClabels(hALCTgetBX2Denominator, EXTENDED, Y);
0817   //      applyCSClabels(hALCTMatch2DMeans, EXTENDED, Y);
0818   applyCSClabels(hALCTMatch2Denominator, EXTENDED, Y);
0819   //      applyCSClabels(hCLCTL1A2DMeans, EXTENDED, Y);
0820   applyCSClabels(hCLCTL1A2Denominator, EXTENDED, Y);
0821 }
0822 
0823 ////////////////
0824 //  Analysis  //
0825 ////////////////
0826 void CSCOfflineMonitor::analyze(const edm::Event& event, const edm::EventSetup& eventSetup) {
0827   edm::Handle<CSCWireDigiCollection> wires;
0828   edm::Handle<CSCStripDigiCollection> strips;
0829   edm::Handle<CSCALCTDigiCollection> alcts;
0830   edm::Handle<CSCCLCTDigiCollection> clcts;
0831   event.getByToken(sd_token, strips);
0832   event.getByToken(wd_token, wires);
0833   event.getByToken(al_token, alcts);
0834   event.getByToken(cl_token, clcts);
0835 
0836   // Get the CSC Geometry :
0837   edm::ESHandle<CSCGeometry> cscGeom;
0838 
0839   cscGeom = eventSetup.getHandle(cscGeomToken_);
0840 
0841   // Get the RecHits collection :
0842   edm::Handle<CSCRecHit2DCollection> recHits;
0843   event.getByToken(rh_token, recHits);
0844 
0845   // get CSC segment collection
0846   edm::Handle<CSCSegmentCollection> cscSegments;
0847   event.getByToken(se_token, cscSegments);
0848 
0849   doOccupancies(strips, wires, recHits, cscSegments, clcts);
0850   doStripDigis(strips);
0851   doWireDigis(wires);
0852   doRecHits(recHits, strips, cscGeom);
0853   doSegments(cscSegments, cscGeom);
0854   doResolution(cscSegments, cscGeom);
0855   doPedestalNoise(strips, cscGeom);
0856   doEfficiencies(wires, strips, recHits, cscSegments, cscGeom);
0857   doBXMonitor(alcts, clcts, event, eventSetup);
0858 }
0859 
0860 // ==============================================
0861 //
0862 // look at Occupancies
0863 //
0864 // ==============================================
0865 
0866 void CSCOfflineMonitor::doOccupancies(edm::Handle<CSCStripDigiCollection> strips,
0867                                       edm::Handle<CSCWireDigiCollection> wires,
0868                                       edm::Handle<CSCRecHit2DCollection> recHits,
0869                                       edm::Handle<CSCSegmentCollection> cscSegments,
0870                                       edm::Handle<CSCCLCTDigiCollection> clcts) {
0871   bool clcto[2][4][4][36];
0872   bool wireo[2][4][4][36];
0873   bool stripo[2][4][4][36];
0874   bool rechito[2][4][4][36];
0875   bool segmento[2][4][4][36];
0876 
0877   bool hasWires = false;
0878   bool hasStrips = false;
0879   bool hasRecHits = false;
0880   bool hasSegments = false;
0881 
0882   for (int e = 0; e < 2; e++) {
0883     for (int s = 0; s < 4; s++) {
0884       for (int r = 0; r < 4; r++) {
0885         for (int c = 0; c < 36; c++) {
0886           clcto[e][s][r][c] = false;
0887           wireo[e][s][r][c] = false;
0888           stripo[e][s][r][c] = false;
0889           rechito[e][s][r][c] = false;
0890           segmento[e][s][r][c] = false;
0891         }
0892       }
0893     }
0894   }
0895 
0896   //clcts
0897   for (CSCCLCTDigiCollection::DigiRangeIterator j = clcts->begin(); j != clcts->end(); j++) {
0898     CSCDetId id = (CSCDetId)(*j).first;
0899     int kEndcap = id.endcap();
0900     int kRing = id.ring();
0901     int kStation = id.station();
0902     int kChamber = id.chamber();
0903     const CSCCLCTDigiCollection::Range& range = (*j).second;
0904     for (CSCCLCTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
0905       // Valid digi in the chamber (or in neighbouring chamber)
0906       if ((*digiIt).isValid()) {
0907         //Check whether this CLCT came from ME11a
0908         if (kStation == 1 && kRing == 1 && (*digiIt).getKeyStrip() > 128)
0909           kRing = 4;
0910         clcto[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
0911       }
0912     }
0913   }
0914 
0915   //wires
0916   for (CSCWireDigiCollection::DigiRangeIterator wi = wires->begin(); wi != wires->end(); wi++) {
0917     CSCDetId id = (CSCDetId)(*wi).first;
0918     int kEndcap = id.endcap();
0919     int kRing = id.ring();
0920     int kStation = id.station();
0921     int kChamber = id.chamber();
0922     std::vector<CSCWireDigi>::const_iterator wireIt = (*wi).second.first;
0923     std::vector<CSCWireDigi>::const_iterator lastWire = (*wi).second.second;
0924     for (; wireIt != lastWire; ++wireIt) {
0925       if (!wireo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
0926         wireo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
0927         hOWires->Fill(kChamber, typeIndex(id, 2));
0928         hOWireSerial->Fill(chamberSerial(id));
0929         hasWires = true;
0930         if (clcto[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1])
0931           hOWiresAndCLCT->Fill(kChamber, typeIndex(id, 2));
0932         //Also check for a CLCT in ME11a if you're in ME11 already
0933         if (kStation == 1 && kRing == 1 && clcto[kEndcap - 1][kStation - 1][3][kChamber - 1]) {
0934           CSCDetId idME11a = CSCDetId(kEndcap, kStation, 4, kChamber);
0935           hOWiresAndCLCT->Fill(kChamber, typeIndex(idME11a, 2));
0936         }
0937       }
0938     }  //end for loop
0939   }
0940 
0941   //strips
0942   for (CSCStripDigiCollection::DigiRangeIterator si = strips->begin(); si != strips->end(); si++) {
0943     CSCDetId id = (CSCDetId)(*si).first;
0944     int kEndcap = id.endcap();
0945     int kRing = id.ring();
0946     int kStation = id.station();
0947     int kChamber = id.chamber();
0948     std::vector<CSCStripDigi>::const_iterator stripIt = (*si).second.first;
0949     std::vector<CSCStripDigi>::const_iterator lastStrip = (*si).second.second;
0950     for (; stripIt != lastStrip; ++stripIt) {
0951       std::vector<int> myADCVals = stripIt->getADCCounts();
0952       bool thisStripFired = false;
0953       float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
0954       float threshold = 13.3;
0955       float diff = 0.;
0956       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
0957         diff = (float)myADCVals[iCount] - thisPedestal;
0958         if (diff > threshold) {
0959           thisStripFired = true;
0960         }
0961       }
0962       if (thisStripFired) {
0963         if (!stripo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
0964           stripo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
0965           hOStrips->Fill(kChamber, typeIndex(id, 2));
0966           hOStripSerial->Fill(chamberSerial(id));
0967           hasStrips = true;
0968           if (clcto[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
0969             // check if there is a wire digi in this chamber too
0970             // for ME 1/4 check for a wire in ME 1/1
0971             if (wireo[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] ||
0972                 (kRing == 4 && wireo[kEndcap - 1][kStation - 1][0][kChamber - 1])) {
0973               hOStripsAndWiresAndCLCT->Fill(kChamber, typeIndex(id, 2));
0974             }
0975           }  //end clct and wire digi check
0976         }
0977       }  //end if (thisStripFired)
0978     }
0979   }
0980 
0981   //rechits
0982   CSCRecHit2DCollection::const_iterator recIt;
0983   for (recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
0984     CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
0985     int kEndcap = idrec.endcap();
0986     int kRing = idrec.ring();
0987     int kStation = idrec.station();
0988     int kChamber = idrec.chamber();
0989     if (!rechito[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
0990       rechito[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
0991       hORecHitsSerial->Fill(chamberSerial(idrec));
0992       hORecHits->Fill(kChamber, typeIndex(idrec, 2));
0993       hasRecHits = true;
0994     }
0995   }
0996 
0997   //segments
0998   for (CSCSegmentCollection::const_iterator segIt = cscSegments->begin(); segIt != cscSegments->end(); segIt++) {
0999     CSCDetId id = (CSCDetId)(*segIt).cscDetId();
1000     int kEndcap = id.endcap();
1001     int kRing = id.ring();
1002     int kStation = id.station();
1003     int kChamber = id.chamber();
1004     if (!segmento[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1]) {
1005       segmento[kEndcap - 1][kStation - 1][kRing - 1][kChamber - 1] = true;
1006       hOSegmentsSerial->Fill(chamberSerial(id));
1007       hOSegments->Fill(kChamber, typeIndex(id, 2));
1008       hasSegments = true;
1009     }
1010   }
1011 
1012   //Overall CSC Occupancy
1013   hCSCOccupancy->Fill(1);
1014   if (hasWires)
1015     hCSCOccupancy->Fill(3);
1016   if (hasStrips)
1017     hCSCOccupancy->Fill(5);
1018   if (hasWires && hasStrips)
1019     hCSCOccupancy->Fill(7);
1020   if (hasRecHits)
1021     hCSCOccupancy->Fill(9);
1022   if (hasSegments)
1023     hCSCOccupancy->Fill(11);
1024 }
1025 
1026 // ==============================================
1027 //
1028 // look at WIRE DIGIs
1029 //
1030 // ==============================================
1031 
1032 void CSCOfflineMonitor::doWireDigis(edm::Handle<CSCWireDigiCollection> wires) {
1033   int nWireGroupsTotal = 0;
1034   for (CSCWireDigiCollection::DigiRangeIterator dWDiter = wires->begin(); dWDiter != wires->end(); dWDiter++) {
1035     CSCDetId id = (CSCDetId)(*dWDiter).first;
1036     std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
1037     std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
1038     for (; wireIter != lWire; ++wireIter) {
1039       int myWire = wireIter->getWireGroup();
1040       int myTBin = wireIter->getTimeBin();
1041       nWireGroupsTotal++;
1042       hWireTBin[typeIndex(id) - 1]->Fill(myTBin);
1043       hWireNumber[typeIndex(id) - 1]->Fill(myWire);
1044     }
1045   }  // end wire loop
1046 
1047   hWirenGroupsTotal->Fill(nWireGroupsTotal);
1048   hWirenGroupsTotalHi->Fill(nWireGroupsTotal);
1049 }
1050 
1051 // ==============================================
1052 //
1053 // look at STRIP DIGIs
1054 //
1055 // ==============================================
1056 
1057 void CSCOfflineMonitor::doStripDigis(edm::Handle<CSCStripDigiCollection> strips) {
1058   int nStripsFired = 0;
1059   for (CSCStripDigiCollection::DigiRangeIterator dSDiter = strips->begin(); dSDiter != strips->end(); dSDiter++) {
1060     CSCDetId id = (CSCDetId)(*dSDiter).first;
1061     std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
1062     std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
1063     for (; stripIter != lStrip; ++stripIter) {
1064       int myStrip = stripIter->getStrip();
1065       std::vector<int> myADCVals = stripIter->getADCCounts();
1066       bool thisStripFired = false;
1067       float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1068       float threshold = 13.3;
1069       float diff = 0.;
1070       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
1071         diff = (float)myADCVals[iCount] - thisPedestal;
1072         if (diff > threshold) {
1073           thisStripFired = true;
1074         }
1075       }
1076       if (thisStripFired) {
1077         nStripsFired++;
1078         hStripNumber[typeIndex(id) - 1]->Fill(myStrip);
1079       }
1080     }
1081   }  // end strip loop
1082 
1083   hStripNFired->Fill(nStripsFired);
1084   hStripNFiredHi->Fill(nStripsFired);
1085 
1086   // fill n per event
1087 }
1088 
1089 //=======================================================
1090 //
1091 // Look at the Pedestal Noise Distributions
1092 //
1093 //=======================================================
1094 
1095 void CSCOfflineMonitor::doPedestalNoise(edm::Handle<CSCStripDigiCollection> strips,
1096                                         edm::ESHandle<CSCGeometry> cscGeom) {
1097   for (CSCStripDigiCollection::DigiRangeIterator dPNiter = strips->begin(); dPNiter != strips->end(); dPNiter++) {
1098     CSCDetId id = (CSCDetId)(*dPNiter).first;
1099     int kStation = id.station();
1100     int kRing = id.ring();
1101     std::vector<CSCStripDigi>::const_iterator pedIt = (*dPNiter).second.first;
1102     std::vector<CSCStripDigi>::const_iterator lStrip = (*dPNiter).second.second;
1103     for (; pedIt != lStrip; ++pedIt) {
1104       int myStrip = pedIt->getStrip();
1105       std::vector<int> myADCVals = pedIt->getADCCounts();
1106       float TotalADC = getSignal(*strips, id, myStrip);
1107       bool thisStripFired = false;
1108       float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1109       float thisSignal =
1110           (1. / 6) * (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1111       float threshold = 13.3;
1112 
1113       if ((kStation == 1 && kRing == 4) && cscGeom->gangedStrips()) {
1114         kRing = 1;
1115       }
1116 
1117       if (TotalADC > threshold) {
1118         thisStripFired = true;
1119       }
1120       if (!thisStripFired) {
1121         float ADC = thisSignal - thisPedestal;
1122         hStripPed[typeIndex(id) - 1]->Fill(ADC);
1123       }
1124     }
1125   }
1126 }
1127 
1128 // ==============================================
1129 //
1130 // look at RECHITs
1131 //
1132 // ==============================================
1133 
1134 void CSCOfflineMonitor::doRecHits(edm::Handle<CSCRecHit2DCollection> recHits,
1135                                   edm::Handle<CSCStripDigiCollection> strips,
1136                                   edm::ESHandle<CSCGeometry> cscGeom) {
1137   // Get the RecHits collection :
1138   int nRecHits = recHits->size();
1139 
1140   // ---------------------
1141   // Loop over rechits
1142   // ---------------------
1143   // Build iterator for rechits and loop :
1144   CSCRecHit2DCollection::const_iterator dRHIter;
1145   for (dRHIter = recHits->begin(); dRHIter != recHits->end(); dRHIter++) {
1146     // Find chamber with rechits in CSC
1147     CSCDetId idrec = (CSCDetId)(*dRHIter).cscDetId();
1148 
1149     // Store rechit as a Local Point:
1150     LocalPoint rhitlocal = (*dRHIter).localPosition();
1151     //float xreco = rhitlocal.x();
1152     //float yreco = rhitlocal.y();
1153 
1154     // Get the reconstucted strip position and error
1155     float stpos = (*dRHIter).positionWithinStrip();
1156     float sterr = (*dRHIter).errorWithinStrip();
1157 
1158     /// Find the charge associated with this hit
1159 
1160     int adcsize = dRHIter->nStrips() * dRHIter->nTimeBins();
1161     float rHSumQ = 0;
1162     float sumsides = 0;
1163     for (unsigned int i = 0; i < dRHIter->nStrips(); i++) {
1164       for (unsigned int j = 0; j < dRHIter->nTimeBins() - 1; j++) {
1165         rHSumQ += dRHIter->adcs(i, j);
1166         if (i != 1)
1167           sumsides += dRHIter->adcs(i, j);  // skip central strip
1168       }
1169     }
1170 
1171     float rHratioQ = sumsides / rHSumQ;
1172     if (adcsize != 12)
1173       rHratioQ = -99;
1174 
1175     // Get the signal timing of this hit
1176     float rHtime = (*dRHIter).tpeak();          //calculated from cathode SCA bins
1177     float rHtimeAnode = (*dRHIter).wireTime();  // calculated from anode wire bx
1178 
1179     // Get pointer to the layer:
1180     const CSCLayer* csclayer = cscGeom->layer(idrec);
1181 
1182     // Transform hit position from local chamber geometry to global CMS geom
1183     GlobalPoint rhitglobal = csclayer->toGlobal(rhitlocal);
1184     float grecx = rhitglobal.x();
1185     float grecy = rhitglobal.y();
1186 
1187     // Fill some histograms
1188     int sIndex = idrec.station() + ((idrec.endcap() - 1) * 4);
1189     int tIndex = typeIndex(idrec);
1190     hRHSumQ[tIndex - 1]->Fill(rHSumQ);
1191     hRHRatioQ[tIndex - 1]->Fill(rHratioQ);
1192     hRHstpos[tIndex - 1]->Fill(stpos);
1193     hRHsterr[tIndex - 1]->Fill(sterr);
1194     hRHTiming[tIndex - 1]->Fill(rHtime);
1195     hRHTimingAnode[tIndex - 1]->Fill(rHtimeAnode);
1196     hRHGlobal[sIndex - 1]->Fill(grecx, grecy);
1197 
1198   }  //end rechit loop
1199 
1200   //  if (nRecHits == 0) nRecHits = -1; // I see no point in doing this
1201   hRHnrechits->Fill(nRecHits);
1202   hRHnrechitsHi->Fill(nRecHits);
1203 }
1204 
1205 // ==============================================
1206 //
1207 // look at SEGMENTs
1208 //
1209 // ===============================================
1210 
1211 void CSCOfflineMonitor::doSegments(edm::Handle<CSCSegmentCollection> cscSegments, edm::ESHandle<CSCGeometry> cscGeom) {
1212   // get CSC segment collection
1213   int nSegments = cscSegments->size();
1214 
1215   for (CSCSegmentCollection::const_iterator dSiter = cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
1216     CSCDetId id = (CSCDetId)(*dSiter).cscDetId();
1217     float chisq = (*dSiter).chi2();
1218     int nhits = (*dSiter).nRecHits();
1219     int nDOF = 2 * nhits - 4;
1220     float nChi2 = chisq / nDOF;
1221     double chisqProb = ChiSquaredProbability((double)chisq, nDOF);
1222     LocalPoint localPos = (*dSiter).localPosition();
1223     LocalVector segDir = (*dSiter).localDirection();
1224 
1225     // prepare to calculate segment times
1226     float timeCathode = 0;   //average from cathode information alone
1227     float timeAnode = 0;     //average from pruned anode information alone
1228     float timeCombined = 0;  //average from cathode hits and pruned anode list
1229     std::vector<float> cathodeTimes;
1230     std::vector<float> anodeTimes;
1231     // Get the CSC recHits that contribute to this segment.
1232     std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
1233     for (vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
1234       if (!((*iRH).isValid()))
1235         continue;  // only interested in valid hits
1236       cathodeTimes.push_back((*iRH).tpeak());
1237       anodeTimes.push_back((*iRH).wireTime());
1238     }  //end rechit loop
1239 
1240     // Calculate cathode average
1241     for (unsigned int i = 0; i < cathodeTimes.size(); i++)
1242       timeCathode += cathodeTimes[i] / cathodeTimes.size();
1243 
1244     // Prune the anode list to deal with the late tail
1245     float anodeMaxDiff;
1246     bool modified = false;
1247     std::vector<float>::iterator anodeMaxHit;
1248     do {
1249       if (anodeTimes.empty())
1250         continue;
1251       timeAnode = 0;
1252       anodeMaxDiff = 0;
1253       modified = false;
1254 
1255       // Find the average
1256       for (unsigned int j = 0; j < anodeTimes.size(); j++)
1257         timeAnode += anodeTimes[j] / anodeTimes.size();
1258 
1259       // Find the maximum outlier hit
1260       for (unsigned int j = 0; j < anodeTimes.size(); j++) {
1261         if (fabs(anodeTimes[j] - timeAnode) > anodeMaxDiff) {
1262           anodeMaxHit = anodeTimes.begin() + j;
1263           anodeMaxDiff = fabs(anodeTimes[j] - timeAnode);
1264         }
1265       }
1266 
1267       // Cut hit if its greater than some time away
1268       if (anodeMaxDiff > 26) {
1269         modified = true;
1270         anodeTimes.erase(anodeMaxHit);
1271       }
1272     } while (modified);
1273 
1274     // Calculate combined anode and cathode time average
1275     if (cathodeTimes.size() + anodeTimes.size() > 0)
1276       timeCombined = (timeCathode * cathodeTimes.size() + timeAnode * anodeTimes.size()) /
1277                      (cathodeTimes.size() + anodeTimes.size());
1278 
1279     // global transformation
1280     float globX = 0.;
1281     float globY = 0.;
1282     float globZ = 0.;
1283     float globTOF = 0.;
1284     float globTheta = 0.;
1285     float globPhi = 0.;
1286     const CSCChamber* cscchamber = cscGeom->chamber(id);
1287     if (cscchamber) {
1288       GlobalPoint globalPosition = cscchamber->toGlobal(localPos);
1289       globX = globalPosition.x();
1290       globY = globalPosition.y();
1291       globZ = globalPosition.z();
1292       globTOF = sqrt(globX * globX + globY * globY + globZ * globZ);
1293       GlobalVector globalDirection = cscchamber->toGlobal(segDir);
1294       globTheta = globalDirection.theta();
1295       globPhi = globalDirection.phi();
1296     }
1297 
1298     // Fill histos
1299     int tIndex = typeIndex(id);
1300     hSnhitsAll->Fill(nhits);
1301     hSnhits[tIndex - 1]->Fill(nhits);
1302     hSChiSqAll->Fill(nChi2);
1303     hSChiSq[tIndex - 1]->Fill(nChi2);
1304     hSChiSqProbAll->Fill(chisqProb);
1305     hSChiSqProb[tIndex - 1]->Fill(chisqProb);
1306     hSGlobalTheta->Fill(globTheta);
1307     hSGlobalPhi->Fill(globPhi);
1308     hSTimeDiff->Fill(timeAnode - timeCathode);
1309     hSTimeDiffByChamberType[tIndex - 1]->Fill(timeAnode - timeCathode);
1310     hSTimeAnode->Fill(timeAnode);
1311     hSTimeAnodeByChamberType[tIndex - 1]->Fill(timeAnode);
1312     hSTimeCathode->Fill(timeCathode);
1313     hSTimeCathodeByChamberType[tIndex - 1]->Fill(timeCathode);
1314     hSTimeCombined->Fill(timeCombined);
1315     hSTimeCombinedByChamberType[tIndex - 1]->Fill(timeCombined);
1316     hSTimeDiffSerial->Fill(chamberSerial(id), timeAnode - timeCathode);
1317     hSTimeAnodeSerial->Fill(chamberSerial(id), timeAnode);
1318     hSTimeCathodeSerial->Fill(chamberSerial(id), timeCathode);
1319     hSTimeCombinedSerial->Fill(chamberSerial(id), timeCombined);
1320     hSTimeVsZ->Fill(globZ, timeCombined);
1321     hSTimeVsTOF->Fill(globTOF, timeCombined);
1322 
1323   }  // end segment loop
1324 
1325   hSnSegments->Fill(nSegments);
1326 }
1327 
1328 // ==============================================
1329 //
1330 // look at hit Resolution
1331 //
1332 // ==============================================
1333 void CSCOfflineMonitor::doResolution(edm::Handle<CSCSegmentCollection> cscSegments,
1334                                      edm::ESHandle<CSCGeometry> cscGeom) {
1335   for (CSCSegmentCollection::const_iterator dSiter = cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
1336     CSCDetId id = (CSCDetId)(*dSiter).cscDetId();
1337     //
1338     // try to get the CSC recHits that contribute to this segment.
1339     std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
1340     int nRH = (*dSiter).nRecHits();
1341     CLHEP::HepMatrix sp(6, 1);
1342     CLHEP::HepMatrix se(6, 1);
1343     for (vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
1344       CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
1345       //int kEndcap  = idRH.endcap();
1346       int kRing = idRH.ring();
1347       int kStation = idRH.station();
1348       //int kChamber = idRH.chamber();
1349       int kLayer = idRH.layer();
1350 
1351       /// Find the strip containing this hit
1352       int centerid = iRH->nStrips() / 2 + 1;
1353       int centerStrip = iRH->channels(centerid - 1);
1354 
1355       // If this segment has 6 hits, find the position of each hit on the strip in units of stripwidth and store values
1356       if (nRH == 6) {
1357         float stpos = (*iRH).positionWithinStrip();
1358         se(kLayer, 1) = (*iRH).errorWithinStrip();
1359         // Take into account half-strip staggering of layers (ME1/1 has no staggering)
1360         if (kStation == 1 && (kRing == 1 || kRing == 4))
1361           sp(kLayer, 1) = stpos + centerStrip;
1362         else {
1363           if (kLayer == 1 || kLayer == 3 || kLayer == 5)
1364             sp(kLayer, 1) = stpos + centerStrip;
1365           if (kLayer == 2 || kLayer == 4 || kLayer == 6)
1366             sp(kLayer, 1) = stpos - 0.5 + centerStrip;
1367         }
1368       }
1369     }
1370 
1371     // Fit all points except layer 3, then compare expected value for layer 3 to reconstructed value
1372     //    float residual = -99.; // used to fill always
1373     if (nRH == 6) {
1374       float expected = fitX(sp, se);
1375       float residual = expected - sp(3, 1);
1376 
1377       hSResid[typeIndex(id) - 1]->Fill(residual);  // fill here so stats make sense
1378     }
1379 
1380     //  hSResid[typeIndex(id)-1]->Fill(residual); // used to fill here but then stats distorted by underflows
1381 
1382   }  // end segment loop
1383 }
1384 
1385 //-------------------------------------------------------------------------------------
1386 // Fits a straight line to a set of 5 points with errors.  Functions assumes 6 points
1387 // and removes hit in layer 3.  It then returns the expected position value in layer 3
1388 // based on the fit.
1389 //-------------------------------------------------------------------------------------
1390 float CSCOfflineMonitor::fitX(const CLHEP::HepMatrix& points, const CLHEP::HepMatrix& errors) {
1391   float S = 0;
1392   float Sx = 0;
1393   float Sy = 0;
1394   float Sxx = 0;
1395   float Sxy = 0;
1396   float sigma2 = 0;
1397 
1398   for (int i = 1; i < 7; i++) {
1399     if (i != 3) {
1400       sigma2 = errors(i, 1) * errors(i, 1);
1401       S = S + (1 / sigma2);
1402       Sy = Sy + (points(i, 1) / sigma2);
1403       Sx = Sx + ((i) / sigma2);
1404       Sxx = Sxx + (i * i) / sigma2;
1405       Sxy = Sxy + (((i)*points(i, 1)) / sigma2);
1406     }
1407   }
1408 
1409   float delta = S * Sxx - Sx * Sx;
1410   float intercept = (Sxx * Sy - Sx * Sxy) / delta;
1411   float slope = (S * Sxy - Sx * Sy) / delta;
1412 
1413   return (intercept + slope * 3);
1414 }
1415 
1416 //---------------------------------------------------------------------------------------
1417 // Given a set of digis, the CSCDetId, and the central strip of your choosing, returns
1418 // the avg. Signal-Pedestal for 6 time bin x 5 strip .
1419 //
1420 // Author: P. Jindal
1421 //---------------------------------------------------------------------------------------
1422 
1423 float CSCOfflineMonitor::getSignal(const CSCStripDigiCollection& stripdigis, CSCDetId idCS, int centerStrip) {
1424   float SigADC[5];
1425   float TotalADC = 0;
1426   SigADC[0] = 0;
1427   SigADC[1] = 0;
1428   SigADC[2] = 0;
1429   SigADC[3] = 0;
1430   SigADC[4] = 0;
1431 
1432   // Loop over strip digis
1433   CSCStripDigiCollection::DigiRangeIterator sIt;
1434 
1435   for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++) {
1436     CSCDetId id = (CSCDetId)(*sIt).first;
1437     if (id == idCS) {
1438       // First, find the Signal-Pedestal for center strip
1439       vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
1440       vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
1441       for (; digiItr != last; ++digiItr) {
1442         int thisStrip = digiItr->getStrip();
1443         if (thisStrip == (centerStrip)) {
1444           std::vector<int> myADCVals = digiItr->getADCCounts();
1445           float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1446           float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1447           SigADC[0] = thisSignal - 6 * thisPedestal;
1448         }
1449         // Now,find the Signal-Pedestal for neighbouring 4 strips
1450         if (thisStrip == (centerStrip + 1)) {
1451           std::vector<int> myADCVals = digiItr->getADCCounts();
1452           float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1453           float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1454           SigADC[1] = thisSignal - 6 * thisPedestal;
1455         }
1456         if (thisStrip == (centerStrip + 2)) {
1457           std::vector<int> myADCVals = digiItr->getADCCounts();
1458           float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1459           float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1460           SigADC[2] = thisSignal - 6 * thisPedestal;
1461         }
1462         if (thisStrip == (centerStrip - 1)) {
1463           std::vector<int> myADCVals = digiItr->getADCCounts();
1464           float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1465           float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1466           SigADC[3] = thisSignal - 6 * thisPedestal;
1467         }
1468         if (thisStrip == (centerStrip - 2)) {
1469           std::vector<int> myADCVals = digiItr->getADCCounts();
1470           float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1471           float thisSignal = (myADCVals[2] + myADCVals[3] + myADCVals[4] + myADCVals[5] + myADCVals[6] + myADCVals[7]);
1472           SigADC[4] = thisSignal - 6 * thisPedestal;
1473         }
1474       }
1475       TotalADC = 0.2 * (SigADC[0] + SigADC[1] + SigADC[2] + SigADC[3] + SigADC[4]);
1476     }
1477   }
1478   return TotalADC;
1479 }
1480 
1481 //----------------------------------------------------------------------------
1482 // Calculate basic efficiencies for recHits and Segments
1483 // Author: S. Stoynev
1484 //----------------------------------------------------------------------------
1485 
1486 void CSCOfflineMonitor::doEfficiencies(edm::Handle<CSCWireDigiCollection> wires,
1487                                        edm::Handle<CSCStripDigiCollection> strips,
1488                                        edm::Handle<CSCRecHit2DCollection> recHits,
1489                                        edm::Handle<CSCSegmentCollection> cscSegments,
1490                                        edm::ESHandle<CSCGeometry> cscGeom) {
1491   bool allWires[2][4][4][36][6];
1492   bool allStrips[2][4][4][36][6];
1493   bool AllRecHits[2][4][4][36][6];
1494   bool AllSegments[2][4][4][36];
1495 
1496   //bool MultiSegments[2][4][4][36];
1497   for (int iE = 0; iE < 2; iE++) {
1498     for (int iS = 0; iS < 4; iS++) {
1499       for (int iR = 0; iR < 4; iR++) {
1500         for (int iC = 0; iC < 36; iC++) {
1501           AllSegments[iE][iS][iR][iC] = false;
1502           //MultiSegments[iE][iS][iR][iC] = false;
1503           for (int iL = 0; iL < 6; iL++) {
1504             allWires[iE][iS][iR][iC][iL] = false;
1505             allStrips[iE][iS][iR][iC][iL] = false;
1506             AllRecHits[iE][iS][iR][iC][iL] = false;
1507           }
1508         }
1509       }
1510     }
1511   }
1512 
1513   // Wires
1514   for (CSCWireDigiCollection::DigiRangeIterator dWDiter = wires->begin(); dWDiter != wires->end(); dWDiter++) {
1515     CSCDetId idrec = (CSCDetId)(*dWDiter).first;
1516     std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
1517     std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
1518     for (; wireIter != lWire; ++wireIter) {
1519       allWires[idrec.endcap() - 1][idrec.station() - 1][idrec.ring() - 1][idrec.chamber() - 1][idrec.layer() - 1] =
1520           true;
1521       break;
1522     }
1523   }
1524 
1525   //---- STRIPS
1526   for (CSCStripDigiCollection::DigiRangeIterator dSDiter = strips->begin(); dSDiter != strips->end(); dSDiter++) {
1527     CSCDetId idrec = (CSCDetId)(*dSDiter).first;
1528     std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
1529     std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
1530     for (; stripIter != lStrip; ++stripIter) {
1531       std::vector<int> myADCVals = stripIter->getADCCounts();
1532       bool thisStripFired = false;
1533       float thisPedestal = 0.5 * (float)(myADCVals[0] + myADCVals[1]);
1534       float threshold = 13.3;
1535       float diff = 0.;
1536       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
1537         diff = (float)myADCVals[iCount] - thisPedestal;
1538         if (diff > threshold) {
1539           thisStripFired = true;
1540           break;
1541         }
1542       }
1543       if (thisStripFired) {
1544         allStrips[idrec.endcap() - 1][idrec.station() - 1][idrec.ring() - 1][idrec.chamber() - 1][idrec.layer() - 1] =
1545             true;
1546         break;
1547       }
1548     }
1549   }
1550 
1551   // Rechits
1552   for (CSCRecHit2DCollection::const_iterator recEffIt = recHits->begin(); recEffIt != recHits->end(); recEffIt++) {
1553     //CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
1554     CSCDetId idrec = (CSCDetId)(*recEffIt).cscDetId();
1555     AllRecHits[idrec.endcap() - 1][idrec.station() - 1][idrec.ring() - 1][idrec.chamber() - 1][idrec.layer() - 1] =
1556         true;
1557   }
1558 
1559   std::vector<uint> seg_ME2(2, 0);
1560   std::vector<uint> seg_ME3(2, 0);
1561   std::vector<pair<CSCDetId, CSCSegment> > theSegments(4);
1562   // Segments
1563   for (CSCSegmentCollection::const_iterator segEffIt = cscSegments->begin(); segEffIt != cscSegments->end();
1564        segEffIt++) {
1565     CSCDetId idseg = (CSCDetId)(*segEffIt).cscDetId();
1566     //if(AllSegments[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber()]){
1567     //MultiSegments[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber()] = true;
1568     //}
1569     AllSegments[idseg.endcap() - 1][idseg.station() - 1][idseg.ring() - 1][idseg.chamber() - 1] = true;
1570     // "Intrinsic" efficiency measurement relies on "good" segment extrapolation - we need the pre-selection below
1571     // station 2 "good" segment will be used for testing efficiencies in ME1 and ME3
1572     // station 3 "good" segment will be used for testing efficiencies in ME2 and ME4
1573     if (2 == idseg.station() || 3 == idseg.station()) {
1574       uint seg_tmp;
1575       if (2 == idseg.station()) {
1576         ++seg_ME2[idseg.endcap() - 1];
1577         seg_tmp = seg_ME2[idseg.endcap() - 1];
1578       } else {
1579         ++seg_ME3[idseg.endcap() - 1];
1580         seg_tmp = seg_ME3[idseg.endcap() - 1];
1581       }
1582       // is the segment good
1583       if (1 == seg_tmp && 6 == (*segEffIt).nRecHits() && (*segEffIt).chi2() / (*segEffIt).degreesOfFreedom() < 3.) {
1584         pair<CSCDetId, CSCSegment> specSeg = make_pair((CSCDetId)(*segEffIt).cscDetId(), *segEffIt);
1585         theSegments[2 * (idseg.endcap() - 1) + (idseg.station() - 2)] = specSeg;
1586       }
1587     }
1588     /*
1589     if(2==idseg.station()){
1590     ++seg_ME2[idseg.endcap() -1];
1591        if(1==seg_ME2[idseg.endcap() -1] && 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
1592            pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
1593            theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
1594        }
1595     }
1596     else if(3==idseg.station()){
1597     ++seg_ME3[idseg.endcap() -1];
1598     if(1==seg_ME3[idseg.endcap() -1] && 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
1599          pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
1600      theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
1601        }
1602     }
1603     */
1604   }
1605   // Simple efficiency calculations
1606   for (int iE = 0; iE < 2; iE++) {
1607     for (int iS = 0; iS < 4; iS++) {
1608       for (int iR = 0; iR < 4; iR++) {
1609         for (int iC = 0; iC < 36; iC++) {
1610           int NumberOfLayers = 0;
1611           for (int iL = 0; iL < 6; iL++) {
1612             if (AllRecHits[iE][iS][iR][iC][iL]) {
1613               NumberOfLayers++;
1614             }
1615           }
1616 
1617           // set bin = 1-10 for ME-42, ME-41,...ME-11B, ME-11A,
1618           //           11-20 for ME+11A, ME+11B, ... ME+41, ME+42
1619           int bin = CSCDetId::iChamberType(iS + 1, iR + 1);  // 1-10 for ME11A...ME42
1620           if (iE > 0) {                                      // in this loop iE=1 is -z endcap
1621             bin = 11 - bin;
1622           } else {  // in this loop iE=0 is +z endcap
1623             bin += 10;
1624           }
1625 
1626           if (NumberOfLayers > 1) {
1627             //if(!(MultiSegments[iE][iS][iR][iC])){
1628             if (AllSegments[iE][iS][iR][iC]) {
1629               //---- Efficient segment evenents
1630               hSnum->Fill(bin);
1631             }
1632             //---- All segment events (normalization)
1633             hSden->Fill(bin);
1634             //}
1635           }
1636           if (AllSegments[iE][iS][iR][iC]) {
1637             if (NumberOfLayers == 6) {
1638               //---- Efficient rechit events
1639               hRHnum->Fill(bin);
1640               ;
1641             }
1642             //---- All rechit events (normalization)
1643             hRHden->Fill(bin);
1644             ;
1645           }
1646         }
1647       }
1648     }
1649   }
1650 
1651   // pick a segment only if there are no others in the station
1652   std::vector<pair<CSCDetId, CSCSegment>*> theSeg;
1653   if (1 == seg_ME2[0])
1654     theSeg.push_back(&theSegments[0]);
1655   if (1 == seg_ME3[0])
1656     theSeg.push_back(&theSegments[1]);
1657   if (1 == seg_ME2[1])
1658     theSeg.push_back(&theSegments[2]);
1659   if (1 == seg_ME3[1])
1660     theSeg.push_back(&theSegments[3]);
1661 
1662   if (!theSeg.empty()) {
1663     std::map<int, GlobalPoint> extrapolatedPoint;
1664     std::map<int, GlobalPoint>::iterator it;
1665     const CSCGeometry::ChamberContainer& ChamberContainer = cscGeom->chambers();
1666     // Pick which chamber with which segment to test
1667     for (unsigned int nCh = 0; nCh < ChamberContainer.size(); nCh++) {
1668       const CSCChamber* cscchamber = ChamberContainer[nCh];
1669       pair<CSCDetId, CSCSegment>* thisSegment = nullptr;
1670       for (uint iSeg = 0; iSeg < theSeg.size(); ++iSeg) {
1671         if (cscchamber->id().endcap() == theSeg[iSeg]->first.endcap()) {
1672           if (1 == cscchamber->id().station() || 3 == cscchamber->id().station()) {
1673             if (2 == theSeg[iSeg]->first.station()) {
1674               thisSegment = theSeg[iSeg];
1675             }
1676           } else if (2 == cscchamber->id().station() || 4 == cscchamber->id().station()) {
1677             if (3 == theSeg[iSeg]->first.station()) {
1678               thisSegment = theSeg[iSeg];
1679             }
1680           }
1681         }
1682       }
1683       // this chamber is to be tested with thisSegment
1684       if (thisSegment) {
1685         CSCSegment* seg = &(thisSegment->second);
1686         const CSCChamber* segChamber = cscGeom->chamber(thisSegment->first);
1687         LocalPoint localCenter(0., 0., 0);
1688         GlobalPoint cscchamberCenter = cscchamber->toGlobal(localCenter);
1689         // try to save some time (extrapolate a segment to a certain position only once)
1690         it = extrapolatedPoint.find(int(cscchamberCenter.z()));
1691         if (it == extrapolatedPoint.end()) {
1692           GlobalPoint segPos = segChamber->toGlobal(seg->localPosition());
1693           GlobalVector segDir = segChamber->toGlobal(seg->localDirection());
1694           double paramaterLine = lineParametrization(segPos.z(), cscchamberCenter.z(), segDir.z());
1695           double xExtrapolated = extrapolate1D(segPos.x(), segDir.x(), paramaterLine);
1696           double yExtrapolated = extrapolate1D(segPos.y(), segDir.y(), paramaterLine);
1697           GlobalPoint globP(xExtrapolated, yExtrapolated, cscchamberCenter.z());
1698           extrapolatedPoint[int(cscchamberCenter.z())] = globP;
1699         }
1700         // Where does the extrapolated point lie in the (tested) chamber local frame? Here:
1701         LocalPoint extrapolatedPointLocal = cscchamber->toLocal(extrapolatedPoint[int(cscchamberCenter.z())]);
1702         const CSCLayer* layer_p = cscchamber->layer(1);  //layer 1
1703         const CSCLayerGeometry* layerGeom = layer_p->geometry();
1704         const std::array<const float, 4>& layerBounds = layerGeom->parameters();
1705         float shiftFromEdge = 15.;  //cm
1706         float shiftFromDeadZone = 10.;
1707         // is the extrapolated point within a sensitive region
1708         bool pass = withinSensitiveRegion(extrapolatedPointLocal,
1709                                           layerBounds,
1710                                           cscchamber->id().station(),
1711                                           cscchamber->id().ring(),
1712                                           shiftFromEdge,
1713                                           shiftFromDeadZone);
1714         if (pass) {  // the extrapolation point of the segment lies within sensitive region of that chamber
1715           // how many rechit layers are there in the chamber?
1716           // 0 - maybe the muon died or is deflected at large angle? do not use that case
1717           // 1 - could be noise...
1718           // 2 or more - this is promissing; this is our definition of a reliable signal; use it below
1719           // is other definition better?
1720           int nRHLayers = 0;
1721           for (int iL = 0; iL < 6; ++iL) {
1722             if (AllRecHits[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1723                           [cscchamber->id().chamber() - 1][iL]) {
1724               ++nRHLayers;
1725             }
1726           }
1727 
1728           // set verticalScale to 1-10 for ME-42...ME-11A,
1729           //                     11-20 for ME+11A...ME+42
1730           float verticalScale =
1731               9. + cscchamber->id().endcap() + (cscchamber->specs()->chamberType()) * (cscchamber->id().zendcap());
1732 
1733           hSensitiveAreaEvt->Fill(float(cscchamber->id().chamber()), verticalScale);
1734           if (nRHLayers > 1) {  // this chamber contains a reliable signal
1735             // this is the denominator for all efficiencies
1736             hEffDenominator->Fill(float(cscchamber->id().chamber()), verticalScale);
1737             // Segment efficiency
1738             if (AllSegments[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1739                            [cscchamber->id().chamber() - 1]) {
1740               hSSTE2->Fill(float(cscchamber->id().chamber()), float(verticalScale));
1741             }
1742 
1743             for (int iL = 0; iL < 6; ++iL) {
1744               float weight = 1. / 6.;
1745               // should account for the weight in the efficiency...
1746               // Rechit efficiency
1747               if (AllRecHits[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1748                             [cscchamber->id().chamber() - 1][iL]) {
1749                 hRHSTE2->Fill(float(cscchamber->id().chamber()), float(verticalScale), weight);
1750               }
1751               // Wire efficiency
1752               if (allWires[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1753                           [cscchamber->id().chamber() - 1][iL]) {
1754                 // one shold account for the weight in the efficiency...
1755                 hWireSTE2->Fill(float(cscchamber->id().chamber()), float(verticalScale), weight);
1756               }
1757               // Strip efficiency
1758               if (allStrips[cscchamber->id().endcap() - 1][cscchamber->id().station() - 1][cscchamber->id().ring() - 1]
1759                            [cscchamber->id().chamber() - 1][iL]) {
1760                 // one shold account for the weight in the efficiency...
1761                 hStripSTE2->Fill(float(cscchamber->id().chamber()), float(verticalScale), weight);
1762               }
1763             }
1764           }
1765         }
1766       }
1767     }
1768   }
1769   //
1770 }
1771 
1772 // ==============================================
1773 //
1774 // Look at BX level trigger synchronization
1775 //
1776 // ==============================================
1777 
1778 void CSCOfflineMonitor::doBXMonitor(edm::Handle<CSCALCTDigiCollection> alcts,
1779                                     edm::Handle<CSCCLCTDigiCollection> clcts,
1780                                     const edm::Event& event,
1781                                     const edm::EventSetup& eventSetup) {
1782   // Loop over ALCTDigis
1783 
1784   for (CSCALCTDigiCollection::DigiRangeIterator j = alcts->begin(); j != alcts->end(); j++) {
1785     const CSCDetId& idALCT = (*j).first;
1786     const CSCALCTDigiCollection::Range& range = (*j).second;
1787     for (CSCALCTDigiCollection::const_iterator digiIt = range.first; digiIt != range.second; ++digiIt) {
1788       // Valid digi in the chamber (or in neighbouring chamber)
1789       if ((*digiIt).isValid()) {
1790         hALCTgetBX->Fill((*digiIt).getBX());
1791         hALCTgetBXSerial->Fill(chamberSerial(idALCT), (*digiIt).getBX());
1792         hALCTgetBX2DNumerator->Fill(idALCT.chamber(), typeIndex(idALCT, 2), (*digiIt).getBX());
1793         hALCTgetBX2Denominator->Fill(idALCT.chamber(), typeIndex(idALCT, 2));
1794       }
1795     }
1796   }  // end ALCT Digi loop
1797 
1798   // Loop over raw data to get TMBHeader information
1799   // Taking code from EventFilter/CSCRawToDigis/CSCDCCUnpacker.cc
1800   edm::ESHandle<CSCCrateMap> hcrate;
1801 
1802   hcrate = eventSetup.getHandle(hcrateToken_);
1803 
1804   const CSCCrateMap* pcrate = hcrate.product();
1805 
1806   // Try to get raw data
1807   edm::Handle<FEDRawDataCollection> rawdata;
1808   if (!(event.getByToken(rd_token, rawdata))) {
1809     edm::LogWarning("CSCOfflineMonitor") << " FEDRawDataCollection not available";
1810     return;
1811   }
1812 
1813   bool goodEvent = false;
1814   unsigned long dccBinCheckMask = 0x06080016;
1815   unsigned int examinerMask = 0x1FEBF3F6;
1816   unsigned int errorMask = 0x0;
1817 
1818   // For new CSC readout layout, which doesn't include DCCs need to loop over DDU FED IDs.
1819   // DCC IDs are included for backward compatibility with old data
1820   std::vector<unsigned int> cscFEDids;
1821 
1822   for (unsigned int id = FEDNumbering::MINCSCFEDID; id <= FEDNumbering::MAXCSCFEDID; ++id)  // loop over DCCs
1823   {
1824     cscFEDids.push_back(id);
1825   }
1826 
1827   for (unsigned int id = FEDNumbering::MINCSCDDUFEDID; id <= FEDNumbering::MAXCSCDDUFEDID; ++id)  // loop over DDUs
1828   {
1829     cscFEDids.push_back(id);
1830   }
1831 
1832   for (unsigned int i = 0; i < cscFEDids.size(); i++)  // loop over all CSC FEDs (DCCs and DDUs)
1833   {
1834     unsigned int id = cscFEDids[i];
1835     bool isDDU_FED = ((id >= FEDNumbering::MINCSCDDUFEDID) && (id <= FEDNumbering::MAXCSCDDUFEDID)) ? true : false;
1836 
1837     /// uncomment this for regional unpacking
1838     /// if (id!=SOME_ID) continue;
1839 
1840     /// Take a reference to this FED's data
1841     const FEDRawData& fedData = rawdata->FEDData(id);
1842     unsigned long length = fedData.size();
1843 
1844     if (length >= 32) {  ///if fed has data then unpack it
1845       CSCDCCExaminer* examiner = nullptr;
1846       std::stringstream examiner_out, examiner_err;
1847       examiner = new CSCDCCExaminer();
1848       if (examinerMask & 0x40000)
1849         examiner->crcCFEB(true);
1850       if (examinerMask & 0x8000)
1851         examiner->crcTMB(true);
1852       if (examinerMask & 0x0400)
1853         examiner->crcALCT(true);
1854       examiner->setMask(examinerMask);
1855       const short unsigned int* data = (short unsigned int*)fedData.data();
1856 
1857       int res = examiner->check(data, long(fedData.size() / 2));
1858       if (res < 0) {
1859         goodEvent = false;
1860       } else {
1861         goodEvent = !(examiner->errors() & dccBinCheckMask);
1862       }
1863 
1864       if (goodEvent) {
1865         ///get a pointer to data and pass it to constructor for unpacking
1866 
1867         CSCDCCExaminer* ptrExaminer = examiner;
1868 
1869         std::vector<CSCDDUEventData> fed_Data;
1870         std::vector<CSCDDUEventData>* ptr_fedData = &fed_Data;
1871 
1872         if (isDDU_FED)  // Use new DDU FED readout mode
1873         {
1874           CSCDDUEventData single_dduData((short unsigned int*)fedData.data(), ptrExaminer);
1875           fed_Data.push_back(single_dduData);
1876 
1877         } else  // Use old DCC FED readout mode
1878         {
1879           CSCDCCEventData dccData((short unsigned int*)fedData.data(), ptrExaminer);
1880           fed_Data = dccData.dduData();
1881         }
1882 
1883         ///get a reference to dduData
1884         const std::vector<CSCDDUEventData>& dduData = *ptr_fedData;
1885 
1886         /// set default detid to that for E=+z, S=1, R=1, C=1, L=1
1887         CSCDetId layer(1, 1, 1, 1, 1);
1888         for (unsigned int iDDU = 0; iDDU < dduData.size(); ++iDDU) {  // loop over DDUs
1889           /// skip the DDU if its data has serious errors
1890           /// define a mask for serious errors
1891           if (dduData[iDDU].trailer().errorstat() & errorMask) {
1892             LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "DDU# " << iDDU << " has serious error - no digis unpacked! "
1893                                                     << std::hex << dduData[iDDU].trailer().errorstat();
1894             continue;  // to next iteration of DDU loop
1895           }
1896 
1897           ///get a reference to chamber data
1898           const std::vector<CSCEventData>& cscData = dduData[iDDU].cscData();
1899 
1900           for (unsigned int iCSC = 0; iCSC < cscData.size(); ++iCSC) {  // loop over CSCs
1901 
1902             ///first process chamber-wide digis such as LCT
1903             int vmecrate = cscData[iCSC].dmbHeader()->crateID();
1904             int dmb = cscData[iCSC].dmbHeader()->dmbID();
1905 
1906             int icfeb = 0;   /// default value for all digis not related to cfebs
1907             int ilayer = 0;  /// layer=0 flags entire chamber
1908 
1909             if ((vmecrate >= 1) && (vmecrate <= 60) && (dmb >= 1) && (dmb <= 10) && (dmb != 6)) {
1910               layer = pcrate->detId(vmecrate, dmb, icfeb, ilayer);
1911             } else {
1912               LogTrace("CSCOfflineMonitor") << " detID input out of range!!! ";
1913               LogTrace("CSCOfflineMonitor") << " skipping chamber vme= " << vmecrate << " dmb= " << dmb;
1914               continue;  // to next iteration of iCSC loop
1915             }
1916 
1917             /// check alct data integrity
1918             int nalct = cscData[iCSC].dmbHeader()->nalct();
1919             bool goodALCT = false;
1920             //if (nalct&&(cscData[iCSC].dataPresent>>6&0x1)==1) {
1921             if (nalct && cscData[iCSC].alctHeader()) {
1922               if (cscData[iCSC].alctHeader()->check()) {
1923                 goodALCT = true;
1924               }
1925             }
1926 
1927             ///check tmb data integrity
1928             int nclct = cscData[iCSC].dmbHeader()->nclct();
1929             bool goodTMB = false;
1930             if (nclct && cscData[iCSC].tmbData()) {
1931               if (cscData[iCSC].tmbHeader()->check()) {
1932                 if (cscData[iCSC].comparatorData()->check())
1933                   goodTMB = true;
1934               }
1935             }
1936 
1937             if (goodTMB && goodALCT) {
1938               const CSCTMBHeader* tmbHead = cscData[iCSC].tmbHeader();
1939               std::vector<CSCCLCTDigi> clcts = cscData[iCSC].tmbHeader()->CLCTDigis(layer.rawId());
1940               if (clcts.empty() || !(clcts[0].isValid()))
1941                 continue;
1942               // Check if the CLCT was in ME11a (ring 4)
1943               if (layer.station() == 1 && layer.ring() == 1 && clcts[0].getKeyStrip() > 128) {
1944                 layer = CSCDetId(layer.endcap(), layer.station(), 4, layer.chamber());
1945               }
1946               hALCTMatch->Fill(tmbHead->ALCTMatchTime());
1947               hALCTMatchSerial->Fill(chamberSerial(layer), tmbHead->ALCTMatchTime());
1948               // Only fill big 2D display if ALCTMatchTime !=6, since this bin is polluted by the CLCT only triggers
1949               // One will have to look at the serial plots to see if the are a lot of entries here
1950               if (tmbHead->ALCTMatchTime() != 6) {
1951                 hALCTMatch2DNumerator->Fill(layer.chamber(), typeIndex(layer, 2), tmbHead->ALCTMatchTime());
1952                 hALCTMatch2Denominator->Fill(layer.chamber(), typeIndex(layer, 2));
1953               }
1954 
1955               int TMB_CLCTpre_rel_L1A = tmbHead->BXNCount() - clcts[0].getFullBX();
1956               if (TMB_CLCTpre_rel_L1A > 3563)
1957                 TMB_CLCTpre_rel_L1A = TMB_CLCTpre_rel_L1A - 3564;
1958               if (TMB_CLCTpre_rel_L1A < 0)
1959                 TMB_CLCTpre_rel_L1A = TMB_CLCTpre_rel_L1A + 3564;
1960 
1961               hCLCTL1A->Fill(TMB_CLCTpre_rel_L1A);
1962               hCLCTL1ASerial->Fill(chamberSerial(layer), TMB_CLCTpre_rel_L1A);
1963               hCLCTL1A2DNumerator->Fill(layer.chamber(), typeIndex(layer, 2), TMB_CLCTpre_rel_L1A);
1964               hCLCTL1A2Denominator->Fill(layer.chamber(), typeIndex(layer, 2));
1965 
1966             }  // end if goodTMB and goodALCT
1967           }  // end loop CSCData
1968         }  // end loop DDU
1969       }  // end if good event
1970       if (examiner != nullptr)
1971         delete examiner;
1972     }  // end if non-zero fed data
1973   }  // end DCC loop for NON-REFERENCE
1974 
1975   return;
1976 }
1977 
1978 bool CSCOfflineMonitor::withinSensitiveRegion(LocalPoint localPos,
1979                                               const std::array<const float, 4>& layerBounds,
1980                                               int station,
1981                                               int ring,
1982                                               float shiftFromEdge,
1983                                               float shiftFromDeadZone) {
1984   //---- check if it is in a good local region (sensitive area - geometrical and HV boundaries excluded)
1985   bool pass = false;
1986 
1987   float y_center = 0.;
1988   double yUp = layerBounds[3] + y_center;
1989   double yDown = -layerBounds[3] + y_center;
1990   double xBound1Shifted = layerBounds[0] - shiftFromEdge;  //
1991   double xBound2Shifted = layerBounds[1] - shiftFromEdge;  //
1992   double lineSlope = (yUp - yDown) / (xBound2Shifted - xBound1Shifted);
1993   double lineConst = yUp - lineSlope * xBound2Shifted;
1994   double yBorder = lineSlope * abs(localPos.x()) + lineConst;
1995 
1996   //bool withinChamberOnly = false;// false = "good region"; true - boundaries only
1997   std::vector<float> deadZoneCenter(6);
1998   float cutZone = shiftFromDeadZone;  //cm
1999   //---- hardcoded... not good
2000   if (station > 1 && station < 5) {
2001     if (2 == ring) {
2002       deadZoneCenter[0] = -162.48;
2003       deadZoneCenter[1] = -81.8744;
2004       deadZoneCenter[2] = -21.18165;
2005       deadZoneCenter[3] = 39.51105;
2006       deadZoneCenter[4] = 100.2939;
2007       deadZoneCenter[5] = 160.58;
2008 
2009       if (localPos.y() > yBorder &&
2010           ((localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone) ||
2011            (localPos.y() > deadZoneCenter[1] + cutZone && localPos.y() < deadZoneCenter[2] - cutZone) ||
2012            (localPos.y() > deadZoneCenter[2] + cutZone && localPos.y() < deadZoneCenter[3] - cutZone) ||
2013            (localPos.y() > deadZoneCenter[3] + cutZone && localPos.y() < deadZoneCenter[4] - cutZone) ||
2014            (localPos.y() > deadZoneCenter[4] + cutZone && localPos.y() < deadZoneCenter[5] - cutZone))) {
2015         pass = true;
2016       }
2017     } else if (1 == ring) {
2018       if (2 == station) {
2019         deadZoneCenter[0] = -95.80;
2020         deadZoneCenter[1] = -27.47;
2021         deadZoneCenter[2] = 33.67;
2022         deadZoneCenter[3] = 90.85;
2023       } else if (3 == station) {
2024         deadZoneCenter[0] = -89.305;
2025         deadZoneCenter[1] = -39.705;
2026         deadZoneCenter[2] = 20.195;
2027         deadZoneCenter[3] = 77.395;
2028       } else if (4 == station) {
2029         deadZoneCenter[0] = -75.645;
2030         deadZoneCenter[1] = -26.055;
2031         deadZoneCenter[2] = 23.855;
2032         deadZoneCenter[3] = 70.575;
2033       }
2034       if (localPos.y() > yBorder &&
2035           ((localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone) ||
2036            (localPos.y() > deadZoneCenter[1] + cutZone && localPos.y() < deadZoneCenter[2] - cutZone) ||
2037            (localPos.y() > deadZoneCenter[2] + cutZone && localPos.y() < deadZoneCenter[3] - cutZone))) {
2038         pass = true;
2039       }
2040     }
2041   } else if (1 == station) {
2042     if (3 == ring) {
2043       deadZoneCenter[0] = -83.155;
2044       deadZoneCenter[1] = -22.7401;
2045       deadZoneCenter[2] = 27.86665;
2046       deadZoneCenter[3] = 81.005;
2047       if (localPos.y() > yBorder &&
2048           ((localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone) ||
2049            (localPos.y() > deadZoneCenter[1] + cutZone && localPos.y() < deadZoneCenter[2] - cutZone) ||
2050            (localPos.y() > deadZoneCenter[2] + cutZone && localPos.y() < deadZoneCenter[3] - cutZone))) {
2051         pass = true;
2052       }
2053     } else if (2 == ring) {
2054       deadZoneCenter[0] = -86.285;
2055       deadZoneCenter[1] = -32.88305;
2056       deadZoneCenter[2] = 32.867423;
2057       deadZoneCenter[3] = 88.205;
2058       if (localPos.y() > (yBorder) &&
2059           ((localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone) ||
2060            (localPos.y() > deadZoneCenter[1] + cutZone && localPos.y() < deadZoneCenter[2] - cutZone) ||
2061            (localPos.y() > deadZoneCenter[2] + cutZone && localPos.y() < deadZoneCenter[3] - cutZone))) {
2062         pass = true;
2063       }
2064     } else {
2065       deadZoneCenter[0] = -81.0;
2066       deadZoneCenter[1] = 81.0;
2067       if (localPos.y() > (yBorder) &&
2068           (localPos.y() > deadZoneCenter[0] + cutZone && localPos.y() < deadZoneCenter[1] - cutZone)) {
2069         pass = true;
2070       }
2071     }
2072   }
2073   return pass;
2074 }
2075 
2076 int CSCOfflineMonitor::typeIndex(CSCDetId id, int flag) {
2077   // linearized index based on endcap, station, and ring
2078 
2079   if (flag == 1) {
2080     int index = 0;
2081     if (id.station() == 1)
2082       index = id.ring();
2083     else
2084       index = id.station() * 2 + id.ring();
2085     if (id.endcap() == 1)
2086       index = index + 10;
2087     if (id.endcap() == 2)
2088       index = 11 - index;
2089     return index;
2090   }
2091 
2092   else if (flag == 2) {
2093     int index = 0;
2094     if (id.station() == 1 && id.ring() != 4)
2095       index = id.ring() + 1;
2096     if (id.station() == 1 && id.ring() == 4)
2097       index = 1;
2098     if (id.station() != 1)
2099       index = id.station() * 2 + id.ring();
2100     if (id.endcap() == 1)
2101       index = index + 10;
2102     if (id.endcap() == 2)
2103       index = 11 - index;
2104     return index;
2105   }
2106 
2107   else
2108     return 0;
2109 }
2110 
2111 int CSCOfflineMonitor::chamberSerial(CSCDetId id) {
2112   int st = id.station();
2113   int ri = id.ring();
2114   int ch = id.chamber();
2115   int ec = id.endcap();
2116   int kSerial = ch;
2117   if (st == 1 && ri == 1)
2118     kSerial = ch;
2119   if (st == 1 && ri == 2)
2120     kSerial = ch + 36;
2121   if (st == 1 && ri == 3)
2122     kSerial = ch + 72;
2123   if (st == 1 && ri == 4)
2124     kSerial = ch;
2125   if (st == 2 && ri == 1)
2126     kSerial = ch + 108;
2127   if (st == 2 && ri == 2)
2128     kSerial = ch + 126;
2129   if (st == 3 && ri == 1)
2130     kSerial = ch + 162;
2131   if (st == 3 && ri == 2)
2132     kSerial = ch + 180;
2133   if (st == 4 && ri == 1)
2134     kSerial = ch + 216;
2135   if (st == 4 && ri == 2)
2136     kSerial = ch + 234;  // from 2014
2137   if (ec == 2)
2138     kSerial = kSerial + 300;
2139   return kSerial;
2140 }
2141 
2142 void CSCOfflineMonitor::applyCSClabels(MonitorElement* me, LabelType t, AxisType a) {
2143   if (me != nullptr) {
2144     me->setAxisTitle("Chamber #");
2145     if (t == EXTENDED) {
2146       me->setBinLabel(1, "ME -4/2", a);
2147       me->setBinLabel(2, "ME -4/1", a);
2148       me->setBinLabel(3, "ME -3/2", a);
2149       me->setBinLabel(4, "ME -3/1", a);
2150       me->setBinLabel(5, "ME -2/2", a);
2151       me->setBinLabel(6, "ME -2/1", a);
2152       me->setBinLabel(7, "ME -1/3", a);
2153       me->setBinLabel(8, "ME -1/2", a);
2154       me->setBinLabel(9, "ME -1/1b", a);
2155       me->setBinLabel(10, "ME -1/1a", a);
2156       me->setBinLabel(11, "ME +1/1a", a);
2157       me->setBinLabel(12, "ME +1/1b", a);
2158       me->setBinLabel(13, "ME +1/2", a);
2159       me->setBinLabel(14, "ME +1/3", a);
2160       me->setBinLabel(15, "ME +2/1", a);
2161       me->setBinLabel(16, "ME +2/2", a);
2162       me->setBinLabel(17, "ME +3/1", a);
2163       me->setBinLabel(18, "ME +3/2", a);
2164       me->setBinLabel(19, "ME +4/1", a);
2165       me->setBinLabel(20, "ME +4/2", a);
2166     } else if (t == SMALL) {
2167       me->setBinLabel(1, "ME -4/1", a);
2168       me->setBinLabel(2, "ME -3/2", a);
2169       me->setBinLabel(3, "ME -3/1", a);
2170       me->setBinLabel(4, "ME -2/2", a);
2171       me->setBinLabel(5, "ME -2/1", a);
2172       me->setBinLabel(6, "ME -1/3", a);
2173       me->setBinLabel(7, "ME -1/2", a);
2174       me->setBinLabel(8, "ME -1/1b", a);
2175       me->setBinLabel(9, "ME -1/1a", a);
2176       me->setBinLabel(10, "ME +1/1a", a);
2177       me->setBinLabel(11, "ME +1/1b", a);
2178       me->setBinLabel(12, "ME +1/2", a);
2179       me->setBinLabel(13, "ME +1/3", a);
2180       me->setBinLabel(14, "ME +2/1", a);
2181       me->setBinLabel(15, "ME +2/2", a);
2182       me->setBinLabel(16, "ME +3/1", a);
2183       me->setBinLabel(17, "ME +3/2", a);
2184       me->setBinLabel(18, "ME +4/1", a);
2185     }
2186   }
2187 }
2188 
2189 DEFINE_FWK_MODULE(CSCOfflineMonitor);