CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DQMOffline/JetMET/src/BeamHaloAnalyzer.cc

Go to the documentation of this file.
00001 #include "DQMOffline/JetMET/interface/BeamHaloAnalyzer.h"
00002 #include "FWCore/ServiceRegistry/interface/Service.h"
00003 
00004 //author : Ronny Remington, University of Florida
00005 //date : 11/11/09
00006 
00007 using namespace edm;
00008 using namespace reco;
00009 
00010 int Phi_To_iPhi(float phi) 
00011 {
00012   phi = phi < 0 ? phi + 2.*TMath::Pi() : phi ;
00013   float phi_degrees = phi * (360.) / ( 2. * TMath::Pi() ) ;
00014   int iPhi = (int) ( ( phi_degrees/5. ) + 1.);
00015    
00016   return iPhi < 73 ? iPhi : 73 ;
00017 }
00018 
00019 
00020 BeamHaloAnalyzer::BeamHaloAnalyzer( const edm::ParameterSet& iConfig)
00021 {
00022   OutputFileName = iConfig.getParameter<std::string>("OutputFile"); 
00023   TextFileName   = iConfig.getParameter<std::string>("TextFile");
00024 
00025   if(TextFileName.size())
00026     out = new ofstream(TextFileName.c_str() );
00027 
00028 
00029   if( iConfig.exists("StandardDQM") )  // If StandardDQM == true , coarse binning is used on selected (important) histograms   
00030     StandardDQM = iConfig.getParameter<bool>("StandardDQM");
00031   else
00032     StandardDQM = false;
00033   
00034   //Get Input Tags
00035   //Digi Level 
00036   IT_L1MuGMTReadout = iConfig.getParameter<edm::InputTag>("L1MuGMTReadoutLabel");
00037   
00038   //RecHit Level
00039   IT_CSCRecHit   = iConfig.getParameter<edm::InputTag>("CSCRecHitLabel");
00040   IT_EBRecHit    = iConfig.getParameter<edm::InputTag>("EBRecHitLabel");
00041   IT_EERecHit    = iConfig.getParameter<edm::InputTag>("EERecHitLabel");
00042   IT_ESRecHit    = iConfig.getParameter<edm::InputTag>("ESRecHitLabel");
00043   IT_HBHERecHit  = iConfig.getParameter<edm::InputTag>("HBHERecHitLabel");
00044   IT_HFRecHit    = iConfig.getParameter<edm::InputTag>("HFRecHitLabel");
00045   IT_HORecHit    = iConfig.getParameter<edm::InputTag>("HORecHitLabel");
00046 
00047   //Higher Level Reco 
00048   IT_CSCSegment = iConfig.getParameter<edm::InputTag>("CSCSegmentLabel");  
00049   IT_CosmicStandAloneMuon = iConfig.getParameter<edm::InputTag>("CosmicStandAloneMuonLabel"); 
00050   IT_BeamHaloMuon = iConfig.getParameter<edm::InputTag>("BeamHaloMuonLabel");
00051   IT_CollisionMuon = iConfig.getParameter<edm::InputTag>("CollisionMuonLabel");
00052   IT_CollisionStandAloneMuon  = iConfig.getParameter<edm::InputTag>("CollisionStandAloneMuonLabel"); 
00053   IT_met = iConfig.getParameter<edm::InputTag>("metLabel");
00054   IT_CaloTower = iConfig.getParameter<edm::InputTag>("CaloTowerLabel");
00055   IT_SuperCluster = iConfig.getParameter<edm::InputTag>("SuperClusterLabel");
00056   IT_Photon = iConfig.getParameter<edm::InputTag>("PhotonLabel") ;
00057   
00058   //Halo Data
00059   IT_CSCHaloData = iConfig.getParameter<edm::InputTag> ("CSCHaloDataLabel");
00060   IT_EcalHaloData = iConfig.getParameter<edm::InputTag>("EcalHaloDataLabel");
00061   IT_HcalHaloData = iConfig.getParameter<edm::InputTag>("HcalHaloDataLabel");
00062   IT_GlobalHaloData = iConfig.getParameter<edm::InputTag>("GlobalHaloDataLabel");
00063   IT_BeamHaloSummary = iConfig.getParameter<edm::InputTag>("BeamHaloSummaryLabel");
00064 
00065   FolderName = iConfig.getParameter<std::string>("folderName");
00066   DumpMET = iConfig.getParameter<double>("DumpMET");
00067 }
00068 
00069 
00070 void BeamHaloAnalyzer::beginJob(void){}
00071 
00072 void BeamHaloAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& iSetup){
00073   
00074   dqm = edm::Service<DQMStore>().operator->();
00075   if( dqm ) {
00076   
00077     // EcalHaloData
00078     dqm->setCurrentFolder(FolderName+"/EcalHaloData");
00079     if(StandardDQM)
00080       {
00081         hEcalHaloData_PhiWedgeMultiplicity = dqm->book1D("EcalHaloData_PhiWedgeMultiplicity","",20, -0.5, 19.5);
00082         hEcalHaloData_PhiWedgeConstituents = dqm->book1D("EcalHaloData_PhiWedgeConstituents","",20,-0.5, 19.5);
00083         //      hEcalHaloData_PhiWedgeiPhi         = dqm->book1D("EcalHaloData_PhiWedgeiPhi","", 360, 0.5, 360.5) ;
00084         hEcalHaloData_PhiWedgeZDirectionConfidence = dqm->book1D("EcalHaloData_ZDirectionConfidence","",  120, -1.2, 1.2);
00085         hEcalHaloData_SuperClusterShowerShapes  = dqm->book2D("EcalHaloData_SuperClusterShowerShapes","", 25,0.0, TMath::Pi(), 25,0.0, 2.0);
00086         hEcalHaloData_SuperClusterEnergy = dqm->book1D("EcalHaloData_SuperClusterEnergy","",50,-0.5,99.5); 
00087         hEcalHaloData_SuperClusterNHits = dqm->book1D("EcalHaloData_SuperClusterNHits", "", 20, -0.5, 19.5);
00088       }
00089     else
00090       {
00091         hEcalHaloData_PhiWedgeMultiplicity = dqm->book1D("EcalHaloData_PhiWedgeMultiplicity","",20, -0.5, 19.5);
00092         hEcalHaloData_PhiWedgeEnergy       = dqm->book1D("EcalHaloData_PhiWedgeEnergy","", 50,-0.5,199.5);
00093         hEcalHaloData_PhiWedgeConstituents = dqm->book1D("EcalHaloData_PhiWedgeConstituents","",20,-0.5, 19.5);
00094         hEcalHaloData_PhiWedgeMinTime      = dqm->book1D("EcalHaloData_PhiWedgeMinTime","", 100, -225.0, 225.0);
00095         hEcalHaloData_PhiWedgeMaxTime      = dqm->book1D("EcalHaloData_PhiWedgeMaxTime","", 100, -225.0, 225.0);
00096         hEcalHaloData_PhiWedgeiPhi         = dqm->book1D("EcalHaloData_PhiWedgeiPhi","", 360, 0.5, 360.5) ;
00097         hEcalHaloData_PhiWedgePlusZDirectionConfidence = dqm->book1D("EcalHaloData_PlusZDirectionConfidence","",  50, 0., 1.0);
00098         hEcalHaloData_PhiWedgeZDirectionConfidence = dqm->book1D("EcalHaloData_ZDirectionConfidence","",  120, -1.2, 1.2);
00099         hEcalHaloData_PhiWedgeMinVsMaxTime = dqm->book2D("EcalHaloData_PhiWedgeMinVsMaxTime","", 50,-100.0, 100.0, 50, -100.0, 100.0);
00100         hEcalHaloData_SuperClusterShowerShapes  = dqm->book2D("EcalHaloData_SuperClusterShowerShapes","", 25,0.0, TMath::Pi(), 25,0.0, 2.0);
00101         hEcalHaloData_SuperClusterEnergy = dqm->book1D("EcalHaloData_SuperClusterEnergy","",100,-0.5,99.5); 
00102         hEcalHaloData_SuperClusterNHits = dqm->book1D("EcalHaloData_SuperClusterNHits", "", 20, -0.5, 19.5);
00103         hEcalHaloData_SuperClusterPhiVsEta = dqm->book2D("EcalHaloData_SuperClusterPhiVsEta","",60, -3.0, 3.0,72, -TMath::Pi(), TMath::Pi());  
00104       }
00105 
00106     // HcalHaloData
00107     dqm->setCurrentFolder(FolderName+"/HcalHaloData");    
00108     if( StandardDQM )
00109       { 
00110         hHcalHaloData_PhiWedgeMultiplicity = dqm->book1D("HcalHaloData_PhiWedgeMultiplicity","", 20, -0.5, 19.5);
00111         hHcalHaloData_PhiWedgeConstituents = dqm->book1D("HcalHaloData_PhiWedgeConstituents","", 20,-0.5, 19.5);
00112         //hHcalHaloData_PhiWedgeiPhi         = dqm->book1D("HcalHaloData_PhiWedgeiPhi","", 72, 0.5,72.5);
00113         hHcalHaloData_PhiWedgeZDirectionConfidence = dqm->book1D("HcalHaloData_ZDirectionConfidence","",  120, -1.2, 1.2);
00114       }
00115     else
00116       {
00117         hHcalHaloData_PhiWedgeMultiplicity = dqm->book1D("HcalHaloData_PhiWedgeMultiplicity","", 20, -0.5, 19.5);
00118         hHcalHaloData_PhiWedgeEnergy       = dqm->book1D("HcalHaloData_PhiWedgeEnergy", "", 50,-0.5,199.5);
00119         hHcalHaloData_PhiWedgeConstituents = dqm->book1D("HcalHaloData_PhiWedgeConstituents","", 20,-0.5, 19.5);
00120         hHcalHaloData_PhiWedgeiPhi         = dqm->book1D("HcalHaloData_PhiWedgeiPhi","", 72, 0.5,72.5);
00121         hHcalHaloData_PhiWedgeMinTime      = dqm->book1D("HcalHaloData_PhiWedgeMinTime", "", 50, -100.0, 100.0);
00122         hHcalHaloData_PhiWedgeMaxTime      = dqm->book1D("HcalHaloData_PhiWedgeMaxTime", "", 50, -100.0, 100.0);
00123         hHcalHaloData_PhiWedgePlusZDirectionConfidence = dqm->book1D("HcalHaloData_PlusZDirectionConfidence","",  50, 0., 1.0);
00124         hHcalHaloData_PhiWedgeZDirectionConfidence = dqm->book1D("HcalHaloData_ZDirectionConfidence","",  120, -1.2, 1.2);
00125         hHcalHaloData_PhiWedgeMinVsMaxTime = dqm->book2D("HcalHaloData_PhiWedgeMinVsMaxTime","" , 50,-100.0, 100.0, 50, -100.0, 100.0);
00126       }
00127 
00128     // CSCHaloData
00129     dqm->setCurrentFolder(FolderName+"/CSCHaloData");
00130     if( StandardDQM ) 
00131       {
00132         hCSCHaloData_TrackMultiplicity  = dqm->book1D("CSCHaloData_TrackMultiplicity", "", 15, -0.5, 14.5);
00133         hCSCHaloData_TrackMultiplicityMEPlus  = dqm->book1D("CSCHaloData_TrackMultiplicityMEPlus", "", 15, -0.5, 14.5);
00134         hCSCHaloData_TrackMultiplicityMEMinus  = dqm->book1D("CSCHaloData_TrackMultiplicityMEMinus", "", 15, -0.5, 14.5);
00135         hCSCHaloData_InnerMostTrackHitR  = dqm->book1D("CSCHaloData_InnerMostTrackHitR", "", 70, 99.5, 799.5);
00136         hCSCHaloData_InnerMostTrackHitPhi  = dqm->book1D("CSCHaloData_InnerMostTrackHitPhi","", 72, -TMath::Pi(), TMath::Pi());
00137         hCSCHaloData_L1HaloTriggersMEPlus  = dqm->book1D("CSCHaloData_L1HaloTriggersMEPlus", "", 10, -0.5, 9.5);
00138         hCSCHaloData_L1HaloTriggersMEMinus  = dqm->book1D("CSCHaloData_L1HaloTriggersMEMinus", "" , 10, -0.5, 9.5);
00139         hCSCHaloData_L1HaloTriggers  = dqm->book1D("CSCHaloData_L1HaloTriggers", "", 10, -0.5, 9.5);
00140         hCSCHaloData_HLHaloTriggers  = dqm->book1D("CSCHaloData_HLHaloTriggers", "", 2, -0.5, 1.5);
00141         hCSCHaloData_NOutOfTimeTriggersvsL1HaloExists  = dqm->book2D("CSCHaloData_NOutOfTimeTriggersvsL1HaloExists", "", 20, -0.5, 19.5, 2, -0.5, 1.5);
00142         hCSCHaloData_NOutOfTimeTriggersMEPlus  = dqm->book1D("CSCHaloData_NOutOfTimeTriggersMEPlus", "", 20, -0.5, 19.5);
00143         hCSCHaloData_NOutOfTimeTriggersMEMinus  = dqm->book1D("CSCHaloData_NOutOfTimeTriggersMEMinus", "", 20, -0.5, 19.5);
00144         hCSCHaloData_NOutOfTimeTriggers  = dqm->book1D("CSCHaloData_NOutOfTimeTriggers", "", 20, -0.5, 19.5);
00145         hCSCHaloData_NOutOfTimeHits  = dqm->book1D("CSCHaloData_NOutOfTimeHits", "", 60, -0.5, 59.5);
00146       }
00147     else 
00148       {
00149         hCSCHaloData_TrackMultiplicity  = dqm->book1D("CSCHaloData_TrackMultiplicity", "", 15, -0.5, 14.5);
00150         hCSCHaloData_TrackMultiplicityMEPlus  = dqm->book1D("CSCHaloData_TrackMultiplicityMEPlus", "", 15, -0.5, 14.5);
00151         hCSCHaloData_TrackMultiplicityMEMinus  = dqm->book1D("CSCHaloData_TrackMultiplicityMEMinus", "", 15, -0.5, 14.5);
00152         hCSCHaloData_InnerMostTrackHitXY  = dqm->book2D("CSCHaloData_InnerMostTrackHitXY","", 100,-700,700,100, -700,700);
00153         hCSCHaloData_InnerMostTrackHitR  = dqm->book1D("CSCHaloData_InnerMostTrackHitR", "", 400, -0.5, 799.5);
00154         hCSCHaloData_InnerMostTrackHitRPlusZ = dqm->book2D("CSCHaloData_InnerMostTrackHitRPlusZ","", 400 , 400, 1200, 400, -0.5, 799.5 );
00155         hCSCHaloData_InnerMostTrackHitRMinusZ = dqm->book2D("CSCHaloData_InnerMostTrackHitRMinusZ","", 400 , -1200, -400, 400, -0.5, 799.5 );
00156         hCSCHaloData_InnerMostTrackHitiPhi  = dqm->book1D("CSCHaloData_InnerMostTrackHitiPhi","", 72, 0.5, 72.5);
00157         hCSCHaloData_InnerMostTrackHitPhi  = dqm->book1D("CSCHaloData_InnerMostTrackHitPhi","", 72, -TMath::Pi(), TMath::Pi());
00158         hCSCHaloData_L1HaloTriggersMEPlus  = dqm->book1D("CSCHaloData_L1HaloTriggersMEPlus", "", 10, -0.5, 9.5);
00159         hCSCHaloData_L1HaloTriggersMEMinus  = dqm->book1D("CSCHaloData_L1HaloTriggersMEMinus", "" , 10, -0.5, 9.5);
00160         hCSCHaloData_L1HaloTriggers  = dqm->book1D("CSCHaloData_L1HaloTriggers", "", 10, -0.5, 9.5);
00161         hCSCHaloData_HLHaloTriggers  = dqm->book1D("CSCHaloData_HLHaloTriggers", "", 2, -0.5, 1.5);
00162         hCSCHaloData_NOutOfTimeTriggersvsL1HaloExists  = dqm->book2D("CSCHaloData_NOutOfTimeTriggersvsL1HaloExists", "", 20, -0.5, 19.5, 2, -0.5, 1.5);
00163         hCSCHaloData_NOutOfTimeTriggers  = dqm->book1D("CSCHaloData_NOutOfTimeTriggers", "", 20, -0.5, 19.5);
00164         hCSCHaloData_NOutOfTimeHits  = dqm->book1D("CSCHaloData_NOutOfTimeHits", "", 60, -0.5, 59.5);
00165       }
00166 
00167     // GlobalHaloData
00168     dqm->setCurrentFolder(FolderName+"/GlobalHaloData");
00169     if(!StandardDQM)
00170       {
00171         hGlobalHaloData_MExCorrection  = dqm->book1D("GlobalHaloData_MExCorrection", "" , 200, -200., 200.);
00172         hGlobalHaloData_MEyCorrection  = dqm->book1D("GlobalHaloData_MEyCorrection", "" , 200, -200., 200.);
00173         hGlobalHaloData_SumEtCorrection = dqm->book1D("GlobalHaloData_SumEtCorrection", "" , 200, -0.5, 399.5);
00174         hGlobalHaloData_HaloCorrectedMET = dqm->book1D("GlobalHaloData_HaloCorrectedMET", "" , 500, -0.5, 1999.5);
00175         hGlobalHaloData_RawMETMinusHaloCorrectedMET = dqm->book1D("GlobalHaloData_RawMETMinusHaloCorrectedMET","" , 250, -500., 500.);
00176         hGlobalHaloData_RawMETOverSumEt  = dqm->book1D("GlobalHaloData_RawMETOverSumEt","" , 100, 0.0, 1.0);
00177         hGlobalHaloData_MatchedHcalPhiWedgeMultiplicity = dqm->book1D("GlobalHaloData_MatchedHcalPhiWedgeMultiplicity","", 15, -0.5, 14.5);    
00178         hGlobalHaloData_MatchedHcalPhiWedgeEnergy       = dqm->book1D("GlobalHaloData_MatchedHcalPhiWedgeEnergy", "", 50,-0.5,199.5);
00179         hGlobalHaloData_MatchedHcalPhiWedgeConstituents = dqm->book1D("GlobalHaloData_MatchedHcalPhiWedgeConstituents","", 20,-0.5, 19.5);
00180         hGlobalHaloData_MatchedHcalPhiWedgeiPhi         = dqm->book1D("GlobalHaloData_MatchedHcalPhiWedgeiPhi","", 1, 0.5,72.5);
00181         hGlobalHaloData_MatchedHcalPhiWedgeMinTime      = dqm->book1D("GlobalHaloData_MatchedHcalPhiWedgeMinTime", "", 50, -100.0, 100.0);
00182         hGlobalHaloData_MatchedHcalPhiWedgeMaxTime      = dqm->book1D("GlobalHaloData_MatchedHcalPhiWedgeMaxTime", "", 50, -100.0, 100.0);
00183         hGlobalHaloData_MatchedHcalPhiWedgeZDirectionConfidence = dqm->book1D("GlobalHaloData_MatchedHcalPhiWedgeZDirectionConfidence","",  120, -1.2, 1.2);
00184         hGlobalHaloData_MatchedEcalPhiWedgeMultiplicity = dqm->book1D("GlobalHaloData_MatchedEcalPhiWedgeMultiplicity","", 15, -0.5, 14.5);
00185         hGlobalHaloData_MatchedEcalPhiWedgeEnergy       = dqm->book1D("GlobalHaloData_MatchedEcalPhiWedgeEnergy", "", 50,-0.5,199.5);
00186         hGlobalHaloData_MatchedEcalPhiWedgeConstituents = dqm->book1D("GlobalHaloData_MatchedEcalPhiWedgeConstituents","", 20,-0.5, 19.5);
00187         hGlobalHaloData_MatchedEcalPhiWedgeiPhi         = dqm->book1D("GlobalHaloData_MatchedEcalPhiWedgeiPhi","", 360, 0.5,360.5);
00188         hGlobalHaloData_MatchedEcalPhiWedgeMinTime      = dqm->book1D("GlobalHaloData_MatchedEcalPhiWedgeMinTime", "", 50, -100.0, 100.0);
00189         hGlobalHaloData_MatchedEcalPhiWedgeMaxTime      = dqm->book1D("GlobalHaloData_MatchedEcalPhiWedgeMaxTime", "", 50, -100.0, 100.0);
00190         hGlobalHaloData_MatchedEcalPhiWedgeZDirectionConfidence = dqm->book1D("GlobalHaloData_MatchedEcalPhiWedgeZDirectionConfidence","",  120, 1.2, 1.2);
00191       }
00192     // BeamHaloSummary 
00193     dqm->setCurrentFolder(FolderName+"/BeamHaloSummary");
00194 
00195     hBeamHaloSummary_Id = dqm->book1D("BeamHaloSumamry_Id", "", 11, 0.5,11.5);
00196     hBeamHaloSummary_Id ->setBinLabel(1,"CSC Loose");
00197     hBeamHaloSummary_Id ->setBinLabel(2,"CSC Tight");
00198     hBeamHaloSummary_Id ->setBinLabel(3,"Ecal Loose");
00199     hBeamHaloSummary_Id ->setBinLabel(4,"Ecal Tight");
00200     hBeamHaloSummary_Id ->setBinLabel(5,"Hcal Loose");
00201     hBeamHaloSummary_Id ->setBinLabel(6,"Hcal Tight");
00202     hBeamHaloSummary_Id ->setBinLabel(7,"Global Loose");
00203     hBeamHaloSummary_Id ->setBinLabel(8,"Global Tight");
00204     hBeamHaloSummary_Id ->setBinLabel(9,"Event Loose");
00205     hBeamHaloSummary_Id ->setBinLabel(10,"Event Tight");
00206     hBeamHaloSummary_Id ->setBinLabel(11,"Nothing");
00207     if(!StandardDQM)
00208       {
00209         hBeamHaloSummary_BXN = dqm->book2D("BeamHaloSummary_BXN", "",11, 0.5, 11.5, 4000, -0.5,3999.5);
00210         hBeamHaloSummary_BXN ->setBinLabel(1,"CSC Loose");
00211         hBeamHaloSummary_BXN ->setBinLabel(2,"CSC Tight");
00212         hBeamHaloSummary_BXN ->setBinLabel(3,"Ecal Loose");
00213         hBeamHaloSummary_BXN ->setBinLabel(4,"Ecal Tight");
00214         hBeamHaloSummary_BXN ->setBinLabel(5,"Hcal Loose");
00215         hBeamHaloSummary_BXN ->setBinLabel(6,"Hcal Tight");
00216         hBeamHaloSummary_BXN ->setBinLabel(7,"Global Loose");
00217         hBeamHaloSummary_BXN ->setBinLabel(8,"Global Tight");
00218         hBeamHaloSummary_BXN ->setBinLabel(9,"Event Loose");
00219         hBeamHaloSummary_BXN ->setBinLabel(10,"Event Tight");
00220         hBeamHaloSummary_BXN ->setBinLabel(11,"Nothing");
00221       }
00222     // Extra
00223     dqm->setCurrentFolder(FolderName+"/ExtraHaloData");
00224     if(StandardDQM)
00225       {
00226         hExtra_CSCTrackInnerOuterDPhi = dqm->book1D("Extra_CSCTrackInnerOuterDPhi","",100, 0, TMath::Pi() );
00227         hExtra_CSCTrackInnerOuterDEta = dqm->book1D("Extra_CSCTrackInnerOuterDEta","", 100, 0, 3.0 );
00228         hExtra_CSCTrackChi2Ndof  = dqm->book1D("Extra_CSCTrackChi2Ndof","", 25, 0, 10);
00229         hExtra_CSCTrackNHits     = dqm->book1D("Extra_CSCTrackNHits","", 75,0, 75);
00230         hExtra_CSCActivityWithMET= dqm->book2D("Extra_CSCActivityWithMET", "", 4, 0.5, 4.5, 4, 0.5, 4.5);
00231         hExtra_CSCActivityWithMET->setBinLabel(1,"Track",1);
00232         hExtra_CSCActivityWithMET->setBinLabel(1,"Track",2);
00233         hExtra_CSCActivityWithMET->setBinLabel(2, "Segments",1);
00234         hExtra_CSCActivityWithMET->setBinLabel(2, "Segments",2);
00235         hExtra_CSCActivityWithMET->setBinLabel(3, "RecHits", 1);
00236         hExtra_CSCActivityWithMET->setBinLabel(3, "RecHits", 2);
00237         hExtra_CSCActivityWithMET->setBinLabel(4, "Nothing", 1);
00238         hExtra_CSCActivityWithMET->setBinLabel(4, "Nothing", 2);
00239         hExtra_InnerMostTrackHitR  = dqm->book1D("Extra_InnerMostTrackHitR", "", 70, 99.5, 799.5);
00240         hExtra_InnerMostTrackHitPhi  = dqm->book1D("Extra_InnerMostTrackHitPhi","", 72, -TMath::Pi(), TMath::Pi());
00241       }
00242     else 
00243       {
00244         hExtra_CSCActivityWithMET= dqm->book2D("Extra_CSCActivityWithMET", "", 4, 0.5, 4.5, 4, 0.5, 4.5);
00245         hExtra_CSCActivityWithMET->setBinLabel(1,"Track",1);
00246         hExtra_CSCActivityWithMET->setBinLabel(1,"Track",2);
00247         hExtra_CSCActivityWithMET->setBinLabel(2, "Segments",1);
00248         hExtra_CSCActivityWithMET->setBinLabel(2, "Segments",2);
00249         hExtra_CSCActivityWithMET->setBinLabel(3, "RecHits", 1);
00250         hExtra_CSCActivityWithMET->setBinLabel(3, "RecHits", 2);
00251         hExtra_CSCActivityWithMET->setBinLabel(4, "Nothing", 1);
00252         hExtra_CSCActivityWithMET->setBinLabel(4, "Nothing", 2);
00253         hExtra_HcalToF  = dqm->book2D("Extra_HcalToF","" , 83,-41.5,41.5 , 1000, -125., 125.); 
00254         hExtra_HcalToF_HaloId  = dqm->book2D("Extra_HcalToF_HaloId","", 83,-41.5,41.5 , 1000, -125., 125.); 
00255         hExtra_EcalToF  = dqm->book2D("Extra_EcalToF","",  171,-85.5,85.5 , 2000, -225., 225.); 
00256         hExtra_EcalToF_HaloId  = dqm->book2D("Extra_EcalToF_HaloId","",  171,-85.5,85.5 , 2000, -225., 225.); 
00257         hExtra_CSCTrackInnerOuterDPhi = dqm->book1D("Extra_CSCTrackInnerOuterDPhi","",100, 0, TMath::Pi() );
00258         hExtra_CSCTrackInnerOuterDEta = dqm->book1D("Extra_CSCTrackInnerOuterDEta","", 100, 0, TMath::Pi() );
00259         hExtra_CSCTrackChi2Ndof  = dqm->book1D("Extra_CSCTrackChi2Ndof","", 100, 0, 10);
00260         hExtra_CSCTrackNHits     = dqm->book1D("Extra_CSCTrackNHits","", 75,0, 75);
00261         hExtra_InnerMostTrackHitXY  = dqm->book2D("Extra_InnerMostTrackHitXY","", 100,-700,700,100, -700,700);
00262         hExtra_InnerMostTrackHitR  = dqm->book1D("Extra_InnerMostTrackHitR", "", 400, -0.5, 799.5);
00263         hExtra_InnerMostTrackHitRPlusZ = dqm->book2D("Extra_InnerMostTrackHitRPlusZ","", 400 , 400, 1200, 400, -0.5, 799.5 );
00264         hExtra_InnerMostTrackHitRMinusZ = dqm->book2D("Extra_InnerMostTrackHitRMinusZ","", 400 , -1200, -400, 400, -0.5, 799.5 );
00265         hExtra_InnerMostTrackHitiPhi  = dqm->book1D("Extra_InnerMostTrackHitiPhi","", 72, 0.5, 72.5);
00266         hExtra_InnerMostTrackHitPhi  = dqm->book1D("Extra_InnerMostTrackHitPhi","", 72, -TMath::Pi(), TMath::Pi());
00267         hExtra_BXN = dqm->book1D("Extra_BXN", "BXN Occupancy", 4000, 0.5, 4000.5);
00268       }
00269   }
00270 }
00271 
00272 void BeamHaloAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00273 {
00274   EventID TheEvent = iEvent.id();
00275   int BXN = iEvent.bunchCrossing() ;
00276   bool Dump = TextFileName.size();
00277   int TheEventNumber = TheEvent.event();
00278   int Lumi = iEvent.luminosityBlock();
00279   int Run  = iEvent.run();
00280 
00281   //Get CSC Geometry
00282   edm::ESHandle<CSCGeometry> TheCSCGeometry;
00283   iSetup.get<MuonGeometryRecord>().get(TheCSCGeometry);
00284 
00285   //Get CaloGeometry
00286   edm::ESHandle<CaloGeometry> TheCaloGeometry;
00287   iSetup.get<CaloGeometryRecord>().get(TheCaloGeometry);
00288 
00289   //Get Stand-alone Muons from Cosmic Muon Reconstruction
00290   edm::Handle< reco::TrackCollection > TheCosmics;
00291   iEvent.getByLabel(IT_CosmicStandAloneMuon, TheCosmics);
00292   bool CSCTrackPlus = false; bool CSCTrackMinus = false;
00293   if( TheCosmics.isValid() )
00294     {
00295       for( reco::TrackCollection::const_iterator cosmic = TheCosmics ->begin() ; cosmic != TheCosmics->end() ; cosmic++ )
00296         {
00297           if( !CSCTrackPlus || !CSCTrackMinus )
00298             {
00299               if( cosmic->eta() > 0 || cosmic->outerPosition().z() > 0  || cosmic->innerPosition().z() > 0 ) CSCTrackPlus = true ;
00300               else if( cosmic->eta() < 0 || cosmic->outerPosition().z() < 0 || cosmic->innerPosition().z() < 0) CSCTrackMinus = true;
00301             }
00302           
00303           float innermost_phi = 0.;
00304           float outermost_phi = 0.;
00305           float innermost_z = 99999.;
00306           float outermost_z = 0.;
00307           float innermost_eta = 0.;
00308           float outermost_eta = 0.;
00309           float innermost_x =0.;
00310           float innermost_y =0.;
00311           float innermost_r =0.;
00312           for(unsigned int j = 0 ; j < cosmic->extra()->recHits().size(); j++ )
00313             {
00314               edm::Ref<TrackingRecHitCollection> hit( cosmic->extra()->recHits(), j );
00315               DetId TheDetUnitId(hit->geographicalId());
00316               if( TheDetUnitId.det() != DetId::Muon ) continue;
00317               if( TheDetUnitId.subdetId() != MuonSubdetId::CSC ) continue;
00318 
00319               const GeomDetUnit *TheUnit = TheCSCGeometry->idToDetUnit(TheDetUnitId);
00320               LocalPoint TheLocalPosition = hit->localPosition();  
00321               const BoundPlane& TheSurface = TheUnit->surface();
00322               const GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
00323               
00324               float z = TheGlobalPosition.z();
00325               if( TMath::Abs(z) < innermost_z )
00326                 {
00327                   innermost_phi = TheGlobalPosition.phi();
00328                   innermost_eta = TheGlobalPosition.eta();
00329                   innermost_z   = TheGlobalPosition.z();
00330                   innermost_x   = TheGlobalPosition.x();
00331                   innermost_y   = TheGlobalPosition.y();
00332                   innermost_r = TMath::Sqrt( innermost_x*innermost_x + innermost_y*innermost_y );
00333                 }
00334               if( TMath::Abs(z) > outermost_z)
00335                 {
00336                   outermost_phi = TheGlobalPosition.phi() ;
00337                   outermost_eta = TheGlobalPosition.eta() ;
00338                   outermost_z   = TheGlobalPosition.z();
00339                 }
00340             }
00341           float dphi = TMath::Abs( outermost_phi - innermost_phi );
00342           float deta = TMath::Abs( outermost_eta - innermost_eta );
00343           hExtra_CSCTrackInnerOuterDPhi -> Fill( dphi );
00344           hExtra_CSCTrackInnerOuterDEta -> Fill( deta ); 
00345           hExtra_CSCTrackChi2Ndof  -> Fill(cosmic->normalizedChi2() );
00346           hExtra_CSCTrackNHits     -> Fill(cosmic->numberOfValidHits() );
00347           hExtra_InnerMostTrackHitR  ->Fill(innermost_r);
00348           hExtra_InnerMostTrackHitPhi ->Fill(innermost_phi);      
00349           if( !StandardDQM )
00350             {
00351               hExtra_InnerMostTrackHitXY  ->Fill(innermost_x, innermost_y);
00352               hExtra_InnerMostTrackHitiPhi ->Fill(Phi_To_iPhi(innermost_phi));        
00353               if(innermost_z > 0 ) 
00354                 hExtra_InnerMostTrackHitRPlusZ ->Fill(innermost_z, innermost_r);
00355               else 
00356                 hExtra_InnerMostTrackHitRMinusZ ->Fill(innermost_z, innermost_r);
00357             }
00358         }
00359     }
00360   
00361   //Get CSC Segments
00362   edm::Handle<CSCSegmentCollection> TheCSCSegments;
00363   iEvent.getByLabel(IT_CSCSegment, TheCSCSegments);
00364 
00365   // Group segments according to endcaps
00366   std::vector< CSCSegment> vCSCSegments_Plus;
00367   std::vector< CSCSegment> vCSCSegments_Minus;
00368 
00369   bool CSCSegmentPlus = false; 
00370   bool CSCSegmentMinus=false;
00371   if( TheCSCSegments.isValid() ) 
00372     {
00373       for(CSCSegmentCollection::const_iterator iSegment = TheCSCSegments->begin(); iSegment != TheCSCSegments->end(); iSegment++) 
00374         {
00375           const std::vector<CSCRecHit2D> vCSCRecHits = iSegment->specificRecHits();
00376           CSCDetId iDetId  = (CSCDetId)(*iSegment).cscDetId();
00377           
00378           if ( iDetId.endcap() == 1 ) vCSCSegments_Plus.push_back( *iSegment );
00379           else vCSCSegments_Minus.push_back( *iSegment );
00380         }      
00381     }
00382   
00383   // Are there segments on the plus/minus side?  
00384   if( vCSCSegments_Plus.size() ) CSCSegmentPlus = true;
00385   if( vCSCSegments_Minus.size() ) CSCSegmentMinus = true;
00386 
00387   //Get CSC RecHits
00388   Handle<CSCRecHit2DCollection> TheCSCRecHits;
00389   iEvent.getByLabel(IT_CSCRecHit, TheCSCRecHits);
00390   bool CSCRecHitPlus = false; 
00391   bool CSCRecHitMinus = false;
00392   if( TheCSCRecHits.isValid() )
00393     {
00394       for(CSCRecHit2DCollection::const_iterator iCSCRecHit = TheCSCRecHits->begin();   iCSCRecHit != TheCSCRecHits->end(); iCSCRecHit++ )
00395         {
00396           DetId TheDetUnitId(iCSCRecHit->geographicalId());
00397           const GeomDetUnit *TheUnit = (*TheCSCGeometry).idToDetUnit(TheDetUnitId);
00398           LocalPoint TheLocalPosition = iCSCRecHit->localPosition();
00399           const BoundPlane& TheSurface = TheUnit->surface();
00400           GlobalPoint TheGlobalPosition = TheSurface.toGlobal(TheLocalPosition);
00401 
00402           //Are there hits on the plus/minus side?
00403           if ( TheGlobalPosition.z() > 0 ) CSCRecHitPlus = true;
00404           else CSCRecHitMinus = true;
00405         }
00406     }
00407   
00408   //Get  EB RecHits
00409   edm::Handle<EBRecHitCollection> TheEBRecHits;
00410   iEvent.getByLabel(IT_EBRecHit, TheEBRecHits);
00411   int EBHits=0;
00412   if( TheEBRecHits.isValid() )
00413     {
00414       for( EBRecHitCollection::const_iterator iEBRecHit = TheEBRecHits->begin() ; iEBRecHit != TheEBRecHits->end(); iEBRecHit++)
00415         {
00416           if( iEBRecHit->energy() < 0.5 ) continue;
00417           DetId id = DetId( iEBRecHit->id() ) ;
00418           EBDetId EcalId ( id.rawId() );
00419           int ieta = EcalId.ieta() ;
00420           if(!StandardDQM)
00421             hExtra_EcalToF ->Fill(ieta, iEBRecHit->time() );
00422           EBHits++;
00423         }
00424     }
00425   
00426 
00427   //Get HB/HE RecHits
00428   edm::Handle<HBHERecHitCollection> TheHBHERecHits;
00429   iEvent.getByLabel(IT_HBHERecHit, TheHBHERecHits);
00430   if( TheHBHERecHits.isValid() )
00431     {
00432       for( HBHERecHitCollection::const_iterator iHBHERecHit = TheHBHERecHits->begin(); iHBHERecHit != TheHBHERecHits->end(); iHBHERecHit++)  
00433         {
00434           if( iHBHERecHit->energy() < 1.) continue;
00435           HcalDetId id = HcalDetId( iHBHERecHit->id() );
00436           if(!StandardDQM)
00437             hExtra_HcalToF->Fill( id.ieta(), iHBHERecHit->time() ) ;
00438         }
00439     }
00440 
00441   //Get MET
00442   edm::Handle< reco::CaloMETCollection > TheCaloMET;
00443   iEvent.getByLabel(IT_met, TheCaloMET);
00444 
00445   //Get CSCHaloData
00446   edm::Handle<reco::CSCHaloData> TheCSCDataHandle;
00447   iEvent.getByLabel(IT_CSCHaloData,TheCSCDataHandle);
00448   int TheHaloOrigin = 0;
00449   if (TheCSCDataHandle.isValid())
00450     {
00451       const CSCHaloData CSCData = (*TheCSCDataHandle.product());
00452       if( CSCData.NumberOfOutOfTimeTriggers(HaloData::plus) && !CSCData.NumberOfOutOfTimeTriggers(HaloData::minus) ) 
00453         TheHaloOrigin = 1;
00454       else if ( CSCData.NumberOfOutOfTimeTriggers(HaloData::minus) && !CSCData.NumberOfOutOfTimeTriggers(HaloData::plus))
00455         TheHaloOrigin = -1 ;
00456 
00457       for( std::vector<GlobalPoint>::const_iterator i=CSCData.GetCSCTrackImpactPositions().begin();  i != CSCData.GetCSCTrackImpactPositions().end() ; i++ )   
00458         {                          
00459           float r = TMath::Sqrt( i->x()*i->x() + i->y()*i->y() );
00460           if( !StandardDQM )
00461             {
00462               hCSCHaloData_InnerMostTrackHitXY->Fill( i->x(), i->y() );
00463               hCSCHaloData_InnerMostTrackHitiPhi  ->Fill( Phi_To_iPhi( i->phi())); 
00464               if( i->z() > 0 ) 
00465                 hCSCHaloData_InnerMostTrackHitRPlusZ ->Fill(i->z(), r) ;
00466               else
00467                 hCSCHaloData_InnerMostTrackHitRMinusZ ->Fill(i->z(), r) ;
00468             }
00469           hCSCHaloData_InnerMostTrackHitR  ->Fill(r);
00470           hCSCHaloData_InnerMostTrackHitPhi  ->Fill( i->phi()); 
00471         }
00472       hCSCHaloData_L1HaloTriggersMEPlus   -> Fill ( CSCData.NumberOfHaloTriggers(HaloData::plus) );
00473       hCSCHaloData_L1HaloTriggersMEMinus  -> Fill ( CSCData.NumberOfHaloTriggers(HaloData::minus));
00474       hCSCHaloData_L1HaloTriggers  -> Fill ( CSCData.NumberOfHaloTriggers(HaloData::both));
00475       hCSCHaloData_HLHaloTriggers  -> Fill ( CSCData.CSCHaloHLTAccept());
00476       hCSCHaloData_TrackMultiplicityMEPlus ->Fill ( CSCData.NumberOfHaloTracks(HaloData::plus) );
00477       hCSCHaloData_TrackMultiplicityMEMinus ->Fill ( CSCData.NumberOfHaloTracks(HaloData::minus) );
00478       hCSCHaloData_TrackMultiplicity->Fill( CSCData.GetTracks().size() );
00479       hCSCHaloData_NOutOfTimeTriggersMEPlus->Fill( CSCData.NOutOfTimeTriggers(HaloData::plus) );
00480       hCSCHaloData_NOutOfTimeTriggersMEMinus->Fill( CSCData.NOutOfTimeTriggers(HaloData::minus) );
00481       hCSCHaloData_NOutOfTimeTriggers->Fill( CSCData.NOutOfTimeTriggers(HaloData::both) );
00482       hCSCHaloData_NOutOfTimeHits->Fill( CSCData.NOutOfTimeHits() );
00483       hCSCHaloData_NOutOfTimeTriggersvsL1HaloExists->Fill( CSCData.NOutOfTimeTriggers(HaloData::both), CSCData.NumberOfHaloTriggers(HaloData::both) >0 );
00484     }
00485 
00486   //Get EcalHaloData 
00487   edm::Handle<reco::EcalHaloData> TheEcalHaloData;
00488   iEvent.getByLabel(IT_EcalHaloData, TheEcalHaloData );
00489   if( TheEcalHaloData.isValid() ) 
00490     {
00491       const EcalHaloData EcalData = (*TheEcalHaloData.product()); 
00492       std::vector<PhiWedge> EcalWedges = EcalData.GetPhiWedges();                                                                                              
00493       for(std::vector<PhiWedge>::const_iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end(); iWedge ++ )                                  
00494         {                                                                                                                                                     
00495           if(!StandardDQM ) 
00496             {
00497               hEcalHaloData_PhiWedgeEnergy->Fill( iWedge->Energy() );
00498               hEcalHaloData_PhiWedgeMinTime     ->Fill( iWedge->MinTime() );
00499               hEcalHaloData_PhiWedgeMaxTime     ->Fill( iWedge->MaxTime() );
00500               hEcalHaloData_PhiWedgeMinVsMaxTime->Fill(iWedge->MinTime() , iWedge->MaxTime() ) ;
00501               hEcalHaloData_PhiWedgePlusZDirectionConfidence->Fill( iWedge->PlusZDirectionConfidence() );
00502               hEcalHaloData_PhiWedgeiPhi->Fill(iWedge->iPhi() ) ;
00503             }
00504           hEcalHaloData_PhiWedgeZDirectionConfidence ->Fill( iWedge->ZDirectionConfidence() );
00505           hEcalHaloData_PhiWedgeConstituents->Fill( iWedge->NumberOfConstituents() ) ;
00506         }      
00507 
00508       hEcalHaloData_PhiWedgeMultiplicity->Fill( EcalWedges.size() );
00509 
00510       edm::ValueMap<float> vm_Angle = EcalData.GetShowerShapesAngle();
00511       edm::ValueMap<float> vm_Roundness = EcalData.GetShowerShapesRoundness();
00512       //Access selected SuperClusters
00513       for(unsigned int n = 0 ; n < EcalData.GetSuperClusters().size() ; n++ )
00514         {
00515           edm::Ref<SuperClusterCollection> cluster(EcalData.GetSuperClusters(), n );
00516           float angle = vm_Angle[cluster];
00517           float roundness = vm_Roundness[cluster];
00518           hEcalHaloData_SuperClusterShowerShapes->Fill(angle, roundness);
00519           hEcalHaloData_SuperClusterNHits->Fill( cluster->size() );
00520           hEcalHaloData_SuperClusterEnergy->Fill(cluster->energy() );
00521 
00522           if(!StandardDQM)
00523             {
00524               hEcalHaloData_SuperClusterPhiVsEta->Fill(cluster->eta() ,cluster->phi() );
00525             }
00526         }
00527     }
00528 
00529   //Get HcalHaloData
00530   edm::Handle<reco::HcalHaloData> TheHcalHaloData;
00531   iEvent.getByLabel(IT_HcalHaloData ,TheHcalHaloData );
00532   if( TheHcalHaloData.isValid( ) )
00533     {
00534       const HcalHaloData HcalData = (*TheHcalHaloData.product());                                                                
00535       std::vector<PhiWedge> HcalWedges = HcalData.GetPhiWedges();                                                                                   
00536       hHcalHaloData_PhiWedgeMultiplicity ->Fill( HcalWedges.size() );
00537       for(std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end(); iWedge ++ )                               
00538         {
00539           if( !StandardDQM ) 
00540             {
00541               hHcalHaloData_PhiWedgeEnergy       ->Fill( iWedge->Energy() );
00542               hHcalHaloData_PhiWedgeMinTime      ->Fill( iWedge->MinTime() );
00543               hHcalHaloData_PhiWedgeMaxTime      ->Fill( iWedge->MaxTime() );
00544               hHcalHaloData_PhiWedgePlusZDirectionConfidence ->Fill( iWedge->PlusZDirectionConfidence() );
00545               hHcalHaloData_PhiWedgeMinVsMaxTime  ->Fill( iWedge->MinTime() , iWedge->MaxTime() );
00546               hHcalHaloData_PhiWedgeiPhi         ->Fill( iWedge->iPhi() );
00547             }     
00548           
00549           hHcalHaloData_PhiWedgeConstituents ->Fill( iWedge->NumberOfConstituents() );
00550           hHcalHaloData_PhiWedgeZDirectionConfidence ->Fill( iWedge->ZDirectionConfidence() );
00551         }
00552     }
00553   
00554 
00555   if(!StandardDQM)
00556     {
00557       //Get GlobalHaloData
00558       edm::Handle<reco::GlobalHaloData> TheGlobalHaloData;
00559       iEvent.getByLabel(IT_GlobalHaloData, TheGlobalHaloData );
00560       if( TheGlobalHaloData.isValid() ) 
00561         {
00562           const GlobalHaloData GlobalData =(*TheGlobalHaloData.product());                                                           
00563           if( TheCaloMET.isValid() ) 
00564             {
00565               // Get Raw Uncorrected CaloMET
00566               const CaloMETCollection *calometcol = TheCaloMET.product();
00567               const CaloMET *RawMET = &(calometcol->front());
00568               
00569               // Get BeamHalo Corrected CaloMET 
00570               const CaloMET CorrectedMET = GlobalData.GetCorrectedCaloMET(*RawMET);
00571               hGlobalHaloData_MExCorrection  ->Fill( GlobalData.DeltaMEx() );
00572               hGlobalHaloData_MEyCorrection  ->Fill( GlobalData.DeltaMEy() );
00573               hGlobalHaloData_HaloCorrectedMET->Fill(CorrectedMET.pt() );
00574               hGlobalHaloData_RawMETMinusHaloCorrectedMET ->Fill( RawMET->pt() - CorrectedMET.pt() );
00575               if( RawMET->sumEt() )
00576                 hGlobalHaloData_RawMETOverSumEt ->Fill( RawMET->pt() / RawMET->sumEt() ); 
00577               
00578             }                
00579           
00580           // Get Matched Hcal Phi Wedges
00581           std::vector<PhiWedge> HcalWedges = GlobalData.GetMatchedHcalPhiWedges();
00582           hGlobalHaloData_MatchedHcalPhiWedgeMultiplicity ->Fill(HcalWedges.size());
00583           // Loop over Matched Hcal Phi Wedges
00584           for( std::vector<PhiWedge>::const_iterator iWedge = HcalWedges.begin() ; iWedge != HcalWedges.end() ; iWedge ++ )
00585             {
00586               hGlobalHaloData_MatchedHcalPhiWedgeEnergy       ->Fill( iWedge->Energy() );
00587               hGlobalHaloData_MatchedHcalPhiWedgeConstituents ->Fill( iWedge->NumberOfConstituents());
00588               hGlobalHaloData_MatchedHcalPhiWedgeiPhi         ->Fill( iWedge->iPhi() );
00589               hGlobalHaloData_MatchedHcalPhiWedgeMinTime      ->Fill( iWedge->MinTime() );
00590               hGlobalHaloData_MatchedHcalPhiWedgeMaxTime      ->Fill( iWedge->MaxTime() );
00591               hGlobalHaloData_MatchedHcalPhiWedgeZDirectionConfidence ->Fill( iWedge->ZDirectionConfidence() ) ;
00592               if( TheHBHERecHits.isValid() )
00593                 {
00594                   for( HBHERecHitCollection::const_iterator iHBHERecHit = TheHBHERecHits->begin(); iHBHERecHit != TheHBHERecHits->end(); iHBHERecHit++)  
00595                     {
00596                       HcalDetId id = HcalDetId( iHBHERecHit->id() ) ;
00597                       int iphi = id.iphi() ;
00598                       if( iphi != iWedge->iPhi() ) continue;
00599                       if( iHBHERecHit->energy() < 1.0) continue;  // Otherwise there are thousands of hits per event (even with negative energies)
00600                       
00601                       float time = iHBHERecHit->time();
00602                       int ieta = id.ieta();
00603                       hExtra_HcalToF_HaloId ->Fill( ieta, time );
00604                     }
00605                 }
00606             }
00607 
00608           // Get Matched Hcal Phi Wedges
00609           std::vector<PhiWedge> EcalWedges = GlobalData.GetMatchedEcalPhiWedges();
00610           hGlobalHaloData_MatchedEcalPhiWedgeMultiplicity ->Fill(EcalWedges.size());
00611           for( std::vector<PhiWedge>::const_iterator iWedge = EcalWedges.begin() ; iWedge != EcalWedges.end() ; iWedge ++ )
00612             {
00613               hGlobalHaloData_MatchedEcalPhiWedgeEnergy       ->Fill(iWedge->Energy());
00614               hGlobalHaloData_MatchedEcalPhiWedgeConstituents ->Fill(iWedge->NumberOfConstituents());
00615               hGlobalHaloData_MatchedEcalPhiWedgeiPhi         ->Fill(iWedge->iPhi());
00616               hGlobalHaloData_MatchedEcalPhiWedgeMinTime      ->Fill(iWedge->MinTime());
00617               hGlobalHaloData_MatchedEcalPhiWedgeMaxTime      ->Fill(iWedge->MaxTime());
00618               hGlobalHaloData_MatchedEcalPhiWedgeZDirectionConfidence ->Fill( iWedge->ZDirectionConfidence() ) ;
00619               if( TheEBRecHits.isValid() ) 
00620                 {
00621                   for( EBRecHitCollection::const_iterator iEBRecHit = TheEBRecHits->begin() ; iEBRecHit != TheEBRecHits->end(); iEBRecHit++ )
00622                     {
00623                       if( iEBRecHit->energy() < 0.5 ) continue;
00624                       DetId id = DetId( iEBRecHit->id() ) ;
00625                       EBDetId EcalId ( id.rawId() );
00626                       int iPhi = EcalId.iphi() ;
00627                       iPhi = (iPhi-1)/5 + 1;
00628                       if( iPhi != iWedge->iPhi() ) continue;
00629                       hExtra_EcalToF_HaloId ->Fill(EcalId.ieta(), iEBRecHit->time() );
00630                     }
00631                 }
00632             }
00633         }
00634     }
00635 
00636 
00637   // Get BeamHaloSummary 
00638   edm::Handle<BeamHaloSummary> TheBeamHaloSummary ;
00639   iEvent.getByLabel(IT_BeamHaloSummary, TheBeamHaloSummary) ;
00640   if( TheBeamHaloSummary.isValid() ) 
00641     {
00642       const BeamHaloSummary TheSummary = (*TheBeamHaloSummary.product() );
00643       if( TheSummary.CSCLooseHaloId() ) 
00644         {
00645           hBeamHaloSummary_Id ->Fill(1);
00646           if(!StandardDQM) hBeamHaloSummary_BXN -> Fill( 1, BXN );
00647           if(Dump)*out << std::setw(15) << "CSCLoose" << std::setw(15) << Run << std::setw(15) << Lumi << std::setw(15) << TheEventNumber << std::endl;
00648         }
00649       if( TheSummary.CSCTightHaloId() ) 
00650         {
00651           hBeamHaloSummary_Id ->Fill(2);
00652           if(!StandardDQM)hBeamHaloSummary_BXN -> Fill( 2, BXN );
00653         }
00654       if( TheSummary.EcalLooseHaloId() )
00655         {
00656           hBeamHaloSummary_Id ->Fill(3);
00657           if(!StandardDQM) hBeamHaloSummary_BXN -> Fill( 3, BXN );
00658           if(Dump) *out << std::setw(15) << "EcalLoose" << std::setw(15) << Run << std::setw(15) << Lumi << std::setw(15) << TheEventNumber << std::endl;
00659         }
00660       if( TheSummary.EcalTightHaloId() ) 
00661         {
00662           hBeamHaloSummary_Id ->Fill(4);
00663           if(!StandardDQM)hBeamHaloSummary_BXN -> Fill( 4, BXN );
00664         }
00665       if( TheSummary.HcalLooseHaloId() ) 
00666         {
00667           hBeamHaloSummary_Id ->Fill(5);
00668           if(!StandardDQM) hBeamHaloSummary_BXN -> Fill( 5, BXN );
00669           if(Dump) *out << std::setw(15) << "HcalLoose" << std::setw(15) << Run << std::setw(15) << Lumi << std::setw(15) << TheEventNumber << std::endl;
00670         }
00671       if( TheSummary.HcalTightHaloId() ) 
00672         {
00673           hBeamHaloSummary_Id ->Fill(6);
00674           if(!StandardDQM)hBeamHaloSummary_BXN -> Fill( 6, BXN );
00675         }
00676       if( TheSummary.GlobalLooseHaloId()) 
00677         {
00678           hBeamHaloSummary_Id ->Fill(7);
00679           if(!StandardDQM)hBeamHaloSummary_BXN -> Fill( 7, BXN );
00680           if(Dump) *out << std::setw(15) << "GlobalLoose" << std::setw(15) << Run << std::setw(15) << Lumi << std::setw(15) << TheEventNumber << std::endl;
00681         }
00682       if( TheSummary.GlobalTightHaloId() )
00683         {
00684           hBeamHaloSummary_Id ->Fill(8);        
00685           if(!StandardDQM)hBeamHaloSummary_BXN -> Fill( 8, BXN );
00686         }
00687       if( TheSummary.LooseId() ) 
00688         {
00689           hBeamHaloSummary_Id ->Fill(9);
00690           if(!StandardDQM)hBeamHaloSummary_BXN -> Fill( 9, BXN );
00691         }
00692       if( TheSummary.TightId() )
00693         {
00694           hBeamHaloSummary_Id ->Fill(10);
00695           if(!StandardDQM)hBeamHaloSummary_BXN -> Fill( 10, BXN );
00696         }
00697       if( !TheSummary.EcalLooseHaloId()  && !TheSummary.HcalLooseHaloId() && !TheSummary.CSCLooseHaloId() && !TheSummary.GlobalLooseHaloId() )
00698         {
00699           hBeamHaloSummary_Id ->Fill(11);
00700           if(!StandardDQM)hBeamHaloSummary_BXN -> Fill( 11, BXN );
00701         }
00702     }
00703 
00704   if( TheCaloMET.isValid() )
00705     {
00706       const CaloMETCollection *calometcol = TheCaloMET.product();
00707       const CaloMET *calomet = &(calometcol->front());
00708       
00709       if( calomet->pt() > DumpMET )
00710         if(Dump) *out << std::setw(15) << "HighMET" << std::setw(15) << Run << std::setw(15) << Lumi << std::setw(15) << TheEventNumber << std::endl;
00711 
00712       //Fill CSC Activity Plot 
00713       if( calomet->pt() > 15.0 ) 
00714         {
00715           if( TheHaloOrigin > 0 )
00716             {
00717               if( CSCTrackPlus && CSCTrackMinus ) 
00718                 hExtra_CSCActivityWithMET->Fill(1,1);
00719               else if( CSCTrackPlus && CSCSegmentMinus) 
00720                 hExtra_CSCActivityWithMET->Fill(1,2);
00721               else if( CSCTrackPlus && CSCRecHitMinus ) 
00722                 hExtra_CSCActivityWithMET->Fill(1,3);
00723               else if( CSCTrackPlus ) 
00724                 hExtra_CSCActivityWithMET->Fill(1,4);
00725               else if( CSCSegmentPlus && CSCTrackMinus ) 
00726                 hExtra_CSCActivityWithMET->Fill(2,1);
00727               else if( CSCSegmentPlus && CSCSegmentMinus )
00728                 hExtra_CSCActivityWithMET-> Fill(2,2);
00729               else if( CSCSegmentPlus && CSCRecHitMinus   )
00730                 hExtra_CSCActivityWithMET-> Fill(2,3);
00731               else if( CSCSegmentPlus ) 
00732                 hExtra_CSCActivityWithMET->Fill(2,4 );
00733               else if( CSCRecHitPlus && CSCTrackMinus  ) 
00734                 hExtra_CSCActivityWithMET->Fill(3,1);
00735               else if( CSCRecHitPlus && CSCSegmentMinus ) 
00736                 hExtra_CSCActivityWithMET->Fill(3,2);
00737               else if( CSCRecHitPlus && CSCRecHitMinus ) 
00738                 hExtra_CSCActivityWithMET->Fill(3,3);
00739               else if( CSCRecHitPlus ) 
00740                 hExtra_CSCActivityWithMET->Fill(3,4);
00741               else 
00742                 hExtra_CSCActivityWithMET->Fill(4,4);
00743             }
00744           else if( TheHaloOrigin < 0 )
00745             {
00746               if( CSCTrackMinus && CSCTrackPlus ) 
00747                 hExtra_CSCActivityWithMET->Fill(1,1);
00748               else if( CSCTrackMinus && CSCSegmentPlus)
00749                 hExtra_CSCActivityWithMET->Fill(1,2);
00750               else if( CSCTrackMinus && CSCRecHitPlus ) 
00751                 hExtra_CSCActivityWithMET->Fill(1,3);
00752               else if( CSCTrackMinus ) 
00753                 hExtra_CSCActivityWithMET->Fill(1,4);
00754               else if( CSCSegmentMinus && CSCTrackPlus) 
00755                 hExtra_CSCActivityWithMET->Fill(2,1);
00756               else if( CSCSegmentMinus && CSCSegmentPlus ) 
00757                 hExtra_CSCActivityWithMET->Fill(2,2 );
00758               else if( CSCSegmentMinus && CSCRecHitPlus ) 
00759                 hExtra_CSCActivityWithMET->Fill(2,3);
00760               else if( CSCSegmentMinus ) 
00761                 hExtra_CSCActivityWithMET->Fill(2,4);
00762               else if( CSCRecHitMinus && CSCTrackPlus )
00763                 hExtra_CSCActivityWithMET->Fill(3,1 );
00764               else if( CSCRecHitMinus && CSCSegmentPlus )
00765                 hExtra_CSCActivityWithMET->Fill(3,2 );
00766               else if( CSCRecHitMinus && CSCRecHitPlus ) 
00767                 hExtra_CSCActivityWithMET->Fill(3,3);
00768               else if( CSCRecHitMinus )
00769                 hExtra_CSCActivityWithMET->Fill(3,4);
00770               else hExtra_CSCActivityWithMET->Fill(4,4);
00771             }
00772         }
00773     }
00774   
00775 }
00776 
00777 void BeamHaloAnalyzer::endJob()
00778 {
00779 
00780 }
00781 
00782 BeamHaloAnalyzer::~BeamHaloAnalyzer(){
00783 }
00784 
00785 //DEFINE_FWK_MODULE(CMSEventAnalyzer);
00786 
00787 
00788 
00789