1 #include "drawhelpers.hxx"
5 if (storagefile.Get(currenthisto->GetName()) != 0) {
6 currenthisto->Add((TH1*)storagefile.Get(currenthisto->GetName()));
8 cout << currenthisto->GetName() <<
": " << currenthisto->GetEntries() << endl;
9 currenthisto->Write(currenthisto->GetName(), TObject::kWriteDelete);
18 kDCH,
kDRC,
kDSK,
kEMC,
kGEM,
kLUMI,
kMDT,
kMVD,
kRPC,
kSTT,
kTPC,
kTOF,
kFTS,
kHYPG,
kHYP};
22 gROOT->LoadMacro(
"$VMCWORKDIR/gconfig/rootlogon.C");
25 TDatabasePDG *pdg =
new TDatabasePDG();
30 TString simFileName =
"Sim_Dpm_500.root";
31 TString parFileName =
"Sim_Dpm_500_params.root";
32 TString digiFileName =
"Sim_Dpm_500_digi.root";
33 TString recoFileName =
"Sim_Dpm_500_reco.root";
34 TString outFileName =
"Sim_Dpm_500_streamdisplay.root";
35 TString histofilename =
"onlinetrkmccheck.root";
39 TFile filerecopixel(recoFileName.Data());
42 TTree *recotree = (TTree*)
filereco.Get(
"pndsim");
44 TFile simfile(simFileName.Data());
45 TTree* mctree = (TTree*) simfile.Get(
"pndsim");
46 TClonesArray* mcarray =
new TClonesArray(
"PndMCTrack");
47 mctree->SetBranchAddress(
"MCTrack", &mcarray);
49 FairRunAna *
fRun =
new FairRunAna();
50 fRun->SetInputFile(simFileName.Data());
51 fRun->AddFriend(recoFileName.Data());
52 fRun->AddFriend(digiFileName.Data());
53 fRun->SetOutputFile(outFileName.Data());
55 FairRuntimeDb*
rtdb = fRun->GetRuntimeDb();
57 PndOnlineGeometryManager *online_geometry =
new PndOnlineGeometryManager(rtdb, parFileName.Data());
59 PndOnlineManager *online =
new PndOnlineManager();
60 online->AddGeometryManager(online_geometry);
63 online->LoadStream(PndOnline::kMVDPixel,
"MVDHitsPixel",stthitlifetime);
64 online->LoadStream(PndOnline::kMVDStrip,
"MVDHitsStrip",stthitlifetime);
67 TClonesArray* tubearray = online_geometry->GetDetectorGeometry(
PndOnline::kSTT);
70 PndOnlineSttTripletFinderMini *triplet_finder =
new PndOnlineSttTripletFinderMini(online, tubearray);
71 online->AddTask((FairTask*)triplet_finder);
74 TCanvas*
c1 =
new TCanvas(
"c1");
75 c1->Range(-42,-42,42,42);
76 c1->SetCanvasSize(1200, 1200);
77 TText* mytext =
new TText();
84 int final_time = 10050;
86 online->SetHESRRevolutionDuration(delta_t);
90 TObjArray* online_fairhits_stt = 0;
91 TObjArray* online_tracks = 0;
92 TObjArray* online_tracks2 = 0;
93 TObjArray* online_fairhits_mvd = 0;
95 std::vector<double> mctracktime;
96 std::vector<double> mctrackpt;
97 std::vector<double> mctrackphi;
98 std::vector<int> mctrackstatus;
99 std::vector<double> recotracktime;
100 std::vector<double> recotrackpt;
101 std::vector<double> recotrackphi;
102 std::vector<int> recotrackstatus;
103 std::vector<int> recotrackmcid;
104 int totalmctracks = 0;
105 int goodmctracks = 0;
106 int totalrecotracks = 0;
107 int goodrecotracks = 0;
108 int norecotracks = 0;
109 int deltaphifailed = 0;
110 int deltaptfailed = 0;
111 int deltabothfailed = 0;
113 int globalmaxmcid = 0;
123 TH2D* hmcall =
new TH2D(
"hmcall",
"hmcall", 1500, -15, 15, 75, 0, 1.5);
124 TH2D* hmcprime =
new TH2D(
"hmcprime",
"hmcprime", 1500, -15, 15, 75, 0, 1.5);
125 TH2D* hmcrecoable =
new TH2D(
"hmcrecoable",
"hmcrecoable", 1500, -15, 15, 75, 0, 1.5);
126 TH2D* hdafuq =
new TH2D(
"hdafuq",
"hdafuq", 1500, -15, 15, 75, 0, 1.5);
127 TH2D* hmcrecoed =
new TH2D(
"hmcrecoed",
"hmcrecoed", 1500, -15, 15, 75, 0, 1.5);
128 TH2D* hmcnotrecoed =
new TH2D(
"hmcnotrecoed",
"hmcnotrecoed", 1500, -15, 15, 75, 0, 1.5);
131 for (current_time = 0; current_time < final_time; current_time += delta_t) {
134 online->ClearTracks();
135 online->LoadHits( delta_t );
140 online_tracks = online->GetTrackObjectList();
144 if (online_tracks->GetEntriesFast() > 0) {
145 PndOnlineTrack* firstTrack = (PndOnlineTrack*) online_tracks->At(firsti);
146 while (firstTrack->DrawMode() != PndOnlineTrack::kVertexMomentumAsCircleHack) {
148 if (firsti > online_tracks->GetEntriesFast()) {
149 cout <<
"No drawable online Track in Array. We have a severe problem." << endl;
152 firstTrack = (PndOnlineTrack*) online_tracks->At(firsti);
154 maxmcid = firstTrack->MCEntryNumber();
155 minmcid = firstTrack->MCEntryNumber();
157 for (
int i = 0;
i < online_tracks->GetEntriesFast();
i++) {
158 PndOnlineTrack* myTrack = (PndOnlineTrack*) online_tracks->At(
i);
159 if (myTrack->DrawMode() == PndOnlineTrack::kVertexMomentumAsCircleHack) {
161 innerhit.Set(myTrack->Vertex().x(), myTrack->Vertex().y());
163 outerhit.Set(myTrack->Momentum().x(), myTrack->Momentum().y());
164 TVector2 circleorigin;
167 CalculateCircle(&innerhit, &outerhit, &circleorigin, &circleradius, &clockwise);
168 Double_t trackpt = circleradius * 2.0 * 3.0;
169 Double_t orthophi = circleorigin.Phi();
178 cout <<
"Reco Track MCEntryNumber: " << myTrack->MCEntryNumber() << endl;
179 cout <<
"Reco Track MCEntryMajority: " << myTrack->MCEntryMajority() << endl;
180 cout <<
"Reco Track MCTrackNumber: " << myTrack->MCTrackNumber() << endl;
181 cout <<
"Reco Track MCTrackMajority: " << myTrack->MCTrackMajority() << endl;
182 cout <<
"Reco Track HitCount: " << myTrack->HitCount() << endl;
184 if ( (myTrack->MCEntryMajority() > 0.9) && (myTrack->MCTrackMajority() > 0.9) ) {
188 if ( (myTrack->MCEntryMajority() > 0.8) && (myTrack->MCTrackMajority() > 0.8) ) {
195 int mcentrynumber = myTrack->MCEntryNumber();
196 if (mcentrynumber > maxmcid) {
197 maxmcid = mcentrynumber;
199 if (mcentrynumber < minmcid) {
200 minmcid = mcentrynumber;
208 recotrackpt.push_back(trackpt);
209 recotrackphi.push_back(trackphi);
210 recotrackstatus.push_back(0);
211 recotrackmcid.push_back(mcentrynumber);
215 if (maxmcid > globalmaxmcid) {
216 globalmaxmcid = maxmcid;
219 for (
int j = minmcid; j < mctree->GetEntriesFast(); j++) {
220 cout <<
"MC outer loop: " << j << endl;
221 if (j > globalmaxmcid) {
225 cout <<
"MC Entry count: " << mcarray->GetEntriesFast() << endl;
226 for (
int k = 0; k < mcarray->GetEntriesFast(); k++) {
229 cout <<
"MC Track has NULL pointer. Oooops." << endl;
233 bool isrecoable =
false;
238 cout <<
"Critical Track at Event: " << j <<
" Track " << k <<
" Particle: " << mctrack->
GetPdgCode() << endl;
249 if (mctrack->
GetMomentum().Pt() < 0.052) isrecoable =
false;
251 cout <<
"Low pt hit" << endl;
257 if (pdg->GetParticle(mctrack->
GetPdgCode())->
Mass() > 1) isrecoable =
false;
260 cout <<
"Low betagamma particle" << endl;
264 cout <<
"Meh, reco possibility mismatch." << endl;
266 cout <<
"Dafuq at Event: " << j <<
" Track " << k <<
" Particle: " << mctrack->
GetPdgCode() <<
" Charge: " << pdg->GetParticle(mctrack->
GetPdgCode())->Charge() << endl;
283 for (
int r = 0;
r < recotrackmcid.size();
r++) {
284 if (recotrackmcid.at(
r) == j) {
285 Double_t deltaphi = recotrackphi.at(
r) - mcphi;
289 Double_t deltapt = recotrackpt.at(
r) - mcpt;
293 bool phiok = (deltaphi < 0.1);
294 bool ptok = ( (deltapt < mcpt * 0.1) || ((mcpt > 450)&&(recotrackpt.at(
r) > 450)) );
297 recotrackstatus.at(
r) = 1;
302 if ((!phiok) && ptok) {
305 if (phiok && (!ptok)) {
308 if ((!phiok) && (!ptok)) {
314 if (trackstatus == 0) {
320 mctrackstatus.push_back(trackstatus);
330 for (
int s = 0;
s < mctrackstatus.size();
s++) {
331 if (mctrackstatus.at(
s) > 0) {
336 int recotrackstatusgoodcount = 0;
337 int recotrackstatusbadcount = 0;
339 for (
int s = 0;
s < recotrackstatus.size();
s++) {
340 if (recotrackmcid.at(
s) <= globalmaxmcid) {
341 if (recotrackstatus.at(
s) > 0) {
342 recotrackstatusgoodcount++;
344 recotrackstatusbadcount++;
353 cout <<
"Total reconstructed track count: " << totalrecotracks << endl;
354 cout <<
"Reached MC ID: " << globalmaxmcid << endl;
355 cout <<
"Reconstructable MC track count: " << goodmctracks << endl;
356 cout <<
"MC Tracks reconstructed: " << goodrecotracks << endl;
357 cout <<
"MC Tracks NOT reconstructed: " << norecotracks << endl;
358 cout <<
"Reco Status Good: " << recotrackstatusgoodcount << endl;
359 cout <<
"Reco Status Bad: " << recotrackstatusbadcount << endl;
360 cout <<
"Delta phi failed: " << deltaphifailed << endl;
361 cout <<
"Delta pt failed: " << deltaptfailed << endl;
362 cout <<
"Delta both failed: " << deltabothfailed << endl;
363 cout <<
"Secondary Tracks: " << secondaries << endl;
365 cout <<
"MC Match Good 90: " << mcidgood90 << endl;
366 cout <<
"MC Match Good 80: " << mcidgood80 << endl;
367 cout <<
"MC Match Bad: " << mcidbad << endl;
371 TFile outputstorage(histofilename,
"UPDATE");
384 cout << endl << endl;
385 cout <<
"Macro finished succesfully." << endl;
386 cout <<
"Real time " << rtime <<
" s, CPU time " << ctime <<
" s" << endl;
TFile filereco("MvdStt_Test_reco.root")
Int_t GetNPoints(DetectorId detId) const
TVector3 GetMomentum() const
TFile filedigi("testdigi.root")
int runTripletFinderMini()
TVector3 GetStartVertex() const
Int_t GetMotherID() const
void SaveAndUpdateHisto(TH1 *currenthisto, TFile &storagefile)