Skip to content

Commit

Permalink
Merge pull request #104 from brownd1978/crvhelp
Browse files Browse the repository at this point in the history
Move CRVAnalysis to CrvInfoHelper
  • Loading branch information
AndrewEdmonds11 authored Sep 29, 2023
2 parents 9ebbf78 + e94db04 commit 73155aa
Show file tree
Hide file tree
Showing 26 changed files with 719 additions and 295 deletions.
6 changes: 1 addition & 5 deletions fcl/CrvExpert.fcl
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#include "TrkAna/fcl/TrkAnaReco.fcl"

physics.analyzers.TrkAnaNeg.FillCRVHits : true
physics.analyzers.TrkAnaNeg.FillCRVPulses : false

physics.analyzers.TrkAnaPos.FillCRVHits : true
physics.analyzers.TrkAnaPos.FillCRVPulses : false
physics.analyzers.TrkAnaPos.FillCRVPulses : false
6 changes: 2 additions & 4 deletions fcl/TrkAnaExtracted.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ physics :
}
analyzers : { @table::TrkAnaReco.analyzers }
}
physics.TrkAnaTrigPath : [ BestCrvLine ]
physics.TrkAnaTrigPath : [ ]
physics.TrkAnaEndPath : [ TrkAnaExt ]

# Include more information (MC, full TrkQual and TrkPID branches)
Expand All @@ -25,12 +25,10 @@ physics.analyzers.TrkAnaExt.candidate.options.fillTrkQual : false
physics.analyzers.TrkAnaExt.candidate.options.fillTrkPID : false
physics.analyzers.TrkAnaExt.FillTriggerInfo : false
physics.analyzers.TrkAnaExt.FitType : KinematicLine
physics.analyzers.TrkAnaExt.FillCRVHits : true
physics.analyzers.TrkAnaExt.FillCRVPulses : true

# for hit level diagnostics, set diagLevel to 2
physics.analyzers.TrkAnaExt.diagLevel : 2
physics.analyzers.TrkAnaExt.FillMCInfo : true
physics.analyzers.TrkAnaExt.FillCRV : true
physics.analyzers.TrkAnaExt.FillCRVHits : true

services.TFileService.fileName: "nts.owner.trkanaextracted-reco.version.sequencer.root"
8 changes: 3 additions & 5 deletions fcl/TrkAnaReco.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ physics :
producers : {
# @table::TrkAnaReco.producers
PBIWeight : @local::PBIWeight
@table::BestCrvProducers
}
analyzers : { @table::TrkAnaReco.analyzers }
}

#physics.TrkAnaTrigPath : [ @sequence::TrkAnaReco.MCTrigSequence, @sequence::TrkAnaReco.TrigSequence ]
physics.TrkAnaTrigPath : [ PBIWeight, @sequence::BestCrvProducersPath ]
physics.TrkAnaTrigPath : [ PBIWeight ]
physics.TrkAnaEndPath : [ @sequence::TrkAnaReco.EndSequence ]

# Include more information (MC, full TrkQual and TrkPID branches)
Expand All @@ -30,13 +28,13 @@ physics.analyzers.TrkAnaPos.candidate.options : @local::AllOpt
# for hit level diagnostics, set diagLevel to 2
physics.analyzers.TrkAnaNeg.diagLevel : 1
physics.analyzers.TrkAnaNeg.FillMCInfo : true
physics.analyzers.TrkAnaNeg.FillCRV : true
physics.analyzers.TrkAnaNeg.FillCRVHits : true
physics.analyzers.TrkAnaNeg.FillTriggerInfo : false
physics.analyzers.TrkAnaNeg.FitType : LoopHelix

physics.analyzers.TrkAnaPos.diagLevel : 1
physics.analyzers.TrkAnaPos.FillMCInfo : true
physics.analyzers.TrkAnaPos.FillCRV : true
physics.analyzers.TrkAnaPos.FillCRVHits : true
physics.analyzers.TrkAnaPos.FillTriggerInfo : false
physics.analyzers.TrkAnaPos.FitType : LoopHelix

Expand Down
6 changes: 3 additions & 3 deletions fcl/TrkAnaReco_wTrkQualFilter.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ physics :
{
producers : { @table::TrkAnaReco.producers }
analyzers : { @table::TrkAnaReco.analyzers }
filters : {
filters : {
trkQualFilter : { module_type : TrkQualFilter
trainName : "TrkQual"
trkHypo : "DeM"
Expand Down Expand Up @@ -53,11 +53,11 @@ physics.analyzers.TrkAnaPos.candidate.options : @local::AllOpt
# for hit level diagnostics, set diagLevel to 2
physics.analyzers.TrkAnaNeg.diagLevel : 1
physics.analyzers.TrkAnaNeg.FillMCInfo : true
physics.analyzers.TrkAnaNeg.FillCRV : true
physics.analyzers.TrkAnaNeg.FillCRVHits : true
physics.analyzers.TrkAnaNeg.FillTriggerInfo : true
physics.analyzers.TrkAnaPos.diagLevel : 1
physics.analyzers.TrkAnaPos.FillMCInfo : true
physics.analyzers.TrkAnaPos.FillCRV : true
physics.analyzers.TrkAnaPos.FillCRVHits : true
physics.analyzers.TrkAnaPos.FillTriggerInfo : true

services.TFileService.fileName: "nts.owner.trkana-reco.version.sequencer.root"
64 changes: 10 additions & 54 deletions fcl/prolog.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -67,43 +67,6 @@ TrkPIDProducers : {
}
TrkPIDProducersPath : [ TrkPIDDeM, TrkPIDDeP ]

BestCrv : {
module_type : BestCrvHitDeltaT
crvCoincidenceTag : "SelectRecoMC:CrvCoincidenceClusterFinder"
}

BestCrvDeM : @local::BestCrv
BestCrvDeM.kalSeedTag : "KKDeM"
BestCrvUeM : @local::BestCrv
BestCrvUeM.kalSeedTag : "KKUeM"
BestCrvDmuM : @local::BestCrv
BestCrvDmuM.kalSeedTag : "KKDmuM"
BestCrvUmuM : @local::BestCrv
BestCrvUmuM.kalSeedTag : "KKUmuM"
BestCrvDeP : @local::BestCrv
BestCrvDeP.kalSeedTag : "KKDeP"
BestCrvUeP : @local::BestCrv
BestCrvUeP.kalSeedTag : "KKUeP"
BestCrvDmuP : @local::BestCrv
BestCrvDmuP.kalSeedTag : "KKDmuP"
BestCrvUmuP : @local::BestCrv
BestCrvUmuP.kalSeedTag : "KKUmuP"
BestCrvLine : @local::BestCrv
BestCrvLine.kalSeedTag : "KKLine"

BestCrvProducers : {
BestCrvDeM : @local::BestCrvDeM
BestCrvUeM : @local::BestCrvUeM
BestCrvDeP : @local::BestCrvDeP
BestCrvUeP : @local::BestCrvUeP
BestCrvDmuM : @local::BestCrvDmuM
BestCrvDmuP : @local::BestCrvDmuP
BestCrvUmuM : @local::BestCrvUmuM
BestCrvUmuP : @local::BestCrvUmuP
BestCrvLine : @local::BestCrvLine
}
BestCrvProducersPath : [ BestCrvDeM, BestCrvUeM, BestCrvDmuM, BestCrvDeP, BestCrvUeP, BestCrvDmuP, BestCrvUmuM, BestCrvUmuP ]

# DIO weighting for flat spectrum electrons
DIOWeight: {
module_type: DecayInOrbitWeight
Expand Down Expand Up @@ -141,11 +104,6 @@ AllOpt : { fillMC : true
fillTrkPID : true
fillHits : true
genealogyDepth : -1
fillBestCrv : true

bestCrvModules : [ "BestCrv" ]
bestCrvInstances : [ "first" ]
bestCrvBranches : [ "bestcrv" ]
}

DeM : { input : "KK"
Expand Down Expand Up @@ -192,14 +150,14 @@ TrkAnaTreeMaker : {
PBITag : "PBISim"
PBTTag : "EWMProducer"
PBTMCTag : "EWMProducer"
CrvCoincidenceModuleLabel : "SelectRecoMC:CrvCoincidenceClusterFinder"
CrvCoincidenceMCModuleLabel : "compressRecoMCs:CrvCoincidenceClusterMatchMC"
CrvRecoPulseLabel : "SelectRecoMC"
CrvStepLabel : "compressRecoMCs"
SimParticleLabel : "compressRecoMCs"
MCTrajectoryLabel : "compressRecoMCs"
CrvWaveformsModuleLabel : "compressRecoMCs"
CrvDigiModuleLabel : "SelectRecoMC"
CrvCoincidencesTag : "SelectRecoMC:CrvCoincidenceClusterFinder"
CrvCoincidenceMCsTag : "compressRecoMCs:CrvCoincidenceClusterMatchMC"
CrvRecoPulsesTag : "SelectRecoMC"
CrvStepsTag : "compressRecoMCs"
SimParticlesTag : "compressRecoMCs"
MCTrajectoriesTag : "compressRecoMCs"
CrvDigiMCsTag : "compressRecoMCs"
CrvDigisTag : "SelectRecoMC"
CrvCoincidenceClusterMCAssnsTag : "CrvCoincidenceClusterMCAssns"
CrvPlaneY : 2653
FillMCInfo : true
Expand All @@ -209,8 +167,7 @@ TrkAnaTreeMaker : {
FillTriggerInfo : true
TriggerProcessName : "Mix"
ProcessEmptyEvents : false
FillCRV : true
FillCRVHits : false
FillCRVHits : true
FillCRVPulses : false
PrimaryParticleTag : "compressRecoMCs"
KalSeedMCAssns : "SelectRecoMC"
Expand All @@ -228,7 +185,6 @@ TrkAnaReco : {
PBIWeight : @local::PBIWeight
@table::TrkQualProducers
@table::TrkPIDProducers
@table::BestCrvProducers
}

analyzers : {
Expand All @@ -251,7 +207,7 @@ TrkAnaReco : {
genCountLogger : @local::genCountLogger
}

TrigSequence : [ PBIWeight, @sequence::TrkQualProducersPath, @sequence::TrkPIDProducersPath, @sequence::BestCrvProducersPath ]
TrigSequence : [ PBIWeight, @sequence::TrkQualProducersPath, @sequence::TrkPIDProducersPath ]
EndSequenceNoMC : [ TrkAnaNeg, TrkAnaPos ]
EndSequence : [ TrkAnaNeg, TrkAnaPos, genCountLogger ]

Expand Down
7 changes: 3 additions & 4 deletions fcl/prolog_trigger.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ TrkAnaTrigger : {
@table::DeM
options : {
@table::AllOpt
fillBestCrv : false
fillHits : true
}
}
supplements : []
ExtraMCStepCollectionTags : []
diagLevel : 2
FillCRV : false
FillCRVHits : false
FillMCInfo : true
FillCaloMC : false
RecoCountTag : ""
Expand All @@ -28,8 +27,8 @@ TrkAnaTrigger : {
FillTriggerInfo : false
supplements : []
PrimaryParticleTag: "compressDigiMCs"
SimParticleLabel: "compressDigiMCs"
MCTrajectoryLabel: "compressDigiMCs"
SimParticlesTag: "compressDigiMCs"
MCTrajectoriesTag: "compressDigiMCs"
ExtraMCStepCollectionTags: [ ]
InfoMCStructHelper : {
SimParticleCollectionTag : "compressDigiMCs"
Expand Down
53 changes: 53 additions & 0 deletions inc/CrvHitInfoMC.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#ifndef CrvHitInfoMC_hh
#define CrvHitInfoMC_hh

#include "CLHEP/Vector/ThreeVector.h"
#include <vector>
#include "Rtypes.h"
#include "Offline/DataProducts/inc/GenVector.hh"

namespace mu2e
{
struct CrvHitInfoMC //information about the MC track which most likely caused the CRV coincidence triplets
{
Bool_t valid = false; //was an MC particle found that matches the coincidence triplets?
Int_t pdgId = -1; //PDG ID of this MC particle
Int_t primaryPdgId = -1; //PDG ID of the primary particle of this MC particle (helps to determine whether it was a cosmic ray, etc.)
Float_t primaryE = -1; //energy of the primary particle of this MC particle
XYZVectorF primary; //starting point of the primary particle of this MC particle
Int_t parentPdgId = -1; //PDG ID of the parent particle of this MC particle (helps to determine whether it was a cosmic ray, etc.)
Float_t parentE = -1; //energy of the parent particle of this MC particle
XYZVectorF parent; //starting point of the parent particle of this MC particle
Int_t gparentPdgId = -1; //PDG ID of the gparent particle of this MC particle (helps to determine whether it was a cosmic ray, etc.)
Float_t gparentE = -1; //energy of the gparent particle of this MC particle
XYZVectorF gparent; //starting point of the gparent particle of this MC particle
XYZVectorF pos; //position of the MC particle when it "created" the first StepPointMC
Float_t time = -1; //time of the MC particle when it "created" the first StepPointMC
Float_t depositedEnergy = -1; //total energy deposited for this cluster (not just for this track)
CrvHitInfoMC(){}
CrvHitInfoMC(bool valid, int pdgId,
int primaryPdgId, float primaryE, CLHEP::Hep3Vector primaryPos,
int parentPdgId, float parentE, CLHEP::Hep3Vector parentPos,
int gparentPdgId, float gparentE, CLHEP::Hep3Vector gparentPos,
CLHEP::Hep3Vector pos, float time, float depositedEnergy) :
valid(valid),
pdgId(pdgId),
primaryPdgId(primaryPdgId),
primaryE(primaryE),
primary(primaryPos),
parentPdgId(parentPdgId),
parentE(parentE),
parent(parentPos),
gparentPdgId(gparentPdgId),
gparentE(gparentE),
gparent(gparentPos),
pos(pos),
time(time),
depositedEnergy(depositedEnergy)
{}
};

typedef std::vector<CrvHitInfoMC> CrvHitInfoMCCollection; //this is the MC vector which will be stored in the main TTree

}
#endif
41 changes: 41 additions & 0 deletions inc/CrvHitInfoReco.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef CrvHitInfoReco_hh
#define CrvHitInfoReco_hh

#include "Offline/DataProducts/inc/GenVector.hh"
#include "CLHEP/Vector/ThreeVector.h"
#include <vector>
#include "Rtypes.h"

namespace mu2e
{

struct CrvHitInfoReco //information about a cluster of CRV coincidence triplets
{
Int_t sectorType =-1; //CRV sector type
XYZVectorF pos; //average position of counters
Float_t timeStart = -1; //first hit time
Float_t timeEnd = -1; //last hit time
Float_t time = -1; // average hit time
Int_t PEs = -1; //total number of PEs for this cluster
Int_t nHits = -1; //number of coincidence hits in this cluster
Int_t nLayers = -1; //number of coincidence layers in this cluster
Float_t angle = -999; //coincidence direction

CrvHitInfoReco(){}
CrvHitInfoReco(int sectorType, CLHEP::Hep3Vector hpos, float timeWindowStart, float timeWindowEnd, float timeAvg, int PEs, int nCoincidenceHits, int nCoincidenceLayers, float coincidenceAngle) :
sectorType(sectorType),
pos(hpos),
timeStart(timeWindowStart),
timeEnd(timeWindowEnd),
time(timeAvg),
PEs(PEs),
nHits(nCoincidenceHits),
nLayers(nCoincidenceLayers),
angle(coincidenceAngle)
{}
};

typedef std::vector<CrvHitInfoReco> CrvHitInfoRecoCollection; //this is the reco vector which will be stored in the main TTree

}
#endif
67 changes: 67 additions & 0 deletions inc/CrvInfoHelper.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Replacement for CRVAnalysis
//
#include "TrkAna/inc/CrvHitInfoReco.hh"
#include "TrkAna/inc/CrvHitInfoMC.hh"
#include "TrkAna/inc/CrvWaveformInfo.hh"
#include "TrkAna/inc/CrvSummaryReco.hh"
#include "TrkAna/inc/CrvSummaryMC.hh"
#include "TrkAna/inc/CrvPlaneInfoMC.hh"
#include "TrkAna/inc/CrvPulseInfoReco.hh"
#include "Offline/RecoDataProducts/inc/CrvCoincidenceCluster.hh"
#include "Offline/RecoDataProducts/inc/CrvRecoPulse.hh"
#include "Offline/RecoDataProducts/inc/CrvDigi.hh"
#include "Offline/MCDataProducts/inc/CrvDigiMC.hh"
#include "Offline/MCDataProducts/inc/CrvStep.hh"
#include "Offline/MCDataProducts/inc/SimParticle.hh"
#include "Offline/MCDataProducts/inc/CrvCoincidenceClusterMC.hh"
#include "Offline/MCDataProducts/inc/MCTrajectory.hh"
#include "art/Framework/Principal/Handle.h"

namespace mu2e
{
class CrvInfoHelper
{
public:

CrvInfoHelper() {}

void FillCrvHitInfoCollections(
art::Handle<CrvCoincidenceClusterCollection> const& crvCoincidences,
art::Handle<CrvCoincidenceClusterMCCollection> const& crvCoincidencesMC,
art::Handle<CrvRecoPulseCollection> const& crvRecoPulses,
art::Handle<CrvStepCollection> const& crvSteps,
art::Handle<MCTrajectoryCollection> const& mcTrajectories,
CrvHitInfoRecoCollection &recoInfo, CrvHitInfoMCCollection &MCInfo,
CrvSummaryReco &recoSummary, CrvSummaryMC &MCSummary,
CrvPlaneInfoMCCollection &MCInfoPlane, double crvPlaneY);

void FillCrvPulseInfoCollections(
art::Handle<CrvRecoPulseCollection> const& crvRecoPulses,
art::Handle<CrvDigiMCCollection> const& crvDigiMCs,
art::Handle<CrvDigiCollection> const& crvDigis,
CrvPulseInfoRecoCollection &recoInfo, CrvHitInfoMCCollection &MCInfo, CrvWaveformInfoCollection &waveformInfo);

private:
static const art::Ptr<SimParticle> &FindPrimaryParticle(const art::Ptr<SimParticle> &simParticle)
{
return simParticle->hasParent() ? FindPrimaryParticle(simParticle->parent()) : simParticle;
}
static const SimParticle &FindPrimaryParticle(const SimParticle &simParticle)
{
return simParticle.hasParent() ? *FindPrimaryParticle(simParticle.parent()) : simParticle;
}
static const art::Ptr<SimParticle> &FindParentParticle(const art::Ptr<SimParticle> &simParticle)
{
return simParticle->hasParent() ? simParticle->parent() : simParticle;
}
static const art::Ptr<SimParticle> &FindGParentParticle(const art::Ptr<SimParticle> &simParticle)
{
const art::Ptr<SimParticle> &parentParticle = simParticle->hasParent() ? simParticle->parent() : simParticle;
return parentParticle->hasParent() ? parentParticle->parent() : parentParticle;
}

static const int _trajectorySimParticleId = 300001; //only temporarily here for some tests
};

}
Loading

0 comments on commit 73155aa

Please sign in to comment.