CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MuonSeedsAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * $Date: 2008/03/25
5  18:37:05 $
6  * \author G. Mila - INFN Torino
7  */
8 
10 
19 
21 
24 
29 
30 #include <string>
31 
32 
33 using namespace std;
34 using namespace edm;
35 
36 
38  parameters = pSet;
39 
40  theService = new MuonServiceProxy(parameters.getParameter<ParameterSet>("ServiceParameters"));
41  theDbe = edm::Service<DQMStore>().operator->();
42 
43 
44  theSeedsCollectionLabel_ = consumes<TrajectorySeedCollection>(parameters.getParameter<InputTag>("SeedCollection"));
45 }
46 
47 
49  delete theService;
50 }
51 
52 
54  metname = "seedsAnalyzer";
55  LogTrace(metname)<<"[MuonSeedsAnalyzer] Parameters initialization";
56 
57 }
58 
59 void MuonSeedsAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup){
60 
61  theDbe->cd();
62  theDbe->setCurrentFolder("Muons/MuonSeedsAnalyzer");
63 
64  seedHitBin = parameters.getParameter<int>("RecHitBin");
65  seedHitMin = parameters.getParameter<double>("RecHitMin");
66  seedHitMax = parameters.getParameter<double>("RecHitMax");
67  string histname = "NumberOfRecHitsPerSeed_";
68  NumberOfRecHitsPerSeed = theDbe->book1D(histname, "Number of seed recHits", seedHitBin, seedHitMin, seedHitMax);
69 
70  PhiBin = parameters.getParameter<int>("PhiBin");
71  PhiMin = parameters.getParameter<double>("PhiMin");
72  PhiMax = parameters.getParameter<double>("PhiMax");
73  histname = "seedPhi_";
74  seedPhi = theDbe->book1D(histname, "Seed #phi", PhiBin, PhiMin, PhiMax);
75  seedPhi->setAxisTitle("rad");
76 
77  EtaBin = parameters.getParameter<int>("EtaBin");
78  EtaMin = parameters.getParameter<double>("EtaMin");
79  EtaMax = parameters.getParameter<double>("EtaMax");
80  histname = "seedEta_";
81  seedEta = theDbe->book1D(histname, "Seed #eta", EtaBin, EtaMin, EtaMax);
82 
83  ThetaBin = parameters.getParameter<int>("ThetaBin");
84  ThetaMin = parameters.getParameter<double>("ThetaMin");
85  ThetaMax = parameters.getParameter<double>("ThetaMax");
86  histname = "seedTheta_";
87  seedTheta = theDbe->book1D(histname, "Seed #theta", ThetaBin, ThetaMin, ThetaMax);
88  seedTheta->setAxisTitle("rad");
89 
90  seedPtBin = parameters.getParameter<int>("seedPtBin");
91  seedPtMin = parameters.getParameter<double>("seedPtMin");
92  seedPtMax = parameters.getParameter<double>("seedPtMax");
93  histname = "seedPt_";
94  seedPt = theDbe->book1D(histname, "Seed p_{t}", seedPtBin, seedPtMin, seedPtMax);
95  seedPt->setAxisTitle("GeV");
96 
97  seedPxyzBin = parameters.getParameter<int>("seedPxyzBin");
98  seedPxyzMin = parameters.getParameter<double>("seedPxyzMin");
99  seedPxyzMax = parameters.getParameter<double>("seedPxyzMax");
100  histname = "seedPx_";
101  seedPx = theDbe->book1D(histname, "Seed p_{x}", seedPxyzBin, seedPxyzMin, seedPxyzMax);
102  seedPx->setAxisTitle("GeV");
103  histname = "seedPy_";
104  seedPy = theDbe->book1D(histname, "Seed p_{y}", seedPxyzBin, seedPxyzMin, seedPxyzMax);
105  seedPy->setAxisTitle("GeV");
106  histname = "seedPz_";
107  seedPz = theDbe->book1D(histname, "Seed p_{z}", seedPxyzBin, seedPxyzMin, seedPxyzMax);
108  seedPz->setAxisTitle("GeV");
109 
110  pErrBin = parameters.getParameter<int>("pErrBin");
111  pErrMin = parameters.getParameter<double>("pErrMin");
112  pErrMax = parameters.getParameter<double>("pErrMax");
113  histname = "seedPtErrOverPt_";
114  seedPtErr = theDbe->book1D(histname, "Seed p_{t}Err/p_{t}", pErrBin, pErrMin, pErrMax);
115  histname = "seedPtErrOverPtVsPhi_";
116  seedPtErrVsPhi = theDbe->book2D(histname, "Seed p_{t}Err/p_{t} vs #phi", PhiBin, PhiMin, PhiMax, pErrBin, pErrMin, pErrMax);
117  seedPtErrVsPhi->setAxisTitle("rad",2);
118  histname = "seedPtErrOverPtVsEta_";
119  seedPtErrVsEta = theDbe->book2D(histname, "Seed p_{t}Err/p_{t} vs #eta", EtaBin, EtaMin, EtaMax, pErrBin, pErrMin, pErrMax);
120  histname = "seedPtErrOverPtVsPt_";
121  seedPtErrVsPt = theDbe->book2D(histname, "Seed p_{t}Err/p_{t} vs p_{t}", seedPtBin/5, seedPtMin, seedPtMax, pErrBin, pErrMin, pErrMax);
122  seedPtErrVsPt->setAxisTitle("GeV",2);
123  histname = "seedPErrOverP_";
124  seedPErr = theDbe->book1D(histname, "Seed pErr/p", pErrBin, pErrMin, pErrMax);
125  histname = "seedPErrOverPVsPhi_";
126  seedPErrVsPhi = theDbe->book2D(histname, "Seed pErr/p vs #phi", PhiBin, PhiMin, PhiMax, pErrBin, pErrMin, pErrMax);
127  seedPErrVsPhi->setAxisTitle("rad",2);
128  histname = "seedPErrOverPVsEta_";
129  seedPErrVsEta = theDbe->book2D(histname, "Seed pErr/p vs #eta", EtaBin, EtaMin, EtaMax, pErrBin, pErrMin, pErrMax);
130  histname = "seedPErrOverPVsPt_";
131  seedPErrVsPt = theDbe->book2D(histname, "Seed pErr/p vs p_{t}", seedPtBin/5, seedPtMin, seedPtMax, pErrBin, pErrMin, pErrMax);
132  seedPErrVsPt->setAxisTitle("GeV",2);
133 
134  pxyzErrBin = parameters.getParameter<int>("pxyzErrBin");
135  pxyzErrMin = parameters.getParameter<double>("pxyzErrMin");
136  pxyzErrMax = parameters.getParameter<double>("pxyzErrMax");
137  histname = "seedPxErrOverPx_";
138  seedPxErr = theDbe->book1D(histname, "Seed p_{x}Err/p_{x}", pxyzErrBin, pxyzErrMin, pxyzErrMax);
139  histname = "seedPyErrOverPy_";
140  seedPyErr = theDbe->book1D(histname, "Seed p_{y}Err/p_{y}", pxyzErrBin, pxyzErrMin, pxyzErrMax);
141  histname = "seedPzErrOverPz_";
142  seedPzErr = theDbe->book1D(histname, "Seed p_{z}Err/p_{z}", pxyzErrBin, pxyzErrMin, pxyzErrMax);
143 
144  phiErrBin = parameters.getParameter<int>("phiErrBin");
145  phiErrMin = parameters.getParameter<double>("phiErrMin");
146  phiErrMax = parameters.getParameter<double>("phiErrMax");
147  histname = "seedPhiErr_";
148  seedPhiErr = theDbe->book1D(histname, "Seed #phi error", phiErrBin, phiErrMin, phiErrMax);
149 
150  etaErrBin = parameters.getParameter<int>("etaErrBin");
151  etaErrMin = parameters.getParameter<double>("etaErrMin");
152  etaErrMax = parameters.getParameter<double>("etaErrMax");
153  histname = "seedEtaErr_";
154  seedEtaErr = theDbe->book1D(histname, "Seed #eta error", etaErrBin, etaErrMin, etaErrMax);
155 
156 }
157 
158 
160  theService->update(iSetup);
161 
162  // Take the seeds container
164  iEvent.getByToken(theSeedsCollectionLabel_, seeds);
165 
166  // if not valid, skip
167  if (!seeds.isValid()) return;
168 
169  for(TrajectorySeedCollection::const_iterator seed = seeds->begin(); seed != seeds->end(); ++seed){
170  // const TrajectorySeed sd = *seed;
171 
172  // Get the Trajectory State on Det (persistent version of a TSOS) from the seed
173  PTrajectoryStateOnDet pTSOD = seed->startingState();
174 
175  // Transform it in a TrajectoryStateOnSurface
176  DetId seedDetId(pTSOD.detId());
177  const GeomDet* gdet = theService->trackingGeometry()->idToDet( seedDetId );
178  TrajectoryStateOnSurface seedTSOS = trajectoryStateTransform::transientState(pTSOD, &(gdet->surface()), &*(theService)->magneticField());
180  double partialPterror = errors(3,3)*pow(seedTSOS.globalMomentum().x(),2) + errors(4,4)*pow(seedTSOS.globalMomentum().y(),2);
181 
182  LogTrace(metname)<<"[MuonSeedAnalyzer] Filling the histos";
183 
184  // nhits
185  LogTrace(metname)<<"Number od recHits per seed: "<<seed->nHits();
186  NumberOfRecHitsPerSeed->Fill(seed->nHits());
187 
188  // pt
189  LogTrace(metname)<<"seed momentum: "<<seedTSOS.globalMomentum().perp();
190  seedPt->Fill(seedTSOS.globalMomentum().perp());
191 
192  // px
193  LogTrace(metname)<<"seed px: "<<seedTSOS.globalMomentum().x();
194  seedPx->Fill(seedTSOS.globalMomentum().x());
195 
196  // py
197  LogTrace(metname)<<"seed py: "<<seedTSOS.globalMomentum().y();
198  seedPy->Fill(seedTSOS.globalMomentum().y());
199 
200  // pz
201  LogTrace(metname)<<"seed pz: "<<seedTSOS.globalMomentum().z();
202  seedPz->Fill(seedTSOS.globalMomentum().z());
203 
204  // phi
205  LogTrace(metname)<<"seed phi: "<<seedTSOS.globalMomentum().phi();
206  seedPhi->Fill(seedTSOS.globalMomentum().phi());
207 
208  // theta
209  LogTrace(metname)<<"seed theta: "<<seedTSOS.globalMomentum().theta();
210  seedTheta->Fill(seedTSOS.globalMomentum().theta());
211 
212  // eta
213  LogTrace(metname)<<"seed eta: "<<seedTSOS.globalMomentum().eta();
214  seedEta->Fill(seedTSOS.globalMomentum().eta());
215 
216  // pt err
217  LogTrace(metname)<<"seed pt error: "<<sqrt(partialPterror)/seedTSOS.globalMomentum().perp();
218  seedPtErr->Fill(sqrt(partialPterror)/seedTSOS.globalMomentum().perp());
219 
220  // ptErr/pt Vs phi
221  seedPtErrVsPhi->Fill(seedTSOS.globalMomentum().phi(),
222  sqrt(partialPterror)/seedTSOS.globalMomentum().perp());
223  // ptErr/pt Vs eta
224  seedPtErrVsEta->Fill(seedTSOS.globalMomentum().eta(),
225  sqrt(partialPterror)/seedTSOS.globalMomentum().perp());
226  // ptErr/pt Vs pt
227  seedPtErrVsPt->Fill(seedTSOS.globalMomentum().perp(),
228  sqrt(partialPterror)/seedTSOS.globalMomentum().perp());
229 
230  // px err
231  LogTrace(metname)<<"seed px error: "<<sqrt(errors(3,3))/seedTSOS.globalMomentum().x();
232  seedPxErr->Fill(sqrt(errors(3,3))/seedTSOS.globalMomentum().x());
233 
234  // py err
235  LogTrace(metname)<<"seed py error: "<<sqrt(errors(4,4))/seedTSOS.globalMomentum().y();
236  seedPyErr->Fill(sqrt(errors(4,4))/seedTSOS.globalMomentum().y());
237 
238  // pz err
239  LogTrace(metname)<<"seed pz error: "<<sqrt(errors(5,5))/seedTSOS.globalMomentum().z();
240  seedPzErr->Fill(sqrt(errors(5,5))/seedTSOS.globalMomentum().z());
241 
242  // p err
243  LogTrace(metname)<<"seed p error: "<<sqrt(partialPterror+errors(5,5)*pow(seedTSOS.globalMomentum().z(),2))/seedTSOS.globalMomentum().mag();
244  seedPErr->Fill(sqrt(partialPterror+errors(5,5)*pow(seedTSOS.globalMomentum().z(),2))/seedTSOS.globalMomentum().mag());
245 
246  // pErr/p Vs phi
247  seedPErrVsPhi->Fill(seedTSOS.globalMomentum().phi(),
248  sqrt(partialPterror+errors(5,5)*pow(seedTSOS.globalMomentum().z(),2))/seedTSOS.globalMomentum().mag());
249  // pErr/p Vs eta
250  seedPErrVsEta->Fill(seedTSOS.globalMomentum().eta(),
251  sqrt(partialPterror+errors(5,5)*pow(seedTSOS.globalMomentum().z(),2))/seedTSOS.globalMomentum().mag());
252  // pErr/p Vs pt
253  seedPErrVsPt->Fill(seedTSOS.globalMomentum().perp(),
254  sqrt(partialPterror+errors(5,5)*pow(seedTSOS.globalMomentum().z(),2))/seedTSOS.globalMomentum().mag());
255 
256  // phi err
257  LogTrace(metname)<<"seed phi error: "<<sqrt(seedTSOS.curvilinearError().matrix()(2,2));
258  seedPhiErr->Fill(sqrt(seedTSOS.curvilinearError().matrix()(2,2)));
259 
260  // eta err
261  LogTrace(metname)<<"seed eta error: "<<sqrt(seedTSOS.curvilinearError().matrix()(1,1))*abs(sin(seedTSOS.globalMomentum().theta()));
262  seedEtaErr->Fill(sqrt(seedTSOS.curvilinearError().matrix()(1,1))*abs(sin(seedTSOS.globalMomentum().theta())));
263  }
264 }
265 
266 
267 //TrajectoryStateOnSurface MuonSeedsAnalyzer::getSeedTSOS(const TrajectorySeed& seed){
268 //
269 // // Get the Trajectory State on Det (persistent version of a TSOS) from the seed
270 // PTrajectoryStateOnDet pTSOD = seed.startingState();
271 // // Transform it in a TrajectoryStateOnSurface
272 //
273 // DetId seedDetId(pTSOD.detId());
274 // const GeomDet* gdet = service()->trackingGeometry()->idToDet( seedDetId );
275 // TrajectoryStateOnSurface initialState = trajectoryStateTransform::transientState(pTSOD, &(gdet->surface()), &*(service())->magneticField());
276 //
277 // return initialState;
278 //
279 //}
280 //
281 
dictionary parameters
Definition: Parameters.py:2
T perp() const
Definition: PV3DBase.h:72
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
const std::string metname
const CurvilinearTrajectoryError & curvilinearError() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
const CartesianTrajectoryError cartesianError() const
T y() const
Definition: PV3DBase.h:63
const double EtaMax[kNumberCalorimeter]
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
int iEvent
Definition: GenABIO.cc:243
T mag() const
Definition: PV3DBase.h:67
void beginJob()
Inizialize parameters for histo binning.
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int detId() const
const double EtaMin[kNumberCalorimeter]
bool isValid() const
Definition: HandleBase.h:76
#define LogTrace(id)
const AlgebraicSymMatrix66 & matrix() const
void beginRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
Definition: DetId.h:18
TrajectoryStateOnSurface transientState(const PTrajectoryStateOnDet &ts, const Surface *surface, const MagneticField *field)
virtual ~MuonSeedsAnalyzer()
Destructor.
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.
T eta() const
Definition: PV3DBase.h:76
const AlgebraicSymMatrix55 & matrix() const
GlobalVector globalMomentum() const
T x() const
Definition: PV3DBase.h:62
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
Definition: Run.h:41
MuonSeedsAnalyzer(const edm::ParameterSet &)
Constructor.