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  rpcRecHitsLabel = iConfig.getParameter<edm::InputTag>("rpcRecHits");
9 
10 }
11 
12 void BetaCalculatorRPC::algo(std::vector<susybsm::RPCHit4D> HSCPRPCRecHits){
13 
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 
117 
119  iSetup.get<MuonGeometryRecord>().get(rpcGeo);
120 
122  iEvent.getByLabel(rpcRecHitsLabel,rpcHits);
123 
124 
125  // here we do basically as in RPCHSCPCANDIDATE.cc, but just for the hits on the muon of interest
127  std::vector<RPCHit4D> hits;
128  // so, loop on the RPC hits of the muon
130  reco::Track track;
131 
132  if( candidate.hasMuonRef() && candidate.muonRef()->combinedMuon() .isNonnull()){
133  start = candidate.muonRef()->combinedMuon()->recHitsBegin();
134  stop = candidate.muonRef()->combinedMuon()->recHitsEnd();
135  }else if(candidate.hasMuonRef() && candidate.muonRef()->standAloneMuon().isNonnull()){ track=*(candidate.muonRef()->standAloneMuon());
136  start = candidate.muonRef()->standAloneMuon()->recHitsBegin();
137  stop = candidate.muonRef()->standAloneMuon()->recHitsEnd();
138  }else return;
139 /*
140  if(candidate.hasMuonCombinedTrack()) {
141  start = candidate.combinedTrack().recHitsBegin();
142  stop = candidate.combinedTrack().recHitsEnd();
143  } else if(candidate.hasMuonStaTrack()) {
144  start = candidate.staTrack().recHitsBegin();
145  stop = candidate.staTrack().recHitsEnd();
146  } else return;
147 */
148  for(trackingRecHit_iterator recHit = start; recHit != stop; ++recHit) {
149  if ( (*recHit)->geographicalId().subdetId() != MuonSubdetId::RPC ) continue;
150  if ( (*recHit)->geographicalId().det() != DetId::Muon ) continue;
151  if (!(*recHit)->isValid()) continue; //Is Valid?
152 
153  RPCDetId rollId = (RPCDetId)(*recHit)->geographicalId();
154 
155  typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
156  rangeRecHits recHitCollection = rpcHits->get(rollId);
158  int size = 0;
159  int clusterS=0;
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  }
180  // here we go on with the RPC procedure
181  std::sort(hits.begin(), hits.end());
182  int lastbx=-7;
183  bool increasing = true;
184  bool outOfTime = false;
185  for(std::vector<RPCHit4D>::iterator point = hits.begin(); point < hits.end(); ++point) {
186  outOfTime |= (point->bx!=0); //condition 1: at least one measurement must have BX!=0
187  increasing &= (point->bx>=lastbx); //condition 2: BX must increase when going inside-out.
188  lastbx = point->bx;
189  }
190  result.isCandidate = (outOfTime&&increasing);
191 
192  //result.beta = 1; // here we should get some pattern-based estimate
193  algo(hits);
194  result.beta = beta();
195  candidate.setRpc(result);
196 }
197 
198 
const double beta
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
T getParameter(std::string const &) const
void addInfoToCandidate(susybsm::HSCParticle &candidate, const edm::Event &iEvent, const edm::EventSetup &iSetup)
GlobalPoint gp
Definition: HSCParticle.h:28
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:45
int iEvent
Definition: GenABIO.cc:243
tuple result
Definition: query.py:137
BetaCalculatorRPC(const edm::ParameterSet &iConfig)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
reco::MuonRef muonRef() const
Definition: HSCParticle.h:72
const T & get() const
Definition: EventSetup.h:55
const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
static const int RPC
Definition: MuonSubdetId.h:16
void setRpc(const RPCBetaMeasurement &data)
Definition: HSCParticle.h:65
void algo(std::vector< susybsm::RPCHit4D > HSCPRPCRecHits)
bool hasMuonRef() const
Definition: HSCParticle.h:55
LimitAlgo * algo
Definition: Combine.cc:60
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