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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 106 of file SimHitShifter.cc.

Constructor & Destructor Documentation

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

Definition at line 121 of file SimHitShifter.cc.

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

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 }
T getUntrackedParameter(std::string const &, T const &) const
std::map< int, float > shiftinfo
std::string ShiftFileName
SimHitShifter::~SimHitShifter ( )
override

Definition at line 153 of file SimHitShifter.cc.

153 {}

Member Function Documentation

void SimHitShifter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 302 of file SimHitShifter.cc.

302 {}
void SimHitShifter::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
override

Definition at line 299 of file SimHitShifter.cc.

299 {}
void SimHitShifter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 305 of file SimHitShifter.cc.

References DEFINE_FWK_MODULE.

305 {}
void SimHitShifter::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 155 of file SimHitShifter.cc.

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

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 }
int chamber() const
Definition: CSCDetId.h:62
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: Event.h:516
int layer() const
Definition: CSCDetId.h:56
int endcap() const
Definition: CSCDetId.h:85
CSCDetId chamberId() const
Definition: CSCDetId.h:47
int ring() const
Definition: CSCDetId.h:68
Definition: DetId.h:17
static constexpr int RPC
Definition: MuonSubdetId.h:13
HLT enums.
int station() const
Definition: CSCDetId.h:79
std::vector< PSimHit > PSimHitContainer
static constexpr int DT
Definition: MuonSubdetId.h:11
static constexpr int CSC
Definition: MuonSubdetId.h:12
std::map< int, float > shiftinfo
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

std::string SimHitShifter::ShiftFileName
private

Definition at line 115 of file SimHitShifter.cc.

Referenced by SimHitShifter().

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

Definition at line 112 of file SimHitShifter.cc.

Referenced by produce(), and SimHitShifter().