CMS 3D CMS Logo

BetaCalculatorRPC.cc
Go to the documentation of this file.
2 
3 using namespace susybsm;
4 
6  rpcRecHitsToken = iC.consumes<RPCRecHitCollection>(iConfig.getParameter<edm::InputTag>("rpcRecHits"));
7 }
8 
9 void BetaCalculatorRPC::algo(const std::vector<susybsm::RPCHit4D>& uHSCPRPCRecHits) {
10  std::vector<susybsm::RPCHit4D> HSCPRPCRecHits = uHSCPRPCRecHits;
11  int lastbx = -7;
12  bool outOfTime = false;
13  bool increasing = true;
14  bool anydifferentzero = true;
15  bool anydifferentone = true;
16 
17  //std::cout<<"Inside BetaCalculatorRPC \t \t Preliminar loop on the RPCHit4D!!!"<<std::endl;
18 
19  std::sort(HSCPRPCRecHits.begin(), HSCPRPCRecHits.end()); //Organizing them
20 
21  for (std::vector<susybsm::RPCHit4D>::iterator point = HSCPRPCRecHits.begin(); point < HSCPRPCRecHits.end(); ++point) {
22  outOfTime |= (point->bx != 0); //condition 1: at least one measurement must have BX!=0
23  increasing &= (point->bx >= lastbx); //condition 2: BX must be increase when going inside-out.
24  anydifferentzero &= (!(point->bx == 0)); //to check one knee withoutzeros
25  anydifferentone &= (!(point->bx == 1)); //to check one knee withoutones
26  lastbx = point->bx;
27  //float r=point->gp.mag();
28  //std::cout<<"Inside BetaCalculatorRPC \t \t r="<<r<<" phi="<<point->gp.phi()<<" eta="<<point->gp.eta()<<" bx="<<point->bx<<" outOfTime"<<outOfTime<<" increasing"<<increasing<<" anydifferentzero"<<anydifferentzero<<std::endl;
29  }
30 
31  bool Candidate = (outOfTime && increasing);
32 
33  // here we should get some pattern-based estimate
34 
35  //Counting knees
36 
37  float delay = 12.5;
38  lastbx = -7; //already declared for the preliminar loop
39  int knees = 0;
40  float maginknee = 0;
41  float maginfirstknee = 0;
42  for (std::vector<susybsm::RPCHit4D>::iterator point = HSCPRPCRecHits.begin(); point < HSCPRPCRecHits.end(); ++point) {
43  if (lastbx == -7) {
44  maginfirstknee = point->gp.mag();
45  } else if ((lastbx != point->bx)) {
46  //std::cout<<"Inside BetaCalculatorRPC \t \t \t one knee between"<<lastbx<<point->bx<<std::endl;
47  maginknee = point->gp.mag();
48  knees++;
49  }
50  lastbx = point->bx;
51  }
52 
53  if (knees == 0) {
54  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t knees="<<knees<<std::endl;
55  betavalue = maginfirstknee / (25. - delay + maginfirstknee / 30.) / 30.;
56  } else if (knees == 1) {
57  float betavalue1 = 0;
58  float betavalue2 = 0;
59  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t knees="<<knees<<std::endl;
60  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t anydifferentzero="<<anydifferentzero<<" anydifferentone="<<anydifferentone<<std::endl;
61  if (!anydifferentzero) {
62  betavalue = maginknee / (25 - delay + maginknee / 30.) / 30.;
63  } else if (!anydifferentone) { //i.e non zeros and no ones
64  betavalue = maginknee / (50 - delay + maginknee / 30.) / 30.;
65  } else {
66  betavalue1 = maginknee / (25 - delay + maginknee / 30.) / 30.;
67  float dr = (maginknee - maginfirstknee);
68  betavalue2 = dr / (25. - delay + dr / 30.);
69  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t \t not zero neither ones betavalue1="<<betavalue1<<" betavalue2="<<betavalue2<<std::endl;
70  betavalue = (betavalue1 + betavalue2) * 0.5;
71  }
72  } else if (knees == 2) {
73  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t knees="<<knees<<std::endl;
74  knees = 0;
75  float betavalue1 = 0;
76  float betavalue2 = 0;
77  lastbx = -7;
78  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t looping again on the RPCRecHits4D="<<knees<<std::endl;
79  for (std::vector<susybsm::RPCHit4D>::iterator point = HSCPRPCRecHits.begin(); point < HSCPRPCRecHits.end();
80  ++point) {
81  if (lastbx == -7) {
82  maginfirstknee = point->gp.mag();
83  } else if ((lastbx != point->bx)) {
84  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t \t one knee between"<<lastbx<<point->bx<<std::endl;
85  knees++;
86  if (knees == 2) {
87  float maginsecondknee = point->gp.mag();
88  betavalue1 = maginknee / (25 - delay + maginknee / 30.) / 30.;
89  float dr = (maginknee - maginsecondknee);
90  betavalue2 = dr / (25. + dr / 30.);
91  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t \t betavalue1="<<betavalue1<<" betavalue2="<<betavalue2<<std::endl;
92  }
93  }
94  lastbx = point->bx;
95  }
96  betavalue = (betavalue1 + betavalue2) * 0.5;
97  }
98 
99  if (Candidate) {
100  //std::cout<<"Inside BetaCalculatorRPC \t \t \t yes! We found an HSCPs let's try to estimate beta"<<std::endl;
101  } else {
102  //std::cout<<"Inside BetaCalculatorRPC \t \t \t seems that there is no RPC HSCP Candidate in the set of RPC4DHit"<<std::endl;
103  betavalue = 1.;
104  }
105 
106  if (HSCPRPCRecHits.empty()) {
107  //std::cout<<"Inside BetaCalculatorRPC \t WARINNG EMPTY RPC4DRecHits CONTAINER!!!"<<std::endl;
108  betavalue = 1.;
109  }
110 }
111 
113  const edm::Event& iEvent,
114  const edm::EventSetup& iSetup) {
116  iSetup.get<MuonGeometryRecord>().get(rpcGeo);
117 
119  iEvent.getByToken(rpcRecHitsToken, rpcHits);
120 
121  // here we do basically as in RPCHSCPCANDIDATE.cc, but just for the hits on the muon of interest
123  std::vector<RPCHit4D> hits;
124  // so, loop on the RPC hits of the muon
127 
128  if (candidate.hasMuonRef() && candidate.muonRef()->combinedMuon().isNonnull()) {
129  start = candidate.muonRef()->combinedMuon()->recHitsBegin();
130  stop = candidate.muonRef()->combinedMuon()->recHitsEnd();
131  } else if (candidate.hasMuonRef() && candidate.muonRef()->standAloneMuon().isNonnull()) {
132  track = *(candidate.muonRef()->standAloneMuon());
133  start = candidate.muonRef()->standAloneMuon()->recHitsBegin();
134  stop = candidate.muonRef()->standAloneMuon()->recHitsEnd();
135  } else
136  return;
137  /*
138  if(candidate.hasMuonCombinedTrack()) {
139  start = candidate.combinedTrack().recHitsBegin();
140  stop = candidate.combinedTrack().recHitsEnd();
141  } else if(candidate.hasMuonStaTrack()) {
142  start = candidate.staTrack().recHitsBegin();
143  stop = candidate.staTrack().recHitsEnd();
144  } else return;
145 */
146 
147  for (trackingRecHit_iterator recHit = start; recHit != stop; ++recHit) {
148  if ((*recHit)->geographicalId().subdetId() != MuonSubdetId::RPC)
149  continue;
150  if ((*recHit)->geographicalId().det() != DetId::Muon)
151  continue;
152  if (!(*recHit)->isValid())
153  continue; //Is Valid?
154 
155  RPCDetId rollId = (RPCDetId)(*recHit)->geographicalId();
156 
157  typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
158  rangeRecHits recHitCollection = rpcHits->get(rollId);
160  int size = 0;
161  int clusterS = 0;
162 
163  for (recHitC = recHitCollection.first; recHitC != recHitCollection.second; recHitC++) {
164  clusterS = (*recHitC).clusterSize();
165  // RPCDetId rollId = (RPCDetId)(*recHitC).geographicalId();
166  // std::cout<<"\t \t \t \t"<<rollId<<" bx "<<(*recHitC).BunchX()<<std::endl;
167  size++;
168  }
169  if (size > 1)
170  continue; //Is the only RecHit in this roll.?
171  if (clusterS > 4)
172  continue; //Is the Cluster Size 5 or bigger?
173 
174  LocalPoint recHitPos = (*recHit)->localPosition();
175  const RPCRoll* rollasociated = rpcGeo->roll(rollId);
176  const BoundPlane& RPCSurface = rollasociated->surface();
177 
178  RPCHit4D ThisHit;
179  ThisHit.bx = ((RPCRecHit*)(&(**recHit)))->BunchX();
180  ThisHit.gp = RPCSurface.toGlobal(recHitPos);
181  ThisHit.id = (RPCDetId)(*recHit)->geographicalId().rawId();
182  hits.push_back(ThisHit);
183  }
184  // here we go on with the RPC procedure
185  std::sort(hits.begin(), hits.end());
186  int lastbx = -7;
187  bool increasing = true;
188  bool outOfTime = false;
189  for (std::vector<RPCHit4D>::iterator point = hits.begin(); point < hits.end(); ++point) {
190  outOfTime |= (point->bx != 0); //condition 1: at least one measurement must have BX!=0
191  increasing &= (point->bx >= lastbx); //condition 2: BX must increase when going inside-out.
192  lastbx = point->bx;
193  }
194  result.isCandidate = (outOfTime && increasing);
195 
196  //result.beta = 1; // here we should get some pattern-based estimate
197  algo(hits);
198  result.beta = beta();
199  candidate.setRpc(result);
200 }
size
Write out results.
T getParameter(std::string const &) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void addInfoToCandidate(susybsm::HSCParticle &candidate, const edm::Event &iEvent, const edm::EventSetup &iSetup)
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
GlobalPoint gp
Definition: HSCParticle.h:27
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
int iEvent
Definition: GenABIO.cc:224
BetaCalculatorRPC(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
reco::MuonRef muonRef() const
Definition: HSCParticle.h:66
static constexpr int RPC
Definition: MuonSubdetId.h:13
T get() const
Definition: EventSetup.h:73
void setRpc(const RPCBetaMeasurement &data)
Definition: HSCParticle.h:60
void algo(const std::vector< susybsm::RPCHit4D > &HSCPRPCRecHits)
bool hasMuonRef() const
Definition: HSCParticle.h:48
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50