Skip to content

Commit 58e700e

Browse files
Merge pull request #369 from ehrlich-uva/main
rearranged CRV part
2 parents 6264a51 + a6615a7 commit 58e700e

5 files changed

Lines changed: 36 additions & 50 deletions

File tree

inc/CrvInfoHelper.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ namespace mu2e
4949
CrvPulseInfoRecoCollection &recoInfo, CrvHitInfoMCCollection &MCInfo);
5050

5151
void FillCrvDigiInfoCollections(
52-
art::Handle<CrvRecoPulseCollection> const& crvRecoPulses,
5352
art::Handle<CrvDigiCollection> const& crvDigis,
5453
CrvWaveformInfoCollection &digiInfo);
5554

inc/CrvPulseInfoReco.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace mu2e
1414
XYZVectorF pos; //average position of counters
1515
int barId = -1; //CRV counter ID
1616
int sectorId = -1; //CRV sector ID
17-
int SiPMId = -1; //SiPMId number //uses actual SiPM numbers for reco pulses of coincidence clusters - otherwise sequential SiPMIs generated by a SiPM map
17+
int SiPMId = -1; //SiPMId number
1818
int PEs = -1; //PEs using pulse integral
1919
int PEsPulseHeight = -1; //PEs using pulse height
2020
float pulseHeight = -1; //Pulse height

inc/CrvWaveformInfo.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ namespace mu2e
99
{
1010
float adc = -1;
1111
float time = -1;
12+
int barId = -1;
1213
int SiPMId = -1;
1314
CrvWaveformInfo(){}
14-
CrvWaveformInfo(float adc, float time, int SiPMId) :
15+
CrvWaveformInfo(float adc, float time, int barId, int SiPMId) :
1516
adc(adc),
1617
time(time),
18+
barId(barId),
1719
SiPMId(SiPMId)
1820
{}
1921
};

src/CrvInfoHelper.cc

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ namespace mu2e
235235
if(!crvRecoPulses.isValid()) return;
236236

237237
GeomHandle<CosmicRayShield> CRS;
238-
const std::map<int,int> sipm_map = GetSiPMMap(CRS);
239238

240239
// Loop through all reco pulses
241240
for(size_t recoPulseIndex=0; recoPulseIndex<crvRecoPulses->size(); recoPulseIndex++)
@@ -250,14 +249,14 @@ namespace mu2e
250249
CrvHelper::GetCrvCounterInfo(CRS, barIndex, sectorNumber, moduleNumber, layerNumber, counterNumber);
251250

252251
//Reco pulses information
253-
int SiPM = crvRecoPulse->GetSiPMNumber();
254-
int SiPMId = sipm_map.find(barIndex.asInt()*CRVId::nChanPerBar + SiPM)->second;
255252
CLHEP::Hep3Vector HitPos = CrvHelper::GetCrvCounterPos(CRS, barIndex);
256-
recoInfo.emplace_back(HitPos, barIndex.asInt(), sectorNumber, SiPMId,
253+
recoInfo.emplace_back(tdet->toDetector(HitPos), barIndex.asInt(), sectorNumber, crvRecoPulse->GetSiPMNumber(),
257254
crvRecoPulse->GetPEs(), crvRecoPulse->GetPEsPulseHeight(), crvRecoPulse->GetPulseHeight(),
258255
crvRecoPulse->GetPulseBeta(), crvRecoPulse->GetPulseFitChi2(), crvRecoPulse->GetPulseTime());
259256

260257
//MCtruth pulses information
258+
if(!crvDigiMCs.isValid()) return;
259+
261260
double visibleEnergyDeposited = 0;
262261
double earliestHitTime = 0;
263262
double avgHitTime = 0;
@@ -296,22 +295,17 @@ namespace mu2e
296295

297296
// Fill digis struct
298297
void CrvInfoHelper::FillCrvDigiInfoCollections (
299-
art::Handle<CrvRecoPulseCollection> const& crvRecoPulses,
300298
art::Handle<CrvDigiCollection> const& crvDigis,
301299
CrvWaveformInfoCollection &digiInfo){
302300

303-
if(!crvRecoPulses.isValid()) return;
304-
305301
GeomHandle<CosmicRayShield> CRS;
306-
const std::map<int,int> sipm_map = GetSiPMMap(CRS);
307302

308303
// Fill digis/waveforminfo struct
309304
for(size_t j=0; j<crvDigis->size(); j++)
310305
{
311306
mu2e::CrvDigi const& digi(crvDigis->at(j));
312-
int SiPMId = sipm_map.find(digi.GetScintillatorBarIndex().asInt()*4 + digi.GetSiPMNumber())->second;
313307
for(size_t k=0; k<digi.GetADCs().size(); k++)
314-
digiInfo.emplace_back(digi.GetADCs()[k], (digi.GetStartTDC()+k)*CRVDigitizationPeriod, SiPMId);
308+
digiInfo.emplace_back(digi.GetADCs()[k], (digi.GetStartTDC()+k)*CRVDigitizationPeriod, digi.GetScintillatorBarIndex().asInt(), digi.GetSiPMNumber());
315309
}
316310
} // FillCrvDigiInfoCollections
317311

src/EventNtupleMaker_module.cc

Lines changed: 28 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ namespace mu2e {
421421
break;
422422
}
423423
}
424-
424+
425425
// Put all the branch configurations together
426426
for(const auto& branch_cfg : _conf.branches()){
427427
_allBranches.push_back(branch_cfg);
@@ -448,7 +448,7 @@ namespace mu2e {
448448
if(_fillcalomc && _fillmc){
449449
_allMCTCHIs[i_branch] = std::vector<CaloClusterInfoMC>();
450450
}
451-
451+
452452
RecoQualInfo rqi;
453453
_allRQIs.push_back(rqi);
454454

@@ -616,24 +616,21 @@ namespace mu2e {
616616

617617
// general CRV info
618618
if(_fillcrvcoincs) {
619-
// coincidence branches should be here FIXME
620619
_ntuple->Branch("crvsummary",&_crvsummary,_buffsize,_splitlevel);
621620
_ntuple->Branch("crvcoincs.",&_crvcoincs,_buffsize,_splitlevel);
622-
if(_fillcrvpulses) {
623-
_ntuple->Branch("crvpulses.",&_crvpulses,_buffsize,_splitlevel);
624-
}
625-
if(_fillcrvdigis) {
626-
_ntuple->Branch("crvdigis.",&_crvdigis,_buffsize,_splitlevel);
627-
}
628621
if(_fillmc){
629622
_ntuple->Branch("crvsummarymc",&_crvsummarymc,_buffsize,_splitlevel);
630623
_ntuple->Branch("crvcoincsmc.",&_crvcoincsmc,_buffsize,_splitlevel);
631624
_ntuple->Branch("crvcoincsmcplane.",&_crvcoincsmcplane,_buffsize,_splitlevel);
632-
if(_fillcrvpulses) {
633-
_ntuple->Branch("crvpulsesmc.",&_crvpulsesmc,_buffsize,_splitlevel);
634-
}
635625
}
636626
}
627+
if(_fillcrvpulses) {
628+
_ntuple->Branch("crvpulses.",&_crvpulses,_buffsize,_splitlevel);
629+
if(_fillmc) _ntuple->Branch("crvpulsesmc.",&_crvpulsesmc,_buffsize,_splitlevel);
630+
}
631+
if(_fillcrvdigis) {
632+
_ntuple->Branch("crvdigis.",&_crvdigis,_buffsize,_splitlevel);
633+
}
637634
// CRV cosmic inference
638635
if(_fillCrvInference) {
639636
_ntuple->Branch("crvcosmic.",&_crvInference,_buffsize,_splitlevel);
@@ -1006,63 +1003,57 @@ namespace mu2e {
10061003
}
10071004
}
10081005

1009-
1010-
// TODO we want MC information when we don't have a track
1011-
// fill general CRV info
1006+
// fill CRV info
10121007
if(_fillcrvcoincs){
1013-
// clear vectors
10141008
_crvcoincs.clear();
10151009
_crvcoincsmc.clear();
10161010
_crvcoincsmcplane.clear();
1017-
_crvpulses.clear();
1018-
_crvdigis.clear();
1019-
_crvpulsesmc.clear();
10201011

10211012
event.getByLabel(_conf.crvCoincidencesTag(),_crvCoincidences);
10221013
event.getByLabel(_conf.crvRecoPulsesTag(),_crvRecoPulses);
10231014
event.getByLabel(_conf.crvStepsTag(),_crvSteps);
1024-
event.getByLabel(_conf.crvDigisTag(),_crvDigis);
1025-
if(_fillmc){
1026-
event.getByLabel(_conf.crvCoincidenceMCsTag(),_crvCoincidenceMCs);
1027-
event.getByLabel(_conf.crvDigiMCsTag(),_crvDigiMCs);
1028-
}
1015+
if(_fillmc) event.getByLabel(_conf.crvCoincidenceMCsTag(),_crvCoincidenceMCs);
10291016
_crvHelper.FillCrvHitInfoCollections(
10301017
_crvCoincidences, _crvCoincidenceMCs,
10311018
_crvRecoPulses, _crvSteps, _mcTrajectories,_crvcoincs, _crvcoincsmc,
10321019
_crvsummary, _crvsummarymc, _crvcoincsmcplane, _crvPlaneY, _pph);
1033-
if(_fillcrvpulses){
1034-
_crvHelper.FillCrvPulseInfoCollections(_crvRecoPulses, _crvDigiMCs, _ewmh,
1035-
_crvpulses, _crvpulsesmc);
1036-
}
1037-
if(_fillcrvdigis){
1038-
_crvHelper.FillCrvDigiInfoCollections(_crvRecoPulses, _crvDigis,
1039-
_crvdigis);
1040-
}
1041-
1020+
}
1021+
if(_fillcrvpulses){
1022+
_crvpulses.clear();
1023+
_crvpulsesmc.clear();
1024+
event.getByLabel(_conf.crvRecoPulsesTag(),_crvRecoPulses);
1025+
if(_fillmc) event.getByLabel(_conf.crvDigiMCsTag(),_crvDigiMCs);
1026+
_crvHelper.FillCrvPulseInfoCollections(_crvRecoPulses, _crvDigiMCs, _ewmh,
1027+
_crvpulses, _crvpulsesmc);
1028+
}
1029+
if(_fillcrvdigis){
1030+
_crvdigis.clear();
1031+
event.getByLabel(_conf.crvDigisTag(),_crvDigis);
1032+
_crvHelper.FillCrvDigiInfoCollections(_crvDigis,_crvdigis);
10421033
}
10431034

10441035
// fill CRV cosmic inference scores (T x C structure aligned with trk branches)
10451036
if(_fillCrvInference) {
10461037
_crvInference.clear();
10471038
// Init associations from CrvInference module: KalSeed <-> CrvCoincidenceCluster with MVAResult data product
10481039
art::Handle<art::Assns<KalSeed, CrvCoincidenceCluster, MVAResult>> crvInfHandle;
1049-
// grab the associations from the art::Event
1040+
// grab the associations from the art::Event
10501041
event.getByLabel(_crvInferenceTag, crvInfHandle);
10511042
// build a map from KalSeed ptr to scores
10521043
std::map<art::Ptr<KalSeed>, std::vector<MVAResultInfo>> crvInfMap;
10531044
// Get the scores from the associations and fill the map
1054-
if(crvInfHandle.isValid()) {
1045+
if(crvInfHandle.isValid()) {
10551046
// loop through association
10561047
for(const auto& assn : *crvInfHandle) {
10571048
MVAResultInfo info;
10581049
info.result = assn.data->_value; // the model score
10591050
info.valid = true; // true if assns is valid
1060-
crvInfMap[assn.first].push_back(info);
1051+
crvInfMap[assn.first].push_back(info);
10611052
}
10621053
}
10631054
// fill the branch
10641055
// iterate over all tracks to keep alignment with trk branches
1065-
// this means filling empty vectors for tracks with no coincidence
1056+
// this means filling empty vectors for tracks with no coincidence
10661057
const auto& kseedptr_coll = *_allKSPCHs.at(0);
10671058
for(size_t i = 0; i < kseedptr_coll.size(); ++i) {
10681059
auto it = crvInfMap.find(kseedptr_coll[i]);

0 commit comments

Comments
 (0)