-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ivan
committed
Apr 27, 2021
1 parent
b47789c
commit 39fe9bb
Showing
7 changed files
with
228 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.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,31 @@ | ||
#ifndef DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H | ||
#define DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H | ||
|
||
#include <vector> | ||
#include <numeric> | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
|
||
class SiStripApproximateClusterv1 { | ||
public: | ||
|
||
SiStripApproximateClusterv1() {} | ||
|
||
explicit SiStripApproximateClusterv1(uint8_t avgCharge, uint16_t barycenter, uint8_t width):avgCharge_(avgCharge) { | ||
baryWidth_ = barycenter; | ||
baryWidth_ = baryWidth_ << 6; | ||
if(width>0x3F) width=0x3F; | ||
baryWidth_ += width; | ||
} | ||
|
||
uint16_t barycenter() const {return (uint16_t)((baryWidth_ & 0xFFC0) >> 6);} | ||
uint8_t width() const {return (uint8_t) (baryWidth_ & 0x3F);} | ||
uint16_t baryWidth() const {return baryWidth_;} | ||
uint8_t avgCharge() const{return avgCharge_;} | ||
|
||
private: | ||
|
||
uint16_t baryWidth_ = 0; | ||
|
||
uint8_t avgCharge_ = 0; | ||
}; | ||
#endif // DATAFORMATS_SISTRIPAPPROXIMATECLUSTERv1_H |
51 changes: 51 additions & 0 deletions
51
RecoLocalTracker/SiStripClusterizer/plugins/SiStripClusters2ApproxClustersv1.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,51 @@ | ||
#include "RecoLocalTracker/SiStripClusterizer/interface/SiStripClusters2ApproxClustersv1.h" | ||
#include <iostream> | ||
|
||
|
||
SiStripClusters2ApproxClustersv1::SiStripClusters2ApproxClustersv1(const edm::ParameterSet& conf){ | ||
inputClusters = conf.getParameter< edm::InputTag >("inputClusters"); | ||
clusterToken = consumes< edmNew::DetSetVector< SiStripCluster > >(inputClusters); | ||
|
||
produces< edmNew::DetSetVector< SiStripApproximateClusterv1 > >(); | ||
|
||
} | ||
|
||
void SiStripClusters2ApproxClustersv1::produce(edm::Event& e, edm::EventSetup const&){ | ||
std::unique_ptr<edmNew::DetSetVector< SiStripApproximateClusterv1 > > result(new edmNew::DetSetVector< SiStripApproximateClusterv1 > ); | ||
|
||
edm::Handle<edmNew::DetSetVector< SiStripCluster >> clusterCollection; | ||
e.getByToken(clusterToken, clusterCollection); | ||
|
||
uint32_t minID = 470444276; | ||
int maxFirst = -1; | ||
|
||
for( edmNew::DetSetVector<SiStripCluster>::const_iterator i = clusterCollection->begin(); i!=clusterCollection->end(); i++){ | ||
|
||
std::vector< SiStripApproximateClusterv1 > tempVec; | ||
|
||
edmNew::DetSetVector<SiStripApproximateClusterv1>::FastFiller ff = edmNew::DetSetVector<SiStripApproximateClusterv1>::FastFiller(*result, i->id()); | ||
|
||
for( edmNew::DetSet<SiStripCluster>::const_iterator j = i->begin(); j!=i->end(); j++){ | ||
|
||
if(maxFirst<j->firstStrip()) maxFirst = j->firstStrip(); | ||
if(minID>i->id()) minID = i->id(); | ||
|
||
uint8_t width = j->amplitudes().size(); | ||
uint16_t barycenter = (uint16_t)j->barycenter(); | ||
|
||
int charge = 0; | ||
for (unsigned k = 0; k < j->amplitudes().size(); k++) { | ||
charge += (int)j->amplitudes()[k]; | ||
} | ||
|
||
SiStripApproximateClusterv1 approxCluster = SiStripApproximateClusterv1( (uint8_t)(charge/width), barycenter, width ); | ||
ff.push_back(approxCluster); | ||
} | ||
|
||
|
||
} | ||
|
||
e.put(std::move(result)); | ||
} | ||
|
||
|
6 changes: 6 additions & 0 deletions
6
RecoLocalTracker/SiStripClusterizer/python/SiStripClusters2ApproxClustersv1_cfi.py
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,6 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
SiStripClusters2ApproxClustersv1 = cms.EDProducer("SiStripClusters2ApproxClustersv1", | ||
inputClusters = cms.InputTag("siStripClusters") | ||
) | ||
|
41 changes: 41 additions & 0 deletions
41
RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.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,41 @@ | ||
#include "RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.h" | ||
|
||
|
||
SiStripApproximatedClustersDump::SiStripApproximatedClustersDump(const edm::ParameterSet& conf) { | ||
inputTagClusters = conf.getParameter< edm::InputTag >("approximatedClustersTag"); | ||
clusterToken = consumes< edmNew::DetSetVector<SiStripApproximateClusterv1>>(inputTagClusters); | ||
|
||
usesResource("TFileService"); | ||
|
||
outNtuple = fs->make<TTree>("ApproxClusters", "ApproxClusters"); | ||
outNtuple->Branch("event", &eventN, "event/i"); | ||
outNtuple->Branch("detId", &detId, "detId/i"); | ||
outNtuple->Branch("barycenter", &barycenter, "barycenter/F"); | ||
outNtuple->Branch("width", &width, "width/b"); | ||
outNtuple->Branch("charge", &avCharge, "charge/b"); | ||
} | ||
|
||
SiStripApproximatedClustersDump::~SiStripApproximatedClustersDump() {} | ||
|
||
void SiStripApproximatedClustersDump::analyze(const edm::Event& event, const edm::EventSetup& es) { | ||
|
||
edm::Handle<edmNew::DetSetVector<SiStripApproximateClusterv1>> inClusters; | ||
event.getByToken(clusterToken, inClusters); | ||
|
||
|
||
for (edmNew::DetSetVector<SiStripApproximateClusterv1>::const_iterator itApprox = inClusters->begin(); itApprox!= inClusters->end(); itApprox++) { | ||
detId = itApprox->detId(); | ||
eventN = event.id().event(); | ||
|
||
for (edmNew::DetSet<SiStripApproximateClusterv1>::const_iterator itClusters = itApprox->begin(); itClusters!= itApprox->end(); itClusters++){ | ||
|
||
barycenter = itClusters->barycenter(); | ||
width = itClusters->width(); | ||
avCharge=itClusters->avgCharge(); | ||
outNtuple->Fill(); | ||
|
||
} | ||
} | ||
} | ||
|
||
|
59 changes: 59 additions & 0 deletions
59
RecoLocalTracker/SiStripClusterizer/test/SiStripApproximatedClustersDump.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,59 @@ | ||
#ifndef RecoLocalTracker_SiStripApproximatedClustersDump_h | ||
#define RecoLocalTracker_SiStripApproximatedClustersDump_h | ||
|
||
|
||
// user include files | ||
#include "FWCore/Framework/interface/Frameworkfwd.h" | ||
#include "FWCore/Framework/interface/one/EDAnalyzer.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "DataFormats/Common/interface/DetSet.h" | ||
#include "DataFormats/Common/interface/DetSetVector.h" | ||
#include "DataFormats/Common/interface/DetSetVectorNew.h" | ||
#include "DataFormats/SiStripCluster/interface/SiStripApproximateClusterv1.h" | ||
|
||
#include "FWCore/ServiceRegistry/interface/Service.h" | ||
#include "CommonTools/UtilAlgos/interface/TFileService.h" | ||
#include "CommonTools/Utils/interface/TFileDirectory.h" | ||
|
||
#include <memory> | ||
#include <iostream> | ||
|
||
//ROOT inclusion | ||
#include "TROOT.h" | ||
#include "TFile.h" | ||
#include "TNtuple.h" | ||
#include "TTree.h" | ||
#include "TMath.h" | ||
#include "TList.h" | ||
#include "TString.h" | ||
|
||
// | ||
// class decleration | ||
// | ||
|
||
|
||
class SiStripApproximatedClustersDump : public edm::one::EDAnalyzer<edm::one::SharedResources> { | ||
public: | ||
explicit SiStripApproximatedClustersDump(const edm::ParameterSet&); | ||
~SiStripApproximatedClustersDump() override; | ||
|
||
|
||
private: | ||
void analyze(const edm::Event&, const edm::EventSetup&) override; | ||
|
||
edm::InputTag inputTagClusters; | ||
edm::EDGetTokenT< edmNew::DetSetVector<SiStripApproximateClusterv1> > clusterToken; | ||
|
||
TTree* outNtuple; | ||
edm::Service<TFileService> fs; | ||
|
||
uint32_t detId; | ||
uint16_t barycenter; | ||
uint16_t width; | ||
uint8_t avCharge; | ||
edm::EventNumber_t eventN; | ||
}; | ||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<use name="DataFormats/Common"/> | ||
<use name="DataFormats/TrajectoryState"/> | ||
<use name="boost"/> | ||
|
||
<export> | ||
<lib name="1"/> | ||
</export> |
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,33 @@ | ||
#ifndef SISTRIPAPPROXIMATECLUSTERv2_CLASSES_H | ||
#define SISTRIPAPPROXIMATECLUSTERv2_CLASSES_H | ||
|
||
#include "DataFormats/Common/interface/Wrapper.h" | ||
#include "DataFormats/Common/interface/DetSetVectorNew.h" | ||
#include "DataFormats/Common/interface/Ref.h" | ||
#include "DataFormats/SiStripApproximateClusterv2/interface/SiStripApproximateClusterv2.h" | ||
#include "DataFormats/Common/interface/ContainerMask.h" | ||
|
||
namespace DataFormats_SiStripApproximateClusterv2 { | ||
struct dictionary2 { | ||
|
||
|
||
edmNew::DetSetVector<SiStripApproximateClusterv2> dsvn; | ||
|
||
edm::Wrapper< SiStripApproximateClusterv2 > dummy0; | ||
edm::Wrapper< std::vector<SiStripApproximateClusterv2> > dummy1; | ||
|
||
edm::Wrapper< edmNew::DetSetVector<SiStripApproximateClusterv2> > dummy4_bis; | ||
|
||
edm::Wrapper<edm::ContainerMask<edmNew::DetSetVector<SiStripApproximateClusterv2> > > dummy_w_cm1; | ||
|
||
std::vector<edm::Ref<edmNew::DetSetVector<SiStripApproximateClusterv2>,SiStripApproximateClusterv2,edmNew::DetSetVector<SiStripApproximateClusterv2>::FindForDetSetVector> > dummy_v; | ||
edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripApproximateClusterv2>,SiStripApproximateClusterv2,edmNew::DetSetVector<SiStripApproximateClusterv2>::FindForDetSetVector> > dumm_dtvr; | ||
edm::Wrapper<edmNew::DetSetVector<edm::Ref<edmNew::DetSetVector<SiStripApproximateClusterv2>,SiStripApproximateClusterv2,edmNew::DetSetVector<SiStripApproximateClusterv2>::FindForDetSetVector> > > dumm_dtvr_w; | ||
|
||
|
||
edm::Ref<edmNew::DetSetVector<SiStripApproximateClusterv2>, SiStripApproximateClusterv2, edmNew::DetSetVector<SiStripApproximateClusterv2>::FindForDetSetVector > refNew; | ||
}; | ||
} | ||
|
||
|
||
#endif // SISTRIPAPPROXIMATECLUSTER_CLASSES_H |