42 fSiliconHits(nullptr),
45 fSiliconTracks(nullptr),
58 if (
f.IsOpen() && !
f.IsZombie()) {
66 cout <<
"Num. of events to be used# " <<
dstChain->GetEntries() << endl;
79 UInt_t runId =
fHeader->GetRunId();
80 cout <<
"runId = " << runId << endl;
84 if (runId && runId < 10000) {
105 TClonesArray*
GEM =
new TClonesArray(
"InnerTrackerParams");
106 TClonesArray*
SILICON =
new TClonesArray(
"InnerTrackerParams");
108 for (Int_t iEvent = 0; iEvent < 2000; iEvent++) {
112 for (Int_t iHit = 0; iHit <
fGemHits->GetEntriesFast(); iHit++) {
115 new ((*GEM)[
GEM->GetEntriesFast()])
120 for (Int_t iHit = 0; iHit <
fSiliconHits->GetEntriesFast(); iHit++) {
123 new ((*SILICON)[
SILICON->GetEntriesFast()])
128 FillAcceptanceMaps(
GEM);
135void BmnEfficiency::FillAcceptanceMaps(TClonesArray* GEMs, TClonesArray* SILs) {
147 set <Double_t>*** x =
new set <Double_t>**[nStats];
148 set <Double_t>*** y =
new set <Double_t>**[nStats];
149 set <Double_t>*** z =
new set <Double_t>**[nStats];
151 for (Int_t iStat = 0; iStat < nStats; iStat++) {
152 x[iStat] =
new set <Double_t>*[nMods];
153 y[iStat] =
new set <Double_t>*[nMods];
154 z[iStat] =
new set <Double_t>*[nMods];
156 for (Int_t iMod = 0; iMod < nMods; iMod++) {
157 x[iStat][iMod] =
new set <Double_t>();
158 y[iStat][iMod] =
new set <Double_t>();
159 z[iStat][iMod] =
new set <Double_t>();
163 TClonesArray* arr = (!SILs) ? GEMs : SILs;
165 for (Int_t iStat = 0; iStat < nStats; iStat++)
166 for (Int_t iMod = 0; iMod < nMods; iMod++)
167 for (Int_t iEle = 0; iEle < arr->GetEntriesFast(); iEle++) {
170 x[iStat][iMod]->insert(g->
xyz().X());
171 y[iStat][iMod]->insert(g->
xyz().Y());
172 z[iStat][iMod]->insert(g->
xyz().Z());
178 for (Int_t iStat = 0; iStat < nStats; iStat++)
179 for (Int_t iMod = 0; iMod < nMods; iMod++) {
181 Double_t minX = *min_element(x[iStat][iMod]->begin(), x[iStat][iMod]->end());
182 Double_t maxX = *max_element(x[iStat][iMod]->begin(), x[iStat][iMod]->end());
184 Double_t minY = *min_element(y[iStat][iMod]->begin(), y[iStat][iMod]->end());
185 Double_t maxY = *max_element(y[iStat][iMod]->begin(), y[iStat][iMod]->end());
187 vector <Double_t> borders{minX, maxX, minY, maxY};
189 if (z[iStat][iMod]->size()) {
190 fStatZ[make_pair(iStat + shift, iMod)] = *z[iStat][iMod]->begin();
191 fStatAcceptance[make_pair(iStat + shift, iMod)] = borders;
196 for (Int_t iStat = 0; iStat < nStats; iStat++)
197 for (Int_t iMod = 0; iMod < nMods; iMod++) {
198 delete x[iStat][iMod];
199 delete y[iStat][iMod];
200 delete z[iStat][iMod];
233 if (
f.IsOpen() && !
f.IsZombie()) {
241 cout <<
"Num. of events to be used# " <<
dstChain->GetEntries() << endl;
254 UInt_t runId =
fHeader->GetRunId();
258 if (runId && runId < 10000) {
271 fField = fAna->GetField();
277 TClonesArray* effSilicon,
278 map <Int_t, vector <pair <Double_t, Double_t>>> gYr,
279 map <Int_t, vector <pair <Double_t, Double_t>>> sYr) {
284 auto silFirst = fStatZ.begin();
285 auto gemLast = fStatZ.rbegin();
288 Double_t zBegin = silFirst->second - 5.;
289 Double_t zEnd = gemLast->second + 5.;
291 Int_t nModsSilicon = 0;
296 auto gemFirst = next(fStatZ.begin(), nModsSilicon);
297 auto silLast = next(fStatZ.begin(), nModsSilicon - 1);
299 Double_t borderSilGem = .5 * (gemFirst->second + silLast->second);
301 gStyle->SetOptStat(0);
306 if (iEvent % 100000 == 0)
307 cout <<
"Event# " << iEvent << endl;
314 if (TMath::Abs(Vp->
GetZ()) > 6.)
318 for (Int_t iTrack = 0; iTrack <
fGlobTracks->GetEntriesFast(); iTrack++) {
321 if (TMath::Abs(track->
GetP()) < .5 || TMath::Abs(track->
GetP()) > 5.)
324 vector <BmnHit*> hits;
330 for (Int_t iHit = 0; iHit < silTrack->
GetNHits(); iHit++)
338 for (Int_t iHit = 0; iHit < gemTrack->
GetNHits(); iHit++)
345 for (
BmnHit* hit : hits) {
346 Double_t Z = hit->GetZ();
347 if (Z > zBegin && Z < zEnd)
355 Int_t nHitsPerSilicon = 0;
356 Int_t nHitsPerGem = 0;
358 for (
BmnHit* hit : hits) {
359 if (hit->GetZ() < borderSilGem)
365 if (nHitsPerSilicon < fNHitsSilicon || nHitsPerGem < fNHitsGem)
369 Double_t x = Vp->
GetX();
370 Double_t y = Vp->
GetY();
371 Double_t z = Vp->
GetZ();
377 FairTrackParam par = *first;
378 for (
BmnHit* hit : hits) {
392 Double_t xPredictedAtVp = par.GetX();
393 Double_t yPredictedAtVp = par.GetY();
395 const Double_t distCut = 2.;
396 Double_t distXY = TMath::Sqrt((xPredictedAtVp - x) * (xPredictedAtVp - x) + (yPredictedAtVp - y) * (yPredictedAtVp - y));
398 if (distXY > distCut)
402 pair <FairTrackParam, FairTrackParam> trackParams = make_pair(parPredicted, *track->
GetParamLast());
405 Bool_t hitsPerStation[nHitsMax];
406 for (Int_t iHit = 0; iHit < nHitsMax; iHit++)
407 hitsPerStation[iHit] = kFALSE;
410 for (
BmnHit* hit : hits) {
411 TString det = GetDetector(hit);
414 Int_t stat = hit->GetStation();
415 hitsPerStation[stat + shift] = kTRUE;
423 v.assign(hitsPerStation, hitsPerStation + nHitsMax);
435 fillEfficiency(std::move(input));
438 input1 = std::move(input);
440 input1.
det =
"SILICON";
445 fillEfficiency(std::move(input1));
450Bool_t BmnEfficiency::isVirtualHitInAcceptance(Int_t iHit, vector <BmnHit*> hits, pair <FairTrackParam, FairTrackParam> params, pair <Double_t, Double_t>& xyPred) {
452 Double_t Z = FindZ(iHit);
454 vector <BmnHit*> hitsBeforeCurrentZ;
456 for (
BmnHit* hit : hits) {
457 Double_t zHit = hit->GetZ();
462 hitsBeforeCurrentZ.push_back(hit);
465 for (
BmnHit* hit : hitsBeforeCurrentZ) {
479 Double_t xPred = params.first.GetX();
480 Double_t yPred = params.first.GetY();
482 xyPred.first = xPred;
483 xyPred.second = yPred;
485 for (
auto it : fStatAcceptance) {
486 Int_t stat = it.first.first;
487 Int_t mod = it.first.second;
489 Double_t xMin = it.second[0];
490 Double_t xMax = it.second[1];
491 Double_t yMin = it.second[2];
492 Double_t yMax = it.second[3];
494 if (xPred > xMin && xPred < xMax && yPred > yMin && yPred < yMax && (stat == iHit)) {
500 return (mod0 > -1) ? kTRUE : kFALSE;
504 const Int_t hitCut = (input.det.Contains(
"GEM") ? input.nGemCut : input.nSilCut);
508 Int_t nHitsPerDetector = 0;
510 auto itBegin = input.usedStats.begin();
511 auto itEnd = input.usedStats.end();
514 if (input.det.Contains(
"SILICON"))
515 for (
auto it = itBegin; it < itMiddle; it++) {
519 for (
auto it = itMiddle; it != itEnd; it++) {
524 if (!nHitsPerDetector)
527 for (Int_t iHit = input.sfIndices.first; iHit < input.sfIndices.second; iHit++) {
529 if (nHitsPerDetector == hitCut && input.usedStats.at(iHit))
532 if (input.usedStats.at(iHit) && nHitsPerDetector != hitCut) {
537 for (
BmnHit* hit : input.hits) {
538 if (!GetDetector(hit).Contains(input.det.Data()))
542 if (stat == (iHit + shift)) {
550 for (Int_t iCont = 0; iCont < input.eContainers->GetEntriesFast(); iCont++) {
553 if (effCont->
Detector() == input.det && effCont->
Station() == (iHit + shift)) {
561 eff->
efficiency(((input.flParams.second.GetQp() > 0.) ? 0 : 1),
"", input.det)->Fill(kTRUE, hit0->GetX(), hit0->GetY());
563 if (input.det.Contains(
"SILICON"))
564 eff->
efficiency(((input.flParams.second.GetQp() > 0.) ? 0 : 1),
"xP", input.det)->Fill(kTRUE, hit0->GetX(),
565 TMath::Abs(1. / input.flParams.first.GetQp()));
567 Int_t yBin = FindBin(hit0->GetY(), stat, ((input.det.Contains(
"GEM")) ? input.gPairMap : input.sPairMap));
569 eff->
efficiency4range(yBin, ((input.flParams.second.GetQp() > 0.) ? 0 : 1), input.det)->Fill(kTRUE, hit0->GetX());
573 pair <Double_t, Double_t> xyPred;
575 if (isVirtualHitInAcceptance(iHit, input.hits, input.flParams, xyPred)) {
576 Int_t yBin = FindBin(xyPred.second, iHit + shift, ((input.det.Contains(
"GEM")) ? input.gPairMap : input.sPairMap));
581 for (Int_t iCont = 0; iCont < input.eContainers->GetEntriesFast(); iCont++) {
584 if (effCont->
Detector() == input.det && effCont->
Station() == (iHit + shift)) {
592 eff->
efficiency(((input.flParams.second.GetQp() > 0.) ? 0 : 1),
"", input.det)->Fill(kFALSE, xyPred.first, xyPred.second);
594 if (input.det.Contains(
"SILICON"))
595 eff->
efficiency(((input.flParams.second.GetQp() > 0.) ? 0 : 1),
"xP", input.det)->Fill(kFALSE, xyPred.first,
596 TMath::Abs(1. / input.flParams.first.GetQp()));
598 eff->
efficiency4range(yBin, ((input.flParams.second.GetQp() > 0.) ? 0 : 1), input.det)->Fill(kFALSE, xyPred.first);
614 Double_t x = hit->GetX();
615 Double_t y = hit->GetY();
618 Bool_t isHitInside[nLayers];
620 for (Int_t iLayer = 0; iLayer < nLayers; iLayer++) {
625 if (isHitInside[0] && isHitInside[1])
627 else if (isHitInside[2] && isHitInside[3])
BmnKalmanFilter * fKalman
BmnNewFieldMap * fMagField
TClonesArray * fInnerHits
void Efficiency(TClonesArray *, TClonesArray *effSilicon, map< Int_t, vector< pair< Double_t, Double_t > > >, map< Int_t, vector< pair< Double_t, Double_t > > >)
BmnGemStripStationSet * gem
TClonesArray * fSiliconTracks
BmnSiliconStationSet * silicon
TClonesArray * fGemTracks
TClonesArray * fSiliconHits
TString GetGemZone(BmnHit *)
TClonesArray * fGlobTracks
void SetScale(Double_t factor)
Bool_t IsPointInsideStripLayer(Double_t x, Double_t y)
BmnGemStripLayer & GetStripLayer(Int_t num)
BmnGemStripStation * GetStation(Int_t station_num)
BmnGemStripModule * GetModule(Int_t module_num)
Int_t GetGemTrackIndex() const
Int_t GetSilTrackIndex() const
Short_t GetStation() const
BmnGemStripStationSet * GetGemGeometry()
BmnSiliconStationSet * GetSiliconGeometry()
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)
BmnSiliconStation * GetStation(Int_t station_num)
FairTrackParam * GetParamFirst()
Int_t GetHitIndex(Int_t iHit) const
FairTrackParam * GetParamLast()
TEfficiency * efficiency(Int_t qpBin=0, TString hType="", TString det="GEM")
TEfficiency * efficiency4range(Int_t range, Int_t qpBin=0, TString det="GEM")
static UniRun * GetRun(int period_number, int run_number)
get run from the database
double * GetFieldVoltage()
get field voltage of the current run