Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:48

0001 
0002 // system include files
0003 #include <memory>
0004 #include <cmath>
0005 #include <iostream>
0006 #include <sstream>
0007 
0008 // user include files
0009 #include "FWCore/Framework/interface/Frameworkfwd.h"
0010 #include "FWCore/Framework/interface/EDAnalyzer.h"
0011 
0012 #include "FWCore/Framework/interface/Event.h"
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 
0015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0016 #include "FWCore/ServiceRegistry/interface/Service.h"
0017 #include "CommonTools/UtilAlgos/interface/TFileService.h"
0018 
0019 #include "L1Trigger/CSCTrackFinder/interface/CSCSectorReceiverLUT.h"
0020 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0021 #include "DataFormats/L1CSCTrackFinder/interface/TrackStub.h"//
0022 #include "DataFormats/L1CSCTrackFinder/interface/CSCTriggerContainer.h"
0023 #include "DataFormats/MuonDetId/interface/CSCTriggerNumbering.h"
0024 #include "L1Trigger/CSCTrackFinder/interface/CSCTrackFinderDataTypes.h"
0025 
0026 #include "L1Trigger/CSCTrackFinder/test/src/RunSRLUTs.h"
0027 
0028 #include "DataFormats/VertexReco/interface/VertexFwd.h"
0029 #include "DataFormats/VertexReco/interface/Vertex.h"
0030 
0031 #include "FWCore/Framework/interface/LuminosityBlock.h"
0032 #include "DataFormats/Luminosity/interface/LumiSummary.h"
0033 
0034 #include "TH1F.h"
0035 #include "TFile.h"
0036 #include "TTree.h"
0037 
0038 using namespace std;
0039 using namespace edm;
0040 
0041 class LCTOccupancies : public edm::EDAnalyzer {
0042    public:
0043       explicit LCTOccupancies(const edm::ParameterSet&);
0044       ~LCTOccupancies();
0045 
0046 
0047    private:
0048       virtual void beginJob() ;
0049       virtual void analyze(const edm::Event&, const edm::EventSetup&);
0050       virtual void endJob() ;
0051       virtual void beginLuminosityBlock(edm::LuminosityBlock const& iLumiBlock, 
0052                     edm::EventSetup const& iSetup);
0053 
0054       // ----------member data ---------------------------
0055 
0056   //TH1F* rateHist;
0057 
0058     edm::InputTag lctsTag;  
0059     edm::InputTag vertexColTag; 
0060     edm::Service<TFileService> fs;
0061         csctf_analysis::RunSRLUTs* runSRLUTs;
0062     float insLumi;
0063     int nVertex;
0064     bool haveRECO;
0065     int singleSectorNum;
0066     std::string outTreeFileName;
0067 
0068     TH1F* hNVertex;
0069     TH1F* hInsLumi;
0070 
0071     TH1F* hMPCLink;
0072     TH1F* hLocalPhi;
0073     TH1F* hPhi;
0074     TH1F* hEta;
0075     TH1F* hPhiPacked;
0076     TH1F* hEtaPacked;
0077     TH1F* hBx;
0078 
0079     TH1F* hSector;
0080     TH1F* hStation;
0081     TH1F* hEndcap;
0082     TH1F* hSubSector;
0083 
0084     TH1F* hOccStation1SubSec1;
0085     TH1F* hOccStation1SubSec2;
0086     TH1F* hOccStation2;
0087     TH1F* hOccStation3;
0088     TH1F* hOccStation4;
0089     TH1F* hOccMax;
0090     TH1F* hOccMaxNo0;
0091     TH1F* hStubsTotal;
0092 
0093     TH1F* hOccME11a;
0094     TH1F* hOccME11b;
0095     TH1F* hOccME12;
0096     TH1F* hOccME13;
0097     TH1F* hOccME21;
0098     TH1F* hOccME22;
0099     TH1F* hOccME31;
0100     TH1F* hOccME32;
0101     TH1F* hOccME41;
0102     TH1F* hOccME42;
0103     TH1F* hOccME42SingleSector;
0104 
0105     std::vector<TH1F*> hOccME1ChambsSubSec1;
0106     std::vector<TH1F*> hOccME1ChambsSubSec2;
0107     std::vector<TH1F*> hOccME2Chambs;
0108     std::vector<TH1F*> hOccME3Chambs;
0109     std::vector<TH1F*> hOccME4Chambs;
0110 
0111     //Tree stuff
0112     TFile* treeFile;
0113     TTree* tree;
0114     std::vector<int> occStation1SubSec1;
0115     std::vector<int> occStation1SubSec2;
0116     std::vector<int> occStation2;
0117     std::vector<int> occStation3;
0118     std::vector<int> occStation4;
0119 
0120     std::vector<std::vector<int> > occME1ChamberSubSec1;
0121     std::vector<std::vector<int> > occME1ChamberSubSec2;
0122     std::vector<std::vector<int> > occME2Chamber;
0123     std::vector<std::vector<int> > occME3Chamber;
0124     std::vector<std::vector<int> > occME4Chamber;
0125 };
0126 //
0127 // constants, enums and typedefs
0128 //
0129 
0130 //
0131 // static data member definitions
0132 //
0133 
0134 //
0135 // constructors and destructor
0136 //
0137 LCTOccupancies::LCTOccupancies(const edm::ParameterSet& iConfig)
0138 
0139 {
0140    //now do what ever initialization is needed
0141    runSRLUTs = new csctf_analysis::RunSRLUTs();
0142    lctsTag= iConfig.getParameter<edm::InputTag>("lctsTag");
0143    vertexColTag= iConfig.getParameter<edm::InputTag>("vertexColTag");
0144    outTreeFileName= iConfig.getUntrackedParameter<std::string>("outTreeFileName");
0145    haveRECO = iConfig.getUntrackedParameter<bool>("haveRECO");
0146    singleSectorNum = iConfig.getUntrackedParameter<int>("singleSectorNum");
0147    
0148    treeFile = new TFile(outTreeFileName.c_str(),"RECREATE");
0149    tree = new TTree("tree","tree");
0150 
0151    occStation1SubSec1 = std::vector<int>(12,0);
0152    occStation1SubSec2 = std::vector<int>(12,0);
0153    occStation2 = std::vector<int>(12,0);
0154    occStation3 = std::vector<int>(12,0);
0155    occStation4 = std::vector<int>(12,0);
0156 
0157    for(int iSector = 0; iSector<12; iSector++)
0158    {
0159       occME1ChamberSubSec1.push_back(std::vector<int>(12,0));
0160       occME1ChamberSubSec2.push_back(std::vector<int>(12,0));
0161       occME2Chamber.push_back(std::vector<int>(9,0));
0162       occME3Chamber.push_back(std::vector<int>(9,0));
0163       occME4Chamber.push_back(std::vector<int>(9,0));
0164    }
0165 
0166    tree->Branch("nVertex",&nVertex,"nVertex/I");  
0167    tree->Branch("insLumi",&insLumi,"insLumi/F");  
0168 
0169    tree->Branch("occStation1SubSec1","vector<int>",&occStation1SubSec1);
0170    tree->Branch("occStation1SubSec2","vector<int>",&occStation1SubSec2);
0171    tree->Branch("occStation2","vector<int>",&occStation2);
0172    tree->Branch("occStation3","vector<int>",&occStation3);
0173    tree->Branch("occStation4","vector<int>",&occStation4);
0174 
0175    tree->Branch("occME1ChamberSubSec1","vector<std::vector<int> >",&occME1ChamberSubSec1);
0176    tree->Branch("occME1ChamberSubSec2","vector<std::vector<int> >",&occME1ChamberSubSec2);
0177    tree->Branch("occME2Chamber","vector<std::vector<int> >",&occME2Chamber);
0178    tree->Branch("occME3Chamber","vector<std::vector<int> >",&occME3Chamber);
0179    tree->Branch("occME4Chamber","vector<std::vector<int> >",&occME4Chamber);
0180 }
0181 
0182 
0183 
0184 LCTOccupancies::~LCTOccupancies()
0185 {
0186  
0187    // do anything here that needs to be done at desctruction time
0188    // (e.g. close files, deallocate resources etc.)
0189    treeFile->cd();
0190    tree->Write();
0191    delete runSRLUTs;
0192 }
0193 
0194 
0195 //
0196 // member functions
0197 //
0198 
0199 // ------------ method called to for each event  ------------
0200 void
0201 LCTOccupancies::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
0202 {
0203   ///////////////////
0204   //Setup Stuff//////
0205   ///////////////////
0206   nVertex=0;
0207 
0208   std::vector<csctf::TrackStub> stubs;
0209   std::vector<csctf::TrackStub>::const_iterator stub;
0210 
0211   //MuonDigiCollection<CSCDetId,CSCCorrelatedLCTDigi>    "csctfunpacker"          ""        "CsctfFilter"   
0212   edm::Handle<CSCCorrelatedLCTDigiCollection> lctDigiColls;
0213   iEvent.getByLabel(lctsTag,lctDigiColls);
0214 
0215   std::vector<csctf::TrackStub>* trackStubs = new std::vector<csctf::TrackStub>;
0216   runSRLUTs->makeTrackStubs(lctDigiColls.product(),trackStubs);
0217 
0218   std::vector<csctf::TrackStub>::const_iterator ts = trackStubs->begin();
0219   std::vector<csctf::TrackStub>::const_iterator tsEnd = trackStubs->end();
0220 
0221   for(unsigned i=0;i<12;i++)
0222   {
0223   }
0224 
0225   std::vector<int> occME11a(24,0);
0226   std::vector<int> occME11b(24,0);
0227   std::vector<int> occME12(24,0);
0228   std::vector<int> occME13(24,0);
0229   std::vector<int> occME21(12,0);
0230   std::vector<int> occME22(12,0);
0231   std::vector<int> occME31(12,0);
0232   std::vector<int> occME32(12,0);
0233   std::vector<int> occME41(12,0);
0234   std::vector<int> occME42(12,0);
0235   int occME42SingleSector=0;
0236 
0237   for(int iSectors = 0; iSectors<12; iSectors++)
0238   {
0239    occStation1SubSec1[iSectors]=0;
0240    occStation1SubSec2[iSectors]=0;
0241    occStation2[iSectors]=0;
0242    occStation3[iSectors]=0;
0243    occStation4[iSectors]=0;
0244    for(int iChambers = 0; iChambers<12; iChambers++)
0245    {
0246     occME1ChamberSubSec1[iSectors][iChambers]=0;
0247     occME1ChamberSubSec2[iSectors][iChambers]=0;
0248     if(iChambers<9)
0249     {
0250       occME2Chamber[iSectors][iChambers]=0;
0251       occME3Chamber[iSectors][iChambers]=0;
0252       occME4Chamber[iSectors][iChambers]=0;
0253     }
0254    }
0255   }
0256 
0257   for (;ts != tsEnd; ts++)
0258   {
0259     //std::cout << "etaValue: \t" <<ts->etaValue()<< std::endl;
0260     //std::cout << "phiValue: \t" <<ts->phiValue()<< std::endl;
0261     //std::cout << "eta: \t" <<ts->etaPacked()<< std::endl;
0262     //std::cout << "phi: \t" <<ts->phiPacked()<< std::endl;
0263     //std::cout << "cscid: \t" <<ts->cscid()<< std::endl;
0264     //std::cout << "subsector: \t" <<ts->subsector()<< std::endl;
0265     //std::cout << "sector: \t" <<ts->sector()<< std::endl;
0266     //std::cout << "station: \t" <<ts->station()<< std::endl;
0267     //std::cout << "endcap: \t" <<ts->endcap()<< std::endl;
0268     //std::cout << "bx: \t" <<ts->BX()<< std::endl;
0269     //std::cout << "MPCLink: \t" <<ts->getMPCLink()<< std::endl;
0270     //std::cout << std::endl;
0271 
0272     unsigned sector = ts->sector()-1;
0273 
0274     if(ts->BX() != 0)
0275         continue;
0276     hMPCLink->Fill(ts->getMPCLink());
0277     hLocalPhi->Fill(ts->phiValue());
0278     hPhi->Fill(ts->phiValue()+15.0*M_PI/180+(sector)*60.0*M_PI/180); 
0279     hPhiPacked->Fill(ts->phiPacked());
0280     hEta->Fill(ts->etaValue());
0281     hEtaPacked->Fill(ts->etaPacked());
0282     hBx->Fill(ts->BX());
0283         int station = ts->station();
0284         int subsector = ts->subsector();
0285     //CSCDetId detId(ts->getDetId().rawId());
0286     CSCDetId detId(ts->getDetId());
0287         int ring = detId.ring();
0288     int triggerChamber = CSCTriggerNumbering::triggerCscIdFromLabels(detId);
0289     //ME11a ring==4 doesn't work, no ring==4 events ?
0290     //std::cout << "station: \t" <<ts->station()<< std::endl;
0291     //std::cout << "ring: \t" <<ring<< std::endl << std::endl;
0292     if (ts->endcap()==2)
0293     {
0294       station = -station;
0295       sector = sector+6;
0296     }
0297     hSector->Fill(sector+1);
0298     hStation->Fill(station);
0299     hSubSector->Fill(subsector);
0300 
0301         //std::cout << "station: " << station << std::endl;
0302         //std::cout << "my sector packed: " << sector << std::endl;
0303         //std::cout << "trigger Chamber: " << triggerChamber << std::endl;
0304     
0305     station = abs(station);
0306     if (station==1)
0307     {
0308       if(subsector==1)
0309       {
0310         occME1ChamberSubSec1[sector][triggerChamber-1]++;
0311         occStation1SubSec1[sector]++;
0312         if (ring==4)
0313           occME11a[sector]++;
0314         else if (ring==1)
0315           occME11b[sector]++;
0316         else if (ring==2)
0317           occME12[sector]++;
0318         else if (ring==3)
0319           occME13[sector]++;
0320           }
0321       else
0322       {
0323         occME1ChamberSubSec2[sector][triggerChamber-1]++;
0324         occStation1SubSec2[sector]++;
0325         if (ring==4)
0326           occME11a[sector+12]++;
0327         else if (ring==1)
0328           occME11b[sector+12]++;
0329         else if (ring==2)
0330           occME12[sector+12]++;
0331         else if (ring==3)
0332           occME13[sector+12]++;
0333           }
0334     }
0335     if (station==2)
0336     {
0337         occME2Chamber[sector][triggerChamber-1]++;
0338         occStation2[sector]++;
0339         if (ring==1)
0340           occME21[sector]++;
0341         else if (ring==2)
0342           occME22[sector]++;
0343     }
0344     if (station==3)
0345     {
0346         occME3Chamber[sector][triggerChamber-1]++;
0347         occStation3[sector]++;
0348         if (ring==1)
0349           occME31[sector]++;
0350         else if (ring==2)
0351           occME32[sector]++;
0352     }
0353     if (station==4)
0354     {
0355         occME4Chamber[sector][triggerChamber-1]++;
0356         occStation4[sector]++;
0357         if (ring==1)
0358           occME41[sector]++;
0359         else if (ring==2)
0360         {
0361           occME42[sector]++;
0362           occME42SingleSector++;
0363         }
0364     }
0365   }
0366 
0367   int maxOcc = 0;
0368 
0369   for (unsigned iSector=0; iSector<12; iSector++)
0370   {
0371     if (singleSectorNum != -1 && singleSectorNum != (int) iSector)
0372     continue;
0373     hOccStation1SubSec1->Fill(occStation1SubSec1[iSector]);
0374     hOccStation1SubSec2->Fill(occStation1SubSec2[iSector]);
0375     hOccStation2->Fill(occStation2[iSector]);
0376     hOccStation3->Fill(occStation3[iSector]);
0377     hOccStation4->Fill(occStation4[iSector]);
0378 
0379     if (occStation1SubSec1[iSector]>maxOcc)
0380     maxOcc = occStation1SubSec1[iSector];
0381     if (occStation1SubSec2[iSector]>maxOcc)
0382     maxOcc = occStation1SubSec2[iSector];
0383     if (occStation2[iSector]>maxOcc)
0384     maxOcc = occStation2[iSector];
0385     if (occStation3[iSector]>maxOcc)
0386     maxOcc = occStation3[iSector];
0387     if (occStation4[iSector]>maxOcc)
0388     maxOcc = occStation4[iSector];
0389   }
0390   hOccMax->Fill(maxOcc);
0391   if(maxOcc>0)
0392     hOccMaxNo0->Fill(maxOcc);
0393 
0394   hStubsTotal->Fill(trackStubs->size());
0395 
0396   for (unsigned iSector=0; iSector<24; iSector++)
0397   {
0398     if (singleSectorNum != -1 && abs(singleSectorNum) != (int) iSector
0399         && abs(singleSectorNum) != (int) iSector-12)
0400     continue;
0401     hOccME11a->Fill(occME11a[iSector]);
0402     hOccME11b->Fill(occME11b[iSector]);
0403     hOccME12->Fill(occME12[iSector]);
0404     hOccME13->Fill(occME13[iSector]);
0405     if(iSector<12)
0406     {
0407       hOccME21->Fill(occME21[iSector]);
0408       hOccME22->Fill(occME22[iSector]);
0409       hOccME31->Fill(occME31[iSector]);
0410       hOccME32->Fill(occME32[iSector]);
0411       hOccME41->Fill(occME41[iSector]);
0412       hOccME42->Fill(occME42[iSector]);
0413     }
0414   }
0415   hOccME42SingleSector->Fill(occME42SingleSector);
0416 
0417   for (unsigned iChamb=0; iChamb<12;iChamb++)
0418   {
0419     for (unsigned iSector=0; iSector<12;iSector++)
0420     {
0421       if (singleSectorNum != -1 && abs(singleSectorNum) != (int) iSector
0422         && abs(singleSectorNum) != (int) iSector-12)
0423       continue;
0424       hOccME1ChambsSubSec1[iChamb]->Fill(occME1ChamberSubSec1[iSector][iChamb]);
0425       hOccME1ChambsSubSec2[iChamb]->Fill(occME1ChamberSubSec2[iSector][iChamb]);
0426       if(iChamb<9)
0427       {
0428         hOccME2Chambs[iChamb]->Fill(occME2Chamber[iSector][iChamb]);
0429         hOccME3Chambs[iChamb]->Fill(occME3Chamber[iSector][iChamb]);
0430         hOccME4Chambs[iChamb]->Fill(occME4Chamber[iSector][iChamb]);
0431       }
0432     }
0433   }
0434 
0435   //Vertex Counting
0436 
0437   if(haveRECO)
0438    if(vertexColTag.label() != "null")
0439    {
0440      edm::Handle<reco::VertexCollection> vertexCol;
0441      iEvent.getByLabel(vertexColTag,vertexCol);
0442      reco::VertexCollection::const_iterator vertex;
0443      for(vertex = vertexCol->begin(); vertex != vertexCol->end(); vertex++)
0444      {
0445     if(vertex->isValid() && !vertex->isFake()) //&& vertex->normalizedChi2()<10)
0446         nVertex++;
0447      }
0448      //std::cout << "nVertex: " << nVertex << std::endl;
0449      //std::cout << "luminosity: " <<insLumi << std::endl;
0450      hNVertex->Fill(nVertex);
0451    }
0452 
0453   tree->Fill();
0454 }
0455 
0456 
0457 // ------------ method called once each job just before starting event loop  ------------
0458 void 
0459 LCTOccupancies::beginJob()
0460 {
0461 
0462   hNVertex=fs->make<TH1F>("NVertex","N Primary Vertices",30,0,30);
0463   hNVertex->GetXaxis()->SetTitle("N Primary Vertices");
0464   hNVertex->GetYaxis()->SetTitle("Counts");
0465   hInsLumi=fs->make<TH1F>("InsLumi","Lumi Section Instantanious Luminosity",10000,0,1000000);
0466   hInsLumi->GetXaxis()->SetTitle("Lumi Section Instantanious Luminosity (Uncorrected HF--10^{30} cm^{2}s^{-1})");
0467   hInsLumi->GetYaxis()->SetTitle("Counts");
0468 
0469   hMPCLink=fs->make<TH1F>("MPCLink","Stub MPC Link Number",5,-1,4);
0470   hMPCLink->GetXaxis()->SetTitle("MPC Link");
0471   hMPCLink->GetYaxis()->SetTitle("Counts");
0472   hLocalPhi=fs->make<TH1F>("LocalPhi","Stub Local #phi",4096,0,2.0*62.0*M_PI/180.0);//62.0*M_PI/180.0
0473   hLocalPhi->GetXaxis()->SetTitle("Local #phi");
0474   hLocalPhi->GetYaxis()->SetTitle("Counts");
0475   hPhi=fs->make<TH1F>("Phi","Stub #phi",100,0,3.2);
0476   hPhi->GetXaxis()->SetTitle("#phi");
0477   hPhi->GetYaxis()->SetTitle("Counts");
0478   hPhiPacked=fs->make<TH1F>("PhiPacked","Stub #phi Packed",4096,0,4096);//4096
0479   hPhiPacked->GetXaxis()->SetTitle("#phi Packed");
0480   hPhiPacked->GetYaxis()->SetTitle("Counts");
0481   hEta=fs->make<TH1F>("Eta","Stub |#eta|",128,0.9,2.4);
0482   hEta->GetXaxis()->SetTitle("|#eta|");
0483   hEta->GetYaxis()->SetTitle("Counts");
0484   hEtaPacked=fs->make<TH1F>("EtaPacked","Stub #eta Packed",128,0,128);//128
0485   hEtaPacked->GetXaxis()->SetTitle("#eta Packed");
0486   hEtaPacked->GetYaxis()->SetTitle("Counts");
0487   hBx=fs->make<TH1F>("Bx","Stub Bx Number",15,0,15);
0488   hBx->GetXaxis()->SetTitle("bx");
0489   hBx->GetYaxis()->SetTitle("Counts");
0490 
0491   hStation=fs->make<TH1F>("Station","Stub Station",9,-4.5,4.5);
0492   hStation->GetXaxis()->SetTitle("Station");
0493   hStation->GetYaxis()->SetTitle("Counts");
0494   hSector=fs->make<TH1F>("Sector","Stub Sector",12,0.5,12.5);
0495   hSector->GetXaxis()->SetTitle("Sector");
0496   hSector->GetYaxis()->SetTitle("Counts");
0497   hSubSector=fs->make<TH1F>("SubSector","Stub SubSector",3,0,3);
0498   hSubSector->GetXaxis()->SetTitle("SubSector");
0499   hSubSector->GetYaxis()->SetTitle("Counts");
0500 
0501   hOccStation1SubSec1=fs->make<TH1F>("OccStation1SubSec1","Stub Occupancy, Station 1, Subsector 1",5,-0.5,4.5);
0502   hOccStation1SubSec1->GetXaxis()->SetTitle("Stub Occupancy, Station 1, Subsector 1, Summed over Sectors");
0503   hOccStation1SubSec1->GetYaxis()->SetTitle("Counts");
0504   hOccStation1SubSec2=fs->make<TH1F>("OccStation1SubSec2","Stub Occupancy, Station 1, Subsector 2",5,-0.5,4.5);
0505   hOccStation1SubSec2->GetXaxis()->SetTitle("Stub Occupancy, Station 1, Subsector 1, Summed over Sectors");
0506   hOccStation1SubSec2->GetYaxis()->SetTitle("Counts");
0507   hOccStation2=fs->make<TH1F>("OccStation2","Stub Occupancy, Station 2",5,-0.5,4.5);
0508   hOccStation2->GetXaxis()->SetTitle("Stub Occupancy, Station 2, Summed over Sectors");
0509   hOccStation2->GetYaxis()->SetTitle("Counts");
0510   hOccStation3=fs->make<TH1F>("OccStation3","Stub Occupancy, Station 3",5,-0.5,4.5);
0511   hOccStation3->GetXaxis()->SetTitle("Stub Occupancy, Station 3, Summed over Sectors");
0512   hOccStation3->GetYaxis()->SetTitle("Counts");
0513   hOccStation4=fs->make<TH1F>("OccStation4","Stub Occupancy, Station 4",5,-0.5,4.5);
0514   hOccStation4->GetXaxis()->SetTitle("Stub Occupancy, Station 4, Summed over Sectors");
0515   hOccStation4->GetYaxis()->SetTitle("Counts");
0516   hOccMax=fs->make<TH1F>("OccMax","Maximum Stub Occupancy",5,-0.5,4.5);
0517   hOccMax->GetXaxis()->SetTitle("Maximum Stub Occupancy of Stations, Sectors, and Subsectors");
0518   hOccMax->GetYaxis()->SetTitle("Counts");
0519   hOccMaxNo0=fs->make<TH1F>("OccMaxNo0","Maximum Stub Occupancy",4,0.5,4.5);
0520   hOccMaxNo0->GetXaxis()->SetTitle("Maximum Stub Occupancy of Stations, Sectors, and Subsectors");
0521   hOccMaxNo0->GetYaxis()->SetTitle("Counts");
0522   hStubsTotal=fs->make<TH1F>("StubsTotal","N Stubs",20,0,20);
0523   hStubsTotal->GetXaxis()->SetTitle("N Stubs Unpacked in Event");
0524   hStubsTotal->GetYaxis()->SetTitle("Counts");
0525 
0526   hOccME11a=fs->make<TH1F>("OccME11a","Stub Occupancy, ME11a, Summed over Sectors, Subsectors",5,-0.5,4.5);
0527   hOccME11a->GetXaxis()->SetTitle("Stub Occupancy, ME11a, Summed over Sectors, Subsectors");
0528   hOccME11a->GetYaxis()->SetTitle("Counts");
0529   hOccME11b=fs->make<TH1F>("OccME11b","Stub Occupancy, ME11b, Summed over Sectors, Subsectors",5,-0.5,4.5);
0530   hOccME11b->GetXaxis()->SetTitle("Stub Occupancy, ME11b, Summed over Sectors, Subsectors");
0531   hOccME11b->GetYaxis()->SetTitle("Counts");
0532   hOccME12=fs->make<TH1F>("OccME12","Stub Occupancy, ME12, Summed over Sectors, Subsectors",5,-0.5,4.5);
0533   hOccME12->GetXaxis()->SetTitle("Stub Occupancy, ME12, Summed over Sectors, Subsectors");
0534   hOccME12->GetYaxis()->SetTitle("Counts");
0535   hOccME13=fs->make<TH1F>("OccME13","Stub Occupancy, ME13, Summed over Sectors, Subsectors",5,-0.5,4.5);
0536   hOccME13->GetXaxis()->SetTitle("Stub Occupancy, ME13, Summed over Sectors, Subsectors");
0537   hOccME13->GetYaxis()->SetTitle("Counts");
0538   hOccME21=fs->make<TH1F>("OccME21","Stub Occupancy, ME21, Summed over Sectors",5,-0.5,4.5);
0539   hOccME21->GetXaxis()->SetTitle("Stub Occupancy, ME21, Summed over Sectors");
0540   hOccME21->GetYaxis()->SetTitle("Counts");
0541   hOccME22=fs->make<TH1F>("OccME22","Stub Occupancy, ME22, Summed over Sectors",5,-0.5,4.5);
0542   hOccME22->GetXaxis()->SetTitle("Stub Occupancy, ME22, Summed over Sectors");
0543   hOccME22->GetYaxis()->SetTitle("Counts");
0544   hOccME31=fs->make<TH1F>("OccME31","Stub Occupancy, ME31, Summed over Sectors",5,-0.5,4.5);
0545   hOccME31->GetXaxis()->SetTitle("Stub Occupancy, ME31, Summed over Sectors");
0546   hOccME31->GetYaxis()->SetTitle("Counts");
0547   hOccME32=fs->make<TH1F>("OccME32","Stub Occupancy, ME32, Summed over Sectors",5,-0.5,4.5);
0548   hOccME32->GetXaxis()->SetTitle("Stub Occupancy, ME32, Summed over Sectors");
0549   hOccME32->GetYaxis()->SetTitle("Counts");
0550   hOccME41=fs->make<TH1F>("OccME41","Stub Occupancy, ME41, Summed over Sectors",5,-0.5,4.5);
0551   hOccME41->GetXaxis()->SetTitle("Stub Occupancy, ME41, Summed over Sectors");
0552   hOccME41->GetYaxis()->SetTitle("Counts");
0553   hOccME42=fs->make<TH1F>("OccME42","Stub Occupancy, ME42, Summed over Sectors",5,-0.5,4.5);
0554   hOccME42->GetXaxis()->SetTitle("Stub Occupancy, ME42, Summed over Sectors");
0555   hOccME42->GetYaxis()->SetTitle("Counts");
0556   hOccME42SingleSector=fs->make<TH1F>("OccME42SingleSector","Stub Occupancy, ME42, All Stubs in 1 Sector",5,-0.5,4.5);
0557   hOccME42SingleSector->GetXaxis()->SetTitle("Stub Occupancy, ME42");
0558   hOccME42SingleSector->GetYaxis()->SetTitle("Counts");
0559 
0560   // Now begin individual chamber modeling
0561   TFileDirectory chambsME1Dir = fs->mkdir("chambsME1");
0562   TFileDirectory chambsME2Dir = fs->mkdir("chambsME2");
0563   TFileDirectory chambsME3Dir = fs->mkdir("chambsME3");
0564   TFileDirectory chambsME4Dir = fs->mkdir("chambsME4");
0565 
0566   for(int i=0; i<12;i++)
0567   {
0568     std::stringstream tmpName;
0569     std::stringstream tmpTitle;
0570     tmpName << "OccME1Chamb" << i+1;
0571     tmpTitle << "Stub Occupancy ME1, Chamber " << i+1 << " Summed Over Sectors, SubSectors";
0572     TH1F* tempHist = chambsME1Dir.make<TH1F>(tmpName.str().c_str(),tmpTitle.str().c_str(),3,-0.5,2.5);
0573     tempHist->GetXaxis()->SetTitle(tmpTitle.str().c_str());
0574     tempHist->GetYaxis()->SetTitle("Counts");
0575     hOccME1ChambsSubSec1.push_back(tempHist);
0576     hOccME1ChambsSubSec2.push_back((TH1F*) tempHist->Clone());
0577   }
0578 
0579   for(int i=0; i<9;i++)
0580   {
0581     for(int j=2; j<5;j++)
0582     {
0583     std::stringstream tmpName;
0584     std::stringstream tmpTitle;
0585     tmpName << "OccME"<<j<<"Chamb" << i+1;
0586     tmpTitle << "Stub Occupancy ME"<<j<<", Chamber " << i+1 << " Summed Over Sectors";
0587     TH1F* tempHist; 
0588     if(j==2)
0589     {
0590       tempHist = chambsME2Dir.make<TH1F>(tmpName.str().c_str(),tmpTitle.str().c_str(),3,-0.5,2.5);
0591       hOccME2Chambs.push_back(tempHist);
0592     }
0593     else if(j==3)
0594     {
0595       tempHist = chambsME3Dir.make<TH1F>(tmpName.str().c_str(),tmpTitle.str().c_str(),3,-0.5,2.5);
0596       hOccME3Chambs.push_back(tempHist);
0597     }
0598     else if(j==4)
0599     {
0600       tempHist = chambsME4Dir.make<TH1F>(tmpName.str().c_str(),tmpTitle.str().c_str(),3,-0.5,2.5);
0601       hOccME4Chambs.push_back(tempHist);
0602     }
0603     else
0604       std::cout << "Warning: problem in initializing Chamber Occ hists!" << std::endl;
0605 
0606     tempHist->GetXaxis()->SetTitle(tmpTitle.str().c_str());
0607     tempHist->GetYaxis()->SetTitle("Counts");
0608     }
0609   }
0610 
0611 }
0612 
0613 // ------------ method called once each job just after ending the event loop  ------------
0614 void 
0615 LCTOccupancies::endJob() 
0616 {
0617   TH1F* hOccStation1AddSubSec=fs->make<TH1F>("OccStation1AddSubSec","Stub Occupancy, Station 1",5,-0.5,4.5);
0618   hOccStation1AddSubSec->GetXaxis()->SetTitle("Stub Occupancy, Station 1, Summed over Sectors, Subsectors");
0619   hOccStation1AddSubSec->GetYaxis()->SetTitle("Counts");
0620   TH1F* hOccAddStations=fs->make<TH1F>("OccAddStation","Stub Occupancy",5,-0.5,4.5);
0621   hOccAddStations->GetXaxis()->SetTitle("Stub Occupancy, Summed over Stations, Sectors, Subsectors");
0622   hOccAddStations->GetYaxis()->SetTitle("Counts");
0623 
0624   hOccStation1AddSubSec->Add(hOccStation1SubSec1);
0625   hOccStation1AddSubSec->Add(hOccStation1SubSec2);
0626   hOccAddStations->Add(hOccStation1SubSec1);
0627   hOccAddStations->Add(hOccStation1SubSec2);
0628   hOccAddStations->Add(hOccStation2);
0629   hOccAddStations->Add(hOccStation3);
0630   hOccAddStations->Add(hOccStation4);
0631 }
0632 
0633 void
0634 LCTOccupancies::beginLuminosityBlock(edm::LuminosityBlock const& iLumiBlock, 
0635                                          edm::EventSetup const& iSetup)
0636 {
0637   if(haveRECO)
0638   {
0639    edm::Handle<LumiSummary> lumiSummary;
0640    iLumiBlock.getByLabel("lumiProducer", lumiSummary);
0641  
0642    //
0643    //collect lumi. 
0644    //
0645    insLumi=lumiSummary->avgInsDelLumi();//*93.244;
0646    //std::cout << "luminosity: " <<insLumi << std::endl;
0647    hInsLumi->Fill(insLumi);
0648   }
0649 }
0650 
0651 //define this as a plug-in
0652 DEFINE_FWK_MODULE(LCTOccupancies);