CMS 3D CMS Logo

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

void beginRun (const edm::Run &, const edm::EventSetup &) override
 
 SimHitShifter (const edm::ParameterSet &)
 
 ~SimHitShifter () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Public Attributes

std::map< int, float > shiftinfo
 

Private Member Functions

void beginJob () override
 
void endJob () override
 
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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Description: [one line class summary]

Implementation: [Notes on implementation]

Definition at line 106 of file SimHitShifter.cc.

Constructor & Destructor Documentation

◆ SimHitShifter()

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

Definition at line 121 of file SimHitShifter.cc.

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

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

◆ ~SimHitShifter()

SimHitShifter::~SimHitShifter ( )
override

Definition at line 153 of file SimHitShifter.cc.

153 {}

Member Function Documentation

◆ beginJob()

void SimHitShifter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 302 of file SimHitShifter.cc.

302 {}

◆ beginRun()

void SimHitShifter::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 299 of file SimHitShifter.cc.

299 {}

◆ endJob()

void SimHitShifter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 305 of file SimHitShifter.cc.

305 {}

◆ produce()

void SimHitShifter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDProducer.

Definition at line 155 of file SimHitShifter.cc.

155  {
156  using namespace edm;
157 
158  //std::cout << " Getting the SimHits " <<std::endl;
159  std::vector<edm::Handle<edm::PSimHitContainer> > theSimHitContainers;
160  iEvent.getManyByType(theSimHitContainers);
161  //std::cout << " The Number of sim Hits is " << theSimHitContainers.size() <<std::endl;
162 
163  std::unique_ptr<edm::PSimHitContainer> pcsc(new edm::PSimHitContainer);
164  std::unique_ptr<edm::PSimHitContainer> pdt(new edm::PSimHitContainer);
165  std::unique_ptr<edm::PSimHitContainer> prpc(new edm::PSimHitContainer);
166 
167  std::vector<PSimHit> theSimHits;
168 
169  using std::dec;
170  using std::oct;
171 
172  for (int i = 0; i < int(theSimHitContainers.size()); i++) {
173  theSimHits.insert(theSimHits.end(), theSimHitContainers.at(i)->begin(), theSimHitContainers.at(i)->end());
174  }
175 
176  for (std::vector<PSimHit>::const_iterator iHit = theSimHits.begin(); iHit != theSimHits.end(); iHit++) {
177  DetId theDetUnitId((*iHit).detUnitId());
178  DetId simdetid = DetId((*iHit).detUnitId());
179 
180  if (simdetid.det() != DetId::Muon)
181  continue;
182 
183  float newtof = 0;
184 
185  if (simdetid.det() == DetId::Muon && simdetid.subdetId() == MuonSubdetId::RPC) { //Only RPCs
186  //std::cout<<"\t\t We have an RPC Sim Hit! in t="<<(*iHit).timeOfFlight()<<" DetId="<<(*iHit).detUnitId()<<std::endl;
187  if (shiftinfo.find(simdetid.rawId()) == shiftinfo.end()) {
188  std::cout << "RPC Warning the RawId = " << simdetid.det() << " | " << simdetid.rawId() << "is not in the map"
189  << std::endl;
190  newtof = (*iHit).timeOfFlight();
191  } else {
192  newtof = (*iHit).timeOfFlight() + shiftinfo[simdetid.rawId()];
193  }
194 
195  PSimHit hit((*iHit).entryPoint(),
196  (*iHit).exitPoint(),
197  (*iHit).pabs(),
198  newtof,
199  (*iHit).energyLoss(),
200  (*iHit).particleType(),
201  simdetid,
202  (*iHit).trackId(),
203  (*iHit).thetaAtEntry(),
204  (*iHit).phiAtEntry(),
205  (*iHit).processType());
206  prpc->push_back(hit);
207  } else if (simdetid.det() == DetId::Muon && simdetid.subdetId() == MuonSubdetId::DT) { //Only DTs
208  int RawId = simdetid.rawId();
209  std::cout << "We found a DT simhit the RawId in Dec is";
210  std::cout << dec << RawId << std::endl;
211  std::cout << "and in oct" << std::endl;
212  std::cout << oct << RawId << std::endl;
213  std::cout << "once masked in oct " << std::endl;
214  int compressedRawId = RawId / 8 / 8 / 8 / 8 / 8;
215  std::cout << compressedRawId << std::endl;
216  std::cout << "extendedRawId" << std::endl;
217  int extendedRawId = compressedRawId * 8 * 8 * 8 * 8 * 8;
218  std::cout << extendedRawId << std::endl;
219  std::cout << "converted again in decimal" << std::endl;
220  std::cout << dec << extendedRawId << std::endl;
221 
222  if (shiftinfo.find(extendedRawId) == shiftinfo.end()) {
223  //std::cout<<"DT Warning the RawId = "<<extendedRawId<<"is not in the map"<<std::endl;
224  newtof = (*iHit).timeOfFlight();
225  } else {
226  newtof = (*iHit).timeOfFlight() + shiftinfo[extendedRawId];
227  std::cout << "RawId = " << extendedRawId << "is in the map " << (*iHit).timeOfFlight() << " " << newtof
228  << std::endl;
229  }
230 
231  std::cout << "\t\t We have an DT Sim Hit! in t=" << (*iHit).timeOfFlight() << " DetId=" << (*iHit).detUnitId()
232  << std::endl;
233  PSimHit hit((*iHit).entryPoint(),
234  (*iHit).exitPoint(),
235  (*iHit).pabs(),
236  newtof,
237  (*iHit).energyLoss(),
238  (*iHit).particleType(),
239  simdetid,
240  (*iHit).trackId(),
241  (*iHit).thetaAtEntry(),
242  (*iHit).phiAtEntry(),
243  (*iHit).processType());
244  pdt->push_back(hit);
245  } else if (simdetid.det() == DetId::Muon && simdetid.subdetId() == MuonSubdetId::CSC) { //Only CSCs
246  //std::cout<<"\t\t We have an CSC Sim Hit! in t="<<(*iHit).timeOfFlight()<<" DetId="<<(*iHit).detUnitId()<<std::endl;
247 
248  CSCDetId TheCSCDetId = CSCDetId(simdetid);
249  CSCDetId TheChamberDetId = TheCSCDetId.chamberId();
250 
251  if (shiftinfo.find(TheChamberDetId.rawId()) == shiftinfo.end()) {
252  std::cout << "The RawId is not in the map,perhaps it is on the CSCs station 1 ring 4" << std::endl;
253  if (TheChamberDetId.station() == 1 && TheChamberDetId.ring() == 4) {
254  CSCDetId TheChamberDetIdNoring4 = CSCDetId(TheChamberDetId.endcap(),
255  TheChamberDetId.station(),
256  1 //1 instead of 4
257  ,
258  TheChamberDetId.chamber(),
259  TheChamberDetId.layer());
260 
261  if (shiftinfo.find(TheChamberDetIdNoring4.rawId()) == shiftinfo.end()) {
262  std::cout << "CSC Warning the RawId = " << TheChamberDetIdNoring4 << " " << TheChamberDetIdNoring4.rawId()
263  << "is not in the map" << std::endl;
264  newtof = (*iHit).timeOfFlight();
265  } else {
266  newtof = (*iHit).timeOfFlight() + shiftinfo[TheChamberDetIdNoring4.rawId()];
267  }
268  }
269  } else {
270  newtof = (*iHit).timeOfFlight() + shiftinfo[TheChamberDetId.rawId()];
271  }
272 
273  PSimHit hit((*iHit).entryPoint(),
274  (*iHit).exitPoint(),
275  (*iHit).pabs(),
276  newtof,
277  (*iHit).energyLoss(),
278  (*iHit).particleType(),
279  simdetid,
280  (*iHit).trackId(),
281  (*iHit).thetaAtEntry(),
282  (*iHit).phiAtEntry(),
283  (*iHit).processType());
284 
285  std::cout << "CSC check newtof" << newtof << " " << (*iHit).timeOfFlight() << std::endl;
286  if (newtof == (*iHit).timeOfFlight())
287  std::cout << "Warning!!!" << std::endl;
288  pcsc->push_back(hit);
289  }
290  }
291 
292  std::cout << "Putting collections in the event" << std::endl;
293 
294  iEvent.put(std::move(pcsc), "MuonCSCHits");
295  iEvent.put(std::move(pdt), "MuonDTHits");
296  iEvent.put(std::move(prpc), "MuonRPCHits");
297 }

References CSCDetId::chamber(), CSCDetId::chamberId(), gather_cfg::cout, MuonSubdetId::CSC, TauDecayModes::dec, MuonSubdetId::DT, CSCDetId::endcap(), mps_fire::i, iEvent, createfilelist::int, CSCDetId::layer(), eostools::move(), DetId::Muon, DetId::rawId(), CSCDetId::ring(), MuonSubdetId::RPC, shiftinfo, and CSCDetId::station().

Member Data Documentation

◆ ShiftFileName

std::string SimHitShifter::ShiftFileName
private

Definition at line 115 of file SimHitShifter.cc.

Referenced by SimHitShifter().

◆ shiftinfo

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

Definition at line 112 of file SimHitShifter.cc.

Referenced by produce(), and SimHitShifter().

MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
mps_fire.i
i
Definition: mps_fire.py:355
edm
HLT enums.
Definition: AlignableModifier.h:19
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
gather_cfg.cout
cout
Definition: gather_cfg.py:144
cms::cuda::assert
assert(be >=bs)
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
DetId
Definition: DetId.h:17
CSCDetId::layer
int layer() const
Definition: CSCDetId.h:56
MuonSubdetId::DT
static constexpr int DT
Definition: MuonSubdetId.h:11
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CSCDetId
Definition: CSCDetId.h:26
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
SimHitShifter::shiftinfo
std::map< int, float > shiftinfo
Definition: SimHitShifter.cc:112
CSCDetId::chamberId
CSCDetId chamberId() const
Definition: CSCDetId.h:47
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
eostools.move
def move(src, dest)
Definition: eostools.py:511
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
MuonSubdetId::RPC
static constexpr int RPC
Definition: MuonSubdetId.h:13
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
DetId::Muon
Definition: DetId.h:26
SimHitShifter::ShiftFileName
std::string ShiftFileName
Definition: SimHitShifter.cc:115
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
PSimHit
Definition: PSimHit.h:15
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:78
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
hit
Definition: SiStripHitEffFromCalibTree.cc:88