CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/HLTrigger/HLTcore/plugins/TriggerSummaryProducerAOD.cc

Go to the documentation of this file.
00001 
00012 #include "HLTrigger/HLTcore/interface/TriggerSummaryProducerAOD.h"
00013 #include "DataFormats/Common/interface/Handle.h"
00014 #include "DataFormats/Common/interface/OrphanHandle.h"
00015 #include "DataFormats/HLTReco/interface/TriggerEvent.h"
00016 #include "DataFormats/Provenance/interface/Provenance.h"
00017 
00018 #include "FWCore/Framework/interface/ProcessMatch.h"
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020 
00021 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00022 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00023 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00024 #include "DataFormats/JetReco/interface/CaloJet.h"
00025 #include "DataFormats/Candidate/interface/CompositeCandidate.h"
00026 #include "DataFormats/METReco/interface/MET.h"
00027 #include "DataFormats/METReco/interface/METFwd.h"
00028 #include "DataFormats/METReco/interface/CaloMET.h"
00029 #include "DataFormats/METReco/interface/CaloMETFwd.h"
00030 #include "DataFormats/HcalIsolatedTrack/interface/IsolatedPixelTrackCandidate.h"
00031 
00032 #include "DataFormats/L1Trigger/interface/L1HFRings.h"
00033 #include "DataFormats/L1Trigger/interface/L1EmParticle.h"
00034 #include "DataFormats/L1Trigger/interface/L1JetParticle.h"
00035 #include "DataFormats/L1Trigger/interface/L1MuonParticle.h"
00036 #include "DataFormats/L1Trigger/interface/L1EtMissParticle.h"
00037 
00038 #include "DataFormats/JetReco/interface/PFJet.h"
00039 #include "DataFormats/TauReco/interface/PFTau.h"
00040 
00041 #include "FWCore/ServiceRegistry/interface/Service.h"
00042 #include "FWCore/Framework/interface/TriggerNamesService.h"
00043 
00044 #include <algorithm>
00045 #include <memory>
00046 #include <typeinfo>
00047 
00048 
00049 //
00050 // constructors and destructor
00051 //
00052 TriggerSummaryProducerAOD::TriggerSummaryProducerAOD(const edm::ParameterSet& ps) : 
00053   pn_(ps.getParameter<std::string>("processName")),
00054   filterTagsEvent_(pn_!="*"),
00055   filterTagsGlobal_(pn_!="*"),
00056   collectionTagsEvent_(pn_!="*"),
00057   collectionTagsGlobal_(pn_!="*"),
00058   toc_(),
00059   tags_(),
00060   offset_(),
00061   keys_(),
00062   ids_(),
00063   maskFilters_()
00064 {
00065   if (pn_=="@") {
00066     edm::Service<edm::service::TriggerNamesService> tns;
00067     if (tns.isAvailable()) {
00068       pn_ = tns->getProcessName();
00069     } else {
00070       edm::LogError("TriggerSummaryProducerAOD") << "HLT Error: TriggerNamesService not available!";
00071       pn_="*";
00072     }
00073 
00074     filterTagsEvent_     =InputTagSet(pn_!="*");
00075     filterTagsGlobal_    =InputTagSet(pn_!="*");
00076     collectionTagsEvent_ =InputTagSet(pn_!="*");
00077     collectionTagsGlobal_=InputTagSet(pn_!="*");
00078   }
00079   LogDebug("TriggerSummaryProducerAOD") << "Using process name: '" << pn_ <<"'";
00080 
00081   filterTagsGlobal_.clear();
00082   collectionTagsGlobal_.clear();
00083 
00084   produces<trigger::TriggerEvent>();
00085 
00086   getTriggerFilterObjectWithRefs_ = edm::GetterOfProducts<trigger::TriggerFilterObjectWithRefs>(edm::ProcessMatch(pn_), this);
00087   getRecoEcalCandidateCollection_ = edm::GetterOfProducts<reco::RecoEcalCandidateCollection>(edm::ProcessMatch(pn_), this);
00088   getElectronCollection_ = edm::GetterOfProducts<reco::ElectronCollection>(edm::ProcessMatch(pn_), this);
00089   getRecoChargedCandidateCollection_ = edm::GetterOfProducts<reco::RecoChargedCandidateCollection>(edm::ProcessMatch(pn_), this);
00090   getCaloJetCollection_ = edm::GetterOfProducts<reco::CaloJetCollection>(edm::ProcessMatch(pn_), this);
00091   getCompositeCandidateCollection_ = edm::GetterOfProducts<reco::CompositeCandidateCollection>(edm::ProcessMatch(pn_), this);
00092   getMETCollection_ = edm::GetterOfProducts<reco::METCollection>(edm::ProcessMatch(pn_), this);
00093   getCaloMETCollection_ = edm::GetterOfProducts<reco::CaloMETCollection>(edm::ProcessMatch(pn_), this);
00094   getIsolatedPixelTrackCandidateCollection_ = edm::GetterOfProducts<reco::IsolatedPixelTrackCandidateCollection>(edm::ProcessMatch(pn_), this);
00095   getL1EmParticleCollection_ = edm::GetterOfProducts<l1extra::L1EmParticleCollection>(edm::ProcessMatch(pn_), this);
00096   getL1MuonParticleCollection_ = edm::GetterOfProducts<l1extra::L1MuonParticleCollection>(edm::ProcessMatch(pn_), this);
00097   getL1JetParticleCollection_ = edm::GetterOfProducts<l1extra::L1JetParticleCollection>(edm::ProcessMatch(pn_), this);
00098   getL1EtMissParticleCollection_ = edm::GetterOfProducts<l1extra::L1EtMissParticleCollection>(edm::ProcessMatch(pn_), this);
00099   getL1HFRingsCollection_ = edm::GetterOfProducts<l1extra::L1HFRingsCollection>(edm::ProcessMatch(pn_), this);
00100   getPFJetCollection_ = edm::GetterOfProducts<reco::PFJetCollection>(edm::ProcessMatch(pn_), this);
00101   getPFTauCollection_ = edm::GetterOfProducts<reco::PFTauCollection>(edm::ProcessMatch(pn_), this);
00102 
00103   callWhenNewProductsRegistered([this](edm::BranchDescription const& bd){
00104     getTriggerFilterObjectWithRefs_(bd);
00105     getRecoEcalCandidateCollection_(bd);
00106     getElectronCollection_(bd);
00107     getRecoChargedCandidateCollection_(bd);
00108     getCaloJetCollection_(bd);
00109     getCompositeCandidateCollection_(bd);
00110     getMETCollection_(bd);
00111     getCaloMETCollection_(bd);
00112     getIsolatedPixelTrackCandidateCollection_(bd);
00113     getL1EmParticleCollection_(bd);
00114     getL1MuonParticleCollection_(bd);
00115     getL1JetParticleCollection_(bd);
00116     getL1EtMissParticleCollection_(bd);
00117     getL1HFRingsCollection_(bd);
00118     getPFJetCollection_(bd);
00119     getPFTauCollection_(bd);
00120   });
00121 }
00122 
00123 TriggerSummaryProducerAOD::~TriggerSummaryProducerAOD()
00124 {
00125 }
00126 
00127 //
00128 // member functions
00129 //
00130 
00131 namespace {
00132   inline void
00133   tokenizeTag(const std::string& tag, std::string& label, std::string& instance, std::string& process){
00134     
00135     using std::string;
00136     
00137     const char token(':');
00138     const string empty;
00139     
00140     label=tag;
00141     const string::size_type i1(label.find(token));
00142     if (i1==string::npos) {
00143       instance=empty;
00144       process=empty;
00145     } else {
00146       instance=label.substr(i1+1);
00147       label.resize(i1);
00148       const string::size_type i2(instance.find(token));
00149       if (i2==string::npos) {
00150         process=empty;
00151       } else {
00152         process=instance.substr(i2+1);
00153         instance.resize(i2);
00154       }
00155     }
00156   }
00157 }
00158 
00159 // ------------ method called to produce the data  ------------
00160 void
00161 TriggerSummaryProducerAOD::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00162 {
00163    using namespace std;
00164    using namespace edm;
00165    using namespace reco;
00166    using namespace l1extra;
00167    using namespace trigger;
00168 
00169    std::vector<edm::Handle<trigger::TriggerFilterObjectWithRefs> > fobs;
00170    getTriggerFilterObjectWithRefs_.fillHandles(iEvent, fobs);
00171 
00172    const unsigned int nfob(fobs.size());
00173    LogTrace("TriggerSummaryProducerAOD") << "Number of filter  objects found: " << nfob;
00174 
00175    string tagLabel,tagInstance,tagProcess;
00176 
00182    maskFilters_.clear();
00183    maskFilters_.resize(nfob);
00184    filterTagsEvent_.clear();
00185    collectionTagsEvent_.clear();
00186    unsigned int nf(0);
00187    for (unsigned int ifob=0; ifob!=nfob; ++ifob) {
00188      maskFilters_[ifob]=false;
00189      const vector<string>& collectionTags_(fobs[ifob]->getCollectionTagsAsStrings());
00190      const unsigned int ncol(collectionTags_.size());
00191      if (ncol>0) {
00192        nf++;
00193        maskFilters_[ifob]=true;
00194        const string& label    (fobs[ifob].provenance()->moduleLabel());
00195        const string& instance (fobs[ifob].provenance()->productInstanceName());
00196        const string& process  (fobs[ifob].provenance()->processName());
00197        filterTagsEvent_.insert(InputTag(label,instance,process));
00198        for (unsigned int icol=0; icol!=ncol; ++icol) {
00199          // overwrite process name (usually not set)
00200          tokenizeTag(collectionTags_[icol],tagLabel,tagInstance,tagProcess);
00201          collectionTagsEvent_.insert(InputTag(tagLabel,tagInstance,pn_));
00202        }
00203      }
00204    }
00206    if (filterTagsEvent_.size()!=nf) {
00207      LogError("TriggerSummaryProducerAOD")
00208        << "Mismatch in number of filter tags: "
00209        << filterTagsEvent_.size() << "!=" << nf ;
00210    }
00211 
00213    collectionTagsGlobal_.insert(collectionTagsEvent_.begin(),collectionTagsEvent_.end());
00214    filterTagsGlobal_.insert(filterTagsEvent_.begin(),filterTagsEvent_.end());
00215 
00217    if (isDebugEnabled()) {
00218 
00220      const unsigned int nc(collectionTagsEvent_.size());
00221      LogTrace("TriggerSummaryProducerAOD") << "Number of unique collections requested " << nc;
00222      const InputTagSet::const_iterator cb(collectionTagsEvent_.begin());
00223      const InputTagSet::const_iterator ce(collectionTagsEvent_.end());
00224      for ( InputTagSet::const_iterator ci=cb; ci!=ce; ++ci) {
00225        LogTrace("TriggerSummaryProducerAOD") << distance(cb,ci) << " " << ci->encode();
00226      }
00227      const unsigned int nf(filterTagsEvent_.size());
00228      LogTrace("TriggerSummaryProducerAOD") << "Number of unique filters requested " << nf;
00229      const InputTagSet::const_iterator fb(filterTagsEvent_.begin());
00230      const InputTagSet::const_iterator fe(filterTagsEvent_.end());
00231      for ( InputTagSet::const_iterator fi=fb; fi!=fe; ++fi) {
00232        LogTrace("TriggerSummaryProducerAOD") << distance(fb,fi) << " " << fi->encode();
00233      }
00234 
00235    }
00236 
00242    toc_.clear();
00243    tags_.clear();
00244    keys_.clear();
00245    offset_.clear();
00246    fillTriggerObjectCollections<          RecoEcalCandidateCollection>(iEvent, getRecoEcalCandidateCollection_);
00247    fillTriggerObjectCollections<                   ElectronCollection>(iEvent, getElectronCollection_);
00248    fillTriggerObjectCollections<       RecoChargedCandidateCollection>(iEvent, getRecoChargedCandidateCollection_);
00249    fillTriggerObjectCollections<                    CaloJetCollection>(iEvent, getCaloJetCollection_);
00250    fillTriggerObjectCollections<         CompositeCandidateCollection>(iEvent, getCompositeCandidateCollection_);
00251    fillTriggerObjectCollections<                        METCollection>(iEvent, getMETCollection_);
00252    fillTriggerObjectCollections<                    CaloMETCollection>(iEvent, getCaloMETCollection_);
00253    fillTriggerObjectCollections<IsolatedPixelTrackCandidateCollection>(iEvent, getIsolatedPixelTrackCandidateCollection_);
00255    fillTriggerObjectCollections<               L1EmParticleCollection>(iEvent, getL1EmParticleCollection_);
00256    fillTriggerObjectCollections<             L1MuonParticleCollection>(iEvent, getL1MuonParticleCollection_);
00257    fillTriggerObjectCollections<              L1JetParticleCollection>(iEvent, getL1JetParticleCollection_);
00258    fillTriggerObjectCollections<           L1EtMissParticleCollection>(iEvent, getL1EtMissParticleCollection_);
00259    fillTriggerObjectCollections<                  L1HFRingsCollection>(iEvent, getL1HFRingsCollection_);
00261    fillTriggerObjectCollections<                      PFJetCollection>(iEvent, getPFJetCollection_);
00262    fillTriggerObjectCollections<                      PFTauCollection>(iEvent, getPFTauCollection_);
00264    const unsigned int nk(tags_.size());
00265    LogDebug("TriggerSummaryProducerAOD") << "Number of collections found: " << nk;
00266    const unsigned int no(toc_.size());
00267    LogDebug("TriggerSummaryProducerAOD") << "Number of physics objects found: " << no;
00268 
00271    auto_ptr<TriggerEvent> product(new TriggerEvent(pn_,nk,no,nf));
00272 
00274    product->addCollections(tags_,keys_);
00275    product->addObjects(toc_);
00276 
00278    for (unsigned int ifob=0; ifob!=nfob; ++ifob) {
00279      if (maskFilters_[ifob]) {
00280        const string& label    (fobs[ifob].provenance()->moduleLabel());
00281        const string& instance (fobs[ifob].provenance()->productInstanceName());
00282        const string& process  (fobs[ifob].provenance()->processName());
00283        const edm::InputTag filterTag(label,instance,process);
00284        ids_.clear();
00285        keys_.clear();
00286        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->photonIds()   ,fobs[ifob]->photonRefs());
00287        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->electronIds() ,fobs[ifob]->electronRefs());
00288        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->muonIds()     ,fobs[ifob]->muonRefs());
00289        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->jetIds()      ,fobs[ifob]->jetRefs());
00290        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->compositeIds(),fobs[ifob]->compositeRefs());
00291        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->basemetIds()  ,fobs[ifob]->basemetRefs());
00292        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->calometIds()  ,fobs[ifob]->calometRefs());
00293        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->pixtrackIds() ,fobs[ifob]->pixtrackRefs());
00294        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->l1emIds()     ,fobs[ifob]->l1emRefs());
00295        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->l1muonIds()   ,fobs[ifob]->l1muonRefs());
00296        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->l1jetIds()    ,fobs[ifob]->l1jetRefs());
00297        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->l1etmissIds() ,fobs[ifob]->l1etmissRefs());
00298        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->l1hfringsIds(),fobs[ifob]->l1hfringsRefs());
00299        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->pfjetIds()    ,fobs[ifob]->pfjetRefs());
00300        fillFilterObjectMembers(iEvent,filterTag,fobs[ifob]->pftauIds()    ,fobs[ifob]->pftauRefs());
00301        product->addFilter(filterTag,ids_,keys_);
00302      }
00303    }
00304 
00305    OrphanHandle<TriggerEvent> ref = iEvent.put(product);
00306    LogTrace("TriggerSummaryProducerAOD") << "Number of physics objects packed: " << ref->sizeObjects();
00307    LogTrace("TriggerSummaryProducerAOD") << "Number of filter  objects packed: " << ref->sizeFilters();
00308 
00309 }
00310 
00311 template <typename C>
00312 void TriggerSummaryProducerAOD::fillTriggerObjectCollections(const edm::Event& iEvent, edm::GetterOfProducts<C>& getter) {
00313 
00317 
00318   using namespace std;
00319   using namespace edm;
00320   using namespace reco;
00321   using namespace l1extra;
00322   using namespace trigger;
00323 
00324   vector<Handle<C> > collections;
00325   getter.fillHandles(iEvent, collections);
00326   const unsigned int nc(collections.size());
00327 
00328   for (unsigned int ic=0; ic!=nc; ++ic) {
00329     const Provenance& provenance(*(collections[ic].provenance()));
00330     const string& label    (provenance.moduleLabel());
00331     const string& instance (provenance.productInstanceName());
00332     const string& process  (provenance.processName());
00333     const InputTag collectionTag(label,instance,process);
00334 
00335     if (collectionTagsEvent_.find(collectionTag)!=collectionTagsEvent_.end()) {
00336       const ProductID pid(collections[ic].provenance()->productID());
00337       if (offset_.find(pid)!=offset_.end()) {
00338         LogError("TriggerSummaryProducerAOD") << "Duplicate pid!";
00339       }
00340       offset_[pid]=toc_.size();
00341       const unsigned int n(collections[ic]->size());
00342       for (unsigned int i=0; i!=n; ++i) {
00343         fillTriggerObject( (*collections[ic])[i] );
00344       }
00345       tags_.push_back(collectionTag.encode());
00346       keys_.push_back(toc_.size());
00347     }
00348 
00349   } 
00350 }
00351 
00352 template <typename T>
00353 void TriggerSummaryProducerAOD::fillTriggerObject(const T& object) {
00354 
00355   using namespace trigger;
00356   toc_.push_back( TriggerObject(object) );
00357 
00358   return;
00359 }
00360 
00361 void TriggerSummaryProducerAOD::fillTriggerObject(const l1extra::L1HFRings& object) {
00362 
00363   using namespace l1extra;
00364   using namespace trigger;
00365 
00366   toc_.push_back(TriggerObject(TriggerL1HfRingEtSums,
00367        object.hfEtSum(L1HFRings::kRing1PosEta),
00368        object.hfEtSum(L1HFRings::kRing1NegEta),
00369        object.hfEtSum(L1HFRings::kRing2PosEta),
00370        object.hfEtSum(L1HFRings::kRing2NegEta) ) );
00371   toc_.push_back(TriggerObject(TriggerL1HfBitCounts,
00372        object.hfBitCount(L1HFRings::kRing1PosEta),
00373        object.hfBitCount(L1HFRings::kRing1NegEta),
00374        object.hfBitCount(L1HFRings::kRing2PosEta),
00375        object.hfBitCount(L1HFRings::kRing2NegEta) ) );
00376 
00377   return;
00378 }
00379 
00380 void TriggerSummaryProducerAOD::fillTriggerObject(const l1extra::L1EtMissParticle& object) {
00381 
00382   using namespace l1extra;
00383   using namespace trigger;
00384 
00385   toc_.push_back( TriggerObject(object) );
00386   if (object.type()==L1EtMissParticle::kMET) {
00387     toc_.push_back(TriggerObject(TriggerL1ETT,object.etTotal(),0.0,0.0,0.0));
00388   } else if (object.type()==L1EtMissParticle::kMHT) {
00389     toc_.push_back(TriggerObject(TriggerL1HTT,object.etTotal(),0.0,0.0,0.0));
00390   } else {
00391     toc_.push_back(TriggerObject(0,           object.etTotal(),0.0,0.0,0.0));
00392   }
00393 
00394   return;
00395 }
00396 
00397 void TriggerSummaryProducerAOD::fillTriggerObject(const reco::CaloMET& object) {
00398 
00399   using namespace reco;
00400   using namespace trigger;
00401 
00402   toc_.push_back( TriggerObject(object) );
00403   toc_.push_back(TriggerObject(TriggerTET    ,object.sumEt()         ,0.0,0.0,0.0));
00404   toc_.push_back(TriggerObject(TriggerMETSig ,object.mEtSig()        ,0.0,0.0,0.0));
00405   toc_.push_back(TriggerObject(TriggerELongit,object.e_longitudinal(),0.0,0.0,0.0));
00406 
00407   return;
00408 }
00409 
00410 void TriggerSummaryProducerAOD::fillTriggerObject(const reco::MET& object) {
00411 
00412   using namespace reco;
00413   using namespace trigger;
00414 
00415   toc_.push_back( TriggerObject(object) );
00416   toc_.push_back(TriggerObject(TriggerTHT    ,object.sumEt()         ,0.0,0.0,0.0));
00417   toc_.push_back(TriggerObject(TriggerMHTSig ,object.mEtSig()        ,0.0,0.0,0.0));
00418   toc_.push_back(TriggerObject(TriggerHLongit,object.e_longitudinal(),0.0,0.0,0.0));
00419 
00420   return;
00421 }
00422 
00423 template <typename C>
00424 void TriggerSummaryProducerAOD::fillFilterObjectMembers(const edm::Event& iEvent, const edm::InputTag& tag, const trigger::Vids& ids, const std::vector<edm::Ref<C> >& refs) {
00425 
00429 
00430   using namespace std;
00431   using namespace edm;
00432   using namespace reco;
00433   using namespace l1extra;
00434   using namespace trigger;
00435 
00436   if (ids.size()!=refs.size()) {
00437     LogError("TriggerSummaryProducerAOD") << "Vector length is different: "
00438                                           << ids.size() << " " << refs.size();
00439   }
00440 
00441   const unsigned int n(min(ids.size(),refs.size()));
00442   for (unsigned int i=0; i!=n; ++i) {
00443     const ProductID pid(refs[i].id());
00444     if (offset_.find(pid)==offset_.end()) {
00445       const string&    label(iEvent.getProvenance(pid).moduleLabel());
00446       const string& instance(iEvent.getProvenance(pid).productInstanceName());
00447       const string&  process(iEvent.getProvenance(pid).processName());
00448       LogError("TriggerSummaryProducerAOD")
00449         << "Uunknown pid:"
00450         << " FilterTag/Key: " << tag.encode()
00451         << "/" << i
00452         << " CollectionTag/Key: "
00453         << InputTag(label,instance,process).encode()
00454         << "/" << refs[i].key()
00455         << " CollectionType: " << typeid(C).name();
00456     } else {
00457       fillFilterObjectMember(offset_[pid],ids[i],refs[i]);
00458     }
00459   }
00460   return;
00461 
00462 }
00463 
00464 template <typename C>
00465 void TriggerSummaryProducerAOD::fillFilterObjectMember(const int& offset, const int& id, const edm::Ref<C> & ref) {
00466 
00467   keys_.push_back(offset+ref.key());
00468   ids_.push_back(id);
00469 
00470   return;
00471 }
00472 
00473 void TriggerSummaryProducerAOD::fillFilterObjectMember(const int& offset, const int& id, const edm::Ref<l1extra::L1HFRingsCollection> & ref) {
00474 
00475   using namespace trigger;
00476 
00477   if (id==TriggerL1HfBitCounts) {
00478     keys_.push_back(offset+2*ref.key()+1);
00479   } else { // if (ids[i]==TriggerL1HfRingEtSums) {
00480     keys_.push_back(offset+2*ref.key()+0);
00481   }
00482   ids_.push_back(id);
00483 
00484   return;
00485 }
00486 
00487 void TriggerSummaryProducerAOD::fillFilterObjectMember(const int& offset, const int& id, const edm::Ref<l1extra::L1EtMissParticleCollection> & ref) {
00488 
00489   using namespace trigger;
00490 
00491   if ( (id==TriggerL1ETT) || (id==TriggerL1HTT) ) {
00492     keys_.push_back(offset+2*ref.key()+1);
00493   } else {
00494     keys_.push_back(offset+2*ref.key()+0);
00495   }
00496   ids_.push_back(id);
00497 
00498   return;
00499 }
00500 
00501 void TriggerSummaryProducerAOD::fillFilterObjectMember(const int& offset, const int& id, const edm::Ref<reco::CaloMETCollection> & ref) {
00502 
00503   using namespace trigger;
00504 
00505   if ( (id==TriggerTHT) || (id==TriggerTET) ) {
00506     keys_.push_back(offset+4*ref.key()+1);
00507   } else if ( (id==TriggerMETSig) || (id==TriggerMHTSig) ) {
00508     keys_.push_back(offset+4*ref.key()+2);
00509   } else if ( (id==TriggerELongit) || (id==TriggerHLongit) ) {
00510     keys_.push_back(offset+4*ref.key()+3);
00511   } else {
00512     keys_.push_back(offset+4*ref.key()+0);
00513   }
00514   ids_.push_back(id);
00515 
00516   return;
00517 }
00518 
00519 void TriggerSummaryProducerAOD::fillFilterObjectMember(const int& offset, const int& id, const edm::Ref<reco::METCollection> & ref) {
00520 
00521   using namespace trigger;
00522 
00523   if ( (id==TriggerTHT) || (id==TriggerTET) ) {
00524     keys_.push_back(offset+4*ref.key()+1);
00525   } else if ( (id==TriggerMETSig) || (id==TriggerMHTSig) ) {
00526     keys_.push_back(offset+4*ref.key()+2);
00527   } else if ( (id==TriggerELongit) || (id==TriggerHLongit) ) {
00528     keys_.push_back(offset+4*ref.key()+3);
00529   } else {
00530     keys_.push_back(offset+4*ref.key()+0);
00531   }
00532   ids_.push_back(id);
00533 
00534   return;
00535 }
00536 
00537 void TriggerSummaryProducerAOD::endJob() {
00538 
00539   using namespace std;
00540   using namespace edm;
00541   using namespace trigger;
00542 
00543   LogVerbatim("TriggerSummaryProducerAOD") << endl;
00544   LogVerbatim("TriggerSummaryProducerAOD") << "TriggerSummaryProducerAOD::endJob - accumulated tags:" << endl;
00545 
00546   const unsigned int nc(collectionTagsGlobal_.size());
00547   const unsigned int nf(filterTagsGlobal_.size());
00548   LogVerbatim("TriggerSummaryProducerAOD") << " Overall number of Collections/Filters: "
00549                   << nc << "/" << nf << endl;
00550 
00551   LogVerbatim("TriggerSummaryProducerAOD") << " The collections: " << nc << endl;
00552   const InputTagSet::const_iterator cb(collectionTagsGlobal_.begin());
00553   const InputTagSet::const_iterator ce(collectionTagsGlobal_.end());
00554   for ( InputTagSet::const_iterator ci=cb; ci!=ce; ++ci) {
00555     LogVerbatim("TriggerSummaryProducerAOD") << "  " << distance(cb,ci) << " " << ci->encode() << endl;
00556   }
00557 
00558   LogVerbatim("TriggerSummaryProducerAOD") << " The filters:" << nf << endl;
00559   const InputTagSet::const_iterator fb(filterTagsGlobal_.begin());
00560   const InputTagSet::const_iterator fe(filterTagsGlobal_.end());
00561   for ( InputTagSet::const_iterator fi=fb; fi!=fe; ++fi) {
00562     LogVerbatim("TriggerSummaryProducerAOD") << "  " << distance(fb,fi) << " " << fi->encode() << endl;
00563   }
00564 
00565   LogVerbatim("TriggerSummaryProducerAOD") << "TriggerSummaryProducerAOD::endJob." << endl;
00566   LogVerbatim("TriggerSummaryProducerAOD") << endl;
00567 
00568   return;
00569 
00570 }