9 vector<Int_t> outCodes,
25 vector<TString> digiNames = {
"BmnSiliconDigit",
"BmnGemStripDigit",
"BmnCSCDigit"};
26 vector<TString> digiNamesOther;
27 vector<TString> outMCNames = {
"BmnSiliconDigit",
"BmnGemStripDigit",
"BmnCSCDigit",
"StsPoint",
28 "SiliconPoint",
"CSCPoint",
"GeoTracks"};
29 vector<TString> outExpNames = {
"SILICON",
"GEM",
"CSC"};
33 vector<TF1*> funcsRescale;
34 vector<TString> digiOutExpNames = (isExp ==
kTRUE) ? outExpNames : outMCNames;
36 vector<TClass*> digiClasses;
38 vector<TClass*> digiClassesOther;
39 vector<TString> matchNames = {
"BmnSiliconDigitMatch",
"BmnGemStripDigitMatch",
"BmnCSCDigitMatch"};
44 UInt_t fNArs = digiNames.size();
53 TFile* fSourceHits =
new TFile(inSourceName,
"READ");
54 if (fSourceHits->
IsOpen() ==
false) {
55 printf(
"\n!!!!\ncannot open file %s !\n", inSourceName.
Data());
58 printf(
"\nINPUT SOURCE FILE: ");
59 printf(
"%s\n", inSourceName.
Data());
62 for (UInt_t
i = 0;
i < fNArs;
i++) {
64 printf(
"digiNames[%d] %s \n",
i, digiNames[
i].Data());
67 if (
i < matchNames.size()) {
68 if (addMatch ==
kTRUE) {
86 TString tempBaseName = inBaseName +
"-temp.root";
92 TFile* fBaseHits =
new TFile(tempBaseName,
"READ");
93 if (fBaseHits->
IsOpen() ==
false) {
94 printf(
"\n!!!!\ncannot open file %s !\n", tempBaseName.
Data());
97 printf(
"\nINPUT BASE FILE: ");
98 printf(
"%s\n", tempBaseName.
Data());
108 for (UInt_t
i = 0;
i < fNArs;
i++) {
109 if (strcmp(b->GetName(), digiOutExpNames[
i].Data()) == 0) {
114 if (strcmp(b->GetName(),
EHDigiName.Data()) == 0)
119 fInTreeBase->SetBranchAddress(b->GetName(), &arDigi);
120 digiNamesOther.push_back(
TString(b->GetName()));
122 digiClassesOther.push_back(arDigi->
GetClass());
125 for (UInt_t
i = 0;
i < fNArs;
i++) {
127 fInTreeBase->SetBranchAddress(digiOutExpNames[
i].Data(), &arDigi);
129 digiClasses.push_back(arDigi->
GetClass());
130 if (addMatch ==
kTRUE)
131 if (
i < matchNames.size()) {
133 fInTreeBase->SetBranchAddress(matchNames[
i].Data(), &ar);
153 funcsMC.push_back(mc);
154 funcsEx.push_back(ex);
155 funcsRescale.push_back(funcRescale);
157 printf(
"%s : xmin %f xmax %f\n", outExpNames[
i].Data(), mc->
GetXmin(), mc->
GetXmax());
164 padDistributions->
Divide(1, 2);
169 mc->
SetTitle(
"MC Integral Distribution");
175 ex->
SetTitle(
"Exp Integral Distribution");
188 TFile* fDestHitsFile =
new TFile(destName,
"RECREATE");
189 if (fDestHitsFile->
IsOpen() ==
false) {
190 printf(
"\n!!!!\ncannot open file %s !\n", destName.
Data());
193 printf(
"\n DEST FILE: ");
194 printf(
"%s\n", destName.
Data());
203 for (UInt_t
i = 0;
i < fNArs;
i++) {
212 fDestTree->Branch(digiNamesOther[
i], &arDigi);
216 fDestTree->Branch(
"BmnEventHeader.", &destEH);
217 if (addMatch ==
kTRUE)
218 for (
size_t i = 0;
i < matchNames.size();
i++) {
232 for (UInt_t iEv = 0; iEv < fNEventSource; ++iEv) {
238 for (UInt_t iBr = 0; iBr < fNArs; iBr++) {
240 if (addMatch ==
kTRUE && iBr < matchNames.size())
251 for (UInt_t iBr = 0; iBr < fNArs; iBr++) {
265 if (turnOffBaseDigits ==
kFALSE)
276 for (
Int_t iDestDig = 0; iDestDig <
digiDestArs[iBr]->GetEntriesFast(); iDestDig++) {
283 if (isHitMakerEfficiencyMode)
296 if (iBr < matchNames.size()) {
307 if (turnOffBaseDigits ==
kFALSE)
326 destEH->SetEventTime(baseEH->GetEventTime());
330 destEH->SetRunId(baseEH->GetRunId());
345 fDestHitsFile->
Write();
347 fSourceHits->
Close();
351 fDestHitsFile->
Close();
356 delete funcsRescale[
i];
359 int32_t sr = system(
Form(
"rm -f %s", tempBaseName.
Data()));
360 printf(
"\nFinished! Search made over %d source events\n Temp removed: %s",
iSourceEvent,
361 (sr == 0) ?
"ok" :
"error");
368 printf(
"\nPreliminary clone selected exp events:");
369 TFile* BaseHits =
new TFile(BaseName,
"READ");
370 if (BaseHits->
IsOpen() ==
false) {
371 printf(
"\n!!!!\ncannot open file %s !\n", BaseName.
Data());
379 TFile* DestHitsFile =
new TFile(TempBaseName,
"RECREATE");
380 if (DestHitsFile->
IsOpen() ==
false) {
381 printf(
"\n!!!!\ncannot open file %s !\n", TempBaseName.
Data());
384 printf(
"\nOUT HITS FILE: ");
385 printf(
"%s\n", TempBaseName.
Data());
390 UInt_t iBaseEvent = 0;
393 for (UInt_t iEv = 0; iEv < NSrcEvents; iEv++) {
396 printf(
"Not enough source events!\n");
399 while (iBaseEvent < NBaseEvents) {
409 DestHitsFile->
Write();
410 DestHitsFile->
Close();
411 DestHitsFile =
nullptr;
413 printf(
"\nPreliminary cloning finished!\n");
void DrawBar(UInt_t iEv, UInt_t nEv)
char * Form(const char *fmt,...)
BmnStatus
Define status code.
vector< Int_t > fOutCodes
vector< TClonesArray * > digiSourceArs
vector< TClonesArray * > digiBaseArsOther
vector< TBranch * > matchDestBrs
vector< TBranch * > digiDestBrs
vector< TClonesArray * > digiDestArsOther
vector< TClonesArray * > matchBaseArs
BmnStatus CloneSelected(TString BaseName, TString TempBaseName)
BmnStatus GetNextValidSourceEvent()
vector< TClonesArray * > matchDestArs
vector< TClonesArray * > matchSourceArs
vector< TClonesArray * > digiDestArs
BmnStatus Embed(TString inSourceName="eve-lam-box.root", TString inBaseName="evetest-p.root", TString destName="merged-digi.root", Int_t code=3122, vector< Int_t > outCodes={2212, -211}, Bool_t turnOffBaseDigits=kFALSE)
vector< TClonesArray * > digiBaseArs
Class BmnStripDigit Base class for strip detector digits.
void SetStripSignal(Double_t signal)
Double_t GetStripSignal()
TClass * GetClass() const
T * Get(const char *namecycle)
std::enable_if_t<!std::is_base_of< TObject, T >::value, Int_t > WriteObject(const T *obj, const char *name, Option_t *option="", Int_t bufsize=0)
virtual Double_t GetXmax() const
void SetTitle(const char *title="") override
void Draw(Option_t *option="") override
virtual Double_t GetXmin() const
Int_t Write(const char *name=nullptr, Int_t opt=0, Int_t bufsize=0) const override
virtual Bool_t IsOpen() const
void Close(Option_t *option="") override
virtual TObject * Next()=0
TIterator * MakeIterator(Bool_t dir=kIterForward) const override
const char * Data() const
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
virtual Long64_t GetEntries() const
Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0) const override
virtual TTree * CloneTree(Long64_t nentries=-1, Option_t *option="")
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
virtual void SetLogx(Int_t value=1)=0
virtual TVirtualPad * cd(Int_t subpadnumber=0)=0
virtual void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0)=0
virtual void SetLogy(Int_t value=1)=0