CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

RPCNoise Class Reference

#include <RecoLocalMuon/RPCNoise/src/RPCNoise.cc>

Inheritance diagram for RPCNoise:
edm::EDFilter edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 RPCNoise (const edm::ParameterSet &)
 ~RPCNoise ()

Private Member Functions

virtual void beginJob ()
virtual void endJob ()
virtual bool filter (edm::Event &, const edm::EventSetup &)

Private Attributes

TH1F * dOrbit
TH1F * fDTDigisOut
TH1F * fDTDigisOutH
bool fillHistograms
int firstOrbit
std::string histogramFileName
TProfile * hitsVsOrbit
TProfile * hitsVsSerial
int iEvent
int iRun
int lastOrbit
int nCSCStripsCut
int nCSCWiresCut
TH1F * nDTDigis
int nDTDigisCut
TH1F * nDTDigisH
TH1F * nDTDigisIn
TH1F * nDTDigisInH
TH1F * nDTDigisOut
TH1F * nDTDigisOutH
int nEventsAnalyzed
int nEventsSelected
int nRPCHitsCut
TH1F * nRPCRecHits
TH1F * nRPCRecHitsLong
TH1F * nStrips
TH1F * nStripsH
TH1F * nWires
TH1F * nWiresH
TProfile * orbitVsSerial
TH1F * RPCBX
TH1F * RPCBXH
TH1F * RPCClSize
TH1F * RPCClSizeH
TH1F * rpcCorner
TH1F * rpcCornerH
TProfile * rpcCornerVsOrbit
TH1F * rpcLayer
TH1F * rpcLayerH
TH1F * rpcRing
TH1F * rpcRingH
TProfile * rpcRingVsOrbit
TH1F * rpcSector
TH1F * rpcSectorH
TProfile * rpcSectorVsOrbit
TH1F * rpcStation
TH1F * rpcStationH
TProfile * rpcStationVsOrbit
TH1F * t0All
TH1F * t0AllH
TFile * theHistogramFile
int thisOrbit

Detailed Description

Description: <simple analyis of RPC noise, and event filter>

Implementation: <simple application="" of="" edfilter>="">

Definition at line 88 of file RPCNoise.cc.


Constructor & Destructor Documentation

RPCNoise::RPCNoise ( const edm::ParameterSet pset) [explicit]
RPCNoise::~RPCNoise ( )

Definition at line 167 of file RPCNoise.cc.

{
}

Member Function Documentation

void RPCNoise::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDFilter.

Definition at line 173 of file RPCNoise.cc.

References RPCNoise_example::fillHistograms, RPCNoise_example::histogramFileName, and iEvent.

{
  // initialize variables
  nEventsAnalyzed = 0;
  nEventsSelected = 0;
  iRun = 0;
  iEvent = 0;
  firstOrbit = lastOrbit = thisOrbit = 0;

  if (fillHistograms) {
    // Create the root file for the histograms
    theHistogramFile = new TFile(histogramFileName.c_str(), "RECREATE");
    theHistogramFile->cd();
    // book histograms
    nWires  = new TH1F("nWires","number of wire digis", 121, -0.5, 120.5);
    nStrips = new TH1F("nStrips","number of strip digis", 201, -0.5, 200.5);
    nWiresH  = new TH1F("nWiresH","number of wire digis HIGH", 121, -0.5, 120.5);
    nStripsH = new TH1F("nStripsH","number of strip digis HIGH", 201, -0.5, 200.5);
    nDTDigis = new TH1F("nDTDigis","number of DT digis",201,-0.5,200.5);
    nDTDigisH = new TH1F("nDTDigisH","number of DT digis HIGH",201,-0.5,200.5);
    nDTDigisIn    = new TH1F("nDTDigisIn","N DT digis in window",75,0.,150.);
    nDTDigisInH   = new TH1F("nDTDigisInH","N DT digis in window HIGH",75,0.,150.);
    nDTDigisOut   = new TH1F("nDTDigisOut","N DT digis out window",75,0.,150.);
    nDTDigisOutH  = new TH1F("nDTDigisOutH","N DT digis out window HIGH",75,0.,150.);
    fDTDigisOut   = new TH1F("fDTDigisOut", "fraction DT digis outside window",55,0.,1.1);
    fDTDigisOutH  = new TH1F("fDTDigisOutH","fraction DT digis outside window HIGH",55,0.,1.1);

    t0All  = new TH1F("t0All","t0",700,0.,7000.);
    t0AllH = new TH1F("t0AllH","t0 HIGH",700,0.,7000.);
    RPCBX  = new TH1F("RPCBX","RPC BX",21,-10.5,10.5);
    RPCBXH = new TH1F("RPCBXH","RPC BX HIGH",21,-10.5,10.5);
    RPCClSize  = new TH1F("RPCClSize","RPC cluster size",61,-0.5,60.5);
    RPCClSizeH = new TH1F("RPCClSizeH","RPC cluster size HIGH",61,-0.5,60.5);
    
    nRPCRecHits = new TH1F("nRPCRecHits","number of RPC RecHits",101,-0.5,100.5);
    nRPCRecHitsLong = new TH1F("nRPCRecHitsLong","number of RPC RecHits",601,-0.5,600.5);
    hitsVsSerial  = new TProfile("hitsVsSerial","mean RPC hits vs serial event number",4000,0.,40000.,0.,1000.);
    orbitVsSerial = new TProfile("orbitVsSerial","relative orbit number vs serial event number",4000,0.,40000.,0.,1.e10);
    hitsVsOrbit   = new TProfile("hitsVsOrbit","mean RPC hits vs orbit number",3000,0.,1200000.,0.,1000.);
    dOrbit = new TH1F("dOrbit","difference in orbit number",121,-0.5,120.5);

    rpcStation  = new TH1F("rpcStation",  "RPC station", 6,-0.5,5.5);
    rpcStationH = new TH1F("rpcStationH", "RPC station HIGH", 6,-0.5,5.5);
    rpcRing     = new TH1F("rpcRing",  "RPC ring", 9,-4.5,4.5);
    rpcRingH    = new TH1F("rpcRingH", "RPC ring HIGH", 9,-4.5,4.5);
    rpcSector   = new TH1F("rpcSector",  "RPC sector", 15,-0.5,14.5);
    rpcSectorH  = new TH1F("rpcSectorH", "RPC sector HIGH", 15,-0.5,14.5);
    rpcLayer    = new TH1F("rpcLayer",  "RPC layer", 4,-0.5,3.5);
    rpcLayerH   = new TH1F("rpcLayerH", "RPC layer HIGH", 4,-0.5,3.5);
    rpcStationVsOrbit = new TProfile("rpcStationVsOrbit","mean RPC station vs. Orbit",3000,0.,1200000.,0.,20.);
    rpcSectorVsOrbit  = new TProfile("rpcSectorVsOrbit","mean RPC sector vs. Orbit",  3000,0.,1200000.,0.,20.);
    rpcRingVsOrbit    = new TProfile("rpcRingVsOrbit","mean RPC ring vs. Orbit",      3000,0.,1200000.,-20.,20.);
    rpcCorner   = new TH1F("rpcCorner", "special corner designation",      4,-0.5,3.5);
    rpcCornerH  = new TH1F("rpcCornerH","special corner designation HIGH", 4,-0.5,3.5);
    rpcCornerVsOrbit = new TProfile("rpcCornerVsOrbit","special corner vs. Orbit",3000,0.,1200000.,-20.,20.);
  }

}
void RPCNoise::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDFilter.

Definition at line 234 of file RPCNoise.cc.

References gather_cfg::cout, and RPCNoise_example::fillHistograms.

                 {
  std::cout << "\n\t===============================================================\n"
       << "\tnumber of events analyzed      = " << nEventsAnalyzed << std::endl
       << "\tnumber of events selected      = " << nEventsSelected << std::endl
       << "\tfirst and last orbit number    : " << firstOrbit << ", " << lastOrbit << ", " << lastOrbit-firstOrbit << std::endl
       << "\t===============================================================\n\n";


  if (fillHistograms) {
    // Write the histos to file
    printf("\n\n======= write out my histograms ====\n\n");
    theHistogramFile->cd();
    nWires->Write();
    nStrips->Write();
    nWiresH->Write();
    nStripsH->Write();
    nDTDigis->Write();
    nDTDigisH->Write();
    nDTDigisIn->Write();
    nDTDigisInH->Write();
    nDTDigisOut->Write();
    nDTDigisOutH->Write();
    fDTDigisOut->Write();
    fDTDigisOutH->Write();
    nRPCRecHits->Write();
    nRPCRecHitsLong->Write();
    hitsVsSerial->Write();
    hitsVsOrbit->Write();
    orbitVsSerial->Write();
    t0All->Write();
    t0AllH->Write();
    RPCBX->Write();
    RPCClSize->Write();
    RPCBXH->Write();
    RPCClSizeH->Write();
    rpcStation->Write();
    rpcStationH->Write();
    rpcRing->Write();
    rpcRingH->Write();
    rpcSector->Write();
    rpcSectorH->Write();
    rpcLayer->Write();
    rpcLayerH->Write();
    dOrbit->Write();
    rpcStationVsOrbit->Write();
    rpcSectorVsOrbit->Write();
    rpcRingVsOrbit->Write();
    rpcCorner->Write();
    rpcCornerH->Write();
    rpcCornerVsOrbit->Write();
    theHistogramFile->Close();
  }
}
bool RPCNoise::filter ( edm::Event event,
const edm::EventSetup eventSetup 
) [private, virtual]

Implements edm::EDFilter.

Definition at line 292 of file RPCNoise.cc.

References gather_cfg::cout, RPCNoise_example::fillHistograms, iEvent, kLayer(), min, RPCNoise_example::nCSCStripsCut, RPCNoise_example::nCSCWiresCut, RPCNoise_example::nDTDigisCut, RPCNoise_example::nRPCHitsCut, RPCDetId::region(), RPCDetId, python::rpcRecHits_cfi::rpcRecHits, and RecoTauPiZeroBuilderPlugins_cfi::strips.

                                                                {

  bool selectThisEvent = false;

  // increment counter
  nEventsAnalyzed++;

  iRun   = event.id().run();
  iEvent = event.id().event();

  bool printThisLine = (nEventsAnalyzed%100 == 0);
  if (printThisLine) {
  std::cout << "======================================"
       << " analyzed= " << nEventsAnalyzed 
       << ", selected= " << nEventsSelected
       << "\trun,event: " << iRun << ", " << iEvent << std::endl;
  }

  /*
  const edm::Timestamp jTime = event.time();
  unsigned int sec  = jTime.value() >> 32;
  unsigned int usec = 0xFFFFFFFF & jTime.value() ;
  double floatTime = sec + usec/(float)1000000.;
  */

  // first event gives
  // sec = 1225315493
  //    orbit = 202375185
  //    bx = 764
  //    mtime = 205094517
  int bx = event.bunchCrossing();
  int thisOrbit = event.orbitNumber();
  long mTime = 3564*thisOrbit + bx;
  if (firstOrbit == 0) {
    firstOrbit = thisOrbit;
    lastOrbit = thisOrbit;
  }
  int deltaOrbit = thisOrbit - lastOrbit;
  lastOrbit = thisOrbit;
  int relativeOrbit = thisOrbit - firstOrbit;

  if (fillHistograms) {dOrbit->Fill(deltaOrbit);}

  if (nEventsAnalyzed < 200) {
    std::cout << iEvent 
      //         << "\tsec,usec: " << sec << ", " << usec
      //         << "\tfloatTime= " << std::setprecision(16) << floatTime
      //         << "\tctime: " << ctime(sec)
         << "\torbit,bx,mTime: " << thisOrbit << "," << bx << "," << mTime
         << "\tdelta= " << deltaOrbit
         << std::endl;
  }


  // ================
  // RPC recHits
  // ================
  edm::Handle<RPCRecHitCollection> rpcRecHits; 
  event.getByLabel("rpcRecHits","",rpcRecHits);

  // count the number of RPC rechits
  int nRPC = 0;
  RPCRecHitCollection::const_iterator rpcIt;
  for (rpcIt = rpcRecHits->begin(); rpcIt != rpcRecHits->end(); rpcIt++) {
    //    RPCDetId id = (RPCDetId)(*rpcIt).rpcId();
    //    LocalPoint rhitlocal = (*rpcIt).localPosition();
    nRPC++;
  }

  // loop again, this time fill histograms
  for (rpcIt = rpcRecHits->begin(); rpcIt != rpcRecHits->end(); rpcIt++) {
    RPCDetId id = (RPCDetId)(*rpcIt).rpcId();
    int kRegion  = id.region();
    int kStation = id.station();
    int kRing = id.ring();
    int kSector = id.sector();
    int kLayer = id.layer();
    int bx = (*rpcIt).BunchX();
    int clSize = (*rpcIt).clusterSize();
    int cornerFlag = 0;
    if ( (kStation>3) && (kSector<3) ) {
      cornerFlag = 1;
      if (kRing < 0) cornerFlag = 2;
    }
    if (nEventsAnalyzed < 100) {
      std::cout << "Region/Station/Ring/Sector/Layer: "
           << kRegion << " / "
           << kStation << " / "
           << kRing << " / "
           << kSector << " / "
           << kLayer 
           << "\tbx,clSize: " << bx << ", " << clSize
           << std::endl;
    }
    if (fillHistograms) {
      RPCBX->Fill(bx);
      RPCClSize->Fill(min((float)clSize,(float)60.));
      rpcStation->Fill(kStation);
      rpcRing->Fill(kRing);
      rpcSector->Fill(kSector);
      rpcLayer->Fill(kLayer);
      rpcStationVsOrbit->Fill(relativeOrbit,kStation);
      rpcSectorVsOrbit->Fill(relativeOrbit,kSector);
      rpcRingVsOrbit->Fill(relativeOrbit,kRing);
      rpcCorner->Fill(cornerFlag);
      rpcCornerVsOrbit->Fill(relativeOrbit,cornerFlag);
      if (nRPC > nRPCHitsCut) {
        RPCBXH->Fill(bx);
        RPCClSizeH->Fill(min((float)clSize,(float)60.));
        rpcStationH->Fill(kStation);
        rpcRingH->Fill(kRing);
        rpcSectorH->Fill(kSector);
        rpcLayerH->Fill(kLayer);
        rpcCornerH->Fill(cornerFlag);
      }
    }

  }

 
  // ===============
  // CSC DIGIs
  // ===============
  edm::Handle<CSCWireDigiCollection>  wires;
  edm::Handle<CSCStripDigiCollection> strips;
  event.getByLabel("muonCSCDigis","MuonCSCWireDigi",wires);
  event.getByLabel("muonCSCDigis","MuonCSCStripDigi",strips);

  // count the number of wire digis.
  int nW = 0;
  for (CSCWireDigiCollection::DigiRangeIterator jW=wires->begin(); jW!=wires->end(); jW++) {
    std::vector<CSCWireDigi>::const_iterator wireIterA = (*jW).second.first;
    std::vector<CSCWireDigi>::const_iterator lWireA = (*jW).second.second;
    for( ; wireIterA != lWireA; ++wireIterA) {
      nW++;
    }
  }

  // count the number of fired strips.
  // I am using a crude indicator of signal - this is fast and adequate for
  // this purpose, but it would be poor for actual CSC studies.
  int nS = 0;
  for (CSCStripDigiCollection::DigiRangeIterator jS=strips->begin(); jS!=strips->end(); jS++) {
    std::vector<CSCStripDigi>::const_iterator stripItA = (*jS).second.first;
    std::vector<CSCStripDigi>::const_iterator lastStripA = (*jS).second.second;
    for( ; stripItA != lastStripA; ++stripItA) {
      std::vector<int> myADCVals = stripItA->getADCCounts();
      int iDiff = myADCVals[4]+myADCVals[5]-myADCVals[0]-myADCVals[1];
      if (iDiff > 30) {
        nS++;
      }
    }
  }

 
  // ===============
  // DT DIGIs
  // ===============
  // see: CalibMuon/DTCalibration/plugins/DTT0Calibration.cc
  edm::Handle<DTDigiCollection>  dtDIGIs;
  event.getByLabel("muonDTDigis",dtDIGIs);

  // count the number of digis.
  int nDT = 0;
  int nDTin = 0;
  int nDTout = 0;
  for (DTDigiCollection::DigiRangeIterator jDT=dtDIGIs->begin(); jDT!=dtDIGIs->end(); ++jDT) {
    const DTDigiCollection::Range& digiRange = (*jDT).second;
    for (DTDigiCollection::const_iterator digi = digiRange.first;
         digi != digiRange.second;
         digi++) {
      double t0 = (*digi).countsTDC();
      nDT++;
      if ((t0>3050) && (t0<3700)) {
        nDTin++;
      } else {
        nDTout++;
      }
      if (fillHistograms) {
        t0All->Fill(t0);
        if (nRPC > nRPCHitsCut) {t0AllH->Fill(t0);}
      }
    }
  }

  //==============
  // Analysis
  //==============

  if (nEventsAnalyzed < 1000) {std::cout << "\tnumber of CSC DIGIS = " << nW << ", " << nS 
                                    << "\tDT DIGIS = " << nDT
                                    << "\tRPC Rechits = " << nRPC << std::endl;}

  if (fillHistograms) {

    nWires->Fill(min((float)nW,(float)120.));
    nStrips->Fill(min((float)nS,(float)200.));
    
    nDTDigis->Fill(min((float)nDT,(float)200.));
    nDTDigisIn->Fill(min((float)nDTin,(float)200.));
    nDTDigisOut->Fill(min((float)nDTout,(float)200.));
    if (nDT > 0) {
      float fracOut = float(nDTout)/float(nDT);
      fDTDigisOut->Fill(fracOut);
    }
    nRPCRecHits->Fill(min((float)nRPC,(float)100.));
    nRPCRecHitsLong->Fill(min((float)nRPC,(float)1000.));
    hitsVsSerial->Fill(nEventsAnalyzed,nRPC);
    hitsVsOrbit->Fill(relativeOrbit,nRPC);
    orbitVsSerial->Fill(nEventsAnalyzed,relativeOrbit);

    if (nRPC > nRPCHitsCut) {
      nWiresH->Fill(min((float)nW,(float)120.));
      nStripsH->Fill(min((float)nS,(float)200.));
      nDTDigisH->Fill(min((float)nDT,(float)200.));
      nDTDigisInH->Fill(min((float)nDTin,(float)200.));
      nDTDigisOutH->Fill(min((float)nDTout,(float)200.));
      if (nDT > 0) {
        float fracOut = float(nDTout)/float(nDT);
        fDTDigisOutH->Fill(fracOut);
      }
    }
  }

  // select this event for output?

  selectThisEvent = (nRPC > nRPCHitsCut) && (nW > nCSCWiresCut || nS > nCSCStripsCut) && (nDT > nDTDigisCut);
  if (selectThisEvent) {nEventsSelected++;}

  return selectThisEvent;
}

Member Data Documentation

TH1F* RPCNoise::dOrbit [private]

Definition at line 136 of file RPCNoise.cc.

TH1F* RPCNoise::fDTDigisOut [private]

Definition at line 129 of file RPCNoise.cc.

TH1F* RPCNoise::fDTDigisOutH [private]

Definition at line 130 of file RPCNoise.cc.

bool RPCNoise::fillHistograms [private]

Definition at line 107 of file RPCNoise.cc.

int RPCNoise::firstOrbit [private]

Definition at line 103 of file RPCNoise.cc.

std::string RPCNoise::histogramFileName [private]

Definition at line 113 of file RPCNoise.cc.

TProfile* RPCNoise::hitsVsOrbit [private]

Definition at line 135 of file RPCNoise.cc.

TProfile* RPCNoise::hitsVsSerial [private]

Definition at line 133 of file RPCNoise.cc.

int RPCNoise::iEvent [private]

Definition at line 102 of file RPCNoise.cc.

int RPCNoise::iRun [private]

Definition at line 101 of file RPCNoise.cc.

int RPCNoise::lastOrbit [private]

Definition at line 104 of file RPCNoise.cc.

int RPCNoise::nCSCStripsCut [private]

Definition at line 109 of file RPCNoise.cc.

int RPCNoise::nCSCWiresCut [private]

Definition at line 110 of file RPCNoise.cc.

TH1F* RPCNoise::nDTDigis [private]

Definition at line 121 of file RPCNoise.cc.

int RPCNoise::nDTDigisCut [private]

Definition at line 111 of file RPCNoise.cc.

TH1F* RPCNoise::nDTDigisH [private]

Definition at line 122 of file RPCNoise.cc.

TH1F* RPCNoise::nDTDigisIn [private]

Definition at line 125 of file RPCNoise.cc.

TH1F* RPCNoise::nDTDigisInH [private]

Definition at line 126 of file RPCNoise.cc.

TH1F* RPCNoise::nDTDigisOut [private]

Definition at line 127 of file RPCNoise.cc.

TH1F* RPCNoise::nDTDigisOutH [private]

Definition at line 128 of file RPCNoise.cc.

Definition at line 99 of file RPCNoise.cc.

Definition at line 100 of file RPCNoise.cc.

int RPCNoise::nRPCHitsCut [private]

Definition at line 108 of file RPCNoise.cc.

TH1F* RPCNoise::nRPCRecHits [private]

Definition at line 131 of file RPCNoise.cc.

TH1F* RPCNoise::nRPCRecHitsLong [private]

Definition at line 132 of file RPCNoise.cc.

TH1F* RPCNoise::nStrips [private]

Definition at line 118 of file RPCNoise.cc.

TH1F* RPCNoise::nStripsH [private]

Definition at line 120 of file RPCNoise.cc.

TH1F* RPCNoise::nWires [private]

Definition at line 117 of file RPCNoise.cc.

TH1F* RPCNoise::nWiresH [private]

Definition at line 119 of file RPCNoise.cc.

TProfile* RPCNoise::orbitVsSerial [private]

Definition at line 134 of file RPCNoise.cc.

TH1F* RPCNoise::RPCBX [private]

Definition at line 137 of file RPCNoise.cc.

TH1F* RPCNoise::RPCBXH [private]

Definition at line 139 of file RPCNoise.cc.

TH1F* RPCNoise::RPCClSize [private]

Definition at line 138 of file RPCNoise.cc.

TH1F* RPCNoise::RPCClSizeH [private]

Definition at line 140 of file RPCNoise.cc.

TH1F* RPCNoise::rpcCorner [private]

Definition at line 152 of file RPCNoise.cc.

TH1F* RPCNoise::rpcCornerH [private]

Definition at line 153 of file RPCNoise.cc.

TProfile* RPCNoise::rpcCornerVsOrbit [private]

Definition at line 154 of file RPCNoise.cc.

TH1F* RPCNoise::rpcLayer [private]

Definition at line 147 of file RPCNoise.cc.

TH1F* RPCNoise::rpcLayerH [private]

Definition at line 148 of file RPCNoise.cc.

TH1F* RPCNoise::rpcRing [private]

Definition at line 143 of file RPCNoise.cc.

TH1F* RPCNoise::rpcRingH [private]

Definition at line 144 of file RPCNoise.cc.

TProfile* RPCNoise::rpcRingVsOrbit [private]

Definition at line 151 of file RPCNoise.cc.

TH1F* RPCNoise::rpcSector [private]

Definition at line 145 of file RPCNoise.cc.

TH1F* RPCNoise::rpcSectorH [private]

Definition at line 146 of file RPCNoise.cc.

TProfile* RPCNoise::rpcSectorVsOrbit [private]

Definition at line 150 of file RPCNoise.cc.

TH1F* RPCNoise::rpcStation [private]

Definition at line 141 of file RPCNoise.cc.

TH1F* RPCNoise::rpcStationH [private]

Definition at line 142 of file RPCNoise.cc.

TProfile* RPCNoise::rpcStationVsOrbit [private]

Definition at line 149 of file RPCNoise.cc.

TH1F* RPCNoise::t0All [private]

Definition at line 123 of file RPCNoise.cc.

TH1F* RPCNoise::t0AllH [private]

Definition at line 124 of file RPCNoise.cc.

TFile* RPCNoise::theHistogramFile [private]

Definition at line 115 of file RPCNoise.cc.

int RPCNoise::thisOrbit [private]

Definition at line 105 of file RPCNoise.cc.