FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairTutorialDet2CustomTask.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  ********************************************************************************/
9 
10 #include "FairLogger.h"
11 #include "FairRootManager.h"
12 #include "FairTutorialDet2Point.h"
13 
14 // we include some unit testing here
15 #ifdef NDEBUG
16 #undef NDEBUG
17 #endif
18 #include <cassert>
19 
21  : FairTask("TutorialDetCustomTask", 0)
22 {}
23 
24 FairTutorialDet2CustomTask::FairTutorialDet2CustomTask(const char* name, const char* /*title*/)
25  : FairTask(name, 0)
26 {}
27 
29 
31 {
32  LOG(info) << " FairTutorialDet2CustomTask :: Init() ";
33 
35  if (!ioman) {
36  LOG(fatal) << "No FairRootManager";
37  return kERROR;
38  } else {
39  fCustomData = ioman->InitObjectAs<std::vector<CustomClass> const*>("TutorialCustomData");
40  if (!fCustomData) {
41  LOG(error) << "No input data found!";
42  LOG(error) << "Task will be inactive";
43  return kERROR;
44  }
45 
46  // assert that some other queries are null:
47  // querying existing data under wrong type
48  assert(ioman->InitObjectAs<double const*>("TutorialCustomData") == nullptr);
49  // querying non-existing branch
50  assert(ioman->InitObjectAs<double const*>("WrongName") == nullptr);
51  fCustomData2 = ioman->InitObjectAs<std::vector<CustomClass> const*>("InMemory1");
52  assert(fCustomData2);
53  }
54  return kSUCCESS;
55 }
56 
57 void FairTutorialDet2CustomTask::Exec(Option_t* /*option*/)
58 {
59  // Here we print something
60  LOG(info) << " I am in FairTutorialDet2CustomTask::Exec";
61 
62  LOG(info) << " The custom data input vector has size" << fCustomData->size();
63  for (auto& entry : *fCustomData) {
64  LOG(info) << " Got entry " << entry.GetX() << " " << entry.GetQ();
65  }
66 
67  // process data that we got from DigitizerTask
68  LOG(info) << " The input vector from DigitizerTask has size" << fCustomData2->size();
69  for (auto& entry : *fCustomData2) {
70  LOG(info) << " Got entry " << entry.GetX() << " " << entry.GetQ();
71  }
72 }
73 
virtual void Exec(Option_t *option)
InitStatus
Definition: FairTask.h:33
T InitObjectAs(const char *BrName)
static FairRootManager * Instance()
ClassImp(FairEventBuilder)