FairRoot/PandaRoot
PndSttFullTCAProducer.cxx
Go to the documentation of this file.
1 //
3 // PndSttHitProducerIdeal
4 //
5 // Class to sum up 2 TCA of STTHits
6 // Usually used to put together the stt parallel and skewed
7 // hits in one full TCA
8 //
9 // authors: Lia Lavezzi - University of Torino (2015)
10 //
12 
13 #include "PndSttFullTCAProducer.h"
14 
15 #include "PndSttHit.h"
16 
17 #include "FairRootManager.h"
18 #include "FairRunAna.h"
19 #include "FairRuntimeDb.h"
20 
21 #include "TClonesArray.h"
22 
23 #include <iostream>
24 #include <cmath>
25 
26 using std::cout;
27 using std::endl;
28 using std::sqrt;
29 
30 // ----- Default constructor -------------------------------------------
32  FairTask("Full STT Hit TCA Producer",0)
33 {
34 
35  fSttHitArray1 = NULL;
36  fSttHitArray2 = NULL;
37  fSttHitArray0 = NULL;
38  fBranchName1 = "STTParalHit";
39  fBranchName2 = "STTSkewHit";
40 }
41 // -------------------------------------------------------------------------
42 
43 
44 
45 // ----- Destructor ----------------------------------------------------
47 {
48 }
49 // -------------------------------------------------------------------------
50 
51 
52 
53 // ----- Public method Init --------------------------------------------
55 {
56  // Get RootManager
57  FairRootManager* ioman = FairRootManager::Instance();
58 
59  if ( ! ioman )
60  {
61  cout << "-E- PndSttFullTCAProducer::Init: "
62  << "RootManager not instantiated!" << endl;
63  return kFATAL;
64  }
65 
66  // Get input array
67  fSttHitArray1 = (TClonesArray*) ioman->GetObject(fBranchName1);
68  if ( ! fSttHitArray1)
69  {
70  cout << "-W- PndSttFullTCAProducer::Init: "
71  << "No " << fBranchName1 << " array!" << endl;
72  return kERROR;
73  }
74 
75  fSttHitArray2 = (TClonesArray*) ioman->GetObject(fBranchName2);
76  if ( ! fSttHitArray2)
77  {
78  cout << "-W- PndSttFullTCAProducer::Init: "
79  << "No " << fBranchName2 << " array!" << endl;
80  return kERROR;
81  }
82 
83  // Create and register output array
84  fSttHitArray0 = new TClonesArray("PndSttHit");
85  ioman->Register("STTHit", "STT", fSttHitArray0, kTRUE);
86 
87  cout << "-I- PndSttFullTCAProducer: Intialisation successfull" << endl;
88  return kSUCCESS;
89 }
90 // -------------------------------------------------------------------------
91 
92 // ----- Public method Exec --------------------------------------------
94 {
95  fSttHitArray0->Delete();
96 
97  PndSttHit* hit = NULL;
98  for(int ihit = 0; ihit < fSttHitArray1->GetEntriesFast(); ihit++) {
99  hit = (PndSttHit*) fSttHitArray1->At(ihit);
100 
101  int size = fSttHitArray0->GetEntriesFast();
102  new ((*fSttHitArray0)[size]) PndSttHit(*hit);
103  }
104 
105  for(int ihit = 0; ihit < fSttHitArray2->GetEntriesFast(); ihit++) {
106  hit = (PndSttHit*) fSttHitArray2->At(ihit);
107 
108  int size = fSttHitArray0->GetEntriesFast();
109  new ((*fSttHitArray0)[size]) PndSttHit(*hit);
110  }
111 }
112 
113 
114 
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
virtual void Exec(Option_t *opt)
virtual InitStatus Init()
int hit(Int_t nEvents=0, TString inFile="sim.root", TString parFile="par.root", TString inDigi="digi.root", TString outFile="hit.root", Int_t timeBased=0)
Definition: hit.C:1
ClassImp(PndAnaContFact)