CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/Calibration/HcalIsolatedTrackReco/src/HITSiStripRawToClustersRoI.cc

Go to the documentation of this file.
00001 #include "Calibration/HcalIsolatedTrackReco/interface/HITSiStripRawToClustersRoI.h"
00002 #include "CalibTracker/Records/interface/SiStripRegionCablingRcd.h"
00003 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidate.h" 
00004 #include "CLHEP/Random/RandFlat.h"
00005 
00006 
00007 using namespace std;
00008 using namespace sistrip;
00009 
00010 HITSiStripRawToClustersRoI::HITSiStripRawToClustersRoI(const edm::ParameterSet& conf) :
00011 
00012   cabling_(),
00013   allregions_(),
00014   nlayers_(conf.getUntrackedParameter<int>("layers",-1)),
00015   global_(conf.getUntrackedParameter<bool>("doGlobal",true)),
00016   random_(conf.getUntrackedParameter<bool>("random",false)),
00017   taujets_(conf.getUntrackedParameter<bool>("useTauJets",false)),
00018   ptrack_(conf.getUntrackedParameter<bool>("usePixelTracks",true)),
00019   siStripLazyGetter_(conf.getParameter<edm::InputTag>("siStripLazyGetter")),
00020   taujetL1_(conf.getParameter<edm::InputTag>("l1tauJetLabel")),
00021   ptrackLabel_(conf.getParameter<edm::InputTag>("pixelTrackLabel")),
00022   taujetdeta_(conf.getUntrackedParameter<double>("tjetEtaWindow",0.2)),
00023   taujetdphi_(conf.getUntrackedParameter<double>("tjetPhiWindow",0.2)),
00024   ptrackEta_(conf.getUntrackedParameter<double>("ptrackEtaWindow",0.3)),
00025   ptrackPhi_(conf.getUntrackedParameter<double>("ptrackPhiWindow",0.3))
00026            
00027 {
00028   produces< RefGetter >();
00029 }
00030 
00031 HITSiStripRawToClustersRoI::~HITSiStripRawToClustersRoI() {}
00032 
00033 void HITSiStripRawToClustersRoI::beginJob() {}
00034 
00035 void HITSiStripRawToClustersRoI::endJob() {}
00036 
00037 void HITSiStripRawToClustersRoI::produce(edm::Event& event, const edm::EventSetup& setup) {
00038 
00039   setup.get<SiStripRegionCablingRcd>().get(cabling_);
00040   allregions_.reserve(cabling_->getRegionCabling().size());
00041   for (uint32_t iregion=0;iregion<cabling_->getRegionCabling().size();iregion++) {
00042     for (uint32_t isubdet=0;isubdet<cabling_->getRegionCabling()[iregion].size();isubdet++) {
00043       for (uint32_t ilayer=0;ilayer<cabling_->getRegionCabling()[iregion][isubdet].size();ilayer++) {
00044         uint32_t index = SiStripRegionCabling::elementIndex(iregion,static_cast<SubDet>(isubdet),ilayer);
00045         allregions_.push_back(index);
00046       }
00047     }
00048   }
00049 
00050   
00051   edm::Handle< LazyGetter > lazygetter;
00052   event.getByLabel(siStripLazyGetter_,lazygetter);
00053 
00055   
00056   if (global_) {
00057     std::auto_ptr<RefGetter> globalrefgetter(new RefGetter(lazygetter,allregions_));
00058     /*//unpack
00059       for (RefGetter::const_iterator iReg = globalrefgetter->begin(); iReg != globalrefgetter->end(); iReg++) *iReg;*/
00060     event.put(globalrefgetter);
00061     return;
00062   }
00063   
00064   std::auto_ptr<RefGetter> refgetter(new RefGetter(allregions_.size()));
00065   refgetter->reserve(10000);
00066   
00068   
00069   if (random_) {random(*refgetter,lazygetter);}
00070   
00072 
00073   if (taujets_) {
00074         edm::Handle<l1extra::L1JetParticleCollection> collection;
00075         event.getByLabel(taujetL1_,collection);
00076         taujets(*collection,*refgetter,lazygetter);
00077     }
00078 
00079 
00081   if (ptrack_) {
00082       edm::Handle<trigger::TriggerFilterObjectWithRefs> collection;
00083       event.getByLabel(ptrackLabel_,collection);
00084       ptracks(*collection,*refgetter,lazygetter);
00085     }
00086   
00087   event.put(refgetter);
00088 }
00089 
00090 bool HITSiStripRawToClustersRoI::physicalLayer(SubDet& subdet, uint32_t& layer) const {
00091   int signedlayer = static_cast<int>(SiStripRegionCabling::physicalLayer(subdet,layer));
00092   return (nlayers_ == -1 || signedlayer < nlayers_) ? true : false;
00093 }
00094 
00095 void HITSiStripRawToClustersRoI::random(RefGetter& refgetter, edm::Handle<LazyGetter>& lazygetter) const {
00096   
00097   uint32_t total = cabling_->getRegionCabling().size();
00098   uint32_t required = static_cast<uint32_t>(CLHEP::RandFlat::shoot()*(total+1));
00099   for (uint32_t iregion = 0; iregion < required; iregion++) {
00100     for (uint32_t isubdet = 0; isubdet < SiStripRegionCabling::ALLSUBDETS; isubdet++) {
00101       SubDet subdet = static_cast<SubDet>(isubdet);
00102       for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
00103         if (!physicalLayer(subdet,ilayer)) break;
00104         cabling_->updateSiStripRefGetter<SiStripCluster>(refgetter,lazygetter,SiStripRegionCabling::elementIndex(iregion,subdet,ilayer));
00105       }
00106     }
00107   }
00108 }
00109 
00110 
00111 void HITSiStripRawToClustersRoI::taujets(const l1extra::L1JetParticleCollection& collection, RefGetter& refgetter, edm::Handle<LazyGetter>& lazygetter) const {
00112 
00113   l1extra::L1JetParticleCollection::const_iterator icollection = collection.begin();
00114   for (; icollection!=collection.end(); icollection++) {
00115     Position position(icollection->eta(),icollection->phi());
00116     for (uint32_t isubdet = 0; isubdet < SiStripRegionCabling::ALLSUBDETS; isubdet++) {
00117       SubDet subdet = static_cast<SubDet>(isubdet);
00118       for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
00119         if (!physicalLayer(subdet,ilayer)) break;
00120         cabling_->updateSiStripRefGetter<SiStripCluster>(refgetter,lazygetter,position,taujetdeta_,taujetdphi_,subdet,ilayer);
00121       }
00122     }    
00123   }
00124 }
00125 
00126 
00127 void HITSiStripRawToClustersRoI::ptracks(const trigger::TriggerFilterObjectWithRefs& collection, RefGetter& refgetter, edm::Handle<LazyGetter>& lazygetter) const {
00128 
00129   std::vector< edm::Ref<reco::IsolatedPixelTrackCandidateCollection> > isoPixTrackRefs;
00130   collection.getObjects(trigger::TriggerTrack, isoPixTrackRefs);
00131   for (uint32_t p=0 ; p<isoPixTrackRefs.size(); p++) {
00132     Position position(isoPixTrackRefs[p]->track()->eta(),isoPixTrackRefs[p]->track()->phi());
00133     for (uint32_t isubdet = 0; isubdet < SiStripRegionCabling::ALLSUBDETS; isubdet++) {
00134       SubDet subdet = static_cast<SubDet>(isubdet);
00135       for (uint32_t ilayer = 0; ilayer < SiStripRegionCabling::ALLLAYERS; ilayer++) {
00136         if (!physicalLayer(subdet,ilayer)) break;
00137         cabling_->updateSiStripRefGetter<SiStripCluster>(refgetter,lazygetter,position,ptrackEta_,ptrackPhi_,subdet,ilayer);
00138       }
00139     }
00140     
00141   }
00142 }