FairShip
Loading...
Searching...
No Matches
MuDISProcessor Class Reference

#include <MuDISProcessor.h>

Collaboration diagram for MuDISProcessor:
[legend]

Public Member Functions

 MuDISProcessor ()
 ~MuDISProcessor ()
bool init (const int &aEvts, const int &aStart, const double &aMinPythiaP, const int &aDIS, const int &aSeed, const double &aZmax, const double &aZmin=2500)
void initPythia6 ()
void rotate (const TVector3 &pvec, const double &theta, const double &phi, TVector3 &newp)
Bool_t InitFile (const char *, int)
Bool_t InitFile (const char *)
Bool_t InitFiles (const std::vector< std::string > &, int)
Bool_t InitFiles (const std::vector< std::string > &)
void process_file (const std::string &input, const std::string &output)
void process_file (const std::vector< std::string > &input, const std::string &output)
void initEvent ()
void fillMCTracks (const Int_t aIdx)
void fillSBTHits (const Int_t aIdx)
void fillUBTHits (const Int_t aIdx)
void fillSSTHits (const Int_t aIdx)
void fillTDHits (const Int_t aIdx)
void CheckAllVolumes ()
void SetMuonShieldField (ShipBFieldMap *field, TGeoManager *geometry)
void SetPocaJumpThreshold (double threshold)
void generateDISevents (const std::string &tType, const double &amuonW, const std::string &aLabel, const MuonPath &aPath, ShipMuDIS::MuonDISBranches &aDISBr)
void ProcessMuons ()

Private Attributes

TChain * ftree
ShipMuDIS::CBMSimBranches finEv
TTree * fouttree
ShipMuDIS::MuonBranches foutEv
FairLogger * fLogger
int fnEvts
 don't make it persistent, magic ROOT command
int fstartEvt
TPythia6 * fPythia
double fMinPythiaP
int fnDIS
int fP6seed
MuGeoProcessor fGeoProcessor

Detailed Description

Definition at line 19 of file MuDISProcessor.h.

Constructor & Destructor Documentation

◆ MuDISProcessor()

MuDISProcessor::MuDISProcessor ( )

default constructor

Definition at line 36 of file MuDISProcessor.cxx.

36 {
37 ftree = nullptr;
38 fouttree = nullptr;
39
40 fLogger = FairLogger::GetLogger();
41 fnEvts = -1;
42 fstartEvt = 0;
43 fPythia = TPythia6::Instance();
44
45 fMinPythiaP = 2;
46 fnDIS = 10;
47 fP6seed = 0;
48}
int fnEvts
don't make it persistent, magic ROOT command
TPythia6 * fPythia
FairLogger * fLogger

◆ ~MuDISProcessor()

MuDISProcessor::~MuDISProcessor ( )
inline

destructor

Definition at line 25 of file MuDISProcessor.h.

25{ delete ftree; }

Member Function Documentation

◆ CheckAllVolumes()

void MuDISProcessor::CheckAllVolumes ( )
inline

Definition at line 48 of file MuDISProcessor.h.

48{ fGeoProcessor.CheckAllVolumes(); }
MuGeoProcessor fGeoProcessor

◆ fillMCTracks()

void MuDISProcessor::fillMCTracks ( const Int_t aIdx)

Definition at line 224 of file MuDISProcessor.cxx.

224 {
225 Int_t iEle = 0;
226 for (auto& tkIt : (*finEv.MCTrack)) {
227 if (iEle == aIdx) foutEv.mcTrks.push_back(tkIt);
228
229 if (tkIt.GetMotherId() == aIdx) {
230 std::string procName = tkIt.GetProcName().Data();
231 if (procName.find("Muon nuclear interaction") == procName.npos)
232 foutEv.mcTrks.push_back(tkIt);
233 }
234 iEle++;
235 }
236}
ShipMuDIS::CBMSimBranches finEv
ShipMuDIS::MuonBranches foutEv

◆ fillSBTHits()

void MuDISProcessor::fillSBTHits ( const Int_t aIdx)

Definition at line 238 of file MuDISProcessor.cxx.

238 {
239 for (auto& hitIt : (*finEv.sbtPt)) {
240 if (hitIt.GetTrackID() == aIdx) {
241 foutEv.sbtPt.push_back(hitIt);
242 }
243 }
244}

◆ fillSSTHits()

void MuDISProcessor::fillSSTHits ( const Int_t aIdx)

Definition at line 254 of file MuDISProcessor.cxx.

254 {
255 for (auto& hitIt : (*finEv.sstPt)) {
256 if (hitIt.GetTrackID() == aIdx) {
257 foutEv.sstPt.push_back(hitIt);
258 }
259 }
260}

◆ fillTDHits()

void MuDISProcessor::fillTDHits ( const Int_t aIdx)

Definition at line 262 of file MuDISProcessor.cxx.

262 {
263 for (const auto& hit : *finEv.tdPt) {
264 if (hit.GetTrackID() == aIdx) foutEv.tdPt.push_back(hit);
265 }
266}

◆ fillUBTHits()

void MuDISProcessor::fillUBTHits ( const Int_t aIdx)

Definition at line 246 of file MuDISProcessor.cxx.

246 {
247 for (auto& hitIt : (*finEv.ubtPt)) {
248 if (hitIt.GetTrackID() == aIdx) {
249 foutEv.ubtPt.push_back(hitIt);
250 }
251 }
252}

◆ generateDISevents()

void MuDISProcessor::generateDISevents ( const std::string & tType,
const double & amuonW,
const std::string & aLabel,
const MuonPath & aPath,
ShipMuDIS::MuonDISBranches & aDISBr )

Definition at line 268 of file MuDISProcessor.cxx.

272 {
273 // for Pythia beam, just use the initial muon momentum...
274 //@FIXME AMM - is this OK ? Reinitialising each time will be too heavy...
275 if (aPath.GetNSlices() < 1) {
276 LOG(error)
277 << " --- calling generateDISevents on an empty path. Doing nothing.";
278 return;
279 }
280 aDISBr.nDISevtsGenerated = 0;
281 double P = aPath.GetMomentum(0);
282 LOG(debug) << " ** initial mu momentum: " << (*finEv.MCTrack).front().GetP()
283 << " Pythia init P: " << P;
284
285 if (P < fMinPythiaP) {
286 LOG(info) << " --- calling Pythia initialise with momentum " << P
287 << " in material " << aLabel
288 << " , min value for Pythia is: " << fMinPythiaP
289 << ". Doing nothing.";
290 return;
291 }
292 fPythia->Initialize("FIXT", tType.c_str(), "p+", P); // target = "p+"
293 if (fPythia->GetMSTI(53) == 1) {
294 LOG(warn) << " --- Pythia found nothing to generate for momentum " << P
295 << " in material " << aLabel
296 << " on a proton target. Skipping this muon.";
297 return;
298 }
299 aDISBr.pPythia = P;
300 bool isProton = true;
301 // print summary of initialisation params
302 // fPythia->Pylist(1);
303
304 // Preserve the shield's material-tail restriction in compact z, then sample
305 // actual segment length so changes of direction do not bias the vertices.
306 const double minLength = DISMinLength(aLabel, aPath);
307 double lastxs = 0;
308 for (int ia(0); ia < fnDIS; ++ia) {
309 LOG(debug) << " ---- Processing DIS event " << ia;
310 //@FIXME AMM - half-way through, we change to neutron target with 50-50 :
311 //---> update to real material ??
312 if (ia == static_cast<int>(fnDIS / 2)) {
313 fPythia->Initialize("FIXT", tType.c_str(), "n0", P); // target = "n0"
314 if (fPythia->GetMSTI(53) == 1) {
315 LOG(warn) << " --- Pythia found nothing to generate for momentum " << P
316 << " in material " << aLabel
317 << " on a neutron target. Keeping only the " << ia
318 << " proton events for this muon.";
319 break;
320 }
321 isProton = false;
322 }
323
324 // Choose a point on the measured segments, excluding spatial jumps.
325 unsigned slice = 0;
326 double realz = aPath.GetZAtLength(
327 gRandom->Uniform(minLength, aPath.GetLength()), slice);
328 double sliceP = aPath.GetMomentum(slice);
329 if (sliceP == 0) {
330 LOG(error) << " --- Slice in z has momentum " << sliceP
331 << ". Skipping DIS event " << ia;
332 continue;
333 }
334
335 fPythia->GenerateEvent();
336 aDISBr.nDISevts++;
337 // clean all but final stable particles
338 fPythia->Pyedit(1);
339
340 lastxs = fPythia->GetPARI(1); // in mb
341 aDISBr.DISxsec.push_back(lastxs); // in mb
342 aDISBr.DIStarget.push_back(isProton);
343
344 aDISBr.DISvz.push_back(realz);
345 aDISBr.DISvx.push_back(aPath.GetX(realz, slice));
346 aDISBr.DISvy.push_back(aPath.GetY(realz, slice));
347 aDISBr.DISvt.push_back(aPath.GetTimeNs(realz, slice));
348
349 double theta = TMath::ACos(aPath.Getpz(slice) / sliceP);
350 // returns phi between -pi and pi
351 double phi = TMath::ATan2(aPath.Getpy(slice), aPath.Getpx(slice));
352
353 unsigned ndaugh = fPythia->GetN();
354 aDISBr.nDISdau.push_back(ndaugh);
355
356 // loop over daughters and rotate in muon input direction
357 for (unsigned itrk(1); itrk < ndaugh + 1; ++itrk) {
358 DISparticle adau;
359 adau.pid = fPythia->GetK(itrk, 2);
360 TVector3 dauP(0, 0, 0);
361 TVector3 indauP(fPythia->GetP(itrk, 1), fPythia->GetP(itrk, 2),
362 fPythia->GetP(itrk, 3));
363 rotate(indauP, theta, phi, dauP);
364 adau.px = dauP.X();
365 adau.py = dauP.Y();
366 adau.pz = dauP.Z();
367 // A spatial rotation leaves the Pythia event-record energy unchanged.
368 adau.E = fPythia->GetP(itrk, 4);
369 aDISBr.DISparticles.push_back(adau);
370 } // loop on daughters
371
372 //
373 } // loop on DIS events
374
375 aDISBr.nDISevtsGenerated = aDISBr.nDISevts;
376
377 // Normalize to the density integrated over the sampled path interval.
378 if (aDISBr.nDISevts > 0)
379 aDISBr.wDIS =
380 amuonW / aDISBr.nDISevts * aPath.GetWeightedDensity(minLength);
381
382 LOG(debug) << " -- path " << aLabel << " muonW " << amuonW
383 << " -- size of DISparticles collections: " << std::endl
384 << " ---- particles: " << aDISBr.DISparticles.size() << std::endl
385 << " ---- nDIS events: " << aDISBr.nDISevts << std::endl
386 << " ---- weightDIS: " << aDISBr.wDIS << std::endl
387 << " ---- xsec: ";
388 for (int i(0); i < aDISBr.nDISevts; ++i) {
389 LOG(debug) << aDISBr.DISxsec[i] << " ";
390 }
391 LOG(debug) << " ---- vertex: ";
392 for (int i(0); i < aDISBr.nDISevts; ++i) {
393 LOG(debug) << "(" << aDISBr.DISvx[i] << "," << aDISBr.DISvy[i] << ","
394 << aDISBr.DISvz[i] << "," << aDISBr.DISvt[i] << ") ";
395 }
396}
const Int_t debug
void rotate(const TVector3 &pvec, const double &theta, const double &phi, TVector3 &newp)
double GetLength() const
Definition MuonPath.h:79
double GetWeightedDensity() const
Definition MuonPath.h:73
double GetX(const double &aZ, const unsigned &idx) const
Definition MuonPath.h:141
unsigned GetNSlices() const
Definition MuonPath.h:97
double Getpz(const unsigned &idx) const
Definition MuonPath.h:62
double Getpy(const unsigned &idx) const
Definition MuonPath.h:57
double GetTimeNs(const double &aZ, const unsigned &idx) const
Definition MuonPath.h:160
double GetY(const double &aZ, const unsigned &idx) const
Definition MuonPath.h:147
double GetMomentum(const unsigned &idx) const
Definition MuonPath.h:47
double GetZAtLength(double length, unsigned &idx) const
Definition MuonPath.cxx:41
double Getpx(const unsigned &idx) const
Definition MuonPath.h:52
int i
Definition ShipAna.py:108
std::vector< DISparticle > DISparticles
Definition MuDISDefs.h:62
std::vector< double > DISvz
Definition MuDISDefs.h:59
std::vector< double > DISvx
Definition MuDISDefs.h:57
std::vector< double > DISvy
Definition MuDISDefs.h:58
std::vector< double > DISxsec
Definition MuDISDefs.h:55
std::vector< double > DISvt
Definition MuDISDefs.h:60
std::vector< bool > DIStarget
Definition MuDISDefs.h:56
std::vector< int > nDISdau
Definition MuDISDefs.h:61

◆ init()

bool MuDISProcessor::init ( const int & aEvts,
const int & aStart,
const double & aMinPythiaP,
const int & aDIS,
const int & aSeed,
const double & aZmax,
const double & aZmin = 2500 )

Definition at line 50 of file MuDISProcessor.cxx.

53 {
54 fnEvts = aEvts;
55 fstartEvt = aStart;
56 fMinPythiaP = aMinPythiaP;
57 if (aDIS <= 0) {
58 LOG(warn) << " -- Invalid value passed for nDIS: " << aDIS
59 << ", should be strictly positive.";
60 return false;
61 } else {
62 fnDIS = aDIS;
63 }
64 fP6seed = aSeed;
65 fGeoProcessor.SetZmax(aZmax);
66 fGeoProcessor.SetZmin(aZmin);
67 return true;
68}

◆ initEvent()

void MuDISProcessor::initEvent ( )

Definition at line 215 of file MuDISProcessor.cxx.

215 {
216 // soft particles + detector hits
217 foutEv.initEvent(100);
218 // Number of DIS events generated per volume.
219 for (unsigned i(0); i < nMats; ++i) {
220 foutEv.br[i].initEvent(fnDIS);
221 }
222}

◆ InitFile() [1/2]

Bool_t MuDISProcessor::InitFile ( const char * fileName)

Definition at line 109 of file MuDISProcessor.cxx.

109 {
110 return InitFile(fileName, 0);
111}
Bool_t InitFile(const char *, int)

◆ InitFile() [2/2]

Bool_t MuDISProcessor::InitFile ( const char * fileName,
int startEvent )

Definition at line 118 of file MuDISProcessor.cxx.

118 {
119 std::vector<std::string> fileNames = {fileName};
120 return InitFiles(fileNames, startEvent);
121}
Bool_t InitFiles(const std::vector< std::string > &, int)

◆ InitFiles() [1/2]

Bool_t MuDISProcessor::InitFiles ( const std::vector< std::string > & fileNames)

Definition at line 113 of file MuDISProcessor.cxx.

113 {
114 return InitFiles(fileNames, 0);
115}

◆ InitFiles() [2/2]

Bool_t MuDISProcessor::InitFiles ( const std::vector< std::string > & fileNames,
int startEvent )

Definition at line 123 of file MuDISProcessor.cxx.

124 {
125 if (fileNames.empty()) {
126 LOG(error) << "MuDISProcessor: no input files provided. "
127 << "Check the -f/--inputFile argument or input file glob.";
128 return kFALSE;
129 }
130 for (const auto& fileName : fileNames) {
131 if (fileName.empty()) {
132 LOG(error) << "MuDISProcessor: received an empty input file name. "
133 << "Check the -f/--inputFile argument.";
134 return kFALSE;
135 }
136 }
137
138 LOG(info) << "Opening input file to find keys " << fileNames.at(0);
139 TFile* testFile = TFile::Open(fileNames.at(0).c_str(), "READ");
140 auto testKeys = testFile ? testFile->GetListOfKeys() : nullptr;
141 if (testKeys == nullptr) {
142 delete testFile;
143 LOG(error) << "MuDISProcessor: Error opening input file " << fileNames.at(0)
144 << ". Check that the path is correct and the file is a readable "
145 "ROOT file.";
146 return kFALSE;
147 }
148 const bool hastree = testKeys->FindObject("cbmsim") != nullptr;
149 testFile->Close();
150 delete testFile;
151
152 if (hastree) {
153 delete ftree;
154 ftree = new TChain("cbmsim");
155 for (auto& f : fileNames) {
156 LOG(info) << "Opening input file " << f;
157 ftree->Add(f.c_str());
158 }
159 int treeEvts = ftree->GetEntries();
160 LOG(info) << "Reading " << treeEvts << " entries.";
161
162 bool ok = finEv.Setup(ftree);
163
164 if (!ok) {
165 LOG(error)
166 << "MuDISProcessor: failed to bind one or more required branches";
167 return kFALSE;
168 }
169 LOG(info) << "MuDISProcessor: Initialization successful.";
170 return kTRUE;
171 }
172 return kFALSE;
173}

◆ initPythia6()

void MuDISProcessor::initPythia6 ( )

Definition at line 70 of file MuDISProcessor.cxx.

70 {
71 // set process 1=QCD, 2=DY/others
72 fPythia->SetMSEL(2);
73 // set min hard scale: 2 GeV --->try 1.5 for soft muons ?
74 fPythia->SetPARP(2, fMinPythiaP);
75 // disable decay for those PDGID
76 unsigned hadrons[10] = {211, 321, 130, 310, 3112,
77 3122, 3222, 3312, 3322, 3334};
78 for (unsigned ikf(0); ikf < 10; ++ikf) {
79 int kc = fPythia->Pycomp(hadrons[ikf]);
80 fPythia->SetMDCY(kc, 1, 0);
81 }
82
83 int seed = static_cast<int>(fP6seed % 900000000);
84 LOG(info) << " * Pythia6 seed set to " << fP6seed << " wrapped to " << seed
85 << std::endl;
86 fPythia->SetMRPY(1, seed);
87 // To direct specific verbose Pythia6 output to a special file.
88 fPythia->SetMSTU(11, 11);
89 // For standard output stream it would be:
90 // fPythia->SetMSTU(11, 6);
91 // Report a failed initialisation through MSTI(53) instead of stopping, so
92 // that a muon without any process to generate can be skipped.
93 fPythia->SetMSTP(127, 1);
94}

◆ process_file() [1/2]

void MuDISProcessor::process_file ( const std::string & input,
const std::string & output )

Definition at line 175 of file MuDISProcessor.cxx.

176 {
177 std::vector<std::string> fileNames = {input};
178 return process_file(fileNames, output);
179}
void process_file(const std::string &input, const std::string &output)

◆ process_file() [2/2]

void MuDISProcessor::process_file ( const std::vector< std::string > & input,
const std::string & output )

Definition at line 181 of file MuDISProcessor.cxx.

182 {
183 Bool_t treeOK = InitFiles(input);
184
185 if (!treeOK) {
186 LOG(error) << " -- Error reading input files: n=" << input.size();
187 if (input.size() > 0) LOG(error) << " first file: " << input[0];
188 return;
189 }
190
191 TFile* outfile = TFile::Open(output.c_str(), "RECREATE");
192 if (!outfile) {
193 LOG(error) << " -- Error creating outputfile: " << output;
194 return;
195 }
196 outfile->cd();
197 fouttree = new TTree(
198 "MuonDIS", "Muon information, DIS products and soft interaction tracks");
199 foutEv.InitTree(fouttree);
200
201 initPythia6();
202
203 Long64_t n = ftree->GetEntries();
204 LOG(info) << " * input tree with " << n << " entries" << std::endl;
205
206 ProcessMuons();
207
208 outfile->cd();
209 fouttree->Write();
210 outfile->Close();
211
212 fGeoProcessor.PrintVolumes();
213}

◆ ProcessMuons()

void MuDISProcessor::ProcessMuons ( )

Definition at line 398 of file MuDISProcessor.cxx.

398 {
399 LOG(info) << " * Start of event loop" << std::endl;
400 fGeoProcessor.ResetDiagnostics();
401
402 if (static_cast<Long64_t>(fstartEvt) >= ftree->GetEntries()) {
403 LOG(error) << " ** Trying to start from event " << fstartEvt
404 << " which is greater than the tree entries: "
405 << ftree->GetEntries() << ". Doing nothing...";
406 return;
407 }
408
409 const Long64_t nEntries =
410 fnEvts >= 0 ? std::min(static_cast<Long64_t>(fstartEvt + fnEvts),
411 ftree->GetEntries())
412 : ftree->GetEntries();
413 LOG(info) << " - Processing event " << fstartEvt << " to event "
414 << nEntries - 1 << std::endl;
415
416 unsigned nplus = 0;
417 unsigned nminus = 0;
418 unsigned skipMu_pmin = 0;
419 unsigned skipMu_acc = 0;
420 unsigned skipEvt = 0;
421 double wplus = 0.;
422 double wminus = 0.;
423 double skipMu_pminW = 0.;
424 double skipMu_accW = 0.;
425 double skipMu_pathW = 0.;
426
427 struct PathTotals {
428 Long64_t muons = 0;
429 double weight = 0.;
430 double length = 0.;
431 double weightedLength = 0.;
432 void Add(double w, double l) {
433 ++muons;
434 weight += w;
435 length += l;
436 weightedLength += w * l;
437 }
438 };
439 PathTotals pathTotals;
440 std::array<PathTotals, nMats> pathTotalsByMat = {};
441
442 for (Long64_t iEvent = static_cast<Long64_t>(fstartEvt); iEvent < nEntries;
443 ++iEvent) {
444 LOG(debug) << " --- Processing event " << iEvent << std::endl;
445 if (iEvent % 100 == 0)
446 LOG(info) << " --- Processing event " << iEvent << std::endl;
447 if (!finEv.PrepareEntry(ftree, iEvent) || ftree->GetEntry(iEvent) <= 0) {
448 LOG(error) << " --- Error reading tree entry: " << iEvent;
449 skipEvt++;
450 continue;
451 }
452
453 if (finEv.MCTrack == nullptr) {
454 skipEvt++;
455 continue;
456 }
457
458 unsigned nTr = (*finEv.MCTrack).size();
459 if (nTr == 0) {
460 skipEvt++;
461 continue;
462 }
463 // interested in the first muon track - for PG setting
464 //@FIXME AMM adapt also to MuonBack input, take all muons?
465 // for now take MCTrack[0]
466 Int_t muIdx = 0;
467
468 ShipMCTrack& track = (*finEv.MCTrack)[static_cast<unsigned>(muIdx)];
469 int pid = track.GetPdgCode();
470 double muW = track.GetWeight();
471
472 double mup = track.GetP();
473
474 if (mup < fMinPythiaP) {
475 LOG(debug) << iEvent << " skipped: muon momentum " << mup
476 << " below min value for Pythia:" << fMinPythiaP;
477 skipMu_pmin++;
478 skipMu_pminW += muW;
479 continue;
480 }
481
482 std::string targetType;
483 if (pid == -13) {
484 nplus++;
485 wplus += muW;
486 targetType = "gamma/mu+";
487 } else if (pid == 13) {
488 nminus++;
489 wminus += muW;
490 targetType = "gamma/mu-";
491 } else {
492 LOG(warning) << iEvent << " skipped: "
493 << " nTracks= " << nTr
494 << " -- 1st track pid not a muon: " << pid << std::endl;
495 skipEvt++;
496 continue;
497 }
498
499 initEvent();
500 fillMCTracks(muIdx);
501 fillUBTHits(muIdx);
502 fillSBTHits(muIdx);
503 fillSSTHits(muIdx);
504 fillTDHits(muIdx);
505
506 // Count events which have no hit in UBT, SBT, SST or TD, muon just
507 // flying out of vessel acceptance never bouncing back... For those, very
508 // numerous in the cudaMu files, skip to optimise processing.
509 //@FIXME AM to do: a study of whether the events created in the last lambda
510 // of MS could still contribute or would hit UBT...
511 if (foutEv.ubtPt.size() == 0 && foutEv.sbtPt.size() == 0 &&
512 foutEv.sstPt.size() == 0 && foutEv.tdPt.size() == 0) {
513 LOG(debug) << " Counting muon event with no hit " << iEvent
514 << " UBT Hits: " << foutEv.ubtPt.size()
515 << ", SBT Hits: " << foutEv.sbtPt.size()
516 << ", SST Hits: " << foutEv.sstPt.size()
517 << ", TD Hits: " << foutEv.tdPt.size() << std::endl;
518 skipMu_acc++;
519 skipMu_accW += muW;
520 // counting, but want to still fill DIS in MS (and UBT detector)...
521 // continue;
522 }
523
524 LOG(debug) << " -- size of hits collections: " << std::endl
525 << " ---- mcTracks: " << foutEv.mcTrks.size() << std::endl
526 << " ---- UBT Hits: " << foutEv.ubtPt.size() << std::endl
527 << " ---- SBT Hits: " << foutEv.sbtPt.size() << std::endl
528 << " ---- SST Hits: " << foutEv.sstPt.size() << std::endl;
529
530 // retrieve a map of material label, with same density, and lengths, and
531 // [zin,zout] ranges
532 if (!fGeoProcessor.initialise(foutEv)) {
533 skipEvt++;
534 skipMu_pathW += muW;
535 continue;
536 }
537 std::map<std::string, MuonPath>& lPathMap = fGeoProcessor.FillMuonPath();
538
539 if (lPathMap.size() == 0) {
540 LOG(error) << " -- No elements in path... Not doing anything...";
541 skipEvt++;
542 skipMu_pathW += muW;
543 continue;
544 }
545
546 // Persist the intervals used for DIS vertex sampling, including the MS
547 // restriction. Keep REST separately, but exclude it from the total.
548 for (unsigned i = 0; i < nMats; ++i) {
549 const auto path = lPathMap.find(MatTypeStr[i].Data());
550 if (path == lPathMap.end() || path->second.GetNSlices() < 1) continue;
551 // Crossed but not generated (including REST) is distinct from unvisited.
552 foutEv.br[i].nDISevtsGenerated = 0;
553 foutEv.pathLengthByMat[i] =
554 path->second.GetLength() - DISMinLength(path->first, path->second);
555 if (i != REST) foutEv.pathLength += foutEv.pathLengthByMat[i];
556 if (foutEv.pathLengthByMat[i] > 0.)
557 pathTotalsByMat[i].Add(muW, foutEv.pathLengthByMat[i]);
558 }
559
560 // loop over the map, and do nDIS event in each element, with weight
561 // length*density. That way, do only once the calculation of the path, and
562 // plenty of DIS in each material. fill a branch with weight = path
563 // length*density.
564 // Discarding REST: many muons go through CONCRETE,no need to record DIS
565 // there....
566 for (unsigned i(0); i < nMats - 1; ++i) {
567 if (lPathMap.find(MatTypeStr[i].Data()) != lPathMap.end())
568 generateDISevents(targetType, muW, MatTypeStr[i].Data(),
569 lPathMap.find(MatTypeStr[i].Data())->second,
570 foutEv.br[i]);
571 }
572
573 fouttree->Fill();
574 pathTotals.Add(muW, foutEv.pathLength);
575
576 } // loop on events
577
578 LOG(info) << "Found " << nplus << " mu+ and " << nminus << " mu-."
579 << std::endl
580 << "Skipped: " << skipEvt << " events and " << skipMu_pmin
581 << " muons with too low p" << std::endl
582 << "Counted: " << skipMu_acc
583 << " muons with no recorded hits in UBT,SBT,SST,TD.";
584 LOG(info) << "Weighted counts (sum MCTrack[0].fW): " << wplus << " mu+ and "
585 << wminus << " mu- (after momentum cut)." << std::endl
586 << "Skipped (sum MCTrack[0].fW): " << skipMu_pminW
587 << " with too low p, " << skipMu_pathW
588 << " muons with invalid or empty paths." << std::endl
589 << "Counted (sum MCTrack[0].fW): " << skipMu_accW
590 << " muons with no recorded hits in UBT,SBT,SST,TD.";
591 fGeoProcessor.PrintDiagnostics();
592 // Print additive quantities so jobs can be combined before taking means.
593 LOG(info) << std::setprecision(17)
594 << "Muon path totals (cm, excluding REST): output muons = "
595 << pathTotals.muons << ", sum(fW) = " << pathTotals.weight
596 << ", sum(L) = " << pathTotals.length
597 << ", sum(fW*L) = " << pathTotals.weightedLength;
598 for (unsigned i = 0; i < nMats; ++i) {
599 const auto& totals = pathTotalsByMat[i];
600 LOG(info) << std::setprecision(17) << "Muon path totals " << MatTypeStr[i]
601 << " (cm): crossing muons = " << totals.muons
602 << ", sum(fW) = " << totals.weight
603 << ", sum(L) = " << totals.length
604 << ", sum(fW*L) = " << totals.weightedLength;
605 }
606}
void fillMCTracks(const Int_t aIdx)
void fillSSTHits(const Int_t aIdx)
void fillTDHits(const Int_t aIdx)
void fillSBTHits(const Int_t aIdx)
void generateDISevents(const std::string &tType, const double &amuonW, const std::string &aLabel, const MuonPath &aPath, ShipMuDIS::MuonDISBranches &aDISBr)
void fillUBTHits(const Int_t aIdx)
Double_t GetWeight() const
Int_t GetPdgCode() const
Definition ShipMCTrack.h:60
Double_t GetP() const
Definition ShipMCTrack.h:76
const std::array< TString, nMats > MatTypeStr
Definition MuDISDefs.h:45

◆ rotate()

void MuDISProcessor::rotate ( const TVector3 & pvec,
const double & theta,
const double & phi,
TVector3 & newp )

Definition at line 96 of file MuDISProcessor.cxx.

97 {
98 // Rotate the daughter particle momentum to align with respect to the muon's
99 // momentum."""
100
101 TRotation rotation;
102 rotation.RotateY(theta); // Rotate around the Y-axis
103 rotation.RotateZ(phi); // Rotate around the Z-axis
104
105 // Apply the rotation to the momentum vector
106 newp = rotation * pvec;
107}

◆ SetMuonShieldField()

void MuDISProcessor::SetMuonShieldField ( ShipBFieldMap * field,
TGeoManager * geometry )
inline

Definition at line 49 of file MuDISProcessor.h.

49 {
50 fGeoProcessor.SetMuonShieldField(field, geometry);
51 }

◆ SetPocaJumpThreshold()

void MuDISProcessor::SetPocaJumpThreshold ( double threshold)
inline

Definition at line 52 of file MuDISProcessor.h.

52 {
53 fGeoProcessor.SetPocaJumpThreshold(threshold);
54 }

Member Data Documentation

◆ fGeoProcessor

MuGeoProcessor MuDISProcessor::fGeoProcessor
private

Definition at line 79 of file MuDISProcessor.h.

◆ finEv

ShipMuDIS::CBMSimBranches MuDISProcessor::finEv
private

Definition at line 64 of file MuDISProcessor.h.

◆ fLogger

FairLogger* MuDISProcessor::fLogger
private

Definition at line 69 of file MuDISProcessor.h.

◆ fMinPythiaP

double MuDISProcessor::fMinPythiaP
private

Definition at line 75 of file MuDISProcessor.h.

◆ fnDIS

int MuDISProcessor::fnDIS
private

Definition at line 76 of file MuDISProcessor.h.

◆ fnEvts

int MuDISProcessor::fnEvts
private

don't make it persistent, magic ROOT command

Definition at line 70 of file MuDISProcessor.h.

◆ foutEv

ShipMuDIS::MuonBranches MuDISProcessor::foutEv
private

Definition at line 67 of file MuDISProcessor.h.

◆ fouttree

TTree* MuDISProcessor::fouttree
private

Definition at line 66 of file MuDISProcessor.h.

◆ fP6seed

int MuDISProcessor::fP6seed
private

Definition at line 77 of file MuDISProcessor.h.

◆ fPythia

TPythia6* MuDISProcessor::fPythia
private

Definition at line 73 of file MuDISProcessor.h.

◆ fstartEvt

int MuDISProcessor::fstartEvt
private

Definition at line 71 of file MuDISProcessor.h.

◆ ftree

TChain* MuDISProcessor::ftree
private

Definition at line 63 of file MuDISProcessor.h.


The documentation for this class was generated from the following files: