File indexing completed on 2025-08-05 08:11:57
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef INTTDSTchain_h
0009 #define INTTDSTchain_h
0010
0011 #include <TROOT.h>
0012 #include <TChain.h>
0013 #include <TFile.h>
0014
0015
0016 #include "vector"
0017
0018 class INTTDSTchain {
0019 public :
0020 TChain *fChain;
0021 Int_t fCurrent;
0022
0023
0024 Int_t event;
0025 Int_t NTruthVtx;
0026 vector<float> *TruthPV_x;
0027 vector<float> *TruthPV_y;
0028 vector<float> *TruthPV_z;
0029 vector<int> *TruthPV_Npart;
0030 vector<int> *TruthPV_Nhits;
0031 vector<int> *TruthPV_NClus;
0032 vector<float> *TruthPV_t;
0033 vector<float> *TruthPV_embed;
0034 Float_t TruthPV_trig_x;
0035 Float_t TruthPV_trig_y;
0036 Float_t TruthPV_trig_z;
0037 Int_t TruthPV_trig_Npart;
0038
0039 Float_t centrality_bimp;
0040 Float_t centrality_mbd;
0041 Float_t centrality_mbdquantity;
0042
0043
0044
0045
0046
0047 vector<float> *UniqueAncG4P_Eta;
0048 vector<float> *UniqueAncG4P_Phi;
0049
0050 vector<int> *UniqueAncG4P_PID;
0051
0052
0053
0054
0055
0056 vector<int> *UniqueAncG4P_TrackID;
0057
0058 Int_t Layer1_occupancy;
0059 Int_t NClus;
0060 Int_t NTrkrhits;
0061 vector<int> *ClusLayer;
0062 vector<float> *ClusX;
0063 vector<float> *ClusY;
0064 vector<float> *ClusZ;
0065 vector<float> *ClusR;
0066 vector<float> *ClusPhi;
0067 vector<float> *ClusEta;
0068 vector<unsigned int> *ClusAdc;
0069 vector<float> *ClusPhiSize;
0070 vector<float> *ClusZSize;
0071 vector<unsigned char> *ClusLadderZId;
0072 vector<unsigned char> *ClusLadderPhiId;
0073
0074
0075 TBranch *b_event;
0076 TBranch *b_NTruthVtx;
0077 TBranch *b_TruthPV_x;
0078 TBranch *b_TruthPV_y;
0079 TBranch *b_TruthPV_z;
0080 TBranch *b_TruthPV_Npart;
0081 TBranch *b_TruthPV_Nhits;
0082 TBranch *b_TruthPV_NClus;
0083 TBranch *b_TruthPV_t;
0084 TBranch *b_TruthPV_embed;
0085 TBranch *b_TruthPV_trig_x;
0086 TBranch *b_TruthPV_trig_y;
0087 TBranch *b_TruthPV_trig_z;
0088 TBranch *b_TruthPV_trig_Npart;
0089
0090
0091
0092
0093 TBranch *b_UniqueAncG4P_Eta;
0094 TBranch *b_UniqueAncG4P_Phi;
0095
0096 TBranch *b_UniqueAncG4P_PID;
0097
0098
0099
0100
0101
0102 TBranch *b_UniqueAncG4P_TrackID;
0103
0104 TBranch *b_Layer1_occupancy;
0105 TBranch *b_NClus;
0106 TBranch *b_NTrkrhits;
0107 TBranch *b_ClusLayer;
0108 TBranch *b_ClusX;
0109 TBranch *b_ClusY;
0110 TBranch *b_ClusZ;
0111 TBranch *b_ClusR;
0112 TBranch *b_ClusPhi;
0113 TBranch *b_ClusEta;
0114 TBranch *b_ClusAdc;
0115 TBranch *b_ClusPhiSize;
0116 TBranch *b_ClusZSize;
0117 TBranch *b_ClusLadderZId;
0118 TBranch *b_ClusLadderPhiId;
0119
0120 TBranch *b_centrality_bimp;
0121 TBranch *b_centrality_mbd;
0122 TBranch *b_centrality_mbdquantity;
0123
0124 INTTDSTchain(TChain *chain_in = 0, string folder_direction = "", vector<string> file_list = {});
0125 INTTDSTchain(TChain *chain_in = 0, string folder_direction = "", string MC_list_name = "");
0126 virtual ~INTTDSTchain();
0127 virtual Int_t Cut(Long64_t entry);
0128 virtual Int_t GetEntry(Long64_t entry);
0129 virtual Long64_t LoadTree(Long64_t entry);
0130 virtual void Init(TChain *chain_in);
0131 virtual void Loop();
0132 virtual Bool_t Notify();
0133 virtual void Show(Long64_t entry = -1);
0134 private :
0135 string folder_direction;
0136 string MC_list_name;
0137 vector<string> file_list;
0138 void read_list();
0139 };
0140
0141 #endif
0142
0143 #ifdef INTTDSTchain_cxx
0144 INTTDSTchain::INTTDSTchain(TChain *chain_in, string folder_direction, vector<string> file_list) :
0145 fChain(0),
0146 folder_direction(folder_direction),
0147 file_list(file_list)
0148 {
0149
0150
0151 if (chain_in == 0) {
0152
0153
0154
0155
0156
0157 std::cout<<"There is no TChain input ?, run exit"<<std::endl;
0158 std::exit(1);
0159 }
0160 if (folder_direction.size() == 0) {std::cout<<"There is no folder_direction input ?, run exit"<<std::endl; std::exit(1);}
0161 if (file_list.size() == 0) {std::cout<<"There is no file_list input ?, run exit"<<std::endl; std::exit(1);}
0162
0163
0164
0165
0166 Init(chain_in);
0167 }
0168
0169 INTTDSTchain::INTTDSTchain(TChain *chain_in, string folder_direction, string MC_list_name) :
0170 fChain(0),
0171 folder_direction(folder_direction),
0172 MC_list_name(MC_list_name)
0173 {
0174
0175
0176 if (chain_in == 0) {
0177
0178
0179
0180
0181
0182 std::cout<<"There is no TChain input ?, run exit"<<std::endl;
0183 std::exit(1);
0184 }
0185 if (folder_direction.size() == 0) {std::cout<<"There is no folder_direction input ?, run exit"<<std::endl; std::exit(1);}
0186 if (MC_list_name.size() == 0) {std::cout<<"There is no MC_list_name input ?, run exit"<<std::endl; std::exit(1);}
0187
0188
0189
0190 read_list();
0191
0192
0193
0194
0195
0196 Init(chain_in);
0197 }
0198
0199 void INTTDSTchain::read_list()
0200 {
0201 string list_buffer;
0202 ifstream data_list;
0203 data_list.open((folder_direction + "/" + MC_list_name).c_str());
0204
0205 file_list.clear();
0206
0207 while (1)
0208 {
0209 data_list >> list_buffer;
0210 if (!data_list.good())
0211 {
0212 break;
0213 }
0214 file_list.push_back(list_buffer);
0215 }
0216
0217 }
0218
0219 INTTDSTchain::~INTTDSTchain()
0220 {
0221 if (!fChain) return;
0222 delete fChain->GetCurrentFile();
0223 }
0224
0225 Int_t INTTDSTchain::GetEntry(Long64_t entry)
0226 {
0227
0228 if (!fChain) return 0;
0229 return fChain->GetEntry(entry);
0230 }
0231 Long64_t INTTDSTchain::LoadTree(Long64_t entry)
0232 {
0233
0234 if (!fChain) return -5;
0235 Long64_t centry = fChain->LoadTree(entry);
0236 if (centry < 0) return centry;
0237 if (fChain->GetTreeNumber() != fCurrent) {
0238 fCurrent = fChain->GetTreeNumber();
0239 Notify();
0240 }
0241 return centry;
0242 }
0243
0244 void INTTDSTchain::Init(TChain *chain_in)
0245 {
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255 TruthPV_x = 0;
0256 TruthPV_y = 0;
0257 TruthPV_z = 0;
0258 TruthPV_Npart = 0;
0259 TruthPV_Nhits = 0;
0260 TruthPV_NClus = 0;
0261 TruthPV_t = 0;
0262 TruthPV_embed = 0;
0263
0264
0265
0266
0267 UniqueAncG4P_Eta = 0;
0268 UniqueAncG4P_Phi = 0;
0269
0270 UniqueAncG4P_PID = 0;
0271
0272
0273
0274
0275
0276 UniqueAncG4P_TrackID = 0;
0277
0278 ClusLayer = 0;
0279 ClusX = 0;
0280 ClusY = 0;
0281 ClusZ = 0;
0282 ClusR = 0;
0283 ClusPhi = 0;
0284 ClusEta = 0;
0285 ClusAdc = 0;
0286 ClusPhiSize = 0;
0287 ClusZSize = 0;
0288 ClusLadderZId = 0;
0289 ClusLadderPhiId = 0;
0290
0291 centrality_bimp = 0;
0292 centrality_mbd = 0;
0293 centrality_mbdquantity = 0;
0294
0295
0296 if (!chain_in) return;
0297 fChain = chain_in;
0298 fCurrent = -1;
0299 fChain->SetMakeClass(1);
0300
0301
0302 for (auto each_file : file_list){ fChain -> Add((folder_direction + "/" + each_file).c_str()); }
0303
0304 fChain -> SetBranchStatus("*",0);
0305 fChain -> SetBranchStatus("event",1);
0306 fChain -> SetBranchStatus("NTruthVtx",1);
0307
0308
0309
0310
0311
0312
0313
0314
0315 fChain -> SetBranchStatus("TruthPV_trig_x",1);
0316 fChain -> SetBranchStatus("TruthPV_trig_y",1);
0317 fChain -> SetBranchStatus("TruthPV_trig_z",1);
0318
0319 fChain -> SetBranchStatus("ClusLayer",1);
0320 fChain -> SetBranchStatus("ClusX",1);
0321 fChain -> SetBranchStatus("ClusY",1);
0322 fChain -> SetBranchStatus("ClusZ",1);
0323 fChain -> SetBranchStatus("ClusR",1);
0324 fChain -> SetBranchStatus("ClusPhi",1);
0325 fChain -> SetBranchStatus("ClusEta",1);
0326 fChain -> SetBranchStatus("ClusAdc",1);
0327 fChain -> SetBranchStatus("ClusPhiSize",1);
0328 fChain -> SetBranchStatus("ClusZSize",1);
0329 fChain -> SetBranchStatus("ClusLadderZId",1);
0330 fChain -> SetBranchStatus("ClusLadderPhiId",1);
0331
0332 fChain -> SetBranchStatus("NClus",1);
0333 fChain -> SetBranchStatus("NTrkrhits",1);
0334
0335
0336 fChain -> SetBranchStatus("UniqueAncG4P_Eta", 1);
0337 fChain -> SetBranchStatus("UniqueAncG4P_Phi", 1);
0338 fChain -> SetBranchStatus("centrality_bimp",1);
0339 fChain -> SetBranchStatus("centrality_mbd",1);
0340 fChain -> SetBranchStatus("centrality_mbdquantity",1);
0341
0342 fChain->SetBranchAddress("event", &event, &b_event);
0343 fChain->SetBranchAddress("NTruthVtx", &NTruthVtx, &b_NTruthVtx);
0344
0345
0346
0347
0348
0349
0350
0351
0352 fChain->SetBranchAddress("TruthPV_trig_x", &TruthPV_trig_x, &b_TruthPV_trig_x);
0353 fChain->SetBranchAddress("TruthPV_trig_y", &TruthPV_trig_y, &b_TruthPV_trig_y);
0354 fChain->SetBranchAddress("TruthPV_trig_z", &TruthPV_trig_z, &b_TruthPV_trig_z);
0355
0356
0357
0358
0359
0360 fChain->SetBranchAddress("UniqueAncG4P_Eta", &UniqueAncG4P_Eta, &b_UniqueAncG4P_Eta);
0361 fChain->SetBranchAddress("UniqueAncG4P_Phi", &UniqueAncG4P_Phi, &b_UniqueAncG4P_Phi);
0362
0363 fChain->SetBranchAddress("UniqueAncG4P_PID", &UniqueAncG4P_PID, &b_UniqueAncG4P_PID);
0364
0365
0366
0367
0368
0369
0370
0371
0372 fChain->SetBranchAddress("NClus", &NClus, &b_NClus);
0373 fChain->SetBranchAddress("NTrkrhits", &NTrkrhits, &b_NTrkrhits);
0374 fChain->SetBranchAddress("ClusLayer", &ClusLayer, &b_ClusLayer);
0375 fChain->SetBranchAddress("ClusX", &ClusX, &b_ClusX);
0376 fChain->SetBranchAddress("ClusY", &ClusY, &b_ClusY);
0377 fChain->SetBranchAddress("ClusZ", &ClusZ, &b_ClusZ);
0378 fChain->SetBranchAddress("ClusR", &ClusR, &b_ClusR);
0379 fChain->SetBranchAddress("ClusPhi", &ClusPhi, &b_ClusPhi);
0380 fChain->SetBranchAddress("ClusEta", &ClusEta, &b_ClusEta);
0381 fChain->SetBranchAddress("ClusAdc", &ClusAdc, &b_ClusAdc);
0382 fChain->SetBranchAddress("ClusPhiSize", &ClusPhiSize, &b_ClusPhiSize);
0383 fChain->SetBranchAddress("ClusZSize", &ClusZSize, &b_ClusZSize);
0384 fChain->SetBranchAddress("ClusLadderZId", &ClusLadderZId, &b_ClusLadderZId);
0385 fChain->SetBranchAddress("ClusLadderPhiId", &ClusLadderPhiId, &b_ClusLadderPhiId);
0386
0387 fChain->SetBranchAddress("centrality_bimp", ¢rality_bimp, &b_centrality_bimp);
0388 fChain->SetBranchAddress("centrality_mbd", ¢rality_mbd, &b_centrality_mbd);
0389 fChain->SetBranchAddress("centrality_mbdquantity", ¢rality_mbdquantity, &b_centrality_mbdquantity);
0390
0391 Notify();
0392 }
0393
0394 Bool_t INTTDSTchain::Notify()
0395 {
0396
0397
0398
0399
0400
0401
0402 return kTRUE;
0403 }
0404
0405 void INTTDSTchain::Show(Long64_t entry)
0406 {
0407
0408
0409 if (!fChain) return;
0410 fChain->Show(entry);
0411 }
0412 Int_t INTTDSTchain::Cut(Long64_t entry)
0413 {
0414
0415
0416
0417 return 1;
0418 }
0419 #endif