@@ -34,6 +34,11 @@ void SimpleStepAnalysis::initialize()
3434 histNStepsPerMod = getHistogram<TH1I>(" nStepsPerMod" , 1 , 2 ., 1 .);
3535 // accumulated number of steps per volume
3636 histNStepsPerVol = getHistogram<TH1I>(" nStepsPerVol" , 1 , 2 ., 1 .);
37+
38+ histOriginPerMod = getHistogram<TH1I>(" OriginsPerMod" , 1 , 2 ., 1 .);
39+ histOriginPerVol = getHistogram<TH1I>(" OriginsPerVol" , 1 , 2 ., 1 .);
40+ histOriginPerVolSorted = getHistogram<TH1I>(" OriginsPerVolSorted" , 1 , 2 ., 1 .);
41+
3742 // accumulated number of steps per pdg
3843 histNStepsPerPDG = getHistogram<TH1I>(" nStepsPerPDG" , 1 , 2 ., 1 .);
3944 histNStepsPerVolSorted = getHistogram<TH1I>(" nStepsPerVolSorted" , 1 , 2 ., 1 .);
@@ -115,9 +120,7 @@ void SimpleStepAnalysis::analyze(const std::vector<StepInfo>* const steps, const
115120
116121 // loop over all steps in an event
117122 for (const auto & step : *steps) {
118- int currentTrackID = step.trackID ;
119- bool newtrack = (currentTrackID != oldTrackID);
120- if (newtrack) oldTrackID = currentTrackID;
123+
121124
122125 // prepare for PDG ids and volume names
123126 mAnalysisManager ->getLookupPDG (step.trackID , pdgId);
@@ -133,6 +136,12 @@ void SimpleStepAnalysis::analyze(const std::vector<StepInfo>* const steps, const
133136 continue ;
134137 }
135138
139+ int currentTrackID = step.trackID ;
140+ bool newtrack = (currentTrackID != oldTrackID);
141+ if (newtrack) {
142+ oldTrackID = currentTrackID;
143+ }
144+
136145 if (keepsteps) {
137146 stepptr = &step;
138147 steptree->Fill ();
@@ -145,6 +154,16 @@ void SimpleStepAnalysis::analyze(const std::vector<StepInfo>* const steps, const
145154 histTrackEnergySpectrum->Fill (log10f (step.E ));
146155 histTrackPDGSpectrum->Fill (pdgasstring.c_str (),1 );
147156 histTrackProdProcess->Fill (step.getProdProcessAsString (),1 );
157+
158+ auto originid = mAnalysisManager ->getLookups ()->trackorigin [step.trackID ];
159+ std::string originVolName;
160+ // to store the module name
161+ std::string originModName;
162+ mAnalysisManager ->getLookupVolName (originid, originVolName);
163+ mAnalysisManager ->getLookupModName (originid, originModName);
164+
165+ histOriginPerMod->Fill (originModName.c_str (), 1 );
166+ histOriginPerVol->Fill (originVolName.c_str (), 1 );
148167 }
149168
150169 // record number of steps per module
@@ -169,6 +188,11 @@ void SimpleStepAnalysis::finalize()
169188 histNStepsPerVolSorted->SetName (" nStepsPerVolSorted" );
170189 histNStepsPerVolSorted->LabelsOption (" >" , " X" );
171190
191+ *histOriginPerVolSorted = *histOriginPerVol;
192+ histOriginPerVolSorted->SetName (" OriginPerVolSorted" );
193+ histOriginPerVolSorted->LabelsOption (" >" , " X" );
194+ histOriginPerVolSorted->SetBins (30 , 0 , 30 );
195+
172196 std::cerr << " MOD have " << histNStepsPerMod->GetEntries () << " entries \n " ;
173197
174198 *histTrackPDGSpectrumSorted = *histTrackPDGSpectrum;
0 commit comments