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5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /readout/src/G4DigiManager.cc (Version 11.3.0) and /readout/src/G4DigiManager.cc (Version 4.1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 //                                                 23 //
                                                   >>  24 // $Id: G4DigiManager.cc,v 1.6 2001/10/18 20:28:19 asaim Exp $
                                                   >>  25 // GEANT4 tag $Name: geant4-04-01 $
 27 //                                                 26 //
 28                                                    27 
 29 #include "G4DigiManager.hh"                        28 #include "G4DigiManager.hh"
 30 #include "G4Event.hh"                              29 #include "G4Event.hh"
 31 #include "G4VHitsCollection.hh"                    30 #include "G4VHitsCollection.hh"
 32 #include "G4VDigiCollection.hh"                    31 #include "G4VDigiCollection.hh"
 33 #include "G4DMmessenger.hh"                        32 #include "G4DMmessenger.hh"
 34 #include "G4DCofThisEvent.hh"                      33 #include "G4DCofThisEvent.hh"
 35 #include "G4RunManager.hh"                         34 #include "G4RunManager.hh"
 36 #include "G4SDManager.hh"                          35 #include "G4SDManager.hh"
 37 #include "G4ios.hh"                                36 #include "G4ios.hh"
 38                                                    37 
 39                                                    38 
 40 G4ThreadLocal G4DigiManager* G4DigiManager::fD <<  39 G4DigiManager* G4DigiManager::fDManager = 0;
 41                                                    40 
 42 G4DigiManager* G4DigiManager::GetDMpointer()       41 G4DigiManager* G4DigiManager::GetDMpointer()
 43 {                                                  42 {
 44   if(!fDManager)                                   43   if(!fDManager)
 45   {                                                44   {
 46     fDManager = new G4DigiManager;                 45     fDManager = new G4DigiManager;
 47   }                                                46   }
 48   return fDManager;                                47   return fDManager;
 49 }                                                  48 }
 50                                                    49 
 51 G4DigiManager* G4DigiManager::GetDMpointerIfEx     50 G4DigiManager* G4DigiManager::GetDMpointerIfExist()
 52 { return fDManager; }                              51 { return fDManager; }
 53                                                    52 
 54 G4DigiManager::G4DigiManager():verboseLevel(0)     53 G4DigiManager::G4DigiManager():verboseLevel(0)
 55 {                                                  54 { 
 56   theMessenger = new G4DMmessenger(this);          55   theMessenger = new G4DMmessenger(this); 
 57   runManager = G4RunManager::GetRunManager();      56   runManager = G4RunManager::GetRunManager();
 58   SDManager = G4SDManager::GetSDMpointer();        57   SDManager = G4SDManager::GetSDMpointer();
 59   DCtable = new G4DCtable;                         58   DCtable = new G4DCtable;
 60 }                                                  59 }
 61                                                    60 
 62 G4DigiManager::~G4DigiManager()                    61 G4DigiManager::~G4DigiManager()
 63 {                                                  62 {
 64   //DMtable.clearAndDestroy();                     63   //DMtable.clearAndDestroy();
 65   for(G4int i=0;i<G4int(DMtable.size());++i)   <<  64   for(G4int i=0;i<int(DMtable.size());i++)
 66   { delete DMtable[i]; }                           65   { delete DMtable[i]; }
 67   DMtable.clear();                                 66   DMtable.clear();
 68   delete DCtable;                                  67   delete DCtable;
 69   delete theMessenger;                             68   delete theMessenger;
 70 }                                                  69 }
 71                                                    70 
 72 void G4DigiManager::AddNewModule(G4VDigitizerM     71 void G4DigiManager::AddNewModule(G4VDigitizerModule* DM)
 73 {                                                  72 {
 74   G4String DMname = DM->GetName();                 73   G4String DMname = DM->GetName();
 75   for(G4int j=0;j<G4int(DMtable.size());++j)   <<  74   for(int j=0;j<int(DMtable.size());j++)
 76   {                                                75   {
 77     if(DMtable[j]==DM)                             76     if(DMtable[j]==DM)
 78     {                                              77     { 
 79       G4cout << "<" << DMname << "> has alread <<  78       G4cout << "<" << DMname << "> has already been registored." << G4endl; 
 80       return;                                      79       return;
 81     }                                              80     }
 82   }                                                81   }
 83   if( verboseLevel > 0 )                           82   if( verboseLevel > 0 )
 84   {                                                83   {
 85     G4cout << "New DigitizerModule <" << DMnam     84     G4cout << "New DigitizerModule <" << DMname
 86          << "> is registered." << G4endl;      <<  85          << "> is registored." << G4endl;
 87   }                                                86   }
 88   DMtable.push_back(DM);                           87   DMtable.push_back(DM);
 89                                                    88 
 90   G4int numberOfCollections = DM->GetNumberOfC     89   G4int numberOfCollections = DM->GetNumberOfCollections();
 91   for(G4int i=0;i<numberOfCollections;++i)     <<  90   for(int i=0;i<numberOfCollections;i++)
 92   {                                                91   {
 93     G4String DCname = DM->GetCollectionName(i)     92     G4String DCname = DM->GetCollectionName(i);
 94     if( DCtable->Registor(DMname,DCname) < 0 )     93     if( DCtable->Registor(DMname,DCname) < 0 )
 95     {                                              94     { 
 96       G4cout << "DigiCollection <" << DCname       95       G4cout << "DigiCollection <" << DCname 
 97            << "> has already been registered w <<  96            << "> has already been registored with "
 98            << DMname << " DigitizerModule." <<     97            << DMname << " DigitizerModule." << G4endl;
 99     }                                              98     }
100     else if( verboseLevel > 0 )                    99     else if( verboseLevel > 0 )
101     {                                             100     {
102       G4cout << "DigiCollection " << DCname       101       G4cout << "DigiCollection " << DCname 
103            << " is registered. " << G4endl;    << 102            << " is registored. " << G4endl;
104     }                                             103     }
105   }                                               104   }
106                                                   105   
107   runManager->SetDCtable(DCtable);                106   runManager->SetDCtable(DCtable);
108 }                                                 107 }
109                                                   108 
110 void G4DigiManager::Digitize(const G4String& m << 109 void G4DigiManager::Digitize(G4String mName)
111 {                                                 110 {
112   G4VDigitizerModule* aDM = FindDigitizerModul    111   G4VDigitizerModule* aDM = FindDigitizerModule(mName);
113   if(aDM)                                         112   if(aDM)
114   { aDM->Digitize(); }                            113   { aDM->Digitize(); }
115   else                                            114   else
116   { G4cout << "Unknown digitizer module <" <<     115   { G4cout << "Unknown digitizer module <" << mName << ">. Digitize() ignored." << G4endl; }
117 }                                                 116 }
118                                                   117 
119 G4VDigitizerModule* G4DigiManager::FindDigitiz << 118 G4VDigitizerModule* G4DigiManager::FindDigitizerModule(G4String mName)
120 {                                                 119 {
121   for(G4int i=0;i<G4int(DMtable.size());++i)   << 120   for(G4int i=0;i<int(DMtable.size());i++)
122   {                                               121   {
123     if(DMtable[i]->GetName() == mName) return     122     if(DMtable[i]->GetName() == mName) return DMtable[i];
124   }                                               123   }
125   return NULL;                                    124   return NULL;
126 }                                                 125 }
127                                                   126 
128 const G4VHitsCollection* G4DigiManager::GetHit    127 const G4VHitsCollection* G4DigiManager::GetHitsCollection(G4int HCID,G4int eventID)
129 {                                                 128 {
130   const G4Event* evt = NULL;                      129   const G4Event* evt = NULL;
131   if(eventID==0)                                  130   if(eventID==0)
132   { evt = runManager->GetCurrentEvent(); }        131   { evt = runManager->GetCurrentEvent(); }
133   else                                            132   else
134   { evt = runManager->GetPreviousEvent(eventID    133   { evt = runManager->GetPreviousEvent(eventID); }
135   if(evt==NULL) return NULL;                      134   if(evt==NULL) return NULL;
136                                                   135   
137   G4HCofThisEvent* HCE = evt->GetHCofThisEvent    136   G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
138   if(HCE==NULL) return NULL;                      137   if(HCE==NULL) return NULL;
139                                                   138 
140   return HCE->GetHC(HCID);                        139   return HCE->GetHC(HCID);
141 }                                                 140 }
142                                                   141 
143 const G4VDigiCollection* G4DigiManager::GetDig    142 const G4VDigiCollection* G4DigiManager::GetDigiCollection(G4int DCID,G4int eventID)
144 {                                                 143 {
145   const G4Event* evt = NULL;                      144   const G4Event* evt = NULL;
146   if(eventID==0)                                  145   if(eventID==0)
147   { evt = runManager->GetCurrentEvent(); }        146   { evt = runManager->GetCurrentEvent(); }
148   else                                            147   else
149   { evt = runManager->GetPreviousEvent(eventID    148   { evt = runManager->GetPreviousEvent(eventID); }
150   if(evt==NULL) return NULL;                      149   if(evt==NULL) return NULL;
151                                                   150   
152   G4DCofThisEvent* DCE = evt->GetDCofThisEvent    151   G4DCofThisEvent* DCE = evt->GetDCofThisEvent();
153   if(DCE==NULL) return NULL;                      152   if(DCE==NULL) return NULL;
154                                                   153 
155   return DCE->GetDC(DCID);                        154   return DCE->GetDC(DCID);
156 }                                                 155 }
157                                                   156 
158 G4int G4DigiManager::GetHitsCollectionID(const << 157 G4int G4DigiManager::GetHitsCollectionID(G4String HCname)
159 {                                                 158 {
160   return SDManager->GetCollectionID(HCname);      159   return SDManager->GetCollectionID(HCname);
161 }                                                 160 }
162                                                   161 
163 G4int G4DigiManager::GetDigiCollectionID(const << 162 G4int G4DigiManager::GetDigiCollectionID(G4String DCname)
164 {                                                 163 {
165   G4int i = DCtable->GetCollectionID(DCname);     164   G4int i = DCtable->GetCollectionID(DCname);
166   if(i==-2)                                       165   if(i==-2)
167   { G4cout << "< " << DCname << "> is ambegiou    166   { G4cout << "< " << DCname << "> is ambegious." << G4endl; }
168   return i;                                       167   return i;
169 }                                                 168 }
170                                                   169 
171 void G4DigiManager::SetDigiCollection(G4int DC    170 void G4DigiManager::SetDigiCollection(G4int DCID,G4VDigiCollection* aDC)
172 {                                                 171 {
173   const G4Event* consEvt = runManager->GetCurr    172   const G4Event* consEvt = runManager->GetCurrentEvent();
174   if(consEvt==NULL)                               173   if(consEvt==NULL) 
175   {                                               174   {
176     G4cout << "G4DigiManager::SetDigiCollectio    175     G4cout << "G4DigiManager::SetDigiCollection --- "
177          << "Event object is not available." <    176          << "Event object is not available." << G4endl;
178     return;                                       177     return;
179   }                                               178   }
180                                                   179   
181   G4Event* evt = (G4Event*)consEvt;               180   G4Event* evt = (G4Event*)consEvt;
182   G4DCofThisEvent* DCE = evt->GetDCofThisEvent    181   G4DCofThisEvent* DCE = evt->GetDCofThisEvent();
183   if(DCE==NULL)                                   182   if(DCE==NULL)
184   {                                               183   {
185     DCE = new G4DCofThisEvent(DCtable->entries    184     DCE = new G4DCofThisEvent(DCtable->entries());
186     evt->SetDCofThisEvent(DCE);                   185     evt->SetDCofThisEvent(DCE);
187     if(verboseLevel>0)                            186     if(verboseLevel>0)
188     { G4cout << "DCofThisEvent object is added    187     { G4cout << "DCofThisEvent object is added to current G4Event." << G4endl; }
189   }                                               188   }
190                                                   189 
191   DCE->AddDigiCollection(DCID,aDC);               190   DCE->AddDigiCollection(DCID,aDC);
192                                                   191 
193   if(verboseLevel>0)                              192   if(verboseLevel>0)
194   {                                               193   {
195     G4cout << aDC->GetName() << " is stored at    194     G4cout << aDC->GetName() << " is stored at " << DCID 
196          << "-th slot of G4DCofThisEvent." <<     195          << "-th slot of G4DCofThisEvent." << G4endl;
197   }                                               196   }
198 }                                                 197 }
199                                                   198   
200 void G4DigiManager::SetVerboseLevel(G4int val)    199 void G4DigiManager::SetVerboseLevel(G4int val)
201 {                                                 200 {
202   verboseLevel = val;                             201   verboseLevel = val;
203   for(G4int i=0;i<G4int(DMtable.size());++i)   << 202   for(G4int i=0;i<int(DMtable.size());i++)
204   { DMtable[i]->SetVerboseLevel(val); }           203   { DMtable[i]->SetVerboseLevel(val); }
205 }                                                 204 }
206                                                   205 
207 void G4DigiManager::List() const                  206 void G4DigiManager::List() const
208 {                                                 207 {
209   for(G4int i=0;i<G4int(DMtable.size());++i)   << 208   for(G4int i=0;i<int(DMtable.size());i++)
210   { G4cout << "   " << i << " : " << DMtable[i    209   { G4cout << "   " << i << " : " << DMtable[i]->GetName() << G4endl; }
211 }                                                 210 }
212                                                   211 
213                                                   212 
214                                                   213 
215                                                   214