CbmRoot
CbmMcbm2019CheckDigisMuch.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 "CbmMuchBeamTimeDigi.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("CbmMcbm2019CheckDigisMuch") {}
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  <CbmMcbm2019CheckDigisMuchDataMember> = (<ClassPointer>*)
43  (rtdb->getContainer("<ContainerName>"));
44  */
45 }
46 
47 // ---- Init ----------------------------------------------------------
49 
50  // Digi Manager
53  fDigiMan->Init();
54 
55  // Get a pointer to the previous already existing data level
57  LOG(info) << "No MUCH digis found.";
58  }
59 
60  CreateHistos();
61 
62  return kSUCCESS;
63 }
64 
65 
67  Double_t dZoomDuration = (fuStopTs - fuStartTs) * fdTsLength;
68  fDigisPerAsicEvo = new TH2F("fDigisPerAsicEvo",
69  "Digis per Asic evo; Time [ ns ]; ASIC []",
70  dZoomDuration / 1000,
71  0,
72  dZoomDuration,
74  0,
75  kuMaxNbAsics);
76 
77  for (UInt_t uAsic = 0; uAsic < kuMaxNbAsics; ++uAsic)
78  for (UInt_t uChan = 0; uChan < kuNbChansAsic; ++uChan) {
79  fdLastMuchDigi[uAsic][uChan] = 0.0;
80  fdLastMuchDigiPulser[uAsic][uChan] = 0.0;
81  } // loop on channel and asic
82 
83  fSameChanDigisDistEvo = new TH2F(
84  "fSameChanDigisDistEvo",
85  "Time dist of digis in same chan evo; Time [ ns ]; Same chan dist [ ns ]",
86  5000,
87  0,
88  500000.,
89  1000,
90  0.,
91  10000.);
92 
94  new TH2F("fDigisPerChanEvo",
95  "Time dist of digis in same chan evo; Time [ ns ]; Channel [ ]",
96  5000,
97  0,
98  5000.,
100  0.,
102 
103  std::cout << Form("TS with jump %5u, first TS time off %12.0f, start TS %5u "
104  "stop TS %5u, TS length %9.0f Start time %12.0f",
105  fuTsJump,
107  fuStartTs,
108  fuStopTs,
109  fdTsLength,
110  fdStartTime)
111  << std::endl;
112 }
113 // ---- ReInit -------------------------------------------------------
114 InitStatus CbmMcbm2019CheckDigisMuch::ReInit() { return kSUCCESS; }
115 
116 // ---- Exec ----------------------------------------------------------
117 void CbmMcbm2019CheckDigisMuch::Exec(Option_t* /*option*/) {
118  LOG(debug) << "executing TS " << fNrTs;
119 
120  if (0 < fNrTs && 0 == fNrTs % 1000)
121  LOG(info) << Form("Processing TS %6d", fNrTs);
122 
124  if (fNrTs < fuStartTs || fuStopTs < fNrTs) {
125  fNrTs++;
126  return;
127  } // if( fNrTs < fuStartTs || fuStopTs < fNrTs )
128 
129  Int_t nrMuchDigis = fDigiMan->GetNofDigis(ECbmModuleId::kMuch);
130  LOG(debug) << GetName() << ": MuchDigis: " << nrMuchDigis;
131 
132  for (Int_t iMuch = 0; iMuch < nrMuchDigis; ++iMuch) {
133 
134  const CbmMuchBeamTimeDigi* Digi = fDigiMan->Get<CbmMuchBeamTimeDigi>(iMuch);
135 
136  Double_t dTime = Digi->GetTime();
137  Double_t dAdc = Digi->GetAdc();
138  UInt_t uAsic = Digi->GetNxId();
139  UInt_t uChan = Digi->GetNxCh();
140 
141  Double_t dTimeSinceStart = dTime - fdStartTime;
142  fDigisPerAsicEvo->Fill(dTimeSinceStart, uAsic);
143 
144  if (0 == iMuch)
145  std::cout << Form("Much first hit in TS %5d: asic %2u chan %3u time "
146  "%12.0f T0 time %12.0f check time %12.0f ADC %2.0f",
147  fNrTs,
148  uAsic,
149  uChan,
150  dTime,
151  dTime - fdFirstTsOffs,
152  dTimeSinceStart,
153  dAdc)
154  << std::endl;
155 
156  if (fdDigiDistStart < dTimeSinceStart && dTimeSinceStart < fdDigiDistStop) {
157  // std::cout << Form( "Much hit in TS %5d: asic %2u chan %3u T0 time %12.0f ADC %2.0f",
158  // fNrTs, uAsic, uChan, (dTimeSinceStart - fdDigiDistStart), dAdc )
159  // << std::endl;
160  Double_t dTimeDistLastDigi =
161  dTimeSinceStart - fdLastMuchDigi[uAsic][uChan];
162  fSameChanDigisDistEvo->Fill(dTimeSinceStart - fdDigiDistStart,
163  dTimeDistLastDigi < 10000 ? dTimeDistLastDigi
164  : 9999);
165 
166  fDigisPerChanEvo->Fill(dTimeSinceStart - fdDigiDistStart,
167  uAsic * kuNbChansAsic + uChan);
168  }
169  /*
170  if( 0.0 == fdLastMuchDigi[ uAsic ][ uChan ] )
171  std::cout << Form( "Much first hit in TS %5d: asic %2u chan %3u T0 time %12.0f ADC %2.0f",
172  fNrTs, uAsic, uChan, dTime - fdFirstTsOffs, dAdc )
173  << std::endl;
174 */
175  fdLastMuchDigi[uAsic][uChan] = dTimeSinceStart;
176 
177  // if( 9 != uAsic )
178  if (9 != uAsic || uChan < 63) continue;
179  if (fuMaxAdcPulserMuch < Digi->GetAdc()
180  || Digi->GetAdc() < fuMinAdcPulserMuch)
181  continue;
182 
183  std::cout << Form("Much pulser in TS %5d: chan %3u T0 time %12.0f time "
184  "start %12.0f ADC %2.0f dt %12.0f",
185  fNrTs,
186  uChan,
187  dTime,
188  dTimeSinceStart,
189  dAdc,
190  dTime - fdLastMuchDigiPulser[uAsic][uChan])
191  << std::endl;
192  fdLastMuchDigiPulser[uAsic][uChan] = dTime;
193  } // for (Int_t iMuch = 0; iMuch < nrMuchDigis; ++iMuch)
194 
195  fNrTs++;
196 }
197 
198 // ---- Finish --------------------------------------------------------
200 
202  TFile* old = gFile;
203  TFile* outfile = TFile::Open(fOutFileName, "RECREATE");
204 
205  fDigisPerAsicEvo->Write();
206  fSameChanDigisDistEvo->Write();
207  fDigisPerChanEvo->Write();
208 
209  outfile->Close();
210  delete outfile;
211 
212  gFile = old;
213 }
214 
CbmMcbm2019CheckDigisMuch::fuTsJump
UInt_t fuTsJump
Definition: CbmMcbm2019CheckDigisMuch.h:89
CbmMcbm2019CheckDigisMuch::CreateHistos
void CreateHistos()
Definition: CbmMcbm2019CheckDigisMuch.cxx:66
CbmMcbm2019CheckDigisMuch::fdTsLength
Double_t fdTsLength
Definition: CbmMcbm2019CheckDigisMuch.h:93
CbmMuchDigi::GetTime
virtual Double_t GetTime() const
Definition: CbmMuchDigi.h:78
CbmMcbm2019CheckDigisMuch::Exec
virtual void Exec(Option_t *)
Definition: CbmMcbm2019CheckDigisMuch.cxx:117
CbmMcbm2019CheckDigisMuch::~CbmMcbm2019CheckDigisMuch
~CbmMcbm2019CheckDigisMuch()
Definition: CbmMcbm2019CheckDigisMuch.cxx:33
CbmMcbm2019CheckDigisMuch::fuStartTs
UInt_t fuStartTs
Definition: CbmMcbm2019CheckDigisMuch.h:91
CbmMcbm2019CheckDigisMuch::fNrTs
UInt_t fNrTs
Definition: CbmMcbm2019CheckDigisMuch.h:86
CbmMcbm2019CheckDigisMuch::fdStartTime
Double_t fdStartTime
Definition: CbmMcbm2019CheckDigisMuch.h:94
CbmDigiManager::Init
InitStatus Init()
Initialisation.
Definition: CbmDigiManager.cxx:71
CbmMuchBeamTimeDigi
Definition: CbmMuchBeamTimeDigi.h:29
CbmMuchDigi::GetAdc
UShort_t GetAdc() const
Definition: CbmMuchDigi.h:74
CbmMcbm2019CheckDigisMuch::fdLastMuchDigi
Double_t fdLastMuchDigi[kuMaxNbAsics][kuNbChansAsic]
Definition: CbmMcbm2019CheckDigisMuch.h:102
CbmMcbm2019CheckDigisMuch::fuMinAdcPulserMuch
UInt_t fuMinAdcPulserMuch
Definition: CbmMcbm2019CheckDigisMuch.h:99
CbmMcbm2019CheckDigisMuch::fOutFileName
TString fOutFileName
Definition: CbmMcbm2019CheckDigisMuch.h:107
CbmDigiManager::GetNofDigis
static Int_t GetNofDigis(ECbmModuleId systemId)
Definition: CbmDigiManager.cxx:62
CbmMcbm2019CheckDigisMuch::fdDigiDistStart
Double_t fdDigiDistStart
Definition: CbmMcbm2019CheckDigisMuch.h:96
CbmDigiManager::UseMuchBeamTimeDigi
void UseMuchBeamTimeDigi(Bool_t choice=kTRUE)
Use CbmMuchBeamTimeDigi instead of CbmMuchDigi for MUCH.
Definition: CbmDigiManager.h:130
CbmDigiManager::IsPresent
static Bool_t IsPresent(ECbmModuleId systemId)
Presence of a digi branch.
Definition: CbmDigiManager.cxx:112
CbmMcbm2019CheckDigisMuch::fDigisPerAsicEvo
TH2 * fDigisPerAsicEvo
Definition: CbmMcbm2019CheckDigisMuch.h:101
CbmDigiManager::Instance
static CbmDigiManager * Instance()
Static instance.
Definition: CbmDigiManager.h:93
CbmMcbm2019CheckDigisMuch::fDigisPerChanEvo
TH2 * fDigisPerChanEvo
Definition: CbmMcbm2019CheckDigisMuch.h:105
CbmMuchBeamTimeDigi::GetNxCh
Int_t GetNxCh() const
Definition: CbmMuchBeamTimeDigi.h:51
CbmMcbm2019CheckDigisMuch::fdLastMuchDigiPulser
Double_t fdLastMuchDigiPulser[kuMaxNbAsics][kuNbChansAsic]
Definition: CbmMcbm2019CheckDigisMuch.h:103
CbmMcbm2019CheckDigisMuch::fDigiMan
CbmDigiManager * fDigiMan
Definition: CbmMcbm2019CheckDigisMuch.h:85
CbmDigiManager::Get
const Digi * Get(Int_t index) const
Get a digi object.
Definition: CbmDigiManager.h:52
CbmMcbm2019CheckDigisMuch::CbmMcbm2019CheckDigisMuch
CbmMcbm2019CheckDigisMuch()
Definition: CbmMcbm2019CheckDigisMuch.cxx:29
CbmMcbm2019CheckDigisMuch::ReInit
virtual InitStatus ReInit()
Definition: CbmMcbm2019CheckDigisMuch.cxx:114
CbmMuchBeamTimeDigi.h
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmMcbm2019CheckDigisMuch::Finish
virtual void Finish()
Definition: CbmMcbm2019CheckDigisMuch.cxx:199
CbmMcbm2019CheckDigisMuch::WriteHistos
void WriteHistos()
Definition: CbmMcbm2019CheckDigisMuch.cxx:201
CbmMcbm2019CheckDigisMuch.h
CbmMcbm2019CheckDigisMuch::Init
virtual InitStatus Init()
Definition: CbmMcbm2019CheckDigisMuch.cxx:48
CbmMcbm2019CheckDigisMuch
Definition: CbmMcbm2019CheckDigisMuch.h:22
CbmDigiManager.h
CbmMcbm2019CheckDigisMuch::SetParContainers
virtual void SetParContainers()
Definition: CbmMcbm2019CheckDigisMuch.cxx:36
ECbmModuleId::kMuch
@ kMuch
Muon detection system.
CbmMcbm2019CheckDigisMuch::fuStopTs
UInt_t fuStopTs
Definition: CbmMcbm2019CheckDigisMuch.h:92
CbmMcbm2019CheckDigisMuch::fdDigiDistStop
Double_t fdDigiDistStop
Definition: CbmMcbm2019CheckDigisMuch.h:97
CbmMuchBeamTimeDigi::GetNxId
Int_t GetNxId() const
Definition: CbmMuchBeamTimeDigi.h:50
CbmMcbm2019CheckDigisMuch::kuNbChansAsic
static const UInt_t kuNbChansAsic
Definition: CbmMcbm2019CheckDigisMuch.h:83
CbmMcbm2019CheckDigisMuch::kuMaxNbAsics
static const UInt_t kuMaxNbAsics
Definition: CbmMcbm2019CheckDigisMuch.h:82
CbmMcbm2019CheckDigisMuch::fdFirstTsOffs
Double_t fdFirstTsOffs
Definition: CbmMcbm2019CheckDigisMuch.h:90
CbmMcbm2019CheckDigisMuch::fSameChanDigisDistEvo
TH2 * fSameChanDigisDistEvo
Definition: CbmMcbm2019CheckDigisMuch.h:87