CMS 3D CMS Logo

GE0TriggerPseudoBuilder.cc
Go to the documentation of this file.
5 
6 #include <iostream>
7 #include <cassert>
8 
9 const unsigned int GE0TriggerPseudoBuilder::ME0KeyLayer = 3;
11 
13  config_ = conf;
14  info_ = config_.getUntrackedParameter<int>("info", 0);
15  dphiresolution_ = config_.getUntrackedParameter<double>("DeltaPhiResolution", 0.25);
16 }
17 
19 
21  if (info_ > 2)
23 
24  for (unsigned int endc = 0; endc < static_cast<unsigned int>(trig_me0s::MAX_ENDCAPS); endc++) {
25  for (unsigned int cham = 0; cham < static_cast<unsigned int>(trig_me0s::MAX_CHAMBERS); cham++) {
26  // 0th layer means whole chamber.
27  // chamber counts from 1 to 18 in ME0ID
28  const int region(endc == 0 ? -1 : 1);
29  // constexpr GEMDetId(int region, int ring, int station, int layer, int chamber, int ieta)
30  GEMDetId detid(region, 1, 0, 0, cham + 1, 0);
31 
32  const auto& drange = me0Segments.get(detid);
33  std::vector<ME0TriggerDigi> trigV;
34  for (auto digiIt = drange.first; digiIt != drange.second; digiIt++) {
35  if (info_ > 1)
36  LogTrace("L1ME0Trigger") << "GE0TriggerPseudoBuilder id " << detid << " ME0 segment " << *digiIt
37  << " to be converted into trigger digi\n";
39  if (trig.isValid())
40  trigV.push_back(trig);
41  if (info_ > 1 and trig.isValid())
42  LogTrace("L1ME0Trigger") << " ME0trigger " << trig << "\n";
43  else if (info_ > 1)
44  LogTrace("L1ME0Trigger") << " ME0trigger is not valid. Conversion failed \n";
45  }
46 
47  if (!trigV.empty()) {
48  LogTrace("L1ME0Trigger") << "GE0TriggerPseudoBuilder got results in " << detid << std::endl
49  << "Put " << trigV.size() << " Trigger digi" << ((trigV.size() > 1) ? "s " : " ")
50  << "in collection\n";
51  oc_trig.put(std::make_pair(trigV.begin(), trigV.end()), detid);
52  }
53  }
54  }
55 }
56 
58  auto detid = segment.gemDetId();
59  const GEMSuperChamber* chamber = me0_g->superChamber(detid);
60  const GEMChamber* keylayer = chamber->chamber(GE0TriggerPseudoBuilder::ME0KeyLayer);
61  int chamberid = detid.superChamberId() % 2;
62  int totRolls = keylayer->nEtaPartitions();
63  float dphi = chamber->computeDeltaPhi(segment.localPosition(), segment.localDirection());
64 
65  int nrechits = segment.nRecHits();
66  std::vector<int> rolls;
67  for (const auto& rechit : segment.specificRecHits()) {
68  if (std::find(rolls.begin(), rolls.end(), rechit.gemId().roll()) == rolls.end())
69  rolls.push_back(rechit.gemId().roll());
70  }
71  if (rolls.size() > 2 or rolls.empty())
72  LogTrace("L1ME0Trigger") << " ME0 segment is crossing " << rolls.size() << " roll !!! \n";
73  //assert(rolls.size() <= 2); // we did found very few ME0 segments crossing 3 rolls!!! this cut is applied offline
74  if (rolls.empty())
75  return ME0TriggerDigi();
76  if (rolls[0] < 1) {
77  LogTrace("L1ME0Trigger") << " ME0 segment has wrong roll number " << rolls[0] << " which should be >= 1 \n !!!";
78  throw edm::Exception(edm::errors::LogicError, "ME0 should have at least one roll");
79  }
80  int partition = (rolls[0] - 1) << 1; //roll from detid counts from 1
81  if (rolls.size() == 2 and rolls[0] > rolls[1])
82  partition = partition - 1;
83  else if (rolls.size() == 2 and rolls[0] < rolls[1])
84  partition = partition + 1;
85 
86  if (partition < 0 or partition >= 2 * totRolls) {
87  LogTrace("L1ME0Trigger") << " ME0 segment rolls size of all hits " << rolls.size() << " rolls[0] " << rolls[0]
88  << " rolls.back() " << rolls.back() << " and ME0 trigger roll is " << partition
89  << " max expected " << 2 * totRolls - 1 << "\n";
90  return ME0TriggerDigi();
91  }
92 
93  //globalpoint from ME0 segment
94  GlobalPoint gp = me0_g->idToDet(segment.gemDetId())->surface().toGlobal(segment.localPosition());
95  const GEMEtaPartition* etapart = keylayer->etaPartition(rolls[0]);
96  LocalPoint segment_lp = etapart->surface().toLocal(gp); // convert segment gp into lp in etapartition coordinate
97  float strippitch = etapart->localPitch(segment_lp);
98  float strip = etapart->strip(segment_lp);
99  int totstrip = etapart->nstrips();
100  int istrip = static_cast<int>(strip);
101  int phiposition = istrip;
102  if (phiposition > totstrip)
103  LogTrace("L1ME0Trigger") << " ME0 segment strip number is " << phiposition << " larger than nstrip " << totstrip
104  << " !!! \n";
105  constexpr float phi_resolution = 0.5; //halfstrip
106  int phiposition2 = (static_cast<int>((strip - phiposition) / phi_resolution) & 1); // half-strip resolution
107  phiposition = (phiposition << 1) | phiposition2;
108 
109  //gloablpoint from ME0 trigger digi
110  float centreOfStrip = istrip + 0.25 + phiposition2 * 0.5;
111  GlobalPoint gp_digi = etapart->toGlobal(etapart->centreOfStrip(centreOfStrip));
112 
113  float strippitch_rad = strippitch / gp.perp(); //unit in rad
114 
115  int idphi = static_cast<int>(fabs(dphi) / (strippitch_rad * dphiresolution_));
116  const int max_idphi = 512;
117  if (idphi >= max_idphi) {
118  LogTrace("L1ME0Trigger") << " ME0 segment dphi " << dphi << " and int type: " << idphi
119  << " larger than max allowed: " << max_idphi << " !!! \n";
120  idphi = max_idphi - 1;
121  }
122  int quality = nrechits; // attention: not the same as discussed in meeting
123  // !!!!TODO!!!! int BX = (static_cast<int>(fabs(time) / 25.0)) * sign_time + GE0TriggerPseudoBuilder::ME0TriggerCentralBX;
125  int bend = (dphi > 0.0) ? 0 : 1;
126  if (info_ > 2)
127  LogTrace("L1ME0Trigger") << " ME0trigger in conversion function:\n"
128  << "\t chamber(1-18) " << detid.chamber() << " chamber id " << chamberid << " \n"
129  << "\t rolls size of all hits " << rolls.size() << " rolls[0] " << rolls[0]
130  << " rolls.back() " << rolls.back() << " roll " << partition << " \n"
131  << "\t nRechits " << nrechits << " quality " << quality << " \n"
132  << "\t strip(float) " << strip << " (int) " << istrip << " phiposition " << phiposition
133  << " resolution (in term of strip) " << phi_resolution << " \n"
134  << "\t deltaphi(float) " << dphi << " (int) " << idphi << " resolution "
135  << strippitch_rad * dphiresolution_ << " bend " << bend << " \n"
136  << "\t global point eta " << gp.eta() << " phi " << gp.phi() << " trigger digi eta "
137  << gp_digi.eta() << " phi " << gp_digi.phi() << " \n"
138  // << "\t time (ns, float) " << time << " BX " << BX << " \n"
139  ;
140 
141  ME0TriggerDigi result = ME0TriggerDigi(chamberid, quality, phiposition, partition, idphi, bend, BX);
142  result.setStrip(istrip);
143  return result;
144 
145  return ME0TriggerDigi();
146 }
147 
149  LogTrace("L1GE0Trigger") << "dumpt all ME0 Segments" << std::endl;
150  for (auto iC = segments.id_begin(); iC != segments.id_end(); ++iC) {
151  auto ch_segs = segments.get(*iC);
152  for (auto iS = ch_segs.first; iS != ch_segs.second; ++iS) {
153  if (iS->gemDetId().station() != 0) // only dump GE0 segments
154  continue;
155  GlobalPoint gp = me0_g->idToDet(iS->gemDetId())->surface().toGlobal(iS->localPosition());
156  LogTrace("L1ME0Trigger") << "ME0Detid " << iS->gemDetId() << " segment " << *iS << " eta " << gp.eta() << " phi "
157  << gp.phi() << std::endl;
158  auto recHits(iS->recHits());
159  LogTrace("L1GE0Trigger") << "\t has " << recHits.size() << " me0 rechits" << std::endl;
160  for (auto& rh : recHits) {
161  const GEMRecHit* me0rh(dynamic_cast<const GEMRecHit*>(rh));
162  LogTrace("L1GEMTrigger") << "\t detid " << me0rh->gemId() << " rechit " << *me0rh << std::endl;
163  }
164  }
165  }
166 }
LocalPoint localPosition() const override
Definition: GEMSegment.h:52
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return the eta partition corresponding to the given id.
Definition: GEMChamber.cc:33
LocalVector localDirection() const override
Local direction.
Definition: GEMSegment.h:55
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
const GeomDet * idToDet(DetId) const override
Definition: GEMGeometry.cc:25
T eta() const
Definition: PV3DBase.h:73
float strip(const LocalPoint &lp) const
int nEtaPartitions() const
Retunr numbers of eta partitions.
Definition: GEMChamber.cc:31
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
LocalPoint toLocal(const GlobalPoint &gp) const
static const int ME0TriggerCentralBX
#define LogTrace(id)
T getUntrackedParameter(std::string const &, T const &) const
string quality
int nRecHits() const
Definition: GEMSegment.h:81
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
ME0TriggerDigi segmentConversion(const GEMSegment segment)
const std::vector< GEMRecHit > & specificRecHits() const
Definition: GEMSegment.h:79
GE0TriggerPseudoBuilder(const edm::ParameterSet &)
void build(const GEMSegmentCollection &me0segments, GE0TriggerDigiCollection &oc_trig)
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
GEMDetId gemId() const
Return the gemId.
Definition: GEMRecHit.h:65
GEMDetId gemDetId() const
Definition: GEMSegment.h:83
float localPitch(const LocalPoint &lp) const
int nstrips() const
number of readout strips in partition
void dumpAllME0Segments(const GEMSegmentCollection &segments) const
static const unsigned int ME0KeyLayer
LocalPoint centreOfStrip(int strip) const
const GEMSuperChamber * superChamber(GEMDetId id) const
Definition: GEMGeometry.cc:69
void put(Range range, const IndexType &index)
insert a range of digis for a given DetUnit
A container for a generic type of digis indexed by some index, implemented with a map<IndexType...