CMS 3D CMS Logo

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