1 #include "oaAnalysisTreeConverter.hxx" 2 #include "InputManager.hxx" 3 #include "Versioning.hxx" 4 #include "BasicUtils.hxx" 5 #include "HighlandAnalysisUtils.hxx" 6 #include "TreeConverterUtils.hxx" 7 #include "Parameters.hxx" 8 #include "P0DAnalysisUtils.hxx" 9 #include "P0DGeometryManager.hxx" 14 void oaAnalysisTreeConverter::GetBunchLocalP0DObjects(){
18 _AnaP0DVertices.clear();
19 _AnaP0DParticles.clear();
20 _AnaP0DClusters.clear();
21 _AnaP0DTracks.clear();
22 _AnaP0DShowers.clear();
24 _AnaP0DVertices.resize(NP0DReconVertices);
25 _AnaP0DParticles.resize(NP0DReconParticles);
26 _AnaP0DClusters.resize(NP0DReconClusters);
27 _AnaP0DTracks.resize(NP0DReconTracks);
28 _AnaP0DShowers.resize(NP0DReconShowers);
32 for (
int iP0D=0; iP0D<NP0DAlgoResults; ++iP0D){
33 ND::TP0DReconModule::TP0DAlgoRes *p0dAlgoRes = (ND::TP0DReconModule::TP0DAlgoRes*) (*P0DAlgoResults)[iP0D];
35 if (p0dAlgoRes->AlgorithmName == _p0dAlgoResName){
36 _topP0DAlgoRes = iP0D;
41 GetBunchLocalP0DObjectsInAlgoResult(_topP0DAlgoRes);
45 void oaAnalysisTreeConverter::GetBunchLocalP0DObjectsInAlgoResult(Int_t iAlgoRes){
48 if (iAlgoRes==-1)
return;
49 ND::TP0DReconModule::TP0DAlgoRes *p0dAlgoRes = (ND::TP0DReconModule::TP0DAlgoRes*) (*P0DAlgoResults)[iAlgoRes];
50 if (!p0dAlgoRes)
return;
52 for (
unsigned int i=0;i<NBUNCHES+1;i++){
53 _bunchP0DVerticesInAlgoRes [i][iAlgoRes].clear();
54 _bunchP0DClustersInAlgoRes [i][iAlgoRes].clear();
55 _bunchP0DParticlesInAlgoRes[i][iAlgoRes].clear();
56 _bunchP0DTracksInAlgoRes [i][iAlgoRes].clear();
57 _bunchP0DShowersInAlgoRes [i][iAlgoRes].clear();
61 for (UInt_t iP0D=0; iP0D<p0dAlgoRes->Vertices.size(); ++iP0D){
62 ND::TP0DReconModule::TP0DVertex *p0dVertex = (ND::TP0DReconModule::TP0DVertex*) (*P0DReconVertices)[p0dAlgoRes->Vertices[iP0D]];
65 if (ibunch==-1) ibunch = NBUNCHES;
67 _bunchP0DVerticesInAlgoRes[ibunch][iAlgoRes].push_back(p0dAlgoRes->Vertices[iP0D]);
71 for (UInt_t iP0D=0; iP0D<p0dAlgoRes->Clusters.size(); ++iP0D){
72 ND::TP0DReconModule::TP0DCluster *p0dCluster = (ND::TP0DReconModule::TP0DCluster*) (*P0DReconClusters)[p0dAlgoRes->Clusters[iP0D]];
75 if (ibunch==-1) ibunch = NBUNCHES;
77 _bunchP0DClustersInAlgoRes[ibunch][iAlgoRes].push_back(p0dAlgoRes->Clusters[iP0D]);
81 for (UInt_t iP0D=0; iP0D<p0dAlgoRes->Particles.size(); ++iP0D){
82 ND::TP0DReconModule::TP0DParticle *p0dParticle = (ND::TP0DReconModule::TP0DParticle*) (*P0DReconParticles)[p0dAlgoRes->Particles[iP0D]];
85 if (ibunch==-1) ibunch = NBUNCHES;
87 _bunchP0DParticlesInAlgoRes[ibunch][iAlgoRes].push_back(p0dAlgoRes->Particles[iP0D]);
91 for (UInt_t iP0D=0; iP0D<p0dAlgoRes->Tracks.size(); ++iP0D){
92 ND::TP0DReconModule::TP0DTrack *p0dTrack = (ND::TP0DReconModule::TP0DTrack*) (*P0DReconTracks)[p0dAlgoRes->Tracks[iP0D]];
95 if (ibunch==-1) ibunch = NBUNCHES;
97 _bunchP0DTracksInAlgoRes[ibunch][iAlgoRes].push_back(p0dAlgoRes->Tracks[iP0D]);
101 for (UInt_t iP0D=0; iP0D<p0dAlgoRes->Showers.size(); ++iP0D){
102 ND::TP0DReconModule::TP0DShower *p0dShower = (ND::TP0DReconModule::TP0DShower*) (*P0DReconShowers)[p0dAlgoRes->Showers[iP0D]];
105 if (ibunch==-1) ibunch = NBUNCHES;
107 _bunchP0DShowersInAlgoRes[ibunch][iAlgoRes].push_back(p0dAlgoRes->Showers[iP0D]);
111 for (UInt_t iP0D=0; iP0D<p0dAlgoRes->AlgoResults.size(); ++iP0D){
112 GetBunchLocalP0DObjectsInAlgoResult(p0dAlgoRes->AlgoResults[iP0D]);
117 void oaAnalysisTreeConverter::FillP0DBunch(
AnaBunchB* bunch, Int_t ibunch, Int_t iAlgoRes){
120 if(!_isUsingReconDirP0DNew)
return;
126 if (iAlgoRes==-1)
return;
127 ND::TP0DReconModule::TP0DAlgoRes *p0dAlgoRes = (ND::TP0DReconModule::TP0DAlgoRes*) (*P0DAlgoResults)[iAlgoRes];
130 p0dBunch->P0DWaterStatus = P0DWaterStatus;
133 p0dBunch->FullName = p0dAlgoRes->FullName;
136 FillP0DVertices(_bunchP0DVerticesInAlgoRes[ibunch][iAlgoRes], p0dBunch);
139 FillP0DParticles( _bunchP0DParticlesInAlgoRes[ibunch][iAlgoRes], p0dBunch);
140 FillP0DParticlesFromTracks( _bunchP0DTracksInAlgoRes [ibunch][iAlgoRes], p0dBunch);
141 FillP0DParticlesFromShowers(_bunchP0DShowersInAlgoRes [ibunch][iAlgoRes], p0dBunch);
144 FillP0DClusters(_bunchP0DClustersInAlgoRes[ibunch][iAlgoRes], p0dBunch);
147 for (UInt_t iAlt=0;iAlt<p0dAlgoRes->AlgoResults.size();iAlt++){
149 p0dBunch->AlternateBunches.push_back(alt);
150 FillP0DBunch(alt, ibunch, p0dAlgoRes->AlgoResults[iAlt]);
155 void oaAnalysisTreeConverter::FillP0DVertices(
const std::vector<Int_t>& indices,
AnaP0DBunch* bunch){
159 for (UInt_t iP0D=0; iP0D<indices.size(); ++iP0D){
160 ND::TP0DReconModule::TP0DVertex *p0dVertex = (ND::TP0DReconModule::TP0DVertex*) (*P0DReconVertices)[indices[iP0D]];
166 FillP0DVertexInfo(*p0dVertex,anaP0D, bunch);
170 if(anaP0D) bunch->
Vertices.push_back(anaP0D);
175 void oaAnalysisTreeConverter::FillP0DClusters(
const std::vector<Int_t>& indices,
AnaP0DBunch* bunch){
179 bunch->nClusters = 0;
180 anaUtils::CreateArray(bunch->Clusters, (Int_t)indices.size());
183 for (UInt_t iP0D=0; iP0D<indices.size(); ++iP0D){
184 ND::TP0DReconModule::TP0DCluster *p0dCluster = (ND::TP0DReconModule::TP0DCluster*) (*P0DReconClusters)[indices[iP0D]];
190 FillP0DClusterInfo(*p0dCluster,anaP0D);
194 if(anaP0D) bunch->Clusters[bunch->nClusters++] = anaP0D;
199 void oaAnalysisTreeConverter::FillP0DParticles(
const std::vector<Int_t>& indices,
AnaP0DBunch* bunch){
203 for (UInt_t iP0D=0; iP0D<indices.size(); ++iP0D){
204 ND::TP0DReconModule::TP0DParticle *p0dParticle = (ND::TP0DReconModule::TP0DParticle*) (*P0DReconParticles)[indices[iP0D]];
210 FillP0DParticleInfo(*p0dParticle,anaP0D);
214 if(anaP0D) bunch->
Particles.push_back(anaP0D);
219 void oaAnalysisTreeConverter::FillP0DParticlesFromTracks(
const std::vector<Int_t>& indices,
AnaP0DBunch* bunch){
223 for (UInt_t iP0D=0; iP0D<indices.size(); ++iP0D){
224 ND::TP0DReconModule::TP0DTrack *p0dTrack = (ND::TP0DReconModule::TP0DTrack*) (*P0DReconTracks)[indices[iP0D]];
227 AnaP0DParticle *anaP0D = GetAnaP0DParticleFromTrack(indices[iP0D]);
230 FillP0DParticleInfo(*p0dTrack,anaP0D);
234 if(anaP0D) bunch->
Particles.push_back(anaP0D);
239 void oaAnalysisTreeConverter::FillP0DParticlesFromShowers(
const std::vector<Int_t>& indices,
AnaP0DBunch* bunch){
243 for (UInt_t iP0D=0; iP0D<indices.size(); ++iP0D){
244 ND::TP0DReconModule::TP0DShower *p0dShower = (ND::TP0DReconModule::TP0DShower*) (*P0DReconShowers)[indices[iP0D]];
247 AnaP0DParticle *anaP0D = GetAnaP0DParticleFromShower(indices[iP0D]);
250 FillP0DParticleInfo(*p0dShower,anaP0D);
254 if(anaP0D) bunch->
Particles.push_back(anaP0D);
259 void oaAnalysisTreeConverter::FillP0DVertexInfo(ND::TP0DReconModule::TP0DVertex& p0dVertex,
AnaP0DVertex* anaP0DVertex,
AnaBunchB* bunch){
264 anaP0DVertex->AlgorithmName = p0dVertex.AlgorithmName;
265 anaP0DVertex->NHits = p0dVertex.NHits;
267 anaP0DVertex->
Status = p0dVertex.Status;
268 anaP0DVertex->ValidDimensions = p0dVertex.ValidDimensions;
269 anaP0DVertex->Fiducial = p0dVertex.Fiducial;
271 anaUtils::VectorToArray(p0dVertex.Position, anaP0DVertex->
Position );
272 anaUtils::VectorToArray(p0dVertex.PosVariance, anaP0DVertex->PosVariance);
275 Float_t max_charge=0;
280 anaP0DVertex->nParticles = 0;
281 anaUtils::CreateArray(anaP0DVertex->
Particles, p0dVertex.Particles.size());
282 for (UInt_t i=0;i<p0dVertex.Particles.size();i++){
283 ND::TP0DReconModule::TP0DParticle *p0dReconParticle = (ND::TP0DReconModule::TP0DParticle*) (*P0DReconParticles)[p0dVertex.Particles[i]];
284 AnaP0DParticle* p0dParticle = GetAnaP0DParticle(p0dVertex.Particles[i]);
288 for (UInt_t j=0;j<bunch->
Particles.size();j++){
298 if (_addGlobalTracksToP0DVertices){
300 anaP0DVertex->
Particles[anaP0DVertex->nParticles++] = globalTrack;
303 AddReconVertexToReconParticle(anaP0DVertex, globalTrack);
308 else if ((UInt_t)bunch->
Particles[j]->UniqueID==p0dReconParticle->UniqueID){
310 if (_addGlobalTracksToP0DVertices){
323 if (!found || !_addGlobalTracksToP0DVertices){
326 anaP0DVertex->
Particles[anaP0DVertex->nParticles++] = p0dParticle;
329 FillP0DParticleInfo(*p0dReconParticle,p0dParticle);
342 for(UInt_t j = 0; j < p0dReconParticle->Truth_TrajIDs.size(); j++ ){
343 if (p0dReconParticle->Truth_ChargeShare[j] > max_charge){
344 max_charge = p0dReconParticle->Truth_ChargeShare[j];
345 max_ID = p0dReconParticle->Truth_TrajIDs[j];
351 anaP0DVertex->nClusters = 0;
352 anaUtils::CreateArray(anaP0DVertex->Clusters, p0dVertex.Clusters.size());
353 for (UInt_t i=0;i<p0dVertex.Clusters.size();i++){
354 ND::TP0DReconModule::TP0DCluster *p0dCluster2 = (ND::TP0DReconModule::TP0DCluster*) (*P0DReconClusters)[p0dVertex.Clusters[i]];
355 AnaP0DCluster* p0dCluster3 = GetAnaP0DCluster(p0dVertex.Clusters[i]);
358 anaP0DVertex->Clusters[anaP0DVertex->nClusters++] = p0dCluster3;
361 FillP0DClusterInfo(*p0dCluster2,p0dCluster3);
366 std::vector<AnaTrueParticleB*>::iterator it;
369 if (max_ID == trueTrack->
ID){
379 void oaAnalysisTreeConverter::FillP0DParticleInfo(ND::TP0DReconModule::TP0DParticle& p0dParticle,
AnaP0DParticle* anaP0DParticle){
387 anaUtils::VectorToArray(p0dParticle.Position, anaP0DParticle->
PositionStart );
388 anaUtils::VectorToArray(p0dParticle.Direction, anaP0DParticle->
DirectionStart);
391 anaP0DParticle->AlgorithmName = p0dParticle.AlgorithmName;
392 anaP0DParticle->
NHits = p0dParticle.NHits;
393 anaP0DParticle->
UniqueID = p0dParticle.UniqueID;
394 anaP0DParticle->
Status = p0dParticle.Status;
395 anaP0DParticle->SideDeposit = p0dParticle.SideDeposit;
396 anaP0DParticle->EndDeposit = p0dParticle.EndDeposit;
397 anaP0DParticle->ValidDimensions = p0dParticle.ValidDimensions;
398 anaP0DParticle->
Momentum = p0dParticle.Momentum;
399 anaP0DParticle->
Charge = p0dParticle.Charge;
400 anaP0DParticle->realPIDNames = p0dParticle.realPIDNames;
401 anaP0DParticle->realPIDValues = p0dParticle.realPIDValues;
402 anaP0DParticle->integerPIDNames = p0dParticle.integerPIDNames;
403 anaP0DParticle->integerPIDValues = p0dParticle.integerPIDValues;
404 anaP0DParticle->PID = p0dParticle.PID;
405 anaP0DParticle->PID_weight = p0dParticle.PID_weight;
408 if (p0dParticle.Tracks.size()==1){
409 anaP0DParticle->Type = AnaP0DParticle::kTrack;
411 ND::TP0DReconModule::TP0DTrack *p0dTrack = (ND::TP0DReconModule::TP0DTrack*) (*P0DReconTracks)[p0dParticle.Tracks[0]];
412 anaP0DParticle->Length = p0dTrack->Length;
415 anaP0DParticle->nClusters = 0;
416 anaUtils::CreateArray(anaP0DParticle->Clusters, p0dTrack->Nodes.size());
417 for (UInt_t i=0;i<p0dTrack->Nodes.size();i++){
418 ND::TP0DReconModule::TP0DNode *p0dNode = (ND::TP0DReconModule::TP0DNode*) (*P0DReconNodes)[p0dTrack->Nodes[i]];
424 anaP0DParticle->Clusters[anaP0DParticle->nClusters++] = p0dCluster;
427 FillP0DClusterInfo(*p0dNode,p0dCluster);
430 else if (p0dParticle.Tracks.size()>1){
431 std::cout <<
"more than 1 track in particle" << std::endl;
435 if (p0dParticle.Showers.size()==1){
436 anaP0DParticle->Type = AnaP0DParticle::kShower;
438 ND::TP0DReconModule::TP0DShower *p0dShower = (ND::TP0DReconModule::TP0DShower*) (*P0DReconShowers)[p0dParticle.Showers[0]];
439 anaP0DParticle->EDeposit = p0dShower->EDeposit;
442 anaP0DParticle->nClusters = 0;
443 anaUtils::CreateArray(anaP0DParticle->Clusters, p0dShower->Clusters.size());
444 for (UInt_t i=0;i<p0dShower->Clusters.size();i++){
445 ND::TP0DReconModule::TP0DCluster *p0dCluster2 = (ND::TP0DReconModule::TP0DCluster*) (*P0DReconClusters)[p0dShower->Clusters[i]];
446 AnaP0DCluster* p0dCluster3 = GetAnaP0DCluster(p0dShower->Clusters[i]);
449 anaP0DParticle->Clusters[anaP0DParticle->nClusters++] = p0dCluster3;
452 FillP0DClusterInfo(*p0dCluster2,p0dCluster3);
474 else if (p0dParticle.Showers.size()>1){
475 std::cout <<
"more than 1 shower in particle" << std::endl;
480 Float_t max_charge=0;
482 Float_t total_charge=0;
483 for (UInt_t i = 0; i<p0dParticle.Truth_PrimaryTrajIDs.size();i++){
484 if (p0dParticle.Truth_ChargeShare[i] > max_charge){
485 max_charge = p0dParticle.Truth_ChargeShare[i];
488 total_charge += p0dParticle.Truth_ChargeShare[i];
496 std::vector<AnaTrueParticleB*>::iterator it;
500 if (p0dParticle.Truth_TrajIDs[max_index] == trueTrack->
ID){
502 if (p0dParticle.Truth_ChargeShare[max_index]/total_charge!=0)
503 static_cast<AnaTrueParticle*
>(trueTrack)->Purity = p0dParticle.Truth_ChargeShare[max_index]/total_charge;
547 void oaAnalysisTreeConverter::FillP0DParticleInfo(ND::TP0DReconModule::TP0DTrack& p0dTrack,
AnaP0DParticle* anaP0DParticle){
555 anaUtils::VectorToArray(p0dTrack.Position, anaP0DParticle->
PositionStart );
556 anaUtils::VectorToArray(p0dTrack.Direction, anaP0DParticle->
DirectionStart);
558 anaP0DParticle->Type = AnaP0DParticle::kTrack;
559 anaP0DParticle->AlgorithmName = p0dTrack.AlgorithmName;
560 anaP0DParticle->
NHits = p0dTrack.NHits;
561 anaP0DParticle->
UniqueID = p0dTrack.UniqueID;
562 anaP0DParticle->
Status = p0dTrack.Status;
563 anaP0DParticle->SideDeposit = p0dTrack.SideDeposit;
564 anaP0DParticle->EndDeposit = p0dTrack.EndDeposit;
565 anaP0DParticle->ValidDimensions = p0dTrack.ValidDimensions;
576 anaP0DParticle->Length = p0dTrack.Length;
579 anaP0DParticle->nClusters = 0;
580 anaUtils::CreateArray(anaP0DParticle->Clusters, p0dTrack.Nodes.size());
581 for (UInt_t i=0;i<p0dTrack.Nodes.size();i++){
582 ND::TP0DReconModule::TP0DNode *p0dNode = (ND::TP0DReconModule::TP0DNode*) (*P0DReconNodes)[p0dTrack.Nodes[i]];
588 anaP0DParticle->Clusters[anaP0DParticle->nClusters++] = p0dCluster;
591 FillP0DClusterInfo(*p0dNode,p0dCluster);
595 Float_t max_charge=0;
597 Float_t total_charge=0;
598 for (UInt_t i = 0; i<p0dTrack.Truth_PrimaryTrajIDs.size();i++){
599 if (p0dTrack.Truth_ChargeShare[i] > max_charge){
600 max_charge = p0dTrack.Truth_ChargeShare[i];
603 total_charge += p0dTrack.Truth_ChargeShare[i];
611 std::vector<AnaTrueParticleB*>::iterator it;
615 if (p0dTrack.Truth_TrajIDs[max_index] == trueTrack->
ID){
617 if (p0dTrack.Truth_ChargeShare[max_index]/total_charge!=0)
618 static_cast<AnaTrueParticle*
>(trueTrack)->Purity = p0dTrack.Truth_ChargeShare[max_index]/total_charge;
639 void oaAnalysisTreeConverter::FillP0DParticleInfo(ND::TP0DReconModule::TP0DShower& p0dShower,
AnaP0DParticle* anaP0DParticle){
647 anaUtils::VectorToArray(p0dShower.Position, anaP0DParticle->
PositionStart );
648 anaUtils::VectorToArray(p0dShower.Direction, anaP0DParticle->
DirectionStart);
650 anaP0DParticle->Type = AnaP0DParticle::kShower;
651 anaP0DParticle->AlgorithmName = p0dShower.AlgorithmName;
652 anaP0DParticle->
NHits = p0dShower.NHits;
653 anaP0DParticle->
UniqueID = p0dShower.UniqueID;
654 anaP0DParticle->
Status = p0dShower.Status;
655 anaP0DParticle->SideDeposit = p0dShower.SideDeposit;
656 anaP0DParticle->EndDeposit = p0dShower.EndDeposit;
657 anaP0DParticle->ValidDimensions = p0dShower.ValidDimensions;
669 anaP0DParticle->Length = p0dShower.Length;
672 anaP0DParticle->nClusters = 0;
673 anaUtils::CreateArray(anaP0DParticle->Clusters, p0dShower.Nodes.size());
674 for (UInt_t i=0;i<p0dShower.Nodes.size();i++){
675 ND::TP0DReconModule::TP0DNode *p0dNode = (ND::TP0DReconModule::TP0DNode*) (*P0DReconNodes)[p0dShower.Nodes[i]];
681 anaP0DParticle->Clusters[anaP0DParticle->nClusters++] = p0dCluster;
684 FillP0DClusterInfo(*p0dNode,p0dCluster);
688 Float_t max_charge=0;
690 Float_t total_charge=0;
691 for (UInt_t i = 0; i<p0dShower.Truth_PrimaryTrajIDs.size();i++){
692 if (p0dShower.Truth_ChargeShare[i] > max_charge){
693 max_charge = p0dShower.Truth_ChargeShare[i];
696 total_charge += p0dShower.Truth_ChargeShare[i];
704 std::vector<AnaTrueParticleB*>::iterator it;
708 if (p0dShower.Truth_TrajIDs[max_index] == trueTrack->
ID){
710 if (p0dShower.Truth_ChargeShare[max_index]/total_charge!=0)
711 static_cast<AnaTrueParticle*
>(trueTrack)->Purity = p0dShower.Truth_ChargeShare[max_index]/total_charge;
733 void oaAnalysisTreeConverter::FillP0DClusterInfo(ND::TP0DReconModule::TP0DCluster& p0dCluster,
AnaP0DCluster* anaP0DCluster){
736 anaP0DCluster->AlgorithmName = p0dCluster.AlgorithmName;
737 anaP0DCluster->UniqueID = p0dCluster.UniqueID;
738 anaP0DCluster->ValidDimensions = p0dCluster.ValidDimensions;
740 anaP0DCluster->EDeposit = p0dCluster.EDeposit;
742 anaUtils::CopyArray(p0dCluster.Moments, anaP0DCluster->
Moments, 9);
744 anaUtils::VectorToArray(p0dCluster.Position, anaP0DCluster->Position );
745 anaUtils::VectorToArray(p0dCluster.PosVariance, anaP0DCluster->PosVariance);
748 anaP0DCluster->nHits = 0;
749 anaUtils::CreateArray(anaP0DCluster->Hits, p0dCluster.Hits.size());
750 for (UInt_t i=0;i<p0dCluster.Hits.size();i++){
751 ND::TP0DReconModule::TP0DHit *p0dHit = (ND::TP0DReconModule::TP0DHit*) (*P0DReconHits)[p0dCluster.Hits[i]];
757 anaP0DCluster->Hits[anaP0DCluster->nHits++] = p0dHit2;
760 FillP0DHitInfo(*p0dHit,p0dHit2);
764 Float_t max_charge=0;
766 for (UInt_t i = 0; i<p0dCluster.Truth_PrimaryTrajIDs.size();i++){
767 if (p0dCluster.Truth_ChargeShare[i] > max_charge){
768 max_charge = p0dCluster.Truth_ChargeShare[i];
774 anaP0DCluster->TrueParticle=NULL;
776 std::vector<AnaTrueParticleB*>::iterator it;
779 if (p0dCluster.Truth_TrajIDs[max_index] == trueTrack->
ID){
789 void oaAnalysisTreeConverter::FillP0DClusterInfo(ND::TP0DReconModule::TP0DNode& p0dNode,
AnaP0DCluster* anaP0DCluster){
794 anaP0DCluster->ValidDimensions = p0dNode.ValidDimensions;
796 anaP0DCluster->EDeposit = p0dNode.EDeposit;
798 anaUtils::VectorToArray(p0dNode.Position, anaP0DCluster->Position );
799 anaUtils::VectorToArray(p0dNode.PosVariance, anaP0DCluster->PosVariance);
802 anaP0DCluster->nHits = 0;
803 anaUtils::CreateArray(anaP0DCluster->Hits, p0dNode.Hits.size());
804 for (UInt_t i=0;i<p0dNode.Hits.size();i++){
805 ND::TP0DReconModule::TP0DHit *p0dHit = (ND::TP0DReconModule::TP0DHit*) (*P0DReconHits)[p0dNode.Hits[i]];
811 anaP0DCluster->Hits[anaP0DCluster->nHits++] = p0dHit2;
814 FillP0DHitInfo(*p0dHit,p0dHit2);
819 Float_t max_charge=0;
821 for (UInt_t i = 0; i<p0dNode.Truth_PrimaryTrajIDs.size();i++){
822 if (p0dNode.Truth_ChargeShare[i] > max_charge){
823 max_charge = p0dNode.Truth_ChargeShare[i];
829 anaP0DCluster->TrueParticle=NULL;
831 std::vector<AnaTrueParticleB*>::iterator it;
834 if (p0dNode.Truth_TrajIDs[max_index] == trueTrack->
ID){
844 void oaAnalysisTreeConverter::FillP0DHitInfo(ND::TP0DReconModule::TP0DHit& p0dHit,
AnaP0DHit* anaP0DHit){
866 anaP0DHit->Charge = p0dHit.Charge;
868 anaP0DHit->GeomID = p0dHit.GeomID;
870 anaP0DHit->Time = p0dHit.Time;
874 ND::TP0DReconModule::TP0DParticle* oaAnalysisTreeConverter::GetP0DReconParticleWithUniqueID(UInt_t uniqueID){
877 ND::TP0DReconModule::TP0DParticle *p0dParticle = NULL;
878 for (Int_t i=0;i<NP0DReconParticles;i++){
879 ND::TP0DReconModule::TP0DParticle *p0dReconParticle = (ND::TP0DReconModule::TP0DParticle*) (*P0DReconParticles)[i];
880 if (p0dReconParticle->UniqueID == uniqueID){
881 p0dParticle = p0dReconParticle;
891 void oaAnalysisTreeConverter::AddReconVertexToReconParticle(
AnaVertexB* vertex,
AnaTrack* part){
907 void oaAnalysisTreeConverter::FillDelayedClustersInfo(
AnaSpill& spill){
910 for (std::vector<AnaBunchC*>::iterator it = spill.
Bunches.begin(); it != spill.
Bunches.end(); ++it) {
918 AnaP0DVertex* oaAnalysisTreeConverter::GetAnaP0DVertex(Int_t index){
921 if (_AnaP0DVertices[index])
return _AnaP0DVertices[index];
923 _AnaP0DVertices[index] = MakeP0DVertex();
924 return _AnaP0DVertices[index];
928 AnaP0DCluster* oaAnalysisTreeConverter::GetAnaP0DCluster(Int_t index){
931 if (_AnaP0DClusters[index])
return _AnaP0DClusters[index];
933 _AnaP0DClusters[index] = MakeP0DCluster();
934 return _AnaP0DClusters[index];
938 AnaP0DParticle* oaAnalysisTreeConverter::GetAnaP0DParticle(Int_t index){
941 if (_AnaP0DParticles[index])
return _AnaP0DParticles[index];
943 _AnaP0DParticles[index] = MakeP0DParticle();
944 return _AnaP0DParticles[index];
948 AnaP0DParticle* oaAnalysisTreeConverter::GetAnaP0DParticleFromTrack(Int_t index){
951 if (_AnaP0DTracks[index])
return _AnaP0DTracks[index];
953 _AnaP0DTracks[index] = MakeP0DParticle();
954 return _AnaP0DTracks[index];
958 AnaP0DParticle* oaAnalysisTreeConverter::GetAnaP0DParticleFromShower(Int_t index){
961 if (_AnaP0DShowers[index])
return _AnaP0DShowers[index];
963 _AnaP0DShowers[index] = MakeP0DParticle();
964 return _AnaP0DShowers[index];
bool cosmic_mode
Whether we're running in "cosmic" mode, where there is only one bunch.
AnaTrueVertexB * TrueVertex
Pointer to the AnaTrueVertexB of the interaction that created this AnaTrueParticleB.
int nP0DSegments
How many P0D tracks are associated with this track.
Float_t PositionStart[4]
The reconstructed start position of the particle.
Representation of a global track.
AnaTrueVertexB * TrueVertex
AnaP0DParticleB * P0DSegments[NMAXP0DS]
The P0D segments that contributed to this global track.
Int_t Status
The Status of the fit of this reconstructed object.
Float_t Position[4]
The identified position of the global vertex.
std::vector< AnaBunchC * > Bunches
The reconstructed objects, split into timing bunches.
Int_t Bunch
The bunch of the track, based on the PositionStart.T()
AnaTrueObjectC * TrueObject
The link to the true oject that most likely generated this reconstructed object.
Float_t Moments[9]
Moments of the Cluster.
Int_t Bunch
The bunch of the global vertex, based on the Position.T()
Int_t UniqueID
The UniqueID of this reconstructed object.
Float_t Charge
The reconstructed charge of the particle.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
std::vector< AnaVertexB * > Vertices
AnaDelayedClustersB ** DelayedClusters
The delayed cluster groups.
static void SetDetectorUsed(unsigned long &BitField, SubDetId::SubDetEnum det)
Method to set a certain subdetector or subdetector system to used used.
Float_t Momentum
The reconstructed momentum of the particle, at the start position.
Representation of a true Monte Carlo vertex.
Representation of a true Monte Carlo trajectory/particle.
Int_t NHits
The number of hits in the particle.
AnaParticleB ** Particles
std::vector< AnaTrueParticleB * > TrueParticles
The true MC particles used in this spill.
Representation of a global vertex.
AnaVertexB * ReconVertex
The pointer to the most primary AnaVertexB (global vertex) associated with this track.
Float_t DirectionStart[3]
The reconstructed start direction of the particle.
Int_t Bunch
The index of this bunch (0-7).
std::vector< AnaVertexB * > ReconVertices
Vector of pointers to AnaVertexB (global vertices) associated with this track.
Int_t PrimaryIndex
Index of the global vertex.
std::vector< AnaParticleB * > Particles
AnaTrueParticleB * GetTrueParticle() const
Return a casted version of the AnaTrueObject associated.
Int_t GetBunch(Float_t tTrack, Int_t run, bool isMC, bool cosmic_mode, Float_t sigma=15., Float_t NSigmas=4.0) const
The run number for a given time.
Representation of a true Monte Carlo trajectory/particle.
Int_t GetMichelElectrons(const AnaSpillB &spill, AnaDelayedClustersB **&delayedClusters, Int_t firstBunch=0)
Get the number of P0D michel electrons.