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 ()
 
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)
 
virtual ~ProducerBase () noexcept(false)
 
- 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
 
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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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)
 
- 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 108 of file SimHitShifter.cc.

Constructor & Destructor Documentation

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

Definition at line 125 of file SimHitShifter.cc.

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

126 {
127  std::cout<<"in the constructor"<<std::endl;
128 
129  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");
130 
131  //iSetup.get<MuonGeometryRecord>().get(rpcGeo);
132 
133  std::ifstream ifin(ShiftFileName.c_str());
134 
135  int rawId;
136  float offset;
137 
138  std::cout<<"In the constructor, The name of the file is "<<ShiftFileName.c_str()<<std::endl;
139 
140  if(!ifin) std::cout<<"Problem reading the map rawId shift "<<ShiftFileName.c_str()<<std::endl;
141  assert(ifin);
142 
143  while (ifin.good()){
144  ifin >>rawId >>offset;
145  shiftinfo[rawId]=offset;
146  std::cout<<"rawId ="<<rawId<<" offset="<<offset<<std::endl;
147  }
148 
149  produces<edm::PSimHitContainer>("MuonCSCHits");
150  produces<edm::PSimHitContainer>("MuonDTHits");
151  produces<edm::PSimHitContainer>("MuonRPCHits");
152 }
T getUntrackedParameter(std::string const &, T const &) const
std::map< int, float > shiftinfo
std::string ShiftFileName
SimHitShifter::~SimHitShifter ( )
override

Definition at line 155 of file SimHitShifter.cc.

156 {
157 }

Member Function Documentation

void SimHitShifter::beginJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 280 of file SimHitShifter.cc.

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

Definition at line 273 of file SimHitShifter.cc.

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

Reimplemented from edm::EDProducer.

Definition at line 287 of file SimHitShifter.cc.

References DEFINE_FWK_MODULE.

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

Definition at line 159 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().

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

Member Data Documentation

std::string SimHitShifter::ShiftFileName
private

Definition at line 118 of file SimHitShifter.cc.

Referenced by SimHitShifter().

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

Definition at line 114 of file SimHitShifter.cc.

Referenced by produce(), and SimHitShifter().