CMS 3D CMS Logo

CSCTriggerPrimitivesProducer.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: CSCTriggerPrimitivesProducer
4 //
5 // Description: Steering routine of the local Level-1 Cathode Strip Chamber
6 // trigger.
7 //
8 // Author List: S. Valuev, UCLA.
9 //
10 //
11 // Modifications:
12 //
13 //--------------------------------------------------
14 
17 
21 
27 
28 //#include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
29 //#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
33 
35 
36 // Configuration via EventSetup
39 
40 
42 
43  // if false, parameters will be read in from DB using EventSetup mechanism
44  // else will use all parameters from the config file
45  debugParameters_ = conf.getParameter<bool>("debugParameters");
46 
47  wireDigiProducer_ = conf.getParameter<edm::InputTag>("CSCWireDigiProducer");
48  compDigiProducer_ = conf.getParameter<edm::InputTag>("CSCComparatorDigiProducer");
49  gemPadDigiProducer_ = conf.existsAs<edm::InputTag>("GEMPadDigiProducer")?conf.getParameter<edm::InputTag>("GEMPadDigiProducer"):edm::InputTag("");
50  rpcDigiProducer_ = conf.existsAs<edm::InputTag>("RPCDigiProducer")?conf.getParameter<edm::InputTag>("RPCDigiProducer"):edm::InputTag("");
51  checkBadChambers_ = conf.getParameter<bool>("checkBadChambers");
52 
53  const edm::ParameterSet commonParam(conf.getParameter<edm::ParameterSet>("commonParam"));
54  runME11ILT_ = commonParam.existsAs<bool>("runME11ILT")?commonParam.getParameter<bool>("runME11ILT"):false;
55  runME21ILT_ = commonParam.existsAs<bool>("runME21ILT")?commonParam.getParameter<bool>("runME21ILT"):false;
56 
57  lctBuilder_.reset( new CSCTriggerPrimitivesBuilder(conf) ); // pass on the conf
58 
59  wire_token_ = consumes<CSCWireDigiCollection>(wireDigiProducer_);
60  comp_token_ = consumes<CSCComparatorDigiCollection>(compDigiProducer_);
61  gem_pad_token_ = consumes<GEMPadDigiCollection>(gemPadDigiProducer_);
62  rpc_digi_token_ = consumes<RPCDigiCollection>(rpcDigiProducer_);
63 
64  // register what this produces
65  produces<CSCALCTDigiCollection>();
66  produces<CSCCLCTDigiCollection>();
67  produces<CSCCLCTPreTriggerCollection>();
68  produces<CSCCorrelatedLCTDigiCollection>();
69  produces<CSCCorrelatedLCTDigiCollection>("MPCSORTED");
71  produces<GEMCoPadDigiCollection>();
72  usesResource("CSCTriggerGeometry");
73  consumes<CSCComparatorDigiCollection>(compDigiProducer_);
74  consumes<CSCWireDigiCollection>(wireDigiProducer_);
75  consumes<GEMPadDigiCollection>(gemPadDigiProducer_);
76  consumes<RPCDigiCollection>(rpcDigiProducer_);
77 }
78 
80  LogDebug("L1CSCTrigger")
81  << "deleting trigger primitives after " << iev << " events.";
82 }
83 
84 //void CSCTriggerPrimitivesProducer::beginRun(const edm::EventSetup& setup) {
85 //}
86 
88  const edm::EventSetup& setup) {
89 
90  LogDebug("L1CSCTrigger") << "start producing LCTs for event " << ++iev;
91 
92  // Find the geometry (& conditions?) for this event & cache it in
93  // CSCTriggerGeometry.
94 
96  setup.get<MuonGeometryRecord>().get(h);
98  lctBuilder_->setCSCGeometry(&*h);
99 
101  setup.get<MuonGeometryRecord>().get(h_gem);
102  if (h_gem.isValid()) {
103  lctBuilder_->setGEMGeometry(&*h_gem);
104  } else {
105  edm::LogInfo("L1CSCTPEmulatorNoGEMGeometry")
106  << "+++ Info: GEM geometry is unavailable. Running CSC-only trigger algorithm. +++\n";
107  }
108 
110  setup.get<MuonGeometryRecord>().get(h_rpc);
111  if (h_rpc.isValid()) {
112  lctBuilder_->setRPCGeometry(&*h_rpc);
113  } else {
114  edm::LogInfo("L1CSCTPEmulatorNoRPCGeometry")
115  << "+++ Info: RPC geometry is unavailable. Running CSC-only trigger algorithm. +++\n";
116  }
117 
118  // Find conditions data for bad chambers.
119  edm::ESHandle<CSCBadChambers> pBadChambers;
120  setup.get<CSCBadChambersRcd>().get(pBadChambers);
121 
122  // If !debugParameters then get config parameters using EventSetup mechanism.
123  // This must be done in produce() for every event and not in beginJob()
124  // (see mail from Jim Brooke sent to hn-cms-L1TrigEmulator on July 30, 2007).
125  if (!debugParameters_) {
127  setup.get<CSCDBL1TPParametersRcd>().get(conf);
128  if (conf.product() == 0) {
129  edm::LogError("L1CSCTPEmulatorConfigError")
130  << "+++ Failed to find a CSCDBL1TPParametersRcd in EventSetup! +++\n"
131  << "+++ Cannot continue emulation without these parameters +++\n";
132  return;
133  }
134  lctBuilder_->setConfigParameters(conf.product());
135  }
136 
137  // temporary hack to run on data
138  lctBuilder_->runOnData(ev.eventAuxiliary().isRealData());
139 
140  // Get the collections of comparator & wire digis from event.
143  // ev.getByLabel(compDigiProducer_.label(), compDigiProducer_.instance(), compDigis);
144  // ev.getByLabel(wireDigiProducer_.label(), wireDigiProducer_.instance(), wireDigis);
145  ev.getByToken(comp_token_, compDigis);
146  ev.getByToken(wire_token_, wireDigis);
147 
148 
149  const GEMPadDigiCollection *gemPads = nullptr;
150  if (!gemPadDigiProducer_.label().empty()) {
152  ev.getByToken(gem_pad_token_, gemPadDigis);
153  gemPads = gemPadDigis.product();
154  }
155 
156  const RPCDigiCollection *rpcDigis = nullptr;
157  if (!rpcDigiProducer_.label().empty()) {
159  ev.getByToken(rpc_digi_token_, rpcs);
160  rpcDigis = rpcs.product();
161  }
162 
163  // Create empty collections of ALCTs, CLCTs, and correlated LCTs upstream
164  // and downstream of MPC.
165  std::unique_ptr<CSCALCTDigiCollection> oc_alct(new CSCALCTDigiCollection);
166  std::unique_ptr<CSCCLCTDigiCollection> oc_clct(new CSCCLCTDigiCollection);
167  std::unique_ptr<CSCCLCTPreTriggerCollection> oc_pretrig(new CSCCLCTPreTriggerCollection);
168  std::unique_ptr<CSCCorrelatedLCTDigiCollection> oc_lct(new CSCCorrelatedLCTDigiCollection);
169  std::unique_ptr<CSCCorrelatedLCTDigiCollection> oc_sorted_lct(new CSCCorrelatedLCTDigiCollection);
170  std::unique_ptr<GEMCoPadDigiCollection> oc_gemcopad(new GEMCoPadDigiCollection);
171 
172  if (!wireDigis.isValid()) {
173  edm::LogWarning("L1CSCTPEmulatorNoInputCollection")
174  << "+++ Warning: Collection of wire digis with label "
176  << " requested in configuration, but not found in the event..."
177  << " Skipping production of CSC TP digis +++\n";
178  }
179  if (!compDigis.isValid()) {
180  edm::LogWarning("L1CSCTPEmulatorNoInputCollection")
181  << "+++ Warning: Collection of comparator digis with label "
183  << " requested in configuration, but not found in the event..."
184  << " Skipping production of CSC TP digis +++\n";
185  }
186  // Fill output collections if valid input collections are available.
187  if (wireDigis.isValid() && compDigis.isValid()) {
188  const CSCBadChambers* temp = checkBadChambers_ ? pBadChambers.product() : new CSCBadChambers;
189  lctBuilder_->build(temp,
190  wireDigis.product(), compDigis.product(), gemPads, rpcDigis,
191  *oc_alct, *oc_clct, *oc_pretrig, *oc_lct, *oc_sorted_lct, *oc_gemcopad);
192  if (!checkBadChambers_)
193  delete temp;
194  }
195 
196  // Put collections in event.
197  ev.put(std::move(oc_alct));
198  ev.put(std::move(oc_clct));
199  ev.put(std::move(oc_pretrig));
200  ev.put(std::move(oc_lct));
201  ev.put(std::move(oc_sorted_lct),"MPCSORTED");
203  ev.put(std::move(oc_gemcopad));
204 }
#define LogDebug(id)
T getParameter(std::string const &) const
bool isRealData() const
virtual void produce(edm::Event &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:78
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
bool ev
CSCTriggerPrimitivesProducer(const edm::ParameterSet &)
static void setGeometry(const edm::ESHandle< CSCGeometry > &thegeom)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetTokenT< CSCComparatorDigiCollection > comp_token_
edm::EDGetTokenT< RPCDigiCollection > rpc_digi_token_
edm::EDGetTokenT< GEMPadDigiCollection > gem_pad_token_
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:55
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< CSCWireDigiCollection > wire_token_
std::unique_ptr< CSCTriggerPrimitivesBuilder > lctBuilder_
bool isValid() const
Definition: ESHandle.h:47
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:510