CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DQMOffline/Muon/src/CSCOfflineMonitor.cc

Go to the documentation of this file.
00001 /*
00002  *  Offline DQM module for CSC local reconstruction.
00003  *
00004  *  Andy Kubik
00005  *  Northwestern University
00006  */
00007 
00008 #include "DQMOffline/Muon/src/CSCOfflineMonitor.h"
00009 
00010 using namespace std;
00011 using namespace edm;
00012 
00013 
00015 //  CONSTRUCTOR  //
00017 CSCOfflineMonitor::CSCOfflineMonitor(const ParameterSet& pset){
00018 
00019   param = pset;
00020 
00021   stripDigiTag_  = pset.getParameter<edm::InputTag>("stripDigiTag");
00022   wireDigiTag_   = pset.getParameter<edm::InputTag>("wireDigiTag"); 
00023   cscRecHitTag_  = pset.getParameter<edm::InputTag>("cscRecHitTag");
00024   cscSegTag_     = pset.getParameter<edm::InputTag>("cscSegTag");
00025 
00026 }
00027 
00028 void CSCOfflineMonitor::beginJob(void){
00029       dbe = Service<DQMStore>().operator->();
00030 
00031       // Occupancies
00032       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Occupancy");
00033       hCSCOccupancy = dbe->book1D("hCSCOccupancy","overall CSC occupancy",13,-0.5,12.5);
00034       hCSCOccupancy->setBinLabel(2,"Total Events");
00035       hCSCOccupancy->setBinLabel(4,"# Events with Wires");
00036       hCSCOccupancy->setBinLabel(6,"# Events with Strips");
00037       hCSCOccupancy->setBinLabel(8,"# Events with Wires&Strips");
00038       hCSCOccupancy->setBinLabel(10,"# Events with Rechits");
00039       hCSCOccupancy->setBinLabel(12,"# Events with Segments");
00040       hOWires = dbe->book2D("hOWires","Wire Digi Occupancy",36,0.5,36.5,20,0.5,20.5);
00041       hOWires->setAxisTitle("Chamber #");
00042       hOWires->setBinLabel(1,"ME -4/2",2);
00043       hOWires->setBinLabel(2,"ME -4/1",2);
00044       hOWires->setBinLabel(3,"ME -3/2",2);
00045       hOWires->setBinLabel(4,"ME -2/1",2);
00046       hOWires->setBinLabel(5,"ME -2/2",2);
00047       hOWires->setBinLabel(6,"ME -2/1",2);
00048       hOWires->setBinLabel(7,"ME -1/3",2);
00049       hOWires->setBinLabel(8,"ME -1/2",2);
00050       hOWires->setBinLabel(9,"ME -1/1b",2);
00051       hOWires->setBinLabel(10,"ME -1/1a",2);
00052       hOWires->setBinLabel(11,"ME +1/1a",2);
00053       hOWires->setBinLabel(12,"ME +1/1b",2);
00054       hOWires->setBinLabel(13,"ME +1/2",2);
00055       hOWires->setBinLabel(14,"ME +1/3",2);
00056       hOWires->setBinLabel(15,"ME +2/1",2);
00057       hOWires->setBinLabel(16,"ME +2/2",2);
00058       hOWires->setBinLabel(17,"ME +3/1",2);
00059       hOWires->setBinLabel(18,"ME +3/2",2);
00060       hOWires->setBinLabel(19,"ME +4/1",2);
00061       hOWires->setBinLabel(20,"ME +4/2",2);
00062       hOWireSerial = dbe->book1D("hOWireSerial","Wire Occupancy by Chamber Serial",601,-0.5,600.5);
00063       hOWireSerial->setAxisTitle("Chamber Serial Number");
00064       hOStrips = dbe->book2D("hOStrips","Strip Digi Occupancy",36,0.5,36.5,20,0.5,20.5);
00065       hOStrips->setAxisTitle("Chamber #");
00066       hOStrips->setBinLabel(1,"ME -4/2",2);
00067       hOStrips->setBinLabel(2,"ME -4/1",2);
00068       hOStrips->setBinLabel(3,"ME -3/2",2);
00069       hOStrips->setBinLabel(4,"ME -2/1",2);
00070       hOStrips->setBinLabel(5,"ME -2/2",2);
00071       hOStrips->setBinLabel(6,"ME -2/1",2);
00072       hOStrips->setBinLabel(7,"ME -1/3",2);
00073       hOStrips->setBinLabel(8,"ME -1/2",2);
00074       hOStrips->setBinLabel(9,"ME -1/1b",2);
00075       hOStrips->setBinLabel(10,"ME -1/1a",2);
00076       hOStrips->setBinLabel(11,"ME +1/1a",2);
00077       hOStrips->setBinLabel(12,"ME +1/1b",2);
00078       hOStrips->setBinLabel(13,"ME +1/2",2);
00079       hOStrips->setBinLabel(14,"ME +1/3",2);
00080       hOStrips->setBinLabel(15,"ME +2/1",2);
00081       hOStrips->setBinLabel(16,"ME +2/2",2);
00082       hOStrips->setBinLabel(17,"ME +3/1",2);
00083       hOStrips->setBinLabel(18,"ME +3/2",2);
00084       hOStrips->setBinLabel(19,"ME +4/1",2);
00085       hOStrips->setBinLabel(20,"ME +4/2",2);
00086       hOStripSerial = dbe->book1D("hOStripSerial","Strip Occupancy by Chamber Serial",601,-0.5,600.5);
00087       hOStripSerial->setAxisTitle("Chamber Serial Number");
00088       hORecHits = dbe->book2D("hORecHits","RecHit Occupancy",36,0.5,36.5,20,0.5,20.5);
00089       hORecHits->setAxisTitle("Chamber #");
00090       hORecHits->setBinLabel(1,"ME -4/2",2);
00091       hORecHits->setBinLabel(2,"ME -4/1",2);
00092       hORecHits->setBinLabel(3,"ME -3/2",2);
00093       hORecHits->setBinLabel(4,"ME -2/1",2);
00094       hORecHits->setBinLabel(5,"ME -2/2",2);
00095       hORecHits->setBinLabel(6,"ME -2/1",2);
00096       hORecHits->setBinLabel(7,"ME -1/3",2);
00097       hORecHits->setBinLabel(8,"ME -1/2",2);
00098       hORecHits->setBinLabel(9,"ME -1/1b",2);
00099       hORecHits->setBinLabel(10,"ME -1/1a",2);
00100       hORecHits->setBinLabel(11,"ME +1/1a",2);
00101       hORecHits->setBinLabel(12,"ME +1/1b",2);
00102       hORecHits->setBinLabel(13,"ME +1/2",2);
00103       hORecHits->setBinLabel(14,"ME +1/3",2);
00104       hORecHits->setBinLabel(15,"ME +2/1",2);
00105       hORecHits->setBinLabel(16,"ME +2/2",2);
00106       hORecHits->setBinLabel(17,"ME +3/1",2);
00107       hORecHits->setBinLabel(18,"ME +3/2",2);
00108       hORecHits->setBinLabel(19,"ME +4/1",2);
00109       hORecHits->setBinLabel(20,"ME +4/2",2);
00110       hORecHitsSerial = dbe->book1D("hORecHitSerial","RecHit Occupancy by Chamber Serial",601,-0.5,600.5);
00111       hORecHitsSerial->setAxisTitle("Chamber Serial Number");
00112       hOSegments = dbe->book2D("hOSegments","Segment Occupancy",36,0.5,36.5,20,0.5,20.5);
00113       hOSegments->setAxisTitle("Chamber #");
00114       hOSegments->setBinLabel(1,"ME -4/2",2);
00115       hOSegments->setBinLabel(2,"ME -4/1",2);
00116       hOSegments->setBinLabel(3,"ME -3/2",2);
00117       hOSegments->setBinLabel(4,"ME -2/1",2);
00118       hOSegments->setBinLabel(5,"ME -2/2",2);
00119       hOSegments->setBinLabel(6,"ME -2/1",2);
00120       hOSegments->setBinLabel(7,"ME -1/3",2);
00121       hOSegments->setBinLabel(8,"ME -1/2",2);
00122       hOSegments->setBinLabel(9,"ME -1/1b",2);
00123       hOSegments->setBinLabel(10,"ME -1/1a",2);
00124       hOSegments->setBinLabel(11,"ME +1/1a",2);
00125       hOSegments->setBinLabel(12,"ME +1/1b",2);
00126       hOSegments->setBinLabel(13,"ME +1/2",2);
00127       hOSegments->setBinLabel(14,"ME +1/3",2);
00128       hOSegments->setBinLabel(15,"ME +2/1",2);
00129       hOSegments->setBinLabel(16,"ME +2/2",2);
00130       hOSegments->setBinLabel(17,"ME +3/1",2);
00131       hOSegments->setBinLabel(18,"ME +3/2",2);
00132       hOSegments->setBinLabel(19,"ME +4/1",2);
00133       hOSegments->setBinLabel(20,"ME +4/2",2);
00134       hOSegmentsSerial = dbe->book1D("hOSegmentSerial","Segment Occupancy by Chamber Serial",601,-0.5,600.5);
00135       hOSegmentsSerial->setAxisTitle("Chamber Serial Number");
00136 
00137       // wire digis
00138       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Digis");
00139       hWirenGroupsTotal = dbe->book1D("hWirenGroupsTotal","Fired Wires per Event; # Wiregroups Fired",61,-0.5,60.5);
00140       hWireTBin.push_back(dbe->book1D("hWireTBin_m42","Wire TBin Fired (ME -4/2); Time Bin (25ns)",17,-0.5,16.5));
00141       hWireTBin.push_back(dbe->book1D("hWireTBin_m41","Wire TBin Fired (ME -4/1); Time Bin (25ns)",17,-0.5,16.5));
00142       hWireTBin.push_back(dbe->book1D("hWireTBin_m32","Wire TBin Fired (ME -3/2); Time Bin (25ns)",17,-0.5,16.5));
00143       hWireTBin.push_back(dbe->book1D("hWireTBin_m31","Wire TBin Fired (ME -3/1); Time Bin (25ns)",17,-0.5,16.5));
00144       hWireTBin.push_back(dbe->book1D("hWireTBin_m22","Wire TBin Fired (ME -2/2); Time Bin (25ns)",17,-0.5,16.5));
00145       hWireTBin.push_back(dbe->book1D("hWireTBin_m21","Wire TBin Fired (ME -2/1); Time Bin (25ns)",17,-0.5,16.5));
00146       hWireTBin.push_back(dbe->book1D("hWireTBin_m11a","Wire TBin Fired (ME -1/1a); Time Bin (25ns)",17,-0.5,16.5));
00147       hWireTBin.push_back(dbe->book1D("hWireTBin_m13","Wire TBin Fired (ME -1/3); Time Bin (25ns)",17,-0.5,16.5));
00148       hWireTBin.push_back(dbe->book1D("hWireTBin_m12","Wire TBin Fired (ME -1/2); Time Bin (25ns)",17,-0.5,16.5));
00149       hWireTBin.push_back(dbe->book1D("hWireTBin_m11b","Wire TBin Fired (ME -1/1b); Time Bin (25ns)",17,-0.5,16.5));
00150       hWireTBin.push_back(dbe->book1D("hWireTBin_p11b","Wire TBin Fired (ME +1/1b); Time Bin (25ns)",17,-0.5,16.5));
00151       hWireTBin.push_back(dbe->book1D("hWireTBin_p12","Wire TBin Fired (ME +1/2); Time Bin (25ns)",17,-0.5,16.5));
00152       hWireTBin.push_back(dbe->book1D("hWireTBin_p13","Wire TBin Fired (ME +1/3); Time Bin (25ns)",17,-0.5,16.5));
00153       hWireTBin.push_back(dbe->book1D("hWireTBin_p11a","Wire TBin Fired (ME +1/1a); Time Bin (25ns)",17,-0.5,16.5));
00154       hWireTBin.push_back(dbe->book1D("hWireTBin_p21","Wire TBin Fired (ME +2/1); Time Bin (25ns)",17,-0.5,16.5));
00155       hWireTBin.push_back(dbe->book1D("hWireTBin_p22","Wire TBin Fired (ME +2/2); Time Bin (25ns)",17,-0.5,16.5));
00156       hWireTBin.push_back(dbe->book1D("hWireTBin_p31","Wire TBin Fired (ME +3/1); Time Bin (25ns)",17,-0.5,16.5));
00157       hWireTBin.push_back(dbe->book1D("hWireTBin_p32","Wire TBin Fired (ME +3/2); Time Bin (25ns)",17,-0.5,16.5));
00158       hWireTBin.push_back(dbe->book1D("hWireTBin_p41","Wire TBin Fired (ME +4/1); Time Bin (25ns)",17,-0.5,16.5));
00159       hWireTBin.push_back(dbe->book1D("hWireTBin_p42","Wire TBin Fired (ME +4/2); Time Bin (25ns)",17,-0.5,16.5));
00160       hWireNumber.push_back(dbe->book1D("hWireNumber_m42","Wiregroup Number Fired (ME -4/2); Wiregroup #",113,-0.5,112.5));
00161       hWireNumber.push_back(dbe->book1D("hWireNumber_m41","Wiregroup Number Fired (ME -4/1); Wiregroup #",113,-0.5,112.5));
00162       hWireNumber.push_back(dbe->book1D("hWireNumber_m32","Wiregroup Number Fired (ME -3/2); Wiregroup #",113,-0.5,112.5));
00163       hWireNumber.push_back(dbe->book1D("hWireNumber_m31","Wiregroup Number Fired (ME -3/1); Wiregroup #",113,-0.5,112.5));
00164       hWireNumber.push_back(dbe->book1D("hWireNumber_m22","Wiregroup Number Fired (ME -2/2); Wiregroup #",113,-0.5,112.5));
00165       hWireNumber.push_back(dbe->book1D("hWireNumber_m21","Wiregroup Number Fired (ME -2/1); Wiregroup #",113,-0.5,112.5));
00166       hWireNumber.push_back(dbe->book1D("hWireNumber_m11a","Wiregroup Number Fired (ME -1/1a); Wiregroup #",113,-0.5,112.5));
00167       hWireNumber.push_back(dbe->book1D("hWireNumber_m13","Wiregroup Number Fired (ME -1/3); Wiregroup #",113,-0.5,112.5));
00168       hWireNumber.push_back(dbe->book1D("hWireNumber_m12","Wiregroup Number Fired (ME -1/2); Wiregroup #",113,-0.5,112.5));
00169       hWireNumber.push_back(dbe->book1D("hWireNumber_m11b","Wiregroup Number Fired (ME -1/1b); Wiregroup #",113,-0.5,112.5));
00170       hWireNumber.push_back(dbe->book1D("hWireNumber_p11b","Wiregroup Number Fired (ME +1/1b); Wiregroup #",113,-0.5,112.5));
00171       hWireNumber.push_back(dbe->book1D("hWireNumber_p12","Wiregroup Number Fired (ME +1/2); Wiregroup #",113,-0.5,112.5));
00172       hWireNumber.push_back(dbe->book1D("hWireNumber_p13","Wiregroup Number Fired (ME +1/3); Wiregroup #",113,-0.5,112.5));
00173       hWireNumber.push_back(dbe->book1D("hWireNumber_p11a","Wiregroup Number Fired (ME +1/1a); Wiregroup #",113,-0.5,112.5));
00174       hWireNumber.push_back(dbe->book1D("hWireNumber_p21","Wiregroup Number Fired (ME +2/1); Wiregroup #",113,-0.5,112.5));
00175       hWireNumber.push_back(dbe->book1D("hWireNumber_p22","Wiregroup Number Fired (ME +2/2); Wiregroup #",113,-0.5,112.5));
00176       hWireNumber.push_back(dbe->book1D("hWireNumber_p31","Wiregroup Number Fired (ME +3/1); Wiregroup #",113,-0.5,112.5));
00177       hWireNumber.push_back(dbe->book1D("hWireNumber_p32","Wiregroup Number Fired (ME +3/2); Wiregroup #",113,-0.5,112.5));
00178       hWireNumber.push_back(dbe->book1D("hWireNumber_p41","Wiregroup Number Fired (ME +4/1); Wiregroup #",113,-0.5,112.5));
00179       hWireNumber.push_back(dbe->book1D("hWireNumber_p42","Wiregroup Number Fired (ME +4/2); Wiregroup #",113,-0.5,112.5));
00180 
00181       // strip digis
00182       hStripNFired = dbe->book1D("hStripNFired","Fired Strips per Event; # Strips Fired (above 13 ADC)",101,-0.5,100.5);
00183       hStripNumber.push_back(dbe->book1D("hStripNumber_m42","Strip Number Fired (ME -4/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00184       hStripNumber.push_back(dbe->book1D("hStripNumber_m41","Strip Number Fired (ME -4/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00185       hStripNumber.push_back(dbe->book1D("hStripNumber_m32","Strip Number Fired (ME -3/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00186       hStripNumber.push_back(dbe->book1D("hStripNumber_m31","Strip Number Fired (ME -3/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00187       hStripNumber.push_back(dbe->book1D("hStripNumber_m22","Strip Number Fired (ME -2/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00188       hStripNumber.push_back(dbe->book1D("hStripNumber_m21","Strip Number Fired (ME -2/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00189       hStripNumber.push_back(dbe->book1D("hStripNumber_m11a","Strip Number Fired (ME -1/1a); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00190       hStripNumber.push_back(dbe->book1D("hStripNumber_m13","Strip Number Fired (ME -1/3); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00191       hStripNumber.push_back(dbe->book1D("hStripNumber_m12","Strip Number Fired (ME -1/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00192       hStripNumber.push_back(dbe->book1D("hStripNumber_m11b","Strip Number Fired (ME -1/1b); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00193       hStripNumber.push_back(dbe->book1D("hStripNumber_p11b","Strip Number Fired (ME +1/1b); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00194       hStripNumber.push_back(dbe->book1D("hStripNumber_p12","Strip Number Fired (ME +1/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00195       hStripNumber.push_back(dbe->book1D("hStripNumber_p13","Strip Number Fired (ME +1/3); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00196       hStripNumber.push_back(dbe->book1D("hStripNumber_p11a","Strip Number Fired (ME +1/1a); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00197       hStripNumber.push_back(dbe->book1D("hStripNumber_p21","Strip Number Fired (ME +2/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00198       hStripNumber.push_back(dbe->book1D("hStripNumber_p22","Strip Number Fired (ME +2/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00199       hStripNumber.push_back(dbe->book1D("hStripNumber_p31","Strip Number Fired (ME +3/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00200       hStripNumber.push_back(dbe->book1D("hStripNumber_p32","Strip Number Fired (ME +3/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00201       hStripNumber.push_back(dbe->book1D("hStripNumber_p41","Strip Number Fired (ME +4/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00202       hStripNumber.push_back(dbe->book1D("hStripNumber_p42","Stripgroup Number Fired (ME +4/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00203 
00204       //Pedestal Noise Plots
00205       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/PedestalNoise");
00206       hStripPed.push_back(dbe->book1D("hStripPedMEm42","Pedestal Noise Distribution Chamber ME -4/2; ADC Counts",50,-25.,25.));
00207       hStripPed.push_back(dbe->book1D("hStripPedMEm41","Pedestal Noise Distribution Chamber ME -4/1; ADC Counts",50,-25.,25.));
00208       hStripPed.push_back(dbe->book1D("hStripPedMEm32","Pedestal Noise Distribution Chamber ME -3/2; ADC Counts",50,-25.,25.));
00209       hStripPed.push_back(dbe->book1D("hStripPedMEm31","Pedestal Noise Distribution Chamber ME -3/1; ADC Counts",50,-25.,25.));
00210       hStripPed.push_back(dbe->book1D("hStripPedMEm22","Pedestal Noise Distribution Chamber ME -2/2; ADC Counts",50,-25.,25.));
00211       hStripPed.push_back(dbe->book1D("hStripPedMEm21","Pedestal Noise Distribution Chamber ME -2/1; ADC Counts",50,-25.,25.));
00212       hStripPed.push_back(dbe->book1D("hStripPedMEm11a","Pedestal Noise Distribution Chamber ME -1/1; ADC Counts",50,-25.,25.));
00213       hStripPed.push_back(dbe->book1D("hStripPedMEm13","Pedestal Noise Distribution Chamber ME -1/3; ADC Counts",50,-25.,25.));
00214       hStripPed.push_back(dbe->book1D("hStripPedMEm12","Pedestal Noise Distribution Chamber ME -1/2; ADC Counts",50,-25.,25.));
00215       hStripPed.push_back(dbe->book1D("hStripPedMEm11b","Pedestal Noise Distribution Chamber ME -1/1; ADC Counts",50,-25.,25.));
00216       hStripPed.push_back(dbe->book1D("hStripPedMEp11b","Pedestal Noise Distribution Chamber ME +1/1; ADC Counts",50,-25.,25.));
00217       hStripPed.push_back(dbe->book1D("hStripPedMEp12","Pedestal Noise Distribution Chamber ME +1/2; ADC Counts",50,-25.,25.));
00218       hStripPed.push_back(dbe->book1D("hStripPedMEp13","Pedestal Noise Distribution Chamber ME +1/3; ADC Counts",50,-25.,25.));
00219       hStripPed.push_back(dbe->book1D("hStripPedMEp11a","Pedestal Noise Distribution Chamber ME +1/1; ADC Counts",50,-25.,25.));
00220       hStripPed.push_back(dbe->book1D("hStripPedMEp21","Pedestal Noise Distribution Chamber ME +2/1; ADC Counts",50,-25.,25.));
00221       hStripPed.push_back(dbe->book1D("hStripPedMEp22","Pedestal Noise Distribution Chamber ME +2/2; ADC Counts",50,-25.,25.));
00222       hStripPed.push_back(dbe->book1D("hStripPedMEp31","Pedestal Noise Distribution Chamber ME +3/1; ADC Counts",50,-25.,25.));
00223       hStripPed.push_back(dbe->book1D("hStripPedMEp32","Pedestal Noise Distribution Chamber ME +3/2; ADC Counts",50,-25.,25.));
00224       hStripPed.push_back(dbe->book1D("hStripPedMEp41","Pedestal Noise Distribution Chamber ME +4/1; ADC Counts",50,-25.,25.));
00225       hStripPed.push_back(dbe->book1D("hStripPedMEp42","Pedestal Noise Distribution Chamber ME +4/2; ADC Counts",50,-25.,25.));
00226 
00227       // recHits
00228       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/recHits");
00229       hRHnrechits = dbe->book1D("hRHnrechits","recHits per Event (all chambers); # of RecHits",50,0,50);
00230       hRHGlobal.push_back(dbe->book2D("hRHGlobalp1","recHit global X,Y station +1; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00231       hRHGlobal.push_back(dbe->book2D("hRHGlobalp2","recHit global X,Y station +2; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00232       hRHGlobal.push_back(dbe->book2D("hRHGlobalp3","recHit global X,Y station +3; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00233       hRHGlobal.push_back(dbe->book2D("hRHGlobalp4","recHit global X,Y station +4; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00234       hRHGlobal.push_back(dbe->book2D("hRHGlobalm1","recHit global X,Y station -1; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00235       hRHGlobal.push_back(dbe->book2D("hRHGlobalm2","recHit global X,Y station -2; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00236       hRHGlobal.push_back(dbe->book2D("hRHGlobalm3","recHit global X,Y station -3; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00237       hRHGlobal.push_back(dbe->book2D("hRHGlobalm4","recHit global X,Y station -4; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00238       hRHSumQ.push_back(dbe->book1D("hRHSumQm42","Sum 3x3 recHit Charge (ME -4/2); ADC counts",100,0,2000));
00239       hRHSumQ.push_back(dbe->book1D("hRHSumQm41","Sum 3x3 recHit Charge (ME -4/1); ADC counts",100,0,2000));
00240       hRHSumQ.push_back(dbe->book1D("hRHSumQm32","Sum 3x3 recHit Charge (ME -3/2); ADC counts",100,0,2000));
00241       hRHSumQ.push_back(dbe->book1D("hRHSumQm31","Sum 3x3 recHit Charge (ME -3/1); ADC counts",100,0,2000));
00242       hRHSumQ.push_back(dbe->book1D("hRHSumQm22","Sum 3x3 recHit Charge (ME -2/2); ADC counts",100,0,2000));
00243       hRHSumQ.push_back(dbe->book1D("hRHSumQm21","Sum 3x3 recHit Charge (ME -2/1); ADC counts",100,0,2000));
00244       hRHSumQ.push_back(dbe->book1D("hRHSumQm11a","Sum 3x3 recHit Charge (ME -1/1a); ADC counts",100,0,4000));
00245       hRHSumQ.push_back(dbe->book1D("hRHSumQm13","Sum 3x3 recHit Charge (ME -1/3); ADC counts",100,0,2000));
00246       hRHSumQ.push_back(dbe->book1D("hRHSumQm12","Sum 3x3 recHit Charge (ME -1/2); ADC counts",100,0,2000));
00247       hRHSumQ.push_back(dbe->book1D("hRHSumQm11b","Sum 3x3 recHit Charge (ME -1/1b); ADC counts",100,0,4000));
00248       hRHSumQ.push_back(dbe->book1D("hRHSumQp11b","Sum 3x3 recHit Charge (ME +1/1b); ADC counts",100,0,4000));
00249       hRHSumQ.push_back(dbe->book1D("hRHSumQp12","Sum 3x3 recHit Charge (ME +1/2); ADC counts",100,0,2000));
00250       hRHSumQ.push_back(dbe->book1D("hRHSumQp13","Sum 3x3 recHit Charge (ME +1/3); ADC counts",100,0,2000));
00251       hRHSumQ.push_back(dbe->book1D("hRHSumQp11a","Sum 3x3 recHit Charge (ME +1/1a); ADC counts",100,0,4000));
00252       hRHSumQ.push_back(dbe->book1D("hRHSumQp21","Sum 3x3 recHit Charge (ME +2/1); ADC counts",100,0,2000));
00253       hRHSumQ.push_back(dbe->book1D("hRHSumQp22","Sum 3x3 recHit Charge (ME +2/2); ADC counts",100,0,2000));
00254       hRHSumQ.push_back(dbe->book1D("hRHSumQp31","Sum 3x3 recHit Charge (ME +3/1); ADC counts",100,0,2000));
00255       hRHSumQ.push_back(dbe->book1D("hRHSumQp32","Sum 3x3 recHit Charge (ME +3/2); ADC counts",100,0,2000));
00256       hRHSumQ.push_back(dbe->book1D("hRHSumQp41","Sum 3x3 recHit Charge (ME +4/1); ADC counts",100,0,2000));
00257       hRHSumQ.push_back(dbe->book1D("hRHSumQp42","Sum 3x3 recHit Charge (ME +4/2); ADC counts",100,0,2000));
00258       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm42","Charge Ratio (Ql+Qr)/Qt (ME -4/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00259       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm41","Charge Ratio (Ql+Qr)/Qt (ME -4/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00260       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm32","Charge Ratio (Ql+Qr)/Qt (ME -3/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00261       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm31","Charge Ratio (Ql+Qr)/Qt (ME -3/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00262       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm22","Charge Ratio (Ql+Qr)/Qt (ME -2/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00263       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm21","Charge Ratio (Ql+Qr)/Qt (ME -2/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00264       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm11a","Charge Ratio (Ql+Qr)/Qt (ME -1/1a); (Ql+Qr)/Qt",100,-0.1,1.1));
00265       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm13","Charge Ratio (Ql+Qr)/Qt (ME -1/3); (Ql+Qr)/Qt",100,-0.1,1.1));
00266       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm12","Charge Ratio (Ql+Qr)/Qt (ME -1/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00267       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm11b","Charge Ratio (Ql+Qr)/Qt (ME -1/1b); (Ql+Qr)/Qt",100,-0.1,1.1));
00268       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp11b","Charge Ratio (Ql+Qr)/Qt (ME +1/1b); (Ql+Qr)/Qt",100,-0.1,1.1));
00269       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp12","Charge Ratio (Ql+Qr)/Qt (ME +1/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00270       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp13","Charge Ratio (Ql+Qr)/Qt (ME +1/3); (Ql+Qr)/Qt",100,-0.1,1.1));
00271       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp11a","Charge Ratio (Ql+Qr)/Qt (ME +1/1a); (Ql+Qr)/Qt",100,-0.1,1.1));
00272       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp21","Charge Ratio (Ql+Qr)/Qt (ME +2/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00273       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp22","Charge Ratio (Ql+Qr)/Qt (ME +2/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00274       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp31","Charge Ratio (Ql+Qr)/Qt (ME +3/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00275       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp32","Charge Ratio (Ql+Qr)/Qt (ME +3/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00276       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp41","Charge Ratio (Ql+Qr)/Qt (ME +4/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00277       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp42","Charge Ratio (Ql+Qr)/Qt (ME +4/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00278       hRHTiming.push_back(dbe->book1D("hRHTimingm42","recHit Time (ME -4/2); ns",200,-500.,500.));
00279       hRHTiming.push_back(dbe->book1D("hRHTimingm41","recHit Time (ME -4/1); ns",200,-500.,500.));
00280       hRHTiming.push_back(dbe->book1D("hRHTimingm32","recHit Time (ME -3/2); ns",200,-500.,500.));
00281       hRHTiming.push_back(dbe->book1D("hRHTimingm31","recHit Time (ME -3/1); ns",200,-500.,500.));
00282       hRHTiming.push_back(dbe->book1D("hRHTimingm22","recHit Time (ME -2/2); ns",200,-500.,500.));
00283       hRHTiming.push_back(dbe->book1D("hRHTimingm21","recHit Time (ME -2/1); ns",200,-500.,500.));
00284       hRHTiming.push_back(dbe->book1D("hRHTimingm11a","recHit Time (ME -1/1a); ns",200,-500.,500.));
00285       hRHTiming.push_back(dbe->book1D("hRHTimingm13","recHit Time (ME -1/3); ns",200,-500.,500.));
00286       hRHTiming.push_back(dbe->book1D("hRHTimingm12","recHit Time (ME -1/2); ns",200,-500.,500.));
00287       hRHTiming.push_back(dbe->book1D("hRHTimingm11b","recHit Time (ME -1/1b); ns",200,-500.,500.));
00288       hRHTiming.push_back(dbe->book1D("hRHTimingp11b","recHit Time (ME +1/1b); ns",200,-500.,500.));
00289       hRHTiming.push_back(dbe->book1D("hRHTimingp12","recHit Time (ME +1/2); ns",200,-500.,500.));
00290       hRHTiming.push_back(dbe->book1D("hRHTimingp13","recHit Time (ME +1/3); ns",200,-500.,500.));
00291       hRHTiming.push_back(dbe->book1D("hRHTimingp11a","recHit Time (ME +1/1a); ns",200,-500.,500.));
00292       hRHTiming.push_back(dbe->book1D("hRHTimingp21","recHit Time (ME +2/1); ns",200,-500.,500.));
00293       hRHTiming.push_back(dbe->book1D("hRHTimingp22","recHit Time (ME +2/2); ns",200,-500.,500.));
00294       hRHTiming.push_back(dbe->book1D("hRHTimingp31","recHit Time (ME +3/1); ns",200,-500.,500.));
00295       hRHTiming.push_back(dbe->book1D("hRHTimingp32","recHit Time (ME +3/2); ns",200,-500.,500.));
00296       hRHTiming.push_back(dbe->book1D("hRHTimingp41","recHit Time (ME +4/1); ns",200,-500.,500.));
00297       hRHTiming.push_back(dbe->book1D("hRHTimingp42","recHit Time (ME +4/2); ns",200,-500.,500.));
00298       hRHstpos.push_back(dbe->book1D("hRHstposm42","Reconstructed Position on Strip (ME -4/2); Strip Widths",120,-0.6,0.6));
00299       hRHstpos.push_back(dbe->book1D("hRHstposm41","Reconstructed Position on Strip (ME -4/1); Strip Widths",120,-0.6,0.6));
00300       hRHstpos.push_back(dbe->book1D("hRHstposm32","Reconstructed Position on Strip (ME -3/2); Strip Widths",120,-0.6,0.6));
00301       hRHstpos.push_back(dbe->book1D("hRHstposm31","Reconstructed Position on Strip (ME -3/1); Strip Widths",120,-0.6,0.6));
00302       hRHstpos.push_back(dbe->book1D("hRHstposm22","Reconstructed Position on Strip (ME -2/2); Strip Widths",120,-0.6,0.6));
00303       hRHstpos.push_back(dbe->book1D("hRHstposm21","Reconstructed Position on Strip (ME -2/1); Strip Widths",120,-0.6,0.6));
00304       hRHstpos.push_back(dbe->book1D("hRHstposm11a","Reconstructed Position on Strip (ME -1/1a); Strip Widths",120,-0.6,0.6));
00305       hRHstpos.push_back(dbe->book1D("hRHstposm13","Reconstructed Position on Strip (ME -1/3); Strip Widths",120,-0.6,0.6));
00306       hRHstpos.push_back(dbe->book1D("hRHstposm12","Reconstructed Position on Strip (ME -1/2); Strip Widths",120,-0.6,0.6));
00307       hRHstpos.push_back(dbe->book1D("hRHstposm11b","Reconstructed Position on Strip (ME -1/1b); Strip Widths",120,-0.6,0.6));
00308       hRHstpos.push_back(dbe->book1D("hRHstposp11b","Reconstructed Position on Strip (ME +1/1b); Strip Widths",120,-0.6,0.6));
00309       hRHstpos.push_back(dbe->book1D("hRHstposp12","Reconstructed Position on Strip (ME +1/2); Strip Widths",120,-0.6,0.6));
00310       hRHstpos.push_back(dbe->book1D("hRHstposp13","Reconstructed Position on Strip (ME +1/3); Strip Widths",120,-0.6,0.6));
00311       hRHstpos.push_back(dbe->book1D("hRHstposp11a","Reconstructed Position on Strip (ME +1/1a); Strip Widths",120,-0.6,0.6));
00312       hRHstpos.push_back(dbe->book1D("hRHstposp21","Reconstructed Position on Strip (ME +2/1); Strip Widths",120,-0.6,0.6));
00313       hRHstpos.push_back(dbe->book1D("hRHstposp22","Reconstructed Position on Strip (ME +2/2); Strip Widths",120,-0.6,0.6));
00314       hRHstpos.push_back(dbe->book1D("hRHstposp31","Reconstructed Position on Strip (ME +3/1); Strip Widths",120,-0.6,0.6));
00315       hRHstpos.push_back(dbe->book1D("hRHstposp32","Reconstructed Position on Strip (ME +3/2); Strip Widths",120,-0.6,0.6));
00316       hRHstpos.push_back(dbe->book1D("hRHstposp41","Reconstructed Position on Strip (ME +4/1); Strip Widths",120,-0.6,0.6));
00317       hRHstpos.push_back(dbe->book1D("hRHstposp42","Reconstructed Position on Strip (ME +4/2); Strip Widths",120,-0.6,0.6));
00318       hRHsterr.push_back(dbe->book1D("hRHsterrm42","Estimated Error on Strip Measurement (ME -4/2); Strip Widths",75,-0.01,0.24));
00319       hRHsterr.push_back(dbe->book1D("hRHsterrm41","Estimated Error on Strip Measurement (ME -4/1); Strip Widths",75,-0.01,0.24));
00320       hRHsterr.push_back(dbe->book1D("hRHsterrm32","Estimated Error on Strip Measurement (ME -3/2); Strip Widths",75,-0.01,0.24));
00321       hRHsterr.push_back(dbe->book1D("hRHsterrm31","Estimated Error on Strip Measurement (ME -3/1); Strip Widths",75,-0.01,0.24));
00322       hRHsterr.push_back(dbe->book1D("hRHsterrm22","Estimated Error on Strip Measurement (ME -2/2); Strip Widths",75,-0.01,0.24));
00323       hRHsterr.push_back(dbe->book1D("hRHsterrm21","Estimated Error on Strip Measurement (ME -2/1); Strip Widths",75,-0.01,0.24));
00324       hRHsterr.push_back(dbe->book1D("hRHsterrm11a","Estimated Error on Strip Measurement (ME -1/1a); Strip Widths",75,-0.01,0.24));
00325       hRHsterr.push_back(dbe->book1D("hRHsterrm13","Estimated Error on Strip Measurement (ME -1/3); Strip Widths",75,-0.01,0.24));
00326       hRHsterr.push_back(dbe->book1D("hRHsterrm12","Estimated Error on Strip Measurement (ME -1/2); Strip Widths",75,-0.01,0.24));
00327       hRHsterr.push_back(dbe->book1D("hRHsterrm11b","Estimated Error on Strip Measurement (ME -1/1b); Strip Widths",75,-0.01,0.24));
00328       hRHsterr.push_back(dbe->book1D("hRHsterrp11b","Estimated Error on Strip Measurement (ME +1/1b); Strip Widths",75,-0.01,0.24));
00329       hRHsterr.push_back(dbe->book1D("hRHsterrp12","Estimated Error on Strip Measurement (ME +1/2); Strip Widths",75,-0.01,0.24));
00330       hRHsterr.push_back(dbe->book1D("hRHsterrp13","Estimated Error on Strip Measurement (ME +1/3); Strip Widths",75,-0.01,0.24));
00331       hRHsterr.push_back(dbe->book1D("hRHsterrp11a","Estimated Error on Strip Measurement (ME +1/1a); Strip Widths",75,-0.01,0.24));
00332       hRHsterr.push_back(dbe->book1D("hRHsterrp21","Estimated Error on Strip Measurement (ME +2/1); Strip Widths",75,-0.01,0.24));
00333       hRHsterr.push_back(dbe->book1D("hRHsterrp22","Estimated Error on Strip Measurement (ME +2/2); Strip Widths",75,-0.01,0.24));
00334       hRHsterr.push_back(dbe->book1D("hRHsterrp31","Estimated Error on Strip Measurement (ME +3/1); Strip Widths",75,-0.01,0.24));
00335       hRHsterr.push_back(dbe->book1D("hRHsterrp32","Estimated Error on Strip Measurement (ME +3/2); Strip Widths",75,-0.01,0.24));
00336       hRHsterr.push_back(dbe->book1D("hRHsterrp41","Estimated Error on Strip Measurement (ME +4/1); Strip Widths",75,-0.01,0.24));
00337       hRHsterr.push_back(dbe->book1D("hRHsterrp42","Estimated Error on Strip Measurement (ME +4/2); Strip Widths",75,-0.01,0.24));
00338 
00339 
00340       // segments
00341       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Segments");
00342       hSnSegments   = dbe->book1D("hSnSegments","Number of Segments per Event; # of Segments",11,-0.5,10.5);
00343       hSnhitsAll = dbe->book1D("hSnhits","N hits on Segments; # of hits",8,-0.5,7.5);
00344       hSnhits.push_back(dbe->book1D("hSnhitsm42","# of hits on Segments (ME -4/2); # of hits",8,-0.5,7.5));
00345       hSnhits.push_back(dbe->book1D("hSnhitsm41","# of hits on Segments (ME -4/1); # of hits",8,-0.5,7.5));
00346       hSnhits.push_back(dbe->book1D("hSnhitsm32","# of hits on Segments (ME -3/2); # of hits",8,-0.5,7.5));
00347       hSnhits.push_back(dbe->book1D("hSnhitsm31","# of hits on Segments (ME -3/1); # of hits",8,-0.5,7.5));
00348       hSnhits.push_back(dbe->book1D("hSnhitsm22","# of hits on Segments (ME -2/2); # of hits",8,-0.5,7.5));
00349       hSnhits.push_back(dbe->book1D("hSnhitsm21","# of hits on Segments (ME -2/1); # of hits",8,-0.5,7.5));
00350       hSnhits.push_back(dbe->book1D("hSnhitsm11a","# of hits on Segments (ME -1/1a); # of hits",8,-0.5,7.5));
00351       hSnhits.push_back(dbe->book1D("hSnhitsm13","# of hits on Segments (ME -1/3); # of hits",8,-0.5,7.5));
00352       hSnhits.push_back(dbe->book1D("hSnhitsm12","# of hits on Segments (ME -1/2); # of hits",8,-0.5,7.5));
00353       hSnhits.push_back(dbe->book1D("hSnhitsm11b","# of hits on Segments (ME -1/1b); # of hits",8,-0.5,7.5));
00354       hSnhits.push_back(dbe->book1D("hSnhitsp11b","# of hits on Segments (ME +1/1b); # of hits",8,-0.5,7.5));
00355       hSnhits.push_back(dbe->book1D("hSnhitsp12","# of hits on Segments (ME +1/2); # of hits",8,-0.5,7.5));
00356       hSnhits.push_back(dbe->book1D("hSnhitsp13","# of hits on Segments (ME +1/3); # of hits",8,-0.5,7.5));
00357       hSnhits.push_back(dbe->book1D("hSnhitsp11a","# of hits on Segments (ME +1/1a); # of hits",8,-0.5,7.5));
00358       hSnhits.push_back(dbe->book1D("hSnhitsp21","# of hits on Segments (ME +2/1); # of hits",8,-0.5,7.5));
00359       hSnhits.push_back(dbe->book1D("hSnhitsp22","# of hits on Segments (ME +2/2); # of hits",8,-0.5,7.5));
00360       hSnhits.push_back(dbe->book1D("hSnhitsp31","# of hits on Segments (ME +3/1); # of hits",8,-0.5,7.5));
00361       hSnhits.push_back(dbe->book1D("hSnhitsp32","# of hits on Segments (ME +3/2); # of hits",8,-0.5,7.5));
00362       hSnhits.push_back(dbe->book1D("hSnhitsp41","# of hits on Segments (ME +4/1); # of hits",8,-0.5,7.5));
00363       hSnhits.push_back(dbe->book1D("hSnhitsp42","# of hits on Segments (ME +4/2); # of hits",8,-0.5,7.5));
00364       hSChiSqAll = dbe->book1D("hSChiSq","Segment Normalized Chi2; Chi2/ndof",110,-0.05,10.5);
00365       hSChiSq.push_back(dbe->book1D("hSChiSqm42","Segment Normalized Chi2 (ME -4/2); Chi2/ndof",110,-0.05,10.5));
00366       hSChiSq.push_back(dbe->book1D("hSChiSqm41","Segment Normalized Chi2 (ME -4/1); Chi2/ndof",110,-0.05,10.5));
00367       hSChiSq.push_back(dbe->book1D("hSChiSqm32","Segment Normalized Chi2 (ME -3/2); Chi2/ndof",110,-0.05,10.5));
00368       hSChiSq.push_back(dbe->book1D("hSChiSqm31","Segment Normalized Chi2 (ME -3/1); Chi2/ndof",110,-0.05,10.5));
00369       hSChiSq.push_back(dbe->book1D("hSChiSqm22","Segment Normalized Chi2 (ME -2/2); Chi2/ndof",110,-0.05,10.5));
00370       hSChiSq.push_back(dbe->book1D("hSChiSqm21","Segment Normalized Chi2 (ME -2/1); Chi2/ndof",110,-0.05,10.5));
00371       hSChiSq.push_back(dbe->book1D("hSChiSqm11a","Segment Normalized Chi2 (ME -1/1a); Chi2/ndof",110,-0.05,10.5));
00372       hSChiSq.push_back(dbe->book1D("hSChiSqm13","Segment Normalized Chi2 (ME -1/3); Chi2/ndof",110,-0.05,10.5));
00373       hSChiSq.push_back(dbe->book1D("hSChiSqm12","Segment Normalized Chi2 (ME -1/2); Chi2/ndof",110,-0.05,10.5));
00374       hSChiSq.push_back(dbe->book1D("hSChiSqm11b","Segment Normalized Chi2 (ME -1/1b); Chi2/ndof",110,-0.05,10.5));
00375       hSChiSq.push_back(dbe->book1D("hSChiSqp11b","Segment Normalized Chi2 (ME +1/1b); Chi2/ndof",110,-0.05,10.5));
00376       hSChiSq.push_back(dbe->book1D("hSChiSqp12","Segment Normalized Chi2 (ME +1/2); Chi2/ndof",110,-0.05,10.5));
00377       hSChiSq.push_back(dbe->book1D("hSChiSqp13","Segment Normalized Chi2 (ME +1/3); Chi2/ndof",110,-0.05,10.5));
00378       hSChiSq.push_back(dbe->book1D("hSChiSqp11a","Segment Normalized Chi2 (ME +1/1a); Chi2/ndof",110,-0.05,10.5));
00379       hSChiSq.push_back(dbe->book1D("hSChiSqp21","Segment Normalized Chi2 (ME +2/1); Chi2/ndof",110,-0.05,10.5));
00380       hSChiSq.push_back(dbe->book1D("hSChiSqp22","Segment Normalized Chi2 (ME +2/2); Chi2/ndof",110,-0.05,10.5));
00381       hSChiSq.push_back(dbe->book1D("hSChiSqp31","Segment Normalized Chi2 (ME +3/1); Chi2/ndof",110,-0.05,10.5));
00382       hSChiSq.push_back(dbe->book1D("hSChiSqp32","Segment Normalized Chi2 (ME +3/2); Chi2/ndof",110,-0.05,10.5));
00383       hSChiSq.push_back(dbe->book1D("hSChiSqp41","Segment Normalized Chi2 (ME +4/1); Chi2/ndof",110,-0.05,10.5));
00384       hSChiSq.push_back(dbe->book1D("hSChiSqp42","Segment Normalized Chi2 (ME +4/2); Chi2/ndof",110,-0.05,10.5));
00385       hSChiSqProbAll = dbe->book1D("hSChiSqProb","Segment chi2 Probability; Probability",110,-0.05,1.05);
00386       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm42","Segment chi2 Probability (ME -4/2); Probability",110,-0.05,1.05));
00387       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm41","Segment chi2 Probability (ME -4/1); Probability",110,-0.05,1.05));
00388       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm32","Segment chi2 Probability (ME -3/2); Probability",110,-0.05,1.05));
00389       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm31","Segment chi2 Probability (ME -3/1); Probability",110,-0.05,1.05));
00390       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm22","Segment chi2 Probability (ME -2/2); Probability",110,-0.05,1.05));
00391       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm21","Segment chi2 Probability (ME -2/1); Probability",110,-0.05,1.05));
00392       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm11a","Segment chi2 Probability (ME -1/1a); Probability",110,-0.05,1.05));
00393       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm13","Segment chi2 Probability (ME -1/3); Probability",110,-0.05,1.05));
00394       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm12","Segment chi2 Probability (ME -1/2); Probability",110,-0.05,1.05));
00395       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm11b","Segment chi2 Probability (ME -1/1b); Probability",110,-0.05,1.05));
00396       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp11b","Segment chi2 Probability (ME +1/1b); Probability",110,-0.05,1.05));
00397       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp12","Segment chi2 Probability (ME +1/2); Probability",110,-0.05,1.05));
00398       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp13","Segment chi2 Probability (ME +1/3); Probability",110,-0.05,1.05));
00399       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp11a","Segment chi2 Probability (ME +1/1a); Probability",110,-0.05,1.05));
00400       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp21","Segment chi2 Probability (ME +2/1); Probability",110,-0.05,1.05));
00401       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp22","Segment chi2 Probability (ME +2/2); Probability",110,-0.05,1.05));
00402       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp31","Segment chi2 Probability (ME +3/1); Probability",110,-0.05,1.05));
00403       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp32","Segment chi2 Probability (ME +3/2); Probability",110,-0.05,1.05));
00404       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp41","Segment chi2 Probability (ME +4/1); Probability",110,-0.05,1.05));
00405       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp42","Segment chi2 Probability (ME +4/2); Probability",110,-0.05,1.05));
00406       hSGlobalTheta = dbe->book1D("hSGlobalTheta","Segment Direction (Global Theta); Global Theta (radians)",136,-0.1,3.3);
00407       hSGlobalPhi   = dbe->book1D("hSGlobalPhi","Segment Direction (Global Phi); Global Phi (radians)",  128,-3.2,3.2);
00408 
00409       // Resolution
00410       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Resolution");
00411       hSResid.push_back(dbe->book1D("hSResidm42","Fitted Position on Strip - Reconstructed for Layer 3 (ME -4/2); Strip Widths",100,-0.5,0.5));
00412       hSResid.push_back(dbe->book1D("hSResidm41","Fitted Position on Strip - Reconstructed for Layer 3 (ME -4/1); Strip Widths",100,-0.5,0.5));
00413       hSResid.push_back(dbe->book1D("hSResidm32","Fitted Position on Strip - Reconstructed for Layer 3 (ME -3/2); Strip Widths",100,-0.5,0.5));
00414       hSResid.push_back(dbe->book1D("hSResidm31","Fitted Position on Strip - Reconstructed for Layer 3 (ME -3/1); Strip Widths",100,-0.5,0.5));
00415       hSResid.push_back(dbe->book1D("hSResidm22","Fitted Position on Strip - Reconstructed for Layer 3 (ME -2/2); Strip Widths",100,-0.5,0.5));
00416       hSResid.push_back(dbe->book1D("hSResidm21","Fitted Position on Strip - Reconstructed for Layer 3 (ME -2/1); Strip Widths",100,-0.5,0.5));
00417       hSResid.push_back(dbe->book1D("hSResidm11a","Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/1a); Strip Widths",100,-0.5,0.5));
00418       hSResid.push_back(dbe->book1D("hSResidm13","Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/3); Strip Widths",100,-0.5,0.5));
00419       hSResid.push_back(dbe->book1D("hSResidm12","Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/2); Strip Widths",100,-0.5,0.5));
00420       hSResid.push_back(dbe->book1D("hSResidm11b","Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/1b); Strip Widths",100,-0.5,0.5));
00421       hSResid.push_back(dbe->book1D("hSResidp11b","Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/1b); Strip Widths",100,-0.5,0.5));
00422       hSResid.push_back(dbe->book1D("hSResidp12","Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/2); Strip Widths",100,-0.5,0.5));
00423       hSResid.push_back(dbe->book1D("hSResidp13","Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/3); Strip Widths",100,-0.5,0.5));
00424       hSResid.push_back(dbe->book1D("hSResidp11a","Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/1a); Strip Widths",100,-0.5,0.5));
00425       hSResid.push_back(dbe->book1D("hSResidp21","Fitted Position on Strip - Reconstructed for Layer 3 (ME +2/1); Strip Widths",100,-0.5,0.5));
00426       hSResid.push_back(dbe->book1D("hSResidp22","Fitted Position on Strip - Reconstructed for Layer 3 (ME +2/2); Strip Widths",100,-0.5,0.5));
00427       hSResid.push_back(dbe->book1D("hSResidp31","Fitted Position on Strip - Reconstructed for Layer 3 (ME +3/1); Strip Widths",100,-0.5,0.5));
00428       hSResid.push_back(dbe->book1D("hSResidp32","Fitted Position on Strip - Reconstructed for Layer 3 (ME +3/2); Strip Widths",100,-0.5,0.5));
00429       hSResid.push_back(dbe->book1D("hSResidp41","Fitted Position on Strip - Reconstructed for Layer 3 (ME +4/1); Strip Widths",100,-0.5,0.5));
00430       hSResid.push_back(dbe->book1D("hSResidp42","Fitted Position on Strip - Reconstructed for Layer 3 (ME +4/2); Strip Widths",100,-0.5,0.5));
00431 
00432       // Efficiency
00433       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Efficiency");
00434       hSSTE = new TH1F("hSSTE","hSSTE",40,0.5,40.5);
00435       hRHSTE = new TH1F("hRHSTE","hRHSTE",40,0.5,40.5);
00436       hSEff = dbe->book1D("hSEff","Segment Efficiency",20,0.5,20.5);
00437       hSEff->setBinLabel(1,"ME +1/1b");
00438       hSEff->setBinLabel(2,"ME +1/2");
00439       hSEff->setBinLabel(3,"ME +1/3");
00440       hSEff->setBinLabel(4,"ME +1/1a");
00441       hSEff->setBinLabel(5,"ME +2/1");
00442       hSEff->setBinLabel(6,"ME +2/2");
00443       hSEff->setBinLabel(7,"ME +3/1");
00444       hSEff->setBinLabel(8,"ME +3/2");
00445       hSEff->setBinLabel(9,"ME +4/1");
00446       hSEff->setBinLabel(10,"ME +4/2");
00447       hSEff->setBinLabel(11,"ME -1/1b");
00448       hSEff->setBinLabel(12,"ME -1/2");
00449       hSEff->setBinLabel(13,"ME -1/3");
00450       hSEff->setBinLabel(14,"ME -1/1a");
00451       hSEff->setBinLabel(15,"ME -2/1");
00452       hSEff->setBinLabel(16,"ME -2/2");
00453       hSEff->setBinLabel(17,"ME -3/1");
00454       hSEff->setBinLabel(18,"ME -3/2");
00455       hSEff->setBinLabel(19,"ME -4/1");
00456       hSEff->setBinLabel(20,"ME -4/2");
00457       hRHEff = dbe->book1D("hRHEff","recHit Efficiency",20,0.5,20.5);
00458       hRHEff->setBinLabel(1,"ME +1/1b");
00459       hRHEff->setBinLabel(2,"ME +1/2");
00460       hRHEff->setBinLabel(3,"ME +1/3");
00461       hRHEff->setBinLabel(4,"ME +1/1a");
00462       hRHEff->setBinLabel(5,"ME +2/1");
00463       hRHEff->setBinLabel(6,"ME +2/2");
00464       hRHEff->setBinLabel(7,"ME +3/1");
00465       hRHEff->setBinLabel(8,"ME +3/2");
00466       hRHEff->setBinLabel(9,"ME +4/1");
00467       hRHEff->setBinLabel(10,"ME +4/2");
00468       hRHEff->setBinLabel(11,"ME -1/1b");
00469       hRHEff->setBinLabel(12,"ME -1/2");
00470       hRHEff->setBinLabel(13,"ME -1/3");
00471       hRHEff->setBinLabel(14,"ME -1/1a");
00472       hRHEff->setBinLabel(15,"ME -2/1");
00473       hRHEff->setBinLabel(16,"ME -2/2");
00474       hRHEff->setBinLabel(17,"ME -3/1");
00475       hRHEff->setBinLabel(18,"ME -3/2");
00476       hRHEff->setBinLabel(19,"ME -4/1");
00477       hRHEff->setBinLabel(20,"ME -4/2");
00478       hSSTE2 = new TH2F("hSSTE2","hSSTE2",36,0.5,36.5, 18, 0.5, 18.5);
00479       hRHSTE2 = new TH2F("hRHSTE2","hRHSTE2",36,0.5,36.5, 18, 0.5, 18.5);
00480       hStripSTE2 = new TH2F("hStripSTE2","hStripSTE2",36,0.5,36.5, 18, 0.5, 18.5);
00481       hWireSTE2 = new TH2F("hWireSTE2","hWireSTE2",36,0.5,36.5, 18, 0.5, 18.5);
00482       hEffDenominator = new TH2F("hEffDenominator","hEffDenominator",36,0.5,36.5, 18, 0.5, 18.5);
00483       hSEff2 = dbe->book2D("hSEff2","Segment Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
00484       hSEff2->setAxisTitle("Chamber #");
00485       hSEff2->setBinLabel(1,"ME -4/1",2);
00486       hSEff2->setBinLabel(2,"ME -3/2",2);
00487       hSEff2->setBinLabel(3,"ME -2/1",2);
00488       hSEff2->setBinLabel(4,"ME -2/2",2);
00489       hSEff2->setBinLabel(5,"ME -2/1",2);
00490       hSEff2->setBinLabel(6,"ME -1/3",2);
00491       hSEff2->setBinLabel(7,"ME -1/2",2);
00492       hSEff2->setBinLabel(8,"ME -1/1b",2);
00493       hSEff2->setBinLabel(9,"ME -1/1a",2);
00494       hSEff2->setBinLabel(10,"ME +1/1a",2);
00495       hSEff2->setBinLabel(11,"ME +1/1b",2);
00496       hSEff2->setBinLabel(12,"ME +1/2",2);
00497       hSEff2->setBinLabel(13,"ME +1/3",2);
00498       hSEff2->setBinLabel(14,"ME +2/1",2);
00499       hSEff2->setBinLabel(15,"ME +2/2",2);
00500       hSEff2->setBinLabel(16,"ME +3/1",2);
00501       hSEff2->setBinLabel(17,"ME +3/2",2);
00502       hSEff2->setBinLabel(18,"ME +4/1",2);
00503       hRHEff2 = dbe->book2D("hRHEff2","recHit Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
00504       hRHEff2->setAxisTitle("Chamber #");
00505       hRHEff2->setBinLabel(1,"ME -4/1",2);
00506       hRHEff2->setBinLabel(2,"ME -3/2",2);
00507       hRHEff2->setBinLabel(3,"ME -2/1",2);
00508       hRHEff2->setBinLabel(4,"ME -2/2",2);
00509       hRHEff2->setBinLabel(5,"ME -2/1",2);
00510       hRHEff2->setBinLabel(6,"ME -1/3",2);
00511       hRHEff2->setBinLabel(7,"ME -1/2",2);
00512       hRHEff2->setBinLabel(8,"ME -1/1b",2);
00513       hRHEff2->setBinLabel(9,"ME -1/1a",2);
00514       hRHEff2->setBinLabel(10,"ME +1/1a",2);
00515       hRHEff2->setBinLabel(11,"ME +1/1b",2);
00516       hRHEff2->setBinLabel(12,"ME +1/2",2);
00517       hRHEff2->setBinLabel(13,"ME +1/3",2);
00518       hRHEff2->setBinLabel(14,"ME +2/1",2);
00519       hRHEff2->setBinLabel(15,"ME +2/2",2);
00520       hRHEff2->setBinLabel(16,"ME +3/1",2);
00521       hRHEff2->setBinLabel(17,"ME +3/2",2);
00522       hRHEff2->setBinLabel(18,"ME +4/1",2);
00523       hStripEff2 = dbe->book2D("hStripEff2","strip Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
00524       hStripEff2->setAxisTitle("Chamber #");
00525       hStripEff2->setBinLabel(1,"ME -4/1",2);
00526       hStripEff2->setBinLabel(2,"ME -3/2",2);
00527       hStripEff2->setBinLabel(3,"ME -2/1",2);
00528       hStripEff2->setBinLabel(4,"ME -2/2",2);
00529       hStripEff2->setBinLabel(5,"ME -2/1",2);
00530       hStripEff2->setBinLabel(6,"ME -1/3",2);
00531       hStripEff2->setBinLabel(7,"ME -1/2",2);
00532       hStripEff2->setBinLabel(8,"ME -1/1b",2);
00533       hStripEff2->setBinLabel(9,"ME -1/1a",2);
00534       hStripEff2->setBinLabel(10,"ME +1/1a",2);
00535       hStripEff2->setBinLabel(11,"ME +1/1b",2);
00536       hStripEff2->setBinLabel(12,"ME +1/2",2);
00537       hStripEff2->setBinLabel(13,"ME +1/3",2);
00538       hStripEff2->setBinLabel(14,"ME +2/1",2);
00539       hStripEff2->setBinLabel(15,"ME +2/2",2);
00540       hStripEff2->setBinLabel(16,"ME +3/1",2);
00541       hStripEff2->setBinLabel(17,"ME +3/2",2);
00542       hStripEff2->setBinLabel(18,"ME +4/1",2);
00543       hWireEff2 = dbe->book2D("hWireEff2","wire Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
00544       hWireEff2->setAxisTitle("Chamber #");
00545       hWireEff2->setBinLabel(1,"ME -4/1",2);
00546       hWireEff2->setBinLabel(2,"ME -3/2",2);
00547       hWireEff2->setBinLabel(3,"ME -2/1",2);
00548       hWireEff2->setBinLabel(4,"ME -2/2",2);
00549       hWireEff2->setBinLabel(5,"ME -2/1",2);
00550       hWireEff2->setBinLabel(6,"ME -1/3",2);
00551       hWireEff2->setBinLabel(7,"ME -1/2",2);
00552       hWireEff2->setBinLabel(8,"ME -1/1b",2);
00553       hWireEff2->setBinLabel(9,"ME -1/1a",2);
00554       hWireEff2->setBinLabel(10,"ME +1/1a",2);
00555       hWireEff2->setBinLabel(11,"ME +1/1b",2);
00556       hWireEff2->setBinLabel(12,"ME +1/2",2);
00557       hWireEff2->setBinLabel(13,"ME +1/3",2);
00558       hWireEff2->setBinLabel(14,"ME +2/1",2);
00559       hWireEff2->setBinLabel(15,"ME +2/2",2);
00560       hWireEff2->setBinLabel(16,"ME +3/1",2);
00561       hWireEff2->setBinLabel(17,"ME +3/2",2);
00562       hWireEff2->setBinLabel(18,"ME +4/1",2);
00563       hSensitiveAreaEvt = dbe->book2D("hSensitiveAreaEvt","Events Passing Selection for Efficiency",36,0.5,36.5, 18, 0.5, 18.5);
00564       hSensitiveAreaEvt->setAxisTitle("Chamber #");
00565       hSensitiveAreaEvt->setBinLabel(1,"ME -4/1",2);
00566       hSensitiveAreaEvt->setBinLabel(2,"ME -3/2",2);
00567       hSensitiveAreaEvt->setBinLabel(3,"ME -2/1",2);
00568       hSensitiveAreaEvt->setBinLabel(4,"ME -2/2",2);
00569       hSensitiveAreaEvt->setBinLabel(5,"ME -2/1",2);
00570       hSensitiveAreaEvt->setBinLabel(6,"ME -1/3",2);
00571       hSensitiveAreaEvt->setBinLabel(7,"ME -1/2",2);
00572       hSensitiveAreaEvt->setBinLabel(8,"ME -1/1b",2);
00573       hSensitiveAreaEvt->setBinLabel(9,"ME -1/1a",2);
00574       hSensitiveAreaEvt->setBinLabel(10,"ME +1/1a",2);
00575       hSensitiveAreaEvt->setBinLabel(11,"ME +1/1b",2);
00576       hSensitiveAreaEvt->setBinLabel(12,"ME +1/2",2);
00577       hSensitiveAreaEvt->setBinLabel(13,"ME +1/3",2);
00578       hSensitiveAreaEvt->setBinLabel(14,"ME +2/1",2);
00579       hSensitiveAreaEvt->setBinLabel(15,"ME +2/2",2);
00580       hSensitiveAreaEvt->setBinLabel(16,"ME +3/1",2);
00581       hSensitiveAreaEvt->setBinLabel(17,"ME +3/2",2);
00582       hSensitiveAreaEvt->setBinLabel(18,"ME +4/1",2);
00583 
00584 }
00585 
00587 //  DESTRUCTOR  //
00589 CSCOfflineMonitor::~CSCOfflineMonitor(){
00590 
00591 }
00592 
00593 void CSCOfflineMonitor::endJob(void) {
00594 
00595   hRHEff = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hRHEff");
00596   hSEff = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hSEff");
00597   hSEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hSEff2");
00598   hRHEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hRHEff2");
00599   hStripEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hStripEff2");
00600   hWireEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hWireEff2");
00601 
00602   if (hRHEff) histoEfficiency(hRHSTE,hRHEff);
00603   if (hSEff) histoEfficiency(hSSTE,hSEff);
00604   if (hSEff2) hSEff2->getTH2F()->Divide(hSSTE2,hEffDenominator,1.,1.,"B");
00605   if (hRHEff2) hRHEff2->getTH2F()->Divide(hRHSTE2,hEffDenominator,1.,1.,"B");
00606   if (hStripEff2) hStripEff2->getTH2F()->Divide(hStripSTE2,hEffDenominator,1.,1.,"B");
00607   if (hWireEff2) hWireEff2->getTH2F()->Divide(hWireSTE2,hEffDenominator,1.,1.,"B");
00608 
00609   bool saveHistos = param.getParameter<bool>("saveHistos");
00610   string outputFileName = param.getParameter<string>("outputFileName");
00611   if(saveHistos){
00612     dbe->save(outputFileName);
00613   }
00614 
00615 }
00616 
00618 //  Analysis  //
00620 void CSCOfflineMonitor::analyze(const Event & event, const EventSetup& eventSetup){
00621 
00622   edm::Handle<CSCWireDigiCollection> wires;
00623   edm::Handle<CSCStripDigiCollection> strips;
00624   event.getByLabel(stripDigiTag_,strips);
00625   event.getByLabel(wireDigiTag_,wires);
00626 
00627   // Get the CSC Geometry :
00628   ESHandle<CSCGeometry> cscGeom;
00629   eventSetup.get<MuonGeometryRecord>().get(cscGeom);
00630 
00631   // Get the RecHits collection :
00632   Handle<CSCRecHit2DCollection> recHits;
00633   event.getByLabel(cscRecHitTag_,recHits);
00634 
00635   // get CSC segment collection
00636   Handle<CSCSegmentCollection> cscSegments;
00637   event.getByLabel(cscSegTag_, cscSegments);
00638 
00639 
00640   doOccupancies(strips,wires,recHits,cscSegments);
00641   doStripDigis(strips);
00642   doWireDigis(wires);
00643   doRecHits(recHits,strips,cscGeom);
00644   doSegments(cscSegments,cscGeom);
00645   doResolution(cscSegments,cscGeom);
00646   doPedestalNoise(strips);
00647   doEfficiencies(wires,strips, recHits, cscSegments,cscGeom);
00648 
00649 }
00650 
00651 // ==============================================
00652 //
00653 // look at Occupancies
00654 //
00655 // ==============================================
00656 
00657 void CSCOfflineMonitor::doOccupancies(edm::Handle<CSCStripDigiCollection> strips, edm::Handle<CSCWireDigiCollection> wires,
00658                                       edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments){
00659 
00660   bool wireo[2][4][4][36];
00661   bool stripo[2][4][4][36];
00662   bool rechito[2][4][4][36];
00663   bool segmento[2][4][4][36];
00664 
00665   bool hasWires = false;
00666   bool hasStrips = false;
00667   bool hasRecHits = false;
00668   bool hasSegments = false;
00669 
00670   for (int e = 0; e < 2; e++){
00671     for (int s = 0; s < 4; s++){
00672       for (int r = 0; r < 4; r++){
00673         for (int c = 0; c < 36; c++){
00674           wireo[e][s][r][c] = false;
00675           stripo[e][s][r][c] = false;
00676           rechito[e][s][r][c] = false;
00677           segmento[e][s][r][c] = false;
00678         }
00679       }
00680     }
00681   }
00682 
00683   //wires
00684   for (CSCWireDigiCollection::DigiRangeIterator wi=wires->begin(); wi!=wires->end(); wi++) {
00685     CSCDetId id = (CSCDetId)(*wi).first;
00686     int kEndcap  = id.endcap();
00687     int kRing    = id.ring();
00688     int kStation = id.station();
00689     int kChamber = id.chamber();
00690     std::vector<CSCWireDigi>::const_iterator wireIt = (*wi).second.first;
00691     std::vector<CSCWireDigi>::const_iterator lastWire = (*wi).second.second;
00692     for( ; wireIt != lastWire; ++wireIt){
00693       if (!wireo[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00694         wireo[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00695         hOWires->Fill(kChamber,typeIndex(id,2));
00696         hOWireSerial->Fill(chamberSerial(id));
00697         hasWires = true;
00698       }
00699     }
00700   }
00701   
00702   //strips
00703   for (CSCStripDigiCollection::DigiRangeIterator si=strips->begin(); si!=strips->end(); si++) {
00704     CSCDetId id = (CSCDetId)(*si).first;
00705     int kEndcap  = id.endcap();
00706     int kRing    = id.ring();
00707     int kStation = id.station();
00708     int kChamber = id.chamber();
00709     std::vector<CSCStripDigi>::const_iterator stripIt = (*si).second.first;
00710     std::vector<CSCStripDigi>::const_iterator lastStrip = (*si).second.second;
00711     for( ; stripIt != lastStrip; ++stripIt) {
00712       std::vector<int> myADCVals = stripIt->getADCCounts();
00713       bool thisStripFired = false;
00714       float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
00715       float threshold = 13.3 ;
00716       float diff = 0.;
00717       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
00718         diff = (float)myADCVals[iCount]-thisPedestal;
00719         if (diff > threshold) { thisStripFired = true; }
00720       }
00721       if (thisStripFired) {
00722         if (!stripo[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00723           stripo[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00724           hOStrips->Fill(kChamber,typeIndex(id,2));
00725           hOStripSerial->Fill(chamberSerial(id));
00726           hasStrips = true;
00727         }
00728       }
00729     }
00730   }
00731 
00732   //rechits
00733   CSCRecHit2DCollection::const_iterator recIt;
00734   for (recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
00735     CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
00736     int kEndcap  = idrec.endcap();
00737     int kRing    = idrec.ring();
00738     int kStation = idrec.station();
00739     int kChamber = idrec.chamber();
00740     if (!rechito[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00741       rechito[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00742       hORecHitsSerial->Fill(chamberSerial(idrec));
00743       hORecHits->Fill(kChamber,typeIndex(idrec,2));
00744       hasRecHits = true;
00745     }
00746   }
00747 
00748   //segments
00749   for(CSCSegmentCollection::const_iterator segIt=cscSegments->begin(); segIt != cscSegments->end(); segIt++) {
00750     CSCDetId id  = (CSCDetId)(*segIt).cscDetId();
00751     int kEndcap  = id.endcap();
00752     int kRing    = id.ring();
00753     int kStation = id.station();
00754     int kChamber = id.chamber();
00755     if (!segmento[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00756       segmento[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00757       hOSegmentsSerial->Fill(chamberSerial(id));
00758       hOSegments->Fill(kChamber,typeIndex(id,2));
00759       hasSegments = true;
00760     }
00761   }
00762 
00763   //Overall CSC Occupancy
00764   hCSCOccupancy->Fill(1);
00765   if (hasWires) hCSCOccupancy->Fill(3);
00766   if (hasStrips) hCSCOccupancy->Fill(5);
00767   if (hasWires && hasStrips) hCSCOccupancy->Fill(7);
00768   if (hasRecHits) hCSCOccupancy->Fill(9);
00769   if (hasSegments) hCSCOccupancy->Fill(11);
00770 
00771 
00772 }
00773 
00774 
00775 // ==============================================
00776 //
00777 // look at WIRE DIGIs
00778 //
00779 // ==============================================
00780 
00781 void CSCOfflineMonitor::doWireDigis(edm::Handle<CSCWireDigiCollection> wires){
00782 
00783   int nWireGroupsTotal = 0;
00784   for (CSCWireDigiCollection::DigiRangeIterator dWDiter=wires->begin(); dWDiter!=wires->end(); dWDiter++) {
00785     CSCDetId id = (CSCDetId)(*dWDiter).first;
00786     std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
00787     std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
00788     for( ; wireIter != lWire; ++wireIter) {
00789       int myWire = wireIter->getWireGroup();
00790       int myTBin = wireIter->getTimeBin();
00791       nWireGroupsTotal++;
00792       hWireTBin[typeIndex(id)-1]->Fill(myTBin);
00793       hWireNumber[typeIndex(id)-1]->Fill(myWire);
00794     }
00795   } // end wire loop
00796 
00797   // this way you can zero suppress but still store info on # events with no digis
00798   if (nWireGroupsTotal == 0) nWireGroupsTotal = -1;
00799   hWirenGroupsTotal->Fill(nWireGroupsTotal);
00800   
00801 }
00802 
00803 
00804 // ==============================================
00805 //
00806 // look at STRIP DIGIs
00807 //
00808 // ==============================================
00809 
00810 void CSCOfflineMonitor::doStripDigis(edm::Handle<CSCStripDigiCollection> strips){
00811 
00812   int nStripsFired = 0;
00813   for (CSCStripDigiCollection::DigiRangeIterator dSDiter=strips->begin(); dSDiter!=strips->end(); dSDiter++) {
00814     CSCDetId id = (CSCDetId)(*dSDiter).first;
00815     std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
00816     std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
00817     for( ; stripIter != lStrip; ++stripIter) {
00818       int myStrip = stripIter->getStrip();
00819       std::vector<int> myADCVals = stripIter->getADCCounts();
00820       bool thisStripFired = false;
00821       float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
00822       float threshold = 13.3 ;
00823       float diff = 0.;
00824       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
00825         diff = (float)myADCVals[iCount]-thisPedestal;
00826         if (diff > threshold) { thisStripFired = true; }
00827       } 
00828       if (thisStripFired) {
00829         nStripsFired++;
00830         hStripNumber[typeIndex(id)-1]->Fill(myStrip);
00831       }
00832     }
00833   } // end strip loop
00834 
00835   // this way you can zero suppress but still store info on # events with no digis
00836   if (nStripsFired == 0) nStripsFired = -1;
00837   hStripNFired->Fill(nStripsFired);
00838   // fill n per event
00839 
00840 }
00841 
00842 
00843 //=======================================================
00844 //
00845 // Look at the Pedestal Noise Distributions
00846 //
00847 //=======================================================
00848 
00849 void CSCOfflineMonitor::doPedestalNoise(edm::Handle<CSCStripDigiCollection> strips){
00850 
00851   for (CSCStripDigiCollection::DigiRangeIterator dPNiter=strips->begin(); dPNiter!=strips->end(); dPNiter++) {
00852     CSCDetId id = (CSCDetId)(*dPNiter).first;
00853     int kStation = id.station();
00854     int kRing = id.ring();
00855     std::vector<CSCStripDigi>::const_iterator pedIt = (*dPNiter).second.first;
00856     std::vector<CSCStripDigi>::const_iterator lStrip = (*dPNiter).second.second;
00857     for( ; pedIt != lStrip; ++pedIt) {
00858       int myStrip = pedIt->getStrip();
00859       std::vector<int> myADCVals = pedIt->getADCCounts();
00860       float TotalADC = getSignal(*strips, id, myStrip);
00861       bool thisStripFired = false;
00862       float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
00863       float thisSignal = (1./6)*(myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
00864       float threshold = 13.3;
00865       if(kStation == 1 && kRing == 4)
00866         {
00867           kRing = 1;
00868           if(myStrip <= 16) myStrip += 64; // no trapping for any bizarreness
00869         }
00870       if (TotalADC > threshold) { thisStripFired = true;}
00871       if (!thisStripFired){
00872         float ADC = thisSignal - thisPedestal;
00873         hStripPed[typeIndex(id)-1]->Fill(ADC);
00874       }
00875     }
00876   }
00877 
00878 }
00879 
00880 
00881 // ==============================================
00882 //
00883 // look at RECHITs
00884 //
00885 // ==============================================
00886 
00887 void CSCOfflineMonitor::doRecHits(edm::Handle<CSCRecHit2DCollection> recHits,
00888                                   edm::Handle<CSCStripDigiCollection> strips,
00889                                   edm::ESHandle<CSCGeometry> cscGeom){
00890 
00891   // Get the RecHits collection :
00892   int nRecHits = recHits->size();
00893  
00894   // ---------------------
00895   // Loop over rechits 
00896   // ---------------------
00897   // Build iterator for rechits and loop :
00898   CSCRecHit2DCollection::const_iterator dRHIter;
00899   for (dRHIter = recHits->begin(); dRHIter != recHits->end(); dRHIter++) {
00900 
00901     // Find chamber with rechits in CSC 
00902     CSCDetId idrec = (CSCDetId)(*dRHIter).cscDetId();
00903 
00904     // Store rechit as a Local Point:
00905     LocalPoint rhitlocal = (*dRHIter).localPosition();  
00906     //float xreco = rhitlocal.x();
00907     //float yreco = rhitlocal.y();
00908 
00909     // Get the reconstucted strip position and error
00910     float stpos = (*dRHIter).positionWithinStrip();
00911     float sterr = (*dRHIter).errorWithinStrip();
00912 
00913     // Find the charge associated with this hit
00914     CSCRecHit2D::ADCContainer adcs = (*dRHIter).adcs();
00915     int adcsize = adcs.size();
00916     float rHSumQ = 0;
00917     float sumsides = 0;
00918     for (int i = 0; i < adcsize; i++){
00919       if (i != 3 && i != 7 && i != 11){
00920         rHSumQ = rHSumQ + adcs[i]; 
00921       }
00922       if (adcsize == 12 && (i < 3 || i > 7) && i < 12){
00923         sumsides = sumsides + adcs[i];
00924       }
00925     }
00926     float rHratioQ = sumsides/rHSumQ;
00927     if (adcsize != 12) rHratioQ = -99;
00928 
00929     // Get the signal timing of this hit
00930     float rHtime = (*dRHIter).tpeak();
00931  
00932     // Get pointer to the layer:
00933     const CSCLayer* csclayer = cscGeom->layer( idrec );
00934 
00935     // Transform hit position from local chamber geometry to global CMS geom
00936     GlobalPoint rhitglobal= csclayer->toGlobal(rhitlocal);
00937     float grecx   =  rhitglobal.x();
00938     float grecy   =  rhitglobal.y();
00939 
00940     // Fill some histograms
00941     int sIndex = idrec.station() + ((idrec.endcap()-1) * 4);
00942     int tIndex = typeIndex(idrec);
00943     hRHSumQ[tIndex-1]->Fill(rHSumQ);
00944     hRHRatioQ[tIndex-1]->Fill(rHratioQ);
00945     hRHstpos[tIndex-1]->Fill(stpos);
00946     hRHsterr[tIndex-1]->Fill(sterr);
00947     hRHTiming[tIndex-1]->Fill(rHtime);
00948     hRHGlobal[sIndex-1]->Fill(grecx,grecy);
00949 
00950   } //end rechit loop
00951 
00952   if (nRecHits == 0) nRecHits = -1;
00953   hRHnrechits->Fill(nRecHits);
00954 
00955 }
00956 
00957 
00958 // ==============================================
00959 //
00960 // look at SEGMENTs
00961 //
00962 // ===============================================
00963 
00964 void CSCOfflineMonitor::doSegments(edm::Handle<CSCSegmentCollection> cscSegments,
00965                                    edm::ESHandle<CSCGeometry> cscGeom){
00966 
00967   // get CSC segment collection
00968   int nSegments = cscSegments->size();
00969 
00970   for(CSCSegmentCollection::const_iterator dSiter=cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
00971     CSCDetId id  = (CSCDetId)(*dSiter).cscDetId();
00972     float chisq    = (*dSiter).chi2();
00973     int nhits      = (*dSiter).nRecHits();
00974     int nDOF       = 2*nhits-4;
00975     float nChi2    = chisq/nDOF;
00976     double chisqProb = ChiSquaredProbability( (double)chisq, nDOF );
00977     //LocalPoint localPos = (*dSiter).localPosition();
00978     LocalVector segDir = (*dSiter).localDirection();
00979 
00980     // global transformation
00981     //float globX = 0.;
00982     //float globY = 0.;
00983     float globTheta = 0.;
00984     float globPhi   = 0.;
00985     const CSCChamber* cscchamber = cscGeom->chamber(id);
00986     if (cscchamber) {
00987       //GlobalPoint globalPosition = cscchamber->toGlobal(localPos);
00988       //globX = globalPosition.x();
00989       //globY = globalPosition.y();
00990       GlobalVector globalDirection = cscchamber->toGlobal(segDir);
00991       globTheta = globalDirection.theta();
00992       globPhi   = globalDirection.phi();
00993     }
00994 
00995     // Fill histos
00996     int tIndex = typeIndex(id);
00997     hSnhitsAll->Fill(nhits);
00998     hSnhits[tIndex-1]->Fill(nhits);
00999     hSChiSqAll->Fill(nChi2);
01000     hSChiSq[tIndex-1]->Fill(nChi2);
01001     hSChiSqProbAll->Fill(chisqProb);
01002     hSChiSqProb[tIndex-1]->Fill(chisqProb);
01003     hSGlobalTheta->Fill(globTheta);
01004     hSGlobalPhi->Fill(globPhi);
01005 
01006 
01007   } // end segment loop
01008 
01009   if (nSegments == 0) nSegments = -1;
01010   hSnSegments->Fill(nSegments);
01011 
01012 }
01013 
01014 // ==============================================
01015 //
01016 // look at hit Resolution
01017 //
01018 // ==============================================
01019 void CSCOfflineMonitor::doResolution(edm::Handle<CSCSegmentCollection> cscSegments,
01020                                      edm::ESHandle<CSCGeometry> cscGeom){
01021 
01022   for(CSCSegmentCollection::const_iterator dSiter=cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
01023     CSCDetId id  = (CSCDetId)(*dSiter).cscDetId();
01024     //
01025     // try to get the CSC recHits that contribute to this segment.
01026     std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
01027     int nRH = (*dSiter).nRecHits();
01028     int jRH = 0;
01029     CLHEP::HepMatrix sp(6,1);
01030     CLHEP::HepMatrix se(6,1);
01031     for ( vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
01032       jRH++;
01033       CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
01034       //int kEndcap  = idRH.endcap();
01035       int kRing    = idRH.ring();
01036       int kStation = idRH.station();
01037       //int kChamber = idRH.chamber();
01038       int kLayer   = idRH.layer();
01039 
01040       // Find the strip containing this hit
01041       CSCRecHit2D::ChannelContainer hitstrips = (*iRH).channels();
01042       int nStrips     =  hitstrips.size();
01043       int centerid    =  nStrips/2 + 1;
01044       int centerStrip =  hitstrips[centerid - 1];
01045 
01046       // If this segment has 6 hits, find the position of each hit on the strip in units of stripwidth and store values
01047       if (nRH == 6){
01048         float stpos = (*iRH).positionWithinStrip();
01049         se(kLayer,1) = (*iRH).errorWithinStrip();
01050         // Take into account half-strip staggering of layers (ME1/1 has no staggering)
01051         if (kStation == 1 && (kRing == 1 || kRing == 4)) sp(kLayer,1) = stpos + centerStrip;
01052         else{
01053           if (kLayer == 1 || kLayer == 3 || kLayer == 5) sp(kLayer,1) = stpos + centerStrip;
01054           if (kLayer == 2 || kLayer == 4 || kLayer == 6) sp(kLayer,1) = stpos - 0.5 + centerStrip;
01055         }
01056       }
01057 
01058     }
01059 
01060     float residual = -99;
01061     // Fit all points except layer 3, then compare expected value for layer 3 to reconstructed value
01062     if (nRH == 6){
01063       float expected = fitX(sp,se);
01064       residual = expected - sp(3,1);
01065     }
01066 
01067     hSResid[typeIndex(id)-1]->Fill(residual);
01068 
01069   } // end segment loop
01070 
01071 
01072 
01073 }
01074 
01075 
01076 //-------------------------------------------------------------------------------------
01077 // Fits a straight line to a set of 5 points with errors.  Functions assumes 6 points
01078 // and removes hit in layer 3.  It then returns the expected position value in layer 3
01079 // based on the fit.
01080 //-------------------------------------------------------------------------------------
01081 float CSCOfflineMonitor::fitX(CLHEP::HepMatrix points, CLHEP::HepMatrix errors){
01082 
01083   float S   = 0;
01084   float Sx  = 0;
01085   float Sy  = 0;
01086   float Sxx = 0;
01087   float Sxy = 0;
01088   float sigma2 = 0;
01089 
01090   for (int i=1;i<7;i++){
01091     if (i != 3){
01092       sigma2 = errors(i,1)*errors(i,1);
01093       S = S + (1/sigma2);
01094       Sy = Sy + (points(i,1)/sigma2);
01095       Sx = Sx + ((i)/sigma2);
01096       Sxx = Sxx + (i*i)/sigma2;
01097       Sxy = Sxy + (((i)*points(i,1))/sigma2);
01098     }
01099   }
01100 
01101   float delta = S*Sxx - Sx*Sx;
01102   float intercept = (Sxx*Sy - Sx*Sxy)/delta;
01103   float slope = (S*Sxy - Sx*Sy)/delta;
01104 
01105   return (intercept + slope*3);
01106 
01107 }
01108 
01109 //---------------------------------------------------------------------------------------
01110 // Given a set of digis, the CSCDetId, and the central strip of your choosing, returns
01111 // the avg. Signal-Pedestal for 6 time bin x 5 strip .
01112 //
01113 // Author: P. Jindal
01114 //---------------------------------------------------------------------------------------
01115 
01116 float CSCOfflineMonitor::getSignal(const CSCStripDigiCollection& stripdigis, 
01117                                    CSCDetId idCS, int centerStrip){
01118 
01119   float SigADC[5];
01120   float TotalADC = 0;
01121   SigADC[0] = 0;
01122   SigADC[1] = 0;
01123   SigADC[2] = 0;
01124   SigADC[3] = 0;
01125   SigADC[4] = 0;
01126 
01127  
01128   // Loop over strip digis 
01129   CSCStripDigiCollection::DigiRangeIterator sIt;
01130   
01131   for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++){
01132     CSCDetId id = (CSCDetId)(*sIt).first;
01133     if (id == idCS){
01134 
01135       // First, find the Signal-Pedestal for center strip
01136       vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
01137       vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
01138       for ( ; digiItr != last; ++digiItr ) {
01139         int thisStrip = digiItr->getStrip();
01140         if (thisStrip == (centerStrip)){
01141           std::vector<int> myADCVals = digiItr->getADCCounts();
01142           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01143           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01144           SigADC[0] = thisSignal - 6*thisPedestal;
01145         }
01146      // Now,find the Signal-Pedestal for neighbouring 4 strips
01147         if (thisStrip == (centerStrip+1)){
01148           std::vector<int> myADCVals = digiItr->getADCCounts();
01149           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01150           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01151           SigADC[1] = thisSignal - 6*thisPedestal;
01152         }
01153         if (thisStrip == (centerStrip+2)){
01154           std::vector<int> myADCVals = digiItr->getADCCounts();
01155           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01156           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01157           SigADC[2] = thisSignal - 6*thisPedestal;
01158         }
01159         if (thisStrip == (centerStrip-1)){
01160           std::vector<int> myADCVals = digiItr->getADCCounts();
01161           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01162           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01163           SigADC[3] = thisSignal - 6*thisPedestal;
01164         }
01165         if (thisStrip == (centerStrip-2)){
01166           std::vector<int> myADCVals = digiItr->getADCCounts();
01167           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01168           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01169           SigADC[4] = thisSignal - 6*thisPedestal;
01170         }
01171       }
01172       TotalADC = 0.2*(SigADC[0]+SigADC[1]+SigADC[2]+SigADC[3]+SigADC[4]);
01173     }
01174   }
01175   return TotalADC;
01176 }
01177 
01178 
01179 
01180 //----------------------------------------------------------------------------
01181 // Calculate basic efficiencies for recHits and Segments
01182 // Author: S. Stoynev
01183 //----------------------------------------------------------------------------
01184 
01185 void CSCOfflineMonitor::doEfficiencies(edm::Handle<CSCWireDigiCollection> wires, edm::Handle<CSCStripDigiCollection> strips,
01186                                        edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
01187                                        edm::ESHandle<CSCGeometry> cscGeom){
01188 
01189   bool allWires[2][4][4][36][6];
01190   bool allStrips[2][4][4][36][6];
01191   bool AllRecHits[2][4][4][36][6];
01192   bool AllSegments[2][4][4][36];
01193   
01194   //bool MultiSegments[2][4][4][36];
01195   for(int iE = 0;iE<2;iE++){
01196     for(int iS = 0;iS<4;iS++){
01197       for(int iR = 0; iR<4;iR++){
01198         for(int iC =0;iC<36;iC++){
01199           AllSegments[iE][iS][iR][iC] = false;
01200           //MultiSegments[iE][iS][iR][iC] = false;
01201           for(int iL=0;iL<6;iL++){
01202             allWires[iE][iS][iR][iC][iL] = false;
01203             allStrips[iE][iS][iR][iC][iL] = false;
01204             AllRecHits[iE][iS][iR][iC][iL] = false;
01205           }
01206         }
01207       }
01208     }
01209   }
01210   
01211   
01212   // Wires
01213   for (CSCWireDigiCollection::DigiRangeIterator dWDiter=wires->begin(); dWDiter!=wires->end(); dWDiter++) {
01214     CSCDetId idrec = (CSCDetId)(*dWDiter).first;
01215     std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
01216     std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
01217     for( ; wireIter != lWire; ++wireIter) {
01218       allWires[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01219       break;
01220     }
01221   }
01222 
01223   //---- STRIPS
01224   for (CSCStripDigiCollection::DigiRangeIterator dSDiter=strips->begin(); dSDiter!=strips->end(); dSDiter++) {
01225     CSCDetId idrec = (CSCDetId)(*dSDiter).first;
01226     std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
01227     std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
01228     for( ; stripIter != lStrip; ++stripIter) {
01229       std::vector<int> myADCVals = stripIter->getADCCounts();
01230       bool thisStripFired = false;
01231       float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01232       float threshold = 13.3 ;
01233       float diff = 0.;
01234       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
01235         diff = (float)myADCVals[iCount]-thisPedestal;
01236         if (diff > threshold) {
01237           thisStripFired = true;
01238           break;
01239         }
01240       }
01241       if(thisStripFired){
01242         allStrips[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01243         break;
01244       }
01245     }
01246   }
01247 
01248   // Rechits
01249   for (CSCRecHit2DCollection::const_iterator recEffIt = recHits->begin(); recEffIt != recHits->end(); recEffIt++) {
01250     //CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
01251     CSCDetId  idrec = (CSCDetId)(*recEffIt).cscDetId();
01252     AllRecHits[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01253 
01254   }
01255 
01256   std::vector <uint> seg_ME2(2,0) ;
01257   std::vector <uint> seg_ME3(2,0) ;
01258   std::vector < pair <CSCDetId, CSCSegment> > theSegments(4);
01259   // Segments
01260   for(CSCSegmentCollection::const_iterator segEffIt=cscSegments->begin(); segEffIt != cscSegments->end(); segEffIt++) {
01261     CSCDetId idseg  = (CSCDetId)(*segEffIt).cscDetId();
01262     //if(AllSegments[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber()]){
01263     //MultiSegments[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber()] = true;
01264     //}
01265     AllSegments[idseg.endcap() -1][idseg.station() -1][idseg.ring() -1][idseg.chamber() -1] = true;
01266     // "Intrinsic" efficiency measurement relies on "good" segment extrapolation - we need the pre-selection below
01267     // station 2 "good" segment will be used for testing efficiencies in ME1 and ME3
01268     // station 3 "good" segment will be used for testing efficiencies in ME2 and ME4
01269     if(2==idseg.station() || 3==idseg.station()){
01270       uint seg_tmp ; 
01271       if(2==idseg.station()){
01272         ++seg_ME2[idseg.endcap() -1];
01273         seg_tmp = seg_ME2[idseg.endcap() -1];
01274       }
01275       else{
01276         ++seg_ME3[idseg.endcap() -1];
01277         seg_tmp = seg_ME3[idseg.endcap() -1];
01278       }
01279       // is the segment good
01280       if(1== seg_tmp&& 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
01281         pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
01282         theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
01283       }
01284     }
01285     /*
01286     if(2==idseg.station()){
01287         ++seg_ME2[idseg.endcap() -1];
01288        if(1==seg_ME2[idseg.endcap() -1] && 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
01289            pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
01290            theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
01291        }
01292     }
01293     else if(3==idseg.station()){
01294         ++seg_ME3[idseg.endcap() -1];
01295         if(1==seg_ME3[idseg.endcap() -1] && 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
01296          pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
01297          theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
01298        }
01299     }
01300     */
01301     
01302   }
01303   // Simple efficiency calculations
01304   for(int iE = 0;iE<2;iE++){
01305     for(int iS = 0;iS<4;iS++){
01306       for(int iR = 0; iR<4;iR++){
01307         for(int iC =0;iC<36;iC++){
01308           int NumberOfLayers = 0;
01309           for(int iL=0;iL<6;iL++){
01310             if(AllRecHits[iE][iS][iR][iC][iL]){
01311               NumberOfLayers++;
01312             }
01313           }
01314           int bin = 0;
01315           if (iS==0) bin = iR+1+(iE*10);
01316           else bin = (iS+1)*2 + (iR+1) + (iE*10);
01317           if(NumberOfLayers>1){
01318             //if(!(MultiSegments[iE][iS][iR][iC])){
01319             if(AllSegments[iE][iS][iR][iC]){
01320               //---- Efficient segment evenents
01321               hSSTE->Fill(bin);
01322             }
01323             //---- All segment events (normalization)
01324             hSSTE->Fill(20+bin);
01325             //}
01326           }
01327           if(AllSegments[iE][iS][iR][iC]){
01328             if(NumberOfLayers==6){
01329               //---- Efficient rechit events
01330               hRHSTE->Fill(bin);;
01331             }
01332             //---- All rechit events (normalization)
01333             hRHSTE->Fill(20+bin);;
01334           }
01335         }
01336       }
01337     }
01338   }
01339 
01340   // pick a segment only if there are no others in the station
01341   std::vector < pair <CSCDetId, CSCSegment> * > theSeg;
01342   if(1==seg_ME2[0]) theSeg.push_back(&theSegments[0]);
01343   if(1==seg_ME3[0]) theSeg.push_back(&theSegments[1]);
01344   if(1==seg_ME2[1]) theSeg.push_back(&theSegments[2]);
01345   if(1==seg_ME3[1]) theSeg.push_back(&theSegments[3]);
01346 
01347   // Needed for plots
01348   // at the end the chamber types will be numbered as 1 to 18 
01349   // (ME-4/1, -ME3/2, -ME3/1, ..., +ME3/1, +ME3/2, ME+4/1 ) 
01350   std::map <std::string, float> chamberTypes;
01351   chamberTypes["ME1/a"] = 0.5;
01352   chamberTypes["ME1/b"] = 1.5;
01353   chamberTypes["ME1/2"] = 2.5;
01354   chamberTypes["ME1/3"] = 3.5;
01355   chamberTypes["ME2/1"] = 4.5;
01356   chamberTypes["ME2/2"] = 5.5;
01357   chamberTypes["ME3/1"] = 6.5;
01358   chamberTypes["ME3/2"] = 7.5;
01359   chamberTypes["ME4/1"] = 8.5;
01360 
01361   if(theSeg.size()){
01362     std::map <int , GlobalPoint> extrapolatedPoint;
01363     std::map <int , GlobalPoint>::iterator it;
01364     const std::vector<CSCChamber*> ChamberContainer = cscGeom->chambers();
01365     // Pick which chamber with which segment to test
01366     for(unsigned int nCh=0;nCh<ChamberContainer.size();nCh++){
01367       const CSCChamber *cscchamber = ChamberContainer[nCh];
01368       pair <CSCDetId, CSCSegment> * thisSegment = 0;
01369       for(uint iSeg =0;iSeg<theSeg.size();++iSeg ){
01370         if(cscchamber->id().endcap() == theSeg[iSeg]->first.endcap()){ 
01371           if(1==cscchamber->id().station() || 3==cscchamber->id().station() ){
01372             if(2==theSeg[iSeg]->first.station()){
01373               thisSegment = theSeg[iSeg];
01374             }
01375           }
01376           else if (2==cscchamber->id().station() || 4==cscchamber->id().station()){
01377             if(3==theSeg[iSeg]->first.station()){
01378               thisSegment = theSeg[iSeg];
01379             }
01380           }
01381         }
01382       }
01383       // this chamber is to be tested with thisSegment
01384       if(thisSegment){
01385         CSCSegment * seg = &(thisSegment->second);
01386         const CSCChamber *segChamber = cscGeom->chamber(thisSegment->first);
01387         LocalPoint localCenter(0.,0.,0);
01388         GlobalPoint cscchamberCenter =  cscchamber->toGlobal(localCenter);
01389         // try to save some time (extrapolate a segment to a certain position only once)
01390         it = extrapolatedPoint.find(int(cscchamberCenter.z()));
01391         if(it==extrapolatedPoint.end()){
01392           GlobalPoint segPos = segChamber->toGlobal(seg->localPosition());
01393           GlobalVector segDir = segChamber->toGlobal(seg->localDirection());
01394           double paramaterLine = lineParametrization(segPos.z(),cscchamberCenter.z() , segDir.z());
01395           double xExtrapolated = extrapolate1D(segPos.x(),segDir.x(), paramaterLine);
01396           double yExtrapolated = extrapolate1D(segPos.y(),segDir.y(), paramaterLine);
01397           GlobalPoint globP (xExtrapolated, yExtrapolated, cscchamberCenter.z());
01398           extrapolatedPoint[int(cscchamberCenter.z())] = globP;
01399         }
01400         // Where does the extrapolated point lie in the (tested) chamber local frame? Here: 
01401         LocalPoint extrapolatedPointLocal = cscchamber->toLocal(extrapolatedPoint[int(cscchamberCenter.z())]);
01402         const CSCLayer *layer_p = cscchamber->layer(1);//layer 1
01403         const CSCLayerGeometry *layerGeom = layer_p->geometry ();
01404         const std::vector<float> layerBounds = layerGeom->parameters ();
01405         float shiftFromEdge = 15.;//cm
01406         float shiftFromDeadZone = 10.;
01407         // is the extrapolated point within a sensitive region
01408         bool pass = withinSensitiveRegion(extrapolatedPointLocal, layerBounds, 
01409                                           cscchamber->id().station(), cscchamber->id().ring(), 
01410                                           shiftFromEdge, shiftFromDeadZone);
01411         if(pass){// the extrapolation point of the segment lies within sensitive region of that chamber
01412           // how many rechit layers are there in the chamber?
01413           // 0 - maybe the muon died or is deflected at large angle? do not use that case
01414           // 1 - could be noise...
01415           // 2 or more - this is promissing; this is our definition of a reliable signal; use it below
01416           // is other definition better? 
01417           int nRHLayers = 0;
01418           for(int iL =0;iL<6;++iL){
01419             if(AllRecHits[cscchamber->id().endcap()-1]
01420                [cscchamber->id().station()-1]
01421                [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01422               ++nRHLayers;
01423             }
01424           }
01425           //std::cout<<" nRHLayers = "<<nRHLayers<<std::endl;
01426           float verticalScale = chamberTypes[cscchamber->specs()->chamberTypeName()];
01427           if(cscchamberCenter.z()<0){
01428             verticalScale = - verticalScale;
01429           } 
01430           verticalScale +=9.5;
01431           hSensitiveAreaEvt->Fill(float(cscchamber->id().chamber()),verticalScale);
01432           if(nRHLayers>1){// this chamber contains a reliable signal
01433             //chamberTypes[cscchamber->specs()->chamberTypeName()];
01434             // "intrinsic" efficiencies
01435             //std::cout<<" verticalScale = "<<verticalScale<<" chType = "<<cscchamber->specs()->chamberTypeName()<<std::endl;
01436             // this is the denominator forr all efficiencies
01437             hEffDenominator->Fill(float(cscchamber->id().chamber()),verticalScale);
01438             // Segment efficiency
01439             if(AllSegments[cscchamber->id().endcap()-1]
01440                [cscchamber->id().station()-1]
01441                [cscchamber->id().ring()-1][cscchamber->id().chamber()-1]){
01442               hSSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale));
01443             }
01444           
01445             for(int iL =0;iL<6;++iL){
01446               float weight = 1./6.;
01447               // one shold account for the weight in the efficiency...
01448               // Rechit efficiency
01449               if(AllRecHits[cscchamber->id().endcap()-1]
01450                  [cscchamber->id().station()-1]
01451                  [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01452                 hRHSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01453               }
01454               // Wire efficiency
01455               if(allWires[cscchamber->id().endcap()-1]
01456                  [cscchamber->id().station()-1]
01457                  [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01458                 // one shold account for the weight in the efficiency...
01459                 hWireSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01460               }
01461               // Strip efficiency
01462               if(allStrips[cscchamber->id().endcap()-1]
01463                  [cscchamber->id().station()-1]
01464                  [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01465                 // one shold account for the weight in the efficiency...
01466                 hStripSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01467               }
01468             }
01469           }
01470         }
01471       }
01472     }
01473   }
01474   //
01475 
01476 
01477 }
01478 
01479 void CSCOfflineMonitor::getEfficiency(float bin, float Norm, std::vector<float> &eff){
01480   //---- Efficiency with binomial error
01481   float Efficiency = 0.;
01482   float EffError = 0.;
01483   if(fabs(Norm)>0.000000001){
01484     Efficiency = bin/Norm;
01485     if(bin<Norm){
01486       EffError = sqrt( (1.-Efficiency)*Efficiency/Norm );
01487     }
01488   }
01489   eff[0] = Efficiency;
01490   eff[1] = EffError;
01491 }
01492 
01493 void CSCOfflineMonitor::histoEfficiency(TH1F *readHisto, MonitorElement *writeHisto){
01494   std::vector<float> eff(2);
01495   int Nbins =  readHisto->GetSize()-2;//without underflows and overflows
01496   std::vector<float> bins(Nbins);
01497   std::vector<float> Efficiency(Nbins);
01498   std::vector<float> EffError(Nbins);
01499   float Num = 1;
01500   float Den = 1;
01501   for (int i=0;i<20;i++){
01502     Num = readHisto->GetBinContent(i+1);
01503     Den = readHisto->GetBinContent(i+21);
01504     getEfficiency(Num, Den, eff);
01505     Efficiency[i] = eff[0];
01506     EffError[i] = eff[1];
01507     writeHisto->setBinContent(i+1, Efficiency[i]);
01508     writeHisto->setBinError(i+1, EffError[i]);
01509   }
01510 }
01511 
01512 bool CSCOfflineMonitor::withinSensitiveRegion(LocalPoint localPos, const std::vector<float> layerBounds,
01513                                               int station, int ring, float shiftFromEdge, float shiftFromDeadZone){
01514 //---- check if it is in a good local region (sensitive area - geometrical and HV boundaries excluded) 
01515   bool pass = false;
01516 
01517   float y_center = 0.;
01518   double yUp = layerBounds[3] + y_center;
01519   double yDown = - layerBounds[3] + y_center;
01520   double xBound1Shifted = layerBounds[0] - shiftFromEdge;//
01521   double xBound2Shifted = layerBounds[1] - shiftFromEdge;//
01522   double lineSlope = (yUp - yDown)/(xBound2Shifted-xBound1Shifted);
01523   double lineConst = yUp - lineSlope*xBound2Shifted;
01524   double yBorder =  lineSlope*abs(localPos.x()) + lineConst;
01525       
01526   //bool withinChamberOnly = false;// false = "good region"; true - boundaries only
01527   std::vector <float> deadZoneCenter(6);
01528   float cutZone = shiftFromDeadZone;//cm
01529   //---- hardcoded... not good
01530   if(station>1 && station<5){
01531     if(2==ring){
01532       deadZoneCenter[0]= -162.48 ;
01533       deadZoneCenter[1] = -81.8744;
01534       deadZoneCenter[2] = -21.18165;
01535       deadZoneCenter[3] = 39.51105;
01536       deadZoneCenter[4] = 100.2939;
01537       deadZoneCenter[5] = 160.58;
01538       
01539       if(localPos.y() >yBorder &&
01540          ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
01541           (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
01542           (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone) ||
01543           (localPos.y()> deadZoneCenter[3] + cutZone && localPos.y()< deadZoneCenter[4] - cutZone) ||
01544           (localPos.y()> deadZoneCenter[4] + cutZone && localPos.y()< deadZoneCenter[5] - cutZone))){
01545         pass = true;
01546       }
01547     }
01548     else if(1==ring){
01549       if(2==station){
01550         deadZoneCenter[0]= -95.80 ;
01551         deadZoneCenter[1] = -27.47;
01552         deadZoneCenter[2] = 33.67;
01553         deadZoneCenter[3] = 90.85;
01554         }
01555       else if(3==station){
01556         deadZoneCenter[0]= -89.305 ;
01557         deadZoneCenter[1] = -39.705;
01558         deadZoneCenter[2] = 20.195;
01559         deadZoneCenter[3] = 77.395;
01560       }
01561       else if(4==station){
01562         deadZoneCenter[0]= -75.645;
01563         deadZoneCenter[1] = -26.055;
01564         deadZoneCenter[2] = 23.855;
01565         deadZoneCenter[3] = 70.575;
01566       }
01567       if(localPos.y() >yBorder &&
01568          ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
01569           (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
01570           (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
01571         pass = true;
01572       }
01573     }
01574   }
01575   else if(1==station){
01576     if(3==ring){
01577       deadZoneCenter[0]= -83.155 ;
01578       deadZoneCenter[1] = -22.7401;
01579       deadZoneCenter[2] = 27.86665;
01580       deadZoneCenter[3] = 81.005;
01581       if(localPos.y() > yBorder &&
01582          ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
01583           (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
01584           (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
01585         pass = true;
01586       }
01587     }
01588     else if(2==ring){
01589       deadZoneCenter[0]= -86.285 ;
01590       deadZoneCenter[1] = -32.88305;
01591       deadZoneCenter[2] = 32.867423;
01592       deadZoneCenter[3] = 88.205;
01593       if(localPos.y() > (yBorder) &&
01594          ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
01595           (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
01596           (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
01597         pass = true;
01598       }
01599     }
01600     else{
01601       deadZoneCenter[0]= -81.0;
01602       deadZoneCenter[1] = 81.0;
01603       if(localPos.y() > (yBorder) &&
01604          (localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone )){
01605         pass = true;
01606       }
01607     }
01608   }
01609   return pass;
01610 }
01611 
01612 
01613 int CSCOfflineMonitor::typeIndex(CSCDetId id, int flag){
01614   
01615   if (flag == 1){
01616     // linearlized index bases on endcap, station, and ring
01617     int index = 0;
01618     if (id.station() == 1) index = id.ring();
01619     else index = id.station()*2 + id.ring();
01620     if (id.endcap() == 1) index = index + 10;
01621     if (id.endcap() == 2) index = 11 - index;
01622     return index;
01623   }
01624 
01625   else if (flag == 2){
01626     int index = 0;
01627     if (id.station() == 1 && id.ring() != 4) index = id.ring()+1;
01628     if (id.station() == 1 && id.ring() == 4) index = 1; 
01629     if (id.station() != 1) index = id.station()*2 + id.ring();
01630     if (id.endcap() == 1) index = index + 10;
01631     if (id.endcap() == 2) index = 11 - index;
01632     return index;
01633   }
01634 
01635   else return 0;
01636 
01637 }
01638 
01639 int CSCOfflineMonitor::chamberSerial( CSCDetId id ) {
01640   int st = id.station();
01641   int ri = id.ring();
01642   int ch = id.chamber();
01643   int ec = id.endcap();
01644   int kSerial = ch;
01645   if (st == 1 && ri == 1) kSerial = ch;
01646   if (st == 1 && ri == 2) kSerial = ch + 36;
01647   if (st == 1 && ri == 3) kSerial = ch + 72;
01648   if (st == 1 && ri == 4) kSerial = ch;
01649   if (st == 2 && ri == 1) kSerial = ch + 108;
01650   if (st == 2 && ri == 2) kSerial = ch + 126;
01651   if (st == 3 && ri == 1) kSerial = ch + 162;
01652   if (st == 3 && ri == 2) kSerial = ch + 180;
01653   if (st == 4 && ri == 1) kSerial = ch + 216;
01654   if (st == 4 && ri == 2) kSerial = ch + 234;  // one day...
01655   if (ec == 2) kSerial = kSerial + 300;
01656   return kSerial;
01657 }
01658 
01659 
01660 
01661 DEFINE_FWK_MODULE(CSCOfflineMonitor);
01662