CMS 3D CMS Logo

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    useTrackerMuons_ = iConfig.getUntrackedParameter<bool>("useTrackerMuons");
00009    useGlobalMuons_ = iConfig.getUntrackedParameter<bool>("useGlobalMuons");
00010    makeDQMPlots_ = iConfig.getUntrackedParameter<bool>("makeDQMPlots");
00011    makeEnergyPlots_ = iConfig.getUntrackedParameter<bool>("makeEnergyPlots");
00012    makeIsoPlots_ = iConfig.getUntrackedParameter<bool>("makeIsoPlots");
00013    make2DPlots_ = iConfig.getUntrackedParameter<bool>("make2DPlots");
00014    makeAllChamberPlots_ = iConfig.getUntrackedParameter<bool>("makeAllChamberPlots");
00015    baseFolder_ = iConfig.getUntrackedParameter<std::string>("baseFolder");
00016 
00017    // If makeDQMPlots_ then disable everything else, and all but a few choice plots
00018    if (makeDQMPlots_) {
00019       makeEnergyPlots_ = false;
00020       makeIsoPlots_ = false;
00021       make2DPlots_ = false;
00022       makeAllChamberPlots_ = false;
00023    }
00024 
00025    dbe_ = 0;
00026    dbe_ = edm::Service<DQMStore>().operator->();
00027 }
00028 
00029 MuonIdVal::~MuonIdVal() {}
00030 
00031 void 
00032 MuonIdVal::beginJob(const edm::EventSetup&)
00033 {
00034    // trackerMuon == 0; globalMuon == 1
00035    for (unsigned int i = 0; i < 2; i++) {
00036       if ((i == 0 && ! useTrackerMuons_) || (i == 1 && ! useGlobalMuons_)) continue;
00037       if (i == 0) dbe_->setCurrentFolder(baseFolder_+"/TrackerMuons");
00038       if (i == 1) dbe_->setCurrentFolder(baseFolder_+"/GlobalMuons");
00039 
00040       hNumChambers[i] = dbe_->book1D("hNumChambers", "Number of Chambers", 11, -0.5, 10.5);
00041       hNumMatches[i] = dbe_->book1D("hNumMatches", "Number of Matches", 11, -0.5, 10.5);
00042       if (! makeDQMPlots_) {
00043          hCaloCompat[i] = dbe_->book1D("hCaloCompat", "Calo Compatibility", 101, -0.05, 1.05);
00044          hSegmentCompat[i] = dbe_->book1D("hSegmentCompat", "Segment Compatibility", 101, -0.05, 1.05);
00045          if (make2DPlots_)
00046             hCaloSegmentCompat[i] = dbe_->book2D("hCaloSegmentCompat", "Calo Compatibility vs. Segment Compatibility", 101, -0.05, 1.05, 101, -0.05, 1.05);
00047          hGlobalMuonPromptTightBool[i] = dbe_->book1D("hGlobalMuonPromptTightBool", "GlobalMuonPromptTight Boolean", 2, -0.5, 1.5);
00048          hTMLastStationLooseBool[i] = dbe_->book1D("hTMLastStationLooseBool", "TMLastStationLoose Boolean", 2, -0.5, 1.5);
00049          hTMLastStationTightBool[i] = dbe_->book1D("hTMLastStationTightBool", "TMLastStationTight Boolean", 2, -0.5, 1.5);
00050          hTM2DCompatibilityLooseBool[i] = dbe_->book1D("hTM2DCompatibilityLooseBool", "TM2DCompatibilityLoose Boolean", 2, -0.5, 1.5);
00051          hTM2DCompatibilityTightBool[i] = dbe_->book1D("hTM2DCompatibilityTightBool", "TM2DCompatibilityTight Boolean", 2, -0.5, 1.5);
00052          hTMOneStationLooseBool[i] = dbe_->book1D("hTMOneStationLooseBool", "TMOneStationLoose Boolean", 2, -0.5, 1.5);
00053          hTMOneStationTightBool[i] = dbe_->book1D("hTMOneStationTightBool", "TMOneStationTight Boolean", 2, -0.5, 1.5);
00054          hTMLastStationOptimizedLowPtLooseBool[i] = dbe_->book1D("hTMLastStationOptimizedLowPtLooseBool", "TMLastStationOptimizedLowPtLoose Boolean", 2, -0.5, 1.5);
00055          hTMLastStationOptimizedLowPtTightBool[i] = dbe_->book1D("hTMLastStationOptimizedLowPtTightBool", "TMLastStationOptimizedLowPtTight Boolean", 2, -0.5, 1.5);
00056 
00057          if (makeEnergyPlots_) {
00058             hEnergyEMBarrel[i] = dbe_->book1D("hEnergyEMBarrel", "Energy in ECAL Barrel", 100, -0.5, 2.);
00059             hEnergyHABarrel[i] = dbe_->book1D("hEnergyHABarrel", "Energy in HCAL Barrel", 100, -4., 12.);
00060             hEnergyHO[i] = dbe_->book1D("hEnergyHO", "Energy HO", 100, -2., 5.);
00061             hEnergyEMEndcap[i] = dbe_->book1D("hEnergyEMEndcap", "Energy in ECAL Endcap", 100, -0.5, 2.);
00062             hEnergyHAEndcap[i] = dbe_->book1D("hEnergyHAEndcap", "Energy in HCAL Endcap", 100, -4., 12.);
00063          }
00064 
00065          if (makeIsoPlots_) {
00066             hIso03sumPt[i] = dbe_->book1D("hIso03sumPt", "Sum Pt in Cone of 0.3", 100, 0., 10.);
00067             hIso03emEt[i] = dbe_->book1D("hIso03emEt", "Em Et in Cone of 0.3", 100, 0., 10.);
00068             hIso03hadEt[i] = dbe_->book1D("hIso03hadEt", "Had Et in Cone of 0.3", 100, 0., 10.);
00069             hIso03hoEt[i] = dbe_->book1D("hIso03hoEt", "HO Et in Cone of 0.3", 100, 0., 10.);
00070             hIso03nTracks[i] = dbe_->book1D("hIso03nTracks", "Number of Tracks in Cone of 0.3", 11, -0.5, 10.5);
00071             hIso03nJets[i] = dbe_->book1D("hIso03nJets", "Number of Jets in Cone of 0.3", 11, -0.5, 10.5);
00072             hIso05sumPt[i] = dbe_->book1D("hIso05sumPt", "Sum Pt in Cone of 0.5", 100, 0., 10.);
00073             hIso05emEt[i] = dbe_->book1D("hIso05emEt", "Em Et in Cone of 0.5", 100, 0., 10.);
00074             hIso05hadEt[i] = dbe_->book1D("hIso05hadEt", "Had Et in Cone of 0.5", 100, 0., 10.);
00075             hIso05hoEt[i] = dbe_->book1D("hIso05hoEt", "HO Et in Cone of 0.5", 100, 0., 10.);
00076             hIso05nTracks[i] = dbe_->book1D("hIso05nTracks", "Number of Tracks in Cone of 0.5", 11, -0.5, 10.5);
00077             hIso05nJets[i] = dbe_->book1D("hIso05nJets", "Number of Jets in Cone of 0.5", 11, -0.5, 10.5);
00078          }
00079       }
00080    }
00081 
00082    if (useTrackerMuons_) {
00083       dbe_->setCurrentFolder(baseFolder_+"/TrackerMuons");
00084 
00085       char name[100], title[200];
00086 
00087       // by station
00088       for(int station = 0; station < 4; ++station)
00089       {
00090          sprintf(name, "hDT%iNumSegments", station+1);
00091          sprintf(title, "DT Station %i Number of Segments (No Arbitration)", station+1);
00092          hDTNumSegments[station] = dbe_->book1D(name, title, 11, -0.5, 10.5);
00093 
00094          sprintf(name, "hDT%iDx", station+1);
00095          sprintf(title, "DT Station %i Delta X", station+1);
00096          hDTDx[station] = dbe_->book1D(name, title, 100, -100., 100.);
00097 
00098          sprintf(name, "hDT%iPullx", station+1);
00099          sprintf(title, "DT Station %i Pull X", station+1);
00100          hDTPullx[station] = dbe_->book1D(name, title, 100, -20., 20.);
00101 
00102          if (station < 3) {
00103             sprintf(name, "hDT%iDy", station+1);
00104             sprintf(title, "DT Station %i Delta Y", station+1);
00105             hDTDy[station] = dbe_->book1D(name, title, 100, -150., 150.);
00106 
00107             sprintf(name, "hDT%iPully", station+1);
00108             sprintf(title, "DT Station %i Pull Y", station+1);
00109             hDTPully[station] = dbe_->book1D(name, title, 100, -20., 20.);
00110 
00111             if (! makeDQMPlots_) {
00112                sprintf(name, "hDT%iPullyPropErr", station+1);
00113                sprintf(title, "DT Station %i Pull Y w/ Propagation Error Only", station+1);
00114                hDTPullyPropErr[station] = dbe_->book1D(name, title, 100, -20., 20.);
00115 
00116                sprintf(name, "hDT%iDdYdZ", station+1);
00117                sprintf(title, "DT Station %i Delta DyDz", station+1);
00118                hDTDdYdZ[station] = dbe_->book1D(name, title, 100, -2., 2.);
00119 
00120                sprintf(name, "hDT%iPulldYdZ", station+1);
00121                sprintf(title, "DT Station %i Pull DyDz", station+1);
00122                hDTPulldYdZ[station] = dbe_->book1D(name, title, 100, -20., 20.);
00123 
00124                sprintf(name, "hDT%iPulldYdZPropErr", station+1);
00125                sprintf(title, "DT Station %i Pull DyDz w/ Propagation Error Only", station+1);
00126                hDTPulldYdZPropErr[station] = dbe_->book1D(name, title, 100, -20., 20.);
00127             }
00128          }
00129 
00130          sprintf(name, "hCSC%iNumSegments", station+1);
00131          sprintf(title, "CSC Station %i Number of Segments (No Arbitration)", station+1);
00132          hCSCNumSegments[station] = dbe_->book1D(name, title, 11, -0.5, 10.5);
00133 
00134          sprintf(name, "hCSC%iDx", station+1);
00135          sprintf(title, "CSC Station %i Delta X", station+1);
00136          hCSCDx[station] = dbe_->book1D(name, title, 100, -50., 50.);
00137 
00138          sprintf(name, "hCSC%iPullx", station+1);
00139          sprintf(title, "CSC Station %i Pull X", station+1);
00140          hCSCPullx[station] = dbe_->book1D(name, title, 100, -20., 20.);
00141 
00142          sprintf(name, "hCSC%iDy", station+1);
00143          sprintf(title, "CSC Station %i Delta Y", station+1);
00144          hCSCDy[station] = dbe_->book1D(name, title, 100, -50., 50.);
00145 
00146          sprintf(name, "hCSC%iPully", station+1);
00147          sprintf(title, "CSC Station %i Pull Y", station+1);
00148          hCSCPully[station] = dbe_->book1D(name, title, 100, -20., 20.);
00149 
00150          if (! makeDQMPlots_) {
00151             sprintf(name, "hDT%iPullxPropErr", station+1);
00152             sprintf(title, "DT Station %i Pull X w/ Propagation Error Only", station+1);
00153             hDTPullxPropErr[station] = dbe_->book1D(name, title, 100, -20., 20.);
00154 
00155             sprintf(name, "hDT%iDdXdZ", station+1);
00156             sprintf(title, "DT Station %i Delta DxDz", station+1);
00157             hDTDdXdZ[station] = dbe_->book1D(name, title, 100, -1., 1.);
00158 
00159             sprintf(name, "hDT%iPulldXdZ", station+1);
00160             sprintf(title, "DT Station %i Pull DxDz", station+1);
00161             hDTPulldXdZ[station] = dbe_->book1D(name, title, 100, -20., 20.);
00162 
00163             sprintf(name, "hDT%iPulldXdZPropErr", station+1);
00164             sprintf(title, "DT Station %i Pull DxDz w/ Propagation Error Only", station+1);
00165             hDTPulldXdZPropErr[station] = dbe_->book1D(name, title, 100, -20., 20.);
00166 
00167             sprintf(name, "hDT%iDistWithSegment", station+1);
00168             sprintf(title, "DT Station %i Dist When There Is A Segment", station+1);
00169             hDTDistWithSegment[station] = dbe_->book1D(name, title, 100, -140., 30.);
00170 
00171             sprintf(name, "hDT%iDistWithNoSegment", station+1);
00172             sprintf(title, "DT Station %i Dist When There Is No Segment", station+1);
00173             hDTDistWithNoSegment[station] = dbe_->book1D(name, title, 100, -140., 30.);
00174 
00175             sprintf(name, "hDT%iPullDistWithSegment", station+1);
00176             sprintf(title, "DT Station %i Pull Dist When There Is A Segment", station+1);
00177             hDTPullDistWithSegment[station] = dbe_->book1D(name, title, 100, -140., 30.);
00178 
00179             sprintf(name, "hDT%iPullDistWithNoSegment", station+1);
00180             sprintf(title, "DT Station %i Pull Dist When There Is No Segment", station+1);
00181             hDTPullDistWithNoSegment[station] = dbe_->book1D(name, title, 100, -140., 30.);
00182 
00183             sprintf(name, "hCSC%iPullxPropErr", station+1);
00184             sprintf(title, "CSC Station %i Pull X w/ Propagation Error Only", station+1);
00185             hCSCPullxPropErr[station] = dbe_->book1D(name, title, 100, -20., 20.);
00186 
00187             sprintf(name, "hCSC%iDdXdZ", station+1);
00188             sprintf(title, "CSC Station %i Delta DxDz", station+1);
00189             hCSCDdXdZ[station] = dbe_->book1D(name, title, 100, -1., 1.);
00190 
00191             sprintf(name, "hCSC%iPulldXdZ", station+1);
00192             sprintf(title, "CSC Station %i Pull DxDz", station+1);
00193             hCSCPulldXdZ[station] = dbe_->book1D(name, title, 100, -20., 20.);
00194 
00195             sprintf(name, "hCSC%iPulldXdZPropErr", station+1);
00196             sprintf(title, "CSC Station %i Pull DxDz w/ Propagation Error Only", station+1);
00197             hCSCPulldXdZPropErr[station] = dbe_->book1D(name, title, 100, -20., 20.);
00198 
00199             sprintf(name, "hCSC%iPullyPropErr", station+1);
00200             sprintf(title, "CSC Station %i Pull Y w/ Propagation Error Only", station+1);
00201             hCSCPullyPropErr[station] = dbe_->book1D(name, title, 100, -20., 20.);
00202 
00203             sprintf(name, "hCSC%iDdYdZ", station+1);
00204             sprintf(title, "CSC Station %i Delta DyDz", station+1);
00205             hCSCDdYdZ[station] = dbe_->book1D(name, title, 100, -1., 1.);
00206 
00207             sprintf(name, "hCSC%iPulldYdZ", station+1);
00208             sprintf(title, "CSC Station %i Pull DyDz", station+1);
00209             hCSCPulldYdZ[station] = dbe_->book1D(name, title, 100, -20., 20.);
00210 
00211             sprintf(name, "hCSC%iPulldYdZPropErr", station+1);
00212             sprintf(title, "CSC Station %i Pull DyDz w/ Propagation Error Only", station+1);
00213             hCSCPulldYdZPropErr[station] = dbe_->book1D(name, title, 100, -50., 50.);
00214 
00215             sprintf(name, "hCSC%iDistWithSegment", station+1);
00216             sprintf(title, "CSC Station %i Dist When There Is A Segment", station+1);
00217             hCSCDistWithSegment[station] = dbe_->book1D(name, title, 100, -70., 20.);
00218 
00219             sprintf(name, "hCSC%iDistWithNoSegment", station+1);
00220             sprintf(title, "CSC Station %i Dist When There Is No Segment", station+1);
00221             hCSCDistWithNoSegment[station] = dbe_->book1D(name, title, 100, -70., 20.);
00222 
00223             sprintf(name, "hCSC%iPullDistWithSegment", station+1);
00224             sprintf(title, "CSC Station %i Pull Dist When There Is A Segment", station+1);
00225             hCSCPullDistWithSegment[station] = dbe_->book1D(name, title, 100, -70., 20.);
00226 
00227             sprintf(name, "hCSC%iPullDistWithNoSegment", station+1);
00228             sprintf(title, "CSC Station %i Pull Dist When There Is No Segment", station+1);
00229             hCSCPullDistWithNoSegment[station] = dbe_->book1D(name, title, 100, -70., 20.);
00230          }
00231       }// station
00232 
00233       hSegmentIsAssociatedBool = dbe_->book1D("hSegmentIsAssociatedBool", "Segment Is Associated Boolean", 2, -0.5, 1.5);
00234       if (make2DPlots_) {
00235          hSegmentIsAssociatedRZ = dbe_->book2D("hSegmentIsAssociatedRZ", "R-Z of Associated Segments", 2140, -1070., 1070., 850, 0., 850.);
00236          hSegmentIsAssociatedXY = dbe_->book2D("hSegmentIsAssociatedXY", "R-#phi of Associated Segments", 1700, -850., 850., 1700, -850., 850.);
00237          hSegmentIsNotAssociatedRZ = dbe_->book2D("hSegmentIsNotAssociatedRZ", "R-Z of Not Associated Segments", 2140, -1070., 1070., 850, 0., 850.);
00238          hSegmentIsNotAssociatedXY = dbe_->book2D("hSegmentIsNotAssociatedXY", "R-#phi of Not Associated Segments", 1700, -850., 850., 1700, -850., 850.);
00239          hSegmentIsBestDrAssociatedRZ = dbe_->book2D("hSegmentIsBestDrAssociatedRZ", "R-Z of Best in Station by #DeltaR Associated Segments", 2140, -1070., 1070., 850, 0., 850.);
00240          hSegmentIsBestDrAssociatedXY = dbe_->book2D("hSegmentIsBestDrAssociatedXY", "R-#phi of Best in Station by #DeltaR Associated Segments", 1700, -850., 850., 1700, -850., 850.);
00241          hSegmentIsBestDrNotAssociatedRZ = dbe_->book2D("hSegmentIsBestDrNotAssociatedRZ", "R-Z of Best in Station by #DeltaR Not Associated Segments", 2140, -1070., 1070., 850, 0., 850.);
00242          hSegmentIsBestDrNotAssociatedXY = dbe_->book2D("hSegmentIsBestDrNotAssociatedXY", "R-#phi of Best in Station by #DeltaR Not Associated Segments", 1700, -850., 850., 1700, -850., 850.);
00243       }
00244 
00245       if (makeAllChamberPlots_) {
00246          // by chamber
00247          for(int station = 0; station < 4; ++station) {
00248             // DT wheels: -2 -> 2
00249             for(int wheel = 0; wheel < 5; ++wheel) {
00250                // DT sectors: 1 -> 14
00251                for(int sector = 0; sector < 14; ++sector)
00252                {
00253                   sprintf(name, "hDTChamberDx_%i_%i_%i", station+1, wheel-2, sector+1);
00254                   sprintf(title, "DT Chamber Delta X: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00255                   hDTChamberDx[station][wheel][sector] = dbe_->book1D(name, title, 100, -100., 100.);
00256 
00257                   if (station < 3) {
00258                      sprintf(name, "hDTChamberDy_%i_%i_%i", station+1, wheel-2, sector+1);
00259                      sprintf(title, "DT Chamber Delta Y: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00260                      hDTChamberDy[station][wheel][sector] = dbe_->book1D(name, title, 100, -150., 150.);
00261                   }
00262 
00263                   sprintf(name, "hDTChamberEdgeXWithSegment_%i_%i_%i", station+1, wheel-2, sector+1);
00264                   sprintf(title, "DT Chamber Edge X When There Is A Segment: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00265                   hDTChamberEdgeXWithSegment[station][wheel][sector] = dbe_->book1D(name, title, 100, -140., 30.);
00266 
00267                   sprintf(name, "hDTChamberEdgeXWithNoSegment_%i_%i_%i", station+1, wheel-2, sector+1);
00268                   sprintf(title, "DT Chamber Edge X When There Is No Segment: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00269                   hDTChamberEdgeXWithNoSegment[station][wheel][sector] = dbe_->book1D(name, title, 100, -140., 30.);
00270 
00271                   sprintf(name, "hDTChamberEdgeYWithSegment_%i_%i_%i", station+1, wheel-2, sector+1);
00272                   sprintf(title, "DT Chamber Edge Y When There Is A Segment: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00273                   hDTChamberEdgeYWithSegment[station][wheel][sector] = dbe_->book1D(name, title, 100, -140., 30.);
00274 
00275                   sprintf(name, "hDTChamberEdgeYWithNoSegment_%i_%i_%i", station+1, wheel-2, sector+1);
00276                   sprintf(title, "DT Chamber Edge Y When There Is No Segment: Station %i Wheel %i Sector %i", station+1, wheel-2, sector+1);
00277                   hDTChamberEdgeYWithNoSegment[station][wheel][sector] = dbe_->book1D(name, title, 100, -140., 30.);
00278                }// sector
00279             }// wheel
00280 
00281             // CSC endcaps: 1 -> 2
00282             for(int endcap = 0; endcap < 2; ++endcap) {
00283                // CSC rings: 1 -> 4
00284                for(int ring = 0; ring < 4; ++ring) {
00285                   // CSC chambers: 1 -> 36
00286                   for(int chamber = 0; chamber < 36; ++chamber)
00287                   {
00288                      sprintf(name, "hCSCChamberDx_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00289                      sprintf(title, "CSC Chamber Delta X: Endcap %i Station %i Ring %i Chamber %i", endcap+1, station+1, ring+1, chamber+1);
00290                      hCSCChamberDx[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -50., 50.);
00291 
00292                      sprintf(name, "hCSCChamberDy_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00293                      sprintf(title, "CSC Chamber Delta Y: Endcap %i Station %i Ring %i Chamber %i", endcap+1, station+1, ring+1, chamber+1);
00294                      hCSCChamberDy[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -50., 50.);
00295 
00296                      sprintf(name, "hCSCChamberEdgeXWithSegment_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00297                      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);
00298                      hCSCChamberEdgeXWithSegment[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -70., 20.);
00299 
00300                      sprintf(name, "hCSCChamberEdgeXWithNoSegment_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00301                      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);
00302                      hCSCChamberEdgeXWithNoSegment[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -70., 20.);
00303 
00304                      sprintf(name, "hCSCChamberEdgeYWithSegment_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00305                      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);
00306                      hCSCChamberEdgeYWithSegment[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -70., 20.);
00307 
00308                      sprintf(name, "hCSCChamberEdgeYWithNoSegment_%i_%i_%i_%i", endcap+1, station+1, ring+1, chamber+1);
00309                      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);
00310                      hCSCChamberEdgeYWithNoSegment[endcap][station][ring][chamber] = dbe_->book1D(name, title, 100, -70., 20.);
00311                   }// chamber
00312                }// ring
00313             }// endcap
00314          }// station
00315       }
00316    }
00317 }
00318 
00319 void
00320 MuonIdVal::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00321 {
00322    using namespace edm;
00323    using namespace reco;
00324 
00325    iEvent.getByLabel(inputMuonCollection_, muonCollectionH_);
00326    iEvent.getByLabel(inputDTRecSegment4DCollection_, dtSegmentCollectionH_);
00327    iEvent.getByLabel(inputCSCSegmentCollection_, cscSegmentCollectionH_);
00328    iSetup.get<GlobalTrackingGeometryRecord>().get(geometry_);
00329 
00330    for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00331          muon != muonCollectionH_->end(); ++muon)
00332    {
00333       // trackerMuon == 0; globalMuon == 1
00334       for (unsigned int i = 0; i < 2; i++) {
00335          if (i == 0 && (! useTrackerMuons_ || ! muon->isTrackerMuon())) continue;
00336          if (i == 1 && (! useGlobalMuons_ || ! muon->isGlobalMuon())) continue;
00337 
00338          hNumChambers[i]->Fill(muon->numberOfChambers());
00339          hNumMatches[i]->Fill(muon->numberOfMatches());
00340          if (! makeDQMPlots_) {
00341             hCaloCompat[i]->Fill(muon->caloCompatibility());
00342             hSegmentCompat[i]->Fill(muon->segmentCompatibility());
00343             if (make2DPlots_)
00344                hCaloSegmentCompat[i]->Fill(muon->caloCompatibility(), muon->segmentCompatibility());
00345             hGlobalMuonPromptTightBool[i]->Fill(muon->isGood(Muon::GlobalMuonPromptTight));
00346             hTMLastStationLooseBool[i]->Fill(muon->isGood(Muon::TMLastStationLoose));
00347             hTMLastStationTightBool[i]->Fill(muon->isGood(Muon::TMLastStationTight));
00348             hTM2DCompatibilityLooseBool[i]->Fill(muon->isGood(Muon::TM2DCompatibilityLoose));
00349             hTM2DCompatibilityTightBool[i]->Fill(muon->isGood(Muon::TM2DCompatibilityTight));
00350             hTMOneStationLooseBool[i]->Fill(muon->isGood(Muon::TMOneStationLoose));
00351             hTMOneStationTightBool[i]->Fill(muon->isGood(Muon::TMOneStationTight));
00352             hTMLastStationOptimizedLowPtLooseBool[i]->Fill(muon->isGood(Muon::TMLastStationOptimizedLowPtLoose));
00353             hTMLastStationOptimizedLowPtTightBool[i]->Fill(muon->isGood(Muon::TMLastStationOptimizedLowPtTight));
00354 
00355             if (makeEnergyPlots_) {
00356                //EM
00357                if (fabs(muon->eta()) > 1.479)
00358                   hEnergyEMEndcap[i]->Fill(muon->calEnergy().em);
00359                else
00360                   hEnergyEMBarrel[i]->Fill(muon->calEnergy().em);
00361                //HAD
00362                if (fabs(muon->eta()) > 1.4)
00363                   hEnergyHAEndcap[i]->Fill(muon->calEnergy().had);
00364                else
00365                   hEnergyHABarrel[i]->Fill(muon->calEnergy().had);
00366                //HO
00367                if (fabs(muon->eta()) < 1.26)
00368                   hEnergyHO[i]->Fill(muon->calEnergy().ho);
00369             }
00370 
00371             if (makeIsoPlots_) {
00372                hIso03sumPt[i]->Fill(muon->isolationR03().sumPt);
00373                hIso03emEt[i]->Fill(muon->isolationR03().emEt);
00374                hIso03hadEt[i]->Fill(muon->isolationR03().hadEt);
00375                hIso03hoEt[i]->Fill(muon->isolationR03().hoEt);
00376                hIso03nTracks[i]->Fill(muon->isolationR03().nTracks);
00377                hIso03nJets[i]->Fill(muon->isolationR03().nJets);
00378                hIso05sumPt[i]->Fill(muon->isolationR05().sumPt);
00379                hIso05emEt[i]->Fill(muon->isolationR05().emEt);
00380                hIso05hadEt[i]->Fill(muon->isolationR05().hadEt);
00381                hIso05hoEt[i]->Fill(muon->isolationR05().hoEt);
00382                hIso05nTracks[i]->Fill(muon->isolationR05().nTracks);
00383                hIso05nJets[i]->Fill(muon->isolationR05().nJets);
00384             }
00385          }
00386       }
00387 
00388       if (! useTrackerMuons_ || ! muon->isTrackerMuon()) continue;
00389 
00390       // by station
00391       for(int station = 0; station < 4; ++station)
00392       {
00393          hDTNumSegments[station]->Fill(muon->numberOfSegments(station+1, MuonSubdetId::DT, Muon::NoArbitration));
00394          hDTDx[station]->Fill(muon->dX(station+1, MuonSubdetId::DT));
00395          hDTPullx[station]->Fill(muon->pullX(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, true));
00396 
00397          if (station < 3) {
00398             hDTDy[station]->Fill(muon->dY(station+1, MuonSubdetId::DT));
00399             hDTPully[station]->Fill(muon->pullY(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, true));
00400             if (! makeDQMPlots_) {
00401                hDTPullyPropErr[station]->Fill(muon->pullY(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, false));
00402                hDTDdYdZ[station]->Fill(muon->dDyDz(station+1, MuonSubdetId::DT));
00403                hDTPulldYdZ[station]->Fill(muon->pullDyDz(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, true));
00404                hDTPulldYdZPropErr[station]->Fill(muon->pullDyDz(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, false));
00405             }
00406          }
00407 
00408          hCSCNumSegments[station]->Fill(muon->numberOfSegments(station+1, MuonSubdetId::CSC, Muon::NoArbitration));
00409          hCSCDx[station]->Fill(muon->dX(station+1, MuonSubdetId::CSC));
00410          hCSCPullx[station]->Fill(muon->pullX(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, true));
00411          hCSCDy[station]->Fill(muon->dY(station+1, MuonSubdetId::CSC));
00412          hCSCPully[station]->Fill(muon->pullY(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, true));
00413 
00414          if (! makeDQMPlots_) {
00415             hDTPullxPropErr[station]->Fill(muon->pullX(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, false));
00416             hDTDdXdZ[station]->Fill(muon->dDxDz(station+1, MuonSubdetId::DT));
00417             hDTPulldXdZ[station]->Fill(muon->pullDxDz(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, true));
00418             hDTPulldXdZPropErr[station]->Fill(muon->pullDxDz(station+1, MuonSubdetId::DT, Muon::SegmentArbitration, false));
00419 
00420             float distance = muon->trackDist(station+1, MuonSubdetId::DT);
00421             float error    = muon->trackDistErr(station+1, MuonSubdetId::DT);
00422             if (error == 0) error = 0.000001;
00423 
00424             if (muon->numberOfSegments(station+1, MuonSubdetId::DT, Muon::NoArbitration) > 0) {
00425                hDTDistWithSegment[station]->Fill(distance);
00426                hDTPullDistWithSegment[station]->Fill(distance/error);
00427             } else {
00428                hDTDistWithNoSegment[station]->Fill(distance);
00429                hDTPullDistWithNoSegment[station]->Fill(distance/error);
00430             }
00431 
00432             hCSCPullxPropErr[station]->Fill(muon->pullX(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, false));
00433             hCSCDdXdZ[station]->Fill(muon->dDxDz(station+1, MuonSubdetId::CSC));
00434             hCSCPulldXdZ[station]->Fill(muon->pullDxDz(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, true));
00435             hCSCPulldXdZPropErr[station]->Fill(muon->pullDxDz(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, false));
00436             hCSCPullyPropErr[station]->Fill(muon->pullY(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, false));
00437             hCSCDdYdZ[station]->Fill(muon->dDyDz(station+1, MuonSubdetId::CSC));
00438             hCSCPulldYdZ[station]->Fill(muon->pullDyDz(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, true));
00439             hCSCPulldYdZPropErr[station]->Fill(muon->pullDyDz(station+1, MuonSubdetId::CSC, Muon::SegmentArbitration, false));
00440 
00441             distance = muon->trackDist(station+1, MuonSubdetId::CSC);
00442             error    = muon->trackDistErr(station+1, MuonSubdetId::CSC);
00443             if (error == 0) error = 0.000001;
00444 
00445             if (muon->numberOfSegments(station+1, MuonSubdetId::CSC, Muon::NoArbitration) > 0) {
00446                hCSCDistWithSegment[station]->Fill(distance);
00447                hCSCPullDistWithSegment[station]->Fill(distance/error);
00448             } else {
00449                hCSCDistWithNoSegment[station]->Fill(distance);
00450                hCSCPullDistWithNoSegment[station]->Fill(distance/error);
00451             }
00452          }
00453       }
00454 
00455       if (makeAllChamberPlots_) {
00456          // by chamber
00457          for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00458                chamberMatch != muon->matches().end(); ++chamberMatch)
00459          {
00460             int station = chamberMatch->station();
00461 
00462             if (chamberMatch->detector() == MuonSubdetId::DT) {
00463                DTChamberId dtId(chamberMatch->id.rawId());
00464                int wheel  = dtId.wheel();
00465                int sector = dtId.sector();
00466 
00467                if (chamberMatch->segmentMatches.empty()) {
00468                   hDTChamberEdgeXWithNoSegment[station-1][wheel+2][sector-1]->Fill(chamberMatch->edgeX);
00469                   hDTChamberEdgeYWithNoSegment[station-1][wheel+2][sector-1]->Fill(chamberMatch->edgeY);
00470                } else {
00471                   hDTChamberEdgeXWithSegment[station-1][wheel+2][sector-1]->Fill(chamberMatch->edgeX);
00472                   hDTChamberEdgeYWithSegment[station-1][wheel+2][sector-1]->Fill(chamberMatch->edgeY);
00473 
00474                   for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00475                         segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00476                   {
00477                      if (segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR)) {
00478                         hDTChamberDx[station-1][wheel+2][sector-1]->Fill(chamberMatch->x-segmentMatch->x);
00479                         if (station < 4) hDTChamberDy[station-1][wheel+2][sector-1]->Fill(chamberMatch->y-segmentMatch->y);
00480                         break;
00481                      }
00482                   }// segmentMatch
00483                }
00484 
00485                continue;
00486             }
00487 
00488             if (chamberMatch->detector() == MuonSubdetId::CSC)  {
00489                CSCDetId cscId(chamberMatch->id.rawId());
00490                int endcap  = cscId.endcap();
00491                int ring    = cscId.ring();
00492                int chamber = cscId.chamber();
00493 
00494                if (chamberMatch->segmentMatches.empty()) {
00495                   hCSCChamberEdgeXWithNoSegment[endcap-1][station-1][ring-1][chamber-1]->Fill(chamberMatch->edgeX);
00496                   hCSCChamberEdgeYWithNoSegment[endcap-1][station-1][ring-1][chamber-1]->Fill(chamberMatch->edgeY);
00497                } else {
00498                   hCSCChamberEdgeXWithSegment[endcap-1][station-1][ring-1][chamber-1]->Fill(chamberMatch->edgeX);
00499                   hCSCChamberEdgeYWithSegment[endcap-1][station-1][ring-1][chamber-1]->Fill(chamberMatch->edgeY);
00500 
00501                   for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00502                         segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00503                   {
00504                      if (segmentMatch->isMask(MuonSegmentMatch::BestInChamberByDR)) {
00505                         hCSCChamberDx[endcap-1][station-1][ring-1][chamber-1]->Fill(chamberMatch->x-segmentMatch->x);
00506                         hCSCChamberDy[endcap-1][station-1][ring-1][chamber-1]->Fill(chamberMatch->y-segmentMatch->y);
00507                         break;
00508                      }
00509                   }// segmentMatch
00510                }
00511             }
00512          }// chamberMatch
00513       }
00514    }// muon
00515 
00516    if (! useTrackerMuons_) return;
00517 
00518    for(DTRecSegment4DCollection::const_iterator segment = dtSegmentCollectionH_->begin();
00519          segment != dtSegmentCollectionH_->end(); ++segment)
00520    {
00521       LocalPoint  segmentLocalPosition       = segment->localPosition();
00522       LocalVector segmentLocalDirection      = segment->localDirection();
00523       LocalError  segmentLocalPositionError  = segment->localPositionError();
00524       LocalError  segmentLocalDirectionError = segment->localDirectionError();
00525       const GeomDet* segmentGeomDet = geometry_->idToDet(segment->geographicalId());
00526       GlobalPoint segmentGlobalPosition = segmentGeomDet->toGlobal(segment->localPosition());
00527       bool segmentFound = false;
00528       bool segmentBestDrFound = false;
00529 
00530       for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00531             muon != muonCollectionH_->end(); ++muon)
00532       {
00533          if (! muon->isMatchesValid())
00534             continue;
00535 
00536          for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00537                chamberMatch != muon->matches().end(); ++chamberMatch) {
00538             for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00539                   segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00540             {
00541                if (fabs(segmentMatch->x       - segmentLocalPosition.x()                           ) < 1E-6 &&
00542                    fabs(segmentMatch->y       - segmentLocalPosition.y()                           ) < 1E-6 &&
00543                    fabs(segmentMatch->dXdZ    - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
00544                    fabs(segmentMatch->dYdZ    - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
00545                    fabs(segmentMatch->xErr    - sqrt(segmentLocalPositionError.xx())               ) < 1E-6 &&
00546                    fabs(segmentMatch->yErr    - sqrt(segmentLocalPositionError.yy())               ) < 1E-6 &&
00547                    fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx())              ) < 1E-6 &&
00548                    fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy())              ) < 1E-6)
00549                {
00550                   segmentFound = true;
00551                   if (segmentMatch->isMask(reco::MuonSegmentMatch::BestInStationByDR)) segmentBestDrFound = true;
00552                   break;
00553                }
00554             }// segmentMatch
00555             if (segmentFound) break;
00556          }// chamberMatch
00557          if (segmentFound) break;
00558       }// muon
00559 
00560       if (segmentFound) {
00561          hSegmentIsAssociatedBool->Fill(1.);
00562 
00563          if (make2DPlots_) {
00564             hSegmentIsAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00565             hSegmentIsAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00566 
00567             if (segmentBestDrFound) {
00568                hSegmentIsBestDrAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00569                hSegmentIsBestDrAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00570             }
00571          }
00572       } else {
00573          hSegmentIsAssociatedBool->Fill(0.);
00574 
00575          if (make2DPlots_) {
00576             hSegmentIsNotAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00577             hSegmentIsNotAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00578             hSegmentIsBestDrNotAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00579             hSegmentIsBestDrNotAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00580          }
00581       }
00582    }// dt segment
00583 
00584    for(CSCSegmentCollection::const_iterator segment = cscSegmentCollectionH_->begin();
00585          segment != cscSegmentCollectionH_->end(); ++segment)
00586    {
00587       LocalPoint  segmentLocalPosition       = segment->localPosition();
00588       LocalVector segmentLocalDirection      = segment->localDirection();
00589       LocalError  segmentLocalPositionError  = segment->localPositionError();
00590       LocalError  segmentLocalDirectionError = segment->localDirectionError();
00591       const GeomDet* segmentGeomDet = geometry_->idToDet(segment->geographicalId());
00592       GlobalPoint segmentGlobalPosition = segmentGeomDet->toGlobal(segment->localPosition());
00593       bool segmentFound = false;
00594       bool segmentBestDrFound = false;
00595 
00596       for(MuonCollection::const_iterator muon = muonCollectionH_->begin();
00597             muon != muonCollectionH_->end(); ++muon)
00598       {
00599          if (! muon->isMatchesValid())
00600             continue;
00601 
00602          for(std::vector<MuonChamberMatch>::const_iterator chamberMatch = muon->matches().begin();
00603                chamberMatch != muon->matches().end(); ++chamberMatch) {
00604             for(std::vector<MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
00605                   segmentMatch != chamberMatch->segmentMatches.end(); ++segmentMatch)
00606             {
00607                if (fabs(segmentMatch->x       - segmentLocalPosition.x()                           ) < 1E-6 &&
00608                    fabs(segmentMatch->y       - segmentLocalPosition.y()                           ) < 1E-6 &&
00609                    fabs(segmentMatch->dXdZ    - segmentLocalDirection.x()/segmentLocalDirection.z()) < 1E-6 &&
00610                    fabs(segmentMatch->dYdZ    - segmentLocalDirection.y()/segmentLocalDirection.z()) < 1E-6 &&
00611                    fabs(segmentMatch->xErr    - sqrt(segmentLocalPositionError.xx())               ) < 1E-6 &&
00612                    fabs(segmentMatch->yErr    - sqrt(segmentLocalPositionError.yy())               ) < 1E-6 &&
00613                    fabs(segmentMatch->dXdZErr - sqrt(segmentLocalDirectionError.xx())              ) < 1E-6 &&
00614                    fabs(segmentMatch->dYdZErr - sqrt(segmentLocalDirectionError.yy())              ) < 1E-6)
00615                {
00616                   segmentFound = true;
00617                   if (segmentMatch->isMask(reco::MuonSegmentMatch::BestInStationByDR)) segmentBestDrFound = true;
00618                   break;
00619                }
00620             }// segmentMatch
00621             if (segmentFound) break;
00622          }// chamberMatch
00623          if (segmentFound) break;
00624       }// muon
00625 
00626       if (segmentFound) {
00627          hSegmentIsAssociatedBool->Fill(1.);
00628 
00629          if (make2DPlots_) {
00630             hSegmentIsAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00631             hSegmentIsAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00632 
00633             if (segmentBestDrFound) {
00634                hSegmentIsBestDrAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00635                hSegmentIsBestDrAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00636             }
00637          }
00638       } else {
00639          hSegmentIsAssociatedBool->Fill(0.);
00640 
00641          if (make2DPlots_) {
00642             hSegmentIsNotAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00643             hSegmentIsNotAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00644             hSegmentIsBestDrNotAssociatedRZ->Fill(segmentGlobalPosition.z(), segmentGlobalPosition.perp());
00645             hSegmentIsBestDrNotAssociatedXY->Fill(segmentGlobalPosition.x(), segmentGlobalPosition.y());
00646          }
00647       }
00648    }// csc segment
00649 }
00650 
00651 void 
00652 MuonIdVal::endJob() {}
00653 
00654 //define this as a plug-in
00655 DEFINE_FWK_MODULE(MuonIdVal);

Generated on Tue Jun 9 17:49:25 2009 for CMSSW by  doxygen 1.5.4