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