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