36 std::cout<<
"============================================================================"<<std::endl;
37 std::cout <<
"ZdcTestAnalysis:: Initialized as observer"<< std::endl;
39 std::cout <<
" Step Ntuple will be created"<< std::endl;
40 std::cout <<
" Step Ntuple file: "<<stepNtFileName<<std::endl;
42 if (doNTzdcevent > 0){
43 std::cout <<
" Event Ntuple will be created"<< std::endl;
44 std::cout <<
" Step Ntuple file: "<<stepNtFileName<<std::endl;
46 std::cout<<
"============================================================================"<<std::endl;
51 new TNtuple(
"NTzdcstep",
"NTzdcstep",
52 "evt:trackid:charge:pdgcode:x:y:z:stepl:stepe:eta:phi:vpx:vpy:vpz:idx:idl:pvtype:ncherphot");
56 new TNtuple(
"NTzdcevent",
"NTzdcevent",
57 "evt:ihit:fiberid:zside:subdet:layer:fiber:channel:enem:enhad:hitenergy:x:y:z:time:etot");
71 std::cout<<
"beggining of job"<<std::endl;;
78 std::cout << std::endl <<
"ZdcTestAnalysis: Begining of Run"<< std::endl;
80 std::cout <<
"ZDCTestAnalysis: output step file created"<< std::endl;
87 std::cout <<
"ZDCTestAnalysis: output event file created"<< std::endl;
107 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
109 G4double stepL = aStep->GetStepLength();
110 G4double stepE = aStep->GetTotalEnergyDeposit();
113 std::cout <<
"Step " << stepL <<
"," << stepE <<std::endl;
115 G4Track * theTrack = aStep->GetTrack();
116 G4int theTrackID = theTrack->GetTrackID();
117 G4double
theCharge = theTrack->GetDynamicParticle()->GetCharge();
118 G4String
particleType = theTrack->GetDefinition()->GetParticleName();
119 G4int pdgcode = theTrack->GetDefinition()->GetPDGEncoding();
121 G4ThreeVector vert_mom = theTrack->GetVertexMomentumDirection();
122 G4double vpx = vert_mom.x();
123 G4double vpy = vert_mom.y();
124 G4double vpz = vert_mom.z();
125 double eta = 0.5 *
log( (1.+vpz) / (1.-vpz) );
126 double phi = atan2(vpy,vpx);
128 G4ThreeVector hitPoint = preStepPoint->GetPosition();
129 G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->
130 GetTopTransform().TransformPoint(hitPoint);
132 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
133 int idx = touch->GetReplicaNumber(0);
137 int historyDepth = touch->GetHistoryDepth();
139 if (historyDepth > 0) {
140 std::vector<int> theReplicaNumbers(historyDepth);
141 std::vector<G4VPhysicalVolume*> thePhysicalVolumes(historyDepth);
142 std::vector<G4String> thePVnames(historyDepth);
143 std::vector<G4LogicalVolume*> theLogicalVolumes(historyDepth);
144 std::vector<G4String> theLVnames(historyDepth);
145 std::vector<G4Material*> theMaterials(historyDepth);
146 std::vector<G4String> theMaterialNames(historyDepth);
148 for (
int jj = 0;
jj < historyDepth;
jj++) {
149 theReplicaNumbers[
jj] = touch->GetReplicaNumber(
jj);
150 thePhysicalVolumes[
jj] = touch->GetVolume(
jj);
151 thePVnames[
jj] = thePhysicalVolumes[
jj]->GetName();
152 theLogicalVolumes[
jj] = thePhysicalVolumes[
jj]->GetLogicalVolume();
153 theLVnames[
jj] = theLogicalVolumes[
jj]->GetName();
154 theMaterials[
jj] = theLogicalVolumes[
jj]->GetMaterial();
155 theMaterialNames[
jj] = theMaterials[
jj]->GetName();
157 std::cout <<
" GHD " <<
jj <<
": " << theReplicaNumbers[
jj] <<
"," 158 << thePVnames[
jj] <<
"," << theLVnames[
jj] <<
"," 159 << theMaterialNames[
jj] << std::endl;
162 idLayer = theReplicaNumbers[1];
163 if (thePVnames[0] ==
"ZDC_EMLayer")
165 else if (thePVnames[0] ==
"ZDC_EMAbsorber")
167 else if (thePVnames[0] ==
"ZDC_EMFiber")
169 else if (thePVnames[0] ==
"ZDC_HadLayer")
171 else if (thePVnames[0] ==
"ZDC_HadAbsorber")
173 else if (thePVnames[0] ==
"ZDC_HadFiber")
175 else if (thePVnames[0] ==
"ZDC_PhobosLayer")
177 else if (thePVnames[0] ==
"ZDC_PhobosAbsorber")
179 else if (thePVnames[0] ==
"ZDC_PhobosFiber")
184 std::cout <<
" pvtype=0 hd=" << historyDepth <<
" " << theReplicaNumbers[0] <<
"," 185 << thePVnames[0] <<
"," << theLVnames[0] <<
"," << theMaterialNames[0] << std::endl;
188 else if (historyDepth == 0) {
189 int theReplicaNumber = touch->GetReplicaNumber(0);
190 G4VPhysicalVolume* thePhysicalVolume = touch->GetVolume(0);
191 G4String thePVname = thePhysicalVolume->GetName();
192 G4LogicalVolume * theLogicalVolume = thePhysicalVolume->GetLogicalVolume();
193 G4String theLVname = theLogicalVolume->GetName();
194 G4Material * theMaterial = theLogicalVolume->GetMaterial();
195 G4String theMaterialName = theMaterial->GetName();
197 std::cout <<
" hd=0 " << theReplicaNumber <<
"," 198 << thePVname <<
"," << theLVname <<
"," 199 << theMaterialName << std::endl;
202 std::cout <<
" hd<0: hd=" << historyDepth << std::endl;
206 double NCherPhot = -1;
234 std::cout << std::endl <<
"ZdcTest::upDate(const EndOfEvent * evt) - event #" << (*evt)()->GetEventID()
235 << std::endl <<
" # of aSteps followed in event = " <<
stepIndex << std::endl;
238 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
241 int theZDCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(
"ZDCHITS");
242 std::cout <<
" - theZDCHCid = " << theZDCHCid;
245 std::cout <<
" - theZDCHC = " << theZDCHC << std::endl;
249 float ETot=0., SEnergy=0.;
252 unsigned int unsignedfiberID=0;
253 std::map<int,float,std::less<int> > energyInFibers;
254 std::map<int,float,std::less<int> > primaries;
255 float totalEnergy = 0;
256 int nentries = theZDCHC->entries();
257 std::cout <<
" theZDCHC has " << nentries <<
" entries" << std::endl;
261 for (
int ihit = 0; ihit < nentries; ihit++) {
266 for (
int ihit = 0; ihit < nentries; ihit++) {
270 double enEm = aHit->
getEM();
271 double enHad = aHit->
getHadr();
275 std::cout <<
" entry #" << ihit <<
": fiberID=0x" << std::hex
276 << fiberID <<
std::dec <<
"; enEm=" << enEm
277 <<
"; enHad=" << enHad <<
"; hitEnergy=" << hitEnergy
278 <<
"z=" << hitPoint.z() << std::endl;
279 energyInFibers[fiberID]+= enEm + enHad;
282 if (time > maxTime) maxTime=(
int)time;
284 int thesubdet, thelayer, thefiber, thechannel, thez;
286 int unsignedsubdet, unsignedlayer, unsignedfiber, unsignedchannel, unsignedz;
288 unsignedlayer, unsignedfiber, unsignedchannel, unsignedz);
314 for (
std::map<
int,
float,std::less<int> >::iterator is = energyInFibers.begin();
315 is!= energyInFibers.end(); is++)
323 G4PrimaryParticle* thePrim=0;
324 G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
325 std::cout <<
"Event has " << nvertex <<
" vertex" << std::endl;
327 std::cout <<
"ZdcTest End Of Event ERROR: no vertex" << std::endl;
329 for (
int i = 0 ;
i<nvertex;
i++) {
331 G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(
i);
333 std::cout <<
"ZdcTest End Of Event ERR: pointer to vertex = 0" 336 std::cout <<
"Vertex number :" <<
i << std::endl;
337 int npart = avertex->GetNumberOfParticle();
339 std::cout <<
"ZdcTest End Of Event ERR: no primary!" << std::endl;
340 if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
344 double px=0.,py=0.,pz=0.;
348 px = thePrim->GetPx();
349 py = thePrim->GetPy();
350 pz = thePrim->GetPz();
353 std::cout <<
"ZdcTest End Of Event ERR: primary has p=0 " << std::endl;
356 std::cout <<
"ZdcTest End Of Event ERR: could not find primary " 365 int iEvt = (*evt)()->GetEventID();
367 std::cout <<
" ZdcTest Event " << iEvt << std::endl;
368 else if ((iEvt < 100) && (iEvt%10 == 0))
369 std::cout <<
" ZdcTest Event " << iEvt << std::endl;
370 else if ((iEvt < 1000) && (iEvt%100 == 0))
371 std::cout <<
" ZdcTest Event " << iEvt << std::endl;
372 else if ((iEvt < 10000) && (iEvt%1000 == 0))
373 std::cout <<
" ZdcTest Event " << iEvt << std::endl;
384 std::cout <<
"ZdcTestAnalysis: Step file closed" << std::endl;
393 std::cout <<
"ZdcTestAnalysis: Event file closed" << std::endl;
T getParameter(std::string const &) const
math::XYZPoint getPosition() const
Float_t zdceventarray[16]
TFile * zdcOutputEventFile
virtual ~ZdcTestAnalysis()
std::string stepNtFileName
TFile * zdcOutputStepFile
void update(const BeginOfJob *run)
This routine will be called when the appropriate signal arrives.
ZdcNumberingScheme * theZdcNumScheme
ZdcTestAnalysis(const edm::ParameterSet &p)
XYZPointD XYZPoint
point in space with cartesian internal representation
static void unpackZdcIndex(const unsigned int &idx, int &subDet, int &layer, int &fiber, int &channel, int &z)
int getTimeSliceID() const
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
std::string eventNtFileName
uint32_t getUnitID() const
Power< A, B >::type pow(const A &a, const B &b)
double getEnergyDeposit() const