{ // gStyle->SetCanvasPreferGL(kTRUE); // TCanvas *glc = new TCanvas("glc", "", 400, 0, 900, 900); gROOT->LoadMacro("$VMCWORKDIR/gconfig/rootlogon.C"); rootlogon(); TFile f("params.root"); PndGeoSttPar *parameters = f.Get("PndGeoSttPar"); PndSttMapCreator *mapper = new PndSttMapCreator(parameters); TClonesArray *fTubeArray = mapper->FillTubeArray(); TCanvas *c = new TCanvas("c", "", 400, 0, 900, 900); TH2F *h2 = new TH2F("h2", "", 100, -42, 42, 100, -42, 42); h2->Draw(); // geometry int ntubes_inner_parallel = 1000; int ntubes_outer_parallel = 884; int ntubes_fillup_parallel = 914; int ntubes_skewed = 1744; int ntubes = ntubes_inner_parallel + ntubes_outer_parallel + ntubes_fillup_parallel + ntubes_skewed; // 4542; int nlayers_inner_parallel = 8; int nlayers_outer_parallel = 4; int nlayers_fillup_parallel = 6; int nlayers = nlayers_inner_parallel + nlayers_outer_parallel + nlayers_fillup_parallel; int nsectors = 6; // cols: layer 1 2 3 4 5 6 7 8 | 9 10 11 12 | 13 14 15 16 17 18 int limen[108] = { 1, 105, 215, 331, 453, 581, 715, 855, 2745, 2957, 3175, 3399, 3629, 3853, 4051, 4231, 4381, 4489, 17, 122, 233, 350, 473, 602, 737, 878, 2779, 2992, 3211, 3436, 3666, 3886, 4081, 4256, 4399, 4498, 36, 142, 254, 372, 496, 626, 762, 904, 2816, 3030, 3250, 3476, 3704, 3919, 4111, 4281, 4417, 4507, 53, 160, 273, 392, 517, 648, 785, 928, 2851, 3066, 3287, 3514, 3741, 3952, 4141, 4306, 4435, 4516, 69, 177, 291, 411, 537, 669, 807, 951, 2885, 3101, 3323, 3551, 3778, 3985, 4171, 4331, 4453, 4525, 88, 197, 312, 433, 560, 693, 832, 977, 2922, 3139, 3362, 3591, 3816, 4018, 4201, 4356, 4471, 4534}; // start/end[sector][layer] int start[nsectors][nlayers] ; int end[nsectors][nlayers]; int irow = 0, icol = 0; for(int i = 0; i < 108; i++) { if(icol == nlayers) { irow++; icol = 0; } start[irow][icol] = limen[i]; icol++; } for(int irow = 0; irow < nsectors; irow++) { for(int icol = 0; icol < nlayers; icol++) { cout << " " << start[irow][icol]; end[irow][icol] = 0; } cout << endl; } cout << endl; for(int irow = 0; irow < nsectors; irow++) { for(int icol = 0; icol < nlayers; icol++) { if(irow == nsectors - 1) { if(icol == nlayers_inner_parallel - 1) end[irow][icol] = ntubes_inner_parallel; else if(icol == nlayers_inner_parallel + nlayers_outer_parallel - 1) end[irow][icol] = ntubes_inner_parallel + + ntubes_skewed + ntubes_outer_parallel; else if(icol == nlayers_inner_parallel + nlayers_outer_parallel + nlayers_fillup_parallel - 1) end[irow][icol] = ntubes_inner_parallel + ntubes_outer_parallel + ntubes_skewed + ntubes_fillup_parallel; else end[irow][icol] = start[0][icol + 1] - 1; } else end[irow][icol] = start[irow + 1][icol] - 1; } } for(int irow = 0; irow < nsectors; irow++) { for(int icol = 0; icol < nlayers; icol++) { cout << " " << end[irow][icol]; } cout << endl; } // for(int icol = 0; icol < nlayers; icol++) { // cout << icol << " " << start[0][icol] << " " << end[5][icol] << endl ; // } // for(int icol = 0; icol < nlayers; icol++) { // for(int irow = 0; irow < nsectors; irow++) { // cout << irow << " " << start[irow][icol] << " " << end[irow][icol] << endl ; // } // cout << endl; // } // ------------------------------------------------- PndSttTube *tube, *tuben; TArc *arc, *arcn; TMarker *mrk; // for(int jtube = 1; jtube < fTubeArray->GetEntriesFast(); jtube++) { // tube = (PndSttTube*) fTubeArray.At(jtube); // TVector3 position = tube->GetPosition(); // if(tube->GetWireDirection() == TVector3(0., 0., 1.)) { // arc = new TArc(position.X(), position.Y(), 0.5); // arc->Draw("SAME"); // } // else { // mrk = new TMarker(position.X(), position.Y(), 7); // mrk->Draw("SAME"); // } // } // int inizio; // cin >> inizio; // for(int itube = inizio; itube < inizio + 100; itube++) { // 800; itube < fTubeArray->GetEntriesFast(); itube++) { // h2->Clear(); // c->Clear(); // h2->Draw(); int itest = 0; int itube = -1; while(itest != 100) { for(int jtube = 1; jtube < fTubeArray->GetEntriesFast(); jtube++) { tube = (PndSttTube*) fTubeArray.At(jtube); TVector3 position = tube->GetPosition(); if(tube->GetWireDirection() == TVector3(0., 0., 1.)) { arc = new TArc(position.X(), position.Y(), 0.5); arc->Draw("SAME"); } else { mrk = new TMarker(position.X(), position.Y(), 7); mrk->Draw("SAME"); } } itest++; cout << "which tube would you like to test? " << endl; cin >> itube; cout << "tube " << itube << endl; if(itube >= 1001 && itube <= 2744) continue; tube = (PndSttTube*) fTubeArray.At(itube); TVector3 position = tube->GetPosition(); arc = new TArc(position.X(), position.Y(), 0.5); arc->SetFillColor(kYellow); arc->Draw("SAME"); // c->Update(); // c->Modified(); // +++++++++ LAYER ++++++++++++++++++++++++++++++++++++++++ int ilayer = -1; for(int ilay = 0; ilay < nlayers; ilay++) { if(itube >= start[0][ilay] && itube <= end[5][ilay]) { ilayer = ilay; tube->SetLayerID(ilayer); break; } } // +++++++++ LAYER ++++++++++++++++++++++++++++++++++++++++ // +++++++++ FILLUP/PARALLELIN/PARALLELOUT ++++++++++++++++ bool fillup = false, inner = false, outer = false; if(ilayer < nlayers_inner_parallel) inner = true; else if(ilayer < nlayers_inner_parallel + nlayers_outer_parallel) outer = true; else if(ilayer < nlayers_inner_parallel + nlayers_outer_parallel + nlayers_fillup_parallel) fillup = true; // +++++++++ FILLUP/PARALLELIN/PARALLELOUT ++++++++++++++++ // +++++++++ SECTOR +++++++++++++++++++++++++++++++++++++++ int isector = -1; for(int isec = 0; isec < nsectors; isec++) { // cout << isec << " " << start[isec][ilayer] << " " << end[isec][ilayer] << endl; if(itube >= start[isec][ilayer] && itube <= end[isec][ilayer]) { isector = isec; tube->SetSectorID(isector); break; } } // +++++++++ SECTOR +++++++++++++++++++++++++++++++++++++++ // cout << "tube " << itube << " is in layer " << ilayer << endl; int neighboring[6] = {-1, -1, -1, -1, -1, -1}; int delta = itube - start[isector][ilayer]; // 8 4 6 int shift[nsectors][nlayers]; int shift1[nlayers] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 7, 11, 16}; int shift2[nlayers] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19}; for(int i = 0; i < nsectors; i++) { for(int j = 0; j < nlayers; j++) { if(i == 0 || i == 3) shift[i][j] = shift1[j]; else shift[i][j] = shift2[j]; } } // for(int i = 0; i < nsectors; i++) { // for(int j = 0; j < nlayers; j++) { // cout << " " << shift[i][j]; // } // cout << endl; // } /** {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 7, 11, 16}; {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19}; {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19}; {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 7, 11, 16}; {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19}; {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 7, 10, 14, 19}; **/ delta += shift[isector][ilayer]; // layer up: i - 1, i, i +1 // same layer: i - 1, *, i + 1 // layer down: i - 1, i, * int surround[7] = {-1, -1, -1, -1, -1, -1, -1}; if(ilayer != nlayers - 1) { surround[0] = start[isector][ilayer + 1] + delta - shift[isector][ilayer + 1] - 1; surround[1] = start[isector][ilayer + 1] + delta - shift[isector][ilayer + 1]; surround[2] = start[isector][ilayer + 1] + delta - shift[isector][ilayer + 1] + 1; } surround[3] = itube - 1; surround[4] = itube + 1; if(ilayer != 0) { surround[5] = start[isector][ilayer - 1] + delta - shift[isector][ilayer - 1] - 1; surround[6] = start[isector][ilayer - 1] + delta - shift[isector][ilayer - 1]; } // \/ 2 /|\ 3 // inside -- 2 hexagon_limit /|\ 3 // /\ 2 | 1 bool hexagon_limit = false; if(itube == start[isector][ilayer] && shift[isector][ilayer] == 0) hexagon_limit = true; // same layer ---------------------------------------------- // before // if it is not the starting tube of sector 0 or 3 AND // if it is not the starting tube of a fillup layer // ==> take the previous tube in the same layer if(!(itube == start[isector][ilayer] && isector == 0) && !(itube == start[isector][ilayer] && isector == 3) && !(itube == start[isector][ilayer] && fillup == true)) neighboring[0] = surround[3]; // after // if it is not the ending tube of sector 2 or 5 AND // if it is not the ending tube of a fillup layer // ==> take the subsequent tube in the same layer if(!(itube == end[isector][ilayer] && isector == 2) && !(itube == end[isector][ilayer] && isector == nsectors - 1) && !(itube == end[isector][ilayer] && fillup == true)) { if(hexagon_limit == true) neighboring[4] = surround[4]; else neighboring[3] = surround[4]; } // layer above --------------------------------------------- if(ilayer != nlayers_inner_parallel - 1 && ilayer != nlayers - 1) { // @ sector limit // if we are at the hexagon limit ==> we take 3 upper tubes if(hexagon_limit == true) { // 3 if(ilayer >= nlayers_inner_parallel + nlayers_outer_parallel - 1) { // fillup if((surround[0] >= start[isector][ilayer + 1]) && (surround[0] <= end[isector][ilayer + 1])) neighboring[1] = surround[0]; if((surround[1] >= start[isector][ilayer + 1]) && (surround[1] <= end[isector][ilayer + 1])) neighboring[2] = surround[1]; if((surround[2] >= start[isector][ilayer + 1]) && (surround[2] <= end[isector][ilayer + 1])) neighboring[3] = surround[2]; } else { if(!(itube == start[isector][ilayer] && isector == 0) && !(itube == start[isector][ilayer] && isector == 3)) neighboring[1] = surround[0]; neighboring[2] = surround[1]; if(!(itube == end[isector][ilayer] && isector == 2) && !(itube == end[isector][ilayer] && isector == nsectors - 1)) neighboring[3] = surround[2]; } } else { if(ilayer >= nlayers_inner_parallel + nlayers_outer_parallel - 1) { // fillup if((surround[1] >= start[isector][ilayer + 1]) && (surround[1] <= end[isector][ilayer + 1])) neighboring[1] = surround[1]; if((surround[2] >= start[isector][ilayer + 1]) && (surround[2] <= end[isector][ilayer + 1])) neighboring[2] = surround[2]; } else { cout << itube << " " << end[isector][ilayer] << " " << isector << " " << nsectors - 1 << endl; neighboring[1] = surround[1]; neighboring[2] = surround[2]; } } } // layer below --------------------------------------------- if(ilayer != nlayers_inner_parallel && ilayer != 0) { // @ sector limit // if we are at the hexagon limit ==> we take 1 lower tube if(hexagon_limit == true) { // 1 neighboring[5] = surround[6]; } // inside sector // if we are inside the sector, not on the limit // ==> we take 2 lower tubes (and we check // that we are not exiting the sector in case // we are in sector 2 or 5 or it is a fillup tube) // CHECK the check ;-) else { neighboring[4] = surround[5]; if(ilayer >= nlayers_inner_parallel + nlayers_outer_parallel + 1) { // fillup neighboring[5] = surround[6]; } else if(!(itube == end[isector][ilayer] && isector == 2) && !(itube == end[isector][ilayer] && isector == nsectors - 1)) neighboring[5] = surround[6]; } } int colors[nlayers] = {6, 7, 8, 9, 11, 12, 6, 7, 8, 9, 11, 12, 6, 7, 8, 9, 11, 12}; for(int in = 0; in < 6; in++) { if(neighboring[in] == -1) continue; cout << in << " neighbor " << neighboring[in] << endl; tuben = (PndSttTube*) fTubeArray.At(neighboring[in]); TVector3 positionn = tuben->GetPosition(); arcn = new TArc(positionn.X(), positionn.Y(), 0.5); arcn->SetFillColor(colors[in]); arcn->Draw("SAME"); } c->Update(); c->Modified(); } }