/
GlobalBoard.cc
1170 lines (975 loc) · 43.9 KB
/
GlobalBoard.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
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* \class GlobalBoard
*
*
* Description: Global Trigger Logic board, see header file for details.
*
* Implementation:
* <TODO: enter implementation details>
*
* \author: M. Fierro - HEPHY Vienna - ORCA version
* \author: Vasile Mihai Ghete - HEPHY Vienna - CMSSW version
* \author: Vladimir Rekovic - add correlation with overlap removal cases
* - fractional prescales
* \author: Elisa Fontanesi - extended for three-body correlation conditions
*
* $Date$
* $Revision$
*
*/
// this class header
#include "L1Trigger/L1TGlobal/interface/GlobalBoard.h"
// user include files
#include "DataFormats/L1TGlobal/interface/GlobalObjectMap.h"
#include "L1Trigger/L1TGlobal/interface/TriggerMenu.h"
#include "L1Trigger/L1TGlobal/interface/GlobalAlgorithm.h"
#include "L1Trigger/L1TGlobal/interface/MuonTemplate.h"
#include "L1Trigger/L1TGlobal/interface/MuonShowerTemplate.h"
#include "L1Trigger/L1TGlobal/interface/CaloTemplate.h"
#include "L1Trigger/L1TGlobal/interface/EnergySumTemplate.h"
#include "L1Trigger/L1TGlobal/interface/ExternalTemplate.h"
#include "L1Trigger/L1TGlobal/interface/CorrelationTemplate.h"
#include "L1Trigger/L1TGlobal/interface/CorrelationThreeBodyTemplate.h"
#include "L1Trigger/L1TGlobal/interface/CorrelationWithOverlapRemovalTemplate.h"
#include "L1Trigger/L1TGlobal/interface/GlobalCondition.h"
#include "L1Trigger/L1TGlobal/interface/CorrCondition.h"
#include "L1Trigger/L1TGlobal/interface/CorrWithOverlapRemovalCondition.h"
#include "L1Trigger/L1TGlobal/interface/ConditionEvaluation.h"
#include "L1Trigger/L1TGlobal/interface/AlgorithmEvaluation.h"
// Conditions for uGt
#include "L1Trigger/L1TGlobal/interface/MuCondition.h"
#include "L1Trigger/L1TGlobal/interface/MuonShowerCondition.h"
#include "L1Trigger/L1TGlobal/interface/CaloCondition.h"
#include "L1Trigger/L1TGlobal/interface/EnergySumCondition.h"
#include "L1Trigger/L1TGlobal/interface/ExternalCondition.h"
#include "L1Trigger/L1TGlobal/interface/CorrCondition.h"
#include "L1Trigger/L1TGlobal/interface/CorrThreeBodyCondition.h"
#include "L1Trigger/L1TGlobal/interface/CorrWithOverlapRemovalCondition.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/MessageLogger/interface/MessageDrop.h"
#include "FWCore/Framework/interface/ESHandle.h"
// forward declarations
// constructor
l1t::GlobalBoard::GlobalBoard()
: m_candL1Mu(new BXVector<const l1t::Muon*>),
m_candL1MuShower(new BXVector<const l1t::MuonShower*>),
m_candL1EG(new BXVector<const l1t::L1Candidate*>),
m_candL1Tau(new BXVector<const l1t::L1Candidate*>),
m_candL1Jet(new BXVector<const l1t::L1Candidate*>),
m_candL1EtSum(new BXVector<const l1t::EtSum*>),
m_candL1External(new BXVector<const GlobalExtBlk*>),
m_firstEv(true),
m_firstEvLumiSegment(true),
m_currentLumi(0),
m_isDebugEnabled(edm::isDebugEnabled()) {
m_uGtAlgBlk.reset();
m_gtlAlgorithmOR.reset();
m_gtlDecisionWord.reset();
// initialize cached IDs
m_l1GtMenuCacheID = 0ULL;
m_l1CaloGeometryCacheID = 0ULL;
m_l1MuTriggerScalesCacheID = 0ULL;
// Counter for number of events board sees
m_boardEventCount = 0;
// Need to expand use with more than one uGt GlobalBoard for now assume 1
m_uGtBoardNumber = 0;
m_uGtFinalBoard = true;
}
// destructor
l1t::GlobalBoard::~GlobalBoard() {
//reset(); //why would we need a reset?
delete m_candL1Mu;
delete m_candL1MuShower;
delete m_candL1EG;
delete m_candL1Tau;
delete m_candL1Jet;
delete m_candL1EtSum;
delete m_candL1External;
// delete m_gtEtaPhiConversions;
}
// operations
void l1t::GlobalBoard::setBxFirst(int bx) { m_bxFirst_ = bx; }
void l1t::GlobalBoard::setBxLast(int bx) { m_bxLast_ = bx; }
void l1t::GlobalBoard::init(const int numberPhysTriggers,
const int nrL1Mu,
const int nrL1MuShower,
const int nrL1EG,
const int nrL1Tau,
const int nrL1Jet,
int bxFirst,
int bxLast) {
setBxFirst(bxFirst);
setBxLast(bxLast);
m_candL1Mu->setBXRange(m_bxFirst_, m_bxLast_);
m_candL1MuShower->setBXRange(m_bxFirst_, m_bxLast_);
m_candL1EG->setBXRange(m_bxFirst_, m_bxLast_);
m_candL1Tau->setBXRange(m_bxFirst_, m_bxLast_);
m_candL1Jet->setBXRange(m_bxFirst_, m_bxLast_);
m_candL1EtSum->setBXRange(m_bxFirst_, m_bxLast_);
m_candL1External->setBXRange(m_bxFirst_, m_bxLast_);
m_uGtAlgBlk.reset();
LogDebug("L1TGlobal") << "\t Initializing Board with bxFirst = " << m_bxFirst_ << ", bxLast = " << m_bxLast_
<< std::endl;
}
// receive data from Calorimeter
void l1t::GlobalBoard::receiveCaloObjectData(edm::Event& iEvent,
const edm::EDGetTokenT<BXVector<l1t::EGamma>>& egInputToken,
const edm::EDGetTokenT<BXVector<l1t::Tau>>& tauInputToken,
const edm::EDGetTokenT<BXVector<l1t::Jet>>& jetInputToken,
const edm::EDGetTokenT<BXVector<l1t::EtSum>>& sumInputToken,
const bool receiveEG,
const int nrL1EG,
const bool receiveTau,
const int nrL1Tau,
const bool receiveJet,
const int nrL1Jet,
const bool receiveEtSums) {
if (m_verbosity) {
LogDebug("L1TGlobal") << "\n**** Board receiving Calo Data "
//<< "\n from input tag " << caloInputTag << "\n"
<< std::endl;
}
resetCalo();
// get data from Calorimeter
if (receiveEG) {
edm::Handle<BXVector<l1t::EGamma>> egData;
iEvent.getByToken(egInputToken, egData);
if (!egData.isValid()) {
if (m_verbosity) {
edm::LogWarning("L1TGlobal") << "\nWarning: BXVector<l1t::EGamma> with input tag "
//<< caloInputTag
<< "\nrequested in configuration, but not found in the event.\n"
<< std::endl;
}
} else {
// bx in EG data
for (int i = egData->getFirstBX(); i <= egData->getLastBX(); ++i) {
// Prevent from pushing back bx that is outside of allowed range
if (i < m_bxFirst_ || i > m_bxLast_)
continue;
//Loop over EG in this bx
int nObj = 0;
for (std::vector<l1t::EGamma>::const_iterator eg = egData->begin(i); eg != egData->end(i); ++eg) {
if (nObj < nrL1EG) {
(*m_candL1EG).push_back(i, &(*eg));
} else {
edm::LogWarning("L1TGlobal") << " Too many EG (" << nObj << ") for uGT Configuration maxEG =" << nrL1EG
<< std::endl;
}
LogDebug("L1TGlobal") << "EG Pt " << eg->hwPt() << " Eta " << eg->hwEta() << " Phi " << eg->hwPhi()
<< " Qual " << eg->hwQual() << " Iso " << eg->hwIso() << std::endl;
nObj++;
} //end loop over EG in bx
} //end loop over bx
} //end if over valid EG data
} //end if ReveiveEG data
if (receiveTau) {
edm::Handle<BXVector<l1t::Tau>> tauData;
iEvent.getByToken(tauInputToken, tauData);
if (!tauData.isValid()) {
if (m_verbosity) {
edm::LogWarning("L1TGlobal") << "\nWarning: BXVector<l1t::Tau> with input tag "
//<< caloInputTag
<< "\nrequested in configuration, but not found in the event.\n"
<< std::endl;
}
} else {
// bx in tau data
for (int i = tauData->getFirstBX(); i <= tauData->getLastBX(); ++i) {
// Prevent from pushing back bx that is outside of allowed range
if (i < m_bxFirst_ || i > m_bxLast_)
continue;
//Loop over tau in this bx
int nObj = 0;
for (std::vector<l1t::Tau>::const_iterator tau = tauData->begin(i); tau != tauData->end(i); ++tau) {
if (nObj < nrL1Tau) {
(*m_candL1Tau).push_back(i, &(*tau));
} else {
LogTrace("L1TGlobal") << " Too many Tau (" << nObj << ") for uGT Configuration maxTau =" << nrL1Tau
<< std::endl;
}
LogDebug("L1TGlobal") << "tau Pt " << tau->hwPt() << " Eta " << tau->hwEta() << " Phi " << tau->hwPhi()
<< " Qual " << tau->hwQual() << " Iso " << tau->hwIso() << std::endl;
nObj++;
} //end loop over tau in bx
} //end loop over bx
} //end if over valid tau data
} //end if ReveiveTau data
if (receiveJet) {
edm::Handle<BXVector<l1t::Jet>> jetData;
iEvent.getByToken(jetInputToken, jetData);
if (!jetData.isValid()) {
if (m_verbosity) {
edm::LogWarning("L1TGlobal") << "\nWarning: BXVector<l1t::Jet> with input tag "
//<< caloInputTag
<< "\nrequested in configuration, but not found in the event.\n"
<< std::endl;
}
} else {
// bx in jet data
for (int i = jetData->getFirstBX(); i <= jetData->getLastBX(); ++i) {
// Prevent from pushing back bx that is outside of allowed range
if (i < m_bxFirst_ || i > m_bxLast_)
continue;
//Loop over jet in this bx
int nObj = 0;
for (std::vector<l1t::Jet>::const_iterator jet = jetData->begin(i); jet != jetData->end(i); ++jet) {
if (nObj < nrL1Jet) {
(*m_candL1Jet).push_back(i, &(*jet));
} else {
edm::LogWarning("L1TGlobal") << " Too many Jets (" << nObj << ") for uGT Configuration maxJet =" << nrL1Jet
<< std::endl;
}
LogDebug("L1TGlobal") << "Jet Pt " << jet->hwPt() << " Eta " << jet->hwEta() << " Phi " << jet->hwPhi()
<< " Qual " << jet->hwQual() << " Iso " << jet->hwIso() << std::endl;
nObj++;
} //end loop over jet in bx
} //end loop over bx
} //end if over valid jet data
} //end if ReveiveJet data
if (receiveEtSums) {
edm::Handle<BXVector<l1t::EtSum>> etSumData;
iEvent.getByToken(sumInputToken, etSumData);
if (!etSumData.isValid()) {
if (m_verbosity) {
edm::LogWarning("L1TGlobal") << "\nWarning: BXVector<l1t::EtSum> with input tag "
//<< caloInputTag
<< "\nrequested in configuration, but not found in the event.\n"
<< std::endl;
}
} else {
for (int i = etSumData->getFirstBX(); i <= etSumData->getLastBX(); ++i) {
// Prevent from pushing back bx that is outside of allowed range
if (i < m_bxFirst_ || i > m_bxLast_)
continue;
//Loop over jet in this bx
for (std::vector<l1t::EtSum>::const_iterator etsum = etSumData->begin(i); etsum != etSumData->end(i); ++etsum) {
(*m_candL1EtSum).push_back(i, &(*etsum));
/* In case we need to split these out
switch ( etsum->getType() ) {
case l1t::EtSum::EtSumType::kMissingEt:
{
//(*m_candETM).push_back(i,&(*etsum));
LogDebug("L1TGlobal") << "ETM: Pt " << etsum->hwPt() << " Phi " << etsum->hwPhi() << std::endl;
}
break;
case l1t::EtSum::EtSumType::kMissingHt:
{
//(*m_candHTM).push_back(i,&(*etsum));
LogDebug("L1TGlobal") << "HTM: Pt " << etsum->hwPt() << " Phi " << etsum->hwPhi() << std::endl;
}
break;
case l1t::EtSum::EtSumType::kTotalEt:
{
//(*m_candETT).push_back(i,&(*etsum));
LogDebug("L1TGlobal") << "ETT: Pt " << etsum->hwPt() << std::endl;
}
break;
case l1t::EtSum::EtSumType::kTotalHt:
{
//(*m_candHTT).push_back(i,&(*etsum));
LogDebug("L1TGlobal") << "HTT: Pt " << etsum->hwPt() << std::endl;
}
break;
case l1t::EtSum::EtSumType::kTowerCount:
{
//(*m_candTowerCount).push_back(i,&(*etsum));
LogDebug("L1TGlobal") << "TowerCount: " << etsum->hwPt() << std::endl;
}
break;
default:
LogDebug("L1TGlobal") << "Default encounted " << std::endl;
break;
}
*/
} //end loop over jet in bx
} //end loop over Bx
}
}
}
// receive data from Global Muon Trigger
void l1t::GlobalBoard::receiveMuonObjectData(edm::Event& iEvent,
const edm::EDGetTokenT<BXVector<l1t::Muon>>& muInputToken,
const bool receiveMu,
const int nrL1Mu) {
if (m_verbosity) {
LogDebug("L1TGlobal") << "\n**** GlobalBoard receiving muon data = "
//<< "\n from input tag " << muInputTag << "\n"
<< std::endl;
}
resetMu();
// get data from Global Muon Trigger
if (receiveMu) {
edm::Handle<BXVector<l1t::Muon>> muonData;
iEvent.getByToken(muInputToken, muonData);
if (!muonData.isValid()) {
if (m_verbosity) {
edm::LogWarning("L1TGlobal") << "\nWarning: BXVector<l1t::Muon> with input tag "
//<< muInputTag
<< "\nrequested in configuration, but not found in the event.\n"
<< std::endl;
}
} else {
// bx in muon data
for (int i = muonData->getFirstBX(); i <= muonData->getLastBX(); ++i) {
// Prevent from pushing back bx that is outside of allowed range
if (i < m_bxFirst_ || i > m_bxLast_)
continue;
//Loop over Muons in this bx
int nObj = 0;
for (std::vector<l1t::Muon>::const_iterator mu = muonData->begin(i); mu != muonData->end(i); ++mu) {
if (nObj < nrL1Mu) {
(*m_candL1Mu).push_back(i, &(*mu));
} else {
edm::LogWarning("L1TGlobal") << " Too many Muons (" << nObj << ") for uGT Configuration maxMu =" << nrL1Mu
<< std::endl;
}
LogDebug("L1TGlobal") << "Muon Pt " << mu->hwPt() << " EtaAtVtx " << mu->hwEtaAtVtx() << " PhiAtVtx "
<< mu->hwPhiAtVtx() << " Qual " << mu->hwQual() << " Iso " << mu->hwIso()
<< std::endl;
nObj++;
} //end loop over muons in bx
} //end loop over bx
} //end if over valid muon data
} //end if ReveiveMuon data
}
// receive muon shower data from Global Muon Trigger
void l1t::GlobalBoard::receiveMuonShowerObjectData(edm::Event& iEvent,
const edm::EDGetTokenT<BXVector<l1t::MuonShower>>& muShowerInputToken,
const bool receiveMuShower,
const int nrL1MuShower) {
// get data from Global Muon Trigger
if (receiveMuShower) {
edm::Handle<BXVector<l1t::MuonShower>> muonData;
iEvent.getByToken(muShowerInputToken, muonData);
if (!muonData.isValid()) {
if (m_verbosity) {
edm::LogWarning("L1TGlobal") << "\nWarning: BXVector<l1t::MuonShower> with input tag "
<< "\nrequested in configuration, but not found in the event.\n"
<< std::endl;
}
} else {
//Loop over Muon Showers in this bx
int nObj = 0;
for (auto mu = muonData->begin(0); mu != muonData->end(0); ++mu) {
if (nObj < nrL1MuShower) {
/* Important here to split up the single object into 4 separate MuonShower
bits for the global board. This is because the UTM library considers those bits separate as well
*/
l1t::MuonShower mus0;
l1t::MuonShower mus1;
l1t::MuonShower musOutOfTime0;
l1t::MuonShower musOutOfTime1;
mus0.setMus0(mu->mus0());
mus1.setMus1(mu->mus1());
musOutOfTime0.setMusOutOfTime0(mu->musOutOfTime0());
musOutOfTime1.setMusOutOfTime1(mu->musOutOfTime1());
(*m_candL1MuShower).push_back(0, &mus0);
(*m_candL1MuShower).push_back(0, &mus1);
(*m_candL1MuShower).push_back(0, &musOutOfTime0);
(*m_candL1MuShower).push_back(0, &musOutOfTime1);
} else {
edm::LogWarning("L1TGlobal") << " Too many Muon Showers (" << nObj
<< ") for uGT Configuration maxMuShower =" << nrL1MuShower << std::endl;
}
nObj++;
} //end loop over muon showers in bx
} //end if over valid muon shower data
} //end if ReveiveMuonShower data
}
// receive data from Global External Conditions
void l1t::GlobalBoard::receiveExternalData(edm::Event& iEvent,
const edm::EDGetTokenT<BXVector<GlobalExtBlk>>& extInputToken,
const bool receiveExt) {
if (m_verbosity) {
LogDebug("L1TGlobal") << "\n**** GlobalBoard receiving external data = "
//<< "\n from input tag " << muInputTag << "\n"
<< std::endl;
}
resetExternal();
// get data from Global Muon Trigger
if (receiveExt) {
edm::Handle<BXVector<GlobalExtBlk>> extData;
iEvent.getByToken(extInputToken, extData);
if (!extData.isValid()) {
if (m_verbosity) {
edm::LogWarning("L1TGlobal") << "\nWarning: BXVector<GlobalExtBlk> with input tag "
//<< muInputTag
<< "\nrequested in configuration, but not found in the event.\n"
<< std::endl;
}
} else {
// bx in muon data
for (int i = extData->getFirstBX(); i <= extData->getLastBX(); ++i) {
// Prevent from pushing back bx that is outside of allowed range
if (i < m_bxFirst_ || i > m_bxLast_)
continue;
//Loop over ext in this bx
for (std::vector<GlobalExtBlk>::const_iterator ext = extData->begin(i); ext != extData->end(i); ++ext) {
(*m_candL1External).push_back(i, &(*ext));
} //end loop over ext in bx
} //end loop over bx
} //end if over valid ext data
} //end if ReveiveExt data
}
// run GTL
void l1t::GlobalBoard::runGTL(edm::Event& iEvent,
const edm::EventSetup& evSetup,
const TriggerMenu* m_l1GtMenu,
const bool produceL1GtObjectMapRecord,
const int iBxInEvent,
std::unique_ptr<GlobalObjectMapRecord>& gtObjectMapRecord,
const unsigned int numberPhysTriggers,
const int nrL1Mu,
const int nrL1MuShower,
const int nrL1EG,
const int nrL1Tau,
const int nrL1Jet) {
const std::vector<ConditionMap>& conditionMap = m_l1GtMenu->gtConditionMap();
const AlgorithmMap& algorithmMap = m_l1GtMenu->gtAlgorithmMap();
const GlobalScales& gtScales = m_l1GtMenu->gtScales();
const std::string scaleSetName = gtScales.getScalesName();
LogDebug("L1TGlobal") << " L1 Menu Scales -- Set Name: " << scaleSetName << std::endl;
// Reset AlgBlk for this bx
m_uGtAlgBlk.reset();
m_algInitialOr = false;
m_algPrescaledOr = false;
m_algIntermOr = false;
m_algFinalOr = false;
m_algFinalOrVeto = false;
const std::vector<std::vector<MuonTemplate>>& corrMuon = m_l1GtMenu->corMuonTemplate();
// Comment out for now
const std::vector<std::vector<CaloTemplate>>& corrCalo = m_l1GtMenu->corCaloTemplate();
const std::vector<std::vector<EnergySumTemplate>>& corrEnergySum = m_l1GtMenu->corEnergySumTemplate();
LogDebug("L1TGlobal") << "Size corrMuon " << corrMuon.size() << "\nSize corrCalo " << corrCalo.size()
<< "\nSize corrSums " << corrEnergySum.size() << std::endl;
// loop over condition maps (one map per condition chip)
// then loop over conditions in the map
// save the results in temporary maps
// never happens in production but at first event...
if (m_conditionResultMaps.size() != conditionMap.size()) {
m_conditionResultMaps.clear();
m_conditionResultMaps.resize(conditionMap.size());
}
int iChip = -1;
for (std::vector<ConditionMap>::const_iterator itCondOnChip = conditionMap.begin();
itCondOnChip != conditionMap.end();
itCondOnChip++) {
iChip++;
AlgorithmEvaluation::ConditionEvaluationMap& cMapResults = m_conditionResultMaps[iChip];
for (CItCond itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
// evaluate condition
switch ((itCond->second)->condCategory()) {
case CondMuon: {
// BLW Not sure what to do with this for now
const int ifMuEtaNumberBits = 0;
MuCondition* muCondition = new MuCondition(itCond->second, this, nrL1Mu, ifMuEtaNumberBits);
muCondition->setVerbosity(m_verbosity);
muCondition->evaluateConditionStoreResult(iBxInEvent);
// BLW COmment out for now
cMapResults[itCond->first] = muCondition;
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
muCondition->print(myCout);
LogTrace("L1TGlobal") << myCout.str() << std::endl;
}
//delete muCondition;
} break;
case CondMuonShower: {
MuonShowerCondition* muShowerCondition = new MuonShowerCondition(itCond->second, this, nrL1MuShower);
muShowerCondition->setVerbosity(m_verbosity);
muShowerCondition->evaluateConditionStoreResult(iBxInEvent);
cMapResults[itCond->first] = muShowerCondition;
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
muShowerCondition->print(myCout);
edm::LogWarning("L1TGlobal") << "MuonShowerCondition " << myCout.str() << std::endl;
}
//delete muShowerCondition;
} break;
case CondCalo: {
// BLW Not sure w hat to do with this for now
const int ifCaloEtaNumberBits = 0;
CaloCondition* caloCondition =
new CaloCondition(itCond->second, this, nrL1EG, nrL1Jet, nrL1Tau, ifCaloEtaNumberBits);
caloCondition->setVerbosity(m_verbosity);
caloCondition->evaluateConditionStoreResult(iBxInEvent);
cMapResults[itCond->first] = caloCondition;
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
caloCondition->print(myCout);
LogTrace("L1TGlobal") << myCout.str() << std::endl;
}
// delete caloCondition;
} break;
case CondEnergySum: {
EnergySumCondition* eSumCondition = new EnergySumCondition(itCond->second, this);
eSumCondition->setVerbosity(m_verbosity);
eSumCondition->evaluateConditionStoreResult(iBxInEvent);
cMapResults[itCond->first] = eSumCondition;
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
eSumCondition->print(myCout);
LogTrace("L1TGlobal") << myCout.str() << std::endl;
}
// delete eSumCondition;
} break;
case CondExternal: {
ExternalCondition* extCondition = new ExternalCondition(itCond->second, this);
extCondition->setVerbosity(m_verbosity);
extCondition->evaluateConditionStoreResult(iBxInEvent);
cMapResults[itCond->first] = extCondition;
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
extCondition->print(myCout);
LogTrace("L1TGlobal") << myCout.str() << std::endl;
}
// delete extCondition;
} break;
case CondCorrelation: {
// get first the sub-conditions
const CorrelationTemplate* corrTemplate = static_cast<const CorrelationTemplate*>(itCond->second);
const GtConditionCategory cond0Categ = corrTemplate->cond0Category();
const GtConditionCategory cond1Categ = corrTemplate->cond1Category();
const int cond0Ind = corrTemplate->cond0Index();
const int cond1Ind = corrTemplate->cond1Index();
const GlobalCondition* cond0Condition = nullptr;
const GlobalCondition* cond1Condition = nullptr;
// maximum number of objects received for evaluation of l1t::Type1s condition
int cond0NrL1Objects = 0;
int cond1NrL1Objects = 0;
LogDebug("L1TGlobal") << " cond0NrL1Objects" << cond0NrL1Objects << " cond1NrL1Objects " << cond1NrL1Objects
<< std::endl;
switch (cond0Categ) {
case CondMuon: {
cond0Condition = &((corrMuon[iChip])[cond0Ind]);
} break;
case CondCalo: {
cond0Condition = &((corrCalo[iChip])[cond0Ind]);
} break;
case CondEnergySum: {
cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
} break;
default: {
// do nothing, should not arrive here
} break;
}
switch (cond1Categ) {
case CondMuon: {
cond1Condition = &((corrMuon[iChip])[cond1Ind]);
} break;
case CondCalo: {
cond1Condition = &((corrCalo[iChip])[cond1Ind]);
} break;
case CondEnergySum: {
cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
} break;
default: {
// do nothing, should not arrive here
} break;
}
CorrCondition* correlationCond = new CorrCondition(itCond->second, cond0Condition, cond1Condition, this);
correlationCond->setVerbosity(m_verbosity);
correlationCond->setScales(>Scales);
correlationCond->evaluateConditionStoreResult(iBxInEvent);
cMapResults[itCond->first] = correlationCond;
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
correlationCond->print(myCout);
LogTrace("L1TGlobal") << myCout.str() << std::endl;
}
// delete correlationCond;
} break;
case CondCorrelationThreeBody: {
// get first the sub-conditions
const CorrelationThreeBodyTemplate* corrTemplate =
static_cast<const CorrelationThreeBodyTemplate*>(itCond->second);
const GtConditionCategory cond0Categ = corrTemplate->cond0Category();
const GtConditionCategory cond1Categ = corrTemplate->cond1Category();
const GtConditionCategory cond2Categ = corrTemplate->cond2Category();
const int cond0Ind = corrTemplate->cond0Index();
const int cond1Ind = corrTemplate->cond1Index();
const int cond2Ind = corrTemplate->cond2Index();
const GlobalCondition* cond0Condition = nullptr;
const GlobalCondition* cond1Condition = nullptr;
const GlobalCondition* cond2Condition = nullptr;
// maximum number of objects received for evaluation of l1t::Type1s condition
int cond0NrL1Objects = 0;
int cond1NrL1Objects = 0;
int cond2NrL1Objects = 0;
LogDebug("L1TGlobal") << " cond0NrL1Objects " << cond0NrL1Objects << " cond1NrL1Objects "
<< cond1NrL1Objects << " cond2NrL1Objects " << cond2NrL1Objects << std::endl;
if (cond0Categ == CondMuon) {
cond0Condition = &((corrMuon[iChip])[cond0Ind]);
} else {
LogDebug("L1TGlobal") << "No muon0 to evaluate three-body correlation condition";
}
if (cond1Categ == CondMuon) {
cond1Condition = &((corrMuon[iChip])[cond1Ind]);
} else {
LogDebug("L1TGlobal") << "No muon1 to evaluate three-body correlation condition";
}
if (cond2Categ == CondMuon) {
cond2Condition = &((corrMuon[iChip])[cond2Ind]);
} else {
LogDebug("L1TGlobal") << "No muon2 to evaluate three-body correlation condition";
}
CorrThreeBodyCondition* correlationThreeBodyCond =
new CorrThreeBodyCondition(itCond->second, cond0Condition, cond1Condition, cond2Condition, this);
correlationThreeBodyCond->setVerbosity(m_verbosity);
correlationThreeBodyCond->setScales(>Scales);
correlationThreeBodyCond->evaluateConditionStoreResult(iBxInEvent);
cMapResults[itCond->first] = correlationThreeBodyCond;
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
correlationThreeBodyCond->print(myCout);
LogTrace("L1TGlobal") << myCout.str() << std::endl;
}
// delete correlationThreeBodyCond;
} break;
case CondCorrelationWithOverlapRemoval: {
// get first the sub-conditions
const CorrelationWithOverlapRemovalTemplate* corrTemplate =
static_cast<const CorrelationWithOverlapRemovalTemplate*>(itCond->second);
const GtConditionCategory cond0Categ = corrTemplate->cond0Category();
const GtConditionCategory cond1Categ = corrTemplate->cond1Category();
const GtConditionCategory cond2Categ = corrTemplate->cond2Category();
const int cond0Ind = corrTemplate->cond0Index();
const int cond1Ind = corrTemplate->cond1Index();
const int cond2Ind = corrTemplate->cond2Index();
const GlobalCondition* cond0Condition = nullptr;
const GlobalCondition* cond1Condition = nullptr;
const GlobalCondition* cond2Condition = nullptr;
// maximum number of objects received for evaluation of l1t::Type1s condition
int cond0NrL1Objects = 0;
int cond1NrL1Objects = 0;
int cond2NrL1Objects = 0;
LogDebug("L1TGlobal") << " cond0NrL1Objects" << cond0NrL1Objects << " cond1NrL1Objects " << cond1NrL1Objects
<< " cond2NrL1Objects " << cond2NrL1Objects << std::endl;
switch (cond0Categ) {
case CondMuon: {
cond0Condition = &((corrMuon[iChip])[cond0Ind]);
} break;
case CondCalo: {
cond0Condition = &((corrCalo[iChip])[cond0Ind]);
} break;
case CondEnergySum: {
cond0Condition = &((corrEnergySum[iChip])[cond0Ind]);
} break;
default: {
// do nothing, should not arrive here
} break;
}
switch (cond1Categ) {
case CondMuon: {
cond1Condition = &((corrMuon[iChip])[cond1Ind]);
} break;
case CondCalo: {
cond1Condition = &((corrCalo[iChip])[cond1Ind]);
} break;
case CondEnergySum: {
cond1Condition = &((corrEnergySum[iChip])[cond1Ind]);
} break;
default: {
// do nothing, should not arrive here
} break;
}
switch (cond2Categ) {
case CondMuon: {
cond2Condition = &((corrMuon[iChip])[cond2Ind]);
} break;
case CondCalo: {
cond2Condition = &((corrCalo[iChip])[cond2Ind]);
} break;
case CondEnergySum: {
cond2Condition = &((corrEnergySum[iChip])[cond2Ind]);
} break;
default: {
// do nothing, should not arrive here
} break;
}
CorrWithOverlapRemovalCondition* correlationCondWOR =
new CorrWithOverlapRemovalCondition(itCond->second, cond0Condition, cond1Condition, cond2Condition, this);
correlationCondWOR->setVerbosity(m_verbosity);
correlationCondWOR->setScales(>Scales);
correlationCondWOR->evaluateConditionStoreResult(iBxInEvent);
cMapResults[itCond->first] = correlationCondWOR;
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
correlationCondWOR->print(myCout);
LogTrace("L1TGlobal") << myCout.str() << std::endl;
}
// delete correlationCondWOR;
} break;
case CondNull: {
// do nothing
} break;
default: {
// do nothing
} break;
}
}
}
// loop over algorithm map
/// DMP Start debugging here
// empty vector for object maps - filled during loop
std::vector<GlobalObjectMap> objMapVec;
if (produceL1GtObjectMapRecord && (iBxInEvent == 0))
objMapVec.reserve(numberPhysTriggers);
for (CItAlgo itAlgo = algorithmMap.begin(); itAlgo != algorithmMap.end(); itAlgo++) {
AlgorithmEvaluation gtAlg(itAlgo->second);
gtAlg.evaluateAlgorithm((itAlgo->second).algoChipNumber(), m_conditionResultMaps);
int algBitNumber = (itAlgo->second).algoBitNumber();
bool algResult = gtAlg.gtAlgoResult();
LogDebug("L1TGlobal") << " ===> for iBxInEvent = " << iBxInEvent << ":\t algBitName = " << itAlgo->first
<< ",\t algBitNumber = " << algBitNumber << ",\t algResult = " << algResult << std::endl;
if (algResult) {
// m_gtlAlgorithmOR.set(algBitNumber);
m_uGtAlgBlk.setAlgoDecisionInitial(algBitNumber, algResult);
m_algInitialOr = true;
}
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout;
(itAlgo->second).print(myCout);
gtAlg.print(myCout);
LogTrace("L1TGlobal") << myCout.str() << std::endl;
}
// object maps only for BxInEvent = 0
if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
std::vector<L1TObjectTypeInCond> otypes;
for (auto iop = gtAlg.operandTokenVector().begin(); iop != gtAlg.operandTokenVector().end(); ++iop) {
//cout << "INFO: operand name: " << iop->tokenName << "\n";
int myChip = -1;
int found = 0;
L1TObjectTypeInCond otype;
for (auto imap = conditionMap.begin(); imap != conditionMap.end(); imap++) {
myChip++;
auto match = imap->find(iop->tokenName);
if (match != imap->end()) {
found = 1;
//cout << "DEBUG: found match for " << iop->tokenName << " at " << match->first << "\n";
otype = match->second->objectType();
for (auto itype = otype.begin(); itype != otype.end(); itype++) {
//cout << "type: " << *itype << "\n";
}
}
}
if (!found) {
edm::LogWarning("L1TGlobal") << "\n Failed to find match for operand token " << iop->tokenName << "\n";
} else {
otypes.push_back(otype);
}
}
// set object map
GlobalObjectMap objMap;
objMap.setAlgoName(itAlgo->first);
objMap.setAlgoBitNumber(algBitNumber);
objMap.setAlgoGtlResult(algResult);
objMap.swapOperandTokenVector(gtAlg.operandTokenVector());
objMap.swapCombinationVector(gtAlg.gtAlgoCombinationVector());
// gtAlg is empty now...
objMap.swapObjectTypeVector(otypes);
if (m_verbosity && m_isDebugEnabled) {
std::ostringstream myCout1;
objMap.print(myCout1);
LogTrace("L1TGlobal") << myCout1.str() << std::endl;
}
objMapVec.push_back(objMap);
}
}
// object maps only for BxInEvent = 0
if (produceL1GtObjectMapRecord && (iBxInEvent == 0)) {
gtObjectMapRecord->swapGtObjectMap(objMapVec);
}
// loop over condition maps (one map per condition chip)
// then loop over conditions in the map
// delete the conditions created with new, zero pointer, do not clear map, keep the vector as is...
for (std::vector<AlgorithmEvaluation::ConditionEvaluationMap>::iterator itCondOnChip = m_conditionResultMaps.begin();
itCondOnChip != m_conditionResultMaps.end();
itCondOnChip++) {
for (AlgorithmEvaluation::ItEvalMap itCond = itCondOnChip->begin(); itCond != itCondOnChip->end(); itCond++) {
delete itCond->second;
itCond->second = nullptr;
}
}
}
// run GTL
void l1t::GlobalBoard::runFDL(edm::Event& iEvent,
const int iBxInEvent,
const int totalBxInEvent,
const unsigned int numberPhysTriggers,
const std::vector<double>& prescaleFactorsAlgoTrig,
const std::vector<unsigned int>& triggerMaskAlgoTrig,
const std::vector<int>& triggerMaskVetoAlgoTrig,
const bool algorithmTriggersUnprescaled,
const bool algorithmTriggersUnmasked) {
if (m_verbosity) {
LogDebug("L1TGlobal") << "\n**** GlobalBoard apply Final Decision Logic " << std::endl;
}
// prescale counters are reset at the beginning of the luminosity segment
if (m_firstEv) {
// prescale counters: numberPhysTriggers counters per bunch cross
m_prescaleCounterAlgoTrig.reserve(numberPhysTriggers * totalBxInEvent);
for (int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent) {
if (m_semiRandomInitialPSCounters) {
m_prescaleCounterAlgoTrig.push_back(semirandomNumber(iEvent, prescaleFactorsAlgoTrig));
} else {
m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
}
}
m_firstEv = false;
m_currentLumi = iEvent.luminosityBlock();
}
// update and clear prescales at the beginning of the luminosity segment
if (m_firstEvLumiSegment || (m_currentLumi != iEvent.luminosityBlock() && m_resetPSCountersEachLumiSec)) {
m_prescaleCounterAlgoTrig.clear();
for (int iBxInEvent = 0; iBxInEvent <= totalBxInEvent; ++iBxInEvent) {
if (m_semiRandomInitialPSCounters) {
m_prescaleCounterAlgoTrig.push_back(semirandomNumber(iEvent, prescaleFactorsAlgoTrig));
} else {
m_prescaleCounterAlgoTrig.push_back(prescaleFactorsAlgoTrig);
}
}
m_firstEvLumiSegment = false;
m_currentLumi = iEvent.luminosityBlock();
}