CMS 3D CMS Logo

Public Member Functions | Private Attributes

RPCRecHitProducer Class Reference

#include <RPCRecHitProducer.h>

Inheritance diagram for RPCRecHitProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void beginRun (edm::Run &, const edm::EventSetup &)
virtual void endRun (edm::Run &, const edm::EventSetup &)
virtual void produce (edm::Event &event, const edm::EventSetup &setup)
 The method which produces the rechits.
 RPCRecHitProducer (const edm::ParameterSet &config)
 Constructor.
virtual ~RPCRecHitProducer ()
 Destructor.

Private Attributes

std::string deadSource
std::vector
< RPCDeadStrips::DeadItem
DeadVec
std::string maskSource
std::vector
< RPCMaskedStrips::MaskItem
MaskVec
RPCDeadStripsRPCDeadStripsObj
RPCMaskedStripsRPCMaskedStripsObj
RPCRecHitBaseAlgotheAlgo
edm::InputTag theRPCDigiLabel

Detailed Description

Module for RPCRecHit production.

Date:
2010/10/19 19:18:52
Revision:
1.6
Author:
M. Maggim -- INFN Bari

Definition at line 41 of file RPCRecHitProducer.h.


Constructor & Destructor Documentation

RPCRecHitProducer::RPCRecHitProducer ( const edm::ParameterSet config)

Constructor.

Definition at line 39 of file RPCRecHitProducer.cc.

References ExpressReco_HICollisions_FallBack::cerr, ExpressReco_HICollisions_FallBack::deadSource, cmsRelvalreport::exit, edm::FileInPath::fullPath(), reco::get(), edm::ParameterSet::getParameter(), recoMuon::in, analyzePatCleaning_cfg::inputFile, ExpressReco_HICollisions_FallBack::maskSource, RPCMaskedStrips::MaskItem::rawId, RPCDeadStrips::DeadItem::rawId, RPCMaskedStrips::MaskItem::strip, and RPCDeadStrips::DeadItem::strip.

                                                              {

  // Set verbose output

  produces<RPCRecHitCollection>();

  theRPCDigiLabel = config.getParameter<InputTag>("rpcDigiLabel");
  
  // Get the concrete reconstruction algo from the factory

  string theAlgoName = config.getParameter<string>("recAlgo");
  theAlgo = RPCRecHitAlgoFactory::get()->create(theAlgoName,
                                                config.getParameter<ParameterSet>("recAlgoConfig"));

  // Get masked- and dead-strip information

  RPCMaskedStripsObj = new RPCMaskedStrips();

  RPCDeadStripsObj = new RPCDeadStrips();

  maskSource = config.getParameter<std::string>("maskSource");

  if (maskSource == "File") {
    edm::FileInPath fp = config.getParameter<edm::FileInPath>("maskvecfile");
    std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
    if ( !inputFile ) {
      std::cerr << "Masked Strips File cannot not be opened" << std::endl;
      exit(1);
    }
    while ( inputFile.good() ) {
      RPCMaskedStrips::MaskItem Item;
      inputFile >> Item.rawId >> Item.strip;
      if ( inputFile.good() ) MaskVec.push_back(Item);
    }
    inputFile.close();
  }

  deadSource = config.getParameter<std::string>("deadSource");

  if (deadSource == "File") {
    edm::FileInPath fp = config.getParameter<edm::FileInPath>("deadvecfile");
    std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
    if ( !inputFile ) {
      std::cerr << "Dead Strips File cannot not be opened" << std::endl;
      exit(1);
    }
    while ( inputFile.good() ) {
      RPCDeadStrips::DeadItem Item;
      inputFile >> Item.rawId >> Item.strip;
      if ( inputFile.good() ) DeadVec.push_back(Item);
    }
    inputFile.close();
  }

}
RPCRecHitProducer::~RPCRecHitProducer ( ) [virtual]

Destructor.

Definition at line 96 of file RPCRecHitProducer.cc.

                                     {

  delete theAlgo;
  delete RPCMaskedStripsObj;
  delete RPCDeadStripsObj;

}

Member Function Documentation

void RPCRecHitProducer::beginRun ( edm::Run r,
const edm::EventSetup setup 
) [virtual]

Reimplemented from edm::EDProducer.

Definition at line 106 of file RPCRecHitProducer.cc.

References ExpressReco_HICollisions_FallBack::deadSource, RPCDeadStrips::DeadVec, edm::EventSetup::get(), ExpressReco_HICollisions_FallBack::maskSource, RPCMaskedStrips::MaskVec, edm::ESHandle< T >::product(), RPCMaskedStrips::MaskItem::rawId, RPCDeadStrips::DeadItem::rawId, RPCMaskedStrips::MaskItem::strip, and RPCDeadStrips::DeadItem::strip.

                                                                      {

  // Getting the masked-strip information

  if ( maskSource == "EventSetup" ) {
    edm::ESHandle<RPCMaskedStrips> readoutMaskedStrips;
    setup.get<RPCMaskedStripsRcd>().get(readoutMaskedStrips);
    const RPCMaskedStrips* tmp_obj = readoutMaskedStrips.product();
    RPCMaskedStripsObj->MaskVec = tmp_obj->MaskVec;
    delete tmp_obj;
  }
  else if ( maskSource == "File" ) {
    std::vector<RPCMaskedStrips::MaskItem>::iterator posVec;
    for ( posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec ) {
      RPCMaskedStrips::MaskItem Item; 
      Item.rawId = (*posVec).rawId;
      Item.strip = (*posVec).strip;
      RPCMaskedStripsObj->MaskVec.push_back(Item);
    }
  }

  // Getting the dead-strip information

  if ( deadSource == "EventSetup" ) {
    edm::ESHandle<RPCDeadStrips> readoutDeadStrips;
    setup.get<RPCDeadStripsRcd>().get(readoutDeadStrips);
    const RPCDeadStrips* tmp_obj = readoutDeadStrips.product();
    RPCDeadStripsObj->DeadVec = tmp_obj->DeadVec;
    delete tmp_obj;
  }
  else if ( deadSource == "File" ) {
    std::vector<RPCDeadStrips::DeadItem>::iterator posVec;
    for ( posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec ) {
      RPCDeadStrips::DeadItem Item;
      Item.rawId = (*posVec).rawId;
      Item.strip = (*posVec).strip;
      RPCDeadStripsObj->DeadVec.push_back(Item);
    }
  }

}
virtual void RPCRecHitProducer::endRun ( edm::Run ,
const edm::EventSetup  
) [inline, virtual]

Reimplemented from edm::EDProducer.

Definition at line 52 of file RPCRecHitProducer.h.

{;}
void RPCRecHitProducer::produce ( edm::Event event,
const edm::EventSetup setup 
) [virtual]

The method which produces the rechits.

Implements edm::EDProducer.

Definition at line 150 of file RPCRecHitProducer.cc.

References edm::OwnVector< T, P >::begin(), edm::OwnVector< T, P >::end(), edm::EventSetup::get(), i, DetId::rawId(), and edm::OwnVector< T, P >::size().

                                                                     {

  // Get the RPC Geometry

  ESHandle<RPCGeometry> rpcGeom;
  setup.get<MuonGeometryRecord>().get(rpcGeom);

  // Get the digis from the event

  Handle<RPCDigiCollection> digis; 
  event.getByLabel(theRPCDigiLabel,digis);

  // Pass the EventSetup to the algo

  theAlgo->setES(setup);

  // Create the pointer to the collection which will store the rechits

  auto_ptr<RPCRecHitCollection> recHitCollection(new RPCRecHitCollection());

  // Iterate through all digi collections ordered by LayerId   

  RPCDigiCollection::DigiRangeIterator rpcdgIt;
  for (rpcdgIt = digis->begin(); rpcdgIt != digis->end();
       ++rpcdgIt){
       
    // The layerId
    const RPCDetId& rpcId = (*rpcdgIt).first;

    // Get the GeomDet from the setup
    const RPCRoll* roll = rpcGeom->roll(rpcId);

    // Get the iterators over the digis associated with this LayerId
    const RPCDigiCollection::Range& range = (*rpcdgIt).second;


    // Getting the roll mask, that includes dead strips, for the given RPCDet

    RollMask mask;
    int rawId = rpcId.rawId();
    int Size = RPCMaskedStripsObj->MaskVec.size();
    for (int i = 0; i < Size; i++ ) {
      if ( RPCMaskedStripsObj->MaskVec[i].rawId == rawId ) {
        int bit = RPCMaskedStripsObj->MaskVec[i].strip;
        mask.set(bit-1);
      }
    }

    Size = RPCDeadStripsObj->DeadVec.size();
    for (int i = 0; i < Size; i++ ) {
      if ( RPCDeadStripsObj->DeadVec[i].rawId == rawId ) {
        int bit = RPCDeadStripsObj->DeadVec[i].strip;
        mask.set(bit-1);
      }
    }

    // Call the reconstruction algorithm    

    OwnVector<RPCRecHit> recHits =
      theAlgo->reconstruct(*roll, rpcId, range, mask);
    
    if(recHits.size() > 0) //FIXME: is it really needed?
      recHitCollection->put(rpcId, recHits.begin(), recHits.end());
  }

  event.put(recHitCollection);

}

Member Data Documentation

std::string RPCRecHitProducer::deadSource [private]

Definition at line 73 of file RPCRecHitProducer.h.

Definition at line 76 of file RPCRecHitProducer.h.

std::string RPCRecHitProducer::maskSource [private]

Definition at line 72 of file RPCRecHitProducer.h.

Definition at line 75 of file RPCRecHitProducer.h.

Definition at line 69 of file RPCRecHitProducer.h.

Definition at line 66 of file RPCRecHitProducer.h.

Definition at line 63 of file RPCRecHitProducer.h.

Definition at line 60 of file RPCRecHitProducer.h.