1313/// \brief This macro retrieves clusters from Krypton and X-Ray runs, input tpcdigits.root
1414/// \author Philip Hauer <philip.hauer@cern.ch>
1515
16- #if !defined(__CLING__ ) || defined(__ROOTCLING__ )
16+ // #if !defined(__CLING__) || defined(__ROOTCLING__)
1717#include "TCanvas.h"
1818#include "TFile.h"
19- #include "TTree.h"
19+ #include "TChain.h"
20+ #include "TGrid.h"
2021
2122#include "DataFormatsTPC/KrCluster.h"
2223#include "TPCReconstruction/KrBoxClusterFinder.h"
2324#include "DataFormatsTPC/Digit.h"
25+ #include "TPCBase/Utils.h"
2426
2527#include <array>
2628#include <iostream>
2729#include <tuple>
2830#include <vector>
29- #endif
31+ // #endif
3032
31- void findKrBoxCluster (int lastTimeBin = 1000 , int run = -1 , int time = -1 , std ::string_view gainMapFile = "" , std ::string inputFile = "tpcdigits .root" , std ::string outputFile = "BoxClusters.root " )
33+ void findKrBoxCluster (std ::string inputFile = "tpcdigits.root " , std ::string outputFile = "BoxClusters .root" , std ::string_view gainMapFile = "" )
3234{
35+ int lastTimeBin = 1000 ;
36+ ULong_t runRead = -1 ;
37+ uint32_t run = 0 ;
38+ uint32_t firstOrbit = 0 ;
39+ uint32_t tfCounter = 0 ;
40+
3341 // Read the digits:
34- TFile * file = new TFile (inputFile .c_str ());
35- TTree * tree = (TTree * )file -> Get ("o2sim" );
42+ TChain * tree = o2 ::tpc ::utils ::buildChain (fmt ::format ("cat {}" , inputFile ), "o2sim" , "o2sim" );
3643 Long64_t nEntries = tree -> GetEntries ();
3744 std ::cout << "The Tree has " << nEntries << " Entries." << std ::endl ;
3845
@@ -46,13 +53,17 @@ void findKrBoxCluster(int lastTimeBin = 1000, int run = -1, int time = -1, std::
4653 // Create a Branch for each sector:
4754 tClusters -> Branch ("cls" , & clusters );
4855 tClusters -> Branch ("run" , & run );
49- tClusters -> Branch ("time" , & time );
56+ tClusters -> Branch ("firstOrbit" , & firstOrbit );
57+ tClusters -> Branch ("tfCounter" , & tfCounter );
5058
5159 std ::array < std ::vector < o2 ::tpc ::Digit > * , 36 > digitizedSignal ;
5260 for (size_t iSec = 0 ; iSec < digitizedSignal .size (); ++ iSec ) {
5361 digitizedSignal [iSec ] = nullptr ;
5462 tree -> SetBranchAddress (Form ("TPCDigit_%zu" , iSec ), & digitizedSignal [iSec ]);
5563 }
64+ tree -> SetBranchAddress ("run" , & runRead );
65+ tree -> SetBranchAddress ("firstOrbit" , & firstOrbit );
66+ tree -> SetBranchAddress ("tfCounter" , & tfCounter );
5667
5768 if (gainMapFile .size ()) {
5869 clFinder -> loadGainMapFromFile (gainMapFile );
@@ -67,13 +78,29 @@ void findKrBoxCluster(int lastTimeBin = 1000, int run = -1, int time = -1, std::
6778 for (int iEvent = 0 ; iEvent < nEntries ; ++ iEvent ) {
6879 std ::cout << iEvent + 1 << "/" << nEntries << std ::endl ;
6980 tree -> GetEntry (iEvent );
81+ run = uint32_t (runRead );
7082
7183 for (int i = 0 ; i < 36 ; i ++ ) {
7284 auto sector = digitizedSignal [i ];
7385 if (sector -> size () == 0 ) {
7486 continue ;
7587 }
76- std ::cout << "Processing sector " << i << "\n" ;
88+ auto& digits = * sector ;
89+ std ::sort (digits .begin (), digits .end (), [](const auto& a , const auto & b ) {
90+ if (a .getTimeStamp () < b .getTimeStamp ()) {
91+ return true;
92+ }
93+ if (a .getTimeStamp () == b .getTimeStamp ()) {
94+ if (a .getRow () < b .getRow ()) {
95+ return true;
96+ } else if (a .getRow () == b .getRow ()) {
97+ return a .getPad () < b .getPad ();
98+ }
99+ }
100+ return false;
101+ });
102+
103+ // std::cout << "Processing sector " << i << "\n";
77104
78105 clFinder -> loopOverSector (* sector , i );
79106 }
0 commit comments