48 string fileName = string(gSystem->Getenv(
"VMCWORKDIR"));
49 vector<string> weightsFilesANN;
52 cout <<
"-E- CbmTrdSetTracksPidANN::Init: " <<
fTRDGeometryType <<
" is wrong geometry type." << endl;
55 fileName +=
"/parameters/trd/elid/ann/" + string(
fTRDGeometryType.Data()) +
"/";
57 for (
int i = 0; i < 10; i++) {
59 ss << fileName <<
"ann_weights_" << (i + 1) <<
".txt";
60 weightsFilesANN.push_back(ss.str());
68 for (UInt_t i = 0; i < weightsFilesANN.size(); i++) {
69 ifstream myfile(weightsFilesANN[i].c_str());
70 if (!myfile.is_open()) {
71 cout <<
"-E- CbmTrdSetTracksPidANN::Init: "
72 <<
"Could not open input file:" << weightsFilesANN[i] << endl;
73 weightsFilesANN[i] =
"";
83 TTree* simu =
new TTree(
"MonteCarlo",
"MontecarloData");
84 simu->Branch(
"x1", &inVector[0],
"x1/F");
85 simu->Branch(
"x2", &inVector[1],
"x2/F");
86 simu->Branch(
"x3", &inVector[2],
"x3/F");
87 simu->Branch(
"x4", &inVector[3],
"x4/F");
88 simu->Branch(
"x5", &inVector[4],
"x5/F");
89 simu->Branch(
"x6", &inVector[5],
"x6/F");
90 simu->Branch(
"x7", &inVector[6],
"x7/F");
91 simu->Branch(
"x8", &inVector[7],
"x8/F");
92 simu->Branch(
"x9", &inVector[8],
"x9/F");
93 simu->Branch(
"x10", &inVector[9],
"x10/F");
94 simu->Branch(
"xOut", &xOut,
"xOut/I");
98 for (
int iH = 0; iH < 10; iH++) {
99 if (weightsFilesANN[iH] ==
"") {
104 for (
int iL = 0; iL <= iH; iL++) {
105 if (iL != iH) ss <<
"x" << (iL + 1) <<
",";
106 int nofHidden = 2 * (iH + 1);
107 if (iL == iH) ss <<
"x" << (iL + 1) <<
":" << nofHidden <<
":xOut";
109 TMultiLayerPerceptron* ann =
new TMultiLayerPerceptron(ss.str().c_str(), simu);
110 ann->LoadWeights(weightsFilesANN[iH].c_str());
120 LOG(fatal) << GetName() <<
"::Init: ReadData failed";
123 FairRootManager* ioman = FairRootManager::Instance();
125 LOG(fatal) << GetName() <<
"::Init: RootManager not instantised";
128 fTrackArray = (TClonesArray*) ioman->GetObject(
"TrdTrack");
130 LOG(fatal) << GetName() <<
"::Init: No TrdTrack array";
133 fTrdHitArray = (TClonesArray*) ioman->GetObject(
"TrdHit");
135 LOG(fatal) << GetName() <<
"::Init: No TrdHit array";
144 std::vector<Double_t> eLossVector;
146 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
150 for (Int_t iTRD = 0; iTRD < nofHits; iTRD++) {
153 eLossVector.push_back(trdHit->
GetELoss());
157 for (UInt_t j = 0; j < eLossVector.size(); j++) {
158 eLossVector[j] = eLossVector[j] * 1.e6;
161 sort(eLossVector.begin(), eLossVector.end());
162 for (UInt_t j = 0; j < eLossVector.size(); j++) {
163 eLossVector[j] = TMath::LandauI(eLossVector[j]);
167 Int_t iANN = nofHits - 1;
169 if (iANN < 0 || iANN >= 12 ||
fNN[iANN] == NULL) {
173 nnEval =
fNN[iANN]->Evaluate(0, &eLossVector[0]);
174 if (TMath::IsNaN(nnEval) == 1) {
175 cout <<
" -W- CbmTrdSetTracksPidANN: nnEval nan " << endl;