001
002
003
004
005
006
007
008
009
010 #include <fstream>
011 #include <cmath>
012 #include <deque>
013 #include <utility>
014
015 #include "AtlfastAlgs/AtlfastB.h"
016 #include "AtlfastAlgs/GlobalEventData.h"
017
018 #include "AtlfastEvent/Jet.h"
019 #include "AtlfastEvent/IKinematic.h"
020 #include "AtlfastEvent/Interpolator.h"
021
022 #include "AtlfastUtils/TesIO.h"
023 #include "AtlfastUtils/HeaderPrinter.h"
024
025
026 #include "GaudiKernel/DataSvc.h"
027 #include "GaudiKernel/ISvcLocator.h"
028 #include "GaudiKernel/MsgStream.h"
029
030
031
032
033 #include "CLHEP/Random/Ranlux64Engine.h"
034 #include "CLHEP/Random/RandFlat.h"
035 #include "CLHEP/Units/SystemOfUnits.h"
036
037 #include "PathResolver/PathResolver.h"
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053 namespace Atlfast {
054
055 using std::abs;
056
057 AtlfastB::AtlfastB( const std::string& name, ISvcLocator* pSvcLocator )
058 : Algorithm( name, pSvcLocator ),
059 m_epsilonBjet(0),
060 m_beff_interpolator(0),
061 m_brejpu_interpolator(0),
062 m_brejnpu_interpolator(0),
063 m_brejtau_interpolator(0),
064 m_brejc_interpolator(0),
065 m_tesIO(0),
066 m_pRandomEngine(0),
067 m_pRandFlatGenerator(0),
068 m_Jets(0),
069 m_taueff_interpolator(0),
070 m_taurej_interpolator(0)
071 {
072
073 MsgStream log( messageService(), name ) ;
074 log << MSG::DEBUG << "Constructor" << endreq;
075
076
077
078 m_AtlfBJetSwitch = true;
079 m_AtlfCalSwitch = true;
080 m_AtlfTauSwitch = true;
081 m_AtlfTauVetoSwitch = false;
082 m_AtlfTrigMuoSwitch = false;
083
084 m_atlfBNSet = 10;
085
086 m_epsitau = 0.5;
087
088 m_indtauveto = 1;
089
090 m_corrjfile = "atlfastDatafiles/AtlfastBjet.dat";
091
092 m_corrcfile = "atlfastDatafiles/AtlfastBcjet.dat";
093 m_corrtaumom = false;
094 m_useTDRBParam = false;
095 m_interpolateBTagging = false;
096 m_correctionFactor = 1.;
097
098 m_AtlfTau1P3PSwitch = false;
099 m_epsitau1P = 0.35;
100 m_epsitau3P = 0.08;
101 m_Tau1P3Pcorrfile = "atlfastDatafiles/Tau1P3Pcorrfile.txt";
102
103
104 m_inputLocation = "/Event/AtlfastJets";
105
106
107
108
109
110
111
112 declareProperty( "InputLocation", m_inputLocation ) ;
113
114 declareProperty( "AtlfBjetSwitch", m_AtlfBJetSwitch ) ;
115 declareProperty( "AtlfCalSwitch", m_AtlfCalSwitch ) ;
116 declareProperty( "AtlfTauSwitch", m_AtlfTauSwitch );
117 declareProperty( "AtlfTauVetoSwitch", m_AtlfTauVetoSwitch );
118 declareProperty( "AtlfTrigMuoSwitch", m_AtlfTrigMuoSwitch );
119 declareProperty( "AtlfTau1P3PSwitch", m_AtlfTau1P3PSwitch );
120
121
122 declareProperty( "AtlfBNSet", m_atlfBNSet ) ;
123 declareProperty( "TauEff", m_epsitau ) ;
124 declareProperty( "TauVetoOption", m_indtauveto ) ;
125 declareProperty( "Tau1PEff", m_epsitau1P ) ;
126 declareProperty( "Tau3PEff", m_epsitau3P ) ;
127
128 declareProperty( "JetCorrFile", m_corrjfile ) ;
129 declareProperty( "CJetCorrFile", m_corrcfile ) ;
130 declareProperty( "Tau1P3PCorrFile", m_Tau1P3Pcorrfile ) ;
131
132 declareProperty( "UseTDRBParam", m_useTDRBParam );
133 declareProperty( "InterpolateBTagging", m_interpolateBTagging );
134 declareProperty( "BCorrectionFactor", m_correctionFactor);
135
136
137 declareProperty( "CalibrateTauMomentum", m_corrtaumom );
138
139 log << MSG::DEBUG << "End of constructor" << endreq;
140
141 }
142
143 AtlfastB::~AtlfastB() {
144
145 MsgStream log( messageService(), name() ) ;
146 log << MSG::DEBUG << "Destructor" << endreq;
147 if ( m_tesIO ) delete m_tesIO;
148 if ( m_pRandomEngine ) delete m_pRandomEngine;
149 if ( m_pRandFlatGenerator ) delete m_pRandFlatGenerator;
150 if ( m_taueff_interpolator ) delete m_taueff_interpolator;
151 if ( m_taurej_interpolator ) delete m_taurej_interpolator;
152 if ( m_beff_interpolator ) delete m_beff_interpolator;
153 if ( m_brejpu_interpolator ) delete m_brejpu_interpolator;
154 if ( m_brejnpu_interpolator ) delete m_brejnpu_interpolator;
155 if ( m_brejtau_interpolator ) delete m_brejtau_interpolator;
156 if ( m_brejc_interpolator ) delete m_brejc_interpolator;
157 }
158
159
160
161
162
163
164
165 StatusCode AtlfastB::initialize(){
166 MsgStream log( messageService(), name() ) ;
167 log << MSG::DEBUG << "instantiating an AtlfastB" << endreq;
168
169
170 m_corrjfile = PathResolver::find_file (m_corrjfile, "DATAPATH");
171 m_corrcfile = PathResolver::find_file (m_corrcfile, "DATAPATH");
172 m_Tau1P3Pcorrfile = PathResolver::find_file (m_Tau1P3Pcorrfile, "DATAPATH");
173
174 log << MSG::DEBUG << " m_corrjfile after PathResolver: " << m_corrjfile <<endreq;
175 log << MSG::DEBUG << " m_corrcfile after PathResolver: " << m_corrcfile <<endreq;
176 log << MSG::DEBUG << " m_Tau1P3Pcorrfile after PathResolver: " << m_Tau1P3Pcorrfile <<endreq;
177
178
179
180
181
182 GlobalEventData* ged = GlobalEventData::Instance();
183 int randSeed = ged->randSeed() ;
184
185 m_mcLocation = ged -> mcLocation();
186
187 m_tesIO= new TesIO(m_mcLocation, ged->justHardScatter());
188
189 std::string fn;
190
191 if (m_useTDRBParam) {
192
193
194 std::ifstream inputjetfile;
195 inputjetfile.open(m_corrjfile.c_str());
196
197 if(inputjetfile){
198
199 log << MSG::INFO
200 << "Pt jet correction factors file "
201 << m_corrjfile
202 <<" open."
203 <<endreq;
204 int nrow;
205 int ncolumn;
206 inputjetfile>>nrow;
207 inputjetfile>>ncolumn;
208 if(nrow != 5||ncolumn != 8) {
209 log << MSG::ERROR
210 <<"no. of input rows,columns: "
211 <<nrow<<" "
212 <<ncolumn<<" "
213 <<"expected 5, 8 "
214 <<endreq;
215 return StatusCode::FAILURE ;
216 }
217
218 for(int i=0; i<nrow;i++){
219 for(int j=0; j<ncolumn; j++){
220
221 int nset = -1;
222 switch (j){
223
224 case 0:
225 nset=1;
226 break;
227 case 1:
228 nset=2;
229 break;
230 case 2:
231 nset=3;
232 break;
233 case 3:
234 nset=5;
235 break;
236 case 4:
237 nset=11;
238 break;
239 case 5:
240 nset=12;
241 break;
242 case 6:
243 nset=13;
244 break;
245 case 7:
246 nset=14;
247 break;
248 default:
249 log << MSG::ERROR<<"j="<<j<<" Nset= "<<nset
250 <<" value not correct. Nset must b one of those: 1,2,3,5,11,12,13,14 "<<endreq;
251 return StatusCode::FAILURE;
252 break;
253
254
255 }
256 inputjetfile>>m_corrj[i][nset];
257
258 }
259 }
260
261 }else{
262 log << MSG::ERROR << "Pt jet correction factors file not found" <<endreq;
263 return StatusCode::FAILURE ;
264 }
265 inputjetfile.close();
266
267 std::ifstream inputcjetfile;
268 inputcjetfile.open(m_corrcfile.c_str());
269
270 if(inputcjetfile){
271
272 log << MSG::INFO
273 << "Pt c jet correction factors file "
274 << m_corrcfile
275 <<" open."
276 <<endreq;
277 int nrow;
278 int ncolumn;
279 inputcjetfile>>nrow;
280 inputcjetfile>>ncolumn;
281 if(nrow != 5||ncolumn != 8) {
282 log << MSG::ERROR
283 <<"no. of input rows,columns: "
284 <<nrow<<" "
285 <<ncolumn<<" "
286 <<"expected 5, 8 "
287 <<endreq;
288 return StatusCode::FAILURE ;
289 }
290 for(int i=0; i<nrow;i++){
291 for(int j=0; j<ncolumn; j++){
292
293 int nset;
294 switch (j){
295
296 case 0:
297 nset=1;
298 break;
299 case 1:
300 nset=2;
301 break;
302 case 2:
303 nset=3;
304 break;
305 case 3:
306 nset=5;
307 break;
308 case 4:
309 nset=11;
310 break;
311 case 5:
312 nset=12;
313 break;
314 case 6:
315 nset=13;
316 break;
317 case 7:
318 nset=14;
319 break;
320 default:
321 log << MSG::ERROR<<"Nset value not correct. Nset must be one of these: 1,2,3,5,11,12,13,14 "<<endreq;
322 return StatusCode::FAILURE;
323 break;
324 }
325 inputcjetfile>>m_corrc[i][nset];
326 }
327 }
328
329 }else{
330 log << MSG::ERROR
331 << "Pt c jet correction factors file not found"
332 <<endreq;
333 return StatusCode::FAILURE ;
334 }
335 inputcjetfile.close();
336 } else {
337 int ialgo = m_atlfBNSet;
338 if (ialgo < 1 || (ialgo > 14 && ialgo != 100) ) {
339 log << MSG::FATAL << "NSET not correct. Should be between 1 and 14, or 100 for canonical b-tagging" << endreq;
340 return StatusCode::FAILURE;
341 }
342
343
344 std::string path = "atlfastDatafiles/RejectionFactor";
345 std::ostringstream o;
346 o << m_atlfBNSet;
347
348 makeInterpolator(m_beff_interpolator,"atlfastDatafiles/BEfficiency"+o.str()+".txt",true);
349 makeInterpolator(m_brejpu_interpolator,path+"PU"+o.str()+".txt",true);
350 makeInterpolator(m_brejnpu_interpolator,path+"NPU"+o.str()+".txt",true);
351 makeInterpolator(m_brejtau_interpolator,path+"Tau"+o.str()+".txt",true);
352 makeInterpolator(m_brejc_interpolator,path+"C"+o.str()+".txt",true);
353
354
355
356 std::string algName = "IP2D";
357 if (ialgo == 100) {
358 algName = "Canonical";
359 m_epsilonBjet = 0.6;
360 } else {
361 if (ialgo > 7){
362 algName = "SV1+IP3D";
363 ialgo -= 7;
364 }
365 m_epsilonBjet = 0.5 + (ialgo - 1)*0.05;
366 }
367
368 log << MSG::INFO << "Running with " << algName << " at eps_b = " << m_epsilonBjet << endreq;
369
370 }
371
372
373 std::ifstream inputfileTau1P3P;
374 inputfileTau1P3P.open(m_Tau1P3Pcorrfile.c_str());
375
376 if(inputfileTau1P3P){
377
378 int nrow;
379 int ncolumn;
380 inputfileTau1P3P>>nrow;
381 inputfileTau1P3P>>ncolumn;
382
383
384 for(int i=0; i<ncolumn; i++){inputfileTau1P3P>>m_corr1P3P[i];}
385
386
387 for(int j=0; j<nrow; j++){
388 for(int k=0; k<ncolumn; k++){
389 inputfileTau1P3P>>m_corr_prob1P[j][k];
390 }
391 }
392
393 for(int l=0; l<nrow; l++){
394 for(int m=0; m<ncolumn; m++){
395 inputfileTau1P3P>>m_corr_prob3P[l][m];
396 }
397 }
398 }else{
399 log << MSG::ERROR
400 << "Tau1P3P corr factor file not found"
401 <<endreq;
402 return StatusCode::FAILURE ;
403 }
404
405
406 if( m_epsitau1P < 0.20){m_epsitau1P = 0.00;
407 log << MSG::INFO<< "Tau1PEff below allowed range (<0.10). Set Tau1PEff = 0.0 "<<endreq;}
408 if( m_epsitau1P > 0.40){m_epsitau1P = 0.40;
409 log << MSG::INFO<< "Tau1PEff above allowed range (>0.40). Set Tau1PEff = 0.40"<<endreq;}
410 if( m_epsitau3P < 0.05){m_epsitau3P = 0.00;
411 log << MSG::INFO<< "Tau3PEff below allowed range (<0.05). Set Tau3PEff = 0.0 "<<endreq;}
412 if( m_epsitau3P > 0.10){m_epsitau3P = 0.10;
413 log << MSG::INFO<< "Tau3PEff above allowed range (>0.10). Set Tau3PEff = 0.10"<<endreq;}
414
415
416 m_pRandomEngine = new Ranlux64Engine(randSeed);
417 m_pRandFlatGenerator=new RandFlat(*m_pRandomEngine);
418
419
420
421 makeInterpolator(m_taueff_interpolator,"atlfastDatafiles/TauEfficiencies.txt",false);
422 makeInterpolator(m_taurej_interpolator,"atlfastDatafiles/TauRejections.txt",false);
423
424 HeaderPrinter hp("AtlfastB:", log);
425
426 hp.add("TES Locations: ");
427 hp.add(" Jets from ", m_inputLocation);
428 hp.add("AtlfBje switch: ", m_AtlfBJetSwitch);
429 hp.add("AtlfBje NSet: ", m_atlfBNSet);
430 hp.add("AtlfCal switch: ", m_AtlfCalSwitch);
431 hp.add("AtlfTau switch: ", m_AtlfTauSwitch);
432 hp.add("AtlfTauVeto switch: ", m_AtlfTauVetoSwitch);
433 hp.add("AtlfTrigMuo switch: ", m_AtlfTrigMuoSwitch);
434 hp.add("AtlfTau1P3P switch: ", m_AtlfTau1P3PSwitch);
435 hp.add("correction file 1: ", m_corrjfile);
436 hp.add("correction file 2: ", m_corrcfile);
437 hp.print();
438
439 return StatusCode::SUCCESS ;
440 }
441
442
443
444
445
446 StatusCode AtlfastB::finalize(){
447
448 MsgStream log( messageService(), name() ) ;
449 log << MSG::INFO << "finalizing" << endreq;
450 return StatusCode::SUCCESS ;
451 }
452
453
454
455
456
457
458 StatusCode AtlfastB::execute(){
459
460 StatusCode sc;
461 MsgStream log( messageService(), name() ) ;
462
463 log << MSG::DEBUG<<"In execute"<<endreq;
464
465 if(!m_tesIO->getDH(m_Jets, m_inputLocation)){
466 log << MSG::ERROR
467 << "Couldn't retrieve JetCollection" << m_inputLocation
468 << endreq ;
469 return StatusCode::FAILURE;
470 }
471
472 if(m_AtlfBJetSwitch){
473
474
475
476
477 sc = m_useTDRBParam ? atlfBje_TDR() : atlfBje();
478
479 if(sc.isFailure()){
480 log << MSG::ERROR<<"Error in atlfBje"<<endreq;
481 return StatusCode::FAILURE;
482 }
483
484 }
485
486 if(m_AtlfTauSwitch){
487
488
489
490 sc=atlfTau(m_epsitau);
491
492 if(sc.isFailure()){
493 log << MSG::ERROR<<"Error in atlfTau"<<endreq;
494 return StatusCode::FAILURE;
495 }
496
497 }
498
499 if(m_AtlfTau1P3PSwitch){
500
501
502
503 sc=atlfTau1P3P();
504
505 if(sc.isFailure()){
506 log << MSG::ERROR<<"Error in atlfTau1P3P"<<endreq;
507 return StatusCode::FAILURE;
508 }
509
510 }
511
512 if(m_AtlfTauVetoSwitch){
513
514
515
516 sc=atlfTauVeto(m_indtauveto);
517
518 if(sc.isFailure()){
519 log << MSG::ERROR<<"Error in atlfTauVeto"<<endreq;
520 return StatusCode::FAILURE;
521 }
522
523 }
524
525
526 if(m_AtlfTrigMuoSwitch){
527
528
529
530 sc=atlfTrigMuo();
531
532 if(sc.isFailure()){
533 log << MSG::ERROR<<"Error in atlfTrigMuo"<<endreq;
534 return StatusCode::FAILURE;
535 }
536
537 }
538
539
540 if(m_AtlfCalSwitch){
541
542
543
544 sc=atlfCal();
545
546 if(sc.isFailure()){
547 log << MSG::ERROR<<"Error in atlfCal"<<endreq;
548 return StatusCode::FAILURE;
549 }
550
551 }
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569 m_it = m_Jets->begin();
570
571
572 for( ; m_it != m_Jets->end(); ++m_it ){
573
574 log << MSG::DEBUG
575 <<"original jets: PDGID= "<<(*m_it)->pdg_id()
576 <<" B tag= " <<(*m_it)->isBTagged()
577 <<" B tag corr factor = " << (*m_it)->bTagCorrFactor()
578 <<" Tau tag= " <<(*m_it)->isTauTagged()
579 <<" Tau tag corr factor = " << (*m_it)->tauTagCorrFactor()
580 <<" pT = " << (*m_it)->pT() << endreq;
581
582
583
584
585
586
587
588
589
590
591 }
592
593
594
595 TesIoStat stat = m_tesIO->lock( m_Jets ) ;
596 if(!stat){
597 log<<MSG::ERROR<<"Could not lock jet collection"<<endreq;
598 return stat;
599 }
600
601
602 return StatusCode::SUCCESS;
603 }
604
605
606
607
608
609 StatusCode AtlfastB::atlfBje_TDR(){
610
611 MsgStream log( messageService(), name() ) ;
612
613
614 switch(m_atlfBNSet){
615
616 case 1:
617 m_epsib=0.5;
618 m_epsic=1./10.9;
619 m_epsij=1./231.;
620 break;
621
622 case 2:
623 m_epsib=0.60;
624 m_epsic=1./6.7;
625 m_epsij=1./93.;
626 break;
627
628 case 3:
629 m_epsib=0.70;
630 m_epsic=1./4.3;
631 m_epsij=1./34.1;
632 break;
633
634 case 5:
635 m_epsib=0.60;
636 m_epsic=1./10.;
637 m_epsij=1./100.;
638 break;
639
640 case 11:
641 m_epsib=0.33;
642 m_epsic=1./22.9;
643 m_epsij=1./1381.;
644 break;
645
646 case 12:
647 m_epsib=0.43;
648 m_epsic=1./10.8;
649 m_epsij=1./219.;
650 break;
651
652 case 13:
653 m_epsib=0.53;
654 m_epsic=1./6.7;
655 m_epsij=1./91.;
656 break;
657
658 case 14:
659 m_epsib=0.624;
660 m_epsic=1./6.7;
661 m_epsij=1./91.;
662 break;
663
664 default:
665 log << MSG::ERROR<<"No b jet tagging efficiencies applied"<<endreq;
666 return StatusCode::FAILURE;
667 break;
668 }
669
670
671
672
673 log<<MSG::DEBUG<<"Applying randomized B tagging...."<<endreq;
674
675 for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
676
677 double randnum;
678 double corpt;
679 double corr;
680
681 double ptjet=(*m_it)->pT();
682 double etajet=(*m_it)->eta();
683 int pdgid=(*m_it)->pdg_id();
684
685
686
687
688 corr=fitcoreb(ptjet);
689
690 ptjet=corr*ptjet;
691
692 randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
693
694 corpt=0.;
695
696 if(abs(pdgid)==5){
697
698 if((abs(etajet)<=2.5)&&(randnum<m_epsib)){
699 (*m_it)->setBTagged("TDR");
700 }
701
702 }else if(abs(pdgid)==4){
703
704 if(ptjet<=30.*GeV) corpt=m_corrc[0][m_atlfBNSet];
705 if((ptjet>30.*GeV)&&(ptjet<= 45.*GeV)) corpt=m_corrc[1][m_atlfBNSet];
706 if((ptjet>45.*GeV)&&(ptjet<= 60.*GeV)) corpt=m_corrc[2][m_atlfBNSet];
707 if((ptjet>60.*GeV)&&(ptjet<=100.*GeV)) corpt=m_corrc[3][m_atlfBNSet];
708 if(ptjet>100.*GeV) corpt=m_corrc[4][m_atlfBNSet];
709
710 if((abs(etajet)<=2.5)&&(randnum<(m_epsic/corpt))) {
711 (*m_it)->setBTagged("TDR");
712 }
713
714 }else if(((abs(pdgid)!=4)&&(abs(pdgid)!=5))||abs(pdgid)==15){
715
716 if(ptjet<=30.*GeV) corpt=m_corrj[0][m_atlfBNSet];
717 if((ptjet>30.*GeV)&&(ptjet<=45.*GeV)) corpt=m_corrj[1][m_atlfBNSet];
718 if((ptjet>45.*GeV)&&(ptjet<=60.*GeV)) corpt=m_corrj[2][m_atlfBNSet];
719 if((ptjet>60.*GeV)&&(ptjet<=100.*GeV)) corpt=m_corrj[3][m_atlfBNSet];
720 if(ptjet>100.*GeV) corpt=m_corrj[4][m_atlfBNSet];
721
722 if((abs(etajet)<=2.5)&&(randnum<(m_epsij/corpt))) {
723 (*m_it)->setBTagged("TDR");
724 }
725
726 }
727 }
728
729 return StatusCode::SUCCESS;
730
731 }
732
733 StatusCode AtlfastB::atlfBje() {
734
735 MsgStream mlog(messageService(), name());
736
737 mlog << MSG::DEBUG << "Applying randomized B tagging, new parametrization" <<endreq;
738
739 int debug = 0;
740 if (mlog.level() < MSG::DEBUG) debug = 1;
741
742 for(m_it=m_Jets->begin(); m_it<m_Jets->end(); ++m_it){
743
744 double randnum = m_pRandFlatGenerator->shoot(m_pRandomEngine);
745 double ptjet = (*m_it)->pT();
746 double etajet = (*m_it)->eta();
747 int pdgid = (*m_it)->pdg_id();
748
749
750 deque<double> input_values;
751 input_values.push_back(ptjet/1.e3);
752 input_values.push_back(fabs(etajet));
753
754 if ( fabs(etajet) <= 2.5 ) {
755 if (abs(pdgid) == 5) {
756
757
758 double epsilonBjet = m_interpolateBTagging ?
759 m_beff_interpolator->interpolate(input_values) :
760 m_beff_interpolator->getNearestValue(input_values);
761 mlog << MSG::DEBUG << " epsb( "<<ptjet/1.e3<<" , "<<etajet<<" ) = "<< epsilonBjet << endreq;
762 if ( randnum < epsilonBjet )
763 (*m_it)->setBTagged("SV1+IP3D");
764 } else if (abs(pdgid) == 4) {
765 double RejC = m_interpolateBTagging ?
766 m_brejc_interpolator->interpolate(input_values) :
767 m_brejc_interpolator->getNearestValue(input_values);
768 mlog << MSG::DEBUG << " Rc( "<<ptjet/1.e3<<" , "<<etajet<<" ) = "<< RejC << endreq;
769 if ( randnum < 1./RejC )
770 (*m_it)->setBTagged("SV1+IP3D");
771 } else if (abs(pdgid) == 15) {
772 double RejTau = m_interpolateBTagging ?
773 m_brejtau_interpolator->interpolate(input_values) :
774 m_brejtau_interpolator->getNearestValue(input_values);
775 mlog << MSG::DEBUG << " Rtau( "<<ptjet/1.e3<<" , "<<etajet<<" ) = "<< RejTau << endreq;
776 if ( randnum < 1./RejTau )
777 (*m_it)->setBTagged("SV1+IP3D");
778 } else {
779 double RejLight = m_interpolateBTagging ?
780 m_brejpu_interpolator->interpolate(input_values) :
781 m_brejpu_interpolator->getNearestValue(input_values);
782 double dRb = (*m_it)->getdRbquark();
783 double dRc = (*m_it)->getdRcquark();
784 double dRtau = (*m_it)->getdRhadtau();
785 if (dRb < 0.8 || dRc < 0.8 || dRtau < 0.8) {
786 RejLight = m_interpolateBTagging ?
787 m_brejnpu_interpolator->interpolate(input_values) :
788 m_brejnpu_interpolator->getNearestValue(input_values);
789 }
790 mlog << MSG::DEBUG << " RLight( "<<ptjet/1.e3<<" , "<<etajet<<" ) = "<< RejLight << endreq;
791
792
793
794 if ( randnum < 1./(RejLight*m_correctionFactor) )
795 (*m_it)->setBTagged("SV1+IP3D");
796 }
797 }
798
799
800 }
801 return StatusCode::SUCCESS;
802 }
803
804 StatusCode AtlfastB::atlfCal(){
805
806
807
808
809 MsgStream log( messageService(), name() ) ;
810
811 for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
812
813 double ptjet=(*m_it)->pT();
814
815
816 (*m_it)->setBTagCorrFactor("SV1+IP3D",fitcoreb(ptjet));
817
818
819 (*m_it)->setTauTagCorrFactor("Tau",1.);
820
821
822 (*m_it)->setLightTagCorrFactor("Standard",fitcoreu(ptjet));
823
824 }
825
826 return StatusCode::SUCCESS;
827
828 }
829
830
831 StatusCode AtlfastB::atlfTau(double epsitau){
832
833 MsgStream log( messageService(), name() ) ;
834
835
836 for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
837
838 double randnum;
839
840 double etajet=(*m_it)->eta();
841 double ptjet=(*m_it)->pT();
842 int pdgid=(*m_it)->pdg_id();
843
844 randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
845
846 deque<double> input_values;
847
848 input_values.push_back(epsitau*100.);
849
850 input_values.push_back(fabs(etajet));
851
852 input_values.push_back(ptjet/GeV);
853
854
855 if(abs(pdgid)==15){
856
857
858 double taueff = m_taueff_interpolator->interpolate(input_values);
859
860 if(randnum<taueff){
861
862 (*m_it)->setTauTagged("Standard");
863 log << MSG::DEBUG << "setTauTagged(\"Standard\"), pT = " << (*m_it)->pT() << endreq;
864
865 }
866
867 }else if(abs(etajet)<=2.5){
868
869 double taurej = m_taurej_interpolator->interpolate(input_values);
870
871
872 if (!taurej) taurej = 1e9;
873
874 if(randnum<(1./taurej)){
875 (*m_it)->setTauTagged("Standard");
876 log << MSG::DEBUG << "setTauTagged(\"Standard\"), pT = " << (*m_it)->pT() << endreq;
877 }
878
879 }
880
881 }
882
883 return StatusCode::SUCCESS;
884
885 }
886
887
888 StatusCode AtlfastB::tautag(double pt,
889 double eta,
890 double efftau,
891 double &rjet, int &iflag){
892
893
894
895
896 MsgStream log( messageService(), name() ) ;
897
898 iflag=0;
899
900
901 double ptInGeV = pt/GeV;
902
903 if((ptInGeV<15.)||(ptInGeV>150.)){
904
905
906 log << MSG::DEBUG<<"Tau pt value out of range (15<pt<150 GeV): pt= "<<ptInGeV
907 <<" GeV No tau tagging efficiencies will be applied"<<endreq;
908
909 iflag=1;
910
911 }
912 if(abs(eta)>2.5){
913
914 log << MSG::DEBUG<<"Tau eta value out of range (eta<2.5): eta= "<<eta<<
915 " No tau tagging efficiencies will be applied"<<endreq;
916
917
918 iflag=1;
919
920 }
921
922
923
924 double eff=efftau;
925 double coefe1;
926 double coefe3;
927 double coef1;
928 double coef2;
929
930 if(abs(eta)<0.7){
931 coefe1=1.35-0.0035*efftau;
932 eff=efftau/coefe1;
933 }
934 if(abs(eta)>1.5){
935 coefe3=0.70+0.0030*efftau;
936 eff=efftau/coefe3;
937 }
938 if(eff>100){
939
940
941 log << MSG::WARNING<<"Tau efficiency value > 100 ! eff= "<<eff<<endreq;
942 iflag=1;
943 }
944
945
946 coef1=0.027+0.00024*ptInGeV;
947 coef2=2.28+0.027*ptInGeV;
948
949 coef1=0.027+0.00024*ptInGeV;
950 coef2=2.28+0.027*ptInGeV;
951 rjet=pow(10,(-coef1*eff+coef2));
952
953
954
955
956
957
958 return StatusCode::SUCCESS;
959
960 }
961
962
963 StatusCode AtlfastB::atlfTau1P3P(){
964
965 MsgStream log( messageService(), name() ) ;
966
967
968 const double MaxPTinGeV = 150.0;
969
970 for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
971 double randnum;
972
973 double etajet=(*m_it)->eta();
974 double ptjet=(*m_it)->pT();
975 int pdgid=(*m_it)->pdg_id();
976
977 randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
978
979 if(abs(pdgid)==15){
980
981 if(ptjet/GeV > MaxPTinGeV){
982 log << MSG::DEBUG<<"Jet with pT="<<ptjet/GeV<<
983 " GeV; Outside range of Tau1P3P - Not Considered for tagging"<<endreq;
984 }else{
985
986 double tau1Peff = m_epsitau1P;
987 double tau3Peff = m_epsitau3P;
988
989
990 if ( ptjet/GeV >= 10.0 && ptjet/GeV < 20.0){ tau3Peff = 0.0; }
991 else if( ptjet/GeV >= 20.0 && ptjet/GeV < 45.0){ tau3Peff = (0.0232*ptjet/GeV-0.044) * m_epsitau3P;}
992 else if( ptjet/GeV >= 45.0 ){tau3Peff = m_epsitau3P;}
993
994 if(randnum<tau1Peff){
995
996 (*m_it)->setTauTagged("Tau1P3P:1prong");
997 (*m_it)->setTauTagCorrFactor("Tau1P3P", 1. );
998 log << MSG::DEBUG << "setTauTagged(\"Tau1P3P:1prong\"), pT = " << (*m_it)->pT() << endreq;
999 }else if(randnum>=tau1Peff && randnum<(tau1Peff+tau3Peff) ){
1000
1001 (*m_it)->setTauTagged("Tau1P3P:3prong");
1002 (*m_it)->setTauTagCorrFactor("Tau1P3P", 1. );
1003 log << MSG::DEBUG << "setTauTagged(\"Tau1P3P:3prong\"), pT = " << (*m_it)->pT() << endreq;
1004 }
1005 }
1006 }else if(abs(etajet)<=2.5){
1007
1008 if(ptjet/GeV > MaxPTinGeV){
1009 log << MSG::DEBUG<<"Jet with pT="<<ptjet/GeV<<
1010 " GeV; Outside range of Tau1P3P - Not Considered for tagging"<<endreq;
1011 }else{
1012
1013
1014 double tau1Pprob = 0.0;
1015 double tau3Pprob = 0.0;
1016
1017 if( m_epsitau1P != 0.0 ){
1018 double tau1Prej = -1.0;
1019
1020 if(ptjet/GeV >= 10. && ptjet/GeV < 20.){
1021 tau1Prej = exp(7.585-6.565*m_epsitau1P);}
1022 else if(ptjet/GeV >= 20. && ptjet/GeV < 30.){
1023 tau1Prej = exp(6.863-6.786*m_epsitau1P);}
1024 else if(ptjet/GeV >= 30. && ptjet/GeV < 40.){
1025 tau1Prej = exp(6.995-7.194*m_epsitau1P);}
1026 else if(ptjet/GeV >= 40. && ptjet/GeV < 50.){
1027 tau1Prej = exp(7.199-7.242*m_epsitau1P);}
1028 else if(ptjet/GeV >= 50. && ptjet/GeV < 60.){
1029 tau1Prej = exp(6.857-5.511*m_epsitau1P);}
1030 else if(ptjet/GeV >= 60.){
1031 tau1Prej = exp(7.344-6.331*m_epsitau1P);}
1032
1033 if( tau1Prej != -1.0 ){ tau1Pprob = 1/tau1Prej; }
1034 }
1035
1036 if( m_epsitau3P != 0.0 ){
1037 double tau3Prej = -1.0;
1038
1039 if(ptjet/GeV >= 20. && ptjet/GeV < 30.){
1040 tau3Prej = exp(8.351-26.997*m_epsitau3P);}
1041 else if(ptjet/GeV >= 30. && ptjet/GeV < 40.){
1042 tau3Prej = exp(7.076-25.647*m_epsitau3P);}
1043 else if(ptjet/GeV >= 40. && ptjet/GeV < 50.){
1044 tau3Prej = exp(6.394-21.407*m_epsitau3P);}
1045 else if(ptjet/GeV >= 50. && ptjet/GeV < 60.){
1046 tau3Prej = exp(6.318-20.522*m_epsitau3P);}
1047 else if(ptjet/GeV >= 60.){
1048 tau3Prej = exp(6.477-19.238*m_epsitau3P);}
1049
1050 if( tau3Prej != -1.0 ){ tau3Pprob = 1/tau3Prej; }
1051 }
1052
1053 if( randnum<tau1Pprob ){
1054
1055 double corr = 0.0;
1056 double rand1P;
1057
1058
1059 while( (corr * (*m_it)->pT())/GeV < 10.){
1060
1061 rand1P=m_pRandFlatGenerator->shoot(m_pRandomEngine);
1062
1063 int ptbin = 0;
1064 if(ptjet/GeV >= 10. && ptjet/GeV < 20.){ ptbin = 0; }
1065 else if(ptjet/GeV >= 20. && ptjet/GeV < 30.){ ptbin = 1; }
1066 else if(ptjet/GeV >= 30. && ptjet/GeV < 40.){ ptbin = 2; }
1067 else if(ptjet/GeV >= 40. && ptjet/GeV < 50.){ ptbin = 3; }
1068 else if(ptjet/GeV >= 50. && ptjet/GeV < 60.){ ptbin = 4; }
1069 else if(ptjet/GeV >= 60.){ ptbin = 5; }
1070
1071 for(int ibin = 0; ibin<20; ibin++){
1072 if(m_corr_prob1P[ptbin][ibin] >= rand1P){
1073 log << MSG::DEBUG << "pT = " << (*m_it)->pT() <<
1074 " ptbin = " << ptbin << " rand1P = " << rand1P <<
1075 " corr = " << m_corr1P3P[ibin] << endreq;
1076 corr = m_corr1P3P[ibin];
1077 break;
1078 }
1079 }
1080 }
1081
1082 log << MSG::DEBUG<<"Jet tagged as Tau1P. Initial Jet PT = "<<ptjet<<
1083 "; After rescaling PT = "<<corr*(*m_it)->pT()/GeV <<endreq;
1084 (*m_it)->setTauTagged("Tau1P3P:1prong");
1085 (*m_it)->setTauTagCorrFactor("Tau1P3P",corr);
1086
1087 }else if( randnum>=tau1Pprob && randnum<(tau1Pprob+tau3Pprob) ){
1088
1089
1090 double corr = 0.0;
1091 double rand3P;
1092
1093
1094 while( (corr * (*m_it)->pT())/GeV < 10.){
1095
1096 rand3P=m_pRandFlatGenerator->shoot(m_pRandomEngine);
1097
1098 int ptbin = 0;
1099 if(ptjet/GeV >= 10. && ptjet/GeV < 20.){ ptbin = 0; }
1100 else if(ptjet/GeV >= 20. && ptjet/GeV < 30.){ ptbin = 1; }
1101 else if(ptjet/GeV >= 30. && ptjet/GeV < 40.){ ptbin = 2; }
1102 else if(ptjet/GeV >= 40. && ptjet/GeV < 50.){ ptbin = 3; }
1103 else if(ptjet/GeV >= 50. && ptjet/GeV < 60.){ ptbin = 4; }
1104 else if(ptjet/GeV >= 60.){ ptbin = 5; }
1105
1106 for(int ibin = 0; ibin<20; ibin++){
1107 if(m_corr_prob3P[ptbin][ibin] >= rand3P){
1108 log << MSG::DEBUG << "pT = " << (*m_it)->pT() << " ptbin = "
1109 << ptbin << " rand3P = " << rand3P << " corr = " << m_corr1P3P[ibin] << endreq;
1110 corr = m_corr1P3P[ibin];
1111 break;
1112 }
1113 }
1114 }
1115 if( corr * (*m_it)->pT()/GeV >= 20.0 ){
1116
1117
1118 log << MSG::DEBUG<<"Jet tagged as Tau3P. Initial Jet PT = "<<ptjet<<
1119 "; After rescaling PT = "<<corr*(*m_it)->pT()/GeV <<endreq;
1120 (*m_it)->setTauTagged("Tau1P3P:3prong");
1121 (*m_it)->setTauTagCorrFactor("Tau1P3P",corr);
1122 }
1123 }
1124 }
1125 }
1126 }
1127 return StatusCode::SUCCESS;
1128 }
1129
1130
1131 StatusCode AtlfastB::atlfTauVeto(int ind){
1132
1133 MsgStream log( messageService(), name() ) ;
1134
1135
1136 StatusCode sc;
1137
1138 for(m_it=m_Jets->begin();m_it<m_Jets->end();++m_it){
1139
1140 double randnum;
1141 double efftau;
1142 double effjet;
1143
1144 double ptjet=(*m_it)->pT();
1145 int pdgid=(*m_it)->pdg_id();
1146
1147 sc=tauveto(ptjet,ind,efftau,effjet);
1148 if(sc.isFailure()){
1149 log << MSG::ERROR<<"Cannot compute tau jet rejection"<<endreq;
1150 return StatusCode::FAILURE;
1151 }
1152
1153 randnum=m_pRandFlatGenerator->shoot(m_pRandomEngine);
1154
1155
1156 if(abs(pdgid)==15) {
1157 if(randnum<efftau/100.){
1158
1159
1160 }
1161 }else{
1162 if(randnum>effjet/100.){
1163 (*m_it)->setTauTagged("Veto");
1164 }
1165 }
1166 }
1167
1168 return StatusCode::SUCCESS;
1169 }
1170
1171
1172
1173 StatusCode AtlfastB::tauveto(double pt, int ind, double &efftau, double &effjet){
1174 MsgStream log( messageService(), name() ) ;
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187 double ptInGeV = pt/GeV;
1188
1189 if(ind==1){
1190
1191 efftau=5.;
1192 effjet=36.+1.5*ptInGeV-0.01*pow(ptInGeV,2);
1193 if(ptInGeV>60.) effjet=90.;
1194 }
1195 else if(ind==2){
1196 effjet=90.;
1197 efftau=27.-0.35*ptInGeV;
1198 if(ptInGeV>60.) efftau=5.;
1199
1200 }else{
1201
1202 log << MSG::ERROR<<"Wrong ind values for tauveto method. ind= "
1203 <<ind<<"ind=1 or ind=2"<<endreq;
1204
1205 return StatusCode::FAILURE;
1206 }
1207
1208
1209
1210 return StatusCode::SUCCESS;
1211 }
1212
1213 StatusCode AtlfastB::atlfTrigMuo(){
1214 MsgStream log( messageService(), name() ) ;
1215
1216 log << MSG::INFO<<"atlfTrigMuo is not yet implemented!!!!!!"<<endreq;
1217
1218
1219 return StatusCode::SUCCESS;
1220 }
1221 double AtlfastB::fitcoreb(double pt){
1222
1223
1224 MsgStream log( messageService(), name() ) ;
1225
1226 double core;
1227 double a0,a1,a2,a3,a4,a5;
1228 double xc;
1229
1230
1231 double ptInGeV = pt/GeV;
1232
1233 if(ptInGeV<10.){
1234
1235 core=0.;
1236 }else if(ptInGeV<55.){
1237
1238 a0=1.26694;
1239 a1=0.12241;
1240 a2=-0.10480e-01;
1241 a3=0.33310e-03;
1242 a4=-0.47454e-05;
1243 a5=0.25436e-07;
1244 core=a0+a1*ptInGeV+a2*pow(ptInGeV,2)+
1245 a3*pow(ptInGeV,3)+a4*pow(ptInGeV,4)+
1246 a5*pow(ptInGeV,5);
1247 core=core*1.006;
1248 }else if(ptInGeV<200.){
1249
1250 a0=1.18;
1251 a1=-0.16672e-02;
1252 a2=0.44414e-05;
1253 core=a0+a1*ptInGeV+a2*pow(ptInGeV,2);
1254
1255 }else{
1256
1257 xc=200.;
1258 a0=1.18;
1259 a1=-0.16672e-02;
1260 a2=0.44414e-05;
1261 core=a0+a1*xc+a2*pow(xc,2);
1262 }
1263
1264
1265
1266 return core;
1267
1268 }
1269
1270 double AtlfastB::fitcoreu(double pt){
1271
1272 MsgStream log( messageService(), name() ) ;
1273
1274 double core;
1275 double a0,a1,a2,a3,a4,a5;
1276 double xc;
1277
1278 double ptInGeV = pt/GeV;
1279
1280 if(ptInGeV<10.){
1281
1282 core=0.;
1283
1284
1285
1286
1287
1288 }else if((ptInGeV<45.)&&(ptInGeV>10.)){
1289
1290 a0=1.5065;
1291 a1=0.31468e-01;
1292 a2=-0.36973e-02;
1293 a3=0.11220e-03;
1294 a4=-0.13921e-05;
1295 a5=0.61538e-08;
1296 core=a0+a1*ptInGeV+a2*pow(ptInGeV,2)+
1297 a3*pow(ptInGeV,3)+a4*pow(ptInGeV,4)+
1298 a5*pow(ptInGeV,5);
1299
1300 }else if(ptInGeV<200.){
1301
1302 a0=1.18;
1303 a1=-0.16672e-02;
1304 a2=0.44414e-05;
1305 core=a0+a1*ptInGeV+a2*pow(ptInGeV,2);
1306 core=core/1.025;
1307 }else{
1308
1309 xc=200.;
1310 a0=1.18;
1311 a1=-0.16672e-02;
1312 a2=0.44414e-05;
1313 core=a0+a1*xc+a2*pow(xc,2);
1314 core=core/1.025;
1315 }
1316
1317
1318
1319 return core;
1320
1321 }
1322
1323 void AtlfastB::makeInterpolator(Interpolator* &intptr, string intname, bool contbounds){
1324 MsgStream log( messageService(), name() ) ;
1325 std::string fn = PathResolver::find_file(intname, "DATAPATH");
1326 intptr = new Interpolator(fn);
1327 log << MSG::DEBUG << "Made Interpolator from input file " << fn << endreq;
1328 if (contbounds) intptr->setContinuousBoundaries();
1329 return;
1330 }
1331
1332
1333 }
1334
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|