ATLAS Offline Software
Loading...
Searching...
No Matches
TestFCalIdentifiers.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "FCS_Cell.h"
10#include "CaloHitAna.h"
12#include "../ISF_FastCaloSimParametrization/FCAL_ChannelMap.h"
13#include "TTree.h"
14#include <string>
15#include <sstream>
16#include <iostream>
17#include "TSystem.h"
18#include "TString.h"
19#include "TFile.h"
20#include <stdlib.h>
21#include "TLorentzVector.h"
22#include "TH1.h"
23#include "TH2.h"
24#include "TH1F.h"
25#include "TH2F.h"
26#include <vector>
27#include "TCanvas.h"
28//#include "MakeBins.C"
29using namespace std;
30
31void TestFCalIdentifiers(TString sampling="Sampling_0"){
32
34 geo->LoadGeometryFromFile("/afs/cern.ch/atlas/groups/Simulation/FastCaloSim/ATLAS-GEO-20-00-01.root","ATLAS-GEO-20-00-01");
35 geo->LoadFCalGeometryFromFiles("FCal1-electrodes.sorted.HV.09Nov2007.dat","FCal2-electrodes.sorted.HV.April2011.dat","FCal3-electrodes.sorted.HV.09Nov2007.dat");
36
37
38 FCAL_ChannelMap* channelMap =geo->GetFCAL_ChannelMap();
39
40
41
42
43
44
45
46
47
48
49
50
51 //TFile *inputFile = TFile::Open("root://eosatlas.cern.ch//eos/atlas/user/z/zhubacek/FastCaloSim/LArShift020715/ISF_HitAnalysis6_evgen_calo__211_E50000_50000_eta20_25_Evts0-5500_vz_0_origin_calo.merged.pool.root");
52
53 // TFile *inputFile = TFile::Open("root://eosatlas.cern.ch//eos/atlas/user/z/zhubacek/FastCaloSim/NTUP_110216/ISF_HitAnalysis_Zach1_merged.root");
54
55 TFile *inputFile = TFile::Open("/eos/atlas/user/s/schaarsc/FCS/user.fladias.428137.FastCalo_pid11_E65536_etam35_35_zv_m100.e4001_s2864_r7736.w0_162706_matched_output.root/user.fladias.8834798._000001.matched_output.root");
56 //TFile *inputFile = TFile::Open("/eos/atlas/user/s/schaarsc/FCS/user.fladias.428137.FastCalo_pid11_E65536_etam35_35_zv_m100.e4001_s2865_r7736.w0_162706_matched_output.root");
57
58 TTree *inputTree = ( TTree* ) inputFile->Get( "FCS_ParametrizationInput" );
59
60 FCS_matchedcellvector *vec=0; //this need to be set to 0!
61 inputTree->SetBranchAddress(sampling,&vec);
62
63
64 std::cout << "Sampling is " << sampling << std::endl;
65
66 Int_t nEvt = inputTree->GetEntries();
67 std::cout << "nEvt " << nEvt << std::endl;
68
69 // nEvt = 1000;
70
71 stringstream ssIdentifier;
72
73 for (Int_t ientry=0; ientry<nEvt; ientry++){
74
75 inputTree->GetEntry(ientry);
76 if(ientry%100 == 0)
77 std::cout << "Processing event # " << ientry << std::endl;
78
79 double weight = 1.0;
80 //cout << (*vec).size() << endl;
81 //loop over cells in sampling
82 for (UInt_t j=0; j<(*vec).size(); j++){
83
84 Float_t cell_E = 0.0;
85 cell_E = ((FCS_matchedcell)(*vec)[j]).cell.energy;
86 Long64_t cell_ID = 0;
87 cell_ID = ((FCS_matchedcell)(*vec)[j]).cell.cell_identifier;
88
89 cout << cell_ID << hex << " 0x"<< cell_ID << endl;
90 // cout << cell_E << endl;
91
92 //now I use the geomery lookup tool to get the cell eta/phi
93 // const CaloDetDescrElement* cell;
94 Identifier cellid(cell_ID);
95 //cell=geo->getDDE(cellid); //This is working also for the FCal
96
97 //loop over hits in the cell
98 for (unsigned int ihit=0; ihit<((FCS_matchedcell)(*vec)[j]).hit.size(); ihit++){
99
100 //now I check what is the hit position
101 float x = ((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_x;
102 float y = ((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_y;
103 float z = ((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_z;
104 float t = ((FCS_matchedcell)(*vec)[j]).hit[ihit].hit_time;
105 TLorentzVector *hitVec = new TLorentzVector(x, y, z, t);
106 const CaloDetDescrElement* foundCell;
107 int hitSampling =((FCS_matchedcell)(*vec)[j]).hit[ihit].sampling;
108
109 //cout << hitSampling << " " << x << " " << y << endl;
110
111 if(hitSampling<21)foundCell=geo->getDDE(hitSampling,hitVec->Eta(),hitVec->Phi());
112 else if(hitSampling<24)foundCell=geo->getFCalDDE(hitSampling,x,y,z);
113 else {
114 cout << endl << "Warning: Found hit with sampling > 23 !!!!!!!!!!!!!!" << endl << endl;
115 foundCell =0;
116 }
117
118
119 int ieta,iphi;
120
121 //cout << "Hit position: " << "x: " << x << " y: " << y << " eta: " << hitVec->Eta() << " phi: " << hitVec->Phi() << endl;
122
123
124
125 if (foundCell){// && cell){
126 channelMap->getTileID(hitSampling - 20,x,y,ieta,iphi);
127 ssIdentifier.str("");
128
129 int zSide = 2;
130 ssIdentifier << 4 // LArCalorimeter
131 << 3 // LArFCAL
132 << zSide // EndCap
133 << hitSampling // FCal Module #
134 << (ieta << 16)+iphi;
135
136 //cout << foundCell->x() << " " << foundCell->y() << endl;
137 //cout << abs(foundCell->x() - x) << " " << abs(foundCell->y() - y) << endl;
138 if( z > 0) cout << "Side A " << hex << foundCell->identify() <<" " << cell_ID <<" " << ((FCS_matchedcell)(*vec)[j]).hit[ihit].cell_identifier << dec << " " << cell_ID <<" " << ((FCS_matchedcell)(*vec)[j]).hit[ihit].cell_identifier <<" " << ieta << " " << iphi << " " << (ieta << 16)+iphi << endl;
139 else cout << "Side C " << hex << foundCell->identify() <<" " << cell_ID << " " << ((FCS_matchedcell)(*vec)[j]).hit[ihit].cell_identifier << dec<< " " << cell_ID <<" " << ((FCS_matchedcell)(*vec)[j]).hit[ihit].cell_identifier << " " << ieta << " " << iphi << " " << (ieta << 16)+iphi << endl;
140 // cout << cell_ID << " " << ((FCS_matchedcell)(*vec)[j]).hit[ihit].identifier << " " << ((FCS_matchedcell)(*vec)[j]).hit[ihit].cell_identifier << " " << ((FCS_matchedcell)(*vec)[j]).g4hit[ihit].identifier << " " << ((FCS_matchedcell)(*vec)[j]).g4hit[ihit].cell_identifier << endl;
141
142
143 } //end if cell ok
144 else cout << "Cell not found!" << endl;
145 } //end loop over hits
146 } //end loop on cells
147 } //end loop on events
148
149
150
151
152
153}
std::vector< size_t > vec
void TestFCalIdentifiers(TString sampling="Sampling_0")
#define y
#define x
#define z
This class groups all DetDescr information related to a CaloCell.
Identifier identify() const override final
cell identifier
This class contains the tube and tile maps for the FCAL A tile is of a set of FCAL tubes.
bool getTileID(int isam, float x, float y, int &eta, int &phi) const
-— For the new LArFCAL_ID Identifier
STL namespace.