EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EicDigiHitProducer.cxx
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EicDigiHitProducer.cxx
1 //
2 // AYK (ayk@bnl.gov), 2013/06/13
3 //
4 // EIC digitized hit producer class;
5 //
6 
7 #include <assert.h>
8 #include <iostream>
9 #include <cmath>
10 
11 #include "TGeoManager.h"
12 #include "TClonesArray.h"
13 #include "TVector3.h"
14 #include "TRandom.h"
15 
16 #include "FairRootManager.h"
17 #include "FairRunAna.h"
18 #include "FairRuntimeDb.h"
19 #include "FairGeoNode.h"
20 #include "FairGeoTransform.h"
21 #include "FairGeoRotation.h"
22 #include "FairGeoVector.h"
23 
24 #include <PndGeoHandling.h>
25 
26 #include "EicDigiHitProducer.h"
27 
28 using namespace std;
29 
30 // ---------------------------------------------------------------------------------------
31 
33  mEventCounter(0), mPersistence(kTRUE), mDigiHitArray(0)
34 {
35  ResetVars();
36 
37  mDetName = new EicDetName(name);
38 
39  // Yes, after EicDetName(name); or could it yet be placed in the header section?;
40  FairTask("EIC " + mDetName->NAME() + " Hit Producer");
41 } // EicDigiHitProducer::EicDigiHitProducer()
42 
43 // ---------------------------------------------------------------------------------------
44 
46 {
47  std::cout<<"#########################################################"<<std::endl;
48  std::cout<<mDetName->Name()<<"DigiHitProducer: Init()#######"<<std::endl;
49  std::cout<<"#########################################################"<<std::endl;
50 
51  // Get RootManager;
53  if ( ! ioman ) {
54  cout << "-E- "<<mDetName->Name()<<"DigiHitProducer::Init: "
55  << "RootManager not instantiated!" << endl;
56  return kFATAL;
57  }
58 
59  // Get input Monte-Carlo point array;
60  mMoCaPointArray = (TClonesArray*) ioman->GetObject(mDetName->Name() + "MoCaPoint");
61  if ( ! mMoCaPointArray ) {
62  cout << "-W- "<<mDetName->Name()<<"DigiHitProducer::Init: "
63  << "No "<<mDetName->Name()<<"Point array!" << endl;
64  return kERROR;
65  } //if
66 
67  {
68  ioman->GetInFile()->GetObject(mDetName->Name() + "GeoParData", mGptr);
69 
70  // Well, missing mapping table is a critical failure;
71  if (!mGptr) {
72  std::cout << "-E- Eic"<< mDetName->Name() <<" hit producer: no map found!" << std::endl;
73  return kERROR;
74  } //if
75 
77 
78  // Loop through all the maps and set sensitive flags for those, whose
79  // top-level volume names match the requested ones;
80  for(int iq=0; iq<mGptr->GetMapNum(); iq++) {
81  EicGeoMap *fmap = mGptr->GetMapPtrViaMapID(iq);
82 
83  const std::pair<TString, double> *entry =
85 
86  // Well, I guess this makes sense: make all maps sensitive unless a fraction
87  // of them activated manually; FIXME: handling of Birk's correction constant here
88  // is indeed a crappy coding style;
89  if (entry || mSensitiveVolumes.IsEmpty()) fmap->SetSensitivityFlag(entry ? entry->second : 0.0);
90  } //for iq
91  }
92 
93  // At the very least these routines are supposed to allocate and register 'mDigiHitArray';
94  if (ExtraInit() != kSUCCESS) return kERROR;
95  //if (mDigiHitArray)
96  //ioman->Register(mDetName->Name() + "DigiHit", mDetName->NAME(), mDigiHitArray, mPersistence);
97 
98  cout << "-I- "<<mDetName->Name()<<"DigiHitProducer: INITIALIZATION SUCCESSFUL" << endl;
99 
100  return kSUCCESS;
101 } // EicDigiHitProducer::Init()
102 
103 // ---------------------------------------------------------------------------------------
104 
106 {
107 
109  //fFtsParameters = (PndGeoFtsPar*) rtdb->getContainer("PndGeoFtsPar");
110  //fFtsParameters = (PndGeoFtsPar*) rtdb->getContainer("TrsGeoPar");
111 } // EicDigiHitProducer::SetParContainers()
112 
113 // ---------------------------------------------------------------------------------------
114 
115 void EicDigiHitProducer::Exec(Option_t* opt)
116 {
117  //printf("Here!\n");
118  if ((fVerbose && mEventCounter%50 == 0) || fVerbose >= 3)
119  cout << "Event Number " << mEventCounter << endl;
120 
121  mEventCounter++;
122 
123  // Reset output array (if declared at all);
124  if ( !mDigiHitArray ) return;
125 
126  mDigiHitArray->Clear();
127 
128  // Possible detector-specific event-level initialization;
129  PreExec();
130 
131  // Loop over MC points;
132  Int_t nPoints = mMoCaPointArray->GetEntriesFast();
133  //printf("%d\n", nPoints);
134 
135  for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
137  if (point == NULL) continue;
138 
139  // Save back-door variable;
140  point->SetPointID(iPoint);
141 
142  HandleHit(point);
143  } //for iPoint
144 
145  // Possible detector-specific event-level post-handling;
146  PostExec();
147 
148  // Event summary; THINK: can be misleading for inherited classes?;
149  printf("-I- %sDigiHitProducer (ev#%5d): %6d point(s); %4d hit(s) created\n",
150  mDetName->Name().Data(), mEventCounter, nPoints, mDigiHitArray->GetEntriesFast());
151 } // EicDigiHitProducer::Exec()
152 
153 // ---------------------------------------------------------------------------------------
154