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 
25 
26 //#include "DataFormats/CSCDigi/interface/CSCComparatorDigiCollection.h"
27 //#include "DataFormats/CSCDigi/interface/CSCWireDigiCollection.h"
31 
32 // Configuration via EventSetup
35 
36 
38 
39  // if false, parameters will be read in from DB using EventSetup mechanism
40  // else will use all parameters from the config file
41  debugParameters_ = conf.getUntrackedParameter<bool>("debugParameters",false);
42 
43  wireDigiProducer_ = conf.getParameter<edm::InputTag>("CSCWireDigiProducer");
44  compDigiProducer_ = conf.getParameter<edm::InputTag>("CSCComparatorDigiProducer");
45  checkBadChambers_ = conf.getUntrackedParameter<bool>("checkBadChambers", true);
46 
47  lctBuilder_ = new CSCTriggerPrimitivesBuilder(conf); // pass on the conf
48 
49  wire_token_ = consumes<CSCWireDigiCollection>(wireDigiProducer_);
50  comp_token_ = consumes<CSCComparatorDigiCollection>(compDigiProducer_);
51 
52  // register what this produces
53  produces<CSCALCTDigiCollection>();
54  produces<CSCCLCTDigiCollection>();
55  produces<CSCCLCTPreTriggerCollection>();
56  produces<CSCCorrelatedLCTDigiCollection>();
57  produces<CSCCorrelatedLCTDigiCollection>("MPCSORTED");
58  usesResource("CSCTriggerGeometry");
59  consumes<CSCComparatorDigiCollection>(compDigiProducer_);
60  consumes<CSCWireDigiCollection>(wireDigiProducer_);
61 }
62 
64  LogDebug("L1CSCTrigger")
65  << "deleting trigger primitives after " << iev << " events.";
66  delete lctBuilder_;
67 }
68 
69 //void CSCTriggerPrimitivesProducer::beginRun(const edm::EventSetup& setup) {
70 //}
71 
73  const edm::EventSetup& setup) {
74 
75  LogDebug("L1CSCTrigger") << "start producing LCTs for event " << ++iev;
76 
77  // Find the geometry (& conditions?) for this event & cache it in
78  // CSCTriggerGeometry.
79  {
81  setup.get<MuonGeometryRecord>().get(h);
83  }
84 
85  // Find conditions data for bad chambers.
86  edm::ESHandle<CSCBadChambers> pBadChambers;
87  setup.get<CSCBadChambersRcd>().get(pBadChambers);
88 
89  // If !debugParameters then get config parameters using EventSetup mechanism.
90  // This must be done in produce() for every event and not in beginJob()
91  // (see mail from Jim Brooke sent to hn-cms-L1TrigEmulator on July 30, 2007).
92  if (!debugParameters_) {
94  setup.get<CSCDBL1TPParametersRcd>().get(conf);
95  if (conf.product() == 0) {
96  edm::LogError("L1CSCTPEmulatorConfigError")
97  << "+++ Failed to find a CSCDBL1TPParametersRcd in EventSetup! +++\n"
98  << "+++ Cannot continue emulation without these parameters +++\n";
99  return;
100  }
102  }
103 
104  // Get the collections of comparator & wire digis from event.
107  // ev.getByLabel(compDigiProducer_.label(), compDigiProducer_.instance(), compDigis);
108  // ev.getByLabel(wireDigiProducer_.label(), wireDigiProducer_.instance(), wireDigis);
109  ev.getByToken(comp_token_, compDigis);
110  ev.getByToken(wire_token_, wireDigis);
111 
112  // Create empty collections of ALCTs, CLCTs, and correlated LCTs upstream
113  // and downstream of MPC.
114  std::auto_ptr<CSCALCTDigiCollection> oc_alct(new CSCALCTDigiCollection);
115  std::auto_ptr<CSCCLCTDigiCollection> oc_clct(new CSCCLCTDigiCollection);
116  std::auto_ptr<CSCCLCTPreTriggerCollection> oc_pretrig(new CSCCLCTPreTriggerCollection);
117  std::auto_ptr<CSCCorrelatedLCTDigiCollection> oc_lct(new CSCCorrelatedLCTDigiCollection);
118  std::auto_ptr<CSCCorrelatedLCTDigiCollection> oc_sorted_lct(new CSCCorrelatedLCTDigiCollection);
119 
120  if (!wireDigis.isValid()) {
121  edm::LogWarning("L1CSCTPEmulatorNoInputCollection")
122  << "+++ Warning: Collection of wire digis with label "
124  << " requested in configuration, but not found in the event..."
125  << " Skipping production of CSC TP digis +++\n";
126  }
127  if (!compDigis.isValid()) {
128  edm::LogWarning("L1CSCTPEmulatorNoInputCollection")
129  << "+++ Warning: Collection of comparator digis with label "
131  << " requested in configuration, but not found in the event..."
132  << " Skipping production of CSC TP digis +++\n";
133  }
134  // Fill output collections if valid input collections are available.
135  if (wireDigis.isValid() && compDigis.isValid()) {
136  const CSCBadChambers* temp = checkBadChambers_ ? pBadChambers.product() : new CSCBadChambers;
137  lctBuilder_->build(temp,
138  wireDigis.product(), compDigis.product(),
139  *oc_alct, *oc_clct, *oc_pretrig, *oc_lct, *oc_sorted_lct);
140  if (!checkBadChambers_)
141  delete temp;
142  }
143 
144  // Put collections in event.
145  ev.put(oc_alct);
146  ev.put(oc_clct);
147  ev.put(oc_pretrig);
148  ev.put(oc_lct);
149  ev.put(oc_sorted_lct,"MPCSORTED");
150 }
#define LogDebug(id)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void produce(edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
void build(const CSCBadChambers *badChambers, const CSCWireDigiCollection *wiredc, const CSCComparatorDigiCollection *compdc, CSCALCTDigiCollection &oc_alct, CSCCLCTDigiCollection &oc_clct, CSCCLCTPreTriggerCollection &oc_pretrig, CSCCorrelatedLCTDigiCollection &oc_lct, CSCCorrelatedLCTDigiCollection &oc_sorted_lct)
bool ev
CSCTriggerPrimitivesProducer(const edm::ParameterSet &)
static void setGeometry(const edm::ESHandle< CSCGeometry > &thegeom)
void setConfigParameters(const CSCDBL1TPParameters *conf)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
bool isValid() const
Definition: HandleBase.h:76
edm::EDGetTokenT< CSCComparatorDigiCollection > comp_token_
tuple conf
Definition: dbtoconf.py:185
T const * product() const
Definition: Handle.h:81
CSCTriggerPrimitivesBuilder * lctBuilder_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::string const & label() const
Definition: InputTag.h:42
edm::EDGetTokenT< CSCWireDigiCollection > wire_token_
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")