CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GEMRecHitProducer.cc
Go to the documentation of this file.
1 
6 #include "GEMRecHitProducer.h"
7 
8 
12 
14 
20 
24 
25 // #include "CondFormats/GEMObjects/interface/GEMMaskedStrips.h"
26 // #include "CondFormats/DataRecord/interface/GEMMaskedStripsRcd.h"
27 // #include "CondFormats/GEMObjects/interface/GEMDeadStrips.h"
28 // #include "CondFormats/DataRecord/interface/GEMDeadStripsRcd.h"
29 
30 #include <string>
31 
32 
33 using namespace edm;
34 using namespace std;
35 
36 
38 
39  // Set verbose output
40 
41  produces<GEMRecHitCollection>();
42 
43  theGEMDigiLabel = config.getParameter<InputTag>("gemDigiLabel");
44 
45  // Get the concrete reconstruction algo from the factory
46 
47  string theAlgoName = config.getParameter<string>("recAlgo");
48  theAlgo = GEMRecHitAlgoFactory::get()->create(theAlgoName,
49  config.getParameter<ParameterSet>("recAlgoConfig"));
50 
51  // Get masked- and dead-strip information
52 
53  /* GEMMaskedStripsObj = new GEMMaskedStrips();
54 
55  GEMDeadStripsObj = new GEMDeadStrips();
56 
57  maskSource = config.getParameter<std::string>("maskSource");
58 
59  if (maskSource == "File") {
60  edm::FileInPath fp = config.getParameter<edm::FileInPath>("maskvecfile");
61  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
62  if ( !inputFile ) {
63  std::cerr << "Masked Strips File cannot not be opened" << std::endl;
64  exit(1);
65  }
66  while ( inputFile.good() ) {
67  GEMMaskedStrips::MaskItem Item;
68  inputFile >> Item.rawId >> Item.strip;
69  if ( inputFile.good() ) MaskVec.push_back(Item);
70  }
71  inputFile.close();
72  }
73 
74  deadSource = config.getParameter<std::string>("deadSource");
75 
76  if (deadSource == "File") {
77  edm::FileInPath fp = config.getParameter<edm::FileInPath>("deadvecfile");
78  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
79  if ( !inputFile ) {
80  std::cerr << "Dead Strips File cannot not be opened" << std::endl;
81  exit(1);
82  }
83  while ( inputFile.good() ) {
84  GEMDeadStrips::DeadItem Item;
85  inputFile >> Item.rawId >> Item.strip;
86  if ( inputFile.good() ) DeadVec.push_back(Item);
87  }
88  inputFile.close();
89  }
90  */
91 }
92 
93 
95 
96  delete theAlgo;
97  // delete GEMMaskedStripsObj;
98  // delete GEMDeadStripsObj;
99 
100 }
101 
102 
103 
105 
106  // Getting the masked-strip information
107  /*
108  if ( maskSource == "EventSetup" ) {
109  edm::ESHandle<GEMMaskedStrips> readoutMaskedStrips;
110  setup.get<GEMMaskedStripsRcd>().get(readoutMaskedStrips);
111  const GEMMaskedStrips* tmp_obj = readoutMaskedStrips.product();
112  GEMMaskedStripsObj->MaskVec = tmp_obj->MaskVec;
113  delete tmp_obj;
114  }
115  else if ( maskSource == "File" ) {
116  std::vector<GEMMaskedStrips::MaskItem>::iterator posVec;
117  for ( posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec ) {
118  GEMMaskedStrips::MaskItem Item;
119  Item.rawId = (*posVec).rawId;
120  Item.strip = (*posVec).strip;
121  GEMMaskedStripsObj->MaskVec.push_back(Item);
122  }
123  }
124  */
125  // Getting the dead-strip information
126  /*
127  if ( deadSource == "EventSetup" ) {
128  edm::ESHandle<GEMDeadStrips> readoutDeadStrips;
129  setup.get<GEMDeadStripsRcd>().get(readoutDeadStrips);
130  const GEMDeadStrips* tmp_obj = readoutDeadStrips.product();
131  GEMDeadStripsObj->DeadVec = tmp_obj->DeadVec;
132  delete tmp_obj;
133  }
134  else if ( deadSource == "File" ) {
135  std::vector<GEMDeadStrips::DeadItem>::iterator posVec;
136  for ( posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec ) {
137  GEMDeadStrips::DeadItem Item;
138  Item.rawId = (*posVec).rawId;
139  Item.strip = (*posVec).strip;
140  GEMDeadStripsObj->DeadVec.push_back(Item);
141  }
142  }
143  */
144 }
145 
146 
147 
149 
150  // Get the GEM Geometry
151 
152  ESHandle<GEMGeometry> gemGeom;
153  setup.get<MuonGeometryRecord>().get(gemGeom);
154 
155  // Get the digis from the event
156 
158  event.getByLabel(theGEMDigiLabel,digis);
159 
160  // Pass the EventSetup to the algo
161 
162  theAlgo->setES(setup);
163 
164  // Create the pointer to the collection which will store the rechits
165 
166  auto_ptr<GEMRecHitCollection> recHitCollection(new GEMRecHitCollection());
167 
168  // Iterate through all digi collections ordered by LayerId
169 
171  for (gemdgIt = digis->begin(); gemdgIt != digis->end();
172  ++gemdgIt){
173 
174  // The layerId
175  const GEMDetId& gemId = (*gemdgIt).first;
176 
177  // Get the GeomDet from the setup
178  const GEMEtaPartition* roll = gemGeom->etaPartition(gemId);
179 
180  // Get the iterators over the digis associated with this LayerId
181  const GEMDigiCollection::Range& range = (*gemdgIt).second;
182 
183 
184  // Getting the roll mask, that includes dead strips, for the given GEMDet
185  EtaPartitionMask mask;
186  /*
187  int rawId = gemId.rawId();
188  int Size = GEMMaskedStripsObj->MaskVec.size();
189  for (int i = 0; i < Size; i++ ) {
190  if ( GEMMaskedStripsObj->MaskVec[i].rawId == rawId ) {
191  int bit = GEMMaskedStripsObj->MaskVec[i].strip;
192  mask.set(bit-1);
193  }
194  }
195 
196  Size = GEMDeadStripsObj->DeadVec.size();
197  for (int i = 0; i < Size; i++ ) {
198  if ( GEMDeadStripsObj->DeadVec[i].rawId == rawId ) {
199  int bit = GEMDeadStripsObj->DeadVec[i].strip;
200  mask.set(bit-1);
201  }
202  }
203  */
204  // Call the reconstruction algorithm
205 
207  theAlgo->reconstruct(*roll, gemId, range, mask);
208 
209  if(recHits.size() > 0) //FIXME: is it really needed?
210  recHitCollection->put(gemId, recHits.begin(), recHits.end());
211  }
212 
213  event.put(recHitCollection);
214 
215 }
216 
T getParameter(std::string const &) const
virtual void produce(edm::Event &event, const edm::EventSetup &setup) override
The method which produces the rechits.
GEMRecHitProducer(const edm::ParameterSet &config)
Constructor.
virtual ~GEMRecHitProducer()
Destructor.
size_type size() const
Definition: OwnVector.h:254
iterator begin()
Definition: OwnVector.h:234
std::bitset< maskSIZE > EtaPartitionMask
edm::RangeMap< GEMDetId, edm::OwnVector< GEMRecHit, edm::ClonePolicy< GEMRecHit > >, edm::ClonePolicy< GEMRecHit > > GEMRecHitCollection
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
iterator end()
Definition: OwnVector.h:239
const T & get() const
Definition: EventSetup.h:55
std::pair< const_iterator, const_iterator > Range
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
T get(const Candidate &c)
Definition: component.h:55
Definition: Run.h:41
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override