58 FairRootManager* ioman = FairRootManager::Instance();
60 cout <<
"-E- BmnGemFastDigitize::Init: "
61 <<
"RootManager not instantiated!" << endl;
66 fPoints = (TClonesArray*) ioman->GetObject(
"StsPoint");
71 fMCTracks = (TClonesArray*) ioman->GetObject(
"MCTrack");
74 if (gSystem->Exec(
"du -s clusLib")) {
75 LOG(fatal) <<
" !!! No clusLib directory found - exit !!!";
81 ifstream fin(
"clusLib/file_list.txt");
85 const Int_t nbinsx = 29, nbinsy = 5;
86 Double_t xlim[nbinsx] = {-72.5, 72.5};
87 Double_t ylim[nbinsy] = {-25, 25};
88 fhInd =
new TH2I(
"hInd",
"",nbinsx,xlim[0],xlim[1],nbinsy,ylim[0],ylim[1]);
89 fhInd->StatOverflows(kTRUE);
99 Int_t ithx = TString(fileName(12,2)).Atoi(), ithy = TString(fileName(18,2)).Atoi();
100 if (fileName(11) ==
'm') ithx = -ithx;
101 if (fileName(17) ==
'm') ithy = -ithy;
114 TFile *file = TFile::Open(fileName);
115 TTree *clus = (TTree*) file->Get(
"clus");
118 TH2I *hXY = (TH2I*) file->Get(
"hXY");
119 hXY = (TH2I*) hXY->Clone(hname);
120 Int_t indXY = fhInd->Fill(ithx,ithy);
121 fHistMap[indXY] = hXY;
122 fTreeMap[indXY] = clus;
124 clus->SetBranchStatus(
"*",0);
125 clus->SetBranchStatus(
"qtot*",1);
126 clus->SetBranchStatus(
"ibeg*",1);
127 clus->SetBranchStatus(
"strin*",1);
128 clus->SetBranchStatus(
"dpitin*",1);
129 clus->SetBranchStatus(
"strout*",1);
130 clus->SetBranchStatus(
"cog*",1);
131 clus->SetBranchStatus(
"digis*",1);
138 TCut cut0(
"abs(ibeg[0]-237)<5&&strout[0]==244");
139 TCut cut1(
"abs(ibeg[1]-252)<5&&strout[1]==259");
141 if (file->Get(
"CUT")) cut = *((TCut*)file->Get(
"CUT"));
143 TEntryList *entryList = NULL;
144 clus->Draw(
">>entryList",cut,
"entrylist",9000000000);
145 entryList = (TEntryList*) gDirectory->Get(
"entryList");
146 clus->SetEntryList(entryList);
147 cout <<
" xxxxxx " << fileName <<
" " << entryList->GetN() <<
" " << ithx <<
" " << ithy <<
" " << indXY << endl;
149 fvDig0 = &fvDigis[0];
150 fvDig1 = &fvDigis[1];
152 clus->SetBranchAddress(
"qtot[2]",&fQtot);
153 clus->SetBranchAddress(
"ibeg[2]",&fIbeg);
154 clus->SetBranchAddress(
"strin[2]",&fStrin);
155 clus->SetBranchAddress(
"dpitin[2]",&fDpitin);
156 clus->SetBranchAddress(
"strout[2]",&fStrout);
157 clus->SetBranchAddress(
"cog[2]",&fCog);
158 clus->SetBranchAddress(
"digis0", &fvDig0);
159 clus->SetBranchAddress(
"digis1", &fvDig1);
161 Int_t entries = entryList->GetN();
162 entries = TMath::Min(10000,entries);
163 map<Int_t,Int_t> strin[2];
164 std::multimap<Float_t,Int_t> mmm;
165 fXYmap[0][indXY] = mmm;
166 fXYmap[1][indXY] = mmm;
168 for (Int_t j = 0; j < entries; ++j) {
169 Int_t treeEn = entryList->GetEntry(j);
170 clus->GetEntry(treeEn);
173 for (Int_t side = 0; side < 2; ++side) {
174 fXYmap[side][indXY].insert(pair<Float_t,Int_t>(fCog[side],treeEn));
175 if (strin[side].find(fStrin[side]) == strin[side].end()) strin[side][fStrin[side]] = 0;
176 ++strin[side][fStrin[side]];
181 for (Int_t side = 0; side < 2; ++side) {
182 map<Int_t,Int_t>::iterator it = strin[side].begin();
183 fStrRef[side][indXY] = it->first;
184 Int_t maxStrip = it->second;
186 for ( ; it != strin[side].end(); ++it) {
187 if (it->second > maxStrip) {
188 maxStrip = it->second;
189 fStrRef[side][indXY] = it->first;
197 cout <<
"-I- BmnGemFastDigitize: Initialisation successful" << endl;
217 Double_t *stripSignalF, Double_t *stripSignalB,
218 map<Int_t, set<Int_t> > &chanPointMapF,
219 map<Int_t, set<Int_t> > &chanPointMapB)
223 Int_t iPoint = -1, stationNr = Int_t(sensor->
GetStationNr());
225 set<Int_t>::iterator it1;
228 for (it1 = pSet.begin(); it1 != pSet.end(); it1++) {
235 point = (
CbmStsPoint*)fPoints->UncheckedAt(iPoint);
237 point->Momentum(mom);
240 TParticlePDG *part = TDatabasePDG::Instance()->GetParticle(mcTr->
GetPdgCode());
241 Double_t mnoc = 1.0, mass = 3.7283999;
242 if (part) mass = part->Mass();
245 lorv.SetVectM(mom, mass);
246 Double_t beta = lorv.Beta();
247 Double_t gamma = lorv.Gamma();
248 Double_t charge = (part) ? part->Charge()/3 : 1;
250 if (mnoc < 0.5)
continue;
253 Double_t coeff = mnoc / 29.2;
259 TVector3 posIn, posOut;
262 TVector3 dpos = posOut;
268 Double_t xrand, yrand;
271 if (mom.Z() < 0) mom *= -1;
272 Double_t theX = TMath::ATan2 (mom.X(),mom.Z()) * TMath::RadToDeg();
273 Double_t theY = TMath::ATan2 (mom.Y(),mom.Z()) * TMath::RadToDeg();
274 if (stationNr % 2 == 0) theY = -theY;
275 Int_t indXY = FindDataSet(theX, theY);
277 TH2I *hxy = fHistMap[indXY];
281 hxy->GetRandom2(xrand,yrand);
286 Int_t istrip0[2] = {0};
287 multimap<Float_t,Int_t>::iterator mit, mit1;
289 for (Int_t ixy = 0; ixy < 2; ++ixy) {
290 map<Int_t,Float_t> charges[2];
292 mit = fXYmap[ixy][indXY].lower_bound(xy[ixy]);
293 if (mit == fXYmap[ixy][indXY].end()) --mit;
295 Int_t entry = mit->second;
296 fTreeMap[indXY]->GetEntry(entry);
297 Double_t delt = TMath::Abs (fCog[ixy] - xy[ixy]);
298 Int_t ndig = fvDigis[ixy].size();
299 Double_t qTot0 = fQtot[ixy];
300 Double_t dpitch0 = fDpitin[ixy];
301 for (Int_t j = 0; j < ndig; ++j) {
302 charges[0][j+fIbeg[ixy]] = fvDigis[ixy][j];
307 if (mit != fXYmap[ixy][indXY].begin()) --mit1;
309 entry = mit1->second;
310 fTreeMap[indXY]->GetEntry(entry);
312 Double_t delt1 = TMath::Abs (fCog[ixy] - xy[ixy]);
313 Double_t
dist = delt + delt1;
316 Double_t w1 = (
dist - delt1) /
dist;
321 ndig = fvDigis[ixy].size();
322 Double_t qTot1 = fQtot[ixy];
323 Double_t dpitch1 = fDpitin[ixy];
324 for (Int_t j = 0; j < ndig; ++j) {
325 charges[1][j+fIbeg[ixy]] = fvDigis[ixy][j];
327 Int_t i0 = TMath::Min(charges[0].begin()->first,charges[1].begin()->first);
329 Int_t i1 = TMath::Max(charges[0].rbegin()->first,charges[1].rbegin()->first);
345 if (stationNr % 2) istrip0[ixy] = sensor->
GetFrontChannel(posIn.X(),posIn.Y(),posIn.Z(),dPitch);
346 else istrip0[ixy] = sensor->
GetFrontChannel(posOut.X(),posOut.Y(),posOut.Z(),dPitch);
348 if (stationNr % 2) istrip0[ixy] = sensor->
GetBackChannel(posIn.X(),posIn.Y(),posIn.Z(),dPitch);
349 else istrip0[ixy] = sensor->
GetBackChannel(posOut.X(),posOut.Y(),posOut.Z(),dPitch);
352 Double_t pitch = (ixy == 0) ? sensor->
GetDx() : sensor->
GetDy();
354 if (dPitch < 0) { --istrip0[ixy]; dPitch += 1.0; }
356 if (stationNr % 2 == 0) { dPitch = 1 - dPitch; }
359 if (stationNr % 2 == 0) ++istrip0[ixy];
362 Double_t qtot12 = qTot0 * w + qTot1 * w1;
363 Double_t dpitch12 = dpitch0 * w + dpitch1 * w1;
365 Int_t ntot = i1 - i0 + 1;
366 Double_t *q12array =
new Double_t[ntot];
367 Double_t q12sum0 = 0, q12sum1 = 0;
369 for (Int_t j = i0; j <= i1; ++j) {
370 if (charges[0].find(j) == charges[0].end()) charges[0][j] = 0;
371 if (charges[1].find(j) == charges[1].end()) charges[1][j] = 0;
373 q12array[j-i0] = (charges[0][j] * w + charges[1][j] * w1) * qtot12;
374 q12sum0 += q12array[j-i0];
376 Double_t shift = dPitch - dpitch12, q12 = 0;
378 map<Int_t,Double_t> buffer;
380 for (Int_t j = i0; j <= i1; ++j) {
381 if (stationNr % 2) q12 = Interp (q12array, j-i0, ntot, -shift);
383 else q12 = Interp (q12array, j-i0, ntot, -shift);
387 Int_t dj = j - fStrRef[ixy][indXY];
393 Double_t scale = q12sum0 / q12sum1;
396 for (map<Int_t,Double_t>::iterator it = buffer.begin(); it != buffer.end(); ++it) {
397 Int_t jj = it->first;
398 if (stationNr % 2 > 0) jj += istrip0[ixy];
399 else jj = istrip0[ixy] - it->first + 0;
403 stripSignalF[jj] += it->second * scale;
404 chanPointMapF[jj].insert(iPoint);
407 stripSignalB[jj] += it->second * scale;
408 chanPointMapB[jj].insert(iPoint);