CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Validation/MuonIdentification/src/MuonIdVal.cc

Go to the documentation of this file.
00001 #include "Validation/MuonIdentification/interface/MuonIdVal.h"
00002 
00003 MuonIdVal::MuonIdVal(const edm::ParameterSet& iConfig)
00004 {
00005    inputMuonCollection_ = iConfig.getParameter<edm::InputTag>("inputMuonCollection");
00006    inputDTRecSegment4DCollection_ = iConfig.getParameter<edm::InputTag>("inputDTRecSegment4DCollection");
00007    inputCSCSegmentCollection_ = iConfig.getParameter<edm::InputTag>("inputCSCSegmentCollection");
00008    inputMuonTimeExtraValueMap_ = iConfig.getParameter<edm::InputTag>("inputMuonTimeExtraValueMap");
00009    inputMuonCosmicCompatibilityValueMap_ = iConfig.getParameter<edm::InputTag>("inputMuonCosmicCompatibilityValueMap");
00010    inputMuonShowerInformationValueMap_ = iConfig.getParameter<edm::InputTag>("inputMuonShowerInformationValueMap");
00011    useTrackerMuons_ = iConfig.getUntrackedParameter<bool>("useTrackerMuons");
00012    useGlobalMuons_ = iConfig.getUntrackedParameter<bool>("useGlobalMuons");
00013    useTrackerMuonsNotGlobalMuons_ = iConfig.getUntrackedParameter<bool>("useTrackerMuonsNotGlobalMuons");
00014    useGlobalMuonsNotTrackerMuons_ = iConfig.getUntrackedParameter<bool>("useGlobalMuonsNotTrackerMuons");
00015    makeEnergyPlots_ = iConfig.getUntrackedParameter<bool>("makeEnergyPlots");
00016    makeTimePlots_ = iConfig.getUntrackedParameter<bool>("makeTimePlots");
00017    make2DPlots_ = iConfig.getUntrackedParameter<bool>("make2DPlots");
00018    makeAllChamberPlots_ = iConfig.getUntrackedParameter<bool>("makeAllChamberPlots");
00019    makeCosmicCompatibilityPlots_ = iConfig.getUntrackedParameter<bool>("makeCosmicCompatibilityPlots");
00020    makeShowerInformationPlots_ = iConfig.getUntrackedParameter<bool>("makeShowerInformationPlots");
00021    baseFolder_ = iConfig.getUntrackedParameter<std::string>("baseFolder");
00022 
00023    dbe_ = 0;
00024    dbe_ = edm::Service<DQMStore>().operator->();
00025 }
00026 
00027 MuonIdVal::~MuonIdVal() {}
00028 
00029 void 
00030 MuonIdVal::beginJob()
00031 {
00032    char name[100], title[200];
00033 
00034    // trackerMuon == 0; globalMuon == 1; trackerMuon && !globalMuon == 2; globalMuon && !trackerMuon == 3
00035    for (unsigned int i = 0; i < 4; i++) {
00036       if ((i == 0 && ! useTrackerMuons_) || (i == 1 && ! useGlobalMuons_)) continue;
00037       if ((i == 2 && ! useTrackerMuonsNotGlobalMuons_) || (i == 3 && ! useGlobalMuonsNotTrackerMuons_)) continue;
00038       if (i == 0) dbe_->setCurrentFolder(baseFolder_+"/TrackerMuons");
00039       if (i == 1) dbe_->setCurrentFolder(baseFolder_+"/GlobalMuons");
00040       if (i == 2) dbe_->setCurrentFolder(baseFolder_+"/TrackerMuonsNotGlobalMuons");
00041       if (i == 3) dbe_->setCurrentFolder(baseFolder_+"/GlobalMuonsNotTrackerMuons");
00042 
00043       if (makeEnergyPlots_) {
00044          hEnergyEMBarrel[i] = dbe_->book1D("hEnergyEMBarrel", "Energy in ECAL Barrel", 100, -0.5, 2.);
00045          hEnergyHABarrel[i] = dbe_->book1D("hEnergyHABarrel", "Energy in HCAL Barrel", 100, -4., 12.);
00046          hEnergyHO[i] = dbe_->book1D("hEnergyHO", "Energy HO", 100, -2., 5.);
00047          hEnergyEMEndcap[i] = dbe_->book1D("hEnergyEMEndcap", "Energy in ECAL Endcap", 100, -0.5, 2.);
00048          hEnergyHAEndcap[i] = dbe_->book1D("hEnergyHAEndcap", "Energy in HCAL Endcap", 100, -4., 12.);
00049       }
00050 
00051       if (makeTimePlots_) {
00052          hMuonTimeNDOF[i] = dbe_->book1D("hMuonTimeNDOF", "MuonTime NDOF", 52, -1.5, 50.5);
00053          hMuonTimeTimeAtIpInOut[i] = dbe_->book1D("hMuonTimeTimeAtIpInOut", "MuonTime TimeAtIpInOut", 100, -20., 20.);
00054          hMuonTimeTimeAtIpInOutErr[i] = dbe_->book1D("hMuonTimeTimeAtIpInOutErr", "MuonTime TimeAtIpInOutErr", 100, 0., 8.);
00055          hMuonTimeTimeAtIpOutIn[i] = dbe_->book1D("hMuonTimeTimeAtIpOutIn", "MuonTime TimeAtIpOutIn", 100, -1., 75.);
00056          hMuonTimeTimeAtIpOutInErr[i] = dbe_->book1D("hMuonTimeTimeAtIpOutInErr", "MuonTime TimeAtIpOutInErr", 100, 0., 8.);
00057          hMuonTimeExtraCombinedNDOF[i] = dbe_->book1D("hMuonTimeExtraCombinedNDOF", "MuonTimeExtra Combined NDOF", 52, -1.5, 50.5);
00058          hMuonTimeExtraCombinedTimeAtIpInOut[i] = dbe_->book1D("hMuonTimeExtraCombinedTimeAtIpInOut", "MuonTimeExtra Combined TimeAtIpInOut", 100, -20., 20.);
00059          hMuonTimeExtraCombinedTimeAtIpInOutErr[i] = dbe_->book1D("hMuonTimeExtraCombinedTimeAtIpInOutErr", "MuonTimeExtra Combined TimeAtIpInOutErr", 100, 0., 8.);
00060          hMuonTimeExtraCombinedTimeAtIpOutIn[i] = dbe_->book1D("hMuonTimeExtraCombinedTimeAtIpOutIn", "MuonTimeExtra Combined TimeAtIpOutIn", 100, -1., 75.);
00061          hMuonTimeExtraCombinedTimeAtIpOutInErr[i] = dbe_->book1D("hMuonTimeExtraCombinedTimeAtIpOutInErr", "MuonTimeExtra Combined TimeAtIpOutInErr", 100, 0., 8.);
00062          hMuonTimeExtraCSCNDOF[i] = dbe_->book1D("hMuonTimeExtraCSCNDOF", "MuonTimeExtra CSC NDOF", 52, -1.5, 50.5);
00063          hMuonTimeExtraCSCTimeAtIpInOut[i] = dbe_->book1D("hMuonTimeExtraCSCTimeAtIpInOut", "MuonTimeExtra CSC TimeAtIpInOut", 100, -20., 20.);
00064          hMuonTimeExtraCSCTimeAtIpInOutErr[i] = dbe_->book1D("hMuonTimeExtraCSCTimeAtIpInOutErr", "MuonTimeExtra CSC TimeAtIpInOutErr", 100, 0., 8.);
00065          hMuonTimeExtraCSCTimeAtIpOutIn[i] = dbe_->book1D("hMuonTimeExtraCSCTimeAtIpOutIn", "MuonTimeExtra CSC TimeAtIpOutIn", 100, -1., 75.);
00066          hMuonTimeExtraCSCTimeAtIpOutInErr[i] = dbe_->book1D("hMuonTimeExtraCSCTimeAtIpOutInErr", "MuonTimeExtra CSC TimeAtIpOutInErr", 100, 0., 8.);
00067          hMuonTimeExtraDTNDOF[i] = dbe_->book1D("hMuonTimeExtraDTNDOF", "MuonTimeExtra DT NDOF", 52, -1.5, 50.5);
00068          hMuonTimeExtraDTTimeAtIpInOut[i] = dbe_->book1D("hMuonTimeExtraDTTimeAtIpInOut", "MuonTimeExtra DT TimeAtIpInOut", 100, -20., 20.);
00069          hMuonTimeExtraDTTimeAtIpInOutErr[i] = dbe_->book1D("hMuonTimeExtraDTTimeAtIpInOutErr", "MuonTimeExtra DT TimeAtIpInOutErr", 100, 0., 8.);
00070          hMuonTimeExtraDTTimeAtIpOutIn[i] = dbe_->book1D("hMuonTimeExtraDTTimeAtIpOutIn", "MuonTimeExtra DT TimeAtIpOutIn", 100, -1., 75.);
00071          hMuonTimeExtraDTTimeAtIpOutInErr[i] = dbe_->book1D("hMuonTimeExtraDTTimeAtIpOutInErr", "MuonTimeExtra DT TimeAtIpOutInErr", 100, 0., 8.);
00072       }
00073 
00074       hCaloCompat[i] = dbe_->book1D("hCaloCompat", "Calo Compatibility", 101, -0.05, 1.05);
00075       hSegmentCompat[i] = dbe_->book1D("hSegmentCompat", "Segment Compatibility", 101, -0.05, 1.05);
00076       if (make2DPlots_)
00077          hCaloSegmentCompat[i] = dbe_->book2D("hCaloSegmentCompat", "Calo Compatibility vs. Segment Compatibility", 101, -0.05, 1.05, 101, -0.05, 1.05);
00078       hMuonQualityTrkRelChi2[i] = dbe_->book1D("hMuonQualityTrkRelChi2", "MuonQuality TrkRelChi2", 100, 0., 1.5);
00079       hMuonQualityStaRelChi2[i] = dbe_->book1D("hMuonQualityStaRelChi2", "MuonQuality StaRelChi2", 100, 0., 3.);
00080       hMuonQualityTrkKink[i] = dbe_->book1D("hMuonQualityTrkKink", "MuonQuality TrkKink", 100, 0., 150.);
00081       hGlobalMuonPromptTightBool[i] = dbe_->book1D("hGlobalMuonPromptTightBool", "GlobalMuonPromptTight Boolean", 2, -0.5, 1.5);
00082       hTMLastStationLooseBool[i] = dbe_->book1D("hTMLastStationLooseBool", "TMLastStationLoose Boolean", 2, -0.5, 1.5);
00083       hTMLastStationTightBool[i] = dbe_->book1D("hTMLastStationTightBool", "TMLastStationTight Boolean", 2, -0.5, 1.5);
00084       hTM2DCompatibilityLooseBool[i] = dbe_->book1D("hTM2DCompatibilityLooseBool", "TM2DCompatibilityLoose Boolean", 2, -0.5, 1.5);
00085       hTM2DCompatibilityTightBool[i] = dbe_->book1D("hTM2DCompatibilityTightBool", "TM2DCompatibilityTight Boolean", 2, -0.5, 1.5);
00086       hTMOneStationLooseBool[i] = dbe_->book1D("hTMOneStationLooseBool", "TMOneStationLoose Boolean", 2, -0.5, 1.5);
00087       hTMOneStationTightBool[i] = dbe_->book1D("hTMOneStationTightBool", "TMOneStationTight Boolean", 2, -0.5, 1.5);
00088       hTMLastStationOptimizedLowPtLooseBool[i] = dbe_->book1D("hTMLastStationOptimizedLowPtLooseBool", "TMLastStationOptimizedLowPtLoose Boolean", 2, -0.5, 1.5);
00089       hTMLastStationOptimizedLowPtTightBool[i] = dbe_->book1D("hTMLastStationOptimizedLowPtTightBool", "TMLastStationOptimizedLowPtTight Boolean", 2, -0.5, 1.5);
00090       hGMTkChiCompatibilityBool[i] = dbe_->book1D("hGMTkChiCompatibilityBool", "GMTkChiCompatibility Boolean", 2, -0.5, 1.5);
00091       hGMStaChiCompatibilityBool[i] = dbe_->book1D("hGMStaChiCompatibilityBool", "GMStaChiCompatibility Boolean", 2, -0.5, 1.5);
00092       hGMTkKinkTightBool[i] = dbe_->book1D("hGMTkKinkTightBool", "GMTkKinkTight Boolean", 2, -0.5, 1.5);
00093       hTMLastStationAngLooseBool[i] = dbe_->book1D("hTMLastStationAngLooseBool", "TMLastStationAngLoose Boolean", 2, -0.5, 1.5);
00094       hTMLastStationAngTightBool[i] = dbe_->book1D("hTMLastStationAngTightBool", "TMLastStationAngTight Boolean", 2, -0.5, 1.5);
00095       hTMOneStationAngLooseBool[i] = dbe_->book1D("hTMOneStationAngLooseBool", "TMOneStationAngLoose Boolean", 2, -0.5, 1.5);
00096       hTMOneStationAngTightBool[i] = dbe_->book1D("hTMOneStationAngTightBool", "TMOneStationAngTight Boolean", 2, -0.5, 1.5);
00097       hTMLastStationOptimizedBarrelLowPtLooseBool[i] = dbe_->book1D("hTMLastStationOptimizedBarrelLowPtLooseBool", "TMLastStationOptimizedBarrelLowPtLoose Boolean", 2, -0.5, 1.5);
00098       hTMLastStationOptimizedBarrelLowPtTightBool[i] = dbe_->book1D("hTMLastStationOptimizedBarrelLowPtTightBool", "TMLastStationOptimizedBarrelLowPtTight Boolean", 2, -0.5, 1.5);
00099 
00100       if (makeCosmicCompatibilityPlots_) {
00101         hCombinedCosmicCompat[i] = dbe_->book1D("hCombinedCosmicCompat", "hCombinedCosmicCompatibility float", 40, 0., 10.);
00102         hTimeCosmicCompat[i] = dbe_->book1D("hTimeCosmicCompat", "hTimeCosmicCompatibility float", 6, 0., 3.);
00103         hB2BCosmicCompat[i] = dbe_->book1D("hB2BCosmicCompat", "Number of back-to-back partners", 10, 0, 10);
00104         hOverlapCosmicCompat[i] = dbe_->book1D("hOverlapCosmicCompat", "Overlap between muons and 1Leg", 2, 0, 2);
00105       }
00106 
00107       // by station
00108       for(int station = 0; station < 4; ++station)
00109       {
00110 
00111          if (makeShowerInformationPlots_) {
00112              sprintf(name, "hMuonShowerSizeT%i", station+1);
00113              sprintf(title, "Station %i Transverse Cluster Size", station+1);
00114              hMuonShowerSizeT[i][station] = dbe_->book1D(name, title,1000,0,500);
00115              sprintf(name, "hMuonShowerDeltaR%i", station+1);
00116              sprintf(title, "Station %i DeltaR", station+1);
00117              hMuonShowerDeltaR[i][station] = dbe_->book1D(name, title,5000,0,0.5);
00118              sprintf(name, "hMuonAllHits%i", station+1);
00119              sprintf(title, "Station %i Number of 1D DT or 2D CSC RecHits", station+1);
00120              hMuonAllHits[i][station] = dbe_->book1D(name, title,400,0,400);
00121              sprintf(name, "hMuonHitsFromSegments%i", station+1);
00122              sprintf(title, "Station %i Hits used by 4D DT or 3D CSC Segments", station+1);
00123              hMuonHitsFromSegments[i][station] = dbe_->book1D(name, title,400,0,400);
00124              sprintf(name, "hMuonUncorrelatedHits%i", station+1);
00125              sprintf(title, "Station %i Uncorrelated Hits", station+1);
00126              hMuonUncorrelatedHits[i][station] = dbe_->book1D(name, title,400,0,400);
00127          }
00128 
00129          sprintf(name, "hDT%iPullxPropErr", station+1);
00130          sprintf(title, "DT Station %i Pull X w/ Propagation Error Only", station+1);
00131          hDTPullxPropErr[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00132 
00133          sprintf(name, "hDT%iPulldXdZPropErr", station+1);
00134          sprintf(title, "DT Station %i Pull DxDz w/ Propagation Error Only", station+1);
00135          hDTPulldXdZPropErr[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00136 
00137          if (station < 3) {
00138             sprintf(name, "hDT%iPullyPropErr", station+1);
00139             sprintf(title, "DT Station %i Pull Y w/ Propagation Error Only", station+1);
00140             hDTPullyPropErr[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00141 
00142             sprintf(name, "hDT%iPulldYdZPropErr", station+1);
00143             sprintf(title, "DT Station %i Pull DyDz w/ Propagation Error Only", station+1);
00144             hDTPulldYdZPropErr[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00145          }
00146 
00147          sprintf(name, "hDT%iDistWithSegment", station+1);
00148          sprintf(title, "DT Station %i Dist When There Is A Segment", station+1);
00149          hDTDistWithSegment[i][station] = dbe_->book1D(name, title, 100, -140., 30.);
00150 
00151          sprintf(name, "hDT%iDistWithNoSegment", station+1);
00152          sprintf(title, "DT Station %i Dist When There Is No Segment", station+1);
00153          hDTDistWithNoSegment[i][station] = dbe_->book1D(name, title, 100, -140., 30.);
00154 
00155          sprintf(name, "hDT%iPullDistWithSegment", station+1);
00156          sprintf(title, "DT Station %i Pull Dist When There Is A Segment", station+1);
00157          hDTPullDistWithSegment[i][station] = dbe_->book1D(name, title, 100, -140., 30.);
00158 
00159          sprintf(name, "hDT%iPullDistWithNoSegment", station+1);
00160          sprintf(title, "DT Station %i Pull Dist When There Is No Segment", station+1);
00161          hDTPullDistWithNoSegment[i][station] = dbe_->book1D(name, title, 100, -140., 30.);
00162 
00163          sprintf(name, "hCSC%iPullxPropErr", station+1);
00164          sprintf(title, "CSC Station %i Pull X w/ Propagation Error Only", station+1);
00165          hCSCPullxPropErr[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00166 
00167          sprintf(name, "hCSC%iPulldXdZPropErr", station+1);
00168          sprintf(title, "CSC Station %i Pull DxDz w/ Propagation Error Only", station+1);
00169          hCSCPulldXdZPropErr[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00170 
00171          sprintf(name, "hCSC%iPullyPropErr", station+1);
00172          sprintf(title, "CSC Station %i Pull Y w/ Propagation Error Only", station+1);
00173          hCSCPullyPropErr[i][station] = dbe_->book1D(name, title, 100, -20., 20.);
00174 
00175          sprintf(name, "hCSC%iPulldYdZPropErr", station+1);
00176          sprintf(title, "CSC Station %i Pull DyDz w/ Propagation Error Only", station+1);
00177          hCSCPulldYdZPropErr[i][station] = dbe_->book1D(name, title, 100, -50., 50.);
00178 
00179          sprintf(name, "hCSC%iDistWithSegment", station+1);
00180          sprintf(title, "CSC Station %i Dist When There Is A Segment", station+1);
00181          hCSCDistWithSegment[i][station] = dbe_->book1D(name, title, 100, -70., 20.);
00182 
00183          sprintf(name, "hCSC%iDistWithNoSegment", station+1);
00184          sprintf(title, "CSC Station %i Dist When There Is No Segment", station+1);
00185          hCSCDistWithNoSegment[i][station] = dbe_->book1D(name, title, 100, -70., 20.);
00186 
00187          sprintf(name, "hCSC%iPullDistWithSegment", station+1);
00188          sprintf(title, "CSC Station %i Pull Dist When There Is A Segment", station+1);
00189          hCSCPullDistWithSegment[i][station] = dbe_->book1D(name, title, 100, -70., 20.);
00190 
00191          sprintf(name, "hCSC%iPullDistWithNoSegment", station+1);
00192          sprintf(title, "CSC Station %i Pull Dist When There Is No Segment", station+1);
00193          hCSCPullDistWithNoSegment[i][station] = dbe_->book1D(name, title, 100, -70., 20.);
00194       }// station
00195    }
00196 
00197    if (make2DPlots_) {
00198       dbe_->setCurrentFolder(baseFolder_);
00199       hSegmentIsAssociatedRZ = dbe_->book2D("hSegmentIsAssociatedRZ", "R-Z of Associated Segments", 2140, -1070., 1070., 850, 0., 850.);
00200       hSegmentIsAssociatedXY = dbe_->book2D("hSegmentIsAssociatedXY", "X-Y of Associated Segments", 1700, -850., 850., 1700, -850., 850.);
00201       hSegmentIsNotAssociatedRZ = dbe_->book2D("hSegmentIsNotAssociatedRZ", "R-Z of Not Associated Segments", 2140, -1070., 1070., 850, 0., 850.);
00202       hSegmentIsNotAssociatedXY = dbe_->book2D("hSegmentIsNotAssociatedXY", "X-Y of Not Associated Segments", 1700, -850., 850., 1700, -850., 850.);
00203       hSegmentIsBestDrAssociatedRZ = dbe_->book2D("hSegmentIsBestDrAssociatedRZ", "R-Z of Best in Station by #DeltaR Associated Segments", 2140, -1070., 1070., 850, 0., 850.);
00204       hSegmentIsBestDrAssociatedXY = dbe_->book2D("hSegmentIsBestDrAssociatedXY", "X-Y of Best in Station by #DeltaR Associated Segments", 1700, -850., 850., 1700, -850., 850.);
00205       hSegmentIsBestDrNotAssociatedRZ = dbe_->book2D("hSegmentIsBestDrNotAssociatedRZ", "R-Z of Best in Station by #DeltaR Not Associated Segments", 2140, -1070., 1070., 850, 0., 850.);
00206       hSegmentIsBestDrNotAssociatedXY = dbe_->book2D("hSegmentIsBestDrNotAssociatedXY", "X-Y of Best in Station by #DeltaR Not Associated Segments", 1700, -850., 850., 1700, -850., 850.);
00207    }
00208 
00209    if (useTrackerMuons_ && makeAllChamberPlots_) {
00210       dbe_->setCurrentFolder(baseFolder_+"/TrackerMuons");
00211 
00212       // by chamber
00213       for(int station = 0; station < 4; ++station) {
00214          // DT wheels: -2 -> 2
00215          for(int wheel = 0; wheel < 5; ++wheel) {
00216             // DT sectors: 1 -> 14
00217             for(int sector = 0; sector < 14; ++sector)
00218             {
00219                sprintf(name, "hDTChamberDx_%i_%i_%i", station+1, wheel-2, sector+1);
00220                sprintf(title, "DT Chamber Delta X: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00221                hDTChamberDx[station][wheel][sector] = dbe_->book1D(name, title, 100, -100., 100.);
00222 
00223                if (station < 3) {
00224                   sprintf(name, "hDTChamberDy_%i_%i_%i", station+1, wheel-2, sector+1);
00225                   sprintf(title, "DT Chamber Delta Y: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00226                   hDTChamberDy[station][wheel][sector] = dbe_->book1D(name, title, 100, -150., 150.);
00227                }
00228 
00229                sprintf(name, "hDTChamberEdgeXWithSegment_%i_%i_%i", station+1, wheel-2, sector+1);
00230                sprintf(title, "DT Chamber Edge X When There Is A Segment: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00231                hDTChamberEdgeXWithSegment[station][wheel][sector] = dbe_->book1D(name, title, 100, -140., 30.);
00232 
00233                sprintf(name, "hDTChamberEdgeXWithNoSegment_%i_%i_%i", station+1, wheel-2, sector+1);
00234                sprintf(title, "DT Chamber Edge X When There Is No Segment: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00235                hDTChamberEdgeXWithNoSegment[station][wheel][sector] = dbe_->book1D(name, title, 100, -140., 30.);
00236 
00237                sprintf(name, "hDTChamberEdgeYWithSegment_%i_%i_%i", station+1, wheel-2, sector+1);
00238                sprintf(title, "DT Chamber Edge Y When There Is A Segment: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00239                hDTChamberEdgeYWithSegment[station][wheel][sector] = dbe_->book1D(name, title, 100, -140., 30.);
00240 
00241                sprintf(name, "hDTChamberEdgeYWithNoSegment_%i_%i_%i", station+1, wheel-2, sector+1);
00242                sprintf(title, "DT Chamber Edge Y When There Is No Segment: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00243                hDTChamberEdgeYWithNoSegment[station][wheel][sector] = dbe_->book1D(name, title, 100, -140., 30.);
00244             }// sector
00245          }// wheel
00246 
00247          // CSC endcaps: 1 -> 2
00248          for(int endcap = 0; endcap < 2; ++endcap) {
00249             // CSC rings: 1 -> 4
00250             for(int ring = 0; ring < 4; ++ring) {
00251                // CSC chambers: 1 -> 36
00252                for(int chamber = 0; chamber < 36; ++chamber)
00253                {
00254                   sprintf(name, "hCSCChamberDx_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00255                   sprintf(title, "CSC Chamber Delta X: Endcap %i Station %i Ring %i Chamber %i", endcap+1, station+1, ring+1, chamber+1);
00256                   hCSCChamberDx[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -50., 50.);
00257 
00258                   sprintf(name, "hCSCChamberDy_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00259                   sprintf(title, "CSC Chamber Delta Y: Endcap %i Station %i Ring %i Chamber %i", endcap+1, station+1, ring+1, chamber+1);
00260                   hCSCChamberDy[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -50., 50.);
00261 
00262                   sprintf(name, "hCSCChamberEdgeXWithSegment_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00263                   sprintf(title, "CSC Chamber Edge X When There Is A Segment: Endcap %i Station %i Ring %i Chamber %i", endcap+1, station+1, ring+1, chamber+1);
00264                   hCSCChamberEdgeXWithSegment[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -70., 20.);
00265 
00266                   sprintf(name, "hCSCChamberEdgeXWithNoSegment_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00267                   sprintf(title, "CSC Chamber Edge X When There Is No Segment: Endcap %i Station %i Ring %i Chamber %i", endcap+1, station+1, ring+1, chamber+1);
00268                   hCSCChamberEdgeXWithNoSegment[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -70., 20.);
00269 
00270                   sprintf(name, "hCSCChamberEdgeYWithSegment_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00271                   sprintf(title, "CSC Chamber Edge Y When There Is A Segment: Endcap %i Station %i Ring %i Chamber %i", endcap+1, station+1, ring+1, chamber+1);
00272                   hCSCChamberEdgeYWithSegment[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -70., 20.);
00273 
00274                   sprintf(name, "hCSCChamberEdgeYWithNoSegment_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00275                   sprintf(title, "CSC Chamber Edge Y When There Is No Segment: Endcap %i Station %i Ring %i Chamber %i", endcap+1, station+1, ring+1, chamber+1);
00276                   hCSCChamberEdgeYWithNoSegment[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -70., 20.);
00277                }// chamber
00278             }// ring
00279          }// endcap
00280       }// station
00281    }
00282 }
00283 
00284 void
00285 MuonIdVal::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00286 {
00287    using namespace edm;
00288    using namespace reco;
00289 
00290    iEvent.getByLabel(inputMuonCollection_, muonCollectionH_);
00291    iEvent.getByLabel(inputDTRecSegment4DCollection_, dtSegmentCollectionH_);
00292    iEvent.getByLabel(inputCSCSegmentCollection_, cscSegmentCollectionH_);
00293    iEvent.getByLabel(inputMuonTimeExtraValueMap_.label(), "combined", combinedMuonTimeExtraValueMapH_);
00294    iEvent.getByLabel(inputMuonTimeExtraValueMap_.label(), "csc", cscMuonTimeExtraValueMapH_);
00295    iEvent.getByLabel(inputMuonTimeExtraValueMap_.label(), "dt", dtMuonTimeExtraValueMapH_);
00296    iEvent.getByLabel(inputMuonCosmicCompatibilityValueMap_, muonCosmicCompatibilityValueMapH_);
00297    iEvent.getByLabel(inputMuonShowerInformationValueMap_, muonShowerInformationValueMapH_);
00298   
00299    iSetup.get<GlobalTrackingGeometryRecord>().get(geometry_);
00300 
00301    unsigned int muonIdx = 0;
00302    for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00303          muon != muonCollectionH_->end(); ++muon)
00304    {
00305       // trackerMuon == 0; globalMuon == 1; trackerMuon && !globalMuon == 2; globalMuon && !trackerMuon == 3
00306       for (unsigned int i = 0; i < 4; i++) {
00307          if (i == 0 && (! useTrackerMuons_ || ! muon->isTrackerMuon())) continue;
00308          if (i == 1 && (! useGlobalMuons_ || ! muon->isGlobalMuon())) continue;
00309          if (i == 2 && (! useTrackerMuonsNotGlobalMuons_ || (! (muon->isTrackerMuon() && ! muon->isGlobalMuon())))) continue;
00310          if (i == 3 && (! useGlobalMuonsNotTrackerMuons_ || (! (muon->isGlobalMuon() && ! muon->isTrackerMuon())))) continue;
00311 
00312          if (makeEnergyPlots_ && muon->isEnergyValid()) {
00313             // EM
00314             if (fabs(muon->eta()) > 1.479)
00315                hEnergyEMEndcap[i]->Fill(muon->calEnergy().em); 
00316             else
00317                hEnergyEMBarrel[i]->Fill(muon->calEnergy().em);
00318             // HAD
00319             if (fabs(muon->eta()) > 1.4)
00320                hEnergyHAEndcap[i]->Fill(muon->calEnergy().had);
00321             else
00322                hEnergyHABarrel[i]->Fill(muon->calEnergy().had);
00323             // HO
00324             if (fabs(muon->eta()) < 1.26)
00325                hEnergyHO[i]->Fill(muon->calEnergy().ho);
00326          }
00327 
00328          if (makeTimePlots_) {
00329             if (muon->isTimeValid()) {
00330                hMuonTimeNDOF[i]->Fill(muon->time().nDof);
00331                hMuonTimeTimeAtIpInOut[i]->Fill(muon->time().timeAtIpInOut);
00332                hMuonTimeTimeAtIpInOutErr[i]->Fill(muon->time().timeAtIpInOutErr);
00333                hMuonTimeTimeAtIpOutIn[i]->Fill(muon->time().timeAtIpOutIn);
00334                hMuonTimeTimeAtIpOutInErr[i]->Fill(muon->time().timeAtIpOutInErr);
00335             }
00336 
00337             MuonRef muonRef(muonCollectionH_, muonIdx);
00338             MuonTimeExtra combinedMuonTimeExtra = (*combinedMuonTimeExtraValueMapH_)[muonRef];
00339             MuonTimeExtra cscMuonTimeExtra = (*cscMuonTimeExtraValueMapH_)[muonRef];
00340             MuonTimeExtra dtMuonTimeExtra = (*dtMuonTimeExtraValueMapH_)[muonRef];
00341 
00342             hMuonTimeExtraCombinedNDOF[i]->Fill(combinedMuonTimeExtra.nDof());
00343             hMuonTimeExtraCombinedTimeAtIpInOut[i]->Fill(combinedMuonTimeExtra.timeAtIpInOut());
00344             hMuonTimeExtraCombinedTimeAtIpInOutErr[i]->Fill(combinedMuonTimeExtra.timeAtIpInOutErr());
00345             hMuonTimeExtraCombinedTimeAtIpOutIn[i]->Fill(combinedMuonTimeExtra.timeAtIpOutIn());
00346             hMuonTimeExtraCombinedTimeAtIpOutInErr[i]->Fill(combinedMuonTimeExtra.timeAtIpOutInErr());
00347             hMuonTimeExtraCSCNDOF[i]->Fill(cscMuonTimeExtra.nDof());
00348             hMuonTimeExtraCSCTimeAtIpInOut[i]->Fill(cscMuonTimeExtra.timeAtIpInOut());
00349             hMuonTimeExtraCSCTimeAtIpInOutErr[i]->Fill(cscMuonTimeExtra.timeAtIpInOutErr());
00350             hMuonTimeExtraCSCTimeAtIpOutIn[i]->Fill(cscMuonTimeExtra.timeAtIpOutIn());
00351             hMuonTimeExtraCSCTimeAtIpOutInErr[i]->Fill(cscMuonTimeExtra.timeAtIpOutInErr());
00352             hMuonTimeExtraDTNDOF[i]->Fill(dtMuonTimeExtra.nDof());
00353             hMuonTimeExtraDTTimeAtIpInOut[i]->Fill(dtMuonTimeExtra.timeAtIpInOut());
00354             hMuonTimeExtraDTTimeAtIpInOutErr[i]->Fill(dtMuonTimeExtra.timeAtIpInOutErr());
00355             hMuonTimeExtraDTTimeAtIpOutIn[i]->Fill(dtMuonTimeExtra.timeAtIpOutIn());
00356             hMuonTimeExtraDTTimeAtIpOutInErr[i]->Fill(dtMuonTimeExtra.timeAtIpOutInErr());
00357          }
00358 
00359          if (muon->isCaloCompatibilityValid())
00360             hCaloCompat[i]->Fill(muon->caloCompatibility());
00361          hSegmentCompat[i]->Fill(muon::segmentCompatibility(*muon));
00362          if (make2DPlots_ && muon->isCaloCompatibilityValid())
00363             hCaloSegmentCompat[i]->Fill(muon->caloCompatibility(), muon::segmentCompatibility(*muon));
00364          if (muon->isQualityValid()) {
00365             hMuonQualityTrkRelChi2[i]->Fill(muon->combinedQuality().trkRelChi2);
00366             hMuonQualityStaRelChi2[i]->Fill(muon->combinedQuality().staRelChi2);
00367             hMuonQualityTrkKink[i]->Fill(muon->combinedQuality().trkKink);
00368          }
00369          hGlobalMuonPromptTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::GlobalMuonPromptTight));
00370          hTMLastStationLooseBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMLastStationLoose));
00371          hTMLastStationTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMLastStationTight));
00372          hTM2DCompatibilityLooseBool[i]->Fill(muon::isGoodMuon(*muon, muon::TM2DCompatibilityLoose));
00373          hTM2DCompatibilityTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::TM2DCompatibilityTight));
00374          hTMOneStationLooseBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMOneStationLoose));
00375          hTMOneStationTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMOneStationTight));
00376          hTMLastStationOptimizedLowPtLooseBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMLastStationOptimizedLowPtLoose));
00377          hTMLastStationOptimizedLowPtTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMLastStationOptimizedLowPtTight));
00378          hGMTkChiCompatibilityBool[i]->Fill(muon::isGoodMuon(*muon, muon::GMTkChiCompatibility));
00379          hGMStaChiCompatibilityBool[i]->Fill(muon::isGoodMuon(*muon, muon::GMStaChiCompatibility));
00380          hGMTkKinkTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::GMTkKinkTight));
00381          hTMLastStationAngLooseBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMLastStationAngLoose));
00382          hTMLastStationAngTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMLastStationAngTight));
00383          hTMOneStationAngLooseBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMOneStationAngLoose));
00384          hTMOneStationAngTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMOneStationAngTight));
00385          hTMLastStationOptimizedBarrelLowPtLooseBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMLastStationOptimizedBarrelLowPtLoose));
00386          hTMLastStationOptimizedBarrelLowPtTightBool[i]->Fill(muon::isGoodMuon(*muon, muon::TMLastStationOptimizedBarrelLowPtTight));
00387 
00388          if (makeCosmicCompatibilityPlots_) {
00389            MuonRef muonRef(muonCollectionH_, muonIdx);
00390            MuonCosmicCompatibility muonCosmicCompatibility = (*muonCosmicCompatibilityValueMapH_)[muonRef];
00391            hCombinedCosmicCompat[i]->Fill(muonCosmicCompatibility.cosmicCompatibility);
00392            hTimeCosmicCompat[i]->Fill(muonCosmicCompatibility.timeCompatibility);
00393            hB2BCosmicCompat[i]->Fill(muonCosmicCompatibility.backToBackCompatibility);
00394            hOverlapCosmicCompat[i]->Fill(muonCosmicCompatibility.overlapCompatibility);
00395          }
00396          
00397          // by station
00398          for(int station = 0; station < 4; ++station)
00399          {
00400          
00401             if (makeShowerInformationPlots_) {
00402                 MuonRef muonRef(muonCollectionH_, muonIdx);
00403                 MuonShower muonShowerInformation = (*muonShowerInformationValueMapH_)[muonRef];
00404   
00405                 hMuonShowerSizeT[i][station]->Fill((muonShowerInformation.stationShowerSizeT).at(station));
00406                 hMuonShowerDeltaR[i][station]->Fill((muonShowerInformation.stationShowerDeltaR.at(station)));
00407                 hMuonAllHits[i][station]->Fill((muonShowerInformation.nStationHits.at(station)));
00408                 hMuonHitsFromSegments[i][station]->Fill((muonShowerInformation.nStationCorrelatedHits.at(station)));
00409                 hMuonUncorrelatedHits[i][station]->Fill((muonShowerInformation.nStationHits.at(station)) - muonShowerInformation.nStationCorrelatedHits.at(station));
00410             }
00411 
00412 
00413             Fill(hDTPullxPropErr[i][station], muon->pullX(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, false));
00414             Fill(hDTPulldXdZPropErr[i][station], muon->pullDxDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, false));
00415 
00416             if (station < 3) {
00417                Fill(hDTPullyPropErr[i][station], muon->pullY(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, false));
00418                Fill(hDTPulldYdZPropErr[i][station], muon->pullDyDz(station+1, MuonSubdetId::DT, Muon::SegmentAndTrackArbitration, false));
00419             }
00420 
00421             float distance = muon->trackDist(station+1, MuonSubdetId::DT);
00422             float error    = muon->trackDistErr(station+1, MuonSubdetId::DT);
00423             if (error == 0) error = 0.000001;
00424 
00425             if (muon->numberOfSegments(station+1, MuonSubdetId::DT, Muon::NoArbitration) > 0) {
00426                Fill(hDTDistWithSegment[i][station], distance);
00427                Fill(hDTPullDistWithSegment[i][station], distance/error);
00428             } else {
00429                Fill(hDTDistWithNoSegment[i][station], distance);
00430                Fill(hDTPullDistWithNoSegment[i][station], distance/error);
00431             }
00432 
00433             Fill(hCSCPullxPropErr[i][station], muon->pullX(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, false));
00434             Fill(hCSCPulldXdZPropErr[i][station], muon->pullDxDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, false));
00435             Fill(hCSCPullyPropErr[i][station], muon->pullY(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, false));
00436             Fill(hCSCPulldYdZPropErr[i][station], muon->pullDyDz(station+1, MuonSubdetId::CSC, Muon::SegmentAndTrackArbitration, false));
00437 
00438             distance = muon->trackDist(station+1, MuonSubdetId::CSC);
00439             error    = muon->trackDistErr(station+1, MuonSubdetId::CSC);
00440             if (error == 0) error = 0.000001;
00441 
00442             if (muon->numberOfSegments(station+1, MuonSubdetId::CSC, Muon::NoArbitration) > 0) {
00443                Fill(hCSCDistWithSegment[i][station], distance);
00444                Fill(hCSCPullDistWithSegment[i][station], distance/error);
00445             } else {
00446                Fill(hCSCDistWithNoSegment[i][station], distance);
00447                Fill(hCSCPullDistWithNoSegment[i][station], distance/error);
00448             }
00449          }// station
00450       }
00451 
00452       if (! useTrackerMuons_ || ! muon->isTrackerMuon()) continue;
00453       if (makeAllChamberPlots_) {
00454          // by chamber
00455          for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00456                chamberMatch != muon->matches().end(); ++chamberMatch)
00457          {
00458             int station = chamberMatch->station();
00459 
00460             if (chamberMatch->detector() == MuonSubdetId::DT) {
00461                DTChamberId dtId(chamberMatch->id.rawId());
00462                int wheel  = dtId.wheel();
00463                int sector = dtId.sector();
00464 
00465                if (chamberMatch->segmentMatches.empty()) {
00466                   Fill(hDTChamberEdgeXWithNoSegment[station-1][wheel+2][sector-1], chamberMatch->edgeX);
00467                   Fill(hDTChamberEdgeYWithNoSegment[station-1][wheel+2][sector-1], chamberMatch->edgeY);
00468                } else {
00469                   Fill(hDTChamberEdgeXWithSegment[station-1][wheel+2][sector-1], chamberMatch->edgeX);
00470                   Fill(hDTChamberEdgeYWithSegment[station-1][wheel+2][sector-1], chamberMatch->edgeY);
00471 
00472                   for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00473                         segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00474                   {
00475                      if (segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR)) {
00476                         Fill(hDTChamberDx[station-1][wheel+2][sector-1], chamberMatch->x-segmentMatch->x);
00477                         if (station < 4) Fill(hDTChamberDy[station-1][wheel+2][sector-1], chamberMatch->y-segmentMatch->y);
00478                         break;
00479                      }
00480                   }// segmentMatch
00481                }
00482 
00483                continue;
00484             }
00485 
00486             if (chamberMatch->detector() == MuonSubdetId::CSC)  {
00487                CSCDetId cscId(chamberMatch->id.rawId());
00488                int endcap  = cscId.endcap();
00489                int ring    = cscId.ring();
00490                int chamber = cscId.chamber();
00491 
00492                if (chamberMatch->segmentMatches.empty()) {
00493                   Fill(hCSCChamberEdgeXWithNoSegment[endcap-1][station-1][ring-1][chamber-1], chamberMatch->edgeX);
00494                   Fill(hCSCChamberEdgeYWithNoSegment[endcap-1][station-1][ring-1][chamber-1], chamberMatch->edgeY);
00495                } else {
00496                   Fill(hCSCChamberEdgeXWithSegment[endcap-1][station-1][ring-1][chamber-1], chamberMatch->edgeX);
00497                   Fill(hCSCChamberEdgeYWithSegment[endcap-1][station-1][ring-1][chamber-1], chamberMatch->edgeY);
00498 
00499                   for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00500                         segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00501                   {
00502                      if (segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR)) {
00503                         Fill(hCSCChamberDx[endcap-1][station-1][ring-1][chamber-1], chamberMatch->x-segmentMatch->x);
00504                         Fill(hCSCChamberDy[endcap-1][station-1][ring-1][chamber-1], chamberMatch->y-segmentMatch->y);
00505                         break;
00506                      }
00507                   }// segmentMatch
00508                }
00509             }
00510          }// chamberMatch
00511       }
00512       ++muonIdx;
00513    }// muon
00514 
00515    if (! make2DPlots_) return;
00516 
00517    for(DTRecSegment4DCollection::const_iterator segment = dtSegmentCollectionH_->begin();
00518          segment != dtSegmentCollectionH_->end(); ++segment)
00519    {
00520       LocalPoint  segmentLocalPosition       = segment->localPosition();
00521       LocalVector segmentLocalDirection      = segment->localDirection();
00522       LocalError  segmentLocalPositionError  = segment->localPositionError();
00523       LocalError  segmentLocalDirectionError = segment->localDirectionError();
00524       const GeomDet* segmentGeomDet = geometry_->idToDet(segment->geographicalId());
00525       GlobalPoint segmentGlobalPosition = segmentGeomDet->toGlobal(segment->localPosition());
00526       bool segmentFound = false;
00527       bool segmentBestDrFound = false;
00528 
00529       for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00530             muon != muonCollectionH_->end(); ++muon)
00531       {
00532          if (! muon->isMatchesValid())
00533             continue;
00534 
00535          for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00536                chamberMatch != muon->matches().end(); ++chamberMatch) {
00537             for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00538                   segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00539             {
00540                if (fabs(segmentMatch->x       - segmentLocalPosition.x()                           ) < 1E-6 &&
00541                    fabs(segmentMatch->y       - segmentLocalPosition.y()                           ) < 1E-6 &&
00542                    fabs(segmentMatch->dXdZ    - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
00543                    fabs(segmentMatch->dYdZ    - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
00544                    fabs(segmentMatch->xErr    - sqrt(segmentLocalPositionError.xx())               ) < 1E-6 &&
00545                    fabs(segmentMatch->yErr    - sqrt(segmentLocalPositionError.yy())               ) < 1E-6 &&
00546                    fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx())              ) < 1E-6 &&
00547                    fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy())              ) < 1E-6)
00548                {
00549                   segmentFound = true;
00550                   if (segmentMatch->isMask(reco::MuonSegmentMatch::BestInStationByDR)) segmentBestDrFound = true;
00551                   break;
00552                }
00553             }// segmentMatch
00554             if (segmentFound) break;
00555          }// chamberMatch
00556          if (segmentFound) break;
00557       }// muon
00558 
00559       if (segmentFound) {
00560          hSegmentIsAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00561          hSegmentIsAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00562 
00563          if (segmentBestDrFound) {
00564             hSegmentIsBestDrAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00565             hSegmentIsBestDrAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00566          }
00567       } else {
00568          hSegmentIsNotAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00569          hSegmentIsNotAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00570          hSegmentIsBestDrNotAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00571          hSegmentIsBestDrNotAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00572       }
00573    }// dt segment
00574 
00575    for(CSCSegmentCollection::const_iterator segment = cscSegmentCollectionH_->begin();
00576          segment != cscSegmentCollectionH_->end(); ++segment)
00577    {
00578       LocalPoint  segmentLocalPosition       = segment->localPosition();
00579       LocalVector segmentLocalDirection      = segment->localDirection();
00580       LocalError  segmentLocalPositionError  = segment->localPositionError();
00581       LocalError  segmentLocalDirectionError = segment->localDirectionError();
00582       const GeomDet* segmentGeomDet = geometry_->idToDet(segment->geographicalId());
00583       GlobalPoint segmentGlobalPosition = segmentGeomDet->toGlobal(segment->localPosition());
00584       bool segmentFound = false;
00585       bool segmentBestDrFound = false;
00586 
00587       for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00588             muon != muonCollectionH_->end(); ++muon)
00589       {
00590          if (! muon->isMatchesValid())
00591             continue;
00592 
00593          for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00594                chamberMatch != muon->matches().end(); ++chamberMatch) {
00595             for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00596                   segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00597             {
00598                if (fabs(segmentMatch->x       - segmentLocalPosition.x()                           ) < 1E-6 &&
00599                    fabs(segmentMatch->y       - segmentLocalPosition.y()                           ) < 1E-6 &&
00600                    fabs(segmentMatch->dXdZ    - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
00601                    fabs(segmentMatch->dYdZ    - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
00602                    fabs(segmentMatch->xErr    - sqrt(segmentLocalPositionError.xx())               ) < 1E-6 &&
00603                    fabs(segmentMatch->yErr    - sqrt(segmentLocalPositionError.yy())               ) < 1E-6 &&
00604                    fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx())              ) < 1E-6 &&
00605                    fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy())              ) < 1E-6)
00606                {
00607                   segmentFound = true;
00608                   if (segmentMatch->isMask(reco::MuonSegmentMatch::BestInStationByDR)) segmentBestDrFound = true;
00609                   break;
00610                }
00611             }// segmentMatch
00612             if (segmentFound) break;
00613          }// chamberMatch
00614          if (segmentFound) break;
00615       }// muon
00616 
00617       if (segmentFound) {
00618          hSegmentIsAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00619          hSegmentIsAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00620 
00621          if (segmentBestDrFound) {
00622             hSegmentIsBestDrAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00623             hSegmentIsBestDrAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00624          }
00625       } else {
00626          hSegmentIsNotAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00627          hSegmentIsNotAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00628          hSegmentIsBestDrNotAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00629          hSegmentIsBestDrNotAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00630       }
00631    }// csc segment
00632 }
00633 
00634 void 
00635 MuonIdVal::endJob() {}
00636 
00637 void MuonIdVal::Fill(MonitorElement* me, float f) {
00638    if (fabs(f) > 900000) return;
00639    //if (fabs(f) < 1E-8) return;
00640    me->Fill(f);
00641 }
00642 
00643 //define this as a plug-in
00644 DEFINE_FWK_MODULE(MuonIdVal);