00001
00002
00003
00004
00005 #include <iostream>
00006 #include <iomanip>
00007 #include <cmath>
00008 #include<vector>
00009
00010 #include "SimG4Core/Notification/interface/BeginOfEvent.h"
00011 #include "SimG4Core/Notification/interface/EndOfEvent.h"
00012 #include "SimG4Core/Notification/interface/TrackWithHistory.h"
00013 #include "SimG4Core/Notification/interface/TrackInformation.h"
00014
00015 #include "FWCore/Framework/interface/Event.h"
00016 #include "FWCore/Framework/interface/EventSetup.h"
00017 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00018
00019 #include "SimG4CMS/Forward/interface/BscNumberingScheme.h"
00020 #include "SimG4CMS/Forward/interface/BscG4HitCollection.h"
00021 #include "SimG4CMS/Forward/interface/BscTest.h"
00022
00023
00024
00025
00026
00027 #include "G4SDManager.hh"
00028 #include "G4Step.hh"
00029 #include "G4Track.hh"
00030 #include "G4VProcess.hh"
00031 #include "G4HCofThisEvent.hh"
00032 #include "G4UserEventAction.hh"
00033 #include "G4TransportationManager.hh"
00034 #include "G4ProcessManager.hh"
00035
00036
00037 #include "CLHEP/Units/GlobalSystemOfUnits.h"
00038 #include "CLHEP/Units/GlobalPhysicalConstants.h"
00039 #include <stdio.h>
00040
00041
00042
00043
00044
00045
00046
00047
00048 #include <cassert>
00049
00050
00051
00052
00053 enum ntbsc_elements {
00054 ntbsc_evt
00055 };
00056
00057
00058 BscTest::BscTest(const edm::ParameterSet &p){
00059
00060 edm::ParameterSet m_Anal = p.getParameter<edm::ParameterSet>("BscTest");
00061 verbosity = m_Anal.getParameter<int>("Verbosity");
00062
00063
00064 fDataLabel = m_Anal.getParameter<std::string>("FDataLabel");
00065 fOutputFile = m_Anal.getParameter<std::string>("FOutputFile");
00066 fRecreateFile = m_Anal.getParameter<std::string>("FRecreateFile");
00067
00068 if (verbosity > 0) {
00069 std::cout<<"============================================================================"<<std::endl;
00070 std::cout << "BscTestconstructor :: Initialized as observer"<< std::endl;
00071 }
00072
00073
00074 theBscNumberingScheme = new BscNumberingScheme();
00075 bsceventntuple = new TNtuple("NTbscevent","NTbscevent","evt");
00076 whichevent = 0;
00077 TheHistManager = new BscAnalysisHistManager(fDataLabel);
00078
00079 if (verbosity > 0) {
00080 std::cout << "BscTest constructor :: Initialized BscAnalysisHistManager"<< std::endl;
00081 }
00082 }
00083
00084
00085
00086 BscTest::~BscTest() {
00087
00088 delete theBscNumberingScheme;
00089
00090 TFile bscOutputFile("newntbsc.root","RECREATE");
00091 std::cout << "Bsc output root file has been created";
00092 bsceventntuple->Write();
00093 std::cout << ", written";
00094 bscOutputFile.Close();
00095 std::cout << ", closed";
00096 delete bsceventntuple;
00097 std::cout << ", and deleted" << std::endl;
00098
00099
00100
00101
00102 TheHistManager->WriteToFile(fOutputFile,fRecreateFile);
00103 if (verbosity > 0) {
00104 std::cout << std::endl << "BscTest Destructor --------> End of BscTest : "
00105 << std::cout << std::endl;
00106 }
00107
00108 std::cout<<"BscTest: End of process"<<std::endl;
00109
00110
00111
00112 }
00113
00114
00115
00116
00117
00118 BscAnalysisHistManager::BscAnalysisHistManager(TString managername)
00119 {
00120
00121
00122 fTypeTitle=managername;
00123 fHistArray = new TObjArray();
00124 fHistNamesArray = new TObjArray();
00125
00126 BookHistos();
00127
00128 fHistArray->Compress();
00129 fHistNamesArray->Compress();
00130
00131
00132
00133 }
00134
00135
00136 BscAnalysisHistManager::~BscAnalysisHistManager()
00137 {
00138
00139
00140 if(fHistArray){
00141 fHistArray->Delete();
00142 delete fHistArray;
00143 }
00144
00145 if(fHistNamesArray){
00146 fHistNamesArray->Delete();
00147 delete fHistNamesArray;
00148 }
00149 }
00150
00151
00152 void BscAnalysisHistManager::BookHistos()
00153 {
00154
00155 HistInit("TrackPhi", "Primary Phi", 100, 0.,360. );
00156 HistInit("TrackTheta", "Primary Theta", 100, 0.,180. );
00157 HistInit("TrackP", "Track XY position Z+ ", 80, -80., 80., 80, -80., 80. );
00158 HistInit("TrackM", "Track XY position Z-", 80, -80., 80., 80, -80., 80. );
00159 HistInit("DetIDs", "Track DetId - vs +", 16, -0.5, 15.5,16, 15.5, 31.5 );
00160 }
00161
00162
00163
00164 void BscAnalysisHistManager::WriteToFile(TString fOutputFile,TString fRecreateFile)
00165 {
00166
00167
00168
00169 std::cout <<"================================================================"<<std::endl;
00170 std::cout <<" Write this Analysis to File "<<fOutputFile<<std::endl;
00171 std::cout <<"================================================================"<<std::endl;
00172
00173 TFile* file = new TFile(fOutputFile, fRecreateFile);
00174
00175 fHistArray->Write();
00176 file->Close();
00177 }
00178
00179
00180 void BscAnalysisHistManager::HistInit(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup)
00181 {
00182
00183
00184 char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
00185 strcpy(newtitle,title);
00186 strcat(newtitle," (");
00187 strcat(newtitle,fTypeTitle);
00188 strcat(newtitle,") ");
00189 fHistArray->AddLast((new TH1F(name, newtitle, nbinsx, xlow, xup)));
00190 fHistNamesArray->AddLast(new TObjString(name));
00191
00192 }
00193
00194
00195 void BscAnalysisHistManager::HistInit(const char* name, const char* title, Int_t nbinsx, Axis_t xlow, Axis_t xup, Int_t nbinsy, Axis_t ylow, Axis_t yup)
00196 {
00197
00198
00199 char* newtitle = new char[strlen(title)+strlen(fTypeTitle)+5];
00200 strcpy(newtitle,title);
00201 strcat(newtitle," (");
00202 strcat(newtitle,fTypeTitle);
00203 strcat(newtitle,") ");
00204 fHistArray->AddLast((new TH2F(name, newtitle, nbinsx, xlow, xup, nbinsy, ylow, yup)));
00205 fHistNamesArray->AddLast(new TObjString(name));
00206
00207 }
00208
00209
00210 TH1F* BscAnalysisHistManager::GetHisto(Int_t Number)
00211 {
00212
00213
00214 if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)0){
00215
00216 return (TH1F*)(fHistArray->At(Number));
00217
00218 }else{
00219
00220 std::cout << "!!!!!!!!!!!!!!!!!!GetHisto!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
00221 std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
00222 std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
00223
00224 return (TH1F*)(fHistArray->At(0));
00225 }
00226 }
00227
00228
00229 TH2F* BscAnalysisHistManager::GetHisto2(Int_t Number)
00230 {
00231
00232
00233 if (Number <= fHistArray->GetLast() && fHistArray->At(Number) != (TObject*)0){
00234
00235 return (TH2F*)(fHistArray->At(Number));
00236
00237 }else{
00238
00239 std::cout << "!!!!!!!!!!!!!!!!GetHisto2!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
00240 std::cout << " WARNING ERROR - HIST ID INCORRECT (TOO HIGH) - " << Number << std::endl;
00241 std::cout << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
00242
00243 return (TH2F*)(fHistArray->At(0));
00244 }
00245 }
00246
00247
00248 TH1F* BscAnalysisHistManager::GetHisto(const TObjString histname)
00249 {
00250
00251
00252 Int_t index = fHistNamesArray->IndexOf(&histname);
00253 return GetHisto(index);
00254 }
00255
00256
00257 TH2F* BscAnalysisHistManager::GetHisto2(const TObjString histname)
00258 {
00259
00260
00261 Int_t index = fHistNamesArray->IndexOf(&histname);
00262 return GetHisto2(index);
00263 }
00264
00265
00266 void BscAnalysisHistManager::StoreWeights()
00267 {
00268
00269
00270 for(int i = 0; i < fHistArray->GetEntries(); i++){
00271 ((TH1F*)(fHistArray->At(i)))->Sumw2();
00272 }
00273 }
00274
00275
00276
00277 void BscTest::update(const BeginOfJob * job) {
00278
00279 std::cout<<"BscTest:beggining of job"<<std::endl;;
00280 }
00281
00282
00283
00284 void BscTest::update(const BeginOfRun * run) {
00285
00286
00287 std::cout << std::endl << "BscTest:: Begining of Run"<< std::endl;
00288 }
00289
00290
00291 void BscTest::update(const EndOfRun * run) {;}
00292
00293
00294
00295
00296 void BscTest::update(const BeginOfEvent * evt) {
00297 iev = (*evt)()->GetEventID();
00298 if (verbosity > 0) {
00299 std::cout <<"BscTest:update Event number = " << iev << std::endl;
00300 }
00301 whichevent++;
00302 }
00303
00304
00305 void BscTest::update(const BeginOfTrack * trk) {
00306 itrk = (*trk)()->GetTrackID();
00307 if (verbosity > 1) {
00308 std::cout <<"BscTest:update BeginOfTrack number = " << itrk << std::endl;
00309 }
00310 if(itrk == 1) {
00311 SumEnerDeposit = 0.;
00312 numofpart = 0;
00313 SumStepl = 0.;
00314 SumStepc = 0.;
00315 tracklength0 = 0.;
00316 }
00317 }
00318
00319
00320
00321
00322 void BscTest::update(const EndOfTrack * trk) {
00323 itrk = (*trk)()->GetTrackID();
00324 if (verbosity > 1) {
00325 std::cout <<"BscTest:update EndOfTrack number = " << itrk << std::endl;
00326 }
00327 if(itrk == 1) {
00328 G4double tracklength = (*trk)()->GetTrackLength();
00329
00330 TheHistManager->GetHisto("SumEDep")->Fill(SumEnerDeposit);
00331 TheHistManager->GetHisto("TrackL")->Fill(tracklength);
00332
00333
00334 G4ThreeVector vert_mom = (*trk)()->GetVertexMomentumDirection();
00335 G4ThreeVector vert_pos = (*trk)()->GetVertexPosition();
00336
00337
00338 float phi = atan2(vert_mom.y(),vert_mom.x());
00339 if (phi < 0.) phi += twopi;
00340 if(tracklength < z4) {
00341
00342 }
00343
00344
00345 const G4Step* aStep = (*trk)()->GetStep();
00346 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
00347 lastpo = preStepPoint->GetPosition();
00348
00349
00350
00351 }
00352
00353 }
00354
00355
00356
00357
00358 void BscTest::update(const G4Step * aStep) {
00359
00360
00361 if (verbosity > 2) {
00362 G4int stepnumber = aStep->GetTrack()->GetCurrentStepNumber();
00363 std::cout <<"BscTest:update Step number = " << stepnumber << std::endl;
00364 }
00365
00366 G4Track* theTrack = aStep->GetTrack();
00367 TrackInformation* trkInfo = dynamic_cast<TrackInformation*> (theTrack->GetUserInformation());
00368 if (trkInfo == 0) {
00369 std::cout << "BscTest on aStep: No trk info !!!! abort " << std::endl;
00370
00371 }
00372 G4int id = theTrack->GetTrackID();
00373 G4String particleType = theTrack->GetDefinition()->GetParticleName();
00374 G4int parentID = theTrack->GetParentID();
00375 G4TrackStatus trackstatus = theTrack->GetTrackStatus();
00376 G4double tracklength = theTrack->GetTrackLength();
00377 G4ThreeVector trackmom = theTrack->GetMomentum();
00378 G4double entot = theTrack->GetTotalEnergy();
00379 G4int curstepnumber = theTrack->GetCurrentStepNumber();
00380 G4ThreeVector vert_pos = theTrack->GetVertexPosition();
00381 G4ThreeVector vert_mom = theTrack->GetVertexMomentumDirection();
00382 G4double stepl = aStep->GetStepLength();
00383 G4double EnerDeposit = aStep->GetTotalEnergyDeposit();
00384 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
00385 G4ThreeVector preposition = preStepPoint->GetPosition();
00386 G4ThreeVector prelocalpoint = theTrack->GetTouchable()->GetHistory()->
00387 GetTopTransform().TransformPoint(preposition);
00388 G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
00389 G4String prename = currentPV->GetName();
00390
00391 const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
00392 int pre_levels = detLevels(pre_touch);
00393 G4String name1[20]; int copyno1[20];
00394 if (pre_levels > 0) {
00395 detectorLevel(pre_touch, pre_levels, copyno1, name1);
00396 }
00397
00398 if ( id == 1 ) {
00399
00400
00401 if (curstepnumber == 1 ) {
00402 entot0 = entot;
00403
00404
00405 }
00406
00407
00408
00409
00410 if(prename == "SBST" ) {
00411 SumStepc += stepl;
00412
00413 }
00414
00415
00416 if(prename == "SBSTs" ) {
00417 SumStepl += stepl;
00418
00419 }
00420
00421
00422
00423
00424 if (trackstatus != 2 ) {
00425
00426 if(prename == "SIDETL" || prename == "SIDETR" ) {
00427 if(prename == "SIDETL") {
00428
00429 }
00430 if(prename == "SIDETR") {
00431
00432 }
00433
00434 G4String posname = aStep->GetPostStepPoint()->GetPhysicalVolume()->GetName();
00435 if((prename == "SIDETL" && posname != "SIDETL") || (prename == "SIDETR" && posname != "SIDETR")) {
00436 if(name1[2] == "SISTATION" ) {
00437
00438 }
00439 if(name1[3] == "SIPLANE" ) {
00440
00441 }
00442
00443 if(prename == "SIDETL") {
00444
00445
00446 if(copyno1[2]<2) {
00447
00448 }
00449 else if(copyno1[2]<3) {
00450
00451 if(copyno1[3]<2) {
00452 }
00453 else if(copyno1[3]<3) {
00454
00455 }
00456 else if(copyno1[3]<4) {
00457
00458 }
00459 else if(copyno1[3]<5) {
00460
00461 }
00462 else if(copyno1[3]<6) {
00463
00464 }
00465 else if(copyno1[3]<7) {
00466
00467 }
00468 else if(copyno1[3]<8) {
00469
00470 }
00471 else if(copyno1[3]<9) {
00472
00473 }
00474 else if(copyno1[3]<10) {
00475
00476 }
00477 }
00478 else if(copyno1[2]<4) {
00479
00480 }
00481 else if(copyno1[2]<5) {
00482
00483 }
00484 }
00485 if(prename == "SIDETR") {
00486
00487
00488 if(copyno1[2]<2) {
00489
00490 }
00491 else if(copyno1[2]<3) {
00492
00493 if(copyno1[3]<2) {
00494 }
00495 else if(copyno1[3]<3) {
00496
00497 }
00498 else if(copyno1[3]<4) {
00499
00500 }
00501 else if(copyno1[3]<5) {
00502
00503 }
00504 else if(copyno1[3]<6) {
00505
00506 }
00507 else if(copyno1[3]<7) {
00508
00509 }
00510 else if(copyno1[3]<8) {
00511
00512 }
00513 else if(copyno1[3]<9) {
00514
00515 }
00516 else if(copyno1[3]<10) {
00517
00518 }
00519 }
00520 else if(copyno1[2]<4) {
00521
00522 }
00523 else if(copyno1[2]<5) {
00524
00525 }
00526 }
00527
00528 }
00529 }
00530
00531 }
00532
00533
00534 SumEnerDeposit += EnerDeposit;
00535 if (trackstatus == 2 ) {
00536
00537
00538 tracklength0 = tracklength;
00539 }
00540 }
00541
00542
00543
00544 if (parentID == 1 && curstepnumber == 1) {
00545
00546 numofpart += 1;
00547 if(prename == "SBST" ) {
00548
00549 }
00550 if(prename == "SBSTs" ) {
00551
00552 }
00553 }
00554
00555 }
00556
00557
00558 int BscTest::detLevels(const G4VTouchable* touch) const {
00559
00560
00561 if (touch)
00562 return ((touch->GetHistoryDepth())+1);
00563 else
00564 return 0;
00565 }
00566
00567
00568 G4String BscTest::detName(const G4VTouchable* touch, int level,
00569 int currentlevel) const {
00570
00571
00572 if (level > 0 && level >= currentlevel) {
00573 int ii = level - currentlevel;
00574 return touch->GetVolume(ii)->GetName();
00575 } else {
00576 return "NotFound";
00577 }
00578 }
00579
00580 void BscTest::detectorLevel(const G4VTouchable* touch, int& level,
00581 int* copyno, G4String* name) const {
00582
00583
00584 if (level > 0) {
00585 for (int ii = 0; ii < level; ii++) {
00586 int i = level - ii - 1;
00587 G4VPhysicalVolume* pv = touch->GetVolume(i);
00588 if (pv != 0)
00589 name[ii] = pv->GetName();
00590 else
00591 name[ii] = "Unknown";
00592 copyno[ii] = touch->GetReplicaNumber(i);
00593 }
00594 }
00595 }
00596
00597
00598
00599 void BscTest::update(const EndOfEvent * evt) {
00600
00601
00602 if (verbosity > 1) {
00603 iev = (*evt)()->GetEventID();
00604 std::cout <<"BscTest:update EndOfEvent = " << iev << std::endl;
00605 }
00606
00607 bsceventarray[ntbsc_evt] = (float)whichevent;
00608
00609
00610 int trackID = 0;
00611 G4PrimaryParticle* thePrim=0;
00612
00613
00614
00615 G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
00616 if (nvertex !=1)
00617 std::cout << "BscTest: My warning: NumberOfPrimaryVertex != 1 --> = " << nvertex << std::endl;
00618
00619 for (int i = 0 ; i<nvertex; i++) {
00620 G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(i);
00621 if (avertex == 0)
00622 std::cout << "BscTest End Of Event ERR: pointer to vertex = 0"
00623 << std::endl;
00624 G4int npart = avertex->GetNumberOfParticle();
00625 if (npart !=1)
00626 std::cout << "BscTest: My warning: NumberOfPrimaryPart != 1 --> = " << npart << std::endl;
00627 if (npart ==0)
00628 std::cout << "BscTest End Of Event ERR: no NumberOfParticle" << std::endl;
00629
00630 if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
00631
00632 if (thePrim!=0) {
00633
00634 G4double vx=0.,vy=0.,vz=0.;
00635 vx = avertex->GetX0();
00636 vy = avertex->GetY0();
00637 vz = avertex->GetZ0();
00638
00639
00640
00641 TheHistManager->GetHisto("VtxX")->Fill(vx);
00642 TheHistManager->GetHisto("VtxY")->Fill(vy);
00643 TheHistManager->GetHisto("VtxZ")->Fill(vz);
00644 }
00645 }
00646
00647
00648
00649 if (thePrim != 0) {
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665 if(lastpo.z()<z4 && lastpo.perp()< 100.) {
00666
00667 }
00668
00669
00670
00671 G4ThreeVector mom = thePrim->GetMomentum();
00672
00673 double phi = atan2(mom.y(),mom.x());
00674 if (phi < 0.) phi += twopi;
00675 double phigrad = phi*180./pi;
00676
00677 double th = mom.theta();
00678 double eta = -log(tan(th/2));
00679 TheHistManager->GetHisto("PrimaryEta")->Fill(eta);
00680 TheHistManager->GetHisto("PrimaryPhigrad")->Fill(phigrad);
00681 TheHistManager->GetHisto("PrimaryTh")->Fill(th*180./pi);
00682
00683 TheHistManager->GetHisto("PrimaryLastpoZ")->Fill(lastpo.z());
00684 if(lastpo.z() < z4 ) {
00685 TheHistManager->GetHisto("PrimaryLastpoX")->Fill(lastpo.x());
00686 TheHistManager->GetHisto("PrimaryLastpoY")->Fill(lastpo.y());
00687 }
00688 if(numofpart > 4 ) {
00689 TheHistManager->GetHisto("XLastpoNumofpart")->Fill(lastpo.x());
00690 TheHistManager->GetHisto("YLastpoNumofpart")->Fill(lastpo.y());
00691 }
00692
00693
00694
00695
00696
00697
00698 std::map<int,float,std::less<int> > themap;
00699 std::map<int,float,std::less<int> > themap1;
00700
00701 std::map<int,float,std::less<int> > themapxy;
00702 std::map<int,float,std::less<int> > themapz;
00703
00704
00705
00706 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
00707
00708 if (verbosity > 0) {
00709 std::cout << "BscTest: accessed all HC" << std::endl;;
00710 }
00711 int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID("BSCHits");
00712
00713 BscG4HitCollection* theCAFI = (BscG4HitCollection*) allHC->GetHC(CAFIid);
00714 if (verbosity > 0) {
00715 std::cout << "BscTest: theCAFI->entries = " << theCAFI->entries() << std::endl;
00716 }
00717 int varia ;
00718 varia = 0;
00719 if( lastpo.z()< z4) {
00720 varia = 1;
00721 }
00722 else{
00723 varia = 2;
00724 }
00725
00726 for (int j=0; j<theCAFI->entries(); j++) {
00727 BscG4Hit* aHit = (*theCAFI)[j];
00728 CLHEP::Hep3Vector hitPoint = aHit->getEntry();
00729 double zz = hitPoint.z();
00730 TheHistManager->GetHisto("zHits")->Fill(zz);
00731 if(tracklength0>8300.) TheHistManager->GetHisto("zHitsTrLoLe")->Fill(zz);
00732 }
00733
00734
00735 if( varia == 2) {
00736
00737
00738 int nhit11 = 0, nhit12 = 0, nhit13 = 0 ;
00739 double totallosenergy= 0.;
00740 for (int j=0; j<theCAFI->entries(); j++) {
00741 BscG4Hit* aHit = (*theCAFI)[j];
00742
00743 CLHEP::Hep3Vector hitEntryLocalPoint = aHit->getEntryLocalP();
00744 CLHEP::Hep3Vector hitExitLocalPoint = aHit->getExitLocalP();
00745 CLHEP::Hep3Vector hitPoint = aHit->getEntry();
00746 int trackIDhit = aHit->getTrackID();
00747 unsigned int unitID = aHit->getUnitID();
00748 double losenergy = aHit->getEnergyLoss();
00749 double phi_hit = hitPoint.phi();
00750 if (phi_hit < 0.) phi_hit += twopi;
00751
00752 double zz = hitPoint.z();
00753
00754 TheHistManager->GetHisto("zHitsnoMI")->Fill(zz);
00755
00756 if (verbosity > 2) {
00757 std::cout << "BscTest:zHits = " << zz << std::endl;
00758 }
00759
00760 themap[unitID] += losenergy;
00761 totallosenergy += losenergy;
00762
00763 int zside, sector;
00764 BscNumberingScheme::unpackBscIndex(unitID);
00765 zside = (unitID&32)>>5;
00766 sector = (unitID&7);
00767
00768
00769
00770 G4ThreeVector middle = (hitExitLocalPoint+hitEntryLocalPoint)/2.;
00771 themapz[unitID] = hitPoint.z()+middle.z();
00772
00773
00774 if(zside==1) {
00775
00776 if(losenergy > 0.00003) {
00777 themap1[unitID] += 1.;
00778 }
00779 }
00780
00781 if(zside==2){
00782
00783 if(losenergy > 0.00005) {
00784 themap1[unitID] += 1.;
00785 }
00786 }
00787
00788
00789 if(sector==1) {
00790 nhit11 += 1;
00791
00792
00793 }
00794 if(sector==2) {
00795 nhit12 += 1;
00796
00797
00798 }
00799 if(sector==3) {
00800 nhit13 += 1;
00801
00802
00803 }
00804
00805 if(lastpo.z()<z4 && lastpo.perp()< 120.) {
00806
00807
00808
00809
00810 if( zz < z2){
00811
00812
00813 }
00814
00815 if( zz < z3 && zz > z2){
00816
00817
00818 }
00819
00820 if( zz < z4 && zz > z3){
00821
00822
00823
00824 }
00825 }
00826 else{
00827
00828
00829
00830
00831
00832
00833 if( zz < z2){
00834
00835
00836
00837
00838 if(zside==1) {
00839
00840 }
00841 if(zside==2){
00842
00843 }
00844 if(trackIDhit == 1){
00845
00846
00847
00848 }
00849 else{
00850
00851 }
00852 }
00853
00854 if( zz < z3 && zz > z2){
00855
00856
00857
00858
00859
00860
00861 if(zside==1) {
00862
00863 }
00864 if(zside==2){
00865
00866 }
00867 if(trackIDhit == 1){
00868
00869
00870 }
00871 else{
00872
00873 }
00874 }
00875
00876 if( zz < z4 && zz > z3){
00877 if(zside==1) {
00878
00879 }
00880 if(zside==2){
00881
00882 }
00883 }
00884 }
00885 }
00886 if(totallosenergy == 0.0) {
00887 std::cout << "BscTest: number of hits = " << theCAFI->entries() << std::endl;
00888 for (int j=0; j<theCAFI->entries(); j++) {
00889 BscG4Hit* aHit = (*theCAFI)[j];
00890 double losenergy = aHit->getEnergyLoss();
00891 std::cout << " j hits = " << j << "losenergy = " << losenergy << std::endl;
00892 }
00893 }
00894
00895 double totalEnergy = 0.;
00896 int nhitsX = 0, nhitsY = 0, nsumhit = 0 ;
00897 for (int sector=1; sector<4; sector++) {
00898 int nhitsecX = 0, nhitsecY = 0;
00899 for (int zmodule=1; zmodule<11; zmodule++) {
00900 for (int zside=1; zside<3; zside++) {
00901 int det= 1;
00902
00903 int index = BscNumberingScheme::packBscIndex(det, zside, sector);
00904 double theTotalEnergy = themap[index];
00905
00906 if(zside<2){
00907
00908 if(theTotalEnergy > 0.00003) {
00909 nhitsX += 1;
00910
00911
00912 }
00913 }
00914
00915 else {
00916
00917 if(theTotalEnergy > 0.00005) {
00918 nhitsY += 1;
00919
00920
00921 }
00922 }
00923
00924 totalEnergy += themap[index];
00925 }
00926 }
00927
00928 if(nhitsecX > 10 || nhitsecY > 10) {
00929 nsumhit +=1;
00930
00931 }
00932 else{
00933 }
00934 }
00935
00936 if( nsumhit >=2 ) {
00937 }
00938 else{
00939 }
00940
00941 }
00942
00943
00944
00945 }
00946
00947 if (verbosity > 0) {
00948 std::cout << "BscTest: END OF Event " << (*evt)()->GetEventID() << std::endl;
00949 }
00950
00951 }
00952