-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathV0AnalyzerHisto.cc
714 lines (511 loc) · 23.4 KB
/
V0AnalyzerHisto.cc
1
2
3
4
5
6
7
8
9
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
//cription: [one line class summary]
// Implementation:
// [Notes on implementation]
//
// Original Author: Zhoudunming Tu,
// Created: Mon Jun 13 20:56:30 CEST 2011
// $Id$
//
//
// system include files
#include <memory>
#include <string>
#include <vector>
#include <iostream>
#include <math.h>
#include <map>
#include <sstream>
#include <TMath.h>
#include <TH1D.h>
#include <TH2D.h>
#include <TH3D.h>
#include <TNtuple.h>
#include <TFile.h>
#include <TROOT.h>
#include <TSystem.h>
#include <TString.h>
#include <TCanvas.h>
#include <TVector3.h>
#include <TRandom.h>
#include <TNtuple.h>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/JetReco/interface/PFJet.h"
#include "DataFormats/JetReco/interface/PFJetCollection.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
#include "DataFormats/Candidate/interface/Candidate.h"
#include "DataFormats/Candidate/interface/VertexCompositeCandidate.h"
#include "DataFormats/Candidate/interface/VertexCompositeCandidateFwd.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "DataFormats/TrackReco/interface/DeDxData.h"
#include <Math/Functions.h>
#include <Math/SVector.h>
#include <Math/SMatrix.h>
//////////////////////////////////////////////
// CMSSW user include files
#include "DataFormats/Common/interface/DetSetAlgorithm.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/SiPixelDetId/interface/PXBDetId.h"
#include "DataFormats/SiPixelDetId/interface/PXFDetId.h"
#include "DataFormats/Common/interface/TriggerResults.h"
#include "DataFormats/VertexReco/interface/Vertex.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
#include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
#include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
#include "Geometry/TrackerGeometryBuilder/interface/TrackerLayerIdAccessor.h"
#include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
#include "SimDataFormats/TrackingHit/interface/PSimHit.h"
#include "SimGeneral/HepPDTRecord/interface/ParticleDataTable.h"
#include "SimTracker/TrackerHitAssociation/interface/TrackerHitAssociator.h"
#include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
#include "L1Trigger/GlobalTrigger/interface/L1GlobalTrigger.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
#include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h"
#include "SimTracker/Records/interface/TrackAssociatorRecord.h"
#include "DataFormats/RecoCandidate/interface/TrackAssociation.h"
#include "SimTracker/TrackAssociation/interface/TrackAssociatorByHits.h"
#include "DataFormats/TrackReco/interface/DeDxData.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
// Heavyion
#include "DataFormats/HeavyIonEvent/interface/Centrality.h"
// Particle Flow
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/ParticleFlowReco/interface/PFBlock.h"
#include "DataFormats/ParticleFlowReco/interface/PFCluster.h"
#include "DataFormats/ParticleFlowReco/interface/PFClusterFwd.h"
// Vertex significance
#include "RecoBTag/SecondaryVertex/interface/SecondaryVertex.h"
// Root include files
#include "TTree.h"
//
// Track Matching and fake rate calculations
//#include "RiceHIG/V0Analysis/interface/V0Validator.h"
#include "DataFormats/VertexReco/interface/VertexFwd.h"
//
// class decleration
//
class V0AnalyzerHisto : public edm::EDAnalyzer {
public:
explicit V0AnalyzerHisto(const edm::ParameterSet&);
~V0AnalyzerHisto();
private:
virtual void beginJob() ;
virtual void analyze(const edm::Event&, const edm::EventSetup&);
virtual void endJob() ;
// ----------member data ---------------------------
edm::InputTag trackSrc_;
edm::InputTag simVertexSrc_;
edm::InputTag generalV0_ks_;
edm::InputTag generalV0_la_;
edm::InputTag generalV0_xi_;
edm::InputTag genParticleSrc_;
std::string vertexSrc_;
std::string jetSrc_;
int multmin_;
int multmax_;
int mult_;
bool doGenParticle_;
TH3D* InvMass_ks_underlying;
TH3D* InvMass_la_underlying;
TH3D* XiDaughter;
TH3D* genKS_underlying;
TH3D* genLA_underlying;
TH1D* vertexDistZ;
TH1D* vertexReweight;
//TH1D* ks_res[15];
//TH1D* la_res[15];
TH2D* ks_pTeta;
TH2D* la_pTeta;
TH1D* multiDist;
TH1D* etaDist;
TH1D* GENetaDist;
TH1D* eventNumber;
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
V0AnalyzerHisto::V0AnalyzerHisto(const edm::ParameterSet& iConfig)
{
trackSrc_ = iConfig.getParameter<edm::InputTag>("trackSrc");
vertexSrc_ = iConfig.getParameter<std::string>("vertexSrc");
simVertexSrc_ = iConfig.getUntrackedParameter<edm::InputTag>("tpVtxSrc",edm::InputTag("mergedtruth","MergedTrackTruth"));
generalV0_ks_ = iConfig.getParameter<edm::InputTag>("generalV0_ks");
generalV0_la_ = iConfig.getParameter<edm::InputTag>("generalV0_la");
generalV0_xi_ = iConfig.getParameter<edm::InputTag>("generalV0_xi");
jetSrc_ = iConfig.getParameter<std::string>("jetSrc");
genParticleSrc_ = iConfig.getParameter<edm::InputTag>("genParticleSrc");
multmin_ = iConfig.getUntrackedParameter<int>("multmin", 120);
multmax_ = iConfig.getUntrackedParameter<int>("multmax", 150);
mult_ = iConfig.getUntrackedParameter<int>("mult",1);
doGenParticle_ = iConfig.getUntrackedParameter<bool>("doGenParticle",false);
}
V0AnalyzerHisto::~V0AnalyzerHisto()
{
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}
//==================
// member functions
//==================
double Mass_ks(double px_1,double py_1,double pz_1,double px_2,double py_2,double pz_2)
{
double temp = 0.0;
double E1 = sqrt((px_1*px_1+py_1*py_1+pz_1*pz_1)+(0.93827203*0.93827203));
double E2 = sqrt((px_2*px_2+py_2*py_2+pz_2*pz_2)+(0.13957018*0.13957018));
double E_tot = E1+E2;
temp = (E_tot*E_tot) - ((px_1+px_2)*(px_1+px_2)+(py_1+py_2)*(py_1+py_2)+(pz_1+pz_2)*(pz_1+pz_2));
return sqrt(temp);
}
double Mass_la(double px_1,double py_1,double pz_1,double px_2,double py_2,double pz_2)
{
double temp = 0.0;
double E1 = sqrt((px_1*px_1+py_1*py_1+pz_1*pz_1)+(0.13957018*0.13957018));
double E2 = sqrt((px_2*px_2+py_2*py_2+pz_2*pz_2)+(0.13957018*0.13957018));
double E_tot = E1+E2;
temp = (E_tot*E_tot) - ((px_1+px_2)*(px_1+px_2)+(py_1+py_2)*(py_1+py_2)+(pz_1+pz_2)*(pz_1+pz_2));
return sqrt(temp);
}
double Mass_e(double px_1,double py_1,double pz_1,double px_2,double py_2,double pz_2)
{
double temp = 0.0;
double E1 = sqrt((px_1*px_1+py_1*py_1+pz_1*pz_1)+(0.000511*0.000511));
double E2 = sqrt((px_2*px_2+py_2*py_2+pz_2*pz_2)+(0.000511*0.000511));
double E_tot = E1+E2;
temp = (E_tot*E_tot) - ((px_1+px_2)*(px_1+px_2)+(py_1+py_2)*(py_1+py_2)+(pz_1+pz_2)*(pz_1+pz_2));
return sqrt(temp);
}
double Angle(double px, double py, double pz, double px_d, double py_d, double pz_d)
{
double pd = px*px_d+py*py_d+pz*pz_d;
double p = sqrt(px*px+py*py+pz*pz);
double d = sqrt(px_d*px_d+py_d*py_d+pz_d*pz_d);
double pd_module = p*d;
double temp = (pd)/(pd_module);
double angle = acos(temp);
return angle;
}
// ------------ method called to for each event ------------
void
V0AnalyzerHisto::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;
using namespace std;
edm::Handle<reco::VertexCollection> vertices;
iEvent.getByLabel(vertexSrc_,vertices);
double bestvz=-999.9, bestvx=-999.9, bestvy=-999.9;
double bestvzError=-999.9, bestvxError=-999.9, bestvyError=-999.9;
const reco::Vertex & vtx = (*vertices)[0];
bestvz = vtx.z(); bestvx = vtx.x(); bestvy = vtx.y();
bestvzError = vtx.zError(); bestvxError = vtx.xError(); bestvyError = vtx.yError();
//first selection; vertices
if(bestvz < -15.0 || bestvz>15.0) return;
Handle<reco::TrackCollection> tracks;
iEvent.getByLabel(trackSrc_, tracks);
int nTracks = 0;
for(unsigned it = 0; it < tracks->size(); it++){
const reco::Track & trk = (*tracks)[it];
math::XYZPoint bestvtx(bestvx,bestvy,bestvz);
double dzvtx = trk.dz(bestvtx);
double dxyvtx = trk.dxy(bestvtx);
double dzerror = sqrt(trk.dzError()*trk.dzError()+bestvzError*bestvzError);
double dxyerror = sqrt(trk.d0Error()*trk.d0Error()+bestvxError*bestvyError);
if(!trk.quality(reco::TrackBase::highPurity)) continue;
if(fabs(trk.ptError())/trk.pt()>0.10) continue;
if(fabs(dzvtx/dzerror) > 3) continue;
if(fabs(dxyvtx/dxyerror) > 3) continue;
//ntrack selection:
if ( fabs(trk.eta()) > 2.4 || trk.pt() < 0.4 ) continue;
etaDist->Fill( trk.eta() );
nTracks++;
}
//multiDist->Fill(nTracks);
edm::Handle<reco::PFJetCollection> jets;
iEvent.getByLabel( jetSrc_ , jets);
// jetSrc = "ak5PFJets" inputTag (string);
edm::Handle<reco::VertexCompositeCandidateCollection> v0candidates_ks;
iEvent.getByLabel(generalV0_ks_,v0candidates_ks);
if(!v0candidates_ks.isValid()) return;
edm::Handle<reco::VertexCompositeCandidateCollection> v0candidates_la;
iEvent.getByLabel(generalV0_la_,v0candidates_la);
if(!v0candidates_la.isValid()) return;
edm::Handle<reco::VertexCompositeCandidateCollection> v0candidates_xi;
iEvent.getByLabel(generalV0_xi_,v0candidates_xi);
if(!v0candidates_xi.isValid()) return;
//multiplicity bins:
//
if ( nTracks > multmin_ && nTracks < multmax_ ){
eventNumber->Fill(1);
vertexDistZ->Fill( vtx.z() );
double bin = vertexReweight->FindBin( vtx.z() );
double weight = vertexReweight->GetBinContent( bin );
if( doGenParticle_ ){
edm::Handle<reco::GenParticleCollection> genParticleCollection;
iEvent.getByLabel(genParticleSrc_, genParticleCollection);
for(unsigned it=0; it<genParticleCollection->size(); ++it) {
const reco::GenParticle & genCand = (*genParticleCollection)[it];
int id = genCand.pdgId();
int status = genCand.status();
double genpt = genCand.pt();
double geneta = genCand.eta();
if ( geneta < -2.4 || geneta > 2.4 ) continue;
/*
select smear hist:
*/
if ( status == 1 ){
if( id == 310 ){
/*for(int i = 2; i < 15; i++){
if( genCand.pt() > ptbins[i] && genCand.pt() < ptbins[i+1] ){
double temp = ks_res[i]->GetRandom();
double binNumber = ks_res[i]->FindBin(temp);
double shift = -0.3 + (binNumber*0.01);
genpt = genCand.pt() + shift;
}
}*/
genKS_underlying->Fill(geneta, genpt, genCand.mass(),weight);
}
//Finding mother:
int mid = 0;
if( TMath::Abs(id) == 3122 ){
/*for(int i = 2; i < 15; i++){
if( genCand.pt() > ptbins[i] && genCand.pt() < ptbins[i+1] ){
double temp = la_res[i]->GetRandom();
double binNumber = la_res[i]->FindBin(temp);
double shift = -0.3 + (binNumber*0.01);
genpt = genCand.pt() + shift;
}
}*/
if(genCand.numberOfMothers()==1){
const reco::Candidate * mom = genCand.mother();
mid = mom->pdgId();
if(mom->numberOfMothers()==1){
const reco::Candidate * mom1 = mom->mother();
mid = mom1->pdgId();
}
}
if (TMath::Abs(mid) != 3322 && TMath::Abs(mid) != 3312 && TMath::Abs(mid) != 3324 && TMath::Abs(mid) != 3314 && TMath::Abs(mid) != 3334){
genLA_underlying->Fill(geneta, genpt, genCand.mass(),weight);
}
}
}
}
}
for(unsigned it=0; it<v0candidates_ks->size(); ++it){
const reco::VertexCompositeCandidate & trk = (*v0candidates_ks)[it];
const reco:: Candidate * d1 = trk.daughter(0);
const reco:: Candidate * d2 = trk.daughter(1);
auto dau1 = d1->get<reco::TrackRef>();
auto dau2 = d2->get<reco::TrackRef>();
double px_dau1 = d1->px();
double py_dau1 = d1->py();
double pz_dau1 = d1->pz();
double px_dau2 = d2->px();
double py_dau2 = d2->py();
double pz_dau2 = d2->pz();
double ks_mass = trk.mass();
double ks_pt = trk.pt();
double ks_px = trk.px();
double ks_py = trk.py();
double ks_pz = trk.pz();
double ks_eta = trk.eta();
//PAngle
double secvz = trk.vz();
double secvx = trk.vx();
double secvy = trk.vy();
TVector3 ptosvec(secvx-bestvx,secvy-bestvy,secvz-bestvz);
TVector3 secvec(ks_px,ks_py,ks_pz);
double agl = cos(secvec.Angle(ptosvec));
//Decay length
typedef ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > SMatrixSym3D;
typedef ROOT::Math::SVector<double, 3> SVector3;
SMatrixSym3D totalCov = vtx.covariance() + trk.vertexCovariance();
SVector3 distanceVector(secvx-bestvx,secvy-bestvy,secvz-bestvz);
double dl = ROOT::Math::Mag(distanceVector);
double dlerror = sqrt(ROOT::Math::Similarity(totalCov, distanceVector))/dl;
double dlos = dl/dlerror;
//NumberofValidHits for two daughters"
double dau1_Nhits = dau1->numberOfValidHits();
double dau2_Nhits = dau2->numberOfValidHits();
//DCA
math::XYZPoint bestvtx(bestvx,bestvy,bestvz);
double dzbest1 = dau1->dz(bestvtx);
double dxybest1 = dau1->dxy(bestvtx);
double dzerror1 = sqrt(dau1->dzError()*dau1->dzError()+bestvzError*bestvzError);
double dxyerror1 = sqrt(dau1->d0Error()*dau1->d0Error()+bestvxError*bestvyError);
double dzos1 = dzbest1/dzerror1;
double dxyos1 = dxybest1/dxyerror1;
double dzbest2 = dau2->dz(bestvtx);
double dxybest2 = dau2->dxy(bestvtx);
double dzerror2 = sqrt(dau2->dzError()*dau2->dzError()+bestvzError*bestvzError);
double dxyerror2 = sqrt(dau2->d0Error()*dau2->d0Error()+bestvxError*bestvyError);
double dzos2 = dzbest2/dzerror2;
double dxyos2 = dxybest2/dxyerror2;
ks_pTeta->Fill(ks_eta,ks_pt);
if (dau1_Nhits > 3 && dau2_Nhits > 3 && ks_eta > -2.4 && ks_eta < 2.4 && dlos > 5 && agl > 0.999 && TMath::Abs(dzos1) > 1 &&
TMath::Abs(dzos2) > 1 && TMath::Abs(dxyos1) > 1 && TMath::Abs(dxyos2) > 1)
{
double temp = Mass_ks(px_dau1,py_dau1,pz_dau1,px_dau2,py_dau2,pz_dau2);
double temp_e = Mass_e(px_dau1,py_dau1,pz_dau1,px_dau2,py_dau2,pz_dau2);
double temp_reverse = Mass_ks(px_dau2,py_dau2,pz_dau2,px_dau1,py_dau1,pz_dau1);
if ( (temp < 1.125683 && temp > 1.105683) )continue;
if ((temp_reverse < 1.125683 && temp_reverse > 1.105683)) continue;
if ( temp_e < 0.015) continue;
InvMass_ks_underlying->Fill(ks_eta,ks_pt,ks_mass,weight);
}
}
for(unsigned it=0; it<v0candidates_la->size(); ++it){
const reco::VertexCompositeCandidate & trk = (*v0candidates_la)[it];
const reco:: Candidate * d1 = trk.daughter(0);
const reco:: Candidate * d2 = trk.daughter(1);
auto dau1 = d1->get<reco::TrackRef>();
auto dau2 = d2->get<reco::TrackRef>();
double px_dau1 = d1->px();
double py_dau1 = d1->py();
double pz_dau1 = d1->pz();
double px_dau2 = d2->px();
double py_dau2 = d2->py();
double pz_dau2 = d2->pz();
double la_mass = trk.mass();
double la_pt = trk.pt();
double la_px = trk.px();
double la_py = trk.py();
double la_pz = trk.pz();
double la_eta = trk.eta();
//PAngle
double secvz = trk.vz();
double secvx = trk.vx();
double secvy = trk.vy();
TVector3 ptosvec(secvx-bestvx,secvy-bestvy,secvz-bestvz);
TVector3 secvec(la_px,la_py,la_pz);
double agl = cos(secvec.Angle(ptosvec));
//Decay length
typedef ROOT::Math::SMatrix<double, 3, 3, ROOT::Math::MatRepSym<double, 3> > SMatrixSym3D;
typedef ROOT::Math::SVector<double, 3> SVector3;
SMatrixSym3D totalCov = vtx.covariance() + trk.vertexCovariance();
SVector3 distanceVector(secvx-bestvx,secvy-bestvy,secvz-bestvz);
double dl = ROOT::Math::Mag(distanceVector);
double dlerror = sqrt(ROOT::Math::Similarity(totalCov, distanceVector))/dl;
double dlos = dl/dlerror;
//NumberofValidHits for two daughters"
double dau1_Nhits = dau1->numberOfValidHits();
double dau2_Nhits = dau2->numberOfValidHits();
//DCA
math::XYZPoint bestvtx(bestvx,bestvy,bestvz);
double dzbest1 = dau1->dz(bestvtx);
double dxybest1 = dau1->dxy(bestvtx);
double dzerror1 = sqrt(dau1->dzError()*dau1->dzError()+bestvzError*bestvzError);
double dxyerror1 = sqrt(dau1->d0Error()*dau1->d0Error()+bestvxError*bestvyError);
double dzos1 = dzbest1/dzerror1;
double dxyos1 = dxybest1/dxyerror1;
double dzbest2 = dau2->dz(bestvtx);
double dxybest2 = dau2->dxy(bestvtx);
double dzerror2 = sqrt(dau2->dzError()*dau2->dzError()+bestvzError*bestvzError);
double dxyerror2 = sqrt(dau2->d0Error()*dau2->d0Error()+bestvxError*bestvyError);
double dzos2 = dzbest2/dzerror2;
double dxyos2 = dxybest2/dxyerror2;
la_pTeta->Fill(la_eta,la_pt);
if (dau1_Nhits > 3 && dau2_Nhits > 3 && la_eta > -2.4 && la_eta < 2.4 && dlos > 5 && agl > 0.999 && TMath::Abs(dzos1) > 1 &&
TMath::Abs(dzos2) > 1 && TMath::Abs(dxyos1) > 1 && TMath::Abs(dxyos2) > 1)
{
double temp = Mass_la(px_dau1,py_dau1,pz_dau1,px_dau2,py_dau2,pz_dau2);
double temp_e = Mass_e(px_dau1,py_dau1,pz_dau1,px_dau2,py_dau2,pz_dau2);
if ( (temp < 0.517614 && temp > 0.477614) ) continue;
if ( temp_e < 0.015) continue;
InvMass_la_underlying->Fill(la_eta,la_pt,la_mass,weight);
for(unsigned it=0; it<v0candidates_xi->size(); ++it){
const reco::VertexCompositeCandidate & trk = (*v0candidates_xi)[it];
const reco:: Candidate * d1 = trk.daughter(0);
//const reco:: Candidate * d2 = trk.daughter(1);
//PAngle
double secvz = trk.vz();
double secvx = trk.vx();
double secvy = trk.vy();
TVector3 ptosvec(secvx-bestvx,secvy-bestvy,secvz-bestvz);
TVector3 secvec(trk.px(),trk.py(),trk.pz());
double agl = cos(secvec.Angle(ptosvec));
double mass = d1->mass();
double pt1 = d1->pt();
if ( mass == la_mass && pt1 == la_pt ){
if ( agl > 0.999 ){
if ( trk.mass() > 1.31486 && trk.mass() < 1.33486 ){
XiDaughter->Fill(la_eta,la_pt,la_mass,weight);
}
}
}
}
}
}
}
}
// ------------ method called once each job just before starting event loop ------------
void
V0AnalyzerHisto::beginJob()
{
edm::Service<TFileService> fs;
TH3D::SetDefaultSumw2();
/*edm::FileInPath fip1("V0Analyzertest/V0Analyzer/data/momentumResSmearHist.root");
TFile f1(fip1.fullPath().c_str(),"READ");
for(int pt = 0; pt < 15; pt++){
ks_res[pt] = (TH1D*)f1.Get(Form("ks_%d",pt));
la_res[pt] = (TH1D*)f1.Get(Form("lam_%d",pt));
}*/
edm::FileInPath fip2("V0Analyzertest/V0Analyzer/data/vertex_epos.root");
TFile f2(fip2.fullPath().c_str(),"READ");
vertexReweight = (TH1D*)f2.Get("data");
InvMass_ks_underlying = fs->make<TH3D>("InvMass_ks_underlying",";eta;pT(GeV/c);mass(GeV/c^{2})",70,-3.5,3.5,120,0,12,360,0.44,0.56);
InvMass_la_underlying = fs->make<TH3D>("InvMass_la_underlying",";eta;pT(GeV/c);mass(GeV/c^{2})",70,-3.5,3.5,120,0,12,360,1.08,1.16);
if(doGenParticle_){
genKS_underlying = fs->make<TH3D>("genKS_underlying",";eta;pT(GeV/c);mass(GeV/c^{2})",70,-3.5,3.5,120,0,12,360,0.44,0.56);
genLA_underlying = fs->make<TH3D>("genLA_underlying",";eta;pT(GeV/c);mass(GeV/c^{2})",70,-3.5,3.5,120,0,12,360,1.08,1.16);
}
XiDaughter = fs->make<TH3D>("XiDaughter",";eta;pT(GeV/c);mass(GeV/c^{2})",70,-3.5,3.5,120,0,12,360,1.08,1.16);
vertexDistZ = fs->make<TH1D>("vertexDistZ",";Vz;#Events",100,-15,15);
ks_pTeta = fs->make<TH2D>("ks_pTeta",";#eta;pT(GeV/c)",700,-3.5,3.5,120,0,12);
la_pTeta = fs->make<TH2D>("la_pTeta",";#eta;pT(GeV/c)",700,-3.5,3.5,120,0,12);
etaDist = fs->make<TH1D>("etaDist",";eta",60,-3,3);
eventNumber = fs->make<TH1D>("eventNumber",";event",10,0,10);
}
// ------------ method called once each job just after ending the event loop ------------
void
V0AnalyzerHisto::endJob() {
}
//define this as a plug-in
DEFINE_FWK_MODULE(V0AnalyzerHisto);