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 
36 
37 // Configuration via EventSetup
40 
41 
43 
44  // if false, parameters will be read in from DB using EventSetup mechanism
45  // else will use all parameters from the config file
46  debugParameters_ = conf.getParameter<bool>("debugParameters");
47 
48  wireDigiProducer_ = conf.getParameter<edm::InputTag>("CSCWireDigiProducer");
49  compDigiProducer_ = conf.getParameter<edm::InputTag>("CSCComparatorDigiProducer");
50  gemPadDigiProducer_ = conf.existsAs<edm::InputTag>("GEMPadDigiProducer")?conf.getParameter<edm::InputTag>("GEMPadDigiProducer"):edm::InputTag("");
51  rpcDigiProducer_ = conf.existsAs<edm::InputTag>("RPCDigiProducer")?conf.getParameter<edm::InputTag>("RPCDigiProducer"):edm::InputTag("");
52  checkBadChambers_ = conf.getParameter<bool>("checkBadChambers");
53  lctBuilder_.reset( new CSCTriggerPrimitivesBuilder(conf) ); // pass on the conf
54 
55  wire_token_ = consumes<CSCWireDigiCollection>(wireDigiProducer_);
56  comp_token_ = consumes<CSCComparatorDigiCollection>(compDigiProducer_);
57  gem_pad_token_ = consumes<GEMPadDigiCollection>(gemPadDigiProducer_);
58  rpc_digi_token_ = consumes<RPCDigiCollection>(rpcDigiProducer_);
59 
60  // register what this produces
61  produces<CSCALCTDigiCollection>();
62  produces<CSCCLCTDigiCollection>();
63  produces<CSCCLCTPreTriggerCollection>();
64  produces<CSCCorrelatedLCTDigiCollection>();
65  produces<CSCCorrelatedLCTDigiCollection>("MPCSORTED");
66  produces<GEMCoPadDigiCollection>();
67  produces<GEMCSCLCTDigiCollection>();
68  usesResource("CSCTriggerGeometry");
69  consumes<CSCComparatorDigiCollection>(compDigiProducer_);
70  consumes<CSCWireDigiCollection>(wireDigiProducer_);
71  consumes<GEMPadDigiCollection>(gemPadDigiProducer_);
72  consumes<RPCDigiCollection>(rpcDigiProducer_);
73 }
74 
76  LogDebug("L1CSCTrigger")
77  << "deleting trigger primitives after " << iev << " events.";
78 }
79 
80 //void CSCTriggerPrimitivesProducer::beginRun(const edm::EventSetup& setup) {
81 //}
82 
84  const edm::EventSetup& setup) {
85 
86  LogDebug("L1CSCTrigger") << "start producing LCTs for event " << ++iev;
87 
88  // Find the geometry (& conditions?) for this event & cache it in
89  // CSCTriggerGeometry.
90  {
92  setup.get<MuonGeometryRecord>().get(h);
94  lctBuilder_->setCSCGeometry(&*h);
95 
97  try {
98  setup.get<MuonGeometryRecord>().get(h_gem);
99  lctBuilder_->setGEMGeometry(&*h_gem);
101  edm::LogInfo("L1CSCTPEmulatorNoGEMGeometry")
102  << "+++ Info: GEM geometry is unavailable. Running CSC-only trigger algorithm. +++\n";
103  }
104 
106  try {
107  setup.get<MuonGeometryRecord>().get(h_rpc);
108  lctBuilder_->setRPCGeometry(&*h_rpc);
110  edm::LogInfo("L1CSCTPEmulatorNoRPCGeometry")
111  << "+++ Info: RPC geometry is unavailable. Running CSC-only trigger algorithm. +++\n";
112  }
113  }
114 
115  // Find conditions data for bad chambers.
116  edm::ESHandle<CSCBadChambers> pBadChambers;
117  setup.get<CSCBadChambersRcd>().get(pBadChambers);
118 
119  // If !debugParameters then get config parameters using EventSetup mechanism.
120  // This must be done in produce() for every event and not in beginJob()
121  // (see mail from Jim Brooke sent to hn-cms-L1TrigEmulator on July 30, 2007).
122  if (!debugParameters_) {
124  setup.get<CSCDBL1TPParametersRcd>().get(conf);
125  if (conf.product() == 0) {
126  edm::LogError("L1CSCTPEmulatorConfigError")
127  << "+++ Failed to find a CSCDBL1TPParametersRcd in EventSetup! +++\n"
128  << "+++ Cannot continue emulation without these parameters +++\n";
129  return;
130  }
131  lctBuilder_->setConfigParameters(conf.product());
132  }
133 
134  // Get the collections of comparator & wire digis from event.
137  // ev.getByLabel(compDigiProducer_.label(), compDigiProducer_.instance(), compDigis);
138  // ev.getByLabel(wireDigiProducer_.label(), wireDigiProducer_.instance(), wireDigis);
139  ev.getByToken(comp_token_, compDigis);
140  ev.getByToken(wire_token_, wireDigis);
141 
142 
143  const GEMPadDigiCollection *gemPads = nullptr;
144  if (!gemPadDigiProducer_.label().empty()) {
146  ev.getByToken(gem_pad_token_, gemPadDigis);
147  gemPads = gemPadDigis.product();
148  }
149 
150  const RPCDigiCollection *rpcDigis = nullptr;
151  if (!rpcDigiProducer_.label().empty()) {
153  ev.getByToken(rpc_digi_token_, rpcs);
154  rpcDigis = rpcs.product();
155  }
156 
157  // Create empty collections of ALCTs, CLCTs, and correlated LCTs upstream
158  // and downstream of MPC.
159  std::auto_ptr<CSCALCTDigiCollection> oc_alct(new CSCALCTDigiCollection);
160  std::auto_ptr<CSCCLCTDigiCollection> oc_clct(new CSCCLCTDigiCollection);
161  std::auto_ptr<CSCCLCTPreTriggerCollection> oc_pretrig(new CSCCLCTPreTriggerCollection);
162  std::auto_ptr<CSCCorrelatedLCTDigiCollection> oc_lct(new CSCCorrelatedLCTDigiCollection);
163  std::auto_ptr<CSCCorrelatedLCTDigiCollection> oc_sorted_lct(new CSCCorrelatedLCTDigiCollection);
164  std::auto_ptr<GEMCoPadDigiCollection> oc_gemcopad(new GEMCoPadDigiCollection);
165  std::auto_ptr<GEMCSCLCTDigiCollection> oc_gemcsclct(new GEMCSCLCTDigiCollection);
166 
167  if (!wireDigis.isValid()) {
168  edm::LogWarning("L1CSCTPEmulatorNoInputCollection")
169  << "+++ Warning: Collection of wire digis with label "
171  << " requested in configuration, but not found in the event..."
172  << " Skipping production of CSC TP digis +++\n";
173  }
174  if (!compDigis.isValid()) {
175  edm::LogWarning("L1CSCTPEmulatorNoInputCollection")
176  << "+++ Warning: Collection of comparator digis with label "
178  << " requested in configuration, but not found in the event..."
179  << " Skipping production of CSC TP digis +++\n";
180  }
181  // Fill output collections if valid input collections are available.
182  if (wireDigis.isValid() && compDigis.isValid()) {
183  const CSCBadChambers* temp = checkBadChambers_ ? pBadChambers.product() : new CSCBadChambers;
184  lctBuilder_->build(temp,
185  wireDigis.product(), compDigis.product(), gemPads, rpcDigis,
186  *oc_alct, *oc_clct, *oc_pretrig, *oc_lct, *oc_sorted_lct, *oc_gemcopad, *oc_gemcsclct);
187  if (!checkBadChambers_)
188  delete temp;
189  }
190 
191  // Put collections in event.
192  ev.put(oc_alct);
193  ev.put(oc_clct);
194  ev.put(oc_pretrig);
195  ev.put(oc_lct);
196  ev.put(oc_sorted_lct,"MPCSORTED");
197  ev.put(oc_gemcopad);
198  ev.put(oc_gemcsclct);
199 }
#define LogDebug(id)
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
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:462
bool ev
CSCTriggerPrimitivesProducer(const edm::ParameterSet &)
static void setGeometry(const edm::ESHandle< CSCGeometry > &thegeom)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
bool isValid() const
Definition: HandleBase.h:75
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: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_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")