Calculates the information needed to compute an event weight, as well as a weight correcting Geant4 to Data. Returns a PionInteractionSystematic object containing all the needed information The detector can be provided externally (not only through the selection since for the moment the info is filled prior to any cuts sequence applied) to give more flexibility
770 TGeoManager* pionSIGeom = ND::hgman().GeoManager();
775 pionSIGeom = ND::hgman().GeoManager();
780 if((UInt_t) nTraj>NMAXTRUEPARTICLES) nTraj = NMAXTRUEPARTICLES;
789 std::vector<AnaTrueParticleB*> trajOfInterest;
790 for (Int_t it = 0; it < nTraj; it++){
797 trajOfInterest.push_back(track);
802 for (Int_t jt = 0; jt < nTraj; jt++){
806 trajOfInterest.push_back(track);
820 std::vector<AnaTrueParticleB*> pionTrajs;
821 std::vector<Interaction*> interactions;
823 for(UInt_t oai = 0; oai < trajOfInterest.size(); oai++){
825 if (trajOfInterest[oai]->PDG == 211 || trajOfInterest[oai]->PDG == -211){
826 if(InVOI(det, trajOfInterest[oai]->Position) )
827 pionTrajs.push_back(trajOfInterest[oai]);
831 if(trajOfInterest[oai]->ParentPDG == 211 || trajOfInterest[oai]->ParentPDG == -211){
833 AnaTrueParticleB* parent = GetParent(trajOfInterest[oai],allTrajInTPCFGD,nTraj);
834 Bool_t matchFound =
false;
835 for (UInt_t jsi = 0; jsi < interactions.size(); jsi++){
836 if (interactions[jsi]->IncludesTrajectory(trajOfInterest[oai])){
837 interactions[jsi]->AddTrajectory(trajOfInterest[oai],parent);
847 interactions.push_back(newInteraction);
858 std::vector< std::pair<AnaTrueParticleB*,Int_t> > pionTrajAndInteraction;
861 Int_t nInteractions = 0;
862 for (UInt_t p = 0; p < pionTrajs.size(); p++){
868 #if (JMDEBUGVERSION == 0) || (JMDEBUGVERSION == 2) || (JMDEBUGVERSION == 3) 869 if(InVOI(sel.GetDetectorFV(branch), pionTraj->
PositionEnd)){
874 #elif JMDEBUGVERSION == 1 879 std::vector<Interaction*> thisPionInteractions;
883 for (UInt_t i = 0; i < interactions.size(); i++){
887 if (interactions[i]->parentID == pionTraj->
ID 888 && interactions[i]->position[3] >= pionTraj->
PositionEnd[3]){
889 thisPionInteractions.push_back(interactions[i]);
912 for (UInt_t i = 0; i < thisPionInteractions.size(); i++){
914 TLorentzVector thisPos(thisPionInteractions[i]->position[0],thisPionInteractions[i]->position[1],thisPionInteractions[i]->position[2],thisPionInteractions[i]->position[3]);
917 if(posEnd == thisPos){
919 NPiPlus += thisPionInteractions[i]->NumberOfParticleType(211);
920 NPiZero += thisPionInteractions[i]->NumberOfParticleType(111)
921 + thisPionInteractions[i]->NPiZeroFromDecayProducts();
922 NPiMinus += thisPionInteractions[i]->NumberOfParticleType(-211);
923 NMuPlus += thisPionInteractions[i]->NumberOfParticleType(-13);
924 NMuMinus += thisPionInteractions[i]->NumberOfParticleType(13);
925 NExotic += thisPionInteractions[i]->CountExoticParticles();
935 NPiPlus += thisPionInteractions[i]->NumberOfParticleType(-13);
938 NPiMinus += thisPionInteractions[i]->NumberOfParticleType(13);
945 if(thisPionInteractions[i]->position[3] - pionTraj->
PositionEnd[3] < 10E-4){
949 NPiZero += thisPionInteractions[i]->NPiZeroFromDecayProducts();
953 TSPiZero += thisPionInteractions[i]->NumberOfParticleType(111);
961 TSPiZero += thisPionInteractions[i]->NumberOfParticleType(111)
962 + thisPionInteractions[i]->NPiZeroFromDecayProducts();
970 if (thisPionInteractions[i]->NumberOfParticleType(211)
972 + thisPionInteractions[i]->NumberOfParticleType(-211)
973 + thisPionInteractions[i]->CountExoticParticles() > 0){
975 if(pionTraj->
PDG == 211){
992 std::vector<Interaction*> interactions;
993 for (std::vector<Interaction*>::iterator it = interactions.begin(); it != interactions.end(); it++){
998 interactions.clear();
1004 Int_t interactionType;
1007 if((pionTraj->
PDG == 211 && NMuPlus == 1)
1008 || (pionTraj->
PDG == -211 && NMuMinus == 1)){
1010 interactionType = 3;
1015 else if(NExotic > 0){
1016 interactionType = 7;
1021 else if (NPiPlus + NPiZero + NPiMinus > 1){
1022 interactionType = 5;
1029 else if (NPiZero == 1){
1030 interactionType = 1;
1035 else if ((pionTraj->
PDG == 211 && NPiMinus == 1)
1036 || (pionTraj->
PDG == -211 && NPiPlus == 1)){
1037 interactionType = 2;
1042 else if ((pionTraj->
PDG == 211 && NPiPlus == 1)
1043 || (pionTraj->
PDG == -211 && NPiMinus == 1)){
1044 interactionType = 4;
1049 else if (NPiPlus + NPiZero + NPiMinus
1050 + NMuMinus + NMuPlus == 0){
1051 interactionType = 0;
1057 interactionType = 7;
1063 pionTrajAndInteraction.push_back(std::make_pair(pionTraj,interactionType));
1068 pionTrajAndInteraction.push_back(std::make_pair(pionTraj,8));
1074 Int_t thisIntType = pionTrajAndInteraction.back().second;
1078 if(thisIntType == 0 || thisIntType == 1 || thisIntType == 4){
1093 std::vector<Float_t> allPionSteps;
1095 Float_t AllPionsMCSumNSigmaStepLength = 0.0;
1096 Float_t AllPionsDataSumNSigmaStepLength = 0.0;
1099 Int_t nPions = (Int_t)pionTrajAndInteraction.size();
1100 Bool_t* pionType =
new Bool_t[(UInt_t)nPions];
1101 Int_t* nSteps =
new Int_t[(UInt_t)nPions];
1102 Float_t* initMom =
new Float_t[(UInt_t)nPions];
1103 Float_t* pInteraction =
new Float_t[(UInt_t)nInteractions];
1104 Int_t* typeInteraction =
new Int_t[(UInt_t)nInteractions];
1105 Int_t interactionsSoFar = 0;
1108 std::vector<Float_t> testFinalMom;
1109 std::vector<TLorentzVector> testFinalPos;
1110 std::vector<Int_t> testInteractionType;
1111 Int_t* pionID =
new Int_t[nPions];
1115 for(UInt_t ip = 0; ip < pionTrajAndInteraction.size(); ip++){
1118 Int_t intCode = pionTrajAndInteraction[ip].second;
1121 if(pionTraj->
PDG == 211){
1123 pionType[ip] =
true;
1128 pionType[ip] =
false;
1138 pionID[ip] = pionTraj->
ID;
1140 TrueParticles[ip] = pionTraj;
1154 nSteps[ip] = sr.stepLengths.size();
1156 testFinalMom.push_back(sr.finalMom);
1158 testFinalPos.push_back(sr.finalPos);
1160 testInteractionType.push_back(intCode);
1164 if(intCode == 0 || intCode == 1 || intCode == 4){
1166 pInteraction[interactionsSoFar] = sr.finalMom;
1171 TGeoNode *node = pionSIGeom->FindNode(pionTraj->
PositionEnd[0],
1175 TGeoVolume *volume = node->GetVolume();
1176 TGeoMaterial *material = volume->GetMaterial();
1177 std::string materialName = material->GetName();
1179 Int_t materialSeries = GetMaterialSeries(materialName);
1186 Int_t pionTypeSeries = 0;
1188 pionTypeSeries = 100;
1192 typeInteraction[interactionsSoFar] = intCode + materialSeries + pionTypeSeries;
1194 InteractionTrueParticles[interactionsSoFar] = pionTraj;
1198 interactionsSoFar++;
1204 for(UInt_t sIdx = 0; sIdx < sr.stepLengths.size() ; sIdx++){
1206 allPionSteps.push_back(sr.stepLengths[sIdx]);
1212 AllPionsMCSumNSigmaStepLength += sr.MCSumNSigmaStepLength;
1213 AllPionsDataSumNSigmaStepLength += sr.DataSumNSigmaStepLength;
1220 Int_t totalSteps = (Int_t)allPionSteps.size();
1223 Float_t* stepLengths =
new Float_t[totalSteps];
1225 for(UInt_t i = 0; i < allPionSteps.size(); i++){
1227 stepLengths[i] = allPionSteps[i];
1233 Float_t weightMCToData = TMath::Exp(-(AllPionsDataSumNSigmaStepLength - AllPionsMCSumNSigmaStepLength));
1236 for(Int_t ni = 0; ni < nInteractions; ni++){
1238 Int_t siType = typeInteraction[ni];
1239 Float_t siMom = pInteraction[ni];
1241 int momBin = int(siMom/10);
1242 if (momBin>800) momBin = 800;
1244 Double_t dataXSec = Interpolate(PiXSec::xsec_data[siType][momBin], PiXSec::xsec_data[siType][momBin+1],momBin,siMom);
1245 Double_t mcXSec = Interpolate(PiXSec::xsec_MC[siType][momBin], PiXSec::xsec_MC[siType][momBin+1],momBin,siMom);
1251 weightMCToData *= dataXSec/mcXSec;
1262 result->nPions = nPions;
1263 result->pionType = pionType;
1264 result->totalSteps = totalSteps;
1265 result->nSteps = nSteps;
1266 result->initMom = initMom;
1267 result->stepLengths = stepLengths;
1268 result->nInteractions = nInteractions;
1269 result->pInteraction = pInteraction;
1270 result->typeInteraction = typeInteraction;
1271 result->testFinalMom = testFinalMom;
1272 result->testFinalPos = testFinalPos;
1273 result->testInteractionType = testInteractionType;
1274 result->weightMCToData = weightMCToData;
1275 result->MCSumNSigmaStepLength = AllPionsMCSumNSigmaStepLength;
1276 result->DataSumNSigmaStepLength = AllPionsDataSumNSigmaStepLength;
1277 result->MCProbNoInt = TMath::Exp(-AllPionsMCSumNSigmaStepLength);
1278 result->DataProbNoInt = TMath::Exp(-AllPionsDataSumNSigmaStepLength);
1279 result->pionID = pionID;
1280 result->TrueParticles = TrueParticles;
1281 result->InteractionTrueParticles = InteractionTrueParticles;
int GetAllTrajInBunch(const AnaEventB &event, AnaTrueParticleB *traj[])
Float_t Momentum
The initial momentum of the true particle.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
Representation of a true Monte Carlo trajectory/particle.
Int_t PDG
The PDG code of this particle.
Int_t ParentID
The ID of this particle's immediate parent, or 0 if there is no parent.
Float_t PositionEnd[4]
The end position of the true particle.
Float_t Position[4]
The initial position of the true particle.
Float_t Direction[3]
The initial direction of the true particle.
bool LoadGeometry(const std::string &file="", Int_t geomID=-1, const std::string &geomDir="")
Load the TGeoManager from the input root file. Returns true when the new geometry was loaded...