CMS 3D CMS Logo

MixingWorker.cc

Go to the documentation of this file.
00001 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00002 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
00003 #include "SimDataFormats/HepMCProduct/interface/HepMCProduct.h"
00004 #include "MixingWorker.h"
00005 
00006 template <> const int  edm::MixingWorker<PSimHit>::lowTrackTof = -36; 
00007 template <> const int  edm::MixingWorker<PSimHit>::highTrackTof = 36; 
00008 template <> const int  edm::MixingWorker<PSimHit>::limHighLowTof = 36; 
00009 
00010 namespace edm {
00011 
00012 template <>
00013 void MixingWorker<PSimHit>::addPileups(const int bcr, Event* e,unsigned int eventNr,int vertexoffset)
00014 {
00015   // default version changed for high/low treatment
00016   if (!isTracker_) {
00017     Handle<std::vector<PSimHit> >  result_t;
00018     bool got =e->getByLabel(tag_,result_t);
00019     if (got) {
00020       LogDebug("MixingModule") <<"For "<<subdet_<<", "<<result_t.product()->size()<<"  pileup objects  added, eventNr "<<eventNr;
00021       crFrame_->addPileups(bcr,result_t.product(),eventNr,vertexoffset);
00022     }
00023   }else {
00024     // Tracker treatment
00025     // do not read branches if clearly outside of tof bounds (and verification is asked for, default)
00026     // we have to add hits from this subdetector + opposite one
00027 
00028     Handle<std::vector<PSimHit> >  simhitshigh,simhitslow;
00029     bool gotHigh,gotLow;
00030 
00031     if(trackerHigh_) {
00032       gotHigh=e->getByLabel(tag_,simhitshigh);
00033       gotLow=e->getByLabel(opp_,simhitslow);
00034     }
00035     else {
00036       gotHigh=e->getByLabel(opp_,simhitshigh);
00037       gotLow=e->getByLabel(tag_,simhitslow);
00038     }
00039 
00040     // add HighTof simhits to high and low signals
00041     float tof = bcr*crFrame_->getBunchSpace();
00042     if (gotHigh) {
00043       if ( !checktof_ || ((limHighLowTof +tof ) <= highTrackTof)) { 
00044         crFrame_->addPileups(bcr,simhitshigh.product(),eventNr,0,checktof_,trackerHigh_);
00045         LogDebug("MixingModule") <<"For bcr "<<bcr<<", "<<subdet_<<", evNr "<<eventNr<<", "<<simhitshigh->size()<<" Hits added from high";
00046       }
00047     }
00048 
00049     // add LowTof simhits to high and low signals
00050     if (gotLow) {
00051       if (  !checktof_ || ((tof+limHighLowTof) >= lowTrackTof && tof <= highTrackTof)) {
00052         crFrame_->addPileups(bcr,simhitslow.product(),eventNr,0,checktof_,trackerHigh_);
00053         LogDebug("MixingModule") <<"For bcr "<<bcr<<", "<<subdet_<<", evNr "<<eventNr<<", "<<simhitslow->size()<<" Hits added from low";
00054       }
00055     }
00056   }
00057 
00058 }
00059 
00060 
00061 template <>
00062 void MixingWorker<SimTrack>::addPileups(const int bcr, Event* e,unsigned int eventNr,int vertexoffset)
00063 {
00064   // default version changed to transmit vertexoffset
00065   Handle<std::vector<SimTrack> >  result_t;
00066   bool got =   e->getByLabel(tag_,result_t);
00067   if (got) {
00068     LogDebug("MixingModule") <<result_t.product()->size()<<"  pileup tracks  added, eventNr "<<eventNr;
00069     crFrame_->addPileups(bcr,result_t.product(),eventNr,vertexoffset);
00070   }
00071 }
00072 
00073 template <>
00074 void MixingWorker<SimVertex>::addPileups(const int bcr, Event* e,unsigned int eventNr,int vertexoffset)
00075 {
00076   // default version changed to take care of vertexoffset
00077   Handle<std::vector<SimVertex> >  result;
00078   bool got = e->getByLabel(tag_,result);
00079   if (got) {
00080     LogDebug("MixingModule") <<result.product()->size()<<"  pileup vertices  added, eventNr "<<eventNr;
00081     crFrame_->addPileups(bcr,result.product(),eventNr);
00082     vertexoffset+=result.product()->size();
00083   }
00084 
00085 }
00086 
00087 
00088 template <>
00089 void MixingWorker<HepMCProduct>::addPileups(const int bcr, Event* e,unsigned int eventNr,int vertexoffset)
00090 {
00091   //HepMC - we are creating a dummy vector, to have the same interfaces as for the other objects
00092   Handle<HepMCProduct>  result_mc;
00093   bool got = e->getByLabel(tag_,result_mc);
00094   if (got){
00095     LogDebug("MixingModule") <<"  pileup HepMCProduct added";
00096     std::vector<HepMCProduct> vec;
00097     vec.push_back(*(result_mc.product()));
00098     crFrame_->addPileups(bcr,&vec,eventNr);
00099   }
00100 }
00101 
00102 template <>
00103 void MixingWorker<HepMCProduct>::addSignals(const Event &e){
00104   // version for HepMCProduct is specific since it doesnt come as a vector
00105   // we have to read it differently, and to store it in a (fake) vector
00106   Handle<HepMCProduct>  result_t;
00107   bool got = e.getByLabel(tag_,result_t);
00108   if (got) {
00109     LogDebug("MixingModule") <<" adding HepMCProduct from signal event  with "<<tag_;
00110     std::vector<HepMCProduct> vec;
00111     vec.push_back(*(result_t.product()));
00112     crFrame_->addSignals(&vec,e.id());
00113   }
00114   else    LogWarning("MixingModule") <<"!!!!!!! Did not get any signal data for HepMCProduct with "<<tag_;
00115 }
00116 
00117 }

Generated on Tue Jun 9 17:47:28 2009 for CMSSW by  doxygen 1.5.4