Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:26:02

0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 
0004 #include "EventFilter/L1TRawToDigi/plugins/PackerFactory.h"
0005 
0006 #include "DataFormats/L1CaloTrigger/interface/L1CaloEmCand.h"
0007 #include "DataFormats/L1TCalorimeter/interface/CaloEmCand.h"
0008 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0009 #include "DataFormats/L1TCalorimeter/interface/CaloRegion.h"
0010 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
0011 #include "DataFormats/L1CaloTrigger/interface/L1CaloCollections.h"
0012 
0013 #include "PhysicsToBitConverter.h"
0014 #include "rctDataBase.h"
0015 
0016 #include "CaloTokens.h"
0017 #include "RCTEmRegionPacker.h"
0018 
0019 namespace l1t {
0020   namespace stage1 {
0021     Blocks RCTEmRegionPacker::pack(const edm::Event& event, const PackerTokens* toks) {
0022       edm::Handle<L1CaloRegionCollection> caloregion;
0023       event.getByToken(static_cast<const CaloTokens*>(toks)->getCaloRegionToken(), caloregion);
0024 
0025       edm::Handle<L1CaloEmCollection> caloemcand;
0026       event.getByToken(static_cast<const CaloTokens*>(toks)->getCaloEmCandToken(), caloemcand);
0027 
0028       std::vector<uint32_t> load[36];
0029 
0030       for (int i = 0; i <= 0; ++i) {
0031         int n = 0;
0032         PhysicsToBitConverter converter[18];
0033         for (auto j = caloregion->begin(); j != caloregion->end(); ++j, ++n) {
0034           int et = (int)j->et();
0035           int overFlow = (int)j->overFlow();
0036           int fineGrain = (int)j->fineGrain();
0037           int mip = (int)j->mip();
0038           bool tauveto = j->tauVeto();
0039           //int quiet=(int)j->quiet();
0040 
0041           int rctCrate = (int)j->rctCrate();
0042           int rctCard = (int)j->rctCard();
0043           int rctRegion = (int)j->rctRegionIndex();
0044           bool isHf = (bool)j->isHf();
0045 
0046           if (!isHf) {
0047             converter[rctCrate].SetRCEt(et, rctCard, rctRegion);
0048             converter[rctCrate].SetRCOf(overFlow, rctCard, rctRegion);
0049             converter[rctCrate].SetRCTau(tauveto, rctCard, rctRegion);
0050             converter[rctCrate].SetRCHad(mip, rctCard, rctRegion);
0051             LogDebug("L1T") << "CRATE" << rctCrate << "region=" << rctRegion << ", card=" << rctCard << ", rgnEt=" << et
0052                             << ", overflow=" << overFlow << ", tauveto=" << tauveto << ", hadveto=" << mip << std::endl;
0053 
0054           } else {
0055             converter[rctCrate].SetHFEt(et, rctRegion);
0056             converter[rctCrate].SetHFFg(fineGrain, rctRegion);
0057             LogDebug("L1T") << "CRATE" << rctCrate << "region=" << rctRegion << ", rgnEt=" << et << std::endl;
0058           }
0059         }  //end calo region
0060 
0061         int m = 0;
0062         for (auto j = caloemcand->begin(); j != caloemcand->end(); ++j, ++m) {
0063           int rank = (int)j->rank();
0064           int index = (int)j->index();
0065           int rctCrate = (int)j->rctCrate();
0066           bool isolated = (bool)j->isolated();
0067           int rctCard = (int)j->rctCard();
0068           int rctRegion = (int)j->rctRegion();
0069 
0070           if (isolated) {
0071             converter[rctCrate].SetIEEt(rank, index);
0072             converter[rctCrate].SetIEReg(rctRegion, index);
0073             converter[rctCrate].SetIECard(rctCard, index);
0074             LogDebug("L1T") << "CRATE" << rctCrate << "ISO em rank=" << rank << ", region=" << rctRegion
0075                             << ", card=" << rctCard << std::endl;
0076           } else {
0077             converter[rctCrate].SetNEEt(rank, index);
0078             converter[rctCrate].SetNEReg(rctRegion, index);
0079             converter[rctCrate].SetNECard(rctCard, index);
0080             LogDebug("L1T") << "CRATE" << rctCrate << "NON ISO em rank=" << rank << ", region=" << rctRegion
0081                             << ", card=" << rctCard << std::endl;
0082           }
0083         }  //end of em cand
0084 
0085         for (int in = 0; in < 18; in++) {
0086           converter[in].Extract32bitwords();
0087           for (int d = 0; d < 6; d++) {
0088             load[2 * in].push_back((uint32_t)converter[in].Get32bitWordLinkEven(d));
0089             load[2 * in + 1].push_back((uint32_t)converter[in].Get32bitWordLinkOdd(d));
0090           }
0091         }
0092       }  // end of BX
0093 
0094       rctDataBase database;
0095 
0096       Blocks res = {};
0097 
0098       for (int i = 0; i < 36; ++i) {
0099         unsigned int mycrateRCT = (int)(i / 2);
0100         bool myRCTeven;
0101         if (i % 2 == 0)
0102           myRCTeven = true;
0103         else
0104           myRCTeven = false;
0105         int linkMP7 = -1;
0106         database.GetLinkMP7(mycrateRCT, myRCTeven, linkMP7);
0107         res.push_back(Block(2 * linkMP7, load[i], 0));
0108         res.push_back(Block(2 * linkMP7, load[i], 1));
0109       }
0110       return res;
0111     }
0112   }  // namespace stage1
0113 }  // namespace l1t
0114 DEFINE_L1T_PACKER(l1t::stage1::RCTEmRegionPacker);