51 if (fDebug) cout <<
" BmnMwpcHitProducer::Init() " << endl;
54 FairRootManager* ioman = FairRootManager::Instance();
55 fBmnPointsArray = (TClonesArray*) ioman->GetObject(fInputBranchName);
56 fMCTracksArray = (TClonesArray*) ioman->GetObject(
"MCTrack");
57 fBmnHitsArray =
new TClonesArray(fOutputHitsBranchName, 100);
58 ioman->Register(fOutputHitsBranchName,
"MWPC", fBmnHitsArray, kTRUE);
62 hY_vsX2 =
new TH2D(
"Y_vsX2",
"Y_vsX2", 140,-35,35, 140,-35,35);fList.Add(hY_vsX2);
63 hY_vsX3 =
new TH2D(
"Y_vsX3",
"Y_vsX3", 140,-35,35, 140,-35,35);fList.Add(hY_vsX3);
64 hY_vsX_star2 =
new TH2D(
"Y_vsX_star2",
"Y_vsX_star2", 140,-35,35, 140,-35,35);fList.Add(hY_vsX_star2);
65 hY_vsX_star3 =
new TH2D(
"Y_vsX_star3",
"Y_vsX_star3", 140,-35,35, 140,-35,35);fList.Add(hY_vsX_star3);
66 hY_vsX_pl0 =
new TH2D(
"Y_vsX_pl0",
"Y_vsX_pl0", 140,-35,35, 140,-35,35);fList.Add(hY_vsX_pl0);
67 hY_vsX_pl1 =
new TH2D(
"Y_vsX_pl1",
"Y_vsX_pl1", 140,-35,35, 140,-35,35);fList.Add(hY_vsX_pl1);
68 hY_vsX_pl2 =
new TH2D(
"Y_vsX_pl2",
"Y_vsX_pl2", 140,-35,35, 140,-35,35);fList.Add(hY_vsX_pl2);
92 Double_t err[3] = {0.25 / Sqrt(12), 0.25 / Sqrt(12), 0.};
95 Double_t kMiddlePl = 47.25;
96 Double_t kCheaksize = 12. + 0.5*dw;
97 Double_t a_side = 4*Sqrt(3) + 0.5*dw;
98 Double_t ShiftX[4]; Double_t ShiftY[4];
100 ShiftX[2] = -0.271 - 0.5;
101 ShiftY[2] = -6.038 + 4.5;
103 ShiftX[3] = -0.234 - 0.5;
104 ShiftY[3] = -6.140 + 4.5;
106 Int_t Nmc_tracks = 0;
118 Double_t xi[6], yi[6], zi[6];
120 for (Int_t
i = 0;
i < fBmnPointsArray->GetEntriesFast();
i++) {
126 Double_t Pz = point->GetPz();
128 if (charge == 0)
continue;
131 if (IsPrimary == 0)
continue;
132 if (Pz < 0.1)
continue;
133 Int_t track_id = point->GetTrackID();
134 if (track_id != Id_curr){
137 if (fDebug) cout<<
" ----"<<endl;
141 Double_t x = point->GetX();
142 Double_t y = point->GetY();
143 Double_t z = point->GetZ();
146 if (z < -847.) ChId = 0;
147 if (z > -756. && z < -750.) ChId = 1;
148 if (z > -360. && z < -354.) ChId = 2;
149 if (z > -211.) ChId = 3;
151 if (ChId == 2 && fDebug) hY_vsX2-> Fill(x,y);
152 if (ChId == 3 && fDebug) hY_vsX3-> Fill(x,y);
154 if (Ch_curr != ChId){
161 if (fDebug) cout<<
"=== track_id "<<track_id<<
" ChId "<<ChId<<
" xmc "<<x<<
" y "<<y<<
" z "<<z<<
" Pz "<<Pz<<endl;
163 TGeoNode* curNode = gGeoManager->FindNode(x, y, z);
164 TString nameNode = TString(curNode->GetName());
166 Short_t planeNum = TString(nameNode(Int_t(nameNode.Length() - 1), 1)).Atoi();
167 Int_t time_wire = 70;
168 if (ChId == 2 && planeNum == 0 && fDebug) hY_vsX_pl0->Fill(x,y);
169 if (ChId == 2 && planeNum == 1 && fDebug) hY_vsX_pl1->Fill(x,y);
170 if (ChId == 2 && planeNum == 2 && fDebug) hY_vsX_pl2->Fill(x,y);
174 plNuml = planeNum + 3;
180 if (plNumf > -1 && plNuml == planeNum){
181 if (ChId == 2) Nmc_tracks++;
186 Double_t Ax = (xf - xl)/(zf - zl);
187 Double_t Ay = (yf - yl)/(zf - zl);
189 for (Int_t ipl = 0; ipl < 6; ipl++) {
190 xi[ipl] = Ax * ( ipl - plNumf ) + xf;
191 yi[ipl] = Ay * ( ipl - plNumf ) + yf;
192 if (fDebug) cout<<
" xi["<<ipl<<
"] "<<xi[ipl]<<
" yi["<<ipl<<
"] "<<yi[ipl]<<
" z "<<zf + ipl - plNumf;
193 xi[ipl] += ShiftX[ChId];
194 yi[ipl] += ShiftY[ChId];
195 zi[ipl] = zf + ipl - plNumf;
198 Double_t wire_pos = -1.;
201 if (ipl == 2 || ipl == 5 ){
203 if (fDebug) cout<<
" -- x --"<<hit_coord<<
" y "<<yi[ipl]<<endl;
204 if (
fabs(yi[ipl]) > a_side)
continue;
206 if (ipl == 0 || ipl == 3 ){
207 hit_coord = 0.5*( xi[ipl] - Sqrt(3)* yi[ipl]);
208 Double_t v_t = (Sqrt(3)*xi[ipl] + yi[ipl]) * 0.5;
209 if (fDebug) cout<<
" -- v --"<<hit_coord<<
" v_t "<<v_t<<endl;
210 if (
fabs(v_t) > a_side)
continue;
212 if (ipl == 1 || ipl == 4 ){
213 hit_coord = 0.5*( xi[ipl] + Sqrt(3)* yi[ipl]);
214 Double_t u_t = (Sqrt(3)*xi[ipl] - yi[ipl]) * 0.5;
215 if (fDebug) cout<<
" -- u --"<<hit_coord<<
" u_t "<<u_t<<endl;
216 if (
fabs(u_t) > a_side)
continue;
220 if (
fabs(hit_coord) > kCheaksize)
continue;
222 if (ipl == 1 || ipl == 2 || ipl == 3){
223 hit_coord = -hit_coord;
227 wire_pos = (hit_coord + kMiddlePl*dw )/dw;
230 Int_t nearest_wire = Int_t(wire_pos);
235 if (fDebug) cout<<
" Ch "<<ChId<<
" track_id "<<track_id<<
" xmc "<<x<<
" y "<<y<<
" pl "<<ipl<<
" XUV "<<hit_coord<<
" wire "<<wire_pos<<
" nearest "<<nearest_wire<<endl;
237 if (nearest_wire < 0 || nearest_wire > 95 )
continue;
238 if (fDebug && ChId == 2 ) hY_vsX_star2->Fill(xi[ipl], yi[ipl]);
239 if (fDebug && ChId == 3 ) hY_vsX_star3->Fill(xi[ipl], yi[ipl]);
245 if (fDebug) cout<<
" pdg "<<pdg<<endl;
248 if(rand_gen.Uniform() <= .9) {
249 BmnMwpcHit* hit1 =
new ((*fBmnHitsArray)[fBmnHitsArray->GetEntriesFast()])
250 BmnMwpcHit(0, TVector3(xi[ipl], yi[ipl], zi[ipl]), TVector3(err[0], err[1], 0.0),
i);
276 if (fDebug) cout<<
" Nmc_tracks "<<Nmc_tracks<<endl;