forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request cms-sw#45037 from aloeliger/Calo_CICADA_Unpacker_PR
Add Unpacker for L1T Calo Layer 1 to unpack CICADA
- Loading branch information
Showing
7 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h" | ||
|
||
#include "CICADAUnpacker.h" | ||
|
||
#include <cmath> | ||
|
||
using namespace edm; | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
bool CICADAUnpacker::unpack(const Block& block, UnpackerCollections* coll) { | ||
LogDebug("L1T") << "Block Size = " << block.header().getSize(); | ||
LogDebug("L1T") << "Board ID = " << block.amc().getBoardID(); | ||
|
||
auto res = static_cast<CaloLayer1Collections*>(coll)->getCICADABxCollection(); | ||
// default BX range to trigger standard -2 to 2 | ||
// Even though CICADA will never have BX information | ||
// And everything gets put in BX 0 | ||
res->setBXRange(-2, 2); | ||
|
||
int amc_slot = block.amc().getAMCNumber(); | ||
if (not(amc_slot == 7)) { | ||
throw cms::Exception("CICADAUnpacker") | ||
<< "Calo Summary (CICADA) unpacker is unpacking an unexpected AMC. Expected AMC number 7, got AMC number " | ||
<< amc_slot << std::endl; | ||
return false; | ||
} else { | ||
std::vector<uint32_t> cicadaWords = {0, 0, 0, 0}; | ||
//the last 4 words are CICADA words | ||
for (uint32_t i = 2; i < 6; ++i) { | ||
cicadaWords.at(i - 2) = ((block.payload().at(i)) >> 28); | ||
} | ||
|
||
float cicadaScore = convertCICADABitsToFloat(cicadaWords); | ||
res->push_back(0, cicadaScore); | ||
return true; | ||
} | ||
} | ||
|
||
//convert the 4 CICADA bits/words into a proper number | ||
float CICADAUnpacker::convertCICADABitsToFloat(const std::vector<uint32_t>& cicadaBits) { | ||
uint32_t tempResult = 0; | ||
tempResult |= cicadaBits.at(0) << 12; | ||
tempResult |= cicadaBits.at(1) << 8; | ||
tempResult |= cicadaBits.at(2) << 4; | ||
tempResult |= cicadaBits.at(3); | ||
float result = 0.0; | ||
result = (float)tempResult * pow(2.0, -8); | ||
return result; | ||
} | ||
} // namespace stage2 | ||
} // namespace l1t | ||
|
||
DEFINE_L1T_UNPACKER(l1t::stage2::CICADAUnpacker); |
19 changes: 19 additions & 0 deletions
19
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CICADAUnpacker.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef EventFilter_L1TRawToDigi_CICADAUnpacker_h | ||
#define EventFilter_L1TRawToDigi_CICADAUnpacker_h | ||
|
||
#include "EventFilter/L1TRawToDigi/interface/Unpacker.h" | ||
#include "CaloLayer1Collections.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
class CICADAUnpacker : public Unpacker { | ||
public: | ||
bool unpack(const Block& block, UnpackerCollections* coll) override; | ||
|
||
private: | ||
float convertCICADABitsToFloat(const std::vector<uint32_t>&); | ||
}; | ||
} // namespace stage2 | ||
} // namespace l1t | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "FWCore/Framework/interface/Event.h" | ||
|
||
#include "CaloSummaryCollections.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
CaloSummaryCollections::~CaloSummaryCollections() { event_.put(std::move(cicadaDigis_)); } | ||
} // namespace stage2 | ||
} // namespace l1t |
23 changes: 23 additions & 0 deletions
23
EventFilter/L1TRawToDigi/plugins/implementations_stage2/CaloSummaryCollections.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef EventFilter_L1TRawToDigi_CaloSummaryCollections_h | ||
#define EventFilter_L1TRawToDigi_CaloSummaryCollections_h | ||
|
||
#include "DataFormats/L1CaloTrigger/interface/CICADA.h" | ||
|
||
#include "EventFilter/L1TRawToDigi/interface/UnpackerCollections.h" | ||
|
||
namespace l1t { | ||
namespace stage2 { | ||
class CaloSummaryCollections : public UnpackerCollections { | ||
public: | ||
CaloSummaryCollections(edm::Event& e) | ||
: UnpackerCollections(e), cicadaDigis_(std::make_unique<CICADABxCollection>()){}; | ||
~CaloSummaryCollections() override; | ||
inline CICADABxCollection* getCICADABxCollection() { return cicadaDigis_.get(); }; | ||
|
||
private: | ||
std::unique_ptr<CICADABxCollection> cicadaDigis_; | ||
}; | ||
} // namespace stage2 | ||
} // namespace l1t | ||
|
||
#endif |