1- // Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2- // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3- // All rights not expressly granted are reserved.
4- //
5- // This software is distributed under the terms of the GNU General Public
6- // License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7- //
8- // In applying this license CERN does not waive the privileges and immunities
9- // granted to it by virtue of its status as an Intergovernmental Organization
10- // or submit itself to any jurisdiction.
11-
12- /// \file findKrBoxCluster.C
13- /// \brief This macro retrieves clusters from Krypton and X-Ray runs, input tpcdigits.root
14- /// \author Philip Hauer <philip.hauer@cern.ch>
15-
16- #if !defined(__CLING__ ) || defined(__ROOTCLING__ )
17- #include "TCanvas.h"
18- #include "TFile.h"
19- #include "TTree.h"
20-
21- #include "TPCReconstruction/KrCluster.h"
22- #include "TPCReconstruction/KrBoxClusterFinder.h"
23- #include "DataFormatsTPC/Digit.h"
24-
25- #include <array>
26- #include <iostream>
27- #include <tuple>
28- #include <vector>
29- #endif
30-
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" )
32- {
33- // Read the digits:
34- TFile * file = new TFile (inputFile .c_str ());
35- TTree * tree = (TTree * )file -> Get ("o2sim" );
36- Long64_t nEntries = tree -> GetEntries ();
37- std ::cout << "The Tree has " << nEntries << " Entries." << std ::endl ;
38-
39- // Initialize File for later writing
40- TFile * fOut = new TFile (outputFile .c_str (), "RECREATE" );
41- TTree * tClusters = new TTree ("Clusters" , "Clusters" );
42-
43- // Create KrBoxClusterFinder object, memory is only allocated once
44- auto clFinder = std ::make_unique < o2 ::tpc ::KrBoxClusterFinder > ();
45- auto& clusters = clFinder -> getClusters ();
46- // Create a Branch for each sector:
47- tClusters -> Branch ("cls" , & clusters );
48- tClusters -> Branch ("run" , & run );
49- tClusters -> Branch ("time" , & time );
50-
51- std ::array < std ::vector < o2 ::tpc ::Digit > * , 36 > digitizedSignal ;
52- for (size_t iSec = 0 ; iSec < digitizedSignal .size (); ++ iSec ) {
53- digitizedSignal [iSec ] = nullptr ;
54- tree -> SetBranchAddress (Form ("TPCDigit_%zu" , iSec ), & digitizedSignal [iSec ]);
55- }
56-
57- if (gainMapFile .size ()) {
58- clFinder -> loadGainMapFromFile (gainMapFile );
59- }
60-
61- // clFinder->setMinNumberOfNeighbours(0);
62- // clFinder->setMinQTreshold(0);
63- clFinder -> setMaxTimes (lastTimeBin );
64-
65- // Now everything can get processed
66- // Loop over all events
67- for (int iEvent = 0 ; iEvent < nEntries ; ++ iEvent ) {
68- std ::cout << iEvent + 1 << "/" << nEntries << std ::endl ;
69- tree -> GetEntry (iEvent );
70-
71- for (int i = 0 ; i < 36 ; i ++ ) {
72- auto sector = digitizedSignal [i ];
73- if (sector -> size () == 0 ) {
74- continue ;
75- }
76-
77- clFinder -> loopOverSector (* sector , i );
78- }
79- // Fill Tree
80- tClusters -> Fill ();
81- clusters .clear ();
82- }
83- // Write Tree to file
84- fOut -> Write ();
85- fOut -> Close ();
86- return ;
87- }
88-
89- int main ()
90- {
91- findKrBoxCluster ();
92- return 0 ;
93- }
1+ // Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+ // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+ // All rights not expressly granted are reserved.
4+ //
5+ // This software is distributed under the terms of the GNU General Public
6+ // License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+ //
8+ // In applying this license CERN does not waive the privileges and immunities
9+ // granted to it by virtue of its status as an Intergovernmental Organization
10+ // or submit itself to any jurisdiction.
11+
12+ /// \file findKrBoxCluster.C
13+ /// \brief This macro retrieves clusters from Krypton and X-Ray runs, input tpcdigits.root
14+ /// \author Philip Hauer <philip.hauer@cern.ch>
15+
16+ #if !defined(__CLING__ ) || defined(__ROOTCLING__ )
17+ #include "TCanvas.h"
18+ #include "TFile.h"
19+ #include "TTree.h"
20+
21+ #include "TPCReconstruction/KrCluster.h"
22+ #include "TPCReconstruction/KrBoxClusterFinder.h"
23+ #include "DataFormatsTPC/Digit.h"
24+
25+ #include <array>
26+ #include <iostream>
27+ #include <tuple>
28+ #include <vector>
29+ #endif
30+
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" )
32+ {
33+ // Read the digits:
34+ TFile * file = new TFile (inputFile .c_str ());
35+ TTree * tree = (TTree * )file -> Get ("o2sim" );
36+ Long64_t nEntries = tree -> GetEntries ();
37+ std ::cout << "The Tree has " << nEntries << " Entries." << std ::endl ;
38+
39+ // Initialize File for later writing
40+ TFile * fOut = new TFile (outputFile .c_str (), "RECREATE" );
41+ TTree * tClusters = new TTree ("Clusters" , "Clusters" );
42+
43+ // Create KrBoxClusterFinder object, memory is only allocated once
44+ auto clFinder = std ::make_unique < o2 ::tpc ::KrBoxClusterFinder > ();
45+ auto& clusters = clFinder -> getClusters ();
46+ // Create a Branch for each sector:
47+ tClusters -> Branch ("cls" , & clusters );
48+ tClusters -> Branch ("run" , & run );
49+ tClusters -> Branch ("time" , & time );
50+
51+ std ::array < std ::vector < o2 ::tpc ::Digit > * , 36 > digitizedSignal ;
52+ for (size_t iSec = 0 ; iSec < digitizedSignal .size (); ++ iSec ) {
53+ digitizedSignal [iSec ] = nullptr ;
54+ tree -> SetBranchAddress (Form ("TPCDigit_%zu" , iSec ), & digitizedSignal [iSec ]);
55+ }
56+
57+ if (gainMapFile .size ()) {
58+ clFinder -> loadGainMapFromFile (gainMapFile );
59+ }
60+
61+ // clFinder->setMinNumberOfNeighbours(0);
62+ // clFinder->setMinQTreshold(0);
63+ clFinder -> setMaxTimes (lastTimeBin );
64+
65+ // Now everything can get processed
66+ // Loop over all events
67+ for (int iEvent = 0 ; iEvent < nEntries ; ++ iEvent ) {
68+ std ::cout << iEvent + 1 << "/" << nEntries << std ::endl ;
69+ tree -> GetEntry (iEvent );
70+
71+ for (int i = 0 ; i < 36 ; i ++ ) {
72+ auto sector = digitizedSignal [i ];
73+ if (sector -> size () == 0 ) {
74+ continue ;
75+ }
76+ std ::cout << "Processing sector " << i << "\n" ;
77+
78+ clFinder -> loopOverSector (* sector , i );
79+ }
80+ // Fill Tree
81+ tClusters -> Fill ();
82+ clusters .clear ();
83+ }
84+ // Write Tree to file
85+ fOut -> Write ();
86+ fOut -> Close ();
87+ return ;
88+ }
89+
90+ int main ()
91+ {
92+ findKrBoxCluster ();
93+ return 0 ;
94+ }
0 commit comments