CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
SimHitShifter Class Reference

#include <simhitshifter/SimHitShifter/src/SimHitShifter.cc>

Inheritance diagram for SimHitShifter:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 SimHitShifter (const edm::ParameterSet &)
 
 ~SimHitShifter ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Public Attributes

std::map< int, float > shiftinfo
 

Private Member Functions

virtual void beginJob (const edm::Run &, const edm::EventSetup &)
 
virtual void endJob () override
 
virtual void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

std::string ShiftFileName
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 109 of file SimHitShifter.cc.

Constructor & Destructor Documentation

SimHitShifter::SimHitShifter ( const edm::ParameterSet iConfig)
explicit

Definition at line 126 of file SimHitShifter.cc.

References assert(), gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), hltrates_dqm_sourceclient-live_cfg::offset, ShiftFileName, shiftinfo, and AlCaHLTBitMon_QueryRunRegistry::string.

127 {
128  std::cout<<"in the constructor"<<std::endl;
129 
130  ShiftFileName = iConfig.getUntrackedParameter<std::string>("ShiftFileName","/afs/cern.ch/user/c/carrillo/simhits/CMSSW_3_5_8_patch2/src/simhitshifter/SimHitShifter/Merged_Muon_RawId_Shift.txt");
131 
132  //iSetup.get<MuonGeometryRecord>().get(rpcGeo);
133 
134  std::ifstream ifin(ShiftFileName.c_str());
135 
136  int rawId;
137  float offset;
138 
139  std::cout<<"In the constructor, The name of the file is "<<ShiftFileName.c_str()<<std::endl;
140 
141  if(!ifin) std::cout<<"Problem reading the map rawId shift "<<ShiftFileName.c_str()<<std::endl;
142  assert(ifin);
143 
144  while (ifin.good()){
145  ifin >>rawId >>offset;
146  shiftinfo[rawId]=offset;
147  std::cout<<"rawId ="<<rawId<<" offset="<<offset<<std::endl;
148  }
149 
150  produces<edm::PSimHitContainer>("MuonCSCHits");
151  produces<edm::PSimHitContainer>("MuonDTHits");
152  produces<edm::PSimHitContainer>("MuonRPCHits");
153 }
T getUntrackedParameter(std::string const &, T const &) const
assert(m_qm.get())
std::map< int, float > shiftinfo
tuple cout
Definition: gather_cfg.py:121
std::string ShiftFileName
SimHitShifter::~SimHitShifter ( )

Definition at line 156 of file SimHitShifter.cc.

157 {
158 }

Member Function Documentation

void SimHitShifter::beginJob ( const edm::Run run,
const edm::EventSetup iSetup 
)
privatevirtual

Definition at line 281 of file SimHitShifter.cc.

282 {
283 
284 }
void SimHitShifter::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 274 of file SimHitShifter.cc.

275 {
276 
277 }
void SimHitShifter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 288 of file SimHitShifter.cc.

288  {
289 }
void SimHitShifter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 160 of file SimHitShifter.cc.

References CSCDetId::chamber(), CSCDetId::chamberId(), gather_cfg::cout, MuonSubdetId::CSC, CSCDetId, TauDecayModes::dec, MuonSubdetId::DT, CSCDetId::endcap(), edm::Event::getManyByType(), i, CSCDetId::layer(), DetId::Muon, edm::Event::put(), DetId::rawId(), CSCDetId::ring(), MuonSubdetId::RPC, shiftinfo, and CSCDetId::station().

160  {
161  using namespace edm;
162 
163  //std::cout << " Getting the SimHits " <<std::endl;
164  std::vector<edm::Handle<edm::PSimHitContainer> > theSimHitContainers;
165  iEvent.getManyByType(theSimHitContainers);
166  //std::cout << " The Number of sim Hits is " << theSimHitContainers.size() <<std::endl;
167 
168  std::auto_ptr<edm::PSimHitContainer> pcsc(new edm::PSimHitContainer);
169  std::auto_ptr<edm::PSimHitContainer> pdt(new edm::PSimHitContainer);
170  std::auto_ptr<edm::PSimHitContainer> prpc(new edm::PSimHitContainer);
171 
172  std::vector<PSimHit> theSimHits;
173 
174  using std::oct;
175  using std::dec;
176 
177  for (int i = 0; i < int(theSimHitContainers.size()); i++){
178  theSimHits.insert(theSimHits.end(),theSimHitContainers.at(i)->begin(),theSimHitContainers.at(i)->end());
179  }
180 
181  for (std::vector<PSimHit>::const_iterator iHit = theSimHits.begin(); iHit != theSimHits.end(); iHit++){
182  DetId theDetUnitId((*iHit).detUnitId());
183  DetId simdetid= DetId((*iHit).detUnitId());
184 
185  if(simdetid.det()!=DetId::Muon) continue;
186 
187  float newtof = 0;
188 
189  if(simdetid.det()==DetId::Muon && simdetid.subdetId()== MuonSubdetId::RPC){//Only RPCs
190  //std::cout<<"\t\t We have an RPC Sim Hit! in t="<<(*iHit).timeOfFlight()<<" DetId="<<(*iHit).detUnitId()<<std::endl;
191  if(shiftinfo.find(simdetid.rawId())==shiftinfo.end()){
192  std::cout<<"RPC Warning the RawId = "<<simdetid.det()<<" | "<<simdetid.rawId()<<"is not in the map"<<std::endl;
193  newtof = (*iHit).timeOfFlight();
194  }else{
195  newtof = (*iHit).timeOfFlight()+shiftinfo[simdetid.rawId()];
196  }
197 
198  PSimHit hit((*iHit).entryPoint(),(*iHit).exitPoint(),(*iHit).pabs(),
199  newtof,
200  (*iHit).energyLoss(),(*iHit).particleType(),simdetid,(*iHit). trackId(),(*iHit).thetaAtEntry(),(*iHit).phiAtEntry(),(*iHit).processType());
201  prpc->push_back(hit);
202  }
203  else if(simdetid.det()==DetId::Muon && simdetid.subdetId()== MuonSubdetId::DT){//Only DTs
204  int RawId = simdetid.rawId();
205  std::cout<<"We found a DT simhit the RawId in Dec is";
206  std::cout<<dec<<RawId<<std::endl;
207  std::cout<<"and in oct"<<std::endl;
208  std::cout<<oct<<RawId<< std::endl;
209  std::cout<<"once masked in oct "<<std::endl;
210  int compressedRawId = RawId/8/8/8/8/8;
211  std::cout<<compressedRawId<<std::endl;
212  std::cout<<"extendedRawId"<<std::endl;
213  int extendedRawId = compressedRawId*8*8*8*8*8;
214  std::cout<<extendedRawId<<std::endl;
215  std::cout<<"converted again in decimal"<<std::endl;
216  std::cout<<dec<<extendedRawId<<std::endl;
217 
218  if(shiftinfo.find(extendedRawId)==shiftinfo.end()){
219  //std::cout<<"DT Warning the RawId = "<<extendedRawId<<"is not in the map"<<std::endl;
220  newtof = (*iHit).timeOfFlight();
221  }else{
222  newtof = (*iHit).timeOfFlight()+shiftinfo[extendedRawId];
223  std::cout<<"RawId = "<<extendedRawId<<"is in the map "<<(*iHit).timeOfFlight()<<" "<<newtof<<std::endl;
224  }
225 
226  std::cout<<"\t\t We have an DT Sim Hit! in t="<<(*iHit).timeOfFlight()<<" DetId="<<(*iHit).detUnitId()<<std::endl;
227  PSimHit hit((*iHit).entryPoint(),(*iHit).exitPoint(),(*iHit).pabs(),
228  newtof,
229  (*iHit).energyLoss(),(*iHit).particleType(),simdetid,(*iHit). trackId(),(*iHit).thetaAtEntry(),(*iHit).phiAtEntry(),(*iHit).processType());
230  pdt->push_back(hit);
231  }
232  else if(simdetid.det()==DetId::Muon && simdetid.subdetId()== MuonSubdetId::CSC){//Only CSCs
233  //std::cout<<"\t\t We have an CSC Sim Hit! in t="<<(*iHit).timeOfFlight()<<" DetId="<<(*iHit).detUnitId()<<std::endl;
234 
235  CSCDetId TheCSCDetId = CSCDetId(simdetid);
236  CSCDetId TheChamberDetId = TheCSCDetId.chamberId();
237 
238  if(shiftinfo.find(TheChamberDetId.rawId())==shiftinfo.end()){
239  std::cout<<"The RawId is not in the map,perhaps it is on the CSCs station 1 ring 4"<<std::endl;
240  if(TheChamberDetId.station()==1 && TheChamberDetId.ring()==4){
241  CSCDetId TheChamberDetIdNoring4= CSCDetId(TheChamberDetId.endcap(),TheChamberDetId.station(),1 //1 instead of 4
242  ,TheChamberDetId.chamber(),TheChamberDetId.layer());
243 
244  if(shiftinfo.find(TheChamberDetIdNoring4.rawId())==shiftinfo.end()){
245  std::cout<<"CSC Warning the RawId = "<<TheChamberDetIdNoring4<<" "<<TheChamberDetIdNoring4.rawId()<<"is not in the map"<<std::endl;
246  newtof = (*iHit).timeOfFlight();
247  }else{
248  newtof = (*iHit).timeOfFlight()+shiftinfo[TheChamberDetIdNoring4.rawId()];
249  }
250  }
251  }else{
252  newtof = (*iHit).timeOfFlight()+shiftinfo[TheChamberDetId.rawId()];
253  }
254 
255  PSimHit hit((*iHit).entryPoint(),(*iHit).exitPoint(),(*iHit).pabs(),
256  newtof,
257  (*iHit).energyLoss(),(*iHit).particleType(),simdetid,(*iHit). trackId(),(*iHit).thetaAtEntry(),(*iHit).phiAtEntry(),(*iHit).processType());
258 
259  std::cout<<"CSC check newtof"<<newtof<<" "<<(*iHit).timeOfFlight()<<std::endl;
260  if(newtof==(*iHit).timeOfFlight())std::cout<<"Warning!!!"<<std::endl;
261  pcsc->push_back(hit);
262  }
263  }
264 
265  std::cout<<"Putting collections in the event"<<std::endl;
266 
267  iEvent.put(pcsc,"MuonCSCHits");
268  iEvent.put(pdt,"MuonDTHits");
269  iEvent.put(prpc,"MuonRPCHits");
270 
271 }
void getManyByType(std::vector< Handle< PROD > > &results) const
Definition: Event.h:439
int chamber() const
Definition: CSCDetId.h:81
int i
Definition: DBlmapReader.cc:9
int layer() const
Definition: CSCDetId.h:74
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
int endcap() const
Definition: CSCDetId.h:106
static const int CSC
Definition: MuonSubdetId.h:13
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
std::map< int, float > shiftinfo
CSCDetId chamberId() const
Definition: CSCDetId.h:66
int ring() const
Definition: CSCDetId.h:88
Definition: DetId.h:18
static const int RPC
Definition: MuonSubdetId.h:14
int station() const
Definition: CSCDetId.h:99
tuple cout
Definition: gather_cfg.py:121
static const int DT
Definition: MuonSubdetId.h:12
std::vector< PSimHit > PSimHitContainer

Member Data Documentation

std::string SimHitShifter::ShiftFileName
private

Definition at line 119 of file SimHitShifter.cc.

Referenced by SimHitShifter().

std::map<int,float> SimHitShifter::shiftinfo

Definition at line 115 of file SimHitShifter.cc.

Referenced by produce(), and SimHitShifter().