Skip to content

Commit

Permalink
Merge pull request Mu2e#31 from brownd1978/diag
Browse files Browse the repository at this point in the history
Diagnostics update
  • Loading branch information
kutschke authored Oct 17, 2019
2 parents 6dc8d93 + 8ce9151 commit 92a75dc
Show file tree
Hide file tree
Showing 11 changed files with 2,504 additions and 43 deletions.
11 changes: 5 additions & 6 deletions JobConfig/reco/MisalignTracker.C
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
#include "TRandom3.h"
#include "TMath.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
// generate parameters to misalign the tracker to include an overall twist (dalphaz/dz), skew (dalphay/dz), and random mis-positions and angles
// generate parameters to misalign the tracker to include an overall twist (dphi/zdz), skew in x and y, and random mis-positions and angles
// David Brown (LBNL)
//

using namespace std;
void MisalignTracker(double twist, double skew, double squeeze, double sigalpha, double sigpos, const char* outfile) {
unsigned NPlanes(36);
double planezgap(83.0);
double planer(700.0);
double planezgap(83.0); // approximate number
double planer(700.0); // approximate number
double trackerlen = NPlanes*planezgap; // approximate

TRandom3 myrand(3499803);
double rtwist = myrand.Uniform(-twist,twist);
double xskew = myrand.Uniform(-skew,skew);
double yskew = myrand.Uniform(-skew,skew);
double rsqueeze = myrand.Uniform(-squeeze,squeeze);
double alphaxskew = xskew/(2*planer);
double alphayskew = yskew/(2*planer);
double dtwist = twist/(6.28*planer*trackerlen);
double dtwist = twist/(TMath::Pi()*2.0*planer*trackerlen);

filebuf fb;
fb.open (outfile,ios::out);
Expand Down
17 changes: 5 additions & 12 deletions TrackerMC/test/RandomDeadStraws.C
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@

using namespace std;
void RandomDeadStraws(unsigned ndeadplane, unsigned ndeadpanel, unsigned ndeadstraw, const char* outfile) {
unsigned NStraws(48);
unsigned NLayers(2);
unsigned NPlanes(40);
unsigned NStraws(96);
unsigned NPlanes(36);
unsigned NPanels(6);
vector<string> deadstraws;
vector<unsigned> inactiveplanes;
vector<string> inactivepanels;
vector<string> inactivestraws;
// 20-slot tracker with 18 stations:w
inactiveplanes.push_back(12);
inactiveplanes.push_back(13);
inactiveplanes.push_back(26);
inactiveplanes.push_back(27);

TRandom3 myrand(3499803);

filebuf fb;
Expand All @@ -35,15 +30,14 @@ void RandomDeadStraws(unsigned ndeadplane, unsigned ndeadpanel, unsigned ndeadst
int plane = myrand.Integer(NPlanes);
if(find(inactiveplanes.begin(), inactiveplanes.end(), plane) == inactiveplanes.end()){
++ndplane;
os << plane;
os << "\"" << plane << "\"";
if(ndplane < ndeadplane) os << "," << endl;
inactiveplanes.push_back(plane);
}
}
os << "]" << endl;
}


if(ndeadpanel > 0){
os << "deadPanels : [ " << endl;
unsigned ndpanel(0);
Expand Down Expand Up @@ -74,10 +68,9 @@ void RandomDeadStraws(unsigned ndeadplane, unsigned ndeadpanel, unsigned ndeadst
char panelid[80];
snprintf(panelid,80,"\"%u_%u\"",plane,panel);
if(find(inactivepanels.begin(),inactivepanels.end(),panelid) == inactivepanels.end()){
unsigned layer = myrand.Integer(NLayers);
unsigned straw = myrand.Integer(NStraws);
char strawid[80];
snprintf(strawid,80,"\"%u_%u_%u_%u\"",plane,panel,layer,straw);
snprintf(strawid,80,"\"%u_%u_%u\"",plane,panel,straw);
if(find(deadstraws.begin(), deadstraws.end(), strawid) == deadstraws.end()){
++ndstraw;
os << strawid;
Expand Down
124 changes: 124 additions & 0 deletions TrkDiag/test/HitAmbigQual.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
#define HitAmbigQual_cxx
#include "HitAmbigQual.h"
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>

void HitAmbigQual::Loop()
{
// In a ROOT session, you can do:
// root> .L HitAmbigQual.C
// root> HitAmbigQual t
// root> t.GetEntry(12); // Fill t data members with entry number 12
// root> t.Show(); // Show values of entry 12
// root> t.Show(16); // Read and show values of entry 16
// root> t.Loop(); // Loop on all entries
//

// This is the loop skeleton where:
// jentry is the global entry number in the chain
// ientry is the entry number in the current Tree
// Note that the argument to GetEntry must be:
// jentry for TChain::GetEntry
// ientry for TTree::GetEntry and TBranch::GetEntry
//
// To read only selected branches, Insert statements like:
// METHOD1:
// fChain->SetBranchStatus("*",0); // disable all branches
// fChain->SetBranchStatus("branchname",1); // activate branchname
// METHOD2: replace line
// fChain->GetEntry(jentry); //read all branches
//by b_branchname->GetEntry(ientry); //read only this branch
if (fChain == 0) return;

Long64_t nentries = fChain->GetEntriesFast();

Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
if(dem__status > 0){
// loop over hits, find ones in the smame plane
//
Float_t spaspanel(0.0), spasplane(0.0), spasstation(0.0);
Float_t spasdpanel(0.0), spasdplane(0.0), spasdstation(0.0);
Float_t spapanel(0.0), spaplane(0.0), spastation(0.0);
Float_t spadpanel(0.0), spadplane(0.0), spadstation(0.0);

Float_t dm = dem__mom - demmcent_mom;

for(Int_t ihit = 0;ihit < demtsh_; ++ihit){
if(demtsh__active[ihit] && demtsh__ambig[ihit]!= 0 ){
for(Int_t jhit = ihit+1;jhit < demtsh_; ++jhit){
if(demtsh__active[jhit] && demtsh__ambig[jhit]!= 0 &&
demtsh__plane[jhit]/2 == demtsh__plane[ihit]/2){
float df = demtsh__trklen[jhit]-demtsh__trklen[ihit];
int da = demtsh__ambig[jhit]*demtsh__ambig[ihit];
float pd = demtsh__rdrift[jhit]*demtsh__rdrift[ihit]*da;
_pastation->Fill(pd);
_pdstation->Fill(df);
spastation += abs(pd);
spadstation += abs(pd)/df;
if(da < 0){
spasstation += pd;
spasdstation += pd/df;
}
if(demtsh__plane[jhit] == demtsh__plane[ihit] ){
_paplane->Fill(pd);
_pdplane->Fill(df);
spaplane += abs(pd);
spadplane += abs(pd)/df;
if(da < 0){
spasplane += pd;
spasdplane += pd/df;
}
if(demtsh__panel[jhit] == demtsh__panel[ihit] ){
_papanel->Fill(pd);
_pdpanel->Fill(df);
spapanel += abs(pd);
spadpanel += abs(pd)/df;
if(da < 0){
spaspanel += pd;
spasdpanel += pd/df;
}
}
}
}
}
}
}
_spaplane->Fill(spaplane);
_spapanel->Fill(spapanel);
_spastation->Fill(spastation);
_spadplane->Fill(spadplane);
_spadpanel->Fill(spadpanel);
_spadstation->Fill(spadstation);
_spasplane->Fill(-spasplane);
_spaspanel->Fill(-spaspanel);
_spasstation->Fill(-spasstation);
_spasdplane->Fill(-spasdplane);
_spasdpanel->Fill(-spasdpanel);
_spasdstation->Fill(-spasdstation);

_spasfplane->Fill(-spasplane/spaplane);
_spasfpanel->Fill(-spaspanel/spapanel);
_spasfstation->Fill(-spasstation/spastation);
_spasdfplane->Fill(-spasdplane/spadplane);
_spasdfpanel->Fill(-spasdpanel/spadpanel);
_spasdfstation->Fill(-spasdstation/spadstation);

_dmplane->Fill(-spasdplane/spadplane,dm);
_dmpanel->Fill(-spasdpanel/spadpanel,dm);
_dmstation->Fill(-spasdstation/spadstation,dm);

if(dem__trkqual > 0.4){
_dmtplane->Fill(-spasdplane/spadplane,dm);
_dmtpanel->Fill(-spasdpanel/spadpanel,dm);
_dmtstation->Fill(-spasdstation/spadstation,dm);
}


}
}
}
Loading

0 comments on commit 92a75dc

Please sign in to comment.