CMS 3D CMS Logo

CMSSW_4_4_3_patch1/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   alctDigiTag_   = pset.getParameter<edm::InputTag>("alctDigiTag");
00024   clctDigiTag_   = pset.getParameter<edm::InputTag>("clctDigiTag"); 
00025   cscRecHitTag_  = pset.getParameter<edm::InputTag>("cscRecHitTag");
00026   cscSegTag_     = pset.getParameter<edm::InputTag>("cscSegTag");
00027   FEDRawDataCollectionTag_  = pset.getParameter<edm::InputTag>("FEDRawDataCollectionTag");
00028 
00029   finalizedHistograms_=false;
00030 
00031 }
00032 
00033 void CSCOfflineMonitor::beginJob(void){
00034       dbe = Service<DQMStore>().operator->();
00035   
00036       // Occupancies
00037       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Occupancy");
00038       hCSCOccupancy = dbe->book1D("hCSCOccupancy","overall CSC occupancy",13,-0.5,12.5);
00039       hCSCOccupancy->setBinLabel(2,"Total Events");
00040       hCSCOccupancy->setBinLabel(4,"# Events with Wires");
00041       hCSCOccupancy->setBinLabel(6,"# Events with Strips");
00042       hCSCOccupancy->setBinLabel(8,"# Events with Wires&Strips");
00043       hCSCOccupancy->setBinLabel(10,"# Events with Rechits");
00044       hCSCOccupancy->setBinLabel(12,"# Events with Segments");
00045       hOWiresAndCLCT = dbe->book2D("hOWiresAndCLCT","Wire and CLCT Digi Occupancy ",36,0.5,36.5,20,0.5,20.5);
00046       hOWiresAndCLCT->setAxisTitle("Chamber #");
00047       hOWiresAndCLCT->setBinLabel(1,"ME -4/2",2);
00048       hOWiresAndCLCT->setBinLabel(2,"ME -4/1",2);
00049       hOWiresAndCLCT->setBinLabel(3,"ME -3/2",2);
00050       hOWiresAndCLCT->setBinLabel(4,"ME -2/1",2);
00051       hOWiresAndCLCT->setBinLabel(5,"ME -2/2",2);
00052       hOWiresAndCLCT->setBinLabel(6,"ME -2/1",2);
00053       hOWiresAndCLCT->setBinLabel(7,"ME -1/3",2);
00054       hOWiresAndCLCT->setBinLabel(8,"ME -1/2",2);
00055       hOWiresAndCLCT->setBinLabel(9,"ME -1/1b",2);
00056       hOWiresAndCLCT->setBinLabel(10,"ME -1/1a",2);
00057       hOWiresAndCLCT->setBinLabel(11,"ME +1/1a",2);
00058       hOWiresAndCLCT->setBinLabel(12,"ME +1/1b",2);
00059       hOWiresAndCLCT->setBinLabel(13,"ME +1/2",2);
00060       hOWiresAndCLCT->setBinLabel(14,"ME +1/3",2);
00061       hOWiresAndCLCT->setBinLabel(15,"ME +2/1",2);
00062       hOWiresAndCLCT->setBinLabel(16,"ME +2/2",2);
00063       hOWiresAndCLCT->setBinLabel(17,"ME +3/1",2);
00064       hOWiresAndCLCT->setBinLabel(18,"ME +3/2",2);
00065       hOWiresAndCLCT->setBinLabel(19,"ME +4/1",2);
00066       hOWiresAndCLCT->setBinLabel(20,"ME +4/2",2);
00067       hOWires = dbe->book2D("hOWires","Wire Digi Occupancy",36,0.5,36.5,20,0.5,20.5);
00068       hOWires->setAxisTitle("Chamber #");
00069       hOWires->setBinLabel(1,"ME -4/2",2);
00070       hOWires->setBinLabel(2,"ME -4/1",2);
00071       hOWires->setBinLabel(3,"ME -3/2",2);
00072       hOWires->setBinLabel(4,"ME -2/1",2);
00073       hOWires->setBinLabel(5,"ME -2/2",2);
00074       hOWires->setBinLabel(6,"ME -2/1",2);
00075       hOWires->setBinLabel(7,"ME -1/3",2);
00076       hOWires->setBinLabel(8,"ME -1/2",2);
00077       hOWires->setBinLabel(9,"ME -1/1b",2);
00078       hOWires->setBinLabel(10,"ME -1/1a",2);
00079       hOWires->setBinLabel(11,"ME +1/1a",2);
00080       hOWires->setBinLabel(12,"ME +1/1b",2);
00081       hOWires->setBinLabel(13,"ME +1/2",2);
00082       hOWires->setBinLabel(14,"ME +1/3",2);
00083       hOWires->setBinLabel(15,"ME +2/1",2);
00084       hOWires->setBinLabel(16,"ME +2/2",2);
00085       hOWires->setBinLabel(17,"ME +3/1",2);
00086       hOWires->setBinLabel(18,"ME +3/2",2);
00087       hOWires->setBinLabel(19,"ME +4/1",2);
00088       hOWires->setBinLabel(20,"ME +4/2",2);
00089       hOWireSerial = dbe->book1D("hOWireSerial","Wire Occupancy by Chamber Serial",601,-0.5,600.5);
00090       hOWireSerial->setAxisTitle("Chamber Serial Number");
00091       hOStrips = dbe->book2D("hOStrips","Strip Digi Occupancy",36,0.5,36.5,20,0.5,20.5);
00092       hOStrips->setAxisTitle("Chamber #");
00093       hOStrips->setBinLabel(1,"ME -4/2",2);
00094       hOStrips->setBinLabel(2,"ME -4/1",2);
00095       hOStrips->setBinLabel(3,"ME -3/2",2);
00096       hOStrips->setBinLabel(4,"ME -2/1",2);
00097       hOStrips->setBinLabel(5,"ME -2/2",2);
00098       hOStrips->setBinLabel(6,"ME -2/1",2);
00099       hOStrips->setBinLabel(7,"ME -1/3",2);
00100       hOStrips->setBinLabel(8,"ME -1/2",2);
00101       hOStrips->setBinLabel(9,"ME -1/1b",2);
00102       hOStrips->setBinLabel(10,"ME -1/1a",2);
00103       hOStrips->setBinLabel(11,"ME +1/1a",2);
00104       hOStrips->setBinLabel(12,"ME +1/1b",2);
00105       hOStrips->setBinLabel(13,"ME +1/2",2);
00106       hOStrips->setBinLabel(14,"ME +1/3",2);
00107       hOStrips->setBinLabel(15,"ME +2/1",2);
00108       hOStrips->setBinLabel(16,"ME +2/2",2);
00109       hOStrips->setBinLabel(17,"ME +3/1",2);
00110       hOStrips->setBinLabel(18,"ME +3/2",2);
00111       hOStrips->setBinLabel(19,"ME +4/1",2);
00112       hOStrips->setBinLabel(20,"ME +4/2",2);
00113       hOStripSerial = dbe->book1D("hOStripSerial","Strip Occupancy by Chamber Serial",601,-0.5,600.5);
00114       hOStripSerial->setAxisTitle("Chamber Serial Number");
00115       hOStripsAndWiresAndCLCT = dbe->book2D("hOStripsAndWiresAndCLCT","Strip And Wire And CLCT Digi Occupancy",36,0.5,36.5,20,0.5,20.5);
00116       hOStripsAndWiresAndCLCT->setAxisTitle("Chamber #");
00117       hOStripsAndWiresAndCLCT->setBinLabel(1,"ME -4/2",2);
00118       hOStripsAndWiresAndCLCT->setBinLabel(2,"ME -4/1",2);
00119       hOStripsAndWiresAndCLCT->setBinLabel(3,"ME -3/2",2);
00120       hOStripsAndWiresAndCLCT->setBinLabel(4,"ME -2/1",2);
00121       hOStripsAndWiresAndCLCT->setBinLabel(5,"ME -2/2",2);
00122       hOStripsAndWiresAndCLCT->setBinLabel(6,"ME -2/1",2);
00123       hOStripsAndWiresAndCLCT->setBinLabel(7,"ME -1/3",2);
00124       hOStripsAndWiresAndCLCT->setBinLabel(8,"ME -1/2",2);
00125       hOStripsAndWiresAndCLCT->setBinLabel(9,"ME -1/1b",2);
00126       hOStripsAndWiresAndCLCT->setBinLabel(10,"ME -1/1a",2);
00127       hOStripsAndWiresAndCLCT->setBinLabel(11,"ME +1/1a",2);
00128       hOStripsAndWiresAndCLCT->setBinLabel(12,"ME +1/1b",2);
00129       hOStripsAndWiresAndCLCT->setBinLabel(13,"ME +1/2",2);
00130       hOStripsAndWiresAndCLCT->setBinLabel(14,"ME +1/3",2);
00131       hOStripsAndWiresAndCLCT->setBinLabel(15,"ME +2/1",2);
00132       hOStripsAndWiresAndCLCT->setBinLabel(16,"ME +2/2",2);
00133       hOStripsAndWiresAndCLCT->setBinLabel(17,"ME +3/1",2);
00134       hOStripsAndWiresAndCLCT->setBinLabel(18,"ME +3/2",2);
00135       hOStripsAndWiresAndCLCT->setBinLabel(19,"ME +4/1",2);
00136       hOStripsAndWiresAndCLCT->setBinLabel(20,"ME +4/2",2);
00137       hORecHits = dbe->book2D("hORecHits","RecHit Occupancy",36,0.5,36.5,20,0.5,20.5);
00138       hORecHits->setAxisTitle("Chamber #");
00139       hORecHits->setBinLabel(1,"ME -4/2",2);
00140       hORecHits->setBinLabel(2,"ME -4/1",2);
00141       hORecHits->setBinLabel(3,"ME -3/2",2);
00142       hORecHits->setBinLabel(4,"ME -2/1",2);
00143       hORecHits->setBinLabel(5,"ME -2/2",2);
00144       hORecHits->setBinLabel(6,"ME -2/1",2);
00145       hORecHits->setBinLabel(7,"ME -1/3",2);
00146       hORecHits->setBinLabel(8,"ME -1/2",2);
00147       hORecHits->setBinLabel(9,"ME -1/1b",2);
00148       hORecHits->setBinLabel(10,"ME -1/1a",2);
00149       hORecHits->setBinLabel(11,"ME +1/1a",2);
00150       hORecHits->setBinLabel(12,"ME +1/1b",2);
00151       hORecHits->setBinLabel(13,"ME +1/2",2);
00152       hORecHits->setBinLabel(14,"ME +1/3",2);
00153       hORecHits->setBinLabel(15,"ME +2/1",2);
00154       hORecHits->setBinLabel(16,"ME +2/2",2);
00155       hORecHits->setBinLabel(17,"ME +3/1",2);
00156       hORecHits->setBinLabel(18,"ME +3/2",2);
00157       hORecHits->setBinLabel(19,"ME +4/1",2);
00158       hORecHits->setBinLabel(20,"ME +4/2",2);
00159       hORecHitsSerial = dbe->book1D("hORecHitSerial","RecHit Occupancy by Chamber Serial",601,-0.5,600.5);
00160       hORecHitsSerial->setAxisTitle("Chamber Serial Number");
00161       hOSegments = dbe->book2D("hOSegments","Segment Occupancy",36,0.5,36.5,20,0.5,20.5);
00162       hOSegments->setAxisTitle("Chamber #");
00163       hOSegments->setBinLabel(1,"ME -4/2",2);
00164       hOSegments->setBinLabel(2,"ME -4/1",2);
00165       hOSegments->setBinLabel(3,"ME -3/2",2);
00166       hOSegments->setBinLabel(4,"ME -2/1",2);
00167       hOSegments->setBinLabel(5,"ME -2/2",2);
00168       hOSegments->setBinLabel(6,"ME -2/1",2);
00169       hOSegments->setBinLabel(7,"ME -1/3",2);
00170       hOSegments->setBinLabel(8,"ME -1/2",2);
00171       hOSegments->setBinLabel(9,"ME -1/1b",2);
00172       hOSegments->setBinLabel(10,"ME -1/1a",2);
00173       hOSegments->setBinLabel(11,"ME +1/1a",2);
00174       hOSegments->setBinLabel(12,"ME +1/1b",2);
00175       hOSegments->setBinLabel(13,"ME +1/2",2);
00176       hOSegments->setBinLabel(14,"ME +1/3",2);
00177       hOSegments->setBinLabel(15,"ME +2/1",2);
00178       hOSegments->setBinLabel(16,"ME +2/2",2);
00179       hOSegments->setBinLabel(17,"ME +3/1",2);
00180       hOSegments->setBinLabel(18,"ME +3/2",2);
00181       hOSegments->setBinLabel(19,"ME +4/1",2);
00182       hOSegments->setBinLabel(20,"ME +4/2",2);
00183       hOSegmentsSerial = dbe->book1D("hOSegmentSerial","Segment Occupancy by Chamber Serial",601,-0.5,600.5);
00184       hOSegmentsSerial->setAxisTitle("Chamber Serial Number");
00185 
00186       // wire digis
00187       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Digis");
00188       hWirenGroupsTotal = dbe->book1D("hWirenGroupsTotal","Fired Wires per Event; # Wiregroups Fired",61,-0.5,60.5);
00189       hWireTBin.push_back(dbe->book1D("hWireTBin_m42","Wire TBin Fired (ME -4/2); Time Bin (25ns)",17,-0.5,16.5));
00190       hWireTBin.push_back(dbe->book1D("hWireTBin_m41","Wire TBin Fired (ME -4/1); Time Bin (25ns)",17,-0.5,16.5));
00191       hWireTBin.push_back(dbe->book1D("hWireTBin_m32","Wire TBin Fired (ME -3/2); Time Bin (25ns)",17,-0.5,16.5));
00192       hWireTBin.push_back(dbe->book1D("hWireTBin_m31","Wire TBin Fired (ME -3/1); Time Bin (25ns)",17,-0.5,16.5));
00193       hWireTBin.push_back(dbe->book1D("hWireTBin_m22","Wire TBin Fired (ME -2/2); Time Bin (25ns)",17,-0.5,16.5));
00194       hWireTBin.push_back(dbe->book1D("hWireTBin_m21","Wire TBin Fired (ME -2/1); Time Bin (25ns)",17,-0.5,16.5));
00195       hWireTBin.push_back(dbe->book1D("hWireTBin_m11a","Wire TBin Fired (ME -1/1a); Time Bin (25ns)",17,-0.5,16.5));
00196       hWireTBin.push_back(dbe->book1D("hWireTBin_m13","Wire TBin Fired (ME -1/3); Time Bin (25ns)",17,-0.5,16.5));
00197       hWireTBin.push_back(dbe->book1D("hWireTBin_m12","Wire TBin Fired (ME -1/2); Time Bin (25ns)",17,-0.5,16.5));
00198       hWireTBin.push_back(dbe->book1D("hWireTBin_m11b","Wire TBin Fired (ME -1/1b); Time Bin (25ns)",17,-0.5,16.5));
00199       hWireTBin.push_back(dbe->book1D("hWireTBin_p11b","Wire TBin Fired (ME +1/1b); Time Bin (25ns)",17,-0.5,16.5));
00200       hWireTBin.push_back(dbe->book1D("hWireTBin_p12","Wire TBin Fired (ME +1/2); Time Bin (25ns)",17,-0.5,16.5));
00201       hWireTBin.push_back(dbe->book1D("hWireTBin_p13","Wire TBin Fired (ME +1/3); Time Bin (25ns)",17,-0.5,16.5));
00202       hWireTBin.push_back(dbe->book1D("hWireTBin_p11a","Wire TBin Fired (ME +1/1a); Time Bin (25ns)",17,-0.5,16.5));
00203       hWireTBin.push_back(dbe->book1D("hWireTBin_p21","Wire TBin Fired (ME +2/1); Time Bin (25ns)",17,-0.5,16.5));
00204       hWireTBin.push_back(dbe->book1D("hWireTBin_p22","Wire TBin Fired (ME +2/2); Time Bin (25ns)",17,-0.5,16.5));
00205       hWireTBin.push_back(dbe->book1D("hWireTBin_p31","Wire TBin Fired (ME +3/1); Time Bin (25ns)",17,-0.5,16.5));
00206       hWireTBin.push_back(dbe->book1D("hWireTBin_p32","Wire TBin Fired (ME +3/2); Time Bin (25ns)",17,-0.5,16.5));
00207       hWireTBin.push_back(dbe->book1D("hWireTBin_p41","Wire TBin Fired (ME +4/1); Time Bin (25ns)",17,-0.5,16.5));
00208       hWireTBin.push_back(dbe->book1D("hWireTBin_p42","Wire TBin Fired (ME +4/2); Time Bin (25ns)",17,-0.5,16.5));
00209       hWireNumber.push_back(dbe->book1D("hWireNumber_m42","Wiregroup Number Fired (ME -4/2); Wiregroup #",113,-0.5,112.5));
00210       hWireNumber.push_back(dbe->book1D("hWireNumber_m41","Wiregroup Number Fired (ME -4/1); Wiregroup #",113,-0.5,112.5));
00211       hWireNumber.push_back(dbe->book1D("hWireNumber_m32","Wiregroup Number Fired (ME -3/2); Wiregroup #",113,-0.5,112.5));
00212       hWireNumber.push_back(dbe->book1D("hWireNumber_m31","Wiregroup Number Fired (ME -3/1); Wiregroup #",113,-0.5,112.5));
00213       hWireNumber.push_back(dbe->book1D("hWireNumber_m22","Wiregroup Number Fired (ME -2/2); Wiregroup #",113,-0.5,112.5));
00214       hWireNumber.push_back(dbe->book1D("hWireNumber_m21","Wiregroup Number Fired (ME -2/1); Wiregroup #",113,-0.5,112.5));
00215       hWireNumber.push_back(dbe->book1D("hWireNumber_m11a","Wiregroup Number Fired (ME -1/1a); Wiregroup #",113,-0.5,112.5));
00216       hWireNumber.push_back(dbe->book1D("hWireNumber_m13","Wiregroup Number Fired (ME -1/3); Wiregroup #",113,-0.5,112.5));
00217       hWireNumber.push_back(dbe->book1D("hWireNumber_m12","Wiregroup Number Fired (ME -1/2); Wiregroup #",113,-0.5,112.5));
00218       hWireNumber.push_back(dbe->book1D("hWireNumber_m11b","Wiregroup Number Fired (ME -1/1b); Wiregroup #",113,-0.5,112.5));
00219       hWireNumber.push_back(dbe->book1D("hWireNumber_p11b","Wiregroup Number Fired (ME +1/1b); Wiregroup #",113,-0.5,112.5));
00220       hWireNumber.push_back(dbe->book1D("hWireNumber_p12","Wiregroup Number Fired (ME +1/2); Wiregroup #",113,-0.5,112.5));
00221       hWireNumber.push_back(dbe->book1D("hWireNumber_p13","Wiregroup Number Fired (ME +1/3); Wiregroup #",113,-0.5,112.5));
00222       hWireNumber.push_back(dbe->book1D("hWireNumber_p11a","Wiregroup Number Fired (ME +1/1a); Wiregroup #",113,-0.5,112.5));
00223       hWireNumber.push_back(dbe->book1D("hWireNumber_p21","Wiregroup Number Fired (ME +2/1); Wiregroup #",113,-0.5,112.5));
00224       hWireNumber.push_back(dbe->book1D("hWireNumber_p22","Wiregroup Number Fired (ME +2/2); Wiregroup #",113,-0.5,112.5));
00225       hWireNumber.push_back(dbe->book1D("hWireNumber_p31","Wiregroup Number Fired (ME +3/1); Wiregroup #",113,-0.5,112.5));
00226       hWireNumber.push_back(dbe->book1D("hWireNumber_p32","Wiregroup Number Fired (ME +3/2); Wiregroup #",113,-0.5,112.5));
00227       hWireNumber.push_back(dbe->book1D("hWireNumber_p41","Wiregroup Number Fired (ME +4/1); Wiregroup #",113,-0.5,112.5));
00228       hWireNumber.push_back(dbe->book1D("hWireNumber_p42","Wiregroup Number Fired (ME +4/2); Wiregroup #",113,-0.5,112.5));
00229 
00230       // strip digis
00231       hStripNFired = dbe->book1D("hStripNFired","Fired Strips per Event; # Strips Fired (above 13 ADC)",101,-0.5,100.5);
00232       hStripNumber.push_back(dbe->book1D("hStripNumber_m42","Strip Number Fired (ME -4/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00233       hStripNumber.push_back(dbe->book1D("hStripNumber_m41","Strip Number Fired (ME -4/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00234       hStripNumber.push_back(dbe->book1D("hStripNumber_m32","Strip Number Fired (ME -3/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00235       hStripNumber.push_back(dbe->book1D("hStripNumber_m31","Strip Number Fired (ME -3/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00236       hStripNumber.push_back(dbe->book1D("hStripNumber_m22","Strip Number Fired (ME -2/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00237       hStripNumber.push_back(dbe->book1D("hStripNumber_m21","Strip Number Fired (ME -2/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00238       hStripNumber.push_back(dbe->book1D("hStripNumber_m11a","Strip Number Fired (ME -1/1a); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00239       hStripNumber.push_back(dbe->book1D("hStripNumber_m13","Strip Number Fired (ME -1/3); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00240       hStripNumber.push_back(dbe->book1D("hStripNumber_m12","Strip Number Fired (ME -1/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00241       hStripNumber.push_back(dbe->book1D("hStripNumber_m11b","Strip Number Fired (ME -1/1b); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00242       hStripNumber.push_back(dbe->book1D("hStripNumber_p11b","Strip Number Fired (ME +1/1b); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00243       hStripNumber.push_back(dbe->book1D("hStripNumber_p12","Strip Number Fired (ME +1/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00244       hStripNumber.push_back(dbe->book1D("hStripNumber_p13","Strip Number Fired (ME +1/3); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00245       hStripNumber.push_back(dbe->book1D("hStripNumber_p11a","Strip Number Fired (ME +1/1a); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00246       hStripNumber.push_back(dbe->book1D("hStripNumber_p21","Strip Number Fired (ME +2/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00247       hStripNumber.push_back(dbe->book1D("hStripNumber_p22","Strip Number Fired (ME +2/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00248       hStripNumber.push_back(dbe->book1D("hStripNumber_p31","Strip Number Fired (ME +3/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00249       hStripNumber.push_back(dbe->book1D("hStripNumber_p32","Strip Number Fired (ME +3/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00250       hStripNumber.push_back(dbe->book1D("hStripNumber_p41","Strip Number Fired (ME +4/1); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00251       hStripNumber.push_back(dbe->book1D("hStripNumber_p42","Stripgroup Number Fired (ME +4/2); Strip # Fired (above 13 ADC)",81,-0.5,80.5));
00252 
00253       //Pedestal Noise Plots
00254       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/PedestalNoise");
00255       hStripPed.push_back(dbe->book1D("hStripPedMEm42","Pedestal Noise Distribution Chamber ME -4/2; ADC Counts",50,-25.,25.));
00256       hStripPed.push_back(dbe->book1D("hStripPedMEm41","Pedestal Noise Distribution Chamber ME -4/1; ADC Counts",50,-25.,25.));
00257       hStripPed.push_back(dbe->book1D("hStripPedMEm32","Pedestal Noise Distribution Chamber ME -3/2; ADC Counts",50,-25.,25.));
00258       hStripPed.push_back(dbe->book1D("hStripPedMEm31","Pedestal Noise Distribution Chamber ME -3/1; ADC Counts",50,-25.,25.));
00259       hStripPed.push_back(dbe->book1D("hStripPedMEm22","Pedestal Noise Distribution Chamber ME -2/2; ADC Counts",50,-25.,25.));
00260       hStripPed.push_back(dbe->book1D("hStripPedMEm21","Pedestal Noise Distribution Chamber ME -2/1; ADC Counts",50,-25.,25.));
00261       hStripPed.push_back(dbe->book1D("hStripPedMEm11a","Pedestal Noise Distribution Chamber ME -1/1; ADC Counts",50,-25.,25.));
00262       hStripPed.push_back(dbe->book1D("hStripPedMEm13","Pedestal Noise Distribution Chamber ME -1/3; ADC Counts",50,-25.,25.));
00263       hStripPed.push_back(dbe->book1D("hStripPedMEm12","Pedestal Noise Distribution Chamber ME -1/2; ADC Counts",50,-25.,25.));
00264       hStripPed.push_back(dbe->book1D("hStripPedMEm11b","Pedestal Noise Distribution Chamber ME -1/1; ADC Counts",50,-25.,25.));
00265       hStripPed.push_back(dbe->book1D("hStripPedMEp11b","Pedestal Noise Distribution Chamber ME +1/1; ADC Counts",50,-25.,25.));
00266       hStripPed.push_back(dbe->book1D("hStripPedMEp12","Pedestal Noise Distribution Chamber ME +1/2; ADC Counts",50,-25.,25.));
00267       hStripPed.push_back(dbe->book1D("hStripPedMEp13","Pedestal Noise Distribution Chamber ME +1/3; ADC Counts",50,-25.,25.));
00268       hStripPed.push_back(dbe->book1D("hStripPedMEp11a","Pedestal Noise Distribution Chamber ME +1/1; ADC Counts",50,-25.,25.));
00269       hStripPed.push_back(dbe->book1D("hStripPedMEp21","Pedestal Noise Distribution Chamber ME +2/1; ADC Counts",50,-25.,25.));
00270       hStripPed.push_back(dbe->book1D("hStripPedMEp22","Pedestal Noise Distribution Chamber ME +2/2; ADC Counts",50,-25.,25.));
00271       hStripPed.push_back(dbe->book1D("hStripPedMEp31","Pedestal Noise Distribution Chamber ME +3/1; ADC Counts",50,-25.,25.));
00272       hStripPed.push_back(dbe->book1D("hStripPedMEp32","Pedestal Noise Distribution Chamber ME +3/2; ADC Counts",50,-25.,25.));
00273       hStripPed.push_back(dbe->book1D("hStripPedMEp41","Pedestal Noise Distribution Chamber ME +4/1; ADC Counts",50,-25.,25.));
00274       hStripPed.push_back(dbe->book1D("hStripPedMEp42","Pedestal Noise Distribution Chamber ME +4/2; ADC Counts",50,-25.,25.));
00275 
00276       // recHits
00277       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/recHits");
00278       hRHnrechits = dbe->book1D("hRHnrechits","recHits per Event (all chambers); # of RecHits",50,0,50);
00279       hRHGlobal.push_back(dbe->book2D("hRHGlobalp1","recHit global X,Y station +1; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00280       hRHGlobal.push_back(dbe->book2D("hRHGlobalp2","recHit global X,Y station +2; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00281       hRHGlobal.push_back(dbe->book2D("hRHGlobalp3","recHit global X,Y station +3; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00282       hRHGlobal.push_back(dbe->book2D("hRHGlobalp4","recHit global X,Y station +4; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00283       hRHGlobal.push_back(dbe->book2D("hRHGlobalm1","recHit global X,Y station -1; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00284       hRHGlobal.push_back(dbe->book2D("hRHGlobalm2","recHit global X,Y station -2; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00285       hRHGlobal.push_back(dbe->book2D("hRHGlobalm3","recHit global X,Y station -3; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00286       hRHGlobal.push_back(dbe->book2D("hRHGlobalm4","recHit global X,Y station -4; Global X (cm); Global Y (cm)",100,-800.,800.,100,-800.,800.));
00287       hRHSumQ.push_back(dbe->book1D("hRHSumQm42","Sum 3x3 recHit Charge (ME -4/2); ADC counts",100,0,2000));
00288       hRHSumQ.push_back(dbe->book1D("hRHSumQm41","Sum 3x3 recHit Charge (ME -4/1); ADC counts",100,0,2000));
00289       hRHSumQ.push_back(dbe->book1D("hRHSumQm32","Sum 3x3 recHit Charge (ME -3/2); ADC counts",100,0,2000));
00290       hRHSumQ.push_back(dbe->book1D("hRHSumQm31","Sum 3x3 recHit Charge (ME -3/1); ADC counts",100,0,2000));
00291       hRHSumQ.push_back(dbe->book1D("hRHSumQm22","Sum 3x3 recHit Charge (ME -2/2); ADC counts",100,0,2000));
00292       hRHSumQ.push_back(dbe->book1D("hRHSumQm21","Sum 3x3 recHit Charge (ME -2/1); ADC counts",100,0,2000));
00293       hRHSumQ.push_back(dbe->book1D("hRHSumQm11a","Sum 3x3 recHit Charge (ME -1/1a); ADC counts",100,0,4000));
00294       hRHSumQ.push_back(dbe->book1D("hRHSumQm13","Sum 3x3 recHit Charge (ME -1/3); ADC counts",100,0,2000));
00295       hRHSumQ.push_back(dbe->book1D("hRHSumQm12","Sum 3x3 recHit Charge (ME -1/2); ADC counts",100,0,2000));
00296       hRHSumQ.push_back(dbe->book1D("hRHSumQm11b","Sum 3x3 recHit Charge (ME -1/1b); ADC counts",100,0,4000));
00297       hRHSumQ.push_back(dbe->book1D("hRHSumQp11b","Sum 3x3 recHit Charge (ME +1/1b); ADC counts",100,0,4000));
00298       hRHSumQ.push_back(dbe->book1D("hRHSumQp12","Sum 3x3 recHit Charge (ME +1/2); ADC counts",100,0,2000));
00299       hRHSumQ.push_back(dbe->book1D("hRHSumQp13","Sum 3x3 recHit Charge (ME +1/3); ADC counts",100,0,2000));
00300       hRHSumQ.push_back(dbe->book1D("hRHSumQp11a","Sum 3x3 recHit Charge (ME +1/1a); ADC counts",100,0,4000));
00301       hRHSumQ.push_back(dbe->book1D("hRHSumQp21","Sum 3x3 recHit Charge (ME +2/1); ADC counts",100,0,2000));
00302       hRHSumQ.push_back(dbe->book1D("hRHSumQp22","Sum 3x3 recHit Charge (ME +2/2); ADC counts",100,0,2000));
00303       hRHSumQ.push_back(dbe->book1D("hRHSumQp31","Sum 3x3 recHit Charge (ME +3/1); ADC counts",100,0,2000));
00304       hRHSumQ.push_back(dbe->book1D("hRHSumQp32","Sum 3x3 recHit Charge (ME +3/2); ADC counts",100,0,2000));
00305       hRHSumQ.push_back(dbe->book1D("hRHSumQp41","Sum 3x3 recHit Charge (ME +4/1); ADC counts",100,0,2000));
00306       hRHSumQ.push_back(dbe->book1D("hRHSumQp42","Sum 3x3 recHit Charge (ME +4/2); ADC counts",100,0,2000));
00307       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm42","Charge Ratio (Ql+Qr)/Qt (ME -4/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00308       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm41","Charge Ratio (Ql+Qr)/Qt (ME -4/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00309       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm32","Charge Ratio (Ql+Qr)/Qt (ME -3/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00310       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm31","Charge Ratio (Ql+Qr)/Qt (ME -3/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00311       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm22","Charge Ratio (Ql+Qr)/Qt (ME -2/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00312       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm21","Charge Ratio (Ql+Qr)/Qt (ME -2/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00313       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm11a","Charge Ratio (Ql+Qr)/Qt (ME -1/1a); (Ql+Qr)/Qt",100,-0.1,1.1));
00314       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm13","Charge Ratio (Ql+Qr)/Qt (ME -1/3); (Ql+Qr)/Qt",100,-0.1,1.1));
00315       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm12","Charge Ratio (Ql+Qr)/Qt (ME -1/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00316       hRHRatioQ.push_back(dbe->book1D("hRHRatioQm11b","Charge Ratio (Ql+Qr)/Qt (ME -1/1b); (Ql+Qr)/Qt",100,-0.1,1.1));
00317       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp11b","Charge Ratio (Ql+Qr)/Qt (ME +1/1b); (Ql+Qr)/Qt",100,-0.1,1.1));
00318       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp12","Charge Ratio (Ql+Qr)/Qt (ME +1/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00319       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp13","Charge Ratio (Ql+Qr)/Qt (ME +1/3); (Ql+Qr)/Qt",100,-0.1,1.1));
00320       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp11a","Charge Ratio (Ql+Qr)/Qt (ME +1/1a); (Ql+Qr)/Qt",100,-0.1,1.1));
00321       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp21","Charge Ratio (Ql+Qr)/Qt (ME +2/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00322       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp22","Charge Ratio (Ql+Qr)/Qt (ME +2/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00323       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp31","Charge Ratio (Ql+Qr)/Qt (ME +3/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00324       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp32","Charge Ratio (Ql+Qr)/Qt (ME +3/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00325       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp41","Charge Ratio (Ql+Qr)/Qt (ME +4/1); (Ql+Qr)/Qt",100,-0.1,1.1));
00326       hRHRatioQ.push_back(dbe->book1D("hRHRatioQp42","Charge Ratio (Ql+Qr)/Qt (ME +4/2); (Ql+Qr)/Qt",100,-0.1,1.1));
00327       hRHTiming.push_back(dbe->book1D("hRHTimingm42","recHit Time (ME -4/2); ns",200,-500.,500.));
00328       hRHTiming.push_back(dbe->book1D("hRHTimingm41","recHit Time (ME -4/1); ns",200,-500.,500.));
00329       hRHTiming.push_back(dbe->book1D("hRHTimingm32","recHit Time (ME -3/2); ns",200,-500.,500.));
00330       hRHTiming.push_back(dbe->book1D("hRHTimingm31","recHit Time (ME -3/1); ns",200,-500.,500.));
00331       hRHTiming.push_back(dbe->book1D("hRHTimingm22","recHit Time (ME -2/2); ns",200,-500.,500.));
00332       hRHTiming.push_back(dbe->book1D("hRHTimingm21","recHit Time (ME -2/1); ns",200,-500.,500.));
00333       hRHTiming.push_back(dbe->book1D("hRHTimingm11a","recHit Time (ME -1/1a); ns",200,-500.,500.));
00334       hRHTiming.push_back(dbe->book1D("hRHTimingm13","recHit Time (ME -1/3); ns",200,-500.,500.));
00335       hRHTiming.push_back(dbe->book1D("hRHTimingm12","recHit Time (ME -1/2); ns",200,-500.,500.));
00336       hRHTiming.push_back(dbe->book1D("hRHTimingm11b","recHit Time (ME -1/1b); ns",200,-500.,500.));
00337       hRHTiming.push_back(dbe->book1D("hRHTimingp11b","recHit Time (ME +1/1b); ns",200,-500.,500.));
00338       hRHTiming.push_back(dbe->book1D("hRHTimingp12","recHit Time (ME +1/2); ns",200,-500.,500.));
00339       hRHTiming.push_back(dbe->book1D("hRHTimingp13","recHit Time (ME +1/3); ns",200,-500.,500.));
00340       hRHTiming.push_back(dbe->book1D("hRHTimingp11a","recHit Time (ME +1/1a); ns",200,-500.,500.));
00341       hRHTiming.push_back(dbe->book1D("hRHTimingp21","recHit Time (ME +2/1); ns",200,-500.,500.));
00342       hRHTiming.push_back(dbe->book1D("hRHTimingp22","recHit Time (ME +2/2); ns",200,-500.,500.));
00343       hRHTiming.push_back(dbe->book1D("hRHTimingp31","recHit Time (ME +3/1); ns",200,-500.,500.));
00344       hRHTiming.push_back(dbe->book1D("hRHTimingp32","recHit Time (ME +3/2); ns",200,-500.,500.));
00345       hRHTiming.push_back(dbe->book1D("hRHTimingp41","recHit Time (ME +4/1); ns",200,-500.,500.));
00346       hRHTiming.push_back(dbe->book1D("hRHTimingp42","recHit Time (ME +4/2); ns",200,-500.,500.));
00347       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem42","Anode recHit Time (ME -4/2); ns",80,-500.,500.));
00348       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem41","Anode recHit Time (ME -4/1); ns",80,-500.,500.));
00349       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem32","Anode recHit Time (ME -3/2); ns",80,-500.,500.));
00350       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem31","Anode recHit Time (ME -3/1); ns",80,-500.,500.));
00351       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem22","Anode recHit Time (ME -2/2); ns",80,-500.,500.));
00352       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem21","Anode recHit Time (ME -2/1); ns",80,-500.,500.));
00353       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem11a","Anode recHit Time (ME -1/1a); ns",80,-500.,500.));
00354       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem13","Anode recHit Time (ME -1/3); ns",80,-500.,500.));
00355       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem12","Anode recHit Time (ME -1/2); ns",80,-500.,500.));
00356       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodem11b","Anode recHit Time (ME -1/1b); ns",80,-500.,500.));
00357       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep11b","Anode recHit Time (ME +1/1b); ns",80,-500.,500.));
00358       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep12","Anode recHit Time (ME +1/2); ns",80,-500.,500.));
00359       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep13","Anode recHit Time (ME +1/3); ns",80,-500.,500.));
00360       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep11a","Anode recHit Time (ME +1/1a); ns",80,-500.,500.));
00361       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep21","Anode recHit Time (ME +2/1); ns",80,-500.,500.));
00362       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep22","Anode recHit Time (ME +2/2); ns",80,-500.,500.));
00363       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep31","Anode recHit Time (ME +3/1); ns",80,-500.,500.));
00364       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep32","Anode recHit Time (ME +3/2); ns",80,-500.,500.));
00365       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep41","Anode recHit Time (ME +4/1); ns",80,-500.,500.));
00366       hRHTimingAnode.push_back(dbe->book1D("hRHTimingAnodep42","Anode recHit Time (ME +4/2); ns",80,-500.,500.));
00367       hRHstpos.push_back(dbe->book1D("hRHstposm42","Reconstructed Position on Strip (ME -4/2); Strip Widths",120,-0.6,0.6));
00368       hRHstpos.push_back(dbe->book1D("hRHstposm41","Reconstructed Position on Strip (ME -4/1); Strip Widths",120,-0.6,0.6));
00369       hRHstpos.push_back(dbe->book1D("hRHstposm32","Reconstructed Position on Strip (ME -3/2); Strip Widths",120,-0.6,0.6));
00370       hRHstpos.push_back(dbe->book1D("hRHstposm31","Reconstructed Position on Strip (ME -3/1); Strip Widths",120,-0.6,0.6));
00371       hRHstpos.push_back(dbe->book1D("hRHstposm22","Reconstructed Position on Strip (ME -2/2); Strip Widths",120,-0.6,0.6));
00372       hRHstpos.push_back(dbe->book1D("hRHstposm21","Reconstructed Position on Strip (ME -2/1); Strip Widths",120,-0.6,0.6));
00373       hRHstpos.push_back(dbe->book1D("hRHstposm11a","Reconstructed Position on Strip (ME -1/1a); Strip Widths",120,-0.6,0.6));
00374       hRHstpos.push_back(dbe->book1D("hRHstposm13","Reconstructed Position on Strip (ME -1/3); Strip Widths",120,-0.6,0.6));
00375       hRHstpos.push_back(dbe->book1D("hRHstposm12","Reconstructed Position on Strip (ME -1/2); Strip Widths",120,-0.6,0.6));
00376       hRHstpos.push_back(dbe->book1D("hRHstposm11b","Reconstructed Position on Strip (ME -1/1b); Strip Widths",120,-0.6,0.6));
00377       hRHstpos.push_back(dbe->book1D("hRHstposp11b","Reconstructed Position on Strip (ME +1/1b); Strip Widths",120,-0.6,0.6));
00378       hRHstpos.push_back(dbe->book1D("hRHstposp12","Reconstructed Position on Strip (ME +1/2); Strip Widths",120,-0.6,0.6));
00379       hRHstpos.push_back(dbe->book1D("hRHstposp13","Reconstructed Position on Strip (ME +1/3); Strip Widths",120,-0.6,0.6));
00380       hRHstpos.push_back(dbe->book1D("hRHstposp11a","Reconstructed Position on Strip (ME +1/1a); Strip Widths",120,-0.6,0.6));
00381       hRHstpos.push_back(dbe->book1D("hRHstposp21","Reconstructed Position on Strip (ME +2/1); Strip Widths",120,-0.6,0.6));
00382       hRHstpos.push_back(dbe->book1D("hRHstposp22","Reconstructed Position on Strip (ME +2/2); Strip Widths",120,-0.6,0.6));
00383       hRHstpos.push_back(dbe->book1D("hRHstposp31","Reconstructed Position on Strip (ME +3/1); Strip Widths",120,-0.6,0.6));
00384       hRHstpos.push_back(dbe->book1D("hRHstposp32","Reconstructed Position on Strip (ME +3/2); Strip Widths",120,-0.6,0.6));
00385       hRHstpos.push_back(dbe->book1D("hRHstposp41","Reconstructed Position on Strip (ME +4/1); Strip Widths",120,-0.6,0.6));
00386       hRHstpos.push_back(dbe->book1D("hRHstposp42","Reconstructed Position on Strip (ME +4/2); Strip Widths",120,-0.6,0.6));
00387       hRHsterr.push_back(dbe->book1D("hRHsterrm42","Estimated Error on Strip Measurement (ME -4/2); Strip Widths",75,-0.01,0.24));
00388       hRHsterr.push_back(dbe->book1D("hRHsterrm41","Estimated Error on Strip Measurement (ME -4/1); Strip Widths",75,-0.01,0.24));
00389       hRHsterr.push_back(dbe->book1D("hRHsterrm32","Estimated Error on Strip Measurement (ME -3/2); Strip Widths",75,-0.01,0.24));
00390       hRHsterr.push_back(dbe->book1D("hRHsterrm31","Estimated Error on Strip Measurement (ME -3/1); Strip Widths",75,-0.01,0.24));
00391       hRHsterr.push_back(dbe->book1D("hRHsterrm22","Estimated Error on Strip Measurement (ME -2/2); Strip Widths",75,-0.01,0.24));
00392       hRHsterr.push_back(dbe->book1D("hRHsterrm21","Estimated Error on Strip Measurement (ME -2/1); Strip Widths",75,-0.01,0.24));
00393       hRHsterr.push_back(dbe->book1D("hRHsterrm11a","Estimated Error on Strip Measurement (ME -1/1a); Strip Widths",75,-0.01,0.24));
00394       hRHsterr.push_back(dbe->book1D("hRHsterrm13","Estimated Error on Strip Measurement (ME -1/3); Strip Widths",75,-0.01,0.24));
00395       hRHsterr.push_back(dbe->book1D("hRHsterrm12","Estimated Error on Strip Measurement (ME -1/2); Strip Widths",75,-0.01,0.24));
00396       hRHsterr.push_back(dbe->book1D("hRHsterrm11b","Estimated Error on Strip Measurement (ME -1/1b); Strip Widths",75,-0.01,0.24));
00397       hRHsterr.push_back(dbe->book1D("hRHsterrp11b","Estimated Error on Strip Measurement (ME +1/1b); Strip Widths",75,-0.01,0.24));
00398       hRHsterr.push_back(dbe->book1D("hRHsterrp12","Estimated Error on Strip Measurement (ME +1/2); Strip Widths",75,-0.01,0.24));
00399       hRHsterr.push_back(dbe->book1D("hRHsterrp13","Estimated Error on Strip Measurement (ME +1/3); Strip Widths",75,-0.01,0.24));
00400       hRHsterr.push_back(dbe->book1D("hRHsterrp11a","Estimated Error on Strip Measurement (ME +1/1a); Strip Widths",75,-0.01,0.24));
00401       hRHsterr.push_back(dbe->book1D("hRHsterrp21","Estimated Error on Strip Measurement (ME +2/1); Strip Widths",75,-0.01,0.24));
00402       hRHsterr.push_back(dbe->book1D("hRHsterrp22","Estimated Error on Strip Measurement (ME +2/2); Strip Widths",75,-0.01,0.24));
00403       hRHsterr.push_back(dbe->book1D("hRHsterrp31","Estimated Error on Strip Measurement (ME +3/1); Strip Widths",75,-0.01,0.24));
00404       hRHsterr.push_back(dbe->book1D("hRHsterrp32","Estimated Error on Strip Measurement (ME +3/2); Strip Widths",75,-0.01,0.24));
00405       hRHsterr.push_back(dbe->book1D("hRHsterrp41","Estimated Error on Strip Measurement (ME +4/1); Strip Widths",75,-0.01,0.24));
00406       hRHsterr.push_back(dbe->book1D("hRHsterrp42","Estimated Error on Strip Measurement (ME +4/2); Strip Widths",75,-0.01,0.24));
00407 
00408 
00409       // segments
00410       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Segments");
00411       hSnSegments   = dbe->book1D("hSnSegments","Number of Segments per Event; # of Segments",11,-0.5,10.5);
00412       hSnhitsAll = dbe->book1D("hSnhits","N hits on Segments; # of hits",8,-0.5,7.5);
00413       hSnhits.push_back(dbe->book1D("hSnhitsm42","# of hits on Segments (ME -4/2); # of hits",8,-0.5,7.5));
00414       hSnhits.push_back(dbe->book1D("hSnhitsm41","# of hits on Segments (ME -4/1); # of hits",8,-0.5,7.5));
00415       hSnhits.push_back(dbe->book1D("hSnhitsm32","# of hits on Segments (ME -3/2); # of hits",8,-0.5,7.5));
00416       hSnhits.push_back(dbe->book1D("hSnhitsm31","# of hits on Segments (ME -3/1); # of hits",8,-0.5,7.5));
00417       hSnhits.push_back(dbe->book1D("hSnhitsm22","# of hits on Segments (ME -2/2); # of hits",8,-0.5,7.5));
00418       hSnhits.push_back(dbe->book1D("hSnhitsm21","# of hits on Segments (ME -2/1); # of hits",8,-0.5,7.5));
00419       hSnhits.push_back(dbe->book1D("hSnhitsm11a","# of hits on Segments (ME -1/1a); # of hits",8,-0.5,7.5));
00420       hSnhits.push_back(dbe->book1D("hSnhitsm13","# of hits on Segments (ME -1/3); # of hits",8,-0.5,7.5));
00421       hSnhits.push_back(dbe->book1D("hSnhitsm12","# of hits on Segments (ME -1/2); # of hits",8,-0.5,7.5));
00422       hSnhits.push_back(dbe->book1D("hSnhitsm11b","# of hits on Segments (ME -1/1b); # of hits",8,-0.5,7.5));
00423       hSnhits.push_back(dbe->book1D("hSnhitsp11b","# of hits on Segments (ME +1/1b); # of hits",8,-0.5,7.5));
00424       hSnhits.push_back(dbe->book1D("hSnhitsp12","# of hits on Segments (ME +1/2); # of hits",8,-0.5,7.5));
00425       hSnhits.push_back(dbe->book1D("hSnhitsp13","# of hits on Segments (ME +1/3); # of hits",8,-0.5,7.5));
00426       hSnhits.push_back(dbe->book1D("hSnhitsp11a","# of hits on Segments (ME +1/1a); # of hits",8,-0.5,7.5));
00427       hSnhits.push_back(dbe->book1D("hSnhitsp21","# of hits on Segments (ME +2/1); # of hits",8,-0.5,7.5));
00428       hSnhits.push_back(dbe->book1D("hSnhitsp22","# of hits on Segments (ME +2/2); # of hits",8,-0.5,7.5));
00429       hSnhits.push_back(dbe->book1D("hSnhitsp31","# of hits on Segments (ME +3/1); # of hits",8,-0.5,7.5));
00430       hSnhits.push_back(dbe->book1D("hSnhitsp32","# of hits on Segments (ME +3/2); # of hits",8,-0.5,7.5));
00431       hSnhits.push_back(dbe->book1D("hSnhitsp41","# of hits on Segments (ME +4/1); # of hits",8,-0.5,7.5));
00432       hSnhits.push_back(dbe->book1D("hSnhitsp42","# of hits on Segments (ME +4/2); # of hits",8,-0.5,7.5));
00433       hSChiSqAll = dbe->book1D("hSChiSq","Segment Normalized Chi2; Chi2/ndof",110,-0.05,10.5);
00434       hSChiSq.push_back(dbe->book1D("hSChiSqm42","Segment Normalized Chi2 (ME -4/2); Chi2/ndof",110,-0.05,10.5));
00435       hSChiSq.push_back(dbe->book1D("hSChiSqm41","Segment Normalized Chi2 (ME -4/1); Chi2/ndof",110,-0.05,10.5));
00436       hSChiSq.push_back(dbe->book1D("hSChiSqm32","Segment Normalized Chi2 (ME -3/2); Chi2/ndof",110,-0.05,10.5));
00437       hSChiSq.push_back(dbe->book1D("hSChiSqm31","Segment Normalized Chi2 (ME -3/1); Chi2/ndof",110,-0.05,10.5));
00438       hSChiSq.push_back(dbe->book1D("hSChiSqm22","Segment Normalized Chi2 (ME -2/2); Chi2/ndof",110,-0.05,10.5));
00439       hSChiSq.push_back(dbe->book1D("hSChiSqm21","Segment Normalized Chi2 (ME -2/1); Chi2/ndof",110,-0.05,10.5));
00440       hSChiSq.push_back(dbe->book1D("hSChiSqm11a","Segment Normalized Chi2 (ME -1/1a); Chi2/ndof",110,-0.05,10.5));
00441       hSChiSq.push_back(dbe->book1D("hSChiSqm13","Segment Normalized Chi2 (ME -1/3); Chi2/ndof",110,-0.05,10.5));
00442       hSChiSq.push_back(dbe->book1D("hSChiSqm12","Segment Normalized Chi2 (ME -1/2); Chi2/ndof",110,-0.05,10.5));
00443       hSChiSq.push_back(dbe->book1D("hSChiSqm11b","Segment Normalized Chi2 (ME -1/1b); Chi2/ndof",110,-0.05,10.5));
00444       hSChiSq.push_back(dbe->book1D("hSChiSqp11b","Segment Normalized Chi2 (ME +1/1b); Chi2/ndof",110,-0.05,10.5));
00445       hSChiSq.push_back(dbe->book1D("hSChiSqp12","Segment Normalized Chi2 (ME +1/2); Chi2/ndof",110,-0.05,10.5));
00446       hSChiSq.push_back(dbe->book1D("hSChiSqp13","Segment Normalized Chi2 (ME +1/3); Chi2/ndof",110,-0.05,10.5));
00447       hSChiSq.push_back(dbe->book1D("hSChiSqp11a","Segment Normalized Chi2 (ME +1/1a); Chi2/ndof",110,-0.05,10.5));
00448       hSChiSq.push_back(dbe->book1D("hSChiSqp21","Segment Normalized Chi2 (ME +2/1); Chi2/ndof",110,-0.05,10.5));
00449       hSChiSq.push_back(dbe->book1D("hSChiSqp22","Segment Normalized Chi2 (ME +2/2); Chi2/ndof",110,-0.05,10.5));
00450       hSChiSq.push_back(dbe->book1D("hSChiSqp31","Segment Normalized Chi2 (ME +3/1); Chi2/ndof",110,-0.05,10.5));
00451       hSChiSq.push_back(dbe->book1D("hSChiSqp32","Segment Normalized Chi2 (ME +3/2); Chi2/ndof",110,-0.05,10.5));
00452       hSChiSq.push_back(dbe->book1D("hSChiSqp41","Segment Normalized Chi2 (ME +4/1); Chi2/ndof",110,-0.05,10.5));
00453       hSChiSq.push_back(dbe->book1D("hSChiSqp42","Segment Normalized Chi2 (ME +4/2); Chi2/ndof",110,-0.05,10.5));
00454       hSChiSqProbAll = dbe->book1D("hSChiSqProb","Segment chi2 Probability; Probability",110,-0.05,1.05);
00455       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm42","Segment chi2 Probability (ME -4/2); Probability",110,-0.05,1.05));
00456       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm41","Segment chi2 Probability (ME -4/1); Probability",110,-0.05,1.05));
00457       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm32","Segment chi2 Probability (ME -3/2); Probability",110,-0.05,1.05));
00458       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm31","Segment chi2 Probability (ME -3/1); Probability",110,-0.05,1.05));
00459       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm22","Segment chi2 Probability (ME -2/2); Probability",110,-0.05,1.05));
00460       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm21","Segment chi2 Probability (ME -2/1); Probability",110,-0.05,1.05));
00461       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm11a","Segment chi2 Probability (ME -1/1a); Probability",110,-0.05,1.05));
00462       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm13","Segment chi2 Probability (ME -1/3); Probability",110,-0.05,1.05));
00463       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm12","Segment chi2 Probability (ME -1/2); Probability",110,-0.05,1.05));
00464       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbm11b","Segment chi2 Probability (ME -1/1b); Probability",110,-0.05,1.05));
00465       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp11b","Segment chi2 Probability (ME +1/1b); Probability",110,-0.05,1.05));
00466       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp12","Segment chi2 Probability (ME +1/2); Probability",110,-0.05,1.05));
00467       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp13","Segment chi2 Probability (ME +1/3); Probability",110,-0.05,1.05));
00468       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp11a","Segment chi2 Probability (ME +1/1a); Probability",110,-0.05,1.05));
00469       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp21","Segment chi2 Probability (ME +2/1); Probability",110,-0.05,1.05));
00470       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp22","Segment chi2 Probability (ME +2/2); Probability",110,-0.05,1.05));
00471       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp31","Segment chi2 Probability (ME +3/1); Probability",110,-0.05,1.05));
00472       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp32","Segment chi2 Probability (ME +3/2); Probability",110,-0.05,1.05));
00473       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp41","Segment chi2 Probability (ME +4/1); Probability",110,-0.05,1.05));
00474       hSChiSqProb.push_back(dbe->book1D("hSChiSqProbp42","Segment chi2 Probability (ME +4/2); Probability",110,-0.05,1.05));
00475       hSGlobalTheta = dbe->book1D("hSGlobalTheta","Segment Direction (Global Theta); Global Theta (radians)",136,-0.1,3.3);
00476       hSGlobalPhi   = dbe->book1D("hSGlobalPhi","Segment Direction (Global Phi); Global Phi (radians)",  128,-3.2,3.2);
00477       hSTimeCathode  = dbe->book1D("hSTimeCathode", "Cathode Only Segment Time  [ns]",200,-200,200);
00478       hSTimeCombined = dbe->book1D("hSTimeCombined", "Segment Time (anode+cathode times) [ns]",200,-200,200);
00479       hSTimeVsZ   = dbe->book2D("hSTimeVsZ","Segment Time vs. Z; [ns] vs. [cm]",200,-1200,1200,200,-200,200);
00480       hSTimeVsTOF = dbe->book2D("hSTimeVsTOF","Segment Time vs. Distance from IP; [ns] vs. [cm]",180,500,1400, 200,-200,200);
00481       // Resolution
00482       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Resolution");
00483       hSResid.push_back(dbe->book1D("hSResidm42","Fitted Position on Strip - Reconstructed for Layer 3 (ME -4/2); Strip Widths",100,-0.5,0.5));
00484       hSResid.push_back(dbe->book1D("hSResidm41","Fitted Position on Strip - Reconstructed for Layer 3 (ME -4/1); Strip Widths",100,-0.5,0.5));
00485       hSResid.push_back(dbe->book1D("hSResidm32","Fitted Position on Strip - Reconstructed for Layer 3 (ME -3/2); Strip Widths",100,-0.5,0.5));
00486       hSResid.push_back(dbe->book1D("hSResidm31","Fitted Position on Strip - Reconstructed for Layer 3 (ME -3/1); Strip Widths",100,-0.5,0.5));
00487       hSResid.push_back(dbe->book1D("hSResidm22","Fitted Position on Strip - Reconstructed for Layer 3 (ME -2/2); Strip Widths",100,-0.5,0.5));
00488       hSResid.push_back(dbe->book1D("hSResidm21","Fitted Position on Strip - Reconstructed for Layer 3 (ME -2/1); Strip Widths",100,-0.5,0.5));
00489       hSResid.push_back(dbe->book1D("hSResidm11a","Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/1a); Strip Widths",100,-0.5,0.5));
00490       hSResid.push_back(dbe->book1D("hSResidm13","Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/3); Strip Widths",100,-0.5,0.5));
00491       hSResid.push_back(dbe->book1D("hSResidm12","Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/2); Strip Widths",100,-0.5,0.5));
00492       hSResid.push_back(dbe->book1D("hSResidm11b","Fitted Position on Strip - Reconstructed for Layer 3 (ME -1/1b); Strip Widths",100,-0.5,0.5));
00493       hSResid.push_back(dbe->book1D("hSResidp11b","Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/1b); Strip Widths",100,-0.5,0.5));
00494       hSResid.push_back(dbe->book1D("hSResidp12","Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/2); Strip Widths",100,-0.5,0.5));
00495       hSResid.push_back(dbe->book1D("hSResidp13","Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/3); Strip Widths",100,-0.5,0.5));
00496       hSResid.push_back(dbe->book1D("hSResidp11a","Fitted Position on Strip - Reconstructed for Layer 3 (ME +1/1a); Strip Widths",100,-0.5,0.5));
00497       hSResid.push_back(dbe->book1D("hSResidp21","Fitted Position on Strip - Reconstructed for Layer 3 (ME +2/1); Strip Widths",100,-0.5,0.5));
00498       hSResid.push_back(dbe->book1D("hSResidp22","Fitted Position on Strip - Reconstructed for Layer 3 (ME +2/2); Strip Widths",100,-0.5,0.5));
00499       hSResid.push_back(dbe->book1D("hSResidp31","Fitted Position on Strip - Reconstructed for Layer 3 (ME +3/1); Strip Widths",100,-0.5,0.5));
00500       hSResid.push_back(dbe->book1D("hSResidp32","Fitted Position on Strip - Reconstructed for Layer 3 (ME +3/2); Strip Widths",100,-0.5,0.5));
00501       hSResid.push_back(dbe->book1D("hSResidp41","Fitted Position on Strip - Reconstructed for Layer 3 (ME +4/1); Strip Widths",100,-0.5,0.5));
00502       hSResid.push_back(dbe->book1D("hSResidp42","Fitted Position on Strip - Reconstructed for Layer 3 (ME +4/2); Strip Widths",100,-0.5,0.5));
00503 
00504       // Efficiency
00505       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/Efficiency");
00506       hSSTE = new TH1F("hSSTE","hSSTE",40,0.5,40.5);
00507       hRHSTE = new TH1F("hRHSTE","hRHSTE",40,0.5,40.5);
00508       hSEff = dbe->book1D("hSEff","Segment Efficiency",20,0.5,20.5);
00509       hSEff->setBinLabel(1,"ME +1/1b");
00510       hSEff->setBinLabel(2,"ME +1/2");
00511       hSEff->setBinLabel(3,"ME +1/3");
00512       hSEff->setBinLabel(4,"ME +1/1a");
00513       hSEff->setBinLabel(5,"ME +2/1");
00514       hSEff->setBinLabel(6,"ME +2/2");
00515       hSEff->setBinLabel(7,"ME +3/1");
00516       hSEff->setBinLabel(8,"ME +3/2");
00517       hSEff->setBinLabel(9,"ME +4/1");
00518       hSEff->setBinLabel(10,"ME +4/2");
00519       hSEff->setBinLabel(11,"ME -1/1b");
00520       hSEff->setBinLabel(12,"ME -1/2");
00521       hSEff->setBinLabel(13,"ME -1/3");
00522       hSEff->setBinLabel(14,"ME -1/1a");
00523       hSEff->setBinLabel(15,"ME -2/1");
00524       hSEff->setBinLabel(16,"ME -2/2");
00525       hSEff->setBinLabel(17,"ME -3/1");
00526       hSEff->setBinLabel(18,"ME -3/2");
00527       hSEff->setBinLabel(19,"ME -4/1");
00528       hSEff->setBinLabel(20,"ME -4/2");
00529       hRHEff = dbe->book1D("hRHEff","recHit Efficiency",20,0.5,20.5);
00530       hRHEff->setBinLabel(1,"ME +1/1b");
00531       hRHEff->setBinLabel(2,"ME +1/2");
00532       hRHEff->setBinLabel(3,"ME +1/3");
00533       hRHEff->setBinLabel(4,"ME +1/1a");
00534       hRHEff->setBinLabel(5,"ME +2/1");
00535       hRHEff->setBinLabel(6,"ME +2/2");
00536       hRHEff->setBinLabel(7,"ME +3/1");
00537       hRHEff->setBinLabel(8,"ME +3/2");
00538       hRHEff->setBinLabel(9,"ME +4/1");
00539       hRHEff->setBinLabel(10,"ME +4/2");
00540       hRHEff->setBinLabel(11,"ME -1/1b");
00541       hRHEff->setBinLabel(12,"ME -1/2");
00542       hRHEff->setBinLabel(13,"ME -1/3");
00543       hRHEff->setBinLabel(14,"ME -1/1a");
00544       hRHEff->setBinLabel(15,"ME -2/1");
00545       hRHEff->setBinLabel(16,"ME -2/2");
00546       hRHEff->setBinLabel(17,"ME -3/1");
00547       hRHEff->setBinLabel(18,"ME -3/2");
00548       hRHEff->setBinLabel(19,"ME -4/1");
00549       hRHEff->setBinLabel(20,"ME -4/2");
00550       hSSTE2 = new TH2F("hSSTE2","hSSTE2",36,0.5,36.5, 18, 0.5, 18.5);
00551       hRHSTE2 = new TH2F("hRHSTE2","hRHSTE2",36,0.5,36.5, 18, 0.5, 18.5);
00552       hStripSTE2 = new TH2F("hStripSTE2","hStripSTE2",36,0.5,36.5, 18, 0.5, 18.5);
00553       hWireSTE2 = new TH2F("hWireSTE2","hWireSTE2",36,0.5,36.5, 18, 0.5, 18.5);
00554       hEffDenominator = new TH2F("hEffDenominator","hEffDenominator",36,0.5,36.5, 18, 0.5, 18.5);
00555       hSEff2 = dbe->book2D("hSEff2","Segment Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
00556       hSEff2->setAxisTitle("Chamber #");
00557       hSEff2->setBinLabel(1,"ME -4/1",2);
00558       hSEff2->setBinLabel(2,"ME -3/2",2);
00559       hSEff2->setBinLabel(3,"ME -2/1",2);
00560       hSEff2->setBinLabel(4,"ME -2/2",2);
00561       hSEff2->setBinLabel(5,"ME -2/1",2);
00562       hSEff2->setBinLabel(6,"ME -1/3",2);
00563       hSEff2->setBinLabel(7,"ME -1/2",2);
00564       hSEff2->setBinLabel(8,"ME -1/1b",2);
00565       hSEff2->setBinLabel(9,"ME -1/1a",2);
00566       hSEff2->setBinLabel(10,"ME +1/1a",2);
00567       hSEff2->setBinLabel(11,"ME +1/1b",2);
00568       hSEff2->setBinLabel(12,"ME +1/2",2);
00569       hSEff2->setBinLabel(13,"ME +1/3",2);
00570       hSEff2->setBinLabel(14,"ME +2/1",2);
00571       hSEff2->setBinLabel(15,"ME +2/2",2);
00572       hSEff2->setBinLabel(16,"ME +3/1",2);
00573       hSEff2->setBinLabel(17,"ME +3/2",2);
00574       hSEff2->setBinLabel(18,"ME +4/1",2);
00575       hRHEff2 = dbe->book2D("hRHEff2","recHit Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
00576       hRHEff2->setAxisTitle("Chamber #");
00577       hRHEff2->setBinLabel(1,"ME -4/1",2);
00578       hRHEff2->setBinLabel(2,"ME -3/2",2);
00579       hRHEff2->setBinLabel(3,"ME -2/1",2);
00580       hRHEff2->setBinLabel(4,"ME -2/2",2);
00581       hRHEff2->setBinLabel(5,"ME -2/1",2);
00582       hRHEff2->setBinLabel(6,"ME -1/3",2);
00583       hRHEff2->setBinLabel(7,"ME -1/2",2);
00584       hRHEff2->setBinLabel(8,"ME -1/1b",2);
00585       hRHEff2->setBinLabel(9,"ME -1/1a",2);
00586       hRHEff2->setBinLabel(10,"ME +1/1a",2);
00587       hRHEff2->setBinLabel(11,"ME +1/1b",2);
00588       hRHEff2->setBinLabel(12,"ME +1/2",2);
00589       hRHEff2->setBinLabel(13,"ME +1/3",2);
00590       hRHEff2->setBinLabel(14,"ME +2/1",2);
00591       hRHEff2->setBinLabel(15,"ME +2/2",2);
00592       hRHEff2->setBinLabel(16,"ME +3/1",2);
00593       hRHEff2->setBinLabel(17,"ME +3/2",2);
00594       hRHEff2->setBinLabel(18,"ME +4/1",2);
00595       hStripReadoutEff2 = dbe->book2D("hStripReadoutEff2","strip readout ratio [(strip+clct+wires)/(clct+wires)] 2D",36,0.5,36.5, 20, 0.5, 20.5);
00596       hStripReadoutEff2->setAxisTitle("Chamber #");
00597       hStripReadoutEff2->setBinLabel(1,"ME -4/2",2);
00598       hStripReadoutEff2->setBinLabel(2,"ME -4/1",2);
00599       hStripReadoutEff2->setBinLabel(3,"ME -3/2",2);
00600       hStripReadoutEff2->setBinLabel(4,"ME -2/1",2);
00601       hStripReadoutEff2->setBinLabel(5,"ME -2/2",2);
00602       hStripReadoutEff2->setBinLabel(6,"ME -2/1",2);
00603       hStripReadoutEff2->setBinLabel(7,"ME -1/3",2);
00604       hStripReadoutEff2->setBinLabel(8,"ME -1/2",2);
00605       hStripReadoutEff2->setBinLabel(9,"ME -1/1b",2);
00606       hStripReadoutEff2->setBinLabel(10,"ME -1/1a",2);
00607       hStripReadoutEff2->setBinLabel(11,"ME +1/1a",2);
00608       hStripReadoutEff2->setBinLabel(12,"ME +1/1b",2);
00609       hStripReadoutEff2->setBinLabel(13,"ME +1/2",2);
00610       hStripReadoutEff2->setBinLabel(14,"ME +1/3",2);
00611       hStripReadoutEff2->setBinLabel(15,"ME +2/1",2);
00612       hStripReadoutEff2->setBinLabel(16,"ME +2/2",2);
00613       hStripReadoutEff2->setBinLabel(17,"ME +3/1",2);
00614       hStripReadoutEff2->setBinLabel(18,"ME +3/2",2);
00615       hStripReadoutEff2->setBinLabel(19,"ME +4/1",2);
00616       hStripReadoutEff2->setBinLabel(20,"ME +4/2",2);
00617       hStripEff2 = dbe->book2D("hStripEff2","strip Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
00618       hStripEff2->setAxisTitle("Chamber #");
00619       hStripEff2->setBinLabel(1,"ME -4/1",2);
00620       hStripEff2->setBinLabel(2,"ME -3/2",2);
00621       hStripEff2->setBinLabel(3,"ME -2/1",2);
00622       hStripEff2->setBinLabel(4,"ME -2/2",2);
00623       hStripEff2->setBinLabel(5,"ME -2/1",2);
00624       hStripEff2->setBinLabel(6,"ME -1/3",2);
00625       hStripEff2->setBinLabel(7,"ME -1/2",2);
00626       hStripEff2->setBinLabel(8,"ME -1/1b",2);
00627       hStripEff2->setBinLabel(9,"ME -1/1a",2);
00628       hStripEff2->setBinLabel(10,"ME +1/1a",2);
00629       hStripEff2->setBinLabel(11,"ME +1/1b",2);
00630       hStripEff2->setBinLabel(12,"ME +1/2",2);
00631       hStripEff2->setBinLabel(13,"ME +1/3",2);
00632       hStripEff2->setBinLabel(14,"ME +2/1",2);
00633       hStripEff2->setBinLabel(15,"ME +2/2",2);
00634       hStripEff2->setBinLabel(16,"ME +3/1",2);
00635       hStripEff2->setBinLabel(17,"ME +3/2",2);
00636       hStripEff2->setBinLabel(18,"ME +4/1",2);
00637       hWireEff2 = dbe->book2D("hWireEff2","wire Efficiency 2D",36,0.5,36.5, 18, 0.5, 18.5);
00638       hWireEff2->setAxisTitle("Chamber #");
00639       hWireEff2->setBinLabel(1,"ME -4/1",2);
00640       hWireEff2->setBinLabel(2,"ME -3/2",2);
00641       hWireEff2->setBinLabel(3,"ME -2/1",2);
00642       hWireEff2->setBinLabel(4,"ME -2/2",2);
00643       hWireEff2->setBinLabel(5,"ME -2/1",2);
00644       hWireEff2->setBinLabel(6,"ME -1/3",2);
00645       hWireEff2->setBinLabel(7,"ME -1/2",2);
00646       hWireEff2->setBinLabel(8,"ME -1/1b",2);
00647       hWireEff2->setBinLabel(9,"ME -1/1a",2);
00648       hWireEff2->setBinLabel(10,"ME +1/1a",2);
00649       hWireEff2->setBinLabel(11,"ME +1/1b",2);
00650       hWireEff2->setBinLabel(12,"ME +1/2",2);
00651       hWireEff2->setBinLabel(13,"ME +1/3",2);
00652       hWireEff2->setBinLabel(14,"ME +2/1",2);
00653       hWireEff2->setBinLabel(15,"ME +2/2",2);
00654       hWireEff2->setBinLabel(16,"ME +3/1",2);
00655       hWireEff2->setBinLabel(17,"ME +3/2",2);
00656       hWireEff2->setBinLabel(18,"ME +4/1",2);
00657       hSensitiveAreaEvt = dbe->book2D("hSensitiveAreaEvt","Events Passing Selection for Efficiency",36,0.5,36.5, 18, 0.5, 18.5);
00658       hSensitiveAreaEvt->setAxisTitle("Chamber #");
00659       hSensitiveAreaEvt->setBinLabel(1,"ME -4/1",2);
00660       hSensitiveAreaEvt->setBinLabel(2,"ME -3/2",2);
00661       hSensitiveAreaEvt->setBinLabel(3,"ME -2/1",2);
00662       hSensitiveAreaEvt->setBinLabel(4,"ME -2/2",2);
00663       hSensitiveAreaEvt->setBinLabel(5,"ME -2/1",2);
00664       hSensitiveAreaEvt->setBinLabel(6,"ME -1/3",2);
00665       hSensitiveAreaEvt->setBinLabel(7,"ME -1/2",2);
00666       hSensitiveAreaEvt->setBinLabel(8,"ME -1/1b",2);
00667       hSensitiveAreaEvt->setBinLabel(9,"ME -1/1a",2);
00668       hSensitiveAreaEvt->setBinLabel(10,"ME +1/1a",2);
00669       hSensitiveAreaEvt->setBinLabel(11,"ME +1/1b",2);
00670       hSensitiveAreaEvt->setBinLabel(12,"ME +1/2",2);
00671       hSensitiveAreaEvt->setBinLabel(13,"ME +1/3",2);
00672       hSensitiveAreaEvt->setBinLabel(14,"ME +2/1",2);
00673       hSensitiveAreaEvt->setBinLabel(15,"ME +2/2",2);
00674       hSensitiveAreaEvt->setBinLabel(16,"ME +3/1",2);
00675       hSensitiveAreaEvt->setBinLabel(17,"ME +3/2",2);
00676       hSensitiveAreaEvt->setBinLabel(18,"ME +4/1",2);
00677 
00678       // BX Monitor for trigger synchronization
00679       dbe->setCurrentFolder("CSC/CSCOfflineMonitor/BXMonitor");
00680       hALCTgetBX = dbe->book1D("hALCTgetBX","ALCT position in ALCT-L1A match window [BX]",7,-0.5,6.5);
00681       hALCTgetBXChamberMeans = dbe->book1D("hALCTgetBXChamberMeans","Chamber Mean ALCT position in ALCT-L1A match window [BX]",60,0,6);
00682       hALCTgetBXSerial = dbe->book2D("hALCTgetBXSerial","ALCT position in ALCT-L1A match window [BX]",601,-0.5,600.5,7,-0.5,6.5);
00683       hALCTgetBXSerial->setAxisTitle("Chamber Serial Number");
00684       hALCTgetBX2DNumerator = new TH2F("hALCTgetBX2DNumerator","ALCT position in ALCT-L1A match window [BX] (sum)",36,0.5,36.5,20,0.5,20.5);
00685       hALCTgetBX2DMeans = dbe->book2D("hALCTgetBX2DMeans","ALCT position in ALCT-L1A match window [BX]",36,0.5,36.5,20,0.5,20.5);
00686       hALCTgetBX2Denominator = dbe->book2D("hALCTgetBX2Denominator","Number of ALCT Digis checked",36,0.5,36.5,20,0.5,20.5);
00687       hALCTgetBX2DMeans->setAxisTitle("Chamber #");
00688       hALCTgetBX2DMeans->setBinLabel(1,"ME -4/2",2);
00689       hALCTgetBX2DMeans->setBinLabel(2,"ME -4/1",2);
00690       hALCTgetBX2DMeans->setBinLabel(3,"ME -3/2",2);
00691       hALCTgetBX2DMeans->setBinLabel(4,"ME -2/1",2);
00692       hALCTgetBX2DMeans->setBinLabel(5,"ME -2/2",2);
00693       hALCTgetBX2DMeans->setBinLabel(6,"ME -2/1",2);
00694       hALCTgetBX2DMeans->setBinLabel(7,"ME -1/3",2);
00695       hALCTgetBX2DMeans->setBinLabel(8,"ME -1/2",2);
00696       hALCTgetBX2DMeans->setBinLabel(9,"ME -1/1b",2);
00697       hALCTgetBX2DMeans->setBinLabel(10,"ME -1/1a",2);
00698       hALCTgetBX2DMeans->setBinLabel(11,"ME +1/1a",2);
00699       hALCTgetBX2DMeans->setBinLabel(12,"ME +1/1b",2);
00700       hALCTgetBX2DMeans->setBinLabel(13,"ME +1/2",2);
00701       hALCTgetBX2DMeans->setBinLabel(14,"ME +1/3",2);
00702       hALCTgetBX2DMeans->setBinLabel(15,"ME +2/1",2);
00703       hALCTgetBX2DMeans->setBinLabel(16,"ME +2/2",2);
00704       hALCTgetBX2DMeans->setBinLabel(17,"ME +3/1",2);
00705       hALCTgetBX2DMeans->setBinLabel(18,"ME +3/2",2);
00706       hALCTgetBX2DMeans->setBinLabel(19,"ME +4/1",2);
00707       hALCTgetBX2DMeans->setBinLabel(20,"ME +4/2",2);
00708       hALCTMatch = dbe->book1D("hALCTMatch","ALCT position in ALCT-CLCT match window [BX]",7,-0.5,6.5);
00709       hALCTMatchChamberMeans = dbe->book1D("hALCTMatchChamberMeans","Chamber Mean ALCT position in ALCT-CLCT match window [BX]",60,0,6);
00710       hALCTMatchSerial = dbe->book2D("hALCTMatchSerial","ALCT position in ALCT-CLCT match window [BX]",601,-0.5,600.5,7,-0.5,6.5);
00711       hALCTMatchSerial->setAxisTitle("Chamber Serial Number");
00712       hALCTMatch2DNumerator = new TH2F("hALCTMatch2DNumerator","ALCT position in ALCT-CLCT match window [BX] (sum)",36,0.5,36.5,20,0.5,20.5);
00713       hALCTMatch2DMeans = dbe->book2D("hALCTMatch2DMeans","ALCT position in ALCT-CLCT match window [BX]",36,0.5,36.5,20,0.5,20.5);
00714       hALCTMatch2Denominator = dbe->book2D("hALCTMatch2Denominator","Number of ALCT-CLCT matches checked",36,0.5,36.5,20,0.5,20.5);
00715       hALCTMatch2DMeans->setAxisTitle("Chamber #");
00716       hALCTMatch2DMeans->setBinLabel(1,"ME -4/2",2);
00717       hALCTMatch2DMeans->setBinLabel(2,"ME -4/1",2);
00718       hALCTMatch2DMeans->setBinLabel(3,"ME -3/2",2);
00719       hALCTMatch2DMeans->setBinLabel(4,"ME -2/1",2);
00720       hALCTMatch2DMeans->setBinLabel(5,"ME -2/2",2);
00721       hALCTMatch2DMeans->setBinLabel(6,"ME -2/1",2);
00722       hALCTMatch2DMeans->setBinLabel(7,"ME -1/3",2);
00723       hALCTMatch2DMeans->setBinLabel(8,"ME -1/2",2);
00724       hALCTMatch2DMeans->setBinLabel(9,"ME -1/1b",2);
00725       hALCTMatch2DMeans->setBinLabel(10,"ME -1/1a",2);
00726       hALCTMatch2DMeans->setBinLabel(11,"ME +1/1a",2);
00727       hALCTMatch2DMeans->setBinLabel(12,"ME +1/1b",2);
00728       hALCTMatch2DMeans->setBinLabel(13,"ME +1/2",2);
00729       hALCTMatch2DMeans->setBinLabel(14,"ME +1/3",2);
00730       hALCTMatch2DMeans->setBinLabel(15,"ME +2/1",2);
00731       hALCTMatch2DMeans->setBinLabel(16,"ME +2/2",2);
00732       hALCTMatch2DMeans->setBinLabel(17,"ME +3/1",2);
00733       hALCTMatch2DMeans->setBinLabel(18,"ME +3/2",2);
00734       hALCTMatch2DMeans->setBinLabel(19,"ME +4/1",2);
00735       hALCTMatch2DMeans->setBinLabel(20,"ME +4/2",2);
00736       hCLCTL1A = dbe->book1D("hCLCTL1A","L1A - CLCTpreTrigger at TMB [BX]",10,149.5,159.5);
00737       hCLCTL1AChamberMeans = dbe->book1D("hCLCTL1AChamberMeans","Chamber Mean L1A - CLCTpreTrigger at TMB [BX]",90,150,159);
00738       hCLCTL1ASerial = dbe->book2D("hCLCTL1ASerial","L1A - CLCTpreTrigger at TMB [BX]",601,-0.5,600.5,10,149.5,159.5);
00739       hCLCTL1ASerial->setAxisTitle("Chamber Serial Number");
00740       hCLCTL1A2DNumerator = new TH2F("hCLCTL1A2DNumerator","L1A - CLCTpreTrigger at TMB [BX] (sum)",36,0.5,36.5,20,0.5,20.5);
00741       hCLCTL1A2DMeans = dbe->book2D("hCLCTL1A2DMeans","L1A - CLCTpreTrigger at TMB [BX]",36,0.5,36.5,20,0.5,20.5);
00742       hCLCTL1A2Denominator = dbe->book2D("hCLCTL1A2Denominator","Number of TMB CLCTs checked",36,0.5,36.5,20,0.5,20.5);
00743       hCLCTL1A2DMeans->setAxisTitle("Chamber #");
00744       hCLCTL1A2DMeans->setBinLabel(1,"ME -4/2",2);
00745       hCLCTL1A2DMeans->setBinLabel(2,"ME -4/1",2);
00746       hCLCTL1A2DMeans->setBinLabel(3,"ME -3/2",2);
00747       hCLCTL1A2DMeans->setBinLabel(4,"ME -2/1",2);
00748       hCLCTL1A2DMeans->setBinLabel(5,"ME -2/2",2);
00749       hCLCTL1A2DMeans->setBinLabel(6,"ME -2/1",2);
00750       hCLCTL1A2DMeans->setBinLabel(7,"ME -1/3",2);
00751       hCLCTL1A2DMeans->setBinLabel(8,"ME -1/2",2);
00752       hCLCTL1A2DMeans->setBinLabel(9,"ME -1/1b",2);
00753       hCLCTL1A2DMeans->setBinLabel(10,"ME -1/1a",2);
00754       hCLCTL1A2DMeans->setBinLabel(11,"ME +1/1a",2);
00755       hCLCTL1A2DMeans->setBinLabel(12,"ME +1/1b",2);
00756       hCLCTL1A2DMeans->setBinLabel(13,"ME +1/2",2);
00757       hCLCTL1A2DMeans->setBinLabel(14,"ME +1/3",2);
00758       hCLCTL1A2DMeans->setBinLabel(15,"ME +2/1",2);
00759       hCLCTL1A2DMeans->setBinLabel(16,"ME +2/2",2);
00760       hCLCTL1A2DMeans->setBinLabel(17,"ME +3/1",2);
00761       hCLCTL1A2DMeans->setBinLabel(18,"ME +3/2",2);
00762       hCLCTL1A2DMeans->setBinLabel(19,"ME +4/1",2);
00763       hCLCTL1A2DMeans->setBinLabel(20,"ME +4/2",2);
00764 
00765 }
00766 
00768 //  DESTRUCTOR  //
00770 CSCOfflineMonitor::~CSCOfflineMonitor(){
00771 
00772 }
00773 
00774 void CSCOfflineMonitor::endRun( edm::Run const &, edm::EventSetup const & ){
00775   
00776   if (!finalizedHistograms_){
00777     finalize() ;
00778     finalizedHistograms_ = true ;
00779   }
00780 
00781 }
00782 
00783 void CSCOfflineMonitor::endJob(){
00784   
00785   finalize() ;
00786   finalizedHistograms_ = true ;
00787   
00788   bool saveHistos = param.getParameter<bool>("saveHistos");
00789   string outputFileName = param.getParameter<string>("outputFileName");
00790   if(saveHistos){
00791     dbe->save(outputFileName);
00792   }
00793 
00794 }
00795 
00796 
00797 void CSCOfflineMonitor::finalize() {
00798 
00799   hRHEff = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hRHEff");
00800   hSEff = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hSEff");
00801   hSEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hSEff2");
00802   hRHEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hRHEff2");
00803   hStripEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hStripEff2");
00804   hWireEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hWireEff2");
00805 
00806   hOStripsAndWiresAndCLCT= dbe->get("CSC/CSCOfflineMonitor/Occupancy/hOStripsAndWiresAndCLCT");
00807   hOWiresAndCLCT= dbe->get("CSC/CSCOfflineMonitor/Occupancy/hOWiresAndCLCT");
00808   hStripReadoutEff2 = dbe->get("CSC/CSCOfflineMonitor/Efficiency/hStripReadoutEff2");
00809 
00810   hALCTgetBX2DMeans = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hALCTgetBX2DMeans");
00811   hALCTMatch2DMeans = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hALCTMatch2DMeans");
00812   hCLCTL1A2DMeans   = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hCLCTL1A2DMeans");
00813 
00814   hALCTgetBXSerial = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hALCTgetBXSerial");
00815   hALCTMatchSerial = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hALCTMatchSerial");
00816   hCLCTL1ASerial   = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hCLCTL1ASerial");
00817 
00818   hALCTgetBXChamberMeans = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hALCTgetBXChamberMeans");
00819   hALCTMatchChamberMeans = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hALCTMatchChamberMeans");
00820   hCLCTL1AChamberMeans   = dbe->get("CSC/CSCOfflineMonitor/BXMonitor/hCLCTL1AChamberMeans");
00821 
00822   if (hRHEff) histoEfficiency(hRHSTE,hRHEff);
00823   if (hSEff) histoEfficiency(hSSTE,hSEff);
00824   if (hSEff2) hSEff2->getTH2F()->Divide(hSSTE2,hEffDenominator,1.,1.,"B");
00825   if (hRHEff2) hRHEff2->getTH2F()->Divide(hRHSTE2,hEffDenominator,1.,1.,"B");
00826   if (hStripEff2) hStripEff2->getTH2F()->Divide(hStripSTE2,hEffDenominator,1.,1.,"B");
00827   if (hWireEff2) hWireEff2->getTH2F()->Divide(hWireSTE2,hEffDenominator,1.,1.,"B");
00828   if (hStripReadoutEff2) hStripReadoutEff2->getTH2F()->Divide(hOStripsAndWiresAndCLCT->getTH2F(),hOWiresAndCLCT->getTH2F(),1.,1.,"B");
00829   if (hALCTMatch2DMeans){ 
00830     harvestChamberMeans(hALCTMatchChamberMeans, hALCTMatch2DMeans, hALCTMatch2DNumerator,hALCTMatch2Denominator );
00831   }
00832   if (hALCTgetBX2DMeans) {
00833     harvestChamberMeans(hALCTgetBXChamberMeans, hALCTgetBX2DMeans, hALCTgetBX2DNumerator, hALCTgetBX2Denominator );
00834   }
00835   if (hCLCTL1A2DMeans) {
00836     harvestChamberMeans(hCLCTL1AChamberMeans, hCLCTL1A2DMeans, hCLCTL1A2DNumerator, hCLCTL1A2Denominator );
00837   }
00838 
00839   if(hALCTgetBXSerial)  normalize(hALCTgetBXSerial);
00840   if(hALCTMatchSerial)  normalize(hALCTMatchSerial);
00841   if(hCLCTL1ASerial)    normalize(hCLCTL1ASerial);
00842 
00843 
00844 }
00845 
00846 void CSCOfflineMonitor::harvestChamberMeans(MonitorElement* meMean1D, MonitorElement *meMean2D, TH2F *hNum, MonitorElement *meDenom){
00847 
00848 
00849   if (hNum->GetNbinsY()!= meDenom->getNbinsY() || hNum->GetNbinsX()!= meDenom->getNbinsX())
00850     return;
00851   if (meMean2D->getNbinsY()!= meDenom->getNbinsY() || meMean2D->getNbinsX()!= meDenom->getNbinsX())
00852     return;
00853 
00854   float mean;
00855   for (int biny = 0; biny < hNum->GetNbinsY()+1 ; biny++){
00856     for (int binx = 0; binx < hNum->GetNbinsX()+1 ; binx++){
00857       if ( meDenom->getBinContent(binx,biny) > 0){
00858         mean = hNum->GetBinContent(binx,biny)/meDenom->getBinContent(binx,biny);
00859         meMean1D->Fill(mean);
00860         meMean2D->setBinContent(binx,biny,mean);
00861       }
00862     }
00863   }
00864 
00865   return;
00866 }
00867 
00868 void CSCOfflineMonitor::normalize(MonitorElement* me){
00869     
00870   TH2F* h = me->getTH2F();
00871   TH1D* hproj = h->ProjectionX("hproj");
00872 
00873   for (int binx = 0; binx < h->GetNbinsX()+1 ; binx++){
00874     Double_t entries = hproj->GetBinContent(binx);
00875     for (Int_t biny=1;biny <= h->GetNbinsY();biny++) {
00876       Double_t cxy = h->GetBinContent(binx,biny);
00877       if (cxy > 0 && entries>0) h->SetBinContent(binx,biny,cxy/entries);
00878     }
00879   }
00880 
00881 
00882     return;
00883 
00884 }
00885 
00886 
00887 
00889 //  Analysis  //
00891 void CSCOfflineMonitor::analyze(const Event & event, const EventSetup& eventSetup){
00892 
00893   edm::Handle<CSCWireDigiCollection> wires;
00894   edm::Handle<CSCStripDigiCollection> strips;
00895   edm::Handle<CSCALCTDigiCollection> alcts;
00896   edm::Handle<CSCCLCTDigiCollection> clcts;
00897   event.getByLabel(stripDigiTag_, strips);
00898   event.getByLabel(wireDigiTag_, wires);
00899   event.getByLabel(alctDigiTag_, alcts);
00900   event.getByLabel(clctDigiTag_, clcts);
00901 
00902   // Get the CSC Geometry :
00903   ESHandle<CSCGeometry> cscGeom;
00904   eventSetup.get<MuonGeometryRecord>().get(cscGeom);
00905 
00906   // Get the RecHits collection :
00907   Handle<CSCRecHit2DCollection> recHits;
00908   event.getByLabel(cscRecHitTag_,recHits);
00909 
00910   // get CSC segment collection
00911   Handle<CSCSegmentCollection> cscSegments;
00912   event.getByLabel(cscSegTag_, cscSegments);
00913 
00914 
00915   doOccupancies(strips,wires,recHits,cscSegments,clcts);
00916   doStripDigis(strips);
00917   doWireDigis(wires);
00918   doRecHits(recHits,strips,cscGeom);
00919   doSegments(cscSegments,cscGeom);
00920   doResolution(cscSegments,cscGeom);
00921   doPedestalNoise(strips);
00922   doEfficiencies(wires,strips, recHits, cscSegments,cscGeom);
00923   doBXMonitor(alcts, clcts, event, eventSetup);
00924 }
00925 
00926 // ==============================================
00927 //
00928 // look at Occupancies
00929 //
00930 // ==============================================
00931 
00932 void CSCOfflineMonitor::doOccupancies(edm::Handle<CSCStripDigiCollection> strips, edm::Handle<CSCWireDigiCollection> wires,
00933                                       edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
00934                                       edm::Handle<CSCCLCTDigiCollection> clcts){
00935 
00936   bool clcto[2][4][4][36];
00937   bool wireo[2][4][4][36];
00938   bool stripo[2][4][4][36];
00939   bool rechito[2][4][4][36];
00940   bool segmento[2][4][4][36];
00941 
00942   bool hasWires = false;
00943   bool hasStrips = false;
00944   bool hasRecHits = false;
00945   bool hasSegments = false;
00946 
00947   for (int e = 0; e < 2; e++){
00948     for (int s = 0; s < 4; s++){
00949       for (int r = 0; r < 4; r++){
00950         for (int c = 0; c < 36; c++){
00951           clcto[e][s][r][c] = false;
00952           wireo[e][s][r][c] = false;
00953           stripo[e][s][r][c] = false;
00954           rechito[e][s][r][c] = false;
00955           segmento[e][s][r][c] = false;
00956         }
00957       }
00958     }
00959   }
00960 
00961   //clcts
00962   for (CSCCLCTDigiCollection::DigiRangeIterator j=clcts->begin(); j!=clcts->end(); j++) {
00963     CSCDetId id = (CSCDetId)(*j).first;
00964     int kEndcap  = id.endcap();
00965     int kRing    = id.ring();
00966     int kStation = id.station();
00967     int kChamber = id.chamber();
00968     const CSCCLCTDigiCollection::Range& range =(*j).second;
00969     for (CSCCLCTDigiCollection::const_iterator digiIt = range.first; digiIt!=range.second; ++digiIt){
00970       // Valid digi in the chamber (or in neighbouring chamber) 
00971       if((*digiIt).isValid()){
00972       //Check whether this CLCT came from ME11a
00973         if( kStation ==1 && kRing==1 && (*digiIt).getKeyStrip()>128)
00974           kRing = 4;
00975         clcto[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00976       }
00977     }
00978   }
00979 
00980   //wires
00981   for (CSCWireDigiCollection::DigiRangeIterator wi=wires->begin(); wi!=wires->end(); wi++) {
00982     CSCDetId id = (CSCDetId)(*wi).first;
00983     int kEndcap  = id.endcap();
00984     int kRing    = id.ring();
00985     int kStation = id.station();
00986     int kChamber = id.chamber();
00987     std::vector<CSCWireDigi>::const_iterator wireIt = (*wi).second.first;
00988     std::vector<CSCWireDigi>::const_iterator lastWire = (*wi).second.second;
00989     for( ; wireIt != lastWire; ++wireIt){
00990       if (!wireo[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
00991         wireo[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
00992         hOWires->Fill(kChamber,typeIndex(id,2));
00993         hOWireSerial->Fill(chamberSerial(id));
00994         hasWires = true;
00995         if( clcto[kEndcap-1][kStation-1][kRing-1][kChamber-1])
00996           hOWiresAndCLCT->Fill(kChamber,typeIndex(id,2));
00997         //Also check for a CLCT in ME11a if you're in ME11 already
00998         if (kStation==1 && kRing==1 && clcto[kEndcap-1][kStation-1][3][kChamber-1]){
00999           CSCDetId idME11a = CSCDetId(kEndcap, kStation, 4, kChamber);
01000           hOWiresAndCLCT->Fill(kChamber,typeIndex(idME11a,2));
01001         } 
01002       }
01003     }//end for loop
01004   }
01005   
01006   //strips
01007   for (CSCStripDigiCollection::DigiRangeIterator si=strips->begin(); si!=strips->end(); si++) {
01008     CSCDetId id = (CSCDetId)(*si).first;
01009     int kEndcap  = id.endcap();
01010     int kRing    = id.ring();
01011     int kStation = id.station();
01012     int kChamber = id.chamber();
01013     std::vector<CSCStripDigi>::const_iterator stripIt = (*si).second.first;
01014     std::vector<CSCStripDigi>::const_iterator lastStrip = (*si).second.second;
01015     for( ; stripIt != lastStrip; ++stripIt) {
01016       std::vector<int> myADCVals = stripIt->getADCCounts();
01017       bool thisStripFired = false;
01018       float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01019       float threshold = 13.3 ;
01020       float diff = 0.;
01021       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
01022         diff = (float)myADCVals[iCount]-thisPedestal;
01023         if (diff > threshold) { thisStripFired = true; }
01024       }
01025       if (thisStripFired) {
01026         if (!stripo[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
01027           stripo[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
01028           hOStrips->Fill(kChamber,typeIndex(id,2));
01029           hOStripSerial->Fill(chamberSerial(id));
01030           hasStrips = true;
01031           if (clcto[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
01032             // check if there is a wire digi in this chamber too
01033             // for ME 1/4 check for a wire in ME 1/1
01034             if(wireo[kEndcap-1][kStation-1][kRing-1][kChamber-1] || (kRing==4 && wireo[kEndcap-1][kStation-1][0][kChamber-1]) ){
01035               hOStripsAndWiresAndCLCT->Fill(kChamber,typeIndex(id,2));
01036             }
01037           }//end clct and wire digi check
01038         }
01039       }//end if (thisStripFired)
01040     }
01041   }
01042 
01043   //rechits
01044   CSCRecHit2DCollection::const_iterator recIt;
01045   for (recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
01046     CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
01047     int kEndcap  = idrec.endcap();
01048     int kRing    = idrec.ring();
01049     int kStation = idrec.station();
01050     int kChamber = idrec.chamber();
01051     if (!rechito[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
01052       rechito[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
01053       hORecHitsSerial->Fill(chamberSerial(idrec));
01054       hORecHits->Fill(kChamber,typeIndex(idrec,2));
01055       hasRecHits = true;
01056     }
01057   }
01058 
01059   //segments
01060   for(CSCSegmentCollection::const_iterator segIt=cscSegments->begin(); segIt != cscSegments->end(); segIt++) {
01061     CSCDetId id  = (CSCDetId)(*segIt).cscDetId();
01062     int kEndcap  = id.endcap();
01063     int kRing    = id.ring();
01064     int kStation = id.station();
01065     int kChamber = id.chamber();
01066     if (!segmento[kEndcap-1][kStation-1][kRing-1][kChamber-1]){
01067       segmento[kEndcap-1][kStation-1][kRing-1][kChamber-1] = true;
01068       hOSegmentsSerial->Fill(chamberSerial(id));
01069       hOSegments->Fill(kChamber,typeIndex(id,2));
01070       hasSegments = true;
01071     }
01072   }
01073 
01074   //Overall CSC Occupancy
01075   hCSCOccupancy->Fill(1);
01076   if (hasWires) hCSCOccupancy->Fill(3);
01077   if (hasStrips) hCSCOccupancy->Fill(5);
01078   if (hasWires && hasStrips) hCSCOccupancy->Fill(7);
01079   if (hasRecHits) hCSCOccupancy->Fill(9);
01080   if (hasSegments) hCSCOccupancy->Fill(11);
01081 
01082 
01083   }
01084 
01085 
01086 // ==============================================
01087 //
01088 // look at WIRE DIGIs
01089 //
01090 // ==============================================
01091 
01092 void CSCOfflineMonitor::doWireDigis(edm::Handle<CSCWireDigiCollection> wires){
01093 
01094   int nWireGroupsTotal = 0;
01095   for (CSCWireDigiCollection::DigiRangeIterator dWDiter=wires->begin(); dWDiter!=wires->end(); dWDiter++) {
01096     CSCDetId id = (CSCDetId)(*dWDiter).first;
01097     std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
01098     std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
01099     for( ; wireIter != lWire; ++wireIter) {
01100       int myWire = wireIter->getWireGroup();
01101       int myTBin = wireIter->getTimeBin();
01102       nWireGroupsTotal++;
01103       hWireTBin[typeIndex(id)-1]->Fill(myTBin);
01104       hWireNumber[typeIndex(id)-1]->Fill(myWire);
01105     }
01106   } // end wire loop
01107 
01108   // this way you can zero suppress but still store info on # events with no digis
01109   if (nWireGroupsTotal == 0) nWireGroupsTotal = -1;
01110   hWirenGroupsTotal->Fill(nWireGroupsTotal);
01111   
01112 }
01113 
01114 
01115 // ==============================================
01116 //
01117 // look at STRIP DIGIs
01118 //
01119 // ==============================================
01120 
01121 void CSCOfflineMonitor::doStripDigis(edm::Handle<CSCStripDigiCollection> strips){
01122 
01123   int nStripsFired = 0;
01124   for (CSCStripDigiCollection::DigiRangeIterator dSDiter=strips->begin(); dSDiter!=strips->end(); dSDiter++) {
01125     CSCDetId id = (CSCDetId)(*dSDiter).first;
01126     std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
01127     std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
01128     for( ; stripIter != lStrip; ++stripIter) {
01129       int myStrip = stripIter->getStrip();
01130       std::vector<int> myADCVals = stripIter->getADCCounts();
01131       bool thisStripFired = false;
01132       float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01133       float threshold = 13.3 ;
01134       float diff = 0.;
01135       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
01136         diff = (float)myADCVals[iCount]-thisPedestal;
01137         if (diff > threshold) { thisStripFired = true; }
01138       } 
01139       if (thisStripFired) {
01140         nStripsFired++;
01141         hStripNumber[typeIndex(id)-1]->Fill(myStrip);
01142       }
01143     }
01144   } // end strip loop
01145 
01146   // this way you can zero suppress but still store info on # events with no digis
01147   if (nStripsFired == 0) nStripsFired = -1;
01148   hStripNFired->Fill(nStripsFired);
01149   // fill n per event
01150 
01151 }
01152 
01153 
01154 //=======================================================
01155 //
01156 // Look at the Pedestal Noise Distributions
01157 //
01158 //=======================================================
01159 
01160 void CSCOfflineMonitor::doPedestalNoise(edm::Handle<CSCStripDigiCollection> strips){
01161 
01162   for (CSCStripDigiCollection::DigiRangeIterator dPNiter=strips->begin(); dPNiter!=strips->end(); dPNiter++) {
01163     CSCDetId id = (CSCDetId)(*dPNiter).first;
01164     int kStation = id.station();
01165     int kRing = id.ring();
01166     std::vector<CSCStripDigi>::const_iterator pedIt = (*dPNiter).second.first;
01167     std::vector<CSCStripDigi>::const_iterator lStrip = (*dPNiter).second.second;
01168     for( ; pedIt != lStrip; ++pedIt) {
01169       int myStrip = pedIt->getStrip();
01170       std::vector<int> myADCVals = pedIt->getADCCounts();
01171       float TotalADC = getSignal(*strips, id, myStrip);
01172       bool thisStripFired = false;
01173       float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01174       float thisSignal = (1./6)*(myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01175       float threshold = 13.3;
01176       if(kStation == 1 && kRing == 4)
01177         {
01178           kRing = 1;
01179           if(myStrip <= 16) myStrip += 64; // no trapping for any bizarreness
01180         }
01181       if (TotalADC > threshold) { thisStripFired = true;}
01182       if (!thisStripFired){
01183         float ADC = thisSignal - thisPedestal;
01184         hStripPed[typeIndex(id)-1]->Fill(ADC);
01185       }
01186     }
01187   }
01188 
01189 }
01190 
01191 
01192 // ==============================================
01193 //
01194 // look at RECHITs
01195 //
01196 // ==============================================
01197 
01198 void CSCOfflineMonitor::doRecHits(edm::Handle<CSCRecHit2DCollection> recHits,
01199                                   edm::Handle<CSCStripDigiCollection> strips,
01200                                   edm::ESHandle<CSCGeometry> cscGeom){
01201 
01202   // Get the RecHits collection :
01203   int nRecHits = recHits->size();
01204   
01205   // ---------------------
01206   // Loop over rechits 
01207   // ---------------------
01208   // Build iterator for rechits and loop :
01209   CSCRecHit2DCollection::const_iterator dRHIter;
01210   for (dRHIter = recHits->begin(); dRHIter != recHits->end(); dRHIter++) {
01211 
01212     // Find chamber with rechits in CSC 
01213     CSCDetId idrec = (CSCDetId)(*dRHIter).cscDetId();
01214 
01215     // Store rechit as a Local Point:
01216     LocalPoint rhitlocal = (*dRHIter).localPosition();  
01217     //float xreco = rhitlocal.x();
01218     //float yreco = rhitlocal.y();
01219 
01220     // Get the reconstucted strip position and error
01221     float stpos = (*dRHIter).positionWithinStrip();
01222     float sterr = (*dRHIter).errorWithinStrip();
01223 
01224     // Find the charge associated with this hit
01225     CSCRecHit2D::ADCContainer adcs = (*dRHIter).adcs();
01226     int adcsize = adcs.size();
01227     float rHSumQ = 0;
01228     float sumsides = 0;
01229     for (int i = 0; i < adcsize; i++){
01230       if (i != 3 && i != 7 && i != 11){
01231         rHSumQ = rHSumQ + adcs[i]; 
01232       }
01233       if (adcsize == 12 && (i < 3 || i > 7) && i < 12){
01234         sumsides = sumsides + adcs[i];
01235       }
01236     }
01237     float rHratioQ = sumsides/rHSumQ;
01238     if (adcsize != 12) rHratioQ = -99;
01239 
01240     // Get the signal timing of this hit
01241     float rHtime = (*dRHIter).tpeak(); //calculated from cathode SCA bins
01242     float rHtimeAnode = (*dRHIter).wireTime(); // calculated from anode wire bx
01243 
01244     // Get pointer to the layer:
01245     const CSCLayer* csclayer = cscGeom->layer( idrec );
01246 
01247     // Transform hit position from local chamber geometry to global CMS geom
01248     GlobalPoint rhitglobal= csclayer->toGlobal(rhitlocal);
01249     float grecx   =  rhitglobal.x();
01250     float grecy   =  rhitglobal.y();
01251 
01252     // Fill some histograms
01253     int sIndex = idrec.station() + ((idrec.endcap()-1) * 4);
01254     int tIndex = typeIndex(idrec);
01255     hRHSumQ[tIndex-1]->Fill(rHSumQ);
01256     hRHRatioQ[tIndex-1]->Fill(rHratioQ);
01257     hRHstpos[tIndex-1]->Fill(stpos);
01258     hRHsterr[tIndex-1]->Fill(sterr);
01259     hRHTiming[tIndex-1]->Fill(rHtime);
01260     hRHTimingAnode[tIndex-1]->Fill(rHtimeAnode);
01261     hRHGlobal[sIndex-1]->Fill(grecx,grecy);
01262 
01263   } //end rechit loop
01264 
01265   if (nRecHits == 0) nRecHits = -1;
01266   hRHnrechits->Fill(nRecHits);
01267 
01268 }
01269 
01270 
01271 // ==============================================
01272 //
01273 // look at SEGMENTs
01274 //
01275 // ===============================================
01276 
01277 void CSCOfflineMonitor::doSegments(edm::Handle<CSCSegmentCollection> cscSegments,
01278                                    edm::ESHandle<CSCGeometry> cscGeom){
01279 
01280   // get CSC segment collection
01281   int nSegments = cscSegments->size();
01282 
01283   for(CSCSegmentCollection::const_iterator dSiter=cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
01284     CSCDetId id  = (CSCDetId)(*dSiter).cscDetId();
01285     float chisq    = (*dSiter).chi2();
01286     int nhits      = (*dSiter).nRecHits();
01287     int nDOF       = 2*nhits-4;
01288     float nChi2    = chisq/nDOF;
01289     double chisqProb = ChiSquaredProbability( (double)chisq, nDOF );
01290     LocalPoint localPos = (*dSiter).localPosition();
01291     LocalVector segDir = (*dSiter).localDirection();
01292 
01293     // prepare to calculate segment times 
01294     float timeCathode = 0;  //average from cathode information alone
01295     float timeAnode = 0;  //average from pruned anode information alone
01296     float timeCombined = 0; //average from cathode hits and pruned anode list
01297     std::vector<float> cathodeTimes;
01298     std::vector<float> anodeTimes;
01299     // Get the CSC recHits that contribute to this segment.
01300     std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
01301     for ( vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
01302       if ( !((*iRH).isValid()) ) continue;  // only interested in valid hits
01303       cathodeTimes.push_back((*iRH).tpeak());
01304       anodeTimes.push_back((*iRH).wireTime());
01305     }//end rechit loop
01306     
01307     // Calculate cathode average
01308     for (unsigned int i=0; i<cathodeTimes.size(); i++) 
01309         timeCathode+=cathodeTimes[i]/cathodeTimes.size();
01310     
01311     // Prune the anode list to deal with the late tail 
01312     float anodeMaxDiff;
01313     bool modified = false;
01314     std::vector<float>::iterator anodeMaxHit;
01315     do {
01316       if (anodeTimes.size()==0) continue;
01317       timeAnode=0;
01318       anodeMaxDiff=0;
01319       modified=false;
01320 
01321       // Find the average
01322       for (unsigned int j=0; j<anodeTimes.size(); j++) timeAnode+=anodeTimes[j]/anodeTimes.size();
01323 
01324       // Find the maximum outlier hit
01325       for (unsigned int j=0; j<anodeTimes.size(); j++) {
01326         if (fabs(anodeTimes[j]-timeAnode)>anodeMaxDiff) {
01327           anodeMaxHit=anodeTimes.begin()+j;
01328           anodeMaxDiff=fabs(anodeTimes[j]-timeAnode);
01329         }
01330       }
01331       
01332       // Cut hit if its greater than some time away
01333       if (anodeMaxDiff>26) {
01334         modified=true;
01335         anodeTimes.erase(anodeMaxHit);
01336       }
01337     } while (modified);
01338 
01339     // Calculate combined anode and cathode time average
01340     if(cathodeTimes.size()+anodeTimes.size() >0 )
01341       timeCombined = (timeCathode*cathodeTimes.size() + timeAnode*anodeTimes.size())/(cathodeTimes.size()+anodeTimes.size());
01342 
01343     // global transformation
01344     float globX = 0.;
01345     float globY = 0.;
01346     float globZ = 0.;
01347     float globTOF = 0.;
01348     float globTheta = 0.;
01349     float globPhi   = 0.;
01350     const CSCChamber* cscchamber = cscGeom->chamber(id);
01351     if (cscchamber) {
01352       GlobalPoint globalPosition = cscchamber->toGlobal(localPos);
01353       globX = globalPosition.x();
01354       globY = globalPosition.y();
01355       globZ = globalPosition.z();
01356       globTOF = sqrt(globX*globX+globY*globY+globZ*globZ);
01357       GlobalVector globalDirection = cscchamber->toGlobal(segDir);
01358       globTheta = globalDirection.theta();
01359       globPhi   = globalDirection.phi();
01360     }
01361 
01362     // Fill histos
01363     int tIndex = typeIndex(id);
01364     hSnhitsAll->Fill(nhits);
01365     hSnhits[tIndex-1]->Fill(nhits);
01366     hSChiSqAll->Fill(nChi2);
01367     hSChiSq[tIndex-1]->Fill(nChi2);
01368     hSChiSqProbAll->Fill(chisqProb);
01369     hSChiSqProb[tIndex-1]->Fill(chisqProb);
01370     hSGlobalTheta->Fill(globTheta);
01371     hSGlobalPhi->Fill(globPhi);
01372     hSTimeCathode->Fill(timeCathode);
01373     hSTimeCombined->Fill(timeCombined);
01374     hSTimeVsZ->Fill(globZ, timeCombined);
01375     hSTimeVsTOF->Fill(globTOF, timeCombined);
01376 
01377   } // end segment loop
01378 
01379   if (nSegments == 0) nSegments = -1;
01380   hSnSegments->Fill(nSegments);
01381 
01382 }
01383 
01384 // ==============================================
01385 //
01386 // look at hit Resolution
01387 //
01388 // ==============================================
01389 void CSCOfflineMonitor::doResolution(edm::Handle<CSCSegmentCollection> cscSegments,
01390                                      edm::ESHandle<CSCGeometry> cscGeom){
01391 
01392   for(CSCSegmentCollection::const_iterator dSiter=cscSegments->begin(); dSiter != cscSegments->end(); dSiter++) {
01393     CSCDetId id  = (CSCDetId)(*dSiter).cscDetId();
01394     //
01395     // try to get the CSC recHits that contribute to this segment.
01396     std::vector<CSCRecHit2D> theseRecHits = (*dSiter).specificRecHits();
01397     int nRH = (*dSiter).nRecHits();
01398     int jRH = 0;
01399     CLHEP::HepMatrix sp(6,1);
01400     CLHEP::HepMatrix se(6,1);
01401     for ( vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
01402       jRH++;
01403       CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
01404       //int kEndcap  = idRH.endcap();
01405       int kRing    = idRH.ring();
01406       int kStation = idRH.station();
01407       //int kChamber = idRH.chamber();
01408       int kLayer   = idRH.layer();
01409 
01410       // Find the strip containing this hit
01411       CSCRecHit2D::ChannelContainer hitstrips = (*iRH).channels();
01412       int nStrips     =  hitstrips.size();
01413       int centerid    =  nStrips/2 + 1;
01414       int centerStrip =  hitstrips[centerid - 1];
01415 
01416       // If this segment has 6 hits, find the position of each hit on the strip in units of stripwidth and store values
01417       if (nRH == 6){
01418         float stpos = (*iRH).positionWithinStrip();
01419         se(kLayer,1) = (*iRH).errorWithinStrip();
01420         // Take into account half-strip staggering of layers (ME1/1 has no staggering)
01421         if (kStation == 1 && (kRing == 1 || kRing == 4)) sp(kLayer,1) = stpos + centerStrip;
01422         else{
01423           if (kLayer == 1 || kLayer == 3 || kLayer == 5) sp(kLayer,1) = stpos + centerStrip;
01424           if (kLayer == 2 || kLayer == 4 || kLayer == 6) sp(kLayer,1) = stpos - 0.5 + centerStrip;
01425         }
01426       }
01427 
01428     }
01429 
01430     float residual = -99;
01431     // Fit all points except layer 3, then compare expected value for layer 3 to reconstructed value
01432     if (nRH == 6){
01433       float expected = fitX(sp,se);
01434       residual = expected - sp(3,1);
01435     }
01436 
01437     hSResid[typeIndex(id)-1]->Fill(residual);
01438 
01439   } // end segment loop
01440 
01441 
01442 
01443 }
01444 
01445 
01446 //-------------------------------------------------------------------------------------
01447 // Fits a straight line to a set of 5 points with errors.  Functions assumes 6 points
01448 // and removes hit in layer 3.  It then returns the expected position value in layer 3
01449 // based on the fit.
01450 //-------------------------------------------------------------------------------------
01451 float CSCOfflineMonitor::fitX(CLHEP::HepMatrix points, CLHEP::HepMatrix errors){
01452 
01453   float S   = 0;
01454   float Sx  = 0;
01455   float Sy  = 0;
01456   float Sxx = 0;
01457   float Sxy = 0;
01458   float sigma2 = 0;
01459 
01460   for (int i=1;i<7;i++){
01461     if (i != 3){
01462       sigma2 = errors(i,1)*errors(i,1);
01463       S = S + (1/sigma2);
01464       Sy = Sy + (points(i,1)/sigma2);
01465       Sx = Sx + ((i)/sigma2);
01466       Sxx = Sxx + (i*i)/sigma2;
01467       Sxy = Sxy + (((i)*points(i,1))/sigma2);
01468     }
01469   }
01470 
01471   float delta = S*Sxx - Sx*Sx;
01472   float intercept = (Sxx*Sy - Sx*Sxy)/delta;
01473   float slope = (S*Sxy - Sx*Sy)/delta;
01474 
01475   return (intercept + slope*3);
01476 
01477 }
01478 
01479 //---------------------------------------------------------------------------------------
01480 // Given a set of digis, the CSCDetId, and the central strip of your choosing, returns
01481 // the avg. Signal-Pedestal for 6 time bin x 5 strip .
01482 //
01483 // Author: P. Jindal
01484 //---------------------------------------------------------------------------------------
01485 
01486 float CSCOfflineMonitor::getSignal(const CSCStripDigiCollection& stripdigis, 
01487                                    CSCDetId idCS, int centerStrip){
01488 
01489   float SigADC[5];
01490   float TotalADC = 0;
01491   SigADC[0] = 0;
01492   SigADC[1] = 0;
01493   SigADC[2] = 0;
01494   SigADC[3] = 0;
01495   SigADC[4] = 0;
01496 
01497  
01498   // Loop over strip digis 
01499   CSCStripDigiCollection::DigiRangeIterator sIt;
01500   
01501   for (sIt = stripdigis.begin(); sIt != stripdigis.end(); sIt++){
01502     CSCDetId id = (CSCDetId)(*sIt).first;
01503     if (id == idCS){
01504 
01505       // First, find the Signal-Pedestal for center strip
01506       vector<CSCStripDigi>::const_iterator digiItr = (*sIt).second.first;
01507       vector<CSCStripDigi>::const_iterator last = (*sIt).second.second;
01508       for ( ; digiItr != last; ++digiItr ) {
01509         int thisStrip = digiItr->getStrip();
01510         if (thisStrip == (centerStrip)){
01511           std::vector<int> myADCVals = digiItr->getADCCounts();
01512           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01513           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01514           SigADC[0] = thisSignal - 6*thisPedestal;
01515         }
01516      // Now,find the Signal-Pedestal for neighbouring 4 strips
01517         if (thisStrip == (centerStrip+1)){
01518           std::vector<int> myADCVals = digiItr->getADCCounts();
01519           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01520           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01521           SigADC[1] = thisSignal - 6*thisPedestal;
01522         }
01523         if (thisStrip == (centerStrip+2)){
01524           std::vector<int> myADCVals = digiItr->getADCCounts();
01525           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01526           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01527           SigADC[2] = thisSignal - 6*thisPedestal;
01528         }
01529         if (thisStrip == (centerStrip-1)){
01530           std::vector<int> myADCVals = digiItr->getADCCounts();
01531           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01532           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01533           SigADC[3] = thisSignal - 6*thisPedestal;
01534         }
01535         if (thisStrip == (centerStrip-2)){
01536           std::vector<int> myADCVals = digiItr->getADCCounts();
01537           float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01538           float thisSignal = (myADCVals[2]+myADCVals[3]+myADCVals[4]+myADCVals[5]+myADCVals[6]+myADCVals[7]);
01539           SigADC[4] = thisSignal - 6*thisPedestal;
01540         }
01541       }
01542       TotalADC = 0.2*(SigADC[0]+SigADC[1]+SigADC[2]+SigADC[3]+SigADC[4]);
01543     }
01544   }
01545   return TotalADC;
01546 }
01547 
01548 
01549 
01550 //----------------------------------------------------------------------------
01551 // Calculate basic efficiencies for recHits and Segments
01552 // Author: S. Stoynev
01553 //----------------------------------------------------------------------------
01554 
01555 void CSCOfflineMonitor::doEfficiencies(edm::Handle<CSCWireDigiCollection> wires, edm::Handle<CSCStripDigiCollection> strips,
01556                                        edm::Handle<CSCRecHit2DCollection> recHits, edm::Handle<CSCSegmentCollection> cscSegments,
01557                                        edm::ESHandle<CSCGeometry> cscGeom){
01558 
01559   bool allWires[2][4][4][36][6];
01560   bool allStrips[2][4][4][36][6];
01561   bool AllRecHits[2][4][4][36][6];
01562   bool AllSegments[2][4][4][36];
01563   
01564   //bool MultiSegments[2][4][4][36];
01565   for(int iE = 0;iE<2;iE++){
01566     for(int iS = 0;iS<4;iS++){
01567       for(int iR = 0; iR<4;iR++){
01568         for(int iC =0;iC<36;iC++){
01569           AllSegments[iE][iS][iR][iC] = false;
01570           //MultiSegments[iE][iS][iR][iC] = false;
01571           for(int iL=0;iL<6;iL++){
01572             allWires[iE][iS][iR][iC][iL] = false;
01573             allStrips[iE][iS][iR][iC][iL] = false;
01574             AllRecHits[iE][iS][iR][iC][iL] = false;
01575           }
01576         }
01577       }
01578     }
01579   }
01580   
01581   
01582   // Wires
01583   for (CSCWireDigiCollection::DigiRangeIterator dWDiter=wires->begin(); dWDiter!=wires->end(); dWDiter++) {
01584     CSCDetId idrec = (CSCDetId)(*dWDiter).first;
01585     std::vector<CSCWireDigi>::const_iterator wireIter = (*dWDiter).second.first;
01586     std::vector<CSCWireDigi>::const_iterator lWire = (*dWDiter).second.second;
01587     for( ; wireIter != lWire; ++wireIter) {
01588       allWires[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01589       break;
01590     }
01591   }
01592 
01593   //---- STRIPS
01594   for (CSCStripDigiCollection::DigiRangeIterator dSDiter=strips->begin(); dSDiter!=strips->end(); dSDiter++) {
01595     CSCDetId idrec = (CSCDetId)(*dSDiter).first;
01596     std::vector<CSCStripDigi>::const_iterator stripIter = (*dSDiter).second.first;
01597     std::vector<CSCStripDigi>::const_iterator lStrip = (*dSDiter).second.second;
01598     for( ; stripIter != lStrip; ++stripIter) {
01599       std::vector<int> myADCVals = stripIter->getADCCounts();
01600       bool thisStripFired = false;
01601       float thisPedestal = 0.5*(float)(myADCVals[0]+myADCVals[1]);
01602       float threshold = 13.3 ;
01603       float diff = 0.;
01604       for (unsigned int iCount = 0; iCount < myADCVals.size(); iCount++) {
01605         diff = (float)myADCVals[iCount]-thisPedestal;
01606         if (diff > threshold) {
01607           thisStripFired = true;
01608           break;
01609         }
01610       }
01611       if(thisStripFired){
01612         allStrips[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01613         break;
01614       }
01615     }
01616   }
01617 
01618   // Rechits
01619   for (CSCRecHit2DCollection::const_iterator recEffIt = recHits->begin(); recEffIt != recHits->end(); recEffIt++) {
01620     //CSCDetId idrec = (CSCDetId)(*recIt).cscDetId();
01621     CSCDetId  idrec = (CSCDetId)(*recEffIt).cscDetId();
01622     AllRecHits[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber() -1][idrec.layer() -1] = true;
01623 
01624   }
01625 
01626   std::vector <uint> seg_ME2(2,0) ;
01627   std::vector <uint> seg_ME3(2,0) ;
01628   std::vector < pair <CSCDetId, CSCSegment> > theSegments(4);
01629   // Segments
01630   for(CSCSegmentCollection::const_iterator segEffIt=cscSegments->begin(); segEffIt != cscSegments->end(); segEffIt++) {
01631     CSCDetId idseg  = (CSCDetId)(*segEffIt).cscDetId();
01632     //if(AllSegments[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber()]){
01633     //MultiSegments[idrec.endcap() -1][idrec.station() -1][idrec.ring() -1][idrec.chamber()] = true;
01634     //}
01635     AllSegments[idseg.endcap() -1][idseg.station() -1][idseg.ring() -1][idseg.chamber() -1] = true;
01636     // "Intrinsic" efficiency measurement relies on "good" segment extrapolation - we need the pre-selection below
01637     // station 2 "good" segment will be used for testing efficiencies in ME1 and ME3
01638     // station 3 "good" segment will be used for testing efficiencies in ME2 and ME4
01639     if(2==idseg.station() || 3==idseg.station()){
01640       uint seg_tmp ; 
01641       if(2==idseg.station()){
01642         ++seg_ME2[idseg.endcap() -1];
01643         seg_tmp = seg_ME2[idseg.endcap() -1];
01644       }
01645       else{
01646         ++seg_ME3[idseg.endcap() -1];
01647         seg_tmp = seg_ME3[idseg.endcap() -1];
01648       }
01649       // is the segment good
01650       if(1== seg_tmp&& 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
01651         pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
01652         theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
01653       }
01654     }
01655     /*
01656     if(2==idseg.station()){
01657         ++seg_ME2[idseg.endcap() -1];
01658        if(1==seg_ME2[idseg.endcap() -1] && 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
01659            pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
01660            theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
01661        }
01662     }
01663     else if(3==idseg.station()){
01664         ++seg_ME3[idseg.endcap() -1];
01665         if(1==seg_ME3[idseg.endcap() -1] && 6==(*segEffIt).nRecHits() && (*segEffIt).chi2()/(*segEffIt).degreesOfFreedom()<3.){
01666          pair <CSCDetId, CSCSegment> specSeg = make_pair( (CSCDetId)(*segEffIt).cscDetId(),*segEffIt);
01667          theSegments[2*(idseg.endcap()-1)+(idseg.station() -2)] = specSeg;
01668        }
01669     }
01670     */
01671     
01672   }
01673   // Simple efficiency calculations
01674   for(int iE = 0;iE<2;iE++){
01675     for(int iS = 0;iS<4;iS++){
01676       for(int iR = 0; iR<4;iR++){
01677         for(int iC =0;iC<36;iC++){
01678           int NumberOfLayers = 0;
01679           for(int iL=0;iL<6;iL++){
01680             if(AllRecHits[iE][iS][iR][iC][iL]){
01681               NumberOfLayers++;
01682             }
01683           }
01684           int bin = 0;
01685           if (iS==0) bin = iR+1+(iE*10);
01686           else bin = (iS+1)*2 + (iR+1) + (iE*10);
01687           if(NumberOfLayers>1){
01688             //if(!(MultiSegments[iE][iS][iR][iC])){
01689             if(AllSegments[iE][iS][iR][iC]){
01690               //---- Efficient segment evenents
01691               hSSTE->Fill(bin);
01692             }
01693             //---- All segment events (normalization)
01694             hSSTE->Fill(20+bin);
01695             //}
01696           }
01697           if(AllSegments[iE][iS][iR][iC]){
01698             if(NumberOfLayers==6){
01699               //---- Efficient rechit events
01700               hRHSTE->Fill(bin);;
01701             }
01702             //---- All rechit events (normalization)
01703             hRHSTE->Fill(20+bin);;
01704           }
01705         }
01706       }
01707     }
01708   }
01709 
01710   // pick a segment only if there are no others in the station
01711   std::vector < pair <CSCDetId, CSCSegment> * > theSeg;
01712   if(1==seg_ME2[0]) theSeg.push_back(&theSegments[0]);
01713   if(1==seg_ME3[0]) theSeg.push_back(&theSegments[1]);
01714   if(1==seg_ME2[1]) theSeg.push_back(&theSegments[2]);
01715   if(1==seg_ME3[1]) theSeg.push_back(&theSegments[3]);
01716 
01717   // Needed for plots
01718   // at the end the chamber types will be numbered as 1 to 18 
01719   // (ME-4/1, -ME3/2, -ME3/1, ..., +ME3/1, +ME3/2, ME+4/1 ) 
01720   std::map <std::string, float> chamberTypes;
01721   chamberTypes["ME1/a"] = 0.5;
01722   chamberTypes["ME1/b"] = 1.5;
01723   chamberTypes["ME1/2"] = 2.5;
01724   chamberTypes["ME1/3"] = 3.5;
01725   chamberTypes["ME2/1"] = 4.5;
01726   chamberTypes["ME2/2"] = 5.5;
01727   chamberTypes["ME3/1"] = 6.5;
01728   chamberTypes["ME3/2"] = 7.5;
01729   chamberTypes["ME4/1"] = 8.5;
01730 
01731   if(theSeg.size()){
01732     std::map <int , GlobalPoint> extrapolatedPoint;
01733     std::map <int , GlobalPoint>::iterator it;
01734     const std::vector<CSCChamber*> ChamberContainer = cscGeom->chambers();
01735     // Pick which chamber with which segment to test
01736     for(unsigned int nCh=0;nCh<ChamberContainer.size();nCh++){
01737       const CSCChamber *cscchamber = ChamberContainer[nCh];
01738       pair <CSCDetId, CSCSegment> * thisSegment = 0;
01739       for(uint iSeg =0;iSeg<theSeg.size();++iSeg ){
01740         if(cscchamber->id().endcap() == theSeg[iSeg]->first.endcap()){ 
01741           if(1==cscchamber->id().station() || 3==cscchamber->id().station() ){
01742             if(2==theSeg[iSeg]->first.station()){
01743               thisSegment = theSeg[iSeg];
01744             }
01745           }
01746           else if (2==cscchamber->id().station() || 4==cscchamber->id().station()){
01747             if(3==theSeg[iSeg]->first.station()){
01748               thisSegment = theSeg[iSeg];
01749             }
01750           }
01751         }
01752       }
01753       // this chamber is to be tested with thisSegment
01754       if(thisSegment){
01755         CSCSegment * seg = &(thisSegment->second);
01756         const CSCChamber *segChamber = cscGeom->chamber(thisSegment->first);
01757         LocalPoint localCenter(0.,0.,0);
01758         GlobalPoint cscchamberCenter =  cscchamber->toGlobal(localCenter);
01759         // try to save some time (extrapolate a segment to a certain position only once)
01760         it = extrapolatedPoint.find(int(cscchamberCenter.z()));
01761         if(it==extrapolatedPoint.end()){
01762           GlobalPoint segPos = segChamber->toGlobal(seg->localPosition());
01763           GlobalVector segDir = segChamber->toGlobal(seg->localDirection());
01764           double paramaterLine = lineParametrization(segPos.z(),cscchamberCenter.z() , segDir.z());
01765           double xExtrapolated = extrapolate1D(segPos.x(),segDir.x(), paramaterLine);
01766           double yExtrapolated = extrapolate1D(segPos.y(),segDir.y(), paramaterLine);
01767           GlobalPoint globP (xExtrapolated, yExtrapolated, cscchamberCenter.z());
01768           extrapolatedPoint[int(cscchamberCenter.z())] = globP;
01769         }
01770         // Where does the extrapolated point lie in the (tested) chamber local frame? Here: 
01771         LocalPoint extrapolatedPointLocal = cscchamber->toLocal(extrapolatedPoint[int(cscchamberCenter.z())]);
01772         const CSCLayer *layer_p = cscchamber->layer(1);//layer 1
01773         const CSCLayerGeometry *layerGeom = layer_p->geometry ();
01774         const std::vector<float> layerBounds = layerGeom->parameters ();
01775         float shiftFromEdge = 15.;//cm
01776         float shiftFromDeadZone = 10.;
01777         // is the extrapolated point within a sensitive region
01778         bool pass = withinSensitiveRegion(extrapolatedPointLocal, layerBounds, 
01779                                           cscchamber->id().station(), cscchamber->id().ring(), 
01780                                           shiftFromEdge, shiftFromDeadZone);
01781         if(pass){// the extrapolation point of the segment lies within sensitive region of that chamber
01782           // how many rechit layers are there in the chamber?
01783           // 0 - maybe the muon died or is deflected at large angle? do not use that case
01784           // 1 - could be noise...
01785           // 2 or more - this is promissing; this is our definition of a reliable signal; use it below
01786           // is other definition better? 
01787           int nRHLayers = 0;
01788           for(int iL =0;iL<6;++iL){
01789             if(AllRecHits[cscchamber->id().endcap()-1]
01790                [cscchamber->id().station()-1]
01791                [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01792               ++nRHLayers;
01793             }
01794           }
01795           //std::cout<<" nRHLayers = "<<nRHLayers<<std::endl;
01796           float verticalScale = chamberTypes[cscchamber->specs()->chamberTypeName()];
01797           if(cscchamberCenter.z()<0){
01798             verticalScale = - verticalScale;
01799           } 
01800           verticalScale +=9.5;
01801           hSensitiveAreaEvt->Fill(float(cscchamber->id().chamber()),verticalScale);
01802           if(nRHLayers>1){// this chamber contains a reliable signal
01803             //chamberTypes[cscchamber->specs()->chamberTypeName()];
01804             // "intrinsic" efficiencies
01805             //std::cout<<" verticalScale = "<<verticalScale<<" chType = "<<cscchamber->specs()->chamberTypeName()<<std::endl;
01806             // this is the denominator forr all efficiencies
01807             hEffDenominator->Fill(float(cscchamber->id().chamber()),verticalScale);
01808             // Segment efficiency
01809             if(AllSegments[cscchamber->id().endcap()-1]
01810                [cscchamber->id().station()-1]
01811                [cscchamber->id().ring()-1][cscchamber->id().chamber()-1]){
01812               hSSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale));
01813             }
01814           
01815             for(int iL =0;iL<6;++iL){
01816               float weight = 1./6.;
01817               // one shold account for the weight in the efficiency...
01818               // Rechit efficiency
01819               if(AllRecHits[cscchamber->id().endcap()-1]
01820                  [cscchamber->id().station()-1]
01821                  [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01822                 hRHSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01823               }
01824               // Wire efficiency
01825               if(allWires[cscchamber->id().endcap()-1]
01826                  [cscchamber->id().station()-1]
01827                  [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01828                 // one shold account for the weight in the efficiency...
01829                 hWireSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01830               }
01831               // Strip efficiency
01832               if(allStrips[cscchamber->id().endcap()-1]
01833                  [cscchamber->id().station()-1]
01834                  [cscchamber->id().ring()-1][cscchamber->id().chamber()-1][iL]){
01835                 // one shold account for the weight in the efficiency...
01836                 hStripSTE2->Fill(float(cscchamber->id().chamber()),float(verticalScale),weight);
01837               }
01838             }
01839           }
01840         }
01841       }
01842     }
01843   }
01844   //
01845 
01846 
01847 }
01848 
01849 // ==============================================
01850 //
01851 // Look at BX level trigger synchronization
01852 //
01853 // ==============================================
01854 
01855 void CSCOfflineMonitor::doBXMonitor(edm::Handle<CSCALCTDigiCollection> alcts, edm::Handle<CSCCLCTDigiCollection> clcts, const edm::Event & event, const EventSetup& eventSetup){
01856 
01857   // Loop over ALCTDigis
01858 
01859   for (CSCALCTDigiCollection::DigiRangeIterator j=alcts->begin(); j!=alcts->end(); j++) {
01860     const CSCDetId& idALCT = (*j).first;
01861     const CSCALCTDigiCollection::Range& range =(*j).second;
01862     for (CSCALCTDigiCollection::const_iterator digiIt = range.first; digiIt!=range.second; ++digiIt){
01863       // Valid digi in the chamber (or in neighbouring chamber)  
01864       if((*digiIt).isValid()){
01865         hALCTgetBX->Fill((*digiIt).getBX());
01866         hALCTgetBXSerial->Fill(chamberSerial(idALCT),(*digiIt).getBX());
01867         hALCTgetBX2DNumerator->Fill(idALCT.chamber(),typeIndex(idALCT,2),(*digiIt).getBX());
01868         hALCTgetBX2Denominator->Fill(idALCT.chamber(),typeIndex(idALCT,2));
01869       }
01870     }
01871   }// end ALCT Digi loop
01872 
01873 
01874   // Loop over raw data to get TMBHeader information
01875   // Taking code from EventFilter/CSCRawToDigis/CSCDCCUnpacker.cc
01876   edm::ESHandle<CSCCrateMap> hcrate;
01877   eventSetup.get<CSCCrateMapRcd>().get(hcrate); 
01878   const CSCCrateMap* pcrate = hcrate.product();
01879 
01880 
01881   // Try to get raw data
01882   edm::Handle<FEDRawDataCollection> rawdata;
01883   if (!(event.getByLabel(FEDRawDataCollectionTag_,rawdata)) ){
01884     edm::LogWarning("CSCOfflineMonitor")<<" raw data with label "<<FEDRawDataCollectionTag_ <<" not available";
01885     return;
01886   }
01887 
01888 
01889 
01890   bool goodEvent = false;
01891   unsigned long dccBinCheckMask = 0x06080016;
01892   unsigned int examinerMask = 0x1FEBF3F6;
01893   unsigned int errorMask = 0x0;
01894 
01895   for (int id=FEDNumbering::MINCSCFEDID;
01896        id<=FEDNumbering::MAXCSCFEDID; ++id) { // loop over DCCs
01899      
01901     const FEDRawData& fedData = rawdata->FEDData(id);
01902     unsigned long length =  fedData.size();
01903    
01904     if (length>=32){ 
01905       CSCDCCExaminer* examiner = NULL;
01906       std::stringstream examiner_out, examiner_err;
01907       goodEvent = true;
01908       examiner = new CSCDCCExaminer();
01909       examiner->output1().redirect(examiner_out);
01910       examiner->output2().redirect(examiner_err);
01911       if( examinerMask&0x40000 ) examiner->crcCFEB(1);
01912       if( examinerMask&0x8000  ) examiner->crcTMB (1);
01913       if( examinerMask&0x0400  ) examiner->crcALCT(1);
01914       examiner->output1().show();
01915       examiner->output2().show();
01916       examiner->setMask(examinerMask);
01917       const short unsigned int *data = (short unsigned int *)fedData.data();
01918  
01919       int res = examiner->check(data,long(fedData.size()/2));
01920       if( res < 0 )   {
01921         goodEvent=false;
01922       } 
01923       else {    
01924         goodEvent=!(examiner->errors()&dccBinCheckMask);
01925       }
01926  
01927                  
01928       if (goodEvent) {
01930  
01931         CSCDCCExaminer * ptrExaminer = examiner;
01932         CSCDCCEventData dccData((short unsigned int *) fedData.data(), ptrExaminer);
01934         const std::vector<CSCDDUEventData> & dduData = dccData.dduData();
01935         
01937         CSCDetId layer(1, 1, 1, 1, 1);
01938         for (unsigned int iDDU=0; iDDU<dduData.size(); ++iDDU) {  // loop over DDUs
01941           if (dduData[iDDU].trailer().errorstat()&errorMask) {
01942             LogTrace("CSCDCCUnpacker|CSCRawToDigi") << "DDU# " << iDDU << " has serious error - no digis unpacked! " <<
01943               std::hex << dduData[iDDU].trailer().errorstat();
01944             continue; // to next iteration of DDU loop
01945           }
01946           
01948           const std::vector<CSCEventData> & cscData = dduData[iDDU].cscData();
01949           
01950           
01951           for (unsigned int iCSC=0; iCSC<cscData.size(); ++iCSC) { // loop over CSCs
01952             
01954             int vmecrate = cscData[iCSC].dmbHeader()->crateID();
01955             int dmb = cscData[iCSC].dmbHeader()->dmbID();
01956             
01957             int icfeb = 0;  
01958             int ilayer = 0; 
01959             
01960              if ((vmecrate>=1)&&(vmecrate<=60) && (dmb>=1)&&(dmb<=10)&&(dmb!=6)) {
01961                layer = pcrate->detId(vmecrate, dmb,icfeb,ilayer );
01962              } 
01963              else{
01964                LogTrace ("CSCOfflineMonitor") << " detID input out of range!!! ";
01965                LogTrace ("CSCOfflineMonitor")
01966                  << " skipping chamber vme= " << vmecrate << " dmb= " << dmb;
01967                continue; // to next iteration of iCSC loop
01968              }
01969 
01970 
01972             int nalct = cscData[iCSC].dmbHeader()->nalct();
01973             bool goodALCT=false;
01974             //if (nalct&&(cscData[iCSC].dataPresent>>6&0x1)==1) {
01975             if (nalct&&cscData[iCSC].alctHeader()) {  
01976               if (cscData[iCSC].alctHeader()->check()){
01977                 goodALCT=true;
01978               }
01979             }
01980             
01982             int nclct = cscData[iCSC].dmbHeader()->nclct();
01983             bool goodTMB=false;
01984             if (nclct&&cscData[iCSC].tmbData()) {
01985               if (cscData[iCSC].tmbHeader()->check()){
01986                 if (cscData[iCSC].clctData()->check()) goodTMB=true; 
01987               }
01988             }
01989             
01990             if (goodTMB && goodALCT) { 
01991               const CSCTMBHeader *tmbHead = cscData[iCSC].tmbHeader();
01992               std::vector<CSCCLCTDigi> clcts = cscData[iCSC].tmbHeader()->CLCTDigis(layer.rawId());
01993               if (clcts.size()==0 || !(clcts[0].isValid()))
01994                 continue;
01995               // Check if the CLCT was in ME11a (ring 4)
01996               if(layer.station()==1 && layer.ring() ==1 && clcts[0].getKeyStrip()>128){
01997                 layer = CSCDetId(layer.endcap(),layer.station(),4, layer.chamber()); 
01998               }
01999               hALCTMatch->Fill(tmbHead->ALCTMatchTime());
02000               hALCTMatchSerial->Fill(chamberSerial(layer),tmbHead->ALCTMatchTime());
02001               // Only fill big 2D display if ALCTMatchTime !=6, since this bin is polluted by the CLCT only triggers
02002               // One will have to look at the serial plots to see if the are a lot of entries here
02003               if(tmbHead->ALCTMatchTime()!=6){
02004                 hALCTMatch2DNumerator->Fill(layer.chamber(),typeIndex(layer,2),tmbHead->ALCTMatchTime());
02005                 hALCTMatch2Denominator->Fill(layer.chamber(),typeIndex(layer,2));             
02006               }
02007 
02008               int TMB_CLCTpre_rel_L1A = tmbHead->BXNCount()-clcts[0].getFullBX();
02009               if (TMB_CLCTpre_rel_L1A > 3563)
02010                 TMB_CLCTpre_rel_L1A = TMB_CLCTpre_rel_L1A - 3564;
02011               if (TMB_CLCTpre_rel_L1A < 0)
02012                 TMB_CLCTpre_rel_L1A = TMB_CLCTpre_rel_L1A + 3564;
02013 
02014               hCLCTL1A->Fill(TMB_CLCTpre_rel_L1A);
02015               hCLCTL1ASerial->Fill(chamberSerial(layer),TMB_CLCTpre_rel_L1A);
02016               hCLCTL1A2DNumerator->Fill(layer.chamber(),typeIndex(layer,2),TMB_CLCTpre_rel_L1A);
02017               hCLCTL1A2Denominator->Fill(layer.chamber(),typeIndex(layer,2));         
02018               
02019             }// end if goodTMB and goodALCT
02020           }// end loop CSCData
02021         }// end loop DDU
02022       }// end if good event
02023       if (examiner!=NULL) delete examiner;
02024     }// end if non-zero fed data
02025   }// end DCC loop for NON-REFERENCE
02026 
02027   return;
02028 
02029 }
02030 
02031 
02032 
02033 void CSCOfflineMonitor::getEfficiency(float bin, float Norm, std::vector<float> &eff){
02034   //---- Efficiency with binomial error
02035   float Efficiency = 0.;
02036   float EffError = 0.;
02037   if(fabs(Norm)>0.000000001){
02038     Efficiency = bin/Norm;
02039     if(bin<Norm){
02040       EffError = sqrt( (1.-Efficiency)*Efficiency/Norm );
02041     }
02042   }
02043   eff[0] = Efficiency;
02044   eff[1] = EffError;
02045 }
02046 
02047 void CSCOfflineMonitor::histoEfficiency(TH1F *readHisto, MonitorElement *writeHisto){
02048   std::vector<float> eff(2);
02049   int Nbins =  readHisto->GetSize()-2;//without underflows and overflows
02050   std::vector<float> bins(Nbins);
02051   std::vector<float> Efficiency(Nbins);
02052   std::vector<float> EffError(Nbins);
02053   float Num = 1;
02054   float Den = 1;
02055   for (int i=0;i<20;i++){
02056     Num = readHisto->GetBinContent(i+1);
02057     Den = readHisto->GetBinContent(i+21);
02058     getEfficiency(Num, Den, eff);
02059     Efficiency[i] = eff[0];
02060     EffError[i] = eff[1];
02061     writeHisto->setBinContent(i+1, Efficiency[i]);
02062     writeHisto->setBinError(i+1, EffError[i]);
02063   }
02064 }
02065 
02066 bool CSCOfflineMonitor::withinSensitiveRegion(LocalPoint localPos, const std::vector<float> layerBounds,
02067                                               int station, int ring, float shiftFromEdge, float shiftFromDeadZone){
02068 //---- check if it is in a good local region (sensitive area - geometrical and HV boundaries excluded) 
02069   bool pass = false;
02070 
02071   float y_center = 0.;
02072   double yUp = layerBounds[3] + y_center;
02073   double yDown = - layerBounds[3] + y_center;
02074   double xBound1Shifted = layerBounds[0] - shiftFromEdge;//
02075   double xBound2Shifted = layerBounds[1] - shiftFromEdge;//
02076   double lineSlope = (yUp - yDown)/(xBound2Shifted-xBound1Shifted);
02077   double lineConst = yUp - lineSlope*xBound2Shifted;
02078   double yBorder =  lineSlope*abs(localPos.x()) + lineConst;
02079       
02080   //bool withinChamberOnly = false;// false = "good region"; true - boundaries only
02081   std::vector <float> deadZoneCenter(6);
02082   float cutZone = shiftFromDeadZone;//cm
02083   //---- hardcoded... not good
02084   if(station>1 && station<5){
02085     if(2==ring){
02086       deadZoneCenter[0]= -162.48 ;
02087       deadZoneCenter[1] = -81.8744;
02088       deadZoneCenter[2] = -21.18165;
02089       deadZoneCenter[3] = 39.51105;
02090       deadZoneCenter[4] = 100.2939;
02091       deadZoneCenter[5] = 160.58;
02092       
02093       if(localPos.y() >yBorder &&
02094          ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
02095           (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
02096           (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone) ||
02097           (localPos.y()> deadZoneCenter[3] + cutZone && localPos.y()< deadZoneCenter[4] - cutZone) ||
02098           (localPos.y()> deadZoneCenter[4] + cutZone && localPos.y()< deadZoneCenter[5] - cutZone))){
02099         pass = true;
02100       }
02101     }
02102     else if(1==ring){
02103       if(2==station){
02104         deadZoneCenter[0]= -95.80 ;
02105         deadZoneCenter[1] = -27.47;
02106         deadZoneCenter[2] = 33.67;
02107         deadZoneCenter[3] = 90.85;
02108         }
02109       else if(3==station){
02110         deadZoneCenter[0]= -89.305 ;
02111         deadZoneCenter[1] = -39.705;
02112         deadZoneCenter[2] = 20.195;
02113         deadZoneCenter[3] = 77.395;
02114       }
02115       else if(4==station){
02116         deadZoneCenter[0]= -75.645;
02117         deadZoneCenter[1] = -26.055;
02118         deadZoneCenter[2] = 23.855;
02119         deadZoneCenter[3] = 70.575;
02120       }
02121       if(localPos.y() >yBorder &&
02122          ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
02123           (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
02124           (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
02125         pass = true;
02126       }
02127     }
02128   }
02129   else if(1==station){
02130     if(3==ring){
02131       deadZoneCenter[0]= -83.155 ;
02132       deadZoneCenter[1] = -22.7401;
02133       deadZoneCenter[2] = 27.86665;
02134       deadZoneCenter[3] = 81.005;
02135       if(localPos.y() > yBorder &&
02136          ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
02137           (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
02138           (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
02139         pass = true;
02140       }
02141     }
02142     else if(2==ring){
02143       deadZoneCenter[0]= -86.285 ;
02144       deadZoneCenter[1] = -32.88305;
02145       deadZoneCenter[2] = 32.867423;
02146       deadZoneCenter[3] = 88.205;
02147       if(localPos.y() > (yBorder) &&
02148          ((localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone) ||
02149           (localPos.y()> deadZoneCenter[1] + cutZone && localPos.y()< deadZoneCenter[2] - cutZone) ||
02150           (localPos.y()> deadZoneCenter[2] + cutZone && localPos.y()< deadZoneCenter[3] - cutZone))){
02151         pass = true;
02152       }
02153     }
02154     else{
02155       deadZoneCenter[0]= -81.0;
02156       deadZoneCenter[1] = 81.0;
02157       if(localPos.y() > (yBorder) &&
02158          (localPos.y()> deadZoneCenter[0] + cutZone && localPos.y()< deadZoneCenter[1] - cutZone )){
02159         pass = true;
02160       }
02161     }
02162   }
02163   return pass;
02164 }
02165 
02166 
02167 int CSCOfflineMonitor::typeIndex(CSCDetId id, int flag){
02168   
02169   if (flag == 1){
02170     // linearlized index bases on endcap, station, and ring
02171     int index = 0;
02172     if (id.station() == 1) index = id.ring();
02173     else index = id.station()*2 + id.ring();
02174     if (id.endcap() == 1) index = index + 10;
02175     if (id.endcap() == 2) index = 11 - index;
02176     return index;
02177   }
02178 
02179   else if (flag == 2){
02180     int index = 0;
02181     if (id.station() == 1 && id.ring() != 4) index = id.ring()+1;
02182     if (id.station() == 1 && id.ring() == 4) index = 1; 
02183     if (id.station() != 1) index = id.station()*2 + id.ring();
02184     if (id.endcap() == 1) index = index + 10;
02185     if (id.endcap() == 2) index = 11 - index;
02186     return index;
02187   }
02188 
02189   else return 0;
02190 
02191 }
02192 
02193 int CSCOfflineMonitor::chamberSerial( CSCDetId id ) {
02194   int st = id.station();
02195   int ri = id.ring();
02196   int ch = id.chamber();
02197   int ec = id.endcap();
02198   int kSerial = ch;
02199   if (st == 1 && ri == 1) kSerial = ch;
02200   if (st == 1 && ri == 2) kSerial = ch + 36;
02201   if (st == 1 && ri == 3) kSerial = ch + 72;
02202   if (st == 1 && ri == 4) kSerial = ch;
02203   if (st == 2 && ri == 1) kSerial = ch + 108;
02204   if (st == 2 && ri == 2) kSerial = ch + 126;
02205   if (st == 3 && ri == 1) kSerial = ch + 162;
02206   if (st == 3 && ri == 2) kSerial = ch + 180;
02207   if (st == 4 && ri == 1) kSerial = ch + 216;
02208   if (st == 4 && ri == 2) kSerial = ch + 234;  // one day...
02209   if (ec == 2) kSerial = kSerial + 300;
02210   return kSerial;
02211 }
02212 
02213 
02214 
02215 DEFINE_FWK_MODULE(CSCOfflineMonitor);
02216