9 #include "ERBeamDetTrackFinder.h" 14 #include "TGeoManager.h" 16 #include "FairRootManager.h" 18 #include "FairRuntimeDb.h" 19 #include "FairLogger.h" 26 :
ERTask(
"ER BeamDet track finding scheme")
32 :
ERTask(
"ER BeamDet track finding scheme ", verbose)
41 FairRootManager* ioman = FairRootManager::Instance();
42 if ( ! ioman ) Fatal(
"Init",
"No FairRootManager");
43 if (interaction_volume_name_ ==
"")
44 Fatal(
"Init",
"TargetVolumeName for ERBeamDetTrackFinder not defined! ");
45 fBeamDetMWPCDigiX1 = (TClonesArray*) ioman->GetObject(
"BeamDetMWPCDigiX1");
46 fBeamDetMWPCDigiX2 = (TClonesArray*) ioman->GetObject(
"BeamDetMWPCDigiX2");
47 fBeamDetMWPCDigiY1 = (TClonesArray*) ioman->GetObject(
"BeamDetMWPCDigiY1");
50 fBeamDetTrack =
new TClonesArray(
"ERBeamDetTrack", consts::approx_beamdet_track_number);
52 ioman->Register(
"BeamDetTrack",
"BeamDet track",
fBeamDetTrack, kTRUE);
56 fRand =
new TRandom3();
61 Bool_t isCluster = kTRUE;
62 for(Int_t i = 0; i < digiArray->GetEntries() - 1; i++) {
65 if((digiNeigborWire->Channel() - digi->Channel()) != 1) {
67 FairRun* run = FairRun::Instance();
75 const TClonesArray* digis,
char coordType) {
76 if (!digis->GetEntriesFast())
77 LOG(FATAL) <<
"ERBeamDetTrackFinder::CalcCoordinateAvg: empty digi collection" 79 ERChannel channel_of_first_digi =
dynamic_cast<ERDigi*
>(digis->At(0))->Channel();
80 ERChannel channel_of_last_digi = channel_of_first_digi;
81 for (
int iDigi(0); iDigi < digis->GetEntriesFast(); ++iDigi) {
82 const auto channel =
dynamic_cast<ERDigi*
>(digis->At(iDigi))->Channel();;
83 if (channel < channel_of_first_digi)
84 channel_of_first_digi = channel;
85 if (channel > channel_of_last_digi)
86 channel_of_last_digi = channel;
90 return 0.5*(
fBeamDetSetup->GetWireGlobX(digi_branch_name, channel_of_first_digi-1)
91 +
fBeamDetSetup->GetWireGlobX(digi_branch_name, channel_of_last_digi-1));
93 return 0.5*(
fBeamDetSetup->GetWireGlobY(digi_branch_name, channel_of_first_digi-1)
94 +
fBeamDetSetup->GetWireGlobY(digi_branch_name, channel_of_last_digi-1));
96 return 0.5*(
fBeamDetSetup->GetWireGlobZ(digi_branch_name, channel_of_first_digi-1)
97 +
fBeamDetSetup->GetWireGlobZ(digi_branch_name, channel_of_last_digi-1));
99 LOG(FATAL) <<
"ERBeamDetTrackFinder::CalcCoordinateAvg: Unknown coordinate type " 106 LOG(DEBUG) <<
"[ERBeamDetTrackFinder]------------Started-----------------------------------------" 109 if(fBeamDetMWPCDigiX1->GetEntriesFast() < 1 ||
110 fBeamDetMWPCDigiX2->GetEntriesFast() < 1 ||
111 fBeamDetMWPCDigiY1->GetEntriesFast() < 1 ||
113 LOG(DEBUG) <<
"Multiplicity less than one" << FairLogger::endl;
118 Double_t xFar, yFar, zFar;
119 Double_t xClose, yClose, zClose;
125 if(fBeamDetMWPCDigiX1->GetEntriesFast() > 1) {
136 digi = (
ERDigi*)fBeamDetMWPCDigiX1->At(0);
137 xFar =
fBeamDetSetup->GetWireGlobX(
"BeamDetMWPCDigiX1", digi->Channel()-1);
138 xFar =
fBeamDetSetup->GetWireGlobX(
"BeamDetMWPCDigiX1", digi->Channel()-1);
139 zFar =
fBeamDetSetup->GetWireGlobZ(
"BeamDetMWPCDigiX1", digi->Channel()-1);
143 if(fBeamDetMWPCDigiX2->GetEntriesFast() > 1) {
144 cluster =
IsCluster (fBeamDetMWPCDigiX2);
153 digi = (
ERDigi*)fBeamDetMWPCDigiX2->At(0);
154 xClose =
fBeamDetSetup->GetWireGlobX(
"BeamDetMWPCDigiX2", digi->Channel()-1);
157 if(fBeamDetMWPCDigiY1->GetEntriesFast() > 1 ) {
158 cluster =
IsCluster (fBeamDetMWPCDigiY1);
167 digi = (
ERDigi*)fBeamDetMWPCDigiY1->At(0);
168 yFar =
fBeamDetSetup->GetWireGlobY(
"BeamDetMWPCDigiY1", digi->Channel()-1);
183 yClose =
fBeamDetSetup->GetWireGlobY(
"BeamDetMWPCDigiY2", digi->Channel()-1);
184 zClose =
fBeamDetSetup->GetWireGlobZ(
"BeamDetMWPCDigiY2", digi->Channel()-1);
186 TVector3 hitFar(xFar, yFar, zFar);
187 TVector3 hitClose(xClose, yClose, zClose);
188 TVector3 vectorOnTarget = hitClose - hitFar;
190 LOG(DEBUG) <<
"Theta = " << vectorOnTarget.Theta() <<
"; Phi = " << vectorOnTarget.Phi() << FairLogger::endl;
192 Double_t xTarget = xClose - zClose*TMath::Tan(vectorOnTarget.Theta())*TMath::Cos(vectorOnTarget.Phi());
193 Double_t yTarget = yClose - zClose*TMath::Tan(vectorOnTarget.Theta())*TMath::Sin(vectorOnTarget.Phi());
195 LOG(DEBUG) <<
"xFar = " << xFar <<
"; yFar = " << yFar <<
"; zFar = " << zFar
196 <<
"xClose = " << xClose <<
"; yClose = " << yClose <<
"; zClose = " << zClose << FairLogger::endl;
199 node = gGeoManager->InitTrack(xClose, yClose, zClose, vectorOnTarget.Unit().X(),
200 vectorOnTarget.Unit().Y(),
201 vectorOnTarget.Unit().Z());
202 Double_t targetMiddleThicknessX;
203 Double_t targetMiddleThicknessY;
204 Double_t targetMiddleThicknessZ;
206 Bool_t target_affected = kFALSE;
207 while(!gGeoManager->IsOutside()){
208 node = gGeoManager->FindNextBoundaryAndStep();
211 if ((TString(node->GetName()).Contains(interaction_volume_name_))) {
212 target_affected = kTRUE;
216 if (!target_affected){
217 LOG(WARNING) <<
"Target is not affected" << FairLogger::endl;
221 node = gGeoManager->FindNextBoundary();
223 const double max_track_range_in_interaction_volume = gGeoManager->GetStep();
224 gGeoManager->SetStep(max_track_range_in_interaction_volume * depth_ratio_);
227 targetMiddleThicknessX = gGeoManager->GetCurrentPoint()[0];
228 targetMiddleThicknessY = gGeoManager->GetCurrentPoint()[1];
229 targetMiddleThicknessZ = gGeoManager->GetCurrentPoint()[2];
232 targetMiddleThicknessY,
233 targetMiddleThicknessZ, vectorOnTarget.Unit());
235 LOG(DEBUG) <<
"Point on target " <<
"(" << targetMiddleThicknessX <<
", " 236 << targetMiddleThicknessY <<
", " 237 << targetMiddleThicknessZ <<
") cm" 239 LOG(DEBUG) <<
"[ERBeamDetTrackFinder]------------Finished-----------------------------------------" 251 return new((*fBeamDetTrack)[
fBeamDetTrack->GetEntriesFast()])
virtual void Exec(Option_t *opt)
Defines the transformation actions for all input data (MWPCDigi) to output data (Track) for each even...
Double_t CalcCoordinateAvg(const TString &digi_branch_name, const TClonesArray *digiArray, char coordType)
Calculates an arithmetic average value in array of consequent wires.
virtual InitStatus Init()
Defines all input and output object colletions participates in track finding.
Class for reconsruction ion's coordinate and momentum direction on target.
ERBeamDetSetup * fBeamDetSetup
access to ERBeamDetSetup class instance
virtual InitStatus Init()
ERBeamDetTrackFinder()
Default constructor.
TClonesArray * fBeamDetMWPCDigiY2
input collection of MWPC Digi
Bool_t IsCluster(TClonesArray *digiArray)
Checks if the collection of digies contatains only neigbour wires.
virtual void Reset()
Resets all output data.
std::vector< TString > fAvailibleRunManagers
Run managers that are availible for this task.
ERBeamDetTrack * AddTrack(Double_t xt, Double_t yt, Double_t zt, TVector3 v)
Adds a ERBeamDetTrack to the output Collection.
TClonesArray * fBeamDetTrack
output collection of tracks
Base abstract class for all tasks in er.