CbmRoot
CbmMcbm2019CheckDigisSts.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
9 
10 #include "CbmDigiManager.h"
11 #include "CbmStsDigi.h"
12 
13 #include "FairLogger.h"
14 #include "FairRootManager.h"
15 #include "FairRunOnline.h"
16 
17 #include "TClonesArray.h"
18 #include "TH1.h"
19 #include "TH2.h"
20 #include "THttpServer.h"
21 #include <TFile.h>
22 
23 #include <iomanip>
24 #include <iostream>
25 using std::fixed;
26 using std::setprecision;
27 
28 // ---- Default constructor -------------------------------------------
30  : FairTask("CbmMcbm2019CheckDigisSts") {}
31 
32 // ---- Destructor ----------------------------------------------------
34 
35 // ---- Initialisation ----------------------------------------------
37  // Load all necessary parameter containers from the runtime data base
38  /*
39  FairRunAna* ana = FairRunAna::Instance();
40  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
41 
42  <CbmMcbm2019CheckDigisStsDataMember> = (<ClassPointer>*)
43  (rtdb->getContainer("<ContainerName>"));
44  */
45 }
46 
47 // ---- Init ----------------------------------------------------------
49  // Digi Manager
51  fDigiMan->Init();
52 
53  // Get a pointer to the previous already existing data level
55  LOG(info) << "No TClonesArray with STS digis found.";
56  }
57 
58  CreateHistos();
59 
60  return kSUCCESS;
61 }
62 
63 
65  Double_t dZoomDuration = (fuStopTs - fuStartTs) * fdTsLength;
66  fDigisPerAsicEvo = new TH2F("fDigisPerAsicEvo",
67  "Digis per Asic evo; Time [ ns ]; ASIC []",
68  dZoomDuration / 1000,
69  0,
70  dZoomDuration,
72  0,
73  kuMaxNbAsics);
74 
75  for (UInt_t uAsic = 0; uAsic < kuMaxNbAsics; ++uAsic)
76  for (UInt_t uChan = 0; uChan < kuNbChansAsic; ++uChan) {
77  fdLastStsDigi[uAsic][uChan] = 0.0;
78  fdLastStsDigiPulser[uAsic][uChan] = 0.0;
79  } // loop on channel and asic
80 
81  fSameChanDigisDistEvo = new TH2F(
82  "fSameChanDigisDistEvo",
83  "Time dist of digis in same chan evo; Time [ ns ]; Same chan dist [ ns ]",
84  5000,
85  0,
86  500000.,
87  1000,
88  0.,
89  10000.);
90 
91  std::cout << Form("TS with jump %5u, first TS time off %12.0f, start TS %5u "
92  "stop TS %5u, TS length %9.0f Start time %12.0f",
93  fuTsJump,
95  fuStartTs,
96  fuStopTs,
97  fdTsLength,
99  << std::endl;
100 }
101 // ---- ReInit -------------------------------------------------------
102 InitStatus CbmMcbm2019CheckDigisSts::ReInit() { return kSUCCESS; }
103 
104 // ---- Exec ----------------------------------------------------------
105 void CbmMcbm2019CheckDigisSts::Exec(Option_t* /*option*/) {
106  LOG(debug) << "executing TS " << fNrTs;
107 
108  if (0 < fNrTs && 0 == fNrTs % 1000)
109  LOG(info) << Form("Processing TS %6d", fNrTs);
110 
112  if (fNrTs < fuStartTs || fuStopTs < fNrTs) {
113  fNrTs++;
114  return;
115  } // if( fNrTs < fuStartTs || fuStopTs < fNrTs )
116 
117  Int_t nrStsDigis = fDigiMan->GetNofDigis(ECbmModuleId::kSts);
118  LOG(debug) << "StsDigis: " << nrStsDigis;
119 
120 
121  for (Int_t iSts = 0; iSts < nrStsDigis; ++iSts) {
122 
123  const CbmStsDigi* Digi = fDigiMan->Get<CbmStsDigi>(iSts);
124 
125  Double_t dTime = Digi->GetTime();
126  Double_t dAdc = Digi->GetCharge();
127  UInt_t uChan = Digi->GetChannel();
128  UInt_t uAsic = uChan / kuNbChansAsic;
129  uChan %= kuNbChansAsic;
130 
131  Double_t dTimeSinceStart = dTime - fdStartTime;
132  fDigisPerAsicEvo->Fill(dTimeSinceStart, uAsic);
133 
134  if (0 == iSts)
135  std::cout << Form("Much first hit in TS %5d: asic %2u chan %3u time "
136  "%12.0f T0 time %12.0f check time %12.0f ADC %2.0f",
137  fNrTs,
138  uAsic,
139  uChan,
140  dTime,
141  dTime - fdFirstTsOffs,
142  dTimeSinceStart,
143  dAdc)
144  << std::endl;
145 
146  if (fdDigiDistStart < dTimeSinceStart && dTimeSinceStart < fdDigiDistStop) {
147  // std::cout << Form( "Sts hit in TS %5d: asic %2u chan %3u T0 time %12.0f ADC %2.0f",
148  // fNrTs, uAsic, uChan, (dTimeSinceStart - fdDigiDistStart), dAdc )
149  // << std::endl;
150  Double_t dTimeDistLastDigi =
151  dTimeSinceStart - fdLastStsDigi[uAsic][uChan];
152  fSameChanDigisDistEvo->Fill(dTimeSinceStart - fdDigiDistStart,
153  dTimeDistLastDigi < 10000 ? dTimeDistLastDigi
154  : 9999);
155  }
156  /*
157  if( 0.0 == fdLastStsDigi[ uAsic ][ uChan ] )
158  std::cout << Form( "Sts first hit in TS %5d: asic %2u chan %3u T0 time %12.0f ADC %2.0f",
159  fNrTs, uAsic, uChan, dTime - fdFirstTsOffs, dAdc )
160  << std::endl;
161 */
162  fdLastStsDigi[uAsic][uChan] = dTimeSinceStart;
163 
164  // if( 9 != uAsic )
165  if (9 != uAsic || uChan < 63) continue;
166  if (fuMaxAdcPulserSts < Digi->GetCharge()
167  || Digi->GetCharge() < fuMinAdcPulserSts)
168  continue;
169 
170  std::cout << Form("Sts pulser in TS %5d: chan %3u T0 time %12.0f time "
171  "start %12.0f ADC %2.0f dt %12.0f",
172  fNrTs,
173  uChan,
174  dTime,
175  dTimeSinceStart,
176  dAdc,
177  dTime - fdLastStsDigiPulser[uAsic][uChan])
178  << std::endl;
179  fdLastStsDigiPulser[uAsic][uChan] = dTime;
180  } // for (Int_t iSts = 0; iSts < nrStsDigis; ++iSts)
181 
182  fNrTs++;
183 }
184 
185 // ---- Finish --------------------------------------------------------
187 
189  TFile* old = gFile;
190  TFile* outfile = TFile::Open(fOutFileName, "RECREATE");
191 
192  fDigisPerAsicEvo->Write();
193  fSameChanDigisDistEvo->Write();
194 
195  outfile->Close();
196  delete outfile;
197 
198  gFile = old;
199 }
200 
CbmMcbm2019CheckDigisSts::fdTsLength
Double_t fdTsLength
Definition: CbmMcbm2019CheckDigisSts.h:92
CbmMcbm2019CheckDigisSts::kuMaxNbAsics
static const UInt_t kuMaxNbAsics
Definition: CbmMcbm2019CheckDigisSts.h:81
CbmMcbm2019CheckDigisSts::fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmMcbm2019CheckDigisSts.h:84
CbmDigiManager::Init
InitStatus Init()
Initialisation.
Definition: CbmDigiManager.cxx:71
CbmMcbm2019CheckDigisSts::fdLastStsDigiPulser
Double_t fdLastStsDigiPulser[kuMaxNbAsics][kuNbChansAsic]
Definition: CbmMcbm2019CheckDigisSts.h:102
CbmDigiManager::GetNofDigis
static Int_t GetNofDigis(ECbmModuleId systemId)
Definition: CbmDigiManager.cxx:62
CbmMcbm2019CheckDigisSts::fdLastStsDigi
Double_t fdLastStsDigi[kuMaxNbAsics][kuNbChansAsic]
Definition: CbmMcbm2019CheckDigisSts.h:101
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
CbmMcbm2019CheckDigisSts
Definition: CbmMcbm2019CheckDigisSts.h:22
CbmDigiManager::Instance
static CbmDigiManager * Instance()
Static instance.
Definition: CbmDigiManager.h:93
CbmMcbm2019CheckDigisSts::fuTsJump
UInt_t fuTsJump
Definition: CbmMcbm2019CheckDigisSts.h:88
CbmStsDigi.h
CbmMcbm2019CheckDigisSts::~CbmMcbm2019CheckDigisSts
~CbmMcbm2019CheckDigisSts()
Definition: CbmMcbm2019CheckDigisSts.cxx:33
CbmMcbm2019CheckDigisSts::fuMinAdcPulserSts
UInt_t fuMinAdcPulserSts
Definition: CbmMcbm2019CheckDigisSts.h:98
CbmDigiManager::Get
const Digi * Get(Int_t index) const
Get a digi object.
Definition: CbmDigiManager.h:52
CbmMcbm2019CheckDigisSts::fdStartTime
Double_t fdStartTime
Definition: CbmMcbm2019CheckDigisSts.h:93
CbmMcbm2019CheckDigisSts::fuStopTs
UInt_t fuStopTs
Definition: CbmMcbm2019CheckDigisSts.h:91
CbmMcbm2019CheckDigisSts::fSameChanDigisDistEvo
TH2 * fSameChanDigisDistEvo
Definition: CbmMcbm2019CheckDigisSts.h:86
CbmStsDigi::GetTime
Double_t GetTime() const
Definition: CbmStsDigi.h:83
CbmMcbm2019CheckDigisSts::fDigisPerAsicEvo
TH2 * fDigisPerAsicEvo
Definition: CbmMcbm2019CheckDigisSts.h:100
CbmMcbm2019CheckDigisSts::fOutFileName
TString fOutFileName
Definition: CbmMcbm2019CheckDigisSts.h:104
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMcbm2019CheckDigisSts::WriteHistos
void WriteHistos()
Definition: CbmMcbm2019CheckDigisSts.cxx:188
CbmMcbm2019CheckDigisSts::fdDigiDistStop
Double_t fdDigiDistStop
Definition: CbmMcbm2019CheckDigisSts.h:96
CbmStsDigi
Data class for a single-channel message in the STS.
Definition: CbmStsDigi.h:29
CbmMcbm2019CheckDigisSts::CbmMcbm2019CheckDigisSts
CbmMcbm2019CheckDigisSts()
Definition: CbmMcbm2019CheckDigisSts.cxx:29
CbmStsDigi::GetCharge
Double_t GetCharge() const
Definition: CbmStsDigi.h:71
CbmMcbm2019CheckDigisSts::kuNbChansAsic
static const UInt_t kuNbChansAsic
Definition: CbmMcbm2019CheckDigisSts.h:82
CbmMcbm2019CheckDigisSts::fNrTs
UInt_t fNrTs
Definition: CbmMcbm2019CheckDigisSts.h:85
CbmMcbm2019CheckDigisSts::Exec
virtual void Exec(Option_t *)
Definition: CbmMcbm2019CheckDigisSts.cxx:105
CbmMcbm2019CheckDigisSts::fdDigiDistStart
Double_t fdDigiDistStart
Definition: CbmMcbm2019CheckDigisSts.h:95
CbmMcbm2019CheckDigisSts::fdFirstTsOffs
Double_t fdFirstTsOffs
Definition: CbmMcbm2019CheckDigisSts.h:89
CbmMcbm2019CheckDigisSts::Init
virtual InitStatus Init()
Definition: CbmMcbm2019CheckDigisSts.cxx:48
CbmDigiManager.h
CbmMcbm2019CheckDigisSts::fuStartTs
UInt_t fuStartTs
Definition: CbmMcbm2019CheckDigisSts.h:90
CbmMcbm2019CheckDigisSts::CreateHistos
void CreateHistos()
Definition: CbmMcbm2019CheckDigisSts.cxx:64
CbmMcbm2019CheckDigisSts::Finish
virtual void Finish()
Definition: CbmMcbm2019CheckDigisSts.cxx:186
ECbmModuleId::kSts
@ kSts
Silicon Tracking System.
CbmMcbm2019CheckDigisSts::ReInit
virtual InitStatus ReInit()
Definition: CbmMcbm2019CheckDigisSts.cxx:102
CbmMcbm2019CheckDigisSts::SetParContainers
virtual void SetParContainers()
Definition: CbmMcbm2019CheckDigisSts.cxx:36
CbmStsDigi::GetChannel
UShort_t GetChannel() const
Channel number in module @value Channel number.
Definition: CbmStsDigi.h:59
CbmMcbm2019CheckDigisSts.h