@@ -6,6 +6,9 @@ double tof_length = 200.; // [cm]
66double tof_sigmat = 0.02 ; // [ns]
77double tof_sigma0 = 0.20 ; // [ns]
88
9+ double tof_mismatch = 0.01 ;
10+ std ::string tof_mismatch_fname ;
11+
912void
1013tof (const char * inputFile = "delphes.root" ,
1114 const char * outputFile = "tof.root" )
@@ -45,23 +48,33 @@ tof(const char *inputFile = "delphes.root",
4548 double logxmax = std ::log10 (xmax );
4649 double binwidth = (logxmax - logxmin ) / nbins ;
4750 double xbins [nbins + 1 ];
48- xbins [0 ] = xmin ;
49- for (Int_t i = 1 ; i <= nbins ; ++ i )
50- xbins [i ] = xmin + std ::pow (10. , logxmin + i * binwidth );
51+ for (Int_t i = 0 ; i <= nbins ; ++ i )
52+ xbins [i ] = std ::pow (10. , logxmin + i * binwidth );
5153
5254 // histograms
5355 auto hTime0 = new TH1F ("hTime0" , ";t_{0} (ns)" , 1000 , -1. , 1. );
5456 auto hBetaP = new TH2F ("hBetaP" , ";#it{p} (GeV/#it{c});#beta" , nbins , xbins , 1000 , 0.1 , 1.1 );
57+ TH2 * hHit = new TH2F ("hHit" , ";#eta;#it{p}_{T} (GeV/#it{c})" , 200 , -4. , 4. , nbins , xbins );
5558 TH2 * hNsigmaPt [5 ], * hNsigmaPt_true [5 ][5 ];
5659 const char * pname [5 ] = {"el" , "mu" , "pi" , "ka" , "pr" };
5760 const char * plabel [5 ] = {"e" , "#mu" , "#pi" , "K" , "p" };
5861 for (int i = 0 ; i < 5 ; ++ i ) {
59- hNsigmaPt [i ] = new TH2F (Form ("hNsigmaPt_%s" , pname [i ]), Form (";#it{p_{T}} (GeV/#it{c});n#sigma_{%s}" , plabel [i ]), nbins , xbins , 200 , -10 . , 10 . );
62+ hNsigmaPt [i ] = new TH2F (Form ("hNsigmaPt_%s" , pname [i ]), Form (";#it{p_{T}} (GeV/#it{c});n#sigma_{%s}" , plabel [i ]), nbins , xbins , 500 , -25 . , 25 . );
6063 for (int j = 0 ; j < 5 ; ++ j ) {
61- hNsigmaPt_true [i ][j ] = new TH2F (Form ("hNsigmaPt_%s_true_%s" , pname [i ], pname [j ]), Form (";#it{p_{T}} (GeV/#it{c});n#sigma_{%s}" , plabel [i ]), nbins , xbins , 200 , -10 . , 10 . );
64+ hNsigmaPt_true [i ][j ] = new TH2F (Form ("hNsigmaPt_%s_true_%s" , pname [i ], pname [j ]), Form (";#it{p_{T}} (GeV/#it{c});n#sigma_{%s}" , plabel [i ]), nbins , xbins , 500 , -25 . , 25 . );
6265 }
6366 }
64-
67+ auto hMismatchTemplateOut = new TH1F ("hMismatchTemplate" , "" , 3000. , -5. , 25. );
68+
69+ // read mismatch template if requested
70+ TH1 * hMismatchTemplateIn = nullptr ;
71+ if (!tof_mismatch_fname .empty ()) {
72+ auto fmismatch = TFile ::Open (tof_mismatch_fname .c_str ());
73+ hMismatchTemplateIn = (TH1 * )fmismatch -> Get ("hMismatchTemplate" );
74+ hMismatchTemplateIn -> SetDirectory (0 );
75+ fmismatch -> Close ();
76+ }
77+
6578 std ::map < int , int > pidmap = { {11 , 0 }, {13 , 1 }, {211 , 2 }, {321 , 3 }, {2212 , 4 } };
6679
6780 for (Int_t ientry = 0 ; ientry < numberOfEntries ; ++ ientry ) {
@@ -80,13 +93,27 @@ tof(const char *inputFile = "delphes.root",
8093 // smear track
8194 if (!smearer .smearTrack (* track )) continue ;
8295
96+ // check if has TOF
97+ if (!toflayer .hasTOF (* track )) continue ;
98+
99+ // fill output mismatch template
100+ auto L = std ::sqrt (track -> XOuter * track -> XOuter +
101+ track -> YOuter * track -> YOuter +
102+ track -> ZOuter * track -> ZOuter );
103+ hMismatchTemplateOut -> Fill (track -> TOuter * 1.e9 - L / 299.79246 );
104+
105+ // do some random mismatch
106+ if (hMismatchTemplateIn && gRandom -> Uniform () < tof_mismatch ) {
107+ track -> TOuter = (hMismatchTemplateIn -> GetRandom () + L / 299.79246 ) * 1.e-9 ;
108+ }
109+
83110 // select primaries based on 3 sigma DCA cuts
84111 if (fabs (track -> D0 / track -> ErrorD0 ) > 3. ) continue ;
85112 if (fabs (track -> DZ / track -> ErrorDZ ) > 3. ) continue ;
86113
87- // check if has TOF
88- if (! toflayer . hasTOF ( * track )) continue ;
89-
114+ // fill hit histogram with true (eta,pt)
115+ hHit -> Fill ( particle -> Eta , particle -> PT ) ;
116+
90117 // push track
91118 tof_tracks .push_back (track );
92119
@@ -123,6 +150,8 @@ tof(const char *inputFile = "delphes.root",
123150 auto fout = TFile ::Open (outputFile , "RECREATE ");
124151 hTime0 -> Write ();
125152 hBetaP -> Write ();
153+ hHit -> Write ();
154+ hMismatchTemplateOut -> Write ();
126155 for (int i = 0 ; i < 5 ; ++ i ) {
127156 hNsigmaPt [i ]-> Write ();
128157 for (int j = 0 ; j < 5 ; ++ j ) {
0 commit comments