@@ -112,6 +112,8 @@ class ScoutingEGammaCollectionMonitoring : public DQMEDAnalyzer {
112112 const edm::EDGetTokenT<std::vector<Run3ScoutingElectron>> scoutingElectronCollection_;
113113 const edm::EDGetTokenT<edm::ValueMap<bool >> eleIdMapTightToken_;
114114
115+ const bool useOfflineObject_;
116+
115117 kHistogramsScoutingEGammaCollectionMonitoring histos;
116118};
117119
@@ -121,10 +123,11 @@ ScoutingEGammaCollectionMonitoring::ScoutingEGammaCollectionMonitoring(const edm
121123 algToken_{consumes<BXVector<GlobalAlgBlk>>(iConfig.getParameter <edm::InputTag>(" AlgInputTag" ))},
122124 triggerResultsToken_ (consumes<edm::TriggerResults>(iConfig.getParameter<edm::InputTag>(" TriggerResultTag" ))),
123125 electronCollection_(
124- consumes <edm::View<pat::Electron>>(iConfig.getParameter<edm::InputTag>(" ElectronCollection" ))),
126+ mayConsume <edm::View<pat::Electron>>(iConfig.getParameter<edm::InputTag>(" ElectronCollection" ))),
125127 scoutingElectronCollection_(consumes<std::vector<Run3ScoutingElectron>>(
126128 iConfig.getParameter<edm::InputTag>(" ScoutingElectronCollection" ))),
127- eleIdMapTightToken_(consumes<edm::ValueMap<bool >>(iConfig.getParameter<edm::InputTag>(" eleIdMapTight" ))) {
129+ eleIdMapTightToken_(mayConsume<edm::ValueMap<bool >>(iConfig.getParameter<edm::InputTag>(" eleIdMapTight" ))),
130+ useOfflineObject_(iConfig.getParameter<bool >(" useOfflineObject" )) {
128131 l1GtUtils_ = std::make_shared<l1t::L1TGlobalUtil>(iConfig, consumesCollector (), l1t::UseEventSetupIn::RunAndEvent);
129132 l1Seeds_ = iConfig.getParameter <std::vector<std::string>>(" L1Seeds" );
130133}
@@ -136,11 +139,49 @@ void ScoutingEGammaCollectionMonitoring::analyze(edm::Event const& iEvent, edm::
136139 // Get PAT / Scouting Electron Token //
137140 // //////////////////////////////////////
138141
139- edm::Handle<edm::View<pat::Electron>> patEls;
140- iEvent.getByToken (electronCollection_, patEls);
141- if (patEls.failedToGet ()) {
142- edm::LogWarning (" ScoutingEGammaCollectionMonitoring" ) << " pat::Electron collection not found." ;
143- return ;
142+ if (useOfflineObject_) {
143+ edm::Handle<edm::View<pat::Electron>> patEls;
144+ iEvent.getByToken (electronCollection_, patEls);
145+ if (patEls.failedToGet ()) {
146+ edm::LogWarning (" ScoutingEGammaCollectionMonitoring" ) << " pat::Electron collection not found." ;
147+ return ;
148+ }
149+ edm::LogInfo (" ScoutingEGammaCollectionMonitoring" ) << " Process pat::Electrons: " << patEls->size ();
150+ edm::Handle<edm::ValueMap<bool >> tight_ele_id_decisions;
151+ iEvent.getByToken (eleIdMapTightToken_, tight_ele_id_decisions);
152+
153+ // Fill pat::Electron histograms
154+ histos.patElectron .h1N ->Fill (patEls->size ());
155+ std::vector<int > tight_patElectron_index;
156+ for (size_t i = 0 ; i < patEls->size (); ++i) {
157+ const auto el = patEls->ptrAt (i);
158+ histos.patElectron .electrons .h1Pt ->Fill (el->pt ());
159+ histos.patElectron .electrons .h1Eta ->Fill (el->eta ());
160+ histos.patElectron .electrons .h1Phi ->Fill (el->phi ());
161+ if (((*tight_ele_id_decisions)[el]))
162+ tight_patElectron_index.push_back (i);
163+ }
164+
165+ // Expect pat electrons to be sorted by pt
166+ if (!patEls->empty ()) {
167+ histos.patElectron .electron1 .h1Pt ->Fill (patEls->ptrAt (0 )->pt ());
168+ histos.patElectron .electron1 .h1Eta ->Fill (patEls->ptrAt (0 )->eta ());
169+ histos.patElectron .electron1 .h1Phi ->Fill (patEls->ptrAt (0 )->phi ());
170+ }
171+
172+ if (patEls->size () >= 2 ) {
173+ histos.patElectron .electron2 .h1Pt ->Fill (patEls->ptrAt (1 )->pt ());
174+ histos.patElectron .electron2 .h1Eta ->Fill (patEls->ptrAt (1 )->eta ());
175+ histos.patElectron .electron2 .h1Phi ->Fill (patEls->ptrAt (1 )->phi ());
176+ if (!tight_patElectron_index.empty ()) {
177+ histos.patElectron .h1InvMass12 ->Fill ((patEls->ptrAt (0 )->p4 () + patEls->ptrAt (1 )->p4 ()).mass ());
178+ }
179+ }
180+
181+ if (tight_patElectron_index.size () == 2 ) {
182+ histos.patElectron .h1InvMassID ->Fill (
183+ (patEls->ptrAt (tight_patElectron_index[0 ])->p4 () + patEls->ptrAt (tight_patElectron_index[1 ])->p4 ()).mass ());
184+ }
144185 }
145186
146187 edm::Handle<std::vector<Run3ScoutingElectron>> sctEls;
@@ -150,10 +191,6 @@ void ScoutingEGammaCollectionMonitoring::analyze(edm::Event const& iEvent, edm::
150191 return ;
151192 }
152193
153- edm::Handle<edm::ValueMap<bool >> tight_ele_id_decisions;
154- iEvent.getByToken (eleIdMapTightToken_, tight_ele_id_decisions);
155-
156- edm::LogInfo (" ScoutingEGammaCollectionMonitoring" ) << " Process pat::Electrons: " << patEls->size ();
157194 edm::LogInfo (" ScoutingEGammaCollectionMonitoring" ) << " Process Run3ScoutingElectrons: " << sctEls->size ();
158195
159196 // Trigger
@@ -179,51 +216,6 @@ void ScoutingEGammaCollectionMonitoring::analyze(edm::Event const& iEvent, edm::
179216 }
180217 }
181218
182- // Loop to verify the sorting of pat::Electron collection - REMOVE IN ONLINE
183- // DQM
184- for (size_t i = 1 ; i < patEls->size (); ++i) {
185- if (patEls->ptrAt (i - 1 )->pt () < patEls->ptrAt (i)->pt ()) {
186- edm::LogWarning (" ScoutingEGammaCollectionMonitoring" )
187- << " pat::Electron collection not sorted by PT in descending order"
188- << " will result in random histo filling. \n "
189- << " pat::Electron[" << i << " ].pt() = " << patEls->ptrAt (i)->pt () << " \n "
190- << " pat::Electron[" << i + 1 << " ].pt() = " << patEls->ptrAt (i + 1 )->pt ();
191- }
192- }
193-
194- // Fill pat::Electron histograms
195- histos.patElectron .h1N ->Fill (patEls->size ());
196- std::vector<int > tight_patElectron_index;
197- for (size_t i = 0 ; i < patEls->size (); ++i) {
198- const auto el = patEls->ptrAt (i);
199- histos.patElectron .electrons .h1Pt ->Fill (el->pt ());
200- histos.patElectron .electrons .h1Eta ->Fill (el->eta ());
201- histos.patElectron .electrons .h1Phi ->Fill (el->phi ());
202- if (((*tight_ele_id_decisions)[el]))
203- tight_patElectron_index.push_back (i);
204- }
205-
206- // Expect pat electrons to be sorted by pt
207- if (!patEls->empty ()) {
208- histos.patElectron .electron1 .h1Pt ->Fill (patEls->ptrAt (0 )->pt ());
209- histos.patElectron .electron1 .h1Eta ->Fill (patEls->ptrAt (0 )->eta ());
210- histos.patElectron .electron1 .h1Phi ->Fill (patEls->ptrAt (0 )->phi ());
211- }
212-
213- if (patEls->size () >= 2 ) {
214- histos.patElectron .electron2 .h1Pt ->Fill (patEls->ptrAt (1 )->pt ());
215- histos.patElectron .electron2 .h1Eta ->Fill (patEls->ptrAt (1 )->eta ());
216- histos.patElectron .electron2 .h1Phi ->Fill (patEls->ptrAt (1 )->phi ());
217- if (!tight_patElectron_index.empty ()) {
218- histos.patElectron .h1InvMass12 ->Fill ((patEls->ptrAt (0 )->p4 () + patEls->ptrAt (1 )->p4 ()).mass ());
219- }
220- }
221-
222- if (tight_patElectron_index.size () == 2 ) {
223- histos.patElectron .h1InvMassID ->Fill (
224- (patEls->ptrAt (tight_patElectron_index[0 ])->p4 () + patEls->ptrAt (tight_patElectron_index[1 ])->p4 ()).mass ());
225- }
226-
227219 // Fill the Run3ScoutingElectron histograms. No sorting assumed.
228220 histos.sctElectron .h1N ->Fill (sctEls->size ());
229221 // unsigned int leadSctElIndx = 0, subleadSctElIndx = -1;
@@ -468,6 +460,7 @@ void ScoutingEGammaCollectionMonitoring::fillDescriptions(edm::ConfigurationDesc
468460 desc.add <edm::InputTag>(" ScoutingElectronCollection" , edm::InputTag (" hltScoutingEgammaPacker" ));
469461 desc.add <edm::InputTag>(" eleIdMapTight" ,
470462 edm::InputTag (" egmGsfElectronIDs:cutBasedElectronID-RunIIIWinter22-V1-tight" ));
463+ desc.add <bool >(" useOfflineObject" , true );
471464 descriptions.addWithDefaultLabel (desc);
472465}
473466
0 commit comments