FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairMCMatchSelectorTask.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // -------------------------------------------------------------------------
9 // ----- FairMCMatchSelectorTask source file -----
10 // ----- Created 18/07/08 by T.Stockmanns -----
11 // -------------------------------------------------------------------------
13 
14 #include "FairMCMatch.h" // for FairMCMatch
15 #include "FairMCResult.h" // for operator<<
16 #include "FairMCStage.h" // for FairMCStage
17 #include "FairRootManager.h" // for FairRootManager
18 
19 #include <iostream> // for operator<<, ostream, etc
20 
21 // ----- Default constructor -------------------------------------------
23  : FairTask("Creates FairMCMatch")
24  , fMCMatch(nullptr)
25  , fStart(-1)
26  , fStop(-1)
27  , fStartString("")
28  , fStopString("")
29  , fStageWeights()
30  , fCommonWeight(0)
31 {}
32 // -------------------------------------------------------------------------
33 
35  : FairTask("Creates FairMCMatch")
36  , fMCMatch(nullptr)
37  , fStart(-1)
38  , fStop(-1)
39  , fStartString(start)
40  , fStopString(stop)
41  , fStageWeights()
42  , fCommonWeight(0)
43 {}
44 
46  : FairTask("Creates FairMCMatch")
47  , fMCMatch(nullptr)
48  , fStart(start)
49  , fStop(stop)
50  , fStartString("")
51  , fStopString("")
52  , fStageWeights()
53  , fCommonWeight(0)
54 {}
55 
56 // ----- Destructor ----------------------------------------------------
58 
59 // ----- Public method Init --------------------------------------------
61 {
62 
64  if (!ioman) {
65  std::cout << "-E- FairMCMatchSelectorTask::Init: "
66  << "RootManager not instantiated!" << std::endl;
67  return kFATAL;
68  }
69 
70  fMCMatch = static_cast<FairMCMatch*>(ioman->GetObject("MCMatch"));
71  if (fStart < 0 && fStop < 0) {
72  fStart = ioman->GetBranchId(fStartString);
73  fStop = ioman->GetBranchId(fStopString);
74  std::cout << fStartString << ": " << fStart << " / " << fStopString << ": " << fStop << std::endl;
75  }
76 
77  std::cout << "-I- FairMCMatchSelectorTask::Init: Initialization successfull" << std::endl;
78 
79  return kSUCCESS;
80 }
81 
82 // -------------------------------------------------------------------------
84 
85 // ----- Public method Exec --------------------------------------------
86 void FairMCMatchSelectorTask::Exec(Option_t* /*opt*/)
87 {
88  std::cout << "Output Selector: " << std::endl;
89  SetWeights();
90  fMCMatch->CreateArtificialStage("MCTrack");
91  std::cout << fMCMatch->GetMCInfo(fStart, fStop);
92  std::cout << std::endl;
93 }
94 
96 {
97  fMCMatch->SetCommonWeightStages(fCommonWeight);
98  for (unsigned int i = 0; i < fStageWeights.size(); i++) {
99  fMCMatch->GetMCStageType(fStageWeights[i].first)->SetWeight(fStageWeights[i].second);
100  }
101 }
102 
104 
FairMCResult GetMCInfo(Int_t start, Int_t stop)
void SetWeight(Double_t weight)
Definition: FairMCStage.h:60
InitStatus
Definition: FairTask.h:33
void SetCommonWeightStages(Float_t weight)
Definition: FairMCMatch.cxx:86
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
TObject * GetObject(const char *BrName)
FairMCStage * GetMCStageType(TString branch)
Definition: FairMCMatch.h:84
virtual void Exec(Option_t *opt)
void CreateArtificialStage(const TString &branchName, const std::string &fileName="")
Int_t GetBranchId(TString const &BrName)