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 }
RPCRoll
Definition: RPCRoll.h:12
susybsm::HSCParticle
Definition: HSCParticle.h:42
start
Definition: start.py:1
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
configurableAnalysis::Candidate
char Candidate[]
Definition: modules.cc:20
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
BetaCalculatorRPC.h
susybsm::HSCParticle::hasMuonRef
bool hasMuonRef() const
Definition: HSCParticle.h:48
zMuMuMuonUserData.beta
beta
Definition: zMuMuMuonUserData.py:10
RPCDetId
Definition: RPCDetId.h:16
BetaCalculatorRPC::addInfoToCandidate
void addInfoToCandidate(susybsm::HSCParticle &candidate, const edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: BetaCalculatorRPC.cc:112
susybsm
Definition: HSCParticle.h:16
RPCGeometry::roll
const RPCRoll * roll(RPCDetId id) const
Return a roll given its id.
Definition: RPCGeometry.cc:50
edm::Handle< RPCRecHitCollection >
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
cmsdt::algo
algo
Definition: constants.h:164
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
susybsm::RPCHit4D
Definition: HSCParticle.h:23
RPCRecHitCollection
RPCRecHit
Definition: RPCRecHit.h:14
reco::Track
Definition: Track.h:27
edm::ESHandle< RPCGeometry >
BetaCalculatorRPC::BetaCalculatorRPC
BetaCalculatorRPC(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
Definition: BetaCalculatorRPC.cc:5
susybsm::RPCHit4D::id
int id
Definition: HSCParticle.h:25
Point3DBase< float, LocalTag >
edm::OwnVector::const_iterator
Definition: OwnVector.h:41
susybsm::RPCHit4D::bx
int bx
Definition: HSCParticle.h:26
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Ref::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
susybsm::HSCParticle::setRpc
void setRpc(const RPCBetaMeasurement &data)
Definition: HSCParticle.h:60
edm::RangeMap::const_iterator
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
iEvent
int iEvent
Definition: GenABIO.cc:224
susybsm::HSCParticle::muonRef
reco::MuonRef muonRef() const
Definition: HSCParticle.h:66
edm::EventSetup
Definition: EventSetup.h:57
get
#define get
MuonSubdetId::RPC
static constexpr int RPC
Definition: MuonSubdetId.h:13
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
BoundPlane
susybsm::RPCBetaMeasurement
Definition: HSCParticle.h:31
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
susybsm::RPCHit4D::gp
GlobalPoint gp
Definition: HSCParticle.h:27
mps_fire.result
result
Definition: mps_fire.py:311
phase2TrackerDigitizer_cfi.delay
delay
Definition: phase2TrackerDigitizer_cfi.py:49
DetId::Muon
Definition: DetId.h:26
command_line.start
start
Definition: command_line.py:167
BetaCalculatorRPC::algo
void algo(const std::vector< susybsm::RPCHit4D > &HSCPRPCRecHits)
Definition: BetaCalculatorRPC.cc:9
point
*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
edm::Event
Definition: Event.h:73
MuonGeometryRecord
Definition: MuonGeometryRecord.h:34
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443