1 |
zhangjin |
1.1 |
// -*- C++ -*-
|
2 |
|
|
//
|
3 |
|
|
// Package: TPTrackMuonSys
|
4 |
|
|
// Class: TPTrackMuonSys
|
5 |
|
|
//
|
6 |
|
|
/**\class TPTrackMuonSys TPTrackMuonSys.cc RPhysicsStudies/TPTrackMuonSys/src/TPTrackMuonSys.cc
|
7 |
|
|
|
8 |
|
|
Description: [one line class summary]
|
9 |
|
|
|
10 |
|
|
Implementation:
|
11 |
|
|
[Notes on implementation]
|
12 |
|
|
*/
|
13 |
|
|
//
|
14 |
|
|
// Original Author: Chaouki Boulahouache,32 4-A05,+41227674763;
|
15 |
|
|
// Jinzhong Zhang,32 4-C21,+41227671337,
|
16 |
|
|
// Created: Wed May 12 15:52:13 CEST 2010
|
17 |
|
|
// $Id$
|
18 |
|
|
//
|
19 |
|
|
// system include files
|
20 |
|
|
#include <memory>
|
21 |
|
|
|
22 |
|
|
// user include files
|
23 |
|
|
#include "../interface/TPTrackMuonSys.h"
|
24 |
|
|
|
25 |
|
|
TPTrackMuonSys::TPTrackMuonSys(const edm::ParameterSet& Conf) : theDbConditions( Conf ) {
|
26 |
|
|
//now do what ever initialization is needed
|
27 |
|
|
m_rootFileName = Conf.getUntrackedParameter<std::string>("rootFileName","PhyTree.root");
|
28 |
|
|
///////////////////////////////
|
29 |
|
|
// Various input parameters.
|
30 |
|
|
//////////////////////////////
|
31 |
|
|
|
32 |
|
|
// A debug flag, here I can set different debugging steps based on the m_debug value,
|
33 |
|
|
m_gTracksTag = Conf.getUntrackedParameter<edm::InputTag>("gTracksTag"); // "generalTracks"
|
34 |
|
|
m_dEdxDiscrimTag = Conf.getUntrackedParameter<edm::InputTag>("dedxTag"); //dedxHarmonic2
|
35 |
|
|
trackProducer = Conf.getParameter<edm::InputTag>("trackProducer");
|
36 |
|
|
m_vertexSrc = Conf.getParameter<edm::InputTag>("vertexCollection");
|
37 |
|
|
|
38 |
|
|
m_hlt = Conf.getUntrackedParameter<edm::InputTag>("hltTag"); //TriggerResults::HLT
|
39 |
|
|
m_hltTrgEv = Conf.getUntrackedParameter<edm::InputTag>("hltEvTag"); //TriggerResults::HLT
|
40 |
|
|
m_L1extraTag = Conf.getUntrackedParameter<edm::InputTag>("L1extraTag");
|
41 |
|
|
|
42 |
|
|
m_HepMCTag = Conf.getUntrackedParameter<string>("HepMCTag","generator");
|
43 |
|
|
|
44 |
|
|
m_HLTMuTrgNames = Conf.getParameter< vector<string> >("HLTMuTrgNames");
|
45 |
|
|
m_HLTDiMuTrgName = Conf.getParameter< string >("HLTDiMuTrgName");
|
46 |
|
|
|
47 |
|
|
// TrackAssociator parameters
|
48 |
|
|
edm::ParameterSet parameters = Conf.getParameter<edm::ParameterSet>("TrackAssociatorParameters");
|
49 |
|
|
parameters_.loadParameters( parameters );
|
50 |
|
|
trackAssociator_.useDefaultPropagator();
|
51 |
|
|
|
52 |
|
|
/// Now the MC specific information... if available...
|
53 |
|
|
//
|
54 |
|
|
m_isMC = Conf.getUntrackedParameter<bool>("isMC");
|
55 |
|
|
m_mcTag = Conf.getUntrackedParameter<edm::InputTag>("mcTag"); //
|
56 |
|
|
|
57 |
|
|
// flags to switch on/off individual modules
|
58 |
|
|
// set counters to zero
|
59 |
|
|
nEventsAnalyzed = 0;
|
60 |
|
|
treeCount = 0;
|
61 |
|
|
|
62 |
|
|
// Create the root file for the histograms
|
63 |
|
|
theFile = new TFile(m_rootFileName.c_str(), "RECREATE");
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
//////////////////// for LUTs
|
67 |
|
|
|
68 |
|
|
bzero(srLUTs_, sizeof(srLUTs_));
|
69 |
|
|
//Int_t endcap =1, sector =1;
|
70 |
|
|
Bool_t TMB07=true;
|
71 |
|
|
edm::ParameterSet srLUTset;
|
72 |
|
|
srLUTset.addUntrackedParameter<bool>("ReadLUTs", false);
|
73 |
|
|
srLUTset.addUntrackedParameter<bool>("Binary", false);
|
74 |
|
|
srLUTset.addUntrackedParameter<std::string>("LUTPath", "./");
|
75 |
|
|
for(Int_t endcapItr = CSCDetId::minEndcapId(); endcapItr <= CSCDetId::maxEndcapId(); endcapItr++){
|
76 |
|
|
for(Int_t sectorItr = CSCTriggerNumbering::minTriggerSectorId();sectorItr <= CSCTriggerNumbering::maxTriggerSectorId();sectorItr++){
|
77 |
|
|
for(Int_t stationItr = 1; stationItr <= 4; stationItr++){
|
78 |
|
|
if(stationItr == 1){
|
79 |
|
|
for(Int_t subsectorItr = 0; subsectorItr < 2; subsectorItr++){
|
80 |
|
|
srLUTs_[endcapItr-1][sectorItr-1][subsectorItr] = new CSCSectorReceiverLUT(endcapItr, sectorItr, subsectorItr+1, stationItr, srLUTset, TMB07);
|
81 |
|
|
}
|
82 |
|
|
} else {
|
83 |
|
|
srLUTs_[endcapItr-1][sectorItr-1][stationItr] = new CSCSectorReceiverLUT(endcapItr, sectorItr, 0, stationItr, srLUTset, TMB07);
|
84 |
|
|
} //if for station 1 or 234
|
85 |
|
|
} // stationItr loop
|
86 |
|
|
} // sectorItr loop
|
87 |
|
|
} // endcapItr loop
|
88 |
|
|
|
89 |
|
|
// ------------------------------
|
90 |
|
|
// --- Summary ntuple booking ---
|
91 |
|
|
// ------------------------------
|
92 |
|
|
|
93 |
|
|
fractNtuple = new TTree("Fraction","/Fraction");
|
94 |
|
|
fractNtuple->Branch("run_number", &run_number, "run_number/I") ;
|
95 |
|
|
fractNtuple->Branch("event_number", &event_number, "event_number/I") ;
|
96 |
|
|
fractNtuple->Branch("LumiBlock", &LumiBlock,"LumiBlock/I") ;
|
97 |
|
|
fractNtuple->Branch("bunchX", &bunchX, "bunchX/I") ;
|
98 |
|
|
fractNtuple->Branch("orbitNumb", &orbitNumb,"orbitNumb/I") ;
|
99 |
|
|
fractNtuple->Branch("mcweight", &mcweight,"mcweight/F") ;
|
100 |
|
|
fractNtuple->Branch("numberOfPUVertices", &numberOfPUVertices, "numberOfPUVertices/i");
|
101 |
|
|
fractNtuple->Branch("numberOfPUVerticesMixingTruth", &numberOfPUVerticesMixingTruth, "numberOfPUVerticesMixingTruth/F");
|
102 |
|
|
fractNtuple->Branch("numberOfPUVerticesTot", &numberOfPUVerticesTot, "numberOfPUVerticesTot/i");
|
103 |
|
|
fractNtuple->Branch("numberOfPrimaryVertices" , &numberOfPrimaryVertices , "numberOfPrimaryVertices/i");
|
104 |
|
|
fractNtuple->Branch("trgSingle", &trgSingle,"trgSingle/O") ;
|
105 |
|
|
fractNtuple->Branch("nTrkCountCSCSeg", &nTrkCountCSCSeg, "nTrkCountCSCSeg/I") ;
|
106 |
|
|
// fractNtuple->Branch("nTrkCountRPCE", &nTrkCountRPCE, "nTrkCountRPCE/I") ;
|
107 |
|
|
//fractNtuple->Branch("nTrkCountEC", &nTrkCountEC, "nTrkCountEC/I") ;
|
108 |
|
|
fractNtuple->Branch("nPosTrk", &nPosTrk, "nPosTrk/I") ;
|
109 |
|
|
fractNtuple->Branch("nNegTrk", &nNegTrk, "nNegTrk/I") ;
|
110 |
|
|
fractNtuple->Branch("nTotalTrks", &nTotalTrks, "nTotalTrks/I") ;
|
111 |
|
|
fractNtuple->Branch("trackVeto", &trackVeto, "trackVeto/O") ;
|
112 |
|
|
fractNtuple->Branch("myRegion", &myRegion, "myRegion/I") ;
|
113 |
|
|
fractNtuple->Branch("MuTagPt", &MuTagPt, "MuTagPt/F") ;
|
114 |
|
|
fractNtuple->Branch("MuTagEta", &MuTagEta, "MuTagEta/F") ;
|
115 |
|
|
fractNtuple->Branch("MuTagPhi", &MuTagPhi, "MuTagPhi/F") ;
|
116 |
|
|
fractNtuple->Branch("MuTagPromt", &MuTagPromt, "MuTagPromt/I");
|
117 |
|
|
fractNtuple->Branch("MuTagnSegTrkArb", &MuTagnSegTrkArb, "MuTagnSegTrkArb/I");
|
118 |
|
|
fractNtuple->Branch("MuTagCaloL", &MuTagCaloL, "MuTagCaloL/O") ;
|
119 |
|
|
fractNtuple->Branch("MuTagCaloT", &MuTagCaloT, "MuTagCaloT/O") ;
|
120 |
|
|
fractNtuple->Branch("MuTagtracktruth_pt", &MuTagtracktruth_pt, "MuTagtracktruth_pt/F") ;
|
121 |
|
|
fractNtuple->Branch("MuTagtracktruth_p", &MuTagtracktruth_p, "MuTagtracktruth_p/F") ;
|
122 |
|
|
fractNtuple->Branch("MuTagtracktruth_id", &MuTagtracktruth_id, "MuTagtracktruth_id/F") ;
|
123 |
|
|
fractNtuple->Branch("MuTagtracktruth_type", &MuTagtracktruth_type, "MuTagtracktruth_type/l") ;
|
124 |
|
|
fractNtuple->Branch("MuTagtracktruth_isPileup", &MuTagtracktruth_isPileup, "MuTagtracktruth_isPileup/O") ;
|
125 |
|
|
fractNtuple->Branch("MuTagtracktruth_thesamewith", &MuTagtracktruth_thesamewith, "MuTagtracktruth_thesamewith/I") ;
|
126 |
|
|
fractNtuple->Branch("vtx_r", &vtx_r, "vtx_r/F") ;
|
127 |
|
|
fractNtuple->Branch("vtx_z", &vtx_z, "vtx_z/F") ;
|
128 |
|
|
fractNtuple->Branch("vtx_rError", &vtx_rError, "vtx_rError/F") ;
|
129 |
|
|
fractNtuple->Branch("vtx_zError", &vtx_zError, "vtx_zError/F") ;
|
130 |
|
|
fractNtuple->Branch("vtx_normChi2", &vtx_normChi2, "vtx_normChi2/F") ;
|
131 |
|
|
fractNtuple->Branch("vtx_size", &vtx_size, "vtx_size/I") ;
|
132 |
|
|
fractNtuple->Branch("iSameVtx", &iSameVtx, "iSameVtx/O") ;
|
133 |
|
|
fractNtuple->Branch("invMass", &invMass, "invMass/F");
|
134 |
|
|
fractNtuple->Branch("tracks_e", &tracks_e, "tracks_e/F");
|
135 |
|
|
fractNtuple->Branch("tracks_pt", &tracks_pt, "tracks_pt/F");
|
136 |
|
|
fractNtuple->Branch("tracks_eta", &tracks_eta, "tracks_eta/F");
|
137 |
|
|
fractNtuple->Branch("tracks_phi", &tracks_phi, "tracks_phi/F");
|
138 |
|
|
fractNtuple->Branch("tracks_charge", &tracks_charge, "tracks_charge/I");
|
139 |
|
|
fractNtuple->Branch("tracks_id", &tracks_id, "tracks_id/I");
|
140 |
|
|
fractNtuple->Branch("tracks_normchi2", &tracks_chi2, "tracks_normchi2/F");
|
141 |
|
|
fractNtuple->Branch("tracks_dxy", &tracks_dxy, "tracks_dxy/F");
|
142 |
|
|
fractNtuple->Branch("tracks_dz", &tracks_dz, "tracks_dz/F");
|
143 |
|
|
fractNtuple->Branch("tracks_vx", &tracks_vx, "tracks_vx/F");
|
144 |
|
|
fractNtuple->Branch("tracks_vy", &tracks_vy, "tracks_vy/F");
|
145 |
|
|
fractNtuple->Branch("tracks_vz", &tracks_vz, "tracks_vz/F");
|
146 |
|
|
fractNtuple->Branch("tracks_qoverp", &tracks_qoverp, "tracks_qoverp/F");
|
147 |
|
|
fractNtuple->Branch("tracks_lambda", &tracks_lambda, "tracks_lambda/F");
|
148 |
|
|
fractNtuple->Branch("tracks_recHitsSize", &tracks_recHitsSize, "tracks_recHitsSize/I");
|
149 |
|
|
fractNtuple->Branch("tracks_numberOfValidHits", &tracks_numberOfValidHits, "tracks_numberOfValidHits/I");
|
150 |
|
|
fractNtuple->Branch("tracks_numberOfLostHits", &tracks_numberOfLostHits, "tracks_numberOfLostHits/I");
|
151 |
|
|
fractNtuple->Branch("tracks_qoverpError", &tracks_qoverpError, "tracks_qoverpError/F");
|
152 |
|
|
fractNtuple->Branch("tracks_ptError", &tracks_ptError, "tracks_ptError/F");
|
153 |
|
|
fractNtuple->Branch("tracks_thetaError", &tracks_thetaError, "tracks_thetaError/F");
|
154 |
|
|
fractNtuple->Branch("tracks_lambdaError", &tracks_lambdaError, "tracks_lambdaError/F");
|
155 |
|
|
fractNtuple->Branch("tracks_etaError", &tracks_etaError, "tracks_etaError/F");
|
156 |
|
|
fractNtuple->Branch("tracks_phiError", &tracks_phiError, "tracks_phiError/F");
|
157 |
|
|
fractNtuple->Branch("tracks_dxyError", &tracks_dxyError, "tracks_dxyError/F");
|
158 |
|
|
fractNtuple->Branch("tracks_d0Error", &tracks_d0Error, "tracks_d0Error/F");
|
159 |
|
|
fractNtuple->Branch("tracks_dszError", &tracks_dszError, "tracks_dszError/F");
|
160 |
|
|
fractNtuple->Branch("tracks_dzError", &tracks_dzError, "tracks_dzError/F");
|
161 |
|
|
fractNtuple->Branch("tracks_isCaloMuTrk", &tracks_isCaloMuTrk, "tracks_isCaloMuTrk/O");
|
162 |
|
|
fractNtuple->Branch("tracks_isTrackerMuTrk", &tracks_isTrackerMuTrk, "tracks_isTrackerMuTrk/O");
|
163 |
|
|
// fractNtuple->Branch("tracks_dedx", &tracks_dedx, "tracks_dedx/F") ;
|
164 |
|
|
// fractNtuple->Branch("tracks_dedxErr", &tracks_dedxErr, "tracks_dedxErr/F") ;
|
165 |
|
|
// fractNtuple->Branch("tracks_nSatMeas", &tracks_nSatMeas, "tracks_nSatMeas/F") ;
|
166 |
|
|
//fractNtuple->Branch("tracks_nMeas", &tracks_nMeas, "tracks_nMeas/F") ;
|
167 |
|
|
fractNtuple->Branch("tracktruth_pt", &tracktruth_pt, "tracktruth_pt/F") ;
|
168 |
|
|
fractNtuple->Branch("tracktruth_p", &tracktruth_p, "tracktruth_p/F") ;
|
169 |
|
|
fractNtuple->Branch("tracktruth_e", &tracktruth_e, "tracktruth_e/F") ;
|
170 |
|
|
fractNtuple->Branch("tracktruth_id", &tracktruth_id, "tracktruth_id/F") ;
|
171 |
|
|
fractNtuple->Branch("tracktruth_type", &tracktruth_type, "tracktruth_type/l") ;
|
172 |
|
|
fractNtuple->Branch("tracktruth_isPileup", &tracktruth_isPileup, "tracktruth_isPileup/O") ;
|
173 |
|
|
fractNtuple->Branch("tracktruth_thesamewith", &tracktruth_thesamewith, "tracktruth_thesamewith/I") ;
|
174 |
|
|
|
175 |
|
|
fractNtuple->Branch("CSCEndCapPlus", &CSCEndCapPlus, "CSCEndCapPlus/O") ;
|
176 |
|
|
|
177 |
|
|
#define MakeBranchAllSt(Name,Type,Var) sprintf(BranchName,"%s%d",Name,st+1); \
|
178 |
|
|
sprintf(BranchTitle,"%s%d/%s",Name,st+1,Type); \
|
179 |
|
|
fractNtuple->Branch(BranchName, &Var[st],BranchTitle)
|
180 |
|
|
|
181 |
|
|
for (Short_t st=0;st<4;st++) {
|
182 |
|
|
char BranchName[30],BranchTitle[30];
|
183 |
|
|
/*CSC Chamber Candidates in each station*/
|
184 |
|
|
MakeBranchAllSt("CSCRg","S",CSCRg);
|
185 |
|
|
MakeBranchAllSt("CSCCh","S",CSCChCand);
|
186 |
|
|
MakeBranchAllSt("CSCCBad","O",CSCChBad);
|
187 |
|
|
|
188 |
|
|
/*Extrapolated Tracks on CSC Chamber Candidates in each station*/
|
189 |
|
|
MakeBranchAllSt("CSCxProjLc","F",CSCxProjLc);
|
190 |
|
|
MakeBranchAllSt("CSCyProjLc","F",CSCyProjLc);
|
191 |
|
|
MakeBranchAllSt("CSCxErrProjLc","F",CSCxErrProjLc);
|
192 |
|
|
MakeBranchAllSt("CSCyErrProjLc","F",CSCyErrProjLc);
|
193 |
|
|
MakeBranchAllSt("CSCDyProjHVGap","F",CSCDyProjHVGap);
|
194 |
|
|
MakeBranchAllSt("CSCProjDistEdge","F",CSCProjEdgeDist);
|
195 |
|
|
MakeBranchAllSt("CSCProjDistErrEdge","F",CSCProjEdgeDistErr);
|
196 |
|
|
|
197 |
|
|
/*Distance from the Extrapolated Tracks to CSC Segments, 99999. for no CSC segment found*/
|
198 |
|
|
MakeBranchAllSt("CSCDrTTSeg","F",CSCDxyTTSeg);
|
199 |
|
|
MakeBranchAllSt("CSCDxTTSeg","F",CSCDxTTSeg);
|
200 |
|
|
MakeBranchAllSt("CSCDyTTSeg","F",CSCDyTTSeg);
|
201 |
|
|
MakeBranchAllSt("CSCDrErrTTSeg","F",CSCDxyErrTTSeg) ;
|
202 |
|
|
MakeBranchAllSt("CSCdXdZTTSeg","F",CSCdXdZTTSeg);
|
203 |
|
|
MakeBranchAllSt("CSCdYdZTTSeg","F",CSCdYdZTTSeg);
|
204 |
|
|
|
205 |
|
|
/*Segments characteristics*/
|
206 |
|
|
MakeBranchAllSt("CSCSegxLc","F",CSCSegxLc);
|
207 |
|
|
MakeBranchAllSt("CSCSegyLc","F",CSCSegyLc);
|
208 |
|
|
MakeBranchAllSt("CSCSegxErrLc","F",CSCSegxErrLc);
|
209 |
|
|
MakeBranchAllSt("CSCSegyErrLc","F",CSCSegyErrLc);
|
210 |
|
|
MakeBranchAllSt("CSCSegChisqProb","F",CSCSegChisqProb);
|
211 |
|
|
MakeBranchAllSt("CSCnSegHits","I",CSCnSegHits) ;
|
212 |
|
|
|
213 |
|
|
/*Distance from the Extrapolated Tracks to LCT, 99999. for no LCT found*/
|
214 |
|
|
MakeBranchAllSt("CSCLCTxLc","F",CSCLCTxLc);
|
215 |
|
|
MakeBranchAllSt("CSCLCTyLc","F",CSCLCTyLc);
|
216 |
|
|
MakeBranchAllSt("CSCDrTTLCT","F",CSCDrTTLCT);
|
217 |
|
|
MakeBranchAllSt("CSCDrErrTTLCT","F",CSCDrErrTTLCT);
|
218 |
|
|
MakeBranchAllSt("CSCLCTbx","I",CSCLCTbx);
|
219 |
|
|
|
220 |
|
|
/*DetlaR between the extrapolated tracker track on muon system and the tagged muon*/
|
221 |
|
|
MakeBranchAllSt("dRTkMu","F",dRTkMu);
|
222 |
|
|
|
223 |
|
|
/*Default decision of whether a segment or LCT is found*/
|
224 |
|
|
// MakeBranchAllSt("segSt","I",segSt);
|
225 |
|
|
// MakeBranchAllSt("lctSt","I",lctSt);
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
HLTMuAcceptance=new vector<Bool_t>();
|
229 |
|
|
fractNtuple->Branch("HLTMuAcceptance", &HLTMuAcceptance);
|
230 |
|
|
fractNtuple->Branch("HLTDiMuAcceptance", &HLTDiMuAcceptance, "HLTDiMuAcceptance/F") ;
|
231 |
|
|
minDRHLTMu=new vector<Float_t>();
|
232 |
|
|
fractNtuple->Branch("minDRHLTMu", &minDRHLTMu) ;
|
233 |
|
|
fractNtuple->Branch("minDRHLTDiMu", &minDRHLTDiMu, "minDRHLTDiMu/F") ;
|
234 |
|
|
fractNtuple->Branch("minDRHLTAllSingleMu", &minDRHLTAllSingleMu, "minDRHLTAllSingleMu/F") ;
|
235 |
|
|
|
236 |
|
|
RunInfo = new TTree("RunInfo","RunInfo");
|
237 |
|
|
RunInfo->Branch("RunNumber",&run_number,"RunNum/i");
|
238 |
|
|
RunInfo->Branch("TableName",&HLTTableName);
|
239 |
|
|
HLTMuNames=new vector<string>();
|
240 |
|
|
RunInfo->Branch("HLTMuNames",&HLTMuNames);
|
241 |
|
|
HLTMuObjModuleNames=new vector<string>();
|
242 |
|
|
RunInfo->Branch("HLTMuObjModuleNames",&HLTMuObjModuleNames);
|
243 |
|
|
RunInfo->Branch("HLTDiMuName",&HLTDiMuName);
|
244 |
|
|
RunInfo->Branch("HLTDiMuObjModuleName",&HLTDiMuObjModuleName);
|
245 |
|
|
RunInfo->Branch("BadCSCChamberIndexList",&badChambersIndices);
|
246 |
|
|
fillChamberPosition();
|
247 |
|
|
}
|
248 |
|
|
|
249 |
|
|
TPTrackMuonSys::~TPTrackMuonSys(){
|
250 |
|
|
// do anything here that needs to be done at desctruction time
|
251 |
|
|
// (e.g. close files, deallocate resources etc.)
|
252 |
|
|
}
|
253 |
|
|
|
254 |
|
|
// ------------ method called to for each event ------------
|
255 |
|
|
void
|
256 |
|
|
TPTrackMuonSys::analyze(const edm::Event& event, const edm::EventSetup& setup){
|
257 |
|
|
//cout << "HERE *************************" << endl;
|
258 |
|
|
|
259 |
|
|
nEventsAnalyzed++;
|
260 |
|
|
// access conditions data for this event
|
261 |
|
|
theDbConditions.initializeEvent( setup ); //initializeEvent(const edm::EventSetup & es);// fetch the maps from the database
|
262 |
|
|
|
263 |
|
|
//////////////////////////////////////////////////////////////////////////
|
264 |
|
|
reco::BeamSpot beamSpot;
|
265 |
|
|
edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
|
266 |
|
|
Bool_t beamExists = false;
|
267 |
|
|
try{
|
268 |
|
|
event.getByLabel(m_beamSpot,recoBeamSpotHandle);
|
269 |
|
|
if ( recoBeamSpotHandle.isValid()) {
|
270 |
|
|
beamSpot = *recoBeamSpotHandle;
|
271 |
|
|
beamExists = true;
|
272 |
|
|
}
|
273 |
|
|
}catch (cms::Exception){
|
274 |
|
|
edm::LogError("")<< "Error! Can't get m_beamSpot by label. ";
|
275 |
|
|
}
|
276 |
|
|
event_number = event.id().event();
|
277 |
|
|
LumiBlock = (int)event.luminosityBlock();
|
278 |
|
|
expType = (int)event.experimentType();
|
279 |
|
|
bunchX = (int)event.bunchCrossing();
|
280 |
|
|
orbitNumb = (int)event.orbitNumber();
|
281 |
|
|
Bool_t isRData = event.isRealData(); //( L1Decision ? "passed" : "failed")
|
282 |
|
|
|
283 |
|
|
//Get the Magnetic field from the setup
|
284 |
|
|
setup.get<IdealMagneticFieldRecord>().get(theBField);
|
285 |
|
|
// Get the GlobalTrackingGeometry from the setup
|
286 |
|
|
setup.get<GlobalTrackingGeometryRecord>().get(theTrackingGeometry);
|
287 |
|
|
// Get the DT Geometry from the setup
|
288 |
|
|
setup.get<MuonGeometryRecord>().get(dtGeom);
|
289 |
|
|
|
290 |
|
|
setup.get<MuonGeometryRecord>().get(cscGeom);
|
291 |
|
|
|
292 |
|
|
// Get the propagators
|
293 |
|
|
setup.get<TrackingComponentsRecord>().get("SmartPropagatorAnyRK", propagatorAlong );
|
294 |
|
|
setup.get<TrackingComponentsRecord>().get("SmartPropagatorAnyOpposite", propagatorOpposite);
|
295 |
|
|
|
296 |
|
|
//vertices
|
297 |
|
|
edm::Handle<reco::VertexCollection> pvHandle;
|
298 |
|
|
try{
|
299 |
|
|
event.getByLabel(m_vertexSrc, pvHandle);
|
300 |
|
|
}catch (cms::Exception){
|
301 |
|
|
edm::LogError("")<< "Error! Can't get m_vertexSrc by label. ";
|
302 |
|
|
}
|
303 |
|
|
const reco::VertexCollection & vertices = *pvHandle.product();
|
304 |
|
|
numberOfPrimaryVertices =pvHandle ->size();
|
305 |
|
|
|
306 |
|
|
// Get the RecHits collection :
|
307 |
|
|
Handle<CSCRecHit2DCollection> recHits;
|
308 |
|
|
event.getByLabel("csc2DRecHits",recHits);
|
309 |
|
|
|
310 |
|
|
// get CSC segment collection
|
311 |
|
|
event.getByLabel("cscSegments", cscSegments);
|
312 |
|
|
|
313 |
|
|
setup.get<MuonGeometryRecord>().get(rpcGeo);
|
314 |
|
|
|
315 |
|
|
edm::Handle<RPCRecHitCollection> rpcRecHits;
|
316 |
|
|
event.getByLabel("rpcRecHits",rpcRecHits);
|
317 |
|
|
|
318 |
|
|
edm::Handle<DTRecSegment4DCollection> dtSegments;
|
319 |
|
|
event.getByLabel( "dt4DSegments", dtSegments );
|
320 |
|
|
|
321 |
|
|
edm::Handle<CSCCorrelatedLCTDigiCollection> mpclcts;
|
322 |
|
|
try{
|
323 |
|
|
event.getByLabel("csctfunpacker","", mpclcts);
|
324 |
|
|
}catch (cms::Exception){
|
325 |
|
|
edm::LogError("")<< "Error! Can't get m_gTracksTag by label. ";
|
326 |
|
|
}
|
327 |
|
|
|
328 |
|
|
// muon trigger scales
|
329 |
|
|
edm::ESHandle<L1MuTriggerScales> trigscales_h;
|
330 |
|
|
setup.get<L1MuTriggerScalesRcd> ().get(trigscales_h);
|
331 |
|
|
theTriggerScales = trigscales_h.product();
|
332 |
|
|
|
333 |
|
|
if (! dtSegments.isValid())
|
334 |
|
|
throw cms::Exception("FatalError") << "Unable to find DTRecSegment4DCollection in event!\n";
|
335 |
|
|
|
336 |
|
|
std::vector<DetId> chamberIds;
|
337 |
|
|
std::vector<DetId>::const_iterator chamberIdIt;
|
338 |
|
|
|
339 |
|
|
Handle<reco::TrackCollection> gTracks;
|
340 |
|
|
// Bool_t trkBool[2]; trkBool[0]= true;
|
341 |
|
|
try{
|
342 |
|
|
event.getByLabel(m_gTracksTag, gTracks);
|
343 |
|
|
}catch (cms::Exception){
|
344 |
|
|
edm::LogError("")<< "Error! Can't get m_gTracksTag by label. ";
|
345 |
|
|
// trkBool[0] = false;
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
try{
|
349 |
|
|
event.getByLabel("muons", muons);
|
350 |
|
|
}catch (cms::Exception){
|
351 |
|
|
edm::LogError("")<< "Error! Can't get muons ";
|
352 |
|
|
}
|
353 |
|
|
Handle<ValueMap<DeDxData> > dEdxTrackHandle;
|
354 |
|
|
event.getByLabel(m_dEdxDiscrimTag, dEdxTrackHandle);
|
355 |
|
|
const ValueMap<DeDxData> dEdxTrack = *dEdxTrackHandle.product();
|
356 |
|
|
|
357 |
|
|
// calo geometry
|
358 |
|
|
edm::ESHandle<CaloGeometry> calogeo;
|
359 |
|
|
setup.get<CaloGeometryRecord>().get(calogeo);
|
360 |
|
|
if (! calogeo.isValid()) throw cms::Exception("FatalError") << "Unable to find CaloGeometryRecord in event!\n";
|
361 |
|
|
|
362 |
|
|
//=======Generation and Simulation information========
|
363 |
|
|
Handle< View<Track> > trackCollectionHV;
|
364 |
|
|
event.getByLabel(m_gTracksTag,trackCollectionHV);
|
365 |
|
|
//Simulated Vertices: the vertexId() is just the index
|
366 |
|
|
Handle<SimVertexContainer> SVCollectionH;
|
367 |
|
|
HepMC::GenEvent * HepGenEvent=NULL;
|
368 |
|
|
|
369 |
|
|
//TrackingParticles
|
370 |
|
|
Handle<TrackingParticleCollection> TPCollectionH ;
|
371 |
|
|
RecoToSimCollection RecoToSimByHits;
|
372 |
|
|
ESHandle<TrackAssociatorBase> AssociatorByHits;
|
373 |
|
|
|
374 |
|
|
vector< vector< vector<Int_t> > > TracksSimChains, MuTracksSimChains;
|
375 |
|
|
|
376 |
|
|
numberOfPUVertices=0; // the number of pileup interactions that have been added to the event from this bunch crossing
|
377 |
|
|
numberOfPUVerticesMixingTruth=0;// the *true* mean number of pileup interactions for this event from which each bunch crossing has been sampled; same for all bunch crossings in an event
|
378 |
|
|
numberOfPUVerticesTot=0;
|
379 |
|
|
mcweight = 1.;
|
380 |
|
|
Handle<edm::HepMCProduct> HepMCH;
|
381 |
|
|
if (m_isMC) {
|
382 |
|
|
event.getByLabel("g4SimHits", SVCollectionH);
|
383 |
|
|
SVC = *SVCollectionH.product();
|
384 |
|
|
event.getByLabel(m_HepMCTag, HepMCH);
|
385 |
|
|
HepGenEvent=const_cast<HepMC::GenEvent *>( HepMCH->GetEvent() );
|
386 |
|
|
Handle<GenEventInfoProduct> hEvtInfo;
|
387 |
|
|
event.getByLabel("generator", hEvtInfo);
|
388 |
|
|
mcweight = hEvtInfo->weight();
|
389 |
|
|
event.getByLabel("mergedtruth",TPCollectionH);
|
390 |
|
|
//event.getByType(TPCollectionH);
|
391 |
|
|
setup.get<TrackAssociatorRecord>().get("TrackAssociatorByHits", AssociatorByHits);
|
392 |
|
|
RecoToSimByHits = AssociatorByHits->associateRecoToSim(trackCollectionHV,TPCollectionH,&event,&setup);
|
393 |
|
|
MCParticlesList.clear();
|
394 |
|
|
SavedSimTrk.clear();
|
395 |
|
|
SavedHepPar.clear();
|
396 |
|
|
/*Start of getting pileup information*/
|
397 |
|
|
edm::InputTag PileupSrc_("addPileupInfo");
|
398 |
|
|
Handle<std::vector< PileupSummaryInfo > > puInfo;
|
399 |
|
|
if ( event.getByLabel(PileupSrc_, puInfo) ) {
|
400 |
|
|
#ifdef GetPUFromEarlierThan_4_1_2
|
401 |
|
|
numberOfPUVertices = (*puInfo)[0].getPU_NumInteractions();
|
402 |
|
|
numberOfPUVerticesMixingTruth=numberOfPUVertices;
|
403 |
|
|
numberOfPUVerticesTot=numberOfPUVertices;
|
404 |
|
|
#else
|
405 |
|
|
for(std::vector<PileupSummaryInfo>::const_iterator PVI = puInfo->begin(); PVI != puInfo->end(); ++PVI) {
|
406 |
|
|
Int_t BX = PVI->getBunchCrossing();
|
407 |
|
|
if(BX == 0) {
|
408 |
|
|
numberOfPUVertices = PVI->getPU_NumInteractions();
|
409 |
|
|
#ifdef GetPUFromEarlierThan_4_4_0
|
410 |
|
|
numberOfPUVerticesMixingTruth = -1.;//not available
|
411 |
|
|
#else
|
412 |
|
|
numberOfPUVerticesMixingTruth = PVI->getTrueNumInteractions();
|
413 |
|
|
#endif
|
414 |
|
|
}
|
415 |
|
|
numberOfPUVerticesTot+=numberOfPUVertices;
|
416 |
|
|
}
|
417 |
|
|
#endif
|
418 |
|
|
}//====== End of getting pileup information =============
|
419 |
|
|
}//======= End of if m_isMC========
|
420 |
|
|
|
421 |
|
|
//////////////////////////////////////////////
|
422 |
|
|
edm::ESHandle<L1GtTriggerMenu> menuRcd;
|
423 |
|
|
setup.get<L1GtTriggerMenuRcd>().get(menuRcd) ;
|
424 |
|
|
const L1GtTriggerMenu* menu = menuRcd.product();
|
425 |
|
|
Handle<L1GlobalTriggerReadoutRecord> gtBeforeMaskRecord;
|
426 |
|
|
event.getByLabel("gtDigis", gtBeforeMaskRecord);
|
427 |
|
|
trgSingle = false;
|
428 |
|
|
if (!gtBeforeMaskRecord.isValid()) {
|
429 |
|
|
LogInfo("PhysicsTrees: ") << " Error: no L1GlobalTriggerReadoutRecord found with input tag --> gtDigis" ;
|
430 |
|
|
} else {
|
431 |
|
|
const TechnicalTriggerWord techDecisionWord = gtBeforeMaskRecord->technicalTriggerWord(0);
|
432 |
|
|
const DecisionWord gtDecisionWordBeforeMask = gtBeforeMaskRecord->decisionWord(0);
|
433 |
|
|
#ifdef m_debug
|
434 |
|
|
Int_t nl1s = 0;
|
435 |
|
|
#endif
|
436 |
|
|
for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo) {
|
437 |
|
|
#ifdef m_debug
|
438 |
|
|
if (nEventsAnalyzed <= 1) {
|
439 |
|
|
cout <<" L1Menu Item m1 = " << nl1s
|
440 |
|
|
<<" corresponds to AlgoName = "
|
441 |
|
|
<< (algo->second).algoName() << " Alias: " << (algo->second).algoAlias()
|
442 |
|
|
<< " and the result= " << menu->gtAlgorithmResult((algo->second).algoAlias(), gtDecisionWordBeforeMask)
|
443 |
|
|
<< endl;
|
444 |
|
|
}
|
445 |
|
|
nl1s = nl1s + 1;
|
446 |
|
|
#endif
|
447 |
|
|
if((algo->second).algoName() == "L1_SingleMuOpen") trgSingle = true;
|
448 |
|
|
if((algo->second).algoName() == "L1_SingleMu5") trgSingle=false;
|
449 |
|
|
}
|
450 |
|
|
}
|
451 |
|
|
|
452 |
|
|
/*-----------Start getting HLT results------------*/
|
453 |
|
|
Handle<TriggerResults> triggerResults;
|
454 |
|
|
Handle< trigger::TriggerEvent > handleTriggerEvent;
|
455 |
|
|
HLTDiMuAcceptance=false;
|
456 |
|
|
HLTMuAcceptance->clear();
|
457 |
|
|
try {
|
458 |
|
|
event.getByLabel(m_hlt, triggerResults);
|
459 |
|
|
if ( triggerResults.product()->wasrun() ){
|
460 |
|
|
LogInfo("")<<" At least one path out of " << triggerResults.product()->size() << " ran? " << triggerResults.product()->wasrun() << endl;
|
461 |
|
|
if ( triggerResults.product()->accept() ) {
|
462 |
|
|
for (vector<Int_t>::const_iterator iter=m_HLTMuTrgBit.begin();iter<m_HLTMuTrgBit.end();iter++)
|
463 |
|
|
HLTMuAcceptance->push_back( triggerResults.product()->accept(*iter) );
|
464 |
|
|
if ( m_HLTDiMuTrgBit>-1 ) HLTDiMuAcceptance=triggerResults.product()->accept( m_HLTDiMuTrgBit );
|
465 |
|
|
} // end if at least one triggerResult accepted
|
466 |
|
|
}// end if wasRun
|
467 |
|
|
} catch (...) {// some old codes, it is possibly not going to happen in >CMSSW_4_4_X versions
|
468 |
|
|
LogWarning("")<<"Not found HLT result, is HLT process name correct?"<< endl;
|
469 |
|
|
if(isRData == 0){
|
470 |
|
|
if(event.getByLabel( m_hltTrgEv, handleTriggerEvent )){
|
471 |
|
|
const trigger::TriggerObjectCollection & toc(handleTriggerEvent->getObjects());
|
472 |
|
|
for ( size_t ia = 0; ia < handleTriggerEvent->sizeFilters(); ++ ia) {
|
473 |
|
|
std::string fullname = handleTriggerEvent->filterTag(ia).encode();
|
474 |
|
|
std::string name;
|
475 |
|
|
size_t p = fullname.find_first_of(':');
|
476 |
|
|
if ( p != std::string::npos) name = fullname.substr(0, p);
|
477 |
|
|
else name = fullname;
|
478 |
|
|
if ( &toc !=0 ) {
|
479 |
|
|
HLTMuAcceptance->assign(m_HLTMuTrgBit.size(),false);
|
480 |
|
|
for (vector<string>::const_iterator iter=HLTMuObjModuleNames->begin(); iter<HLTMuObjModuleNames->end();iter++ )
|
481 |
|
|
if ( name == *iter ) HLTMuAcceptance->at( iter-HLTMuObjModuleNames->begin() )=true;
|
482 |
|
|
if ( name == *HLTDiMuObjModuleName ) HLTDiMuAcceptance=true;
|
483 |
|
|
}
|
484 |
|
|
}
|
485 |
|
|
}
|
486 |
|
|
}
|
487 |
|
|
}
|
488 |
|
|
Bool_t m_GotTrgObj=event.getByLabel( m_hltTrgEv, handleTriggerEvent );
|
489 |
|
|
/*-----------End getting HLT results------------*/
|
490 |
|
|
|
491 |
|
|
if(!gTracks.isValid() ) return;
|
492 |
|
|
if(!muons.isValid() ) return;
|
493 |
|
|
if (gTracks->size() > MAXNTRACKS) return;
|
494 |
|
|
|
495 |
|
|
#ifdef m_debug
|
496 |
|
|
cout << "Run: " << run_number << " Event: " << event_number << " LumiBlock: " << LumiBlock << " BX: " << bunchX
|
497 |
|
|
<< " isRealDAT: " << isRData
|
498 |
|
|
<< endl;
|
499 |
|
|
#endif
|
500 |
|
|
|
501 |
|
|
Int_t trackNumber[2][4][4][36];
|
502 |
|
|
Bool_t trkVeto[MAXNTRACKS];
|
503 |
|
|
|
504 |
|
|
for(Int_t i1 = 0; i1 < 2; i1++)
|
505 |
|
|
for(Int_t i2 = 0; i2 < 4; i2++)
|
506 |
|
|
for(Int_t i3 = 0; i3 < 4; i3++)
|
507 |
|
|
for(Int_t i4 = 0; i4 < 36; i4++)
|
508 |
|
|
trackNumber[i1][i2][i3][i4] = -1;
|
509 |
|
|
|
510 |
|
|
for(Int_t i1 = 0; i1 < MAXNTRACKS; i1++)
|
511 |
|
|
trkVeto[i1] = false;
|
512 |
|
|
|
513 |
|
|
nPosTrk = 0;
|
514 |
|
|
nNegTrk = 0;
|
515 |
|
|
nTotalTrks = gTracks->size();
|
516 |
|
|
for(reco::TrackCollection::const_iterator itTrack = gTracks->begin(); itTrack != gTracks->end(); itTrack++){//start loop tracks
|
517 |
|
|
UInt_t itrk=itTrack - gTracks->begin();
|
518 |
|
|
if(itTrack->charge() == 0) continue;
|
519 |
|
|
if(itTrack->p() < 3.0) continue;
|
520 |
|
|
|
521 |
|
|
reco::TrackRef trackRef(gTracks, itrk );
|
522 |
|
|
tracks_eta = itTrack->eta(); tracks_phi = itTrack->phi();
|
523 |
|
|
if(tracks_phi < 0 )tracks_phi = tracks_phi + 2*M_PI;
|
524 |
|
|
tracks_chi2 = 9999.;
|
525 |
|
|
if(itTrack->ndof() != 0)tracks_chi2 = itTrack->chi2()/itTrack->ndof();
|
526 |
|
|
tracks_dxy = itTrack->dxy(); tracks_dz = itTrack->dz();
|
527 |
|
|
if(beamExists){
|
528 |
|
|
tracks_dxy = itTrack->dxy(beamSpot.position());
|
529 |
|
|
tracks_dz = itTrack->dz(beamSpot.position());
|
530 |
|
|
}
|
531 |
|
|
|
532 |
|
|
tracks_numberOfValidHits = itTrack->numberOfValidHits();
|
533 |
|
|
if ( ! (tracks_numberOfValidHits>7 && fabs(tracks_dz)<24 && fabs(tracks_dxy)< 2.0 && tracks_chi2>0 && tracks_chi2<4) ) continue;
|
534 |
|
|
Bool_t ec= ( tracks_eta > 0 );
|
535 |
|
|
// if(fabs(tracks_eta) < 1.2 ) trackDT = true;
|
536 |
|
|
Bool_t GotCSCSegMatched = false;
|
537 |
|
|
if(fabs(tracks_eta) > 0.9 )//if it is a CSCTrack
|
538 |
|
|
for(UInt_t j =0; j < 6; j++){//start of matched segments check
|
539 |
|
|
/* not necessary codes, it will give the same result
|
540 |
|
|
Float_t zzPlaneME = 0.0;
|
541 |
|
|
if(trackCSC && MEZ[j] != 0){
|
542 |
|
|
zzPlaneME = MEZ[j];
|
543 |
|
|
if (!ec) zzPlaneME = -MEZ[j];
|
544 |
|
|
TrajectoryStateOnSurface tsos = surfExtrapTrkSam(trackRef, zzPlaneME);
|
545 |
|
|
if (!tsos.isValid()) continue;
|
546 |
|
|
Float_t trkEta = tsos.globalPosition().eta(), trkPhi = tsos.globalPosition().phi();
|
547 |
|
|
Int_t rg = ringCandidate(j>2?j-1:1, trkEta, trkPhi);
|
548 |
|
|
if (rg==0) continue;
|
549 |
|
|
if( thisChamberCandidate(st, rg, trkPhi) %2 == 0 ){
|
550 |
|
|
zzPlaneME = MEZEven[j];
|
551 |
|
|
if(!ec)zzPlaneME = -MEZEven[j];
|
552 |
|
|
tsos = surfExtrapTrkSam(trackRef, zzPlaneME);
|
553 |
|
|
}else{
|
554 |
|
|
zzPlaneME = MEZOdd[j];
|
555 |
|
|
if(!ec)zzPlaneME = -MEZOdd[j];
|
556 |
|
|
tsos = surfExtrapTrkSam(trackRef, zzPlaneME);
|
557 |
|
|
}
|
558 |
|
|
if (!tsos.isValid())continue;*/
|
559 |
|
|
CSCSegmentCollection::const_iterator cscSegOut;
|
560 |
|
|
if( !matchTTwithCSCSeg(ec, j, trackRef, cscSegments, cscSegOut) ) continue;
|
561 |
|
|
GotCSCSegMatched=true;
|
562 |
|
|
CSCDetId id = (CSCDetId) cscSegOut->cscDetId();
|
563 |
|
|
Byte_t endcapCSC = id.endcap() - 1,ringCSC = id.ring() - 1,stationCSC = id.station() - 1,chamberCSC = id.chamber() - 1;
|
564 |
|
|
if ( trackNumber[endcapCSC][stationCSC][ringCSC][chamberCSC] < 0 )
|
565 |
|
|
trackNumber[endcapCSC][stationCSC][ringCSC][chamberCSC] = itrk;
|
566 |
|
|
else {
|
567 |
|
|
trkVeto[ trackNumber[endcapCSC][stationCSC][ringCSC][chamberCSC] ]=true;
|
568 |
|
|
trkVeto[ itrk ]=true;
|
569 |
|
|
}
|
570 |
|
|
}//end of matched segments check
|
571 |
|
|
|
572 |
|
|
if (GotCSCSegMatched) {
|
573 |
|
|
if(ec){
|
574 |
|
|
nPosTrk ++;
|
575 |
|
|
}else{
|
576 |
|
|
nNegTrk ++;
|
577 |
|
|
}
|
578 |
|
|
}
|
579 |
|
|
}//end of first track loop
|
580 |
|
|
|
581 |
|
|
for (reco::MuonCollection::const_iterator muIter1 = muons->begin(); muIter1 != muons->end(); ++muIter1) {
|
582 |
|
|
if (!muIter1->isTrackerMuon() ) continue;
|
583 |
|
|
if(!muIter1->track().isNonnull()) continue;
|
584 |
|
|
MuTagPt = muIter1->track()->pt() ;
|
585 |
|
|
if (MuTagPt < 5.) continue;
|
586 |
|
|
|
587 |
|
|
Float_t mu1dxy = 1000., mu1dz = 1000.;
|
588 |
|
|
|
589 |
|
|
if(beamExists){
|
590 |
|
|
mu1dxy = muIter1->track()->dxy(beamSpot.position());
|
591 |
|
|
mu1dz = muIter1->track()->dz(beamSpot.position());
|
592 |
|
|
}else{
|
593 |
|
|
mu1dxy = muIter1->track()->dxy();
|
594 |
|
|
mu1dz = muIter1->track()->dz();
|
595 |
|
|
}
|
596 |
|
|
Float_t mu1Chi2 = muIter1->track()->normalizedChi2();
|
597 |
|
|
MuTagHitsTrkSys = muIter1->track()->hitPattern().numberOfValidTrackerHits();
|
598 |
|
|
Bool_t goodTrack = (fabs(mu1dxy) < 2.0 && fabs(mu1dz) < 24.0 && fabs(mu1Chi2) < 4.0 && MuTagHitsTrkSys > 7 ); //&& MuTagHitsMuSys > 3
|
599 |
|
|
if(!goodTrack)continue;
|
600 |
|
|
|
601 |
|
|
MuTagnSegTrkArb = muIter1->numberOfMatches(); // get number of chambers with matched segments
|
602 |
|
|
if (MuTagnSegTrkArb < 2) continue;
|
603 |
|
|
|
604 |
|
|
MuTagPx = muIter1->track()->px() ;
|
605 |
|
|
MuTagPy = muIter1->track()->py() ;
|
606 |
|
|
MuTagPz = muIter1->track()->pz() ;
|
607 |
|
|
|
608 |
|
|
MuTagE = muIter1->track()->p() ;
|
609 |
|
|
MuTagEta = muIter1->track()->eta() ;
|
610 |
|
|
MuTagPhi = muIter1->track()->phi() ;
|
611 |
|
|
|
612 |
|
|
MuTagcharge = muIter1->track()->charge() ;
|
613 |
|
|
|
614 |
|
|
MuTagHitsPixSys = muIter1->track()->hitPattern().numberOfValidPixelHits();
|
615 |
|
|
MuTagHitsRPCSys = muIter1->track()->hitPattern().numberOfValidMuonRPCHits();
|
616 |
|
|
|
617 |
|
|
/// check for HLT matching
|
618 |
|
|
minDRHLTDiMu=100.; minDRHLTAllSingleMu=100.;
|
619 |
|
|
minDRHLTMu->assign(HLTMuObjModuleNames->size(),100.);
|
620 |
|
|
Float_t PhiTemp1 = MuTagPhi<0?MuTagPhi + 2*M_PI:MuTagPhi;
|
621 |
|
|
if ( m_GotTrgObj ){
|
622 |
|
|
const trigger::TriggerObjectCollection & toc(handleTriggerEvent->getObjects());
|
623 |
|
|
for ( size_t ia = 0; ia < handleTriggerEvent->sizeFilters(); ++ ia) {
|
624 |
|
|
std::string fullname = handleTriggerEvent->filterTag(ia).encode();
|
625 |
|
|
std::string name;
|
626 |
|
|
size_t p = fullname.find_first_of(':');
|
627 |
|
|
if ( p != std::string::npos) name = fullname.substr(0, p);
|
628 |
|
|
else name = fullname;
|
629 |
|
|
if ( &toc ==0) continue;
|
630 |
|
|
const trigger::Keys & k = handleTriggerEvent->filterKeys(ia);
|
631 |
|
|
for (trigger::Keys::const_iterator ki = k.begin(); ki !=k.end(); ++ki ) {
|
632 |
|
|
double l3phi = toc[*ki].phi();
|
633 |
|
|
double l3eta = toc[*ki].eta();
|
634 |
|
|
|
635 |
|
|
if(l3phi < 0 )l3phi = l3phi + 2*M_PI;
|
636 |
|
|
|
637 |
|
|
Float_t deltaR_TTHLT = sqrt((l3eta - MuTagEta) * (l3eta - MuTagEta) + (l3phi - PhiTemp1) *(l3phi - PhiTemp1));
|
638 |
|
|
if ( deltaR_TTHLT > 0.4 ) continue;
|
639 |
|
|
if ( name == *HLTDiMuObjModuleName ) {
|
640 |
|
|
if ( deltaR_TTHLT < minDRHLTDiMu ){
|
641 |
|
|
minDRHLTDiMu = deltaR_TTHLT;
|
642 |
|
|
}
|
643 |
|
|
}
|
644 |
|
|
Byte_t idx=0;
|
645 |
|
|
for (vector<string>::const_iterator iter=HLTMuObjModuleNames->begin(); iter<HLTMuObjModuleNames->end();iter++,idx++ )
|
646 |
|
|
if ( name == *iter ) {
|
647 |
|
|
if ( deltaR_TTHLT < minDRHLTMu->at(idx) ){
|
648 |
|
|
minDRHLTMu->at(idx) = deltaR_TTHLT;
|
649 |
|
|
}
|
650 |
|
|
if ( deltaR_TTHLT < minDRHLTAllSingleMu ){
|
651 |
|
|
minDRHLTAllSingleMu = deltaR_TTHLT;
|
652 |
|
|
}
|
653 |
|
|
break;
|
654 |
|
|
}
|
655 |
|
|
}//end of loop ki
|
656 |
|
|
}//end of loop ia
|
657 |
|
|
}//end of if m_GotTrgObj
|
658 |
|
|
|
659 |
|
|
MuTagCaloL= muon::isGoodMuon(*muIter1,muon::TM2DCompatibilityLoose);
|
660 |
|
|
MuTagCaloT= muon::isGoodMuon(*muIter1,muon::TM2DCompatibilityTight);
|
661 |
|
|
|
662 |
|
|
/*------------------------Start getting the Monte Carlo Truth--------------------------*/
|
663 |
|
|
MuTagtracktruth_pt = -9999.;
|
664 |
|
|
MuTagtracktruth_p = -9999.;
|
665 |
|
|
MuTagtracktruth_id = -9999.;
|
666 |
|
|
MuTagtracktruth_type = 0;
|
667 |
|
|
MuTagtracktruth_isPileup=false;
|
668 |
|
|
MuTagtracktruth_thesamewith=-1;
|
669 |
|
|
if ( m_isMC) {
|
670 |
|
|
//TrackingParticles
|
671 |
|
|
MuTracksSimChains.push_back(* new vector< vector<Int_t> >() );
|
672 |
|
|
if ( TPCollectionH.isValid() ) {
|
673 |
|
|
//SimToReco Tracks Association
|
674 |
|
|
reco::TrackBaseRef trackBaseRef(muIter1->track());
|
675 |
|
|
if ( RecoToSimByHits.find(trackBaseRef) != RecoToSimByHits.end() ) {
|
676 |
|
|
pair<TrackingParticleRef, double> BestMatch=RecoToSimByHits[trackBaseRef].front();
|
677 |
|
|
//vector<pair<TrackingParticleRef, double> > TPCByChi2=RecoToSimByChi2[trk];
|
678 |
|
|
TrackingParticleRef tpr = BestMatch.first;
|
679 |
|
|
//Simulated Tracks
|
680 |
|
|
MuTagtracktruth_pt=tpr->pt();
|
681 |
|
|
MuTagtracktruth_p=tpr->p();
|
682 |
|
|
MuTagtracktruth_id=tpr->pdgId();
|
683 |
|
|
MuTagtracktruth_isPileup=GetDecayChains(tpr,HepGenEvent,MuTagtracktruth_type,MuTagtracktruth_thesamewith, MuTracksSimChains);
|
684 |
|
|
}
|
685 |
|
|
}//end of TPCollection.isValid
|
686 |
|
|
}//end of m_isMC
|
687 |
|
|
/*------------------------End of getting the Monte Carlo Truth--------------------------*/
|
688 |
|
|
|
689 |
|
|
CLHEP::Hep3Vector Mu1Vector(MuTagPx, MuTagPy, MuTagPz);
|
690 |
|
|
|
691 |
|
|
Float_t etaMuVec[4] ={-9999., -9999., -9999., -9999.};
|
692 |
|
|
Float_t phiMuVec[4] ={-9999., -9999., -9999., -9999.};
|
693 |
|
|
|
694 |
|
|
Float_t allCSC_mu = MEZ[0];
|
695 |
|
|
if(fabs(MuTagEta) < 1.5)allCSC_mu = MEZ[1];
|
696 |
|
|
if(MuTagEta < 0) allCSC_mu = -allCSC_mu;
|
697 |
|
|
|
698 |
|
|
reco::TrackRef trackMuRef = muIter1->track();
|
699 |
|
|
TrajectoryStateOnSurface tsos = surfExtrapTrkSam(trackMuRef, allCSC_mu);
|
700 |
|
|
if(tsos.isValid()){
|
701 |
|
|
etaMuVec[0] = tsos.globalPosition().eta();
|
702 |
|
|
phiMuVec[0] = tsos.globalPosition().phi();
|
703 |
|
|
}
|
704 |
|
|
allCSC_mu = MEZ[3];
|
705 |
|
|
if(MuTagEta < 0) allCSC_mu = -allCSC_mu;
|
706 |
|
|
tsos = surfExtrapTrkSam(trackMuRef, allCSC_mu);
|
707 |
|
|
if(tsos.isValid()){
|
708 |
|
|
etaMuVec[1] = tsos.globalPosition().eta();
|
709 |
|
|
phiMuVec[1] = tsos.globalPosition().phi();
|
710 |
|
|
}
|
711 |
|
|
|
712 |
|
|
allCSC_mu = MEZ[4];
|
713 |
|
|
if(MuTagEta < 0) allCSC_mu = -allCSC_mu;
|
714 |
|
|
tsos = surfExtrapTrkSam(trackMuRef, allCSC_mu);
|
715 |
|
|
if(tsos.isValid()){
|
716 |
|
|
etaMuVec[2] = tsos.globalPosition().eta();
|
717 |
|
|
phiMuVec[2] = tsos.globalPosition().phi();
|
718 |
|
|
}
|
719 |
|
|
|
720 |
|
|
allCSC_mu = MEZ[5];
|
721 |
|
|
if(MuTagEta < 0) allCSC_mu = -allCSC_mu;
|
722 |
|
|
tsos = surfExtrapTrkSam(trackMuRef, allCSC_mu);
|
723 |
|
|
if(tsos.isValid()){
|
724 |
|
|
etaMuVec[3] = tsos.globalPosition().eta();
|
725 |
|
|
phiMuVec[3] = tsos.globalPosition().phi();
|
726 |
|
|
}
|
727 |
|
|
|
728 |
|
|
Bool_t firsttrackmatchingtoMuTag=true;
|
729 |
|
|
|
730 |
|
|
for(reco::TrackCollection::const_iterator itTrack = gTracks->begin(); itTrack != gTracks->end(); itTrack++){
|
731 |
|
|
UInt_t itrk = itTrack - gTracks->begin();
|
732 |
|
|
if(itTrack->charge() == 0) continue;
|
733 |
|
|
if(itTrack->p() < 3.0) continue;
|
734 |
|
|
trackVeto = trkVeto[itrk];
|
735 |
|
|
reco::TrackRef trackRef(gTracks, itrk );
|
736 |
|
|
|
737 |
|
|
if(itTrack->charge()*MuTagcharge != -1) continue;
|
738 |
|
|
|
739 |
|
|
tracks_eta = itTrack->eta();
|
740 |
|
|
|
741 |
|
|
if(fabs(tracks_eta) > 0.9 ) {
|
742 |
|
|
if(fabs(tracks_eta) < 1.2 ) myRegion = 2;
|
743 |
|
|
else myRegion = 3;
|
744 |
|
|
}
|
745 |
|
|
else myRegion = 1;
|
746 |
|
|
if (myRegion == 1) continue;//currently, only CSC
|
747 |
|
|
|
748 |
|
|
tracks_phi = itTrack->phi();
|
749 |
|
|
if(tracks_phi < 0 )tracks_phi = tracks_phi + 2*M_PI;
|
750 |
|
|
|
751 |
|
|
tracks_chi2 = -9999.;
|
752 |
|
|
if(itTrack->ndof() != 0)tracks_chi2 = itTrack->chi2()/itTrack->ndof();
|
753 |
|
|
tracks_charge = itTrack->charge();
|
754 |
|
|
|
755 |
|
|
tracks_dxy = itTrack->dxy(); tracks_dz = itTrack->dz();
|
756 |
|
|
if(beamExists){
|
757 |
|
|
tracks_dxy = itTrack->dxy(beamSpot.position()); tracks_dz = itTrack->dz(beamSpot.position());
|
758 |
|
|
}
|
759 |
|
|
|
760 |
|
|
MuProbenHitsTrkSys = itTrack->hitPattern().numberOfValidTrackerHits();
|
761 |
|
|
MuProbenHitsPixSys = itTrack->hitPattern().numberOfValidPixelHits();
|
762 |
|
|
|
763 |
|
|
goodTrack = ( fabs(itTrack->eta())< 2.4 && fabs(tracks_dz)< 24.0 &&
|
764 |
|
|
fabs(tracks_dxy)< 2.0 && tracks_chi2> 0.0 && tracks_chi2< 4.0 && MuProbenHitsTrkSys > 7 );
|
765 |
|
|
|
766 |
|
|
if (!goodTrack) continue;
|
767 |
|
|
if(tracks_eta > 0) CSCEndCapPlus = true;
|
768 |
|
|
else CSCEndCapPlus = false;
|
769 |
|
|
|
770 |
|
|
tracks_pt = itTrack->pt();
|
771 |
|
|
tracks_e = itTrack->p();
|
772 |
|
|
tracks_vx = itTrack->vx(); // x coordinate of the reference point on track
|
773 |
|
|
tracks_vy = itTrack->vy(); // y coordinate of the reference point on track
|
774 |
|
|
tracks_vz = itTrack->vz(); // z coordinate of the reference point on track
|
775 |
|
|
tracks_qoverp = itTrack->qoverp(); // q/p
|
776 |
|
|
tracks_lambda = itTrack->lambda();
|
777 |
|
|
tracks_recHitsSize= itTrack->recHitsSize();
|
778 |
|
|
tracks_qoverpError = itTrack->qoverpError();//TrackAlgorithm tAlg = itTrack->algo();
|
779 |
|
|
tracks_ptError = itTrack->ptError();/// error on Pt (set to 1000 TeV if charge==0 for safety)
|
780 |
|
|
tracks_thetaError = itTrack->thetaError();/// error on theta
|
781 |
|
|
tracks_lambdaError = itTrack->lambdaError(); /// error on lambda
|
782 |
|
|
tracks_etaError = itTrack->etaError(); tracks_phiError = itTrack->phiError(); tracks_dxyError = itTrack->dxyError();/// error on dxy
|
783 |
|
|
tracks_d0Error = itTrack->d0Error(); tracks_dszError = itTrack->dszError();tracks_dzError = itTrack->dzError();/// error on dz
|
784 |
|
|
tracks_numberOfValidHits = itTrack->numberOfValidHits(); ///unsigned short number of valid hits found
|
785 |
|
|
tracks_numberOfLostHits = itTrack->numberOfLostHits(); ///unsigned short number of cases where track crossed a layer without getting a hit.
|
786 |
|
|
if(tracks_phi < 0)tracks_phi = tracks_phi + 2*M_PI;
|
787 |
|
|
reco::MuonCollection::const_iterator matchedMu=matchTTwithMT(itTrack);
|
788 |
|
|
if ( matchedMu!=muons->end() ) {
|
789 |
|
|
tracks_isCaloMuTrk=matchedMu->isCaloMuon();
|
790 |
|
|
tracks_isTrackerMuTrk=matchedMu->isTrackerMuon();
|
791 |
|
|
}
|
792 |
|
|
else {
|
793 |
|
|
tracks_isCaloMuTrk=false;
|
794 |
|
|
tracks_isTrackerMuTrk=false;
|
795 |
|
|
}
|
796 |
|
|
|
797 |
|
|
Bool_t trQuality = (fabs(MuTagEta) < 2.4 && fabs(tracks_eta) > 0.9 && fabs(tracks_eta) < 2.4
|
798 |
|
|
&& tracks_etaError < 0.003 && tracks_phiError < 0.003
|
799 |
|
|
&& tracks_ptError/tracks_pt < 0.05 && tracks_numberOfValidHits >= 10); // cuts removed from the SkimDPG.C file and put here...
|
800 |
|
|
|
801 |
|
|
if(!trQuality)continue;
|
802 |
|
|
|
803 |
|
|
Float_t mMu = 0.1134289256;
|
804 |
|
|
invMass = pow( ( sqrt(pow(itTrack->p(),2)+ mMu*mMu) + sqrt(pow(muIter1->track()->p(),2)+ mMu*mMu) ) ,2 ) -
|
805 |
|
|
(
|
806 |
|
|
pow((itTrack->px() + muIter1->track()->px()),2) +
|
807 |
|
|
pow((itTrack->py() + muIter1->track()->py()),2) +
|
808 |
|
|
pow((itTrack->pz() + muIter1->track()->pz()),2)
|
809 |
|
|
);
|
810 |
|
|
|
811 |
|
|
if(invMass < 0) continue;
|
812 |
|
|
invMass = sqrt(invMass);
|
813 |
|
|
Bool_t gotMass = ((invMass > 2.5 && invMass < 3.6) || (invMass > 75.)) ;
|
814 |
|
|
if(!gotMass)continue;
|
815 |
|
|
|
816 |
|
|
/*------------------------Start getting the Monte Carlo Truth--------------------------*/
|
817 |
|
|
tracktruth_pt = -9999.;
|
818 |
|
|
tracktruth_e = -9999.;
|
819 |
|
|
tracktruth_p = -9999.;
|
820 |
|
|
tracktruth_id = -9999.;
|
821 |
|
|
tracktruth_type = 0;
|
822 |
|
|
tracktruth_isPileup=false;
|
823 |
|
|
tracktruth_thesamewith=-1;
|
824 |
|
|
|
825 |
|
|
if ( m_isMC) {
|
826 |
|
|
//TrackingParticles
|
827 |
|
|
if ( TPCollectionH.isValid() ) {
|
828 |
|
|
#ifdef jz_debug
|
829 |
|
|
// cout<<"track "<<i<<" has "<<tracks_numberOfValidHits << " hits" <<endl;
|
830 |
|
|
#endif
|
831 |
|
|
if (!firsttrackmatchingtoMuTag) MuTracksSimChains.push_back( MuTracksSimChains.back() );
|
832 |
|
|
TracksSimChains.push_back(* new vector< vector<Int_t> >() );
|
833 |
|
|
//SimToReco Tracks Association
|
834 |
|
|
reco::TrackBaseRef trackBaseRef(trackRef);
|
835 |
|
|
if ( RecoToSimByHits.find(trackBaseRef) != RecoToSimByHits.end() ) {
|
836 |
|
|
pair<TrackingParticleRef, double> BestMatch=RecoToSimByHits[trackBaseRef].front();
|
837 |
|
|
//vector<pair<TrackingParticleRef, double> > TPCByChi2=RecoToSimByChi2[trk];
|
838 |
|
|
TrackingParticleRef tpr = BestMatch.first;
|
839 |
|
|
//Simulated Tracks
|
840 |
|
|
tracktruth_pt=tpr->pt();
|
841 |
|
|
tracktruth_e=tpr->energy();
|
842 |
|
|
tracktruth_p=tpr->p();
|
843 |
|
|
tracktruth_id=tpr->pdgId();
|
844 |
|
|
tracktruth_isPileup=GetDecayChains(tpr,HepGenEvent,tracktruth_type,tracktruth_thesamewith,TracksSimChains);
|
845 |
|
|
}
|
846 |
|
|
}//end of TPCollection.isValid
|
847 |
|
|
}//end of m_isMC
|
848 |
|
|
/*------------------------End of getting the Monte Carlo Truth--------------------------*/
|
849 |
|
|
|
850 |
|
|
CLHEP::Hep3Vector trackVector(itTrack->px(), itTrack->py(), itTrack->pz());
|
851 |
|
|
//////////// Check if they have the same good vertex...
|
852 |
|
|
|
853 |
|
|
Bool_t gotVertexTrk1 = false, gotVertexTrk2 = false;
|
854 |
|
|
|
855 |
|
|
iSameVtx = false;
|
856 |
|
|
vtx_r = -9999.; vtx_z = -9999.;
|
857 |
|
|
vtx_rError = -9999.; vtx_zError = -9999.;
|
858 |
|
|
vtx_normChi2 = 100000.; vtx_size = -1;
|
859 |
|
|
|
860 |
|
|
for(reco::VertexCollection::const_iterator it=vertices.begin() ; it!=vertices.end() ; ++it) {
|
861 |
|
|
if(!it->isValid())continue;
|
862 |
|
|
if(it->isFake())continue;
|
863 |
|
|
for(std::vector<TrackBaseRef>::const_iterator itr=it->tracks_begin() ; itr!=it->tracks_end() ; ++itr) {
|
864 |
|
|
if ( & (*muIter1->track().get() ) == &( * const_cast<reco::Track *>(itr->get()) ) ) {
|
865 |
|
|
// cerr<<"Got MuTag trk matched"<<endl;
|
866 |
|
|
gotVertexTrk1 = true;
|
867 |
|
|
if (gotVertexTrk2) break;
|
868 |
|
|
}
|
869 |
|
|
if ( & (* itTrack) == & ( * (itr->get()) ) ) {
|
870 |
|
|
// cerr<<"Got TT trk matched"<<endl;
|
871 |
|
|
gotVertexTrk2 = true;
|
872 |
|
|
if (gotVertexTrk1) break;
|
873 |
|
|
}
|
874 |
|
|
}// tracks within vertex
|
875 |
|
|
|
876 |
|
|
if(gotVertexTrk1 && gotVertexTrk2){
|
877 |
|
|
vtx_size = it->tracksSize();
|
878 |
|
|
vtx_r = sqrt(pow(it->x(),2)+ pow(it->y(),2)); vtx_z = it->z();
|
879 |
|
|
if(it->x() != 0 && it->y() != 0) vtx_rError = vtx_r*sqrt(pow((it->xError()/it->x()),2) + pow((it->yError()/it->y()),2));
|
880 |
|
|
if(it->x() != 0 && it->y() == 0) vtx_rError = it->xError();
|
881 |
|
|
if(it->x() == 0 && it->y() != 0) vtx_rError = it->yError();
|
882 |
|
|
vtx_zError = it->zError();
|
883 |
|
|
if(it->ndof() != 0) vtx_normChi2 = it->chi2()/it->ndof();
|
884 |
|
|
iSameVtx = true;
|
885 |
|
|
}
|
886 |
|
|
}// for loop over vertices..
|
887 |
|
|
|
888 |
|
|
/////////// finished checking the vertex..
|
889 |
|
|
|
890 |
|
|
nTrkCountCSCSeg=0;
|
891 |
|
|
for(Byte_t j =0; j < 4; j++){
|
892 |
|
|
/*CSC Chamber Candidates in each station*/
|
893 |
|
|
CSCRg[j]=-9999;
|
894 |
|
|
CSCChCand[j]=-9999;
|
895 |
|
|
CSCChBad[j] = false;
|
896 |
|
|
/*Extrapolated Tracks on CSC Chamber Candidates in each station*/
|
897 |
|
|
CSCxProjLc[j]=-9999.;
|
898 |
|
|
CSCyProjLc[j]=-9999.;
|
899 |
|
|
CSCxErrProjLc[j]=-9999.;
|
900 |
|
|
CSCyErrProjLc[j]=-9999.;
|
901 |
|
|
CSCDyProjHVGap[j]=-9999.;
|
902 |
|
|
CSCProjEdgeDist[j]=-9999.;
|
903 |
|
|
CSCProjEdgeDistErr[j]=-9999.;
|
904 |
|
|
/*Segments characteristics*/
|
905 |
|
|
CSCSegxLc[j]=-9999.;
|
906 |
|
|
CSCSegyLc[j]=-9999.;
|
907 |
|
|
CSCSegxErrLc[j]=-9999.;
|
908 |
|
|
CSCSegyErrLc[j]=-9999.;
|
909 |
|
|
CSCSegChisqProb[j]=-9999.;
|
910 |
|
|
CSCnSegHits[j]=-9999;
|
911 |
|
|
/*Distance from the Extrapolated Tracks to CSC Segments, 9999. for no CSC segment found*/
|
912 |
|
|
CSCDxyTTSeg[j]=-9999.;
|
913 |
|
|
CSCDxTTSeg[j]=-9999.;
|
914 |
|
|
CSCDyTTSeg[j]=-9999.;
|
915 |
|
|
CSCDxyErrTTSeg[j]=-9999.;
|
916 |
|
|
CSCdXdZTTSeg[j]=-9999.;
|
917 |
|
|
CSCdYdZTTSeg[j]=-9999.;
|
918 |
|
|
/*Distance from the Extrapolated Tracks to LCT, 9999. for no LCT found*/
|
919 |
|
|
CSCLCTxLc[j] = -9999.;
|
920 |
|
|
CSCLCTyLc[j] = -9999.;
|
921 |
|
|
CSCDrTTLCT[j] = -9999.;
|
922 |
|
|
CSCDrErrTTLCT[j] = -9999.;
|
923 |
|
|
CSCLCTbx[j] = -9999;
|
924 |
|
|
/*DetlaR between the extrapolated tracker track on muon system and the tagged muon*/
|
925 |
|
|
dRTkMu[j] = -9999.;
|
926 |
|
|
/*Default decision of whether a segment or LCT is found*/
|
927 |
|
|
segSt[j]=false;
|
928 |
|
|
lctSt[j]=false;
|
929 |
|
|
}
|
930 |
|
|
|
931 |
|
|
for(UInt_t j =0; j < 6; j++) {
|
932 |
|
|
|
933 |
|
|
if( MEZ[j] == 0)continue;
|
934 |
|
|
|
935 |
|
|
Float_t zzPlaneME = MEZ[j];
|
936 |
|
|
if(!CSCEndCapPlus) zzPlaneME = -MEZ[j];
|
937 |
|
|
tsos = surfExtrapTrkSam(trackRef, zzPlaneME);
|
938 |
|
|
if (!tsos.isValid()) continue;
|
939 |
|
|
|
940 |
|
|
Int_t st = j>2?j-2:0, ec=CSCEndCapPlus?1:2; // determine the station number...
|
941 |
|
|
Float_t trkEta = tsos.globalPosition().eta(), trkPhi = tsos.globalPosition().phi();
|
942 |
|
|
|
943 |
|
|
Int_t rg = ringCandidate(st+1, trkEta, trkPhi);
|
944 |
|
|
if (rg==-9999) continue;
|
945 |
|
|
|
946 |
|
|
//for chamber overlap region
|
947 |
|
|
/* This part of code is useless. Just directly extrapolate to chamber
|
948 |
|
|
cerr<< "CHK"<<thisChamberCandidate(st+1, rg, trkPhi);
|
949 |
|
|
if ( thisChamberCandidate(st+1, rg, trkPhi)%2 == 0 ) zzPlaneME = MEZEven[j];
|
950 |
|
|
else zzPlaneME = MEZOdd[j];
|
951 |
|
|
|
952 |
|
|
if(!CSCEndCapPlus)zzPlaneME = -zzPlaneME;
|
953 |
|
|
|
954 |
|
|
tsos = surfExtrapTrkSam(trackRef, zzPlaneME);
|
955 |
|
|
if (!tsos.isValid()) continue;*/
|
956 |
|
|
|
957 |
|
|
trkEta = tsos.globalPosition().eta(); trkPhi = tsos.globalPosition().phi();
|
958 |
|
|
if(trkPhi < 0) trkPhi += 2*M_PI;
|
959 |
|
|
|
960 |
|
|
CSCRg[st] = ringCandidate(st+1, trkEta, trkPhi);
|
961 |
|
|
if ( CSCRg[st]==0 ) continue;
|
962 |
|
|
CSCChCand[st] = thisChamberCandidate(st+1, CSCRg[st], trkPhi);
|
963 |
|
|
CSCDetId myid = CSCDetId( ec, st+1, rg, CSCChCand[st], 0 );
|
964 |
|
|
CSCChBad[st] = badChambers_->isInBadChamber(myid);
|
965 |
|
|
const GeomDet* gdet=cscGeom->idToDet(myid);
|
966 |
|
|
const CSCChamber* cscch = cscGeom->chamber(myid);
|
967 |
|
|
tsos=surfExtrapTrkSam(trackRef, gdet->surface().position().z());//update tsos with chamber Z position in database
|
968 |
|
|
if (!tsos.isValid()) continue;
|
969 |
|
|
|
970 |
|
|
/*dR between muon and track*/
|
971 |
|
|
Float_t MPhi = phiMuVec[st];
|
972 |
|
|
if(MPhi < 0 ) MPhi += 2*M_PI;
|
973 |
|
|
Float_t TPhi = tsos.globalPosition().phi();
|
974 |
|
|
if(TPhi < 0 ) TPhi += 2*M_PI;
|
975 |
|
|
dRTkMu[st] = deltaR( etaMuVec[st], MPhi, tsos.globalPosition().eta() , TPhi);
|
976 |
|
|
// printf("Mu(%f,%f),Trk(%f,%f)-->dR(%f)",etaMuVec[st], MPhi, tsos.globalPosition().eta() , TPhi,dRTkMu[st]);
|
977 |
|
|
|
978 |
|
|
#ifdef jz_debug
|
979 |
|
|
if (CSCChBad[st]) cerr<<(CSCEndCapPlus?"ME+":"ME-")<<st+1<<"/"<<CSCRg[st]<<"/"<<CSCChBad[st]<<" is a dead chamber."<<endl;
|
980 |
|
|
#endif
|
981 |
|
|
LocalPoint localTTPos = gdet->surface().toLocal(tsos.freeState()->position());
|
982 |
|
|
const CSCChamberSpecs* chamberSpecs = cscch->specs();
|
983 |
|
|
|
984 |
|
|
const CSCLayerGeometry* layerGeometry = chamberSpecs->oddLayerGeometry(1);
|
985 |
|
|
const CSCWireTopology* wireTopology = layerGeometry->wireTopology();
|
986 |
|
|
Float_t wideWidth = wireTopology->wideWidthOfPlane();
|
987 |
|
|
Float_t narrowWidth = wireTopology->narrowWidthOfPlane();
|
988 |
|
|
Float_t length = wireTopology->lengthOfPlane();
|
989 |
|
|
// If slanted, there is no y offset between local origin and symmetry center of wire plane
|
990 |
|
|
Float_t yOfFirstWire = fabs(wireTopology->wireAngle())>1.E-06 ? -0.5*length : wireTopology->yOfWire(1);
|
991 |
|
|
// y offset between local origin and symmetry center of wire plane
|
992 |
|
|
Float_t yCOWPOffset = yOfFirstWire+0.5*length;
|
993 |
|
|
|
994 |
|
|
// tangent of the incline angle from inside the trapezoid
|
995 |
|
|
Float_t tangent = (wideWidth-narrowWidth)/(2.*length);
|
996 |
|
|
// y position wrt bottom of trapezoid
|
997 |
|
|
Float_t yPrime = localTTPos.y()+fabs(yOfFirstWire);
|
998 |
|
|
// half trapezoid width at y' is 0.5 * narrowWidth + x side of triangle with the above tangent and side y'
|
999 |
|
|
Float_t halfWidthAtYPrime = 0.5*narrowWidth+yPrime*tangent;
|
1000 |
|
|
Float_t edgex = fabs(localTTPos.x()) - halfWidthAtYPrime;
|
1001 |
|
|
Float_t edgey = fabs(localTTPos.y()-yCOWPOffset) - 0.5*length;
|
1002 |
|
|
|
1003 |
|
|
CSCxProjLc[st] = localTTPos.x();
|
1004 |
|
|
CSCyProjLc[st] = localTTPos.y();
|
1005 |
|
|
CSCDyProjHVGap[st]=YDistToHVDeadZone(CSCyProjLc[st], (st+1)*10+CSCRg[st]);
|
1006 |
|
|
|
1007 |
|
|
//CSCxErrProjLc[st] = sqrt(tsos.cartesianError().position().cxx());
|
1008 |
|
|
//CSCyErrProjLc[st] = sqrt(tsos.cartesianError().position().cyy());
|
1009 |
|
|
LocalError localTTErr=tsos.localError().positionError();
|
1010 |
|
|
CSCxErrProjLc[st] = sqrt( localTTErr.xx() );
|
1011 |
|
|
CSCyErrProjLc[st] = sqrt( localTTErr.yy() );
|
1012 |
|
|
|
1013 |
|
|
if ( edgex > edgey ) {
|
1014 |
|
|
CSCProjEdgeDist[st] = edgex;
|
1015 |
|
|
CSCProjEdgeDistErr[st] = CSCxErrProjLc[st];
|
1016 |
|
|
}
|
1017 |
|
|
else {
|
1018 |
|
|
CSCProjEdgeDist[st] = edgey;
|
1019 |
|
|
CSCProjEdgeDistErr[st] = CSCyErrProjLc[st];
|
1020 |
|
|
}
|
1021 |
|
|
|
1022 |
|
|
/// Check the CSC segments in that region..
|
1023 |
|
|
/// Get the matched CSC segment..
|
1024 |
|
|
//cerr<<"CSCxProjLc: "<<tsos.localPosition().x()<<","<<CSCxProjLc[st]<<"+-"<<CSCxErrProjLc[st]<<endl;
|
1025 |
|
|
//cerr<<"CSCyProjLc: "<<tsos.localPosition().y()<<","<<CSCyProjLc[st]<<"+-"<<CSCyErrProjLc[st]<<endl;
|
1026 |
|
|
CSCSegmentCollection::const_iterator cscSegOut;
|
1027 |
|
|
TrajectoryStateOnSurface *TrajToSeg = matchTTwithCSCSeg( trackRef, cscSegments, cscSegOut, myid);//check tsos with segment Z position
|
1028 |
|
|
|
1029 |
|
|
if ( TrajToSeg!=NULL ) {
|
1030 |
|
|
/* Save the chamber ID */
|
1031 |
|
|
CSCDetId id = (CSCDetId) cscSegOut->cscDetId();
|
1032 |
|
|
/* Save the segment postion and direction */
|
1033 |
|
|
LocalPoint localSegPos = (*cscSegOut).localPosition();
|
1034 |
|
|
//GlobalPoint globalSegPosition = cscchamber->toGlobal( localSegPos );
|
1035 |
|
|
CSCSegxLc[st] = localSegPos.x();
|
1036 |
|
|
CSCSegyLc[st] = localSegPos.y();
|
1037 |
|
|
LocalError localSegErr = (*cscSegOut).localPositionError();
|
1038 |
|
|
CSCSegxErrLc[st] = sqrt(localSegErr.xx());
|
1039 |
|
|
CSCSegyErrLc[st] = sqrt(localSegErr.yy());
|
1040 |
|
|
//cerr<<"CSCSegxLc:"<<localSegPos.x()<<"+-"<<CSCSegxErrLc[st]<<endl;
|
1041 |
|
|
//cerr<<"CSCSegyLc:"<<localSegPos.y()<<"+-"<<CSCSegyErrLc[st]<<endl;
|
1042 |
|
|
|
1043 |
|
|
/* Save the segment quality */
|
1044 |
|
|
CSCnSegHits[st] = cscSegOut->specificRecHits().size();
|
1045 |
|
|
Int_t nDOFCSC = 2*CSCnSegHits[st]-4;
|
1046 |
|
|
CSCSegChisqProb[st] = ChiSquaredProbability( double( (*cscSegOut).chi2() ), nDOFCSC );
|
1047 |
|
|
|
1048 |
|
|
/* Save the difference between the ex-tracker track and the segment */
|
1049 |
|
|
const GeomDet* gdet=cscGeom->idToDet(id);
|
1050 |
|
|
LocalPoint localpCSC = gdet->surface().toLocal(TrajToSeg->freeState()->position());
|
1051 |
|
|
CSCDxTTSeg[st] = CSCSegxLc[st] - localpCSC.x();
|
1052 |
|
|
CSCDyTTSeg[st] = CSCSegyLc[st] - localpCSC.y();
|
1053 |
|
|
CSCDxyTTSeg[st] = sqrt(pow(CSCDxTTSeg[st],2)+pow(CSCDxTTSeg[st],2));
|
1054 |
|
|
|
1055 |
|
|
LocalError localTTErr =TrajToSeg->localError().positionError();
|
1056 |
|
|
Float_t CSCdeltaXErr2 = localSegErr.xx() + localTTErr.xx();
|
1057 |
|
|
Float_t CSCdeltaYErr2 = localSegErr.yy() + localTTErr.yy();
|
1058 |
|
|
CSCDxyErrTTSeg[st] = sqrt(pow(CSCDxTTSeg[st],2)*CSCdeltaXErr2+pow(CSCDyTTSeg[st],2)*CSCdeltaYErr2)/CSCDxyTTSeg[st];
|
1059 |
|
|
|
1060 |
|
|
LocalVector trackLocalDir = TrajToSeg->localDirection();
|
1061 |
|
|
LocalVector segDir = (*cscSegOut).localDirection();
|
1062 |
|
|
if ( trackLocalDir.z()!=0. && segDir.z()!=0.) {
|
1063 |
|
|
Float_t dxdz_trk = trackLocalDir.x()/trackLocalDir.z();
|
1064 |
|
|
Float_t dydz_trk = trackLocalDir.y()/trackLocalDir.z();
|
1065 |
|
|
Float_t dxdz_seg = segDir.x()/segDir.z();
|
1066 |
|
|
Float_t dydz_seg = segDir.y()/segDir.z();
|
1067 |
|
|
if(fabs(id.station()) == 3 || fabs(id.station()) == 4) dydz_seg = -dydz_seg;
|
1068 |
|
|
CSCdXdZTTSeg[st] = dxdz_trk - dxdz_seg;
|
1069 |
|
|
CSCdYdZTTSeg[st] = dydz_trk - dydz_seg;
|
1070 |
|
|
}
|
1071 |
|
|
nTrkCountCSCSeg++;
|
1072 |
|
|
}
|
1073 |
|
|
////// Loop over MPC infromation to look for LCTs....
|
1074 |
|
|
LocalPoint *LCTPos=matchTTwithLCTs( CSCxProjLc[st], CSCyProjLc[st], CSCEndCapPlus?1:2, st+1, CSCRg[st], CSCChCand[st], mpclcts, CSCDrTTLCT[st], CSCLCTbx[st]);
|
1075 |
|
|
if (LCTPos!=NULL) {
|
1076 |
|
|
CSCLCTxLc[st]=LCTPos->x();
|
1077 |
|
|
CSCLCTyLc[st]=LCTPos->y();
|
1078 |
|
|
//cout << "(x,y)=("<<CSCLCTxLc[st]<<","<< CSCLCTyLc[st] <<")"<< endl;
|
1079 |
|
|
CSCDrErrTTLCT[st] =sqrt(pow(CSCLCTxLc[st]-CSCxProjLc[st],2)*CSCxErrProjLc[st]*CSCxErrProjLc[st] + pow(CSCLCTyLc[st]-CSCyProjLc[st],2)*CSCyErrProjLc[st]*CSCyErrProjLc[st])/CSCDrTTLCT[st];
|
1080 |
|
|
}
|
1081 |
|
|
} // for loop for the stations -- j
|
1082 |
|
|
/*
|
1083 |
|
|
for (Byte_t st=0;st<4;st++) {
|
1084 |
|
|
lctSt[st] = ( CSCDrTTLCT[st] >0. && CSCDrTTLCT[st] < 40 )?1:0;
|
1085 |
|
|
segSt[st] = ( CSCDxyTTSeg[st] >0. && CSCDxyTTSeg[st] < 40)?1:0;
|
1086 |
|
|
}*/
|
1087 |
|
|
fractNtuple->Fill();
|
1088 |
|
|
firsttrackmatchingtoMuTag=false;
|
1089 |
|
|
} // loop over tracks...
|
1090 |
|
|
} // loop over muon tracks
|
1091 |
|
|
}
|
1092 |
|
|
|
1093 |
|
|
// ------------ method called once each job just before starting event loop ------------
|
1094 |
|
|
void TPTrackMuonSys::beginJob() {}
|
1095 |
|
|
// ------------ method called once each job just after ending the event loop ------------
|
1096 |
|
|
void TPTrackMuonSys::endJob() {
|
1097 |
|
|
theFile->Write();
|
1098 |
|
|
theFile->Close();
|
1099 |
|
|
std::cout<<"Events in "<<nEventsAnalyzed<<std::endl;
|
1100 |
|
|
}
|
1101 |
|
|
|
1102 |
|
|
//copied and modified from http://www.codeproject.com/KB/string/wildcmp.aspx
|
1103 |
|
|
//It does not belong to any class
|
1104 |
|
|
Bool_t wildcmp(const char *wild, const char *string) {
|
1105 |
|
|
// Written by Jack Handy - jakkhandy@hotmail.com
|
1106 |
|
|
const char *cp = NULL, *mp = NULL;
|
1107 |
|
|
|
1108 |
|
|
while ((*string) && (*wild != '*')) {
|
1109 |
|
|
if ((*wild != *string) && (*wild != '?')) {
|
1110 |
|
|
return false;
|
1111 |
|
|
}
|
1112 |
|
|
wild++;
|
1113 |
|
|
string++;
|
1114 |
|
|
}
|
1115 |
|
|
|
1116 |
|
|
while (*string) {
|
1117 |
|
|
if (*wild == '*') {
|
1118 |
|
|
if (!*++wild) {
|
1119 |
|
|
return true;
|
1120 |
|
|
}
|
1121 |
|
|
mp = wild;
|
1122 |
|
|
cp = string+1;
|
1123 |
|
|
} else if ((*wild == *string) || (*wild == '?')) {
|
1124 |
|
|
wild++;
|
1125 |
|
|
string++;
|
1126 |
|
|
} else {
|
1127 |
|
|
wild = mp;
|
1128 |
|
|
string = cp++;
|
1129 |
|
|
}
|
1130 |
|
|
}
|
1131 |
|
|
|
1132 |
|
|
while (*wild == '*') {
|
1133 |
|
|
wild++;
|
1134 |
|
|
}
|
1135 |
|
|
return !*wild;
|
1136 |
|
|
}
|
1137 |
|
|
|
1138 |
|
|
// ------------ method called in the beginning of each run ------------
|
1139 |
|
|
void TPTrackMuonSys::beginRun(const Run& r, const EventSetup& iSet)
|
1140 |
|
|
{
|
1141 |
|
|
run_number = r.runAuxiliary().run();
|
1142 |
|
|
iSet.get<CSCBadChambersRcd>().get(pBad);
|
1143 |
|
|
badChambers_=const_cast<CSCBadChambers*>(pBad.product());
|
1144 |
|
|
badChambersIndices=new vector<Int_t>( badChambers_->container() );
|
1145 |
|
|
|
1146 |
|
|
char plotname[100],plottitle[100];
|
1147 |
|
|
sprintf(plotname,"Run%d_BadChambers",run_number);
|
1148 |
|
|
sprintf(plottitle,"Known BadChambers in Run %d; chamber number",run_number);
|
1149 |
|
|
/* Draw a badchamber plot and save it to the ntuple*/
|
1150 |
|
|
TH2F *TH2F_BadChambers=new TH2F(plotname,plottitle,36,1,37,18,-9,9);
|
1151 |
|
|
const char *chambers[36] = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36"};
|
1152 |
|
|
const char *rings[18] = {"ME-42","ME-41","ME-32","ME-31","ME-22","ME-21","ME-13","ME-12","ME-11","ME+11","ME+12","ME+13","ME+21","ME+22","ME+31","ME+32","ME+41","ME+42"};
|
1153 |
|
|
for (Byte_t i=0;i<36;i++)
|
1154 |
|
|
TH2F_BadChambers->GetXaxis()->SetBinLabel(i+1,chambers[i]);
|
1155 |
|
|
for (Byte_t i=0;i<18;i++)
|
1156 |
|
|
TH2F_BadChambers->GetYaxis()->SetBinLabel(i+1,rings[i]);
|
1157 |
|
|
for( Short_t indexc = 1; indexc<=540; ++indexc ) {// chamber indices are in range 1-468 (CSCs 2008) or 469-540 (ME42)
|
1158 |
|
|
CSCDetId id = CSCIndexer().detIdFromChamberIndex( indexc );
|
1159 |
|
|
if ( !badChambers_->isInBadChamber( id ) ) continue;
|
1160 |
|
|
Byte_t ring=id.station()*10+id.ring();
|
1161 |
|
|
Float_t fillY;
|
1162 |
|
|
switch ( ring )
|
1163 |
|
|
{
|
1164 |
|
|
case 14:
|
1165 |
|
|
fillY=0.5;
|
1166 |
|
|
break;
|
1167 |
|
|
case 11:
|
1168 |
|
|
fillY=0.5;
|
1169 |
|
|
break;
|
1170 |
|
|
case 12:
|
1171 |
|
|
fillY=1.5;
|
1172 |
|
|
break;
|
1173 |
|
|
case 13:
|
1174 |
|
|
fillY=2.5;
|
1175 |
|
|
break;
|
1176 |
|
|
case 21:
|
1177 |
|
|
fillY=3.5;
|
1178 |
|
|
break;
|
1179 |
|
|
case 22:
|
1180 |
|
|
fillY=4.5;
|
1181 |
|
|
break;
|
1182 |
|
|
case 31:
|
1183 |
|
|
fillY=5.5;
|
1184 |
|
|
break;
|
1185 |
|
|
case 32:
|
1186 |
|
|
fillY=6.5;
|
1187 |
|
|
break;
|
1188 |
|
|
case 41:
|
1189 |
|
|
fillY=7.5;
|
1190 |
|
|
break;
|
1191 |
|
|
case 42:
|
1192 |
|
|
fillY=8.5;
|
1193 |
|
|
break;
|
1194 |
|
|
default:
|
1195 |
|
|
printf("Unexpected ring number: %d",ring);
|
1196 |
|
|
fillY=9.5;
|
1197 |
|
|
}
|
1198 |
|
|
if (id.endcap()==2) fillY*=-1;
|
1199 |
|
|
TH2F_BadChambers->Fill(id.chamber()+0.5,fillY);
|
1200 |
|
|
#ifdef jz_debug
|
1201 |
|
|
cerr<<(id.endcap()==1?"ME+":"ME-")<<Int_t(ring)<<"/"<<id.chamber()<<"("<<indexc<<")";
|
1202 |
|
|
#endif
|
1203 |
|
|
}
|
1204 |
|
|
// TCanvas *BadChambersView=new TCanvas("badch","badch",1200,1000);
|
1205 |
|
|
// BadChambersView->SetGrid();
|
1206 |
|
|
TH2F_BadChambers->SetStats(0);
|
1207 |
|
|
TH2F_BadChambers->SetMinimum(0);
|
1208 |
|
|
TH2F_BadChambers->SetMaximum(0.8);
|
1209 |
|
|
TH2F_BadChambers->Draw("colz");
|
1210 |
|
|
TH2F_BadChambers->SetLabelSize(0.035,"X");
|
1211 |
|
|
#ifndef GetCSCHitsBefore500
|
1212 |
|
|
theFile->cd();
|
1213 |
|
|
#endif
|
1214 |
|
|
TH2F_BadChambers->Write();
|
1215 |
|
|
// BadChambersView->Write("BadChambersPlot");
|
1216 |
|
|
/* End of drawing the badchamber plot*/
|
1217 |
|
|
|
1218 |
|
|
Bool_t isConfigChanged = false;
|
1219 |
|
|
m_HLTMuTrgBit.clear();
|
1220 |
|
|
HLTMuNames->clear();
|
1221 |
|
|
HLTMuObjModuleNames->clear();
|
1222 |
|
|
m_HLTDiMuTrgBit=-1;
|
1223 |
|
|
HLTDiMuName=new string();
|
1224 |
|
|
HLTDiMuObjModuleName=new string();
|
1225 |
|
|
if ( hltConfigProvider_.init( r, iSet, m_hlt.process() , isConfigChanged ) ) {
|
1226 |
|
|
HLTTableName=new string( hltConfigProvider_.tableName() );
|
1227 |
|
|
const vector<string> & HLTNamesSet_=hltConfigProvider_.triggerNames();
|
1228 |
|
|
UInt_t idx=0;
|
1229 |
|
|
for ( vector<string>::const_iterator itertable=HLTNamesSet_.begin();itertable != HLTNamesSet_.end();itertable++,idx++ ) {
|
1230 |
|
|
#ifdef jz_debug
|
1231 |
|
|
cout<<endl<<idx<<":"<<*itertable;
|
1232 |
|
|
#endif
|
1233 |
|
|
Bool_t selected=false;
|
1234 |
|
|
for ( vector<string>::const_iterator iter=m_HLTMuTrgNames.begin();iter!=m_HLTMuTrgNames.end();iter++ ) {
|
1235 |
|
|
if ( wildcmp(iter->c_str(),itertable->c_str()) ) {
|
1236 |
|
|
selected=true;
|
1237 |
|
|
break;
|
1238 |
|
|
}
|
1239 |
|
|
}
|
1240 |
|
|
if (selected) {
|
1241 |
|
|
m_HLTMuTrgBit.push_back(idx);
|
1242 |
|
|
HLTMuNames->push_back(*itertable);
|
1243 |
|
|
HLTMuObjModuleNames->push_back( *(hltConfigProvider_.moduleLabels(idx).end()-2) );
|
1244 |
|
|
#ifdef jz_debug
|
1245 |
|
|
cout<<", saved for singlemu";
|
1246 |
|
|
#endif
|
1247 |
|
|
}
|
1248 |
|
|
if ( m_HLTDiMuTrgBit<0 && wildcmp(m_HLTDiMuTrgName.c_str(),itertable->c_str()) ) {
|
1249 |
|
|
m_HLTDiMuTrgBit=idx;
|
1250 |
|
|
HLTDiMuName->assign(*itertable);
|
1251 |
|
|
HLTDiMuObjModuleName->assign( *(hltConfigProvider_.moduleLabels(idx).end()-2) );
|
1252 |
|
|
#ifdef jz_debug
|
1253 |
|
|
cout<<", saved for doublemu";
|
1254 |
|
|
#endif
|
1255 |
|
|
}
|
1256 |
|
|
}//end of iter HLT table
|
1257 |
|
|
RunInfo->Fill();
|
1258 |
|
|
} else {
|
1259 |
|
|
// if init returns FALSE, initialisation has NOT succeeded, which indicates a problem
|
1260 |
|
|
// with the file and/or code and needs to be investigated!
|
1261 |
|
|
LogWarning("DataLost") << " HLT config extraction failure with process name " <<m_hlt.process();
|
1262 |
|
|
// In this case, all access methods will return empty values!
|
1263 |
|
|
}
|
1264 |
|
|
}
|
1265 |
|
|
|
1266 |
|
|
////////////////////////////////////////////
|
1267 |
|
|
reco::MuonCollection::const_iterator TPTrackMuonSys::matchTTwithMT(reco::TrackCollection::const_iterator &itrack)
|
1268 |
|
|
{
|
1269 |
|
|
for (reco::MuonCollection::const_iterator muIter = muons->begin(); muIter != muons->end(); muIter++) {
|
1270 |
|
|
if (muIter->combinedMuon().isNonnull() )
|
1271 |
|
|
if ( &( * muIter->combinedMuon().get() ) == & (*itrack) ) return muIter;
|
1272 |
|
|
if (muIter->track().isNonnull() )
|
1273 |
|
|
if ( &(* muIter->track().get() ) == & (*itrack) ) return muIter;
|
1274 |
|
|
if (muIter->standAloneMuon().isNonnull() )
|
1275 |
|
|
if ( &( *muIter->standAloneMuon().get() ) == & (*itrack) ) return muIter;
|
1276 |
|
|
}
|
1277 |
|
|
return muons->end();
|
1278 |
|
|
}
|
1279 |
|
|
|
1280 |
|
|
////// Match TT with RPCEndCapHit
|
1281 |
|
|
Bool_t TPTrackMuonSys::matchTTwithCSCRecHit(Bool_t trackDir,
|
1282 |
|
|
Int_t j,
|
1283 |
|
|
reco::TrackRef trackRef,
|
1284 |
|
|
edm::Handle<CSCRecHit2DCollection> recHits,
|
1285 |
|
|
//std::vector<CSCRecHit2DCollection> recHitOut,
|
1286 |
|
|
std::vector<CSCRecHit2D> & recHitOut,
|
1287 |
|
|
std::vector<Int_t >& deltaRecHitX,
|
1288 |
|
|
std::vector<Int_t >& deltaRecHitY)
|
1289 |
|
|
{
|
1290 |
|
|
|
1291 |
|
|
Bool_t aMatch = false;
|
1292 |
|
|
CSCRecHit2D tmp[6];
|
1293 |
|
|
|
1294 |
|
|
Float_t minDX[6]={999., 999., 999., 999., 999., 999.};
|
1295 |
|
|
Float_t minDY[6]={999., 999., 999., 999., 999., 999.};
|
1296 |
|
|
Float_t minDR[6]={999., 999., 999., 999., 999., 999.};
|
1297 |
|
|
recHitOut.clear();
|
1298 |
|
|
|
1299 |
|
|
Float_t rCut = 50.;
|
1300 |
|
|
|
1301 |
|
|
for (CSCRecHit2DCollection::const_iterator recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
|
1302 |
|
|
CSCDetId id = (CSCDetId)(*recIt).cscDetId();
|
1303 |
|
|
|
1304 |
|
|
if((trackDir && id.endcap() == 2) || (!trackDir && id.endcap() == 1)) continue;
|
1305 |
|
|
if(
|
1306 |
|
|
(j == 0 && id.station() == 1 && ((id.ring() == 1) || (id.ring() == 4 ))) || // ME1/1,4
|
1307 |
|
|
(j == 1 && id.station() == 1 && (id.ring() == 2)) || // ME1/2
|
1308 |
|
|
(j == 2 && id.station() == 1 && (id.ring() == 3)) || // ME1/3
|
1309 |
|
|
(j == 3 && id.station() == 2) || // ME2/1,2
|
1310 |
|
|
(j == 4 && id.station() == 3) || // ME3/1,2
|
1311 |
|
|
(j == 5 && id.station() == 4) // ME4/1
|
1312 |
|
|
){
|
1313 |
|
|
|
1314 |
|
|
// Get pointer to the layer:
|
1315 |
|
|
const CSCLayer* csclayer = cscGeom->layer( id );
|
1316 |
|
|
if (!csclayer)continue;
|
1317 |
|
|
|
1318 |
|
|
// Transform hit position from local chamber geometry to global CMS geom
|
1319 |
|
|
LocalPoint rhitlocal = (*recIt).localPosition();
|
1320 |
|
|
GlobalPoint rhitglobal = csclayer->toGlobal(rhitlocal);
|
1321 |
|
|
Float_t RecHit_grecx = rhitglobal.x();
|
1322 |
|
|
Float_t RecHit_grecy = rhitglobal.y();
|
1323 |
|
|
TrajectoryStateOnSurface tsos = surfExtrapTrkSam(trackRef, rhitglobal.z());
|
1324 |
|
|
if (!tsos.isValid()) continue;
|
1325 |
|
|
Float_t cscdeltaX = RecHit_grecx - tsos.globalPosition().x();
|
1326 |
|
|
Float_t cscdeltaY = RecHit_grecy - tsos.globalPosition().y();
|
1327 |
|
|
Float_t cscdeltaR = sqrt(pow(cscdeltaX,2)+pow(cscdeltaY,2));
|
1328 |
|
|
|
1329 |
|
|
Int_t mlayer = id.layer() - 1;
|
1330 |
|
|
if(fabs(cscdeltaR) < fabs(minDR[mlayer]) && fabs(cscdeltaR) < rCut){
|
1331 |
|
|
aMatch = true;
|
1332 |
|
|
minDX[mlayer] = cscdeltaX;
|
1333 |
|
|
minDY[mlayer] = cscdeltaY;
|
1334 |
|
|
minDR[mlayer] = cscdeltaR;
|
1335 |
|
|
tmp[mlayer] = (*recIt);
|
1336 |
|
|
}
|
1337 |
|
|
}
|
1338 |
|
|
}
|
1339 |
|
|
|
1340 |
|
|
for (Int_t i = 0; i < 6; i++) {
|
1341 |
|
|
Float_t cscdeltaR = sqrt(pow(minDX[i],2)+pow(minDY[i],2));
|
1342 |
|
|
if(cscdeltaR < rCut) recHitOut.push_back(tmp[i]);
|
1343 |
|
|
}
|
1344 |
|
|
for (Int_t i = 0; i < 6; i++) {
|
1345 |
|
|
deltaRecHitX.push_back(minDX[i]);
|
1346 |
|
|
deltaRecHitY.push_back(minDY[i]);
|
1347 |
|
|
}
|
1348 |
|
|
return aMatch;
|
1349 |
|
|
}
|
1350 |
|
|
|
1351 |
|
|
////// Match TT with RPCEndCapHit
|
1352 |
|
|
Bool_t TPTrackMuonSys::matchTTwithRPCEChit(Bool_t trackDir,
|
1353 |
|
|
Int_t j,
|
1354 |
|
|
reco::TrackRef trackRef,
|
1355 |
|
|
edm::Handle<RPCRecHitCollection> rpcRecHits,
|
1356 |
|
|
RPCRecHitCollection::const_iterator &rpcHitOut)
|
1357 |
|
|
// Float_t deltaRPCX, Float_t deltaRPCY)
|
1358 |
|
|
{
|
1359 |
|
|
Bool_t aMatch = false;
|
1360 |
|
|
|
1361 |
|
|
//Float_t deltaRPCX = 999.0, deltaRPCY = 999.0;
|
1362 |
|
|
Float_t deltaRPCR = 999.0;// deltaRPCPhi = 999.0;
|
1363 |
|
|
|
1364 |
|
|
for (RPCRecHitCollection::const_iterator rpcIt = rpcRecHits->begin(); rpcIt != rpcRecHits->end(); rpcIt++) {
|
1365 |
|
|
RPCDetId id = (RPCDetId)(*rpcIt).rpcId();
|
1366 |
|
|
const GeomDet* gdet=rpcGeo->idToDet(id);
|
1367 |
|
|
const BoundPlane & surface = gdet->surface();
|
1368 |
|
|
if(id.region() == 0)continue;
|
1369 |
|
|
if((trackDir && id.region() == -1) || (!trackDir && id.region() == 1) ) continue;
|
1370 |
|
|
if(
|
1371 |
|
|
(j >= 1 && j <= 2 && id.station() == 1) ||
|
1372 |
|
|
(j == 3 && id.station() == 2) ||
|
1373 |
|
|
(j == 4 && id.station() == 3)
|
1374 |
|
|
){
|
1375 |
|
|
|
1376 |
|
|
LocalPoint localPos = (*rpcIt).localPosition();
|
1377 |
|
|
GlobalPoint globalPosition=surface.toGlobal(localPos);
|
1378 |
|
|
TrajectoryStateOnSurface tsos = surfExtrapTrkSam(trackRef, globalPosition.z());
|
1379 |
|
|
if (!tsos.isValid()) continue;
|
1380 |
|
|
|
1381 |
|
|
Float_t RPCEdeltaXMin = globalPosition.x() - tsos.globalPosition().x();
|
1382 |
|
|
Float_t RPCEdeltaYMin = globalPosition.y() - tsos.globalPosition().y();
|
1383 |
|
|
//Float_t RPCEdeltaRMin = sqrt(pow(RPCEdeltaXMin,2)+pow(RPCEdeltaYMin,2));
|
1384 |
|
|
|
1385 |
|
|
Float_t RPCEPhiProj = tsos.globalPosition().phi();
|
1386 |
|
|
Float_t RPCEPhiPos = globalPosition.phi();
|
1387 |
|
|
|
1388 |
|
|
////// New for RPCEC
|
1389 |
|
|
if(RPCEPhiProj < 0) RPCEPhiProj = RPCEPhiProj + 2*M_PI;
|
1390 |
|
|
if(RPCEPhiPos < 0) RPCEPhiPos = RPCEPhiPos + 2*M_PI;
|
1391 |
|
|
|
1392 |
|
|
// Float_t RPCEdeltaPhiMin = fabs(RPCEPhiProj - RPCEPhiPos);//sqrt(pow(RPCEdeltaXMin,2)+pow(RPCEdeltaYMin,2));
|
1393 |
|
|
|
1394 |
|
|
Float_t RPCEdeltaRMin = sqrt(pow(RPCEdeltaXMin,2)+pow(RPCEdeltaYMin,2));
|
1395 |
|
|
if(fabs(RPCEdeltaRMin) < fabs(deltaRPCR) && fabs(RPCEdeltaRMin) < 50. ){
|
1396 |
|
|
aMatch = true;
|
1397 |
|
|
// deltaRPCPhi = RPCEdeltaPhiMin;
|
1398 |
|
|
deltaRPCR = RPCEdeltaRMin;
|
1399 |
|
|
rpcHitOut = rpcIt;
|
1400 |
|
|
}
|
1401 |
|
|
}
|
1402 |
|
|
} // loop over RPCE rechits
|
1403 |
|
|
|
1404 |
|
|
return aMatch;
|
1405 |
|
|
}
|
1406 |
|
|
|
1407 |
|
|
////////////// Get the matching with LCTs...
|
1408 |
|
|
LocalPoint * TPTrackMuonSys::matchTTwithLCTs(Float_t xPos, Float_t yPos, Short_t ec, Short_t st, Short_t rg, Short_t cham,
|
1409 |
|
|
edm::Handle<CSCCorrelatedLCTDigiCollection> mpclcts, Float_t &dRTrkLCT, Int_t &lctBX ) {
|
1410 |
|
|
LocalPoint *interSect=NULL;
|
1411 |
|
|
|
1412 |
|
|
for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator detMPCUnitIt = mpclcts->begin();
|
1413 |
|
|
detMPCUnitIt != mpclcts->end(); detMPCUnitIt++) {
|
1414 |
|
|
const CSCDetId& id = (*detMPCUnitIt).first;
|
1415 |
|
|
|
1416 |
|
|
if(ec != id.endcap())continue;
|
1417 |
|
|
if(st != id.station())continue;
|
1418 |
|
|
if(cham != id.chamber())continue;
|
1419 |
|
|
|
1420 |
|
|
Bool_t ed1 = (st == 1) && ((rg == 1 || rg == 4) && (id.ring() == 1 || id.ring() == 4));
|
1421 |
|
|
Bool_t ed2 = (st == 1) && ((rg == 2 && id.ring() == 2) || (rg == 3 && id.ring() == 3));
|
1422 |
|
|
Bool_t ed3 = (st != 1) && (rg == id.ring());
|
1423 |
|
|
Bool_t TMCSCMatch = (ed1 || ed2 || ed3);
|
1424 |
|
|
if(! TMCSCMatch)continue;
|
1425 |
|
|
|
1426 |
|
|
const CSCCorrelatedLCTDigiCollection::Range& MPCrange = (*detMPCUnitIt).second;
|
1427 |
|
|
for (CSCCorrelatedLCTDigiCollection::const_iterator mpcIt = MPCrange.first; mpcIt != MPCrange.second; mpcIt++) {
|
1428 |
|
|
Bool_t lct_valid = (*mpcIt).isValid();
|
1429 |
|
|
if(!lct_valid)continue;
|
1430 |
|
|
Int_t wireGroup_id = (*mpcIt).getKeyWG();
|
1431 |
|
|
Float_t strip_id = (*mpcIt).getStrip()/2.;
|
1432 |
|
|
const CSCLayerGeometry *layerGeom = cscGeom->chamber(id)->layer (3)->geometry ();
|
1433 |
|
|
const Int_t Nstrips=layerGeom->numberOfStrips();
|
1434 |
|
|
Bool_t me11a = ( (st == 1) && (id.ring() == 1 || id.ring() == 4) && strip_id>Nstrips );
|
1435 |
|
|
if ( me11a ) strip_id-=Nstrips;
|
1436 |
|
|
for(Int_t ii = 0; ii < 3; ii++){
|
1437 |
|
|
if ( strip_id>Nstrips ) LogWarning("Strip_id") << "Got "<<strip_id<<", but there are "<< Nstrips <<" strips in total." <<m_hlt.process();
|
1438 |
|
|
LocalPoint interSect_ = layerGeom->stripWireGroupIntersection(Int_t(strip_id), wireGroup_id);
|
1439 |
|
|
// printf( "ME%d/%d: %.1f/%d, %d/%d: xLCT-xTT=%.2f-%.2f; yLCT-yTT=%.2f-%.2f \n",st,id.ring(),strip_id,Nstrips,wireGroup_id,layerGeom->numberOfWireGroups(),interSect_.x(),xPos,interSect_.y(),yPos);
|
1440 |
|
|
if ( strip_id>Int_t(strip_id) ) {//the staggers of strips, which happens for layer 1,3,5
|
1441 |
|
|
LocalPoint interSect_plus = layerGeom->stripWireGroupIntersection(Int_t(strip_id)+1, wireGroup_id);
|
1442 |
|
|
interSect_=LocalPoint( (interSect_.x()+interSect_plus.x())/2., (interSect_.y()+interSect_plus.y())/2. );
|
1443 |
|
|
// printf( "corrected ME%d/%d: %.1f/%d, %d/%d: xLCT-xTT=%.2f-%.2f; yLCT-yTT=%.2f-%.2f \n",st,id.ring(),strip_id,Nstrips,wireGroup_id,layerGeom->numberOfWireGroups(),interSect_.x(),xPos,interSect_.y(),yPos);
|
1444 |
|
|
}
|
1445 |
|
|
Float_t DeltaR_ = sqrt(pow((interSect_.x()-xPos),2) + pow((interSect_.y()-yPos),2));
|
1446 |
|
|
if( DeltaR_ < fabs(dRTrkLCT) ) {
|
1447 |
|
|
interSect=new LocalPoint(interSect_);
|
1448 |
|
|
dRTrkLCT = DeltaR_ ;
|
1449 |
|
|
lctBX = (*mpcIt).getBX();
|
1450 |
|
|
//cout << "1: BX = " << (*mpcIt).getBX() << " BX0 = " << (*mpcIt).getBX0() << std::endl;
|
1451 |
|
|
} // for the matching if statement...
|
1452 |
|
|
if (me11a) strip_id+=16.;
|
1453 |
|
|
else break;
|
1454 |
|
|
}// end iteration over of ME11A triplet
|
1455 |
|
|
}// end iteration over lcts_mpc_data in one chamber
|
1456 |
|
|
}// end iteration over lcts_mpc_data
|
1457 |
|
|
return interSect;
|
1458 |
|
|
}
|
1459 |
|
|
|
1460 |
|
|
inline Float_t TPTrackMuonSys::TrajectoryDistToSeg( TrajectoryStateOnSurface *TrajSuf, CSCSegmentCollection::const_iterator segIt) {
|
1461 |
|
|
if (!TrajSuf->isValid()) return 9999.;
|
1462 |
|
|
const GeomDet* gdet=cscGeom->idToDet( (CSCDetId)(*segIt).cscDetId() );
|
1463 |
|
|
LocalPoint localTTPos = gdet->surface().toLocal(TrajSuf->freeState()->position());
|
1464 |
|
|
LocalPoint localSegPos = (*segIt).localPosition();
|
1465 |
|
|
Float_t CSCdeltaX = localSegPos.x() - localTTPos.x();
|
1466 |
|
|
Float_t CSCdeltaY = localSegPos.y() - localTTPos.y();
|
1467 |
|
|
return sqrt(pow(CSCdeltaX,2)+pow(CSCdeltaY,2));
|
1468 |
|
|
}
|
1469 |
|
|
|
1470 |
|
|
TrajectoryStateOnSurface *TPTrackMuonSys::matchTTwithCSCSeg( reco::TrackRef trackRef, edm::Handle<CSCSegmentCollection> cscSegments,
|
1471 |
|
|
CSCSegmentCollection::const_iterator &cscSegOut, CSCDetId & idCSC ) {
|
1472 |
|
|
TrajectoryStateOnSurface *TrajSuf=NULL;
|
1473 |
|
|
Float_t deltaCSCR = 50.0;
|
1474 |
|
|
for(CSCSegmentCollection::const_iterator segIt=cscSegments->begin(); segIt != cscSegments->end(); segIt++) {
|
1475 |
|
|
CSCDetId id = (CSCDetId)(*segIt).cscDetId();
|
1476 |
|
|
if(idCSC.endcap() != id.endcap())continue;
|
1477 |
|
|
if(idCSC.station() != id.station())continue;
|
1478 |
|
|
if(idCSC.chamber() != id.chamber())continue;
|
1479 |
|
|
|
1480 |
|
|
Bool_t ed1 = (idCSC.station() == 1) && ((idCSC.ring() == 1 || idCSC.ring() == 4) && (id.ring() == 1 || id.ring() == 4));
|
1481 |
|
|
Bool_t ed2 = (idCSC.station() == 1) && ((idCSC.ring() == 2 && id.ring() == 2) || (idCSC.ring() == 3 && id.ring() == 3));
|
1482 |
|
|
Bool_t ed3 = (idCSC.station() != 1) && (idCSC.ring() == id.ring());
|
1483 |
|
|
Bool_t TMCSCMatch = (ed1 || ed2 || ed3);
|
1484 |
|
|
if(! TMCSCMatch)continue;
|
1485 |
|
|
|
1486 |
|
|
const CSCChamber* cscchamber = cscGeom->chamber(id);
|
1487 |
|
|
if (!cscchamber) continue;
|
1488 |
|
|
TrajectoryStateOnSurface TrajSuf_ = surfExtrapTrkSam(trackRef, cscchamber->toGlobal( (*segIt).localPosition() ).z());
|
1489 |
|
|
|
1490 |
|
|
Float_t dR_= fabs( TrajectoryDistToSeg( &TrajSuf_, segIt ) );
|
1491 |
|
|
if ( dR_ < deltaCSCR ){
|
1492 |
|
|
TrajSuf=new TrajectoryStateOnSurface(TrajSuf_);
|
1493 |
|
|
deltaCSCR = dR_;
|
1494 |
|
|
cscSegOut = segIt;
|
1495 |
|
|
}
|
1496 |
|
|
}//loop over segments
|
1497 |
|
|
return TrajSuf;
|
1498 |
|
|
}
|
1499 |
|
|
////////////// Get the matching with CSC-sgements...
|
1500 |
|
|
Bool_t TPTrackMuonSys::matchTTwithCSCSeg(Bool_t trackDir, Int_t st_, reco::TrackRef trackRef, edm::Handle<CSCSegmentCollection> cscSegments,
|
1501 |
|
|
CSCSegmentCollection::const_iterator &cscSegOut ) {
|
1502 |
|
|
Bool_t aMatch = false;
|
1503 |
|
|
// Float_t deltaCSCX = 9999.0, deltaCSCY = 9999.0;
|
1504 |
|
|
Float_t deltaCSCR = 50.0;
|
1505 |
|
|
for(CSCSegmentCollection::const_iterator segIt=cscSegments->begin(); segIt != cscSegments->end(); segIt++) {
|
1506 |
|
|
CSCDetId id = (CSCDetId)(*segIt).cscDetId();
|
1507 |
|
|
if((trackDir && id.endcap() == 2) || (!trackDir && id.endcap() == 1)) continue;
|
1508 |
|
|
if(
|
1509 |
|
|
(st_ == 0 && id.station() == 1 && ((id.ring() == 1) || (id.ring() == 4 ))) || // ME1/1,4
|
1510 |
|
|
(st_ == 1 && id.station() == 1 && (id.ring() == 2)) || // ME1/2
|
1511 |
|
|
(st_ == 2 && id.station() == 1 && (id.ring() == 3)) || // ME1/3
|
1512 |
|
|
(st_ == 3 && id.station() == 2) || // ME2/1,2
|
1513 |
|
|
(st_ == 4 && id.station() == 3) || // ME3/1,2
|
1514 |
|
|
(st_ == 5 && id.station() == 4) // ME4/1
|
1515 |
|
|
) {
|
1516 |
|
|
const CSCChamber* cscchamber = cscGeom->chamber(id);
|
1517 |
|
|
if (!cscchamber) continue;
|
1518 |
|
|
TrajectoryStateOnSurface TrajSuf = surfExtrapTrkSam(trackRef, cscchamber->toGlobal( (*segIt).localPosition() ).z());
|
1519 |
|
|
|
1520 |
|
|
Float_t dR_= fabs( TrajectoryDistToSeg( &TrajSuf, segIt ) );
|
1521 |
|
|
|
1522 |
|
|
if ( dR_ < deltaCSCR ){
|
1523 |
|
|
aMatch = true;
|
1524 |
|
|
deltaCSCR = dR_;
|
1525 |
|
|
cscSegOut = segIt;
|
1526 |
|
|
}
|
1527 |
|
|
}
|
1528 |
|
|
} // loop over segments
|
1529 |
|
|
return aMatch;
|
1530 |
|
|
}
|
1531 |
|
|
|
1532 |
|
|
////
|
1533 |
|
|
Int_t TPTrackMuonSys::getNLayerMatchedCSCSeg(CSCSegmentCollection::const_iterator &cscSegMatch,
|
1534 |
|
|
edm::Handle<CSCRecHit2DCollection> recHits,
|
1535 |
|
|
Float_t *delRecSegX,
|
1536 |
|
|
Float_t *delRecSegY,
|
1537 |
|
|
Int_t &nGhits
|
1538 |
|
|
)
|
1539 |
|
|
{
|
1540 |
|
|
Int_t nhits = 0;
|
1541 |
|
|
CSCDetId idCSC = (CSCDetId)(*cscSegMatch).cscDetId();
|
1542 |
|
|
Int_t ec = idCSC.endcap(), st = idCSC.station(), rg = idCSC.ring(), cham = idCSC.chamber();
|
1543 |
|
|
LocalPoint localPos = (*cscSegMatch).localPosition();
|
1544 |
|
|
|
1545 |
|
|
Float_t cscx = localPos.x();
|
1546 |
|
|
Float_t cscy = localPos.y();
|
1547 |
|
|
|
1548 |
|
|
for(Int_t i = 0; i < 6; i++){
|
1549 |
|
|
delRecSegX[i] = 999.;
|
1550 |
|
|
delRecSegY[i] = 999.;
|
1551 |
|
|
}
|
1552 |
|
|
Float_t minDeltaR = 999.;
|
1553 |
|
|
|
1554 |
|
|
for (CSCRecHit2DCollection::const_iterator recIt = recHits->begin(); recIt != recHits->end(); recIt++) {
|
1555 |
|
|
CSCDetId id = (CSCDetId)(*recIt).cscDetId();
|
1556 |
|
|
if(ec != id.endcap())continue;
|
1557 |
|
|
if(st != id.station())continue;
|
1558 |
|
|
if(rg != id.ring())continue;
|
1559 |
|
|
if(cham != id.chamber())continue;
|
1560 |
|
|
LocalPoint rhitlocal = (*recIt).localPosition();
|
1561 |
|
|
Float_t recx = rhitlocal.x();
|
1562 |
|
|
Float_t recy = rhitlocal.y();
|
1563 |
|
|
Float_t myDeltaR = sqrt(pow((cscx - recx),2)+ pow((cscy - recy),2));
|
1564 |
|
|
|
1565 |
|
|
Int_t layer = id.layer();
|
1566 |
|
|
|
1567 |
|
|
if(myDeltaR < minDeltaR){
|
1568 |
|
|
minDeltaR = myDeltaR;
|
1569 |
|
|
delRecSegX[layer-1] = cscx - recx;
|
1570 |
|
|
delRecSegY[layer-1] = cscy - recy;
|
1571 |
|
|
}
|
1572 |
|
|
nhits = nhits + 1;
|
1573 |
|
|
}
|
1574 |
|
|
|
1575 |
|
|
nGhits = 0;
|
1576 |
|
|
for(Int_t i = 0; i < 6; i++){
|
1577 |
|
|
Float_t myDeltaR = sqrt(pow(delRecSegX[i],2)+ pow(delRecSegY[i],2));
|
1578 |
|
|
if(myDeltaR < 15.)nGhits = nGhits + 1; /// look for this hit is within 15 cm.
|
1579 |
|
|
}
|
1580 |
|
|
|
1581 |
|
|
|
1582 |
|
|
return nhits; // this is probably not the right number of hits.
|
1583 |
|
|
}
|
1584 |
|
|
|
1585 |
|
|
|
1586 |
|
|
|
1587 |
|
|
|
1588 |
|
|
#ifdef GetCSCHitsBefore500
|
1589 |
|
|
void TPTrackMuonSys::getCSCSegWkeyHalfStrip(const std::vector<CSCRecHit2D> &theseRecHits, Float_t &cStrp, Float_t &ckWG){
|
1590 |
|
|
|
1591 |
|
|
#ifdef m_debug
|
1592 |
|
|
cout << " Start of the function " << endl;
|
1593 |
|
|
#endif
|
1594 |
|
|
|
1595 |
|
|
Float_t m_cStrp = 999.0, m_ckWG = 999.;
|
1596 |
|
|
|
1597 |
|
|
Float_t strpSum =0.0, wkeySum = 0.0;
|
1598 |
|
|
Int_t nhits =0 ;
|
1599 |
|
|
Bool_t layer3 = false;
|
1600 |
|
|
Bool_t me11a = false;
|
1601 |
|
|
|
1602 |
|
|
for ( std::vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++) {
|
1603 |
|
|
CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
|
1604 |
|
|
Int_t mx_layer = idRH.layer();
|
1605 |
|
|
|
1606 |
|
|
if (idRH.ring() == 4) me11a = true;
|
1607 |
|
|
|
1608 |
|
|
/////////////////////////
|
1609 |
|
|
//
|
1610 |
|
|
// Get the strip number... ------> m_cStrp
|
1611 |
|
|
//
|
1612 |
|
|
/////////////////////////
|
1613 |
|
|
LocalPoint rhitlocal = (*iRH).localPosition();
|
1614 |
|
|
Float_t pWS = (*iRH).positionWithinStrip();
|
1615 |
|
|
// Find the strip containing this hit
|
1616 |
|
|
CSCRecHit2D::ChannelContainer hitstrips = (*iRH).channels();
|
1617 |
|
|
|
1618 |
|
|
Int_t nStrips = hitstrips.size();
|
1619 |
|
|
// Int_t centerid = nStrips/2 + 1;
|
1620 |
|
|
|
1621 |
|
|
if(nStrips == 3) m_cStrp = (int) (2.0*(hitstrips[1] + pWS - 0.5 ));
|
1622 |
|
|
else m_cStrp = (int) ( 2.0*(hitstrips[0] - pWS - 0.5 ));
|
1623 |
|
|
|
1624 |
|
|
Bool_t evenLayer = (mx_layer % 2 == 0);
|
1625 |
|
|
if ( evenLayer )m_cStrp -= 1;
|
1626 |
|
|
if ( (idRH.station() == 1) && (idRH.layer() != 3) && evenLayer ) m_cStrp += 1;
|
1627 |
|
|
//m_cStrp = hitstrips[centerid - 1];
|
1628 |
|
|
/////////////////////////
|
1629 |
|
|
//
|
1630 |
|
|
// Get the wireKey number...------> m_ckWG
|
1631 |
|
|
//
|
1632 |
|
|
/////////////////////////
|
1633 |
|
|
|
1634 |
|
|
CSCRecHit2D::ChannelContainer wiresg = (*iRH).wgroups();
|
1635 |
|
|
// m_ckWG = wiresg[0]-1;
|
1636 |
|
|
m_ckWG = wiresg[wiresg.size()/2]-1;//corrected from to wiresg[0] to [wiresg.size()/2]
|
1637 |
|
|
|
1638 |
|
|
if(mx_layer == 3){
|
1639 |
|
|
cStrp = m_cStrp;
|
1640 |
|
|
ckWG = m_ckWG;
|
1641 |
|
|
layer3 = true;
|
1642 |
|
|
}
|
1643 |
|
|
strpSum = strpSum + m_cStrp;
|
1644 |
|
|
wkeySum = wkeySum + m_ckWG;
|
1645 |
|
|
nhits = nhits + 1;
|
1646 |
|
|
}
|
1647 |
|
|
if(! layer3 && nhits != 0){
|
1648 |
|
|
cStrp = strpSum/nhits;
|
1649 |
|
|
ckWG = wkeySum/nhits;
|
1650 |
|
|
}
|
1651 |
|
|
if (me11a)cStrp = ((int)cStrp - 1)%32 + 1;
|
1652 |
|
|
}
|
1653 |
|
|
#else
|
1654 |
|
|
void TPTrackMuonSys::getCSCSegWkeyHalfStrip(const vector<CSCRecHit2D> &theseRecHits, Float_t &cStrp, Float_t &ckWG){
|
1655 |
|
|
Float_t strpSum = 0., wkeySum = 0.;
|
1656 |
|
|
Int_t nhits = 0; Bool_t me11a=false;
|
1657 |
|
|
for ( vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); iRH++,nhits++ ) {
|
1658 |
|
|
CSCDetId idRH = (CSCDetId)(*iRH).cscDetId();
|
1659 |
|
|
if (idRH.ring() == 4) me11a = true;
|
1660 |
|
|
Byte_t layer = idRH.layer();
|
1661 |
|
|
Float_t pWS = (*iRH).positionWithinStrip();
|
1662 |
|
|
Int_t m_cStrp = (Int_t) (2.0*(iRH->channels(1) + pWS - 0.5 ));
|
1663 |
|
|
if ( layer%2!=0 &&
|
1664 |
|
|
!( (idRH.station() == 1) && (idRH.layer() != 3) ) ) m_cStrp--;
|
1665 |
|
|
|
1666 |
|
|
if( layer == 3 ) {
|
1667 |
|
|
cStrp=m_cStrp;
|
1668 |
|
|
ckWG=iRH->hitWire()-1;
|
1669 |
|
|
nhits=1;
|
1670 |
|
|
break;
|
1671 |
|
|
}
|
1672 |
|
|
else {
|
1673 |
|
|
strpSum += m_cStrp;
|
1674 |
|
|
wkeySum += iRH->hitWire()-1;
|
1675 |
|
|
}
|
1676 |
|
|
#ifdef m_debug
|
1677 |
|
|
clog << "ME" << idRH.station() << idRH.ring() <<":" << endl
|
1678 |
|
|
<< "cstrips ("<< iRH->nStrips() <<"): " //should be always 3
|
1679 |
|
|
<< iRH->channels(0) << "," << iRH->channels(1) << "," << iRH->channels(2)
|
1680 |
|
|
<< "; cwire:" << iRH->hitWire() << endl;
|
1681 |
|
|
#endif
|
1682 |
|
|
}
|
1683 |
|
|
cStrp = strpSum/nhits;
|
1684 |
|
|
ckWG = wkeySum/nhits;
|
1685 |
|
|
if (me11a) cStrp = ( (Int_t) cStrp - 1)%32 + 1;
|
1686 |
|
|
#ifdef m_debug
|
1687 |
|
|
clog << "cStrip: "<< cStrp << "; cWire: " << ckWG << endl;
|
1688 |
|
|
#endif
|
1689 |
|
|
}
|
1690 |
|
|
#endif// end of GetCSCHitsBefore500
|
1691 |
|
|
|
1692 |
|
|
Bool_t TPTrackMuonSys::matchCSCSegWithLCT(edm::Handle<CSCCorrelatedLCTDigiCollection> mpclcts,
|
1693 |
|
|
CSCDetId & idCSC,
|
1694 |
|
|
Int_t TT,
|
1695 |
|
|
Float_t TrkPhi, Float_t TrkEta,
|
1696 |
|
|
Float_t c1, Float_t w1,
|
1697 |
|
|
CSCCorrelatedLCTDigiCollection::const_iterator &mpcItOut,
|
1698 |
|
|
CSCCorrelatedLCTDigiCollection::const_iterator &mpcHsWkOut,
|
1699 |
|
|
Bool_t *xMatch,
|
1700 |
|
|
Float_t *mDAngle,
|
1701 |
|
|
Float_t *diffTrkEta,
|
1702 |
|
|
Float_t *diffTrkPhi,
|
1703 |
|
|
Float_t *delHStrp,
|
1704 |
|
|
Float_t *delWkey
|
1705 |
|
|
)
|
1706 |
|
|
{
|
1707 |
|
|
/// Input
|
1708 |
|
|
// idCSC, halfstrip and wireKey
|
1709 |
|
|
|
1710 |
|
|
/// Output
|
1711 |
|
|
/// Whether there is a match based on halfstrip and wireKey
|
1712 |
|
|
/// or based on phi.
|
1713 |
|
|
/// also: minPhi, minDAngle;
|
1714 |
|
|
|
1715 |
|
|
for(Int_t i = 0; i < 2; i++){
|
1716 |
|
|
xMatch[i] = false;
|
1717 |
|
|
mDAngle[i] = 999.;
|
1718 |
|
|
diffTrkEta[i] = 999.;
|
1719 |
|
|
diffTrkPhi[i] = 999.;
|
1720 |
|
|
delHStrp[i] = 99999.;
|
1721 |
|
|
delWkey[i] = 99999.;
|
1722 |
|
|
}
|
1723 |
|
|
|
1724 |
|
|
Int_t ec = idCSC.endcap(), st = idCSC.station(), rg = idCSC.ring(), cham = idCSC.chamber();
|
1725 |
|
|
Bool_t me11a = false;
|
1726 |
|
|
if (rg == 4) me11a = true;
|
1727 |
|
|
|
1728 |
|
|
//// For the minimization:
|
1729 |
|
|
|
1730 |
|
|
for (CSCCorrelatedLCTDigiCollection::DigiRangeIterator detMPCUnitIt = mpclcts->begin(); detMPCUnitIt != mpclcts->end(); detMPCUnitIt++) {
|
1731 |
|
|
const CSCDetId& id = (*detMPCUnitIt).first;
|
1732 |
|
|
|
1733 |
|
|
if(ec != id.endcap())continue;
|
1734 |
|
|
if(st != id.station())continue;
|
1735 |
|
|
if(cham != id.chamber())continue;
|
1736 |
|
|
|
1737 |
|
|
Bool_t ed1 = (st == 1) && ((rg == 1 || rg == 4) && (id.ring() == 1 || id.ring() == 4));
|
1738 |
|
|
Bool_t ed2 = (st == 1) && ((rg == 2 && id.ring() == 2) || (rg == 3 && id.ring() == 3));
|
1739 |
|
|
Bool_t ed3 = (st != 1) && (rg == id.ring());
|
1740 |
|
|
Bool_t TMCSCMatch = (ed1 || ed2 || ed3);
|
1741 |
|
|
if(! TMCSCMatch)continue;
|
1742 |
|
|
|
1743 |
|
|
const CSCCorrelatedLCTDigiCollection::Range& MPCrange = (*detMPCUnitIt).second;
|
1744 |
|
|
for (CSCCorrelatedLCTDigiCollection::const_iterator mpcIt = MPCrange.first; mpcIt != MPCrange.second; mpcIt++) {
|
1745 |
|
|
Bool_t lct_valid = (*mpcIt).isValid();
|
1746 |
|
|
if(!lct_valid)continue;
|
1747 |
|
|
|
1748 |
|
|
Int_t station = id.station()-1;
|
1749 |
|
|
Int_t sector = id.triggerSector()-1;
|
1750 |
|
|
Int_t subSector = CSCTriggerNumbering::triggerSubSectorFromLabels(id);
|
1751 |
|
|
Int_t fpga = ( subSector ? subSector-1 : station+1 );
|
1752 |
|
|
Int_t endcap = id.endcap()-1;
|
1753 |
|
|
lclphidat lclPhi = srLUTs_[endcap][sector][fpga]->localPhi((*mpcIt).getStrip(),(*mpcIt).getPattern(),(*mpcIt).getQuality(),(*mpcIt).getBend() );
|
1754 |
|
|
gblphidat gblPhi = srLUTs_[endcap][sector][fpga]->globalPhiME( lclPhi.phi_local, (*mpcIt).getKeyWG(), id.triggerCscId() );
|
1755 |
|
|
gbletadat gblEta = srLUTs_[endcap][sector][fpga]->globalEtaME(lclPhi.phi_bend_local, lclPhi.phi_local,(*mpcIt).getKeyWG(), id.triggerCscId() );
|
1756 |
|
|
|
1757 |
|
|
UInt_t mpcphi = gblPhi.global_phi;
|
1758 |
|
|
UInt_t mpceta = gblEta.global_eta;
|
1759 |
|
|
double geta = theTriggerScales->getRegionalEtaScale(2)->getCenter(mpceta); //Type 2 is CSC
|
1760 |
|
|
double radphi = ((mpcphi)/4096.)*(62./180.)*M_PI; // cscphi in rad
|
1761 |
|
|
|
1762 |
|
|
double gphi = radphi + sector*M_PI/3.+ (14*M_PI/180.);//0.24434609;// Global Phi with respect to 0 degrees.
|
1763 |
|
|
if(sector == 5){
|
1764 |
|
|
if(radphi <=45*(M_PI/180.)) gphi = radphi + 315*M_PI/180.;
|
1765 |
|
|
else gphi = radphi - 45*M_PI/180.;
|
1766 |
|
|
}
|
1767 |
|
|
if(TrkPhi < 0)TrkPhi = TrkPhi + 2*M_PI;
|
1768 |
|
|
if(gphi < 0)gphi = gphi + 2*M_PI;
|
1769 |
|
|
Float_t DeltaAngle = sqrt(pow((TrkEta-geta),2) + pow((TrkPhi-gphi),2));
|
1770 |
|
|
|
1771 |
|
|
Int_t m_strip = (*mpcIt).getStrip(); // halfstrip that goes from 0 to 31
|
1772 |
|
|
if (me11a)m_strip = (m_strip-1)%32+1;
|
1773 |
|
|
Float_t m_keyWG = (*mpcIt).getKeyWG(); //
|
1774 |
|
|
Float_t m_delHStrp = c1 - m_strip;
|
1775 |
|
|
Float_t m_delWkey = w1 - m_keyWG;
|
1776 |
|
|
|
1777 |
|
|
if (me11a){ // the ganging of ME11a causes wraparound effects at the boundaries for delta strip
|
1778 |
|
|
if (m_delHStrp > 16) m_delHStrp -= 32;
|
1779 |
|
|
if (m_delHStrp < -16)m_delHStrp += 32;
|
1780 |
|
|
}
|
1781 |
|
|
|
1782 |
|
|
Float_t phiDiff = TrkPhi-gphi;
|
1783 |
|
|
if( fabs(phiDiff) < fabs(diffTrkPhi[0]) ){
|
1784 |
|
|
xMatch[0] = true;
|
1785 |
|
|
mDAngle[0] = DeltaAngle;
|
1786 |
|
|
diffTrkEta[0] = TrkEta-geta;
|
1787 |
|
|
diffTrkPhi[0] = phiDiff;
|
1788 |
|
|
delHStrp[0] = m_delHStrp;
|
1789 |
|
|
delWkey[0] = m_delWkey;
|
1790 |
|
|
mpcItOut = mpcIt;
|
1791 |
|
|
} // for the matching if statement...
|
1792 |
|
|
|
1793 |
|
|
if( (fabs(m_delHStrp) < fabs(delHStrp[1])) && (fabs(m_delWkey) < fabs(delWkey[1])) ){ // match strips at <=10 and wirekeys at <=5
|
1794 |
|
|
xMatch[1] = true;
|
1795 |
|
|
mDAngle[1] = DeltaAngle;
|
1796 |
|
|
diffTrkEta[1] = TrkEta-geta;
|
1797 |
|
|
diffTrkPhi[1] = TrkPhi-gphi;
|
1798 |
|
|
delHStrp[1] = m_delHStrp;
|
1799 |
|
|
delWkey[1] = m_delWkey;
|
1800 |
|
|
mpcHsWkOut = mpcIt;
|
1801 |
|
|
} // for the matching if statement...
|
1802 |
|
|
|
1803 |
|
|
#ifdef m_debug
|
1804 |
|
|
std::cout << "MPC E: " << id.endcap() << " R:" << id.ring() << " S: " << id.station() << " C: " << id.chamber()
|
1805 |
|
|
<< std::endl;
|
1806 |
|
|
#endif
|
1807 |
|
|
}
|
1808 |
|
|
}// end iteration over lcts_mpc_data
|
1809 |
|
|
return (xMatch[0] || xMatch[1]);
|
1810 |
|
|
}
|
1811 |
|
|
|
1812 |
|
|
void TPTrackMuonSys::chamberCandidates(Int_t station, Float_t feta, Float_t phi, std::vector <int> &coupleOfChambers){
|
1813 |
|
|
// yeah, hardcoded again...
|
1814 |
|
|
coupleOfChambers.clear();
|
1815 |
|
|
|
1816 |
|
|
Int_t ring = ringCandidate(station, feta, phi);
|
1817 |
|
|
if(ring != -9999){
|
1818 |
|
|
Float_t phi_zero = 0.;// check! the phi at the "edge" of Ch 1
|
1819 |
|
|
Float_t phi_const = 2.*M_PI/36.;
|
1820 |
|
|
Int_t first_chamber = 1, last_chamber = 36;
|
1821 |
|
|
if(1 != station && 1==ring){ // 18 chambers in the ring
|
1822 |
|
|
phi_const*=2;
|
1823 |
|
|
last_chamber /= 2;
|
1824 |
|
|
}
|
1825 |
|
|
if(phi < 0.) phi += 2*M_PI;
|
1826 |
|
|
|
1827 |
|
|
Float_t chamber_float = (phi - phi_zero)/phi_const;
|
1828 |
|
|
Int_t chamber_int = int(chamber_float);
|
1829 |
|
|
if (chamber_float - Float_t(chamber_int) -0.5 <0.){
|
1830 |
|
|
|
1831 |
|
|
if(0!=chamber_int ) coupleOfChambers.push_back(chamber_int);
|
1832 |
|
|
else coupleOfChambers.push_back(last_chamber);
|
1833 |
|
|
coupleOfChambers.push_back(chamber_int+1);
|
1834 |
|
|
|
1835 |
|
|
}else{
|
1836 |
|
|
coupleOfChambers.push_back(chamber_int+1);
|
1837 |
|
|
if(last_chamber!=chamber_int+1) coupleOfChambers.push_back(chamber_int+2);
|
1838 |
|
|
else coupleOfChambers.push_back(first_chamber);
|
1839 |
|
|
}
|
1840 |
|
|
}
|
1841 |
|
|
}
|
1842 |
|
|
|
1843 |
|
|
|
1844 |
|
|
Int_t TPTrackMuonSys::ringCandidate(Int_t station, Float_t feta, Float_t phi){
|
1845 |
|
|
// yeah, hardcoded again...
|
1846 |
|
|
|
1847 |
|
|
Int_t ring = -9999;
|
1848 |
|
|
|
1849 |
|
|
switch (station){
|
1850 |
|
|
case 1:
|
1851 |
|
|
if(fabs(feta)>=0.85 && fabs(feta)<1.18){//ME13
|
1852 |
|
|
ring = 3;
|
1853 |
|
|
}
|
1854 |
|
|
if(fabs(feta)>=1.18 && fabs(feta)<=1.5){//ME12 if(fabs(feta)>1.18 && fabs(feta)<1.7){//ME12
|
1855 |
|
|
ring = 2;
|
1856 |
|
|
}
|
1857 |
|
|
if(fabs(feta)>1.5 && fabs(feta)<2.45){//ME11
|
1858 |
|
|
ring = 1; //or 4;
|
1859 |
|
|
}
|
1860 |
|
|
break;
|
1861 |
|
|
case 2:
|
1862 |
|
|
if(fabs(feta)>0.95 && fabs(feta)<1.6){//ME22
|
1863 |
|
|
ring = 2;
|
1864 |
|
|
}
|
1865 |
|
|
if(fabs(feta)>1.55 && fabs(feta)<2.45){//ME21
|
1866 |
|
|
ring = 1;
|
1867 |
|
|
}
|
1868 |
|
|
break;
|
1869 |
|
|
case 3:
|
1870 |
|
|
if(fabs(feta)>1.08 && fabs(feta)<1.72){//ME32
|
1871 |
|
|
ring = 2;
|
1872 |
|
|
}
|
1873 |
|
|
if(fabs(feta)>1.69 && fabs(feta)<2.45){//ME31
|
1874 |
|
|
ring = 1;
|
1875 |
|
|
}
|
1876 |
|
|
break;
|
1877 |
|
|
case 4:
|
1878 |
|
|
if(fabs(feta)>1.78 && fabs(feta) <2.45){//ME41
|
1879 |
|
|
ring = 1;
|
1880 |
|
|
}
|
1881 |
|
|
if(fabs(feta)>1.15 && fabs(feta) <=1.78){//ME42
|
1882 |
|
|
ring = 2;
|
1883 |
|
|
}
|
1884 |
|
|
break;
|
1885 |
|
|
default:
|
1886 |
|
|
LogError("")<<"Invalid station: "<<station<<endl;
|
1887 |
|
|
break;
|
1888 |
|
|
}
|
1889 |
|
|
return ring;
|
1890 |
|
|
}
|
1891 |
|
|
|
1892 |
|
|
Short_t TPTrackMuonSys::thisChamberCandidate(Short_t station, Short_t ring, Float_t phi){
|
1893 |
|
|
|
1894 |
|
|
// double minDelPhi = 0.17; Int_t station, Int_t ring, Float_t phi
|
1895 |
|
|
|
1896 |
|
|
Float_t *MyPhiValues=NULL;
|
1897 |
|
|
//36 chambers
|
1898 |
|
|
if (station == 1) MyPhiValues = StationOnePhi;
|
1899 |
|
|
if (station == 2 && ring == 2) MyPhiValues = StationTwoTwoPhi;
|
1900 |
|
|
if (station == 3 && ring == 2) MyPhiValues = StationThreeTwoPhi;
|
1901 |
|
|
if (station == 4 && ring == 2) MyPhiValues = StationFourTwoPhi;
|
1902 |
|
|
//18 chambers
|
1903 |
|
|
if(station == 2 && ring == 1) MyPhiValues = StationTwoOnePhi;
|
1904 |
|
|
if(station == 3 && ring == 1) MyPhiValues = StationThreeOnePhi;
|
1905 |
|
|
if(station == 4 && ring == 1) MyPhiValues = StationFourOnePhi;
|
1906 |
|
|
|
1907 |
|
|
if ( MyPhiValues==NULL ) {
|
1908 |
|
|
LogError("")<<"Invalid station and ring: "<<station<<"/"<<ring<<endl;
|
1909 |
|
|
return 0;
|
1910 |
|
|
}
|
1911 |
|
|
|
1912 |
|
|
Int_t iCh=0;
|
1913 |
|
|
if(phi < 0.) phi = phi + 2*M_PI;
|
1914 |
|
|
|
1915 |
|
|
Short_t nVal = 36;
|
1916 |
|
|
if(station != 1 && ring == 1) nVal = 18;
|
1917 |
|
|
|
1918 |
|
|
double minDelPhi = 100000.;
|
1919 |
|
|
for (Short_t i = 0; i < nVal; i++){
|
1920 |
|
|
double dphi = deltaPhi(MyPhiValues[i], phi);
|
1921 |
|
|
if(fabs(dphi) < minDelPhi){
|
1922 |
|
|
minDelPhi = fabs(dphi);
|
1923 |
|
|
iCh = i+2;
|
1924 |
|
|
}
|
1925 |
|
|
}
|
1926 |
|
|
if(iCh > nVal)iCh = 1;
|
1927 |
|
|
return iCh;
|
1928 |
|
|
}
|
1929 |
|
|
|
1930 |
|
|
|
1931 |
|
|
void TPTrackMuonSys::fillChamberPosition(){
|
1932 |
|
|
TVector3 x(0,0,1);
|
1933 |
|
|
for (Int_t i = 0; i < 36; i++){
|
1934 |
|
|
StationOnePhi[i] = 0.0;
|
1935 |
|
|
StationTwoTwoPhi[i] = 0.0;
|
1936 |
|
|
StationThreeTwoPhi[i] = 0.0;
|
1937 |
|
|
StationFourTwoPhi[i] = 0.0;
|
1938 |
|
|
if(i < 18){
|
1939 |
|
|
StationTwoOnePhi[i] = 0.0;
|
1940 |
|
|
StationThreeOnePhi[i] = 0.0;
|
1941 |
|
|
StationFourOnePhi[i] = 0.0;
|
1942 |
|
|
}
|
1943 |
|
|
}
|
1944 |
|
|
|
1945 |
|
|
/////////////////////////////////
|
1946 |
|
|
|
1947 |
|
|
TVector3 pp(180.5,0,0);
|
1948 |
|
|
for (Int_t i = 0; i < 36; i++){
|
1949 |
|
|
pp.Rotate(2*M_PI/36,x);
|
1950 |
|
|
StationOnePhi[i] = pp.Phi();
|
1951 |
|
|
if(StationOnePhi[i] < 0)StationOnePhi[i] = StationOnePhi[i] + 2*M_PI;
|
1952 |
|
|
#ifdef m_debug
|
1953 |
|
|
std::cout << " PHI(1-" << i << ")" << StationOnePhi[i];
|
1954 |
|
|
#endif
|
1955 |
|
|
}
|
1956 |
|
|
std::cout << std::endl;
|
1957 |
|
|
|
1958 |
|
|
TVector3 pp1(241.73,0,0);
|
1959 |
|
|
pp1.Rotate(M_PI/36 ,x);
|
1960 |
|
|
for (Int_t i = 0; i < 18; i++){
|
1961 |
|
|
pp1.Rotate(2*M_PI/18,x);
|
1962 |
|
|
StationTwoOnePhi[i] = pp1.Phi();
|
1963 |
|
|
if(StationTwoOnePhi[i] < 0)StationTwoOnePhi[i] = StationTwoOnePhi[i] + 2*M_PI;
|
1964 |
|
|
#ifdef m_debug
|
1965 |
|
|
std::cout << " PHI(2/1-" << i << ")" << StationTwoOnePhi[i];
|
1966 |
|
|
#endif
|
1967 |
|
|
}
|
1968 |
|
|
std::cout << std::endl;
|
1969 |
|
|
|
1970 |
|
|
TVector3 pp2(707.56,0,0);
|
1971 |
|
|
for (Int_t i = 0; i < 36; i++){
|
1972 |
|
|
pp2.Rotate(2*M_PI/36,x);
|
1973 |
|
|
StationTwoTwoPhi[i] = pp2.Phi();
|
1974 |
|
|
if(StationTwoTwoPhi[i] < 0)StationTwoTwoPhi[i] = StationTwoTwoPhi[i] + 2*M_PI;
|
1975 |
|
|
#ifdef m_debug
|
1976 |
|
|
std::cout << " PHI(2/2-" << i << ")" << StationTwoTwoPhi[i];
|
1977 |
|
|
#endif
|
1978 |
|
|
}
|
1979 |
|
|
std::cout << std::endl;
|
1980 |
|
|
|
1981 |
|
|
TVector3 pp3(251.74, 0.0, 0.0);
|
1982 |
|
|
pp3.Rotate(M_PI/36,x);
|
1983 |
|
|
//pp3.Rotate(0.0511,x);
|
1984 |
|
|
for (Int_t i = 0; i < 18; i++){
|
1985 |
|
|
pp3.Rotate(2*M_PI/18,x);
|
1986 |
|
|
StationThreeOnePhi[i] = pp3.Phi();
|
1987 |
|
|
if(StationThreeOnePhi[i] < 0)StationThreeOnePhi[i] = StationThreeOnePhi[i] + 2*M_PI;
|
1988 |
|
|
#ifdef m_debug
|
1989 |
|
|
std::cout << " PHI(3/1-" << i << ")" << StationThreeOnePhi[i];
|
1990 |
|
|
#endif
|
1991 |
|
|
}
|
1992 |
|
|
std::cout << std::endl;
|
1993 |
|
|
|
1994 |
|
|
TVector3 pp4(525.55,0.0,0);
|
1995 |
|
|
for (Int_t i = 0; i < 36; i++){
|
1996 |
|
|
pp4.Rotate(2*M_PI/36,x);
|
1997 |
|
|
StationThreeTwoPhi[i] = pp4.Phi();
|
1998 |
|
|
if(StationThreeTwoPhi[i] < 0)StationThreeTwoPhi[i] = StationThreeTwoPhi[i] + 2*M_PI;
|
1999 |
|
|
#ifdef m_debug
|
2000 |
|
|
std::cout << " PHI(3/2-" << i << ")" << StationThreeTwoPhi[i];
|
2001 |
|
|
#endif
|
2002 |
|
|
}
|
2003 |
|
|
std::cout << std::endl;
|
2004 |
|
|
|
2005 |
|
|
TVector3 pp5(261.7,0.,0.);
|
2006 |
|
|
pp5.Rotate(M_PI/36,x);
|
2007 |
|
|
for (Int_t i = 0; i < 18; i++){
|
2008 |
|
|
pp5.Rotate(2*M_PI/18,x);
|
2009 |
|
|
StationFourOnePhi[i] = pp5.Phi();
|
2010 |
|
|
if(StationFourOnePhi[i] < 0)StationFourOnePhi[i] = StationFourOnePhi[i] + 2*M_PI;
|
2011 |
|
|
#ifdef m_debug
|
2012 |
|
|
std::cout << " PHI(4/1-" << i << ")" << StationFourOnePhi[i];
|
2013 |
|
|
#endif
|
2014 |
|
|
}
|
2015 |
|
|
std::cout << std::endl;
|
2016 |
|
|
}
|
2017 |
|
|
|
2018 |
|
|
///////////////////////
|
2019 |
|
|
// to get the track position info at a particular rho
|
2020 |
|
|
TrajectoryStateOnSurface TPTrackMuonSys::cylExtrapTrkSam(reco::TrackRef track, double rho)
|
2021 |
|
|
{
|
2022 |
|
|
Cylinder::PositionType pos(0, 0, 0);
|
2023 |
|
|
Cylinder::RotationType rot;
|
2024 |
|
|
Cylinder::CylinderPointer myCylinder = Cylinder::build(pos, rot, rho);
|
2025 |
|
|
try{
|
2026 |
|
|
FreeTrajectoryState recoStart = freeTrajStateMuon(track);
|
2027 |
|
|
TrajectoryStateOnSurface recoProp = propagatorAlong->propagate(recoStart, *myCylinder);
|
2028 |
|
|
if (!recoProp.isValid()) {
|
2029 |
|
|
recoProp = propagatorOpposite->propagate(recoStart, *myCylinder);
|
2030 |
|
|
}
|
2031 |
|
|
return recoProp;
|
2032 |
|
|
}
|
2033 |
|
|
catch(cms::Exception){
|
2034 |
|
|
edm::LogError("")<<"invalid track extrapolation to cylinder"<<endl;
|
2035 |
|
|
TrajectoryStateOnSurface recoProp;
|
2036 |
|
|
return recoProp;
|
2037 |
|
|
}
|
2038 |
|
|
}
|
2039 |
|
|
|
2040 |
|
|
// to get track position at a particular (xy) plane given its z
|
2041 |
|
|
TrajectoryStateOnSurface TPTrackMuonSys::surfExtrapTrkSam(reco::TrackRef track, double z)
|
2042 |
|
|
{
|
2043 |
|
|
Plane::PositionType pos(0, 0, z);
|
2044 |
|
|
Plane::RotationType rot;
|
2045 |
|
|
Plane::PlanePointer myPlane = Plane::build(pos, rot);
|
2046 |
|
|
try{
|
2047 |
|
|
FreeTrajectoryState recoStart = freeTrajStateMuon(track);
|
2048 |
|
|
TrajectoryStateOnSurface recoProp = propagatorAlong->propagate(recoStart, *myPlane);
|
2049 |
|
|
if (!recoProp.isValid()) {
|
2050 |
|
|
recoProp = propagatorOpposite->propagate(recoStart, *myPlane);
|
2051 |
|
|
}
|
2052 |
|
|
return recoProp;
|
2053 |
|
|
}
|
2054 |
|
|
catch(cms::Exception){
|
2055 |
|
|
edm::LogError("")<<"invalid track extrapolation to plane"<<endl;
|
2056 |
|
|
TrajectoryStateOnSurface recoProp;
|
2057 |
|
|
return recoProp;
|
2058 |
|
|
}
|
2059 |
|
|
}
|
2060 |
|
|
|
2061 |
|
|
FreeTrajectoryState TPTrackMuonSys::freeTrajStateMuon(reco::TrackRef track)
|
2062 |
|
|
{
|
2063 |
|
|
GlobalPoint innerPoint(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
|
2064 |
|
|
GlobalVector innerVec (track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
|
2065 |
|
|
|
2066 |
|
|
GlobalTrajectoryParameters gtPars(innerPoint, innerVec, track->charge(), &*theBField);
|
2067 |
|
|
|
2068 |
|
|
//FreeTrajectoryState recoStart(innerPoint, innerVec, track->charge(), &*theBField);
|
2069 |
|
|
//return recoStart;
|
2070 |
|
|
|
2071 |
|
|
AlgebraicSymMatrix66 cov;
|
2072 |
|
|
cov *= 1e-20;
|
2073 |
|
|
|
2074 |
|
|
CartesianTrajectoryError tCov(cov);
|
2075 |
|
|
|
2076 |
|
|
return (cov.kRows == 6 ? FreeTrajectoryState(gtPars, tCov) : FreeTrajectoryState(gtPars)) ;
|
2077 |
|
|
}
|
2078 |
|
|
|
2079 |
|
|
|
2080 |
|
|
Bool_t TPTrackMuonSys::GetDecayChains(TrackingParticleRef tpr, HepMC::GenEvent *HepGenEvent, ULong64_t &truth_type, Int_t & truth_thesamewith, vector<vector< vector<Int_t> > > & ExistingSimChains) {
|
2081 |
|
|
Bool_t IsPileup=false;
|
2082 |
|
|
truth_thesamewith=-1;
|
2083 |
|
|
vector<TheTrackType> types;
|
2084 |
|
|
for (vector<SimTrack>::const_iterator g4Track_iter = tpr->g4Track_begin(); g4Track_iter != tpr->g4Track_end(); ++g4Track_iter ) {
|
2085 |
|
|
//g4Track loop begin
|
2086 |
|
|
DChain.clear();SimChains.clear();
|
2087 |
|
|
const SimTrack *thisTrk=&(*g4Track_iter);
|
2088 |
|
|
SimTrackDaughtersTree( thisTrk,tpr );
|
2089 |
|
|
Bool_t ChainEnd; TrackingParticleRef tpr_tmp=tpr;
|
2090 |
|
|
do {
|
2091 |
|
|
ChainEnd=true;
|
2092 |
|
|
if ( !thisTrk->noVertex() ) {
|
2093 |
|
|
TrackingVertexRef tvr=tpr_tmp->parentVertex();
|
2094 |
|
|
for ( TrackingParticleRefVector::iterator parenttp=tvr->sourceTracks_begin();parenttp!=tvr->sourceTracks_end();parenttp++ ) {
|
2095 |
|
|
for (vector<SimTrack>::const_iterator g4Trk_iter = (*parenttp)->g4Track_begin() ; g4Trk_iter != (*parenttp)->g4Track_end(); ++g4Trk_iter )
|
2096 |
|
|
if ( SVC[thisTrk->vertIndex()].parentIndex()==Int_t(g4Trk_iter->trackId()) && g4Trk_iter->eventId().rawId()==thisTrk->eventId().rawId()) {
|
2097 |
|
|
thisTrk=&(*g4Trk_iter);tpr_tmp=*parenttp;
|
2098 |
|
|
vector<const SimTrack *>::iterator SavedSimTrk_iter=find(SavedSimTrk.begin(),SavedSimTrk.end(),thisTrk);
|
2099 |
|
|
if (SavedSimTrk_iter==SavedSimTrk.end()) {
|
2100 |
|
|
DChain.push_back( MCParticlesList.size() );
|
2101 |
|
|
SavedSimTrk.push_back(thisTrk);
|
2102 |
|
|
MCParticlesList.push_back( MCParticleInfo_Creator(thisTrk,tpr_tmp) );
|
2103 |
|
|
}
|
2104 |
|
|
else DChain.push_back( FindSimTrackInMCParticlesList(SavedSimTrk_iter-SavedSimTrk.begin()));
|
2105 |
|
|
ChainEnd=false;
|
2106 |
|
|
break;
|
2107 |
|
|
}
|
2108 |
|
|
if (!ChainEnd) break;
|
2109 |
|
|
}
|
2110 |
|
|
}
|
2111 |
|
|
}while (!ChainEnd);
|
2112 |
|
|
for (vector< vector<Int_t> >::iterator SimChains_iter = SimChains.begin(); SimChains_iter != SimChains.end(); ++SimChains_iter )
|
2113 |
|
|
SimChains_iter->insert(SimChains_iter->begin(),DChain.rbegin(),DChain.rend());
|
2114 |
|
|
DChain.clear();
|
2115 |
|
|
|
2116 |
|
|
//HepMC Particles
|
2117 |
|
|
HepMCChains.clear();
|
2118 |
|
|
if (!thisTrk->noGenpart() ) {
|
2119 |
|
|
HepMC::GenParticle *genPar=HepGenEvent->barcode_to_particle(thisTrk->genpartIndex());
|
2120 |
|
|
if (genPar!=NULL) {
|
2121 |
|
|
vector<const SimTrack *>::iterator SavedSimTrk_iter=find(SavedSimTrk.begin(),SavedSimTrk.end(),thisTrk);
|
2122 |
|
|
if (SavedSimTrk_iter!=SavedSimTrk.end()) MCParticlesList[FindSimTrackInMCParticlesList(SavedSimTrk_iter-SavedSimTrk.begin())].IsParticleFromGenerator=true;
|
2123 |
|
|
else LogError("CodeWrong")<<"Cannot find the simulated track in saved sim tracks.";
|
2124 |
|
|
HepMCParentTree( genPar );
|
2125 |
|
|
}
|
2126 |
|
|
else LogWarning("RefNull")<<"Either SimTrack::genpartIndex() or HepMC::GenParticle::barcode is wrong. Pilup track?";
|
2127 |
|
|
}
|
2128 |
|
|
|
2129 |
|
|
//merge the HepMC and SimTrack Decay Chains
|
2130 |
|
|
for (vector< vector<Int_t> >::iterator SimChains_iter = SimChains.begin(); SimChains_iter != SimChains.end(); ++SimChains_iter )
|
2131 |
|
|
if ( !HepMCChains.empty() )
|
2132 |
|
|
for (vector< vector<Int_t> >::iterator HepMCChains_iter = HepMCChains.begin(); HepMCChains_iter != HepMCChains.end(); ++HepMCChains_iter ) {
|
2133 |
|
|
vector<Int_t> thisChain(HepMCChains_iter->rbegin(),HepMCChains_iter->rend());
|
2134 |
|
|
thisChain.insert(thisChain.end(),SimChains_iter->begin(),SimChains_iter->end());
|
2135 |
|
|
IsPileup=SaveAndClassify(thisChain,types, truth_thesamewith, ExistingSimChains);
|
2136 |
|
|
}
|
2137 |
|
|
else IsPileup=SaveAndClassify( *SimChains_iter,types, truth_thesamewith, ExistingSimChains );
|
2138 |
|
|
}//g4Track loop end
|
2139 |
|
|
for (vector <TheTrackType>::iterator type_iter=types.begin();type_iter!=types.end();type_iter++)
|
2140 |
|
|
truth_type=truth_type*100+Long64_t(*type_iter);
|
2141 |
|
|
return IsPileup;
|
2142 |
|
|
}
|
2143 |
|
|
|
2144 |
|
|
void TPTrackMuonSys::SimTrackDaughtersTree(const SimTrack * thisTrk, TrackingParticleRef tpr)
|
2145 |
|
|
{
|
2146 |
|
|
// Find MC Truth Segment - the offical one use chi2 to match simtrk (MuonIdTruthInfo.cc) and it won't know the decay in flight segment truth
|
2147 |
|
|
// The particle type of the hit may differ from the particle type of the SimTrack with id trackId().
|
2148 |
|
|
// This happends if the hit was created by a secondary track(e.g. a delta ray) originating from the trackId() and not existing as aseparate SimTrack.
|
2149 |
|
|
// ( particle type match notice is from haiyun.teng@cern.ch )
|
2150 |
|
|
Bool_t ChainEnd=true;
|
2151 |
|
|
//To avoid duplicate particle saving
|
2152 |
|
|
vector<const SimTrack *>::iterator SavedSimTrk_iter=find(SavedSimTrk.begin(),SavedSimTrk.end(),thisTrk);
|
2153 |
|
|
if (SavedSimTrk_iter==SavedSimTrk.end()) {
|
2154 |
|
|
DChain.push_back( MCParticlesList.size() );
|
2155 |
|
|
SavedSimTrk.push_back(thisTrk);
|
2156 |
|
|
MCParticlesList.push_back( MCParticleInfo_Creator(thisTrk,tpr) );
|
2157 |
|
|
}
|
2158 |
|
|
else DChain.push_back( FindSimTrackInMCParticlesList(SavedSimTrk_iter-SavedSimTrk.begin()) );
|
2159 |
|
|
|
2160 |
|
|
for ( TrackingVertexRefVector::iterator tvr=tpr->decayVertices().begin();tvr!=tpr->decayVertices().end();tvr++ )
|
2161 |
|
|
for ( TrackingParticleRefVector::iterator daughtertp=(*tvr)->daughterTracks_begin();daughtertp!=(*tvr)->daughterTracks_end();daughtertp++ )
|
2162 |
|
|
for (vector<SimTrack>::const_iterator g4Trk_iter = (*daughtertp)->g4Track_begin() ; g4Trk_iter != (*daughtertp)->g4Track_end(); ++g4Trk_iter )
|
2163 |
|
|
if ( SVC[g4Trk_iter->vertIndex()].parentIndex()==Int_t(thisTrk->trackId()) && g4Trk_iter->eventId().rawId()==thisTrk->eventId().rawId()) {
|
2164 |
|
|
ChainEnd=false;
|
2165 |
|
|
SimTrackDaughtersTree( &(*g4Trk_iter), *daughtertp );
|
2166 |
|
|
}
|
2167 |
|
|
if (ChainEnd) SimChains.push_back(DChain);
|
2168 |
|
|
DChain.pop_back();
|
2169 |
|
|
}
|
2170 |
|
|
|
2171 |
|
|
void TPTrackMuonSys::HepMCParentTree(HepMC::GenParticle *genPar) {
|
2172 |
|
|
HepMC::GenVertex *thisVtx = genPar->production_vertex();
|
2173 |
|
|
Bool_t ChainEnd=true;
|
2174 |
|
|
if (thisVtx) {
|
2175 |
|
|
for (HepMC::GenVertex::particles_in_const_iterator pgenD = thisVtx->particles_in_const_begin(); pgenD != thisVtx->particles_in_const_end(); ++pgenD)
|
2176 |
|
|
if ((*pgenD)->pdg_id()!=92) {//Pythia special code for string, we only care about the particles after hadronization
|
2177 |
|
|
ChainEnd=false;
|
2178 |
|
|
vector<HepMC::GenParticle *>::iterator SavedHepPar_iter=find(SavedHepPar.begin(),SavedHepPar.end(),*pgenD);
|
2179 |
|
|
if (SavedHepPar_iter==SavedHepPar.end())
|
2180 |
|
|
{
|
2181 |
|
|
DChain.push_back(MCParticlesList.size());
|
2182 |
|
|
SavedHepPar.push_back(*pgenD);
|
2183 |
|
|
MCParticlesList.push_back( MCParticleInfo_Creator( (*pgenD) ) );
|
2184 |
|
|
}
|
2185 |
|
|
else DChain.push_back(FindHepMCInMCParticlesList(SavedHepPar_iter-SavedHepPar.begin()));
|
2186 |
|
|
HepMCParentTree(*pgenD);
|
2187 |
|
|
DChain.pop_back();
|
2188 |
|
|
}
|
2189 |
|
|
}
|
2190 |
|
|
if (ChainEnd) HepMCChains.push_back(DChain);
|
2191 |
|
|
}
|
2192 |
|
|
|
2193 |
|
|
Bool_t TPTrackMuonSys::SaveAndClassify(vector<Int_t> &Chain, vector<TheTrackType> &types, Int_t &truth_thesamewith, vector< vector< vector<Int_t> > > &ExistingSimChains) {
|
2194 |
|
|
//Find out if another track is just a decay product or mother particle of this track
|
2195 |
|
|
truth_thesamewith=-1;
|
2196 |
|
|
Bool_t truth_isPileup=false;
|
2197 |
|
|
for ( vector< vector< vector<Int_t> > >::const_iterator atrack=ExistingSimChains.begin(); atrack!=ExistingSimChains.end(); atrack++ ) {
|
2198 |
|
|
for ( vector< vector<Int_t> >::const_iterator adecaychain=atrack->begin(); adecaychain!=atrack->end(); adecaychain++ )
|
2199 |
|
|
if ( IstheSameDChain(Chain,*adecaychain) ) {
|
2200 |
|
|
truth_thesamewith=atrack-ExistingSimChains.begin();
|
2201 |
|
|
break;
|
2202 |
|
|
}
|
2203 |
|
|
if ( truth_thesamewith>-1 ) break;
|
2204 |
|
|
}
|
2205 |
|
|
|
2206 |
|
|
//Save
|
2207 |
|
|
ExistingSimChains.back().push_back(Chain);
|
2208 |
|
|
|
2209 |
|
|
//Classification
|
2210 |
|
|
TheTrackType type=Classify(Chain);
|
2211 |
|
|
if ( !MCParticlesList[Chain[0]].IsParticleFromGenerator ) truth_isPileup=true;
|
2212 |
|
|
#ifdef jz_debug
|
2213 |
|
|
// if ( Int_t(type)<2||Int_t(type)>100|| truth_isPileup ) {
|
2214 |
|
|
cerr<<"======================================================="<<endl;
|
2215 |
|
|
for (vector<Int_t>::reverse_iterator iter = Chain.rbegin(); iter != Chain.rend(); iter++)
|
2216 |
|
|
cerr<<"("<<MCParticlesList[*iter].pdgId<<","<<MCParticlesList[*iter].DoesParticleHaveMuonHit<<") <--|";
|
2217 |
|
|
cerr<<endl;
|
2218 |
|
|
cerr<<"MuTagpdgID:"<<MuTagtracktruth_id<<"; pdgID:"<<tracktruth_id;
|
2219 |
|
|
cerr<<"; type is "<<Int_t(type)<<"; pileup: "<<Int_t(truth_isPileup)<<endl
|
2220 |
|
|
<<"======================================================="<<endl;
|
2221 |
|
|
// }
|
2222 |
|
|
#endif
|
2223 |
|
|
if ( types.empty() ) types.push_back(type);
|
2224 |
|
|
else if (type!=Others) {
|
2225 |
|
|
if ( find(types.begin(),types.end(),type)==types.end() ) {
|
2226 |
|
|
vector<TheTrackType>::iterator DeterminedAsOthers=find(types.begin(),types.end(),Others);
|
2227 |
|
|
if ( DeterminedAsOthers!=types.end() ) *DeterminedAsOthers=type;
|
2228 |
|
|
else {
|
2229 |
|
|
vector<TheTrackType>::iterator DeterminedAsNoMuSysHit=find(types.begin(),types.end(),Others);
|
2230 |
|
|
if ( DeterminedAsNoMuSysHit!=types.end() ) *DeterminedAsOthers=type;
|
2231 |
|
|
else types.push_back(type);
|
2232 |
|
|
}
|
2233 |
|
|
}
|
2234 |
|
|
}
|
2235 |
|
|
return truth_isPileup;
|
2236 |
|
|
}
|
2237 |
|
|
|
2238 |
|
|
inline TPTrackMuonSys::ParticleType TPTrackMuonSys::ParticleCata(Int_t pid)
|
2239 |
|
|
{
|
2240 |
|
|
pid=pid>0?pid:pid*-1;
|
2241 |
|
|
if (pid==13) return Muon;
|
2242 |
|
|
if (pid==443) return JPsi;
|
2243 |
|
|
if (pid==23) return Z;
|
2244 |
|
|
if (pid==24) return W;
|
2245 |
|
|
if ((pid>110&&pid<900)||(pid>10000))
|
2246 |
|
|
{
|
2247 |
|
|
pid=pid%1000;
|
2248 |
|
|
if (pid<400) return LightMeson;
|
2249 |
|
|
if (pid>400&&pid<440) return CharmedMeson;
|
2250 |
|
|
if (pid>440&&pid<500) return ccbarMeson;
|
2251 |
|
|
if (pid>500&&pid<550) return BottomMeson;
|
2252 |
|
|
if (pid>550&&pid<600) return bbarMeson;
|
2253 |
|
|
}
|
2254 |
|
|
if (pid>1111&&pid<3350&&(pid%100)/10>0) return LightBaryon;
|
2255 |
|
|
if (pid>4111&&pid<4450&&(pid%100)/10>0) return CharmedBaryon;
|
2256 |
|
|
if (pid>5111&&pid<5560&&(pid%100)/10>0) return BottomBaryon;
|
2257 |
|
|
if (pid>1000&&pid<6000&&(pid%100)/10==0) return DiQuarks;
|
2258 |
|
|
if (pid>10&&pid<19) return Lepton;
|
2259 |
|
|
return Other;
|
2260 |
|
|
}
|
2261 |
|
|
|
2262 |
|
|
TPTrackMuonSys::TheTrackType TPTrackMuonSys::Classify(vector<Int_t> &Chain) {
|
2263 |
|
|
Int_t MuPos=-1;
|
2264 |
|
|
for (vector<Int_t>::reverse_iterator iter = Chain.rbegin(); iter != Chain.rend(); iter++) {
|
2265 |
|
|
ParticleType ParType=ParticleCata(MCParticlesList[*iter].pdgId);
|
2266 |
|
|
if (ParType==Muon&&MuPos<0) {//only care of the last muon
|
2267 |
|
|
MuPos=*iter;
|
2268 |
|
|
if ( !MCParticlesList[MuPos].DoesParticleHaveMuonHit ) return NoMuSysHit;
|
2269 |
|
|
continue;
|
2270 |
|
|
}
|
2271 |
|
|
if (MuPos>=0&&(ParType==W||ParType==Z)) {
|
2272 |
|
|
if ( MCParticlesList[MuPos].IsParticleFromGenerator ) {
|
2273 |
|
|
if (ParType==W) return PromptMuFromW;
|
2274 |
|
|
else return PromptMuFromZ;
|
2275 |
|
|
}
|
2276 |
|
|
else return NotPromptMufromWZ;//should never happen
|
2277 |
|
|
}
|
2278 |
|
|
if (MuPos>=0&&(ParType==JPsi)) return PromptMuFromJPsi;
|
2279 |
|
|
if (MuPos<0&&ParType>=LightMeson&&ParType<=DiQuarks) {
|
2280 |
|
|
if ( MCParticlesList[*iter].DoesParticleHaveMuonHit ) return PunchThrough;
|
2281 |
|
|
else return NoMuSysHit;
|
2282 |
|
|
}
|
2283 |
|
|
if (MuPos>=0&&ParType>=LightMeson&&ParType<=BottomBaryon) {
|
2284 |
|
|
if ( MCParticlesList[MuPos].IsParticleFromGenerator||MCParticlesList[MuPos].IsParticleBornInsideOfARegion ) {//inside pixel detector
|
2285 |
|
|
if (ParType==LightMeson) return PromptMuFromLightMeson;
|
2286 |
|
|
if (ParType>LightMeson&&ParType<LightBaryon) return PromptMuFromHeavyMeson;
|
2287 |
|
|
if (ParType==LightBaryon) return PromptMuFromLightBaryon;
|
2288 |
|
|
if (ParType>LightBaryon&&ParType<=BottomBaryon) return PromptMuFromHeavyBaryon;
|
2289 |
|
|
}
|
2290 |
|
|
if ( MCParticlesList[*iter].DoesParticleHaveMuonHit ) return PunchThroughAndDecayInFlight;
|
2291 |
|
|
else {
|
2292 |
|
|
if (ParType==LightMeson) return DecayInFlightFromLightMeson;
|
2293 |
|
|
if (ParType>LightMeson&&ParType<LightBaryon) return DecayInFlightFromHeavyMeson;
|
2294 |
|
|
if (ParType==LightBaryon) return DecayInFlightFromLightBaryon;
|
2295 |
|
|
if (ParType>LightBaryon&&ParType<=BottomBaryon) return DecayInFlightFromHeavyBaryon;
|
2296 |
|
|
}
|
2297 |
|
|
}
|
2298 |
|
|
}
|
2299 |
|
|
if (MuPos>=0) return PromptMuFromOthers;
|
2300 |
|
|
else return Others;
|
2301 |
|
|
}
|
2302 |
|
|
|
2303 |
|
|
Bool_t TPTrackMuonSys::IstheSameDChain(const vector<Int_t> &Chain1,const vector<Int_t> &Chain2) {//whether two chains include each other
|
2304 |
|
|
Bool_t ChainIncluded=false;
|
2305 |
|
|
vector<Int_t>::const_iterator Chain1_Particle = Chain1.begin(),Chain2_Particle = Chain2.begin();
|
2306 |
|
|
for (; Chain2_Particle != Chain2.end()&&Chain1_Particle != Chain1.end(); Chain2_Particle++) {
|
2307 |
|
|
if (ChainIncluded&&*Chain1_Particle!=*Chain2_Particle) ChainIncluded=false;
|
2308 |
|
|
if (Chain1.front() == *Chain2_Particle) {
|
2309 |
|
|
ChainIncluded=true;
|
2310 |
|
|
Chain1_Particle = Chain1.begin();
|
2311 |
|
|
}
|
2312 |
|
|
if (ChainIncluded) Chain1_Particle++;
|
2313 |
|
|
}
|
2314 |
|
|
if (!ChainIncluded) {
|
2315 |
|
|
Chain2_Particle = Chain2.begin(); Chain1_Particle = Chain1.begin();
|
2316 |
|
|
for (; Chain2_Particle != Chain2.end()&&Chain1_Particle != Chain1.end(); Chain1_Particle++) {
|
2317 |
|
|
if (ChainIncluded&&*Chain1_Particle!=*Chain2_Particle) ChainIncluded=false;
|
2318 |
|
|
if (Chain2.front() == *Chain1_Particle) {
|
2319 |
|
|
Chain2_Particle = Chain2.begin();
|
2320 |
|
|
ChainIncluded=true;
|
2321 |
|
|
}
|
2322 |
|
|
if (ChainIncluded) Chain2_Particle++;
|
2323 |
|
|
}
|
2324 |
|
|
}
|
2325 |
|
|
return ChainIncluded;
|
2326 |
|
|
}
|
2327 |
|
|
|
2328 |
|
|
TPTrackMuonSys::MCParticleInfo TPTrackMuonSys::MCParticleInfo_Creator( const SimTrack * thisTrk, TrackingParticleRef tpr ) {
|
2329 |
|
|
MCParticleInfo TBA;
|
2330 |
|
|
TBA.IsThisFromSimTrk=true;
|
2331 |
|
|
TBA.IsParticleFromGenerator=false;TBA.DoesParticleHaveMuonHit=false;
|
2332 |
|
|
TBA.IsParticleBornInsideOfARegion=false;
|
2333 |
|
|
TBA.IsPileup=false;
|
2334 |
|
|
TBA.pdgId=thisTrk->type();
|
2335 |
|
|
for ( vector<PSimHit>::const_iterator g4Hit_iter=tpr->pSimHit_begin();g4Hit_iter!=tpr->pSimHit_end();g4Hit_iter++ )
|
2336 |
|
|
if ( g4Hit_iter->trackId()==thisTrk->trackId() && g4Hit_iter->eventId().rawId()==thisTrk->eventId().rawId() && g4Hit_iter->particleType() == thisTrk->type() ) {
|
2337 |
|
|
DetId DetectorId( g4Hit_iter->detUnitId() );
|
2338 |
|
|
if ( DetectorId.det() == DetId::Muon ) {
|
2339 |
|
|
TBA.DoesParticleHaveMuonHit=true;
|
2340 |
|
|
break;
|
2341 |
|
|
}
|
2342 |
|
|
}
|
2343 |
|
|
if (!thisTrk->noVertex()) {
|
2344 |
|
|
SimVertex thisVtx=SVC[thisTrk->vertIndex()];
|
2345 |
|
|
//if ( (thisVtx.position().Perp2()<161604.&&deltaZ<568.)||(deltaRPhi2>82024.96&&deltaRPhi2<161604.&&deltaZ<666.)) //inside HCAL
|
2346 |
|
|
if ( thisVtx.position().Perp2()<100&&
|
2347 |
|
|
fabs(thisVtx.position().z())<30 ) //inside pixel detector
|
2348 |
|
|
TBA.IsParticleBornInsideOfARegion=true;
|
2349 |
|
|
}
|
2350 |
|
|
else TBA.IsPileup=true;
|
2351 |
|
|
return TBA;
|
2352 |
|
|
}
|
2353 |
|
|
|
2354 |
|
|
//deadzone center is according to http://cmslxr.fnal.gov/lxr/source/RecoLocalMuon/CSCEfficiency/src/CSCEfficiency.cc#605
|
2355 |
|
|
//wire spacing is according to CSCTDR
|
2356 |
|
|
Float_t TPTrackMuonSys::YDistToHVDeadZone(Float_t yLocal, Int_t StationAndRing){
|
2357 |
|
|
const Float_t deadZoneCenterME1_14[2] = {-81.0,81.0};
|
2358 |
|
|
const Float_t deadZoneCenterME1_2[4] = {-86.285,-32.88305,32.867423,88.205};
|
2359 |
|
|
const Float_t deadZoneCenterME1_3[4] = {-83.155,-22.7401,27.86665,81.005};
|
2360 |
|
|
const Float_t deadZoneCenterME2_1[4] = {-95.94,-27.47,33.67,93.72};
|
2361 |
|
|
const Float_t deadZoneCenterME3_1[4] = {-85.97,-36.21,23.68,84.04};
|
2362 |
|
|
const Float_t deadZoneCenterME4_1[4] = {-75.82,-26.14,23.85,73.91};
|
2363 |
|
|
const Float_t deadZoneCenterME234_2[6] = {-162.48,-81.8744,-21.18165,39.51105,100.2939,160.58};
|
2364 |
|
|
const Float_t *deadZoneCenter;
|
2365 |
|
|
Float_t deadZoneHeightHalf=2.53/2.,minY=999999.;
|
2366 |
|
|
Byte_t nGaps=4;
|
2367 |
|
|
switch (abs(StationAndRing)) {
|
2368 |
|
|
case 11:
|
2369 |
|
|
case 14:
|
2370 |
|
|
deadZoneCenter=deadZoneCenterME1_14;
|
2371 |
|
|
deadZoneHeightHalf=2/2.;
|
2372 |
|
|
nGaps=2;
|
2373 |
|
|
break;
|
2374 |
|
|
case 12:
|
2375 |
|
|
deadZoneCenter=deadZoneCenterME1_2;
|
2376 |
|
|
break;
|
2377 |
|
|
case 13:
|
2378 |
|
|
deadZoneCenter=deadZoneCenterME1_3;
|
2379 |
|
|
break;
|
2380 |
|
|
case 21:
|
2381 |
|
|
deadZoneCenter=deadZoneCenterME2_1;
|
2382 |
|
|
deadZoneHeightHalf=2.5/2.;
|
2383 |
|
|
break;
|
2384 |
|
|
case 31:
|
2385 |
|
|
deadZoneCenter=deadZoneCenterME3_1;
|
2386 |
|
|
deadZoneHeightHalf=2.5/2.;
|
2387 |
|
|
break;
|
2388 |
|
|
case 41:
|
2389 |
|
|
deadZoneCenter=deadZoneCenterME4_1;
|
2390 |
|
|
deadZoneHeightHalf=2.5/2.;
|
2391 |
|
|
break;
|
2392 |
|
|
default:
|
2393 |
|
|
deadZoneCenter=deadZoneCenterME234_2;
|
2394 |
|
|
nGaps=6;
|
2395 |
|
|
}
|
2396 |
|
|
for ( Byte_t iGap=0;iGap<nGaps;iGap++ ) {
|
2397 |
|
|
Float_t newMinY=yLocal<deadZoneCenter[iGap]?deadZoneCenter[iGap]-deadZoneHeightHalf-yLocal:yLocal-(deadZoneCenter[iGap]+deadZoneHeightHalf);
|
2398 |
|
|
if ( newMinY<minY ) minY=newMinY;
|
2399 |
|
|
}
|
2400 |
|
|
return minY;
|
2401 |
|
|
}
|
2402 |
|
|
|
2403 |
|
|
//define this as a plug-in
|
2404 |
|
|
DEFINE_FWK_MODULE(TPTrackMuonSys);
|
2405 |
|
|
|
2406 |
|
|
|