CMS 3D CMS Logo

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  theGEMDigiToken = consumes<GEMDigiCollection>(config.getParameter<edm::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.getByToken(theGEMDigiToken,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 recHitCollection = std::make_unique<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
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 
206  OwnVector<GEMRecHit> recHits =
207  theAlgo->reconstruct(*roll, gemId, range, mask);
208 
209  if(!recHits.empty()) //FIXME: is it really needed?
210  recHitCollection->put(gemId, recHits.begin(), recHits.end());
211  }
212 
213  event.put(std::move(recHitCollection));
214 
215 }
216 
T getParameter(std::string const &) const
void produce(edm::Event &event, const edm::EventSetup &setup) override
The method which produces the rechits.
GEMRecHitProducer(const edm::ParameterSet &config)
Constructor.
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
Definition: config.py:1
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:99
iterator begin()
Definition: OwnVector.h:244
bool empty() const
Definition: OwnVector.h:269
std::bitset< maskSIZE > EtaPartitionMask
~GEMRecHitProducer() override
Destructor.
iterator end()
Definition: OwnVector.h:249
HLT enums.
T get() const
Definition: EventSetup.h:68
std::pair< const_iterator, const_iterator > Range
def move(src, dest)
Definition: eostools.py:511
T get(const Candidate &c)
Definition: component.h:55
Definition: event.py:1
Definition: Run.h:44
void beginRun(const edm::Run &, const edm::EventSetup &) override