Go to the documentation of this file.00001 #include "SUSYBSMAnalysis/HSCP/interface/BetaCalculatorRPC.h"
00002
00003 using namespace susybsm;
00004
00005
00006 BetaCalculatorRPC::BetaCalculatorRPC(const edm::ParameterSet& iConfig){
00007
00008 rpcRecHitsLabel = iConfig.getParameter<edm::InputTag>("rpcRecHits");
00009
00010 }
00011
00012 void BetaCalculatorRPC::algo(std::vector<susybsm::RPCHit4D> HSCPRPCRecHits){
00013
00014 int lastbx=-7;
00015 bool outOfTime = false;
00016 bool increasing = true;
00017 bool anydifferentzero = true;
00018 bool anydifferentone = true;
00019
00020
00021
00022 std::sort(HSCPRPCRecHits.begin(), HSCPRPCRecHits.end());
00023
00024 for(std::vector<susybsm::RPCHit4D>::iterator point = HSCPRPCRecHits.begin(); point < HSCPRPCRecHits.end(); ++point) {
00025 outOfTime |= (point->bx!=0);
00026 increasing &= (point->bx>=lastbx);
00027 anydifferentzero &= (!point->bx==0);
00028 anydifferentone &= (!point->bx==1);
00029 lastbx = point->bx;
00030
00031
00032 }
00033
00034 bool Candidate = (outOfTime&&increasing);
00035
00036
00037
00038
00039
00040 float delay=12.5;
00041 lastbx=-7;
00042 int knees=0;
00043 float maginknee = 0;
00044 float maginfirstknee = 0;
00045 for(std::vector<susybsm::RPCHit4D>::iterator point = HSCPRPCRecHits.begin(); point < HSCPRPCRecHits.end(); ++point) {
00046 if(lastbx==-7){
00047 maginfirstknee = point->gp.mag();
00048 }else if((lastbx!=point->bx)){
00049
00050 maginknee=point->gp.mag();
00051 knees++;
00052 }
00053 lastbx=point->bx;
00054 }
00055
00056 if(knees==0){
00057
00058 betavalue=maginfirstknee/(25.-delay+maginfirstknee/30.)/30.;
00059 }else if(knees==1){
00060 float betavalue1=0;
00061 float betavalue2=0;
00062
00063
00064 if(!anydifferentzero){
00065 betavalue=maginknee/(25-delay+maginknee/30.)/30.;
00066 }else if(!anydifferentone){
00067 betavalue=maginknee/(50-delay+maginknee/30.)/30.;
00068 }else{
00069 betavalue1=maginknee/(25-delay+maginknee/30.)/30.;
00070 float dr =(maginknee-maginfirstknee);
00071 betavalue2 = dr/(25.-delay+dr/30.);
00072
00073 betavalue = (betavalue1 + betavalue2)*0.5;
00074 }
00075 }else if(knees==2){
00076
00077 knees=0;
00078 float betavalue1=0;
00079 float betavalue2=0;
00080 lastbx=-7;
00081
00082 for(std::vector<susybsm::RPCHit4D>::iterator point = HSCPRPCRecHits.begin(); point < HSCPRPCRecHits.end(); ++point) {
00083 if(lastbx==-7){
00084 maginfirstknee = point->gp.mag();
00085 }else if((lastbx!=point->bx)){
00086
00087 knees++;
00088 if(knees==2){
00089 float maginsecondknee=point->gp.mag();
00090 betavalue1=maginknee/(25-delay+maginknee/30.)/30.;
00091 float dr =(maginknee-maginsecondknee);
00092 betavalue2 = dr/(25.+dr/30.);
00093
00094 }
00095 }
00096 lastbx=point->bx;
00097 }
00098 betavalue = (betavalue1 + betavalue2)*0.5;
00099 }
00100
00101 if(Candidate){
00102
00103 }else{
00104
00105 betavalue = 1.;
00106 }
00107
00108 if(HSCPRPCRecHits.size()==0){
00109
00110 betavalue = 1.;
00111 }
00112 }
00113
00114
00115
00116 void BetaCalculatorRPC::addInfoToCandidate(HSCParticle& candidate, const edm::Event& iEvent, const edm::EventSetup& iSetup) {
00117
00118 edm::ESHandle<RPCGeometry> rpcGeo;
00119 iSetup.get<MuonGeometryRecord>().get(rpcGeo);
00120
00121 edm::Handle<RPCRecHitCollection> rpcHits;
00122 iEvent.getByLabel(rpcRecHitsLabel,rpcHits);
00123
00124
00125
00126 RPCBetaMeasurement result;
00127 std::vector<RPCHit4D> hits;
00128
00129 trackingRecHit_iterator start,stop;
00130 reco::Track track;
00131
00132 if( candidate.hasMuonRef() && candidate.muonRef()->combinedMuon() .isNonnull()){
00133 start = candidate.muonRef()->combinedMuon()->recHitsBegin();
00134 stop = candidate.muonRef()->combinedMuon()->recHitsEnd();
00135 }else if(candidate.hasMuonRef() && candidate.muonRef()->standAloneMuon().isNonnull()){ track=*(candidate.muonRef()->standAloneMuon());
00136 start = candidate.muonRef()->standAloneMuon()->recHitsBegin();
00137 stop = candidate.muonRef()->standAloneMuon()->recHitsEnd();
00138 }else return;
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148 for(trackingRecHit_iterator recHit = start; recHit != stop; ++recHit) {
00149 if ( (*recHit)->geographicalId().subdetId() != MuonSubdetId::RPC ) continue;
00150 if ( (*recHit)->geographicalId().det() != DetId::Muon ) continue;
00151 if (!(*recHit)->isValid()) continue;
00152
00153 RPCDetId rollId = (RPCDetId)(*recHit)->geographicalId();
00154
00155 typedef std::pair<RPCRecHitCollection::const_iterator, RPCRecHitCollection::const_iterator> rangeRecHits;
00156 rangeRecHits recHitCollection = rpcHits->get(rollId);
00157 RPCRecHitCollection::const_iterator recHitC;
00158 int size = 0;
00159 int clusterS=0;
00160 for(recHitC = recHitCollection.first; recHitC != recHitCollection.second ; recHitC++) {
00161 clusterS=(*recHitC).clusterSize();
00162
00163
00164 size++;
00165 }
00166 if(size>1) continue;
00167 if(clusterS>4) continue;
00168
00169 LocalPoint recHitPos=(*recHit)->localPosition();
00170 const RPCRoll* rollasociated = rpcGeo->roll(rollId);
00171 const BoundPlane & RPCSurface = rollasociated->surface();
00172
00173 RPCHit4D ThisHit;
00174 ThisHit.bx = ((RPCRecHit*)(&(**recHit)))->BunchX();
00175 ThisHit.gp = RPCSurface.toGlobal(recHitPos);
00176 ThisHit.id = (RPCDetId)(*recHit)->geographicalId().rawId();
00177 hits.push_back(ThisHit);
00178
00179 }
00180
00181 std::sort(hits.begin(), hits.end());
00182 int lastbx=-7;
00183 bool increasing = true;
00184 bool outOfTime = false;
00185 for(std::vector<RPCHit4D>::iterator point = hits.begin(); point < hits.end(); ++point) {
00186 outOfTime |= (point->bx!=0);
00187 increasing &= (point->bx>=lastbx);
00188 lastbx = point->bx;
00189 }
00190 result.isCandidate = (outOfTime&&increasing);
00191
00192
00193 algo(hits);
00194 result.beta = beta();
00195 candidate.setRpc(result);
00196 }
00197
00198