4mAnal(nullptr), fAna(nullptr), fGeomFile(
""), fNFiles(0) {
7 fAna =
new FairRunAna();
10void BmnDataAnalRun7::resetHistos() {
13 for (Int_t iRes = 0; iRes < nRes; iRes++) {
16 hResSil[iRes][iStat][iMod]->Reset();
19 for (Int_t iMod = 0; iMod <
gem->
GetStation(iStat)->GetNModules(); iMod++)
20 hResGem[iRes][iStat][iMod]->Reset();
24void BmnDataAnalRun7::writeHistos(TString out) {
27 TFile*
f =
new TFile(out.Data(),
"recreate");
28 for (Int_t iRes = 0; iRes < nRes; iRes++) {
31 DoNormalization(hResSil[iRes][iStat][iMod]);
32 hResSil[iRes][iStat][iMod]->Write();
36 for (Int_t iMod = 0; iMod <
gem->
GetStation(iStat)->GetNModules(); iMod++) {
37 DoNormalization(hResGem[iRes][iStat][iMod]);
38 hResGem[iRes][iStat][iMod]->Write();
45void BmnDataAnalRun7::calcResiduals(TString dst) {
51 cout <<
"Processing file# " << dst << endl;
56 if (iEvent % 1000 == 0)
57 cout <<
"Event# " << iEvent << endl;
61 Double_t zVp = Vp->
GetZ();
64 if (TMath::Abs(zVp) > 6. || nTracks < 2)
68 for (Int_t iTrack = 0; iTrack <
fGlobTracks->GetEntriesFast(); iTrack++) {
82 for (Int_t iHit = 0; iHit < silTrack->
GetNHits(); iHit++) {
92 for (Int_t iHit = 0; iHit < gemTrack->
GetNHits(); iHit++) {
99 for (
auto it = hits.begin(); it != hits.end(); it++) {
105 Double_t Z = hit.GetZ();
106 TString det = (Z > 30.) ?
"GEM" :
"SILICON";
108 Double_t xOrig, yOrig = 0.;
109 doKalman(track, Z, xOrig, yOrig);
112 vector <BmnHit> hits0;
114 for (
auto it1 = hits.begin(); it1 != hits.end(); it1++) {
118 hits0.push_back(*it1);
122 Double_t xUpdated, yUpdated = 0.;
123 doKalman(track, hits0, Z, xUpdated, yUpdated);
126 TH1F**** h = det.Contains(
"GEM") ? hResGem : hResSil;
128 h[0][stat][mod]->Fill(xOrig - xUpdated);
129 h[1][stat][mod]->Fill(yOrig - yUpdated);
138 const Int_t nRes = 2;
140 hResGem =
new TH1F***[nRes];
141 hResSil =
new TH1F***[nRes];
143 for (Int_t iRes = 0; iRes < nRes; iRes++) {
144 TString res = (iRes == 0) ? TString::Format(
"X").Data() : TString::Format(
"Y").Data();
152 hResSil[iRes][iStat][iMod] =
new TH1F(Form(
"SILICON, Res %s, Stat %d, Mod %d", res.Data(), iStat, iMod),
153 Form(
"SILICON, Res %s, Stat %d, Mod %d", res.Data(), iStat, iMod), 200, -1., +1.);
161 for (Int_t iMod = 0; iMod <
gem->
GetStation(iStat)->GetNModules(); iMod++)
162 hResGem[iRes][iStat][iMod] =
new TH1F(Form(
"GEM, Res %s, Stat %d, Mod %d", res.Data(), iStat, iMod),
163 Form(
"GEM, Res %s, Stat %d, Mod %d", res.Data(), iStat, iMod), 200, -1., +1.);
168 if (fGeomFile.IsNull())
169 Fatal(
"BmnDataAnalRun7::doResidAnal()",
"No geometry file passed!!!");
171 TGeoManager::Import(fGeomFile.Data());
173 vector <TString> fList;
176 if (!fMcDataPath.IsNull()) {
182 for (
auto itFile = fList.begin(); itFile != fList.end(); itFile++) {
183 if (fNFiles && distance(fList.begin(), itFile) == fNFiles)
186 calcResiduals(*itFile);
189 writeHistos(
"residMc.root");
199 fNFiles = fList.size();
203 for (
auto itFile = fList.begin(); itFile != fList.end(); itFile++) {
204 if (fNFiles && distance(fList.begin(), itFile) == fNFiles)
207 calcResiduals(*itFile);
211 writeHistos(TString::Format(
"residData_%s.root", fTarget.Data()));
214void BmnDataAnalRun7::doKalman(
BmnGlobalTrack* track, Double_t Z, Double_t& xOrig, Double_t& yOrig) {
218 FairTrackParam par = *first;
226void BmnDataAnalRun7::doKalman(
BmnGlobalTrack* track, vector <BmnHit> hits, Double_t Z, Double_t& xUpdated, Double_t& yUpdated) {
231 FairTrackParam par = *first;
245 xUpdated = par.GetX();
246 yUpdated = par.GetY();
250void BmnDataAnalRun7::DoNormalization(TH1F* h) {
251 if (h->GetEntries() == 0)
255 Double_t contentAll = 0.;
257 for (Int_t iBin = 1; iBin < h->GetNbinsX() + 1; iBin++)
258 contentAll += h->GetBinContent(iBin);
261 for (Int_t iBin = 1; iBin < h->GetNbinsX() + 1; iBin++) {
262 h->SetBinContent(iBin, h->GetBinContent(iBin) / contentAll);
263 h->SetBinError(iBin, 0.);
266 h->GetYaxis()->SetRangeUser(0., 1.1 * h->GetMaximum());
BmnKalmanFilter * fKalman
BmnGemStripStationSet * gem
TClonesArray * fSiliconTracks
BmnSiliconStationSet * silicon
TClonesArray * fGemTracks
TClonesArray * fSiliconHits
TClonesArray * fGlobTracks
BmnGemStripStation * GetStation(Int_t station_num)
Int_t GetGemTrackIndex() const
Int_t GetSilTrackIndex() const
Short_t GetStation() const
BmnStatus TGeoTrackPropagate(FairTrackParam *par, Double_t zOut, Int_t pdg, vector< Double_t > *F, Double_t *length, Bool_t isField)
BmnStatus Update(FairTrackParam *par, const BmnHit *hit, Double_t &chiSq)
vector< TString > createFilelist()
void SetTarget(TString t)
vector< TString > GetFileList()
BmnSiliconStation * GetStation(Int_t station_num)
FairTrackParam * GetParamFirst()
Int_t GetHitIndex(Int_t iHit) const
FairTrackParam * GetParamLast()