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 
4 
5  rpcRecHitsLabel = iConfig.getParameter<edm::InputTag>("rpcRecHits");
6 
7 }
8 
9 void BetaCalculatorRPC::algo(std::vector<susybsm::RPCHit4D> HSCPRPCRecHits){
10 
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(); ++point) {
80  if(lastbx==-7){
81  maginfirstknee = point->gp.mag();
82  }else if((lastbx!=point->bx)){
83  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t \t one knee between"<<lastbx<<point->bx<<std::endl;
84  knees++;
85  if(knees==2){
86  float maginsecondknee=point->gp.mag();
87  betavalue1=maginknee/(25-delay+maginknee/30.)/30.;
88  float dr =(maginknee-maginsecondknee);
89  betavalue2 = dr/(25.+dr/30.);
90  //std::cout<<"Inside BetaCalculatorRPC \t \t \t \t \t betavalue1="<<betavalue1<<" betavalue2="<<betavalue2<<std::endl;
91  }
92  }
93  lastbx=point->bx;
94  }
95  betavalue = (betavalue1 + betavalue2)*0.5;
96  }
97 
98  if(Candidate){
99  //std::cout<<"Inside BetaCalculatorRPC \t \t \t yes! We found an HSCPs let's try to estimate beta"<<std::endl;
100  }else{
101  //std::cout<<"Inside BetaCalculatorRPC \t \t \t seems that there is no RPC HSCP Candidate in the set of RPC4DHit"<<std::endl;
102  betavalue = 1.;
103  }
104 
105  if(HSCPRPCRecHits.size()==0){
106  //std::cout<<"Inside BetaCalculatorRPC \t WARINNG EMPTY RPC4DRecHits CONTAINER!!!"<<std::endl;
107  betavalue = 1.;
108  }
109 }
110 
111 
112 
114 
116  iSetup.get<MuonGeometryRecord>().get(rpcGeo);
117 
119  iEvent.getByLabel(rpcRecHitsLabel,rpcHits);
120 
121 
122  // here we do basically as in RPCHSCPCANDIDATE.cc, but just for the hits on the muon of interest
124  std::vector<RPCHit4D> hits;
125  // so, loop on the RPC hits of the muon
126  trackingRecHit_iterator start,stop;
127  reco::Track track;
128 
129  if( candidate.hasMuonRef() && candidate.muonRef()->combinedMuon() .isNonnull()){
130  start = candidate.muonRef()->combinedMuon()->recHitsBegin();
131  stop = candidate.muonRef()->combinedMuon()->recHitsEnd();
132  }else if(candidate.hasMuonRef() && candidate.muonRef()->standAloneMuon().isNonnull()){ track=*(candidate.muonRef()->standAloneMuon());
133  start = candidate.muonRef()->standAloneMuon()->recHitsBegin();
134  stop = candidate.muonRef()->standAloneMuon()->recHitsEnd();
135  }else return;
136 /*
137  if(candidate.hasMuonCombinedTrack()) {
138  start = candidate.combinedTrack().recHitsBegin();
139  stop = candidate.combinedTrack().recHitsEnd();
140  } else if(candidate.hasMuonStaTrack()) {
141  start = candidate.staTrack().recHitsBegin();
142  stop = candidate.staTrack().recHitsEnd();
143  } else return;
144 */
145  for(trackingRecHit_iterator recHit = start; recHit != stop; ++recHit) {
146  if ( (*recHit)->geographicalId().subdetId() != MuonSubdetId::RPC ) continue;
147  if ( (*recHit)->geographicalId().det() != DetId::Muon ) continue;
148  if (!(*recHit)->isValid()) continue; //Is Valid?
149 
150  RPCDetId rollId = (RPCDetId)(*recHit)->geographicalId();
151 
152  typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
153  rangeRecHits recHitCollection = rpcHits->get(rollId);
155  int size = 0;
156  int clusterS=0;
157  for(recHitC = recHitCollection.first; recHitC != recHitCollection.second ; recHitC++) {
158  clusterS=(*recHitC).clusterSize();
159  RPCDetId rollId = (RPCDetId)(*recHitC).geographicalId();
160 // std::cout<<"\t \t \t \t"<<rollId<<" bx "<<(*recHitC).BunchX()<<std::endl;
161  size++;
162  }
163  if(size>1) continue; //Is the only RecHit in this roll.?
164  if(clusterS>4) continue; //Is the Cluster Size 5 or bigger?
165 
166  LocalPoint recHitPos=(*recHit)->localPosition();
167  const RPCRoll* rollasociated = rpcGeo->roll(rollId);
168  const BoundPlane & RPCSurface = rollasociated->surface();
169 
170  RPCHit4D ThisHit;
171  ThisHit.bx = ((RPCRecHit*)(&(**recHit)))->BunchX();
172  ThisHit.gp = RPCSurface.toGlobal(recHitPos);
173  ThisHit.id = (RPCDetId)(*recHit)->geographicalId().rawId();
174  hits.push_back(ThisHit);
175 
176  }
177  // here we go on with the RPC procedure
178  std::sort(hits.begin(), hits.end());
179  int lastbx=-7;
180  bool increasing = true;
181  bool outOfTime = false;
182  for(std::vector<RPCHit4D>::iterator point = hits.begin(); point < hits.end(); ++point) {
183  outOfTime |= (point->bx!=0); //condition 1: at least one measurement must have BX!=0
184  increasing &= (point->bx>=lastbx); //condition 2: BX must increase when going inside-out.
185  lastbx = point->bx;
186  }
187  result.isCandidate = (outOfTime&&increasing);
188 
189  //result.beta = 1; // here we should get some pattern-based estimate
190  algo(hits);
191  result.beta = beta();
192  candidate.setRpc(result);
193 }
194 
195 
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:78
T getParameter(std::string const &) const
void addInfoToCandidate(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:249
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:46
int iEvent
Definition: GenABIO.cc:243
edm::InputTag rpcRecHitsLabel
tuple result
Definition: query.py:137
BetaCalculatorRPC(const edm::ParameterSet &iConfig)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
reco::MuonRef muonRef() const
Definition: HSCParticle.h:72
const T & get() const
Definition: EventSetup.h:55
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
virtual const BoundPlane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
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