test
CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  try {
102  setup.get<MuonGeometryRecord>().get(h_gem);
103  lctBuilder_->setGEMGeometry(&*h_gem);
105  edm::LogInfo("L1CSCTPEmulatorNoGEMGeometry")
106  << "+++ Info: GEM geometry is unavailable. Running CSC-only trigger algorithm. +++\n";
107  }
108 
110  try {
111  setup.get<MuonGeometryRecord>().get(h_rpc);
112  lctBuilder_->setRPCGeometry(&*h_rpc);
114  edm::LogInfo("L1CSCTPEmulatorNoRPCGeometry")
115  << "+++ Info: RPC geometry is unavailable. Running CSC-only trigger algorithm. +++\n";
116  }
117  }
118 
119  // Find conditions data for bad chambers.
120  edm::ESHandle<CSCBadChambers> pBadChambers;
121  setup.get<CSCBadChambersRcd>().get(pBadChambers);
122 
123  // If !debugParameters then get config parameters using EventSetup mechanism.
124  // This must be done in produce() for every event and not in beginJob()
125  // (see mail from Jim Brooke sent to hn-cms-L1TrigEmulator on July 30, 2007).
126  if (!debugParameters_) {
128  setup.get<CSCDBL1TPParametersRcd>().get(conf);
129  if (conf.product() == 0) {
130  edm::LogError("L1CSCTPEmulatorConfigError")
131  << "+++ Failed to find a CSCDBL1TPParametersRcd in EventSetup! +++\n"
132  << "+++ Cannot continue emulation without these parameters +++\n";
133  return;
134  }
135  lctBuilder_->setConfigParameters(conf.product());
136  }
137 
138  // temporary hack to run on data
139  lctBuilder_->runOnData(ev.eventAuxiliary().isRealData());
140 
141  // Get the collections of comparator & wire digis from event.
144  // ev.getByLabel(compDigiProducer_.label(), compDigiProducer_.instance(), compDigis);
145  // ev.getByLabel(wireDigiProducer_.label(), wireDigiProducer_.instance(), wireDigis);
146  ev.getByToken(comp_token_, compDigis);
147  ev.getByToken(wire_token_, wireDigis);
148 
149 
150  const GEMPadDigiCollection *gemPads = nullptr;
151  if (!gemPadDigiProducer_.label().empty()) {
153  ev.getByToken(gem_pad_token_, gemPadDigis);
154  gemPads = gemPadDigis.product();
155  }
156 
157  const RPCDigiCollection *rpcDigis = nullptr;
158  if (!rpcDigiProducer_.label().empty()) {
160  ev.getByToken(rpc_digi_token_, rpcs);
161  rpcDigis = rpcs.product();
162  }
163 
164  // Create empty collections of ALCTs, CLCTs, and correlated LCTs upstream
165  // and downstream of MPC.
166  std::unique_ptr<CSCALCTDigiCollection> oc_alct(new CSCALCTDigiCollection);
167  std::unique_ptr<CSCCLCTDigiCollection> oc_clct(new CSCCLCTDigiCollection);
168  std::unique_ptr<CSCCLCTPreTriggerCollection> oc_pretrig(new CSCCLCTPreTriggerCollection);
169  std::unique_ptr<CSCCorrelatedLCTDigiCollection> oc_lct(new CSCCorrelatedLCTDigiCollection);
170  std::unique_ptr<CSCCorrelatedLCTDigiCollection> oc_sorted_lct(new CSCCorrelatedLCTDigiCollection);
171  std::unique_ptr<GEMCoPadDigiCollection> oc_gemcopad(new GEMCoPadDigiCollection);
172 
173  if (!wireDigis.isValid()) {
174  edm::LogWarning("L1CSCTPEmulatorNoInputCollection")
175  << "+++ Warning: Collection of wire digis with label "
177  << " requested in configuration, but not found in the event..."
178  << " Skipping production of CSC TP digis +++\n";
179  }
180  if (!compDigis.isValid()) {
181  edm::LogWarning("L1CSCTPEmulatorNoInputCollection")
182  << "+++ Warning: Collection of comparator digis with label "
184  << " requested in configuration, but not found in the event..."
185  << " Skipping production of CSC TP digis +++\n";
186  }
187  // Fill output collections if valid input collections are available.
188  if (wireDigis.isValid() && compDigis.isValid()) {
189  const CSCBadChambers* temp = checkBadChambers_ ? pBadChambers.product() : new CSCBadChambers;
190  lctBuilder_->build(temp,
191  wireDigis.product(), compDigis.product(), gemPads, rpcDigis,
192  *oc_alct, *oc_clct, *oc_pretrig, *oc_lct, *oc_sorted_lct, *oc_gemcopad);
193  if (!checkBadChambers_)
194  delete temp;
195  }
196 
197  // Put collections in event.
198  ev.put(std::move(oc_alct));
199  ev.put(std::move(oc_clct));
200  ev.put(std::move(oc_pretrig));
201  ev.put(std::move(oc_lct));
202  ev.put(std::move(oc_sorted_lct),"MPCSORTED");
204  ev.put(std::move(oc_gemcopad));
205 }
#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
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.
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::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
bool ev
CSCTriggerPrimitivesProducer(const edm::ParameterSet &)
static void setGeometry(const edm::ESHandle< CSCGeometry > &thegeom)
usesResource(TFileService::kSharedResource)
def move
Definition: eostools.py:510
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetTokenT< CSCComparatorDigiCollection > comp_token_
edm::EDGetTokenT< RPCDigiCollection > rpc_digi_token_
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:78
edm::EDGetTokenT< GEMPadDigiCollection > gem_pad_token_
T const * product() const
Definition: Handle.h:81
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::string const & label() const
Definition: InputTag.h:36
edm::EDGetTokenT< CSCWireDigiCollection > wire_token_
std::unique_ptr< CSCTriggerPrimitivesBuilder > lctBuilder_