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 
8 #include "GEMRecHitProducer.h"
9 
10 
14 
16 
22 
26 
27 // #include "CondFormats/GEMObjects/interface/GEMMaskedStrips.h"
28 // #include "CondFormats/DataRecord/interface/GEMMaskedStripsRcd.h"
29 // #include "CondFormats/GEMObjects/interface/GEMDeadStrips.h"
30 // #include "CondFormats/DataRecord/interface/GEMDeadStripsRcd.h"
31 
32 #include <string>
33 
34 
35 using namespace edm;
36 using namespace std;
37 
38 
40 
41  // Set verbose output
42 
43  produces<GEMRecHitCollection>();
44 
45  theGEMDigiLabel = config.getParameter<InputTag>("gemDigiLabel");
46 
47  // Get the concrete reconstruction algo from the factory
48 
49  string theAlgoName = config.getParameter<string>("recAlgo");
50  theAlgo = GEMRecHitAlgoFactory::get()->create(theAlgoName,
51  config.getParameter<ParameterSet>("recAlgoConfig"));
52 
53  // Get masked- and dead-strip information
54 
55  /* GEMMaskedStripsObj = new GEMMaskedStrips();
56 
57  GEMDeadStripsObj = new GEMDeadStrips();
58 
59  maskSource = config.getParameter<std::string>("maskSource");
60 
61  if (maskSource == "File") {
62  edm::FileInPath fp = config.getParameter<edm::FileInPath>("maskvecfile");
63  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
64  if ( !inputFile ) {
65  std::cerr << "Masked Strips File cannot not be opened" << std::endl;
66  exit(1);
67  }
68  while ( inputFile.good() ) {
69  GEMMaskedStrips::MaskItem Item;
70  inputFile >> Item.rawId >> Item.strip;
71  if ( inputFile.good() ) MaskVec.push_back(Item);
72  }
73  inputFile.close();
74  }
75 
76  deadSource = config.getParameter<std::string>("deadSource");
77 
78  if (deadSource == "File") {
79  edm::FileInPath fp = config.getParameter<edm::FileInPath>("deadvecfile");
80  std::ifstream inputFile(fp.fullPath().c_str(), std::ios::in);
81  if ( !inputFile ) {
82  std::cerr << "Dead Strips File cannot not be opened" << std::endl;
83  exit(1);
84  }
85  while ( inputFile.good() ) {
86  GEMDeadStrips::DeadItem Item;
87  inputFile >> Item.rawId >> Item.strip;
88  if ( inputFile.good() ) DeadVec.push_back(Item);
89  }
90  inputFile.close();
91  }
92  */
93 }
94 
95 
97 
98  delete theAlgo;
99  // delete GEMMaskedStripsObj;
100  // delete GEMDeadStripsObj;
101 
102 }
103 
104 
105 
107 
108  // Getting the masked-strip information
109  /*
110  if ( maskSource == "EventSetup" ) {
111  edm::ESHandle<GEMMaskedStrips> readoutMaskedStrips;
112  setup.get<GEMMaskedStripsRcd>().get(readoutMaskedStrips);
113  const GEMMaskedStrips* tmp_obj = readoutMaskedStrips.product();
114  GEMMaskedStripsObj->MaskVec = tmp_obj->MaskVec;
115  delete tmp_obj;
116  }
117  else if ( maskSource == "File" ) {
118  std::vector<GEMMaskedStrips::MaskItem>::iterator posVec;
119  for ( posVec = MaskVec.begin(); posVec != MaskVec.end(); ++posVec ) {
120  GEMMaskedStrips::MaskItem Item;
121  Item.rawId = (*posVec).rawId;
122  Item.strip = (*posVec).strip;
123  GEMMaskedStripsObj->MaskVec.push_back(Item);
124  }
125  }
126  */
127  // Getting the dead-strip information
128  /*
129  if ( deadSource == "EventSetup" ) {
130  edm::ESHandle<GEMDeadStrips> readoutDeadStrips;
131  setup.get<GEMDeadStripsRcd>().get(readoutDeadStrips);
132  const GEMDeadStrips* tmp_obj = readoutDeadStrips.product();
133  GEMDeadStripsObj->DeadVec = tmp_obj->DeadVec;
134  delete tmp_obj;
135  }
136  else if ( deadSource == "File" ) {
137  std::vector<GEMDeadStrips::DeadItem>::iterator posVec;
138  for ( posVec = DeadVec.begin(); posVec != DeadVec.end(); ++posVec ) {
139  GEMDeadStrips::DeadItem Item;
140  Item.rawId = (*posVec).rawId;
141  Item.strip = (*posVec).strip;
142  GEMDeadStripsObj->DeadVec.push_back(Item);
143  }
144  }
145  */
146 }
147 
148 
149 
151 
152  // Get the GEM Geometry
153 
154  ESHandle<GEMGeometry> gemGeom;
155  setup.get<MuonGeometryRecord>().get(gemGeom);
156 
157  // Get the digis from the event
158 
160  event.getByLabel(theGEMDigiLabel,digis);
161 
162  // Pass the EventSetup to the algo
163 
164  theAlgo->setES(setup);
165 
166  // Create the pointer to the collection which will store the rechits
167 
168  auto_ptr<GEMRecHitCollection> recHitCollection(new GEMRecHitCollection());
169 
170  // Iterate through all digi collections ordered by LayerId
171 
173  for (gemdgIt = digis->begin(); gemdgIt != digis->end();
174  ++gemdgIt){
175 
176  // The layerId
177  const GEMDetId& gemId = (*gemdgIt).first;
178 
179  // Get the GeomDet from the setup
180  const GEMEtaPartition* roll = gemGeom->etaPartition(gemId);
181 
182  // Get the iterators over the digis associated with this LayerId
183  const GEMDigiCollection::Range& range = (*gemdgIt).second;
184 
185 
186  // Getting the roll mask, that includes dead strips, for the given GEMDet
187  EtaPartitionMask mask;
188  /*
189  int rawId = gemId.rawId();
190  int Size = GEMMaskedStripsObj->MaskVec.size();
191  for (int i = 0; i < Size; i++ ) {
192  if ( GEMMaskedStripsObj->MaskVec[i].rawId == rawId ) {
193  int bit = GEMMaskedStripsObj->MaskVec[i].strip;
194  mask.set(bit-1);
195  }
196  }
197 
198  Size = GEMDeadStripsObj->DeadVec.size();
199  for (int i = 0; i < Size; i++ ) {
200  if ( GEMDeadStripsObj->DeadVec[i].rawId == rawId ) {
201  int bit = GEMDeadStripsObj->DeadVec[i].strip;
202  mask.set(bit-1);
203  }
204  }
205  */
206  // Call the reconstruction algorithm
207 
208  OwnVector<GEMRecHit> recHits =
209  theAlgo->reconstruct(*roll, gemId, range, mask);
210 
211  if(recHits.size() > 0) //FIXME: is it really needed?
212  recHitCollection->put(gemId, recHits.begin(), recHits.end());
213  }
214 
215  event.put(recHitCollection);
216 
217 }
218 
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:247
iterator begin()
Definition: OwnVector.h:227
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:232
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:56
Definition: Run.h:36
virtual void beginRun(const edm::Run &, const edm::EventSetup &) override